:root {
  --ink: #f8fafc;
  --muted: #b8c3e6;
  --bg-1: #0b1230;
  --bg-2: #070b20;
  --glow: #24317d;
  --card: #16214f;
  --card-2: #1d2a63;
  --line: #2d3b80;
  --brand: #f59e0b;
  --brand-dark: #b45309;
  --play: #16a34a;
  --play-dark: #166534;
  --good: #22c55e;
  --bad: #ef4444;
  --red: #ef4444;
  --blue: #3b82f6;
  --green: #22c55e;
  --yellow: #eab308;
  --a0: #e11d48; --a1: #2563eb; --a2: #d97706; --a3: #16a34a;
  --radius: 22px;
  --font: 'Fredoka', ui-rounded, 'SF Pro Rounded', 'Segoe UI', system-ui, sans-serif;
  --emoji: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html { background: var(--bg-2); }
html, body {
  margin: 0; min-height: 100%;
  font-family: var(--font); color: var(--ink);
  background: radial-gradient(1200px 640px at 50% -12%, var(--glow), transparent 70%), linear-gradient(180deg, var(--bg-1), var(--bg-2)) fixed;
  background-color: var(--bg-1);
  -webkit-tap-highlight-color: transparent;
}
body { overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
[hidden] { display: none !important; }
kbd { font: 600 .85em var(--font); background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.3); border-bottom-width: 3px; border-radius: 6px; padding: 0 6px; }

.screen { display: none; }
.screen.active { display: block; }

/* ---------- Home & results ---------- */
#home, #results {
  min-height: 100dvh;
  padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) calc(24px + var(--safe-b)) calc(16px + var(--safe-l));
}
.inner { max-width: 860px; margin: 0 auto; display: grid; gap: 16px; }
.back { color: #fff; font-weight: 600; text-decoration: none; justify-self: start; padding: 6px 2px; }
.brand { text-align: center; }
.brand .logo { font-size: clamp(44px, 11vw, 70px); line-height: 1.1; font-family: var(--emoji); filter: drop-shadow(0 6px 18px rgba(245,158,11,.45)); }
.brand h1 { margin: 2px 0 0; font-size: clamp(36px, 9vw, 60px); letter-spacing: .5px;
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--green), var(--blue)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand p { margin: 4px 0 0; font-size: clamp(16px, 4vw, 20px); font-weight: 500; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: 0 12px 30px rgba(0,0,0,.35); }
.card h2 { margin: 0 0 12px; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.step { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #1c1305; font-size: 16px; flex: none; }

.years { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 640px) { .years { grid-template-columns: repeat(6, 1fr); } }
.year { border: 3px solid var(--line); background: var(--card-2); border-radius: 18px; min-height: 76px; display: grid; place-content: center; padding: 6px; }
.year b { font-size: 28px; line-height: 1; }
.year small { color: var(--muted); font-size: 13px; }
.year[aria-checked="true"] { border-color: var(--brand); background: #3a2b10; box-shadow: 0 0 0 3px rgba(245,158,11,.25); }

.dskp { margin-top: 12px; background: var(--card-2); border-radius: 14px; padding: 10px 12px; }
.dskp summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.dskp ul { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.dskp li { display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: 8px; font-size: 14px; line-height: 1.35; }
.dskp .code { font-weight: 700; color: var(--brand); }
.dskp .note { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

.option { display: grid; gap: 6px; margin-bottom: 12px; }
.option:last-child { margin-bottom: 0; }
.option-label { font-weight: 600; color: var(--muted); font-size: 14px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; min-height: 44px; padding: 8px 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--card-2); font-weight: 500; font-size: 15px; }
.seg button[aria-pressed="true"] { border-color: var(--brand); background: #3a2b10; font-weight: 600; }
.level-seg button { min-height: 56px; font-size: 17px; }
.mode-seg { margin-bottom: 12px; }
.mode-seg button { display: grid; gap: 2px; min-height: 72px; flex-basis: 220px; }
.mode-seg b { font-size: 18px; }
.mode-seg small { color: var(--muted); font-size: 13px; }
.level-note { margin: 8px 0 0; font-size: 14px; color: var(--muted); line-height: 1.35; }
.tip { margin: 4px 0 0; font-size: 14px; color: var(--muted); line-height: 1.45; }

.stepper { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stepper input { width: 84px; min-height: 44px; border-radius: 12px; border: 2px solid var(--line); background: var(--card-2); color: var(--ink); font-size: 20px; font-weight: 700; text-align: center; }
.stepper .btn-small { min-width: 48px; font-size: 20px; }
.stepper #secReset { font-size: 15px; }

.team-edit { display: grid; gap: 8px; margin-bottom: 10px; }
.team-row { display: flex; align-items: center; gap: 8px; background: var(--card-2); border-radius: 16px; padding: 6px 8px; border-left: 8px solid var(--tc); }
.swatch { width: 14px; height: 14px; border-radius: 50%; background: var(--tc); flex: none; }
.emoji-btn { font-family: var(--emoji); font-size: 28px; width: 52px; height: 48px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg-1); flex: none; }
.name-in { flex: 1; min-width: 0; min-height: 46px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg-1); color: var(--ink); padding: 6px 12px; font-size: 18px; font-weight: 600; }
.name-in:focus, .stepper input:focus { outline: 3px solid var(--brand); outline-offset: 1px; }

.btn { border: 0; border-radius: 999px; min-height: 52px; padding: 10px 26px; font-weight: 700; font-size: 20px; transition: transform .1s; }
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-play { background: var(--play); color: #fff; box-shadow: 0 5px 0 var(--play-dark); }
.btn-ghost { background: #fff; color: #1e1b4b; box-shadow: 0 5px 0 #94a3b8; }
.btn-small { border: 2px solid var(--line); background: var(--card-2); border-radius: 999px; padding: 6px 16px; font-weight: 600; font-size: 16px; min-height: 44px; }
#playBtn { font-size: 28px; min-height: 68px; justify-self: center; width: min(100%, 380px); background: var(--brand); color: #1c1305; box-shadow: 0 6px 0 var(--brand-dark), 0 0 40px rgba(245,158,11,.35); }
.install { display: grid; justify-items: center; gap: 6px; font-size: 14px; text-align: center; color: var(--muted); }
.install p { margin: 0; }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.resume { border-color: var(--brand); }
.resume p { margin: 0 0 12px; color: var(--muted); line-height: 1.4; }
.spinner { width: 44px; height: 44px; margin: 4px auto; border-radius: 50%; border: 5px solid rgba(255,255,255,.2); border-top-color: var(--brand); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Lobby ---------- */
#lobby.active { min-height: 100dvh; display: flex; flex-direction: column; gap: 16px;
  padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) calc(18px + var(--safe-b)) calc(16px + var(--safe-l)); }
.lobby { display: grid; gap: 18px; grid-template-columns: 1fr; flex: 1; max-width: 1500px; width: 100%; margin: 0 auto; }
@media (min-width: 900px) { .lobby { grid-template-columns: minmax(320px, 0.9fr) 1.4fr; align-items: start; } }
.join-panel { background: var(--card); border: 1px solid var(--line); border-radius: 26px; padding: 18px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.join-panel h2 { margin: 0; font-size: clamp(26px, 3.2vw, 44px); }
.qr { width: min(100%, 44vh, 380px); aspect-ratio: 1; background: #fff; border-radius: 18px; padding: 10px; display: grid; place-items: center; }
.qr svg { width: 100%; height: 100%; display: block; }
.qr-off { color: #1e1b4b; font-size: 22px; text-align: center; line-height: 1.3; }
.qr-off:first-child:only-child { font-size: 64px; }
.join-url { margin: 0; font-size: clamp(16px, 1.8vw, 24px); word-break: break-all; }
.join-url b { color: var(--brand); }
.room { margin: 0; font-size: clamp(20px, 2.4vw, 32px); }
.room b { display: block; font-size: clamp(56px, 8vw, 120px); letter-spacing: .14em; line-height: 1; color: #fff; text-shadow: 0 0 30px rgba(245,158,11,.6); }
.net-status { margin: 0; font-size: 16px; color: var(--muted); }
.lobby-side h2 { margin: 0 0 12px; font-size: clamp(22px, 2.6vw, 36px); }
.team-cols { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.team-col { background: var(--card); border-radius: 20px; border-top: 8px solid var(--tc); padding: 10px 12px 14px; min-height: 120px; }
.team-col h3 { margin: 0 0 8px; font-size: clamp(18px, 1.8vw, 26px); display: flex; align-items: center; gap: 6px; }
.team-col h3 span { font-family: var(--emoji); }
.team-col h3 small { margin-left: auto; background: var(--tc); color: #0b1230; border-radius: 999px; padding: 0 10px; font-size: 16px; }
.names { display: flex; flex-wrap: wrap; gap: 6px; }
.names .empty { color: var(--muted); font-size: 15px; }
.name-chip { display: inline-flex; align-items: center; background: var(--card-2); border: 2px solid var(--tc); border-radius: 999px; font-size: clamp(16px, 1.6vw, 22px); font-weight: 600; animation: pop .3s ease-out; }
.name-chip.off { opacity: .45; border-style: dashed; }
.name-chip button { border: 0; background: none; min-height: 40px; }
.name-chip .nm { padding: 2px 4px 2px 12px; }
.name-chip .x { padding: 2px 10px 2px 6px; color: var(--muted); font-size: 14px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.fail { max-width: 860px; margin: 0 auto; border-color: var(--bad); background: #3b1220; }
.fail h2 { color: #fecaca; }
.fail p { margin: 0 0 12px; line-height: 1.4; }
.lobby-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
#lobbyStart { font-size: 26px; min-height: 64px; min-width: min(100%, 320px); }

/* ---------- Play (projector) ---------- */
#play.active { position: fixed; inset: 0; overflow-y: auto; display: block; }
.play {
  min-height: 100%; max-width: 1800px; margin: 0 auto;
  display: flex; flex-direction: column; gap: clamp(8px, 1.4vh, 14px);
  padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) calc(12px + var(--safe-b)) calc(14px + var(--safe-l));
}
.hud { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill { background: var(--card); border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: clamp(15px, 1.6vw, 24px); white-space: nowrap; }
.hud-std { color: var(--brand); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
.hud-room { color: #fde68a; }
.hud-year { margin-left: auto; background: var(--brand); color: #1c1305; border-color: var(--brand); }
.hud-btn { min-width: 48px; min-height: 44px; }

.scoreboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.team-chip { position: relative; display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 18px; padding: 6px 14px; border-bottom: 6px solid var(--tc); font-size: clamp(16px, 1.7vw, 28px); font-weight: 700; min-width: 0; transition: transform .2s; }
.team-chip .te { font-family: var(--emoji); font-size: 1.3em; }
.team-chip .tn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.team-chip small { color: var(--muted); font-size: .6em; }
.team-chip .ts { margin-left: auto; font-size: 1.25em; color: #fff; }
.team-chip.turn { background: color-mix(in srgb, var(--tc) 35%, var(--card)); box-shadow: 0 0 0 4px var(--tc), 0 0 30px color-mix(in srgb, var(--tc) 55%, transparent); transform: scale(1.03); }
.team-chip.lead .ts::before { content: '👑 '; font-family: var(--emoji); font-size: .8em; }
.team-chip .gain { position: absolute; right: 10px; top: -14px; background: var(--good); color: #052e16; border-radius: 999px; padding: 0 10px; font-size: .75em; animation: rise 1.6s ease-out forwards; }
@keyframes rise { 0% { transform: translateY(10px); opacity: 0; } 20% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }

.stage { display: grid; gap: clamp(10px, 1.6vh, 18px); flex: 1 0 auto; align-content: start; }
@media (min-width: 1000px) {
  .stage.has-text { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
  .stage.has-text .answers { grid-template-columns: 1fr !important; }
}
.question { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 26px; padding: clamp(12px, 2vh, 24px) clamp(14px, 2vw, 28px); display: grid; gap: 8px; justify-items: center; text-align: center; }
.timer {
  --p: 1; position: absolute; top: 10px; right: 10px; width: clamp(64px, 8vw, 120px); aspect-ratio: 1; border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--p) * 1turn), rgba(255,255,255,.12) 0);
  display: grid; place-items: center;
}
.timer::before { content: ''; position: absolute; inset: 9%; border-radius: 50%; background: var(--card); }
.timer span { position: relative; font-size: clamp(26px, 3.4vw, 54px); font-weight: 700; }
.timer.urgent { background: conic-gradient(var(--bad) calc(var(--p) * 1turn), rgba(255,255,255,.12) 0); animation: beat .5s infinite alternate; }
.timer.done span { color: var(--bad); }
@keyframes beat { to { transform: scale(1.08); } }
.q-turn { font-size: clamp(20px, 2.4vw, 38px); font-weight: 700; background: var(--tc); color: #fff; border-radius: 999px; padding: 4px 22px; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.q-title { font-size: clamp(18px, 1.8vw, 28px); font-weight: 700; color: var(--brand); }
.q-title:empty, .q-text:empty, .q-visual:empty, .q-word:empty, .q-letters:empty { display: none; }
.q-listen { font-size: clamp(20px, 2.2vw, 34px); font-weight: 700; color: #fde68a; }
.q-text { max-width: 60em; text-align: left; font-size: clamp(18px, 1.9vw, 30px); line-height: 1.45; background: var(--card-2); border-radius: 16px; padding: 8px 18px; padding-right: clamp(18px, 6vw, 110px); }
.q-text p { margin: .3em 0; }
.q-text.short { text-align: center; font-size: clamp(22px, 2.6vw, 42px); }
.q-text b { color: #fde68a; }
.q-text .gap { display: inline-block; min-width: 3em; border-bottom: 4px solid var(--brand); vertical-align: -0.1em; }
.q-text.teacher-read { border: 3px dashed #fde68a; }
.q-text .heard { color: var(--muted); font-size: .7em; margin: 0; }
.q-main { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.q-visual { font-family: var(--emoji); font-size: clamp(48px, 9vh, 110px); line-height: 1.1; }
.q-word { font-size: clamp(34px, 5vw, 84px); font-weight: 700; line-height: 1.15; }
.q-word.long { font-size: clamp(26px, 3.4vw, 54px); }
.q-letters { font-size: clamp(36px, 5vw, 80px); font-weight: 700; letter-spacing: .1em; color: #fde68a; }
.q-prompt { margin: 0; font-size: clamp(24px, 3.2vw, 54px); line-height: 1.2; padding: 0 clamp(60px, 8vw, 120px); }
.q-tools { display: flex; gap: 8px; }
.q-explain { margin: 0; font-size: clamp(17px, 1.7vw, 26px); color: #bbf7d0; }
.read-bar { width: min(100%, 700px); height: 10px; border-radius: 99px; background: rgba(255,255,255,.12); overflow: hidden; }
.read-bar span { display: block; height: 100%; width: 0; background: var(--brand); }

.answers { display: grid; gap: clamp(8px, 1.2vw, 16px); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stage[data-n="3"] .answers { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .stage[data-n="3"] .answers { grid-template-columns: 1fr; } }
.ans {
  position: relative; display: flex; align-items: center; gap: clamp(8px, 1vw, 16px); text-align: left;
  min-height: clamp(76px, 15vh, 170px); padding: 10px clamp(12px, 1.4vw, 22px); border: 0; border-radius: 20px;
  color: #fff; font-weight: 700; font-size: clamp(20px, 2.6vw, 46px); line-height: 1.15;
  box-shadow: 0 6px 0 rgba(0,0,0,.35); transition: transform .12s, opacity .3s, filter .3s; overflow: hidden;
}
.ans:active { transform: translateY(3px); }
.a0 { background: var(--a0); } .a1 { background: var(--a1); } .a2 { background: var(--a2); } .a3 { background: var(--a3); }
.ans .shape, .ans .letter { position: relative; z-index: 1; }
.ans .shape { font-size: 1.2em; opacity: .9; width: 1.1em; text-align: center; flex: none; }
.ans .letter { flex: none; display: grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%; background: rgba(255,255,255,.25); font-size: .75em; }
.ans .body { display: flex; align-items: center; gap: .4em; min-width: 0; flex: 1; position: relative; z-index: 1; }
.ans .emoji { font-family: var(--emoji); font-size: 1.25em; flex: none; }
.ans .emoji:empty { display: none; }
.ans .txt { overflow-wrap: anywhere; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.ans .txt small { display: block; font-size: .55em; font-weight: 500; opacity: .9; }
.ans.big .txt { font-size: 1.8em; }
.ans .tally { display: flex; align-items: center; gap: 6px; flex: none; font-size: .8em; }
.ans .tally > b, .ans .tally .who { position: relative; z-index: 1; }
.ans .tally > b { min-width: 1.6em; text-align: center; background: rgba(0,0,0,.28); border-radius: 12px; padding: 0 8px; }
.ans .tally:empty { display: none; }
/* Live bar chart: each answer fills from the left by how many chose it. */
.ans .tally .bar { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--h) * 100%); background: rgba(255,255,255,.22); animation: grow .7s ease-out; z-index: 0; }
@keyframes grow { from { width: 0; } }
.ans .tally .who { font-family: var(--emoji); font-size: .8em; }
.ans.right { box-shadow: 0 0 0 6px #fff, 0 0 40px rgba(255,255,255,.5); transform: scale(1.02); }
.ans.right::after { content: '✔'; position: absolute; right: 12px; top: 6px; font-size: .9em; }
.ans.dim { opacity: .35; filter: saturate(.4); }
.ans.chosen { opacity: .7; outline: 5px dashed #fff; outline-offset: -8px; }

.panel-bar { min-height: 48px; display: grid; gap: 10px; }
.status { text-align: center; font-size: clamp(18px, 2vw, 32px); font-weight: 700; }
.status.big b { color: var(--brand); font-size: 1.3em; }
.status .muted, .muted { color: var(--muted); font-weight: 500; }
.entry { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.entry-row { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 18px; padding: 6px 10px; border-left: 10px solid var(--tc); cursor: pointer; }
.entry-row.active { box-shadow: 0 0 0 4px var(--tc); background: color-mix(in srgb, var(--tc) 20%, var(--card)); }
.entry-row .tname { font-size: clamp(17px, 1.7vw, 26px); font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-row .picks { display: flex; gap: 6px; }
.pick { width: clamp(44px, 4vw, 64px); height: clamp(44px, 4vw, 60px); border-radius: 12px; border: 3px solid transparent; font-size: clamp(18px, 1.8vw, 28px); font-weight: 700; color: #fff; opacity: .35; }
.pick.on { opacity: 1; border-color: #fff; transform: scale(1.08); }
.reveal-line { text-align: center; font-size: clamp(18px, 2.1vw, 34px); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 14px; }
.ans-chip { display: inline-block; color: #fff; border-radius: 10px; padding: 0 10px; }
.reveal-row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: flex-start; }
.gains { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.gain-chip { background: var(--card); border-bottom: 5px solid var(--tc); border-radius: 14px; padding: 4px 14px; font-size: clamp(18px, 1.8vw, 28px); font-weight: 700; }
.top5-mini { margin: 0; padding: 6px 12px 6px 34px; background: var(--card); border-radius: 16px; font-size: clamp(16px, 1.5vw, 24px); min-width: min(100%, 300px); }
.top5-mini li { padding: 2px 0; }
.top5-mini li span { border-bottom: 3px solid var(--tc); }
.top5-mini li b { float: right; margin-left: 16px; }
.play-actions { display: flex; justify-content: center; }
#actionBtn { font-size: clamp(20px, 2vw, 30px); min-height: clamp(52px, 7vh, 72px); min-width: min(100%, 320px); }
#actionBtn.pulse { animation: glow 1s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 5px 0 var(--play-dark), 0 0 0 8px rgba(34,197,94,.35); } }
.keys { margin: 0; text-align: center; color: var(--muted); font-size: 13px; }
@media (hover: none) and (pointer: coarse) { .keys { display: none; } }

.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(3, 6, 20, .7); }
.overlay .panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; width: min(100%, 520px); text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.ov-icon { font-size: 52px; line-height: 1.1; }
.overlay .panel h2 { margin: 6px 0; font-size: 28px; }
.overlay .panel p { margin: 0 0 14px; color: var(--muted); font-size: 18px; line-height: 1.4; }

/* ---------- Results ---------- */
.results { display: grid; gap: 12px; text-align: center; }
.results h2 { justify-content: center; font-size: clamp(28px, 5vw, 44px); margin: 0; }
.results h3 { margin: 10px 0 0; font-size: 18px; }
.results h3 small { font-weight: 400; color: var(--muted); }
.winner { display: grid; justify-items: center; }
.winner .crown { font-family: var(--emoji); font-size: 44px; line-height: 1; animation: bob 1.4s ease-in-out infinite alternate; }
.winner .w-emoji { font-family: var(--emoji); font-size: clamp(70px, 16vw, 120px); line-height: 1.1; filter: drop-shadow(0 0 30px var(--tc)); }
@keyframes bob { to { transform: translateY(-6px) rotate(-6deg); } }
.res-score { margin: 0; font-size: 17px; color: var(--muted); line-height: 1.4; }
.podium { display: grid; gap: 8px; }
.pod { position: relative; display: flex; align-items: center; gap: 10px; background: var(--card-2); border-radius: 16px; padding: 8px 14px; font-size: 20px; font-weight: 700; overflow: hidden; border-left: 8px solid var(--tc); }
.pod .pbar { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--h) * 100%); background: var(--tc); opacity: .22; }
.pod > *:not(.pbar) { position: relative; }
.pod .pe { font-family: var(--emoji); font-size: 28px; }
.pod .pn { flex: 1; text-align: left; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top5 { background: var(--card-2); border-radius: 16px; padding: 8px 14px; text-align: left; }
.top5 h3 { margin: 0 0 4px; }
.top5 ol { margin: 0; padding-left: 26px; font-size: 18px; }
.top5 li span { border-bottom: 3px solid var(--tc); }
.top5 li b { float: right; }
.table-wrap { overflow-x: auto; }
.std-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
.std-table th, .std-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.std-table th { color: var(--muted); font-weight: 600; }
.std-table td:first-child { font-weight: 700; color: var(--brand); white-space: nowrap; }
.std-table td:last-child { white-space: nowrap; text-align: right; }
.std-table td:last-child b { display: block; font-size: 17px; }
.std-table td:last-child small { color: var(--muted); }
.std-table .good b { color: var(--good); } .std-table .mid b { color: #fbbf24; } .std-table .low b { color: #f87171; }
#copyBtn { justify-self: center; }
.review-box { text-align: left; background: var(--card-2); border-radius: 14px; padding: 10px 12px; }
.review-box summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.review { margin: 8px 0 0; padding-left: 24px; display: grid; gap: 6px; font-size: 15px; }
.review li { line-height: 1.35; }
.review .mark { font-weight: 700; margin-left: 6px; }
.review .ok { color: var(--good); } .review .mid { color: #fbbf24; } .review .no { color: #f87171; }

/* ---------- Pupil join page ---------- */
body.pupil { min-height: 100dvh; }
.j-wrap { min-height: 100dvh; display: flex; flex-direction: column; gap: 12px; max-width: 560px; margin: 0 auto;
  padding: calc(12px + var(--safe-t)) calc(14px + var(--safe-r)) calc(16px + var(--safe-b)) calc(14px + var(--safe-l)); }
.j-top { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.j-top .me { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.j-top .me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.j-top .score { margin-left: auto; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; font-weight: 700; font-size: 18px; white-space: nowrap; }
.j-top .bm { border: 0; border-radius: 999px; background: rgba(255,255,255,.92); color: #1e1b4b; font-weight: 600; font-size: 14px; min-height: 36px; padding: 4px 10px; }
.j-screen { display: none; flex: 1; flex-direction: column; gap: 14px; }
.j-screen.active { display: flex; }
.j-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 12px; }
.j-card h1 { margin: 0; text-align: center; font-size: 32px; }
.j-card label { font-weight: 600; color: var(--muted); font-size: 15px; }
.j-input { width: 100%; min-height: 56px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg-1); color: var(--ink); padding: 8px 14px; font-size: 24px; font-weight: 700; }
.j-input.code { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-size: 34px; }
.j-input:focus { outline: 3px solid var(--brand); }
.j-err { margin: 0; color: #fecaca; font-weight: 600; min-height: 1.2em; text-align: center; }
.j-big { font-size: 26px; min-height: 64px; width: 100%; }
.j-note { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; text-align: center; }
.j-center { flex: 1; display: grid; place-content: center; justify-items: center; text-align: center; gap: 10px; }
.j-center .big-emoji { font-family: var(--emoji); font-size: 84px; line-height: 1.1; }
.j-center h2 { margin: 0; font-size: 30px; }
.j-center p { margin: 0; color: var(--muted); font-size: 19px; line-height: 1.4; }
.team-badge { display: inline-flex; align-items: center; gap: 8px; background: var(--tc); color: #fff; border-radius: 999px; padding: 6px 18px; font-size: 22px; font-weight: 700; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.team-pick { display: grid; gap: 8px; width: min(100%, 420px); }
.team-pick button { min-height: 56px; border-radius: 16px; border: 3px solid var(--tc); background: var(--card); font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; padding: 6px 14px; }
.team-pick button[aria-pressed="true"] { background: var(--tc); color: #fff; }
.team-pick button small { margin-left: auto; font-size: 14px; opacity: .85; }
.j-q { display: grid; gap: 4px; text-align: center; }
.j-q .n { color: var(--muted); font-size: 15px; font-weight: 600; }
.j-q .prompt { font-size: 20px; font-weight: 700; line-height: 1.25; }
.j-timebar { height: 10px; border-radius: 99px; background: rgba(255,255,255,.12); overflow: hidden; }
.j-timebar span { display: block; height: 100%; width: 100%; background: var(--brand); transform-origin: left; }
.j-wait { text-align: center; color: #fde68a; font-weight: 700; font-size: 18px; min-height: 1.3em; margin: 0; }
.j-answers { flex: 1; display: grid; gap: 10px; grid-auto-rows: minmax(84px, 1fr); }
.j-answers.n4 { grid-template-columns: 1fr 1fr; }
.j-ans { border: 0; border-radius: 20px; color: #fff; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; padding: 10px 14px; text-align: left;
  font-weight: 700; font-size: 20px; line-height: 1.15; box-shadow: 0 6px 0 rgba(0,0,0,.35); transition: transform .1s, opacity .2s; min-height: 84px; }
.j-answers.n4 .j-ans { grid-template-columns: 1fr; justify-items: center; align-content: center; text-align: center; gap: 8px; }
.j-ans:active { transform: translateY(3px); }
.j-ans:disabled { cursor: default; }
.j-ans .sym { font-size: 34px; line-height: 1; display: flex; align-items: center; gap: 6px; }
.j-ans .sym b { font-size: 20px; background: rgba(255,255,255,.25); border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center; }
.j-ans .t { overflow-wrap: anywhere; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.j-ans .t small { display: block; font-size: 13px; font-weight: 500; }
.j-ans .e { font-family: var(--emoji); margin-right: 4px; }
.j-ans.big .t { font-size: 40px; }
.j-answers.locked .j-ans { opacity: .3; }
.j-answers.locked .j-ans.mine { opacity: 1; box-shadow: 0 0 0 5px #fff; }
.j-answers.wait .j-ans { opacity: .55; }
.j-result { flex: 1; display: grid; place-content: center; justify-items: center; text-align: center; gap: 8px; border-radius: var(--radius); padding: 20px; }
.j-result.ok { background: linear-gradient(160deg, #15803d, #166534); }
.j-result.no { background: linear-gradient(160deg, #b91c1c, #7f1d1d); }
.j-result.none { background: var(--card); }
.j-result .big-emoji { font-family: var(--emoji); font-size: 76px; line-height: 1.1; }
.j-result h2 { margin: 0; font-size: 34px; }
.j-result p { margin: 0; font-size: 19px; line-height: 1.4; }
.j-result .pts { font-size: 40px; font-weight: 700; }
.j-result .j-note { color: rgba(255,255,255,.88); }
.j-teams { display: grid; gap: 6px; }
.j-team { display: flex; align-items: center; gap: 8px; background: var(--card); border-left: 8px solid var(--tc); border-radius: 12px; padding: 6px 12px; font-weight: 700; font-size: 18px; }
.j-team b { margin-left: auto; }
.j-team.mine { box-shadow: 0 0 0 3px var(--tc); }
.j-banner { position: fixed; left: 50%; top: calc(8px + var(--safe-t)); transform: translateX(-50%); z-index: 30; background: #fde68a; color: #422006; border-radius: 999px; padding: 6px 16px; font-weight: 700; font-size: 15px; box-shadow: 0 6px 18px rgba(0,0,0,.4); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
