:root {
  --blue: #0d6ff5;
  --text: #3d3d3d;
  --green: #00f044;
  --solid-blue: #0c6df2;
  --orange: #ffc236;
  --brown: #cda028;
  --red: #ff1515;
  --stage: #eeeeee;
  --font-title: clamp(28px, 2.3vw, 38px);
  --font-subtitle: clamp(22px, 1.8vw, 30px);
  --font-body: clamp(16px, 1.3vw, 22px);
  --font-button: clamp(20px, 1.6vw, 26px);
  --font-metric: clamp(44px, 4vw, 60px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: #fff;
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
  font-weight: 800;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.github-corner {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  width: 78px;
  height: 78px;
  color: #fff;
}

.github-corner svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.github-corner .corner-bg {
  fill: #2f2f2f;
}

.github-corner .octo-arm,
.github-corner .octo-body {
  fill: #fff;
  transform-origin: 130px 106px;
}

.github-corner:hover .octo-arm {
  animation: octocat-wave 560ms ease-in-out;
}

@keyframes octocat-wave {
  0%,
  100% {
    transform: rotate(0deg);
  }

  20%,
  60% {
    transform: rotate(-25deg);
  }

  40%,
  80% {
    transform: rotate(10deg);
  }
}

.screen {
  display: none;
  min-height: 100vh;
  overflow: hidden;
}

.screen.active {
  display: block;
}

.start-screen {
  position: relative;
  place-items: center;
}

.start-screen.active {
  display: grid;
}

.start-panel {
  display: grid;
  justify-items: center;
  gap: clamp(28px, 4vh, 46px);
  margin-top: 24px;
}

.start-panel h1 {
  margin: 0;
  font-size: clamp(34px, 4vw, 56px);
  line-height: 1;
}

.standard-picker {
  display: flex;
  gap: 30px;
  align-items: center;
  font-size: var(--font-subtitle);
}

.standard-picker label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.standard-picker input {
  width: 22px;
  height: 22px;
  accent-color: #2d2d2d;
}

.play-button {
  position: relative;
  width: clamp(68px, 6vw, 88px);
  height: clamp(68px, 6vw, 88px);
  border: 0;
  border-radius: 50%;
  background: #2f2f2f;
}

.play-button span {
  position: absolute;
  left: 42%;
  top: 32%;
  width: 0;
  height: 0;
  border-top: clamp(13px, 1.2vw, 17px) solid transparent;
  border-bottom: clamp(13px, 1.2vw, 17px) solid transparent;
  border-left: clamp(20px, 1.8vw, 26px) solid #fff;
}

.home-rank-button {
  min-width: 180px;
  min-height: 48px;
  padding: 0 30px;
  font-size: var(--font-button);
}

.settings-button {
  position: absolute;
  top: 28px;
  right: 110px;
  min-height: 42px;
  border: 3px solid var(--blue);
  border-radius: 24px;
  padding: 0 24px;
  color: var(--text);
  background: #fff;
  font-size: var(--font-body);
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.28);
}

.settings-modal.open {
  display: grid;
}

.settings-card {
  width: min(560px, 100%);
  border-radius: 8px;
  padding: 30px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

.settings-card h2 {
  margin: 0 0 22px;
  font-size: var(--font-title);
}

.token-field {
  display: grid;
  gap: 10px;
  font-size: var(--font-body);
}

.token-field input {
  width: 100%;
  height: 48px;
  border: 2px solid #d0d0d0;
  border-radius: 6px;
  padding: 0 14px;
  color: var(--text);
  font-size: var(--font-body);
  font-weight: 600;
}

.settings-status {
  min-height: 24px;
  margin-top: 12px;
  font-size: 15px;
  font-weight: 600;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.primary-button.compact,
.outline-button.compact {
  min-width: 96px;
  min-height: 42px;
  border-width: 2px;
  padding: 0 18px;
  font-size: 18px;
}

.arrange-screen {
  display: none;
  flex-direction: column;
  background: #fff;
}

.arrange-screen.active {
  display: flex;
}

.arrange-top {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(380px, 0.88fr);
  gap: clamp(28px, 4vw, 58px);
  align-items: center;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  min-height: 38vh;
  padding: clamp(28px, 4vh, 42px) clamp(28px, 4vw, 52px) clamp(22px, 3vh, 34px);
}

.arrange-actions,
.instructions {
  align-self: center;
}

.arrange-actions h2,
.instructions h2 {
  margin: 0 0 10px;
  font-size: var(--font-title);
  line-height: 1.05;
}

.timer {
  margin-bottom: 18px;
  font-size: var(--font-metric);
  line-height: 1;
}

.primary-button,
.outline-button {
  min-height: 52px;
  border-radius: 28px;
  padding: 0 28px;
  font-size: var(--font-button);
  line-height: 1;
}

.primary-button {
  min-width: min(280px, 100%);
  border: 3px solid var(--blue);
  color: #fff;
  background: var(--blue);
}

.outline-button {
  min-width: min(180px, 100%);
  border: 3px solid var(--blue);
  color: var(--text);
  background: #fff;
}

.instructions p {
  max-width: 560px;
  margin: 0;
  font-size: var(--font-body);
  line-height: 1.45;
}

.wire-stage {
  position: relative;
  flex: 1;
  height: auto;
  min-height: 0;
  margin-top: 0;
  padding: 0 min(13vw, 210px);
  display: grid;
  grid-template-columns: repeat(8, minmax(36px, 1fr));
  align-items: end;
  gap: min(4.8vw, 68px);
  background: var(--stage);
}

.wire {
  --wire-color: #000;
  width: 22px;
  height: 85%;
  max-height: none;
  justify-self: center;
  border: 0;
  border-radius: 18px 18px 0 0;
  background: var(--wire-color);
  touch-action: none;
  transition: transform 160ms ease, filter 160ms ease;
}

.wire.striped {
  background: repeating-linear-gradient(
    to bottom,
    var(--wire-color) 0 32px,
    transparent 32px 64px
  );
}

.wire.dragging {
  transform: translateY(-18px) scale(1.04);
  filter: drop-shadow(0 12px 12px rgba(0, 0, 0, 0.18));
  z-index: 5;
}

.result-screen {
  padding: clamp(34px, 5vh, 56px) clamp(24px, 4vw, 56px) 34px;
  flex-direction: column;
}

.result-screen.active {
  display: flex;
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.75fr) minmax(460px, 1.25fr);
  gap: clamp(32px, 5vw, 68px);
  align-items: start;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.result-wires {
  min-width: 0;
}

#resultWireList {
  display: grid;
  gap: clamp(24px, 4vh, 42px);
}

.result-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(200px, 270px) 48px;
  align-items: center;
  gap: 22px;
  min-height: 42px;
}

.result-wire {
  --wire-color: #000;
  height: 14px;
  border-radius: 0 12px 12px 0;
  background: var(--wire-color);
}

.result-wire.striped {
  background: repeating-linear-gradient(
    to right,
    var(--wire-color) 0 48px,
    transparent 48px 78px
  );
}

.wrong-mark {
  display: grid;
  place-items: center;
  grid-column: 2;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  background: var(--red);
  font-size: 34px;
  line-height: 1;
}

.result-standard {
  margin: 18px 0 0 20px;
  font-size: clamp(24px, 2.4vw, 34px);
}

.metrics {
  display: flex;
  align-items: baseline;
  gap: clamp(18px, 3vw, 34px);
  margin-bottom: clamp(32px, 6vh, 52px);
  white-space: nowrap;
}

.metrics div {
  font-size: var(--font-subtitle);
}

.metrics strong {
  font-size: var(--font-metric);
  line-height: 1;
}

.result-summary h2 {
  margin: 0;
  font-size: var(--font-body);
  line-height: 1.45;
}

.result-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(16px, 2.5vw, 28px);
  width: 100%;
  max-width: 1280px;
  margin: auto auto 0;
  padding-top: clamp(42px, 7vh, 74px);
}

.primary-button.wide {
  min-width: min(280px, 100%);
}

.leaderboard-screen {
  padding: clamp(36px, 5vh, 56px) clamp(24px, 4vw, 56px) 70px;
  text-align: center;
}

.leaderboard-screen h1 {
  margin: 0 0 54px;
  font-size: var(--font-title);
  line-height: 1;
}

.leaderboard-list {
  display: grid;
  gap: 18px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 1fr 1.35fr 1fr 1fr 1.35fr;
  align-items: center;
  width: 100%;
  max-width: 1280px;
  min-height: 64px;
  margin: 0 auto;
  border: 3px solid #000;
  border-radius: 20px;
  padding: 0 34px;
  font-size: var(--font-button);
  line-height: 1;
}

.empty-rank {
  margin-top: 120px;
  font-size: 44px;
}

.back-button {
  position: fixed;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
}

@media (max-width: 900px) {
  .github-corner {
    width: 64px;
    height: 64px;
  }

  .settings-button {
    top: 18px;
    right: 84px;
  }

  .start-panel {
    gap: 48px;
    padding: 24px;
  }

  .standard-picker {
    flex-direction: column;
    gap: 16px;
  }

  .arrange-screen {
    overflow: auto;
  }

  .arrange-top {
    grid-template-columns: 1fr;
    gap: 26px;
    min-height: 42vh;
    padding: 32px 24px;
  }

  .primary-button,
  .outline-button {
    min-width: 0;
    width: 100%;
    min-height: 70px;
    font-size: 32px;
  }

  .wire-stage {
    min-height: 360px;
    flex: 1;
    height: auto;
    gap: 18px;
    padding: 0 18px;
  }

  .wire {
    width: 26px;
    height: 85%;
    max-height: none;
  }

  .result-screen {
    overflow: auto;
    padding: 42px 20px;
  }

  .result-layout {
    grid-template-columns: 1fr;
    gap: 44px;
  }

  .result-row {
    grid-template-columns: 1fr 60px;
    gap: 20px;
    min-height: 52px;
  }

  .wrong-mark {
    width: 52px;
    height: 52px;
    font-size: 42px;
  }

  .metrics {
    display: grid;
    gap: 18px;
  }

  .result-actions {
    display: grid;
    gap: 18px;
    margin: auto 0 0;
    padding-top: 48px;
  }

  .leaderboard-screen {
    overflow: auto;
    padding: 48px 16px 140px;
  }

  .leaderboard-row {
    grid-template-columns: 0.8fr 1.3fr 1fr 1fr 1.1fr;
    gap: 8px;
    min-height: 74px;
    padding: 0 14px;
    border-radius: 18px;
    font-size: 19px;
  }
}
