/* MusicGrid design system
   One stylesheet for the daily grid, custom grids and the grid builder. */

@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo-latin.woff") format("woff");
  font-weight: 400 900;
  font-stretch: 100% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  --stage: #1e44b5;
  --stage-deep: #11298a;
  --stage-ink: #ffffff;
  --stage-soft: rgba(255, 255, 255, 0.78);
  --stage-faint: rgba(255, 255, 255, 0.16);

  --surface: #ffffff;
  --surface-2: #eef1fa;
  --ink: #10163a;
  --muted: #565f8a;
  --line: #d6dbee;

  --gold: #ffc93c;
  --gold-deep: #d49b00;
  --gold-ink: #2a2000;
  --miss: #ff6b5e;
  --miss-soft: #ffe3df;
  --miss-ink: #8f1d12;

  --radius: 14px;
  --gutter: clamp(16px, 4vw, 32px);
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --stage: #13308f;
    --stage-deep: #0a1c63;
    --surface: #121a47;
    --surface-2: #1b2560;
    --ink: #eef1ff;
    --muted: #a9b1da;
    --line: #2b3674;
    --miss-soft: #4a1f2a;
    --miss-ink: #ffb4ab;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--stage);
  color: var(--stage-ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 8px; }

.skip {
  position: absolute; left: 8px; top: -60px; z-index: 50;
  padding: 10px 14px; border-radius: 10px;
  background: var(--gold); color: var(--gold-ink); font-weight: 700; text-decoration: none;
}
.skip:focus { top: 8px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1080px; width: 100%; margin: 0 auto;
  padding: 14px var(--gutter);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; font-stretch: 112%; font-size: 19px; letter-spacing: -0.01em;
  text-decoration: none;
}
.brand img { width: 32px; height: 32px; filter: drop-shadow(0 3px 0 var(--stage-deep)); transition: transform 0.12s ease; }
.brand:hover img { transform: translateY(-2px) rotate(-4deg); }
.brand:active img { transform: translateY(1px); }
.topnav { display: flex; gap: 4px; }
.topnav a {
  padding: 8px 12px; border-radius: 10px;
  font-size: 15px; font-weight: 600; text-decoration: none; color: var(--stage-soft);
}
.topnav a:hover { color: var(--stage-ink); background: var(--stage-faint); }
.topnav a[aria-current="page"] { color: var(--stage-ink); background: var(--stage-faint); }

.foot {
  margin-top: auto;
  padding: 32px var(--gutter) 28px;
  text-align: center; font-size: 14px; color: var(--stage-soft);
}
.foot a { font-weight: 600; text-decoration-color: var(--gold); text-underline-offset: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px;
  border: 0; border-radius: 12px;
  background: var(--gold); color: var(--gold-ink);
  font-weight: 700; text-decoration: none;
  box-shadow: 0 4px 0 var(--gold-deep);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.btn:hover { transform: translateY(1px); box-shadow: 0 3px 0 var(--gold-deep); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--gold-deep); }
.btn[disabled] { opacity: 0.55; cursor: default; transform: none; box-shadow: 0 4px 0 var(--gold-deep); }
.btn-ink { background: var(--ink); color: var(--surface); box-shadow: 0 4px 0 #000; }
.btn-ink:hover { box-shadow: 0 3px 0 #000; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border: 1.5px solid var(--stage-faint); border-radius: 12px;
  background: transparent; color: var(--stage-ink); font-weight: 600; text-decoration: none;
}
.btn-ghost:hover { background: var(--stage-faint); }
.card .btn-ghost, .sheet .btn-ghost { border-color: var(--line); color: var(--ink); }
.card .btn-ghost:hover, .sheet .btn-ghost:hover { background: var(--surface-2); }
.icon { width: 20px; height: 20px; flex: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); color: var(--ink);
  border-radius: 20px;
  padding: clamp(20px, 4vw, 28px);
}
.card h2 { margin: 0 0 12px; font-size: 20px; font-weight: 750; font-stretch: 108%; letter-spacing: -0.01em; }
.card p { color: var(--muted); }

/* ---------- Game layout ---------- */
.game {
  width: 100%; max-width: 1080px; margin: 0 auto;
  padding: 8px var(--gutter) 0;
  display: grid; gap: 24px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "head" "hud" "board" "results" "flags" "side";
}
@media (min-width: 960px) {
  .game {
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-areas: "head head" "board hud" "board results" "board flags" "board side";
    grid-template-rows: auto auto auto auto 1fr;
    align-items: start;
    column-gap: 40px;
  }
  .game > .side, .game > .results, .game > .flagged-card { align-self: start; }
}
.game-head { grid-area: head; }
.title {
  margin: 0;
  font-size: clamp(32px, 6vw, 56px);
  font-weight: 850; font-stretch: 118%;
  line-height: 1; letter-spacing: -0.025em;
  text-wrap: balance;
}
.subtitle { margin: 12px 0 0; max-width: 54ch; color: var(--stage-soft); font-size: 16px; }

/* HUD */
.hud {
  grid-area: hud;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px 16px;
}
.hud .toggle { grid-column: 1 / -1; }
@media (min-width: 960px) {
  .hud { padding: 22px; border-radius: 20px; background: var(--stage-deep); gap: 18px 16px; }
}
.hud-score { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.hud-num {
  font-size: 52px; font-weight: 850; font-stretch: 118%; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -0.03em;
}
.hud-label { color: var(--stage-soft); font-weight: 600; }
.hud-lives { display: grid; justify-items: end; gap: 6px; }
.lives { display: flex; align-items: center; gap: 4px; }
.life { display: block; width: 26px; height: 26px; color: var(--miss); }
.life svg { width: 100%; height: 100%; display: block; }
.life.lost { color: rgba(255, 255, 255, 0.4); }
.sudden {
  padding: 4px 10px; border-radius: 999px;
  background: var(--miss); color: #fff;
  font-size: 13px; font-weight: 750;
}
.hud-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

/* Toggle */
.toggle { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-track {
  position: relative; width: 46px; height: 28px; flex: none;
  border-radius: 999px; background: var(--stage-faint);
  transition: background 0.2s ease;
}
.toggle-track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  transition: transform 0.2s ease;
}
.toggle input:checked + .toggle-track { background: var(--gold); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle input:focus-visible + .toggle-track { outline: 3px solid var(--gold); outline-offset: 2px; }
.toggle-note { display: block; font-size: 13px; font-weight: 500; color: var(--stage-soft); }

/* ---------- Board ---------- */
.slot { display: flex; align-items: center; min-width: 0; }
.slot > .cell { width: 100%; }
.board-wrap { grid-area: board; }
.board {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 1.2vw, 10px);
  max-width: 680px;
}
.head {
  display: flex; padding: 4px;
  font-size: clamp(12px, 1.6vw, 15px); line-height: 1.2;
  overflow-wrap: anywhere;
  transition: color 0.15s ease;
}
.head-artist {
  align-items: flex-end; justify-content: center; text-align: center;
  min-height: 52px; padding-bottom: 8px;
  font-weight: 750; font-stretch: 106%; font-size: clamp(13px, 1.9vw, 17px);
  border-bottom: 3px solid transparent;
}
.head-cat {
  align-items: center; padding-right: 4px;
  font-size: clamp(11.5px, 1.5vw, 14px); hyphens: auto; -webkit-hyphens: auto;
  color: var(--stage-soft); font-weight: 600;
  border-left: 3px solid transparent; padding-left: 8px;
}
.head.lit { color: var(--stage-ink); }
.head-artist.lit { border-bottom-color: var(--gold); }
.head-cat.lit { border-left-color: var(--gold); }

.cell {
  position: relative;
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px; border: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  box-shadow: 0 5px 0 var(--stage-deep);
  text-align: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
button.cell:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--stage-deep); }
button.cell:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--stage-deep); }
.cell-plus { width: 26px; height: 26px; color: var(--line); transition: color 0.15s ease; }
button.cell:hover .cell-plus { color: var(--stage); }
.cell-misses { position: absolute; top: 7px; left: 8px; display: flex; gap: 3px; }
.cell-misses i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--miss);
}
.cell[data-state="pending"] { cursor: progress; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--stage);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.cell[data-state="solved"] {
  background: var(--gold); color: var(--gold-ink);
  box-shadow: 0 5px 0 var(--gold-deep);
  cursor: default;
}
.cell-song {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  font-weight: 750; font-size: clamp(12px, 1.7vw, 15px); line-height: 1.2;
  overflow-wrap: anywhere;
}
.cell-points {
  margin-top: 6px; padding: 2px 8px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.1);
  font-size: 12px; font-weight: 750; font-variant-numeric: tabular-nums;
}
.cell[data-state="missed"] {
  background: transparent; color: var(--stage-soft);
  box-shadow: none; outline: 2px dashed var(--stage-faint); outline-offset: -2px;
  cursor: default;
}
.cell-missed { font-size: 13px; font-weight: 600; }
.cell-listen {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 9px; border: 0; border-radius: 999px;
  background: var(--stage-faint); color: var(--stage-ink);
  font-size: 12px; font-weight: 700;
}
.cell-listen:hover { background: rgba(255, 255, 255, 0.28); }
.cell-listen .icon { width: 14px; height: 14px; }
@media (max-width: 599px) {
  .cell-listen { width: 36px; height: 36px; padding: 0; justify-content: center; }
  .cell-listen span { display: none; }
  .cell-listen .icon { width: 16px; height: 16px; }
}

.board-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

@media (prefers-reduced-motion: no-preference) {
  .cell.flip { animation: flip 0.5s cubic-bezier(0.3, 1.3, 0.5, 1); }
  .cell.shake { animation: shake 0.42s ease; }
  .life.pop { animation: pop 0.35s ease; }
  .hud-num.bump { animation: bump 0.4s ease; }
}
@keyframes flip {
  0% { transform: rotateY(90deg) scale(0.9); }
  100% { transform: none; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
@keyframes pop { 50% { transform: scale(1.35); } }
@keyframes bump { 40% { transform: scale(1.12); } }
.cell.flash-miss { background: var(--miss-soft); }

/* Loading + error */
.board-state {
  max-width: 680px; padding: 28px; border-radius: 20px;
  background: var(--stage-deep); color: var(--stage-soft);
}
.board-state strong { display: block; margin-bottom: 4px; color: var(--stage-ink); font-size: 18px; }
.board-state .btn { margin-top: 16px; }
.skeleton .cell, .skeleton .head { background: var(--stage-faint); box-shadow: none; color: transparent; }
.skeleton .head { border-radius: 10px; min-height: 0; margin: 10px 4px; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: breathe 1.6s ease-in-out infinite; }
}
@keyframes breathe { 50% { opacity: 0.55; } }
.loading-note { margin: 14px 0 0; color: var(--stage-soft); font-size: 15px; }

/* ---------- Side column: results + leaderboard ---------- */
.results { grid-area: results; }
.side { grid-area: side; display: grid; gap: 24px; }
.final-score {
  display: flex; align-items: baseline; gap: 10px; margin: 4px 0 6px;
}
.final-score b {
  font-size: 64px; font-weight: 850; font-stretch: 118%; line-height: 1; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.results .summary { margin: 0 0 18px; }
.mini {
  display: grid; grid-template-columns: repeat(3, 22px); gap: 4px; margin: 0 0 18px;
}
.mini i { width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); }
.mini i.on { background: var(--gold); }
.results-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.submit-form { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.submit-form label { display: block; margin-bottom: 8px; font-weight: 650; }
.field-row { display: flex; gap: 8px; }
.field {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 14px;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font-size: 16px;
}
.field:focus { outline: none; border-color: var(--stage); box-shadow: 0 0 0 3px rgba(30, 68, 181, 0.25); }
.form-note { margin: 8px 0 0; font-size: 14px; }

.board-list { list-style: none; margin: 0; padding: 0; }
.board-list li {
  display: grid; grid-template-columns: 2.2em 1fr auto; align-items: center; gap: 8px;
  padding: 9px 0; border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.board-list li:first-child { border-top: 0; }
.board-list .rank { color: var(--muted); font-weight: 600; }
.board-list .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.board-list .pts { font-weight: 750; }
.board-list li.me { margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 10px; background: var(--gold); color: var(--gold-ink); border-color: transparent; }
.board-list li.me .rank { color: inherit; }
.board-list li.me + li { border-top-color: transparent; }
.empty-note { margin: 0; color: var(--muted); }
/* Room on both sides for the highlighted row, and no sideways scrolling */
.lb-scroll {
  max-height: 420px; margin: 0 -10px; padding: 0 10px;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.lb-scroll::-webkit-scrollbar { width: 8px; height: 0; }
.lb-scroll::-webkit-scrollbar-thumb { border-radius: 999px; background: var(--line); }
.lb-scroll::-webkit-scrollbar-track { background: transparent; }

/* ---------- Guess sheet ---------- */
.sheet {
  width: min(560px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  margin: 10px auto auto;
  padding: 0; border: 0; border-radius: 20px;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 60px rgba(4, 10, 50, 0.45);
  overflow: hidden;
}
@media (min-width: 700px) { .sheet { margin-top: 12vh; } }
.sheet::backdrop { background: rgba(6, 14, 60, 0.6); }
@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: sheet-in 0.22s ease-out; }
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(-12px); } }
.sheet-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 20px); }
@media (min-width: 700px) { .sheet-inner { max-height: 76vh; } }
.sheet-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 18px 12px;
}
.sheet-title { flex: 1; min-width: 0; }
.sheet-title b { display: block; font-size: 20px; font-weight: 800; font-stretch: 110%; line-height: 1.15; }
.sheet-title span { display: block; margin-top: 2px; color: var(--muted); font-size: 15px; }
.close {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--ink);
}
.search { position: relative; margin: 0 18px; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; min-height: 52px; padding: 0 14px 0 44px;
  border: 2px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); font-size: 17px;
}
.search input:focus { outline: none; border-color: var(--stage); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 10px 14px; overscroll-behavior: contain; }
.sheet-msg { margin: 6px 8px 10px; color: var(--muted); font-size: 15px; }
.tried { margin: 0 8px 10px; font-size: 14px; color: var(--muted); }
.tried s { color: var(--miss-ink); text-decoration-thickness: 2px; }
.results-list { list-style: none; margin: 0; padding: 0; }
.result {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 12px;
  background: transparent; color: var(--ink); text-align: left;
}
.result:hover, .result:focus-visible { background: var(--surface-2); }
.result:focus-visible { outline-offset: -3px; }
.result[disabled] { opacity: 0.45; cursor: default; background: transparent; }
.art {
  width: 44px; height: 44px; flex: none; border-radius: 8px;
  background: var(--surface-2); object-fit: cover;
}
.art-blank { display: grid; place-items: center; color: var(--muted); }
.result-text { min-width: 0; }
.result-text b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.result-text span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 14px; }
.result-tag { margin-left: auto; flex: none; font-size: 12px; font-weight: 700; color: var(--miss-ink); }
.hint-row {
  display: flex; align-items: center; gap: 12px;
  margin: 0 18px; padding: 12px 0 2px;
}
.hint-row p { margin: 0; color: var(--muted); font-size: 14px; }
.hint-row .btn-ghost { flex: none; white-space: nowrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 12px 18px; border-radius: 12px;
  background: var(--ink); color: var(--surface);
  font-weight: 650; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Builder ---------- */
.builder {
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 8px var(--gutter) 0;
}
.builder .title { margin-bottom: 12px; }
.steps { display: flex; gap: 8px; margin: 0 0 22px; padding: 0; list-style: none; font-size: 14px; font-weight: 650; color: var(--stage-soft); }
.steps li { display: flex; align-items: center; gap: 8px; }
.steps li + li::before { content: ""; width: 18px; height: 2px; background: var(--stage-faint); }
.steps .num {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--stage-faint); color: var(--stage-ink); font-size: 13px;
}
.steps .now { color: var(--stage-ink); }
.steps .now .num { background: var(--gold); color: var(--gold-ink); }
.steps .done .num { background: var(--stage-ink); color: var(--stage); }
.builder .card + .card { margin-top: 18px; }
.lede { margin: 0 0 20px; font-size: 17px; }
.fine { margin: 16px 0 0; font-size: 14px; color: var(--muted); }

.choices { display: grid; gap: 14px; }
@media (min-width: 640px) { .choices { grid-template-columns: 1fr 1fr; } }
.choice {
  display: flex; flex-direction: column; gap: 8px;
  padding: 22px; border-radius: 20px; text-decoration: none;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 5px 0 var(--stage-deep);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
a.choice:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--stage-deep); }
.choice b { font-size: 20px; font-weight: 800; font-stretch: 108%; line-height: 1.2; }
.choice span { color: var(--muted); }
.choice .tag { align-self: flex-start; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 700; }
.choice.off { background: transparent; color: var(--stage-ink); box-shadow: none; outline: 2px dashed var(--stage-faint); outline-offset: -2px; }
.choice.off span { color: var(--stage-soft); }
.choice.off .tag { background: var(--stage-faint); color: var(--stage-ink); }

.account { display: flex; align-items: center; gap: 14px; margin: 0 0 20px; }
.account img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.account b { display: block; font-size: 18px; }
.account span { color: var(--muted); font-size: 15px; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.text-btn { padding: 8px 4px; border: 0; background: none; color: var(--muted); font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }

.segmented { display: grid; gap: 10px; }
@media (min-width: 560px) { .segmented { grid-template-columns: repeat(3, 1fr); } }
.seg {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 16px; border: 2px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--ink); text-align: left;
}
.seg:hover { border-color: var(--stage); }
.seg b { font-size: 17px; }
.seg span { color: var(--muted); font-size: 14px; }

.sortable-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sortable-list .item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 10px; border-radius: 14px;
  background: var(--surface-2); color: var(--ink);
  touch-action: pan-y; user-select: none;
}
.sortable-list .item.dragging { opacity: 0.4; }
.item .rank { width: 1.6em; text-align: right; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.item .details { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.item .details img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--line); }
.item .details span { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; font-weight: 650; overflow-wrap: anywhere; }
.item .details img { flex: none; }
.sortable-list .item { min-width: 0; }
.item .moves { display: flex; gap: 4px; }
.move {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 10px; background: var(--surface); color: var(--ink);
}
.move[disabled] { opacity: 0.3; cursor: default; }
.handle { color: var(--muted); cursor: grab; display: grid; place-items: center; width: 24px; }
.sticky-go {
  position: sticky; bottom: 0; z-index: 5;
  margin: 18px calc(-1 * clamp(20px, 4vw, 28px)) calc(-1 * clamp(20px, 4vw, 28px));
  padding: 14px clamp(20px, 4vw, 28px);
  background: var(--surface); border-top: 1px solid var(--line);
  border-radius: 0 0 20px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.sticky-go p { margin: 0; font-size: 14px; }
.sticky-go .btn { flex: none; white-space: nowrap; }

/* Builder progress (structure comes from gb-artistSelect.js) */
.progressContainer { display: grid; gap: 6px; }
.progressContainer:empty { display: none; }
.progressContainer .row {
  display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, 34px); align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 12px; background: var(--surface-2);
}
.progressContainer .row:first-child { background: transparent; padding-top: 0; padding-bottom: 0; }
.progressContainer .cell {
  aspect-ratio: auto; display: block; padding: 0; background: none; box-shadow: none; border-radius: 0; text-align: left;
}
.progressContainer [data-progress-type="cheats-available"],
.progressContainer [data-progress-type="group-compare"],
.progressContainer .cheats-available-header,
.progressContainer .group-compare-header,
.progressContainer .progress-header:nth-child(n+5) { display: none; }
.progressContainer .progress-header { font-size: 0; }
.progressContainer .progress-header.artist-header::after { content: "Artist"; font-size: 13px; color: var(--muted); font-weight: 650; }
.progressContainer .progress-header.category-header:nth-child(2)::after { content: "Years"; }
.progressContainer .progress-header.category-header:nth-child(3)::after { content: "Length"; }
.progressContainer .progress-header.category-header:nth-child(4)::after { content: "Titles"; }
.progressContainer .progress-header.category-header::after { font-size: 12px; color: var(--muted); font-weight: 650; display: block; text-align: center; }
.progressContainer .artist-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.progressContainer .progress-cell { justify-self: center; width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.progressContainer .progress-cell.in-progress { background: var(--stage); }
.progressContainer .progress-cell.finished { background: var(--gold); box-shadow: 0 0 0 3px rgba(255, 201, 60, 0.35); }
@media (prefers-reduced-motion: no-preference) {
  .progressContainer .progress-cell.in-progress { animation: breathe 1s ease-in-out infinite; }
}
.progress-copy { margin: 0 0 16px; }

/* Encoding preview grid in the builder (cells come from gb-artistSelect.js) */
.build-grid {
  display: grid; grid-template-columns: minmax(0, 0.9fr) repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 18px;
}
.build-grid .row { display: contents; }
.build-grid .cell {
  aspect-ratio: auto; display: flex; padding: 4px; border-radius: 0;
  background: none; box-shadow: none; color: var(--ink); text-align: left;
}
.build-grid .artist { align-items: flex-end; justify-content: center; text-align: center; font-size: 13px; font-weight: 750; overflow-wrap: anywhere; }
.build-grid .genre-header { align-items: center; font-size: 12px; font-weight: 600; color: var(--muted); overflow-wrap: anywhere; }
.build-grid .song-cell { aspect-ratio: 1; border-radius: 10px; background: var(--surface-2); transition: background 0.3s ease; }
.build-grid .song-cell.in-progress { background: var(--stage); }
.build-grid .song-cell.finished { background: var(--gold); }
@media (prefers-reduced-motion: no-preference) {
  .build-grid .song-cell.in-progress { animation: breathe 1s ease-in-out infinite; }
}

.share-link { display: flex; gap: 8px; margin: 18px 0 0; }
.share-link input { flex: 1; min-width: 0; }

.notice { margin: 0 0 18px; padding: 14px 16px; border-radius: 14px; background: var(--miss-soft); color: var(--miss-ink); font-weight: 600; }
.notice a { color: inherit; }

/* Error / 404 pages */
.notfound { max-width: 560px; margin: 0 auto; padding: 40px var(--gutter) 0; }
.notfound p { color: var(--stage-soft); font-size: 18px; }

@media (max-width: 479px) {
  .sortable-list .item { gap: 8px; padding-left: 6px; }
  .item .details { gap: 10px; }
  .item .details img { width: 36px; height: 36px; }
  .item .rank { width: 1.3em; }
  .item .handle { display: none; }
  .move { width: 34px; height: 34px; }
}

/* Pick any artists */
.card .search { margin: 0; }
.artist-results { margin: 8px -10px 0; }
.artist-results .art { border-radius: 50%; }
.result-add {
  margin-left: auto; flex: none; padding: 6px 12px; border-radius: 999px;
  background: var(--gold); color: var(--gold-ink); font-size: 13px; font-weight: 750;
}
.result[disabled] .result-add { background: var(--surface-2); color: var(--muted); }
.card .picked-head { display: flex; align-items: baseline; gap: 10px; margin: 24px 0 10px; font-size: 18px; }
.card .picked-head span { color: var(--muted); font-size: 14px; font-weight: 600; }
.card .sheet-msg { margin: 12px 0 0; }
.move.remove { color: var(--miss-ink); }

/* Two leaderboards */
.lb-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card .lb-head h2 { margin: 0; }
.lb-count { color: var(--muted); font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card .lb-sub { margin: -6px 0 12px; font-size: 14px; }
.board-list .who small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.recent-board { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.lb-subhead { margin: 0 0 10px; font-size: 15px; font-weight: 750; letter-spacing: -0.01em; }
.board-list .who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list li.me .who small { color: inherit; opacity: 0.75; }
.board-list li.gap { display: block; padding: 2px 0; border-top: 0; color: var(--muted); text-align: center; }
.board-list li.gap + li { border-top-color: transparent; }
.grid-date { margin: 0 0 10px; color: var(--stage-soft); font-weight: 650; }

/* Results mini grid matches the share squares */
.mini i.deep { background: #2fb36b; }
.mini i.low { background: #ff9f43; }
.mini i.ez, .mini.small i.ez { border-radius: 50%; }
.mini i.miss { background: var(--miss); }

/* ---------- Browse ---------- */
.browse { width: 100%; max-width: 1080px; margin: 0 auto; padding: 8px var(--gutter) 0; }
.browse-tabs {
  display: inline-flex; gap: 4px; margin: 24px 0 16px; padding: 4px;
  border-radius: 14px; background: var(--stage-deep);
}
.browse-tabs button {
  min-height: 42px; padding: 0 18px; border: 0; border-radius: 10px;
  background: transparent; color: var(--stage-soft); font-weight: 700;
}
.browse-tabs button[aria-selected="true"] { background: var(--stage-ink); color: var(--stage); }
.browse-note { margin: 0 0 18px; max-width: 60ch; color: var(--stage-soft); }
.browse-note a { color: var(--stage-ink); font-weight: 650; text-decoration-color: var(--gold); text-underline-offset: 4px; }
.empty-note.on-stage { color: var(--stage-soft); }
.grid-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-card {
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
  padding: 18px; border-radius: 18px; text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.grid-card:hover { transform: translateY(-2px); }
.gc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.gc-tag { padding: 3px 9px; border-radius: 999px; font-weight: 750; }
.gc-players { font-weight: 600; white-space: nowrap; }
.gc-title { font-size: 20px; font-weight: 800; font-stretch: 108%; line-height: 1.15; overflow-wrap: anywhere; }
.gc-artists { font-size: 14px; overflow-wrap: anywhere; }
.gc-status { margin-top: auto; padding-top: 6px; font-size: 13px; font-weight: 700; }

/* Daily grids: white tiles with a gold date, like the game board */
.grid-card.daily { background: var(--surface); color: var(--ink); box-shadow: 0 5px 0 var(--stage-deep); }
.grid-card.daily:hover { box-shadow: 0 7px 0 var(--stage-deep); }
.grid-card.daily .gc-tag { background: var(--gold); color: var(--gold-ink); }
.grid-card.daily .gc-players, .grid-card.daily .gc-artists, .grid-card.daily .gc-status { color: var(--muted); }
.grid-card.daily .gc-status.done { color: #1f8a52; }
.grid-card.daily .gc-status.started { color: var(--stage); }

/* Player-made grids: dark, outlined, clearly not official */
.grid-card.custom { background: var(--stage-deep); color: var(--stage-ink); border: 2px solid var(--stage-faint); }
.grid-card.custom:hover { border-color: rgba(255, 255, 255, 0.4); }
.grid-card.custom .gc-tag { background: var(--stage-faint); color: var(--stage-ink); }
.grid-card.custom .gc-players, .grid-card.custom .gc-artists, .grid-card.custom .gc-status { color: var(--stage-soft); }
.grid-card.custom .gc-status.done { color: #7ee2a8; }
.grid-card.custom .gc-status.started { color: var(--gold); }
.more { margin-top: 18px; }

/* Phones: logo only, so the four nav links fit beside it */
.brand, .topnav { flex: none; }
@media (max-width: 560px) {
  .brand span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .topnav a { padding: 8px 10px; }
}

/* Countdown to the next daily grid */
.next-grid {
  display: inline-flex; align-items: baseline; gap: 6px; margin: 14px 0 0;
  padding: 6px 12px; border-radius: 999px; background: var(--stage-deep);
  color: var(--stage-soft); font-size: 14px; font-weight: 600;
}
.next-grid b { color: var(--stage-ink); font-variant-numeric: tabular-nums; }
.next-grid a { color: var(--gold); font-weight: 750; }
.next-grid-panel {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 0 0 18px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2);
}
.next-grid-panel span { color: var(--muted); font-weight: 650; }
.next-grid-panel b { font-size: 26px; font-weight: 850; font-stretch: 112%; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ---------- Stats ---------- */
:root { --series: #1e44b5; }
@media (prefers-color-scheme: dark) { :root { --series: #5b8cff; } }
.stats { width: 100%; max-width: 1080px; margin: 0 auto; padding: 8px var(--gutter) 0; }
.stats .browse-tabs { margin-bottom: 0; }
.browse-tabs button[aria-pressed="true"] { background: var(--stage-ink); color: var(--stage); }
.stats-empty { margin-top: 24px; max-width: 560px; }
#statsBody { display: grid; gap: 20px; margin-top: 24px; }
.stat-tiles { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) {
  .stat-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
  .stat-tiles[data-count="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.stat {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: 16px; border-radius: 16px;
  background: var(--surface); color: var(--ink); box-shadow: 0 4px 0 var(--stage-deep);
}
.stat-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.stat-value { font-size: clamp(30px, 6vw, 40px); font-weight: 850; font-stretch: 115%; line-height: 1.1; letter-spacing: -0.02em; }
.stat-sub {
  font-size: 13px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.stat-sub a { color: inherit; font-weight: 750; text-decoration-color: currentColor; text-underline-offset: 3px; }
.stat.accent { background: var(--gold); color: var(--gold-ink); box-shadow: 0 4px 0 var(--gold-deep); }
.stat.accent .stat-label, .stat.accent .stat-sub { color: var(--gold-ink); }

.chart-card .lb-head { display: block; }
.chart-sub { margin: 4px 0 0; font-size: 14px; }
.chart { position: relative; margin-top: 14px; touch-action: pan-y; -webkit-tap-highlight-color: transparent; }
.chart:focus-visible { outline-offset: 6px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart-grid text, .chart-axis text { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-area { fill: var(--series); fill-opacity: 0.1; }
.chart-line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dots circle { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart-focus { fill: var(--series); stroke: var(--surface); stroke-width: 3; pointer-events: none; }
.chart-cross { stroke: var(--muted); stroke-width: 1; stroke-opacity: 0.6; pointer-events: none; }
.chart-labels text {
  fill: var(--ink); font-size: 12px; font-weight: 750; font-variant-numeric: tabular-nums;
  paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round;
}
.chart-hit { fill: transparent; cursor: crosshair; }
.chart-tip {
  position: absolute; z-index: 2; pointer-events: none;
  display: flex; flex-direction: column; gap: 1px; max-width: 230px;
  padding: 8px 11px; border-radius: 10px;
  background: var(--ink); color: var(--surface); font-size: 13px; line-height: 1.35;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}
.chart-tip b { font-size: 16px; font-weight: 850; font-variant-numeric: tabular-nums; }
.tip-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip-meta { font-size: 12px; opacity: 0.78; }
.chart-note { margin: 10px 0 0; font-size: 14px; }

.history { list-style: none; margin: 0; padding: 0; }
.history li + li { border-top: 1px solid var(--line); }
.hist-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  margin: 0 -10px; padding: 12px 10px; border-radius: 12px;
  color: inherit; text-decoration: none;
}
.hist-row:hover { background: var(--surface-2); }
.mini.small { gap: 2px; margin: 0; }
.mini.small i { width: 12px; height: 12px; border-radius: 3px; }
.hist-main { display: flex; flex-direction: column; min-width: 0; }
.hist-title { font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-meta { font-size: 13px; color: var(--muted); }
.hist-score { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hist-score b { font-size: 22px; font-weight: 850; font-stretch: 110%; }
.hist-score small { font-size: 12px; color: var(--muted); }
.hist-score .keep { color: var(--ink); font-size: 13px; font-weight: 750; text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }
.history-card .more { margin-top: 12px; }
.stats-foot { margin: 24px 0 0; font-size: 14px; }

/* Four nav links on the smallest phones */
@media (max-width: 360px) {
  .topnav { gap: 2px; }
  .topnav a { padding: 8px 8px; font-size: 14px; }
}

/* Difficulty on Browse cards: four bars, filled up to the level */
.gc-diff { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; white-space: nowrap; }
.gc-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.gc-bars i { width: 4px; border-radius: 2px; }
.gc-bars i:nth-child(1) { height: 5px; }
.gc-bars i:nth-child(2) { height: 7px; }
.gc-bars i:nth-child(3) { height: 10px; }
.gc-bars i:nth-child(4) { height: 12px; }
.grid-card.daily .gc-diff { color: var(--muted); }
.grid-card.daily .gc-bars i { background: var(--line); }
.grid-card.daily .gc-bars i.on { background: var(--series); }
.grid-card.custom .gc-diff { color: var(--stage-soft); }
.grid-card.custom .gc-bars i { background: var(--stage-faint); }
.grid-card.custom .gc-bars i.on { background: var(--stage-ink); }

/* Toggles on white cards (the builder's song-clip option) */
.toggle.on-card .toggle-track { background: var(--line); }
.toggle.on-card .toggle-note { color: var(--muted); }
.clip-opt { margin-top: 18px; }

/* The board takes focus after the guess sheet closes; no ring around it */
.board:focus { outline: none; }

/* Easy mode confirmation */
.sheet.confirm { width: min(440px, calc(100vw - 32px)); margin: auto; }
.confirm-inner { padding: 22px; }
.confirm-inner b { display: block; font-size: 22px; font-weight: 800; font-stretch: 110%; line-height: 1.2; }
.confirm-inner p { margin: 8px 0 18px; color: var(--muted); }
.confirm-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Builder: options, live category checks, picking ---------- */
.build-options { display: grid; gap: 14px; margin-top: 18px; }
.check-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.check-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: middle;
  background: transparent; box-shadow: inset 0 0 0 1.5px var(--line);
  transition: background 0.2s ease, transform 0.2s ease, width 0.2s ease, height 0.2s ease;
}
.dot.wait { background: var(--line); }
.dot.ok { background: var(--gold); box-shadow: 0 0 0 3px rgba(255, 201, 60, 0.3); }
.dot.no { width: 8px; height: 8px; background: var(--line); box-shadow: none; opacity: 0.6; }
@media (prefers-reduced-motion: no-preference) {
  .dot.wait { animation: breathe 1s ease-in-out infinite; }
  .dot.ok { animation: pop-in 0.25s ease-out; }
}
@keyframes pop-in { from { transform: scale(0.4); } }
.check-scroll { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
.check-matrix { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.check-matrix th[scope="row"] {
  position: sticky; left: 0; z-index: 1; min-width: 132px; max-width: 180px;
  padding: 6px 12px 6px 0; background: var(--surface); text-align: left; font-weight: 600; line-height: 1.25;
}
.check-matrix td { padding: 6px 4px; text-align: center; }
.check-matrix tbody tr + tr th, .check-matrix tbody tr + tr td { border-top: 1px solid var(--surface-2); }
.check-matrix tbody tr[data-kind="ai"]:first-of-type th, .check-matrix tbody tr[data-kind] { scroll-margin: 40px; }
.cm-artist { min-width: 38px; padding: 0 4px 8px; vertical-align: bottom; }
.cm-face {
  display: grid; place-items: center; width: 28px; height: 28px; margin: 0 auto; border-radius: 50%;
  background: var(--surface-2); color: var(--ink); font-weight: 750; object-fit: cover;
}
.cm-name { display: block; max-width: 58px; margin: 4px auto 0; font-size: 11px; font-weight: 650; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-artist[data-state="checking"] .cm-face { box-shadow: 0 0 0 3px var(--stage); }
.cm-artist[data-state="done"] .cm-face { box-shadow: 0 0 0 3px var(--gold); }
.cm-artist[data-state="error"] { opacity: 0.4; }
@media (prefers-color-scheme: dark) { .cm-artist[data-state="checking"] .cm-face { box-shadow: 0 0 0 3px var(--series); } }
.kind-tag {
  display: inline-block; padding: 1px 6px; border-radius: 999px; vertical-align: 1px;
  background: var(--surface-2); color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.02em;
}

.choose-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 10px !important; }
.card .choose-head:first-child { margin-top: 0 !important; }
.choose-artists { display: flex; flex-wrap: wrap; gap: 8px; }
.choose-artist {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px 6px 6px;
  border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 650;
}
.choose-artist .cm-face { width: 30px; height: 30px; margin: 0; }
.choose-artist[aria-pressed="true"], .choose-cat[aria-pressed="true"] { background: var(--gold); border-color: var(--gold-deep); color: var(--gold-ink); }
.choose-artist:disabled, .choose-cat:disabled { opacity: 0.4; cursor: default; }
.choose-note { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.choose-group { display: grid; gap: 6px; margin-top: 16px; }
.choose-group h3, .choose-group .choose-note { grid-column: 1 / -1; }
.choose-group h3 { margin: 0; font-size: 14px; font-weight: 750; color: var(--muted); }
@media (min-width: 700px) { .choose-group { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.choose-cat {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 46px; padding: 8px 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-align: left; font-weight: 600;
}
.cc-counts { flex: none; font-size: 13px; font-variant-numeric: tabular-nums; opacity: 0.8; }
.choose-preview { color: var(--muted); font-size: 14px; }
.choose-preview table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 6px; margin: 0 -6px; }
.choose-preview th { font-size: 12px; font-weight: 700; color: var(--ink); text-align: center; overflow-wrap: anywhere; }
.choose-preview th:first-child { width: 30%; }
.choose-preview tr th:first-child { text-align: left; }
.choose-preview td button {
  width: 100%; min-height: 54px; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--ink); font-weight: 750; font-size: 14px;
}
.choose-preview td button[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--gold); }
#previewSongs { margin-top: 8px; }
.sticky-go p { flex: 1; min-width: 0; }
.done-edit { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ---------- Flags, verdicts and the creator's answer editor ---------- */
.grid-note { margin: 12px 0 0; max-width: 60ch; padding-left: 10px; border-left: 3px solid var(--gold); color: var(--stage-soft); font-size: 14px; }
.edit-btn { margin-top: 14px; min-height: 40px; font-size: 15px; }
.head-cat.has-kind { flex-direction: column; align-items: flex-start; justify-content: center; gap: 5px; }
.head-cat .kind-tag { background: var(--stage-faint); color: var(--stage-ink); white-space: nowrap; overflow-wrap: normal; hyphens: none; -webkit-hyphens: none; }
.flag-bar {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 61; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100vw - 24px);
  padding: 10px 10px 10px 16px; border-radius: 14px;
  background: var(--ink); color: var(--surface); font-weight: 600; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}
.flag-bar[hidden] { display: none !important; }
.flag-bar #flagText { min-width: 0; font-size: 15px; line-height: 1.3; }
.flag-btn { flex: none; min-height: 40px; padding: 0 12px; border-color: rgba(255, 255, 255, 0.35); color: var(--surface); }
.flag-btn:hover { background: rgba(255, 255, 255, 0.12); }
@media (prefers-color-scheme: dark) { .flag-btn { border-color: rgba(0, 0, 0, 0.25); } .flag-btn:hover { background: rgba(0, 0, 0, 0.08); } }
.flag-close { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: inherit; opacity: 0.7; }
.flag-link { padding: 0; border: 0; background: none; color: var(--stage); font-size: 14px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
@media (prefers-color-scheme: dark) { .flag-link { color: var(--series); } }
.flag-done { color: var(--muted); font-size: 14px; }
.flagged-card { grid-area: flags; }
.flagged-card h2 { margin: 0 0 8px; }
.flag-list { margin: 0; padding: 0; list-style: none; }
.flag-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.flag-list li:first-child { border-top: 0; }
.fl-main { display: flex; flex-direction: column; min-width: 0; }
.fl-main b { overflow-wrap: anywhere; }
.fl-main span { font-size: 13px; color: var(--muted); }
.fl-side { display: flex; flex-direction: column; align-items: flex-end; flex: none; text-align: right; }
.fl-side small { font-size: 12px; color: var(--muted); }
.fl-status { padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 750; background: var(--surface-2); color: var(--muted); }
.fl-status.approved { background: #dff5e7; color: #1b6b3d; }
.fl-status.rejected { background: var(--miss-soft); color: var(--miss-ink); }
@media (prefers-color-scheme: dark) { .fl-status.approved { background: #17402b; color: #9be3b6; } }

.sheet.editor { width: min(720px, calc(100vw - 20px)); }
.editor-body { padding: 0 18px 8px; }
.edit-square { padding: 14px 0; border-top: 1px solid var(--line); }
.edit-square:first-child { border-top: 0; padding-top: 4px; }
.edit-square h3 { margin: 0 0 8px; font-size: 15px; font-weight: 750; }
.edit-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.edit-chip { display: inline-flex; align-items: center; gap: 2px; padding: 3px 4px 3px 12px; border-radius: 999px; background: var(--surface-2); font-size: 14px; font-weight: 600; }
.edit-chip button { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
.edit-chip button .icon { width: 16px; height: 16px; }
.edit-chip button:hover { background: var(--miss-soft); color: var(--miss-ink); }
.edit-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.edit-input { width: 100%; min-height: 44px; }
.edit-results { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.edit-add { min-height: 36px; padding: 0 12px; border: 1.5px dashed var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 650; }
.edit-add:hover:not(:disabled) { border-color: var(--gold-deep); background: rgba(255, 201, 60, 0.18); }
.edit-add:disabled { opacity: 0.5; cursor: default; }
.editor-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); }
.editor-foot p { margin: 0; color: var(--muted); font-size: 14px; }
.build-keep { margin: 8px 0 0; color: var(--stage-soft); font-size: 14px; }

/* All-time: how players are counted */
.lb-title { display: inline-flex; align-items: center; gap: 8px; }
.info-btn {
  display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0;
  border: 1.5px solid var(--line); border-radius: 999px; background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 800; line-height: 1; cursor: pointer;
  position: relative;
}
.info-btn::after { content: ""; position: absolute; inset: -10px; } /* a bigger tap target */
.info-btn:hover, .info-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--ink); }
.card .lb-info { margin: -4px 0 14px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--ink); font-size: 14px; }

/* Stats: player code */
.link-confirm { margin-top: 24px; max-width: 640px; border: 2px solid var(--gold); }
.link-confirm h2, .device-card h2 { margin: 0 0 8px; }
.device-card { margin-top: 20px; max-width: 640px; }
.device-card p { margin: 0 0 10px; }
.device-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.device-code { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); overflow-wrap: anywhere; }
.device-code code { color: var(--ink); font-size: 14px; }
.device-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.device-form label { display: block; margin-bottom: 8px; font-weight: 650; }
.device-card .device-hint { margin: -2px 0 10px; font-size: 14px; color: var(--muted); }
.device-card .device-warn { margin: 12px 0 0; font-size: 13px; }

/* Spotify sign-in needs approval */
.spotify-note { margin-top: 18px; }
.spotify-note h2, .access-card h2 { margin: 0 0 8px; font-size: 19px; }
.spotify-note p { margin: 0 0 10px; }
.spotify-note p:last-child { margin-bottom: 0; }
.card .spotify-note a, .spotify-note a, .access-card a { color: var(--ink); font-weight: 650; }
.access-card p { margin: 0 0 10px; }
.access-form { margin-top: 16px; }
.access-fields { display: grid; gap: 12px; margin-bottom: 14px; }
@media (min-width: 560px) { .access-fields { grid-template-columns: 1fr 1fr; } }
.access-fields label { display: grid; gap: 6px; font-weight: 650; font-size: 15px; }
.access-fields .field { width: 100%; }
.access-form .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.access-card .access-spotify { margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; }

/* Build page: a third choice spans the row; links under a builder card */
@media (min-width: 640px) { .choices .choice.wide { grid-column: 1 / -1; } }
.builder-alt { margin: 16px 0 0; }
.builder-alt a { color: var(--stage-ink); font-weight: 650; }

/* One song, one square */
.rule-line { margin: 10px 0 0; max-width: 60ch; color: var(--stage-soft); font-size: 15px; }
.rule-line b { color: var(--gold); font-weight: 800; }

/* Builder: picks that would need the same song twice */
.choose-cat.clash:disabled { opacity: 0.55; text-decoration: line-through; text-decoration-thickness: 1px; }
.choose-preview td button.clash { box-shadow: inset 0 0 0 2px var(--miss-ink); background: var(--miss-soft); color: var(--miss-ink); }
.sticky-go p.clash-note { color: var(--miss-ink); font-weight: 650; }

/* ---------- Misses, last chance and the leaderboard prompt: hard to miss ---------- */
:root { --miss-strong: #c62828; }

/* The miss bar: red, big, with a hearts line */
.flag-bar {
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(580px, calc(100vw - 20px)); max-width: none;
  gap: 12px; padding: 14px 12px 14px 14px; border-radius: 18px;
  background: var(--miss-strong); color: #fff;
  box-shadow: 0 0 0 3px #fff, 0 18px 40px rgba(110, 10, 10, 0.45);
}
.flag-icon { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 50%; background: #fff; color: var(--miss-strong); }
.flag-icon svg { width: 20px; height: 20px; }
.flag-copy { display: grid; gap: 5px; flex: 1; min-width: 0; }
.flag-bar #flagText { font-size: 17px; font-weight: 800; line-height: 1.25; }
.flag-extra { justify-self: start; font-size: 14px; font-weight: 700; }
.flag-bar.danger .flag-extra { padding: 3px 10px; border-radius: 999px; background: var(--gold); color: var(--gold-ink); font-weight: 850; }
.flag-bar .flag-btn, .flag-bar .flag-btn:hover { border-color: rgba(255, 255, 255, 0.75); color: #fff; }
.flag-bar .flag-btn:hover { background: rgba(255, 255, 255, 0.16); }
.flag-bar .flag-close { color: #fff; opacity: 0.9; }
@media (max-width: 520px) {
  .flag-bar { flex-wrap: wrap; }
  .flag-copy { flex: 1 1 0; }
  .flag-bar .flag-close { order: 2; }
  .flag-bar .flag-btn { order: 3; flex: 1 0 100%; }
}

/* A red flash around the screen edge on a miss */
.miss-flash {
  position: fixed; inset: 0; z-index: 59; pointer-events: none; opacity: 0;
  box-shadow: inset 0 0 0 6px var(--miss), inset 0 0 140px rgba(255, 70, 50, 0.5);
}
.miss-flash.static { opacity: 0.8; }

/* Out of hearts: a banner over the grid, a pulsing outline, a warning in the guess sheet */
.sudden-banner {
  margin: 0 0 14px; padding: 12px 16px; border-radius: 14px;
  background: var(--miss-strong); color: #fff; font-weight: 650; line-height: 1.35;
  box-shadow: 0 0 0 3px #fff;
}
.sudden-banner b { font-weight: 850; }
.board-wrap.danger .board { outline: 3px solid var(--miss); outline-offset: 8px; border-radius: 16px; }
.sudden { padding: 5px 12px; font-size: 14px; }
.sheet-warn { margin: 0 8px 10px; padding: 10px 12px; border-radius: 12px; background: var(--miss-strong); color: #fff; font-size: 15px; font-weight: 750; }

@media (prefers-reduced-motion: no-preference) {
  .flag-bar.enter { animation: miss-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1); }
  .miss-flash.on { animation: miss-flash 0.75s ease-out; }
  .board-wrap.danger .board { animation: danger-pulse 1.6s ease-in-out infinite; }
  .sudden { animation: pill-pulse 1.6s ease-in-out infinite; }
  .results:not([hidden]) .submit-form:not([hidden]) { animation: callout-in 0.6s cubic-bezier(0.2, 1.3, 0.4, 1) 0.35s both; }
}
@keyframes miss-in { from { opacity: 0; transform: translate(-50%, 34px) scale(0.92); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes miss-flash { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }
@keyframes danger-pulse { 50% { outline-color: rgba(255, 107, 94, 0.3); } }
@keyframes pill-pulse { 50% { transform: scale(1.06); } }
@keyframes callout-in { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }

/* The leaderboard prompt: a gold callout right under the score */
.results .submit-form {
  margin: 0 0 20px; padding: 16px; border-top: 0; border-radius: 16px;
  background: var(--gold); color: var(--gold-ink); box-shadow: 0 4px 0 var(--gold-deep);
}
.results .submit-form label { margin: 0; font-size: 21px; font-weight: 850; font-stretch: 108%; line-height: 1.2; }
.card .submit-sub { margin: 2px 0 12px; color: var(--gold-ink); font-size: 15px; opacity: 0.85; }
.results .submit-form .field { border-color: var(--gold-deep); background: #fff; color: #10163a; }
.results .submit-form .field::placeholder { color: #5b6280; }
.results .submit-form .btn-ink { background: #10163a; color: #fff; }
.card .results .submit-form .form-note, .results .submit-form .form-note { color: var(--gold-ink); }
.submit-done {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 20px;
  padding: 12px 16px; border-radius: 14px; background: var(--surface-2); color: var(--ink); font-weight: 650;
}
.see-rank { color: var(--ink); font-weight: 800; text-underline-offset: 3px; }

/* Name reviews */
.appeal-btn { flex-basis: 100%; justify-self: start; padding: 0; border: 0; background: none; color: var(--ink); font-size: 14px; font-weight: 700; text-align: left; text-decoration: underline; text-underline-offset: 3px; }
.appeal-note { flex-basis: 100%; font-size: 14px; font-weight: 650; color: var(--muted); }
.appeal-note.restored { color: #1f7a3f; }
@media (prefers-color-scheme: dark) { .appeal-note.restored { color: #8fe0a8; } }

/* ---------- Phones: get the whole board on the first screen ---------- */
@media (max-width: 599px) {
  .topbar { padding-top: 10px; padding-bottom: 6px; }
  .game { gap: 14px; padding-top: 4px; }
  /* Title and countdown share a line */
  .game-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
  .game-head > * { flex: 1 1 100%; }
  .game-head > .title, .game-head > .next-grid { flex: 0 1 auto; }
  .grid-date { margin: 0; font-size: 14px; }
  .title { font-size: 30px; }
  .next-grid { margin: 0; padding: 5px 10px; font-size: 13px; }
  .subtitle { margin: 2px 0 0; font-size: 15px; }
  .rule-line { margin: 0; font-size: 14px; }
  .grid-note { margin: 0; }
  /* Players who've played before know the rules: keep only the no-repeats line */
  .returning .game-head .subtitle { display: none; }
  .hud { gap: 8px 12px; }
  .hud-num { font-size: 40px; }
  .life { width: 24px; height: 24px; }
  .toggle-note { font-size: 12px; }
  .sudden-banner { margin-bottom: 10px; padding: 8px 12px; border-radius: 12px; font-size: 14px; }
  .board-wrap.danger .board { outline-offset: 5px; }
  .board-actions { margin-top: 14px; }
}
.lb-more { width: 100%; justify-content: center; margin-top: 12px; }
.lb-sentinel { height: 1px; }

/* ---------- About ---------- */
.about { width: 100%; max-width: 760px; margin: 0 auto; padding: 8px var(--gutter) 0; }
.about-card { margin-top: 16px; }
.about .subtitle { margin-bottom: 8px; }
.about-card p { margin: 0 0 10px; line-height: 1.55; }
.about-card p:last-child { margin-bottom: 0; }
.about-card a { color: var(--stage); font-weight: 650; }
.score-table { margin: 4px 0 14px; padding: 0; }
.score-table div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 9px 0; border-top: 1px solid var(--line); }
.score-table div:first-child { border-top: 0; }
.score-table dt { color: var(--muted); }
.score-table dd { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.score-table .total dt { color: var(--ink); font-weight: 700; }
.score-table .total dd { font-size: 20px; }
.legend { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; color: var(--muted); }
.legend span { display: inline-block; min-width: 3.6em; color: var(--ink); }
.about-cta { margin: 24px 0 0; text-align: center; }
.foot .foot-about { display: inline-block; margin-left: 4px; }
.subtitle a { color: var(--gold); font-weight: 700; text-underline-offset: 3px; white-space: nowrap; }
