:root {
  --bg: #0B0F1A; --surface: #151B2B; --surface-2: #1E2739; --line: #2A3448; --text: #F0F3FA; --muted: #8B96AD;
  --accent: #FFB020; --correct: #2ECC71; --wrong: #E7466A;
  --p1: #FF6B6B; --p2: #4DABF7; --p3: #51CF66; --p4: #FCC419; --p5: #CC5DE8; --p6: #FF922B; --p7: #22B8CF; --p8: #F783AC;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 17px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; touch-action: manipulation;
  -webkit-user-select: none; user-select: none; }
[hidden] { display: none !important; }
#app { min-height: 100dvh; display: flex; flex-direction: column; padding: env(safe-area-inset-top) env(safe-area-inset-right)
  env(safe-area-inset-bottom) env(safe-area-inset-left); overflow: hidden; }
.screen { flex: 1; display: flex; flex-direction: column; padding: 20px 18px 24px; max-width: 560px; width: 100%; margin: 0 auto;
  animation: in 260ms var(--ease) both; min-height: 0; }
@keyframes in { from { opacity: 0; transform: translateX(8%); } }
.grow { flex: 1; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
h1 { font-size: 34px; margin: 0 0 6px; letter-spacing: -.02em; }
h2 { font-size: 22px; margin: 0 0 12px; }
a { color: var(--accent); }
input { font: inherit; color: var(--text); background: var(--surface-2); border: 2px solid var(--line); border-radius: 12px;
  height: 54px; padding: 0 16px; width: 100%; outline: none; user-select: text; -webkit-user-select: text; }
input:focus { border-color: var(--accent); }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; width: 100%; border: 0; border-radius: 14px;
  font: inherit; font-size: 18px; font-weight: 600; line-height: 1.2; color: var(--text); background: var(--surface-2); cursor: pointer; padding: 12px 18px;
  transition: transform 90ms; text-decoration: none; }
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--accent); color: #1a1200; }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn:disabled { opacity: .5; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.logo { font-size: 44px; font-weight: 800; letter-spacing: -.03em; margin: 12vh 0 4px; }
.logo span { color: var(--accent); }
.card { background: var(--surface); border-radius: 16px; padding: 16px; }
.me-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; padding: 0; cursor: pointer; }
.err { color: var(--wrong); min-height: 1.4em; font-size: 15px; }

/* avatars */
.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.av-btn { aspect-ratio: 1; border-radius: 12px; border: 2px solid transparent; background: var(--surface-2); font-size: 24px; cursor: pointer; padding: 0; }
.av-btn[aria-pressed="true"] { border-color: var(--accent); background: #2a2410; }
.av-btn.taken { opacity: .45; }
.av { width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 24px; background: var(--surface-2);
  box-shadow: 0 0 0 3px var(--pc, var(--line)); flex: none; }
.av.big { width: 120px; height: 120px; font-size: 64px; box-shadow: 0 0 0 5px var(--pc); }

/* lobby */
.code { font-size: 44px; font-weight: 800; letter-spacing: .18em; color: var(--accent); }
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 14px 0; }
.pl { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 14px; padding: 10px; font-weight: 600; min-width: 0; }
.pl .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl.off { opacity: .45; }
.crown { font-size: 14px; }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.settings select { font: inherit; color: var(--text); background: var(--surface-2); border: 0; border-radius: 10px; height: 44px; padding: 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; grid-column: 1 / -1; }
.chip { border: 2px solid var(--line); background: transparent; color: var(--text); border-radius: 999px; padding: 8px 12px; font: inherit; font-size: 15px; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: #2a2410; }

/* question */
.qtop { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.cat { font-size: 13px; background: var(--surface-2); padding: 5px 10px; border-radius: 999px; color: var(--muted); }
.ring { width: 58px; height: 58px; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: var(--accent); stroke-linecap: round; }
.ring.low .fg { stroke: var(--wrong); }
.ring.low { animation: pulse .6s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 18px; font-variant-numeric: tabular-nums; }
.qtext { font-size: 24px; font-weight: 700; line-height: 1.3; margin: 8px 0 18px; }
.answers { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.ans { position: relative; overflow: hidden; min-height: 60px; text-align: left; justify-content: flex-start; font-size: 18px; padding-left: 18px; }
.ans.chosen { box-shadow: 0 0 0 3px var(--accent) inset; }
.ans.right { background: var(--correct); color: #06210f; animation: bounce 400ms var(--ease); }
.ans.wrong { background: var(--wrong); animation: shake 350ms; }
.ans.dim { opacity: .45; }
@keyframes bounce { 60% { transform: scale(1.03); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.answered { text-align: center; color: var(--muted); margin-top: 12px; min-height: 1.4em; }
.award { font-size: 54px; font-weight: 800; text-align: center; color: var(--accent); animation: pop 600ms var(--ease); margin: 8px 0; }
.award.zero { color: var(--muted); }
@keyframes pop { from { transform: scale(1.4); opacity: 0; } }
.explain { background: var(--surface); border-radius: 14px; padding: 14px 16px; color: var(--muted); margin-top: 14px; }
.numreveal { font-size: 40px; font-weight: 800; text-align: center; color: var(--correct); }

/* round winner / picker / countdown */
.spot { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; text-align: center; gap: 24px; }
.spring { animation: spring 900ms cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes spring { from { transform: scale(0); } }
.glow { position: relative; }
.glow::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 3px solid var(--accent); animation: glow 1.2s ease-out infinite; }
@keyframes glow { to { transform: scale(1.6); opacity: 0; } }
.pick-cards { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
.gcard { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 16px;
  color: var(--text); font: inherit; text-align: left; cursor: pointer; animation: deal 500ms var(--ease) both, float 3s ease-in-out 600ms infinite alternate; }
.gcard:nth-child(2) { animation-delay: 80ms, 700ms; } .gcard:nth-child(3) { animation-delay: 160ms, 800ms; }
.gcard .gi { font-size: 40px; }
.gcard b { display: block; font-size: 19px; }
.gcard.fly { animation: flyoff 400ms var(--ease) forwards; }
.gcard.sel { animation: chosen 600ms var(--ease) forwards; border-color: var(--accent); }
@keyframes deal { from { transform: translateY(120%); opacity: 0; } }
@keyframes float { to { transform: translateY(-4px); } }
@keyframes flyoff { to { transform: translateX(120%); opacity: 0; } }
@keyframes chosen { to { transform: scale(1.06); } }
.slam { font-size: 90px; animation: slam 400ms cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes slam { from { transform: scale(2.6); opacity: 0; } }
.dots::after { content: "…"; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1.2em; text-align: left; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0; } }
.count { font-size: 140px; font-weight: 800; animation: countin 700ms var(--ease) both; }
@keyframes countin { from { transform: scale(2.2); opacity: 0; filter: blur(6px); } }

/* mini-game */
.mg { position: fixed; inset: 0; background: #070a12; touch-action: none; z-index: 5; }
.mg canvas { display: block; width: 100%; height: 100%; }
.hud { position: fixed; top: calc(env(safe-area-inset-top) + 10px); left: 12px; right: 12px; display: flex; justify-content: space-between;
  z-index: 6; font-weight: 700; pointer-events: none; text-shadow: 0 1px 3px #000; }
.toasts { position: fixed; right: 10px; top: calc(env(safe-area-inset-top) + 50px); display: flex; flex-direction: column; gap: 6px; z-index: 9; pointer-events: none; }
.toast { background: var(--surface); border-left: 4px solid var(--pc, var(--accent)); padding: 6px 12px; border-radius: 8px; font-size: 14px;
  animation: toastin 220ms var(--ease), toastout 300ms 1.8s forwards; }
@keyframes toastin { from { transform: translateX(110%); } }
@keyframes toastout { to { opacity: 0; } }

/* results / scoreboard */
.rank { display: flex; flex-direction: column; gap: 8px; }
.rrow { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 14px; padding: 10px 12px;
  animation: in 500ms var(--ease) both; }
.rrow .nm { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rrow .pts { font-variant-numeric: tabular-nums; font-weight: 700; }
.stars { color: var(--accent); letter-spacing: 2px; }
.star-fly { display: inline-block; animation: starpop 800ms cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes starpop { from { transform: translate(-40px, 30px) scale(0); } }
.bars { flex: 1; display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-2); margin-top: 6px; }
.bars i { display: block; height: 100%; transform-origin: left; animation: grow 700ms cubic-bezier(.34, 1.3, .64, 1) both; }
.bars .bq { background: var(--pc); } .bars .bs { background: var(--accent); }
@keyframes grow { from { transform: scaleX(0); } }
.delta { font-size: 13px; width: 22px; text-align: center; }
.up { color: var(--correct); } .down { color: var(--wrong); }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 20px 0; height: 220px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 30%; }
.pod .blk { width: 100%; border-radius: 12px 12px 0 0; background: var(--surface-2); display: grid; place-items: start center; padding-top: 8px;
  font-size: 26px; font-weight: 800; transform-origin: bottom; animation: rise 600ms var(--ease) both; }
.pod.p1 .blk { height: 130px; background: #3a2c07; color: var(--accent); animation-delay: 1.2s; }
.pod.p2 .blk { height: 95px; animation-delay: .7s; } .pod.p3 .blk { height: 70px; animation-delay: .2s; }
.pod .nm { font-weight: 700; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes rise { from { transform: scaleY(0); } }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 8; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* host bar & pill */
.hostbar { display: flex; gap: 6px; margin-top: 14px; }
.hostbar button { flex: 1; min-height: 44px; font-size: 14px; border-radius: 10px; }
.pill { position: fixed; top: calc(env(safe-area-inset-top) + 10px); left: 50%; transform: translateX(-50%); background: var(--wrong); color: #fff;
  padding: 6px 14px; border-radius: 999px; font-size: 14px; z-index: 10; }
.tip { font-size: 14px; color: var(--muted); background: var(--surface); border-radius: 12px; padding: 10px 12px; }
.hs-list { margin: 0; padding-left: 22px; } .hs-list li { padding: 3px 0; } .hs-list .pts { float: right; font-weight: 700; }

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