/* ==========================================================================
   QuizBowl Live – Dark modern theme
   ========================================================================== */

:root {
  --bg:          #08080f;
  --surface:     #111120;
  --surface-2:   #191930;
  --surface-3:   #222244;
  --border:      #2a2a4a;
  --border-light:#3a3a5c;

  --text:        #e4e4f0;
  --text-2:      #9a9ab4;
  --text-3:      #6a6a88;

  --primary:     #6366f1;
  --primary-h:   #818cf8;
  --accent:      #a78bfa;
  --accent-bg:   rgba(99,102,241,.12);

  --success:     #34d399;
  --success-bg:  rgba(52,211,153,.12);
  --error:       #f87171;
  --error-bg:    rgba(248,113,113,.12);
  --warning:     #fbbf24;

  --buzz-purple: #a855f7;
  --buzz-glow:   rgba(139,92,246,.35);

  --radius:      12px;
  --radius-sm:   12px;
  --radius-xs:   6px;
  --shadow:      0 2px 24px rgba(0,0,0,.45);

  --font:        'Inter', system-ui, -apple-system, sans-serif;
}

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

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: linear-gradient(160deg, #08080f 0%, #0d0d20 50%, #100818 100%);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-h); text-decoration: none; }
a:hover { text-decoration: underline; }

input, button, select, textarea { font-family: inherit; font-size: inherit; }

/* ── Utility ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-light); }
.btn:active { transform: scale(.95); }
.btn:disabled { opacity: .4; pointer-events: none; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); }

.btn-accent { background: linear-gradient(135deg, var(--primary), var(--accent)); border: none; color: #fff; }
.btn-accent:hover { filter: brightness(1.12); }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }

.btn-sm  { padding: 6px 12px; font-size: .82rem; }
.btn-lg  { padding: 14px 32px; font-size: 1.05rem; }
.btn-icon{ padding: 8px; font-size: 1.25rem; line-height: 1; }
.btn-block{ width: 100%; }

.key-hint {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  background: rgba(255,255,255,.12);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
  vertical-align: middle;
  margin-left: 4px;
}

kbd {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-size: .85em;
  font-family: var(--font);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: .8rem;
  font-weight: 600;
}

/* ── Views ─────────────────────────────────────────────────────────────── */
.view { display: none; }
/* Lobby scrolls normally */
#lobby-view.active { display: flex; flex-direction: column; min-height: 100dvh; }
/* Game view is FIXED to the viewport — no page scroll */
#game-view.active  { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

/* ======================================================================
   LOBBY
   ====================================================================== */
.lobby-hero {
  text-align: center;
  padding: 72px 24px 36px;
}
.logo {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.1;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo .accent {
  /* gradient inherited from .logo */
}
.subtitle { color: var(--text-2); margin-top: 10px; font-size: 1.05rem; }

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.15rem; margin-bottom: 18px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.form-group input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus { border-color: var(--primary); }
.form-group input::placeholder { color: var(--text-3); }

.join-card .btn { width: 100%; margin-top: 6px; }
.hint { font-size: .78rem; color: var(--text-3); margin-top: 10px; text-align: center; }

.card-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card-header-row h2 { margin-bottom: 0; }

.room-list { max-height: 280px; overflow-y: auto; }
.empty-state { color: var(--text-3); font-size: .9rem; text-align: center; padding: 32px 0; }

.room-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s;
}
.room-item:hover { background: var(--surface-2); }
.room-item .room-name { font-weight: 600; }
.room-item .room-players { font-size: .82rem; color: var(--text-2); }

.lobby-footer {
  text-align: center;
  padding: 24px;
  font-size: .82rem;
  color: var(--text-3);
  margin-top: auto;
}

/* ======================================================================
   GAME HEADER
   ====================================================================== */
.game-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  z-index: 50;
}
.hdr-left, .hdr-right { display: flex; align-items: center; gap: 10px; }
.room-title { font-size: 1rem; font-weight: 700; }

.hdr-right .btn-icon {
  transition: background .15s, border-color .15s;
}
.hdr-right .btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}

/* ======================================================================
   GAME LAYOUT – 3-column, fills remaining viewport height
   ====================================================================== */
.game-layout {
  display: grid;
  grid-template-columns: 220px 1fr 240px;
  gap: 0;
  flex: 1;          /* fill remaining height inside #game-view */
  min-height: 0;    /* allow shrinking below content size */
  overflow: hidden;
}

.panel {
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel:last-child { border-right: none; border-left: 1px solid rgba(255, 255, 255, 0.06); }
.panel h3 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  margin-bottom: 12px;
  flex-shrink: 0;
}

/* ── Scoreboard ────────────────────────────────────────────────────────── */
.player-list { flex: 1; overflow-y: auto; min-height: 0; }

.player-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  transition: background 600ms ease-out;
}
.player-item.highlight {
  background: rgba(139, 92, 246, 0.08);
  border-left: 3px solid rgba(139, 92, 246, 0.4);
}

.player-item.score-changed {
  background: rgba(139, 92, 246, 0.12);
}

.player-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.player-score { font-weight: 700; font-size: .95rem; color: var(--accent); }
.player-stats {
  font-size: .75rem;
  color: var(--text-3);
  margin-top: 2px;
}
.player-info { display: flex; flex-direction: column; }

/* ── Centre column ─────────────────────────────────────────────────────── */
.centre-col {
  display: flex;
  flex-direction: column;
  padding: 16px 28px;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ── Action bar ────────────────────────────────────────────────────────── */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 4px 0 4px;
  flex-shrink: 0;
}

.buzz-btn {
  width: 160px; height: 52px;
  border-radius: var(--radius);
  border: 2px solid var(--buzz-purple);
  background: linear-gradient(145deg, #7c3aed, #6d28d9);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: .06em;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s, opacity .15s;
  box-shadow: 0 0 24px rgba(139,92,246,.35), 0 4px 20px rgba(0,0,0,.4);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  animation: buzz-glow-pulse 2s ease-in-out infinite;
}
.buzz-btn:hover:not(:disabled) {
  box-shadow: 0 0 32px rgba(139,92,246,.5), 0 4px 24px rgba(0,0,0,.5);
  transform: scale(1.04);
}
.buzz-btn:active:not(:disabled) { transform: scale(.92); }
.buzz-btn:disabled {
  opacity: .3;
  cursor: default;
  box-shadow: none;
  animation: none;
}
.buzz-btn.already-buzzed:disabled {
  opacity: .25;
  background: linear-gradient(145deg, #374151, #1f2937);
  border-color: #4b5563;
}

.btn-next { min-width: 120px; }

/* ── Answer section (for the answering player) ────────────────────────── */
.answer-section {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  flex-shrink: 0;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
  pointer-events: none;
}

.answer-section.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.answer-row {
  display: flex; gap: 8px;
}
.answer-row input {
  flex: 1;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  font-size: 1rem;
}
.answer-row input:focus { border-color: var(--primary-h); }

.timer-bar {
  margin-top: 6px;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  /* Width updated via JS every 100ms — no CSS width transition needed */
  transition: background-color .4s;
  width: 100%;
}
.timer-fill.no-transition { transition: none !important; }
.timer-fill.danger { background: var(--error); }

.timer-secs-display {
  text-align: right;
  font-size: .78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-height: 1.1em;
  margin-top: 3px;
  transition: color .3s;
}
.timer-secs-display.danger { color: var(--error); }

.prompt-text {
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(251,191,36,.1);
  border: 1px solid rgba(251,191,36,.3);
  color: var(--warning);
  font-weight: 600;
  font-size: .9rem;
  text-align: center;
}

/* ── Spectator timer (visible to everyone during a buzz / EOQ window) ──── */
.spectator-timer {
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
  pointer-events: none;
}

.spectator-timer.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.spectator-timer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.spectator-timer-label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-2);
}
.spectator-timer-seconds {
  font-size: .85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: color .3s;
}
.spectator-timer-seconds.danger { color: var(--error); }

.live-answer-display {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-xs);
  font-size: .9rem;
  color: var(--text-2);
  min-height: 34px;
  font-style: italic;
}
.live-answer-display::before {
  content: 'Typing: ';
  font-weight: 600;
  color: var(--text-3);
  font-style: normal;
}

/* ── End-of-question window spectator indicator ──────────────────────── */
.spectator-timer.eoq-window {
  border-color: var(--warning);
  background: rgba(251,191,36,.06);
}
.spectator-timer.eoq-window .spectator-timer-label {
  color: var(--warning);
}

/* ══════════════════════════════════════════════════════════════════════════
   EVENT LOG – reverse-chronological feed, independent scrollbar
   ══════════════════════════════════════════════════════════════════════════ */
.event-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px; /* space for scrollbar */
}

/* Generic entry */
.event-log-entry {
  padding: 6px 0;
  line-height: 1.6;
  font-size: .92rem;
}

/* System / info entries */
.system-entry {
  color: var(--text-3);
  font-size: .82rem;
  font-style: italic;
  padding: 4px 0 4px 10px;
  border-left: 3px solid rgba(139, 92, 246, 0.25);
}

/* ── Question block: meta + text in one card ───────────────────────────── */
.question-block {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  margin: 4px 0;
  animation: slide-in-top 250ms ease-out;
}

.q-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--primary-h);
  margin-bottom: 4px;
}

.question-meta {
  display: flex; gap: 6px; flex-wrap: wrap;
  font-size: .75rem;
  margin-bottom: 10px;
}
.meta-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 500;
}

.question-text {
  font-size: 1.05rem;
  line-height: 1.7;
  min-height: 20px;
}

.buzz-marker {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--buzz-purple);
  box-shadow: 0 0 6px var(--buzz-glow);
  vertical-align: middle;
  margin: 0 3px;
}

.unread-words { color: var(--text-3); }

/* ── Answer display (inline in event log) ──────────────────────────────── */
.answer-display {
  margin-top: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  line-height: 1.5;
  animation: scale-pulse 300ms ease-out;
}
.answer-display.correct {
  background: var(--success-bg);
  border-left: 4px solid var(--success);
}
.answer-display.incorrect {
  background: var(--error-bg);
  border-left: 4px solid var(--error);
}
.answer-display.dead {
  background: var(--surface-2);
  border-left: 4px solid var(--text-3);
}
.answer-display .answer-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 3px;
}
.answer-display .answer-label.correct { color: var(--success); }
.answer-display .answer-label.incorrect { color: var(--error); }
.answer-display .answer-label.dead { color: var(--text-3); }

.answer-display .answer-text b,
.answer-display .answer-text strong { color: #fff; }

/* ── Buzz event entry ──────────────────────────────────────────────────── */
.buzz-entry {
  font-weight: 600;
  font-size: .85rem;
  color: var(--warning);
  padding: 3px 0;
}

.result-entry {
  font-size: .85rem;
  padding: 3px 0;
}
.result-entry.correct { color: var(--success); }
.result-entry.incorrect { color: var(--error); }

/* ── Bonus block ───────────────────────────────────────────────────────── */
.bonus-block {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  margin: 4px 0;
  animation: slide-in-top 250ms ease-out;
}

.bonus-leadin {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-2);
  margin-bottom: 12px;
}

.bonus-parts { display: flex; flex-direction: column; gap: 10px; }

.bonus-part-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border-left: 4px solid var(--border);
  transition: border-color .2s;
}
.bonus-part-item.correct  { border-left-color: var(--success); }
.bonus-part-item.incorrect{ border-left-color: var(--error); }
.bonus-part-item.active   { border-left-color: var(--primary); background: var(--accent-bg); }

.bonus-part-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.bonus-part-num {
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
}
.bonus-part-pts { font-weight: 700; font-size: .85rem; }
.bonus-part-pts.correct { color: var(--success); }
.bonus-part-pts.incorrect { color: var(--error); }

.bonus-part-text { font-size: .92rem; line-height: 1.6; }
.bonus-part-answer {
  margin-top: 6px;
  font-size: .85rem;
  color: var(--text-2);
}
.bonus-part-answer b, .bonus-part-answer strong { color: #fff; }

.bonus-total {
  margin-top: 12px;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* ── Chat ──────────────────────────────────────────────────────────────── */
.chat-panel { border-left: 1px solid var(--border); }

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 8px;
}

.chat-msg {
  font-size: .82rem;
  line-height: 1.4;
  padding: 3px 0;
  word-break: break-word;
}
.chat-msg .chat-author { font-weight: 700; margin-right: 6px; color: #a78bfa; }
.chat-msg.system { color: var(--text-3); font-style: italic; font-size: .78rem; }

.chat-input-row { margin-top: auto; flex-shrink: 0; }
.chat-input-row input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  font-size: .85rem;
}
.chat-input-row input:focus { border-color: var(--primary); }
.chat-input-row input::placeholder { color: var(--text-3); }

/* ======================================================================
   MODAL
   ====================================================================== */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 200ms ease-out;
}
.modal-dialog {
  position: relative;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 640px;
  max-width: 94vw;
  max-height: 88vh;
  overflow-y: auto;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}

.modal.active .modal-backdrop {
  opacity: 1;
}
.modal.active .modal-dialog {
  opacity: 1;
  transform: scale(1);
}

/* Wider dialog for the filter modal */
.filter-dialog {
  width: 820px;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px 14px;
}
.modal-header h2 { font-size: 1.1rem; }
.modal-body { padding: 8px 24px 16px; }
.modal-footer { padding: 14px 24px 20px; text-align: right; }

.modal-header .btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
}

.setting-group { margin-bottom: 20px; }
.setting-group > label {
  display: flex; align-items: center; gap: 8px;
  font-size: .85rem; font-weight: 600; color: var(--text-2);
  margin-bottom: 8px;
}

/* Range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: 0 0 6px rgba(99,102,241,.4);
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--surface);
}
.range-labels {
  display: flex; justify-content: space-between;
  font-size: .72rem; color: var(--text-3); margin-top: 4px;
}

/* Chip grid – difficulty toggles */
.chip-grid { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  user-select: none;
}
.chip:hover { border-color: var(--border-light); }
.chip.selected {
  background: var(--accent-bg);
  border-color: var(--primary);
  color: var(--primary-h);
}

/* ── 3-column category selector ────────────────────────────────────────── */
.cat-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cat-header-row label {
  font-size: .85rem; font-weight: 600; color: var(--text-2);
}

.cat-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 420px; /* fixed height — each column scrolls independently */
}

.cat-col {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}
.cat-col:last-child { border-right: none; }

.cat-col-header {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-3);
  padding: 7px 10px 5px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 1;
}

.cat-btn, .sub-btn, .alt-btn {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: none;
  border-left: 3px solid var(--cat-color, var(--border));
  background: transparent;
  color: var(--text-2);
  font-size: .8rem;
  font-family: var(--font);
  cursor: pointer;
  text-align: left;
  transition: background .1s, color .1s;
  line-height: 1.4;
}
.cat-btn:hover, .sub-btn:hover, .alt-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.cat-btn.selected {
  background: rgba(99,102,241,.1);
  color: var(--text);
  border-left-color: var(--cat-color, var(--primary));
}
.sub-btn.selected, .alt-btn.selected {
  background: var(--surface-2);
  color: var(--text);
  border-left-color: var(--cat-color, var(--primary));
}

.cat-alt-header {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  padding: 8px 10px 3px;
  border-left: 3px solid var(--cat-color, var(--border));
}

.sub-hidden { display: none !important; }

/* ── Target score input ─────────────────────────────────────────────────── */
.target-score-input {
  width: 130px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  text-align: center;
  font-size: .95rem;
}
.target-score-input:focus { border-color: var(--primary); }

.inline-fields {
  display: flex; align-items: center; gap: 10px;
}
.inline-fields input {
  width: 100px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  text-align: center;
}
.inline-fields input:focus { border-color: var(--primary); }
.sep { color: var(--text-3); }

.toggles { display: flex; flex-direction: column; gap: 10px; }
.toggle-label {
  display: flex; align-items: center; gap: 10px;
  font-size: .88rem; cursor: pointer;
}
.toggle-label input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ======================================================================
   GAME OVER MODAL
   ====================================================================== */
.game-over-winner {
  text-align: center;
  padding: 24px 0 18px;
}
.game-over-crown {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 10px;
}
.game-over-winner-name {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--warning), #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}
.game-over-subtitle {
  font-size: .95rem;
  color: var(--text-2);
}

.game-over-leaderboard {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.go-player-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.go-player-row:last-child { border-bottom: none; }
.go-player-row.winner { background: rgba(251,191,36,.07); }

.go-rank {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-3);
  text-align: center;
}
.go-player-row.winner .go-rank { color: var(--warning); }
.go-name {
  font-weight: 600;
  font-size: .95rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.go-pts {
  font-weight: 700;
  font-size: .95rem;
  color: var(--accent);
  white-space: nowrap;
}
.go-stats {
  font-size: .78rem;
  color: var(--text-3);
  white-space: nowrap;
}

.game-over-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Animations ───────────────────────────────────────────────────────── */
@keyframes buzz-glow-pulse {
  0%, 100% { box-shadow: 0 0 24px rgba(139,92,246,.35), 0 4px 20px rgba(0,0,0,.4); }
  50%      { box-shadow: 0 0 32px rgba(139,92,246,.5), 0 4px 24px rgba(0,0,0,.5); }
}

@keyframes slide-in-top {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scale-pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* ======================================================================
   RESPONSIVE
   ====================================================================== */
@media (max-width: 900px) {
  .lobby-grid { grid-template-columns: 1fr; }

  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  .scoreboard-panel {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    gap: 8px;
  }
  .scoreboard-panel h3 { display: none; }
  .scoreboard-panel .player-list {
    display: flex; gap: 10px;
    overflow-x: auto; overflow-y: visible;
    flex: none;
  }
  .scoreboard-panel .player-item { min-width: max-content; padding: 6px 12px; }
  #clear-stats-btn { display: none; }

  .chat-panel {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 180px;
  }

  .centre-col { padding: 12px 14px; }

  .buzz-btn { width: 140px; height: 48px; font-size: 1rem; }

  .cat-3col { max-height: 240px; }
}

@media (max-width: 480px) {
  .logo { font-size: 2.2rem; }
  .lobby-hero { padding: 48px 16px 24px; }
  .card { padding: 20px; }
  .question-block, .bonus-block { padding: 14px 14px; }
}

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
