/* ═════════════════════════ Live Quiz — shared design system ═════════════════════════ */
:root {
  --bg: #070A14;
  --bg-2: #0C1122;
  --panel: rgba(255, 255, 255, .045);
  --panel-solid: #121933;
  --panel-2: rgba(255, 255, 255, .075);
  --line: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .16);
  --text: #F3F5FF;
  --muted: #A3ABC8;
  --dim: #6E7799;

  --brand: #8B5CF6;
  --brand-2: #22D3EE;
  --brand-grad: linear-gradient(120deg, #8B5CF6 0%, #6366F1 45%, #22D3EE 100%);

  --good: #22C55E;
  --good-ink: #052e16;
  --bad: #F43F5E;
  --warn: #FBBF24;

  --opt-0: #F43F5E; /* A ▲ */
  --opt-1: #3B82F6; /* B ◆ */
  --opt-2: #F59E0B; /* C ● */
  --opt-3: #10B981; /* D ■ */

  --gold: #FBBF24;
  --silver: #CBD5E1;
  --bronze: #F59E6B;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, .6);
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', 'Inter', ui-sans-serif, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body::before { /* ambient aurora */
  content: ''; position: fixed; inset: -20vmax; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40vmax 30vmax at 15% 10%, rgba(139, 92, 246, .22), transparent 60%),
    radial-gradient(35vmax 30vmax at 90% 20%, rgba(34, 211, 238, .13), transparent 60%),
    radial-gradient(40vmax 35vmax at 60% 100%, rgba(99, 102, 241, .16), transparent 60%);
  animation: drift 24s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate3d(-3vmax, 2vmax, 0) rotate(4deg); } }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }
svg { display: block; }
h1, h2, h3, .display { font-family: var(--display); letter-spacing: -.02em; margin: 0; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.mono { font-family: var(--mono); }
.tabular { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.grad-text { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ───────── Buttons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  height: 48px; padding: 0 22px; border-radius: 999px; font-weight: 650; letter-spacing: -.005em;
  background: var(--panel-2); border: 1px solid var(--line-2);
  transition: transform .15s var(--ease), background .2s, opacity .2s, box-shadow .2s;
  user-select: none; white-space: nowrap; text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { background: rgba(255, 255, 255, .11); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.primary { background: var(--brand-grad); border-color: transparent; color: #fff; box-shadow: 0 8px 30px -8px rgba(139, 92, 246, .7); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.light { background: #fff; color: #0B0F1F; border-color: transparent; }
.btn.danger { color: #FDA4AF; border-color: rgba(244, 63, 94, .35); background: rgba(244, 63, 94, .08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel); }
.btn.lg { height: 60px; padding: 0 30px; font-size: 18px; }
.btn.block { width: 100%; }
.btn.sm { height: 36px; padding: 0 14px; font-size: 14px; }
.kbd { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .35); opacity: .75; }

/* ───────── Surfaces ───────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); }
.pill svg { width: 14px; height: 14px; }
.pill.live { color: #FDA4AF; border-color: rgba(244, 63, 94, .35); background: rgba(244, 63, 94, .1); }
.pill.live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); animation: pulse 1.4s infinite; }
.pill.ok { color: #86EFAC; border-color: rgba(34, 197, 94, .3); background: rgba(34, 197, 94, .08); }
.pill.wait { color: #FCD34D; border-color: rgba(251, 191, 36, .3); background: rgba(251, 191, 36, .08); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, .6); } 50% { box-shadow: 0 0 0 6px rgba(244, 63, 94, 0); } }

.avatar {
  --h: 260; display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%; font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 75% 58%), hsl(calc(var(--h) + 40) 75% 45%));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .15);
}

.field { display: grid; gap: 8px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  height: 56px; padding: 0 18px; border-radius: var(--r); background: rgba(255, 255, 255, .06);
  border: 1.5px solid var(--line-2); font-size: 18px; outline: none; transition: border .2s, background .2s; width: 100%;
}
.input:focus { border-color: var(--brand); background: rgba(139, 92, 246, .08); }

/* ───────── Answer tiles ───────── */
.opt {
  --c: var(--opt-0);
  position: relative; display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 16px 18px; border-radius: var(--r); min-height: 72px;
  background: var(--c); color: #fff; font-weight: 650; font-size: 17px; line-height: 1.25;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .22), 0 6px 20px -8px var(--c);
  transition: transform .18s var(--spring), opacity .25s, filter .25s, box-shadow .2s;
}
.opt[data-i="1"] { --c: var(--opt-1); }
.opt[data-i="2"] { --c: var(--opt-2); }
.opt[data-i="3"] { --c: var(--opt-3); }
.opt .shape { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: rgba(0, 0, 0, .18); }
.opt .shape svg { width: 18px; height: 18px; fill: #fff; }
.opt .letter { font-family: var(--mono); font-size: 12px; opacity: .8; position: absolute; top: 8px; right: 12px; }
.opt .txt { flex: 1; text-wrap: pretty; }
.opt .mark { flex: none; width: 30px; height: 30px; border-radius: 50%; background: #fff; color: var(--c); display: grid; place-items: center; opacity: 0; transform: scale(.4); transition: all .25s var(--spring); }
.opt .mark svg { width: 18px; height: 18px; }

/* ───────── Timer ring ───────── */
.ring { position: relative; display: grid; place-items: center; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: rgba(255, 255, 255, .1); }
.ring .bar { stroke: var(--brand-2); stroke-linecap: round; transition: stroke .3s; }
.ring.warn .bar { stroke: var(--warn); }
.ring.danger .bar { stroke: var(--bad); }
.ring .num { position: absolute; font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; }
.ring.danger .num { color: #FDA4AF; animation: beat 1s infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 20% { transform: scale(1.12); } }

/* ───────── Misc ───────── */
.confetti-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 100; }
.toasts { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 200; width: min(92vw, 420px); }
.toast { padding: 14px 18px; border-radius: 14px; background: #1C2445; border: 1px solid var(--line-2); box-shadow: var(--shadow); font-weight: 550; animation: toastIn .35s var(--spring); }
.toast.error { border-color: rgba(244, 63, 94, .5); background: #3A1424; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } }

.enter > * { animation: rise .55s var(--ease) both; }
.enter > *:nth-child(2) { animation-delay: .06s; }
.enter > *:nth-child(3) { animation-delay: .12s; }
.enter > *:nth-child(4) { animation-delay: .18s; }
.enter > *:nth-child(5) { animation-delay: .24s; }
.enter > *:nth-child(6) { animation-delay: .3s; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes pop { 0% { opacity: 0; transform: scale(.5); } 70% { transform: scale(1.06); } 100% { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .2); border-top-color: #fff; animation: spin .8s linear infinite; }

.conn-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 150; display: flex; justify-content: center; gap: 8px; align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; font-size: 13px; font-weight: 600;
  background: #3A1424; color: #FDA4AF; transform: translateY(-100%); transition: transform .3s var(--ease);
}
.conn-banner svg { width: 16px; height: 16px; }
.conn-banner.show { transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
