*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d1a;
  --card: #15152a;
  --border: #2a2a4a;
  --accent: #7c3aed;
  --accent2: #10b981;
  --text: #e2e8f0;
  --muted: #64748b;
  --radius: 14px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; overflow: hidden; }

.screen { display: none; position: fixed; inset: 0; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; overflow-y: auto; }
.screen.active { display: flex; }

/* ── Lobby ── */
.logo { font-size: 2.6rem; font-weight: 900; letter-spacing: -1px; text-align: center; }
.logo span { color: var(--accent2); }
.tagline { color: var(--muted); margin: .3rem 0 2rem; text-align: center; font-size: .95rem; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; width: 100%; max-width: 380px; }

input[type=text] {
  width: 100%; padding: .75rem 1rem;
  background: #0d0d1a; border: 1.5px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 1rem;
  font-family: inherit; margin-bottom: .75rem;
}
input:focus { outline: none; border-color: var(--accent); }
input::placeholder { color: var(--muted); }

.btn { display: block; width: 100%; padding: .8rem; border: none; border-radius: 8px; font-size: 1rem; font-weight: 700; cursor: pointer; transition: opacity .15s, transform .1s; font-family: inherit; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: transparent; border: 1.5px solid var(--border); color: var(--text); margin-top: .5rem; }
.btn-green { background: var(--accent2); color: #0d0d1a; }
.btn-green:disabled { opacity: .4; cursor: not-allowed; }
.btn-ready { background: #1e293b; border: 2px solid var(--muted); color: var(--text); }
.btn-ready.is-ready { background: #0d2f25; border-color: var(--accent2); color: var(--accent2); }
.btn:hover { opacity: .88; }

.divider { text-align: center; color: var(--muted); font-size: .85rem; margin: .8rem 0; }

.error-box { background: #450a0a; border: 1px solid #7f1d1d; color: #fca5a5; border-radius: 8px; padding: .65rem 1rem; font-size: .88rem; margin-bottom: .75rem; display: none; }
.error-box.show { display: block; }

/* ── Waiting Room ── */
.waiting-wrap { width: 100%; max-width: 420px; }
.room-code-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem 1.5rem; text-align: center; margin-bottom: 1rem; }
.room-code-label { font-size: .75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.room-code { font-size: 2.8rem; font-weight: 900; letter-spacing: 8px; color: var(--accent2); line-height: 1; margin: .2rem 0; }
.room-code-hint { font-size: .78rem; color: var(--muted); }

.section-label { font-size: .75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: .6rem; }
.player-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.player-chip { display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; background: var(--card); border: 1px solid var(--border); border-radius: 8px; font-size: .9rem; }
.player-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.player-chip .crown { margin-left: auto; font-size: .8rem; }

/* ── Countdown ── */
#screen-countdown { gap: .5rem; }
.countdown-num { font-size: 8rem; font-weight: 900; color: var(--accent2); animation: pop .4s ease; line-height: 1; }
.countdown-sub { color: var(--muted); font-size: 1rem; }
@keyframes pop { from { transform: scale(1.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Question Screen ── */
#screen-question { padding: 0; justify-content: flex-start; align-items: stretch; }

.q-header {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem; background: var(--card);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.q-num-label { font-size: .8rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.q-timer-wrap { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.q-timer-bar { height: 100%; width: 100%; background: var(--accent2); border-radius: 4px; }
.q-time-num { font-size: 1.1rem; font-weight: 900; width: 28px; text-align: right; font-variant-numeric: tabular-nums; transition: color .3s; }

.q-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1.25rem 1.5rem; min-height: 80px; }
.q-text { font-size: 1.25rem; font-weight: 700; text-align: center; line-height: 1.4; }

.q-answered-bar {
  text-align: center; font-size: .85rem; color: var(--muted);
  padding: .4rem 1rem; flex-shrink: 0; min-height: 30px;
  transition: color .2s;
}
.q-answered-bar.reveal-correct { color: #4ade80; font-weight: 700; }
.q-answered-bar.reveal-wrong   { color: #f87171; font-weight: 700; }

.q-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  flex-shrink: 0; min-height: 220px;
}
.q-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .35rem; padding: .75rem .5rem;
  border: none; cursor: pointer; font-family: inherit;
  font-weight: 700; font-size: .85rem; color: #fff;
  transition: filter .2s, box-shadow .2s, opacity .2s;
  text-align: center; line-height: 1.3;
}
.q-btn:active { filter: brightness(.85); }
.q-shape { font-size: 1.4rem; line-height: 1; }
.q-answer-text { max-width: 130px; }

.q-red    { background: #e21b3c; }
.q-blue   { background: #1368ce; }
.q-yellow { background: #d89e00; }
.q-green  { background: #26890c; }

/* Interaction states */
.q-btn.q-selected   { box-shadow: inset 0 0 0 4px rgba(255,255,255,.8); }
.q-btn.q-dimmed     { opacity: .45; }
/* Reveal states */
.q-btn.q-correct    { box-shadow: inset 0 0 0 4px #fff; filter: brightness(1.15); }
.q-btn.q-wrong      { filter: brightness(.45) saturate(.3); }
.q-btn.q-dim-reveal { filter: brightness(.35); }
.q-btn:disabled     { cursor: default; }

/* ── Scores (between questions) ── */
#screen-scores { padding: 1rem; }
.scores-wrap { width: 100%; max-width: 420px; }
.scores-title { font-size: 1.6rem; font-weight: 900; text-align: center; color: var(--accent2); }
.scores-sub { text-align: center; color: var(--muted); font-size: .85rem; margin: .3rem 0 1rem; }
.scores-list { display: flex; flex-direction: column; gap: .5rem; }

.score-row { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.score-row.me { border-color: var(--accent2); background: #0d2f25; }
.score-rank { font-size: 1.1rem; font-weight: 900; width: 28px; text-align: center; }
.score-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.score-name { flex: 1; font-weight: 600; font-size: .95rem; }
.score-pts { font-size: .9rem; font-weight: 700; color: var(--accent2); font-variant-numeric: tabular-nums; }

/* ── Results ── */
.results-wrap { width: 100%; max-width: 400px; }
.results-title { font-size: 1.8rem; font-weight: 900; text-align: center; }
.results-sub { text-align: center; color: var(--muted); font-size: .85rem; margin: .2rem 0 1.2rem; }
.results-list { display: flex; flex-direction: column; gap: .55rem; margin-bottom: .5rem; }

.result-row { display: flex; align-items: center; gap: .8rem; padding: .75rem 1rem; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.result-row.first { border-color: #fbbf24; background: #1a1408; }
.result-row.me { border-color: var(--accent2); }
.result-rank { font-size: 1.2rem; font-weight: 900; width: 28px; text-align: center; }
.result-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.result-name { flex: 1; font-weight: 600; }
.result-score { font-size: .9rem; font-weight: 700; color: var(--accent2); font-variant-numeric: tabular-nums; }
