/* Trivia Sprint + Daily Trivia (Arena13 originals). Shared styles. */
@font-face { font-family: "Unbounded"; src: url("/fonts/unbounded-latin-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-display: swap; }
@font-face { font-family: "Inter Tight"; src: url("/fonts/inter-tight-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  /* arcade (default) */
  --bg: #170b3b; --s1: #241258; --s2: #301a6e; --s3: #3e2589;
  --tx: #ffffff; --mu: #cdc3f5; --mu2: #9789d0;
  --gold: #ffc531; --on-gold: #3a2000; --vio: #b57bff; --hot: #ff3d7f; --good: #2fe08a;
  --line: rgba(255, 255, 255, .1); --line2: rgba(255, 255, 255, .2);
  --accent: var(--gold); --on-accent: var(--on-gold);
  --play-bg: linear-gradient(180deg, #3ee57f, #16b455); --play-tx: #05290f;
  --play-sh: 0 4px 0 #0a7d37, 0 10px 20px -8px rgba(22, 180, 85, .7), inset 0 1px 0 rgba(255, 255, 255, .45);
  --play-sh-down: 0 1px 0 #0a7d37, inset 0 1px 0 rgba(255, 255, 255, .45);
  --ans-bg: linear-gradient(180deg, #33197d, #28125f);
  --ans-sh: 0 4px 0 #12073a, inset 0 1px 0 rgba(255, 255, 255, .12);
  --ans-sh-down: 0 1px 0 #12073a, inset 0 1px 0 rgba(255, 255, 255, .12);
  --card-bg: linear-gradient(180deg, #2e1874, #22105a);
  --card-sh: inset 0 1px 0 rgba(255, 255, 255, .12), inset 0 0 0 1px rgba(255, 255, 255, .07), 0 8px 20px -12px rgba(5, 0, 25, .85);
  --good-bg: linear-gradient(180deg, #45ec90, #19bd5c); --good-tx: #05290f; --good-sh: 0 4px 0 #0a7d37;
  --hot-bg: linear-gradient(180deg, #ff5b93, #e8246a); --hot-tx: #ffffff; --hot-sh: 0 4px 0 #9c0f43;
  --key-bg: rgba(255, 255, 255, .1); --track: rgba(8, 2, 30, .45);
  --page: radial-gradient(520px 320px at 100% -60px, rgba(255, 61, 127, .22), transparent 70%),
          radial-gradient(620px 380px at -10% -40px, rgba(70, 110, 255, .2), transparent 70%),
          linear-gradient(180deg, #240d5e 0, #170b3b 420px);
  --num: "Unbounded", "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --ui: "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --r: 14px;
  color-scheme: dark;
}
[data-theme="dark"] {
  --bg: #0b1020; --s1: #141a2e; --s2: #1c2440; --s3: #26304f;
  --tx: #f2f4fa; --mu: #a7afc6; --mu2: #7d86a0;
  --gold: #f5b94a; --on-gold: #0b1020; --vio: #8a6cff; --hot: #ff4d6d; --good: #3dd68c;
  --line: rgba(167, 175, 198, .16); --line2: rgba(167, 175, 198, .3);
  --play-bg: #f5b94a; --play-tx: #0b1020; --play-sh: none; --play-sh-down: none;
  --ans-bg: #141a2e; --ans-sh: inset 0 0 0 1px rgba(167, 175, 198, .16); --ans-sh-down: inset 0 0 0 1px rgba(167, 175, 198, .3);
  --card-bg: #141a2e; --card-sh: inset 0 0 0 1px rgba(167, 175, 198, .14);
  --good-bg: #3dd68c; --good-tx: #0b1020; --good-sh: none;
  --hot-bg: #ff4d6d; --hot-tx: #0b1020; --hot-sh: none;
  --key-bg: rgba(167, 175, 198, .14); --track: #1c2440;
  --page: #0b1020;
}
[data-theme="light"] {
  --bg: #f4f6fb; --s1: #ffffff; --s2: #eef1f8; --s3: #e2e7f2;
  --tx: #141a2e; --mu: #4b5470; --mu2: #6b7390;
  --gold: #e08a00; --on-gold: #ffffff; --vio: #6b4eff; --hot: #e5304f; --good: #129e5b;
  --line: rgba(75, 84, 112, .16); --line2: rgba(75, 84, 112, .3);
  --accent: var(--vio); --on-accent: #ffffff;
  --play-bg: #6b4eff; --play-tx: #ffffff; --play-sh: 0 8px 18px -10px rgba(107, 78, 255, .7); --play-sh-down: none;
  --ans-bg: #ffffff; --ans-sh: inset 0 0 0 1px rgba(75, 84, 112, .18), 0 2px 6px -3px rgba(20, 26, 46, .18);
  --ans-sh-down: inset 0 0 0 1px rgba(75, 84, 112, .3);
  --card-bg: #ffffff; --card-sh: inset 0 0 0 1px rgba(75, 84, 112, .12), 0 6px 18px -12px rgba(20, 26, 46, .25);
  --good-bg: #129e5b; --good-tx: #ffffff; --good-sh: none;
  --hot-bg: #e5304f; --hot-tx: #ffffff; --hot-sh: none;
  --key-bg: #eef1f8; --track: #e2e7f2;
  --page: #f4f6fb;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--tx);
  font: 500 15px/1.35 var(--ui); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
body { background: var(--page); background-color: var(--bg); background-repeat: no-repeat; }
button, a { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------- header ---------- */
.bar {
  flex: none; height: calc(48px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand svg { width: 26px; height: 26px; flex: none; }
.brand b { font: 700 15px/1 var(--num); letter-spacing: -.01em; white-space: nowrap; }
.pill {
  font-size: 12px; font-weight: 650; color: var(--mu); background: var(--s2); border-radius: 999px;
  padding: 4px 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
@media (max-width: 420px) { .in-quiz .pill { display: none; } }
.bar-r { display: flex; align-items: center; gap: 2px; flex: none; }
.lives { display: flex; gap: 3px; margin-right: 4px; }
.lives svg { width: 20px; height: 20px; display: block; transition: transform .25s ease, opacity .25s ease; }
.lives svg.lost { opacity: .35; transform: scale(.82); }
.ghost {
  border-radius: 10px; padding: 8px 10px; color: var(--mu); font-weight: 650; font-size: 14px;
}
.ghost:hover, .ghost:focus-visible { color: var(--tx); background: var(--s2); outline: none; }
.icon { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; }
.icon svg { width: 20px; height: 20px; }

/* ---------- quiz ---------- */
#quiz { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 14px 14px; gap: 10px; }
.hud { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; }
.hud-score { position: relative; margin-right: auto; display: flex; align-items: baseline; gap: 7px; }
.hud-score span, .hud-q span { font-size: 13px; color: var(--mu); font-weight: 600; }
.hud-score b { font: 700 21px/1 var(--num); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.daily .hud-q { display: none; }
.hud-q { display: flex; align-items: baseline; gap: 6px; }
.hud-q b { font: 700 15px/1 var(--num); letter-spacing: -.02em; }
.gain {
  position: absolute; left: 100%; top: 50%; margin: -8px 0 0 10px; font: 700 14px/1 var(--num); color: var(--good);
  white-space: nowrap; opacity: 0; pointer-events: none;
}
.gain.show { animation: gain 1s ease-out forwards; }
@keyframes gain { 0% { opacity: 0; transform: translateY(6px); } 15% { opacity: 1; transform: translateY(0); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-8px); } }
.streak {
  font-size: 13px; font-weight: 700; color: var(--mu); background: var(--s2); border-radius: 999px; padding: 4px 10px;
  white-space: nowrap; transition: background-color .2s ease, color .2s ease;
}
.streak b { font: 700 12px/1 var(--num); margin-left: 4px; }
.streak.on { background: var(--gold); color: var(--on-gold); }
.dots { display: flex; gap: 4px; }
.dots i { width: 10px; height: 10px; border-radius: 3px; background: var(--s3); display: block; }
.dots i.cur { box-shadow: inset 0 0 0 2px var(--accent); background: transparent; }
.dots i.y { background: var(--good); }
.dots i.n { background: var(--hot); }

.timer { flex: none; display: flex; align-items: center; gap: 10px; }
.track { flex: 1; height: 12px; border-radius: 999px; background: var(--track); position: relative; overflow: visible; }
.fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: 999px; background: var(--gold);
  transform-origin: left center;
}
.fill::after {
  content: ""; position: absolute; right: -5px; top: 50%; width: 20px; height: 20px; margin-top: -10px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 30%, transparent);
}
.timer.low .fill, .timer.low .fill::after { background: var(--hot); }
.timer.low .fill::after { box-shadow: 0 0 0 4px color-mix(in srgb, var(--hot) 30%, transparent); }
.timer.stop .fill::after { box-shadow: none; }
.secs { width: 34px; text-align: right; font: 700 17px/1 var(--num); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.timer.low .secs { color: var(--hot); }

.body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.qbox {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 16px;
  background: var(--card-bg); box-shadow: var(--card-sh); border-radius: 18px;
}
.qmeta { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--mu); font-weight: 650; }
.qmeta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pips { display: flex; gap: 3px; flex: none; align-items: center; }
.pips i { width: 7px; height: 7px; border-radius: 50%; background: var(--s3); display: block; }
.pips i.on { background: var(--vio); }
.qwrap { flex: 1; min-height: 0; overflow: hidden; display: flex; align-items: center; }
.qtext {
  margin: 0; width: 100%; font: 650 var(--qs, 22px)/1.28 var(--ui); letter-spacing: -.012em; text-wrap: pretty;
  overflow-wrap: anywhere;
}
.answers { flex: none; display: grid; grid-template-columns: 1fr; gap: 8px; padding-bottom: 4px; }
.ans {
  position: relative; display: flex; align-items: center; gap: 11px; min-height: 48px; width: 100%; text-align: left;
  padding: 8px 12px 8px 9px; border-radius: var(--r); background: var(--ans-bg); box-shadow: var(--ans-sh); color: var(--tx);
  font: 650 var(--as, 16px)/1.22 var(--ui); transition: transform .08s ease, box-shadow .08s ease, opacity .2s ease;
}
.ans .k {
  flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--key-bg);
  font: 700 12px/1 var(--num); color: var(--mu);
}
.ans .t { min-width: 0; overflow-wrap: anywhere; }
.ans .st { margin-left: auto; flex: none; width: 20px; height: 20px; display: none; }
.ans:focus-visible { outline: 2px solid var(--vio); outline-offset: 2px; }
.ans:active:not([disabled]) { transform: translateY(3px); box-shadow: var(--ans-sh-down); }
[data-theme="dark"] .ans:active:not([disabled]), [data-theme="light"] .ans:active:not([disabled]) { transform: translateY(1px); }
@media (hover: hover) {
  .ans:hover:not([disabled]) { box-shadow: var(--ans-sh), inset 0 0 0 2px var(--line2); }
}
.ans[disabled] { cursor: default; }
.answers.done .ans:not(.good):not(.bad) { opacity: .45; }
.ans.good { background: var(--good-bg); color: var(--good-tx); box-shadow: var(--good-sh); }
.ans.bad { background: var(--hot-bg); color: var(--hot-tx); box-shadow: var(--hot-sh); }
.ans.good .k, .ans.bad .k { background: rgba(255, 255, 255, .25); color: inherit; }
.ans.good .st, .ans.bad .st { display: block; }
.ans.bad.shake { animation: shake .36s ease; }
@keyframes shake { 20% { transform: translateX(-6px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } 100% { transform: translateX(0); } }

/* ---------- overlays ---------- */
.overlay {
  position: absolute; left: 0; right: 0; bottom: 0; top: calc(48px + env(safe-area-inset-top)); z-index: 4;
  display: flex; align-items: center; justify-content: center; padding: 6px 16px 16px; overflow: hidden;
}
.card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.card .col { display: contents; }
.mark { width: 60px; height: 60px; margin-bottom: -2px; }
.title { font: 800 clamp(32px, 10.5vmin, 54px)/1 var(--num); letter-spacing: -.045em; margin: 0; }
.title i { font-style: normal; color: var(--accent); }
.pitch { margin: -4px 0 0; color: var(--mu); font-size: 16px; }
.label { margin: 0 0 -6px; font-size: 13px; color: var(--mu); font-weight: 650; }
.topics { display: flex; flex-wrap: wrap; gap: 6px; }
.topic {
  height: 36px; padding: 0 12px; border-radius: 999px; background: var(--s1); box-shadow: inset 0 0 0 1px var(--line);
  font-size: 14px; font-weight: 650; color: var(--mu); white-space: nowrap;
}
.topic[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); box-shadow: none; }
:root:not([data-theme="dark"]):not([data-theme="light"]) .topic { background: rgba(255, 255, 255, .07); color: var(--tx); }
:root:not([data-theme="dark"]):not([data-theme="light"]) .topic[aria-pressed="true"] {
  background: linear-gradient(180deg, #ffdb5c, #ffb20f); color: #3a2000; box-shadow: 0 3px 0 #b86e00;
}
.topic:focus-visible { outline: 2px solid var(--vio); outline-offset: 2px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 18px; border-radius: 14px;
  background: var(--s2); color: var(--tx); font-weight: 700; font-size: 16px; text-decoration: none; flex: 1;
  box-shadow: inset 0 0 0 1px var(--line); transition: transform .08s ease, box-shadow .08s ease;
}
:root:not([data-theme="dark"]):not([data-theme="light"]) .btn:not(.play) {
  background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .2);
}
.btn.play { background: var(--play-bg); color: var(--play-tx); box-shadow: var(--play-sh); }
.btn:active { transform: translateY(1px); }
.btn.play:active { transform: translateY(3px); box-shadow: var(--play-sh-down); }
[data-theme="dark"] .btn.play:active, [data-theme="light"] .btn.play:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--vio); outline-offset: 3px; }
.btn[disabled] { opacity: .6; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.big { height: 56px; font-size: 19px; flex: none; }
.row { display: flex; gap: 8px; }
.meta { margin: 0; color: var(--mu); font-size: 14px; text-align: center; font-weight: 600; }
.meta b { color: var(--tx); font-family: var(--num); font-weight: 700; letter-spacing: -.02em; }
.credit { margin: -4px 0 0; color: var(--mu2); font-size: 12px; text-align: center; }
.err { color: var(--hot); }

.res-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.res-head h2 { margin: 0; font: 800 24px/1.05 var(--num); letter-spacing: -.035em; }
.res-head span { color: var(--mu); font-size: 13px; font-weight: 650; white-space: nowrap; }
.score-big { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.score-big b { font: 800 clamp(40px, 13vmin, 60px)/1 var(--num); letter-spacing: -.05em; }
.score-big span { color: var(--mu); font-weight: 650; }
.score-big .chip, .chip { display: inline-block; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--gold); color: var(--on-gold); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stat { background: var(--card-bg); box-shadow: var(--card-sh); border-radius: 12px; padding: 8px 4px 9px; text-align: center; min-width: 0; }
.stat span { display: block; font-size: 12px; color: var(--mu); font-weight: 650; }
.stat b { display: block; font: 700 17px/1.25 var(--num); letter-spacing: -.03em; white-space: nowrap; }
.squares { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.squares i { aspect-ratio: 1; border-radius: 6px; background: var(--s3); display: block; max-height: 34px; }
.squares i.y { background: var(--good); }
.squares i.n { background: var(--hot); }
#toast { min-height: 18px; margin: -6px 0 0; text-align: center; color: var(--mu); font-size: 13px; font-weight: 600; }

/* desktop / tablet: 2x2 answers */
@media (min-width: 620px) and (min-height: 561px) {
  #quiz { width: 100%; max-width: 760px; margin: 0 auto; padding: 4px 22px 22px; gap: 14px; }
  .answers { grid-template-columns: 1fr 1fr; gap: 12px; }
  .ans { min-height: 64px; }
  #quiz { justify-content: center; padding-bottom: 40px; }
  .body { flex: 0 1 auto; }
  .qbox { flex: 0 1 auto; min-height: 260px; padding: 18px 22px 22px; }
  .hud-score b { font-size: 24px; }
  .dots i { width: 12px; height: 12px; }
}

/* landscape phones: question left, answers right */
@media (min-aspect-ratio: 5/4) and (max-height: 560px) {
  .bar { height: calc(44px + env(safe-area-inset-top)); }
  .overlay { top: calc(44px + env(safe-area-inset-top)); padding: 4px 18px 12px; }
  #quiz { padding: 0 14px 12px; gap: 8px; }
  .body { flex-direction: row; gap: 12px; }
  .qbox { flex: 1 1 50%; padding: 12px 14px 14px; }
  .answers { flex: 1 1 50%; align-content: center; gap: 7px; padding-bottom: 4px; }
  .ans { min-height: 44px; }
  .card.wide { max-width: 660px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 22px; row-gap: 10px; align-items: center; }
  .card.wide .col { display: flex; flex-direction: column; gap: 11px; }
  .mark { display: none; }
  .title { font-size: 38px; }
  .card { gap: 11px; }
  .big { height: 50px; }
  .score-big b { font-size: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .ans, .btn, .lives svg, .streak { transition: none; }
  .ans.bad.shake { animation: none; }
  .gain.show { animation: none; opacity: 1; }
}
