:root {
  --bg: #0e1a2b;
  --bg2: #16263d;
  --panel: #1c3050;
  --line: #2c4468;
  --text: #f3f6fb;
  --muted: #9fb2cc;
  --gold: #f6bd41;
  --low: #1fb5a8;
  --high: #ee6a52;
  --under: #8573e6;
  --good: #4ed38a;
  --bad: #ff7b7b;
  --well: #0b1524;
  --glow: #1d3557;
  --on-gold: #1b1300;
  --slot-bg: var(--bg2);
  /* Betting spots are filled with their side's colour; the lighter shade above caps the card. */
  --low-bg: #0e6f69;
  --high-bg: #b4432f;
  --mid-bg: #86640f;
  --under-bg: #5546ad;
  --slot-fg: var(--text);
  --display: inherit;
  color-scheme: dark;
}

/* ------------------------------------------------------------------ themes
   The host picks the look. Each theme only swaps colours and a few touches. */
html[data-theme="vegas"] {
  --bg: #06251a;
  --bg2: #0a3a27;
  --panel: #0b3f2b;
  --line: #7f6a2c;
  --text: #fbf3dc;
  --muted: #cdbf93;
  --gold: #f4c542;
  --low: #111111;
  --high: #b3162c;
  --under: #12864a;
  --good: #7be495;
  --bad: #ff8d8d;
  --well: #041a12;
  --glow: #17794d;
  --low-bg: #131313;
  --high-bg: #a3152a;
  --mid-bg: #6a5312;
  --under-bg: #0f7a43;
  --display: Georgia, "Times New Roman", serif;
}
html[data-theme="holiday"] {
  --bg: #33070f;
  --bg2: #470d18;
  --panel: #561320;
  --line: #863340;
  --text: #fff6ea;
  --muted: #e6bdb3;
  --gold: #f7cf6a;
  --low: #35b377;
  --high: #f2f6fa;
  --under: #6fb7ea;
  --good: #7fe3a8;
  --bad: #ffc2ad;
  --well: #24040a;
  --glow: #7a1626;
  --low-bg: #17693f;
  --high-bg: #f4f7fa;
  --mid-bg: #a87a12;
  --under-bg: #2c79b3;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, var(--glow) 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--gold); }
[hidden] { display: none !important; }

.brand { font-family: var(--display); font-weight: 900; letter-spacing: -0.02em; line-height: 1; white-space: nowrap; }
.brand .amp { color: var(--gold); padding: 0 0.12em; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.btn {
  border: 0; border-radius: 12px; padding: 14px 20px; font-weight: 800; font-size: 1.05rem;
  background: var(--gold); color: var(--on-gold); width: 100%;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border: 2px solid var(--line); }
.btn.small { width: auto; padding: 8px 14px; font-size: 0.92rem; border-radius: 10px; }
.btn.danger { background: transparent; color: var(--bad); border: 2px solid #6b3340; }
.field {
  width: 100%; border-radius: 12px; border: 2px solid var(--line); background: var(--well); color: var(--text);
  padding: 14px 16px; font-size: 1.15rem;
}
.field:focus { outline: none; border-color: var(--gold); }
label.lbl { display: block; font-size: 0.85rem; color: var(--muted); font-weight: 700; margin: 0 0 6px 2px; text-transform: uppercase; letter-spacing: 0.06em; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: #40121a; color: #ffd9de; border: 1px solid #a5404f; padding: 12px 18px; border-radius: 12px;
  font-weight: 700; max-width: 92vw; text-align: center; transition: 0.2s; z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.offline { position: fixed; top: 0; left: 0; right: 0; background: #7a2732; color: #fff; text-align: center; font-weight: 700; padding: 6px; z-index: 40; font-size: 0.9rem; }

[data-countdown] { font-variant-numeric: tabular-nums; font-weight: 900; }
[data-countdown].low { color: var(--bad); }
[data-countdown].up { color: var(--bad); }

/* ------------------------------------------------------------ board of guesses */
.board { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 0.7em; }
.board.sides { margin-top: 0.7em; }
.slot {
  position: relative; background: var(--slot-bg); border: 2px solid var(--line); border-top: 0.5em solid var(--muted);
  border-radius: 0.8em; padding: 0.6em 0.5em 0.7em; text-align: center; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 0.25em; transition: opacity 0.4s, transform 0.4s;
  container-type: inline-size;
}
.slot, .spot { color: var(--slot-fg); --slot-sub: color-mix(in srgb, var(--slot-fg) 82%, transparent); }
.side-low { --slot-bg: var(--low-bg); }
.side-high { --slot-bg: var(--high-bg); }
.side-mid { --slot-bg: var(--mid-bg); }
.slot.under, .spot.under { --slot-bg: var(--under-bg); }
.slot.side-low { border-top-color: var(--low); }
.slot.side-high { border-top-color: var(--high); }
.slot.side-mid { border-top-color: var(--gold); }
.slot.under { border-top-color: var(--under); }
.slot .odds { font-weight: 900; font-size: 0.8em; color: var(--slot-sub); letter-spacing: 0.04em; }
/* Long numbers shrink to stay on one line: --ch is the number of characters. */
.slot .val { font-weight: 900; font-size: min(1.7em, calc(96cqi / (var(--ch, 4) * 0.6))); line-height: 1.05; white-space: nowrap; }
.slot .val.small { white-space: normal; }
.slot .val.small { font-size: 1.05em; }
.slot .who { font-size: 0.72em; color: var(--slot-sub); font-weight: 600; overflow-wrap: anywhere; }
.slot .chips { display: flex; flex-wrap: wrap; gap: 0.25em; justify-content: center; margin-top: 0.2em; }
.chip { background: var(--well); color: var(--text); border: 1px solid var(--line); border-radius: 99px; padding: 0.1em 0.6em; font-size: 0.62em; white-space: nowrap; }
.chip b { color: var(--gold); }
.slot.win { border-color: var(--gold); box-shadow: 0 0 0 0.25em rgba(246, 189, 65, 0.6), 0 0 2.6em rgba(246, 189, 65, 0.6); }
.slot.lose { opacity: 0.42; }
/* The tag on the winning guess: who won it and the bonus they earn. */
.win-tag {
  position: absolute; top: -1.15em; left: 50%; transform: translateX(-50%); white-space: nowrap; z-index: 2;
  background: var(--gold); color: var(--on-gold); font-weight: 900; font-size: 0.72em; letter-spacing: 0.04em;
  padding: 0.15em 0.8em; border-radius: 99px; box-shadow: 0 0.15em 0.6em rgba(0, 0, 0, 0.45);
}

/* ---------------------------------------------------------------- phone page */
.phone { max-width: 520px; margin: 0 auto; padding: 16px 16px 40px; }
.phone header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.phone header .brand { font-size: 1.15rem; }
.me-pill { background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 6px 14px; font-weight: 700; font-size: 0.95rem; max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-pill b { color: var(--gold); margin-left: 6px; }
.hero { text-align: center; padding: 26px 0 8px; }
.hero .brand { font-size: 2.5rem; }
.hero p { color: var(--muted); margin-top: 10px; }
.round-tag { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-weight: 800; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; }
.round-tag [data-countdown] { font-size: 1.5rem; color: var(--gold); }
.question { font-size: 1.3rem; font-weight: 700; }
.big-num { font-size: 2.6rem; font-weight: 900; color: var(--gold); line-height: 1.1; overflow-wrap: anywhere; }
.center { text-align: center; }
.result-net { font-size: 3rem; font-weight: 900; line-height: 1; }
.lines { font-size: 0.98rem; }
.lines div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.lines div:first-child { border-top: 0; }
.rank-list { list-style: none; padding: 0; margin: 0; }
.rank-list li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.rank-list li:first-child { border-top: 0; }
.rank-list .pl { width: 1.8em; color: var(--muted); font-weight: 800; }
.rank-list .nm { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .sc { font-weight: 900; font-variant-numeric: tabular-nums; }
.rank-list li.me .nm { color: var(--gold); }

.chips-left { display: flex; align-items: baseline; gap: 8px; justify-content: center; color: var(--muted); font-weight: 700; }
.chips-left b { font-size: 2rem; color: var(--gold); }
.steps { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--muted); font-size: 0.9rem; margin-top: 8px; }
.steps button { border: 2px solid var(--line); background: transparent; border-radius: 10px; padding: 6px 14px; font-weight: 800; }
.steps button.on { border-color: var(--gold); color: var(--gold); }
.spots { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 12px; }
.spot { display: flex; align-items: center; gap: 10px; background: var(--slot-bg); border: 2px solid var(--line); border-left: 8px solid var(--muted); border-radius: 12px; padding: 8px 8px 8px 10px; }
.spot.side-low { border-left-color: var(--low); }
.spot.side-high { border-left-color: var(--high); }
.spot.side-mid { border-left-color: var(--gold); }
.spot.under { border-left-color: var(--under); }
.spot.has { border-color: var(--gold); border-left-width: 8px; }
.spot-odds { font-weight: 900; color: var(--slot-sub); width: 2.4em; font-size: 0.95rem; }
.spot-main { flex: 1; min-width: 0; }
.spot-title { font-weight: 900; font-size: 1.25rem; line-height: 1.1; overflow-wrap: anywhere; }
.spot.side .spot-title, .spot.under .spot-title { font-size: 1.05rem; }
.spot-sub { color: var(--slot-sub); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spot-amt { width: 2.2em; text-align: center; font-weight: 900; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.pm { color: var(--text); width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: var(--well); font-size: 1.5rem; font-weight: 800; line-height: 1; flex: none; }
.pm:disabled { opacity: 0.3; }
.sticky-bar { position: sticky; bottom: 0; padding: 12px 0 4px; background: linear-gradient(transparent, var(--bg) 35%); }

/* ---------------------------------------------------------------- big screen */
.screen { height: 100vh; overflow: hidden; display: flex; flex-direction: column; padding: 2.2vh 2.4vw; font-size: clamp(11px, min(1.55vw, 2.75vh), 40px); }
.screen .top { display: flex; justify-content: space-between; align-items: center; gap: 2vw; }
.screen .top .brand { font-size: 1.5em; }
.screen .top .join { color: var(--muted); font-weight: 700; font-size: 0.9em; }
.screen .top .join b { color: var(--gold); letter-spacing: 0.12em; font-size: 1.25em; margin-left: 0.3em; }
.screen #stage { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; margin: 1.5vh 0; overflow: hidden; }
#fitbox { display: flex; flex-direction: column; }
.screen .teams-strip { display: flex; flex-wrap: wrap; gap: 0.5em; justify-content: center; min-height: 2.2em; }
.tchip { background: var(--panel); border: 2px solid var(--line); border-radius: 99px; padding: 0.22em 0.9em; font-weight: 700; font-size: 0.8em; display: flex; gap: 0.5em; align-items: center; }
.tchip.done { border-color: var(--good); }
.tchip.done::before { content: "\2713"; color: var(--good); font-weight: 900; }
.tchip.off { opacity: 0.5; }
.tchip b { color: var(--gold); }

.lobby { display: grid; grid-template-columns: 1.15fr 1fr; gap: 4vw; align-items: center; }
.lobby .brand { font-size: 4.2em; white-space: normal; }
.lobby .how { font-size: 1.25em; color: var(--muted); margin-top: 0.8em; }
.lobby .how b { color: var(--text); }
.lobby .code { font-size: 5.5em; font-weight: 900; letter-spacing: 0.14em; color: var(--gold); line-height: 1; margin-top: 0.15em; }
.lobby .qr { background: #fff; border-radius: 1em; padding: 0.8em; width: min(38vh, 26vw); margin: 0 auto; }
.lobby .qr svg { display: block; width: 100%; height: auto; }
.lobby .joined { text-align: center; color: var(--muted); font-weight: 700; margin-top: 1em; }

.stage-head { display: flex; justify-content: space-between; align-items: center; gap: 2vw; margin-bottom: 1.2vh; }
.stage-head .tag { color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.85em; }
.stage-head [data-countdown] { font-size: 2.6em; color: var(--gold); line-height: 1; min-width: 2.2em; text-align: right; }
.q-big { font-size: 2.5em; font-weight: 800; line-height: 1.18; text-align: center; margin: auto 4vw; text-wrap: balance; }
.q-small { font-size: 1.15em; font-weight: 700; text-align: center; margin: 0 2vw 1.6vh; text-wrap: balance; }
.prompt { text-align: center; color: var(--gold); font-weight: 800; margin-top: 1.6vh; font-size: 1.05em; }
.screen .board { font-size: 1em; }

.reveal { display: grid; grid-template-columns: minmax(0, 2.5fr) minmax(0, 1fr); gap: 2vw; align-items: start; min-height: 0; }
.answer-banner { text-align: center; margin-bottom: 1.6vh; }
.answer-banner .lab { color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.8em; }
.answer-banner .num { font-size: 3.6em; font-weight: 900; color: var(--gold); line-height: 1.05; }
.answer-banner .note { color: var(--muted); font-size: 0.85em; }
.leader { background: var(--panel); border: 1px solid var(--line); border-radius: 0.9em; padding: 0.7em 0.9em; font-size: 0.85em; max-height: 100%; overflow: hidden; }
.leader h3 { font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 0.3em; }
.leader .rank-list li { padding: 0.28em 0; }
.leader .delta { width: 3.2em; text-align: right; font-weight: 800; font-size: 0.9em; }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.reveal .answer-banner .num { animation: pop 0.5s 0.9s both cubic-bezier(0.2, 1.6, 0.4, 1); }
.reveal .answer-banner .note { animation: fade 0.5s 1.5s both; }
.reveal .slot.win { animation: winglow 0.6s 2s both; }
.reveal .slot.lose { animation: dim 0.6s 2s both; }
.reveal .slot .chips { animation: fade 0.5s 2.8s both; }
.reveal .leader { animation: fade 0.6s 3.6s both; }
@keyframes winglow { from { border-color: var(--line); box-shadow: none; } }
@keyframes dim { from { opacity: 1; } to { opacity: 0.42; } }
.reveal .win-tag { animation: fade 0.4s 2.2s both; }
.win-line { text-align: center; font-weight: 800; font-size: 1.15em; margin: 0 0 2.6vh; animation: fade 0.5s 2.2s both; }
.win-line .star { color: var(--gold); }
.win-line b { color: var(--gold); }
.win-line .bonus { display: inline-block; background: var(--gold); color: var(--on-gold); border-radius: 99px; padding: 0.05em 0.7em; margin-left: 0.4em; font-weight: 900; }
.rank-list li.won .nm { color: var(--gold); }
.rank-list li.won .nm::after { content: " \2605"; }

.final { text-align: center; }
.final .lab { color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.14em; }
.final .winner { font-size: 4.2em; font-weight: 900; color: var(--gold); line-height: 1.1; margin: 0.1em 0 0.3em; overflow-wrap: anywhere; }
.final .rank-list { max-width: 26em; margin: 0 auto; text-align: left; font-size: 1.05em; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.ctl { position: fixed; right: 12px; bottom: 12px; opacity: 0.25; z-index: 20; }
.ctl:hover { opacity: 1; }

/* ----------------------------------------------------------------- host page */
.hostpage { max-width: 1060px; margin: 0 auto; padding: 16px 16px 60px; }
.hostpage header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.hostpage header .brand { font-size: 1.4rem; }
.codebox { font-weight: 800; color: var(--muted); }
.codebox b { color: var(--gold); letter-spacing: 0.12em; font-size: 1.3rem; margin-left: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }
.card h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 12px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; }
.opt input[type="number"], .opt select { width: 120px; border-radius: 10px; border: 2px solid var(--line); background: var(--well); padding: 8px 10px; }
.opt input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--gold); }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 8px 16px; font-weight: 800; }
.seg button.on { background: var(--gold); color: var(--on-gold); }
.host-q { font-size: 1.35rem; font-weight: 700; }
.host-a { font-size: 1.1rem; margin-top: 8px; }
.host-a b { color: var(--gold); font-size: 1.4rem; }
.host-timer { font-size: 2rem; color: var(--gold); min-width: 3em; }
table.tt { width: 100%; border-collapse: collapse; }
table.tt th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 6px 8px; }
table.tt td { padding: 9px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
table.tt td.num, table.tt th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #55657e; margin-right: 8px; }
.dot.on { background: var(--good); }
.linkbtn { background: none; border: 0; color: var(--gold); padding: 2px 4px; font-weight: 700; text-decoration: underline; font-size: 0.9rem; }
.qlist { max-height: 320px; overflow: auto; font-size: 0.92rem; }
.qlist div { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border-top: 1px solid var(--line); }
.qlist b { color: var(--gold); white-space: nowrap; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(640px, 94vw); max-height: 92vh; }
dialog::backdrop { background: rgba(4, 9, 18, 0.75); }
dialog h3 { margin-bottom: 12px; }
textarea.field { min-height: 220px; font-size: 0.95rem; font-family: ui-monospace, Consolas, monospace; }
.hostpage .board { font-size: 0.8rem; }

/* -------------------------------------------------------------- Vegas touches
   Felt table, roulette colours on the betting spots, marquee lights, poker chips. */
html[data-theme="vegas"] body {
  background: radial-gradient(1300px 800px at 50% -10%, var(--glow) 0%, var(--bg) 62%, #03160f 100%) fixed, var(--bg);
}
html[data-theme="vegas"] .slot, html[data-theme="vegas"] .spot { border-color: #a88a35; }
html[data-theme="vegas"] .slot { border-top-color: var(--gold); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35); }
html[data-theme="vegas"] .spot { border-left-color: var(--gold); }
html[data-theme="vegas"] .final .winner { font-family: var(--display); }
html[data-theme="vegas"] .chip { background: #fbf3dc; color: #1a1a1a; border: 0.16em dashed #b3162c; font-weight: 700; }
html[data-theme="vegas"] .chip b { color: #b3162c; }
html[data-theme="vegas"] .screen .brand, html[data-theme="vegas"] .hero .brand {
  text-shadow: 0 0 0.35em rgba(244, 197, 66, 0.55);
}
html[data-theme="vegas"] .lobby .code { text-shadow: 0 0 0.3em rgba(244, 197, 66, 0.6); }
html[data-theme="vegas"] .screen::before, html[data-theme="vegas"] .screen::after {
  content: ""; position: fixed; left: 0; right: 0; height: 0.9vh; z-index: 3; pointer-events: none;
  background: radial-gradient(circle, #ffe9a3 0 28%, #f4c542 30% 42%, transparent 46%) 0 50% / 2.6vh 0.9vh repeat-x;
  filter: drop-shadow(0 0 0.5vh rgba(244, 197, 66, 0.9));
  animation: bulbs 1.2s steps(2) infinite;
}
html[data-theme="vegas"] .screen::before { top: 0.5vh; }
html[data-theme="vegas"] .screen::after { bottom: 0.5vh; animation-delay: 0.6s; }
@keyframes bulbs { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { html[data-theme="vegas"] .screen::before, html[data-theme="vegas"] .screen::after { animation: none; } }

/* ------------------------------------------------------------ Holiday touches */
html[data-theme="holiday"] .side-high { --slot-fg: #3d0a13; }
html[data-theme="holiday"] .slot { border-color: rgba(255, 255, 255, 0.45); border-top-color: #ffffff; }
html[data-theme="holiday"] .spot { border-color: rgba(255, 255, 255, 0.45); border-left-color: #ffffff; }
html[data-theme="holiday"] .slot.win { border-color: var(--gold); }
html[data-theme="holiday"] .chip { background: #b01b2e; color: #fff; border: 0.14em solid #f7cf6a; font-weight: 700; }
html[data-theme="holiday"] .chip b { color: #ffe9a8; }
html[data-theme="holiday"] .brand, html[data-theme="holiday"] .final .winner { font-family: Georgia, "Times New Roman", serif; }
html[data-theme="holiday"] .screen .brand, html[data-theme="holiday"] .hero .brand { text-shadow: 0 0.06em 0 rgba(0, 0, 0, 0.35); }
/* A string of coloured lights across the top of the big screen, and falling snow behind the cards. */
html[data-theme="holiday"] .screen::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 2vh; z-index: 3; pointer-events: none;
  background:
    radial-gradient(ellipse 0.55vh 0.8vh at 1.5vh 1vh, #ff5a5a 0 90%, transparent 100%),
    radial-gradient(ellipse 0.55vh 0.8vh at 4.5vh 1.15vh, #ffd75e 0 90%, transparent 100%),
    radial-gradient(ellipse 0.55vh 0.8vh at 7.5vh 1vh, #5fd08a 0 90%, transparent 100%),
    radial-gradient(ellipse 0.55vh 0.8vh at 10.5vh 1.15vh, #6fb7ea 0 90%, transparent 100%),
    linear-gradient(#1c3b2a, #1c3b2a) 0 0.2vh / 100% 0.18vh no-repeat;
  background-size: 12vh 2vh, 12vh 2vh, 12vh 2vh, 12vh 2vh, 100% 0.18vh;
  filter: drop-shadow(0 0 0.6vh rgba(255, 235, 170, 0.75));
  animation: twinkle 1.6s steps(2) infinite;
}
@keyframes twinkle { 50% { filter: drop-shadow(0 0 0.2vh rgba(255, 235, 170, 0.35)) brightness(0.8); } }
html[data-theme="holiday"] .screen::after {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.75;
  background-image:
    radial-gradient(circle at 40px 60px, #fff 0 2.5px, transparent 3.5px),
    radial-gradient(circle at 170px 20px, #fff 0 1.8px, transparent 2.8px),
    radial-gradient(circle at 90px 210px, #fff 0 3px, transparent 4px),
    radial-gradient(circle at 250px 130px, rgba(255, 255, 255, 0.7) 0 2px, transparent 3px);
  background-size: 220px 220px, 300px 300px, 380px 380px, 330px 330px;
  animation: snow 22s linear infinite;
}
@keyframes snow { to { background-position: 60px 440px, -40px 600px, 30px 760px, -60px 660px; } }
html[data-theme="holiday"] .screen > * { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { html[data-theme="holiday"] .screen::before, html[data-theme="holiday"] .screen::after { animation: none; } }
html[data-theme="holiday"] .screen .brand .amp, html[data-theme="holiday"] .hero .brand .amp { color: var(--low); }

.after { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
/* Big games: the score lists run in columns so every team stays readable. */
.reveal.many { display: block; }
.reveal.many .leader { margin-top: 1.2vh; font-size: 0.8em; }
.rank-list.cols4 { columns: 4; column-gap: 1.6em; }
.rank-list.cols5 { columns: 5; column-gap: 1.6em; }
.rank-list.cols4 li, .rank-list.cols5 li { break-inside: avoid; }
.rank-list.cols4 li:first-child, .rank-list.cols5 li:first-child { border-top: 1px solid transparent; }
.rank-list.cols2 { columns: 2; column-gap: 1.6em; }
.rank-list.cols3 { columns: 3; column-gap: 1.6em; }
.rank-list.cols2 li, .rank-list.cols3 li { break-inside: avoid; }
.rank-list.cols2 li:first-child, .rank-list.cols3 li:first-child { border-top: 1px solid transparent; }
.final .rank-list.cols2 { max-width: 46em; }
.final .rank-list.cols3 { max-width: 64em; font-size: 0.9em; }
.final.many .winner { font-size: 3.2em; }
.final .after { margin-top: 1.2em; position: relative; z-index: 10; }
.final .after .btn { width: auto; font-size: 0.6em; padding: 0.6em 1.2em; }
.final .hint { color: var(--muted); font-size: 0.7em; margin-top: 1em; }
/* Snow must not show through the cards that lost, so they darken instead of fading. */
html[data-theme="holiday"] .screen .slot.lose { opacity: 1; filter: brightness(0.45) saturate(0.7); }
html[data-theme="holiday"] .reveal .slot.lose { animation: dimdark 0.6s 2s both; }
@keyframes dimdark { from { filter: none; } }

/* ------------------------------------------------------------- team pictures
   A round badge: the photo or GIF, an emoji, or the first letter of the name. */
.av {
  position: relative; display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; flex: none;
  border-radius: 50%; overflow: hidden; vertical-align: middle; line-height: 1; font-weight: 900; color: #fff;
  background: hsl(var(--h, 210) 48% 34%); box-shadow: 0 0 0 0.09em rgba(255, 255, 255, 0.55);
}
.av .ini { font-size: 0.8em; }
.av .em { font-size: 1.02em; }
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.av:has(img) .ini, .av:has(.em) .ini { display: none; }
.av:has(.em) { background: var(--well); }
.av.gap { margin-right: 0.5em; }
.av.xl { width: 5.2rem; height: 5.2rem; font-size: 3.1rem; box-shadow: 0 0 0 3px var(--gold); }
.av.xl .ini, .av.xl .em { font-size: 1em; }

.me-pill { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.me-pill span:not(.av):not(.ini):not(.em) { overflow: hidden; text-overflow: ellipsis; }
.me-pill b { margin-left: 0; }
.me-pill:has(.av) { padding-left: 6px; }
.avbtn { background: none; border: 0; padding: 0; border-radius: 50%; display: block; margin: 12px auto 0; }
.rank-list .av { width: 1.5em; height: 1.5em; }
.tchip:has(.av) { padding-left: 0.3em; }
.teams-strip.in-lobby.few { font-size: 1.35em; }
.slot .who { display: flex; flex-direction: column; align-items: center; gap: 0.2em; max-width: 100%; }
.slot .who .wl { display: flex; align-items: center; gap: 0.35em; max-width: 100%; min-width: 0; }
.board.roomy .who .wl { flex-direction: column; gap: 0.25em; }
.board.roomy .who { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 0.5em 0.9em; }
.board.roomy .who .av { width: 3em; height: 3em; font-size: 1.25em; }
.board.roomy .who .av .ini, .board.roomy .who .av .em { font-size: 1.5em; }
.chip:has(.av) { padding-left: 0.2em; display: inline-flex; align-items: center; gap: 0.3em; }
.chip .av { width: 1.5em; height: 1.5em; box-shadow: none; }
.win-line .av { margin: 0 0.3em 0 0.15em; font-weight: 900; }
.winner-av { display: flex; justify-content: center; gap: 0.6em; margin-top: 0.3em; }
.winner-av .av { width: 3.4em; height: 3.4em; font-size: 2em; box-shadow: 0 0 0 0.09em var(--gold), 0 0 1em rgba(246, 189, 65, 0.6); }
.winner-av .av .ini, .winner-av .av .em { font-size: 1.5em; }
.final.many .winner-av .av { width: 2.6em; height: 2.6em; }
.hostpage .board.roomy .who .av { width: 2.2em; height: 2.2em; }

/* The window where a picture is chosen */
dialog.avdlg { overflow: auto; }
dialog.avdlg.busy { opacity: 0.6; pointer-events: none; }
.avhead { display: flex; align-items: center; gap: 14px; }
.avhead > div { flex: 1; min-width: 0; }
.avhead h3 { margin: 0; }
.avhead .av.xl { width: 4rem; height: 4rem; font-size: 2.4rem; }
.avbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.avbtns .btn { width: 100%; padding: 12px 10px; }
.avnote { font-size: 0.85rem; margin-top: 8px; }
dialog.avdlg h4 { margin: 18px 0 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.avgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 8px; }
.avgrid button { position: relative; aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--line); background: var(--well); padding: 0; overflow: hidden; font-size: 1.9rem; line-height: 1; }
.avgrid button:hover, .avgrid button:focus-visible { border-color: var(--gold); outline: none; }
.avgrid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avgrid i { position: absolute; left: 50%; bottom: 3px; transform: translateX(-50%); font-style: normal; font-size: 0.55rem; font-weight: 900; letter-spacing: 0.06em; background: rgba(0, 0, 0, 0.7); color: #fff; padding: 1px 5px; border-radius: 99px; }
.avgrid.emoji { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
.camview { border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 1; max-width: 420px; margin: 0 auto; }
.camview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }

/* /avatars: the list of pictures teams can pick from */
.drop { border: 2px dashed var(--line); border-radius: 16px; padding: 26px 16px; text-align: center; }
.drop.over { border-color: var(--gold); background: var(--well); }
.libgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px; }
.libitem { text-align: center; font-size: 0.8rem; }
.libitem .pic { position: relative; aspect-ratio: 1; border-radius: 50%; overflow: hidden; border: 2px solid var(--line); background: var(--well); }
.libitem img { width: 100%; height: 100%; object-fit: cover; display: block; }
.libitem .nm { margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.teams-strip.in-lobby .av { width: 2em; height: 2em; }

/* The list of every team on the phone, and a team picture shown large */
.teamsbox { margin-top: 16px; padding-bottom: 10px; }
.teamsbox .rank-list .av { width: 2.1em; height: 2.1em; cursor: pointer; }
.teamsbox .tick { color: var(--good); font-weight: 900; width: 1.4em; text-align: center; }
.teamsbox .tick.wait { color: var(--muted); }
.teamsbox .delta { font-weight: 800; font-size: 0.9em; }
.teamsbox .sc { min-width: 1.6em; text-align: right; color: var(--gold); }
.teamsbox .hint { font-size: 0.8rem; text-align: center; margin-top: 6px; }
.phone .rank-list .av, .hostpage table.tt .av { cursor: pointer; }
dialog.avview { text-align: center; width: fit-content; max-width: 94vw; cursor: pointer; }
dialog.avview h3 { margin: 14px 0; font-size: 1.4rem; }
dialog.avview .btn { display: block; margin: 0 auto; }
.av.huge { width: min(74vw, 60vh, 420px); height: min(74vw, 60vh, 420px); font-size: min(40vw, 32vh, 220px); box-shadow: 0 0 0 4px var(--gold); }
.av.huge .ini, .av.huge .em { font-size: 1em; }

/* Big screen: the count of who is in, and the notice when everybody is */
.teams-strip .tally { flex: 0 0 100%; text-align: center; color: var(--muted); font-weight: 800; font-size: 0.85em; }
.teams-strip .tally b { color: var(--text); }
.teams-strip .tally.all { color: var(--good); font-size: 1.35em; font-weight: 900; animation: tallypop 0.5s ease-out; }
@keyframes tallypop { from { transform: scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }
.ctl.ready { opacity: 1; font-size: 1.05rem; padding: 14px 20px; box-shadow: 0 0 0 0 rgba(246, 189, 65, 0.7); animation: ctlpulse 1.6s infinite; }
@keyframes ctlpulse { 70% { box-shadow: 0 0 0 16px rgba(246, 189, 65, 0); } 100% { box-shadow: 0 0 0 0 rgba(246, 189, 65, 0); } }
.screen .av[data-team] { cursor: pointer; }
body:has(.screen) .av.huge { width: min(70vw, 62vh); height: min(70vw, 62vh); font-size: min(38vw, 34vh); }
body:has(.screen) dialog.avview h3 { font-size: 2.2rem; }

/* Picking a picture: search box and categories */
.avsearch { margin-top: 16px; }
.avcats { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0 2px; }
.avcats.sub { padding-bottom: 10px; }
.avcats:empty { display: none; }
.avcats button { flex: none; border: 2px solid var(--line); background: transparent; color: var(--text); border-radius: 99px; padding: 6px 14px; font-weight: 800; font-size: 0.9rem; white-space: nowrap; }
.avcats button.on { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.avcats.sub button { font-size: 0.8rem; padding: 4px 12px; }
dialog.avdlg h5 { margin: 12px 0 6px; font-size: 0.85rem; color: var(--text); }
dialog.avdlg h5:empty { display: none; }
dialog.avdlg.picker { min-height: min(80vh, 560px); }

/* /avatars: categories, search and picking several at once */
.libtools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }
.libtools .field { flex: 1 1 200px; width: auto; margin: 0; }
.libtools select.field { flex: 0 1 220px; color-scheme: dark; }
.libpair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.selbar { position: sticky; top: 8px; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--well); border: 2px solid var(--gold); border-radius: 12px; padding: 8px 14px; margin-bottom: 12px; font-weight: 800; }
.selbar .btn { width: auto; }
.libhead { margin: 20px 0 10px; font-size: 1rem; }
.libhead span { color: var(--muted); font-weight: 600; }
.libitem .pic { display: block; cursor: pointer; }
.libitem .pic input { position: absolute; left: 8%; top: 8%; width: 20px; height: 20px; z-index: 1; accent-color: var(--gold); }
.libitem.sel .pic { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold); }
.emojishow { display: flex; flex-wrap: wrap; gap: 8px; }
.emojishow span { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--line); background: var(--well); display: grid; place-items: center; font-size: 1.7rem; line-height: 1; }
dialog.libdlg { width: min(460px, 94vw); }
dialog.libdlg .row { margin-top: 16px; justify-content: flex-end; gap: 10px; }
/* Room for the lit-up Next button, so it does not cover the last teams */
body:has(.ctl.ready) .screen { padding-bottom: 72px; }
/* Large view of a picture before choosing it */
.avview-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
dialog.avview .avview-btns .btn { margin: 0; width: auto; min-width: 130px; }
.libitem .pic img, .emojishow span { cursor: zoom-in; }
.libitem .pic input { cursor: pointer; }
/* GIF search */
.gifform { display: flex; gap: 8px; margin-top: 12px; }
.gifform .field { flex: 1; width: auto; min-width: 0; margin: 0; }
.gifform .btn { width: auto; }
.gifnote { font-size: 0.85rem; margin: 8px 0; min-height: 1.2em; }
.gifby { font-size: 0.75rem; text-align: right; margin-top: 8px; }
.avgrid.gifs { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.avgrid.gifs button { border-radius: 14px; }
#gifbox .avgrid.gifs { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
/* GIFs: a square frame, and the whole picture in the large view, so words near the edges stay readable */
.av.sq { border-radius: 18%; }
.av.huge.sq { border-radius: 16px; background: #0b1220; }
.av.huge.sq img { object-fit: contain; }
.avgrid button.sq, .libitem .pic.sq { border-radius: 16%; }
/* The people on a team */
.mem { display: block; font-size: 0.72em; font-weight: 600; color: var(--muted); white-space: normal; line-height: 1.25; margin-top: 1px; }
.rank-list li.me .nm .mem, .rank-list li.won .nm .mem { color: var(--muted); }
dialog.avview h3 .mem { font-size: 0.7em; margin-top: 6px; }
.lobbymem { color: var(--text); font-weight: 600; margin: 4px 0 8px; }
table.tt .tn { display: inline-block; vertical-align: middle; }
dialog.teamdlg { width: min(460px, 94vw); }
/* Host: the code that puts a team back on a phone */
dialog.linkdlg .qr { background: #fff; border-radius: 14px; padding: 14px; width: min(260px, 70vw); margin: 14px auto; }
dialog.linkdlg .qr svg { display: block; width: 100%; height: auto; }
/* A picture shown with the answer */
.answer-banner.haspic { display: flex; justify-content: center; align-items: center; gap: 1.6em; text-align: left; }
.apic { height: 7.5em; max-width: 42%; object-fit: contain; border-radius: 0.5em; cursor: zoom-in; animation: fade 0.5s 1.2s both; }
.reveal.many .apic { height: 5.5em; }
.apic-phone { display: block; max-width: 100%; max-height: 38vh; margin: 10px auto; border-radius: 12px; }
.qthumb { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; vertical-align: middle; cursor: zoom-in; }
.qthumb.big { width: 96px; height: 72px; cursor: default; }

/* /questions */
table.qtable { width: 100%; }
table.qtable td { vertical-align: middle; }
table.qtable tr.qgroup td { padding-top: 18px; font-weight: 800; color: var(--gold); border-bottom: 2px solid var(--line); }
table.qtable tr.sel td { background: rgba(246, 189, 65, 0.08); }
table.qtable input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--gold); }
.qtext { width: 100%; }
.star { background: none; border: 0; font-size: 1.3rem; line-height: 1; color: var(--muted); padding: 2px 4px; }
.star.on { color: var(--gold); }
.favonly { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.favonly input { width: 18px; height: 18px; accent-color: var(--gold); }
.pcode { font-size: 1.3rem; letter-spacing: 0.15em; color: var(--gold); }
dialog.teamdlg.wide { width: min(680px, 94vw); }
textarea.field.qarea { min-height: 84px; font-family: inherit; font-size: 1rem; }
.pqs { max-height: 44vh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.pq { display: flex; align-items: center; gap: 8px; padding: 6px; border-bottom: 1px solid var(--line); }
.pq:last-child { border-bottom: 0; }
.pq .pn { width: 1.6em; text-align: right; color: var(--muted); font-weight: 800; }
.pq .pt { flex: 1; font-size: 0.92rem; }
.pq .pt b { color: var(--gold); margin-left: 6px; }
.pq button { background: var(--well); border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 30px; height: 30px; }
.pq button:disabled { opacity: 0.3; }
.presetbtn { display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 8px; text-align: left; }
.presetbtn b { letter-spacing: 0.15em; color: var(--gold); font-size: 1.1rem; }
.presetbtn span { font-weight: 600; }
