/* ═══════════════════════════════════════════════════
   BrightMinds — css/app.css
   kids.leaflk.com
   Mobile-first PWA stylesheet
═══════════════════════════════════════════════════ */

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

:root {
  --brand:       #6C63FF;
  --brand-dark:  #4B44CC;
  --brand-light: #EEF0FF;
  --green:       #22C55E;
  --green-light: #DCFCE7;
  --red:         #EF4444;
  --red-light:   #FEE2E2;
  --amber:       #F59E0B;
  --amber-light: #FEF3C7;
  --blue:        #3B82F6;
  --blue-light:  #DBEAFE;
  --pink:        #EC4899;
  --pink-light:  #FCE7F3;
  --teal:        #14B8A6;
  --teal-light:  #CCFBF1;
  --purple:      #A855F7;
  --purple-light:#F3E8FF;

  --text-main:   #1E1B4B;
  --text-soft:   #6B7280;
  --text-muted:  #9CA3AF;
  --surface:     #FFFFFF;
  --surface-1:   #F8F7FF;
  --surface-2:   #F1F0F9;
  --border:      #E5E7EB;
  --border-strong: #D1D5DB;
  --radius-sm:   8px;
  --radius:      14px;
  --radius-lg:   20px;
  --radius-xl:   28px;
  --shadow-sm:   0 1px 3px rgba(108,99,255,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:      0 4px 16px rgba(108,99,255,.12), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg:   0 8px 32px rgba(108,99,255,.16), 0 4px 12px rgba(0,0,0,.08);
  --transition:  0.18s ease;
  --font: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

html { height: 100%; font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--surface-1);
  color: var(--text-main);
  min-height: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: hidden;
}

/* ── App Shell ────────────────────────────────── */
#app {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

/* ── Screen System ────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
  animation: fadeIn 0.22s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Typography ───────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 800; line-height: 1.2; }
h2 { font-size: 1.35rem; font-weight: 700; line-height: 1.3; }
h3 { font-size: 1.1rem;  font-weight: 700; line-height: 1.4; }
p  { line-height: 1.6; }

/* ── Buttons ──────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  text-decoration: none;
  white-space: nowrap;
  min-height: 52px;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(108,99,255,.35);
  width: 100%;
}
.btn-primary:hover { background: var(--brand-dark); box-shadow: 0 6px 20px rgba(108,99,255,.4); }

.btn-secondary {
  background: var(--brand-light);
  color: var(--brand);
  width: 100%;
}
.btn-secondary:hover { background: #E0DEFF; }

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  width: 100%;
  border: 1.5px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-1); }

.btn-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  padding: 0;
  background: var(--surface-1);
  color: var(--text-main);
  border: 1.5px solid var(--border);
  min-height: unset;
}
.btn-icon:hover { background: var(--surface-2); }

.btn-sm { padding: 10px 18px; font-size: 0.9rem; min-height: 42px; }

/* ── Form Elements ────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  min-height: 52px;
}
.form-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(108,99,255,.12);
}
.form-input::placeholder { color: var(--text-muted); font-weight: 500; }

/* ── Cards ────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-hover {
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.card-hover:hover  { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand); }
.card-hover:active { transform: scale(0.98); box-shadow: var(--shadow-sm); }

/* ── Badges & Pills ───────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
}
.badge-brand   { background: var(--brand-light); color: var(--brand-dark); }
.badge-green   { background: var(--green-light);  color: #15803D; }
.badge-amber   { background: var(--amber-light);  color: #B45309; }
.badge-red     { background: var(--red-light);    color: #B91C1C; }
.badge-lock    { background: var(--surface-2);    color: var(--text-soft); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-soft);
}

/* ── Progress Bar ─────────────────────────────── */
.progress-track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 10px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #A78BFA);
  border-radius: 10px;
  transition: width 0.4s ease;
}

/* ── Divider ──────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 8px 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Bottom Nav ───────────────────────────────── */
.bottom-nav {
  display: flex;
  background: var(--surface);
  border-top: 1.5px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 12px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 700;
  transition: color var(--transition);
  min-height: 60px;
}
.nav-item .nav-icon { font-size: 1.5rem; transition: transform var(--transition); }
.nav-item.active    { color: var(--brand); }
.nav-item.active .nav-icon { transform: scale(1.15); }
.nav-item:active .nav-icon { transform: scale(0.9); }

/* ── Top Bar ──────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-size: 1.1rem; font-weight: 800; color: var(--text-main); flex: 1; }
.topbar-sub   { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }

/* ══════════════════════════════════════════════
   SCREEN: SPLASH
══════════════════════════════════════════════ */
#screen-splash {
  background: var(--brand);
  align-items: center;
  justify-content: center;
  gap: 0;
}
.splash-logo {
  width: 110px; height: 110px;
  border-radius: 28px;
  background: rgba(255,255,255,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  margin-bottom: 20px;
  animation: popIn 0.5s cubic-bezier(.34,1.56,.64,1) 0.2s both;
}
@keyframes popIn {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.splash-name {
  font-size: 2.2rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.5px;
  animation: fadeUp 0.4s ease 0.5s both;
}
.splash-tagline {
  color: rgba(255,255,255,.8);
  font-size: 1rem;
  font-weight: 600;
  margin-top: 6px;
  animation: fadeUp 0.4s ease 0.65s both;
}
.splash-dots {
  display: flex;
  gap: 8px;
  margin-top: 48px;
  animation: fadeUp 0.4s ease 0.8s both;
}
.splash-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,.4);
  animation: pulse 1.2s ease-in-out infinite;
}
.splash-dot:nth-child(2) { animation-delay: 0.2s; }
.splash-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%,100% { background: rgba(255,255,255,.35); transform: scale(1); }
  50%      { background: rgba(255,255,255,.95); transform: scale(1.2); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════
   SCREEN: LOGIN
══════════════════════════════════════════════ */
#screen-login { background: var(--surface); }
.login-hero {
  background: var(--brand);
  padding: 36px 24px 48px;
  text-align: center;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}
.login-hero-icon {
  font-size: 3rem;
  margin-bottom: 10px;
  display: block;
}
.login-hero h1 { color: #fff; font-size: 1.8rem; }
.login-hero p  { color: rgba(255,255,255,.8); margin-top: 4px; font-size: 0.95rem; font-weight: 600; }

.login-card {
  margin: -28px 20px 0;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  border: 1.5px solid var(--border);
}
.login-footer {
  padding: 20px 24px 32px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ══════════════════════════════════════════════
   SCREEN: HOME
══════════════════════════════════════════════ */
#screen-home { background: var(--surface-1); }
.home-scroll { flex: 1; overflow-y: auto; padding: 20px; }

.welcome-card {
  background: var(--brand);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: #fff;
}
.welcome-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
}
.welcome-card h2   { font-size: 1.05rem; font-weight: 800; color: #fff; }
.welcome-card p    { font-size: 0.85rem; color: rgba(255,255,255,.8); margin-top: 2px; font-weight: 600; }
.welcome-streak    { margin-top: 8px; display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: rgba(255,255,255,.9); font-weight: 700; }

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-card .stat-val { font-size: 1.8rem; font-weight: 900; color: var(--brand); }
.stat-card .stat-lbl { font-size: 0.78rem; color: var(--text-soft); font-weight: 700; margin-top: 2px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Stage cards grid */
.stages-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.stage-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 14px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}
.stage-card:hover  { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand); }
.stage-card:active { transform: scale(0.97); }
.stage-card.locked { opacity: 0.7; cursor: pointer; }
.stage-card .stage-icon {
  width: 46px; height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 10px;
}
.stage-card h3 { font-size: 0.9rem; font-weight: 800; margin-bottom: 2px; }
.stage-card p  { font-size: 0.75rem; color: var(--text-soft); font-weight: 600; }
.stage-lock-badge {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 0.85rem;
}
.stage-progress { margin-top: 10px; }

/* Achievements */
.achievements-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 4px;
}
.achievement-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-soft);
}
.achievement-chip.earned {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand-dark);
}

/* ══════════════════════════════════════════════
   SCREEN: SUBJECT (topic list)
══════════════════════════════════════════════ */
#screen-subject { background: var(--surface-1); }
.subject-scroll { flex: 1; overflow-y: auto; padding: 16px; }

.stage-hero {
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  color: #fff;
}
.stage-hero h2 { font-size: 1.2rem; font-weight: 800; }
.stage-hero p  { font-size: 0.85rem; opacity: 0.85; margin-top: 4px; font-weight: 600; }

.topic-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.topic-card:hover  { transform: translateX(3px); box-shadow: var(--shadow-sm); border-color: var(--brand); }
.topic-card:active { transform: scale(0.98); }
.topic-card.locked { opacity: 0.65; }
.topic-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.topic-info { flex: 1; min-width: 0; }
.topic-info h3 { font-size: 0.95rem; font-weight: 800; margin-bottom: 2px; }
.topic-info p  { font-size: 0.78rem; color: var(--text-soft); font-weight: 600; }
.topic-meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.topic-arrow { font-size: 1.2rem; color: var(--text-muted); flex-shrink: 0; }

/* ══════════════════════════════════════════════
   SCREEN: QUIZ
══════════════════════════════════════════════ */
#screen-quiz { background: var(--surface); }
.quiz-header { padding: 16px 20px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.quiz-meta   { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.quiz-progress-label { font-size: 0.82rem; font-weight: 700; color: var(--text-soft); }
.quiz-timer {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--brand);
  background: var(--brand-light);
  padding: 4px 10px;
  border-radius: 20px;
}
.quiz-timer.urgent { color: var(--red); background: var(--red-light); animation: timerPulse 0.5s ease infinite; }
@keyframes timerPulse { 0%,100%{opacity:1} 50%{opacity:0.6} }

.quiz-scroll { flex: 1; overflow-y: auto; padding: 20px; }

.question-card {
  background: var(--brand-light);
  border: 2px solid rgba(108,99,255,.2);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}
.question-num  { font-size: 0.78rem; font-weight: 800; color: var(--brand); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.question-text { font-size: 1.05rem; font-weight: 700; color: var(--text-main); line-height: 1.5; }

.options-list  { display: flex; flex-direction: column; gap: 10px; }
.option-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  text-align: left;
}
.option-btn:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-light); }
.option-btn:active:not(:disabled) { transform: scale(0.98); }
.option-btn:disabled { cursor: default; }
.option-letter {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text-soft);
  flex-shrink: 0;
  transition: all var(--transition);
}
.option-text { font-size: 0.95rem; font-weight: 600; color: var(--text-main); flex: 1; line-height: 1.4; }

/* Option states */
.option-btn.selected  { border-color: var(--brand); background: var(--brand-light); }
.option-btn.selected .option-letter { background: var(--brand); border-color: var(--brand); color: #fff; }
.option-btn.correct   { border-color: var(--green); background: var(--green-light); }
.option-btn.correct .option-letter { background: var(--green); border-color: var(--green); color: #fff; }
.option-btn.wrong     { border-color: var(--red); background: var(--red-light); }
.option-btn.wrong .option-letter   { background: var(--red); border-color: var(--red); color: #fff; }

/* Feedback banner */
.feedback-banner {
  display: none;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 700;
  margin: 12px 0 16px;
  align-items: center;
  gap: 10px;
}
.feedback-banner.show  { display: flex; }
.feedback-banner.correct { background: var(--green-light); color: #15803D; border: 1.5px solid #86EFAC; }
.feedback-banner.wrong   { background: var(--red-light);   color: #B91C1C; border: 1.5px solid #FCA5A5; }
.feedback-icon { font-size: 1.3rem; }

.quiz-actions { padding: 0 0 16px; }

/* ══════════════════════════════════════════════
   SCREEN: RESULTS
══════════════════════════════════════════════ */
#screen-results { background: var(--surface-1); }
.results-scroll { flex: 1; overflow-y: auto; padding: 20px; }

.results-hero { text-align: center; padding: 16px 0 24px; }
.score-emoji  { font-size: 4rem; display: block; margin-bottom: 8px; animation: popIn 0.5s cubic-bezier(.34,1.56,.64,1) both; }
.results-hero h2 { font-size: 1.4rem; font-weight: 900; margin-bottom: 6px; }
.results-hero p  { color: var(--text-soft); font-weight: 600; }

.score-ring-wrap { display: flex; justify-content: center; margin: 16px 0 24px; }
.score-ring {
  width: 130px; height: 130px;
  border-radius: 50%;
  border: 8px solid var(--brand-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}
.score-ring::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 8px solid transparent;
  border-top-color: var(--brand);
  border-right-color: var(--brand);
  transform: rotate(var(--deg, 0deg));
}
.score-ring .score-num { font-size: 2.2rem; font-weight: 900; color: var(--brand); line-height: 1; }
.score-ring .score-den { font-size: 0.82rem; font-weight: 700; color: var(--text-soft); }

.results-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.result-stat {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
}
.result-stat .rs-val { font-size: 1.4rem; font-weight: 900; }
.result-stat .rs-lbl { font-size: 0.72rem; font-weight: 700; color: var(--text-soft); margin-top: 2px; }

.breakdown-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}
.breakdown-title { padding: 14px 16px; font-size: 0.82rem; font-weight: 800; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--border); background: var(--surface-1); }
.breakdown-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.breakdown-row:last-child { border-bottom: none; }
.br-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.br-q    { font-size: 0.85rem; font-weight: 600; color: var(--text-main); flex: 1; line-height: 1.4; }
.br-ans  { font-size: 0.78rem; color: var(--text-soft); font-weight: 600; margin-top: 2px; }

.results-actions { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }

/* ══════════════════════════════════════════════
   SCREEN: PROGRESS
══════════════════════════════════════════════ */
#screen-progress { background: var(--surface-1); }
.progress-scroll { flex: 1; overflow-y: auto; padding: 16px; }
.progress-stage-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}
.psc-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.psc-icon   { font-size: 1.5rem; }
.psc-title  { font-size: 0.95rem; font-weight: 800; }
.psc-sub    { font-size: 0.78rem; color: var(--text-soft); font-weight: 600; }
.psc-bar    { margin-top: 6px; }
.psc-bar-label { display: flex; justify-content: space-between; font-size: 0.75rem; font-weight: 700; color: var(--text-soft); margin-bottom: 4px; }

/* ══════════════════════════════════════════════
   SCREEN: LEADERBOARD
══════════════════════════════════════════════ */
#screen-leaderboard { background: var(--surface-1); }
.lb-scroll { flex: 1; overflow-y: auto; padding: 16px; }
.lb-hero {
  background: var(--brand);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
  color: #fff;
}
.lb-hero h2 { font-size: 1.1rem; font-weight: 800; }
.lb-hero p  { font-size: 0.82rem; opacity: .8; font-weight: 600; margin-top: 4px; }
.lb-podium  { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 12px 0 0; }
.lb-podium-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.lb-podium-avatar { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.lb-podium-avatar.gold { width: 52px; height: 52px; background: rgba(255,215,0,.3); }
.lb-podium-name  { font-size: 0.72rem; font-weight: 700; color: rgba(255,255,255,.9); }
.lb-podium-score { font-size: 0.68rem; color: rgba(255,255,255,.7); font-weight: 600; }

.lb-list-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.lb-rank  { font-size: 1rem; font-weight: 900; color: var(--text-soft); width: 24px; text-align: center; flex-shrink: 0; }
.lb-av    { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.lb-name  { flex: 1; font-size: 0.92rem; font-weight: 800; }
.lb-pts   { font-size: 0.85rem; font-weight: 800; color: var(--brand); }
.lb-list-item.mine { border-color: var(--brand); background: var(--brand-light); }

/* ══════════════════════════════════════════════
   MODAL / OVERLAY
══════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30,27,75,.55);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.show { display: flex; }
.modal-sheet {
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 28px 24px 40px;
  width: 100%;
  max-width: 480px;
  animation: slideUp 0.28s cubic-bezier(.34,1.2,.64,1);
  text-align: center;
}
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-icon  { font-size: 3.2rem; margin-bottom: 12px; display: block; }
.modal-title { font-size: 1.3rem; font-weight: 900; margin-bottom: 8px; }
.modal-body  { color: var(--text-soft); font-size: 0.95rem; font-weight: 600; margin-bottom: 24px; line-height: 1.6; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }

/* ══════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════ */
.toast {
  display: none;
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-main);
  color: #fff;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 0.88rem;
  font-weight: 700;
  z-index: 200;
  white-space: nowrap;
  animation: toastIn 0.25s ease;
}
.toast.show { display: block; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ══════════════════════════════════════════════
   UTILITIES
══════════════════════════════════════════════ */
.text-center { text-align: center; }
.text-muted  { color: var(--text-soft); }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ══════════════════════════════════════════════
   COLOUR THEMES FOR STAGES
══════════════════════════════════════════════ */
.theme-purple { --stage-color: #6C63FF; --stage-light: #EEF0FF; }
.theme-blue   { --stage-color: #3B82F6; --stage-light: #DBEAFE; }
.theme-green  { --stage-color: #22C55E; --stage-light: #DCFCE7; }
.theme-amber  { --stage-color: #F59E0B; --stage-light: #FEF3C7; }
.theme-pink   { --stage-color: #EC4899; --stage-light: #FCE7F3; }
.theme-teal   { --stage-color: #14B8A6; --stage-light: #CCFBF1; }

.themed-bg { background: var(--stage-color) !important; }
.themed-light { background: var(--stage-light) !important; }
.themed-text  { color: var(--stage-color) !important; }
.themed-border { border-color: var(--stage-color) !important; }

/* ══════════════════════════════════════════════
   RESPONSIVE — larger screens
══════════════════════════════════════════════ */
@media (min-width: 480px) {
  body { background: #F0EEFF; align-items: center; min-height: 100dvh; }
  #app {
    margin: 24px auto;
    min-height: calc(100dvh - 48px);
    max-height: 900px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
  }
  .modal-overlay { border-radius: var(--radius-xl); max-width: 480px; left: 50%; transform: translateX(-50%); }
}

/* ══════════════════════════════════════════════
   SCROLLBAR (webkit)
══════════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
