:root {
  color-scheme: dark;
  --bg-0: #10130f;
  --bg-1: #1c2320;
  --bg-2: #2b2842;
  --panel: rgba(16, 19, 15, 0.76);
  --panel-strong: rgba(20, 24, 20, 0.94);
  --line: rgba(233, 244, 221, 0.16);
  --ink: #f6fbff;
  --muted: #b9c7b4;
  --accent: #54e3b4;
  --accent-2: #ffd166;
  --accent-3: #ff7a68;
  --good: #9df27f;
  --bad: #ff7a68;
  --shadow: 0 30px 70px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  overflow-x: hidden;
  background:
    linear-gradient(120deg, rgba(84, 227, 180, 0.1), transparent 34%),
    linear-gradient(240deg, rgba(255, 122, 104, 0.11), transparent 38%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.028) 0 1px, transparent 1px 54px),
    linear-gradient(160deg, var(--bg-0) 0%, var(--bg-1) 48%, var(--bg-2) 100%);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.ambient-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.42;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100% - 20px));
  margin: 0 auto;
  padding: 16px 0 22px;
}

.hero-card,
.board-panel,
.guess-panel,
.leaderboard-panel {
  position: relative;
  overflow: hidden;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-card::before,
.board-panel::before,
.guess-panel::before,
.leaderboard-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 35%);
  pointer-events: none;
}

.hero-card {
  padding: 18px 20px;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.hero-top > div {
  min-width: 0;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin-top: 10px;
  font-size: 2.65rem;
  line-height: 0.96;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.hero-copy {
  max-width: 34rem;
  margin-top: 8px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.hero-actions {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 10px;
}

.user-chip,
.sound-toggle,
.primary-action,
.ghost-action,
.option-button {
  border: 0;
}

.user-chip,
.sound-toggle {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 800;
}

.user-chip {
  display: inline-grid;
  align-items: center;
  max-width: min(40vw, 280px);
  overflow: hidden;
  border: 1px solid rgba(114, 224, 255, 0.26);
  background: rgba(114, 224, 255, 0.12);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sound-toggle {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

.sound-toggle.is-on {
  color: #0f1812;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.sound-toggle.is-waiting {
  color: #10130f;
  background: linear-gradient(135deg, var(--accent-2), rgba(255, 255, 255, 0.9));
}

.sound-toggle:active,
.primary-action:active,
.ghost-action:active,
.option-button:active {
  transform: scale(0.98);
}

.stats-strip {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.stat-card {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.stat-card strong {
  display: block;
  margin-top: 7px;
  font-size: 1.3rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.timer-card strong {
  font-size: 2.1rem;
  color: var(--accent);
  white-space: nowrap;
  overflow-wrap: normal;
}

.accent-card {
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.14), rgba(255, 122, 104, 0.08));
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.65fr);
  gap: 12px;
  margin-top: 12px;
}

.board-panel,
.guess-panel,
.leaderboard-panel {
  padding: 14px;
}

.side-panel {
  display: grid;
  min-width: 0;
  gap: 12px;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.panel-head.compact {
  margin-bottom: 14px;
}

.panel-head h2 {
  font-size: 1.02rem;
}

.panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

.primary-action,
.ghost-action {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 850;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

.primary-action {
  min-width: 180px;
  color: #10130f;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 18px 38px rgba(84, 227, 180, 0.22);
}

.ghost-action {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.number-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 4px;
  min-height: 0;
}

.number-cell {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid rgba(233, 244, 221, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.072), rgba(255, 255, 255, 0.032)),
    rgba(16, 19, 15, 0.44);
  font-size: 0.92rem;
  font-weight: 820;
  font-variant-numeric: tabular-nums;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.number-cell.is-wrong {
  animation: flash-wrong 220ms ease;
}

.start-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 8px;
  background: rgba(16, 19, 15, 0.74);
}

.start-panel.is-hidden {
  display: none;
}

.result-panel {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 14px;
  text-align: center;
}

.result-panel span {
  color: var(--good);
  font-size: 1rem;
  font-weight: 850;
}

.result-panel strong {
  font-size: 2.35rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.result-panel small {
  color: var(--muted);
  font-size: 0.9rem;
}

.guess-panel,
.leaderboard-panel {
  min-height: 0;
}

.picked-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
  margin-bottom: 10px;
}

.picked-empty {
  color: var(--muted);
  font-size: 0.86rem;
}

.picked-pill {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(157, 242, 127, 0.95), rgba(84, 227, 180, 0.88));
  color: #10130f;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.option-button {
  min-height: 44px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.option-button:hover {
  background: rgba(84, 227, 180, 0.14);
}

.option-button.is-correct {
  background: linear-gradient(135deg, rgba(157, 242, 127, 0.95), rgba(84, 227, 180, 0.86));
  color: #10130f;
}

.option-button.is-wrong {
  background: linear-gradient(135deg, rgba(255, 122, 104, 0.92), rgba(255, 209, 102, 0.5));
}

.option-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.leaderboard-row,
.leaderboard-empty {
  display: grid;
  align-items: center;
  min-height: 48px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.leaderboard-row {
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 0 12px;
}

.leaderboard-row.is-me {
  outline: 1px solid rgba(84, 227, 180, 0.36);
  background: rgba(84, 227, 180, 0.1);
}

.leaderboard-rank {
  color: var(--accent);
  font-weight: 900;
}

.leaderboard-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 780;
}

.leaderboard-time {
  font-weight: 860;
  font-variant-numeric: tabular-nums;
}

.leaderboard-empty {
  justify-content: center;
  padding: 0 12px;
  color: var(--muted);
  text-align: center;
}

@keyframes flash-wrong {
  0% { transform: scale(1); }
  40% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

@media (max-width: 1080px) {
  .play-layout {
    grid-template-columns: 1fr;
  }

  .number-board {
    min-height: 0;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(calc(100vw - 12px), 390px);
    max-width: 390px;
    margin-left: 6px;
    margin-right: auto;
    padding: 6px 0 12px;
  }

  .hero-card,
  .board-panel,
  .guess-panel,
  .leaderboard-panel {
    border-radius: 8px;
  }

  .hero-card,
  .board-panel,
  .guess-panel,
  .leaderboard-panel {
    padding: 8px;
  }

  .hero-top,
  .panel-head {
    flex-direction: row;
  }

  .hero-actions {
    justify-items: start;
  }

  .stats-strip {
    grid-template-columns: 1.85fr repeat(4, minmax(0, 1fr));
    gap: 5px;
    margin-top: 8px;
  }

  .stat-card {
    min-height: 48px;
    padding: 7px 6px;
  }

  .stat-card span {
    font-size: 0.68rem;
  }

  .stat-card strong {
    margin-top: 4px;
    font-size: 1rem;
  }

  .number-board {
    gap: 3px;
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }

  .number-cell {
    min-height: 24px;
    border-radius: 6px;
    font-size: 0.74rem;
  }

  .option-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
  }

  .option-button {
    min-height: 34px;
    font-size: 0.8rem;
  }

  h1 {
    font-size: 1.32rem;
    line-height: 1.08;
    word-break: break-word;
  }

  .timer-card strong {
    font-size: 1rem;
  }

  .hero-copy,
  .panel-head p,
  .picked-empty,
  .result-panel small {
    font-size: 0.72rem;
  }

  .hero-copy {
    display: none;
  }

  .play-layout {
    gap: 7px;
    margin-top: 7px;
  }

  .panel-head {
    margin-bottom: 6px;
  }

  .eyebrow {
    font-size: 0.58rem;
  }

  .hero-actions {
    gap: 6px;
  }

  .user-chip,
  .sound-toggle {
    min-height: 30px;
    padding: 0 8px;
    font-size: 0.68rem;
  }

  .primary-action,
  .ghost-action {
    min-height: 30px;
    padding: 0 10px;
    font-size: 0.82rem;
  }

  .picked-strip {
    min-height: 24px;
    margin-bottom: 6px;
  }

  .picked-pill {
    min-width: 34px;
    min-height: 28px;
    padding: 0 8px;
  }
}

@media (max-width: 430px) {
  .hero-copy {
    max-width: 100%;
  }

  .timer-card strong {
    font-size: 1rem;
  }
}
