/* ============================================
   INFINITE EINSTEIN - Design System v3
   🤖 @frontend-specialist BRIGHT CANDY THEME
   Sunny, vibrant, magical for kids!
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Quicksand:wght@400;500;600;700&display=swap');

/* ─── CSS Custom Properties ─── */
:root {
  /* Base Colors — Bright & Warm */
  --color-bg: #e8f4f8;
  --color-bg-mid: #d4ecf7;
  --color-bg-warm: #fff5e6;
  --color-surface: #ffffff;
  --color-surface-hover: #f0f8ff;
  --color-surface-solid: #ffffff;
  --color-text: #2d3436;
  --color-text-dim: #636e72;
  --color-text-accent: #e17055;

  /* Primary Palette — Candy Bright (NO PURPLE) */
  --color-primary: #ff6b35;
  --color-primary-light: #ff8c5a;
  --color-primary-dark: #e55a2b;
  --color-secondary: #00b894;
  --color-secondary-dark: #009975;
  --color-accent: #fdcb6e;
  --color-accent-dark: #e6b84d;
  --color-danger: #ff6b6b;
  --color-danger-light: #ff8787;
  --color-magic: #0984e3;

  /* Fun Palette */
  --color-sky: #74b9ff;
  --color-mint: #55efc4;
  --color-coral: #ff7675;
  --color-sun: #ffeaa7;
  --color-peach: #fab1a0;
  --color-grass: #00b894;

  /* Medal Colors */
  --color-bronze: #cd7f32;
  --color-silver: #b2bec3;
  --color-gold: #ffc312;
  --color-diamond: #74b9ff;

  /* World Theme Colors */
  --world-primary: var(--color-primary);
  --world-secondary: var(--color-secondary);
  --world-bg: var(--color-bg);

  /* Spacing (8pt grid) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Typography */
  --font-display: 'Fredoka', sans-serif;
  --font-body: 'Quicksand', sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;
  --font-size-3xl: 2.5rem;
  --font-size-4xl: 3.5rem;
  --font-size-hero: 5rem;

  /* Border Radius — Extreme Friendly (kids game!) */
  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-xl: 36px;
  --radius-full: 50%;

  /* Shadows — Soft colorful depth */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-chunky: 0 6px 0 rgba(0, 0, 0, 0.1);
  --shadow-colored: 0 6px 0 rgba(255, 107, 53, 0.3);
  --shadow-inner-light: inset 0 2px 0 rgba(255, 255, 255, 0.7);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── World Themes — Bright Backgrounds ─── */
[data-world="dino"] {
  --world-primary: #00b894;
  --world-secondary: #55efc4;
  --world-bg: #e0f7ef;
}

[data-world="racing"] {
  --world-primary: #ff6b6b;
  --world-secondary: #ff9f43;
  --world-bg: #ffe8e8;
}

[data-world="ocean"] {
  --world-primary: #0984e3;
  --world-secondary: #74b9ff;
  --world-bg: #dfe6e9;
}

[data-world="space"] {
  --world-primary: #00cec9;
  --world-secondary: #55efc4;
  --world-bg: #e0f7f7;
}

[data-world="volcano"] {
  --world-primary: #e17055;
  --world-secondary: #ff9f43;
  --world-bg: #ffeee8;
}

[data-world="crystal"] {
  --world-primary: #fd79a8;
  --world-secondary: #fab1a0;
  --world-bg: #ffeef5;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  font-weight: 500;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ─── App Container ─── */
#app {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* ─── Screens ─── */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  overflow-y: auto;
  overflow-x: hidden;
}

.screen.active {
  display: flex;
  z-index: 1;
  animation: screen-enter 400ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes screen-enter {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ─── Bright Playful Background ─── */
.screen-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 15% 20%, rgba(85, 239, 196, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 25%, rgba(116, 185, 255, 0.2) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(253, 203, 110, 0.2) 0%, transparent 50%),
    radial-gradient(ellipse at 20% 70%, rgba(255, 118, 117, 0.15) 0%, transparent 40%),
    linear-gradient(180deg, #e8f4f8 0%, #fff5e6 50%, #ffeef5 100%);
}

/* Floating colorful dots */
.screen-bg::before {
  content: '';
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image:
    radial-gradient(6px 6px at 15% 25%, rgba(255, 107, 53, 0.15), transparent),
    radial-gradient(8px 8px at 35% 15%, rgba(85, 239, 196, 0.2), transparent),
    radial-gradient(5px 5px at 55% 35%, rgba(253, 203, 110, 0.2), transparent),
    radial-gradient(7px 7px at 75% 20%, rgba(116, 185, 255, 0.18), transparent),
    radial-gradient(6px 6px at 25% 65%, rgba(255, 118, 117, 0.15), transparent),
    radial-gradient(9px 9px at 65% 55%, rgba(85, 239, 196, 0.12), transparent),
    radial-gradient(5px 5px at 45% 75%, rgba(255, 107, 53, 0.12), transparent),
    radial-gradient(7px 7px at 85% 70%, rgba(253, 203, 110, 0.15), transparent),
    radial-gradient(6px 6px at 10% 45%, rgba(116, 185, 255, 0.12), transparent),
    radial-gradient(8px 8px at 90% 45%, rgba(255, 118, 117, 0.12), transparent);
  background-size: 400px 400px;
  animation: dots-drift 90s linear infinite;
}

/* Subtle paper texture for warmth */
.screen-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  pointer-events: none;
}

@keyframes dots-drift {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(-200px, -200px);
  }
}

/* ─── Typography ─── */
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
}

.title-hero {
  font-size: var(--font-size-hero);
  background: linear-gradient(135deg, #ff6b35, #e17055, #0984e3);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer-text 4s ease-in-out infinite;
  filter: drop-shadow(0 3px 6px rgba(255, 107, 53, 0.2));
}

@keyframes shimmer-text {

  0%,
  100% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }
}

.title-lg {
  font-size: var(--font-size-3xl);
  color: var(--color-text);
}

.title-md {
  font-size: var(--font-size-2xl);
  color: var(--color-text);
}

.subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-text-dim);
  font-weight: 500;
}

/* ─── Buttons — Chunky Candy for Kids ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 600;
  cursor: pointer;
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 200ms ease;
  min-height: 56px;
  min-width: 56px;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: white;
  will-change: transform;
}

/* Top highlight — candy sheen */
.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 45%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, transparent 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 50% 50%;
  pointer-events: none;
}

.btn:active {
  transform: scale(0.95) translateY(4px);
}

.btn-primary {
  background: linear-gradient(180deg, #ff8c5a, #ff6b35);
  box-shadow: 0 6px 0 #cc5528, 0 8px 20px rgba(255, 107, 53, 0.25);
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 #cc5528, 0 12px 28px rgba(255, 107, 53, 0.35);
}

.btn-primary:active {
  box-shadow: 0 2px 0 #cc5528;
}

.btn-success {
  background: linear-gradient(180deg, #55efc4, #00b894);
  box-shadow: 0 6px 0 #009975, 0 8px 20px rgba(0, 184, 148, 0.25);
}

.btn-success:hover {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 #009975, 0 12px 28px rgba(0, 184, 148, 0.35);
}

.btn-accent {
  background: linear-gradient(180deg, #ffeaa7, #fdcb6e);
  color: #6c5200;
  box-shadow: 0 6px 0 #d4a84e, 0 8px 20px rgba(253, 203, 110, 0.3);
}

.btn-accent:hover {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 #d4a84e, 0 12px 28px rgba(253, 203, 110, 0.4);
}

.btn-danger {
  background: linear-gradient(180deg, #ff8787, #ff6b6b);
  box-shadow: 0 6px 0 #cc5555, 0 8px 20px rgba(255, 107, 107, 0.25);
}

.btn-ghost {
  background: var(--color-surface);
  border: 2px solid #dfe6e9;
  color: var(--color-text);
  box-shadow: 0 4px 0 #d5dce0, var(--shadow-sm);
}

.btn-ghost:hover {
  background: #f8fbfc;
  border-color: #b2bec3;
}

.btn-ghost::after {
  display: none;
}

.btn-ghost:active {
  box-shadow: 0 1px 0 #d5dce0;
}

.btn-lg {
  padding: var(--space-lg) var(--space-2xl);
  font-size: var(--font-size-xl);
  min-height: 72px;
  border-radius: var(--radius-xl);
}

.btn-sm {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  min-height: 40px;
  border-radius: var(--radius-md);
}

.btn-icon {
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xl);
}

/* ─── World Buttons ─── */
.btn-world {
  width: 100%;
  padding: var(--space-lg);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  border: 3px solid #eef2f5;
  border-left: 6px solid var(--world-primary);
  text-align: left;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-height: 80px;
  box-shadow: 0 4px 0 #d5dce0, var(--shadow-sm);
  transition: all 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--color-text);
}

.btn-world:hover {
  transform: translateX(4px) translateY(-2px);
  box-shadow: 0 7px 0 #d5dce0, 0 10px 24px rgba(0, 0, 0, 0.06);
  border-left-color: var(--world-primary);
}

.btn-world::after {
  display: none;
}

.btn-world.locked {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(0.5);
  border-left-color: #dfe6e9;
}

.world-icon-img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.1));
  margin-right: var(--space-md);
  transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-world:hover .world-icon-img {
  transform: scale(1.1) rotate(5deg);
}

.btn-world .world-info {
  flex: 1;
}

.btn-world .world-name {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text);
}

.btn-world .world-tables {
  font-size: var(--font-size-sm);
  color: var(--color-text-dim);
}

.btn-world .world-progress {
  width: 48px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-text-dim);
}

/* ─── Cards ─── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 2px solid #eef2f5;
  padding: var(--space-lg);
  transition: all var(--transition-normal);
  box-shadow: 0 4px 0 #d5dce0, var(--shadow-sm);
}

.card:hover {
  border-color: #d5dce0;
  box-shadow: 0 6px 0 #d5dce0, var(--shadow-md);
  transform: translateY(-2px);
}

/* ─── Mode Selection Cards ─── */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  width: 100%;
  max-width: 600px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xl) var(--space-md);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  border: 3px solid #eef2f5;
  cursor: pointer;
  transition: all 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 140px;
  box-shadow: 0 6px 0 #d5dce0, var(--shadow-sm);
  position: relative;
  overflow: hidden;
  will-change: transform;
  color: var(--color-text);
}

.mode-card:active {
  transform: scale(0.95) translateY(4px);
  box-shadow: 0 2px 0 #d5dce0;
}

.mode-card:hover {
  border-color: var(--world-primary);
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.08), 0 14px 28px rgba(0, 0, 0, 0.06);
}

.mode-card .mode-icon {
  font-size: var(--font-size-4xl);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.1));
  transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mode-card:hover .mode-icon {
  transform: scale(1.2) rotate(-5deg);
}

.mode-card .mode-name {
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  font-weight: 600;
}

.mode-card.locked {
  opacity: 0.35;
  pointer-events: none;
}

/* ─── Progress Bar ─── */
.progress-bar {
  width: 100%;
  height: 14px;
  background: #eef2f5;
  border-radius: 7px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-secondary), #55efc4, var(--color-accent));
  border-radius: 7px;
  transition: width var(--transition-slow);
  position: relative;
  box-shadow: 0 0 8px rgba(0, 184, 148, 0.3);
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 7px 7px 0 0;
}

/* ─── Game Area ─── */
.game-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
}

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

.stat-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text);
}

.stat-icon {
  font-size: var(--font-size-xl);
}

.game-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xl);
  width: 100%;
  max-width: 700px;
  padding-top: 70px;
}

/* ─── Question Display ─── */
.question-display {
  text-align: center;
  padding: var(--space-xl);
}

.question-text {
  font-family: var(--font-display);
  font-size: var(--font-size-4xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.question-text .operator {
  color: var(--color-primary);
  text-shadow: 0 2px 4px rgba(255, 107, 53, 0.2);
}

.question-text .unknown {
  display: inline-block;
  width: 80px;
  height: 60px;
  border-bottom: 4px solid var(--color-primary);
  margin: 0 var(--space-sm);
  animation: pulse-glow 2s ease-in-out infinite;
}

.question-label {
  font-size: var(--font-size-lg);
  color: var(--color-text-dim);
  margin-bottom: var(--space-md);
}

/* ─── Answer Options — BIG chunky candy buttons ─── */
.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  width: 100%;
  max-width: 500px;
}

.answer-btn {
  padding: var(--space-lg);
  border: 3px solid #eef2f5;
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  font-family: var(--font-display);
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
  transition: all 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 0 #d5dce0, var(--shadow-sm);
  will-change: transform;
}

.answer-btn:active {
  transform: scale(0.95) translateY(4px);
  box-shadow: 0 2px 0 #d5dce0;
}

.answer-btn:hover {
  border-color: var(--color-sky);
  background: #f0f8ff;
  transform: translateY(-3px);
  box-shadow: 0 9px 0 #d5dce0, 0 12px 20px rgba(0, 0, 0, 0.06);
}

.answer-btn.correct {
  background: linear-gradient(180deg, #55efc4, #00b894) !important;
  border-color: #00b894 !important;
  color: white !important;
  animation: correct-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 6px 0 #009975, 0 0 24px rgba(0, 184, 148, 0.3) !important;
}

.answer-btn.wrong {
  background: linear-gradient(180deg, #ff8787, #ff6b6b) !important;
  border-color: #ff6b6b !important;
  color: white !important;
  animation: shake 0.5s ease;
  box-shadow: 0 6px 0 #cc5555 !important;
}

/* ─── Learn Mode Blocks ─── */
.blocks-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  justify-content: center;
  align-items: flex-end;
  padding: var(--space-xl);
  min-height: 200px;
}

.block-group {
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  align-items: center;
  transition: all var(--transition-spring);
}

.block {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: white;
  animation: block-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15), var(--shadow-inner-light);
}

.block-label {
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  font-weight: 600;
  margin-top: var(--space-xs);
  color: var(--color-text-dim);
}

/* Block Colors — Bright candy */
.block-1 {
  background: linear-gradient(180deg, #ff8787, #ff6b6b);
}

.block-2 {
  background: linear-gradient(180deg, #ff9f43, #e17055);
}

.block-3 {
  background: linear-gradient(180deg, #ffeaa7, #fdcb6e);
  color: #6c5200;
}

.block-4 {
  background: linear-gradient(180deg, #55efc4, #00b894);
}

.block-5 {
  background: linear-gradient(180deg, #74b9ff, #0984e3);
}

.block-6 {
  background: linear-gradient(180deg, #ff8c5a, #ff6b35);
}

.block-7 {
  background: linear-gradient(180deg, #fd79a8, #e84393);
}

.block-8 {
  background: linear-gradient(180deg, #74b9ff, #0984e3);
}

.block-9 {
  background: linear-gradient(180deg, #55efc4, #00cec9);
}

.block-10 {
  background: linear-gradient(180deg, #badc58, #6ab04c);
}

.block-11 {
  background: linear-gradient(180deg, #ff9f43, #e17055);
}

/* ─── Challenge Mode Grid ─── */
.challenge-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
  width: 100%;
  max-width: 500px;
}

.challenge-tile {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 3px solid #c8d6e5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  transition: all 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: var(--space-xs);
  text-align: center;
  line-height: 1.2;
  box-shadow: 0 4px 0 #b2bec3, var(--shadow-sm);
  will-change: transform;
}

.challenge-tile:active {
  transform: scale(0.92) translateY(3px);
  box-shadow: 0 1px 0 #d5dce0;
}

.challenge-tile.selected {
  border-color: var(--color-primary);
  background: #fff5ee;
  box-shadow: 0 4px 0 #d5dce0, 0 0 16px rgba(255, 107, 53, 0.15);
  transform: translateY(-2px);
}

.challenge-tile.matched {
  background: linear-gradient(180deg, #55efc4, #00b894);
  border-color: #00b894;
  color: white;
  opacity: 0.8;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(0, 184, 148, 0.2);
}

.challenge-tile.wrong-match {
  animation: shake 0.4s ease;
  border-color: var(--color-danger);
}

/* ─── Adventure Mode ─── */
.adventure-scene {
  width: 100%;
  max-width: 700px;
  height: 200px;
  background: linear-gradient(180deg, #dfe6e9, #eef2f5);
  border-radius: var(--radius-xl);
  position: relative;
  overflow: hidden;
  border: 3px solid #d5dce0;
  box-shadow: var(--shadow-md), inset 0 -40px 60px rgba(0, 0, 0, 0.03);
}

.adventure-character {
  position: absolute;
  bottom: 20px;
  font-size: 48px;
  transition: left 1s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
}

.adventure-path {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  height: 4px;
  background: #d5dce0;
}

.adventure-obstacle {
  position: absolute;
  bottom: 20px;
  font-size: 36px;
  transition: all var(--transition-normal);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.adventure-obstacle.cleared {
  transform: scale(0) rotate(360deg);
  opacity: 0;
}

/* ─── Medal Showcase ─── */
.medal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--space-md);
  width: 100%;
  max-width: 600px;
}

.medal-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 2px solid #eef2f5;
  transition: all 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 3px 0 #d5dce0;
}

.medal-item:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 7px 0 #d5dce0, var(--shadow-md);
}

.medal-icon {
  font-size: var(--font-size-3xl);
}

.medal-name {
  font-family: var(--font-display);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-align: center;
  color: var(--color-text-dim);
}

.medal-item.earned {
  border-color: var(--color-gold);
  background: #fffbea;
  box-shadow: 0 3px 0 #d4a84e, 0 0 12px rgba(255, 195, 18, 0.15);
}

.medal-item.earned .medal-name {
  color: #e17055;
}

.medal-item.locked .medal-icon {
  filter: grayscale(1) opacity(0.3);
}

/* ─── Streak Display ─── */
.streak-display {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-xl);
  background: #fff5ee;
  border: 2px solid #fab1a0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--font-size-lg);
  color: #e17055;
}

.streak-display.on-fire {
  background: #ffe8e0;
  animation: fire-pulse 0.5s ease infinite alternate;
  box-shadow: 0 0 16px rgba(255, 107, 53, 0.15);
}

/* ─── Feedback Overlay ─── */
.feedback-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.feedback-overlay.show {
  opacity: 1;
}

.feedback-emoji {
  font-size: 120px;
  animation: feedback-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.15));
}

/* ─── Medal Popup ─── */
.medal-popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.medal-popup.show {
  opacity: 1;
  visibility: visible;
}

.medal-popup-content {
  text-align: center;
  animation: medal-reveal 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.medal-popup .medal-big {
  font-size: 100px;
  display: block;
  margin-bottom: var(--space-md);
  filter: drop-shadow(0 8px 20px rgba(255, 195, 18, 0.3));
}

.medal-popup .medal-title {
  font-family: var(--font-display);
  font-size: var(--font-size-2xl);
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
}

.medal-popup .medal-desc {
  font-size: var(--font-size-md);
  color: var(--color-text-dim);
  margin-bottom: var(--space-xl);
}

/* ─── Parent Dashboard ─── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  width: 100%;
  max-width: 800px;
}

.dashboard-stat {
  text-align: center;
  padding: var(--space-lg);
}

.dashboard-stat .stat-value {
  font-family: var(--font-display);
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--color-primary);
}

.dashboard-stat .stat-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-dim);
  margin-top: var(--space-xs);
}

/* Mastery Heatmap */
.mastery-grid {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 600px;
}

.mastery-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--font-size-xs);
  font-weight: 600;
  transition: all var(--transition-normal);
}

.mastery-cell.mastery-0 {
  background: #eef2f5;
  color: var(--color-text-dim);
}

.mastery-cell.mastery-1 {
  background: #ffe0e0;
  color: #ff6b6b;
}

.mastery-cell.mastery-2 {
  background: #ffe8d0;
  color: #e17055;
}

.mastery-cell.mastery-3 {
  background: #fff4d0;
  color: #d4a84e;
}

.mastery-cell.mastery-4 {
  background: #d0f7e8;
  color: #00b894;
}

.mastery-cell.mastery-5 {
  background: #ffe0cc;
  color: #ff6b35;
}

/* ─── Level Complete Screen ─── */
.level-complete {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}

.stars-display {
  display: flex;
  gap: var(--space-md);
  font-size: var(--font-size-4xl);
}

.star {
  opacity: 0.2;
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.star.earned {
  opacity: 1;
  animation: star-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  filter: drop-shadow(0 0 10px rgba(255, 195, 18, 0.5));
}

.star:nth-child(2).earned {
  animation-delay: 0.2s;
}

.star:nth-child(3).earned {
  animation-delay: 0.4s;
}

/* ─── Confetti ─── */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

/* ─── Scrollable Content ─── */
.scroll-content {
  width: 100%;
  max-width: 700px;
  overflow-y: auto;
  flex: 1;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* ─── Navigation ─── */
.nav-bar {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm);
}

.back-btn {
  position: absolute;
  top: var(--space-md);
  left: var(--space-md);
  z-index: 20;
}

/* ─── PIN Entry ─── */
.pin-input {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
}

.pin-digit {
  width: 56px;
  height: 64px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 3px solid #dfe6e9;
  font-family: var(--font-display);
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  outline: none;
  transition: all var(--transition-fast);
}

.pin-digit:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 12px rgba(255, 107, 53, 0.2);
}

.pin-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  max-width: 280px;
  margin: 0 auto;
}

.pin-numpad .btn {
  font-size: var(--font-size-xl);
  min-height: 64px;
}

/* ─── Level Select ─── */
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-md);
  width: 100%;
  max-width: 400px;
}

.level-btn {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 3px solid #eef2f5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: all 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
  box-shadow: 0 3px 0 #d5dce0;
}

.level-btn:hover:not(.locked) {
  border-color: var(--world-primary);
  transform: translateY(-3px);
  box-shadow: 0 6px 0 #d5dce0, var(--shadow-md);
}

.level-btn.completed {
  border-color: #00b894;
  background: #e8faf4;
  box-shadow: 0 3px 0 #009975;
}

.level-btn.locked {
  opacity: 0.3;
  pointer-events: none;
}

.level-btn .level-stars {
  font-size: 10px;
  letter-spacing: 1px;
}

/* ─── Splash Screen Extras ─── */
.splash-particle {
  position: absolute;
  font-size: 1.5em;
  opacity: 0.3;
  animation: float-particle 6s ease-in-out infinite;
  pointer-events: none;
}

.splash-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Pulsing ring around play button */
.splash-btn {
  position: relative;
}

.splash-btn::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: var(--radius-xl);
  border: 3px solid var(--color-primary);
  opacity: 0;
  animation: pulse-ring 2s ease-in-out infinite;
}

@keyframes pulse-ring {
  0% {
    transform: scale(1);
    opacity: 0.4;
  }

  100% {
    transform: scale(1.12);
    opacity: 0;
  }
}

@keyframes float-particle {

  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-30px) rotate(10deg);
  }
}

/* ─── Utilities ─── */
.text-center {
  text-align: center;
}

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

.flex-col {
  display: flex;
  flex-direction: column;
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

.gap-xl {
  gap: var(--space-xl);
}

.w-full {
  width: 100%;
}

.max-w-sm {
  max-width: 400px;
}

.max-w-md {
  max-width: 600px;
}

.max-w-lg {
  max-width: 800px;
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  :root {
    --font-size-hero: 3.5rem;
    --font-size-4xl: 2.5rem;
    --font-size-3xl: 2rem;
  }

  .mode-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .challenge-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .level-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-sm);
  }

  .answer-grid {
    gap: var(--space-sm);
  }
}

@media (max-width: 480px) {
  :root {
    --font-size-hero: 2.5rem;
    --font-size-4xl: 2rem;
  }

  .blocks-container {
    padding: var(--space-md);
  }

  .block {
    width: 36px;
    height: 36px;
    font-size: var(--font-size-sm);
  }
}

/* ─── Landscape optimization for tablet ─── */
@media (min-width: 768px) and (orientation: landscape) {
  .game-content {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .question-display {
    flex: 1;
    min-width: 300px;
  }

  .answer-grid {
    flex: 1;
    min-width: 300px;
  }
}

/* ─── Nanobanana Seamless Backgrounds ─── */
@keyframes bg-drift {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 512px 512px;
  }
}

[data-world="dino"] .screen-bg,
[data-world="racing"] .screen-bg,
[data-world="ocean"] .screen-bg,
[data-world="space"] .screen-bg,
[data-world="volcano"] .screen-bg,
[data-world="crystal"] .screen-bg {
  background-repeat: repeat !important;
  background-size: 512px !important;
  animation: bg-drift 120s linear infinite;
  background-color: #fdfdfd;
}

/* Specific Images */
[data-world="dino"] .screen-bg {
  background-image: url('../img/bg_dino.png') !important;
  background-color: #e8f5e9;
}

[data-world="racing"] .screen-bg {
  background-image: url('../img/bg_racing.png') !important;
  background-color: #fff3e0;
}

[data-world="ocean"] .screen-bg {
  background-image: url('../img/bg_ocean.png') !important;
  background-color: #e0f7fa;
}

[data-world="space"] .screen-bg {
  background-image: url('../img/bg_space.png') !important;
  background-color: #ede7f6;
  animation-duration: 240s;
}

[data-world="volcano"] .screen-bg {
  background-image: url('../img/bg_volcano.png') !important;
  background-color: #fff8e1;
}

[data-world="crystal"] .screen-bg {
  background-image: url('../img/bg_crystal.png') !important;
  background-color: #fce4ec;
}

/* Overlay for text readability (replaces dots) */
[data-world="dino"] .screen-bg::before,
[data-world="racing"] .screen-bg::before,
[data-world="ocean"] .screen-bg::before,
[data-world="volcano"] .screen-bg::before,
[data-world="crystal"] .screen-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  /* Soft white overlay */
  backdrop-filter: blur(1px);
  z-index: 1;
  animation: none;
  /* Stop the dots animation */
}

/* Space needs darker overlay or less white */
[data-world="space"] .screen-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(25, 20, 40, 0.4);
  /* Darkening for space */
  backdrop-filter: blur(1px);
  z-index: 1;
  animation: none;
}
/* ─── Nanobanana Icons ─── */
.mode-icon-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: var(--space-sm);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
  transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mode-card:hover .mode-icon-img {
  transform: scale(1.1) rotate(5deg);
}

.mode-card.locked .mode-icon-img {
  opacity: 0.5;
  filter: grayscale(1);
}

.medal-img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin-bottom: var(--space-xs);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
  transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.medal-item:hover .medal-img {
  transform: scale(1.1) rotate(5deg);
}

.medal-item.locked .medal-img {
  opacity: 0.4;
  filter: grayscale(1);
  transform: scale(0.9);
}

/* ─── Saga Map Styles ─── */
.saga-map {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  /* Background handled by .screen-bg */
}

.saga-canvas {
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.saga-path-stroke {
  opacity: 0.8;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.1));
}

.saga-node {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid white;
  background: radial-gradient(circle at 30% 30%, #fff, #2196f3); /* Default Blue */
  box-shadow: 0 4px 0 #1976d2, 0 6px 12px rgba(0,0,0,0.2);
  color: white;
  font-weight: 800;
  font-size: 1.5em;
  text-shadow: 0 2px 0 rgba(0,0,0,0.2);
  transform: translate(-50%, -50%); /* Center anchor */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s;
  cursor: pointer;
  z-index: 10;
}

.saga-node:active {
  transform: translate(-50%, -46%) scale(0.95);
  box-shadow: 0 2px 0 #1976d2, 0 3px 6px rgba(0,0,0,0.2);
}

.saga-node.completed {
  background: radial-gradient(circle at 30% 30%, #fff, #4caf50); /* Green */
  box-shadow: 0 4px 0 #388e3c, 0 6px 12px rgba(0,0,0,0.2);
}

.saga-node.locked {
  background: radial-gradient(circle at 30% 30%, #eee, #9e9e9e); /* Grey */
  box-shadow: 0 4px 0 #757575, 0 6px 12px rgba(0,0,0,0.2);
  color: #bdbdbd;
  cursor: default;
  pointer-events: none;
}

/* Stars below node */
.node-stars-row {
  position: absolute;
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.8em;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.2));
}

/* Avatar */
.saga-avatar {
  position: absolute;
  width: 80px; /* Bigger than node */
  height: 80px;
  transform: translate(-50%, -100%); /* Sit on top of node */
  z-index: 20;
  pointer-events: none;
  animation: bounce-float 2s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}

.saga-avatar img.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.3));
}

.saga-avatar::after {
  content: 'YOU';
  position: absolute;
  top: -25px;
  background: white;
  color: black;
  font-weight: bold;
  font-size: 0.7em;
  padding: 2px 8px;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  animation: bounce-float 2s ease-in-out infinite reverse; /* Keep steady? No, bounce with avatar */
}

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

/* Floating back button */
.floating-back-btn {
  transition: transform 0.2s;
}
.floating-back-btn:active {
  transform: scale(0.9);
}
