/* ─── Fonts ────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700;800;900&family=Geist+Mono:wght@400;500;600;700&display=swap');

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

/* ─── Design tokens — Bardo Studio palette ─────────────────────────────────── */
:root {
  --zinc-50:  #fafafa;
  --zinc-200: #e4e4e7;
  --zinc-400: #a1a1aa;
  --zinc-700: #3f3f46;
  --zinc-800: #27272a;
  --zinc-900: #18181b;
  --zinc-950: #09090b;

  --cyan-200: #a8fbe9;
  --cyan-400: #4fe9d0;
  --cyan-500: #38e8cb;
  --cyan-600: #22c4ab;

  --bg:           var(--zinc-950);
  --surface:      var(--zinc-900);
  --surface-2:    var(--zinc-800);
  --surface-3:    var(--zinc-700);
  --border:       rgba(255, 255, 255, 0.12);
  --border-focus: var(--cyan-500);
  --text:         var(--zinc-50);
  --muted:        var(--zinc-400);
  --primary:      var(--cyan-500);
  --primary-fg:   var(--zinc-900);
  --ring:         rgba(56, 232, 203, 0.28);

  --radius-sm: 2px;
  --radius-md: 4px;
  --radius:    6px;
  --radius-xl: 10px;

  /* Answer option colours — Bardo extra palette (vibrant on zinc-950) */
  --opt-a: #5d6bff;   /* extra-electric-blue   */
  --opt-b: #ff7c43;   /* extra-peach            */
  --opt-c: #d453ee;   /* extra-magenta          */
  --opt-d: #ABCC16;   /* extra-zesty-lime       */

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow:    0 4px 16px rgba(0,0,0,0.45);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.55);

  --font-sans: 'Geist', system-ui, -apple-system, sans-serif;
  --font-mono: 'Geist Mono', 'Menlo', monospace;
}

/* ─── Base ─────────────────────────────────────────────────────────────────── */
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

/* ─── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
}
.card-wide { max-width: 900px; }

/* ─── Typography ───────────────────────────────────────────────────────────── */
h1 { font-size: 1.714rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.3px; }
h2 { font-size: 1.286rem; font-weight: 600; line-height: 1.2; }
h3 { font-size: 1rem;     font-weight: 600; }
.muted { color: var(--muted); font-size: 0.857rem; }
.mono  { font-family: var(--font-mono); }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 36px;
  padding: 0 1rem;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, background 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:hover:not(:disabled)  { opacity: 0.88; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }

.btn-primary   { background: var(--primary);   color: var(--primary-fg); font-weight: 600; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost     { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); opacity: 1; }
.btn-danger    { background: #f87171; color: #fff; }
.btn-full { width: 100%; }
.btn-lg   { height: 40px; padding: 0 1.5rem; font-size: 14px; font-weight: 600; }
.btn-sm   { height: 32px; padding: 0 0.75rem; font-size: 13px; }

/* ─── Form ─────────────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  height: 36px;
  padding: 0 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--ring);
}
.input::placeholder { color: var(--muted); }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}
.field { margin-bottom: 1rem; }

/* ─── Brand ────────────────────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1.5rem; }
.brand-icon {
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--primary-fg);
}
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; }

/* ─── Quiz header bar ──────────────────────────────────────────────────────── */
.quiz-header {
  position: fixed; top: 0; left: 0; right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  z-index: 100;
}
.quiz-header .quiz-title { font-weight: 600; font-size: 14px; }
.quiz-header .q-counter  { color: var(--muted); font-size: 13px; font-family: var(--font-mono); }

/* ─── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 2px 8px; border-radius: 9999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.badge-green  { background: rgba(56,232,203,0.1);  color: var(--cyan-400);  border-color: rgba(56,232,203,0.2);  }
.badge-red    { background: rgba(249,93,106,0.1);  color: #f95d6a;          border-color: rgba(249,93,106,0.2);  }
.badge-yellow { background: rgba(255,166,0,0.1);   color: #ffa600;          border-color: rgba(255,166,0,0.2);   }
.badge-blue   { background: rgba(71,166,243,0.1);  color: #47a6f3;          border-color: rgba(71,166,243,0.2);  }
.badge-purple { background: rgba(161,115,255,0.1); color: #a173ff;          border-color: rgba(161,115,255,0.2); }

/* ─── Waiting ──────────────────────────────────────────────────────────────── */
.waiting {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.75rem; text-align: center; padding: 1.25rem 0;
}
.pulse {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  background: rgba(56,232,203,0.08);
  border: 1px solid rgba(56,232,203,0.2);
  animation: pulse 1.6s ease-in-out infinite;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0    rgba(56,232,203,0.12); }
  50%       { box-shadow: 0 0 0 10px rgba(56,232,203,0);    }
}

/* ─── Song guess section (player) ─────────────────────────────────────────── */
.song-guess-section {
  background: var(--surface-2);
  border: 1px solid rgba(56,232,203,0.15);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
}
.song-guess-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(70% 80% at 50% 0%, rgba(56,232,203,0.05) 0%, transparent 100%);
  pointer-events: none;
}
.song-guess-header {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.875rem;
}
.song-guess-header h3 { font-size: 0.9rem; font-weight: 600; }

.guess-confirmed {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  background: rgba(56,232,203,0.08);
  border: 1px solid rgba(56,232,203,0.2);
  border-radius: var(--radius-md);
  color: var(--cyan-400);
  font-size: 13px; font-weight: 500;
}

/* ─── Question blocks (player group view) ─────────────────────────────────── */
.questions-section { display: flex; flex-direction: column; gap: 1rem; }
.section-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 0.5rem;
}

.question-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
  transition: border-color 0.2s;
}
.question-block.answered {
  border-color: rgba(56,232,203,0.2);
}
.question-block-text {
  font-size: 14px; font-weight: 600; line-height: 1.4;
  margin-bottom: 0.75rem;
}
.question-block-num {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 4px;
}

/* ─── Answer grid ──────────────────────────────────────────────────────────── */
.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.answers-grid.two-col { grid-template-columns: 1fr 1fr; }

.answer-btn {
  position: relative;
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border: none; border-radius: var(--radius);
  color: #fff;
  font-family: var(--font-sans); font-size: 13px; font-weight: 600;
  cursor: pointer; text-align: left;
  min-height: 48px; word-break: break-word;
  transition: filter 0.15s, transform 0.1s, opacity 0.15s;
}
.answer-btn:hover:not(:disabled)  { filter: brightness(1.09); transform: translateY(-1px); }
.answer-btn:active:not(:disabled) { transform: scale(0.98); }
.answer-btn:disabled { cursor: default; }

.answer-btn[data-opt="a"] { background: var(--opt-a); }
.answer-btn[data-opt="b"] { background: var(--opt-b); }
.answer-btn[data-opt="c"] { background: var(--opt-c); }
.answer-btn[data-opt="d"] { background: var(--opt-d); }

.answer-btn .opt-label {
  width: 20px; height: 20px; border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0; text-transform: uppercase;
}
.answer-btn.selected  { outline: 2px solid rgba(255,255,255,0.75); outline-offset: 1px; }
.answer-btn.correct   { outline: 2px solid #fff; outline-offset: 1px; filter: brightness(1.1); }
.answer-btn.incorrect { opacity: 0.28; }
.answer-btn.dimmed    { opacity: 0.32; }

/* ─── Result bars ──────────────────────────────────────────────────────────── */
.result-bars { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.625rem; }
.result-bar-row { display: flex; align-items: center; gap: 0.5rem; }
.result-bar-label {
  width: 20px; height: 20px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0; text-transform: uppercase; color: #fff;
}
.result-bar-label[data-opt="a"] { background: var(--opt-a); }
.result-bar-label[data-opt="b"] { background: var(--opt-b); }
.result-bar-label[data-opt="c"] { background: var(--opt-c); }
.result-bar-label[data-opt="d"] { background: var(--opt-d); }

.result-bar-track {
  flex: 1; height: 18px; background: var(--surface-2);
  border-radius: var(--radius-sm); overflow: hidden;
}
.result-bar-fill {
  height: 100%; border-radius: var(--radius-sm);
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1); min-width: 3px;
}
.result-bar-fill[data-opt="a"] { background: var(--opt-a); }
.result-bar-fill[data-opt="b"] { background: var(--opt-b); }
.result-bar-fill[data-opt="c"] { background: var(--opt-c); }
.result-bar-fill[data-opt="d"] { background: var(--opt-d); }
.result-bar-count {
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  color: var(--muted); min-width: 18px; text-align: right;
}

/* ─── Host question progress rows ─────────────────────────────────────────── */
.q-progress-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.75rem 0; }
.q-progress-row  { display: flex; align-items: center; gap: 0.625rem; }
.q-progress-label { font-size: 13px; font-weight: 500; flex: 1; color: var(--muted); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-progress-track {
  width: 120px; height: 6px; background: var(--surface-2);
  border-radius: 9999px; overflow: hidden; flex-shrink: 0;
}
.q-progress-fill {
  height: 100%; background: var(--cyan-500);
  border-radius: 9999px; transition: width 0.4s ease;
}
.q-progress-count { font-family: var(--font-mono); font-size: 12px; color: var(--muted); min-width: 40px; text-align: right; }

/* ─── Host song guess scoring ─────────────────────────────────────────────── */
.guess-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.625rem; }

.guess-row {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.625rem 0.875rem;
}
.guess-row.scored { border-color: rgba(56,232,203,0.2); }

.guess-player-name {
  font-size: 13px; font-weight: 600; min-width: 80px; flex-shrink: 0;
}
.guess-text {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
}
.guess-song-title  { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guess-song-artist { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.guess-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }

.score-btn {
  height: 28px; padding: 0 0.625rem;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.score-btn:hover  { opacity: 0.82; }
.score-btn:active { transform: scale(0.96); }
.score-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.score-btn-1000 { background: rgba(56,232,203,0.15); color: var(--cyan-400); border: 1px solid rgba(56,232,203,0.25); }
.score-btn-500  { background: rgba(255,166,0,0.12);  color: #ffa600;         border: 1px solid rgba(255,166,0,0.2); }
.score-btn-0    { background: rgba(249,93,106,0.1);  color: #f95d6a;         border: 1px solid rgba(249,93,106,0.2); }

.guess-awarded-badge {
  font-size: 12px; font-weight: 600; font-family: var(--font-mono);
  color: var(--cyan-500); display: none;
}
.guess-row.scored .guess-awarded-badge { display: inline; }
.guess-row.scored .guess-actions { display: none; }

/* ─── Leaderboard ──────────────────────────────────────────────────────────── */
.leaderboard { display: flex; flex-direction: column; gap: 0.375rem; margin-top: 0.75rem; }
.lb-row {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.625rem 0.875rem;
  position: relative; overflow: hidden;
}
.lb-row.top-1::after, .lb-row.top-2::after, .lb-row.top-3::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
}
.lb-row.top-1 { border-color: rgba(56,232,203,0.3); }
.lb-row.top-1::after { background: radial-gradient(80% 120% at 50% 100%, rgba(56,232,203,0.1) 0%, transparent 100%); }
.lb-row.top-2 { border-color: rgba(255,255,255,0.18); }
.lb-row.top-2::after { background: radial-gradient(80% 120% at 50% 100%, rgba(255,255,255,0.04) 0%, transparent 100%); }
.lb-row.top-3 { border-color: rgba(255,166,0,0.2); }
.lb-row.top-3::after { background: radial-gradient(80% 120% at 50% 100%, rgba(255,166,0,0.06) 0%, transparent 100%); }

.lb-rank  { font-family: var(--font-mono); font-size: 15px; font-weight: 700; width: 28px; text-align: center; flex-shrink: 0; }
.lb-name  { flex: 1; font-weight: 500; font-size: 15px; }
.lb-score { font-family: var(--font-mono); font-weight: 600; font-size: 15px; color: var(--cyan-500); }

/* ─── Player result items (after group ends) ──────────────────────────────── */
.result-items { display: flex; flex-direction: column; gap: 0.375rem; margin: 0.75rem 0; }
.result-item {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.5rem 0.75rem;
}
.result-item.correct  { border-color: rgba(81,196,139,0.25); }
.result-item.wrong    { border-color: rgba(249,93,106,0.15); }
.result-item.skipped  { opacity: 0.55; }

.result-item-icon   { font-size: 14px; flex-shrink: 0; }
.result-item-text   { flex: 1; font-size: 13px; font-weight: 500; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-item-points { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--cyan-500); flex-shrink: 0; }
.result-item.wrong .result-item-points, .result-item.skipped .result-item-points { color: var(--muted); }

/* ─── Player chips ─────────────────────────────────────────────────────────── */
.player-chips { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.625rem; min-height: 30px; }
.player-chip {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 3px 10px;
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.player-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan-500); flex-shrink: 0; }
.player-chip.disconnected .dot { background: var(--muted); }

/* ─── Host layout ──────────────────────────────────────────────────────────── */
.host-layout {
  display: grid; grid-template-columns: 1fr 272px; gap: 1rem;
  width: 100%; max-width: 1060px; padding-top: 64px; align-items: start;
}
.host-main    { min-width: 0; }
.host-sidebar { display: flex; flex-direction: column; gap: 0.75rem; }

@media (max-width: 720px) {
  .host-layout  { grid-template-columns: 1fr; }
  .answers-grid { grid-template-columns: 1fr; }
}

/* ─── QR code ──────────────────────────────────────────────────────────────── */
.qr-img {
  border-radius: var(--radius); border: 1px solid var(--border);
  width: 100%; max-width: 192px; display: block; margin: 0 auto;
}

/* ─── Song reveal (host) ───────────────────────────────────────────────────── */
.song-reveal {
  background: var(--surface-2);
  border: 1px solid rgba(56,232,203,0.15);
  border-radius: var(--radius); padding: 0.75rem 1rem;
  position: relative; overflow: hidden;
}
.song-reveal::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(80% 120% at 50% 100%, rgba(56,232,203,0.07) 0%, transparent 100%);
  pointer-events: none;
}
.song-reveal-meta   { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.song-reveal-title  { font-size: 1rem; font-weight: 700; }
.song-reveal-artist { font-size: 0.875rem; font-weight: 500; color: var(--cyan-500); margin-top: 2px; }

/* ─── Sticky submit bar (player group view) ───────────────────────────────── */
.sticky-submit-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 0.875rem 1rem;
  background: linear-gradient(to top, var(--zinc-950) 70%, transparent);
  z-index: 90;
  display: flex;
  justify-content: center;
}
.sticky-submit-bar .btn {
  width: 100%;
  max-width: 560px;
  height: 48px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(56,232,203,0.25);
  letter-spacing: 0.01em;
}
.sticky-submit-bar.submitted .btn {
  background: var(--surface-2);
  color: var(--muted);
  box-shadow: none;
  cursor: default;
  pointer-events: none;
}

/* ─── Toast ────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 1.25rem; left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); padding: 7px 16px; border-radius: 9999px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 999; pointer-events: none; white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ─── Spacing utilities ────────────────────────────────────────────────────── */
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.gap  { display: flex; gap: 8px; }

hr.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ─── Animations ───────────────────────────────────────────────────────────── */
.fade-in  { animation: fadeIn  0.2s ease; }
.slide-up { animation: slideUp 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Scrollbar ────────────────────────────────────────────────────────────── */
html { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 9999px; }
