/* ============================================
   CS MULTIVERSE — Global Design System
   ============================================ */

:root {
  /* Base cosmic palette */
  --bg-void: #050410;
  --bg-deep: #0a0820;
  --bg-elevated: #14122c;
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-strong: rgba(255, 255, 255, 0.08);

  --ink-100: #f6f5ff;
  --ink-200: #d8d6f0;
  --ink-300: #a3a0c8;
  --ink-400: #6f6c95;
  --ink-500: #4a4775;
  --ink-line: rgba(255, 255, 255, 0.08);
  --ink-line-strong: rgba(255, 255, 255, 0.16);

  /* Iridescent platform accent */
  --iris-1: oklch(75% 0.18 300);
  --iris-2: oklch(78% 0.16 220);
  --iris-3: oklch(80% 0.16 160);
  --iris-warm: oklch(82% 0.16 60);

  /* Default active world (overridden per world via data-world) */
  --w-h: 300;
  --w-c: 0.2;
  --w-primary: oklch(75% var(--w-c) var(--w-h));
  --w-bright: oklch(85% var(--w-c) var(--w-h));
  --w-deep: oklch(40% 0.16 var(--w-h));
  --w-glow: oklch(75% var(--w-c) var(--w-h) / 0.35);
  --w-tint: oklch(75% var(--w-c) var(--w-h) / 0.12);

  /* Type */
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* Density */
  --d: 1;          /* density multiplier — 1 cinematic, 0.7 compact */
  --space-1: calc(4px * var(--d));
  --space-2: calc(8px * var(--d));
  --space-3: calc(12px * var(--d));
  --space-4: calc(16px * var(--d));
  --space-5: calc(20px * var(--d));
  --space-6: calc(24px * var(--d));
  --space-8: calc(32px * var(--d));
  --space-10: calc(40px * var(--d));
  --space-12: calc(48px * var(--d));
  --space-16: calc(64px * var(--d));

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-xl: 32px;
  --r-full: 999px;

  /* Theme presets — arcade & glass override these */
  --shell-bg: radial-gradient(ellipse 80% 60% at 20% -10%, oklch(35% 0.15 280 / 0.4), transparent 60%),
              radial-gradient(ellipse 60% 50% at 100% 100%, oklch(40% 0.18 200 / 0.3), transparent 60%),
              radial-gradient(ellipse 50% 40% at 50% 50%, oklch(30% 0.12 320 / 0.2), transparent 70%),
              var(--bg-void);
}

[data-theme="arcade"] {
  --bg-void: #0d0d10;
  --bg-deep: #16161c;
  --bg-elevated: #1f1f28;
  --shell-bg:
    linear-gradient(180deg, #0d0d10 0%, #0a0a0c 100%);
  --iris-1: oklch(72% 0.22 30);
}

[data-theme="glass"] {
  --bg-void: #1a1830;
  --bg-deep: #221f3c;
  --bg-elevated: rgba(255, 255, 255, 0.06);
  --bg-glass: rgba(255, 255, 255, 0.08);
  --bg-glass-strong: rgba(255, 255, 255, 0.16);
  --shell-bg:
    radial-gradient(ellipse 100% 70% at 50% 0%, oklch(60% 0.18 260 / 0.5), transparent 70%),
    radial-gradient(ellipse 80% 60% at 0% 100%, oklch(55% 0.18 320 / 0.4), transparent 70%),
    linear-gradient(180deg, #1a1830, #0e0c1e);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-void);
  color: var(--ink-100);
  font-family: var(--font-body);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  overflow: hidden;
}

html { height: 100%; }

#root {
  position: relative;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
}

/* App fills the real viewport. No fake-device bezel. */
.app-shell {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--shell-bg);
  overflow: hidden;
}

/* ===== STARFIELD ===== */
.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.stars::before, .stars::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, white, transparent),
    radial-gradient(1px 1px at 70% 60%, white, transparent),
    radial-gradient(1px 1px at 40% 80%, white, transparent),
    radial-gradient(2px 2px at 85% 15%, white, transparent),
    radial-gradient(1px 1px at 15% 75%, white, transparent),
    radial-gradient(1px 1px at 55% 25%, white, transparent),
    radial-gradient(2px 2px at 92% 88%, white, transparent),
    radial-gradient(1px 1px at 33% 55%, white, transparent);
  background-size: 400px 400px;
  background-repeat: repeat;
  opacity: 0.35;
}
.stars::after {
  background-size: 700px 700px;
  opacity: 0.5;
  /* animation: drift removed — animating background-position forces a full-viewport
     repaint every frame. Static starfield is visually equivalent at this opacity. */
}
/* @keyframes drift removed along with the animation above. */

/* ===== Noise overlay =====
   The SVG feTurbulence noise was re-rasterized every frame on every page
   that uses .noise (which is most of them). On phones and integrated GPUs
   this alone was burning ~5-8ms per frame. The aesthetic loss is ~0 at
   the 0.05 opacity we were drawing it at. Kept as an empty rule so any
   stray <div class="noise"> doesn't reflow the layout. */
.noise {
  display: none;
}

/* ===== Top Nav ===== */
.topnav {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  padding: var(--space-4) var(--space-6);
  gap: var(--space-6);
  border-bottom: 1px solid var(--ink-line);
  /* Dropped backdrop-filter: blur(20px) — tanked frame rate on integrated GPUs.
     A slightly more opaque solid gives the same visual weight without GPU cost. */
  background: linear-gradient(180deg, rgba(10, 8, 32, 0.88), rgba(10, 8, 32, 0.78));
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background:
    conic-gradient(from 0deg,
      oklch(75% 0.2 300),
      oklch(75% 0.2 220),
      oklch(75% 0.2 160),
      oklch(75% 0.2 60),
      oklch(75% 0.2 300));
  position: relative;
  box-shadow: 0 0 20px oklch(75% 0.2 280 / 0.5);
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 4px;
  background: var(--bg-void);
}

.nav-pills {
  display: flex;
  gap: var(--space-1);
  margin-left: var(--space-8);
}

.nav-pill {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--r-full);
  color: var(--ink-300);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  letter-spacing: 0.01em;
}
.nav-pill:hover {
  color: var(--ink-100);
  background: var(--bg-glass);
}
.nav-pill.active {
  color: var(--ink-100);
  background: var(--bg-glass-strong);
}

.nav-spacer { flex: 1; }

.nav-stats {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-full);
  background: var(--bg-glass);
  border: 1px solid var(--ink-line);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.stat-chip svg { width: 14px; height: 14px; }
.stat-chip.streak { color: oklch(85% 0.16 60); }
.stat-chip.xp { color: oklch(85% 0.16 160); }
.stat-chip.gem { color: oklch(80% 0.16 280); }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: conic-gradient(from 90deg, oklch(70% 0.2 280), oklch(70% 0.2 60));
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  color: white;
}

/* ===== Mobile bottom nav ===== */
.bottomnav {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-around;
  padding: 10px 8px calc(20px + env(safe-area-inset-bottom));
  /* Dropped backdrop-filter — solid bottom on mobile reads better and frees the GPU. */
  background: linear-gradient(180deg, rgba(10, 8, 32, 0.92), rgba(10, 8, 32, 0.98));
  border-top: 1px solid var(--ink-line);
  flex-shrink: 0;
}
.bottomnav-btn {
  background: transparent;
  border: none;
  color: var(--ink-400);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.2s;
}
.bottomnav-btn.active { color: var(--ink-100); }
.bottomnav-btn svg { width: 22px; height: 22px; }
.bottomnav-btn.active svg { /* filter: drop-shadow removed — filter on animated/active elements triggers compositor skip. */ color: var(--w-primary); }

/* ===== Scroll area ===== */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 2;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-line-strong) transparent;
}
.scroll-area::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll-area::-webkit-scrollbar-thumb { background: var(--ink-line-strong); border-radius: 3px; }

/* ===== Buttons ===== */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.005em;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--w-bright), var(--w-primary));
  color: #0a0820;
  padding: 14px 28px;
  border-radius: var(--r-full);
  font-size: 15px;
  box-shadow:
    0 10px 30px -10px var(--w-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn-primary:hover {
  box-shadow:
    0 14px 40px -8px var(--w-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.btn-ghost {
  background: var(--bg-glass);
  color: var(--ink-100);
  padding: 13px 26px;
  border-radius: var(--r-full);
  border: 1px solid var(--ink-line-strong);
  font-size: 15px;
  /* backdrop-filter dropped — too many .btn-ghost on screen at once to be free. */
}
.btn-ghost:hover { background: var(--bg-glass-strong); border-color: rgba(255, 255, 255, 0.3); }

.btn-sm { padding: 8px 14px; font-size: 12px; }

button:not(:disabled):focus-visible,
.btn:focus-visible,
.nav-pill:focus-visible {
  outline: 2px solid var(--w-bright);
  outline-offset: 3px;
}

/* ===== Cards / panels ===== */
.panel {
  /* backdrop-filter dropped: 10+ panels on screen at once was the single biggest
     paint cost on integrated GPUs. The slightly heavier solid (--bg-glass +
     border) reads the same at normal opacity. */
  background: var(--bg-glass);
  border: 1px solid var(--ink-line);
  border-radius: var(--r-lg);
}

.panel-bordered {
  background: linear-gradient(180deg, var(--bg-glass), transparent);
  border: 1px solid var(--ink-line);
  border-radius: var(--r-lg);
  position: relative;
  overflow: hidden;
}

/* Type ramps */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-300);
  font-weight: 500;
}

.display-xl { font-family: var(--font-display); font-weight: 700; font-size: clamp(40px, 6vw, 84px); line-height: 0.95; letter-spacing: -0.035em; }
.display-lg { font-family: var(--font-display); font-weight: 700; font-size: clamp(32px, 4vw, 56px); line-height: 1; letter-spacing: -0.03em; }
.display-md { font-family: var(--font-display); font-weight: 700; font-size: clamp(24px, 3vw, 36px); line-height: 1.05; letter-spacing: -0.02em; }
.display-sm { font-family: var(--font-display); font-weight: 600; font-size: 22px; line-height: 1.1; letter-spacing: -0.01em; }

.text-mono { font-family: var(--font-mono); }
.muted { color: var(--ink-300); }

/* Page transition */
.page {
  animation: pageIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Utility */
.hidden { display: none !important; }
.row { display: flex; gap: var(--space-4); }
.col { display: flex; flex-direction: column; gap: var(--space-4); }
.center { display: flex; align-items: center; justify-content: center; }

/* Iridescent text */
.iridescent {
  background: linear-gradient(135deg,
    oklch(85% 0.15 300) 0%,
    oklch(85% 0.15 240) 30%,
    oklch(85% 0.15 180) 60%,
    oklch(88% 0.15 60) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Glow ring (world card) */
.glow-ring {
  position: relative;
}
.glow-ring::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, var(--w-bright), transparent 50%, var(--w-primary));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* Progress bar */
.progress {
  height: 6px;
  background: var(--bg-glass);
  border-radius: var(--r-full);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--w-deep), var(--w-bright));
  border-radius: var(--r-full);
  position: relative;
  transform-origin: left center;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 2.5s linear infinite;
  will-change: transform;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .progress-fill::after {
    animation: none;
  }
}

/* Hover lift */
.lift {
  position: relative;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.lift::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  z-index: -1;
  will-change: opacity;
}
.lift:hover { transform: translateY(-3px); }
.lift:hover::before { opacity: 1; }

/* ===== Planet animations ===== */
@keyframes planet-slide {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
@keyframes planet-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.95; }
}
@keyframes planet-wobble {
  0%, 100% { transform: translateX(-12%); }
  50% { transform: translateX(-38%); }
}
@keyframes nebula-drift {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.7; }
  33% { transform: translate(40px, -25px) scale(1.05); opacity: 0.9; }
  66% { transform: translate(-30px, 20px) scale(0.95); opacity: 0.6; }
}
/* @keyframes shooting-star removed — shooting-star elements were removed from JSX (see landing.jsx). */
@keyframes float-y {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes ring-shimmer {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* .shooting-star removed — element no longer exists in JSX (confirmed dead code). */

/* World-tinted glass */
.world-glass {
  background:
    radial-gradient(ellipse 80% 60% at 0% 0%, var(--w-tint), transparent 60%),
    var(--bg-glass);
  border: 1px solid var(--ink-line);
  position: relative;
  overflow: hidden;
}
.world-glass::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, var(--w-glow), transparent 60%);
  opacity: 0.4;
  pointer-events: none;
}

/* ===== Student journey layer ===== */
.mentor-briefing {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 30% 0%, oklch(82% var(--w-c) var(--w-h) / 0.18), transparent 58%),
    rgba(0, 0, 0, 0.3);
  border: 1px solid var(--ink-line);
  overflow: hidden;
}
.mentor-briefing::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.05));
  pointer-events: none;
}
.mentor-portrait {
  position: relative;
  z-index: 1;
  width: 96px;
  height: 96px;
  margin: 0 auto;
  border-radius: 26px;
  background-image: url("assets/mentor-guide-talk.png?v=1");
  background-repeat: no-repeat;
  background-size: 200% 200%;
  background-position: 0% 0%;
  animation:
    guide-talk 2.4s steps(1, end) infinite,
    guide-breathe 3.2s ease-in-out infinite;
  filter: drop-shadow(0 0 18px oklch(82% var(--w-c) var(--w-h) / 0.45));
}
.mentor-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
}
.mentor-eyebrow {
  margin-bottom: 6px;
  color: var(--w-bright);
}
.mentor-title {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.05;
  font-weight: 700;
  margin-bottom: 8px;
}
.mentor-text {
  color: var(--ink-200);
  font-size: 12px;
  line-height: 1.45;
  margin-bottom: 12px;
}
.mentor-loop {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}
.mentor-loop span {
  min-width: 0;
  padding: 5px 7px;
  border-radius: 999px;
  border: 1px solid oklch(85% var(--w-c) var(--w-h) / 0.18);
  background: oklch(85% var(--w-c) var(--w-h) / 0.08);
  color: var(--ink-100);
  font-family: var(--font-mono);
  font-size: 9px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.mentor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.learning-compass {
  padding: 18px;
}
.learning-compass-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 16px;
}
.learning-compass-score {
  text-align: right;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1;
}
.learning-compass-score span {
  display: block;
  font-size: 34px;
  color: var(--w-bright);
}
.learning-compass-score small {
  color: var(--ink-300);
  font-family: var(--font-mono);
  font-size: 10px;
}
.learning-stage-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.learning-stage {
  min-width: 0;
  display: flex;
  gap: 9px;
  padding: 11px;
  border-radius: 13px;
  border: 1px solid var(--ink-line);
  background: rgba(255, 255, 255, 0.035);
}
.learning-stage.active {
  border-color: var(--w-primary);
  background: var(--w-tint);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.learning-stage.done {
  border-color: oklch(72% 0.16 160 / 0.32);
  background: oklch(72% 0.16 160 / 0.08);
}
.learning-stage.locked {
  opacity: 0.58;
}
.learning-stage-dot {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass-strong);
  color: var(--ink-100);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
}
.learning-stage.active .learning-stage-dot {
  color: #0a0820;
  background: var(--w-primary);
}
.learning-stage.done .learning-stage-dot {
  color: #061510;
  background: oklch(72% 0.16 160);
}
.learning-stage-body {
  min-width: 0;
}
.learning-stage-title {
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 1.1;
  font-weight: 700;
  margin-bottom: 3px;
}
.learning-stage-range {
  color: var(--ink-300);
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.learning-stage-promise {
  color: var(--ink-300);
  font-size: 11px;
  line-height: 1.35;
}
.mission-briefing {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 18px;
  padding: 22px;
  border-color: oklch(85% var(--w-c) var(--w-h) / 0.18);
  background:
    radial-gradient(circle at 0% 0%, var(--w-tint), transparent 55%),
    var(--bg-glass);
}
.mission-briefing-title {
  margin: 8px 0 10px;
}
.mission-briefing-text {
  max-width: 720px;
  margin: 0 0 16px;
  color: var(--ink-200);
  font-size: 15px;
  line-height: 1.5;
}
.mission-loop-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.mission-loop-grid span {
  min-width: 0;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--ink-line);
  color: var(--ink-200);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mission-briefing-side {
  padding: 16px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--ink-line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mission-vet-copy {
  color: var(--ink-200);
  font-size: 13px;
  line-height: 1.45;
}
.mission-reward-note {
  color: var(--ink-300);
  font-size: 11px;
  line-height: 1.4;
}
.victory-debrief {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
  text-align: left;
}
.victory-debrief-card {
  position: relative;
  overflow: hidden;
  padding: 15px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 0% 0%, var(--w-tint), transparent 58%),
    rgba(255, 255, 255, 0.045);
  border: 1px solid var(--ink-line);
}
.victory-debrief-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 18%, rgba(255, 255, 255, 0.12) 45%, transparent 72%);
  transform: translateX(-120%);
  animation: fx-sweep 2.8s ease-in-out 0.3s both;
  pointer-events: none;
}
.victory-debrief-card.unlock {
  border-color: oklch(82% 0.16 60 / 0.28);
  background:
    radial-gradient(circle at 100% 0%, oklch(82% 0.16 60 / 0.16), transparent 58%),
    rgba(255, 255, 255, 0.045);
}
.victory-debrief-title {
  margin: 7px 0 6px;
  color: var(--w-bright);
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.1;
  font-weight: 700;
}
.victory-debrief-copy {
  color: var(--ink-200);
  font-size: 12px;
  line-height: 1.42;
}

@media (max-width: 980px) {
  .learning-stage-grid {
    grid-template-columns: 1fr;
  }
  .mission-briefing {
    grid-template-columns: 1fr;
  }
  .mission-loop-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .victory-debrief {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .learning-compass {
    padding: 14px;
  }
  .learning-compass-head {
    align-items: flex-start;
  }
  .mission-briefing {
    padding: 16px;
  }
  .mission-loop-grid {
    grid-template-columns: 1fr;
  }
}

/* World icon (abstract glyph) */
.world-glyph {
  width: 56px;
  height: 56px;
  border-radius: var(--r-md);
  background:
    radial-gradient(circle at 30% 30%, var(--w-bright), var(--w-deep));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  position: relative;
  box-shadow: 0 6px 20px -6px var(--w-glow);
  flex-shrink: 0;
}
.world-glyph::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Generic util scroll-snap row */
.snap-row {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 8px;
}
.snap-row > * {
  scroll-snap-align: start;
  flex-shrink: 0;
}

/* Animated halo */
@keyframes halo {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}
.halo { animation: halo 4s ease-in-out infinite; will-change: transform, opacity; }

/* Compact mode tightens */
[data-density="compact"] {
  --d: 0.7;
}
[data-density="compact"] .display-xl { font-size: clamp(32px, 4.5vw, 60px); }
[data-density="compact"] .display-lg { font-size: clamp(26px, 3.5vw, 44px); }
[data-density="compact"] .display-md { font-size: clamp(20px, 2.5vw, 30px); }

/* ===== WorldMap perf: compositor-owned transitions =====
   These classes replace inline style objects rebuilt on every hover so that
   opacity and box-shadow transitions run on the compositor thread with zero
   JS overhead per frame. */

/* Nebula blobs — opacity is the only thing that changes on hover. */
.world-nebula {
  opacity: 0.5;
  transition: opacity 0.4s;
}
.world-nebula--active {
  opacity: 1;
}

/* World node inner square — box-shadow variant swapped via class toggle. */
.world-node-inner {
  box-shadow: none;
}
.world-node-inner--unlocked {
  box-shadow: 0 0 20px oklch(80% var(--node-chroma) var(--node-hue) / 0.4);
}
.world-node-inner--unlocked.world-node-inner--active {
  box-shadow: 0 0 40px oklch(80% var(--node-chroma) var(--node-hue) / 0.7);
}

/* =====================================================================
   Lesson FX — shared animation vocabulary for the ten lesson games.
   Consumed by lesson-fx.jsx and the per-lesson modules. Transform/opacity
   only (GPU-cheap); one-shot unless a lesson deliberately loops one.
   ===================================================================== */
@keyframes fx-spark {
  /* particle burst — --dx/--dy are set inline per spark */
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to   { transform: translate(var(--dx), var(--dy)) scale(0.25); opacity: 0; }
}
@keyframes fx-rise {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fx-pop {
  0%   { opacity: 0; transform: scale(0.82); }
  60%  { opacity: 1; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes fx-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes fx-flash-fade {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes fx-glow-pulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 1; }
}
@keyframes fx-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@keyframes fx-sweep {
  from { transform: translateX(-120%); }
  to   { transform: translateX(120%); }
}
@keyframes guide-talk {
  0%, 18% { background-position: 0% 0%; }
  24%, 42% { background-position: 100% 0%; }
  48%, 66% { background-position: 0% 100%; }
  72%, 100% { background-position: 100% 100%; }
}
@keyframes guide-breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.02); }
}
@keyframes guide-scanline {
  0% { transform: translateY(-120%); opacity: 0; }
  15%, 75% { opacity: 0.45; }
  100% { transform: translateY(120%); opacity: 0; }
}

/* one-shot helper classes the lessons can drop straight onto an element */
.fx-shake     { animation: fx-shake 380ms cubic-bezier(.36,.07,.19,.97) both; }
.fx-pop       { animation: fx-pop 320ms cubic-bezier(.2,.7,.3,1) both; }
.fx-rise      { animation: fx-rise 380ms cubic-bezier(.2,.7,.3,1) both; }

.fx-flash-good, .fx-flash-bad {
  position: relative;
}
.fx-flash-good::after, .fx-flash-bad::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  will-change: opacity;
}
.fx-flash-good::after {
  background-color: oklch(72% 0.18 150 / 0.40);
  animation: fx-flash-fade 720ms ease-out forwards;
}
.fx-flash-bad::after {
  background-color: oklch(65% 0.21 25 / 0.40);
  animation: fx-flash-fade 720ms ease-out forwards;
}

@media (prefers-reduced-motion: reduce) {
  .fx-shake, .fx-pop, .fx-rise { animation: none; }
  .fx-flash-good::after, .fx-flash-bad::after { animation: none; }
}

/* --- Lesson guide portrait: generated 2x2 talking sprite sheet. --- */
.lesson-guide {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 152px;
  padding: 5px 12px 5px 6px;
  border: 1px solid oklch(85% var(--w-c) var(--w-h) / 0.22);
  border-radius: var(--r-full);
  background:
    radial-gradient(circle at 24px 22px, oklch(85% var(--w-c) var(--w-h) / 0.2), transparent 58%),
    rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  overflow: hidden;
}
.lesson-guide::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.16) 50%, transparent 100%);
  animation: guide-scanline 3.4s ease-in-out infinite;
  pointer-events: none;
}
.lesson-guide-sprite {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  background-image: url("assets/mentor-guide-talk.png?v=1");
  background-repeat: no-repeat;
  background-size: 200% 200%;
  background-position: 0% 0%;
  animation:
    guide-talk 2.2s steps(1, end) infinite,
    guide-breathe 3.2s ease-in-out infinite;
  filter: drop-shadow(0 0 10px oklch(82% var(--w-c) var(--w-h) / 0.45));
}
.lesson-guide-copy {
  position: relative;
  z-index: 1;
  display: grid;
  min-width: 0;
  line-height: 1;
}
.lesson-guide-kicker {
  color: var(--ink-400);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.lesson-guide-name {
  color: var(--ink-100);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  max-width: 86px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 860px) {
  .lesson-guide { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .lesson-guide::after,
  .lesson-guide-sprite {
    animation: none;
  }
}

/* --- Challenger World avatars: positioned imperatively by the rAF loop. --- */
.chal-avatar {
  position: absolute; left: 0; top: 0; width: 0; height: 0;
  will-change: transform;
}
.chal-nametag {
  position: absolute; left: 0; top: -56px;
  transform: translateX(-50%); white-space: nowrap;
  padding: 2px 8px; border-radius: 999px;
  font-family: var(--font-display); font-weight: 700; font-size: 11px;
}
.chal-sprite {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -50%);
}
.chal-avatar[data-facing="left"] .chal-sprite {
  transform: translate(-50%, -50%) scaleX(-1);
}
.chal-bob { animation: chal-bob 2.6s ease-in-out infinite; }
@keyframes chal-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
  .chal-bob { animation: none; }
}

/* Task 1: Short-viewport scroll fallback */
@media (max-height: 600px) {
  html, body {
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  #root {
    height: auto !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
  }
  .app-shell {
    height: auto !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    overflow-y: visible !important;
    overflow-x: hidden !important;
  }
  .scroll-area {
    overflow-y: visible !important;
  }
}

/* Task 3: Circuit Board Sizing */
.circuit-board-svg {
  width: 100%;
  max-width: 460px;
}


