/* ===========================================================
   Live Quiz — Main Stylesheet
   Signature: circular "hot seat" countdown timer + game-show
   navy/gold palette. Mobile-first, dark mode via [data-theme].
   =========================================================== */

:root {
  --navy-900: #0f1230;
  --navy-800: #171b45;
  --navy-700: #232a63;
  --gold-500: #ffc93c;
  --gold-600: #f2b100;
  --green-500: #22c55e;
  --red-500: #ef4444;
  --ink: #12142b;
  --ink-soft: #565b7a;
  --bg: #f5f6fb;
  --card-bg: #ffffff;
  --border: #e5e7f0;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-display: 'Poppins', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

[data-theme="dark"] {
  --ink: #eef0fb;
  --ink-soft: #a4a9cc;
  --bg: #0b0d24;
  --card-bg: #171b45;
  --border: #2a2f5f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  transition: background .2s ease, color .2s ease;
}

.container { max-width: 720px; margin: 0 auto; padding: 0 18px; }

/* ---------- Header ---------- */
.site-header {
  background: var(--navy-900);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; }
.logo { color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 20px; text-decoration: none; letter-spacing: -0.02em; }
.main-nav { display: flex; align-items: center; gap: 16px; }
.main-nav a { color: #cfd3f2; text-decoration: none; font-size: 14px; font-weight: 600; }
.theme-toggle { background: rgba(255,255,255,.08); border: none; color: #fff; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 15px; }

/* ---------- Main content ---------- */
.main-content { padding: 24px 18px 60px; }

/* ---------- Hero / homepage ---------- */
.hero-card {
  background: linear-gradient(135deg, var(--navy-800), var(--navy-900));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
}
.hero-card h1 { font-family: var(--font-display); font-size: 26px; margin: 0 0 8px; letter-spacing: -0.02em; }
.hero-sub { color: #b9bde3; margin: 0 0 20px; font-size: 15px; }
.quiz-state-box { min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.state-text { color: #d8daf5; margin: 0; }
.loading-text { color: #9aa0d4; }

.live-badge {
  display: inline-flex; align-items: center; gap: 6px; background: rgba(34,197,94,.15); color: #4ade80;
  padding: 5px 14px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .04em; margin-bottom: 4px;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; animation: livePulse 1.4s ease-in-out infinite; }
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74,222,128,.6); }
  70% { box-shadow: 0 0 0 8px rgba(74,222,128,0); }
}

.btn-primary, .btn-join {
  display: inline-block;
  background: var(--gold-500);
  color: var(--navy-900);
  font-weight: 700;
  font-family: var(--font-display);
  padding: 14px 32px;
  border-radius: 999px;
  border: none;
  text-decoration: none;
  cursor: pointer;
  font-size: 16px;
  letter-spacing: .02em;
  transition: transform .15s ease, background .15s ease;
}
.btn-primary:hover, .btn-join:hover { background: var(--gold-600); transform: translateY(-1px); }
.btn-secondary {
  display: inline-block; background: transparent; border: 1.5px solid #cfd3f2; color: #fff;
  padding: 12px 28px; border-radius: 999px; text-decoration: none; font-weight: 600; margin-top: 10px;
}

.nav-user-link { background: rgba(255,255,255,.08); padding: 6px 12px; border-radius: 999px; }

/* ---------- Auth pages (login/register) ---------- */
.auth-card { max-width: 380px; margin: 0 auto; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px 24px; }
.auth-card h1 { font-family: var(--font-display); font-size: 22px; margin: 0 0 6px; text-align: center; }
.auth-sub { color: var(--ink-soft); font-size: 13px; text-align: center; margin: 0 0 18px; }
.auth-card label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--ink-soft); }
.auth-card input { width: 100%; padding: 11px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--bg); color: var(--ink); font-size: 14px; }
.auth-errors { background: rgba(239,68,68,.1); border: 1px solid var(--red-500); color: var(--red-500); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 10px; }
.auth-errors p { margin: 2px 0; }
.auth-switch { text-align: center; font-size: 13px; color: var(--ink-soft); margin-top: 14px; }
.auth-switch a { color: var(--gold-600); font-weight: 600; text-decoration: none; }
.auth-hint { font-size: 12px; color: var(--ink-soft); margin-top: -6px; }
.auth-hint a { color: var(--gold-600); font-weight: 600; }

/* ---------- Categories ---------- */
.categories-strip { margin-top: 28px; }
.categories-strip h2 { font-family: var(--font-display); font-size: 17px; margin: 0 0 10px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card-bg); border: 1px solid var(--border); padding: 7px 14px; border-radius: 999px; font-size: 13px; color: var(--ink-soft); }

.games-teaser { margin-top: 28px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.games-teaser h2 { font-family: var(--font-display); font-size: 17px; margin: 0 0 4px; }
.games-teaser-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.games-teaser-item {
  width: 52px; height: 52px; border-radius: 14px; background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 24px; text-decoration: none;
  transition: transform .15s ease, border-color .15s ease;
}
.games-teaser-item:hover { transform: translateY(-3px); border-color: var(--gold-500); }
.games-teaser-more { font-family: var(--font-display); font-weight: 800; font-size: 15px; color: var(--ink-soft); }

/* ---------- Quiz play page ---------- */
.name-gate {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 28px 22px; text-align: center;
}
.name-gate h2 { font-family: var(--font-display); font-size: 20px; margin: 0 0 8px; }
.name-gate p { color: var(--ink-soft); margin: 0 0 16px; }
#guestNameInput {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  font-size: 15px; margin-bottom: 16px; background: var(--bg); color: var(--ink);
}

.quiz-top-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
#quizProgress { font-weight: 700; color: var(--ink-soft); font-size: 14px; }

.timer-circle { position: relative; width: 58px; height: 58px; }
.timer-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-track { fill: none; stroke: var(--border); stroke-width: 5; }
.timer-progress { fill: none; stroke: var(--gold-500); stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke .2s; }
.timer-circle.urgent .timer-progress { stroke: var(--red-500); }
#timerText { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; font-family: var(--font-display); }

.progress-bar-outer { height: 5px; border-radius: 4px; background: var(--border); margin-bottom: 20px; overflow: hidden; }
.progress-bar-inner { height: 100%; background: var(--gold-500); width: 0%; transition: width .3s ease; }

.question-text {
  font-family: var(--font-display); font-size: 21px; line-height: 1.4; margin: 0 0 22px; font-weight: 600;
}

.options-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.option-btn {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--card-bg); border: 1.5px solid var(--border); border-radius: var(--radius-md);
  padding: 14px 16px; font-size: 15px; color: var(--ink); cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.option-btn:active { transform: scale(0.98); }
.option-btn:hover:not(:disabled) { border-color: var(--gold-500); }
.opt-label {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; background: var(--bg);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--ink-soft);
}
.option-btn.selected { border-color: var(--gold-500); background: rgba(255,201,60,.1); }
.option-btn.correct { border-color: var(--green-500); background: rgba(34,197,94,.12); }
.option-btn.correct .opt-label { background: var(--green-500); color: #fff; }
.option-btn.wrong { border-color: var(--red-500); background: rgba(239,68,68,.1); }
.option-btn.wrong .opt-label { background: var(--red-500); color: #fff; }
.option-btn:disabled { cursor: default; }

.reveal-box { margin-top: 18px; padding: 16px; background: var(--bg); border-radius: var(--radius-md); }
.reveal-box p { margin: 0; }
#revealMessage { font-weight: 700; font-family: var(--font-display); margin-bottom: 6px !important; }
.explanation-text { color: var(--ink-soft); font-size: 14px; }

.quiz-loading { text-align: center; color: var(--ink-soft); padding: 30px 0; }

/* ---------- Result page ---------- */
.result-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 30px 22px; text-align: center; }
.result-card h1 { font-family: var(--font-display); margin: 0 0 20px; }
.score-circle {
  width: 140px; height: 140px; border-radius: 50%; background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
  display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto 24px;
}
.score-num { font-family: var(--font-display); font-size: 28px; font-weight: 800; color: var(--navy-900); }
.score-label { font-size: 12px; color: var(--navy-900); opacity: .8; }

.result-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.stat-box { background: var(--bg); border-radius: var(--radius-sm); padding: 14px 8px; }
.stat-num { display: block; font-family: var(--font-display); font-size: 19px; font-weight: 700; }
.stat-box.correct .stat-num { color: var(--green-500); }
.stat-box.wrong .stat-num { color: var(--red-500); }
.stat-label { font-size: 11px; color: var(--ink-soft); }

.rank-banner { background: var(--navy-900); color: #fff; padding: 12px; border-radius: var(--radius-sm); margin-bottom: 20px; font-family: var(--font-display); }
.rank-banner strong { color: var(--gold-500); }

.share-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 22px; }
.share-btn { padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 700; text-decoration: none; border: none; cursor: pointer; color: #fff; }
.share-btn.wa { background: #25d366; }
.share-btn.fb { background: #1877f2; }
.share-btn.tg { background: #229ed9; }
.share-btn.copy { background: var(--ink-soft); }

/* ---------- Leaderboard ---------- */
.leaderboard-page h1 { font-family: var(--font-display); margin-bottom: 2px; }
.leaderboard-page .sub { color: var(--ink-soft); margin-top: 0; margin-bottom: 20px; }
.leaderboard-list { display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: grid; grid-template-columns: 40px 1fr auto; grid-template-areas: "rank name score" "rank correct time";
  align-items: center; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; gap: 2px 10px;
}
.lb-rank { grid-area: rank; font-family: var(--font-display); font-weight: 800; font-size: 16px; }
.lb-name { grid-area: name; font-weight: 600; }
.lb-score { grid-area: score; font-weight: 700; color: var(--gold-600); font-size: 13px; }
.lb-correct { grid-area: correct; font-size: 12px; color: var(--ink-soft); }
.lb-time { grid-area: time; font-size: 12px; color: var(--ink-soft); text-align: right; }

/* ---------- Ads ---------- */
.ad-slot { background: var(--card-bg); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 10px; margin: 16px 0; text-align: center; font-size: 12px; color: var(--ink-soft); overflow: hidden; }

/* ---------- Footer ---------- */
.site-footer { text-align: center; padding: 24px 0 40px; color: var(--ink-soft); font-size: 13px; }

/* ---------- Responsive ---------- */
@media (min-width: 640px) {
  .options-grid { grid-template-columns: 1fr 1fr; }
  .hero-card h1 { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
