/* ============================================================
   Design Tokens — Mobile-First Redesign
   Extracted from study-hub-redesign.html
   Loaded BEFORE styles.css so older rules can override
   temporarily during the per-screen migration.
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #f0f4fb;
  --bg2: #ffffff;
  --bg3: #e6ecf6;
  --surface: #ffffff;

  /* Navigation */
  --nav: #10233f;
  --nav2: #1a3560;

  /* Text */
  --text: #0d1f38;
  --text2: #4a5e7a;
  --muted: #8fa0bb;

  /* Brand / accents */
  --accent: #0ea5e9;
  --accent2: #0284c7;
  --orange: #f97316;
  --green: #10b981;
  --gold: #f59e0b;
  --purple: #8b5cf6;

  /* Borders / shadows */
  --border: rgba(15, 35, 63, 0.1);
  --shadow: 0 2px 12px rgba(15, 35, 63, 0.08);
  --shadow2: 0 6px 32px rgba(15, 35, 63, 0.14);

  /* Radii */
  --r: 14px;
  --r2: 20px;

  /* Fonts */
  --font-display: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-arcade: 'Bungee', 'Outfit', sans-serif;
  --font-numeric: 'Rajdhani', 'Outfit', sans-serif;
}

/* Dark mode — toggle via data-dark attribute on <html> */
[data-dark] {
  --bg: #070e1c;
  --bg2: #0c1728;
  --bg3: #101e30;
  --surface: #0c1728;
  --text: #e2ecff;
  --text2: #7a9dc4;
  --muted: #3d5577;
  --border: rgba(0, 165, 233, 0.12);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --shadow2: 0 6px 32px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   NAV (58px header)
   Shared across all screens. Replaces .app-header.
   ============================================================ */

.nav {
  background: linear-gradient(135deg, var(--nav), var(--nav2));
  height: 58px;
  padding: 0 20px;
  padding-top: env(safe-area-inset-top, 0);
  height: calc(58px + env(safe-area-inset-top, 0));
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 500; /* must sit above all game overlays (breakout-question: 100, pu-question-overlay: 200) */
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.25);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nav-logo {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #0ea5e9, #0369a1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.nav-text {
  min-width: 0;
}

.nav-title {
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-chip {
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  text-align: center;
  min-width: 48px;
}

.chip-val {
  font-family: var(--font-numeric);
  font-size: 16px;
  font-weight: 700;
  color: #38bdf8;
  line-height: 1;
}

.chip-lab {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toggle-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: 0.2s;
  color: #fff;
  padding: 0;
  position: relative;
}
/* Visual size kept at 32px via inner circle illusion; full 44px tap target */
.toggle-btn::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: inherit;
  border: inherit;
  pointer-events: none;
  opacity: 0;
}
.toggle-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ============================================================
   HOME SCREEN — subject picker
   ============================================================ */

.home-hero {
  padding: 44px 20px 28px;
  text-align: center;
}

.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(24px, 5vw, 38px);
  font-weight: 800;
  color: var(--text);
  background: linear-gradient(135deg, var(--text) 30%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
  line-height: 1.15;
}

.home-hero p {
  color: var(--text2);
  font-size: 15px;
  font-family: var(--font-display);
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 0 20px 48px;
  max-width: 900px;
  margin: 0 auto;
}

.subj-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 24px;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  font-family: var(--font-display);
}

.subj-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.22s ease;
}

.subj-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow2);
  border-color: rgba(14, 165, 233, 0.3);
}

.subj-card:hover::after {
  transform: scaleX(1);
}

.subj-icon {
  font-size: 28px;
  margin-bottom: 14px;
  display: block;
}

.subj-name {
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 8px;
  color: var(--text);
}

.subj-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 16px;
}

.subj-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.subj-count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

/* .enrich-btn: visual is compact, but tap target is ≥44px via ::before hitbox */
.enrich-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg3);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text2);
  transition: 0.15s;
  font-family: var(--font-display);
  position: relative;
  min-height: 28px;
}
.enrich-btn::before {
  content: '';
  position: absolute;
  inset: -10px -6px;
  /* Expand tap area to ≥44px tall without changing visual size */
}
.enrich-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.add-card {
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: var(--r2);
  padding: 24px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 170px;
  gap: 10px;
  transition: 0.22s;
  font-family: var(--font-display);
}

.add-card:hover {
  border-color: var(--accent);
  background: rgba(14, 165, 233, 0.04);
}

.add-circle {
  width: 48px;
  height: 48px;
  background: var(--bg3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--muted);
  transition: 0.2s;
}

.add-card:hover .add-circle {
  background: var(--accent);
  color: #fff;
}

.add-card-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.add-card-sub {
  font-size: 12px;
  color: var(--muted);
}

/* ============================================================
   RESPONSIVE — very narrow viewports
   ============================================================ */

@media (max-width: 380px) {
  .stat-chip:nth-child(2) {
    display: none;
  }
  .nav-logo {
    display: none;
  }
}

/* Body font baseline (applies globally once tokens.css is loaded) */
body {
  font-family: var(--font-display);
}

/* ============================================================
   DASHBOARD — Phase 3
   ============================================================ */

.dashboard {
  font-family: var(--font-display);
}

/* Dashboard topbar */
.dash-topbar {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 6px;
  background: none;
  border: none;
  padding: 8px 4px;            /* raises tap target to ≥36px */
  margin-left: -4px;           /* visually align with title */
  font-family: var(--font-display);
  min-height: 44px;            /* touch-target compliance */
}

.dash-title {
  font-weight: 800;
  font-size: 22px;
  color: var(--text);
}

.dash-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* Section divider pattern */
.sec-wrap {
  padding: 20px 20px 4px;
}

.sec-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.sec-title {
  font-weight: 800;
  font-size: 14px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sec-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Progress rings */
.prog-row {
  display: flex;
  gap: 10px;
  padding: 0 20px 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.prog-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 16px;
  min-width: 120px;
  flex: 1;
  box-shadow: var(--shadow);
  text-align: center;
}

.ring-wrap {
  position: relative;
  width: 60px;
  height: 60px;
  margin: 0 auto 10px;
}

.ring-svg {
  width: 60px;
  height: 60px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--bg3);
  stroke-width: 5;
}

.ring-fg {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 157;
  stroke-dashoffset: 157;
  transition: stroke-dashoffset 1.2s cubic-bezier(.4, 0, .2, 1);
}

.ring-val {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-numeric);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.prog-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 700;
}

/* Mobile: fit 3 rings side-by-side on 375px (iPhone SE) */
@media (max-width: 380px) {
  .prog-card {
    min-width: 0;
    padding: 14px 8px;
  }
}

/* Standard Study Methods */
.methods-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 20px 20px;
}

@media (min-width: 500px) {
  .methods-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.method-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 14px;
  cursor: pointer;
  transition: 0.2s;
  box-shadow: var(--shadow);
  text-align: center;
  font-family: var(--font-display);
}

.method-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow2);
  border-color: rgba(14, 165, 233, 0.3);
}

.method-icon {
  font-size: 24px;
  margin-bottom: 8px;
  display: block;
}

.method-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 3px;
}

.method-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

/* Weak Areas callout */
.weak-card {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fcd34d;
  border-radius: var(--r);
  padding: 16px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 320px;
  margin: 0 20px 20px;
  box-shadow: var(--shadow);
  transition: 0.2s;
  font-family: var(--font-display);
  text-align: left;
  width: calc(100% - 40px);
}

[data-dark] .weak-card {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(251, 191, 36, 0.05));
  border-color: rgba(245, 158, 11, 0.3);
}

.weak-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow2);
}

.weak-icon {
  font-size: 26px;
  flex-shrink: 0;
}

.weak-text {
  min-width: 0;
}

.weak-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.weak-desc {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}

/* ── Needs Work panel (progress-svc powered) ─────────────────── */
.weak-areas-list {
  padding: 0 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.weak-area-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

/* accuracy badge — red for ≤39%, orange for 40–59% */
.weak-area-badge {
  flex-shrink: 0;
  min-width: 44px;
  text-align: center;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 3px 7px;
  font-weight: 800;
  font-size: 12px;
  color: #dc2626;
  font-family: var(--font-numeric);
}

.weak-area-badge.moderate {
  background: #fff7ed;
  border-color: #fdba74;
  color: #ea580c;
}

[data-dark] .weak-area-badge {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(252, 165, 165, 0.25);
  color: #f87171;
}

[data-dark] .weak-area-badge.moderate {
  background: rgba(234, 88, 12, 0.12);
  border-color: rgba(253, 186, 116, 0.25);
  color: #fb923c;
}

.weak-area-q {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.weak-area-meta {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ============================================================
   ARCADE ZONE — always-dark neon treatment
   ============================================================ */

.arcade-zone {
  background: linear-gradient(180deg, var(--bg) 0, #06111f 50px);
  position: relative;
  overflow: hidden;
  margin-top: 8px;
}

.arcade-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(14, 165, 233, 0.06) 0, transparent 55%),
    radial-gradient(ellipse at 80% 70%, rgba(249, 115, 22, 0.04) 0, transparent 55%);
  pointer-events: none;
}

.arcade-zone::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(14, 165, 233, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14, 165, 233, 0.025) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
}

.arcade-header {
  padding: 28px 20px 18px;
  position: relative;
  z-index: 2;
}

/* Marquee — carnival-style sign with chasing light bulbs */
.marquee {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  background: linear-gradient(180deg, #dc2626 0%, #991b1b 100%);
  border-radius: 14px;
  padding: 12px 36px;
  border: 3px solid #fde68a;
  box-shadow:
    0 0 32px rgba(220, 38, 38, 0.45),
    inset 0 2px 0 rgba(255, 255, 255, 0.15),
    inset 0 -3px 0 rgba(0, 0, 0, 0.2);
}

.marquee-inner {
  background: linear-gradient(180deg, #991b1b 0%, #7f1d1d 100%);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
  border: 1px dashed rgba(253, 230, 138, 0.3);
}

.marquee-title {
  font-family: var(--font-arcade);
  font-size: clamp(18px, 4.5vw, 30px);
  color: #fde68a;
  letter-spacing: 2px;
  text-shadow:
    0 0 8px rgba(253, 230, 138, 0.5),
    2px 2px 0 #7f1d1d,
    -1px -1px 0 #fbbf24;
  line-height: 1;
  white-space: nowrap;
}

.marquee-sub {
  font-size: 11px;
  color: rgba(253, 230, 138, 0.75);
  margin-top: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
}

/* Chasing light bulbs around the marquee perimeter.
   Bulb elements are injected by app.js (placeArcadeBulbs); this
   stylesheet controls their appearance and animation. */
.bulbs {
  position: absolute;
  inset: -6px;
  pointer-events: none;
}

.bulb {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fde68a;
  box-shadow:
    0 0 6px #fbbf24,
    0 0 12px rgba(251, 191, 36, 0.6);
  animation: bulb-chase 1.5s infinite;
}

@keyframes bulb-chase {
  0%, 100% {
    background: #fde68a;
    box-shadow: 0 0 6px #fbbf24, 0 0 12px rgba(251, 191, 36, 0.6);
    opacity: 1;
  }
  50% {
    background: #78350f;
    box-shadow: none;
    opacity: 0.4;
  }
}

/* Respect OS reduce-motion preference */
@media (prefers-reduced-motion: reduce) {
  .bulb {
    animation: none;
    background: #fde68a;
  }
}

/* ============================================================
   FLASHCARDS — Phase 4
   Scoped under #flashcardsView so .filter-pill / .progress-bar-*
   class rules for the 8 other views that share those names stay
   untouched. IDs preserved from the old markup; JS unchanged.
   ============================================================ */

/* Topbar variant — back + title + icon in a horizontal row */
.dash-topbar.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
}

.dash-topbar.topbar-row .back-btn {
  margin-bottom: 0;
}

.topbar-title {
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
  font-family: var(--font-display);
}

.topbar-action {
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text2);
  cursor: pointer;
  transition: 0.15s;
  padding: 0;
}

.topbar-action:hover {
  background: var(--bg3);
  color: var(--accent);
  border-color: var(--accent);
}

/* Filter pills — scoped override of the global .filter-pill to match
   the mockup's .pill aesthetic for migrated views. The 6 non-migrated
   views that also use .filter-pill (concentration, reinforce, sorter,
   scenario, scramble, and the weak-areas filter inside reinforce)
   keep their existing .filter-pill look until they're migrated. */
#flashcardsView .filter-bar,
#matchingView .filter-bar,
#glossaryView .filter-bar,
#concentrationView .filter-bar {
  padding: 14px 20px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border: none;
  background: transparent;
  margin: 0;
}

#flashcardsView .filter-pill,
#matchingView .filter-pill,
#glossaryView .filter-pill,
#concentrationView .filter-pill {
  padding: 8px 14px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid var(--border);
  color: var(--text2);
  background: var(--surface);
  transition: 0.15s;
  font-family: var(--font-display);
  min-height: 36px;
  line-height: 1;
}

#flashcardsView .filter-pill.active,
#matchingView .filter-pill.active,
#glossaryView .filter-pill.active,
#concentrationView .filter-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.3);
}

#flashcardsView .filter-pill:hover:not(.active),
#matchingView .filter-pill:hover:not(.active),
#glossaryView .filter-pill:hover:not(.active),
#concentrationView .filter-pill:hover:not(.active) {
  border-color: var(--accent);
  color: var(--accent);
}

/* Exam-weight chip inside a category filter pill. Shown only when
   the course has domainWeights defined (safe-agilist.json has the
   official 6.0 blueprint; user-generated courses may or may not).
   Gracefully absent when weights aren't provided. */
.pill-weight {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: rgba(14, 165, 233, 0.12);
  color: var(--accent);
  vertical-align: baseline;
  line-height: 1.4;
}

.filter-pill.active .pill-weight {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Weight chip variant for the Jeopardy board column headers.
   Jeopardy headers are dark (game-show palette); the chip needs a
   light-on-dark treatment to stay legible. */
.jeopardy-header-weight {
  display: block;
  margin-top: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.4;
  width: max-content;
  margin-left: auto;
  margin-right: auto;
  text-transform: none;
}

/* Multi-select filter bar: "All" master-toggle pill gets a subtle
   visual distinction so it's clearly the shortcut control. Shared
   between Matching (by set), Flashcards (by domain), and Memory
   Match (by domain). */
#matchingView .filter-pill.pill-all,
#flashcardsView .filter-pill.pill-all,
#concentrationView .filter-pill.pill-all {
  background: linear-gradient(135deg, var(--bg3), var(--surface));
  border-color: var(--border);
  color: var(--text);
  font-weight: 800;
  padding-left: 16px;
  padding-right: 16px;
}

#matchingView .filter-pill.pill-all.active,
#flashcardsView .filter-pill.pill-all.active,
#concentrationView .filter-pill.pill-all.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border-color: var(--accent2);
}

/* Active multi-select pills get a checkmark badge */
#matchingView .filter-pill.active:not(.pill-all)::before,
#flashcardsView .filter-pill.active:not(.pill-all)::before,
#concentrationView .filter-pill.active:not(.pill-all)::before {
  content: '\2713\00a0';
  font-weight: 700;
}

/* Memory Match layout — labeled filter sections + empty/warning
   placeholder when the pool is too small for the current grid size. */
#concentrationView .conc-filter-section {
  padding: 8px 0 0;
}

#concentrationView .conc-filter-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 0 20px;
  margin-bottom: 2px;
}

.concentration-empty {
  /* Grid parent has grid-template-columns set from the size class; span
     the full width so the message isn't confined to one column cell. */
  grid-column: 1 / -1;
  padding: 40px 24px;
  text-align: center;
  color: var(--text2);
  font-size: 14px;
  font-family: var(--font-display);
  line-height: 1.6;
  border: 1px dashed var(--border);
  border-radius: var(--r);
  margin: 0 20px;
  background: var(--surface);
  max-width: 520px;
  justify-self: center;
  box-sizing: border-box;
}

.concentration-empty strong {
  color: var(--accent);
  font-weight: 800;
}

/* Pool-info chip turns amber-ish when pool < needed to hint the user
   they won't be able to start the game without adjusting. */
#concentrationPoolInfo.pool-short {
  color: var(--gold);
  font-weight: 700;
}

/* Desktop-only size pills (6x8, 8x8) are hidden on narrow viewports
   where the resulting 48-64 cards would collapse below tap-target
   minimums or truncate text to unreadability. Mobile users see the
   three smaller sizes (4x4, 4x6, 6x6) only. */
@media (max-width: 500px) {
  #concentrationDifficulty .filter-pill.size-pill-desktop {
    display: none;
  }
}

/* ============================================================
   Surprise Me! button + shape-mode grid — Phase 4
   ============================================================ */

.conc-surprise-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px 0;
  flex-wrap: wrap;
}

.conc-surprise-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  border: 2px solid transparent;
  background: linear-gradient(135deg, #f97316, #dc2626);
  color: #fff;
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  min-height: 36px;
}

.conc-surprise-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(249, 115, 22, 0.5);
}

.conc-surprise-btn.active {
  background: linear-gradient(135deg, #fbbf24, #f97316);
  box-shadow: 0 4px 14px rgba(251, 191, 36, 0.45),
              inset 0 2px 0 rgba(255, 255, 255, 0.2);
}

.conc-surprise-spark {
  animation: conc-sparkle 1.6s ease-in-out infinite;
  display: inline-block;
  font-size: 13px;
}
.conc-surprise-spark:last-child {
  animation-delay: 0.8s;
}
@keyframes conc-sparkle {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.25); opacity: 0.85; }
}

.conc-shape-label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.3px;
}

/* Shape-mode grid: bounding cols/rows come from inline CSS vars set
   by loadConcentrationGame. Square aspect-ratio keeps cards from
   stretching on wide viewports. */
.concentration-grid.shape-mode {
  display: grid;
  grid-template-columns: repeat(var(--shape-cols, 4), 1fr);
  grid-template-rows: repeat(var(--shape-rows, 4), 1fr);
  aspect-ratio: var(--shape-cols, 4) / var(--shape-rows, 4);
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  gap: 0.6rem;
}

@media (min-width: 720px) {
  .concentration-grid.shape-mode {
    max-width: 720px;
  }
}

/* Centerpiece emoji (grid-placed spanning 1+ cells via inline style) */
.concentration-center {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(28px, 6vw, 56px);
  pointer-events: none;
  animation: conc-bob 2.8s ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(14, 165, 233, 0.3));
}

@keyframes conc-bob {
  0%, 100% { transform: translateY(0) rotate(0); }
  50%      { transform: translateY(-6px) rotate(4deg); }
}

@media (prefers-reduced-motion: reduce) {
  .conc-surprise-spark,
  .concentration-center {
    animation: none;
  }
}

/* ============================================================
   Sound control (mute toggle + volume slider) in the nav
   ============================================================ */

.sound-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.sound-toggle {
  /* Inherits .toggle-btn; just ensures the emoji is centered at the
     right size. Different base icon sets may render the speaker emoji
     slightly off, so tweak alignment here if it drifts. */
  font-size: 15px;
}

.sound-toggle.muted {
  opacity: 0.55;
}

.sound-slider {
  width: 70px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  cursor: pointer;
  outline: none;
  accent-color: #38bdf8;
}

.sound-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #38bdf8;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.sound-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #38bdf8;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.sound-slider.muted {
  opacity: 0.35;
}

/* Hide the slider on very narrow viewports; users can still toggle
   mute, and volume persists across sessions anyway. */
@media (max-width: 500px) {
  .sound-slider {
    display: none;
  }
}

/* ============================================================
   Inner Matching board — scoped under #matchingView so the four
   other games that share .game-stats-bar / .matching-* classes
   keep their pre-redesign look until they're migrated.
   ============================================================ */

/* Stats bar — compact card with new token system */
#matchingView .game-stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 0 20px 20px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  font-family: var(--font-display);
}

#matchingView .game-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

#matchingView .game-stat svg {
  color: var(--muted);
  flex-shrink: 0;
}

#matchingView .game-stat-label {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Numerical values in the stats bar use Rajdhani for that scoreboard feel */
#matchingView .game-stat span:not(.game-stat-label) {
  font-family: var(--font-numeric);
  font-size: 15px;
  font-weight: 700;
}

#matchingView #matchingPairCount {
  color: var(--accent);
}

/* Board — two-column grid with generous rhythm */
#matchingView .matching-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 20px 32px;
  max-width: 960px;
  margin: 0 auto;
}

#matchingView .matching-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Item tiles — quiet, card-like, with clear affordance on hover */
#matchingView .matching-item {
  padding: 14px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s cubic-bezier(.4, 0, .2, 1),
              box-shadow 0.15s ease,
              border-color 0.15s ease,
              background 0.15s ease;
  text-align: left;
  box-shadow: var(--shadow);
  /* Tiles can be multi-line; make sure they share a common baseline
     within each column for visual rhythm. */
  min-height: 56px;
  display: flex;
  align-items: center;
}

#matchingView .matching-item:hover {
  border-color: rgba(14, 165, 233, 0.5);
  box-shadow: var(--shadow2);
  transform: translateY(-2px);
}

/* Selected — the one the user has picked but not yet paired with
   a partner. Clear accent fill so both selected items are obvious. */
#matchingView .matching-item.selected {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: var(--accent2);
  color: #fff;
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.3),
              0 0 0 3px rgba(14, 165, 233, 0.15);
  transform: translateY(-1px);
}

/* Matched — keep it present but quieter, so the user's attention
   moves on to un-matched items. */
#matchingView .matching-item.matched {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--text2);
  opacity: 0.75;
  cursor: default;
  pointer-events: none;
  box-shadow: none;
  transform: none;
}

[data-dark] #matchingView .matching-item.matched {
  background: rgba(16, 185, 129, 0.08);
  color: rgba(226, 236, 255, 0.55);
}

/* Matched items get a small ✓ prefix to reinforce the "done" state */
#matchingView .matching-item.matched::before {
  content: '\2713';
  color: var(--green);
  font-weight: 900;
  margin-right: 8px;
  flex-shrink: 0;
}

/* Wrong — red shake. The shake animation is intentionally preserved
   from the old design; it's a well-established UX pattern. */
#matchingView .matching-item.wrong {
  background: rgba(239, 68, 68, 0.08);
  border-color: #ef4444;
  color: #ef4444;
  animation: matching-shake 0.4s ease;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

@keyframes matching-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  50%      { transform: translateX(6px); }
  75%      { transform: translateX(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  #matchingView .matching-item.wrong {
    animation: none;
  }
  #matchingView .matching-item {
    transition: none;
  }
}

/* Narrow viewports — keep 2 columns but tighten spacing so tiles
   don't wrap awkwardly. Term+definition pairs can be long, and
   long text already expands vertically. */
@media (max-width: 500px) {
  #matchingView .matching-board {
    gap: 8px;
    padding: 0 12px 24px;
  }
  #matchingView .matching-column {
    gap: 6px;
  }
  #matchingView .matching-item {
    padding: 11px 12px;
    font-size: 12px;
    min-height: 52px;
  }
  #matchingView .game-stats-bar {
    gap: 14px;
    padding: 10px 14px;
    margin: 0 12px 16px;
  }
}

/* ============================================================
   Inner Glossary — scoped under #glossaryView. All .search-* and
   .glossary-* classes are Glossary-exclusive (not used by any
   other view), so in theory these could be global — kept scoped
   for consistency with the Matching/Flashcards/Memory Match
   redesign pattern and to make future rollback surgical.
   ============================================================ */

/* Search bar — accent focus ring, matches Add-Subject form inputs */
#glossaryView .search-bar {
  position: relative;
  margin: 0 20px 14px;
}

#glossaryView .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

#glossaryView .search-input {
  width: 100%;
  padding: 12px 14px 12px 44px;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  box-shadow: var(--shadow);
}

#glossaryView .search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12), var(--shadow);
}

#glossaryView .search-input::placeholder {
  color: var(--muted);
}

/* Term list */
#glossaryView .glossary-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 20px 32px;
  max-width: 760px;
  margin: 0 auto;
}

/* Each term card — follows the .subj-card / .method-card language
   with the accent top-border hover sweep already used on Home */
#glossaryView .glossary-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform 0.18s cubic-bezier(.4, 0, .2, 1),
              box-shadow 0.18s ease,
              border-color 0.18s ease;
  font-family: var(--font-display);
}

#glossaryView .glossary-item::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.22s ease;
}

#glossaryView .glossary-item:hover,
#glossaryView .glossary-item:focus-within {
  transform: translateY(-2px);
  box-shadow: var(--shadow2);
  border-color: rgba(14, 165, 233, 0.3);
}

#glossaryView .glossary-item:hover::after,
#glossaryView .glossary-item:focus-within::after {
  transform: scaleX(1);
}

/* Term header row: name + category badge */
#glossaryView .glossary-term {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

#glossaryView .glossary-term-text {
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
}

/* Category badge matches the .pill-weight visual language so
   weight chips + category badges feel related when both appear
   in the app. */
#glossaryView .glossary-category-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.12);
  color: var(--accent);
  letter-spacing: 0.3px;
  line-height: 1.4;
  flex-shrink: 0;
  white-space: nowrap;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
}

#glossaryView .glossary-category-badge:empty {
  display: none;
}

/* Definition body */
#glossaryView .glossary-definition {
  font-size: 13.5px;
  color: var(--text2);
  line-height: 1.65;
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Search match highlight — pick up from accent rather than a
   raw yellow so it stays on-theme in both light and dark mode */
#glossaryView mark {
  background: rgba(14, 165, 233, 0.18);
  color: inherit;
  padding: 0 3px;
  border-radius: 3px;
  font-weight: 700;
}

[data-dark] #glossaryView mark {
  background: rgba(56, 189, 248, 0.25);
}

@media (max-width: 500px) {
  #glossaryView .search-bar {
    margin: 0 12px 10px;
  }
  #glossaryView .search-input {
    padding-left: 40px;
    font-size: 13px;
  }
  #glossaryView .search-icon {
    left: 14px;
    width: 16px;
    height: 16px;
  }
  #glossaryView .glossary-list {
    padding: 4px 12px 24px;
    gap: 8px;
  }
  #glossaryView .glossary-item {
    padding: 13px 14px;
  }
  #glossaryView .glossary-term-text {
    font-size: 15px;
  }
  #glossaryView .glossary-definition {
    font-size: 13px;
    line-height: 1.6;
  }
  #glossaryView .glossary-category-badge {
    max-width: 50%;
    font-size: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #glossaryView .glossary-item,
  #glossaryView .glossary-item::after {
    transition: none;
  }
}

/* ============================================================
   Practice Exam inner screens — scoped under #examView so the
   Reinforce Quiz view (which shares many classes:
   .exam-question-text, .exam-options-list, .exam-option-btn,
   .exam-option-letter, .exam-option-text, .results-score*,
   .results-domains, .results-actions, .domain-bar*) keeps its
   pre-redesign look until its own migration.

   Covers three sub-views: #examConfig, #examActive, #examResults.
   Single append; no css/styles.css edits, no index.html edits,
   no js/app.js edits required.
   ============================================================ */

/* -------------------------------------------------------
   #examConfig — Pre-exam configuration
   ------------------------------------------------------- */

#examView .exam-config {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  font-family: var(--font-display);
}

#examView .exam-config h3 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  margin: 8px 0 22px;
  letter-spacing: -0.01em;
}

#examView .exam-mode-section,
#examView .exam-length-section {
  margin-bottom: 22px;
}

#examView .exam-mode-section h4,
#examView .exam-length-section h4 {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 0 0 10px;
  padding-left: 2px;
}

/* Mode: 2 side-by-side cards */
#examView .exam-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Length: 2-column grid (5 options wrap to 3 rows on desktop,
   1 column on mobile) */
#examView .exam-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* Visually-hidden but accessible radio */
#examView .exam-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

#examView .exam-option {
  display: block;
  cursor: pointer;
  position: relative;
  margin: 0;
}

#examView .exam-option-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  transition: transform 0.15s cubic-bezier(.4, 0, .2, 1),
              border-color 0.15s ease,
              box-shadow 0.15s ease,
              background 0.15s ease;
  min-height: 64px;
  color: var(--text);
}

#examView .exam-option-card:hover {
  border-color: rgba(14, 165, 233, 0.5);
  transform: translateY(-2px);
  box-shadow: var(--shadow2);
}

/* Selected (native :checked on the hidden radio propagates via
   adjacent-sibling selector) */
#examView .exam-option input[type="radio"]:checked + .exam-option-card {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: var(--accent2);
  color: #fff;
  box-shadow: 0 4px 18px rgba(14, 165, 233, 0.35);
  transform: translateY(-1px);
}

#examView .exam-option input[type="radio"]:focus-visible + .exam-option-card {
  outline: 3px solid rgba(14, 165, 233, 0.35);
  outline-offset: 2px;
}

#examView .exam-option-card strong {
  font-size: 14px;
  font-weight: 800;
  color: inherit;
  line-height: 1.2;
}

#examView .exam-option-card span {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.4;
}

#examView .exam-option input[type="radio"]:checked + .exam-option-card span {
  color: rgba(255, 255, 255, 0.88);
}

/* Start button — full-width accent gradient (matches
   #addSubjectView .generate-btn aesthetic) */
#examView #examStart {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(14, 165, 233, 0.3);
  min-height: 50px;
  margin-top: 18px;
}

#examView #examStart:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(14, 165, 233, 0.4);
}

/* -------------------------------------------------------
   #examActive — Live exam
   ------------------------------------------------------- */

#examView .exam-active {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px 20px 48px;
  font-family: var(--font-display);
}

/* Toolbar: timer + progress label + flag, card-styled row */
#examView .exam-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

#examView .exam-timer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-numeric);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

#examView .exam-timer svg {
  color: var(--muted);
}

/* Timer urgency states — stubbed for future JS use.
   Safe to pre-define; currently no JS path adds these classes. */
#examView .exam-timer.warning {
  color: var(--gold);
}
#examView .exam-timer.warning svg {
  color: var(--gold);
}
#examView .exam-timer.danger {
  color: #ef4444;
  animation: exam-timer-pulse 0.8s ease-in-out infinite;
}
#examView .exam-timer.danger svg {
  color: #ef4444;
}
@keyframes exam-timer-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

#examView .exam-progress-info {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Flag button (scoped ghost-pill with active state for flagged) */
#examView #examFlag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 36px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  cursor: pointer;
  transition: 0.15s;
}

#examView #examFlag:hover {
  border-color: var(--gold);
  color: var(--gold);
}

#examView #examFlag.active {
  background: rgba(245, 158, 11, 0.12);
  border-color: var(--gold);
  color: var(--gold);
}

/* Progress bar — scoped thin track + gradient fill */
#examView .progress-bar {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 16px;
  padding: 0;
  display: block;
  box-shadow: none;
  border: none;
}

#examView .progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0%;
  display: block;
}

/* Nav grid — responsive square buttons, Rajdhani numerals */
#examView .exam-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 6px;
  margin-bottom: 18px;
}

#examView .exam-nav-btn {
  /* position:relative so .flagged::after anchors correctly
     (the old styles.css rule didn't set this) */
  position: relative;
  min-height: 36px;
  padding: 0;
  font-family: var(--font-numeric);
  font-size: 13px;
  font-weight: 700;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text2);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, background 0.15s, color 0.15s;
}

#examView .exam-nav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#examView .exam-nav-btn.current {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border-color: var(--accent2);
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.35);
  transform: translateY(-1px);
}

#examView .exam-nav-btn.answered {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--green);
}

/* Current state wins when both answered + current */
#examView .exam-nav-btn.answered.current {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border-color: var(--accent2);
}

/* Flagged dot indicator — top-right corner */
#examView .exam-nav-btn.flagged::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 1.5px var(--surface);
}

/* Survey-mode review states */
#examView .exam-nav-btn.nav-correct {
  background: rgba(16, 185, 129, 0.22);
  border-color: var(--green);
  color: var(--green);
}

#examView .exam-nav-btn.nav-incorrect {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #ef4444;
}

/* Question card */
#examView .exam-question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 24px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

#examView .exam-question-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  margin: 0 0 20px;
}

/* Option buttons with letter pill */
#examView .exam-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#examView .exam-option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 14px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
  width: 100%;
}

#examView .exam-option-btn:hover {
  border-color: rgba(14, 165, 233, 0.5);
  transform: translateY(-1px);
  box-shadow: var(--shadow2);
}

#examView .exam-option-letter {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  color: var(--text2);
  border-radius: 50%;
  font-family: var(--font-numeric);
  font-size: 14px;
  font-weight: 800;
  transition: 0.15s;
}

#examView .exam-option-text {
  flex: 1;
  line-height: 1.45;
}

#examView .exam-option-btn.selected {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.08), rgba(14, 165, 233, 0.18));
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

#examView .exam-option-btn.selected .exam-option-letter {
  background: var(--accent);
  color: #fff;
}

#examView .exam-option-btn.correct {
  background: rgba(16, 185, 129, 0.10);
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

#examView .exam-option-btn.correct .exam-option-letter {
  background: var(--green);
  color: #fff;
}

#examView .exam-option-btn.incorrect {
  background: rgba(239, 68, 68, 0.08);
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

#examView .exam-option-btn.incorrect .exam-option-letter {
  background: #ef4444;
  color: #fff;
}

#examView .exam-option-btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* Controls row */
#examView .exam-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

#examView .exam-controls .btn {
  padding: 11px 20px;
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  min-height: 44px;
  background: transparent;
}

#examView .exam-controls .btn-primary {
  border-color: var(--accent2);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.3);
}

#examView .exam-controls .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.45);
}

#examView .exam-controls .btn-secondary {
  border-color: var(--border);
  color: var(--text2);
  background: var(--bg3);
}

#examView .exam-controls .btn-secondary:hover {
  border-color: var(--text2);
  color: var(--text);
}

#examView .exam-controls .btn-finish {
  background: linear-gradient(135deg, var(--green), #059669);
  border-color: #059669;
  color: #fff;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

#examView .exam-controls .btn-finish:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.45);
}

/* Survey feedback panel (Exam-exclusive). The left-border color is
   set via JS inline style (border-left-color: green|red) per question;
   the width/style are kept in CSS so the inline only tints color. */
#examView .survey-feedback {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--r);
  padding: 16px 18px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}

#examView .survey-feedback-header {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 10px;
}

#examView .survey-feedback-header.correct {
  color: var(--green);
}

#examView .survey-feedback-header.incorrect {
  color: #ef4444;
}

#examView .survey-feedback-section {
  margin-bottom: 12px;
}

#examView .survey-feedback-section:last-child {
  margin-bottom: 0;
}

#examView .survey-feedback-section h5 {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 0 0 6px;
}

#examView .survey-feedback-section p {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  margin: 0;
}

#examView .survey-distractor {
  padding: 10px 12px;
  background: var(--bg3);
  border-radius: 8px;
  margin-bottom: 8px;
}

#examView .survey-distractor:last-child {
  margin-bottom: 0;
}

#examView .survey-distractor-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

#examView .survey-distractor-reason {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
}

/* -------------------------------------------------------
   #examResults — Post-exam results
   ------------------------------------------------------- */

#examView .exam-results {
  max-width: 700px;
  margin: 0 auto;
  padding: 20px;
  font-family: var(--font-display);
}

#examView .results-header {
  padding: 24px 24px 20px;
  border-radius: var(--r2);
  margin-bottom: 22px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
}

#examView .results-header.pass {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(16, 185, 129, 0.04));
  border-color: rgba(16, 185, 129, 0.4);
}

#examView .results-header.fail {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.14), rgba(239, 68, 68, 0.03));
  border-color: rgba(239, 68, 68, 0.4);
}

#examView .results-header h3 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

#examView .results-header.pass h3 {
  color: var(--green);
}

#examView .results-header.fail h3 {
  color: #dc2626;
}

#examView .results-header p {
  font-size: 13px;
  color: var(--text2);
  margin: 0;
}

/* Score circle — large badge with pass/fail variant */
#examView .results-score {
  display: flex;
  justify-content: center;
  margin-bottom: 26px;
}

#examView .results-score-circle {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  border: 4px solid var(--border);
}

#examView .results-score-circle.pass {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(16, 185, 129, 0.06));
  border-color: var(--green);
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.1);
}

#examView .results-score-circle.fail {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.14), rgba(239, 68, 68, 0.05));
  border-color: #ef4444;
  box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.08);
}

#examView .results-score-value {
  font-family: var(--font-numeric);
  font-size: 34px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

#examView .results-score-circle.pass .results-score-value {
  color: var(--green);
}

#examView .results-score-circle.fail .results-score-value {
  color: #ef4444;
}

/* Per-domain bars */
#examView .results-domains {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

#examView .results-domains h4 {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 0 0 14px;
}

#examView .domain-bar {
  margin-bottom: 14px;
}

#examView .domain-bar:last-child {
  margin-bottom: 0;
}

#examView .domain-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
  gap: 10px;
}

#examView .domain-bar-name {
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#examView .domain-bar-score {
  color: var(--text2);
  font-family: var(--font-numeric);
  font-weight: 700;
  flex-shrink: 0;
}

#examView .domain-bar-track {
  height: 8px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
}

#examView .domain-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.9s cubic-bezier(.4, 0, .2, 1);
  width: 0%;
}

#examView .domain-bar-fill.good {
  background: linear-gradient(90deg, var(--green), #34d399);
}

#examView .domain-bar-fill.ok {
  background: linear-gradient(90deg, var(--gold), #fbbf24);
}

#examView .domain-bar-fill.bad {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

/* Results actions */
#examView .results-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

#examView .results-actions .btn {
  padding: 11px 22px;
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  min-height: 44px;
  background: transparent;
}

#examView .results-actions .btn-primary {
  border-color: var(--accent2);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.3);
}

#examView .results-actions .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.45);
}

#examView .results-actions .btn-secondary {
  border-color: var(--border);
  color: var(--text2);
  background: var(--bg3);
}

#examView .results-actions .btn-secondary:hover {
  border-color: var(--text2);
  color: var(--text);
}

/* Review panel (collapsed by default; shown when user clicks Review) */
#examView .exam-review {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: var(--shadow);
}

#examView .review-question {
  padding: 14px 16px;
  border-left: 4px solid #ef4444;
  background: rgba(239, 68, 68, 0.05);
  border-radius: 0 8px 8px 0;
  margin-bottom: 12px;
}

#examView .review-question:last-child {
  margin-bottom: 0;
}

#examView .review-question.correct-review {
  border-left-color: var(--green);
  background: rgba(16, 185, 129, 0.06);
}

#examView .review-question p {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin: 0 0 8px;
}

#examView .review-correct {
  font-size: 12px;
  color: var(--green);
  font-weight: 700;
}

#examView .review-wrong {
  font-size: 12px;
  color: #ef4444;
  font-weight: 700;
}

#examView .review-explanation {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* -------------------------------------------------------
   Responsive — narrow viewports
   ------------------------------------------------------- */

@media (max-width: 500px) {
  #examView .exam-config {
    padding: 16px 14px 32px;
  }
  #examView .exam-modes {
    grid-template-columns: 1fr;
  }
  #examView .exam-options {
    grid-template-columns: 1fr;
  }
  #examView .exam-option-card {
    min-height: 58px;
    padding: 12px 14px;
  }

  #examView .exam-active {
    padding: 12px 14px 32px;
  }
  #examView .exam-toolbar {
    padding: 10px 12px;
    gap: 8px;
  }
  #examView .exam-timer {
    font-size: 16px;
  }
  #examView .exam-progress-info {
    font-size: 11px;
  }

  /* Nav grid tightens — 28-32px buttons so 45-65 items don't balloon */
  #examView .exam-nav-grid {
    grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
    gap: 4px;
  }
  #examView .exam-nav-btn {
    min-height: 30px;
    font-size: 12px;
    border-radius: 6px;
  }
  #examView .exam-nav-btn.flagged::after {
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
  }

  #examView .exam-question-card {
    padding: 18px 16px;
  }
  #examView .exam-question-text {
    font-size: 15px;
  }
  #examView .exam-option-btn {
    padding: 12px 14px;
    font-size: 13px;
  }
  #examView .exam-option-letter {
    width: 26px;
    height: 26px;
    font-size: 13px;
  }

  #examView .exam-results {
    padding: 16px 12px;
  }
  #examView .results-header {
    padding: 20px 18px 16px;
  }
  #examView .results-header h3 {
    font-size: 18px;
  }
  #examView .results-score-circle {
    width: 110px;
    height: 110px;
    border-width: 3px;
  }
  #examView .results-score-value {
    font-size: 28px;
  }
  #examView .results-domains {
    padding: 14px 16px;
  }
  #examView .domain-bar-name {
    font-size: 11px;
  }
  #examView .exam-review {
    padding: 14px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #examView .exam-option-card,
  #examView .exam-option-btn,
  #examView .exam-option-letter,
  #examView .exam-nav-btn,
  #examView .exam-controls .btn,
  #examView .results-actions .btn,
  #examView #examFlag,
  #examView #examStart {
    transition: none;
  }
  #examView .exam-timer.danger {
    animation: none;
  }
  #examView .domain-bar-fill {
    transition: width 0.001s;
  }
}

/* New Game button container — centered under the grid, in the same
   visual system as the rest of the redesigned Memory Match view. */
.conc-actions {
  display: flex;
  justify-content: center;
  padding: 20px 20px 32px;
}

.conc-new-game-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 24px;
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid var(--border);
  color: var(--text2);
  background: var(--bg3);
  transition: 0.18s;
  min-height: 44px;
}

.conc-new-game-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface);
}

.conc-new-game-btn svg {
  flex-shrink: 0;
}

/* Matching empty state (when user deselects everything) */
.matching-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font-display);
  border: 1px dashed var(--border);
  border-radius: var(--r);
  margin: 20px;
  grid-column: 1 / -1;
}

/* Pair-count chip visual emphasis in the stats bar */
#matchingPairCount {
  color: var(--accent);
  font-weight: 700;
}

/* Progress bar — scoped override */
#flashcardsView .fc-bar-track {
  height: 4px;
  background: var(--bg3);
  margin: 0 20px;
  border-radius: 2px;
  overflow: hidden;
  padding: 0;
  display: block;
  box-shadow: none;
}

#flashcardsView .fc-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
  border-radius: 2px;
  width: 0%;
  transition: width 0.4s ease;
  display: block;
}

.fc-counter {
  text-align: right;
  padding: 6px 20px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  font-family: var(--font-display);
}

/* Card area */
#flashcardsView .card-area {
  padding: 20px;
  perspective: 1200px;
}

/* Preserve the existing 3D-flip mechanics. The flashcard markup is:
   .flashcard > .flashcard-inner > .flashcard-front + .flashcard-back
   with .flashcard.flipped rotating .flashcard-inner 180deg on Y axis.
   Re-style without breaking the flip. */
#flashcardsView .flashcard {
  background: transparent;
  border: none;
  padding: 0;
  min-height: 220px;
  cursor: pointer;
  position: relative;
  width: 100%;
}

#flashcardsView .flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 220px;
  transition: transform 0.5s cubic-bezier(.4, 0, .2, 1);
  transform-style: preserve-3d;
}

#flashcardsView .flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

#flashcardsView .flashcard-front,
#flashcardsView .flashcard-back {
  position: absolute;
  inset: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r2);
  padding: 52px 36px;
  box-shadow: var(--shadow2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
}

#flashcardsView .flashcard-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, var(--surface), var(--bg3));
  border-color: rgba(14, 165, 233, 0.35);
}

#flashcardsView .flashcard:hover .flashcard-front,
#flashcardsView .flashcard:hover .flashcard-back {
  box-shadow: 0 12px 48px rgba(15, 35, 63, 0.18);
}

/* Difficulty badge (top-right of card) */
#flashcardsView .card-diff {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--green);
  background: rgba(16, 185, 129, 0.1);
  padding: 3px 9px;
  border-radius: 4px;
}

#flashcardsView .card-diff:empty {
  display: none;
}

#flashcardsView .flashcard-difficulty.medium {
  color: var(--gold);
  background: rgba(245, 158, 11, 0.1);
}

#flashcardsView .flashcard-difficulty.hard {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* Question / answer text */
#flashcardsView .card-q {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.45;
  margin: 0;
}

#flashcardsView .flashcard-back .card-q {
  font-size: 17px;
  font-weight: 500;
  color: var(--text2);
}

#flashcardsView .card-hint {
  margin-top: 18px;
  font-size: 11px;
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
}

/* Mobile padding reduction (resolves Phase 2 deferred UX item) */
@media (max-width: 400px) {
  #flashcardsView .flashcard-front,
  #flashcardsView .flashcard-back {
    padding: 28px 20px;
  }
  #flashcardsView .card-q {
    font-size: 17px;
  }
  #flashcardsView .flashcard-back .card-q {
    font-size: 15px;
  }
}

/* Controls row */
.fc-btns {
  display: flex;
  gap: 10px;
  padding: 0 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.fc-btn {
  padding: 11px 20px;
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid;
  transition: 0.18s;
  min-height: 44px;
  background: transparent;
}

.fc-btn.btn-review {
  border-color: var(--gold);
  color: var(--gold);
}

.fc-btn.btn-review:hover,
.fc-btn.btn-review.active {
  background: var(--gold);
  color: #fff;
}

.fc-btn.btn-known {
  border-color: var(--green);
  color: var(--green);
}

.fc-btn.btn-known:hover,
.fc-btn.btn-known.active {
  background: var(--green);
  color: #fff;
}

.fc-btn.btn-nav {
  border-color: var(--border);
  color: var(--text2);
  background: var(--bg3);
}

.fc-btn.btn-nav:hover {
  border-color: var(--text2);
  color: var(--text);
}

/* Keyboard shortcut help */
.fc-keys {
  text-align: center;
  padding: 14px 20px 28px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-display);
}

/* ============================================================
   ADD SUBJECT FORM — Phase 5
   Scoped under #addSubjectView so the enrich-modal on the Home
   screen (which uses .add-subject-input too) stays on its old
   styling until migrated.
   ============================================================ */

.add-form {
  padding: 20px;
  max-width: 640px;
  margin: 0 auto;
  font-family: var(--font-display);
}

#addSubjectView .add-subject-input-group {
  margin-bottom: 18px;
}

#addSubjectView .form-label {
  display: block;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 7px;
}

#addSubjectView .add-subject-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-display);
  transition: 0.18s;
  outline: none;
}

#addSubjectView .add-subject-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

#addSubjectView .add-subject-input.file-input,
#addSubjectView input[type="file"].add-subject-input {
  padding: 8px 14px;
  cursor: pointer;
}

/* Textarea inputs (e.g., examBlueprintInput) — vertical-only resize
   so users can't drag them wider than the form container. */
#addSubjectView textarea.add-subject-input {
  resize: vertical;
  min-height: 80px;
  font-family: var(--font-display);
  line-height: 1.5;
}

/* Visual separator between the paste-text and upload-file options
   for the optional exam blueprint. */
#addSubjectView .blueprint-or {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin: 10px 0;
}

#addSubjectView .form-sub,
#addSubjectView .input-hint {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 5px;
}

#addSubjectView .url-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

#addSubjectView .url-input-row .add-subject-input {
  flex: 1;
}

#addSubjectView .btn-remove-url {
  width: 36px;
  height: 44px;
  min-width: 36px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: 0.15s;
}

#addSubjectView .btn-remove-url:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fca5a5;
}

#addSubjectView .add-url-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  margin-left: -4px;
  font-family: var(--font-display);
  min-height: 36px;
}

#addSubjectView .add-url-btn:hover {
  color: var(--accent2);
  text-decoration: underline;
}

#addSubjectView .crawl-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  padding: 6px 0;
  min-height: 32px;
}

#addSubjectView .crawl-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

#addSubjectView .generate-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  transition: 0.2s;
  box-shadow: 0 4px 20px rgba(14, 165, 233, 0.3);
  min-height: 50px;
}

#addSubjectView .generate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(14, 165, 233, 0.4);
}

#addSubjectView .generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--muted);
  box-shadow: none;
}

/* Generation progress panel (appears after submit) */
#addSubjectView .generation-progress {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg3);
  border-radius: 12px;
  border: 1px solid var(--border);
}

#addSubjectView .progress-status {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

#addSubjectView .progress-log {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text2);
  font-family: var(--font-numeric);
  max-height: 180px;
  overflow-y: auto;
  line-height: 1.5;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 20px 40px;
  position: relative;
  z-index: 2;
}

@media (min-width: 500px) {
  .games-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 800px) {
  .games-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.game-card {
  background: rgba(8, 20, 38, 0.85);
  border: 1px solid rgba(14, 165, 233, 0.15);
  border-radius: var(--r);
  padding: 14px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.22s cubic-bezier(.4, 0, .2, 1);
  backdrop-filter: blur(8px);
  color: #d8ecff;
  font-family: var(--font-display);
  text-align: left;
}

.game-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gc, #0ea5e9), transparent);
  opacity: 0.7;
}

.game-card:hover {
  transform: translateY(-4px) scale(1.01);
  border-color: var(--gc, #0ea5e9);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.4),
    0 0 0 1px var(--gc, #0ea5e9) inset;
}

.g-icon {
  font-size: 22px;
  margin-bottom: 8px;
  display: block;
}

.g-name {
  font-weight: 700;
  font-size: 12px;
  color: #d8ecff;
  margin-bottom: 3px;
}

.g-desc {
  font-size: 10px;
  color: rgba(150, 180, 220, 0.65);
  line-height: 1.4;
}

/* ============================================================
   PHASE 9 — REINFORCE / WEAK AREAS (scoped under #reinforceView)
   Scoped strictly so Exam's identical class names stay put.
   Future stats-tracking integration will flow into Setup phase
   (auto-derived scores with manual override) without needing
   structural changes.
   ============================================================ */

#reinforceView .view-container {
  padding: 14px 14px 40px;
  max-width: 900px;
  margin: 0 auto;
}

#reinforceView .topbar-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  flex: 1;
  letter-spacing: -0.01em;
}

/* ---------- Setup phase ---------- */
#reinforceView .reinforce-intro {
  text-align: center;
  max-width: 560px;
  margin: 8px auto 22px;
  padding: 0 8px;
}

#reinforceView .reinforce-intro h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

#reinforceView .reinforce-intro p {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.55;
  margin: 0;
}

#reinforceView .reinforce-scores {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 22px;
}

#reinforceView .reinforce-domain-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 16px 18px 8px;
  box-shadow: var(--shadow);
}

#reinforceView .reinforce-domain-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}

#reinforceView .reinforce-domain-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#reinforceView .reinforce-domain-weight {
  font-family: var(--font-numeric);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 50px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(14, 165, 233, 0.22));
  color: var(--accent);
  border: 1px solid rgba(14, 165, 233, 0.3);
  flex-shrink: 0;
  text-transform: none;
}

#reinforceView .reinforce-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

#reinforceView .reinforce-score-row:last-child {
  border-bottom: none;
}

#reinforceView .reinforce-score-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}

#reinforceView .reinforce-score-input-wrap {
  position: relative;
  flex-shrink: 0;
  width: 94px;
}

#reinforceView .reinforce-score-input {
  width: 100%;
  padding: 9px 26px 9px 12px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-numeric);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

#reinforceView .reinforce-score-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

#reinforceView .reinforce-score-input::-webkit-outer-spin-button,
#reinforceView .reinforce-score-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#reinforceView .reinforce-score-input[type="number"] {
  -moz-appearance: textfield;
}

#reinforceView .reinforce-score-suffix {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-numeric);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  pointer-events: none;
}

#reinforceView .reinforce-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 8px 0 20px;
}

#reinforceView .reinforce-actions .btn {
  padding: 12px 22px;
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  min-height: 44px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#reinforceView .reinforce-actions .btn-primary,
#reinforceView .reinforce-actions .btn-primary.btn-lg {
  border-color: var(--accent2);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.3);
  padding: 13px 28px;
  font-size: 15px;
}

#reinforceView .reinforce-actions .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.45);
}

#reinforceView .reinforce-actions .btn-secondary {
  border-color: var(--border);
  color: var(--text2);
  background: var(--bg3);
}

#reinforceView .reinforce-actions .btn-secondary:hover {
  border-color: var(--text2);
  color: var(--text);
}

/* ---------- Study Plan phase ---------- */
#reinforceView .reinforce-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

#reinforceView .reinforce-summary-header {
  margin-bottom: 12px;
}

#reinforceView .reinforce-summary-header h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

#reinforceView .reinforce-summary-header p {
  font-size: 13px;
  color: var(--text2);
  margin: 0;
}

#reinforceView .reinforce-topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#reinforceView .reinforce-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid;
}

#reinforceView .reinforce-chip.critical {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.35);
  color: #ef4444;
}

#reinforceView .reinforce-chip.weak {
  background: rgba(245, 158, 11, 0.10);
  border-color: rgba(245, 158, 11, 0.35);
  color: var(--gold);
}

#reinforceView .reinforce-chip.moderate {
  background: rgba(14, 165, 233, 0.08);
  border-color: rgba(14, 165, 233, 0.3);
  color: var(--accent);
}

#reinforceView .reinforce-chip-score {
  font-family: var(--font-numeric);
  font-weight: 800;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 50px;
  background: rgba(0, 0, 0, 0.12);
}

/* Topic filter pills */
#reinforceView .filter-bar,
#reinforceView .reinforce-topic-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  margin-bottom: 12px;
  scrollbar-width: thin;
}

#reinforceView .filter-pill {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 50px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.15s;
  min-height: 32px;
  white-space: nowrap;
}

#reinforceView .filter-pill:hover {
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-1px);
}

#reinforceView .filter-pill.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: var(--accent2);
  color: #fff;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

/* Progress bar */
#reinforceView .progress-bar-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

#reinforceView .progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

#reinforceView .progress-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.5s cubic-bezier(.4, 0, .2, 1);
  background: linear-gradient(90deg, var(--accent), #38bdf8);
}

#reinforceView .progress-bar-fill.accent {
  background: linear-gradient(90deg, var(--accent), #38bdf8);
}

#reinforceView .progress-bar-fill.success {
  background: linear-gradient(90deg, var(--green), #34d399);
}

#reinforceView .progress-text {
  font-family: var(--font-numeric);
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Study card */
#reinforceView .reinforce-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

#reinforceView .reinforce-card:hover {
  box-shadow: var(--shadow2);
}

#reinforceView .reinforce-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}

#reinforceView .reinforce-card-type {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 50px;
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.25);
}

#reinforceView .reinforce-card-topic {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#reinforceView .reinforce-difficulty {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 50px;
  margin-left: 8px;
  border: 1px solid;
}

#reinforceView .reinforce-difficulty.easy {
  background: rgba(16, 185, 129, 0.10);
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.3);
}

#reinforceView .reinforce-difficulty.medium {
  background: rgba(245, 158, 11, 0.10);
  color: var(--gold);
  border-color: rgba(245, 158, 11, 0.3);
}

#reinforceView .reinforce-difficulty.hard {
  background: rgba(239, 68, 68, 0.10);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

#reinforceView .reinforce-card-body {
  min-height: 120px;
}

#reinforceView .reinforce-card-footer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

#reinforceView .reinforce-explanation {
  padding: 12px 14px;
  background: rgba(14, 165, 233, 0.06);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

#reinforceView .reinforce-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
}

/* Flashcard-style 3D flip inside reinforce study card */
#reinforceView .reinforce-flashcard {
  perspective: 1200px;
  cursor: pointer;
  outline: none;
}

#reinforceView .reinforce-flashcard:focus-visible .reinforce-flashcard-inner {
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.35);
  border-radius: var(--r);
}

#reinforceView .reinforce-flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 180px;
  transition: transform 0.55s cubic-bezier(.4, 0, .2, 1);
  transform-style: preserve-3d;
}

#reinforceView .reinforce-flashcard.flipped .reinforce-flashcard-inner {
  transform: rotateY(180deg);
}

#reinforceView .reinforce-flashcard-front,
#reinforceView .reinforce-flashcard-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  text-align: center;
}

#reinforceView .reinforce-flashcard-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.04), rgba(14, 165, 233, 0.10));
  border-color: rgba(14, 165, 233, 0.3);
}

/* Reinforce practice-question rendering (inside study card) */
#reinforceView .reinforce-question-text {
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 14px;
}

#reinforceView .reinforce-question-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Controls row */
#reinforceView .reinforce-controls {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

#reinforceView .reinforce-controls .btn {
  padding: 10px 18px;
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  transition: transform 0.15s, border-color 0.15s, background 0.15s, color 0.15s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#reinforceView .reinforce-controls .btn:hover {
  border-color: var(--text2);
  color: var(--text);
  transform: translateY(-1px);
}

#reinforceView .reinforce-center-actions {
  display: flex;
  gap: 10px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

#reinforceView .reinforce-center-actions .btn {
  padding: 10px 20px;
}

#reinforceView .reinforce-center-actions .btn.needs-review {
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--gold);
  background: rgba(245, 158, 11, 0.06);
}

#reinforceView .reinforce-center-actions .btn.needs-review:hover,
#reinforceView .reinforce-center-actions .btn.needs-review.active {
  background: linear-gradient(135deg, #fbbf24, var(--gold));
  border-color: var(--gold);
  color: #fff;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
}

#reinforceView .reinforce-center-actions .btn.known {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--green);
  background: rgba(16, 185, 129, 0.06);
}

#reinforceView .reinforce-center-actions .btn.known:hover,
#reinforceView .reinforce-center-actions .btn.known.active {
  background: linear-gradient(135deg, #34d399, var(--green));
  border-color: var(--green);
  color: #fff;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

/* Bottom actions */
#reinforceView .reinforce-bottom-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

#reinforceView .reinforce-bottom-actions .btn {
  padding: 11px 22px;
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#reinforceView .reinforce-bottom-actions .btn-secondary {
  border-color: var(--border);
  color: var(--text2);
  background: var(--bg3);
}

#reinforceView .reinforce-bottom-actions .btn-secondary:hover {
  border-color: var(--text2);
  color: var(--text);
}

#reinforceView .reinforce-bottom-actions .btn-primary {
  border-color: var(--accent2);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.3);
}

#reinforceView .reinforce-bottom-actions .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.45);
}

/* Keyboard hint */
#reinforceView .keyboard-hint {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 16px 0 0;
}

/* ---------- Quiz Mode phase ---------- */
#reinforceView .game-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

#reinforceView .game-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-numeric);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

#reinforceView .game-stat-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

#reinforceView .reinforce-quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

#reinforceView .reinforce-quiz-card .reinforce-card-topic {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 50px;
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.25);
  margin-bottom: 12px;
  text-align: left;
}

#reinforceView .exam-question-text {
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 16px;
  font-weight: 500;
}

#reinforceView .exam-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

#reinforceView .exam-option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 14px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
  width: 100%;
}

#reinforceView .exam-option-btn:hover {
  border-color: rgba(14, 165, 233, 0.5);
  transform: translateY(-1px);
  box-shadow: var(--shadow2);
}

#reinforceView .exam-option-letter {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  color: var(--text2);
  border-radius: 50%;
  font-family: var(--font-numeric);
  font-size: 14px;
  font-weight: 800;
  transition: 0.15s;
}

#reinforceView .exam-option-text {
  flex: 1;
  line-height: 1.45;
}

#reinforceView .exam-option-btn.selected {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.08), rgba(14, 165, 233, 0.18));
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

#reinforceView .exam-option-btn.selected .exam-option-letter {
  background: var(--accent);
  color: #fff;
}

#reinforceView .exam-option-btn.correct {
  background: rgba(16, 185, 129, 0.10);
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

#reinforceView .exam-option-btn.correct .exam-option-letter {
  background: var(--green);
  color: #fff;
}

#reinforceView .exam-option-btn.incorrect {
  background: rgba(239, 68, 68, 0.08);
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

#reinforceView .exam-option-btn.incorrect .exam-option-letter {
  background: #ef4444;
  color: #fff;
}

#reinforceView .exam-option-btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

#reinforceView .reinforce-quiz-card .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 24px;
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid var(--accent2);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
  min-height: 44px;
  margin-top: 6px;
}

#reinforceView .reinforce-quiz-card .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.45);
}

/* ---------- Quiz Results phase ---------- */
#reinforceView #reinforceQuizResults {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 24px 22px;
  box-shadow: var(--shadow);
}

#reinforceView #reinforceQuizResultMessage {
  text-align: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 18px;
  letter-spacing: -0.01em;
}

#reinforceView .results-score {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

#reinforceView .results-score-circle {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  border: 4px solid var(--border);
}

#reinforceView .results-score-circle.pass {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(16, 185, 129, 0.06));
  border-color: var(--green);
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.1);
}

#reinforceView .results-score-circle.fail {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.14), rgba(239, 68, 68, 0.05));
  border-color: #ef4444;
  box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.08);
}

#reinforceView .results-score-value {
  font-family: var(--font-numeric);
  font-size: 34px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

#reinforceView .results-score-circle.pass .results-score-value {
  color: var(--green);
}

#reinforceView .results-score-circle.fail .results-score-value {
  color: #ef4444;
}

#reinforceView .results-domains {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  margin-bottom: 18px;
}

#reinforceView .results-domains h4 {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 0 0 14px;
}

#reinforceView .domain-bar {
  margin-bottom: 14px;
}

#reinforceView .domain-bar:last-child {
  margin-bottom: 0;
}

#reinforceView .domain-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
  gap: 10px;
}

#reinforceView .domain-bar-name {
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#reinforceView .domain-bar-score {
  color: var(--text2);
  font-family: var(--font-numeric);
  font-weight: 700;
  flex-shrink: 0;
}

#reinforceView .domain-bar-track {
  height: 8px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

#reinforceView .domain-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.9s cubic-bezier(.4, 0, .2, 1);
  width: 0%;
}

#reinforceView .domain-bar-fill.good {
  background: linear-gradient(90deg, var(--green), #34d399);
}

#reinforceView .domain-bar-fill.ok {
  background: linear-gradient(90deg, var(--gold), #fbbf24);
}

#reinforceView .domain-bar-fill.bad {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

#reinforceView .results-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

#reinforceView .results-actions .btn {
  padding: 11px 22px;
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  min-height: 44px;
  background: transparent;
}

#reinforceView .results-actions .btn-primary {
  border-color: var(--accent2);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.3);
}

#reinforceView .results-actions .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.45);
}

#reinforceView .results-actions .btn-secondary {
  border-color: var(--border);
  color: var(--text2);
  background: var(--bg3);
}

#reinforceView .results-actions .btn-secondary:hover {
  border-color: var(--text2);
  color: var(--text);
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 500px) {
  #reinforceView .view-container {
    padding: 10px 10px 32px;
  }
  #reinforceView .reinforce-domain-group {
    padding: 14px 14px 6px;
  }
  #reinforceView .reinforce-domain-heading {
    font-size: 12px;
    letter-spacing: 1px;
  }
  #reinforceView .reinforce-score-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  #reinforceView .reinforce-score-label {
    flex: 1 1 100%;
    font-size: 13px;
  }
  #reinforceView .reinforce-score-input-wrap {
    width: 88px;
    margin-left: auto;
  }
  #reinforceView .reinforce-intro h3 {
    font-size: 19px;
  }
  #reinforceView .reinforce-card {
    padding: 16px;
  }
  #reinforceView .reinforce-controls {
    gap: 8px;
  }
  #reinforceView .reinforce-controls .btn {
    padding: 9px 14px;
    font-size: 12px;
  }
  #reinforceView .reinforce-center-actions {
    order: 3;
    flex: 1 1 100%;
    justify-content: space-between;
  }
  #reinforceView .reinforce-center-actions .btn {
    flex: 1;
    padding: 10px 12px;
  }
  #reinforceView .exam-question-text {
    font-size: 15px;
  }
  #reinforceView .exam-option-btn {
    padding: 12px 14px;
    font-size: 13px;
  }
  #reinforceView .results-score-circle {
    width: 110px;
    height: 110px;
  }
  #reinforceView .results-score-value {
    font-size: 28px;
  }
  #reinforceView .keyboard-hint {
    font-size: 10px;
    letter-spacing: 0.5px;
  }
}

/* ---------- Legacy !important overrides (styles.css 2259-2328) ----------
   styles.css still has .reinforce-q-option/.reinforce-quiz-opt with
   !important on background/border. We must match specificity + !important
   to win, so the new redesign look applies inside Reinforce. */

#reinforceView .reinforce-q-option.correct,
#reinforceView .reinforce-quiz-opt.correct {
  border-color: var(--green) !important;
  background: rgba(16, 185, 129, 0.10) !important;
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

#reinforceView .reinforce-q-option.correct .exam-option-letter,
#reinforceView .reinforce-quiz-opt.correct .exam-option-letter {
  background: var(--green);
  color: #fff;
}

#reinforceView .reinforce-q-option.incorrect,
#reinforceView .reinforce-quiz-opt.incorrect {
  border-color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.08) !important;
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

#reinforceView .reinforce-q-option.incorrect .exam-option-letter,
#reinforceView .reinforce-quiz-opt.incorrect .exam-option-letter {
  background: #ef4444;
  color: #fff;
}

/* ---------- Future stats-tracking hooks (structural placeholders) ----------
   When stats feature ships, the Setup phase will auto-populate scores from
   tracked performance data. Hooks preserved:
   - .reinforce-score-input becomes read-only-with-override variant
   - .reinforce-domain-heading gets "Your rolling avg: 67%" line
   - .reinforce-summary adds "Based on your last N sessions" context
   - .reinforce-chip severity auto-computed from accuracy instead of manual %
   No structural changes required — all content-level additions. */

/* ============================================================
   SCENARIO CHALLENGE — letter-pill fix
   Targeted fix for A/B/C/D prefix running into option text.
   Full scenario redesign deferred; this just gives the letter
   its pill treatment and makes the option a flex row so the
   text no longer hugs the letter.
   ============================================================ */

#scenarioView .scenario-option {
  display: flex;
  align-items: center;
  gap: 14px;
}

#scenarioView .scenario-option-letter {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  color: var(--text2);
  border-radius: 50%;
  font-family: var(--font-numeric);
  font-size: 14px;
  font-weight: 800;
  transition: 0.15s;
}

#scenarioView .scenario-option.selected .scenario-option-letter {
  background: var(--accent);
  color: #fff;
}

#scenarioView .scenario-option.correct .scenario-option-letter {
  background: var(--green);
  color: #fff;
}

#scenarioView .scenario-option.incorrect .scenario-option-letter {
  background: #ef4444;
  color: #fff;
}

/* Dark-mode text/contrast fix for Scenario options.
   Same root cause as the Fill-in-Blank fix below: legacy styles.css
   .scenario-option has no `color` rule, so the button inherits the UA
   default (near-black) instead of --text. In dark mode the option text
   becomes invisible against the dark card bg. Also flip the hardcoded
   light backgrounds on selected/correct/incorrect to translucent tints
   that read on a dark surface. */
#scenarioView .scenario-option {
  color: var(--text);
}

[data-dark] #scenarioView .scenario-option {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

[data-dark] #scenarioView .scenario-option:hover {
  border-color: var(--accent);
  color: var(--text);
}

[data-dark] #scenarioView .scenario-option.selected {
  background: rgba(14, 165, 233, 0.15) !important;
  border-color: var(--accent) !important;
  color: var(--text);
}

[data-dark] #scenarioView .scenario-option.correct {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: var(--green) !important;
  color: var(--text);
}

[data-dark] #scenarioView .scenario-option.incorrect {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: #ef4444 !important;
  color: var(--text);
}

/* ============================================================
   FILL IN THE BLANK — dark-mode text/contrast fix
   The legacy styles.css .fill-blank-option has no color rule, so
   in dark mode the button text defaults to near-black against a
   dark card. Add explicit text color for both modes and flip the
   correct/incorrect hardcoded light backgrounds for dark mode.
   Full fill-blank redesign still deferred.
   ============================================================ */

#fillBlankView .fill-blank-option {
  color: var(--text);
}

[data-dark] #fillBlankView .fill-blank-option {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

[data-dark] #fillBlankView .fill-blank-option:hover {
  border-color: var(--accent);
  color: var(--text);
}

[data-dark] #fillBlankView .fill-blank-option.correct {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: var(--green) !important;
  color: var(--text);
}

[data-dark] #fillBlankView .fill-blank-option.incorrect {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: #ef4444 !important;
  color: var(--text);
}

[data-dark] #fillBlankView .fill-blank-statement {
  color: var(--text);
}

[data-dark] #fillBlankView .fill-blank-explanation {
  background: rgba(14, 165, 233, 0.08);
  color: var(--text);
  border-left-color: var(--accent);
}

/* ============================================================
   BRICK BREAKER — question overlay close button + exit hint
   The question overlay is position:fixed z-index:100 so it
   covers the top "← Dashboard" link. This adds an × button
   inline in the header and a small keyboard hint at the bottom
   of the box. ESC key is wired in app.js.
   ============================================================ */

#breakoutView .breakout-q-close {
  margin-left: 10px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 60, 60, 0.15);
  border: 1.5px solid rgba(200, 60, 60, 0.5);
  border-radius: 50%;
  color: #ff8a8a;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}

#breakoutView .breakout-q-close:hover,
#breakoutView .breakout-q-close:focus-visible {
  background: #c83c3c;
  border-color: #ff8a8a;
  color: #fff;
  transform: scale(1.08);
  outline: none;
}

#breakoutView .breakout-q-hint {
  margin: 12px 0 0;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(220, 200, 200, 0.55);
}

#breakoutView .breakout-q-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 2px;
  background: rgba(200, 60, 60, 0.18);
  border: 1px solid rgba(200, 60, 60, 0.45);
  border-radius: 4px;
  font-family: var(--font-numeric);
  font-size: 10px;
  font-weight: 700;
  color: #ffcccc;
}
