:root {
  --navy: #1b2a4a;
  --navy-dark: #101a30;
  --blue: #2f6feb;
  --blue-light: #eaf1ff;
  --gold: #f5b942;
  --green: #2fa860;
  --red: #e05a5a;
  --grey: #6b7280;
  --bg: #f4f6fb;
  --card: #ffffff;
  --radius: 14px;
  font-size: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--navy-dark);
  min-height: 100vh;
}
.wrap { padding: 20px 16px 60px; max-width: 640px; margin: 0 auto; }
h1, h2, h3 { margin-top: 0; }
.muted { color: var(--grey); }
.brand { text-align: center; padding: 24px 16px 8px; }
.brand h1 { font-size: 1.5rem; color: var(--navy); margin-bottom: 4px; }
.brand p { color: var(--grey); margin-top: 0; }

button { font-family: inherit; cursor: pointer; }
.btn-primary {
  display: block; width: 100%; padding: 16px; font-size: 1.05rem; font-weight: 600;
  background: var(--blue); color: white; border: none; border-radius: var(--radius); margin-top: 10px;
}
.btn-primary:disabled { opacity: 0.5; }
.btn-secondary {
  display: block; width: 100%; padding: 14px; font-size: 1rem; font-weight: 600;
  background: var(--card); color: var(--navy); border: 2px solid var(--blue-light);
  border-radius: var(--radius); margin-top: 10px;
}
.btn-link { background: none; border: none; color: var(--blue); font-size: 0.9rem; text-decoration: underline; padding: 4px; }
.btn-tiny { padding: 6px 10px; font-size: 0.85rem; background: var(--blue-light); color: var(--navy); border: none; border-radius: 8px; }
.btn-tiny.danger { background: #fde3e3; color: var(--red); }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: 0 2px 6px rgba(20,30,60,0.08); margin-top: 16px; }
input[type="text"], input[type="number"], select {
  width: 100%; padding: 14px; font-size: 1rem; border: 2px solid #e2e8f5; border-radius: 10px; margin-top: 6px;
  font-family: inherit; background: white;
}
label { font-weight: 600; font-size: 0.9rem; color: var(--navy); }
.error-text { color: var(--red); font-size: 0.9rem; min-height: 1.2em; margin-top: 8px; }
.hidden { display: none !important; }

.room-code { font-size: 2.6rem; font-weight: 800; letter-spacing: 0.12em; text-align: center; color: var(--navy); background: var(--blue-light); border-radius: var(--radius); padding: 18px 10px; margin-top: 14px; }

/* Countdown bar */
.countdown-wrap { margin: 14px 0 6px; }
.countdown-bar-track { background: #e2e8f5; border-radius: 20px; height: 10px; overflow: hidden; }
.countdown-bar-fill { height: 100%; background: var(--blue); border-radius: 20px; transition: width 0.15s linear, background-color 0.3s; }
.countdown-bar-fill.urgent { background: var(--red); }
.countdown-seconds { text-align: center; font-weight: 700; color: var(--navy); margin-top: 4px; font-size: 0.9rem; }

/* Question / choices */
.q-text { font-size: 1.25rem; line-height: 1.4; margin: 6px 0 16px; font-weight: 600; color: var(--navy); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .choice-grid { grid-template-columns: 1fr; } }
.choice-btn {
  padding: 16px 12px; font-size: 1rem; font-weight: 600; text-align: left;
  background: var(--card); border: 2px solid #e2e8f5; border-radius: 12px; color: var(--navy-dark);
}
.choice-btn:disabled { opacity: 0.9; }
.choice-btn.chosen { border-color: var(--blue); background: var(--blue-light); }
.choice-btn.correct { border-color: var(--green); background: #e9f9ef; font-weight: 700; }
.choice-btn.incorrect { border-color: var(--red); background: #fdecec; }

.score-chip { display: inline-flex; gap: 6px; align-items: center; background: var(--navy); color: white; padding: 6px 12px; border-radius: 20px; font-size: 0.85rem; margin: 3px; }
.score-chip strong { color: var(--gold); }

.leaderboard-row, .rank-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--blue-light); padding: 10px 14px; border-radius: 10px; margin-top: 8px;
}
.leaderboard-row .pos { font-weight: 800; color: var(--navy); width: 1.6em; }
.leaderboard-row .name { flex: 1; font-weight: 600; }
.leaderboard-row .pts { font-weight: 800; color: var(--blue); }

.match-vs { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; font-weight: 700; color: var(--navy); }
.match-vs .score { font-size: 1.6rem; color: var(--blue); }

.bracket-round { margin-top: 16px; }
.bracket-round h4 { margin-bottom: 6px; color: var(--navy); }
.bracket-match-row { display: flex; justify-content: space-between; background: var(--blue-light); padding: 8px 12px; border-radius: 8px; margin-top: 6px; font-size: 0.9rem; }
.bracket-match-row .winner { font-weight: 700; color: var(--green); }

.status-banner { text-align: center; padding: 20px 16px; }
.status-banner .big { font-size: 1.3rem; font-weight: 700; color: var(--navy); }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.topbar h2 { font-size: 1.1rem; margin: 0; }

.pill-select { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.pill-select button {
  flex: 1; min-width: 90px; padding: 10px; border-radius: 20px; border: 2px solid #e2e8f5;
  background: white; font-weight: 600; color: var(--navy);
}
.pill-select button.active { background: var(--blue); border-color: var(--blue); color: white; }

footer.small-print { text-align: center; color: var(--grey); font-size: 0.75rem; padding: 24px 16px 40px; }
