:root {
  --bg: #120d24;
  --bg2: #1d1438;
  --panel: rgba(255, 255, 255, 0.07);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.14);
  --text: #fbf8ff;
  --muted: #b9b0d6;
  --accent: #ff3ea5;
  --accent2: #19c3b4;
  --good: #3ddc84;
  --bad: #ff5c7a;
  --oa: #e5484d; --ob: #3e63dd; --oc: #f5a524; --od: #2f9e64;
  --display: 'Bungee', 'Arial Black', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
[data-decade='80s'] { --accent: #ff3ea5; --accent2: #19d3f5; }
[data-decade='90s'] { --accent: #19c3b4; --accent2: #c86bff; }
[data-decade='00s'] { --accent: #a3e635; --accent2: #5ab4ff; }
[data-decade='10s'] { --accent: #ff7a59; --accent2: #ffd23f; }
[data-decade='20s'] { --accent: #9d7bff; --accent2: #ff9ed2; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 90% at 50% -10%, color-mix(in srgb, var(--accent) 22%, var(--bg2)) 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.6s;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
input { font: inherit; }
h1, h2, h3 { margin: 0; }

.screen { min-height: 100dvh; display: flex; flex-direction: column; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; }
.muted { color: var(--muted); }
.display { font-family: var(--display); font-weight: 400; letter-spacing: 0.01em; line-height: 1.05; }
.glow { color: var(--accent); text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 55%, transparent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px 28px; border-radius: 999px; font-weight: 800; font-size: 1.15rem;
  background: var(--accent); color: #140d26;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--accent) 55%, #000), 0 10px 30px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 55%, #000); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.ghost { background: var(--panel-strong); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.btn.small { padding: 10px 18px; font-size: 0.95rem; }
.btn.big { padding: 20px 40px; font-size: 1.4rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 20px; backdrop-filter: blur(8px); }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--panel-strong); border: 1px solid var(--line); font-weight: 800; font-size: 0.9rem; white-space: nowrap; }
.pill.accent { background: var(--accent); color: #140d26; border-color: transparent; }

.status { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 50; background: #ffb020; color: #221500; font-weight: 800; padding: 8px 16px; border-radius: 999px; font-size: 0.9rem; display: none; }
.status.show { display: block; }
.error { color: var(--bad); font-weight: 700; min-height: 1.4em; }

/* entrance animation, only when a new screen mounts */
.anim > * { animation: rise 0.45s cubic-bezier(.2, .9, .3, 1.2) both; }
.anim > *:nth-child(2) { animation-delay: 0.06s; }
.anim > *:nth-child(3) { animation-delay: 0.12s; }
.anim > *:nth-child(4) { animation-delay: 0.18s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.98); } }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }

/* answer options */
.opt { --c: var(--oa); position: relative; display: flex; align-items: center; gap: 14px; text-align: left; border-radius: 18px; padding: 16px 18px; background: var(--c); color: #fff; font-weight: 800; box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 60%, #000); transition: opacity 0.3s, transform 0.3s, filter 0.3s; }
.opt:nth-child(2) { --c: var(--ob); }
.opt:nth-child(3) { --c: var(--oc); color: #2a1700; }
.opt:nth-child(4) { --c: var(--od); }
.opt .letter { flex: none; display: grid; place-items: center; width: 1.9em; height: 1.9em; border-radius: 12px; background: rgba(0, 0, 0, 0.22); font-family: var(--display); }
.opt .txt { flex: 1; line-height: 1.15; }
.opt.dim { opacity: 0.28; filter: saturate(0.4); }
.opt.right { outline: 5px solid #fff; outline-offset: 3px; transform: scale(1.02); }
.opt .count { flex: none; font-family: var(--display); font-size: 0.9em; background: rgba(0, 0, 0, 0.25); border-radius: 10px; padding: 4px 10px; }
.opt .check { position: absolute; top: -16px; right: 14px; width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #16a34a; display: grid; place-items: center; font-size: 26px; font-weight: 900; animation: pop 0.4s both; }

/* timer ring */
.timer { position: relative; width: 84px; height: 84px; flex: none; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 9; }
.timer .track { stroke: var(--panel-strong); }
.timer .bar { stroke: var(--accent); stroke-linecap: round; transition: stroke 0.3s; }
.timer .num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: 1.7rem; }
.timer.low .bar { stroke: var(--bad); }
.timer.low .num { color: var(--bad); }

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

/* ================= HOST (iPad) ================= */
.host .top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.host .top .spacer { flex: 1; }
.joinchip { cursor: pointer; }
.joinchip b { font-family: var(--display); letter-spacing: 0.12em; }

.lobby { flex: 1; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 20px; margin-top: 14px; min-height: 0; }
.lobby .join { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }
.qr { background: #fff; border-radius: 20px; padding: 14px; width: min(300px, 34vh, 80%); aspect-ratio: 1; }
.qr svg, .qr img { width: 100%; height: 100%; display: block; }
.code { font-family: var(--display); font-size: clamp(3rem, 9vh, 5.5rem); letter-spacing: 0.14em; line-height: 1; color: var(--accent); text-shadow: 0 0 28px color-mix(in srgb, var(--accent) 50%, transparent); }
.url { font-weight: 800; font-size: 1.15rem; word-break: break-all; }
.lobby .side { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.lobby .players { flex: 1; min-height: 120px; overflow: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { padding: 10px 16px; border-radius: 999px; background: var(--panel-strong); border: 1px solid var(--line); font-weight: 800; font-size: 1.05rem; display: inline-flex; align-items: center; gap: 8px; animation: pop 0.35s both; }
.chip.off { opacity: 0.5; }
.chip.done { background: var(--accent); color: #140d26; border-color: transparent; }
.chip .x { opacity: 0.6; font-size: 0.85em; }

.settings { display: grid; gap: 14px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.setting label, .setting .lbl { font-weight: 800; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button { padding: 8px 14px; border-radius: 999px; background: var(--panel-strong); border: 1px solid var(--line); font-weight: 800; }
.seg button[aria-pressed='true'] { background: var(--accent); color: #140d26; border-color: transparent; }
.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper button { width: 40px; height: 40px; border-radius: 50%; background: var(--panel-strong); border: 1px solid var(--line); font-size: 1.3rem; font-weight: 900; }
.stepper output { min-width: 2ch; text-align: center; font-family: var(--display); font-size: 1.3rem; }
.textin { background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; color: var(--text); width: min(240px, 100%); }
.textin:focus { outline: 2px solid var(--accent); }
.summary { font-weight: 700; }

.qscreen { flex: 1; display: grid; grid-template-rows: auto 1fr auto auto; gap: 18px; min-height: 0; margin-top: 10px; }
.qtext { align-self: center; text-align: center; font-weight: 900; font-size: clamp(1.8rem, 4.6vw, 3.4rem); line-height: 1.15; padding: 0 2vw; text-wrap: balance; }
.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid4 .opt { font-size: clamp(1.2rem, 2.6vw, 2rem); min-height: clamp(84px, 13vh, 130px); padding: 18px 22px; }
.bottom { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.bottom .chips { flex: 1; }
.bottom .chip { font-size: 0.95rem; padding: 7px 13px; }
.fact { display: flex; gap: 14px; align-items: flex-start; font-size: clamp(1rem, 1.8vw, 1.3rem); font-weight: 700; }
.fact .tag { font-family: var(--display); color: var(--accent); flex: none; }
.winners { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; }
.winners .chip { background: color-mix(in srgb, var(--good) 25%, transparent); border-color: color-mix(in srgb, var(--good) 50%, transparent); }
.winners .chip small { color: var(--good); font-weight: 900; }

.intro .round { font-size: clamp(1.2rem, 2.4vw, 1.8rem); font-weight: 900; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.intro .decade { font-size: clamp(5rem, 16vw, 12rem); }
.intro .bday { font-size: clamp(1.3rem, 3vw, 2.2rem); font-weight: 900; }

.board { width: min(860px, 100%); display: grid; gap: 10px; }
.row { text-align: left; display: grid; grid-template-columns: 3.2rem 1fr auto; align-items: center; gap: 14px; padding: 12px 18px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); font-weight: 800; font-size: clamp(1.1rem, 2.2vw, 1.5rem); position: relative; overflow: hidden; }
.row .fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--accent) 22%, transparent); z-index: 0; transition: width 0.8s; }
.row > *:not(.fill) { position: relative; z-index: 1; }
.row .rk { font-family: var(--display); color: var(--accent); }
.row .sc { font-family: var(--display); }
.row.top1 { background: color-mix(in srgb, #ffd23f 22%, var(--panel)); }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 14px; width: min(860px, 100%); }
.podium .step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.podium .name { font-weight: 900; font-size: clamp(1.1rem, 2.6vw, 1.9rem); text-align: center; word-break: break-word; }
.podium .pts { color: var(--muted); font-weight: 800; }
.podium .block { width: 100%; border-radius: 18px 18px 6px 6px; display: grid; place-items: center; font-family: var(--display); font-size: clamp(2rem, 6vw, 4rem); color: #140d26; animation: rise 0.7s both; }
.podium .p1 .block { height: 30vh; background: #ffd23f; animation-delay: 0.5s; }
.podium .p2 .block { height: 21vh; background: #d6dbe8; animation-delay: 0.25s; }
.podium .p3 .block { height: 15vh; background: #e59a5c; }

.overlay { position: fixed; inset: 0; background: rgba(8, 5, 18, 0.85); z-index: 60; display: grid; place-items: center; padding: 20px; }
.overlay .panel { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; max-width: 520px; }
.menu { position: relative; }
.menu .items { position: absolute; right: 0; top: calc(100% + 8px); background: #241a45; border: 1px solid var(--line); border-radius: 16px; padding: 8px; display: none; flex-direction: column; min-width: 230px; z-index: 40; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); }
.menu.open .items { display: flex; }
.menu .items button { text-align: left; padding: 12px 14px; border-radius: 10px; font-weight: 800; }
.menu .items button:hover { background: var(--panel-strong); }

@media (max-width: 900px) and (orientation: portrait) {
  .lobby { grid-template-columns: 1fr; }
  .qr { width: min(240px, 50vw); }
}

/* ================= PHONE ================= */
.phone { max-width: 560px; margin: 0 auto; }
.phone .head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.phone .me { font-weight: 800; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone .score { font-family: var(--display); }
.form { width: 100%; display: grid; gap: 12px; text-align: left; }
.form label { font-weight: 800; color: var(--muted); font-size: 0.95rem; }
.field { width: 100%; background: rgba(0, 0, 0, 0.3); border: 2px solid var(--line); border-radius: 16px; padding: 16px; color: var(--text); font-size: 1.3rem; font-weight: 800; }
.field:focus { outline: none; border-color: var(--accent); }
.field.codein { font-family: var(--display); letter-spacing: 0.3em; text-transform: uppercase; text-align: center; font-size: 2rem; }
.phone .qsmall { font-weight: 800; font-size: 1.15rem; line-height: 1.3; text-align: center; margin: 14px 4px 16px; text-wrap: balance; }
.phone .opts { display: grid; gap: 12px; }
.phone .opt { min-height: 74px; font-size: 1.2rem; width: 100%; }
.phone .opt:disabled { cursor: default; }
.phone .opt.right { transform: none; outline-width: 4px; outline-offset: 2px; }
.phone .opt.picked { outline: 4px solid #fff; outline-offset: 2px; }
.tbar { height: 8px; background: var(--panel-strong); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.tbar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.tbar.low i { background: var(--bad); }
.big-emoji { font-size: 5rem; line-height: 1; animation: pop 0.5s both; }
.verdict { font-size: clamp(2.2rem, 11vw, 3.4rem); }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.lockcard { width: 100%; }
.place { font-size: clamp(3rem, 18vw, 5.5rem); color: var(--accent); }
.mini { width: 100%; display: grid; gap: 8px; }
.mini .row { font-size: 1.05rem; padding: 10px 14px; grid-template-columns: 2.4rem 1fr auto; }
.linkbtn { color: var(--muted); text-decoration: underline; font-weight: 700; padding: 8px; }
