@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400;1,600&family=DM+Sans:wght@300;400;500&display=swap');

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

:root {
  --bg:         #0D0D1A;
  --bg-card:    #1A1A2E;
  --bg-deep:    #12102a;
  --violet:     #7B2FBE;
  --violet-dim: #4a1a78;
  --gold:       #F5C842;
  --teal:       #2DD4BF;
  --text:       #F0EEF6;
  --text-muted: #9988bb;
  --text-dim:   #6655aa;
  --border:     #2a1a4a;
  --border-glow:#7B2FBE44;
  --font-d:     'Playfair Display', serif;
  --font-b:     'DM Sans', sans-serif;
  --r:          12px;
  --r-sm:       8px;
  --r-pill:     99px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-b);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Starfield background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10%  20%, #ffffff22 0%, transparent 100%),
    radial-gradient(1px 1px at 30%  55%, #ffffff1a 0%, transparent 100%),
    radial-gradient(1px 1px at 55%  15%, #ffffff22 0%, transparent 100%),
    radial-gradient(1px 1px at 70%  70%, #ffffff18 0%, transparent 100%),
    radial-gradient(1px 1px at 85%  35%, #ffffff20 0%, transparent 100%),
    radial-gradient(1px 1px at 20%  80%, #ffffff15 0%, transparent 100%),
    radial-gradient(1px 1px at 92%  10%, #ffffff22 0%, transparent 100%),
    radial-gradient(1px 1px at 45%  90%, #ffffff18 0%, transparent 100%),
    radial-gradient(2px 2px at 60%  45%, #F5C84215 0%, transparent 100%),
    radial-gradient(2px 2px at 25%  35%, #7B2FBE15 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ───────────────────────────────────────────────── */
.page { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ── Nav ──────────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.85rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.nav-logo {
  font-family: var(--font-d);
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-logo .star { font-size: 14px; }
.nav-right { font-size: 12px; color: var(--text-muted); cursor: pointer; text-decoration: none; }
.nav-right:hover { color: var(--teal); }

/* ── Bottom Bar ───────────────────────────────────────────── */
.bottom-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 0.6rem 0 0.5rem;
}
.bb-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 0 1rem;
}
.bb-item.active { color: var(--text-muted); }
.bb-item.active .bb-icon { color: var(--violet); }
.bb-icon { font-size: 18px; line-height: 1; }

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  padding: 2rem 1.4rem 1.6rem;
  text-align: center;
  background: linear-gradient(180deg, #14082a 0%, transparent 100%);
}
.hero-sparkle { color: var(--gold); font-size: 13px; letter-spacing: 8px; margin-bottom: 0.6rem; opacity: 0.7; }
.hero h1 {
  font-family: var(--font-d);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 0.4rem;
}
.hero h1 em { color: var(--gold); font-style: normal; }
.hero-sub {
  font-family: var(--font-d);
  font-style: italic;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 1.4rem;
}
.btn {
  display: inline-block;
  padding: 0.65rem 1.6rem;
  border-radius: var(--r-pill);
  font-family: var(--font-b);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: opacity 0.15s, transform 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--violet); color: var(--text); }
.btn-secondary { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted); }
.btn-gold      { background: var(--gold); color: var(--bg); font-weight: 600; }

/* ── Section label ────────────────────────────────────────── */
.section-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
  padding: 1.2rem 1.25rem 0.5rem;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--r);
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-glow); }

/* ── Category tiles ───────────────────────────────────────── */
.categories { display: flex; flex-direction: column; gap: 0.65rem; padding: 0 1.25rem; }
.cat-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  cursor: pointer;
  text-decoration: none;
}
.cat-left { display: flex; align-items: center; gap: 0.8rem; }
.cat-icon-wrap {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.cat-icon-books   { background: #2a1060; }
.cat-icon-theatre { background: #122a1a; }
.cat-icon-movies  { background: #2a1510; }
.cat-name { font-family: var(--font-d); font-size: 15px; font-weight: 600; color: var(--text); }
.cat-count { font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.cat-arrow { color: var(--violet); font-size: 18px; font-weight: 300; }

/* ── Quiz list ────────────────────────────────────────────── */
.quiz-list { display: flex; flex-direction: column; gap: 0.65rem; padding: 0 1.25rem; }
.quiz-list-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  text-decoration: none;
}
.quiz-list-name { font-family: var(--font-d); font-size: 14px; font-weight: 600; color: var(--text); }
.quiz-list-desc { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.8rem 1.25rem 0.4rem;
  background: none;
  border: none;
  font-family: var(--font-b);
}
.back-btn:hover { color: var(--teal); }

/* ── Progress bar ─────────────────────────────────────────── */
.progress-wrap { padding: 0 1.25rem 0.5rem; }
.progress-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }
.progress-track { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill  { height: 100%; background: var(--violet); border-radius: 2px; transition: width 0.4s ease; }

/* ── Question ─────────────────────────────────────────────── */
.question-area { padding: 0.9rem 1.25rem 0; }
.quiz-category-tag {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 0.6rem;
}
.question-text {
  font-family: var(--font-d);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  margin-bottom: 1.2rem;
}

/* ── Answers ──────────────────────────────────────────────── */
.answers { display: flex; flex-direction: column; gap: 0.55rem; padding: 0 1.25rem; }
.answer-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  font-family: var(--font-b);
  color: var(--text);
}
.answer-btn:hover:not([disabled]) { border-color: var(--violet); }
.answer-btn[disabled] { cursor: default; }
.answer-letter {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: #2a1a4a;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  flex-shrink: 0;
}
.answer-text { font-size: 13.5px; line-height: 1.35; }

.answer-btn.correct { border-color: var(--teal); background: #0d2a28; }
.answer-btn.correct .answer-letter { background: #2DD4BF22; color: var(--teal); }
.answer-btn.correct .answer-text { color: var(--teal); }

.answer-btn.wrong { border-color: #8B2020; background: #2a0d0d; opacity: 0.7; }
.answer-btn.wrong .answer-letter { background: #8B202022; color: #cc5555; }

/* ── Feedback ─────────────────────────────────────────────── */
.feedback-wrap { padding: 0.9rem 1.25rem 0.5rem; }
.feedback-box {
  background: var(--bg-deep);
  border: 1px solid #2DD4BF33;
  border-radius: var(--r-sm);
  padding: 0.65rem 0.9rem;
  font-family: var(--font-d);
  font-style: italic;
  font-size: 13px;
  color: var(--teal);
  display: none;
}
.feedback-box.wrong-feedback { border-color: #8B202033; color: #cc7777; }
.feedback-box.show { display: block; }

.next-wrap { padding: 0.75rem 1.25rem 1.25rem; }

/* ── Score badge ──────────────────────────────────────────── */
.score-badge { font-size: 12px; color: var(--teal); font-weight: 500; }

/* ── Results ──────────────────────────────────────────────── */
.results-hero { padding: 1.8rem 1.4rem 1.2rem; text-align: center; background: linear-gradient(180deg, #14082a 0%, transparent 100%); }
.results-stars { color: var(--gold); font-size: 20px; letter-spacing: 6px; margin-bottom: 0.6rem; }
.results-title { font-family: var(--font-d); font-size: 1.8rem; font-weight: 700; color: var(--gold); line-height: 1.2; margin-bottom: 0.3rem; }
.results-sub { font-family: var(--font-d); font-style: italic; font-size: 13px; color: var(--text-muted); margin-bottom: 1.2rem; }
.score-pill {
  display: inline-block;
  background: var(--violet);
  color: var(--text);
  font-family: var(--font-d);
  font-size: 2.2rem;
  font-weight: 700;
  padding: 0.5rem 2rem;
  border-radius: var(--r-pill);
  margin-bottom: 0.35rem;
}
.score-label { font-size: 10px; color: var(--text-dim); letter-spacing: 0.08em; text-transform: uppercase; }

.lb-submit-card { margin: 0.9rem 1.25rem 0; }
.lb-submit-card .card { padding: 1rem 1.1rem; }
.lb-submit-title { font-family: var(--font-d); font-size: 13px; font-weight: 600; color: var(--gold); margin-bottom: 0.7rem; }
.lb-name-input {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.6rem 0.85rem;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font-b);
  margin-bottom: 0.6rem;
  outline: none;
  transition: border-color 0.15s;
}
.lb-name-input:focus { border-color: var(--violet); }
.lb-name-input::placeholder { color: var(--text-dim); }
.submit-msg { font-size: 12px; color: var(--teal); margin-top: 0.4rem; display: none; }
.submit-msg.show { display: block; }

.results-actions { display: flex; gap: 0.6rem; padding: 0.9rem 1.25rem 1.25rem; }
.results-actions .btn { flex: 1; text-align: center; }

/* ── Leaderboard ──────────────────────────────────────────── */
.lb-tabs { display: flex; gap: 0.4rem; padding: 0.9rem 1.25rem 0.5rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.lb-tab {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  padding: 0.35rem 0.85rem;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  background: none;
  font-family: var(--font-b);
  transition: all 0.15s;
}
.lb-tab.active { background: #7B2FBE22; color: var(--text-muted); border-color: #7B2FBE55; }
.lb-list { display: flex; flex-direction: column; gap: 0.5rem; padding: 0 1.25rem 1.25rem; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
}
.lb-row.gold   { border-color: #F5C84244; background: #1e1a0d; }
.lb-row.silver { border-color: #aaaaaa22; }
.lb-row.bronze { border-color: #cd7f3222; }
.lb-rank { font-family: var(--font-d); font-size: 14px; font-weight: 700; width: 22px; text-align: center; flex-shrink: 0; }
.lb-rank.gold { color: var(--gold); }
.lb-rank.silver { color: #bbbbbb; }
.lb-rank.bronze { color: #cd7f32; }
.lb-rank.plain { color: var(--text-dim); font-size: 11px; font-family: var(--font-b); }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-meta { font-size: 10px; color: var(--text-dim); margin-top: 1px; }
.lb-score { font-size: 13px; font-weight: 500; color: var(--teal); flex-shrink: 0; }
.lb-pct   { font-size: 14px; font-weight: 600; color: var(--teal); }
.lb-perfect { font-size: 9px; color: var(--gold); text-align: right; }
.lb-empty { padding: 2rem 1.25rem; text-align: center; font-family: var(--font-d); font-style: italic; color: var(--text-dim); font-size: 14px; }

/* ── Maintenance ──────────────────────────────────────────── */
.maint-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2rem 2rem; }
.maint-star { font-size: 56px; color: var(--gold); margin-bottom: 1.2rem; animation: pulse 3s ease-in-out infinite; }
.maint-title { font-family: var(--font-d); font-size: 2rem; font-weight: 700; color: var(--gold); line-height: 1.2; margin-bottom: 0.6rem; }
.maint-msg { font-family: var(--font-d); font-style: italic; font-size: 15px; color: var(--text-muted); line-height: 1.6; margin-bottom: 1.8rem; }
.maint-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 0.5rem 1.2rem; font-size: 12px; color: var(--teal); }
.maint-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); animation: pulse 1.5s ease-in-out infinite; }

/* ── Animations ───────────────────────────────────────────── */
@keyframes pulse { 0%, 100% { opacity: 0.6; transform: scale(0.95); } 50% { opacity: 1; transform: scale(1.05); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease forwards; }

/* ── Loading ──────────────────────────────────────────────── */
.loading { padding: 3rem 1.25rem; text-align: center; color: var(--text-dim); font-family: var(--font-d); font-style: italic; }

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

/* ── Desktop centering ────────────────────────────────────── */
@media (min-width: 520px) {
  .page { box-shadow: 0 0 80px #7B2FBE18; }
}
