/* Layout: one phone-width column, a bottom tab bar, and full-screen play mode. Late-night quiz show: plum studio, violet lights. */
:root {
  --bg: #120d24;
  --panel: #1d1640;
  --panel-2: #2b2260;
  --line: #3a3080;
  --accent: #5b4bf0;
  --on-accent: #ffffff;
  --accent-soft: #9b8cff;
  --gold: #ffc145;
  --ink: #f6f4ff;
  --mute: #a79fd0;
  --green: #3ddc97;
  --red: #ff6b6b;
  --orange: #ff9f5a;
  --silver: #cfd3e6;
  --bronze: #e0915f;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-lg: 22px;
  --r-md: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--ink); }
body { font-family: var(--font); font-size: 16px; line-height: 1.45; font-weight: 600; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 3px; }
.wrap { max-width: 480px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 16px 110px; display: flex; flex-direction: column; gap: 18px; }
.top { display: flex; align-items: center; justify-content: center; gap: 10px; }
.logo { width: 40px; height: 40px; flex: none; }
.brand { font-weight: 900; font-size: 23px; letter-spacing: -0.3px; }
h2 { margin: 0; font-size: 19px; font-weight: 900; text-wrap: balance; }
.eyebrow { font-size: 12px; font-weight: 900; letter-spacing: 1.2px; text-transform: uppercase; color: var(--accent-soft); }
.muted { color: var(--mute); font-size: 14px; }
.small { font-size: 13px; }
.card { background: var(--panel); border-radius: var(--r-lg); padding: 20px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.hero-title { font-size: 31px; font-weight: 900; line-height: 1.1; letter-spacing: -0.5px; margin: 0; text-wrap: balance; }
.bar { height: 10px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent-soft); border-radius: 6px; }
.btn { background: var(--accent); color: var(--on-accent); font-weight: 900; font-size: 18px; border-radius: 18px; padding: 16px 18px; text-align: center; width: 100%; transition: transform .08s; }
.btn:active { transform: scale(.98); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--panel-2); font-size: 16px; }
.btn[disabled] { opacity: .45; cursor: default; }
.row { display: flex; align-items: center; gap: 10px; }
.avatars { display: flex; flex-wrap: wrap; gap: 6px; }
.av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 900; background: var(--panel-2); color: var(--mute); flex: none; }
.av.on { background: var(--green); color: var(--bg); }
.av.me { box-shadow: 0 0 0 2px var(--accent-soft); }
.av.custom { opacity: .4; }
.av.custom.on, .av.custom.sm, .av.custom.big, .av.custom.tab { opacity: 1; }
.av.emoji { font-size: 20px; }
.av.sm { width: 26px; height: 26px; font-size: 11px; }
.av.sm.emoji { font-size: 15px; }
.av.tab { width: 24px; height: 24px; font-size: 11px; }
.av.tab.emoji { font-size: 14px; }
.tabs button[aria-current="page"] .av.tab { box-shadow: 0 0 0 2px var(--accent-soft); }
.av.big { width: 88px; height: 88px; font-size: 30px; background: var(--accent); color: var(--on-accent); }
.av.big.emoji { font-size: 46px; }
.table { background: var(--panel); border-radius: 20px; padding: 8px 14px; display: flex; flex-direction: column; }
.tr { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tr:last-child { border-bottom: 0; }
.tr.me .name { color: var(--accent-soft); }
.medal { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 900; background: var(--panel-2); color: var(--ink); flex: none; font-variant-numeric: tabular-nums; }
.m1 { background: var(--gold); color: var(--bg); } .m2 { background: var(--silver); color: var(--bg); } .m3 { background: var(--bronze); color: var(--bg); }
.name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.pts { font-weight: 900; color: var(--accent-soft); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.move { width: 14px; text-align: center; font-size: 12px; font-weight: 900; color: var(--mute); }
.up { color: var(--green); } .down { color: var(--red); }
.form { display: flex; gap: 3px; }
.form b { width: 18px; height: 18px; border-radius: 5px; font-size: 10px; display: grid; place-items: center; background: var(--panel-2); color: var(--mute); font-variant-numeric: tabular-nums; }
.form b.f1 { background: var(--gold); color: var(--bg); } .form b.f2 { background: var(--silver); color: var(--bg); } .form b.f3 { background: var(--bronze); color: var(--bg); }
.th { display: flex; gap: 10px; font-size: 11px; font-weight: 900; letter-spacing: 1px; color: var(--mute); padding: 0 14px; }
.empty { text-align: center; padding: 26px 20px; color: var(--mute); }
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }

/* tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
.tabs nav { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabs button { padding: 10px 4px 12px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--mute); font-size: 12px; font-weight: 800; }
.tabs button[aria-current="page"] { color: var(--accent-soft); }
.tabs svg { width: 22px; height: 22px; }
body.playing .tabs { display: none; }

/* play */
.qhead { display: flex; justify-content: space-between; font-weight: 800; color: var(--mute); font-size: 15px; font-variant-numeric: tabular-nums; }
.qhead b { color: var(--accent-soft); }
.timer { height: 12px; }
.timer > i { transition: none; }
.timer.low > i { background: var(--red); }
.secs { font-weight: 900; color: var(--accent-soft); font-variant-numeric: tabular-nums; font-size: 14px; }
.qcard { padding: 22px; }
.qtext { font-size: 23px; font-weight: 900; line-height: 1.22; margin: 0; text-wrap: balance; }
.answers { display: flex; flex-direction: column; gap: 10px; }
.ans { background: var(--panel-2); border-radius: 18px; padding: 15px 16px; display: flex; align-items: center; gap: 14px; text-align: left; font-size: 18px; font-weight: 800; width: 100%; transition: background .15s, transform .08s; }
.ans:active { transform: scale(.985); }
.ans .k { width: 32px; height: 32px; border-radius: 10px; background: var(--bg); color: var(--accent-soft); display: grid; place-items: center; font-size: 14px; font-weight: 900; flex: none; }
.ans.right { background: var(--green); color: var(--bg); }
.ans.right .k { background: rgba(18,13,36,.18); color: var(--bg); }
.ans.wrong { background: var(--red); color: var(--bg); animation: shake .4s; }
.ans.wrong .k { background: rgba(18,13,36,.18); color: var(--bg); }
.ans.dim { opacity: .45; }
.ans.won { position: relative; z-index: 1; animation: pop .5s cubic-bezier(.34, 1.56, .64, 1), ring .7s ease-out; }
.spark { position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; border-radius: 50%; background: var(--c); pointer-events: none; animation: spark .75s cubic-bezier(.2, .8, .3, 1) forwards; }
.verdict.good { animation: verdict-pop .45s cubic-bezier(.34, 1.56, .64, 1); }
.qhead b.bump { display: inline-block; animation: verdict-pop .5s cubic-bezier(.34, 1.56, .64, 1); }
.verdict { text-align: center; font-weight: 900; font-size: 20px; min-height: 30px; }
.verdict.good { color: var(--green); } .verdict.bad { color: var(--red); }
@keyframes pop { 0% { transform: scale(1) } 40% { transform: scale(1.05) } 100% { transform: scale(1) } }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(61,220,151,.7) } 100% { box-shadow: 0 0 0 18px rgba(61,220,151,0) } }
@keyframes spark { 0% { transform: translate(-50%, -50%) scale(1); opacity: 1 } 100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2); opacity: 0 } }
@keyframes verdict-pop { 0% { transform: scale(.7); opacity: 0 } 100% { transform: scale(1); opacity: 1 } }
@keyframes shake { 0%,100% { transform: translateX(0) } 20% { transform: translateX(-8px) } 40% { transform: translateX(8px) } 60% { transform: translateX(-5px) } 80% { transform: translateX(5px) } }
.linkbtn { color: var(--mute); font-size: 14px; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; align-self: center; padding: 6px; }

/* league period picker */
.seg { display: flex; gap: 6px; background: var(--panel); border-radius: 16px; padding: 5px; }
.seg button { flex: 1; padding: 9px 4px; border-radius: 12px; font-size: 14px; font-weight: 900; color: var(--mute); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* recap day navigation */
.daynav { display: flex; align-items: center; gap: 12px; }
.daynav-title { flex: 1; display: flex; flex-direction: column; gap: 2px; text-align: center; }
.navbtn { width: 44px; height: 44px; border-radius: 50%; background: var(--panel-2); font-size: 32px; font-weight: 900; line-height: 1; display: grid; place-items: center; flex: none; padding-bottom: 3px; }
.navbtn:disabled { opacity: .3; cursor: default; }

/* profile */
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick button { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; background: var(--panel-2); color: var(--mute); font-weight: 900; }
.pick.emojis button { border-radius: 12px; }
.pick button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--accent-soft); }
.linkbtn.danger { color: var(--red); }

/* results */
.score-big { font-size: 68px; font-weight: 900; color: var(--accent-soft); line-height: 1; letter-spacing: -2px; font-variant-numeric: tabular-nums; }
.center { align-items: center; text-align: center; }
.grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.sq { aspect-ratio: 1; max-width: 100%; border-radius: 6px; display: grid; place-items: center; font-size: 12px; background: var(--red); }
.sq.g { background: var(--green); } .sq.fast { background: var(--gold); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--mute); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.share { background: var(--bg); border-radius: 14px; padding: 12px; font-size: 14px; white-space: pre-wrap; line-height: 1.3; user-select: all; margin: 0; overflow-x: auto; }
.qlist { display: flex; flex-direction: column; gap: 10px; }
.qitem { background: var(--panel); border-radius: var(--r-md); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.qitem .qn { font-size: 12px; color: var(--mute); font-weight: 800; }
.qitem .qa { font-weight: 800; }
.tag { display: inline-block; font-size: 12px; font-weight: 900; border-radius: 6px; padding: 1px 7px; }
.tag.ok { background: var(--green); color: var(--bg); } .tag.no { background: var(--red); color: var(--bg); }

/* recap */
.winner { background: var(--gold); color: var(--bg); border-radius: var(--r-lg); padding: 24px 20px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.winner .wname { font-size: 40px; font-weight: 900; line-height: 1.05; letter-spacing: -0.5px; overflow-wrap: anywhere; }
.winner .eyebrow { color: var(--bg); }

/* profile */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--panel); border-radius: 18px; padding: 14px 8px; text-align: center; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat b { font-size: 24px; font-weight: 900; color: var(--accent-soft); line-height: 1.1; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.stat b.word { font-size: 16px; padding-top: 5px; }
.stat span { font-size: 11px; color: var(--mute); }
.trophies { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.trophy { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 12px; color: var(--mute); }
.trophy .disc { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; color: var(--bg); font-size: 17px; }
.catrow { display: grid; grid-template-columns: 96px 1fr 40px; gap: 10px; align-items: center; font-size: 13px; }
.catrow span:last-child { text-align: right; color: var(--mute); font-variant-numeric: tabular-nums; }

.banner { background: var(--panel-2); border-radius: var(--r-md); padding: 12px 14px; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); font-weight: 900; padding: 10px 18px; border-radius: 999px; z-index: 20; font-size: 14px; }
canvas#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; width: 100%; height: 100%; }
@media (prefers-reduced-motion: reduce) { .ans.wrong, .ans.won, .verdict.good, .qhead b.bump { animation: none; } .spark { display: none; } .btn, .ans { transition: none; } }

/* forms (sign-in, admin) */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 800; color: var(--mute); }
.input { font: inherit; font-weight: 700; color: var(--ink); background: var(--bg); border: 2px solid var(--panel-2); border-radius: 14px; padding: 13px 14px; width: 100%; }
.input:focus { outline: none; border-color: var(--accent-soft); }
textarea.input { min-height: 160px; font-size: 13px; line-height: 1.4; resize: vertical; }
.error { color: var(--red); font-size: 14px; font-weight: 800; }
.linkbox { display: flex; gap: 8px; align-items: center; background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.linkbox code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-size: 13px; color: var(--accent-soft); user-select: all; }
.btn.small { font-size: 14px; padding: 10px 14px; width: auto; border-radius: 12px; }

