/* Party Scoreboard styles. Self-contained (system fonts, no external requests). Dark stage on purpose: it reads best on a TV. */
:root {
  color-scheme: dark;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --num: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, -apple-system, "Segoe UI", sans-serif;
}
/* Themes: bg, surface, ink, muted, line, accent (buttons/focus), and six team colours. */
[data-theme="classic"] {
  --bg: #141b2d; --surface: #1d2640; --surface-2: #26314f; --ink: #f5f3ee; --muted: #aab3c8; --line: #34405f;
  --accent: #f2b84b; --accent-ink: #141b2d; --buzz: #e5484d; --ding: #1d8f5c;
  --t1: #ff7a59; --t2: #4fa3ff; --t3: #f2c94c; --t4: #3ecf8e; --t5: #c084fc; --t6: #ff8fb8;
}
[data-theme="thanksgiving"] {
  --bg: #2b1712; --surface: #43261c; --surface-2: #5a3324; --ink: #fff6ea; --muted: #d8bca5; --line: #6b3f2c;
  --accent: #f2b84b; --accent-ink: #2b1712; --buzz: #d9472f; --ding: #5f7a25;
  --t1: #e8913a; --t2: #c9d36a; --t3: #f2b84b; --t4: #8fb4e8; --t5: #c79bd8; --t6: #7fc6c2;
}
[data-theme="christmas"] {
  --bg: #0f2a22; --surface: #163a2f; --surface-2: #1e4a3c; --ink: #fbf6ec; --muted: #b9cfc3; --line: #2a5a4a;
  --accent: #edbe55; --accent-ink: #0f2a22; --buzz: #d94650; --ding: #2f7d57;
  --t1: #ff6b72; --t2: #edbe55; --t3: #8fd3ac; --t4: #7fb2ff; --t5: #f6f1e7; --t6: #f59bc2;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--font); overflow-x: hidden; transition: background-color .3s; }
a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 10px; }
.skip:focus { top: 10px; }
kbd { font: 600 .78rem/1 ui-monospace, Menlo, Consolas, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 2px 5px; background: var(--surface); color: var(--ink); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: 650 1rem/1.1 var(--font); cursor: pointer; text-decoration: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 44px; padding: 7px 13px; font-size: .92rem; border-radius: 11px; }
.btn[aria-pressed="false"] .wave { opacity: .2; }
.grow { flex: 1 1 0; }
.wide { width: 100%; }
.linkish { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; cursor: pointer; min-height: 24px; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; max-width: 1400px; margin: 0 auto; padding: 10px 16px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 650; font-size: .98rem; min-height: 44px; white-space: nowrap; }
.brand svg { width: 24px; height: 24px; color: var(--accent); }
.brand b { font-weight: 650; color: var(--muted); }
.tools { display: flex; gap: 8px; }
@media (max-width: 520px) { .tools .lbl { display: none; } .tools .btn { padding: 7px 11px; } }

.app { max-width: 1400px; margin: 0 auto; padding: 0 16px; }
.intro { padding: 2px 0 12px; }
h1 { margin: 0; }
.h1-big { display: block; font: 800 clamp(2rem, 8vw, 3.2rem)/1 var(--display); letter-spacing: -.02em; }
.h1-sub { display: block; margin-top: 6px; font: 500 clamp(.95rem, 3.6vw, 1.1rem)/1.4 var(--font); color: var(--muted); }

/* Team cards */
.board { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) { .board[data-n="3"], .board[data-n="5"], .board[data-n="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); } .board[data-n="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 359px) { .board { grid-template-columns: minmax(0, 1fr); } }
.team { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 12px; border-radius: 22px; background: var(--surface);
  border: 2px solid transparent; box-shadow: inset 0 6px 0 var(--c); transition: border-color .2s, transform .2s; }
.team.picked { border-color: var(--c); }
.team .name { width: 100%; min-height: 44px; padding: 6px 8px; border: 1.5px solid transparent; border-radius: 10px; background: transparent; color: var(--ink);
  font: 750 clamp(1rem, 3.6vw, 1.35rem)/1.2 var(--display); text-align: center; text-overflow: ellipsis; }
.team .name:hover { border-color: var(--line); }
.team .name:focus { border-color: var(--c); outline: none; background: var(--surface-2); }
.score { display: block; width: 100%; margin: 0; padding: 0; border: 0; background: none; color: var(--c); cursor: pointer; border-radius: 14px; white-space: nowrap; overflow: hidden;
  font: 800 clamp(3rem, 15vw, 6rem)/1 var(--num); font-variant-numeric: tabular-nums; letter-spacing: -.03em; text-align: center; touch-action: manipulation; }
.score.neg { color: var(--buzz); }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.steps button { min-height: 48px; padding: 0; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--ink); font: 750 clamp(.8rem, 3.1vw, 1.1rem)/1 var(--num);
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.steps button.plus { background: color-mix(in srgb, var(--c) 30%, var(--surface-2)); }
/* Narrow team cards (two phones-width columns): 2 x 2 steps, -10/+10 on top and -100/+100 below, so each button stays >= 44 px wide */
.team { container-type: inline-size; }
@container (max-width: 210px) {
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps button[data-d="-10"] { order: 1; } .steps button[data-d="10"] { order: 2; }
  .steps button[data-d="-100"] { order: 3; } .steps button[data-d="100"] { order: 4; }
  .steps button { min-height: 44px; font-size: 1.05rem; }
}
.steps button:active { transform: scale(.96); }
.crown { position: absolute; top: -9px; left: 50%; translate: -50% 0; white-space: nowrap; font: 700 .72rem/1 var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink);
  background: var(--accent); padding: 5px 8px; border-radius: 999px; opacity: 0; transform: translateY(-4px); transition: opacity .25s, transform .25s; pointer-events: none; }
.team.leader .crown { opacity: 1; transform: none; }
.pop { position: absolute; left: 50%; top: 42%; font: 800 1.6rem/1 var(--num); color: var(--c); pointer-events: none; animation: pop .9s ease-out forwards; }
.pop.neg { color: var(--buzz); }
@keyframes pop { from { opacity: 1; transform: translate(-50%, 0) scale(1); } to { opacity: 0; transform: translate(-50%, -60px) scale(1.25); } }

/* Dock */
.dock { display: grid; gap: 12px; margin-top: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .dock { grid-template-columns: 1.1fr 1fr 1fr; } }
.panel { background: var(--surface); border-radius: 22px; padding: 14px; min-width: 0; }
.row { display: flex; gap: 8px; }
.timer-face { font: 800 clamp(3rem, 14vw, 4.6rem)/1 var(--num); font-variant-numeric: tabular-nums; text-align: center; letter-spacing: -.02em; padding: 4px 0 10px; }
.timer.running .timer-face { color: var(--accent); }
.timer.low .timer-face { color: var(--buzz); animation: blink 1s steps(2, start) infinite; }
.timer.done .timer-face { color: var(--buzz); }
@keyframes blink { to { opacity: .55; } }
.chips { display: flex; gap: 6px; margin-bottom: 10px; }
.chip { flex: 1 1 0; min-height: 44px; border: 1.5px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); font: 650 .95rem/1 var(--font); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pads { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pad-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 120px; border: 0; border-radius: 18px; color: #fff; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: transform .08s; }
.pad-btn:active, .pad-btn.hit { transform: scale(.95); }
.buzz { background: var(--buzz); }
.ding { background: var(--ding); }
.pad-big { font: 800 clamp(1.6rem, 6vw, 2.2rem)/1 var(--display); }
.pad-sub { font: 600 .82rem/1.2 var(--font); opacity: .92; }
.pad-sub kbd { background: rgba(0,0,0,.18); border-color: rgba(255,255,255,.35); color: #fff; }
.setup { display: flex; flex-direction: column; gap: 10px; }
.setup-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.setup-lbl { font-weight: 650; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper output { min-width: 1.5em; text-align: center; font: 800 1.5rem/1 var(--num); }
.stepper .btn { min-width: 48px; font-size: 1.3rem; }
select { min-height: 44px; padding: 6px 10px; border-radius: 11px; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink); font: 600 1rem var(--font); }
.hint { color: var(--muted); font-size: .9rem; line-height: 1.7; margin: 12px 0 0; }

/* TV mode: only scores, timer and pads, sized to the screen. */
body.tv .top, body.tv .intro, body.tv .hint, body.tv .learn, body.tv .foot, body.tv .setup { display: none; }
body.tv .app { max-width: none; padding: 52px 2vw 2vh; height: 100vh; height: 100dvh; display: grid; grid-template-rows: 1fr auto; gap: 2vh; }
body.tv .board { gap: 1.6vw; align-content: stretch; }
body.tv .board[data-n="2"], body.tv .board[data-n="4"] { grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); }
body.tv .team { justify-content: center; padding: 1.6vh 1.2vw; }
body.tv .team .name { font-size: clamp(1rem, min(3.2vw, 5.5vh), 3rem); min-height: 0; padding: 0 8px; }
body.tv .score { font-size: max(2.2rem, min(var(--tvnum, 14vw), var(--tvh, 15vh))); }
body.tv .steps button { min-height: max(40px, 6vh); font-size: clamp(.9rem, min(1.6vw, 2.6vh), 1.6rem); }
body.tv .board { min-height: 0; }
body.tv .dock { margin: 0; grid-template-columns: 1.2fr 1fr; }
body.tv .timer { display: grid; grid-template-columns: auto 1fr; gap: 1vw; align-items: center; }
body.tv .timer-face { font-size: clamp(2.6rem, 6vw, 6rem); padding: 0 1vw; grid-row: span 2; }
body.tv .chips { margin: 0; }
body.tv .pad-btn { min-height: max(72px, 11vh); }
body.tv .panel { padding: min(14px, 1.6vh) 14px; }
body.tv .exit-tv { display: inline-flex; }
.exit-tv { display: none; position: fixed; right: 2vw; top: 4px; z-index: 5; opacity: .85; min-height: 44px; border-color: var(--muted); }
.exit-tv:hover, .exit-tv:focus-visible { opacity: 1; }

/* Dialogs */
dialog { border: 0; border-radius: 22px; padding: 20px; background: var(--surface); color: var(--ink); width: min(420px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0,0,0,.5); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h2 { margin: 0 0 12px; font: 800 1.4rem/1.2 var(--display); }
dialog .row { margin: 12px 0 8px; flex-wrap: wrap; }
.amt-lbl { display: block; font-weight: 650; color: var(--muted); margin-bottom: 4px; }
#amountIn { width: 100%; min-height: 56px; padding: 8px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink); font: 800 1.8rem/1 var(--num); }
.keys { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: .95rem; }
.keys td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.keys td:first-child { white-space: nowrap; padding-right: 12px; }

/* Below the fold */
.learn { max-width: 1400px; margin: 40px auto 0; padding: 0 16px; display: grid; gap: 12px 32px; }
@media (min-width: 900px) { .learn { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.learn h2 { font: 800 1.25rem/1.25 var(--display); margin: 0 0 8px; }
.learn p, .learn li { color: var(--muted); }
.learn b { color: var(--ink); }
.learn ol { padding-left: 1.2em; margin: 0 0 8px; }
details { border-bottom: 1px solid var(--line); padding: 8px 0; }
summary { cursor: pointer; font-weight: 650; min-height: 32px; }
.foot { max-width: 1400px; margin: 32px auto 0; padding: 18px 16px 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px; }
.foot p { margin: 0; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 650; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.flash { animation: flash .6s ease-out; }
@keyframes flash { 0% { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--buzz) 35%, transparent); } 100% { box-shadow: inset 0 0 0 9999px transparent; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
