/* Jev Quiz: a late-night game show. A dark stage under warm spotlights, a marquee sign, chunky
   coloured tiles that press like real buttons, one bold yellow. */
:root {
  --bg: #0f0e17;
  --surface: #1b1a26;
  --line: #2c2a3a;
  --text: #fff6e0;
  --muted: #a9a3b8;
  --accent: #ffc933;      /* marquee yellow */
  --accent-deep: #c78f00;
  --right: #38d9a9;
  --wrong: #ff5a4e;
  --sky: #4db3ff;
  --pink: #ff7ac6;
  --orange: #ff9a3c;
  --sign: "Bungee", "Arial Black", ui-sans-serif, sans-serif;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.5 var(--body); }
body { min-height: 100dvh; padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom); overflow-x: hidden; }
main { max-width: 680px; margin: 0 auto; position: relative; z-index: 1; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* The stage: three soft spotlights sweeping slowly over the dark. */
.stage { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.beam {
  position: absolute; top: -20vh; width: 44vw; height: 140vh; filter: blur(40px); opacity: 0.16;
  background: linear-gradient(180deg, var(--c), transparent 75%);
  clip-path: polygon(42% 0, 58% 0, 100% 100%, 0 100%); transform-origin: 50% 0;
  animation: sweep 14s ease-in-out infinite alternate;
}
.b1 { --c: #ffc933; left: -8vw; animation-duration: 13s; }
.b2 { --c: #ff7ac6; left: 30vw; animation-duration: 17s; animation-delay: -6s; opacity: 0.11; }
.b3 { --c: #4db3ff; right: -10vw; animation-duration: 15s; animation-delay: -3s; opacity: 0.12; }
@keyframes sweep { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }
body.flash-right .stage { animation: flash-right 420ms var(--ease); }
body.flash-wrong .stage { animation: flash-wrong 420ms var(--ease); }
@keyframes flash-right { 30% { background: color-mix(in srgb, var(--right) 16%, transparent); } }
@keyframes flash-wrong { 30% { background: color-mix(in srgb, var(--wrong) 14%, transparent); } }

.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }

.mute {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 16px; z-index: 20; width: 44px; height: 44px;
  border-radius: 50%; border: 0; background: color-mix(in srgb, var(--surface) 80%, transparent); display: grid; place-items: center;
}
.mute svg { width: 22px; height: 22px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mute svg path:first-child { fill: var(--text); }
.mute .x { display: none; }
.mute[aria-pressed="true"] .waves { display: none; }
.mute[aria-pressed="true"] .x { display: inline; }

.screen { padding-block: 64px 96px; animation: in 260ms var(--ease); }
@keyframes in { from { opacity: 0; transform: translateY(10px); } }

/* Home: the marquee sign */
.intro { text-align: center; }
.marquee {
  position: relative; display: inline-flex; gap: 0.28em; margin: 8px 0 0; padding: 0.42em 0.6em 0.38em;
  font: 400 clamp(56px, 15vw, 104px)/0.9 var(--sign); letter-spacing: 0.01em; color: var(--accent);
  border-radius: 28px; background: linear-gradient(180deg, #1f1d2c, #151420);
  box-shadow: inset 0 0 0 3px #2f2c40, 0 18px 50px -20px rgba(255, 201, 51, 0.45);
  text-shadow: 0 0 22px rgba(255, 201, 51, 0.55), 0 4px 0 var(--accent-deep);
  animation: sign-on 900ms var(--bounce) both;
}
.marquee span:nth-of-type(2) { color: var(--text); text-shadow: 0 0 20px rgba(255, 246, 224, 0.35), 0 4px 0 #6b6480; }
@keyframes sign-on { from { transform: scale(0.8) rotate(-3deg); opacity: 0; } }
.bulb {
  position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%;
  background: #fff3c4; box-shadow: 0 0 8px 2px rgba(255, 201, 51, 0.8); animation: chase 1.2s steps(1) infinite;
}
@keyframes chase { 50% { background: #5a4a1c; box-shadow: none; } }
.intro p { color: var(--muted); font-size: 19px; margin: 26px auto 38px; max-width: 28ch; }

.ask {
  display: flex; align-items: center; gap: 8px; padding: 7px; background: var(--surface);
  border: 2px solid var(--line); border-radius: 20px; transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.ask:focus-within, .ask.listening { border-color: var(--accent); box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 14%, transparent); }
.ask input { flex: 1; min-width: 0; background: none; border: 0; outline: none; padding: 12px 4px; font: 500 20px var(--display); }
.ask input::placeholder { color: #75708a; }
.say {
  flex: none; width: 50px; height: 50px; border-radius: 14px; border: 0; background: var(--line); display: grid; place-items: center;
  transition: background 150ms var(--ease), transform 150ms var(--ease);
}
.say svg { width: 22px; height: 22px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.say:hover { background: #3a374c; }
.say:active { transform: scale(0.94); }
.say[aria-pressed="true"] { background: var(--accent); animation: listen 1.2s var(--ease) infinite; }
.say[aria-pressed="true"] svg { stroke: #111; }
@keyframes listen { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 22%, transparent); } }
.ask button[type="submit"], .primary {
  background: var(--accent); color: #1a1405; border: 0; border-radius: 14px; padding: 13px 24px;
  font: 400 18px var(--sign); letter-spacing: 0.02em; box-shadow: 0 5px 0 var(--accent-deep);
  transition: transform 90ms var(--ease), box-shadow 90ms var(--ease);
}
.ask button[type="submit"]:active, .primary:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--accent-deep); }
.ask button[type="submit"]:disabled { opacity: 0.7; cursor: progress; }
.ask-hint { color: var(--muted); margin: 14px 4px 0; font-size: 15px; min-height: 1.5em; text-align: center; }

/* Topic tiles: each category its own colour, pressable, a little askew like a real board. */
.catalogue { margin-top: 56px; display: grid; gap: 40px; }
.catalogue h2 { font: 400 15px var(--sign); color: var(--c, var(--accent)); letter-spacing: 0.08em; margin: 0 0 14px; }
.catalogue section:nth-child(6n + 1) { --c: #ffc933; --cd: #b58400; }
.catalogue section:nth-child(6n + 2) { --c: #ff7ac6; --cd: #b53d86; }
.catalogue section:nth-child(6n + 3) { --c: #4db3ff; --cd: #1f73b8; }
.catalogue section:nth-child(6n + 4) { --c: #38d9a9; --cd: #1b8f6c; }
.catalogue section:nth-child(6n + 5) { --c: #ff9a3c; --cd: #b8621a; }
.catalogue section:nth-child(6n + 6) { --c: #ff5a4e; --cd: #b0302a; }
.chips { display: flex; flex-wrap: wrap; gap: 12px; list-style: none; padding: 0; margin: 0; }
.chips li:nth-child(3n + 1) button { rotate: -1.2deg; }
.chips li:nth-child(3n + 2) button { rotate: 0.8deg; }
.chips li:nth-child(3n) button { rotate: -0.4deg; }
.chips button {
  display: inline-flex; align-items: baseline; gap: 8px; border: 0; background: var(--c); color: #16121f; border-radius: 14px;
  padding: 11px 16px 10px; font: 700 18px/1.2 var(--display); box-shadow: 0 5px 0 var(--cd);
  transition: transform 90ms var(--ease), box-shadow 90ms var(--ease), filter 150ms var(--ease);
}
.chips button:hover { filter: brightness(1.08); transform: translateY(-2px); box-shadow: 0 7px 0 var(--cd); }
.chips button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--cd); }
.chips .best { font: 400 12px var(--sign); background: rgba(22, 18, 31, 0.16); padding: 2px 7px; border-radius: 8px; }
.duel-link { text-align: center; margin-top: 56px; }
.duel-link a { color: var(--accent); font: 400 15px var(--sign); letter-spacing: 0.04em; text-decoration: none; }
.duel-link a:hover { text-decoration: underline; text-underline-offset: 5px; }

.error { color: var(--wrong); margin-top: 16px; text-align: center; }

/* A friend's challenge link: their score, one big button. */
.challenge {
  margin: 0 0 34px; padding: 24px; border-radius: 22px; text-align: center; background: var(--surface);
  border: 3px dashed var(--pink); rotate: -0.6deg; animation: in 400ms var(--bounce);
}
.challenge-line { font: 700 24px/1.3 var(--display); margin: 0 0 18px; }
.challenge-line b { font: 400 30px var(--sign); color: var(--pink); }
.primary.big { font-size: 22px; padding: 16px 30px; }
.share {
  background: var(--pink); color: #16121f; border: 0; border-radius: 14px; padding: 13px 22px;
  font: 400 16px var(--sign); letter-spacing: 0.02em; box-shadow: 0 5px 0 #b53d86; transition: transform 90ms var(--ease), box-shadow 90ms var(--ease);
}
.share:active { transform: translateY(4px); box-shadow: 0 1px 0 #b53d86; }
.actions { flex-wrap: wrap; }

/* Countdown: each number punches in, a ring blows out behind it. */
.topic-label { color: var(--muted); font: 700 20px var(--display); margin: 0; text-align: center; }
.count-wrap { display: grid; place-items: center; margin: 40px 0; min-height: 260px; }
.count { font: 400 clamp(150px, 42vw, 240px)/1 var(--sign); margin: 0; color: var(--accent); text-shadow: 0 8px 0 var(--accent-deep), 0 0 50px rgba(255, 201, 51, 0.5); position: relative; }
.count.hit { animation: punch 620ms var(--bounce); }
.count.hit::after {
  content: ""; position: absolute; inset: 50% auto auto 50%; width: 1.1em; height: 1.1em; margin: -0.55em 0 0 -0.55em;
  border-radius: 50%; border: 6px solid currentColor; animation: ring 620ms var(--ease) forwards;
}
.count.c3 { color: var(--pink); text-shadow: 0 8px 0 #b53d86, 0 0 50px rgba(255, 122, 198, 0.5); }
.count.c2 { color: var(--sky); text-shadow: 0 8px 0 #1f73b8, 0 0 50px rgba(77, 179, 255, 0.5); }
.count.go { color: var(--right); text-shadow: 0 8px 0 #1b8f6c, 0 0 60px rgba(56, 217, 169, 0.6); }
@keyframes punch { from { transform: scale(2.1) rotate(-8deg); opacity: 0; } 60% { opacity: 1; } }
@keyframes ring { from { transform: scale(0.4); opacity: 0.9; } to { transform: scale(2.2); opacity: 0; } }
.hint { color: var(--muted); text-align: center; font-size: 18px; }

/* Play */
.hud { display: flex; align-items: center; gap: 18px; }
.timer { flex: 1; height: 16px; background: var(--line); border-radius: 99px; overflow: hidden; box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.3); }
#timer-fill {
  height: 100%; width: 100%; transform-origin: left; border-radius: 99px;
  background: repeating-linear-gradient(-45deg, var(--accent) 0 12px, #ffd966 12px 24px);
  background-size: 34px 34px; animation: stripes 700ms linear infinite;
}
#timer-fill.low { background: repeating-linear-gradient(-45deg, var(--wrong) 0 12px, #ff8a80 12px 24px); background-size: 34px 34px; animation-duration: 350ms; }
@keyframes stripes { to { background-position: 34px 0; } }
.score {
  font: 400 34px/1 var(--sign); margin: 0; min-width: 2.4ch; text-align: center; padding: 10px 14px 8px; border-radius: 16px;
  background: var(--accent); color: #1a1405; box-shadow: 0 5px 0 var(--accent-deep);
}
.score span { display: inline-block; }
.score span.bump { animation: bump 380ms var(--bounce); }
@keyframes bump { 40% { transform: scale(1.6) rotate(-6deg); } }

.streak {
  margin: 18px 0 0; text-align: right; font: 400 16px var(--sign); color: var(--orange); letter-spacing: 0.04em;
  animation: streak-in 420ms var(--bounce);
}
@keyframes streak-in { from { transform: scale(0.4) rotate(8deg); opacity: 0; } }

.card { margin-top: 48px; min-height: 280px; transition: opacity 140ms var(--ease), transform 140ms var(--ease); }
.card.out { opacity: 0; transform: translateX(-30px) rotate(-2deg); }
.card.in { animation: card-in 300ms var(--bounce); }
@keyframes card-in { from { opacity: 0; transform: translateX(40px) rotate(2deg); } }
.prompt { font: 800 clamp(34px, 8vw, 54px)/1.06 var(--display); letter-spacing: -0.025em; margin: 0; }
.choices { list-style: none; padding: 0; margin: 34px 0 0; display: grid; gap: 12px; counter-reset: c; }
.choices li {
  display: flex; gap: 14px; align-items: center; padding: 15px 18px; border-radius: 16px; background: var(--surface);
  border: 2px solid var(--line); font: 600 20px var(--display); transition: border-color 120ms var(--ease), background 120ms var(--ease), transform 160ms var(--bounce);
}
.choices .n {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; font: 400 16px var(--sign); color: #16121f;
}
.choices li:nth-child(1) .n { background: var(--accent); }
.choices li:nth-child(2) .n { background: var(--pink); }
.choices li:nth-child(3) .n { background: var(--sky); }
.choices li:nth-child(4) .n { background: var(--right); }
.choices li.hover { border-color: var(--accent); transform: scale(1.02); }
.choices li.right { border-color: var(--right); background: color-mix(in srgb, var(--right) 20%, var(--surface)); transform: scale(1.04); }
.choices li.wrong { border-color: var(--wrong); background: color-mix(in srgb, var(--wrong) 18%, var(--surface)); }

.card.right .prompt { color: var(--right); animation: pop 300ms var(--bounce); }
.card.wrong { animation: shake 380ms var(--ease); }
.card.wrong .prompt { color: var(--wrong); }
@keyframes pop { 50% { transform: scale(1.04); } }
@keyframes shake { 20% { transform: translateX(-10px) rotate(-1deg); } 40% { transform: translateX(9px) rotate(1deg); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
.reveal { font: 600 22px var(--display); color: var(--muted); margin-top: 20px; }
.reveal b { color: var(--text); }

.heard { display: flex; align-items: center; gap: 12px; margin-top: 36px; min-height: 32px; }
.mic { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); flex: none; transform: scale(var(--level, 0.6)); transition: transform 60ms linear; }
.heard-text { margin: 0; color: var(--muted); font: 500 20px var(--display); }
.quiet { background: none; border: 0; color: var(--muted); padding: 10px 0; margin-top: 30px; text-decoration: underline; text-underline-offset: 4px; }
.quiet:hover { color: var(--text); }

/* Done */
.big-score {
  font: 400 clamp(150px, 44vw, 250px)/1 var(--sign); text-align: center; margin: 18px 0 0; color: var(--accent);
  text-shadow: 0 10px 0 var(--accent-deep), 0 0 70px rgba(255, 201, 51, 0.45);
}
.big-score span { display: inline-block; animation: slam 700ms var(--bounce) both; }
@keyframes slam { from { transform: scale(3) rotate(-10deg); opacity: 0; } 50% { opacity: 1; } }
.stamp {
  width: fit-content; margin: 4px auto 0; padding: 6px 14px 4px; border: 3px solid var(--pink); color: var(--pink); border-radius: 10px;
  font: 400 22px var(--sign); letter-spacing: 0.04em; rotate: -6deg; animation: stamp 500ms var(--bounce) 450ms both;
}
@keyframes stamp { from { transform: scale(2.4); opacity: 0; } }
.verdict { text-align: center; font: 600 21px var(--display); color: var(--muted); margin: 16px 0 38px; }
.actions { display: flex; gap: 24px; justify-content: center; align-items: center; }
.actions .quiet { margin: 0; }
.review { list-style: none; padding: 0; margin: 60px 0 0; border-top: 2px solid var(--line); }
.review li { display: grid; grid-template-columns: 28px 1fr; gap: 4px 12px; padding: 16px 0; border-bottom: 2px solid var(--line); }
.review .mark { font: 400 18px var(--sign); }
.review .mark.ok { color: var(--right); }
.review .mark.no { color: var(--wrong); }
.review .q { font: 700 17px var(--display); }
.review .said { grid-column: 2; color: var(--muted); font-size: 15px; }

.debug { position: fixed; right: 12px; bottom: calc(8px + env(safe-area-inset-bottom)); margin: 0; font: 12px ui-monospace, monospace; color: #4a465c; z-index: 1; }

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