:root {
  --purple: #46178f;
  --purple-dark: #2b0f5a;
  --purple-light: #6a2fc4;
  --red: #e21b3c;
  --blue: #1368ce;
  --yellow: #d89e00;
  --green: #26890c;
  --good: #66bf39;
  --bad: #f35;
  --ink: #1e1e1e;
  --white: #fff;
  --radius: 10px;
  --shadow: 0 6px 0 rgba(0,0,0,.25);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Montserrat', system-ui, sans-serif;
  background: var(--purple);
  color: var(--white);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }

/* Floating background shapes */
.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.bg span { position: absolute; opacity: .08; background: #fff; animation: float 22s linear infinite; }
.bg .c { border-radius: 50%; }
.bg .s { transform: rotate(45deg); }
@keyframes float { from { transform: translateY(110vh) rotate(0); } to { transform: translateY(-30vh) rotate(360deg); } }

main { position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column; }
.screen { display: none; flex: 1; flex-direction: column; align-items: center; padding: 16px; animation: pop .35s ease; }
.screen.active { display: flex; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }

.logo { font-weight: 900; font-size: clamp(2.6rem, 9vw, 4.5rem); letter-spacing: -2px; text-shadow: 0 5px 0 rgba(0,0,0,.25); margin: 4vh 0 2vh; }
.logo b { color: #ffd23f; }

.card { background: var(--white); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; width: 100%; max-width: 420px; }
.card h2 { font-weight: 800; margin-bottom: 14px; }
.field { width: 100%; padding: 13px 14px; border: 2px solid #ccc; border-radius: 6px; margin-bottom: 10px; font-weight: 700; }
.field:focus { outline: none; border-color: var(--purple); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 20px; border-radius: 6px;
       font-weight: 800; font-size: 1rem; color: #fff; background: #333; box-shadow: 0 4px 0 rgba(0,0,0,.3); transition: transform .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.3); }
.btn.block { width: 100%; }
.btn.primary { background: var(--purple); }
.btn.green { background: var(--green); }
.btn.ghost { background: rgba(255,255,255,.15); box-shadow: none; }
.btn.big { font-size: 1.6rem; padding: 20px 40px; border-radius: 10px; }
.link { background: none; color: var(--purple); font-weight: 800; text-decoration: underline; }
.error { color: var(--red); font-weight: 700; min-height: 1.3em; margin-bottom: 8px; font-size: .9rem; }

/* Top bar */
.topbar { width: 100%; max-width: 900px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.topbar .me { font-weight: 800; background: rgba(0,0,0,.25); padding: 8px 14px; border-radius: 30px; }
.topbar .actions { display: flex; gap: 8px; }
.icon-btn { background: rgba(0,0,0,.25); color: #fff; border-radius: 30px; padding: 8px 14px; font-weight: 800; }

/* Home */
.home-grid { width: 100%; max-width: 900px; display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 760px) { .home-grid { grid-template-columns: 1fr 1fr; } }
.play-hero { text-align: center; padding: 26px 18px; background: rgba(0,0,0,.2); border-radius: var(--radius); }
.play-hero p { opacity: .9; margin: 10px 0 18px; font-weight: 600; }
.play-btn { background: #fff; color: var(--purple); font-size: 2rem; padding: 18px 54px; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.stat { background: rgba(255,255,255,.12); border-radius: 8px; padding: 10px 4px; }
.stat b { display: block; font-size: 1.35rem; font-weight: 900; }
.stat small { font-weight: 700; opacity: .85; font-size: .72rem; text-transform: uppercase; }

.board { background: #fff; color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.board h3 { font-weight: 900; padding: 14px 16px 8px; display: flex; align-items: center; gap: 8px; }
.tabs { display: flex; gap: 6px; padding: 0 16px 10px; }
.tab { flex: 1; padding: 8px; border-radius: 6px; background: #eee; font-weight: 800; color: #555; font-size: .85rem; }
.tab.on { background: var(--purple); color: #fff; }
.rows { max-height: 420px; overflow-y: auto; }
.row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid #eee; font-weight: 700; }
.row .pos { font-weight: 900; text-align: center; }
.row .sub { font-size: .75rem; color: #777; font-weight: 600; }
.row .pts { font-weight: 900; }
.row.me { background: #f2ebff; }
.row:nth-child(1) .pos { color: #d4a000; } .row:nth-child(2) .pos { color: #8c8c8c; } .row:nth-child(3) .pos { color: #b0662d; }
.empty { padding: 24px; text-align: center; color: #777; font-weight: 600; }

/* Get ready / interstitial */
.center-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; }
.countdown { font-size: 9rem; font-weight: 900; text-shadow: 0 8px 0 rgba(0,0,0,.25); animation: zoom .9s ease; }
@keyframes zoom { from { transform: scale(2.2); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); } }
.qnum-badge { background: #fff; color: var(--purple); font-weight: 900; font-size: 1.4rem; padding: 12px 26px; border-radius: 40px; box-shadow: var(--shadow); }
.progress-dots { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; max-width: 420px; }
.progress-dots i { width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,.25); }
.progress-dots i.ok { background: var(--good); } .progress-dots i.no { background: var(--bad); } .progress-dots i.now { background: #fff; transform: scale(1.3); }

/* Question screen */
#screen-question { padding: 0; background: #f2f2f2; color: var(--ink); }
.q-head { width: 100%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.12); padding: 18px 16px; text-align: center; }
.q-text { font-weight: 800; font-size: clamp(1.15rem, 3.6vw, 2rem); max-width: 1000px; margin: 0 auto; line-height: 1.25; }
.q-mid { width: 100%; max-width: 1100px; flex: 1; display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; gap: 12px; }
.timer { width: 86px; height: 86px; border-radius: 50%; position: relative; display: grid; place-items: center; flex-shrink: 0; }
.timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 8; }
.timer .track { stroke: #ddd; } .timer .arc { stroke: var(--purple); stroke-linecap: round; transition: stroke .3s; }
.timer.low .arc { stroke: var(--red); } .timer.low b { color: var(--red); animation: throb .5s ease-in-out infinite; }
.timer b { font-size: 2rem; font-weight: 900; position: relative; }
@keyframes throb { 50% { transform: scale(1.18); } }
.q-pot { text-align: center; font-weight: 800; color: var(--purple); }
.q-pot small { display: block; color: #666; text-transform: uppercase; font-size: .72rem; }
.q-pot b { display: block; font-size: clamp(2.6rem, 9vw, 5.5rem); font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; }
.q-pot b::before { content: '⚡'; font-size: .6em; margin-right: 4px; vertical-align: middle; }
.q-pot span { color: #ff7a00; font-weight: 900; font-size: .9rem; }
.q-score { text-align: center; font-weight: 800; }
.q-score b { display: block; font-size: 1.6rem; font-weight: 900; }
.q-score small { color: #666; text-transform: uppercase; font-size: .7rem; }
.streak-pill { background: #ff7a00; color: #fff; font-weight: 900; padding: 4px 10px; border-radius: 20px; font-size: .85rem; display: inline-block; margin-top: 4px; }
.answers { width: 100%; max-width: 1100px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 10px 12px; }
.ans { min-height: 92px; border-radius: 6px; color: #fff; font-weight: 800; font-size: clamp(1rem, 2.6vw, 1.4rem); text-align: left;
       display: flex; align-items: center; gap: 14px; padding: 14px 16px; box-shadow: 0 5px 0 rgba(0,0,0,.25); transition: transform .1s, opacity .25s, filter .25s; }
.ans:hover { filter: brightness(1.08); }
.ans:active { transform: translateY(3px); }
.ans svg { width: 38px; height: 38px; flex-shrink: 0; fill: #fff; }
.ans.a0 { background: var(--red); } .ans.a1 { background: var(--blue); } .ans.a2 { background: var(--yellow); } .ans.a3 { background: var(--green); }
.ans.dim { opacity: .3; } .ans.picked { outline: 4px solid #fff; outline-offset: -8px; }
.ans.right { animation: bounce .5s ease; }
.ans .tick { margin-left: auto; font-size: 1.8rem; }
@keyframes bounce { 40% { transform: scale(1.04); } }
.ans:disabled { cursor: default; }
@media (max-width: 520px) { .answers { grid-template-columns: 1fr; } .ans { min-height: 64px; } .timer { width: 70px; height: 70px; } .timer b { font-size: 1.6rem; } }

/* Feedback banner */
#screen-feedback { justify-content: center; }
#screen-feedback.good { background: var(--good); } #screen-feedback.bad { background: var(--red); } #screen-feedback.late { background: #555; }
.fb-title { font-size: clamp(2.4rem, 8vw, 4rem); font-weight: 900; text-shadow: 0 5px 0 rgba(0,0,0,.2); }
.fb-icon { font-size: 5rem; animation: zoom .5s ease; }
.fb-points { background: rgba(0,0,0,.25); padding: 12px 26px; border-radius: 40px; font-weight: 900; font-size: 1.6rem; }
.fb-note { font-weight: 700; opacity: .95; max-width: 520px; }
.fb-streak { font-weight: 900; font-size: 1.2rem; }

/* Results */
.results { width: 100%; max-width: 640px; text-align: center; }
.podium-score { font-size: clamp(3rem, 12vw, 5.5rem); font-weight: 900; text-shadow: 0 6px 0 rgba(0,0,0,.25); line-height: 1; }
.medal { font-size: 4rem; animation: zoom .7s ease; }
.badge-pb { display: inline-block; background: #ffd23f; color: var(--ink); font-weight: 900; padding: 6px 14px; border-radius: 20px; margin: 10px 0; animation: pulse 1.4s infinite; }
.res-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; }
.res-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.review { background: #fff; color: var(--ink); border-radius: var(--radius); text-align: left; overflow: hidden; margin-bottom: 30px; }
.review summary { padding: 14px 16px; font-weight: 900; cursor: pointer; }
.rv { padding: 10px 16px; border-top: 1px solid #eee; font-size: .92rem; }
.rv b { display: block; margin-bottom: 3px; }
.rv .ok { color: var(--green); font-weight: 800; } .rv .no { color: var(--red); font-weight: 800; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 12px 18px; border-radius: 8px; font-weight: 700; z-index: 60; }
.hidden { display: none !important; }
