/* ========================================
   MATH ADVENTURES - Global Styles
   ======================================== */

:root {
  /* Color Palette */
  --bg-dark: #0f0e17;
  --bg-darker: #090814;
  --surface: #1a1932;
  --surface-light: #2a2950;
  --primary: #ff8906;
  --primary-glow: #ff890640;
  --secondary: #e53170;
  --accent: #7f5af0;
  --accent-glow: #7f5af040;
  --success: #2cb67d;
  --danger: #e53170;
  --text: #fffffe;
  --text-dim: #94a1b2;
  --gold: #ffd700;
  --boss-yellow: #f5c542;
  --boss-purple: #9b59b6;
  --icy-blue: #4fc3f7;
  --chaos-purple: #e040fb;
  --space-green: #00e676;

  /* Typography */
  --font-display: 'Bangers', cursive;
  --font-heading: 'Fredoka', sans-serif;
  --font-body: 'Comic Neue', cursive;
  --font-numbers: 'Outfit', sans-serif;

  /* Spacing */
  --gap-xs: 0.25rem;
  --gap-sm: 0.5rem;
  --gap-md: 1rem;
  --gap-lg: 1.5rem;
  --gap-xl: 2rem;
  --gap-2xl: 3rem;

  /* Borders */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;
}

/* ========================================
   RESET & BASE
   ======================================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-dark);
  color: var(--text);
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

img {
  max-width: 100%;
  display: block;
}

button {
  cursor: pointer;
  border: none;
  outline: none;
  font-family: var(--font-heading);
  transition: all 0.2s ease;
}

button:active {
  transform: scale(0.95);
}

/* ========================================
   SCREEN SYSTEM
   ======================================== */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
  z-index: 10;
}

.screen.fade-out {
  opacity: 0;
}

/* ========================================
   COMIC INTRO SCREEN
   ======================================== */
#comic-overlay {
  background: #111;
  z-index: 100;
}

.comic-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: var(--gap-lg);
}

.comic-page {
  display: none;
  max-width: 960px;
  width: 100%;
  animation: comicSlideIn 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.comic-page.active {
  display: block;
}

.comic-page img {
  width: 100%;
  border-radius: var(--radius-lg);
  box-shadow:
    0 0 0 3px rgba(255, 137, 6, 0.3),
    0 20px 60px rgba(0, 0, 0, 0.6),
    0 0 80px rgba(127, 90, 240, 0.15);
}

@keyframes comicSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.comic-nav {
  display: flex;
  align-items: center;
  gap: var(--gap-xl);
  margin-top: var(--gap-lg);
}

.comic-btn {
  background: linear-gradient(135deg, var(--accent), #6c3fcf);
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.7rem 1.8rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.5px;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.comic-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #9070f0, var(--accent));
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(127, 90, 240, 0.5);
}

.comic-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.comic-dots {
  display: flex;
  gap: var(--gap-sm);
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface-light);
  transition: all 0.3s ease;
}

.dot.active {
  background: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
  transform: scale(1.2);
}

/* ========================================
   LEVEL SELECT SCREEN
   ======================================== */
#level-select {
  background: radial-gradient(ellipse at center, #1a1545 0%, var(--bg-dark) 70%);
  overflow-y: auto;
  padding: var(--gap-xl) var(--gap-md);
}

.level-select-content {
  text-align: center;
  animation: fadeInUp 0.8s ease;
  width: 100%;
  max-width: 1000px;
}

.level-select-title {
  font-family: var(--font-display);
  font-size: 3rem;
  letter-spacing: 4px;
  background: linear-gradient(135deg, var(--gold), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--gap-xs);
}

.level-select-subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: var(--gap-xl);
}

.level-cards {
  display: flex;
  gap: var(--gap-lg);
  justify-content: center;
  flex-wrap: wrap;
}

.level-card {
  background: var(--surface);
  border: 2px solid rgba(127, 90, 240, 0.2);
  border-radius: var(--radius-xl);
  padding: var(--gap-lg) var(--gap-md);
  width: 260px;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.level-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.03));
  pointer-events: none;
}

.level-card.unlocked:hover {
  transform: translateY(-8px) scale(1.03);
  border-color: var(--accent);
  box-shadow:
    0 12px 40px rgba(127, 90, 240, 0.3),
    0 0 60px rgba(127, 90, 240, 0.1);
}

.level-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

.level-card-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 3px;
  color: var(--primary);
  background: rgba(255, 137, 6, 0.1);
  border: 1px solid rgba(255, 137, 6, 0.3);
  padding: 0.2rem 1rem;
  border-radius: var(--radius-full);
  margin-bottom: var(--gap-sm);
  text-transform: uppercase;
}

.level-card-img-wrap {
  width: 140px;
  height: 140px;
  margin: 0 auto var(--gap-sm);
  position: relative;
}

.level-card-img-wrap::before {
  content: '';
  position: absolute;
  inset: -15px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(127, 90, 240, 0.25) 0%, transparent 70%);
  animation: bossGlow 2s ease-in-out infinite alternate;
}

.level-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0 15px rgba(127, 90, 240, 0.3));
}

.level-card.unlocked .level-card-img-wrap img {
  animation: bossFloat 3s ease-in-out infinite;
}

.level-card-name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  letter-spacing: 2px;
  color: var(--text);
  margin-bottom: var(--gap-xs);
}

.level-card-boss {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--boss-yellow);
  font-weight: 600;
  margin-bottom: var(--gap-xs);
}

.level-card-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: var(--gap-sm);
}

.level-card-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-xl);
  z-index: 5;
  backdrop-filter: blur(2px);
}

.level-card-stars {
  font-size: 1.3rem;
  min-height: 1.5rem;
  display: flex;
  gap: 4px;
  justify-content: center;
}

/* Level card per-boss theme accents */
#level-card-1.unlocked {
  border-color: rgba(255, 137, 6, 0.3);
}
#level-card-1.unlocked:hover {
  border-color: var(--primary);
  box-shadow: 0 12px 40px rgba(255, 137, 6, 0.25);
}

#level-card-2.unlocked {
  border-color: rgba(79, 195, 247, 0.3);
}
#level-card-2.unlocked:hover {
  border-color: var(--icy-blue);
  box-shadow: 0 12px 40px rgba(79, 195, 247, 0.25);
}

#level-card-3.unlocked {
  border-color: rgba(224, 64, 251, 0.3);
}
#level-card-3.unlocked:hover {
  border-color: var(--chaos-purple);
  box-shadow: 0 12px 40px rgba(224, 64, 251, 0.25);
}

#level-card-4.unlocked {
  border-color: rgba(0, 230, 118, 0.3);
}
#level-card-4.unlocked:hover {
  border-color: var(--space-green);
  box-shadow: 0 12px 40px rgba(0, 230, 118, 0.25);
}

/* ========================================
   LEVEL INTRO SCREEN
   ======================================== */
#level-intro {
  background: radial-gradient(ellipse at center, #1e1545 0%, var(--bg-dark) 70%);
  overflow: hidden;
}

.level-intro-content {
  text-align: center;
  animation: fadeInUp 0.8s ease;
}

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

.level-badge {
  display: inline-block;
  margin-bottom: var(--gap-md);
}

.level-number {
  font-family: var(--font-display);
  font-size: 1.4rem;
  letter-spacing: 4px;
  color: var(--primary);
  background: rgba(255, 137, 6, 0.1);
  border: 2px solid rgba(255, 137, 6, 0.3);
  padding: 0.4rem 1.5rem;
  border-radius: var(--radius-full);
}

.level-title {
  font-family: var(--font-display);
  font-size: 3.5rem;
  letter-spacing: 3px;
  background: linear-gradient(135deg, var(--gold), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--gap-sm);
  text-shadow: none;
}

.level-subtitle {
  font-size: 1.2rem;
  color: var(--text-dim);
  margin-bottom: var(--gap-xl);
}

.boss-name-highlight {
  color: var(--boss-yellow);
  font-weight: 700;
}

.level-boss-preview {
  width: 220px;
  height: 220px;
  margin: 0 auto var(--gap-xl);
  position: relative;
}

.level-boss-preview::before {
  content: '';
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(127, 90, 240, 0.3) 0%, transparent 70%);
  animation: bossGlow 2s ease-in-out infinite alternate;
}

@keyframes bossGlow {
  from { transform: scale(0.9); opacity: 0.5; }
  to { transform: scale(1.1); opacity: 1; }
}

.level-boss-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0 30px rgba(127, 90, 240, 0.5));
  animation: bossFloat 3s ease-in-out infinite;
}

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

/* ========================================
   ACTION BUTTONS
   ======================================== */
.action-btn {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 2px;
  padding: 1rem 2.5rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), #e06c00);
  color: white;
  box-shadow:
    0 4px 20px rgba(255, 137, 6, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-transform: uppercase;
}

.action-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 35px rgba(255, 137, 6, 0.5);
}

.secondary-btn {
  background: linear-gradient(135deg, var(--surface-light), var(--surface));
  font-size: 1.1rem;
  padding: 0.7rem 1.8rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(127, 90, 240, 0.3);
}

.secondary-btn:hover {
  background: linear-gradient(135deg, #3a3970, var(--surface-light));
  box-shadow: 0 6px 25px rgba(127, 90, 240, 0.3);
  border-color: var(--accent);
}

.victory-actions,
.gameover-actions {
  display: flex;
  gap: var(--gap-md);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--gap-md);
}

.pulse-btn {
  animation: btnPulse 2s ease-in-out infinite;
}

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(255, 137, 6, 0.4); }
  50% { box-shadow: 0 4px 40px rgba(255, 137, 6, 0.7), 0 0 60px rgba(255, 137, 6, 0.2); }
}

/* ========================================
   BATTLE SCREEN
   ======================================== */
#battle-screen {
  background: radial-gradient(ellipse at 50% 20%, #1e1545 0%, var(--bg-dark) 60%);
  flex-direction: column;
  padding: var(--gap-md);
  gap: 0;
  justify-content: flex-start;
}

/* Battle Particles */
.battle-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0;
  animation: particleFloat 6s ease-in-out infinite;
}

@keyframes particleFloat {
  0% { opacity: 0; transform: translateY(100vh) scale(0); }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% { opacity: 0; transform: translateY(-20px) scale(1); }
}

/* ========================================
   BATTLE HUD
   ======================================== */
.battle-hud {
  width: 100%;
  max-width: 800px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--gap-sm) var(--gap-md);
  background: rgba(26, 25, 50, 0.8);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(127, 90, 240, 0.2);
  backdrop-filter: blur(10px);
  z-index: 2;
  margin-bottom: var(--gap-sm);
}

.hud-section {
  text-align: center;
}

.hud-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-family: var(--font-heading);
}

.hud-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--primary);
  letter-spacing: 1px;
}

.question-counter {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--text);
  letter-spacing: 2px;
}

.score-display {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--gold);
  letter-spacing: 1px;
}

/* ========================================
   BOSS AREA
   ======================================== */
.boss-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 800px;
  z-index: 2;
  min-height: 0;
  gap: var(--gap-sm);
}

/* Boss Health Bar */
.boss-health-bar-container {
  width: 100%;
  max-width: 400px;
}

.boss-health-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-family: var(--font-heading);
  font-size: 0.85rem;
}

.boss-health-name {
  color: var(--boss-yellow);
  font-weight: 600;
}

.boss-health-text {
  color: var(--danger);
  font-weight: 600;
}

.boss-health-bar {
  width: 100%;
  height: 18px;
  background: var(--surface);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 2px solid rgba(229, 49, 112, 0.3);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.boss-health-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--danger), #ff6b6b);
  border-radius: var(--radius-full);
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  box-shadow: 0 0 12px rgba(229, 49, 112, 0.5);
}

.boss-health-fill::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 8px;
  right: 8px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
}

/* Boss Character */
.boss-character {
  position: relative;
  width: 180px;
  height: 180px;
  flex-shrink: 0;
}

.boss-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 25px rgba(127, 90, 240, 0.4));
  animation: bossIdle 3s ease-in-out infinite;
  transition: filter 0.2s ease;
}

@keyframes bossIdle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-6px) rotate(-1deg); }
  75% { transform: translateY(-3px) rotate(1deg); }
}

.boss-img.hit {
  animation: bossHit 0.5s ease;
  filter: brightness(2) drop-shadow(0 0 30px rgba(255, 255, 255, 0.8));
}

@keyframes bossHit {
  0% { transform: translateX(0); }
  15% { transform: translateX(-15px) rotate(-5deg); }
  30% { transform: translateX(15px) rotate(5deg); }
  45% { transform: translateX(-10px) rotate(-3deg); }
  60% { transform: translateX(10px) rotate(3deg); }
  75% { transform: translateX(-5px); }
  100% { transform: translateX(0); }
}

.boss-img.angry {
  animation: bossAngry 0.4s ease;
}

@keyframes bossAngry {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); filter: hue-rotate(30deg) brightness(1.3); }
}

.boss-damage-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.8), transparent 60%);
  opacity: 0;
  pointer-events: none;
  border-radius: 50%;
}

.boss-damage-flash.flash {
  animation: damageFlash 0.3s ease;
}

@keyframes damageFlash {
  0% { opacity: 0.8; transform: scale(0.8); }
  100% { opacity: 0; transform: scale(1.5); }
}

/* Boss Speech Bubble */
.boss-speech {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--gap-sm) var(--gap-md);
  max-width: 400px;
  position: relative;
  box-shadow: 0 0 20px var(--accent-glow);
  animation: speechPop 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  min-height: 50px;
  display: flex;
  align-items: center;
}

.boss-speech::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 10px solid var(--accent);
}

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

.boss-speech-text {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text);
  text-align: center;
  font-weight: 700;
  line-height: 1.4;
}

/* ========================================
   EQUATION AREA
   ======================================== */
.equation-area {
  width: 100%;
  max-width: 800px;
  z-index: 2;
  padding: var(--gap-sm) 0;
}

.equation-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-md);
  padding: var(--gap-md) var(--gap-lg);
  background: rgba(26, 25, 50, 0.6);
  border-radius: var(--radius-lg);
  border: 2px solid rgba(255, 137, 6, 0.2);
  box-shadow: 0 0 30px rgba(255, 137, 6, 0.1);
}

.eq-num, .eq-op, .eq-equals, .eq-answer {
  font-family: var(--font-numbers);
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: 2px;
}

.eq-num {
  color: var(--text);
  min-width: 60px;
  text-align: center;
}

.eq-op {
  color: var(--primary);
}

.eq-equals {
  color: var(--text-dim);
}

.eq-answer {
  color: var(--gold);
  min-width: 60px;
  text-align: center;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-md);
  border: 2px dashed rgba(255, 215, 0, 0.4);
  background: rgba(255, 215, 0, 0.05);
}

/* Hidden extra equation elements for 2-number equations */
.eq-extra {
  transition: opacity 0.3s ease, max-width 0.3s ease;
}

.eq-hidden {
  display: none !important;
}

/* ========================================
   ANSWER OPTIONS
   ======================================== */
.answer-area {
  width: 100%;
  max-width: 800px;
  z-index: 2;
  padding: var(--gap-sm) 0 var(--gap-md);
}

.answers-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap-md);
}

.answer-btn {
  font-family: var(--font-numbers);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, var(--surface-light), var(--surface));
  color: var(--text);
  border: 2px solid rgba(127, 90, 240, 0.2);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.answer-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.05));
  pointer-events: none;
}

.answer-btn:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--accent);
  box-shadow: 0 8px 30px rgba(127, 90, 240, 0.3);
  background: linear-gradient(145deg, #3a3970, var(--surface-light));
}

.answer-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.answer-btn.correct {
  background: linear-gradient(145deg, var(--success), #1e9e6a) !important;
  border-color: var(--success) !important;
  color: white !important;
  animation: correctPop 0.5s ease;
  box-shadow: 0 0 30px rgba(44, 182, 125, 0.5) !important;
}

@keyframes correctPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.answer-btn.wrong {
  background: linear-gradient(145deg, var(--danger), #c0284e) !important;
  border-color: var(--danger) !important;
  color: white !important;
  animation: wrongShake 0.5s ease;
  box-shadow: 0 0 30px rgba(229, 49, 112, 0.5) !important;
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ========================================
   FEEDBACK OVERLAY
   ======================================== */
.feedback-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
}

.feedback-overlay.show {
  display: flex;
}

.feedback-content {
  font-family: var(--font-display);
  font-size: 4rem;
  letter-spacing: 4px;
  animation: feedbackPop 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.feedback-content.correct-feedback {
  color: var(--success);
}

.feedback-content.wrong-feedback {
  color: var(--danger);
}

@keyframes feedbackPop {
  0% { opacity: 0; transform: scale(0.3) translateY(30px); }
  40% { opacity: 1; transform: scale(1.2) translateY(-10px); }
  70% { transform: scale(1) translateY(0); }
  100% { opacity: 0; transform: scale(0.8) translateY(-30px); }
}

/* ========================================
   VICTORY SCREEN
   ======================================== */
#victory-screen {
  background: radial-gradient(ellipse at center, #1a2a1a 0%, var(--bg-dark) 70%);
}

.victory-content {
  text-align: center;
  animation: fadeInUp 0.8s ease;
  position: relative;
}

.victory-title {
  font-family: var(--font-display);
  font-size: 3.5rem;
  letter-spacing: 4px;
  background: linear-gradient(135deg, var(--gold), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--gap-sm);
  animation: victoryBounce 1s ease infinite alternate;
}

@keyframes victoryBounce {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

.victory-subtitle {
  font-size: 1.3rem;
  color: var(--text-dim);
  margin-bottom: var(--gap-xl);
}

.victory-stats {
  display: flex;
  gap: var(--gap-lg);
  justify-content: center;
  margin-bottom: var(--gap-xl);
}

.stat-card {
  background: var(--surface);
  border: 1px solid rgba(127, 90, 240, 0.2);
  border-radius: var(--radius-lg);
  padding: var(--gap-md) var(--gap-lg);
  min-width: 100px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.stat-icon {
  font-size: 1.8rem;
  margin-bottom: var(--gap-xs);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--gold);
  letter-spacing: 2px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--font-heading);
}

.star-rating {
  font-size: 3rem;
  margin-bottom: var(--gap-xl);
  display: flex;
  gap: var(--gap-sm);
  justify-content: center;
}

.star-rating .star {
  animation: starPop 0.5s ease;
  animation-fill-mode: backwards;
}

.star-rating .star:nth-child(1) { animation-delay: 0.2s; }
.star-rating .star:nth-child(2) { animation-delay: 0.5s; }
.star-rating .star:nth-child(3) { animation-delay: 0.8s; }

@keyframes starPop {
  from { opacity: 0; transform: scale(0) rotate(-30deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ========================================
   GAME OVER SCREEN
   ======================================== */
#gameover-screen {
  background: radial-gradient(ellipse at center, #2a1010 0%, var(--bg-dark) 70%);
}

.gameover-content {
  text-align: center;
  animation: fadeInUp 0.8s ease;
}

.gameover-title {
  font-family: var(--font-display);
  font-size: 3rem;
  letter-spacing: 4px;
  color: var(--danger);
  margin-bottom: var(--gap-sm);
}

.gameover-subtitle {
  font-size: 1.2rem;
  color: var(--text-dim);
  margin-bottom: var(--gap-sm);
}

.gameover-encourage {
  font-size: 1.1rem;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: var(--gap-xl);
}

/* ========================================
   CONFETTI
   ======================================== */
.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  top: -10px;
  opacity: 0;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(100vh) rotate(720deg); }
}

/* ========================================
   DAMAGE NUMBERS
   ======================================== */
.damage-number {
  position: absolute;
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--gold);
  pointer-events: none;
  z-index: 30;
  animation: damageFloat 1s ease-out forwards;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

@keyframes damageFloat {
  0% { opacity: 1; transform: translateY(0) scale(0.5); }
  30% { transform: translateY(-20px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-60px) scale(0.8); }
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 700px) {
  .eq-num, .eq-op, .eq-equals, .eq-answer {
    font-size: 2rem;
  }
  
  .answers-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--gap-sm);
  }
  
  .answer-btn {
    font-size: 1.6rem;
    padding: 0.8rem;
  }
  
  .boss-character {
    width: 140px;
    height: 140px;
  }
  
  .boss-speech-text {
    font-size: 0.85rem;
  }
  
  .level-title {
    font-size: 2.5rem;
  }
  
  .victory-title {
    font-size: 2.5rem;
  }
  
  .battle-hud {
    padding: var(--gap-xs) var(--gap-sm);
  }
  
  .hud-title {
    font-size: 0.9rem;
  }

  .level-select-title {
    font-size: 2.2rem;
  }

  .level-cards {
    flex-direction: column;
    align-items: center;
  }

  .level-card {
    width: 90%;
    max-width: 300px;
  }

  .victory-stats {
    flex-direction: column;
    align-items: center;
  }

  .victory-actions,
  .gameover-actions {
    flex-direction: column;
    align-items: center;
  }

  .equation-display {
    gap: var(--gap-sm);
    padding: var(--gap-sm) var(--gap-md);
  }
}

@media (max-width: 480px) {
  .eq-num, .eq-op, .eq-equals, .eq-answer {
    font-size: 1.6rem;
    min-width: 40px;
  }
  
  .equation-display {
    gap: var(--gap-xs);
    padding: var(--gap-sm);
  }
  
  .comic-nav {
    gap: var(--gap-md);
  }
  
  .comic-btn {
    font-size: 0.9rem;
    padding: 0.5rem 1.2rem;
  }

  .level-card-img-wrap {
    width: 100px;
    height: 100px;
  }

  .action-btn {
    font-size: 1.2rem;
    padding: 0.8rem 1.5rem;
  }

  .secondary-btn {
    font-size: 0.95rem;
    padding: 0.6rem 1.2rem;
  }
}
