[hidden] { display: none !important; }
/* ═══════════════════════ MedTech Reviewer — styles ═══════════════════════ */

:root {
  --bg: #f5f3ff;
  --bg-2: #fdf4ff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2ff;
  --text: #1e1b4b;
  --muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 10px 30px -12px rgba(76, 29, 149, .25);
  --shadow-sm: 0 4px 14px -6px rgba(76, 29, 149, .25);

  --primary: #7c3aed;
  --primary-2: #ec4899;
  --primary-soft: #ede9fe;
  --on-primary: #ffffff;
  --grad: linear-gradient(135deg, var(--primary), var(--primary-2));

  --good: #16a34a;
  --good-soft: #dcfce7;
  --bad: #e11d48;
  --bad-soft: #ffe4e6;
  --warn: #f59e0b;
  --gold: #fbbf24;
  --silver: #cbd5e1;
  --bronze: #f59e6b;

  --radius: 20px;
  --radius-sm: 12px;
  --font-scale: 1;
  --anim: 1;
  color-scheme: light;
}

/* Accent palettes */
:root[data-accent="ocean"]  { --primary: #0284c7; --primary-2: #06b6d4; --primary-soft: #e0f2fe; }
:root[data-accent="sunset"] { --primary: #ea580c; --primary-2: #e11d48; --primary-soft: #ffedd5; }
:root[data-accent="forest"] { --primary: #059669; --primary-2: #84cc16; --primary-soft: #d1fae5; }
:root[data-accent="candy"]  { --primary: #db2777; --primary-2: #f59e0b; --primary-soft: #fce7f3; }

/* Dark theme */
:root[data-theme="dark"] {
  --bg: #0f0b1f;
  --bg-2: #160f2e;
  --surface: #1c1636;
  --surface-2: #241d44;
  --surface-3: #2e2556;
  --text: #f5f3ff;
  --muted: #a5a1c2;
  --border: #352c63;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  --shadow-sm: 0 4px 14px -6px rgba(0, 0, 0, .6);
  --primary-soft: #2e2556;
  --good-soft: #0f3b23;
  --bad-soft: #4a1323;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: calc(16px * var(--font-scale)); scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh;
  font-family: 'Nunito', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, var(--bg-2), transparent), var(--bg);
  display: flex; flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4, .display { font-family: 'Fredoka', 'Nunito', sans-serif; letter-spacing: .2px; margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: 2rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.15rem; }
p { line-height: 1.55; }
a { color: var(--primary); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--primary-2); outline-offset: 2px; border-radius: 8px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* Floating background blobs */
.bg-blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-blobs span { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .35; animation: float calc(18s / var(--anim, 1)) ease-in-out infinite; }
.bg-blobs span:nth-child(1) { width: 380px; height: 380px; background: var(--primary); top: -120px; right: -80px; }
.bg-blobs span:nth-child(2) { width: 320px; height: 320px; background: var(--primary-2); bottom: -100px; left: -80px; animation-delay: -6s; }
.bg-blobs span:nth-child(3) { width: 240px; height: 240px; background: #22d3ee; top: 40%; left: 45%; animation-delay: -12s; opacity: .18; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(30px, -40px) scale(1.1); } }

/* ───────── Top bar ───────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  padding: 10px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.brand-logo { font-size: 1.7rem; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--grad); box-shadow: var(--shadow-sm); }
.brand-text { font-family: 'Fredoka', sans-serif; font-size: 1.3rem; font-weight: 600; }
.brand-text b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topnav { display: flex; gap: 4px; margin-left: auto; }
.topnav a { text-decoration: none; color: var(--text); padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: .95rem; transition: background .2s; white-space: nowrap; }
.topnav a:hover { background: var(--primary-soft); }
.topnav a.active { background: var(--grad); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.player-chip { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 800; font-size: .9rem; white-space: nowrap; }
.player-chip .avatar { width: 34px; height: 34px; font-size: 1.2rem; }
.player-chip:empty { display: none; }

/* ───────── Bottom tab bar (mobile) ───────── */
.tabbar { display: none; }
@media (max-width: 900px) {
  .topnav { display: none; }
  .player-chip { margin-left: auto; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 800; padding: 4px 0; border-radius: 12px; }
  .tabbar a span { font-size: 1.35rem; transition: transform .2s; }
  .tabbar a.active { color: var(--primary); }
  /* The selected tab's icon sits in a raised purple circle; the others stay flat. Heights balance
     (30px vs 48px − 18px) so every label lines up. */
  .tabbar a span { width: 48px; height: 30px; display: grid; place-items: center; border-radius: 50%; border: 4px solid transparent; transition: background .2s, margin .2s, height .2s; }
  .tabbar a.active span { background: var(--grad); height: 48px; margin-top: -18px; box-shadow: var(--shadow); border-color: var(--surface); }
  body { padding-bottom: 76px; }
  .brand-text { font-size: 1.1rem; }
}

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: clamp(16px, 3vw, 32px) clamp(16px, 4vw, 40px) 40px; outline: none; }
.footer { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; align-items: center; padding: 18px 16px; font-size: .85rem; color: var(--muted); }
.footer a { color: var(--muted); text-decoration: none; font-weight: 700; }
.footer a:hover { color: var(--primary); }
@media (max-width: 900px) { .footer { padding-bottom: 8px; } }

.boot-loader { display: grid; place-items: center; gap: 12px; padding: 80px 0; color: var(--muted); font-weight: 700; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid var(--primary-soft); border-top-color: var(--primary); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view-enter { animation: viewIn calc(.35s * var(--anim)) ease-out; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ───────── Building blocks ───────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.card.pad-lg { padding: clamp(20px, 4vw, 32px); }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 999px; border: 0; cursor: pointer;
  font-weight: 800; font-size: 1rem; text-decoration: none; line-height: 1;
  background: var(--surface-3); color: var(--text);
  transition: transform .12s, box-shadow .2s, filter .2s;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--grad); color: var(--on-primary); box-shadow: 0 8px 20px -8px var(--primary); }
.btn.good { background: linear-gradient(135deg, #22c55e, #10b981); color: #fff; }
.btn.danger { background: linear-gradient(135deg, #f43f5e, #e11d48); color: #fff; }
.btn.ghost { background: transparent; border: 2px solid var(--border); }
.btn.sm { padding: 8px 14px; font-size: .88rem; }
.btn.lg { padding: 16px 28px; font-size: 1.1rem; }
.btn.block { width: 100%; }
.icon-btn { background: var(--surface-2); border: 1px solid var(--border); width: 38px; height: 38px; border-radius: 12px; cursor: pointer; display: inline-grid; place-items: center; font-size: 1rem; }
.icon-btn:hover { background: var(--primary-soft); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; background: var(--surface-3); color: var(--text); white-space: nowrap; }
.chip.easy { background: #dcfce7; color: #166534; }
.chip.medium { background: #fef3c7; color: #92400e; }
.chip.hard { background: #ffe4e6; color: #9f1239; }

.avatar { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--grad); font-size: 1.5rem; flex-shrink: 0; box-shadow: inset 0 0 0 3px rgba(255,255,255,.35); }
.avatar.xl { width: 96px; height: 96px; font-size: 3.2rem; }

.progress { height: 12px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--grad); transition: width .6s ease; }

.field { display: flex; flex-direction: column; gap: 6px; }
.row > .field { min-width: 140px; }
.field label, .label { font-weight: 800; font-size: .9rem; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 2px solid var(--border);
  background: var(--surface-2); outline: none; transition: border-color .2s;
}
.input:focus { border-color: var(--primary); }
textarea.input { resize: vertical; min-height: 90px; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .big { font-size: 3rem; display: block; margin-bottom: 8px; }

/* ───────── Hero ───────── */
.hero {
  position: relative; overflow: hidden; border-radius: 28px; padding: clamp(22px, 4vw, 40px);
  background: var(--grad); color: #fff; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: center;
}
.hero::after { content: ''; position: absolute; width: 320px; height: 320px; border-radius: 50%; background: rgba(255,255,255,.12); right: -80px; top: -120px; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); }
.hero p { opacity: .95; margin: 0 0 18px; }
.hero .btn { background: #fff; color: var(--primary); }
.hero .btn.ghost { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.4); }
.hero-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; position: relative; z-index: 1; }
.hero-stat { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); border-radius: 18px; padding: 14px; backdrop-filter: blur(6px); }
.hero-stat b { display: block; font-family: 'Fredoka'; font-size: 1.6rem; }
.hero-stat span { font-size: .82rem; font-weight: 700; opacity: .9; }
@media (max-width: 720px) { .hero { grid-template-columns: 1fr; } }

.level-card { display: flex; gap: 16px; align-items: center; }
.level-badge { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: linear-gradient(135deg, #fbbf24, #f97316); color: #fff; font-family: 'Fredoka'; font-size: 1.6rem; box-shadow: var(--shadow-sm); flex-shrink: 0; }
.level-badge small { display: block; font-size: .6rem; margin-top: -6px; letter-spacing: 1px; }

/* Daily challenge banner */
.daily {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  border-radius: var(--radius); padding: 18px 20px; color: #fff;
  background: linear-gradient(135deg, #f59e0b, #ef4444 60%, #db2777);
  box-shadow: var(--shadow);
}
.daily .emoji { font-size: 2.6rem; animation: bob calc(2s / var(--anim)) ease-in-out infinite; }
.daily .btn { background: #fff; color: #db2777; margin-left: auto; }
.daily.done { background: linear-gradient(135deg, #10b981, #0ea5e9); }
.daily.done .btn { color: #0ea5e9; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-6px) rotate(6deg); } }

/* ───────── Subject cards ───────── */
.subject-card {
  --c: var(--primary);
  position: relative; overflow: hidden; cursor: pointer; text-align: left;
  border: 0; border-radius: var(--radius); padding: 18px; color: #fff;
  background: linear-gradient(145deg, var(--c), color-mix(in srgb, var(--c) 55%, #1e1b4b));
  box-shadow: 0 12px 24px -14px var(--c);
  transition: transform .2s, box-shadow .2s;
  display: flex; flex-direction: column; gap: 10px; min-height: 150px; text-decoration: none;
}
.subject-card:hover { transform: translateY(-4px) rotate(-.4deg); box-shadow: 0 18px 30px -14px var(--c); }
.subject-card .s-icon { font-size: 2.2rem; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 16px; background: rgba(255,255,255,.2); }
.subject-card h3 { margin: 0; font-size: 1.15rem; }
.subject-card .meta { font-size: .82rem; font-weight: 700; opacity: .9; }
.subject-card .progress { background: rgba(255,255,255,.25); height: 8px; margin-top: auto; }
.subject-card .progress > span { background: #fff; }
.subject-card::after { content: ''; position: absolute; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.1); right: -30px; top: -30px; }
.subject-card.selected { outline: 4px solid var(--text); outline-offset: 3px; }
.subject-card.mini { min-height: 0; flex-direction: row; align-items: center; padding: 12px 14px; }
.subject-card.mini .s-icon { width: 42px; height: 42px; font-size: 1.5rem; }

/* ───────── Tabs / segmented ───────── */
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-3); flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 9px 16px; border-radius: 999px; font-weight: 800; cursor: pointer; color: var(--muted); }
.tabs button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ───────── Reviewer ───────── */
.material { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; transition: transform .15s; }
.material:hover { transform: translateY(-2px); }
.material .m-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.6rem; flex-shrink: 0; }
.m-video { background: #fee2e2; } .m-slides { background: #ffedd5; } .m-pdf { background: #e0e7ff; } .m-note { background: #dcfce7; } .m-link { background: #e0f2fe; }
.material h3 { margin: 0 0 4px; font-size: 1.05rem; }
.material .seen { margin-left: auto; font-size: 1.1rem; }

.viewer { border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 16 / 9; width: 100%; }
.viewer iframe, .viewer video { width: 100%; height: 100%; border: 0; display: block; }
.viewer.doc { aspect-ratio: 4 / 3; background: var(--surface-2); }
.note-body { line-height: 1.65; }
.note-body h1 { font-size: 1.5rem; } .note-body h2 { font-size: 1.2rem; margin-top: 1em; }
.note-body ul { padding-left: 1.3em; } .note-body li { margin: 4px 0; }

/* Flashcards */
.flash-wrap { perspective: 1400px; max-width: 680px; margin: 0 auto; }
.flashcard { position: relative; min-height: 320px; transform-style: preserve-3d; transition: transform calc(.6s * var(--anim)); cursor: pointer; }
.flashcard.flipped { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 24px; padding: 28px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 12px; box-shadow: var(--shadow); overflow: auto; }
.flash-front { background: var(--surface); border: 3px solid var(--primary-soft); }
.flash-back { background: var(--grad); color: #fff; transform: rotateY(180deg); }
.flash-face .q { font-size: 1.2rem; font-weight: 800; }
.flash-face img { max-height: 150px; border-radius: 12px; }
.flash-hint { font-size: .8rem; opacity: .7; font-weight: 700; }

/* ───────── Quiz setup ───────── */
.mode-card { cursor: pointer; border: 3px solid transparent; text-align: left; display: flex; flex-direction: column; gap: 6px; transition: transform .15s, border-color .15s; }
.mode-card:hover { transform: translateY(-2px); }
.mode-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.mode-card .m-emoji { font-size: 2rem; }
.mode-card h3 { margin: 0; }
.mode-card p { margin: 0; font-size: .88rem; color: var(--muted); }
.setup-bar { position: sticky; bottom: 12px; z-index: 5; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
@media (max-width: 900px) { .setup-bar { bottom: 86px; } }

/* ───────── Quiz play ───────── */
.play { max-width: 820px; margin: 0 auto; }
.hud { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.hud .pill { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font-weight: 900; box-shadow: var(--shadow-sm); }
.hud .pill.score b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 1.1rem; }
.hud .lives { letter-spacing: 2px; }
.combo { color: #f97316; animation: pulse calc(.8s / var(--anim)) ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.1); } }

.timer { height: 12px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-bottom: 16px; }
.timer > span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #22c55e, #84cc16); transition: width .25s linear, background .3s; }
.timer.warn > span { background: linear-gradient(90deg, #f59e0b, #f97316); }
.timer.danger > span { background: linear-gradient(90deg, #ef4444, #e11d48); }

.qcard { position: relative; }
.q-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.q-text { font-size: 1.3rem; font-weight: 800; line-height: 1.4; margin: 6px 0 14px; }
.q-image { display: block; margin: 0 auto 16px; max-height: 340px; border-radius: 14px; border: 1px solid var(--border); cursor: zoom-in; background: #fff; }
.choices { display: grid; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  padding: 14px 16px; border-radius: 16px; border: 2px solid var(--border); background: var(--surface-2);
  cursor: pointer; font-weight: 700; font-size: 1.02rem; transition: transform .12s, border-color .15s, background .15s;
}
.choice:hover:not(:disabled) { border-color: var(--primary); transform: translateX(4px); }
.choice .key { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-family: 'Fredoka'; background: var(--surface-3); flex-shrink: 0; transition: background .15s; }
.choice:nth-child(1) .key { background: #fecdd3; color: #9f1239; }
.choice:nth-child(2) .key { background: #bfdbfe; color: #1e3a8a; }
.choice:nth-child(3) .key { background: #fde68a; color: #78350f; }
.choice:nth-child(4) .key { background: #bbf7d0; color: #14532d; }
.choice:nth-child(5) .key { background: #ddd6fe; color: #4c1d95; }
.choice:nth-child(6) .key { background: #a5f3fc; color: #164e63; }
.choice:disabled { cursor: default; }
.choice.correct { border-color: var(--good); background: var(--good-soft); animation: pop calc(.4s * var(--anim)); }
.choice.correct .key { background: var(--good); color: #fff; }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); animation: shake calc(.4s * var(--anim)); }
.choice.wrong .key { background: var(--bad); color: #fff; }
.choice.eliminated { opacity: .3; text-decoration: line-through; }
@keyframes pop { 50% { transform: scale(1.03); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.lifelines { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.lifeline { border: 2px dashed var(--border); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-weight: 800; cursor: pointer; font-size: .9rem; }
.lifeline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.lifeline:disabled { opacity: .35; cursor: not-allowed; }

.feedback { margin-top: 16px; border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 6px; animation: viewIn calc(.3s * var(--anim)); }
.feedback.good { background: var(--good-soft); border: 2px solid var(--good); }
.feedback.bad { background: var(--bad-soft); border: 2px solid var(--bad); }
.feedback .title { font-family: 'Fredoka'; font-size: 1.2rem; }

.float-points { position: fixed; pointer-events: none; z-index: 70; font-family: 'Fredoka'; font-size: 1.6rem; font-weight: 700; color: var(--good); text-shadow: 0 2px 0 #fff; animation: floatUp 1s ease-out forwards; }
@keyframes floatUp { from { opacity: 1; transform: translateY(0) scale(.8); } to { opacity: 0; transform: translateY(-70px) scale(1.2); } }

/* ───────── Results ───────── */
.results { max-width: 760px; margin: 0 auto; text-align: center; }
.stars { font-size: 3rem; letter-spacing: 6px; margin: 4px 0; }
.stars .off { filter: grayscale(1); opacity: .3; }
.stars span { display: inline-block; animation: starIn calc(.5s * var(--anim)) backwards; }
.stars span:nth-child(2) { animation-delay: .15s; } .stars span:nth-child(3) { animation-delay: .3s; }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } }
.big-score { font-family: 'Fredoka'; font-size: clamp(3rem, 10vw, 4.6rem); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 20px 0; }
.stat { background: var(--surface-2); border-radius: 16px; padding: 14px; border: 1px solid var(--border); }
.stat b { display: block; font-family: 'Fredoka'; font-size: 1.5rem; }
.stat span { font-size: .8rem; color: var(--muted); font-weight: 800; }
.review-item { text-align: left; border-left: 5px solid var(--good); }
.review-item.wrong { border-left-color: var(--bad); }
.review-item img { max-height: 120px; border-radius: 10px; }

/* ───────── Leaderboard ───────── */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 12px; align-items: end; max-width: 620px; margin: 10px auto 24px; }
.podium .spot { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.podium .block { width: 100%; border-radius: 18px 18px 8px 8px; color: #fff; font-family: 'Fredoka'; font-size: 2rem; display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.podium .p1 .block { height: 130px; background: linear-gradient(180deg, #fbbf24, #f59e0b); }
.podium .p2 .block { height: 96px; background: linear-gradient(180deg, #cbd5e1, #94a3b8); }
.podium .p3 .block { height: 76px; background: linear-gradient(180deg, #fdba74, #f97316); }
.podium .name { font-weight: 900; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .pts { font-size: .85rem; font-weight: 800; color: var(--muted); }
.podium .p1 .avatar { width: 72px; height: 72px; font-size: 2.4rem; box-shadow: 0 0 0 4px var(--gold); }
.podium .crown { font-size: 1.8rem; margin-bottom: -10px; animation: bob calc(2s / var(--anim)) ease-in-out infinite; }
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.rank-row.me { background: var(--primary-soft); border-color: var(--primary); }
.rank-row .pos { width: 34px; text-align: center; font-family: 'Fredoka'; font-size: 1.15rem; color: var(--muted); }
.rank-row .who { flex: 1; min-width: 0; }
.rank-row .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .pts { font-family: 'Fredoka'; font-size: 1.15rem; }

/* ───────── Profile / badges ───────── */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.badge { text-align: center; padding: 16px 10px; border-radius: 18px; background: var(--surface); border: 2px solid var(--border); }
.badge .b-icon { font-size: 2.2rem; display: block; margin-bottom: 6px; }
.badge b { display: block; font-size: .92rem; }
.badge span { font-size: .75rem; color: var(--muted); }
.badge.locked .b-icon { filter: grayscale(1); opacity: .35; }
.badge.unlocked { border-color: var(--gold); background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 18%, var(--surface)), var(--surface)); }
.subject-stat { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; }
.subject-stat .progress { height: 10px; }
.avatar-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-picker button { width: 50px; height: 50px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface-2); font-size: 1.6rem; cursor: pointer; }
.avatar-picker button.selected { border-color: var(--primary); background: var(--primary-soft); transform: scale(1.08); }

/* ───────── Settings ───────── */
.setting { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting .s-label { flex: 1; }
.setting .s-label b { display: block; }
.setting .s-label span { font-size: .85rem; color: var(--muted); }
.switch { position: relative; width: 54px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border); cursor: pointer; transition: background .2s; }
.switch span::after { content: ''; position: absolute; width: 24px; height: 24px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform .2s; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--grad); }
.switch input:checked + span::after { transform: translateX(24px); }
.switch input:focus-visible + span { outline: 3px solid var(--primary-2); outline-offset: 2px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 2px var(--border); cursor: pointer; }
.swatch.selected { box-shadow: 0 0 0 3px var(--text); }
input[type=range] { accent-color: var(--primary); width: 160px; }
.setting select.input { width: auto; min-width: 140px; padding: 8px 12px; }
.setting .tabs { flex-wrap: nowrap; }
.setting .tabs button { padding: 8px 12px; }

/* ───────── Admin ───────── */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: .92rem; }
.admin-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.admin-table .thumb { width: 48px; height: 36px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.admin-table .qtext { max-width: 460px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.table-wrap { overflow-x: auto; }
@media (max-width: 720px) { .admin-table .hide-sm { display: none; } }
.choice-edit { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.choice-edit input[type=radio] { width: 22px; height: 22px; accent-color: var(--good); }
.img-drop { border: 2px dashed var(--border); border-radius: var(--radius-sm); padding: 16px; text-align: center; background: var(--surface-2); cursor: pointer; }
.img-drop.drag { border-color: var(--primary); background: var(--primary-soft); }
.img-drop img { max-height: 180px; border-radius: 10px; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; background: var(--surface-3); padding: 10px; border-radius: 10px; white-space: pre-wrap; word-break: break-word; }
.notice { border-radius: 14px; padding: 12px 14px; background: #fef3c7; color: #78350f; font-weight: 700; font-size: .9rem; }
:root[data-theme="dark"] .notice { background: #422006; color: #fde68a; }

/* ───────── Modal / toast / confetti ───────── */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(15, 10, 40, .55); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: fadeIn .2s; }
.modal { background: var(--surface); border-radius: 24px; width: 100%; max-width: 640px; max-height: calc(100vh - 32px); overflow: auto; padding: clamp(18px, 4vw, 28px); box-shadow: var(--shadow); animation: modalIn calc(.3s * var(--anim)) cubic-bezier(.2, 1.4, .4, 1); }
.modal.wide { max-width: 900px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal.image-zoom { max-width: 96vw; background: transparent; box-shadow: none; padding: 0; text-align: center; }
.modal.image-zoom img { max-height: 90vh; border-radius: 12px; background: #fff; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: scale(.9) translateY(20px); } }

#toastRoot { position: fixed; top: 76px; right: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--primary); border-radius: 14px; padding: 12px 16px; box-shadow: var(--shadow); font-weight: 700; max-width: 340px; animation: toastIn calc(.35s * var(--anim)) cubic-bezier(.2, 1.4, .4, 1); }
.toast.good { border-left-color: var(--good); } .toast.bad { border-left-color: var(--bad); } .toast.gold { border-left-color: var(--gold); }
.toast.out { animation: toastOut .3s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }
@media (max-width: 600px) { #toastRoot { left: 16px; right: 16px; top: 70px; } .toast { max-width: none; } }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }

/* Reduced motion */
:root[data-motion="reduced"] { --anim: 1000; }
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
@media (prefers-reduced-motion: reduce) { :root:not([data-motion="full"]) .bg-blobs span { animation: none; } }
@media (max-width: 600px) { .tabs button { padding: 8px 11px; font-size: .88rem; } }

/* ═══════════════ Mobile-first refinements ═══════════════ */
button, a, .choice, .lifeline, .subject-card, .flashcard { touch-action: manipulation; }
html { -webkit-text-size-adjust: 100%; }
.resume-card { margin-bottom: 18px; border: 2px solid var(--primary); background: var(--primary-soft); }

/* During a quiz: no tab bar or footer to tap by accident, all space for the question */
body.playing .tabbar, body.playing .footer { display: none; }
body.playing { padding-bottom: env(safe-area-inset-bottom); }

@media (max-width: 600px) {
  h1 { font-size: 1.6rem; }
  main { padding-top: 14px; }
  .card { padding: 16px; border-radius: 18px; }
  .card.pad-lg { padding: 18px; }
  .btn.lg { padding: 14px 20px; font-size: 1rem; }
  .hero { padding: 20px; border-radius: 22px; }
  .hero .row .btn { flex: 1; }
  .hero-stat { padding: 10px 12px; }
  .hero-stat b { font-size: 1.3rem; }
  .daily { padding: 14px 16px; }
  .daily .emoji { font-size: 2rem; }
  .daily .btn { width: 100%; margin-left: 0; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .subject-card { min-height: 128px; padding: 14px; gap: 6px; }
  .subject-card .s-icon { width: 44px; height: 44px; font-size: 1.6rem; }
  .subject-card h3 { font-size: 1rem; }
  .subject-card .meta { font-size: .74rem; }
  .subject-card.mini { padding: 10px; gap: 8px; }
  .subject-card.mini .s-icon { width: 36px; height: 36px; font-size: 1.2rem; }
  .subject-card.mini h3 { font-size: .88rem !important; }

  /* Quiz screen */
  .play { margin: 0 -4px; }
  .hud { gap: 6px; margin-bottom: 10px; }
  .hud .pill { padding: 6px 10px; font-size: .88rem; }
  .hud .lives { letter-spacing: 0; }
  .q-text { font-size: 1.12rem; margin: 4px 0 12px; }
  .q-image { max-height: 240px; width: 100%; object-fit: contain; }
  .choice { padding: 14px 12px; gap: 12px; font-size: 1rem; min-height: 58px; }
  .choice:hover:not(:disabled) { transform: none; }
  .lifelines { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
  .lifeline { padding: 10px 6px; text-align: center; }
  .feedback .row .btn { width: 100%; padding: 15px; }
  .play .small.muted.center { display: none; } /* keyboard hint is useless on phones */

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-grid .stat:last-child:nth-child(odd) { grid-column: span 2; }
  .stars { font-size: 2.4rem; }
  .results .row .btn { flex: 1 1 100%; }
  .podium { gap: 8px; }
  .podium .avatar { width: 40px; height: 40px; font-size: 1.3rem; }
  .podium .p1 .avatar { width: 56px; height: 56px; font-size: 1.9rem; }
  .podium .block { font-size: 1.5rem; }
  .podium .p1 .block { height: 100px; } .podium .p2 .block { height: 74px; } .podium .p3 .block { height: 58px; }
  .rank-row { padding: 8px 10px; gap: 8px; }
  .setting { flex-wrap: wrap; gap: 10px; }
  .setting .s-label { min-width: 60%; }
  .tabs { display: flex; width: 100%; }
  .tabs button { flex: 1; white-space: nowrap; }
  .flashcard { min-height: 300px; }
  .flash-face { padding: 20px; }
  .modal { border-radius: 20px; }
  .modal-foot .btn { flex: 1; }
  .section-head .input { width: 100% !important; }
}
@media (max-width: 380px) {
  .brand-logo { width: 38px; height: 38px; font-size: 1.4rem; }
  .brand-text { font-size: 1rem; }
}
@media (max-width: 600px) {
  .resume-card .resume-actions { width: 100%; }
  .resume-card .resume-actions .btn { flex: 1; }
  .setup-bar { padding: 10px 12px; bottom: 82px; flex-wrap: nowrap; }
  .setup-bar #poolInfo { font-size: .9rem; }
  .setup-bar #poolSub { display: none; }
  .setup-bar .btn.lg { padding: 12px 18px; flex-shrink: 0; }
}
@media (max-width: 600px) {
  #toastRoot { top: auto; bottom: calc(92px + env(safe-area-inset-bottom)); flex-direction: column-reverse; }
  body.playing #toastRoot { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .toast { padding: 10px 14px; font-size: .92rem; }
}

/* ═══════════════ Calm design: fewer competing colours, more white space ═══════════════ */
:root { --shadow-sm: 0 1px 3px rgba(30, 27, 75, .06), 0 4px 12px -6px rgba(30, 27, 75, .12); }
:root[data-theme="dark"] { --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4); }
.bg-blobs span { opacity: .14; }
.bg-blobs span:nth-child(3) { display: none; }
.card { box-shadow: var(--shadow-sm); }
h1 { margin-bottom: .6em; }
.section { margin-top: 32px; }
.footer { font-size: .8rem; opacity: .8; }
.topnav a { font-weight: 700; color: var(--muted); }
.topnav a:hover { color: var(--text); background: transparent; }
.topnav a.active { background: var(--primary-soft); color: var(--primary); box-shadow: none; }

/* Hero: greeting, level and two buttons */
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; }
.hero::after { opacity: .6; }
.hero-main { position: relative; z-index: 1; flex: 1 1 280px; }
.hero .eyebrow { margin: 0 0 4px; font-weight: 800; opacity: .9; }
.hero h1 { margin: 0 0 14px; }
.hero-level { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; font-size: .95rem; margin-bottom: 8px; }
.hero-level span { margin-left: auto; opacity: .85; font-size: .85rem; }
.progress.light { background: rgba(255,255,255,.25); height: 10px; }
.progress.light > span { background: #fff; }
.hero-actions { position: relative; z-index: 1; display: flex; gap: 10px; flex-wrap: wrap; }

/* One quiet row of numbers instead of many tiles */
.stat-strip { display: flex; margin: 18px 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.stat-strip > div { flex: 1; text-align: center; padding: 14px 6px; }
.stat-strip > div + div { border-left: 1px solid var(--border); }
.stat-strip b { display: block; font-family: 'Fredoka'; font-size: 1.35rem; line-height: 1.1; }
.stat-strip span { font-size: .78rem; color: var(--muted); font-weight: 700; }

/* Slim banners (Daily Challenge, next badge, level up) */
.slim-banner { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; font: inherit; color: var(--text); text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid #f59e0b; border-radius: 16px; padding: 12px 16px; margin-bottom: 10px; cursor: pointer; box-shadow: var(--shadow-sm); }
.slim-banner:disabled { cursor: default; }
.slim-banner.done { border-left-color: var(--good); }
.slim-banner .sb-icon { font-size: 1.6rem; }
.slim-banner .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.slim-banner .grow > span:not(.progress) { font-size: .85rem; color: var(--muted); }
.slim-banner .sb-go { font-weight: 800; color: var(--primary); white-space: nowrap; font-size: .9rem; }
.slim-banner.badge-teaser { border-left-color: var(--gold); }
.slim-banner.level-up { border-left-color: var(--primary); margin: 0 0 14px; cursor: default; }
.slim-banner:not(:disabled):hover { border-color: var(--primary); }
.progress.tiny { height: 6px; margin-top: 6px; display: block; }

/* Subject cards: white card, coloured icon tile, thin progress bar */
.subject-card, .subject-card:hover { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-sm); transform: none; }
.subject-card { min-height: 0; padding: 16px; gap: 8px; }
.subject-card:hover { border-color: var(--c); }
.subject-card::after { display: none; }
.subject-card .s-icon { width: 46px; height: 46px; font-size: 1.6rem; border-radius: 14px; background: color-mix(in srgb, var(--c) 14%, transparent); }
.subject-card .s-name { font-family: 'Fredoka'; font-weight: 600; font-size: 1.02rem; line-height: 1.2; }
.subject-card .s-meta { font-size: .8rem; color: var(--muted); font-weight: 700; }
.subject-card .progress { background: var(--surface-3); margin-top: auto; }
.subject-card .progress > span { background: var(--c); }
.subject-card.mini { flex-direction: row; align-items: center; padding: 10px 12px; }
.subject-card.mini .s-icon { width: 36px; height: 36px; font-size: 1.2rem; border-radius: 10px; flex-shrink: 0; }
.subject-card.mini .s-name { font-size: .92rem; }
.subject-card.mini.all { --c: var(--primary); }
.subject-card.selected { outline: none; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 8%, var(--surface)); padding: 9px 11px; }

/* Quiz setup */
h3.step { margin: 26px 0 10px; font-size: .8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.mode-card { display: flex; flex-direction: row; align-items: center; gap: 12px; padding: 14px; text-align: left; font: inherit; color: var(--text);
  background: var(--surface); border: 2px solid var(--border); border-radius: 16px; box-shadow: none; }
.mode-card:hover { transform: none; border-color: var(--primary); }
.mode-card .m-emoji { font-size: 1.6rem; }
.mode-card .grow { display: flex; flex-direction: column; gap: 2px; }
.mode-card .grow span { font-size: .84rem; color: var(--muted); }
.mode-card .m-tag { font-size: .7rem; font-weight: 800; color: var(--primary); background: var(--primary-soft); padding: 3px 8px; border-radius: 999px; }
.mode-card.selected { border-color: var(--primary); background: var(--primary-soft); }

/* Results */
.result-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.result-actions .btn.primary { min-width: 220px; }
.new-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 18px; }
.new-badges .badge { min-width: 120px; }

/* Badges */
h3.badge-group { margin: 22px 0 10px; font-size: .95rem; display: flex; gap: 8px; align-items: baseline; }
h3.badge-group span { color: var(--muted); font-size: .8rem; }
.badge-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.badge { font: inherit; color: var(--text); cursor: pointer; padding: 12px 8px; border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.badge .b-icon { font-size: 1.9rem; margin: 0; }
.badge b { font-size: .8rem; line-height: 1.2; }
.badge .progress { width: 80%; }
.badge.unlocked { border-color: color-mix(in srgb, var(--gold) 70%, transparent); }
.badge.locked b { color: var(--muted); }

@media (max-width: 600px) {
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1; }
  .stat-strip b { font-size: 1.15rem; }
  .grid.cols-3 { gap: 8px; }
  .badge-grid { grid-template-columns: repeat(3, 1fr); }
}
.banners { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 10px; }
.banners .slim-banner { margin: 0; }

/* ═══════════════ Learning path (Duolingo-style) ═══════════════ */
.learn { max-width: 560px; margin: 0 auto; }
.learn-top { position: sticky; top: 64px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: -6px -8px 12px; padding: 8px; background: var(--bg); border-radius: 0 0 16px 16px; }
.course-btn { display: flex; align-items: center; gap: 8px; border: 2px solid var(--border); border-bottom-width: 4px; background: var(--surface); color: var(--text);
  border-radius: 14px; padding: 6px 12px; font: inherit; font-weight: 800; cursor: pointer; min-width: 0; }
.course-btn b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.course-btn .cb-icon { font-size: 1.3rem; }
.course-btn .caret { color: var(--muted); }
.learn-stats { display: flex; align-items: center; gap: 6px; }
.learn-stats .ls { display: inline-flex; align-items: center; gap: 4px; font-weight: 900; padding: 4px 6px; border-radius: 12px; }
.goal-btn { border: 0; background: transparent; cursor: pointer; padding: 0 !important; color: var(--text); }
.ring { display: block; }

.learn-summary { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--surface); border: 2px solid var(--border); border-radius: 20px; padding: 14px 16px; margin-bottom: 22px; }
.learn-summary .ls-goal { display: flex; align-items: center; gap: 12px; flex: 1 1 220px; }
.learn-summary .ls-goal > div { display: flex; flex-direction: column; }
.learn-summary .btn-3d { width: auto; flex: 0 0 auto; padding: 12px 18px; }

/* Chunky "3D" buttons */
.btn-3d { --b: #22c55e; display: block; width: 100%; padding: 15px 18px; border: 0; border-radius: 16px; cursor: pointer; font: inherit; font-weight: 900;
  letter-spacing: .8px; text-transform: uppercase; color: #fff; text-align: center; text-decoration: none;
  background: var(--b); box-shadow: 0 5px 0 color-mix(in srgb, var(--b) 70%, #000); transition: transform .08s, box-shadow .08s; }
.btn-3d:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 color-mix(in srgb, var(--b) 70%, #000); }
.btn-3d:disabled { background: var(--surface-3); color: var(--muted); box-shadow: 0 5px 0 var(--border); cursor: default; }
.btn-3d.red { --b: #ef4444; }
.btn-3d.blue { --b: #0ea5e9; }
.btn-3d.ghost3d { --b: var(--surface); color: var(--primary); border: 2px solid var(--border); box-shadow: 0 4px 0 var(--border); }

/* Units and the winding path */
.unit { margin-bottom: 18px; }
.unit-head { display: flex; align-items: center; gap: 12px; background: var(--u); color: #fff; border-radius: 18px; padding: 14px 16px;
  box-shadow: 0 5px 0 color-mix(in srgb, var(--u) 65%, #000); position: sticky; top: 124px; z-index: 10; }
.unit-head.locked { background: color-mix(in srgb, var(--u) 45%, #94a3b8); box-shadow: 0 5px 0 #64748b; }
.unit-head small { font-weight: 900; letter-spacing: 1px; opacity: .9; font-size: .72rem; }
.unit-head h2 { margin: 2px 0; font-size: 1.2rem; }
.unit-head p { margin: 0; font-size: .85rem; opacity: .92; line-height: 1.35; }
.guide-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 2px solid rgba(255,255,255,.4); background: rgba(255,255,255,.15); color: #fff;
  border-radius: 14px; padding: 8px 10px; font: inherit; font-size: 1.1rem; cursor: pointer; flex-shrink: 0; }
.guide-btn span { font-size: .66rem; font-weight: 900; text-transform: uppercase; letter-spacing: .5px; }
.path { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 64px 0 38px; }
.node-wrap { position: relative; display: flex; flex-direction: column; align-items: center; transform: translateX(var(--x)); }
.node { position: relative; width: 74px; height: 68px; border-radius: 50%; border: 0; cursor: pointer; background: var(--u);
  box-shadow: 0 8px 0 color-mix(in srgb, var(--u) 62%, #000), inset 0 -4px 0 rgba(0,0,0,.08); transition: transform .08s, box-shadow .08s; }
.node:active { transform: translateY(6px); box-shadow: 0 2px 0 color-mix(in srgb, var(--u) 62%, #000); }
.node .node-icon { font-size: 2rem; line-height: 1; filter: drop-shadow(0 2px 0 rgba(0,0,0,.15)); }
.node.done { background: #fbbf24; box-shadow: 0 8px 0 #d97706, inset 0 -4px 0 rgba(0,0,0,.08); }
.node.locked { background: var(--surface-3); box-shadow: 0 8px 0 var(--border); }
.node.locked .node-icon { filter: grayscale(1); opacity: .55; font-size: 1.5rem; }
.node.exam { width: 86px; height: 78px; border-radius: 28px; }
.node.current { animation: nodePulse 1.8s ease-in-out infinite; }
@keyframes nodePulse { 0%, 100% { outline: 0 solid color-mix(in srgb, var(--u) 30%, transparent); outline-offset: 4px; } 50% { outline: 8px solid color-mix(in srgb, var(--u) 22%, transparent); outline-offset: 6px; } }
.node-due { position: absolute; top: -6px; right: -6px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .85rem;
  background: var(--surface); box-shadow: 0 2px 0 var(--border); border: 2px solid #0ea5e9; }
.node-stars { margin-top: 10px; color: #f59e0b; font-size: .9rem; letter-spacing: 2px; }
.node-stars span { color: var(--border); }
.start-bubble { position: absolute; bottom: calc(100% + 12px); white-space: nowrap; background: var(--surface); color: var(--u); font-weight: 900; letter-spacing: .5px;
  padding: 8px 14px; border-radius: 12px; border: 2px solid var(--border); animation: bob 1.6s ease-in-out infinite; z-index: 2; }
.start-bubble::after { content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); border: 8px solid transparent; border-top-color: var(--border); }
.side-mascot { position: absolute; top: -18px; pointer-events: none; }
.side-mascot.left { right: calc(100% + 36px); }
.side-mascot.right { left: calc(100% + 36px); }
.mascot { display: block; animation: bob 2.6s ease-in-out infinite; }
.mascot.mood-sad { animation: none; }
.path-end { display: flex; align-items: center; gap: 14px; padding: 10px 6px 30px; }
.path-end p { margin: 0; }

/* Bottom sheets */
.modal.sheet { max-width: 520px; }
@media (max-width: 600px) {
  .modal-backdrop:has(.sheet) { place-items: end stretch; padding: 0; }
  .modal.sheet { border-radius: 24px 24px 0 0; max-height: 88vh; padding-bottom: calc(22px + env(safe-area-inset-bottom)); animation: sheetUp .25s ease-out; }
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
.node-sheet h3 { font-size: 1.3rem; margin-bottom: 4px; }
.node-sheet .btn-3d { --b: var(--u); }
.node-sheet .btn-3d.ghost3d { --b: var(--surface); color: var(--text); }
.locked-note { background: var(--surface-3); border-radius: 12px; padding: 12px; font-weight: 700; }
.course-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 2px solid var(--border); border-bottom-width: 4px; border-radius: 16px;
  background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.course-row .s-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.5rem; background: color-mix(in srgb, var(--c) 15%, transparent); }
.course-row .grow { display: flex; flex-direction: column; }
.course-row .grow span { font-size: .82rem; color: var(--muted); }
.course-row.active { border-color: var(--c); }
.guide-lesson { margin-top: 18px; }
.guide-lesson h3 { color: var(--u); }
.guide-card { border-left: 4px solid var(--u); background: var(--surface-2); border-radius: 0 12px 12px 0; padding: 10px 14px; margin: 8px 0; }
.guide-card .note-body p { margin: 4px 0; }

/* Goal picker */
.goal-picker { display: flex; flex-direction: column; gap: 16px; }
.gp-head { display: flex; align-items: center; gap: 12px; }
.bubble { position: relative; background: var(--surface); border: 2px solid var(--border); border-radius: 16px; padding: 12px 14px; font-weight: 800; }
.goal-opt { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 2px solid var(--border); border-bottom-width: 4px; border-radius: 16px;
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.goal-opt b { flex: 1; }
.goal-opt > span:first-child { font-size: 1.4rem; }
.goal-opt.sel { border-color: #38bdf8; background: color-mix(in srgb, #38bdf8 12%, var(--surface)); }

/* Lesson screen */
body.lesson-mode .topbar { display: none; }
body.lesson-mode main { padding-top: 10px; padding-bottom: 0; }
.lesson { max-width: 640px; margin: 0 auto; min-height: calc(100dvh - 20px); display: flex; flex-direction: column; }
.lesson-bar { display: flex; align-items: center; gap: 12px; padding: 4px 0 16px; }
.icon-btn.plain { background: transparent; border: 0; font-size: 1.3rem; color: var(--muted); }
.lesson-progress { flex: 1; height: 16px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.lesson-progress span { display: block; height: 100%; border-radius: 999px; background: #22c55e; transition: width .4s ease;
  box-shadow: inset 0 4px 0 rgba(255,255,255,.3); min-width: 16px; }
.lesson-streak { min-width: 44px; text-align: right; font-weight: 900; color: #f97316; }
.stage { flex: 1; padding-bottom: 20px; }
.stage.enter { animation: viewIn .3s ease-out; }
.ex-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ex-head .mascot { animation: none; flex-shrink: 0; }
.ex-head .bubble { font-size: .95rem; }
.ex-prompt { font-size: 1.2rem; font-weight: 800; line-height: 1.45; margin: 0 0 18px; }
.opts { display: grid; gap: 10px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px 16px; min-height: 56px; font: inherit; font-weight: 700; color: var(--text);
  background: var(--surface); border: 2px solid var(--border); border-bottom-width: 4px; border-radius: 16px; cursor: pointer; transition: background .12s, border-color .12s; }
.opt .k { width: 28px; height: 28px; flex-shrink: 0; border: 2px solid var(--border); border-radius: 8px; display: grid; place-items: center; font-size: .8rem; color: var(--muted); }
.opt.sel { border-color: #38bdf8; background: color-mix(in srgb, #38bdf8 14%, var(--surface)); color: #0369a1; }
:root[data-theme="dark"] .opt.sel { color: #7dd3fc; }
.opt.sel .k { border-color: #38bdf8; color: #0284c7; }
.tf-statement { font-size: 1.15rem; font-weight: 800; line-height: 1.45; padding: 18px; border-radius: 18px; background: var(--surface); border: 2px solid var(--border); margin-bottom: 18px; }
.tf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tf-grid .opt { justify-content: center; font-size: 1.1rem; min-height: 72px; }
.blank-line { line-height: 2.3; }
.blank-slot { display: inline-block; min-width: 110px; min-height: 1.6em; line-height: 1.35; vertical-align: baseline; margin: 0 6px; padding: 3px 12px 5px; font: inherit; font-weight: 800;
  border: 0; border-bottom: 3px dashed var(--muted); background: transparent; color: var(--text); cursor: pointer; }
.blank-slot.filled { border: 2px solid #38bdf8; border-bottom-width: 4px; border-radius: 12px; background: color-mix(in srgb, #38bdf8 12%, var(--surface)); }
.word-bank { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 10px; }
.word { padding: 10px 16px; font: inherit; font-weight: 800; color: var(--text); background: var(--surface); border: 2px solid var(--border); border-bottom-width: 4px; border-radius: 14px; cursor: pointer; }
.word.used { visibility: hidden; }
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.tile { min-height: 58px; padding: 10px; font: inherit; font-weight: 700; font-size: .92rem; line-height: 1.25; color: var(--text); background: var(--surface);
  border: 2px solid var(--border); border-bottom-width: 4px; border-radius: 14px; cursor: pointer; transition: opacity .3s, background .15s; }
.tile.sel { border-color: #38bdf8; background: color-mix(in srgb, #38bdf8 14%, var(--surface)); }
.tile.ok { border-color: #22c55e; background: color-mix(in srgb, #22c55e 14%, var(--surface)); opacity: .45; }
.tile.bad { border-color: #ef4444; background: color-mix(in srgb, #ef4444 14%, var(--surface)); animation: shake .4s; }
.retry-pill, .new-pill { display: inline-block; font-size: .72rem; font-weight: 900; letter-spacing: .6px; padding: 5px 10px; border-radius: 999px; margin-bottom: 10px; }
.retry-pill { background: #fef3c7; color: #92400e; }
.new-pill { background: color-mix(in srgb, var(--u) 15%, transparent); color: var(--u); }
.learn-card { background: var(--surface); border: 2px solid var(--border); border-bottom-width: 5px; border-radius: 22px; padding: 20px; }
.learn-card .lc-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.learn-card h2 { font-size: 1.35rem; }
.learn-card .note-body { font-size: 1.04rem; }
.lesson-foot { position: sticky; bottom: 0; margin: 0 -16px; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 2px solid var(--border); }
.lesson-foot.static { position: static; border-top: 0; margin-top: auto; }
.lesson-foot.good { background: color-mix(in srgb, #22c55e 18%, var(--bg)); border-top-color: transparent; }
.lesson-foot.bad { background: color-mix(in srgb, #ef4444 15%, var(--bg)); border-top-color: transparent; }
.fb { margin-bottom: 12px; }
.fb-title { font-family: 'Fredoka'; font-size: 1.3rem; font-weight: 700; }
.lesson-foot.good .fb-title { color: #15803d; } .lesson-foot.bad .fb-title { color: #b91c1c; }
:root[data-theme="dark"] .lesson-foot.good .fb-title { color: #4ade80; } :root[data-theme="dark"] .lesson-foot.bad .fb-title { color: #f87171; }
.fb-streak { font-size: .9rem; color: #f97316; margin-left: 6px; }
.fb-answer { margin-top: 4px; }
.fb-why { margin-top: 6px; font-size: .92rem; color: var(--muted); }
@media (min-width: 700px) { .lesson-foot { display: flex; align-items: center; justify-content: flex-end; gap: 20px; border-radius: 0; } .lesson-foot .fb { flex: 1; margin: 0; } .lesson-foot .btn-3d { width: 200px; flex-shrink: 0; } }

/* Lesson complete */
.done-screen { text-align: center; }
.done-hero { display: flex; flex-direction: column; align-items: center; padding-top: 20px; }
.done-hero h1 { color: #f59e0b; margin: 10px 0 6px; font-size: 2rem; }
.done-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
.dt { border-radius: 16px; border: 2px solid var(--c); overflow: hidden; background: var(--surface); }
.dt span { display: block; background: var(--c); color: #fff; font-size: .7rem; font-weight: 900; letter-spacing: .6px; padding: 5px; }
.dt b { display: block; padding: 12px 4px; font-family: 'Fredoka'; font-size: 1.15rem; color: var(--c); }
.dt.xp { --c: #f59e0b; } .dt.acc { --c: #22c55e; } .dt.time { --c: #0ea5e9; }
.done-goal { display: flex; align-items: center; gap: 12px; justify-content: center; text-align: left; margin-bottom: 16px; }
.done-goal > div { display: flex; flex-direction: column; }
.resume-lesson { margin-bottom: 16px; }

@media (max-width: 600px) {
  .learn-top { top: 58px; }
  .unit-head { top: 112px; }
  .side-mascot .mascot { width: 58px; height: 64px; }
  .side-mascot.left { right: calc(100% + 18px); }
  .side-mascot.right { left: calc(100% + 18px); }
  .ex-prompt, .tf-statement { font-size: 1.08rem; }
  .learn-summary .btn-3d { width: 100%; }
  .tile { font-size: .85rem; }
}
@media (max-width: 380px) { .path { --scale: .8; } .node-wrap { transform: translateX(calc(var(--x) * .75)); } }

/* Lesson bridges, recaps and checkpoint feedback */
.bridge-card { display: flex; flex-direction: column; gap: 14px; }
.bridge-card .new-pill { align-self: flex-start; }
.bridge-row { display: flex; align-items: flex-end; gap: 12px; }
.bridge-row .mascot { flex-shrink: 0; }
.bubble.big { font-weight: 700; font-size: 1.05rem; line-height: 1.5; padding: 14px 16px; border-radius: 18px 18px 18px 4px; }
.bubble.big p { margin: 0; }
.bridge-card h2 { margin: 6px 0 0; }
.recap-list { list-style: none; padding: 0; margin: 6px 0 14px; display: grid; gap: 8px; }
.recap-list li { font-weight: 800; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.next-up { background: color-mix(in srgb, var(--u, var(--primary)) 12%, var(--surface)); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.review-list { display: flex; flex-direction: column; gap: 6px; text-align: left; background: var(--surface); border: 2px solid var(--border); border-radius: 14px; padding: 12px 14px; margin: 10px auto 0; max-width: 420px; }
.guide-intro { font-style: italic; color: var(--muted); margin: 0 0 6px; }
.guide-intro p { margin: 0; }
.note-body .book-note { font-size: .88rem; background: color-mix(in srgb, #0ea5e9 10%, var(--surface)); border-left: 4px solid #0ea5e9; border-radius: 0 10px 10px 0; padding: 8px 12px; margin-top: 10px; }

/* ───────── Accounts ───────── */
.google-btn { background: #fff; color: #1f1f1f; border: 2px solid #dadce0; display: inline-flex; align-items: center; gap: 10px; justify-content: center; }
.google-btn:hover { background: #f8f9fa; }
.or-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 6px 0; }
.or-line::before, .or-line::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.trial-banner { border-left-color: var(--primary); margin-bottom: 12px; }
.trial-banner .btn { flex-shrink: 0; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 10px; font-size: .85rem; flex-shrink: 0; }
.account-card { margin-bottom: 14px; flex-wrap: wrap; }
@media (max-width: 520px) { .trial-banner .grow > span { display: none; } .account-card .google-btn { width: 100%; } }

/* ───────── Report a problem ───────── */
.report-btn { background: none; border: 0; color: var(--muted); font: inherit; font-size: .8rem; cursor: pointer; padding: 4px 6px; border-radius: 8px; opacity: .75; }
.report-btn:hover, .report-btn:focus-visible { opacity: 1; background: var(--surface-2); color: var(--text); }
.lc-top .report-btn { margin-left: auto; align-self: flex-start; }
.fb .report-btn { display: block; margin-top: 6px; padding-left: 0; }
.report-snap { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 8px 0; white-space: pre-wrap; word-break: break-word; }
.report-reasons { display: grid; gap: 8px; }
.report-reason { display: flex; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.report-reason:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.report-card { margin-bottom: 12px; }
.report-list { padding-left: 18px; margin: 8px 0; display: grid; gap: 8px; }
.btn.xs { padding: 4px 10px; font-size: .78rem; border-radius: 9px; }

/* ───────── PvP ───────── */
.pvp-banner { border-left-color: #ef4444; margin-top: 10px; }
.pvp-hero h1 { margin: 4px 0; }
.pvp-vs { font-size: 2.4rem; font-weight: 900; color: var(--primary); }
.pvp-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 6px 0 12px; }
.pvp-join { justify-content: center; max-width: 320px; margin: 0 auto; flex-wrap: nowrap; }
.pvp-join .input { text-transform: uppercase; letter-spacing: .2em; text-align: center; }
.pvp-wait { display: grid; gap: 10px; justify-items: center; }
.pvp-code { font-size: 2.6rem; font-weight: 900; letter-spacing: .25em; padding: 10px 18px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); }
.pvp-countdown { display: grid; gap: 14px; justify-items: center; padding: 30px 0; }
.pvp-count { font-size: 5rem; font-weight: 900; color: var(--primary); animation: pop .9s ease; }
@keyframes pop { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.pvp-faces { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.pvp-faces > div:not(.pvp-vs) { display: grid; justify-items: center; gap: 6px; min-width: 120px; }
.pvp-hud { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; margin-bottom: 10px; }
.pvp-side { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pvp-side .avatar { width: 36px; height: 36px; font-size: 1.1rem; }
.pvp-side b { font-size: .9rem; }
.pvp-score { font-size: 1.1rem !important; color: var(--primary); min-width: 44px; text-align: center; }
.pvp-dots { display: flex; gap: 3px; margin-top: 3px; }
.pvp-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); }
.pvp-dot.ok { background: var(--good); border-color: var(--good); }
.pvp-dot.bad { background: var(--bad); border-color: var(--bad); }
@media (max-width: 420px) { .pvp-side .avatar { display: none; } .pvp-dot { width: 7px; height: 7px; } }
.pvp-faces { flex-wrap: nowrap; gap: 10px; }
.pvp-faces > div:not(.pvp-vs) { min-width: 0; flex: 1; }
.pvp-faces .avatar.xl { width: 76px; height: 76px; font-size: 2.3rem; }
.pvp-faces .big-score { font-size: 2.1rem; line-height: 1.1; }
.pvp-faces .pvp-vs { font-size: 1.6rem; }

/* ───────── Instant button feedback ───────── */
.btn-3d, .btn { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.btn-3d:active:not(:disabled), .btn:active:not(:disabled) { transform: translateY(2px); filter: brightness(.95); }
.is-busy { position: relative; pointer-events: none; color: transparent !important; }
.is-busy::after { content: ''; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.55); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn.ghost.is-busy::after, .btn:not(.primary).is-busy::after { border-color: rgba(0,0,0,.2); border-top-color: var(--primary); }

/* ═══════════════ Roomier phones ═══════════════ */
.topnav .ni { display: none; }
.learn-rail { display: none; }
@media (max-width: 600px) {
  main { padding: 20px 18px 48px; }
  h1 { margin-bottom: .75em; }
  .stack { gap: 14px; }
  .grid { gap: 14px; }
  .grid.cols-4, .grid.cols-3 { gap: 12px; }
  .card { padding: 18px; }
  .section { margin-top: 36px; }
  .section-head { margin-bottom: 16px; }
  .learn-top { margin-bottom: 18px; padding: 10px 8px; }
  .learn-summary { padding: 16px 18px; gap: 16px; margin-bottom: 28px; }
  .unit { margin-bottom: 32px; }
  .unit-head { padding: 16px 18px; }
  .path { gap: 26px; padding: 70px 0 42px; }
  .subject-card.mini { padding: 12px; gap: 10px; }
  .mode-card { padding: 16px; }
  .choices { gap: 12px; }
  .choice { padding: 15px 14px; }
  .rank-row { padding: 10px 12px; }
  .hud { gap: 8px; margin-bottom: 14px; }
  .learn-card { padding: 20px 18px; }
  .lesson-foot { padding: 16px 18px calc(18px + env(safe-area-inset-bottom)); margin: 0 -18px; }
  .modal { padding: 20px; }
  .setup-bar { margin-top: 16px; }
  .tabbar { padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); }
  body { padding-bottom: 82px; }
}

/* ═══════════════ Laptop & desktop: sidebar navigation + wider layouts ═══════════════ */
@media (min-width: 1024px) {
  body { padding-left: 250px; }
  body.lesson-mode { padding-left: 0; }
  .topbar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 250px; z-index: 40;
    flex-direction: column; align-items: stretch; gap: 6px;
    padding: 24px 16px 20px; border-bottom: 0; border-right: 1px solid var(--border);
    background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .brand { padding: 0 8px 20px; }
  .topnav { flex-direction: column; margin: 0; gap: 4px; }
  .topnav a { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; font-size: 1rem; color: var(--muted); border: 2px solid transparent; }
  .topnav a:hover { background: var(--surface-2); color: var(--text); }
  .topnav a.active { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 35%, transparent); box-shadow: none; }
  .topnav .ni { display: inline-grid; place-items: center; width: 28px; font-size: 1.35rem; }
  .player-chip { margin-top: auto; align-self: stretch; padding: 8px 12px 8px 8px; border-radius: 16px; }
  main { max-width: 1240px; padding: 36px 48px 56px; }
  .footer { padding: 18px 48px; }
  #toastRoot { left: auto; }

  .learn { max-width: 620px; }
  .learn-top { top: 0; margin-top: -12px; padding-top: 12px; }
  .unit-head { top: 72px; }
  /* Lessons: a wider, more readable column on big screens */
  .lesson { max-width: 780px; }
  .learn-card { padding: 28px 32px; }
  .learn-card .note-body { font-size: 1.1rem; }

  /* Quiz setup bar sits inside the content column */
  .setup-bar { bottom: 20px; }
}
@media (min-width: 1024px) and (max-height: 700px) {
  .topnav a { padding: 9px 14px; }
  .brand { padding-bottom: 12px; }
}

@media (min-width: 1200px) {
  /* Learn: path in the middle, progress rail on the right */
  .learn-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 56px; align-items: start; max-width: 1060px; margin: 0 auto; }
  .learn-layout .learn { max-width: 620px; width: 100%; margin: 0 auto; }
  .learn-layout .learn-top, .learn-layout .learn-summary { display: none; }
  .learn-layout .unit-head { top: 20px; }
  .learn-layout .unit { margin-bottom: 28px; }
  .learn-rail { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 36px; max-height: calc(100vh - 56px); overflow-y: auto; padding-bottom: 8px; }
  .rail-course { width: 100%; justify-content: flex-start; padding: 12px 14px; font-size: 1.02rem; }
  .rail-course .caret { margin-left: auto; }
  .rail-card { background: var(--surface); border: 2px solid var(--border); border-radius: 20px; padding: 18px; }
  .rail-card h3 { margin: 0 0 12px; font-size: 1.05rem; }
  .rail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; padding: 14px 10px; }
  .rail-stats div { display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .rail-stats span { font-size: 1.4rem; }
  .rail-stats b { font-family: 'Fredoka'; font-size: 1.3rem; }
  .rail-stats small { color: var(--muted); font-weight: 700; font-size: .75rem; }
  .rail-goal { display: flex; flex-direction: column; gap: 16px; }
  .rail-goal .ls-goal { display: flex; align-items: center; gap: 14px; }
  .rail-goal .ls-goal > div { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
  .link-btn { border: 0; background: none; padding: 0; color: var(--primary); font: inherit; font-weight: 800; font-size: .85rem; cursor: pointer; }
  .link-btn:hover { text-decoration: underline; }
  .rail-units { display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; }
  .rail-units h3 { padding: 0 6px; }
  .rail-unit { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; text-align: left; font: inherit; color: var(--text); padding: 8px 6px; border-radius: 12px; cursor: pointer; }
  .rail-unit:hover { background: var(--surface-2); }
  .rail-unit .ru-num { flex: 0 0 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--u); color: #fff; font-weight: 900; font-size: .85rem; }
  .rail-unit.locked .ru-num { background: var(--surface-3); color: var(--muted); }
  .rail-unit .ru-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
  .rail-unit .ru-body b { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rail-unit .ru-bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
  .rail-unit .ru-bar span { display: block; height: 100%; background: var(--u); border-radius: 999px; }
  .rail-unit small { color: var(--muted); font-weight: 800; font-size: .78rem; }
  .rail-links { display: flex; flex-direction: column; gap: 2px; padding: 10px; }
  .rail-links a { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 12px; text-decoration: none; color: var(--text); font-weight: 800; }
  .rail-links a:hover { background: var(--surface-2); }

}

/* Admin: question mix editor */
.mix-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; }
.mix-box h4 { margin: 0 0 10px; font-size: 1rem; }
.mix-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.mix-field { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; font-weight: 800; color: var(--muted); }
.mix-input { display: flex; align-items: center; gap: 6px; }
.mix-input .input { width: 100%; min-width: 0; text-align: center; font-weight: 800; }
.mix-input b { color: var(--text); }

/* Tabs that wrap onto two rows: rounded-rectangle tray so the active tab stays inside it */
.tabs.admin-tabs { display: grid; grid-template-columns: repeat(5, auto); border-radius: 18px; }
.tabs.admin-tabs button { border-radius: 14px; white-space: nowrap; text-align: center; }
@media (max-width: 760px) {
  .tabs.admin-tabs { grid-template-columns: repeat(6, minmax(0, 1fr)); width: 100%; gap: 4px; padding: 5px; }
  .tabs.admin-tabs button { grid-column: span 2; padding: 10px 6px; display: flex; align-items: center; justify-content: center; gap: 4px; }
  .tabs.admin-tabs button:nth-child(n+4) { grid-column: span 3; }
}
@media (max-width: 600px) {
  .tabs { border-radius: 18px; }
  .tabs button { border-radius: 14px; }
}

/* Admin question list filters */
.aq-filters { display: grid; grid-template-columns: minmax(200px, 1fr) auto auto auto; gap: 10px; align-items: center; margin-bottom: 14px; }
.aq-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 8px; }
.aq-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.aq-count { font-size: .82rem; font-weight: 800; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.src-chip { font-size: .7rem; }
@media (max-width: 760px) {
  .aq-filters { grid-template-columns: 1fr 1fr; }
  .aq-filters #aqSearch { grid-column: 1 / -1; }
  .aq-filters #aqAdd { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  /* Any tab tray on phones: equal-width cells that never spill outside the tray */
  .tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .tabs button { display: flex; align-items: center; justify-content: center; gap: 4px; text-align: center; white-space: nowrap; min-height: 40px; padding-left: 6px; padding-right: 6px; }
  .tabs:has(> button:nth-child(4)) { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabs.admin-tabs, .tabs.admin-tabs:has(> button:nth-child(4)) { grid-auto-flow: row; grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 600px) { .tabs.admin-tabs button { font-size: .84rem; padding: 9px 4px; } }

/* Learn: Practice + Flashcards buttons side by side */
.learn-summary .ls-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.learn-summary .ls-actions .btn-3d { text-align: center; text-decoration: none; white-space: nowrap; }
a.btn-3d { text-align: center; text-decoration: none; }
@media (max-width: 600px) { .learn-summary .ls-actions { width: 100%; } .learn-summary .ls-actions .btn-3d { flex: 1 1 0; width: auto; padding: 12px 10px; } }
.flash-pick { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 16px; }
.flash-pick select { max-width: 320px; }

/* Flashcards: Prev · Got it · Next, then New set */
.fc-actions { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 10px; margin-top: 16px; }
.fc-actions .btn { justify-content: center; }

/* Labs */
.lab-panel h2 { margin-top: 0; }
.lab-forms { margin-top: 14px; }
.lab-form { display: flex; flex-direction: column; gap: 10px; }
.lab-form h3 { margin: 0; }
.lab-code { font: 900 2.2rem/1 var(--font-head, inherit); letter-spacing: .3em; padding: 16px 10px 16px 22px; border-radius: 16px;
  background: var(--primary-soft); color: var(--primary); display: inline-block; margin-top: 6px; user-select: all; }
.lab-head { margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
a.lab-link { text-decoration: none; color: inherit; margin: 14px 0 18px; }
.pvp-scope { max-width: 420px; margin: 4px auto 10px; }
@media (max-width: 600px) { .lab-forms { grid-template-columns: 1fr; } }

/* Header never overflows: the brand can shrink, the player chip stays whole. On phones the chip
   stacks "Lv 5" over "1,406 XP" so it fits even with large system fonts. */
.topbar .brand { min-width: 0; flex-shrink: 1; }
.topbar .brand-text { white-space: nowrap; }
.player-chip { flex-shrink: 0; white-space: nowrap; }
@media (max-width: 600px) {
  .topbar { gap: 10px; }
  .player-chip { padding: 3px 12px 3px 3px; }
  .player-chip .pc-text { display: flex; flex-direction: column; line-height: 1.15; font-size: .8rem; }
  .player-chip .pc-lv { font-weight: 900; }
  .player-chip .pc-sep { display: none; }
  .player-chip .pc-xp { font-size: .72rem; color: var(--muted); font-weight: 700; }
}
@media (max-width: 360px) { .topbar .brand-text { font-size: .95rem; } }

/* Locked badges show only a silhouette of their icon — revealed in full color when earned. */
.badge.locked .b-icon { filter: brightness(0); opacity: .3; }
:root[data-theme="dark"] .badge.locked .b-icon { filter: brightness(0) invert(1); opacity: .22; }

/* Learn: the sticky course bar and unit banner stack under the real header height on every phone
   (measured in JS: --top-h, --lt-h), with a gap so they never touch. */
@media (max-width: 1023px) {
  .learn-top { top: var(--top-h, 64px); }
  .unit-head { top: calc(var(--top-h, 64px) + var(--lt-h, 56px) + 12px); }
}

/* Subject mastery (board readiness) */
.ready-info { width: 34px; height: 34px; font-size: 1.1rem; }
.ready-btn { width: 100%; background: none; border: 0; padding: 6px 4px; border-radius: 12px; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.ready-btn:hover { background: var(--surface-2); }
.ready-chip { font-size: .7rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.ready-chip.r1 { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.ready-chip.r2 { background: color-mix(in srgb, #f59e0b 20%, transparent); color: #d97706; }
.ready-chip.r3 { background: color-mix(in srgb, #0ea5e9 20%, transparent); color: #0284c7; }
.ready-chip.r4 { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
:root[data-theme="dark"] .ready-chip.r2 { color: #fbbf24; } :root[data-theme="dark"] .ready-chip.r3 { color: #38bdf8; }
.ready-list { padding-left: 20px; display: grid; gap: 8px; } .ready-list ul { margin: 6px 0 0; padding-left: 18px; }
.ready-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.ready-score { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ready-score b { font: 900 2.4rem/1 'Fredoka', sans-serif; }
.ready-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 2px; font-size: .9rem; }
.ready-row > span:first-child { width: 42%; } .ready-row .progress { margin: 0; } .ready-row b { min-width: 64px; text-align: right; }
.ready-note { margin: 0 0 6px; }

/* Lab links + 30-day notice */
.lab-link { display: inline-block; margin: 6px 0 12px; font-weight: 800; word-break: break-all; color: var(--primary); text-decoration: none; background: var(--primary-soft); padding: 8px 14px; border-radius: 12px; }
.lab-link-preview { margin: -4px 0 0; word-break: break-all; }
.lab-ttl { background: var(--surface-3); border-radius: 12px; padding: 10px 12px; margin: 4px 0 0; color: var(--text); }
.lab-head-link { word-break: break-all; margin-top: 2px; }
.lab-member { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.lab-member .av { font-size: 1.5rem; width: 36px; text-align: center; }
.lab-member .grow { min-width: 0; }
.lab-member .small { overflow-wrap: anywhere; }
.lab-invite-form .input { min-width: 0; flex: 1 1 220px; }
.btn.danger { color: var(--bad); }

/* Learndini brand in the app header */
.topbar .brand-mascot { height: 44px; width: auto; flex: none; transition: transform .3s; }
.topbar .brand:hover .brand-mascot { transform: rotate(-8deg); }
.brand-text { display: inline-flex; flex-direction: column; line-height: 1.05; }
.brand-text .brand-by { font: 800 .62rem/1 Nunito, sans-serif; color: var(--muted); letter-spacing: .04em; margin-top: 2px; }
@media (max-width: 600px) { .topbar .brand-mascot { height: 38px; } }
