/* ============ Tokens ============ */
:root {
  --paper: #eef1f4;      /* cool filing-cabinet grey */
  --sheet: #ffffff;
  --ink: #16233f;        /* deep ledger navy */
  --ink-2: #4b5876;
  --ink-3: #7b869c;
  --rule: #cfd6e0;
  --stamp: #c23b4e;      /* filing-stamp red */
  --ok: #1f7a4d;
  --ok-bg: #e3f3ea;
  --bad: #b3261e;
  --bad-bg: #fbe7e5;

  /* answer colours, each paired with its letter so colour is never the only cue */
  --opt-A: #1d6a8c;
  --opt-B: #b67a06;
  --opt-C: #6a4597;
  --opt-D: #2c7d5a;

  --ui: 'Bricolage Grotesque', system-ui, sans-serif;
  --read: 'Source Serif 4', Georgia, serif;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --shadow: 0 1px 0 rgba(22, 35, 63, 0.08), 0 8px 24px -12px rgba(22, 35, 63, 0.25);
  --wrap: 1080px;
  --measure: 68ch;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--ui);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 1.5rem 1.25rem 4rem; outline: none; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.75rem); font-weight: 750; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 1em; }
a { color: var(--ink); text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--stamp); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.loading { color: var(--ink-2); padding: 3rem 0; text-align: center; }

/* ============ Top bar ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1.25rem; max-width: var(--wrap); width: 100%; margin: 0 auto;
}
.wordmark {
  font-weight: 800; font-size: 1.35rem; letter-spacing: -0.02em; text-decoration: none;
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.wordmark::before {
  content: ''; width: 0.9rem; height: 0.9rem; border: 2.5px solid var(--stamp); border-radius: 3px;
  transform: rotate(-8deg);
}
.topnav { display: flex; gap: 1.25rem; font-weight: 550; }
.topnav a { text-decoration: none; color: var(--ink-2); }
.topnav a:hover { color: var(--ink); }
.topnav-join { color: var(--stamp) !important; }
body.stage .topbar { display: none; }  /* host screen goes full-bleed */

/* ============ Buttons & inputs ============ */
.btn {
  appearance: none; border: 1.5px solid var(--ink); background: var(--sheet); color: var(--ink);
  border-radius: var(--r-md); padding: 0.7rem 1.15rem; font-weight: 650; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; text-decoration: none;
  transition: transform 80ms ease, background-color 120ms ease;
}
.btn:hover { background: #f6f8fa; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #22325a; }
.btn-stamp { background: var(--stamp); border-color: var(--stamp); color: #fff; }
.btn-stamp:hover { background: #a9303f; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(22, 35, 63, 0.06); }
.btn-lg { padding: 0.95rem 1.5rem; font-size: 1.1rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
kbd {
  font: 600 0.72rem/1 var(--ui); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px;
  padding: 0.15rem 0.35rem; color: var(--ink-2); background: var(--sheet);
}
.btn-primary kbd, .btn-stamp kbd { background: transparent; color: inherit; border-color: rgba(255,255,255,.4); }

.field { display: grid; gap: 0.35rem; }
.field label { font-weight: 600; }
.input {
  border: 1.5px solid var(--rule); background: var(--sheet); border-radius: var(--r-md);
  padding: 0.75rem 0.9rem; width: 100%;
}
.input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(22, 35, 63, 0.12); }
.form-error { color: var(--bad); font-weight: 550; min-height: 1.5em; margin: 0.25rem 0 0; }

.panel { background: var(--sheet); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 1.5rem; }

/* ============ Home ============ */
.home { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 2rem; align-items: start; }
.joinbox { position: sticky; top: 1rem; }
.joinbox h1 { font-size: clamp(1.7rem, 3.5vw, 2.3rem); }
.code-input {
  font: 800 2rem/1 var(--ui); letter-spacing: 0.32em; text-transform: uppercase; text-align: center;
  padding: 0.85rem 0.5rem 0.85rem 0.82rem;
}
.code-input::placeholder { color: var(--rule); }
.joinbox form { display: grid; gap: 0.75rem; margin-top: 1.25rem; }
.quizlist { display: grid; gap: 1rem; }
.quizlist > h2 { margin-top: 0.4rem; }
.quizcard {
  display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 1rem; align-items: center;
  padding: 1.25rem 1.4rem; text-decoration: none; border-left: 5px solid var(--ink);
}
.quizcard:hover { border-left-color: var(--stamp); }
.quizcard h3 { font-size: 1.3rem; margin: 0; }
.quizcard p { margin: 0; grid-column: 1; }
.quizcard .count { grid-row: 1 / span 2; grid-column: 2; text-align: right; font-weight: 750; font-size: 1.5rem; line-height: 1; }
.quizcard .count span { display: block; font-size: 0.8rem; font-weight: 500; color: var(--ink-2); margin-top: 0.2rem; }
.history { margin-top: 1.5rem; }
.history ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.history li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.65rem 0; border-bottom: 1px solid var(--rule); font-size: 0.95rem; }
.history li:last-child { border-bottom: 0; }

/* ============ Quiz setup ============ */
.setup-head { display: flex; justify-content: space-between; gap: 1rem; align-items: end; flex-wrap: wrap; margin-bottom: 1.5rem; }
.setup-head p { max-width: var(--measure); margin: 0; }
.setup { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
.parts { display: grid; gap: 1.25rem; }
.part { border: 0; padding: 0; margin: 0; }
.part-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.35rem; }
.part-head legend { font-weight: 700; font-size: 1rem; padding: 0; }
.linkish { background: none; border: 0; padding: 0.2rem 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; font-size: 0.875rem; }
.chap {
  display: grid; grid-template-columns: auto 2.25rem 1fr auto; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--rule); cursor: pointer;
}
.chap:hover { background: rgba(22, 35, 63, 0.03); }
.chap input { width: 1.1rem; height: 1.1rem; accent-color: var(--ink); }
.chap .num { font-weight: 750; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chap .n { color: var(--ink-3); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.side { position: sticky; top: 1rem; display: grid; gap: 1rem; }
.side .panel { padding: 1.25rem; }
.selected-count { font-size: 2.4rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.seg { display: flex; border: 1.5px solid var(--ink); border-radius: var(--r-md); overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--sheet); padding: 0.5rem 0.25rem; cursor: pointer; font-weight: 600; }
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button[aria-pressed='true'] { background: var(--ink); color: #fff; }
.check { display: flex; gap: 0.55rem; align-items: center; cursor: pointer; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--ink); }
.modes { display: grid; gap: 0.5rem; }
.mode { justify-content: space-between; text-align: left; }
.mode small { font-weight: 450; color: var(--ink-2); }
.btn-primary .mode-sub, .mode .mode-sub { display: block; font-weight: 450; font-size: 0.82rem; opacity: 0.8; }
.live { border-top: 4px solid var(--stamp); }
.live select { padding: 0.5rem; border-radius: var(--r-sm); border: 1.5px solid var(--rule); background: var(--sheet); }
.stack { display: grid; gap: 0.85rem; }
.hardest { font-size: 0.9rem; }
.hardest ol { padding-left: 1.2rem; margin: 0.25rem 0 0; }

/* ============ Question + options (shared) ============ */
.qwrap { max-width: 760px; margin: 0 auto; }
.qmeta { color: var(--ink-2); font-size: 0.9rem; margin-bottom: 0.5rem; display: flex; gap: 1rem; flex-wrap: wrap; justify-content: space-between; }
.qtext { font: 500 clamp(1.2rem, 2.4vw, 1.45rem)/1.45 var(--read); margin: 0 0 1.4rem; max-width: var(--measure); }
.opts { display: grid; gap: 0.65rem; }
.opt {
  --c: var(--ink);
  display: grid; grid-template-columns: 2.4rem 1fr; gap: 0.85rem; align-items: center; text-align: left;
  width: 100%; padding: 0.8rem 1rem 0.8rem 0.8rem; border: 1.5px solid var(--rule); border-radius: var(--r-md);
  background: var(--sheet); cursor: pointer; font: 400 1.03rem/1.4 var(--read);
  transition: border-color 120ms ease, background-color 120ms ease, opacity 150ms ease;
}
.opt[data-l='A'] { --c: var(--opt-A); }
.opt[data-l='B'] { --c: var(--opt-B); }
.opt[data-l='C'] { --c: var(--opt-C); }
.opt[data-l='D'] { --c: var(--opt-D); }
.opt-letter {
  width: 2.4rem; height: 2.4rem; border-radius: 8px; display: grid; place-items: center;
  background: var(--c); color: #fff; font: 800 1.05rem/1 var(--ui);
}
.opt:not([disabled]):hover { border-color: var(--c); }
.opt[disabled] { cursor: default; }
.opt[data-state='correct'] { border-color: var(--ok); background: var(--ok-bg); }
.opt[data-state='wrong'] { border-color: var(--bad); background: var(--bad-bg); }
.opt[data-state='picked'] { border-color: var(--c); box-shadow: inset 0 0 0 1.5px var(--c); }
.opt[data-state='dim'] { opacity: 0.45; }
.opt-tag { grid-column: 2; font: 650 0.8rem/1 var(--ui); margin-top: 0.15rem; }
.opt[data-state='correct'] .opt-tag { color: var(--ok); }
.opt[data-state='wrong'] .opt-tag { color: var(--bad); }

.feedback { margin-top: 1.25rem; padding: 1.1rem 1.25rem; border-radius: var(--r-md); border-left: 5px solid; animation: rise 180ms ease-out; }
.feedback.good { background: var(--ok-bg); border-color: var(--ok); }
.feedback.bad { background: var(--bad-bg); border-color: var(--bad); }
.feedback h3 { margin-bottom: 0.3rem; }
.feedback p { font: 400 1rem/1.6 var(--read); margin: 0; max-width: var(--measure); }
.continue-row { margin-top: 1.25rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

.progress { height: 6px; background: var(--rule); border-radius: 99px; overflow: hidden; margin-bottom: 1.5rem; }
.progress > i { display: block; height: 100%; background: var(--ink); border-radius: 99px; transition: width 300ms ease; }
.sessionbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.6rem; }
.sessionbar strong { font-variant-numeric: tabular-nums; }

/* ============ Test mode ============ */
.test-list { display: grid; gap: 1.25rem; counter-reset: q; }
.test-q { padding: 1.4rem; }
.test-q .qtext { font-size: 1.15rem; margin-bottom: 1rem; }
.test-q .opt { font-size: 0.98rem; padding: 0.6rem 0.9rem 0.6rem 0.6rem; grid-template-columns: 2rem 1fr; }
.test-q .opt-letter { width: 2rem; height: 2rem; font-size: 0.9rem; }
.test-q.unanswered { box-shadow: var(--shadow), inset 4px 0 0 var(--stamp); }
.test-foot {
  position: sticky; bottom: 0; margin: 1.5rem -1.25rem -4rem; padding: 0.9rem 1.25rem calc(0.9rem + env(safe-area-inset-bottom));
  background: rgba(238, 241, 244, 0.92); backdrop-filter: blur(8px); border-top: 1px solid var(--rule);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.score-hero { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.score-hero .big { font-size: clamp(3.5rem, 10vw, 5.5rem); font-weight: 800; letter-spacing: -0.04em; line-height: 0.9; }
.review-item { padding: 1.1rem 0; border-bottom: 1px solid var(--rule); }
.review-item .qtext { font-size: 1.05rem; margin-bottom: 0.5rem; }
.review-item .ans { font: 400 0.98rem/1.5 var(--read); margin: 0.2rem 0; }
.review-item .expl { font: italic 400 0.96rem/1.55 var(--read); color: var(--ink-2); margin-top: 0.4rem; max-width: var(--measure); }
.mark { font: 700 0.85rem/1 var(--ui); }
.mark.good { color: var(--ok); }
.mark.bad { color: var(--bad); }

/* ============ Flashcards ============ */
.card-stage { perspective: 1600px; max-width: 760px; margin: 0 auto; }
.flash {
  position: relative; min-height: 340px; cursor: pointer; transform-style: preserve-3d;
  transition: transform 420ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.flash.flipped { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; padding: 2rem; display: flex; flex-direction: column; justify-content: center;
}
.flash-back { transform: rotateY(180deg); }
.flash-face .qtext { margin-bottom: 1rem; }
.flash-opts { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.35rem; font: 400 1rem/1.45 var(--read); }
.flash-opts b { font-family: var(--ui); margin-right: 0.4rem; }
.flash-answer { font: 600 1.35rem/1.35 var(--read); margin-bottom: 0.9rem; }
.flash-hint { text-align: center; color: var(--ink-3); font-size: 0.85rem; margin-top: 0.85rem; }

/* ============ Live game: host stage ============ */
body.stage { background: var(--ink); color: #fff; }
body.stage main { max-width: none; padding: 0; display: flex; }
.stage-wrap { flex: 1; display: grid; grid-template-rows: auto 1fr auto; min-height: 100dvh; padding: clamp(1rem, 2.5vw, 2rem); gap: 1.5rem; }
.stage-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.stage-top .wordmark { color: #fff; }
.stage-top .muted { color: #aeb8cc; }
.stage .btn { border-color: #fff; }
.stage .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.stage .btn-ghost:hover { background: rgba(255,255,255,.08); }
.stage .muted { color: #aeb8cc; }

.lobby { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 4rem); align-items: center; }
.join-how { font-size: clamp(1.1rem, 2vw, 1.5rem); }
.join-how strong { color: #fff; }
.stamp {
  display: inline-block; margin: 1rem 0 1.5rem; padding: 0.6rem 1.4rem 0.7rem;
  border: 6px solid var(--stamp); border-radius: 14px; color: #ffd9de;
  font: 800 clamp(3.5rem, 11vw, 8.5rem)/1 var(--ui); letter-spacing: 0.12em;
  transform: rotate(-3deg); position: relative;
  text-shadow: 0 0 1px rgba(255,255,255,.3);
  box-shadow: inset 0 0 0 2px rgba(194, 59, 78, 0.45);
  animation: stamp-in 420ms cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
.stamp::after {
  content: 'Filed'; position: absolute; top: -0.9rem; right: 1rem; background: var(--ink); padding: 0 0.5rem;
  color: var(--stamp); font: 800 1rem/1.6 var(--ui); letter-spacing: 0.06em;
}
@keyframes stamp-in { from { opacity: 0; transform: rotate(-12deg) scale(1.6); } }
.roster { background: rgba(255,255,255,.06); border-radius: var(--r-lg); padding: 1.25rem; min-height: 260px; }
.roster-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.85rem; }
.roster-head strong { font-size: 2.2rem; line-height: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem; background: #fff; color: var(--ink);
  border-radius: 99px; padding: 0.4rem 0.45rem 0.4rem 0.9rem; font-weight: 650; animation: rise 200ms ease-out;
}
.chip.off { opacity: 0.5; }
.chip button { border: 0; background: transparent; cursor: pointer; width: 1.6rem; height: 1.6rem; border-radius: 99px; color: var(--ink-3); font-size: 1.1rem; line-height: 1; }
.chip button:hover { background: var(--bad-bg); color: var(--bad); }

.stage-q { display: grid; grid-template-rows: auto 1fr; gap: 1.5rem; }
.stage-qtext { font: 500 clamp(1.4rem, 3vw, 2.4rem)/1.35 var(--read); max-width: 40ch; margin: 0; }
.stage-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-content: end; }
.stage-opt {
  --c: var(--opt-A); background: var(--c); color: #fff; border-radius: var(--r-lg); padding: 1.1rem 1.3rem;
  display: grid; grid-template-columns: 3rem 1fr auto; gap: 1rem; align-items: center; min-height: 6rem;
  font: 500 clamp(1rem, 1.6vw, 1.3rem)/1.35 var(--read); transition: opacity 200ms ease, transform 200ms ease;
}
.stage-opt[data-l='B'] { --c: var(--opt-B); }
.stage-opt[data-l='C'] { --c: var(--opt-C); }
.stage-opt[data-l='D'] { --c: var(--opt-D); }
.stage-opt .opt-letter { background: rgba(255,255,255,.2); width: 3rem; height: 3rem; font-size: 1.4rem; }
.stage-opt .tally { font: 800 1.5rem/1 var(--ui); }
.stage-opt.dim { opacity: 0.28; }
.stage-opt.win { transform: scale(1.015); box-shadow: 0 0 0 4px #fff; }
.timer {
  --p: 1; width: 5.5rem; height: 5.5rem; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(#fff calc(var(--p) * 360deg), rgba(255,255,255,.15) 0);
  font: 800 1.9rem/1 var(--ui); position: relative;
}
.timer::before { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--ink); }
.timer span { position: relative; font-variant-numeric: tabular-nums; }
.timer.low { background: conic-gradient(var(--stamp) calc(var(--p) * 360deg), rgba(255,255,255,.15) 0); }
.stage-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.answered-count { font-size: 1.1rem; }
.answered-count strong { font-size: 2rem; }

.reveal { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr); gap: 2rem; align-items: start; }
.reveal .stage-opts { grid-template-columns: 1fr; gap: 0.6rem; }
.reveal .stage-opt { min-height: 0; padding: 0.75rem 1rem; grid-template-columns: 2.5rem 1fr auto; }
.reveal .stage-opt .opt-letter { width: 2.5rem; height: 2.5rem; font-size: 1.1rem; }
.expl-stage { margin-top: 1.25rem; font: 400 clamp(1rem, 1.4vw, 1.2rem)/1.6 var(--read); color: #dde3ee; max-width: 62ch; }
.board { background: #fff; color: var(--ink); border-radius: var(--r-lg); padding: 1.25rem; }
.board ol { list-style: none; padding: 0; margin: 0; }
.board li { display: grid; grid-template-columns: 2rem 1fr auto; gap: 0.5rem; padding: 0.6rem 0; border-bottom: 1px solid var(--rule); font-weight: 600; align-items: center; }
.board li:last-child { border-bottom: 0; }
.board .rk { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.board .sc { font-variant-numeric: tabular-nums; font-weight: 800; }

.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: end; max-width: 820px; margin: 0 auto; width: 100%; }
.step { text-align: center; }
.step .nm { font-weight: 800; font-size: clamp(1.1rem, 2.2vw, 1.6rem); margin-bottom: 0.25rem; overflow-wrap: anywhere; }
.step .pts { color: #aeb8cc; margin-bottom: 0.6rem; font-variant-numeric: tabular-nums; }
.step .block { background: #fff; color: var(--ink); border-radius: var(--r-md) var(--r-md) 0 0; display: grid; place-items: center; font: 800 2.6rem/1 var(--ui); }
.step.p1 .block { height: 220px; background: var(--stamp); color: #fff; }
.step.p2 .block { height: 160px; }
.step.p3 .block { height: 120px; }
.step.p1 { order: 2; } .step.p2 { order: 1; } .step.p3 { order: 3; }
.final-table { max-width: 820px; margin: 1.5rem auto 0; width: 100%; }

/* ============ Live game: player (phone) ============ */
.player { max-width: 560px; margin: 0 auto; }
.player-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; font-weight: 600; }
.player-top .pill { background: var(--sheet); border-radius: 99px; padding: 0.35rem 0.85rem; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }
.wait { text-align: center; padding: 3rem 1rem; }
.wait h1 { font-size: 1.8rem; }
.pulse { width: 14px; height: 14px; border-radius: 50%; background: var(--stamp); margin: 0 auto 1.25rem; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.6); opacity: 0.4; } }
.player .qtext { font-size: 1.15rem; }
.player .opt { padding: 1rem 1rem 1rem 0.8rem; min-height: 4rem; }
.mini-timer { font: 800 1.3rem/1 var(--ui); font-variant-numeric: tabular-nums; }
.mini-timer.low { color: var(--stamp); }
.result { border-radius: var(--r-lg); padding: 1.6rem; text-align: center; color: #fff; margin-bottom: 1rem; animation: rise 200ms ease-out; }
.result.good { background: var(--ok); }
.result.bad { background: var(--bad); }
.result.miss { background: var(--ink-2); }
.result h1 { margin: 0 0 0.25rem; font-size: 2.2rem; }
.result p { margin: 0; font-size: 1.1rem; }
.conn { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 0.5rem 1rem; border-radius: 99px; font-size: 0.9rem; z-index: 10; }
.stage .conn { background: var(--stamp); }

/* ============ Responsive ============ */
@media (max-width: 880px) {
  .home, .setup, .lobby, .reveal { grid-template-columns: 1fr; }
  .joinbox, .side { position: static; }
  .stage-opts { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  main { padding: 1rem 1rem 3rem; }
  .topnav a:first-child { display: none; }
  .panel { padding: 1.15rem; }
  .test-foot { margin: 1.5rem -1rem -3rem; padding-inline: 1rem; }
  .podium .block { font-size: 1.8rem; }
  .step.p1 .block { height: 150px; } .step.p2 .block { height: 110px; } .step.p3 .block { height: 80px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
