/* =====================================================
   MATHVERSE — Cyberpunk / Gen-Z Neon Theme
   ===================================================== */

/* ---------- CSS Variables ---------- */
:root {
  --bg-dark: #0a0a1a;
  --bg-card: rgba(15, 15, 35, 0.85);
  --bg-glass: rgba(20, 20, 50, 0.6);
  --neon-purple: #b44aff;
  --neon-blue: #00d4ff;
  --neon-pink: #ff2ecb;
  --neon-green: #39ff14;
  --neon-orange: #ff6b35;
  --neon-yellow: #ffe600;
  --neon-red: #ff3860;
  --neon-cyan: #00fff7;
  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --text-dim: #555577;
  --glass-border: rgba(180, 74, 255, 0.25);
  --shadow-neon: 0 0 20px rgba(180, 74, 255, 0.3);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

#particle-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ---------- Screens ---------- */
.screen {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1;
  animation: fadeIn 0.35s ease;
  background: var(--bg-dark);
}
.screen.active { display: block; }
/* Flex screens center their content */
#splash-screen.active,
#onboarding-screen.active,
#results-screen.active { display: flex; }

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

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

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 5px var(--neon-purple), 0 0 15px rgba(180,74,255,0.3); }
  50% { box-shadow: 0 0 15px var(--neon-purple), 0 0 40px rgba(180,74,255,0.5); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes rotateHue {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* ---------- Glass Panel ---------- */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
}

/* =====================================================
   SPLASH SCREEN
   ===================================================== */
#splash-screen {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(180,74,255,0.1) 0%, transparent 70%), var(--bg-dark);
}

.splash-content {
  max-width: 600px;
  width: 100%;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo-glitch {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 0 10px var(--neon-purple),
    0 0 40px var(--neon-purple),
    0 0 80px rgba(180,74,255,0.5);
  position: relative;
  letter-spacing: 4px;
  margin-left: -4px; /* compensate letter-spacing visual shift */
  animation: float 3s ease-in-out infinite;
  text-align: center;
}
.logo-glitch::before,
.logo-glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}
.logo-glitch::before {
  color: var(--neon-cyan);
  animation: glitch1 2s infinite;
  clip-path: inset(0 0 60% 0);
}
.logo-glitch::after {
  color: var(--neon-pink);
  animation: glitch2 2s infinite;
  clip-path: inset(40% 0 0 0);
}
@keyframes glitch1 {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, 1px); }
}
@keyframes glitch2 {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(3px, -2px); }
  40% { transform: translate(-3px, 2px); }
  60% { transform: translate(2px, -1px); }
}

.splash-subtitle {
  font-family: var(--font-display);
  font-size: clamp(0.9rem, 2.5vw, 1.3rem);
  color: var(--neon-blue);
  letter-spacing: 6px;
  margin-left: -6px;
  margin-top: 0.5rem;
  text-align: center;
}

.splash-tagline {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin: 1.5rem 0;
  text-align: center;
}

/* Hex grid decoration */
.hex-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 2rem auto;
  max-width: 200px;
}
.hex {
  width: 40px; height: 46px;
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-blue));
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  opacity: 0.4;
  animation: pulse 2s ease-in-out infinite;
}
.hex:nth-child(odd) { animation-delay: 0.3s; }
.hex:nth-child(3n) { animation-delay: 0.6s; }

.splash-hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 1.5rem;
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn-neon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 36px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-blue));
  border: none;
  border-radius: 50px;
  cursor: pointer;
  overflow: hidden;
  transition: var(--transition);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.btn-neon:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(180,74,255,0.5), 0 0 50px rgba(0,212,255,0.3);
}
.btn-neon:active { transform: translateY(0) scale(0.97); }

.btn-neon.btn-secondary {
  background: transparent;
  border: 2px solid var(--neon-purple);
  color: var(--neon-purple);
}
.btn-neon.btn-secondary:hover {
  background: rgba(180,74,255,0.15);
}

.btn-neon.btn-accent {
  background: linear-gradient(135deg, var(--neon-green), var(--neon-cyan));
  color: #0a0a1a;
}

.btn-start {
  padding: 18px 50px;
  font-size: 1.1rem;
  animation: glow 2s ease-in-out infinite;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-back:hover { color: #fff; border-color: var(--neon-purple); }

.btn-text-only {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9rem;
  margin-top: 1rem;
  transition: var(--transition);
}
.btn-text-only:hover { color: var(--text-secondary); }

/* =====================================================
   ONBOARDING
   ===================================================== */
#onboarding-screen {
  align-items: center;
  justify-content: center;
}

.onboard-container {
  max-width: 620px;
  width: 92%;
  padding: 2.5rem;
  text-align: center;
}

.neon-text {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--neon-purple);
  text-shadow: 0 0 20px rgba(180,74,255,0.4);
  margin-bottom: 1.5rem;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}

.avatar-option {
  padding: 16px 8px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}
.avatar-option:hover { border-color: rgba(180,74,255,0.4); background: rgba(180,74,255,0.08); }
.avatar-option.selected {
  border-color: var(--neon-purple);
  background: rgba(180,74,255,0.15);
  box-shadow: 0 0 20px rgba(180,74,255,0.2);
}

.avatar-emoji { font-size: 2.5rem; display: block; margin-bottom: 4px; }
.avatar-name { font-size: 0.75rem; color: var(--text-secondary); }

/* Onboarding Steps */
.onboard-step { display: none; }
.onboard-step.active { display: block; animation: fadeIn 0.3s ease; }
.onboard-step-desc { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 1.2rem; line-height: 1.5; }
.onboard-btn-row { display: flex; gap: 12px; justify-content: center; margin-top: 0.5rem; }
.onboard-btn-row .btn-neon { flex: 1; max-width: 200px; }

/* Exam Grid */
.exam-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 1.5rem;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}
.exam-grid::-webkit-scrollbar { width: 4px; }
.exam-grid::-webkit-scrollbar-thumb { background: rgba(180,74,255,0.3); border-radius: 4px; }

.exam-option {
  padding: 14px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  position: relative;
}
.exam-option:hover {
  border-color: rgba(180,74,255,0.4);
  background: rgba(180,74,255,0.06);
}
.exam-option.selected {
  border-color: var(--neon-purple);
  background: rgba(180,74,255,0.12);
  box-shadow: 0 0 20px rgba(180,74,255,0.15);
}
.exam-icon { font-size: 1.5rem; display: block; margin-bottom: 6px; }
.exam-name {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  display: block;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.exam-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: block;
  line-height: 1.4;
}
.exam-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.55rem;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 4px;
}
.exam-badge.popular {
  background: rgba(180,74,255,0.25);
  color: var(--neon-purple);
  border: 1px solid rgba(180,74,255,0.4);
}

.name-input-wrap { margin: 1.5rem 0; text-align: left; }
.input-label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 6px; }

.neon-input {
  width: 100%;
  padding: 14px 18px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: #fff;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(180,74,255,0.3);
  border-radius: var(--radius-sm);
  outline: none;
  transition: var(--transition);
}
.neon-input:focus {
  border-color: var(--neon-purple);
  box-shadow: 0 0 15px rgba(180,74,255,0.3);
}
.neon-input::placeholder { color: var(--text-dim); }

/* =====================================================
   HUD BAR
   ===================================================== */
.hud-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(10,10,26,0.9);
  backdrop-filter: blur(15px);
  border-bottom: 1px solid rgba(180,74,255,0.2);
}

.hud-left { display: flex; align-items: center; gap: 12px; }
.hud-avatar {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  background: rgba(180,74,255,0.15);
  border: 2px solid var(--neon-purple);
  border-radius: 50%;
}
.hud-info { display: flex; flex-direction: column; gap: 2px; }
.hud-name { font-weight: 600; font-size: 0.9rem; }
.hud-level { display: flex; align-items: center; gap: 8px; }

.level-badge {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--neon-cyan);
  background: rgba(0,212,255,0.15);
  padding: 2px 10px;
  border-radius: 50px;
  letter-spacing: 1px;
}

.xp-bar-mini {
  width: 80px; height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.xp-fill-mini {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-purple), var(--neon-cyan));
  border-radius: 3px;
  transition: width 0.5s ease;
}
.xp-text-mini { font-size: 0.65rem; color: var(--text-dim); font-family: var(--font-mono); }

.hud-center { display: flex; align-items: center; }
.streak-display {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 14px;
  background: rgba(255,100,0,0.1);
  border: 1px solid rgba(255,100,0,0.3);
  border-radius: 50px;
}
.streak-fire { font-size: 1.2rem; }
.streak-count { font-family: var(--font-display); font-weight: 700; color: var(--neon-orange); }
.streak-label { font-size: 0.7rem; color: var(--text-dim); }

.hud-right { display: flex; gap: 8px; }
.hud-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
}
.hud-btn:hover { color: #fff; border-color: var(--neon-purple); }
.hud-btn span { font-family: var(--font-mono); font-size: 0.75rem; }

/* =====================================================
   TRAIL MAP
   ===================================================== */
.trail-container { padding: 1rem 1.5rem 4rem; max-width: 900px; margin: 0 auto; }

.trail-header { text-align: center; margin-bottom: 2rem; }
.trail-title {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 4vw, 2rem);
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-blue), var(--neon-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.trail-desc { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.5rem; }

/* Readiness Meter */
.readiness-meter {
  margin-top: 1.2rem;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 12px 24px;
  cursor: pointer;
  transition: var(--transition);
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}
.readiness-meter:hover {
  border-color: rgba(0,212,255,0.3);
  background: rgba(0,212,255,0.04);
  box-shadow: 0 0 20px rgba(0,212,255,0.08);
}
.readiness-ring-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}
.readiness-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.readiness-ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 5;
}
.readiness-ring-fill {
  fill: none;
  stroke: url(#readiness-gradient);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}
.readiness-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.readiness-pct {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0,212,255,0.4);
}
.readiness-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.readiness-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0,212,255,0.3);
}
.readiness-detail {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.readiness-bar {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 2px;
}
.readiness-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-purple), var(--neon-cyan), var(--neon-green));
  border-radius: 3px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(0,212,255,0.3);
}

.trail-map {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

/* Trail connector line */
.trail-map::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg,
    var(--neon-purple) 0%,
    var(--neon-blue) 25%,
    var(--neon-green) 50%,
    var(--neon-orange) 75%,
    var(--neon-pink) 100%
  );
  opacity: 0.3;
  transform: translateX(-50%);
}

.world-node {
  position: relative;
  display: flex;
  align-items: center;
  padding: 1rem 0;
  z-index: 2;
}
.world-node:nth-child(odd) { justify-content: flex-start; }
.world-node:nth-child(even) { justify-content: flex-end; }

.world-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 380px;
  max-width: 85%;
  padding: 18px 22px;
  background: var(--bg-glass);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.world-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--world-color, var(--neon-purple));
  opacity: 0.8;
}
.world-card:hover {
  transform: translateY(-3px);
  border-color: var(--world-color, var(--neon-purple));
  box-shadow: 0 8px 30px rgba(0,0,0,0.3), 0 0 20px color-mix(in srgb, var(--world-color, var(--neon-purple)) 30%, transparent);
}
.world-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.5);
}
.world-card.locked:hover { transform: none; border-color: rgba(255,255,255,0.08); box-shadow: none; }
.world-card.completed { border-color: var(--neon-green); }
.world-card.completed::before { background: var(--neon-green); }

.world-card-icon {
  font-size: 2.2rem;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.world-card-info { flex: 1; min-width: 0; }
.world-card-num {
  font-family: var(--font-display);
  font-size: 0.6rem;
  color: var(--world-color, var(--text-dim));
  letter-spacing: 2px;
  text-transform: uppercase;
}
.world-card-name {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.world-card-sub { font-size: 0.75rem; color: var(--text-dim); }

.world-card-status {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.world-card-pct {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
}
.world-card-bar {
  width: 40px; height: 5px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.world-card-bar-fill {
  height: 100%;
  background: var(--world-color, var(--neon-purple));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.world-lock-icon {
  font-size: 1.2rem;
  opacity: 0.5;
}

/* Side quest nodes on trail */
.trail-sidequest {
  text-align: center;
  padding: 0.5rem 0;
  z-index: 2;
  position: relative;
}
.trail-sq-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: 0.8rem;
  color: var(--neon-yellow);
  background: rgba(255,230,0,0.08);
  border: 1px dashed rgba(255,230,0,0.3);
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
}
.trail-sq-btn:hover {
  background: rgba(255,230,0,0.15);
  border-color: var(--neon-yellow);
}

/* =====================================================
   WORLD DETAIL
   ===================================================== */
.world-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.world-title-wrap { display: flex; align-items: center; gap: 10px; flex: 1; }
.world-icon { font-size: 2rem; }
.world-title { font-family: var(--font-display); font-size: 1.3rem; }
.world-progress-wrap { display: flex; align-items: center; gap: 10px; }
.world-progress-bar {
  width: 120px; height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}
.world-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-purple), var(--neon-cyan));
  border-radius: 4px;
  transition: width 0.5s ease;
}
.world-progress-text { font-family: var(--font-mono); font-size: 0.85rem; color: var(--neon-cyan); }

.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  padding: 2rem;
  max-width: 1000px;
  margin: 0 auto;
}

.level-card {
  padding: 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.level-card:hover {
  border-color: var(--neon-purple);
  transform: translateY(-3px);
  box-shadow: var(--shadow-neon);
}
.level-card.locked { opacity: 0.35; cursor: not-allowed; }
.level-card.locked:hover { transform: none; border-color: rgba(255,255,255,0.08); box-shadow: none; }
.level-card.completed { border-color: var(--neon-green); }

.level-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.level-num {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--text-dim);
}
.level-status-icon { font-size: 1.2rem; }

.level-name { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.level-desc { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 12px; }

.level-bar {
  width: 100%; height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}
.level-bar-fill {
  height: 100%;
  background: var(--neon-purple);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.level-meta { display: flex; gap: 12px; margin-top: 8px; }
.level-meta span {
  font-size: 0.7rem;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 3px;
}

/* =====================================================
   LESSON
   ===================================================== */
.lesson-header {
  padding: 1rem 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.lesson-title { font-family: var(--font-display); font-size: 1.1rem; flex: 1; }
.lesson-progress { display: flex; align-items: center; gap: 8px; }
#lesson-step-text { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-dim); }
.lesson-progress-bar {
  width: 100px; height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.lesson-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-purple), var(--neon-cyan));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.lesson-content {
  max-width: 750px;
  margin: 0 auto;
  padding: 2rem;
  animation: slideUp 0.3s ease;
}

.lesson-step {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 2rem;
}

.lesson-step h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--neon-cyan);
  margin-bottom: 1rem;
}

.lesson-step p {
  margin-bottom: 1rem;
  line-height: 1.7;
}

.lesson-step .highlight {
  color: var(--neon-yellow);
  font-weight: 600;
}

.lesson-step .formula {
  display: block;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--neon-green);
  background: rgba(57,255,20,0.08);
  border: 1px solid rgba(57,255,20,0.2);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 1rem 0;
  letter-spacing: 1px;
}

.lesson-step .example-box {
  background: rgba(0,212,255,0.08);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 1rem 0;
}
.lesson-step .example-box .example-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: var(--neon-blue);
  margin-bottom: 8px;
}

.lesson-step .tip-box {
  background: rgba(255,230,0,0.08);
  border: 1px solid rgba(255,230,0,0.2);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 1rem 0;
}
.lesson-step .tip-box::before {
  content: '💡 PRO TIP';
  display: block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: var(--neon-yellow);
  margin-bottom: 6px;
}

.lesson-step .warning-box {
  background: rgba(255,56,96,0.08);
  border: 1px solid rgba(255,56,96,0.2);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 1rem 0;
}
.lesson-step .warning-box::before {
  content: '⚠️ WATCH OUT';
  display: block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: var(--neon-red);
  margin-bottom: 6px;
}

/* Interactive try-it section */
.try-it {
  background: rgba(180,74,255,0.08);
  border: 1px solid rgba(180,74,255,0.25);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin: 1.5rem 0;
}
.try-it-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: var(--neon-purple);
  margin-bottom: 10px;
}
.try-it-question { font-weight: 600; margin-bottom: 12px; }
.try-it-input-wrap { display: flex; gap: 10px; }
.try-it-input {
  flex: 1;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: #fff;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(180,74,255,0.3);
  border-radius: var(--radius-xs);
  outline: none;
  transition: var(--transition);
}
.try-it-input:focus { border-color: var(--neon-purple); }
.try-it-check {
  padding: 10px 20px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: #fff;
  background: var(--neon-purple);
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition);
}
.try-it-check:hover { background: #c76aff; }
.try-it-feedback {
  margin-top: 10px;
  font-size: 0.9rem;
  padding: 10px;
  border-radius: var(--radius-xs);
  display: none;
}
.try-it-feedback.correct {
  display: block;
  color: var(--neon-green);
  background: rgba(57,255,20,0.1);
}
.try-it-feedback.incorrect {
  display: block;
  color: var(--neon-red);
  background: rgba(255,56,96,0.1);
}

/* Visual / graph area in lessons */
.visual-area {
  width: 100%;
  min-height: 200px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  margin: 1rem 0;
  position: relative;
  overflow: hidden;
}
.visual-area canvas {
  width: 100%;
  height: 100%;
}

/* Steps list */
.steps-list {
  list-style: none;
  counter-reset: step;
}
.steps-list li {
  counter-increment: step;
  padding: 10px 0 10px 40px;
  position: relative;
  border-left: 2px solid rgba(180,74,255,0.3);
  margin-left: 12px;
}
.steps-list li::before {
  content: counter(step);
  position: absolute;
  left: -13px;
  width: 24px; height: 24px;
  background: var(--neon-purple);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.steps-list li:last-child { border-left-color: transparent; }

.lesson-nav {
  display: flex;
  justify-content: space-between;
  padding: 1rem 2rem 2rem;
  max-width: 750px;
  margin: 0 auto;
}

/* =====================================================
   QUIZ
   ===================================================== */
.quiz-header {
  padding: 1rem 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.quiz-info { display: flex; align-items: center; gap: 1rem; flex: 1; }
.quiz-topic { font-family: var(--font-display); font-size: 0.9rem; color: var(--neon-cyan); }
.quiz-timer {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 12px;
  background: rgba(255,56,96,0.1);
  border: 1px solid rgba(255,56,96,0.3);
  border-radius: 50px;
}
.timer-icon { font-size: 0.9rem; }
#timer-text { font-family: var(--font-mono); font-size: 0.85rem; color: var(--neon-red); }
.quiz-progress { display: flex; align-items: center; gap: 8px; }
#quiz-q-count { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-dim); }
.quiz-dots { display: flex; gap: 6px; }
.quiz-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transition: var(--transition);
}
.quiz-dot.current { background: var(--neon-purple); box-shadow: 0 0 8px var(--neon-purple); }
.quiz-dot.correct { background: var(--neon-green); }
.quiz-dot.wrong { background: var(--neon-red); }

.quiz-body {
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem;
}

.quiz-question-card {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 2rem;
  animation: slideUp 0.3s ease;
}

.quiz-q-text {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}
.quiz-q-text .mono {
  font-family: var(--font-mono);
  color: var(--neon-green);
}

.quiz-options { display: flex; flex-direction: column; gap: 10px; }

.quiz-option {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: rgba(255,255,255,0.03);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
}
.quiz-option:hover { border-color: rgba(180,74,255,0.4); background: rgba(180,74,255,0.08); }
.quiz-option.selected { border-color: var(--neon-purple); background: rgba(180,74,255,0.15); }
.quiz-option.correct-reveal {
  border-color: var(--neon-green) !important;
  background: rgba(57,255,20,0.12) !important;
}
.quiz-option.wrong-reveal {
  border-color: var(--neon-red) !important;
  background: rgba(255,56,96,0.12) !important;
}
.quiz-option.disabled { pointer-events: none; }

.quiz-option-letter {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  flex-shrink: 0;
}
.quiz-option.selected .quiz-option-letter { background: var(--neon-purple); color: #fff; }
.quiz-option.correct-reveal .quiz-option-letter { background: var(--neon-green); color: #000; }
.quiz-option.wrong-reveal .quiz-option-letter { background: var(--neon-red); color: #fff; }

.quiz-option-text { flex: 1; }

/* Free response quiz input */
.quiz-input-wrap {
  display: flex;
  gap: 10px;
  margin-top: 1rem;
}
.quiz-input {
  flex: 1;
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: #fff;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(180,74,255,0.3);
  border-radius: var(--radius-sm);
  outline: none;
  transition: var(--transition);
}
.quiz-input:focus { border-color: var(--neon-purple); box-shadow: 0 0 15px rgba(180,74,255,0.2); }

.quiz-submit-row {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.quiz-explanation {
  margin-top: 1rem;
  padding: 14px;
  background: rgba(0,212,255,0.08);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-secondary);
  animation: fadeIn 0.3s ease;
}
.quiz-explanation strong { color: var(--neon-cyan); }

/* =====================================================
   RESULTS
   ===================================================== */
#results-screen {
  align-items: center;
  justify-content: center;
}

.results-container {
  max-width: 480px;
  width: 90%;
  padding: 2.5rem;
  text-align: center;
}

.results-icon { font-size: 3.5rem; margin-bottom: 0.5rem; animation: float 2s ease-in-out infinite; }
.results-title { font-family: var(--font-display); font-size: 1.4rem; margin-bottom: 1.5rem; }

.results-score { margin: 1.5rem 0; }
.score-circle {
  width: 120px; height: 120px;
  margin: 0 auto;
  position: relative;
}
.score-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-bg { fill: none; stroke: rgba(255,255,255,0.1); stroke-width: 8; }
.score-ring {
  fill: none;
  stroke: var(--neon-green);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 1.5s ease;
}
.score-pct {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
}

.results-stats { display: flex; justify-content: center; gap: 2rem; margin: 1.5rem 0; }
.stat-item { text-align: center; }
.stat-val { display: block; font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; }
.stat-label { font-size: 0.75rem; color: var(--text-dim); }

.results-message {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 1rem 0;
  font-style: italic;
}

.results-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 1.5rem; }

/* =====================================================
   REVIEW
   ===================================================== */
.review-header {
  padding: 1rem 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 1rem;
}
.review-header h2 { font-family: var(--font-display); font-size: 1.1rem; }

.review-body {
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem;
  display: flex; flex-direction: column; gap: 1rem;
}

.review-item {
  padding: 18px;
  background: var(--bg-glass);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
}
.review-item.correct { border-left: 4px solid var(--neon-green); }
.review-item.wrong { border-left: 4px solid var(--neon-red); }
.review-q { font-weight: 600; margin-bottom: 8px; }
.review-your { font-size: 0.9rem; color: var(--text-secondary); }
.review-correct { font-size: 0.9rem; color: var(--neon-green); }
.review-explanation { font-size: 0.85rem; color: var(--text-dim); margin-top: 8px; }

/* =====================================================
   MEDALS
   ===================================================== */
.medals-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 1rem;
}
.medals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
}
.medal-card {
  text-align: center;
  padding: 20px 12px;
  background: var(--bg-glass);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  transition: var(--transition);
}
.medal-card.earned {
  border-color: var(--neon-yellow);
  background: rgba(255,230,0,0.05);
}
.medal-card.unearned { opacity: 0.35; filter: grayscale(1); }
.medal-card-icon { font-size: 2.5rem; margin-bottom: 6px; }
.medal-card-name { font-weight: 700; font-size: 0.85rem; margin-bottom: 2px; }
.medal-card-desc { font-size: 0.7rem; color: var(--text-dim); }

/* =====================================================
   SIDE QUESTS
   ===================================================== */
.sq-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sq-header .btn-back { margin-bottom: 0.5rem; }
.sq-desc { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.5rem; }

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

.sq-card {
  padding: 20px;
  background: var(--bg-glass);
  border: 1px dashed rgba(255,230,0,0.25);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}
.sq-card:hover {
  border-color: var(--neon-yellow);
  box-shadow: 0 0 20px rgba(255,230,0,0.15);
  transform: translateY(-2px);
}
.sq-card.completed {
  border-style: solid;
  border-color: var(--neon-green);
  opacity: 0.7;
}
.sq-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.sq-card-icon { font-size: 1.5rem; }
.sq-card-reward {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--neon-yellow);
  background: rgba(255,230,0,0.1);
  padding: 2px 8px;
  border-radius: 50px;
}
.sq-card-name { font-weight: 700; margin-bottom: 4px; }
.sq-card-desc { font-size: 0.8rem; color: var(--text-secondary); }

/* Side quest active */
.sq-active-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sq-active-title { font-family: var(--font-display); font-size: 1.2rem; margin-top: 0.5rem; }
.sq-active-body { max-width: 700px; margin: 0 auto; padding: 2rem; }

/* =====================================================
   PROFILE
   ===================================================== */
.profile-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.profile-body {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem;
}

.profile-card {
  text-align: center;
  padding: 2rem;
  background: var(--bg-glass);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}
.profile-avatar { font-size: 4rem; margin-bottom: 0.5rem; }
.profile-name { font-family: var(--font-display); font-size: 1.3rem; }
.profile-exam-badge {
  display: inline-block;
  margin: 0.4rem 0;
  padding: 4px 14px;
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--neon-purple);
  background: rgba(180,74,255,0.12);
  border: 1px solid rgba(180,74,255,0.3);
  border-radius: 20px;
}
.profile-level { color: var(--neon-cyan); font-family: var(--font-display); font-size: 0.85rem; margin: 0.5rem 0; }

.profile-xp-bar {
  width: 100%; height: 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  overflow: hidden;
  margin: 1rem 0 0.5rem;
}
.profile-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-purple), var(--neon-cyan));
  border-radius: 6px;
  transition: width 0.5s ease;
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1.5rem;
}
.profile-stat {
  padding: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  text-align: center;
}
.profile-stat-val { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }
.profile-stat-label { font-size: 0.75rem; color: var(--text-dim); }

.profile-reset {
  margin-top: 2rem;
  text-align: center;
}
.btn-danger {
  padding: 10px 24px;
  font-size: 0.85rem;
  color: var(--neon-red);
  background: rgba(255,56,96,0.1);
  border: 1px solid rgba(255,56,96,0.3);
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
}
.btn-danger:hover { background: rgba(255,56,96,0.2); }

/* =====================================================
   TOAST
   ===================================================== */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  backdrop-filter: blur(10px);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  max-width: 320px;
}
.toast.success { border-color: var(--neon-green); }
.toast.xp { border-color: var(--neon-cyan); color: var(--neon-cyan); }
.toast.medal { border-color: var(--neon-yellow); }
.toast.error { border-color: var(--neon-red); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateX(40px); }
}

/* =====================================================
   MODALS
   ===================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal-content {
  max-width: 440px;
  width: 90%;
  padding: 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  text-align: center;
  animation: slideUp 0.4s ease;
}

/* Level up */
.levelup-content { position: relative; overflow: hidden; }
.levelup-glow {
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(180,74,255,0.2) 0%, transparent 60%);
  animation: rotateHue 3s linear infinite;
}
.levelup-icon { font-size: 3rem; position: relative; animation: float 1.5s ease-in-out infinite; }
.levelup-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
}
.levelup-level {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--neon-yellow);
  margin: 0.5rem 0;
  position: relative;
}
.levelup-message { color: var(--text-secondary); margin-bottom: 1.5rem; position: relative; }

/* Medal earned */
.medal-earn-content { position: relative; }
.medal-sparkle { font-size: 2rem; animation: pulse 1s ease-in-out infinite; }
.medal-earned-icon { font-size: 3rem; margin: 0.5rem 0; }
.medal-earned-name { font-family: var(--font-display); font-size: 1rem; color: var(--neon-yellow); margin: 0.5rem 0; }
.medal-earned-desc { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1.5rem; }

/* Choice modal */
.choice-content { max-width: 500px; }
.choice-title { font-family: var(--font-display); font-size: 1.2rem; margin-bottom: 0.5rem; }
.choice-desc { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1.5rem; }
.choice-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  background: rgba(255,255,255,0.03);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-primary);
  font-family: var(--font-body);
}
.choice-card:hover {
  border-color: var(--neon-purple);
  background: rgba(180,74,255,0.1);
  transform: translateY(-3px);
}
.choice-icon { font-size: 2.5rem; }
.choice-label { font-family: var(--font-display); font-size: 0.9rem; font-weight: 700; }
.choice-sublabel { font-size: 0.75rem; color: var(--text-dim); text-align: center; }

/* =====================================================
   GRAPH / VISUAL COMPONENTS
   ===================================================== */
.graph-container {
  width: 100%;
  aspect-ratio: 1;
  max-width: 360px;
  margin: 1rem auto;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  position: relative;
}
.graph-container canvas {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
}

.number-line {
  width: 100%;
  height: 60px;
  margin: 1rem 0;
  position: relative;
  background: rgba(0,0,0,0.3);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =====================================================
   INTERACTIVE WIDGETS
   ===================================================== */
.widget-container {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-glass);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(180,74,255,0.2);
  border-radius: var(--radius);
}

.widget-canvas-wrap {
  width: 100%;
  aspect-ratio: 4/3;
  max-width: 500px;
  margin: 0 auto 1rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}
.widget-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}
.widget-canvas-wrap.square { aspect-ratio: 1; }

.widget-slider-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 1rem 0;
}
.widget-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.widget-slider-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--neon-cyan);
  min-width: 40px;
  text-align: right;
}
.widget-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  outline: none;
}
.widget-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  background: var(--neon-purple);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 0 10px rgba(180,74,255,0.5);
}
.widget-slider::-moz-range-thumb {
  width: 20px; height: 20px;
  background: var(--neon-purple);
  border: none;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 0 10px rgba(180,74,255,0.5);
}
.widget-slider-val {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--neon-green);
  min-width: 45px;
  text-align: left;
}

.widget-value-display {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  color: var(--neon-green);
  padding: 10px;
  margin: 0.5rem 0;
  background: rgba(57,255,20,0.08);
  border: 1px solid rgba(57,255,20,0.2);
  border-radius: var(--radius-xs);
  letter-spacing: 1px;
}

.widget-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 1rem 0;
}
.widget-btn {
  padding: 8px 18px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition);
}
.widget-btn:hover {
  border-color: var(--neon-purple);
  background: rgba(180,74,255,0.15);
}
.widget-btn.active {
  border-color: var(--neon-green);
  background: rgba(57,255,20,0.15);
  color: var(--neon-green);
}

.widget-challenge {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: rgba(180,74,255,0.08);
  border: 1px solid rgba(180,74,255,0.25);
  border-radius: var(--radius-sm);
}
.widget-challenge-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: var(--neon-purple);
  margin-bottom: 8px;
}
.widget-challenge-prompt {
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.6;
}
.widget-challenge-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.widget-challenge-check {
  padding: 10px 24px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: #fff;
  background: var(--neon-purple);
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition);
}
.widget-challenge-check:hover { background: #c76aff; }
.widget-challenge-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  cursor: pointer;
  background: none;
  border: none;
  transition: var(--transition);
}
.widget-challenge-hint:hover { color: var(--text-secondary); }
.widget-challenge-feedback {
  margin-top: 10px;
  font-size: 0.9rem;
  padding: 10px;
  border-radius: var(--radius-xs);
  display: none;
}
.widget-challenge-feedback.correct {
  display: block;
  color: var(--neon-green);
  background: rgba(57,255,20,0.1);
}
.widget-challenge-feedback.incorrect {
  display: block;
  color: var(--neon-red);
  background: rgba(255,56,96,0.1);
}

/* Equation balance */
.eq-balance {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  flex-wrap: wrap;
}
.eq-side {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.eq-term {
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}
.eq-term.variable {
  background: rgba(180,74,255,0.2);
  color: var(--neon-purple);
  border: 1px solid rgba(180,74,255,0.3);
}
.eq-term.constant {
  background: rgba(0,212,255,0.15);
  color: var(--neon-blue);
  border: 1px solid rgba(0,212,255,0.25);
}
.eq-equals { font-size: 1.5rem; color: var(--neon-yellow); }

/* Stat cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 1rem 0;
}
.stat-card {
  padding: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-xs);
  text-align: center;
}
.stat-card-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.stat-card-val {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--neon-cyan);
}

/* Data input list */
.widget-data-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 1rem 0;
  align-items: center;
}
.widget-data-item {
  width: 48px;
  padding: 8px 4px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: #fff;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(0,255,247,0.3);
  border-radius: var(--radius-xs);
  outline: none;
  transition: var(--transition);
}
.widget-data-item:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 8px rgba(0,255,247,0.3);
}

/* Logic cards */
.logic-card {
  padding: 14px;
  margin: 8px 0;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  line-height: 1.5;
  cursor: pointer;
  transition: var(--transition);
}
.logic-card.hypothesis {
  background: rgba(180,74,255,0.12);
  border: 1px solid rgba(180,74,255,0.3);
}
.logic-card.conclusion {
  background: rgba(0,212,255,0.12);
  border: 1px solid rgba(0,212,255,0.3);
}
.logic-card.selected {
  border-color: var(--neon-green);
  background: rgba(57,255,20,0.1);
}

/* Widget readout strip */
.widget-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 0.75rem 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.widget-readout span {
  padding: 4px 10px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
}
.widget-readout .val { color: var(--neon-green); font-weight: 600; }

/* Readout used as text block (not flex) */
.widget-readout p {
  margin: 0.4rem 0;
  color: var(--text-secondary);
  line-height: 1.5;
}
.widget-readout small {
  color: var(--text-muted);
}

/* Proportion solver fraction display */
.widget-value-display span[style*="border-bottom"] {
  display: inline-block;
}

/* Data table in lessons */
.data-table {
  border-collapse: collapse;
  margin: 0.5rem auto;
}
.data-table td, .data-table th {
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,0.1);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.data-table tr:first-child td {
  background: rgba(0,230,118,0.06);
  font-weight: 600;
}

/* =====================================================
   YODA CHAT TUTOR
   ===================================================== */
.yoda-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 1rem;
  padding: 8px 16px;
  background: rgba(138,43,226,0.15);
  border: 1px solid rgba(138,43,226,0.4);
  border-radius: var(--radius-sm);
  color: #c084fc;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.yoda-btn:hover {
  background: rgba(138,43,226,0.3);
  border-color: #c084fc;
  transform: translateY(-1px);
}
.yoda-btn .yoda-btn-icon {
  font-size: 1.1em;
}

.yoda-chat-panel {
  width: 95%;
  max-width: 440px;
  max-height: 85vh;
  background: var(--bg-panel);
  border: 1px solid rgba(138,43,226,0.4);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(138,43,226,0.2), 0 20px 60px rgba(0,0,0,0.5);
  animation: modalIn 0.3s ease;
}

.yoda-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(138,43,226,0.1);
  border-bottom: 1px solid rgba(138,43,226,0.2);
}
.yoda-avatar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.yoda-avatar {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 6px rgba(138,43,226,0.6));
}
.yoda-name {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: #c084fc;
  letter-spacing: 0.5px;
}
.yoda-status {
  font-size: 0.7rem;
  color: var(--neon-green);
  background: rgba(0,230,118,0.1);
  padding: 2px 8px;
  border-radius: 10px;
}
.yoda-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: all 0.2s;
}
.yoda-close:hover {
  color: #f87171;
  background: rgba(248,113,113,0.1);
}

.yoda-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 50vh;
}

.yoda-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  animation: msgSlide 0.3s ease;
}
@keyframes msgSlide {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.yoda-msg.yoda {
  align-self: flex-start;
  background: rgba(138,43,226,0.15);
  border: 1px solid rgba(138,43,226,0.25);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
}
.yoda-msg.user {
  align-self: flex-end;
  background: rgba(0,230,118,0.12);
  border: 1px solid rgba(0,230,118,0.2);
  border-bottom-right-radius: 4px;
  color: var(--neon-green);
  font-weight: 500;
}

.yoda-typing {
  align-self: flex-start;
  padding: 12px 18px;
  background: rgba(138,43,226,0.1);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
  animation: msgSlide 0.3s ease;
}
.yoda-typing-dot {
  width: 7px;
  height: 7px;
  background: #c084fc;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}
.yoda-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.yoda-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.yoda-choices {
  padding: 12px 18px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.yoda-choice-btn {
  flex: 1;
  min-width: 120px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.yoda-choice-btn:hover {
  background: rgba(138,43,226,0.2);
  border-color: #c084fc;
  color: #c084fc;
}
.yoda-choice-btn.primary {
  background: rgba(0,230,118,0.1);
  border-color: rgba(0,230,118,0.3);
  color: var(--neon-green);
}
.yoda-choice-btn.primary:hover {
  background: rgba(0,230,118,0.2);
  border-color: var(--neon-green);
}

.yoda-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.15);
}
.yoda-text-input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(138,43,226,0.25);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}
.yoda-text-input:focus {
  border-color: #c084fc;
  background: rgba(138,43,226,0.06);
}
.yoda-text-input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}
.yoda-send-btn {
  width: 42px;
  height: 42px;
  background: rgba(138,43,226,0.3);
  border: 1px solid rgba(138,43,226,0.4);
  border-radius: var(--radius-sm);
  color: #c084fc;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.yoda-send-btn:hover {
  background: rgba(138,43,226,0.5);
  color: #e9d5ff;
  transform: scale(1.05);
}
.yoda-input-area.disabled .yoda-text-input,
.yoda-input-area.disabled .yoda-send-btn {
  opacity: 0.4;
  pointer-events: none;
}

/* =====================================================
   SKILL BADGE CATALOG
   ===================================================== */

/* ---------- Catalog Animations ---------- */
@keyframes shineGold {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes badgeEarned {
  0% { transform: scale(0.5) rotate(-10deg); opacity: 0; }
  50% { transform: scale(1.15) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes realmBarFill {
  from { width: 0; }
}

@keyframes sealPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(255,215,0,0.3), 0 0 60px rgba(255,215,0,0.15); }
  50% { box-shadow: 0 0 40px rgba(255,215,0,0.5), 0 0 100px rgba(255,215,0,0.25); }
}

@keyframes catalogPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(0,212,255,0.2); }
  50% { box-shadow: 0 0 14px rgba(0,212,255,0.4); }
}

/* ---------- Catalog Screen Layout ---------- */
.catalog-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.catalog-header .btn-back { flex-shrink: 0; }

.catalog-title {
  font-family: var(--font-display);
  font-size: clamp(1rem, 3vw, 1.3rem);
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  flex: 1;
}

/* ---------- Catalog Summary Bar ---------- */
.catalog-summary {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1rem 2rem;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.catalog-summary-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.catalog-summary-stat .val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--neon-cyan);
}

.catalog-summary-stat .label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.catalog-completion-bar {
  width: 120px;
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
}

.catalog-completion-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-purple), var(--neon-green));
  border-radius: 4px;
  transition: width 0.6s ease;
  animation: realmBarFill 0.8s ease;
}

.catalog-tier-breakdown {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.catalog-tier-breakdown .tier-count {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 50px;
}

.catalog-tier-breakdown .tier-count.bronze { color: #cd7f32; }
.catalog-tier-breakdown .tier-count.silver { color: #c0c0c0; }
.catalog-tier-breakdown .tier-count.gold { color: #ffd700; }

/* ---------- Catalog Body ---------- */
.catalog-body {
  padding: 2rem;
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ---------- IM2 READY Seal ---------- */
.catalog-seal {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem;
  text-align: center;
}

.catalog-seal.active {
  display: flex;
  animation: badgeEarned 0.6s ease;
}

.catalog-seal-icon {
  font-size: 4rem;
  filter: drop-shadow(0 0 20px rgba(255,215,0,0.5));
  animation: float 2.5s ease-in-out infinite;
}

.catalog-seal-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #ffd700, #ffec80, #ffd700);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shineGold 3s linear infinite;
}

.catalog-seal-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.catalog-seal-glow {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,215,0,0.06);
  border: 2px solid rgba(255,215,0,0.3);
  animation: sealPulse 2s ease-in-out infinite;
}

/* ---------- Tier Legend ---------- */
.catalog-tier-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 0.5rem 0;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.catalog-tier-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.catalog-tier-legend .star-bronze { color: #cd7f32; }
.catalog-tier-legend .star-silver { color: #c0c0c0; }
.catalog-tier-legend .star-gold { color: #ffd700; }

/* ---------- Realm Cards ---------- */
.catalog-realm {
  background: var(--bg-glass);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}

.catalog-realm:hover {
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

.catalog-realm-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  position: relative;
}

.catalog-realm-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--realm-color, var(--neon-purple));
  opacity: 0.8;
}

.catalog-realm-icon {
  font-size: 1.6rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.catalog-realm-info {
  flex: 1;
  min-width: 0;
}

.catalog-realm-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--realm-color, var(--text-primary));
}

.catalog-realm-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.catalog-realm-bar {
  flex: 1;
  max-width: 120px;
  height: 5px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.catalog-realm-bar-fill {
  height: 100%;
  background: var(--realm-color, var(--neon-purple));
  border-radius: 3px;
  transition: width 0.6s ease;
  animation: realmBarFill 0.8s ease;
}

.catalog-realm-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ---------- Badges Grid within Realm ---------- */
.catalog-realm-badges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  padding: 1.25rem 1.5rem;
}

/* ---------- Badge Cards ---------- */
.badge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 12px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  text-align: center;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

/* Badge Card — Locked State */
.badge-card.badge-locked {
  opacity: 0.45;
  filter: grayscale(0.8);
  cursor: default;
}

.badge-card.badge-locked .badge-card-icon {
  position: relative;
}

.badge-card.badge-locked .badge-card-icon::after {
  content: '🔒';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.2rem;
  opacity: 0.7;
}

.badge-card.badge-locked .badge-card-status {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* Badge Card — Earned State */
.badge-card.badge-earned {
  background: rgba(255,255,255,0.05);
  border-color: var(--realm-color, var(--neon-purple));
  box-shadow: 0 0 12px color-mix(in srgb, var(--realm-color, var(--neon-purple)) 30%, transparent);
  animation: badgeEarned 0.5s ease;
}

.badge-card.badge-earned:hover {
  transform: translateY(-3px);
  box-shadow: 0 0 20px color-mix(in srgb, var(--realm-color, var(--neon-purple)) 40%, transparent);
}

.badge-card.badge-earned .badge-card-status {
  color: var(--neon-green);
  font-size: 1rem;
}

/* Badge Card — Tier Indicators */
.badge-card.badge-tier-1 {
  border-color: rgba(205,127,50,0.4);
  box-shadow: 0 0 10px rgba(205,127,50,0.15);
}
.badge-card.badge-tier-1.badge-earned {
  border-color: #cd7f32;
  box-shadow: 0 0 14px rgba(205,127,50,0.3);
}

.badge-card.badge-tier-2 {
  border-color: rgba(192,192,192,0.4);
  box-shadow: 0 0 10px rgba(192,192,192,0.15);
}
.badge-card.badge-tier-2.badge-earned {
  border-color: #c0c0c0;
  box-shadow: 0 0 14px rgba(192,192,192,0.3);
}

.badge-card.badge-tier-3 {
  border-color: rgba(255,215,0,0.4);
  box-shadow: 0 0 10px rgba(255,215,0,0.15);
}
.badge-card.badge-tier-3.badge-earned {
  border-color: #ffd700;
  box-shadow: 0 0 18px rgba(255,215,0,0.35);
  position: relative;
}
.badge-card.badge-tier-3.badge-earned::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255,215,0,0.08) 45%,
    rgba(255,215,0,0.15) 50%,
    rgba(255,215,0,0.08) 55%,
    transparent 60%
  );
  background-size: 200% 100%;
  animation: shineGold 3s linear infinite;
  pointer-events: none;
  border-radius: var(--radius-sm);
}

/* Badge Card Internal Layout */
.badge-card-icon {
  font-size: 2.5rem;
  line-height: 1;
  position: relative;
}

.badge-card-tier {
  font-size: 0.7rem;
  letter-spacing: 1px;
  line-height: 1;
}

.badge-card-tier.bronze { color: #cd7f32; }
.badge-card-tier.silver { color: #c0c0c0; }
.badge-card-tier.gold { color: #ffd700; text-shadow: 0 0 6px rgba(255,215,0,0.4); }

.badge-card-name {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-primary);
  line-height: 1.3;
}

.badge-card-desc {
  font-size: 0.65rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.badge-card-status {
  font-size: 0.75rem;
  margin-top: 2px;
}

/* ---------- HUD Catalog Button ---------- */
.hud-btn-catalog {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
}

.hud-btn-catalog:hover {
  color: #fff;
  border-color: var(--neon-cyan);
}

.hud-btn-catalog.has-new {
  animation: catalogPulse 2s ease-in-out infinite;
  border-color: rgba(0,212,255,0.3);
}

.catalog-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--neon-cyan);
}

/* =====================================================
   BOSS BATTLE ARENA
   ===================================================== */
.boss-arena {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  background: radial-gradient(ellipse at center, rgba(255,0,50,0.08) 0%, transparent 70%);
}

.boss-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  gap: 1rem;
}

.boss-entity {
  text-align: center;
  flex: 1;
  max-width: 200px;
}

.boss-villain-icon, .boss-player-icon {
  font-size: 3.5rem;
}

.boss-villain-icon {
  filter: drop-shadow(0 0 15px rgba(255,0,50,0.6));
  animation: bossFloat 2s ease-in-out infinite;
}

.boss-player-icon {
  filter: drop-shadow(0 0 15px rgba(0,212,255,0.6));
}

.boss-vs {
  font-size: 2rem;
  color: var(--neon-yellow);
  text-shadow: 0 0 20px rgba(255,224,58,0.5);
  animation: vsPulse 1.5s ease-in-out infinite;
}

.boss-hp-bar {
  width: 100%;
  height: 10px;
  background: rgba(255,255,255,0.1);
  border-radius: 5px;
  overflow: hidden;
  margin-top: 8px;
}

.boss-hp-bar.villain-hp .boss-hp-fill {
  background: linear-gradient(90deg, #ff0032, #ff6b35);
}

.boss-hp-bar.player-hp .boss-hp-fill {
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-green));
}

.boss-hp-fill {
  height: 100%;
  width: 100%;
  transition: width 0.5s ease;
  border-radius: 5px;
}

.boss-hp-text {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.boss-villain-name, .boss-player-name {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 4px;
}

.boss-villain-name { color: #ff0032; text-shadow: 0 0 10px rgba(255,0,50,0.4); }
.boss-player-name { color: var(--neon-cyan); }

.boss-narrative {
  text-align: center;
  padding: 1rem 2rem;
  min-height: 60px;
  color: var(--neon-yellow);
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-shadow: 0 0 10px rgba(255,224,58,0.3);
}

.boss-question-area {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
}

.boss-q-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,0,50,0.15);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.boss-q-text {
  font-size: 1rem;
  margin-bottom: 1.2rem;
  line-height: 1.6;
}

.boss-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.boss-opt {
  padding: 12px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.boss-opt:hover { border-color: var(--neon-cyan); background: rgba(0,212,255,0.06); }
.boss-opt.correct { border-color: var(--neon-green); background: rgba(57,255,20,0.12); }
.boss-opt.wrong { border-color: #ff0032; background: rgba(255,0,50,0.12); }

.boss-fr-wrap {
  display: flex;
  gap: 10px;
}
.boss-fr-input {
  flex: 1;
  padding: 12px 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 1rem;
}
.boss-fr-submit {
  padding: 12px 24px;
  background: rgba(255,0,50,0.2);
  border: 1px solid rgba(255,0,50,0.4);
  color: #fff;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}
.boss-fr-submit:hover { background: rgba(255,0,50,0.3); }

@keyframes bossFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes vsPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.8; }
}
@keyframes bossHit {
  0% { transform: translateX(0); }
  20% { transform: translateX(-15px); filter: brightness(2); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-5px); }
  100% { transform: translateX(0); }
}
@keyframes playerHit {
  0% { transform: translateX(0); }
  20% { transform: translateX(15px); filter: brightness(0.5); }
  40% { transform: translateX(-10px); }
  60% { transform: translateX(5px); }
  100% { transform: translateX(0); }
}
@keyframes bossDeath {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); filter: brightness(3); }
  100% { transform: scale(0); opacity: 0; filter: brightness(5); }
}

.boss-villain-icon.hit { animation: bossHit 0.5s ease; }
.boss-player-icon.hit { animation: playerHit 0.5s ease; }
.boss-villain-icon.defeated { animation: bossDeath 0.8s ease forwards; }

/* =====================================================
   BOSS RESULT MODAL
   ===================================================== */
.boss-result-content {
  text-align: center;
  padding: 2.5rem;
}
.boss-result-icon { font-size: 4rem; margin-bottom: 0.5rem; }
.boss-result-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}
.boss-result-msg {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.boss-result-rewards {
  font-family: var(--font-mono);
  color: var(--neon-green);
  margin-bottom: 1.5rem;
}

/* =====================================================
   COMBO COUNTER
   ===================================================== */
.quiz-combo {
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%) scale(0.5);
}
.quiz-combo.active {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}
.combo-multiplier {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--neon-cyan);
  text-shadow: 0 0 15px currentColor;
}
.quiz-combo.combo-3 .combo-multiplier { color: var(--neon-green); }
.quiz-combo.combo-4 .combo-multiplier { color: var(--neon-orange); }
.quiz-combo.combo-5 .combo-multiplier { color: var(--neon-yellow); text-shadow: 0 0 20px rgba(255,224,58,0.6), 0 0 40px rgba(255,100,0,0.3); }
.combo-label {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.15em;
  color: var(--text-dim);
}
@keyframes comboPop {
  0% { transform: translateY(-50%) scale(0.5); }
  50% { transform: translateY(-50%) scale(1.3); }
  100% { transform: translateY(-50%) scale(1); }
}
.quiz-combo.bump {
  animation: comboPop 0.3s ease;
}

/* =====================================================
   LIVES (HEARTS)
   ===================================================== */
.quiz-lives {
  display: flex;
  gap: 4px;
  align-items: center;
}
.life-heart {
  font-size: 1.1rem;
  transition: all 0.3s ease;
  filter: drop-shadow(0 0 4px rgba(255,50,50,0.4));
}
.life-heart.lost {
  filter: grayscale(1) opacity(0.3);
  transform: scale(0.7);
}
@keyframes heartBreak {
  0% { transform: scale(1); }
  30% { transform: scale(1.4); filter: brightness(2); }
  100% { transform: scale(0.7); filter: grayscale(1) opacity(0.3); }
}
.life-heart.breaking {
  animation: heartBreak 0.5s ease forwards;
}

/* =====================================================
   DAILY CHALLENGE CARD
   ===================================================== */
.daily-challenge-card {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, rgba(255,224,58,0.06), rgba(255,107,53,0.06));
  border: 1px solid rgba(255,224,58,0.2);
  border-radius: var(--radius);
  padding: 12px 20px;
  cursor: pointer;
  transition: var(--transition);
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}
.daily-challenge-card:hover {
  border-color: rgba(255,224,58,0.5);
  box-shadow: 0 0 20px rgba(255,224,58,0.1);
  transform: translateY(-1px);
}
.daily-challenge-card.completed {
  border-color: rgba(57,255,20,0.2);
  background: linear-gradient(135deg, rgba(57,255,20,0.04), rgba(0,212,255,0.04));
  cursor: default;
}
.daily-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
  animation: dailyPulse 2s ease-in-out infinite;
}
.daily-challenge-card.completed .daily-icon {
  animation: none;
}
@keyframes dailyPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); filter: brightness(1.3); }
}
.daily-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.daily-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px rgba(255,224,58,0.3);
}
.daily-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.daily-status {
  flex-shrink: 0;
}
.daily-go {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--neon-yellow);
  font-weight: 700;
}
.daily-challenge-card.completed .daily-go {
  color: var(--neon-green);
}

/* =====================================================
   DAILY CHALLENGE MODAL
   ===================================================== */
.daily-content {
  max-width: 480px;
  width: 90%;
  padding: 0;
  overflow: hidden;
}
.daily-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.daily-modal-header h2 {
  flex: 1;
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--neon-yellow);
}
.daily-modal-icon { font-size: 1.5rem; }
.daily-modal-body {
  padding: 1.5rem;
}
.daily-result {
  text-align: center;
  padding: 1rem;
}
.daily-result-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.daily-result-text {
  font-family: var(--font-display);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}
.daily-result-xp {
  font-family: var(--font-mono);
  color: var(--neon-green);
  font-size: 0.9rem;
}

/* =====================================================
   WEAK SPOTS SCREEN
   ===================================================== */
.ws-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ws-desc {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}
.ws-body {
  padding: 1.5rem 2rem;
  max-width: 700px;
  margin: 0 auto;
}
.ws-empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-dim);
}
.ws-empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.ws-topic-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,0,50,0.15);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: var(--transition);
}
.ws-topic-card:hover {
  border-color: rgba(255,107,53,0.3);
  background: rgba(255,107,53,0.04);
}
.ws-topic-icon { font-size: 1.5rem; }
.ws-topic-info { flex: 1; }
.ws-topic-name {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.ws-topic-stat {
  font-size: 0.7rem;
  color: #ff6b6b;
  font-family: var(--font-mono);
}
.ws-topic-bar {
  width: 80px;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.ws-topic-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff0032, #ff6b35);
  border-radius: 3px;
}
.ws-drill-btn {
  padding: 8px 16px;
  background: rgba(255,107,53,0.15);
  border: 1px solid rgba(255,107,53,0.3);
  color: var(--neon-orange);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.ws-drill-btn:hover {
  background: rgba(255,107,53,0.25);
}

/* =====================================================
   SPEED RUN
   ===================================================== */
.speed-run-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.speed-run-badge.gold { background: rgba(255,215,0,0.15); color: #ffd700; border: 1px solid rgba(255,215,0,0.3); }
.speed-run-badge.silver { background: rgba(192,192,192,0.15); color: #c0c0c0; border: 1px solid rgba(192,192,192,0.3); }
.speed-run-badge.bronze { background: rgba(205,127,50,0.15); color: #cd7f32; border: 1px solid rgba(205,127,50,0.3); }
.speed-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255,224,58,0.1);
  border: 1px solid rgba(255,224,58,0.25);
  color: var(--neon-yellow);
  font-family: var(--font-display);
  font-size: 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.speed-btn:hover { background: rgba(255,224,58,0.2); border-color: rgba(255,224,58,0.5); }
.quiz-header .timer-danger { color: #ff0032; animation: timerFlash 0.5s ease infinite; }
@keyframes timerFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 640px) {
  .hud-bar { padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
  .hud-center { order: 3; width: 100%; justify-content: center; }
  .trail-container { padding: 1rem; }
  .readiness-meter { padding: 10px 16px; gap: 12px; }
  .readiness-ring-wrap { width: 52px; height: 52px; }
  .readiness-pct { font-size: 0.8rem; }
  .readiness-title { font-size: 0.6rem; }
  .world-card { width: 100%; max-width: 100%; }
  .world-node:nth-child(odd),
  .world-node:nth-child(even) { justify-content: center; }
  .trail-map::before { display: none; }
  .levels-grid { padding: 1rem; grid-template-columns: 1fr; }
  .lesson-content, .quiz-body, .review-body { padding: 1rem; }
  .lesson-nav { padding: 1rem; }
  .choice-options { grid-template-columns: 1fr; }
  .avatar-grid { grid-template-columns: repeat(2, 1fr); }
  .exam-grid { grid-template-columns: 1fr; max-height: 340px; }
  .onboard-container { padding: 1.5rem; }
  .onboard-btn-row { flex-direction: column; }
  .onboard-btn-row .btn-neon { max-width: none; }
  .results-actions { flex-direction: column; }
  .results-actions .btn-neon { width: 100%; }
  .widget-canvas-wrap { aspect-ratio: 1; max-width: 100%; }
  .widget-slider-row { flex-wrap: wrap; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .eq-balance { font-size: 1rem; gap: 10px; }
  .widget-value-display { font-size: 1.1rem; }

  /* Catalog responsive */
  .catalog-header { padding: 1rem; gap: 0.75rem; }
  .catalog-summary { padding: 0.75rem 1rem; gap: 0.75rem; }
  .catalog-body { padding: 1rem; gap: 1.5rem; }
  .catalog-realm-badges { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 1rem; }
  .catalog-realm-header { padding: 1rem; }
  .catalog-tier-legend { gap: 1rem; font-size: 0.7rem; }
  .catalog-seal-title { font-size: 1.2rem; letter-spacing: 2px; }
  .catalog-seal-glow { width: 110px; height: 110px; }
  .catalog-seal-icon { font-size: 3rem; }
  .catalog-tier-breakdown { gap: 6px; }
  .catalog-summary-stat { font-size: 0.8rem; }

  /* Boss Battle responsive */
  .boss-top { flex-direction: row; padding: 1rem; }
  .boss-villain-icon, .boss-player-icon { font-size: 2.5rem; }
  .boss-options { grid-template-columns: 1fr; }
  .boss-narrative { font-size: 0.75rem; padding: 0.5rem 1rem; }

  /* Combo responsive */
  .quiz-combo { right: 0.5rem; }
  .combo-multiplier { font-size: 1.1rem; }

  /* Daily Challenge responsive */
  .daily-challenge-card { padding: 10px 14px; }

  /* Weak Spots responsive */
  .ws-body { padding: 1rem; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(180,74,255,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(180,74,255,0.5); }

/* Selection */
::selection { background: rgba(180,74,255,0.3); }

/* ===================== AUTH SCREEN ===================== */
.auth-container {
  max-width: 420px;
  width: 90%;
  padding: 2.5rem;
  text-align: center;
}
.auth-logo {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 900;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-blue), var(--neon-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 2rem;
  text-shadow: none;
}
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(180,74,255,0.2);
}
.auth-tab {
  flex: 1;
  padding: 10px 0;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
.auth-tab.active {
  background: rgba(180,74,255,0.15);
  color: var(--neon-purple);
  text-shadow: 0 0 10px rgba(180,74,255,0.3);
}
.auth-tab:hover:not(.active) {
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
}
.auth-form {
  display: none;
}
.auth-form.active {
  display: block;
  animation: fadeIn 0.3s ease;
}
.auth-field {
  margin-bottom: 1rem;
  text-align: left;
}
.auth-error {
  color: #ff4466;
  font-size: 0.8rem;
  min-height: 1.2rem;
  margin-bottom: 0.5rem;
  font-family: var(--font-mono);
}
.auth-container .btn-neon {
  width: 100%;
  margin-top: 0.5rem;
}
.auth-container .btn-neon.loading {
  opacity: 0.6;
  pointer-events: none;
}
.auth-container .btn-neon.loading .btn-text::after {
  content: '...';
  animation: dots 1s steps(3) infinite;
}
@keyframes dots {
  0% { content: '.'; }
  33% { content: '..'; }
  66% { content: '...'; }
}


/* ===================== UX POLISH ===================== */

/* Screen shake */
@keyframes shakeSmall {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-4px) rotate(-0.5deg); }
  30% { transform: translateX(3px) rotate(0.3deg); }
  45% { transform: translateX(-3px); }
  60% { transform: translateX(2px); }
  75% { transform: translateX(-1px); }
}
@keyframes shakeBig {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-8px) rotate(-1deg); }
  20% { transform: translateX(7px) rotate(0.8deg); }
  30% { transform: translateX(-6px) rotate(-0.6deg); }
  40% { transform: translateX(5px); }
  50% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  70% { transform: translateX(-2px); }
  80% { transform: translateX(1px); }
}
.shake-small { animation: shakeSmall 0.4s ease; }
.shake-big { animation: shakeBig 0.5s ease; }

/* Smooth screen transitions */
.screen-enter {
  animation: screenFadeIn 0.3s ease-out;
}
@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 3D tilt on cards */
.world-node,
.exam-option,
.medal-card,
.badge-card,
.sidequest-card {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.world-node:hover,
.exam-option:hover,
.medal-card:hover,
.badge-card:hover,
.sidequest-card:hover {
  transform: perspective(600px) rotateX(2deg) rotateY(-2deg) translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,255,136,0.15);
}
.world-node:active,
.exam-option:active {
  transform: perspective(600px) scale(0.97);
}

/* Pulsing world nodes */
@keyframes worldPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(0,255,136,0.3); }
  50% { box-shadow: 0 0 20px rgba(0,255,136,0.6), 0 0 40px rgba(0,255,136,0.2); }
}
.world-node:not(.locked) {
  animation: worldPulse 3s ease-in-out infinite;
}
.world-node.completed {
  animation: none;
  box-shadow: 0 0 12px rgba(0,255,136,0.4);
}

/* Quiz option hover glow */
.quiz-option {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.quiz-option:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0,212,255,0.2);
  border-color: rgba(0,212,255,0.5);
}

/* Correct / Wrong flash on quiz options */
@keyframes optionCorrect {
  0% { background: rgba(0,255,136,0.3); border-color: #00ff88; }
  100% { background: rgba(0,255,136,0.1); border-color: #00ff88; }
}
@keyframes optionWrong {
  0% { background: rgba(255,0,110,0.4); border-color: #ff006e; transform: translateX(-5px); }
  25% { transform: translateX(5px); }
  50% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
  100% { background: rgba(255,0,110,0.15); border-color: #ff006e; transform: translateX(0); }
}
.quiz-option.option-correct {
  animation: optionCorrect 0.6s ease forwards;
  border-color: #00ff88 !important;
}
.quiz-option.option-wrong {
  animation: optionWrong 0.5s ease forwards;
  border-color: #ff006e !important;
}

/* XP bar shimmer */
@keyframes xpShimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}
.xp-fill {
  background: linear-gradient(90deg, #00ff88, #00ff88 40%, #66ffbb 50%, #00ff88 60%, #00ff88) !important;
  background-size: 200% 100% !important;
  animation: xpShimmer 3s linear infinite;
}

/* Button press effect */
.btn-neon:active {
  transform: scale(0.95) !important;
  filter: brightness(1.2);
}

/* Toast slide-in */
@keyframes toastIn {
  from { transform: translateX(100%) scale(0.8); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateX(0) scale(1); opacity: 1; }
  to { transform: translateX(100%) scale(0.8); opacity: 0; }
}
.toast {
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.toast.fade-out {
  animation: toastOut 0.3s ease forwards;
}

/* Timer danger mode */
@keyframes timerPulse {
  0%, 100% { color: #ff006e; text-shadow: 0 0 8px rgba(255,0,110,0.5); }
  50% { color: #ff4444; text-shadow: 0 0 16px rgba(255,0,110,0.8), 0 0 30px rgba(255,0,110,0.4); transform: scale(1.1); }
}
@keyframes timerWarn {
  0%, 100% { color: #ffbe0b; }
  50% { color: #ffdd57; text-shadow: 0 0 8px rgba(255,190,11,0.4); }
}
.timer-danger #timer-text {
  animation: timerPulse 0.5s ease infinite;
}
.timer-warning #timer-text {
  animation: timerWarn 1s ease infinite;
}

/* Streak fire wiggle */
@keyframes fireWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-3deg) scale(1.05); }
  75% { transform: rotate(3deg) scale(1.05); }
}
.streak-badge:not(:empty) {
  animation: fireWiggle 2s ease-in-out infinite;
}

/* Combo counter pop */
@keyframes comboPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.combo-counter.active {
  animation: comboPop 0.3s ease;
}

/* Quiz dot animations */
@keyframes dotCorrect {
  0% { transform: scale(1); }
  50% { transform: scale(1.5); background: #00ff88; box-shadow: 0 0 12px #00ff88; }
  100% { transform: scale(1); background: #00ff88; }
}
@keyframes dotWrong {
  0% { transform: scale(1); }
  50% { transform: scale(1.5); background: #ff006e; box-shadow: 0 0 12px #ff006e; }
  100% { transform: scale(1); background: #ff006e; }
}
.quiz-dot.correct {
  animation: dotCorrect 0.4s ease forwards;
}
.quiz-dot.wrong {
  animation: dotWrong 0.4s ease forwards;
}

/* Hearts lose animation */
@keyframes heartLose {
  0% { transform: scale(1); opacity: 1; }
  30% { transform: scale(1.4); }
  100% { transform: scale(0); opacity: 0; filter: grayscale(1); }
}
.heart-icon.lost {
  animation: heartLose 0.5s ease forwards;
}

/* Level-up modal entrance */
@keyframes levelUpBurst {
  0% { transform: scale(0.3) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.1) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
#levelup-modal.active .modal-content {
  animation: levelUpBurst 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Medal modal entrance */
@keyframes medalDrop {
  0% { transform: translateY(-50px) scale(0.5); opacity: 0; }
  70% { transform: translateY(5px) scale(1.05); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
#medal-modal.active .modal-content {
  animation: medalDrop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Dashboard stat cards subtle hover */
.stat-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0,255,136,0.15);
}

/* Boss HP bar drain animation */
@keyframes hpDrain {
  from { filter: brightness(1.5); }
  to { filter: brightness(1); }
}
.boss-hp-fill {
  transition: width 0.5s ease;
}
.boss-hp-fill.hit {
  animation: hpDrain 0.3s ease;
}

/* Glass panel subtle breathing */
@keyframes glassBreath {
  0%, 100% { border-color: rgba(0,255,136,0.15); }
  50% { border-color: rgba(0,255,136,0.25); }
}
.glass-panel {
  animation: glassBreath 4s ease-in-out infinite;
}

/* Neon text subtle glow pulse */
@keyframes neonPulse {
  0%, 100% { text-shadow: 0 0 10px rgba(0,255,136,0.5), 0 0 20px rgba(0,255,136,0.3); }
  50% { text-shadow: 0 0 15px rgba(0,255,136,0.7), 0 0 30px rgba(0,255,136,0.4), 0 0 45px rgba(0,255,136,0.2); }
}
.neon-text {
  animation: neonPulse 3s ease-in-out infinite;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.3);
}
::-webkit-scrollbar-thumb {
  background: rgba(0,255,136,0.3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0,255,136,0.5);
}


/* ===================== SPLASH INTRO CARDS ===================== */
.splash-intro {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 520px;
  margin: 1.5rem auto;
  text-align: left;
}

.intro-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(0,255,136,0.1);
  border-radius: 12px;
  transition: transform 0.2s ease, border-color 0.25s ease, background 0.25s ease;
  animation: introFadeIn 0.5s ease both;
}
.intro-card:nth-child(1) { animation-delay: 0.1s; }
.intro-card:nth-child(2) { animation-delay: 0.2s; }
.intro-card:nth-child(3) { animation-delay: 0.3s; }
.intro-card:nth-child(4) { animation-delay: 0.4s; }
.intro-card:nth-child(5) { animation-delay: 0.5s; }
.intro-card:nth-child(6) { animation-delay: 0.6s; }

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

.intro-card:hover {
  border-color: rgba(0,255,136,0.3);
  background: rgba(0,255,136,0.04);
  transform: translateX(4px);
}

.intro-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  width: 2.2rem;
  text-align: center;
  margin-top: 2px;
}

.intro-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.intro-text strong {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: #fff;
  letter-spacing: 0.5px;
}
.intro-text span {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
}
.intro-text em {
  color: var(--neon-green);
  font-style: normal;
  font-weight: 600;
}

.splash-cta-section {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.splash-cta-section .splash-hint {
  margin-top: 0;
}

/* Adjust splash for scrolling on smaller screens */
#splash-screen {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2rem 0;
}
#splash-screen .splash-content {
  padding: 1rem 1.5rem 3rem;
}

/* Splash tagline update */
.splash-tagline {
  max-width: 420px;
  line-height: 1.5;
}


/* ===================== MOBILE RESPONSIVE ===================== */

/* Safe area for notched phones */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Prevent pull-to-refresh and bounce on iOS */
html {
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

/* Touch-friendly minimum sizes */
button, .quiz-option, .exam-option, .world-node, .medal-card, .badge-card {
  min-height: 44px;
}
input[type="text"], input[type="password"] {
  font-size: 16px !important; /* Prevents iOS zoom on focus */
}

/* ---- 480px: Small phones ---- */
@media (max-width: 480px) {
  /* HUD */
  .hud-bar {
    padding: 6px 10px;
    padding-top: calc(6px + var(--safe-top));
    gap: 6px;
  }
  .hud-avatar { width: 32px; height: 32px; font-size: 1.1rem; }
  .hud-name { font-size: 0.75rem; }
  .level-badge { font-size: 0.55rem; padding: 1px 6px; }
  .xp-bar-wrap { display: none; }
  .hud-right { gap: 4px; }
  .hud-btn { padding: 4px 8px; font-size: 0.65rem; min-height: 34px; }
  .hud-btn span { font-size: 0.6rem; display: none; }
  .hud-center { order: 3; width: 100%; justify-content: center; }

  /* Splash */
  #splash-screen .splash-content { padding: 0.75rem 1rem 2rem; }
  .logo-glitch { font-size: clamp(2rem, 10vw, 3rem); letter-spacing: 2px; }
  .splash-subtitle { font-size: 0.7rem; letter-spacing: 3px; }
  .splash-tagline { font-size: 0.85rem; margin: 1rem 0; }
  .intro-card { padding: 0.65rem 0.75rem; gap: 0.6rem; }
  .intro-icon { font-size: 1.3rem; width: 1.8rem; }
  .intro-text strong { font-size: 0.85rem; }
  .intro-text span { font-size: 0.75rem; }

  /* Auth */
  .auth-container { padding: 1.5rem; width: 95%; }
  .auth-logo { font-size: 1.3rem; margin-bottom: 1.2rem; }

  /* Onboarding */
  .onboard-container { padding: 1rem; }
  .exam-grid { grid-template-columns: 1fr; max-height: 50vh; gap: 8px; }
  .exam-option { padding: 10px 12px; min-height: 50px; }
  .exam-name { font-size: 0.85rem; }
  .exam-desc { font-size: 0.7rem; }
  .avatar-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .avatar-option { font-size: 2rem; padding: 10px; }

  /* Trail / Dashboard */
  .trail-container { padding: 0.75rem 0.75rem 3rem; }
  .trail-title { font-size: 1.1rem; }
  .trail-desc { font-size: 0.78rem; }
  .readiness-meter { padding: 8px 12px; gap: 10px; flex-direction: row; }
  .readiness-ring-wrap { width: 44px; height: 44px; }
  .readiness-pct { font-size: 0.7rem; }
  .readiness-title { font-size: 0.55rem; letter-spacing: 0.08em; }
  .readiness-detail { font-size: 0.65rem; }

  /* World nodes */
  .world-node { padding: 12px; }
  .world-node-icon { font-size: 1.5rem; width: 40px; height: 40px; }
  .world-node-info h3 { font-size: 0.85rem; }
  .world-node-info p { font-size: 0.7rem; }
  .world-node-progress { font-size: 0.6rem; }

  /* World detail */
  .levels-grid { padding: 0.75rem; gap: 8px; grid-template-columns: 1fr; }
  .level-card { padding: 12px; }
  .level-card-name { font-size: 0.85rem; }

  /* Lessons */
  .lesson-header { padding: 0.75rem 1rem; }
  .lesson-title { font-size: 0.9rem; }
  .lesson-content { padding: 0.75rem; }
  .lesson-content h3 { font-size: 1rem; }
  .lesson-content p { font-size: 0.85rem; }
  .lesson-nav { padding: 0.75rem; gap: 8px; }
  .lesson-nav .btn-neon { padding: 10px 16px; font-size: 0.75rem; }

  /* Quiz */
  .quiz-header { padding: 8px 12px; flex-wrap: wrap; }
  .quiz-body { padding: 0.75rem; }
  .quiz-question { font-size: 0.95rem; padding: 12px; }
  .quiz-option { padding: 12px 14px; font-size: 0.85rem; min-height: 48px; }
  .quiz-option-letter { width: 28px; height: 28px; font-size: 0.7rem; }
  .quiz-dots { gap: 4px; }
  .quiz-dot { width: 8px; height: 8px; }
  .quiz-combo { right: 8px; top: 55px; }
  .combo-multiplier { font-size: 0.9rem; }
  .combo-label { font-size: 0.55rem; }
  .quiz-lives { gap: 2px; }
  .heart-icon { font-size: 1rem; }
  .quiz-timer { font-size: 0.85rem; }

  /* Results */
  .results-stats { gap: 1rem; flex-wrap: wrap; }
  .results-score { font-size: 2.5rem; }
  .results-actions { flex-direction: column; gap: 8px; }
  .results-actions .btn-neon { width: 100%; }

  /* Medals */
  .medal-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 0.75rem; }
  .medal-card { padding: 12px 8px; }
  .medal-card-icon { font-size: 2rem; }
  .medal-card-name { font-size: 0.75rem; }
  .medal-card-desc { font-size: 0.65rem; }

  /* Profile */
  .profile-body { padding: 1rem; }
  .profile-card { padding: 1.2rem; }
  .profile-avatar { font-size: 3rem; }
  .profile-name { font-size: 1.1rem; }
  .profile-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .profile-stat { padding: 10px; }
  .profile-stat-val { font-size: 1.2rem; }
  .profile-stat-label { font-size: 0.65rem; }

  /* Boss Battle */
  .boss-arena { padding: 0.75rem; }
  .boss-top { padding: 0.75rem; gap: 8px; }
  .boss-villain-icon, .boss-player-icon { font-size: 2rem; }
  .boss-hp-bar { height: 10px; }
  .boss-narrative { font-size: 0.7rem; padding: 6px 10px; }
  .boss-question-text { font-size: 0.9rem; }
  .boss-options { grid-template-columns: 1fr; gap: 6px; }
  .boss-option { padding: 10px; font-size: 0.8rem; }

  /* Catalog */
  .catalog-header { padding: 0.75rem; }
  .catalog-body { padding: 0.75rem; gap: 1rem; }
  .catalog-realm-badges { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 0.75rem; }
  .badge-card { padding: 10px; }
  .catalog-seal-glow { width: 80px; height: 80px; }
  .catalog-seal-icon { font-size: 2.2rem; }
  .catalog-seal-title { font-size: 0.9rem; }

  /* Side Quests */
  .sidequest-card { padding: 12px; }

  /* Daily Challenge */
  .daily-challenge-card { padding: 8px 12px; }

  /* Weak Spots */
  .ws-body { padding: 0.75rem; }
  .ws-topic { padding: 10px; }

  /* Modals */
  .modal-content { padding: 1.5rem; width: 92%; }
  #levelup-modal .modal-content { padding: 1.5rem; }

  /* Toast */
  .toast-container { top: calc(50px + var(--safe-top)); right: 10px; left: 10px; }
  .toast { max-width: 100%; font-size: 0.8rem; padding: 10px 14px; }

  /* Yoda */
  .yoda-chat-panel { width: 100%; max-width: 100%; border-radius: 0; max-height: 100vh; height: 100vh; }
  .yoda-messages { padding: 10px; }
  .yoda-msg { max-width: 90%; font-size: 0.82rem; padding: 10px 12px; }
  .yoda-input-row { padding: 8px; }
  .yoda-input-row input { font-size: 16px !important; }

  /* Widgets */
  .widget-container { padding: 12px; }
  .widget-canvas-wrap { aspect-ratio: 1; }
  .widget-slider-row { flex-direction: column; gap: 8px; }
  .widget-btn-group { flex-wrap: wrap; gap: 6px; }
  .widget-btn { padding: 8px 12px; font-size: 0.75rem; }
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat-card { padding: 8px; }
  .stat-card-val { font-size: 1rem; }
  .stat-card-label { font-size: 0.6rem; }

  /* Review screen */
  .review-body { padding: 0.75rem; }
  .review-item { padding: 10px; }
}

/* ---- 768px: Tablets / large phones ---- */
@media (min-width: 481px) and (max-width: 768px) {
  .hud-bar { padding: 8px 14px; }
  .hud-avatar { width: 36px; height: 36px; font-size: 1.2rem; }
  .hud-name { font-size: 0.8rem; }
  .hud-btn span { font-size: 0.65rem; }

  .trail-container { padding: 1rem 1rem 3rem; }
  .levels-grid { grid-template-columns: 1fr 1fr; }
  .quiz-body { padding: 1rem 1.5rem; }
  .quiz-option { padding: 14px 16px; }
  .medal-grid { grid-template-columns: repeat(3, 1fr); }
  .profile-body { padding: 1.5rem; }
  .boss-options { grid-template-columns: 1fr 1fr; }
  .catalog-realm-badges { grid-template-columns: repeat(3, 1fr); }
  .exam-grid { grid-template-columns: 1fr 1fr; }
  .modal-content { width: 85%; }
  .yoda-chat-panel { width: 90%; }
}

/* ---- Landscape phones ---- */
@media (max-height: 500px) and (orientation: landscape) {
  .splash-intro { max-height: 35vh; overflow-y: auto; }
  .logo-glitch { font-size: 2rem; }
  .splash-subtitle { margin-top: 0.2rem; }
  .splash-tagline { margin: 0.5rem 0; font-size: 0.85rem; }
  .intro-card { padding: 0.4rem 0.6rem; }
  .intro-icon { font-size: 1.1rem; }
  .intro-text span { font-size: 0.7rem; }
  .modal-content { padding: 1rem; max-height: 90vh; overflow-y: auto; }
  .quiz-body { padding: 0.5rem 1rem; }
  .quiz-question { font-size: 0.85rem; padding: 8px; }
  .boss-top { padding: 0.5rem; }
  .yoda-chat-panel { max-height: 100vh; }
}

/* ---- Touch-specific improvements ---- */
@media (hover: none) and (pointer: coarse) {
  /* Disable hover effects on touch (they stick on tap) */
  .world-node:hover,
  .exam-option:hover,
  .medal-card:hover,
  .badge-card:hover,
  .sidequest-card:hover {
    transform: none;
    box-shadow: none;
  }
  .quiz-option:hover {
    transform: none;
    box-shadow: none;
    border-color: inherit;
  }
  .intro-card:hover {
    transform: none;
    border-color: rgba(0,255,136,0.1);
    background: rgba(255,255,255,0.03);
  }

  /* Add active states instead */
  .world-node:active { transform: scale(0.97); }
  .quiz-option:active { transform: scale(0.98); background: rgba(180,74,255,0.1); }
  .exam-option:active { transform: scale(0.97); }
  .btn-neon:active { transform: scale(0.95) !important; }
  .medal-card:active { transform: scale(0.96); }
  .intro-card:active { transform: scale(0.98); border-color: rgba(0,255,136,0.3); }

  /* Larger touch targets */
  .quiz-option { min-height: 52px; }
  .btn-neon { min-height: 48px; }

  /* Disable glass breathing animation on mobile to save battery */
  .glass-panel { animation: none; }
  .neon-text { animation: none; text-shadow: 0 0 10px rgba(0,255,136,0.5), 0 0 20px rgba(0,255,136,0.3); }
  .world-node:not(.locked) { animation: none; }
}

/* ---- Dark mode system bar ---- */
@media (display-mode: standalone) {
  body { padding-top: var(--safe-top); }
  .hud-bar { padding-top: calc(10px + var(--safe-top)); }
  .screen { top: 0; }
  #splash-screen { padding-top: var(--safe-top); }
}

/* ---- Print — hide everything except content ---- */
@media print {
  .hud-bar, .btn-neon, .toast-container, #particle-canvas, #confetti-canvas { display: none !important; }
  .screen { position: static !important; overflow: visible !important; }
}
