/* UI: arena colours (night navy, pool cyan, medal gold), soft rounded panels, a rounded readable font. */
:root {
  --ink: #1e1424;
  --paper: #fbf5e4;
  --paper-2: #eadfc4;
  --muted: #9fb4d0;
  --text: #e8f1fb;
  --accent: #3fc3d8;
  --accent-hi: #8fe3f0;
  --gold: #e9b949;
  --good: #74c943;
  --bad: #e8433b;
  --font: "Fredoka", "Nunito", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #3f8fe6; color: var(--ink); font-family: var(--font);
  -webkit-font-smoothing: antialiased; }
#scene { position: fixed; left: 0; top: 0; display: block; image-rendering: pixelated; image-rendering: crisp-edges;
}

.hud { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); pointer-events: none; }
.brand, .total { font-weight: 700; color: var(--paper); font-size: 22px; letter-spacing: 1px;
  text-shadow: 2px 0 var(--ink), -2px 0 var(--ink), 0 2px var(--ink), 0 -2px var(--ink), 2px 2px var(--ink), 3px 3px var(--ink); }
.brand small { font-size: 13px; font-weight: 500; letter-spacing: 0; }
.dots { display: flex; gap: 4px; }
.dots span { width: 12px; height: 12px; background: var(--paper); border: 2px solid var(--ink); }
.dots span.current { background: var(--accent); outline: 2px solid var(--paper); }

.panel { position: fixed; left: 50%; bottom: clamp(20px, 11vh, 120px); transform: translateX(-50%); width: min(560px, calc(100% - 32px));
  color: var(--text); background: linear-gradient(180deg, rgba(27, 52, 108, .94), rgba(13, 27, 62, .96));
  border: 2px solid rgba(120, 190, 235, .35); border-radius: 14px; padding: 14px 16px 16px;
  box-shadow: 0 18px 40px rgba(3, 6, 18, .55), inset 0 1px 0 rgba(255, 255, 255, .12);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .3s ease; will-change: transform, opacity; }
.panel::before { content: ""; position: absolute; left: 14px; right: 14px; top: -2px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--gold), transparent); }
.panel.away { transform: translate(-50%, 140%); opacity: 0; }
.meta { display: flex; justify-content: flex-start; align-items: center; font-size: 14px; color: var(--muted); }
.chip { background: rgba(63, 195, 216, .16); color: var(--accent-hi); border: 1px solid rgba(63, 195, 216, .45);
  padding: 2px 9px; border-radius: 999px; }
.panel h1 { font-size: clamp(22px, 4.8vw, 30px); font-weight: 600; margin: 8px 0 12px; line-height: 1.15; text-wrap: balance;
  color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); margin-bottom: 22px; }

.timer { position: relative; height: 10px; border-radius: 999px; background: rgba(0, 0, 0, .35);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .5); margin: 0 0 14px; }
.timer .fill { position: absolute; inset: 0; border-radius: inherit; transform-origin: left; will-change: transform;
  background: linear-gradient(90deg, var(--accent), #7fe0c9); transition: background-color .3s; }
.timer .fill.low { background: linear-gradient(90deg, var(--bad), #ff8a5c); }
.timer span { position: absolute; right: 0; top: -22px; font-size: 15px; font-weight: 700; color: var(--accent-hi);
  font-variant-numeric: tabular-nums; }

form { display: flex; gap: 8px; }
input { flex: 1; min-width: 0; font: inherit; font-size: 20px; padding: 10px 12px; border-radius: 10px; outline: none;
  color: #fff; background: rgba(4, 10, 28, .55); border: 2px solid rgba(120, 190, 235, .3);
  transition: border-color .2s, box-shadow .2s; }
input::placeholder { color: rgba(200, 220, 240, .45); }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(63, 195, 216, .25); }
button { font: inherit; font-weight: 700; font-size: 19px; padding: 10px 18px; border: 0; border-radius: 10px;
  background: linear-gradient(180deg, #f4cf63, var(--gold)); color: #2a1d08; cursor: pointer;
  box-shadow: 0 3px 0 #a87c1c, 0 6px 14px rgba(0, 0, 0, .3); transition: transform .12s, box-shadow .12s, filter .2s; }
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #a87c1c, 0 3px 8px rgba(0, 0, 0, .3); }
button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: rgba(255, 255, 255, .1); color: var(--text); box-shadow: inset 0 0 0 2px rgba(120, 190, 235, .35); }
.reject { margin: 10px 0 0; font-size: 16px; color: #ff9b8a; animation: rise .25s ease-out both; }
.suggest { margin: 10px 0 0; font-size: 17px; color: var(--muted); animation: rise .25s ease-out both; }
.suggest .was { text-decoration: line-through; text-decoration-color: rgba(255, 120, 120, .7); }
.suggest .now { color: var(--accent-hi); }
.suggest small { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.shake { animation: shake .3s ease-out; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
/* a wrong answer: the box flashes red and fades back */
.wrong input { animation: wrong 1.1s ease-out; }
@keyframes wrong { 0%, 35% { border-color: #ff4d5e; background: #4a1622; color: #ffd6db; } }

.reveal { display: grid; gap: 10px; }
.score-line { display: flex; gap: 14px; align-items: center; }
.big { font-size: 52px; font-weight: 700; line-height: .9; font-variant-numeric: tabular-nums; color: #fff; }
.big small { font-size: 18px; color: var(--muted); }
.tier { font-weight: 700; font-size: 20px; color: var(--gold); }
.you { font-size: 15px; color: var(--muted); }
.answers { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.answers li { position: relative; display: flex; justify-content: space-between; padding: 4px 10px; border-radius: 8px;
  background: rgba(0, 0, 0, .28); font-size: 16px; overflow: hidden; animation: rise .4s var(--d, 0ms) both cubic-bezier(.2,.8,.2,1); }
.answers li .bar { position: absolute; left: 0; top: 0; bottom: 0; width: var(--w); background: rgba(120, 190, 235, .18);
  border-radius: inherit; transform-origin: left; animation: grow .7s calc(var(--d, 0ms) + 120ms) both cubic-bezier(.2,.8,.2,1); }
.answers li.mine { box-shadow: inset 0 0 0 2px var(--accent); }
.answers li.mine .bar { background: rgba(63, 195, 216, .45); }
.answers li .label, .answers li .pct { position: relative; }

.final { bottom: auto; top: 50%; transform: translate(-50%, -50%); text-align: center; }
.final h1 { margin-top: 2px; }
.medal { margin: 8px auto 2px; display: inline-block; padding: 3px 12px; border-radius: 999px; font-weight: 600; font-size: 15px;
  color: var(--muted); background: rgba(255,255,255,.08); animation: rise .5s .9s both cubic-bezier(.2,.8,.2,1); }
.medal.gold { color: #2a1d08; background: linear-gradient(180deg, #ffe08a, #e9b949); }
.medal.silver { color: #1d2433; background: linear-gradient(180deg, #f2f5fa, #b9c3d3); }
.medal.bronze { color: #2b1408; background: linear-gradient(180deg, #f2b98a, #c97a45); }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.rows { list-style: none; padding: 0; margin: 4px 0 14px; display: grid; gap: 5px; text-align: left; max-height: min(52vh, 460px); overflow-y: auto; }
.rows li { border-radius: 10px; background: rgba(0, 0, 0, .28); overflow: hidden;
  animation: rise .45s var(--d, 0ms) both cubic-bezier(.2,.8,.2,1); }
.rows summary { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 10px; font-size: 16px;
  cursor: pointer; list-style: none; }
.rows summary::-webkit-details-marker { display: none; }
.rows summary:hover { background: rgba(255, 255, 255, .05); }
.rows summary .bar { position: absolute; left: 0; top: 0; bottom: 0; width: var(--w); background: var(--c); opacity: .22;
  transform-origin: left; animation: grow .7s calc(var(--d, 0ms) + 150ms) both cubic-bezier(.2,.8,.2,1); }
.rows summary > :not(.bar) { position: relative; }
.rows .chev { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px); transition: transform .25s; flex: none; }
.rows > li > details[open] > summary .chev { transform: rotate(225deg) translateY(-2px); }
.rows .detail { padding: 2px 10px 10px; animation: rise .3s both cubic-bezier(.2,.8,.2,1); }
.rows .dq { margin: 4px 0 2px; font-weight: 600; font-size: 15px; color: #fff; }
.rows .detail .you { margin: 0 0 8px; font-size: 13px; }
.rows .detail .answers li { font-size: 14px; padding: 3px 9px; }
.hint { margin: 2px 0 6px; font-size: 13px; color: var(--muted); }
.rows .qn { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: rgba(255,255,255,.12); color: var(--muted); flex: none; }
.rows .ans { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.popup { position: fixed; left: 0; right: 0; top: 24%; text-align: center; pointer-events: none; }
.pop-title { font-size: clamp(40px, 9vw, 76px); font-weight: 700; color: var(--pop, #fff); letter-spacing: 2px;
  text-shadow: 3px 0 var(--ink), -3px 0 var(--ink), 0 3px var(--ink), 0 -3px var(--ink), 3px 3px var(--ink), -3px -3px var(--ink), 3px -3px var(--ink), -3px 3px var(--ink), 6px 6px var(--ink); }
.pop-sub { font-size: clamp(22px, 4vw, 32px); font-weight: 700; color: var(--paper);
  text-shadow: 2px 0 var(--ink), -2px 0 var(--ink), 0 2px var(--ink), 0 -2px var(--ink), 3px 3px var(--ink); }
.popup.show { animation: pop 2.4s ease forwards; }
.popup.show .pop-title { animation: popin .45s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes popin { from { transform: scale(.4) translateY(20px); } to { transform: scale(1); } }
@keyframes pop { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

.bench { position: fixed; top: 52px; left: 16px; right: 16px; display: flex; flex-wrap: wrap; gap: 6px; }
.bench button { font-size: 14px; padding: 4px 8px; border-radius: 8px; box-shadow: 0 2px 0 #a87c1c; }

@media (max-width: 480px) {
  .brand small { display: none; }
  .dots span { width: 9px; height: 9px; }
  .big { font-size: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  .panel, #scene { transition: none; }
  .rows li, .rows summary .bar, .answers li, .answers li .bar, .medal { animation: none; }
  .popup.show .pop-title { animation: none; }
}

.ico { width: 24px; height: 24px; image-rendering: pixelated; vertical-align: -6px; }
.chip .ico { width: 18px; height: 18px; vertical-align: -4px; }
.big-ico { width: 36px; height: 36px; margin: 0 2px; }
.bench .ico { width: 18px; height: 18px; vertical-align: -4px; }

.hud-right { display: flex; align-items: center; gap: 10px; }
.mute { padding: 5px 7px; line-height: 0; background: rgba(255,255,255,.9); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.mute .ico { width: 24px; height: 24px; }
.mute { pointer-events: auto; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 10px; }
.stats div { background: rgba(0, 0, 0, .25); border-radius: 10px; padding: 6px 2px; }
.stats dt { font-size: 11px; color: var(--muted); }
.stats dd { margin: 0; font-size: 20px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.next { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.next b { color: #fff; font-variant-numeric: tabular-nums; }
.foot { position: fixed; right: 12px; bottom: 6px; font-size: 12px; z-index: 6; }
.foot a { color: rgba(200, 220, 240, .5); text-decoration: none; }
.foot a:hover { color: var(--text); }

/* ---------- home ---------- */
.home { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px 12vh; text-align: center; color: var(--text); z-index: 5;
  background: radial-gradient(ellipse 75% 62% at 50% 48%, rgba(6, 12, 30, .78), rgba(6, 12, 30, 0) 72%);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  transition: opacity .6s ease; }
.home.leaving { opacity: 0; pointer-events: none; }
body.at-home .hud { opacity: 0; }
.hud { transition: opacity .5s; }
.logo { margin: 0; line-height: 0; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .5)); }
.logo svg { display: block; image-rendering: pixelated; }
/* the page's one designed moment: the wordmark drops in and lands like a clean entry */
.logo { animation: drop .9s cubic-bezier(.3, 1.35, .5, 1) both; }
@keyframes drop { from { transform: translateY(-40px); opacity: 0; } 60% { opacity: 1; } to { transform: none; opacity: 1; } }
.tag { margin: 22px 0 26px; font-size: clamp(17px, 2.4vw, 21px); line-height: 1.45; color: #d6e4f5; font-weight: 500; }
.modes { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.start { display: flex; flex-direction: column; align-items: center; min-width: 200px; font-size: 24px; padding: 13px 30px 12px;
  border-radius: 14px; letter-spacing: .5px; box-shadow: 0 5px 0 #a87c1c, 0 14px 30px rgba(0, 0, 0, .45); }
.start small { font-size: 14px; font-weight: 600; letter-spacing: 0; opacity: .8; margin-top: 1px; }
.start:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #a87c1c, 0 18px 34px rgba(0, 0, 0, .45); filter: none; }
.start:active { transform: translateY(3px); box-shadow: 0 2px 0 #a87c1c, 0 8px 16px rgba(0, 0, 0, .4); }
.start.deep { background: linear-gradient(180deg, #6fdcec, var(--accent)); color: #06243a; box-shadow: 0 5px 0 #1d7f93, 0 14px 30px rgba(0, 0, 0, .45); }
.start.deep:hover { box-shadow: 0 7px 0 #1d7f93, 0 18px 34px rgba(0, 0, 0, .45); }
.start.deep:active { box-shadow: 0 2px 0 #1d7f93, 0 8px 16px rgba(0, 0, 0, .4); }
@media (max-width: 480px) { .start { min-width: 0; flex: 1; padding: 12px 10px 11px; font-size: 21px; } .start small { font-size: 12.5px; } .modes { width: 100%; flex-wrap: nowrap; gap: 10px; } }
.home-meta { margin: 16px 0 0; font-size: 14px; color: #c9d8ea; font-variant-numeric: tabular-nums; text-shadow: 0 1px 3px rgba(0, 0, 0, .9); }
.how { margin-top: 14px; max-width: 460px; text-align: left; font-size: 15px; color: #c9d8ea; }
.how summary { cursor: pointer; text-align: center; color: var(--accent-hi); font-weight: 600; list-style: none; text-shadow: 0 1px 3px rgba(0, 0, 0, .9); }
.how summary::-webkit-details-marker { display: none; }
.how ol { margin: 10px 0 0; padding: 12px 14px 12px 32px; background: rgba(6, 12, 30, .6); border-radius: 12px; }
.how li + li { margin-top: 6px; }
::selection { background: rgba(63, 195, 216, .4); color: #fff; }
@media (prefers-reduced-motion: reduce) { .logo { animation: none; } }

.answers li.gap { display: block; text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; background: none; }
.answers li.gap::before { content: none; }

/* medal groups in the answer breakdown */
.answers li.cat { display: block; padding: 0; background: rgba(255, 255, 255, .05); }
.answers li.cat.mine { box-shadow: inset 0 0 0 2px var(--c); }
.answers li.cat summary { display: flex; align-items: center; gap: 8px; padding: 5px 10px; cursor: pointer; list-style: none; }
.answers li.cat summary::-webkit-details-marker { display: none; }
.answers li.cat .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25); flex: none; }
.answers li.cat .label { flex: 1; font-weight: 600; }
.answers li.cat .n { font-size: 13px; color: var(--muted); }
.answers li.cat.mine .n { color: var(--c); font-weight: 700; }
.answers li.cat .chev { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; margin: -3px 2px 0 4px; }
.answers li.cat details[open] .chev { transform: rotate(-135deg); margin-top: 3px; }
.answers li.cat .names { margin: 0; padding: 0 10px 8px 30px; font-size: 14px; line-height: 1.5; color: #d6e4f5; animation: rise .25s both; }
.answers li.cat .names .me { color: var(--c); font-weight: 700; }
.rows .detail .answers li.cat { padding: 0; font-size: 15px; }

/* ad spots: home screen and results only, clearly apart from the buttons */
.ad { width: min(100%, 468px); min-height: 60px; margin: 22px auto 0; }
.final .ad { margin-top: 28px; }
