/* Dial: an old radio. Walnut cabinet ground, one backlit glass tuning scale, one red needle
   that is always yours. Amber only for the station band at the reveal. Spacing on an 8px grid. */

:root {
  --ground: #21170f;
  --raised: #2e2117;
  --line: #4a382a;
  --text: #f3ead9;
  --muted: #bba993;
  --glass: #f1e2b6;
  --glass-edge: #d9c48e;
  --ink: #1d140d;
  --ink-soft: #5b4a35;
  --needle: #d42a1e;
  --z2: #f2cf7c;
  --z3: #e9ab45;
  --z4: #cf7a22;
  --am: #c98bb0;
  --fm: #5fb0bd;
  --font: "Archivo", system-ui, sans-serif;
  --u: 8px;
  --r: 4px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 400 17px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
}
::selection { background: var(--glass); color: var(--ink); }
:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
button, input { font: inherit; color: inherit; }
img { display: block; }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--u) * 2) calc(var(--u) * 2) calc(var(--u) * 18);
  padding-top: max(calc(var(--u) * 2), env(safe-area-inset-top));
}

.icon { width: 20px; height: 20px; flex: none; }

/* ---------- the wide-caps voice of a radio's printed scale ---------- */

.wordmark, .room-code, .clue, .end, .btn, .group h2, .status h2, .verdict, .champ h2,
.team-label, .team-col h3, .readout {
  font-stretch: 118%;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--u);
  width: 100%; min-height: 56px; padding: 0 calc(var(--u) * 3);
  border: 0; border-radius: var(--r);
  background: var(--text); color: var(--ground);
  font-size: 18px; font-weight: 800; cursor: pointer;
  transition: transform 0.15s var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { background: var(--raised); color: var(--muted); cursor: default; transform: none; }
.btn.plain { background: transparent; color: var(--text); box-shadow: inset 0 0 0 2px var(--line); }
.btn.plain:hover { box-shadow: inset 0 0 0 2px var(--muted); }
.btn.small { width: auto; min-height: 48px; font-size: 15px; padding: 0 calc(var(--u) * 2); }

.link {
  display: inline-flex; align-items: center; gap: var(--u);
  background: none; border: 0; padding: var(--u) 0; min-height: 48px;
  color: var(--muted); text-decoration: underline; text-underline-offset: 4px; cursor: pointer;
}
.link:hover { color: var(--text); }
.link.small { min-height: 40px; font-size: 14px; padding: 0; }

.field {
  width: 100%; min-height: 56px; padding: 0 calc(var(--u) * 2);
  border: 2px solid var(--line); border-radius: var(--r);
  background: var(--raised); color: var(--text); font-size: 19px; caret-color: var(--text);
}
.field::placeholder { color: #a8957e; }
.field:focus { outline: none; border-color: var(--text); }
.field.code { width: 128px; flex: none; text-transform: uppercase; letter-spacing: 0.2em; font-weight: 800; text-align: center; }

.choice { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; background: var(--line); border-radius: var(--r); padding: 2px; }
.choice button { min-height: 48px; border: 0; border-radius: 2px; background: var(--ground); color: var(--muted); font-weight: 700; cursor: pointer; }
.choice button[aria-pressed="true"] { background: var(--text); color: var(--ground); }
.choice button:disabled { cursor: default; }

.stepper { display: flex; align-items: center; gap: calc(var(--u) * 2); }
.stepper button { width: 48px; height: 48px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: var(--r); background: transparent; cursor: pointer; }
.stepper .value { font-size: 32px; font-weight: 800; min-width: 2ch; text-align: center; }
.stepper .unit { color: var(--muted); }

.hint { color: var(--muted); font-size: 15px; margin-top: var(--u); }
.hint.center { text-align: center; }

/* ---------- home ---------- */

.home { display: flex; flex-direction: column; gap: calc(var(--u) * 2); padding-top: calc(var(--u) * 3); }
.home-glass { position: relative; height: 56px; border-radius: var(--r); background: var(--glass); box-shadow: inset 0 0 0 2px var(--glass-edge); overflow: hidden; }
.home-glass .ticks { position: absolute; inset: 8px 16px; }
.home-glass .needle { top: 0; bottom: 0; }
.wordmark { font-size: 104px; line-height: 0.85; font-weight: 900; letter-spacing: -0.01em; margin-top: var(--u); }
.lede { font-size: 19px; color: var(--muted); max-width: 32ch; margin-bottom: var(--u); }
.join { margin-top: calc(var(--u) * 3); padding-top: calc(var(--u) * 3); border-top: 1px solid var(--line); display: grid; gap: calc(var(--u) * 2); }
.label { color: var(--muted); font-size: 15px; }
.row { display: flex; gap: var(--u); }
.row .btn { flex: 1; }

.photo-pick { display: flex; align-items: center; gap: calc(var(--u) * 2); text-align: left; padding: calc(var(--u) * 2); border: 2px dashed var(--line); border-radius: var(--r); background: transparent; cursor: pointer; }
.photo-pick b { display: block; font-weight: 700; }
.photo-pick small { display: block; color: var(--muted); font-size: 14px; line-height: 1.35; }

/* ---------- faces ---------- */

.face {
  position: relative; flex: none; display: inline-grid; place-items: center; overflow: hidden;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--raised); box-shadow: inset 0 0 0 2px var(--line);
  font-weight: 800; font-size: 13px; color: var(--muted);
}
.face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.face.xs { width: 32px; height: 32px; font-size: 11px; }
.face.m { width: 56px; height: 56px; font-size: 18px; }
.face.l { width: 96px; height: 96px; font-size: 30px; }
.face.team-am, .face.team-fm { overflow: visible; }
.face.team-am::after, .face.team-fm::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 3px var(--am); z-index: 1; }
.face.team-fm::after { box-shadow: inset 0 0 0 3px var(--fm); }
.face img { border-radius: 50%; }
.face.off { opacity: 0.4; }

/* ---------- lobby ---------- */

.lobby { display: flex; flex-direction: column; }
.code-block { display: flex; align-items: center; justify-content: space-between; gap: calc(var(--u) * 2); }
.room-code { font-size: 48px; line-height: 1; font-weight: 900; letter-spacing: 0.06em; }
.code-help { display: flex; align-items: center; justify-content: space-between; gap: calc(var(--u) * 2); color: var(--muted); }
.group { margin-top: calc(var(--u) * 4); }
.group h2 { font-size: 17px; font-weight: 800; margin-bottom: calc(var(--u) * 2); }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--u); }
.group-head .hint, .group-head .link { margin: 0; }

.roster { display: flex; flex-wrap: wrap; gap: var(--u); }
.chip-player { display: flex; align-items: center; gap: var(--u); min-height: 48px; padding: 4px calc(var(--u) * 2) 4px 4px; border-radius: 28px; background: var(--raised); min-width: 0; }
.chip-name { font-weight: 700; overflow-wrap: break-word; hyphens: auto; }
.tag { font-size: 12px; font-weight: 700; color: var(--muted); }
.team-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--u); }
.team-col { display: grid; align-content: start; gap: var(--u); padding: 0 var(--u) var(--u); border-radius: var(--r); background: var(--raised); overflow: hidden; }
.team-col h3 { margin: 0 calc(var(--u) * -1); padding: var(--u); font-size: 15px; font-weight: 800; color: var(--ink); }
.team-col.team-am h3 { background: var(--am); }
.team-col.team-fm h3 { background: var(--fm); }
.team-col .chip-player { display: grid; grid-template-columns: auto 1fr auto; padding: 0; background: none; border-radius: 0; }
.team-col .chip-name { min-width: 0; }
.team-col .tag { grid-column: 2; margin-top: -8px; }
.switch-team { grid-column: 3; grid-row: 1; width: 40px; height: 40px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.lobby-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--u); margin-top: calc(var(--u) * 2); }

.decks { display: grid; gap: 2px; background: var(--line); border-radius: var(--r); overflow: hidden; }
.deck { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: calc(var(--u) * 2); min-height: 56px; padding: var(--u) calc(var(--u) * 2); border: 0; background: var(--ground); text-align: left; cursor: pointer; }
.deck:disabled { cursor: default; }
.tick-box { width: 28px; height: 28px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 2px; }
.deck[aria-pressed="true"] .tick-box { background: var(--text); border-color: var(--text); color: var(--ground); }
.deck[aria-pressed="false"] .deck-name { color: var(--muted); }
.deck-name { display: flex; align-items: center; gap: var(--u); font-weight: 700; }
.deck-count { color: var(--muted); font-size: 15px; }
.adult { padding: 0 4px; border-radius: 2px; box-shadow: inset 0 0 0 2px var(--text); color: var(--text); font-size: 12px; font-weight: 800; }

/* ---------- action bar ---------- */

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: calc(var(--u) * 2) calc(var(--u) * 2) max(calc(var(--u) * 2), env(safe-area-inset-bottom));
  background: var(--ground); border-top: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: var(--u);
}
.actionbar > * { width: 100%; max-width: 448px; }
.actionbar .link { width: auto; }
.waiting { color: var(--muted); text-align: center; padding: var(--u) 0; }
.waiting.small { padding: 0; font-size: 15px; }

/* ---------- top bar ---------- */

.topbar { position: sticky; top: 0; z-index: 4; margin: calc(var(--u) * -2) calc(var(--u) * -2) calc(var(--u) * 3); padding: var(--u) calc(var(--u) * 2); background: var(--ground); }
.topbar-line { display: flex; align-items: center; justify-content: space-between; gap: var(--u); }
.guide { display: flex; align-items: baseline; gap: var(--u); flex-wrap: wrap; color: var(--muted); font-size: 15px; }
.guide strong { color: var(--text); font-weight: 800; }
.guide-tuner::before { content: "·"; margin-right: var(--u); }
.menu-btn { min-height: 44px; padding: 0 calc(var(--u) * 2); border: 2px solid var(--line); border-radius: var(--r); background: none; cursor: pointer; font-weight: 700; font-size: 15px; }
/* every player stays on screen: the bar wraps rather than scrolling anyone out of view */
.scores { display: flex; flex-wrap: wrap; gap: 4px; padding-top: var(--u); }
.score { position: relative; display: flex; align-items: center; gap: var(--u); padding: 2px var(--u) 2px 2px; border-radius: 20px; background: var(--raised); }
.score .pts { font-weight: 800; font-size: 17px; }
.score.tuning { background: var(--glass); color: var(--ink); }
.score .mark { position: absolute; left: 16px; right: 16px; bottom: -4px; height: 3px; border-radius: 2px; background: var(--line); }
.score.done .mark { background: var(--text); }
.team-scores { display: grid; grid-template-columns: 1fr 1fr; gap: var(--u); padding-top: var(--u); }
.team-score { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 var(--u); padding: var(--u); border-radius: var(--r); background: var(--raised); }
.team-score .team-label { padding: 2px var(--u); border-radius: 2px; color: var(--ink); }
.team-score.team-am .team-label { background: var(--am); }
.team-score.team-fm .team-label { background: var(--fm); }
.team-score.mine { box-shadow: inset 0 0 0 2px var(--text); }
.team-label { font-weight: 800; font-size: 15px; }
.team-score .num { font-size: 28px; font-weight: 900; justify-self: end; }
.team-faces { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; margin-top: var(--u); }

/* ---------- the tuning glass ---------- */

.glass {
  position: relative; display: grid; gap: var(--u); padding: calc(var(--u) * 2);
  border-radius: var(--r); color: var(--ink);
  /* the glass is lit from behind: brightest in the middle, falling off toward the frame */
  background: radial-gradient(120% 140% at 50% 45%, #fbf0cf 0%, var(--glass) 55%, #e2cd93 100%);
  box-shadow: inset 0 0 0 3px var(--glass-edge), 0 0 0 6px var(--raised);
  margin: var(--u) 6px;
  padding-inline: calc(var(--u) * 3);
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.glass.live { cursor: ew-resize; }
.glass-ends { display: flex; justify-content: space-between; align-items: flex-end; gap: calc(var(--u) * 2); }
.end { font-size: 15px; font-weight: 800; line-height: 1.1; max-width: 48%; font-stretch: 100%; overflow-wrap: anywhere; hyphens: auto; }
.end.right { text-align: right; }
.scale { position: relative; height: 144px; margin-top: var(--u); }
.ticks { position: absolute; inset: 0 0 24px; z-index: 2; }
.tick { position: absolute; bottom: 0; width: 1px; height: 24px; background: var(--ink-soft); translate: -50% 0; }
.tick.major { width: 2px; height: 40px; background: var(--ink); }
.freq { position: absolute; bottom: -24px; translate: -50% 0; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.needle { position: absolute; top: 8px; bottom: 16px; width: 4px; translate: -50% 0; border-radius: 2px; background: var(--needle); z-index: 3; }
.needle::after { content: ""; position: absolute; left: 50%; top: -8px; width: 16px; height: 16px; translate: -50% 0; border-radius: 50%; background: var(--needle); }
.needle.team-am, .needle.team-am::after { background: var(--am); }
.needle.team-fm, .needle.team-fm::after { background: var(--fm); }
.band-wrap.secret { opacity: 0; transition: opacity 0.15s; }
.glass.peek .band-wrap.secret { opacity: 1; }
.btn.hold { margin-top: calc(var(--u) * 2); touch-action: none; user-select: none; -webkit-user-select: none; }

/* the station band: 2, 3, 4, 3, 2 points across a stripe centred on the target */
.band { position: absolute; top: 0; bottom: 0; left: calc((var(--t) - 18) * 1%); width: 36%; display: grid; grid-template-columns: 7fr 7fr 8fr 7fr 7fr; }
.band-wrap { position: absolute; inset: 0 0 24px; overflow: hidden; z-index: 1; }
.band span { display: grid; align-items: start; justify-items: center; padding-top: 4px; }
.band b { font-size: 12px; font-weight: 800; color: var(--ink); }
.band .z2 { background: var(--z2); }
.band .z3 { background: var(--z3); }
.band .z4 { background: var(--z4); }
.band .z4 b { color: var(--ink); }

.marker {
  position: absolute; bottom: calc(56px + var(--row, 0) * 24px); translate: -50% 0; z-index: calc(4 + var(--row, 0));
  padding: 2px 6px; border-radius: 2px; background: var(--ink); color: var(--glass);
  font-size: 12px; font-weight: 800; white-space: nowrap;
}
.marker::after { content: ""; position: absolute; left: 50%; top: 100%; width: 2px; height: calc(32px + var(--row, 0) * 24px); translate: -50% 0; background: var(--ink); }
.marker.mine { background: var(--needle); color: #fff; }
.marker.mine::after { background: var(--needle); }
.marker.team-am { background: var(--am); color: var(--ink); }
.marker.team-fm { background: var(--fm); color: var(--ink); }

.tune-in.fresh .band-wrap { animation: tune 1.2s var(--ease) both; }
.tune-in.fresh .marker { animation: drop 0.6s var(--ease) both; animation-delay: calc(0.9s + var(--i, 0) * 0.15s); }
@keyframes tune { 0% { opacity: 0; filter: blur(6px); clip-path: inset(0 45% 0 45%); } 60% { opacity: 1; filter: blur(0); } 100% { clip-path: inset(0 0 0 0); } }
@keyframes drop { from { opacity: 0; translate: -50% -16px; } }

.fine { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: var(--u); margin-top: calc(var(--u) * 2); }
.nudge { height: 56px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 50%; background: var(--raised); cursor: pointer; }
.nudge:active { background: var(--line); }
.readout { text-align: center; font-size: 32px; font-weight: 900; }
.readout small { font-size: 14px; color: var(--muted); margin-left: 4px; text-transform: none; }
.readout-line { text-align: center; color: var(--muted); margin-top: calc(var(--u) * 2); }
.readout-line .num { color: var(--text); font-weight: 800; }

/* ---------- on air ---------- */

.on-air { margin-bottom: calc(var(--u) * 2); }
.clue { font-size: 40px; font-weight: 900; line-height: 1; overflow-wrap: anywhere; }
.clue.long { font-size: 30px; }
.clue.longword { font-size: 28px; font-stretch: 100%; }
.clue.longword.xl { font-size: 22px; }

.status { margin-bottom: calc(var(--u) * 2); }
.status h2 { font-size: 30px; font-weight: 900; line-height: 1; }
.status p { color: var(--muted); margin-top: var(--u); }
.clue-form { display: grid; gap: var(--u); margin-top: calc(var(--u) * 3); }
.clue-form .link { justify-self: start; }

.bet-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--u); }
.btn.bet { min-height: 72px; font-size: 20px; }

/* ---------- reveal and game over ---------- */

.verdict { font-size: 30px; font-weight: 900; line-height: 1; margin-top: calc(var(--u) * 3); }
.results { display: grid; gap: 2px; margin-top: calc(var(--u) * 2); }
.result-line { display: flex; align-items: center; gap: var(--u); min-height: 48px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.result-line .who { flex: 1; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.result-line .dist { color: var(--muted); font-size: 15px; }
.result-line .gain { min-width: 3ch; text-align: right; font-weight: 900; font-size: 20px; }
.result-line.mine .who { color: var(--text); text-decoration: underline 3px var(--needle); text-underline-offset: 4px; }
.result-line.team-am span:first-child, .result-line.team-fm span:first-child { flex: 1; font-weight: 700; }
.result-line.team-am span:first-child::before, .result-line.team-fm span:first-child::before { content: ""; display: inline-block; width: 16px; height: 16px; margin-right: var(--u); border-radius: 2px; vertical-align: -2px; }
.result-line.team-am span:first-child::before { background: var(--am); }
.result-line.team-fm span:first-child::before { background: var(--fm); }

.champ { display: grid; justify-items: start; gap: calc(var(--u) * 2); padding-top: var(--u); margin-bottom: calc(var(--u) * 3); }
.champ-faces { display: flex; gap: var(--u); }
.champ h2 { font-size: 40px; font-weight: 900; line-height: 0.95; }
.champ p { color: var(--muted); }
.standings { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.standings li { display: flex; align-items: center; gap: calc(var(--u) * 2); padding: var(--u) 0; border-bottom: 1px solid var(--line); }
.standings .who { flex: 1; font-weight: 700; }
.standings .pts { font-size: 24px; font-weight: 900; }

/* ---------- menu, toast, status ---------- */

.sheet { width: 100%; max-width: 480px; margin: auto auto 0; padding: calc(var(--u) * 3) calc(var(--u) * 2) max(calc(var(--u) * 3), env(safe-area-inset-bottom)); border: 0; border-radius: var(--r) var(--r) 0 0; background: var(--raised); color: var(--text); }
.sheet::backdrop { background: rgb(0 0 0 / 0.6); }
.sheet .stack { display: grid; gap: var(--u); }
.sheet .link { justify-self: center; }

#toast { position: fixed; left: 50%; bottom: calc(var(--u) * 14); z-index: 20; translate: -50% 16px; max-width: calc(100% - 32px); padding: calc(var(--u) * 2); border-radius: var(--r); background: var(--text); color: var(--ground); font-weight: 700; opacity: 0; pointer-events: none; transition: opacity 0.2s, translate 0.3s var(--ease); }
#toast.show { opacity: 1; translate: -50% 0; }
.connecting { color: var(--muted); text-align: center; padding-top: 30vh; }
.offline-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; padding: var(--u); text-align: center; background: var(--text); color: var(--ground); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-delay: 0ms !important; }
}
