/* Art direction: Children's reading game → warm, cheerful, playful yet clean
   Palette: Pink & Coral primary, peach accent — bright, feminine, and encouraging
   Typography: Nunito (body, rounded and friendly) + Baloo 2 (display, fun and warm)
   Density: spacious — large touch targets, generous whitespace for young readers */

/* ========== iOS / MOBILE TOUCH FIXES ========== */
* {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  -webkit-touch-callout: none;
}
html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
  height: 100%;
}
body {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  position: relative;
  min-height: 100%;
  height: auto;
}
.main-content, #main-content {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
  min-height: 0;
}

/* iOS Capacitor safe areas */
body.capacitor-ios {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Fix iOS touch scrolling in all scrollable containers */
* {
  -webkit-overflow-scrolling: touch;
}
button, a, .nav-item, [onclick] {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
/* Safe area insets for notched iPhones */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ========== DESIGN TOKENS ========== */
:root {
  /* Type Scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);

  /* Fonts */
  --font-body: 'Nunito', 'Segoe UI', sans-serif;
  --font-display: 'Baloo 2', 'Nunito', sans-serif;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Radius */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-interactive: 200ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Content widths */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;
}

/* ========== LIGHT MODE (default) ========== */
:root, [data-theme="light"] {
  --color-bg:             #fef7f5;
  --color-surface:        #ffffff;
  --color-surface-2:      #fdf0ed;
  --color-surface-offset: #f8e8e3;
  --color-divider:        #f0ddd7;
  --color-border:         #e6cfc8;

  --color-text:           #3a2028;
  --color-text-muted:     #7a5a65;
  --color-text-faint:     #b89da8;
  --color-text-inverse:   #ffffff;

  /* Primary — Warm Pink */
  --color-primary:        #e4637e;
  --color-primary-hover:  #d14f6b;
  --color-primary-active: #be3d5a;
  --color-primary-light:  #fde8ed;
  --color-primary-surface: #fef1f4;

  /* Accent — Coral Peach */
  --color-accent:         #f0906a;
  --color-accent-hover:   #e67d55;
  --color-accent-light:   #fef0e8;

  /* Success — Soft Green */
  --color-success:        #5bb87a;
  --color-success-light:  #e8f7ee;

  /* Error — Warm Red */
  --color-error:          #d94e4e;
  --color-error-light:    #fde8e8;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(58, 32, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(58, 32, 40, 0.08);
  --shadow-lg: 0 8px 30px rgba(58, 32, 40, 0.12);
  --shadow-glow: 0 0 20px rgba(228, 99, 126, 0.15);

  /* Hero banner */
  --hero-gradient: linear-gradient(135deg, #fef3c7, #fde68a, #fbbf24);
  --hero-text: #78350f;
  --hero-text-sub: #92400e;
  --hero-xp-bar-bg: rgba(120,53,15,0.25);
  --hero-xp-bar-border: rgba(120,53,15,0.2);
  --hero-xp-fill: linear-gradient(90deg, #f97316, #ef4444);
  --hero-streak-bg: rgba(255,255,255,0.9);
  --hero-streak-color: #b45309;
  --hero-avatar-border: white;

  /* Goal / progress colors */
  --goal-done-border: #22c55e;
  --goal-done-bg: #f0fdf4;
  --goal-done-text: #16a34a;
  --weekly-bar-bg: #e2e8f0;
  --weekly-fill: linear-gradient(90deg, #f59e0b, #ef4444);
  --weekly-count-color: #f59e0b;
  --start-pill-bg: var(--color-primary);
  --start-pill-color: #fff;

  /* Stat fallbacks */
  --stat-hover-border: #e2e8f0;
  --stat-value-color: #1e293b;
  --suggestion-color: var(--color-primary);

  /* Feedback states (shared across all modules) */
  --feedback-correct-bg: #dcfce7;
  --feedback-correct-text: #166534;
  --feedback-correct-border: #22c55e;
  --feedback-correct-light: #f0fdf4;
  --feedback-wrong-bg: #fef2f2;
  --feedback-wrong-text: #7f1d1d;
  --feedback-wrong-border: #ef4444;
  --feedback-wrong-light: #fee2e2;
  --feedback-info-bg: #fef3c7;
  --feedback-info-text: #78350f;
  --feedback-info-border: #f59e0b;
  --feedback-completed-bg: #f0fdf4;
  --feedback-completed-border: #86efac;
  --feedback-completed-text: #14532d;
}

/* ========== DARK MODE ========== */
[data-theme="dark"] {
  --color-bg:             #1e1418;
  --color-surface:        #291c22;
  --color-surface-2:      #32222a;
  --color-surface-offset: #221820;
  --color-divider:        #3e2c34;
  --color-border:         #503a44;

  --color-text:           #f0e4e8;
  --color-text-muted:     #ad8f98;
  --color-text-faint:     #7d5f6a;
  --color-text-inverse:   #1e1418;

  --color-primary:        #f08da0;
  --color-primary-hover:  #f5a3b3;
  --color-primary-active: #e47388;
  --color-primary-light:  #3a2028;
  --color-primary-surface: #2e1a22;

  --color-accent:         #f5a882;
  --color-accent-hover:   #f8bb9a;
  --color-accent-light:   #3a2a1e;

  --color-success:        #70d090;
  --color-success-light:  #1e3a28;

  --color-error:          #f08080;
  --color-error-light:    #3a1e1e;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 20px rgba(240, 141, 160, 0.2);

  /* Hero banner dark */
  --hero-gradient: linear-gradient(135deg, #3a2a1e, #4a3020, #5a3a22);
  --hero-text: #fde68a;
  --hero-text-sub: #fbbf24;
  --hero-xp-bar-bg: rgba(251,191,36,0.2);
  --hero-xp-bar-border: rgba(251,191,36,0.15);
  --hero-xp-fill: linear-gradient(90deg, #f97316, #ef4444);
  --hero-streak-bg: rgba(0,0,0,0.4);
  --hero-streak-color: #fbbf24;
  --hero-avatar-border: rgba(255,255,255,0.3);

  /* Goal / progress dark */
  --goal-done-border: #166534;
  --goal-done-bg: #14532d;
  --goal-done-text: #4ade80;
  --weekly-bar-bg: #334155;
  --weekly-fill: linear-gradient(90deg, #f59e0b, #ef4444);
  --weekly-count-color: #fbbf24;
  --start-pill-bg: var(--color-primary);
  --start-pill-color: #fff;

  /* Stat fallbacks dark */
  --stat-hover-border: #334155;
  --stat-value-color: #e2e8f0;
  --suggestion-color: var(--color-primary);

  /* Feedback states dark */
  --feedback-correct-bg: #14532d;
  --feedback-correct-text: #4ade80;
  --feedback-correct-border: #166534;
  --feedback-correct-light: #052e16;
  --feedback-wrong-bg: #450a0a;
  --feedback-wrong-text: #fca5a5;
  --feedback-wrong-border: #991b1b;
  --feedback-wrong-light: #3a1e1e;
  --feedback-info-bg: #451a03;
  --feedback-info-text: #fde68a;
  --feedback-info-border: #b45309;
  --feedback-completed-bg: #052e16;
  --feedback-completed-border: #166534;
  --feedback-completed-text: #4ade80;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:             #1e1418;
    --color-surface:        #291c22;
    --color-surface-2:      #32222a;
    --color-surface-offset: #221820;
    --color-divider:        #3e2c34;
    --color-border:         #503a44;
    --color-text:           #f0e4e8;
    --color-text-muted:     #ad8f98;
    --color-text-faint:     #7d5f6a;
    --color-text-inverse:   #1e1418;
    --color-primary:        #f08da0;
    --color-primary-hover:  #f5a3b3;
    --color-primary-active: #e47388;
    --color-primary-light:  #3a2028;
    --color-primary-surface: #2e1a22;
    --color-accent:         #f5a882;
    --color-accent-hover:   #f8bb9a;
    --color-accent-light:   #3a2a1e;
    --color-success:        #70d090;
    --color-success-light:  #1e3a28;
    --color-error:          #f08080;
    --color-error-light:    #3a1e1e;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 20px rgba(240, 141, 160, 0.2);
  }
}

/* ============================================================
   BLUE & TEAL THEME
   ============================================================ */
[data-color-theme="blue"] {
  --color-bg:             #f0f7fa;
  --color-surface:        #ffffff;
  --color-surface-2:      #e6f2f7;
  --color-surface-offset: #daedf5;
  --color-divider:        #c4dde8;
  --color-border:         #a8cdd8;

  --color-text:           #1a2e38;
  --color-text-muted:     #4a7080;
  --color-text-faint:     #8db0be;
  --color-text-inverse:   #ffffff;

  /* Primary — Ocean Blue */
  --color-primary:        #3a8ec2;
  --color-primary-hover:  #2d7aad;
  --color-primary-active: #21669a;
  --color-primary-light:  #e0f0fa;
  --color-primary-surface: #eaf5fc;

  /* Accent — Teal */
  --color-accent:         #2bb5a0;
  --color-accent-hover:   #22a08c;
  --color-accent-light:   #e0f7f3;

  --color-success:        #5bb87a;
  --color-success-light:  #e8f7ee;

  --color-error:          #d94e4e;
  --color-error-light:    #fde8e8;

  --shadow-sm: 0 1px 3px rgba(26, 46, 56, 0.06);
  --shadow-md: 0 4px 12px rgba(26, 46, 56, 0.08);
  --shadow-lg: 0 8px 30px rgba(26, 46, 56, 0.12);
  --shadow-glow: 0 0 20px rgba(58, 142, 194, 0.15);

  /* Hero banner blue light */
  --hero-gradient: linear-gradient(135deg, #dbeafe, #93c5fd, #3b82f6);
  --hero-text: #1e3a5f;
  --hero-text-sub: #1e40af;
  --hero-xp-bar-bg: rgba(30,64,175,0.2);
  --hero-xp-bar-border: rgba(30,64,175,0.15);
  --hero-xp-fill: linear-gradient(90deg, #3a8ec2, #2bb5a0);
  --hero-streak-bg: rgba(255,255,255,0.9);
  --hero-streak-color: #1e40af;
  --hero-avatar-border: white;

  /* Goal / progress blue light */
  --goal-done-border: #22c55e;
  --goal-done-bg: #f0fdf4;
  --goal-done-text: #16a34a;
  --weekly-bar-bg: #cbd5e1;
  --weekly-fill: linear-gradient(90deg, #3a8ec2, #2bb5a0);
  --weekly-count-color: #3a8ec2;
  --start-pill-bg: var(--color-primary);
  --start-pill-color: #fff;

  --stat-hover-border: #bfdbfe;
  --stat-value-color: #1e3a5f;
  --suggestion-color: var(--color-primary);
}

[data-color-theme="blue"][data-theme="dark"] {
  --color-bg:             #121e24;
  --color-surface:        #1a2c34;
  --color-surface-2:      #22343e;
  --color-surface-offset: #162228;
  --color-divider:        #2e4450;
  --color-border:         #3a5562;

  --color-text:           #e0eff5;
  --color-text-muted:     #8cb8cc;
  --color-text-faint:     #5a8898;
  --color-text-inverse:   #121e24;

  --color-primary:        #5aade0;
  --color-primary-hover:  #72bde8;
  --color-primary-active: #4899cc;
  --color-primary-light:  #1a2c34;
  --color-primary-surface: #162228;

  --color-accent:         #42d4be;
  --color-accent-hover:   #5ae0cc;
  --color-accent-light:   #1a3430;

  --color-success:        #70d090;
  --color-success-light:  #1e3a28;

  --color-error:          #f08080;
  --color-error-light:    #3a1e1e;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 20px rgba(90, 173, 224, 0.2);

  /* Hero banner blue dark */
  --hero-gradient: linear-gradient(135deg, #172554, #1e3a5f, #1e40af);
  --hero-text: #93c5fd;
  --hero-text-sub: #60a5fa;
  --hero-xp-bar-bg: rgba(96,165,250,0.2);
  --hero-xp-bar-border: rgba(96,165,250,0.15);
  --hero-xp-fill: linear-gradient(90deg, #5aade0, #42d4be);
  --hero-streak-bg: rgba(0,0,0,0.4);
  --hero-streak-color: #93c5fd;
  --hero-avatar-border: rgba(255,255,255,0.3);

  /* Goal / progress blue dark */
  --goal-done-border: #166534;
  --goal-done-bg: #14532d;
  --goal-done-text: #4ade80;
  --weekly-bar-bg: #1e3a5f;
  --weekly-fill: linear-gradient(90deg, #5aade0, #42d4be);
  --weekly-count-color: #5aade0;
  --start-pill-bg: var(--color-primary);
  --start-pill-color: #fff;

  --stat-hover-border: #1e3a5f;
  --stat-value-color: #e0eff5;
  --suggestion-color: var(--color-primary);
}

@media (prefers-color-scheme: dark) {
  [data-color-theme="blue"]:not([data-theme]) {
    --color-bg:             #121e24;
    --color-surface:        #1a2c34;
    --color-surface-2:      #22343e;
    --color-surface-offset: #162228;
    --color-divider:        #2e4450;
    --color-border:         #3a5562;
    --color-text:           #e0eff5;
    --color-text-muted:     #8cb8cc;
    --color-text-faint:     #5a8898;
    --color-text-inverse:   #121e24;
    --color-primary:        #5aade0;
    --color-primary-hover:  #72bde8;
    --color-primary-active: #4899cc;
    --color-primary-light:  #1a2c34;
    --color-primary-surface: #162228;
    --color-accent:         #42d4be;
    --color-accent-hover:   #5ae0cc;
    --color-accent-light:   #1a3430;
    --color-success:        #70d090;
    --color-success-light:  #1e3a28;
    --color-error:          #f08080;
    --color-error-light:    #3a1e1e;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 20px rgba(90, 173, 224, 0.2);
  }
}

/* Theme picker styles */
.theme-picker-section {
  margin-top: var(--space-6);
  padding: var(--space-5);
  background: var(--color-surface);
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--color-divider);
}
.theme-picker-section h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  margin: 0 0 var(--space-2) 0;
}
.theme-picker-section p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-4) 0;
}
.theme-options {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md, 8px);
  border: 2px solid var(--color-border);
  background: var(--color-surface-2);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 120px;
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--color-text);
}
.theme-option:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.theme-option.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  box-shadow: 0 0 0 3px var(--color-primary-surface);
}
.theme-swatch {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #fff;
  border-radius: 6px;
}
.theme-swatch span {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: block;
}
.theme-option-label {
  font-weight: 600;
}


/* ========== APP LAYOUT ========== */
#app {
  display: flex;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overflow: visible;
}

/* --- SIDEBAR --- */
.sidebar {
  width: 240px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-divider);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-logo {
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.sidebar-logo svg {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.sidebar-logo h1 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: 0 var(--space-3);
}

.nav-group-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-4) 2px;
  margin-top: var(--space-2);
  opacity: 0.7;
}
.nav-group-label:first-child {
  margin-top: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  min-height: 32px;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--color-primary-light);
  color: var(--color-text);
}

.nav-item.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.nav-item.active:hover {
  background: var(--color-primary-hover);
}

.nav-item i {
  font-size: 16px;
  width: 20px;
  height: 16px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-divider);
  margin-top: auto;
}

.sidebar-xp {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.sidebar-xp .xp-bar {
  flex: 1;
  height: 6px;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.sidebar-xp .xp-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  width: 100%;
  min-height: 36px;
}

.theme-toggle-btn:hover {
  background: var(--color-surface-2);
}

/* --- MOBILE SIDEBAR --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  z-index: 98;
  padding: 0 var(--space-4);
  align-items: center;
  gap: var(--space-3);
}

.hamburger-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.hamburger-btn:hover {
  background: var(--color-surface-2);
}

@media (max-width: 768px), (min-width: 0px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open {
    display: block;
  }
  .mobile-header {
    display: flex;
  }
  .main-content {
    margin-left: 0 !important;
    padding-top: 72px !important;
  }
}

/* --- MAIN CONTENT --- */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: var(--space-8) var(--space-8) var(--space-12);
  max-width: 100%;
  overflow-x: hidden;
}

/* --- PAGE HEADER --- */
.page-header {
  margin-bottom: var(--space-8);
}

.page-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.page-header p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ========== STORY LIBRARY ========== */
.filter-bar {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

.filter-chip {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  min-height: 40px;
}

.filter-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.filter-chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-6);
}

.story-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  border: 1px solid var(--color-divider);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.story-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.story-card-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.story-card-level {
  display: inline-flex;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--color-primary-light);
  color: var(--color-primary);
  width: fit-content;
}

.story-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.story-card p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
  flex: 1;
}

.story-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
}

.story-progress {
  font-size: var(--text-xs);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.story-progress.not-started { color: var(--color-text-faint); }
.story-progress.in-progress { color: var(--color-accent); }
.story-progress.completed { color: var(--color-success); }

.story-topic {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-transform: capitalize;
}

/* ========== READING INTERFACE ========== */
.reading-view {
  max-width: 720px;
  margin: 0 auto;
}

.reading-controls-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  gap: var(--space-3);
  flex-wrap: wrap;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  min-height: 40px;
}

.back-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.font-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.font-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.font-btn:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.font-btn.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}

.reading-story-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.reading-story-header .story-emoji {
  font-size: 3rem;
  margin-bottom: var(--space-3);
}

.reading-story-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.reading-story-header .story-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Reading text area */
.reading-panel {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-8);
  border: 1px solid var(--color-divider);
  margin-bottom: var(--space-6);
  min-height: 200px;
  position: relative;
}

.reading-text {
  font-size: var(--text-base);
  line-height: 2;
  color: var(--color-text);
  max-width: 65ch;
  margin: 0 auto;
}

.reading-text.font-large {
  font-size: var(--text-lg);
  line-height: 2.2;
}

.reading-text.font-small {
  font-size: var(--text-sm);
  line-height: 1.9;
}

.reading-text.spacing-wide {
  line-height: 2.6;
}

.reading-text.font-large.spacing-wide {
  line-height: 2.8;
}

/* Vocabulary words */
.vocab-word {
  color: var(--color-primary);
  font-weight: 700;
  cursor: pointer;
  border-bottom: 2px dashed var(--color-primary);
  padding: 0 2px;
  border-radius: 2px;
  position: relative;
}

.vocab-word:hover {
  background: var(--color-primary-light);
}

/* Vocab popup */
.vocab-popup {
  position: fixed;
  z-index: 200;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-lg);
  max-width: 320px;
  width: 90vw;
  animation: popupIn 0.2s ease;
}

@keyframes popupIn {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.vocab-popup-word {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.vocab-popup-def {
  font-size: var(--text-sm);
  color: var(--color-text);
  margin-bottom: var(--space-3);
  line-height: 1.6;
}

.vocab-popup-example {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-style: italic;
  padding: var(--space-3);
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}

.vocab-popup-close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--color-text-faint);
  font-size: 18px;
}

.vocab-popup-close:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

/* Page navigation */
.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
}

.page-nav-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 700;
  min-height: 48px;
}

.page-nav-btn.primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.page-nav-btn.primary:hover {
  background: var(--color-primary-hover);
}

.page-nav-btn.secondary {
  background: var(--color-surface);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.page-nav-btn.secondary:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.page-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-indicator {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: 600;
}

/* Page progress bar */
.reading-progress {
  height: 4px;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-6);
  overflow: hidden;
}

.reading-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* ========== QUIZ ========== */
.quiz-container {
  max-width: 640px;
  margin: 0 auto;
}

.quiz-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.quiz-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.quiz-header p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.quiz-progress {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}

.quiz-dot {
  flex: 1;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  transition: background 0.3s ease;
}

.quiz-dot.correct { background: var(--color-success); }
.quiz-dot.incorrect { background: var(--color-error); }
.quiz-dot.current { background: var(--color-primary); }

.quiz-question {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  border: 1px solid var(--color-divider);
  margin-bottom: var(--space-6);
}

.quiz-question h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-6);
  line-height: 1.5;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.quiz-option {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  text-align: left;
  min-height: 52px;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.quiz-option.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.quiz-option.correct {
  border-color: var(--color-success);
  background: var(--color-success-light);
  color: var(--color-success);
}

.quiz-option.incorrect {
  border-color: var(--color-error);
  background: var(--color-error-light);
  color: var(--color-error);
}

.quiz-option .option-letter {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--color-surface-2);
  flex-shrink: 0;
}

.quiz-option.correct .option-letter {
  background: var(--color-success);
  color: white;
}

.quiz-option.incorrect .option-letter {
  background: var(--color-error);
  color: white;
}

.quiz-feedback {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: center;
  margin-top: var(--space-4);
  animation: popupIn 0.3s ease;
}

.quiz-feedback.correct {
  background: var(--color-success-light);
  color: var(--color-success);
}

.quiz-feedback.incorrect {
  background: var(--color-error-light);
  color: var(--color-error);
}

.quiz-next-btn {
  display: block;
  margin: var(--space-6) auto 0;
  padding: var(--space-3) var(--space-8);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 700;
  min-height: 48px;
}

.quiz-next-btn:hover {
  background: var(--color-primary-hover);
}

/* Quiz results */
.quiz-results {
  text-align: center;
  padding: var(--space-8);
}

.quiz-results .score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-6);
  font-family: var(--font-display);
}

.quiz-results .score-circle.great {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 3px solid var(--color-success);
}

.quiz-results .score-circle.good {
  background: var(--color-accent-light);
  color: var(--color-accent);
  border: 3px solid var(--color-accent);
}

.quiz-results .score-circle.try-again {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 3px solid var(--color-primary);
}

.score-number {
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1;
}

.score-label {
  font-size: var(--text-xs);
  font-weight: 600;
}

.quiz-results h3 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.quiz-results p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
  max-width: 100%;
}

.quiz-results-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

.points-earned {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  background: var(--color-accent-light);
  color: var(--color-accent);
  font-size: var(--text-sm);
  font-weight: 700;
  margin-bottom: var(--space-4);
  animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
  0% { transform: scale(0); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ========== BADGES PAGE ========== */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}

.badge-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  border: 1px solid var(--color-divider);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.badge-card.earned {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

.badge-card.locked {
  opacity: 0.5;
}

.badge-card .badge-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.badge-card.locked .badge-icon {
  filter: grayscale(1);
}

.badge-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
}

.badge-card p {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  max-width: 100%;
}

/* ========== PROFILE / AVATAR ========== */
.profile-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 600px;
  margin: 0 auto;
}

.avatar-display {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  border: 1px solid var(--color-divider);
  text-align: center;
}

.avatar-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  margin: 0 auto var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  position: relative;
  border: 4px solid var(--color-primary);
}

.avatar-hat {
  position: absolute;
  top: -20px;
  font-size: 2rem;
}

.avatar-companion {
  position: absolute;
  bottom: -10px;
  right: -10px;
  font-size: 1.8rem;
}

.avatar-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.avatar-level {
  font-size: var(--text-xs);
  color: var(--color-primary);
  font-weight: 700;
}

.avatar-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.avatar-stat {
  padding: var(--space-3);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  text-align: center;
}

.avatar-stat .stat-value {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
}

.avatar-stat .stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Avatar shop */
.avatar-shop {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  border: 1px solid var(--color-divider);
}

.shop-section {
  margin-bottom: var(--space-6);
}

.shop-section:last-child {
  margin-bottom: 0;
}

.shop-section h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.shop-items {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.shop-item {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  min-width: 80px;
  font-size: var(--text-xs);
}

.shop-item:hover:not(:disabled) {
  border-color: var(--color-primary);
}

.shop-item.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.shop-item.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.shop-item .item-emoji {
  font-size: 1.5rem;
}

.shop-item .item-cost {
  color: var(--color-accent);
  font-weight: 700;
}

/* ========== PARENT DASHBOARD ========== */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  border: 1px solid var(--color-divider);
}

.stat-card .stat-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-2);
}

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
}

.stat-card .stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.dashboard-section {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  border: 1px solid var(--color-divider);
  margin-bottom: var(--space-6);
}

.dashboard-section h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

/* Simple bar chart for dashboard */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  height: 160px;
  padding-top: var(--space-4);
}

.bar-chart-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  height: 100%;
  justify-content: flex-end;
}

.bar-chart-bar {
  width: 100%;
  max-width: 40px;
  background: var(--color-primary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 4px;
  transition: height 0.5s ease;
}

.bar-chart-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 600;
}

.bar-chart-value {
  font-size: var(--text-xs);
  color: var(--color-text);
  font-weight: 700;
}

/* Activity log */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.activity-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
}

.activity-item .activity-icon {
  font-size: 1.2rem;
}

.activity-item .activity-text {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.activity-item .activity-time {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  white-space: nowrap;
}

.activity-date-header {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-2) 0 var(--space-1);
  border-bottom: 1px solid var(--color-divider);
  margin-top: var(--space-2);
}

.activity-date-header:first-child {
  margin-top: 0;
}

/* ========== PARENT DASHBOARD PIN ========== */
.pin-gate {
  max-width: 360px;
  margin: var(--space-16) auto;
  text-align: center;
}

.pin-gate h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}

.pin-gate p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
  max-width: 100%;
}

.pin-input-group {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-bottom: var(--space-6);
}

.pin-input {
  width: 56px;
  height: 64px;
  text-align: center;
  font-size: var(--text-xl);
  font-weight: 700;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.pin-input:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.pin-hint {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ========== TOAST NOTIFICATION ========== */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 280px;
  max-width: 400px;
  animation: toastIn 0.3s ease;
}

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

.toast.hiding {
  animation: toastOut 0.3s ease forwards;
}

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

.toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
}

.toast-message {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ========== CONFETTI ANIMATION ========== */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confettiFall var(--fall-duration, 3s) ease-out forwards;
  animation-delay: var(--fall-delay, 0s);
}

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

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: var(--space-12);
  color: var(--color-text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
}

.empty-state p {
  font-size: var(--text-sm);
  max-width: 100%;
}

/* ========== NAME INPUT (first use) ========== */
.welcome-screen {
  max-width: 480px;
  margin: var(--space-16) auto;
  text-align: center;
  padding: var(--space-8);
}

.welcome-screen h1 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.welcome-screen p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-8);
  max-width: 100%;
}

.welcome-input {
  width: 100%;
  padding: var(--space-3) var(--space-5);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  text-align: center;
  background: var(--color-surface);
  margin-bottom: var(--space-2);
  color: var(--color-text);
}

.welcome-input:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.welcome-btn {
  padding: var(--space-4) var(--space-10);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  font-weight: 700;
  min-height: 52px;
}

.welcome-btn:hover {
  background: var(--color-primary-hover);
}

.welcome-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* OAuth buttons */
.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 340px;
  margin: 0 auto var(--space-2);
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid var(--color-border);
}
.oauth-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.oauth-apple {
  background: #000;
  color: #fff;
  border-color: #000;
}
.oauth-apple:hover {
  background: #1a1a1a;
}
.oauth-google {
  background: #fff;
  color: #333;
  border-color: #ddd;
}
.oauth-google:hover {
  background: #f8f8f8;
}

/* Dark mode oauth */
[data-theme="dark"] .oauth-google,
.dark-mode .oauth-google {
  background: var(--color-surface-2);
  color: var(--color-text);
  border-color: var(--color-border);
}
[data-theme="dark"] .oauth-google:hover,
.dark-mode .oauth-google:hover {
  background: var(--color-surface-offset);
}

.auth-divider {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 340px;
  margin: var(--space-3) auto;
  gap: var(--space-2);
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}
.auth-divider span {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.welcome-input + .welcome-input {
  margin-bottom: var(--space-2);
}

.auth-error {
  background: color-mix(in oklch, var(--color-error) 12%, transparent);
  color: var(--color-error);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-4);
  text-align: center;
}

.auth-success {
  background: color-mix(in oklch, var(--color-success) 12%, transparent);
  color: var(--color-success);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-4);
  text-align: center;
}

.auth-switch {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.auth-switch a {
  color: var(--color-primary);
  font-weight: 700;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.logout-btn {
  margin-top: var(--space-2);
  color: var(--color-text-muted);
  opacity: 0.8;
}

.logout-btn:hover {
  opacity: 1;
  color: var(--color-error);
}

/* ========== FOOTER ========== */
/* ─── Kids Dashboard ─── */
.kid-dash { max-width: 700px; margin: 0 auto; padding-bottom: var(--space-8); }
.kid-dash-hero {
  display: flex; align-items: center; gap: var(--space-4); padding: var(--space-5);
  background: var(--hero-gradient); border-radius: var(--radius-lg, 16px);
  margin-bottom: var(--space-4); position: relative; overflow: hidden;
}
.kid-dash-avatar {
  width: 80px; height: 80px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 2.5rem; border: 4px solid var(--hero-avatar-border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); position: relative; flex-shrink: 0;
}
.kid-dash-hat { position: absolute; top: -10px; font-size: 1.2rem; }
.kid-dash-face { font-size: 2.5rem; }
.kid-dash-info { flex: 1; }
.kid-dash-name { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 700; margin: 0; color: var(--hero-text); }
.kid-dash-level { font-size: var(--text-sm); color: var(--hero-text-sub); font-weight: 600; margin-bottom: 6px; }
.kid-dash-xp-bar { height: 12px; background: var(--hero-xp-bar-bg); border-radius: 6px; overflow: hidden; border: 1px solid var(--hero-xp-bar-border); }
.kid-dash-xp-fill { height: 100%; background: var(--hero-xp-fill); border-radius: 6px; transition: width 0.5s; min-width: 8px; }
.kid-dash-xp-text { font-size: var(--text-xs); color: var(--hero-text); margin-top: 3px; font-weight: 700; }
.kid-dash-streaks {
  position: absolute; top: 10px; right: 12px; display: flex; flex-direction: column; gap: 4px;
}
.kid-dash-streak {
  background: var(--hero-streak-bg); padding: 3px 10px; border-radius: 14px;
  font-weight: 700; font-size: 0.7rem; color: var(--hero-streak-color); text-align: center;
}
.kid-dash-streak.dim { opacity: 0.5; }

.kid-dash-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3); margin-bottom: var(--space-4);
}
.kid-dash-stat {
  background: var(--color-surface); border: 2px solid var(--color-border); border-radius: var(--radius-lg, 16px);
  padding: var(--space-3); text-align: center; transition: transform 0.15s;
}
.kid-dash-stat:hover { transform: translateY(-2px); border-color: var(--stat-color, var(--stat-hover-border)); }
.kid-dash-stat-icon { font-size: 1.5rem; margin-bottom: 4px; }
.kid-dash-stat-value { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 700; color: var(--stat-color, var(--stat-value-color)); }
.kid-dash-stat-label { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; }

.kid-dash-section { margin-bottom: var(--space-4); }
.kid-dash-section-title { font-family: var(--font-display); font-size: var(--text-lg); margin: 0 0 var(--space-3); }

.kid-dash-goals { display: flex; flex-direction: column; gap: var(--space-2); }
.kid-dash-goal {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  background: var(--color-surface); border: 2px solid var(--color-border); border-radius: var(--radius-md, 12px);
  font-weight: 600; font-size: var(--text-sm); transition: all 0.2s;
}
.kid-dash-goal.done { border-color: var(--goal-done-border); background: var(--goal-done-bg); text-decoration: line-through; color: var(--goal-done-text); }
.kid-dash-goal-check { font-size: 1.2rem; }
.kid-dash-goals-done { text-align: center; padding: var(--space-3); color: var(--goal-done-text); font-weight: 700; font-size: var(--text-sm); margin-top: var(--space-2); }
.kid-dash-goals-hint { text-align: center; padding: var(--space-2); color: var(--color-text-muted); font-size: var(--text-xs); }

.kid-dash-suggestion {
  display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5);
  background: var(--color-surface); border: 2px solid var(--color-border); border-radius: var(--radius-lg, 16px);
  cursor: pointer; transition: all 0.2s;
}
.kid-dash-suggestion:hover { transform: translateY(-3px); border-color: var(--suggestion-color, var(--color-primary)); box-shadow: 0 6px 20px rgba(0,0,0,0.08); }
.kid-dash-suggestion-emoji { font-size: 2.5rem; }
.kid-dash-suggestion-name { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; }
.kid-dash-suggestion-cta { font-size: var(--text-sm); color: var(--suggestion-color, var(--color-primary)); font-weight: 600; margin-top: 2px; }

.kid-dash-modules {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-3);
}
.kid-dash-module {
  background: var(--color-surface); border: 2px solid var(--color-border); border-radius: var(--radius-lg, 16px);
  padding: var(--space-3); text-align: center; cursor: pointer; transition: all 0.15s;
}
.kid-dash-module:hover { transform: translateY(-3px); border-color: var(--mod-color, var(--color-primary)); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.kid-dash-module-emoji { font-size: 2rem; margin-bottom: 4px; }
.kid-dash-module-name { font-size: var(--text-xs); font-weight: 700; margin-bottom: 4px; }
.kid-dash-module-progress { font-size: 0.65rem; color: var(--mod-color, var(--color-text-muted)); font-weight: 600; }
.kid-dash-start-pill { display: inline-block; background: var(--start-pill-bg); color: var(--start-pill-color); padding: 2px 10px; border-radius: 10px; font-size: 0.6rem; font-weight: 700; }

.kid-dash-recent { display: flex; flex-direction: column; gap: var(--space-2); }
.kid-dash-activity {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3);
  background: var(--color-surface); border-radius: var(--radius-md, 12px); font-size: var(--text-sm);
}
.kid-dash-activity-icon { font-size: 1.2rem; flex-shrink: 0; }
.kid-dash-activity-text { flex: 1; color: var(--color-text); }
.kid-dash-activity-time { font-size: var(--text-xs); color: var(--color-text-muted); }
.kid-dash-empty { text-align: center; padding: var(--space-4); color: var(--color-text-muted); font-style: italic; }

.kid-dash-weekly { display: flex; flex-direction: column; gap: var(--space-3); }
.kid-dash-weekly-goal {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  background: var(--color-surface); border: 2px solid var(--color-border); border-radius: var(--radius-md, 12px);
}
.kid-dash-weekly-icon { font-size: 1.5rem; flex-shrink: 0; }
.kid-dash-weekly-info { flex: 1; min-width: 0; }
.kid-dash-weekly-name { font-size: var(--text-sm); font-weight: 600; margin-bottom: 4px; }
.kid-dash-weekly-bar { height: 8px; background: var(--weekly-bar-bg); border-radius: 4px; overflow: hidden; }
.kid-dash-weekly-fill { height: 100%; background: var(--weekly-fill); border-radius: 4px; transition: width 0.5s; }
.kid-dash-weekly-count { font-family: var(--font-display); font-weight: 700; font-size: var(--text-sm); color: var(--weekly-count-color); min-width: 32px; text-align: right; }
.kid-dash-weekly-modules { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.kid-dash-module-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 0.7rem; font-weight: 600; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; padding: 2px 8px; color: var(--text-color); }

@media (max-width: 600px) {
  .kid-dash-stats { grid-template-columns: repeat(2, 1fr); }
  .kid-dash-modules { grid-template-columns: repeat(3, 1fr); }
  .kid-dash-hero { flex-direction: column; text-align: center; }
  .kid-dash-streak { position: static; margin-top: var(--space-2); }
}

.app-footer {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--color-text-faint);
  font-size: var(--text-xs);
}

.app-footer a {
  color: var(--color-text-faint);
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--color-text-muted);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .main-content {
    padding: var(--space-5) var(--space-4) var(--space-10);
  }

  .story-grid {
    grid-template-columns: 1fr;
  }

  .reading-panel {
    padding: var(--space-5);
  }

  .quiz-question {
    padding: var(--space-5);
  }

  .dashboard-stats {
    grid-template-columns: 1fr 1fr;
  }

  .badges-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .page-nav-btn span.btn-label {
    display: none;
  }
}

/* ========== RECOMMENDED BADGE ========== */
.recommended-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-accent-light);
  color: var(--color-accent);
  font-size: var(--text-xs);
  font-weight: 700;
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
}

/* Spacing toggle */
.spacing-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-muted);
}

.spacing-btn:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.spacing-btn.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}

/* ========== READ ALOUD PRACTICE (Phase 2) ========== */
.voice-section {
  margin-bottom: var(--space-6);
}

.voice-start-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: stretch;
}
.voice-mic-tip {
  font-size: 0.8rem;
  color: var(--color-warning, #e67e22);
  background: var(--color-warning-surface, #fef9e7);
  border: 1px solid var(--color-warning-border, #f5d77d);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  text-align: center;
  font-weight: 600;
}

.voice-read-aloud-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--color-primary-surface);
  border: 2px dashed var(--color-primary);
  border-radius: var(--radius-lg);
  color: var(--color-primary);
  font-weight: 700;
  font-size: var(--text-sm);
  transition: all var(--transition-interactive);
}

.voice-read-aloud-btn:hover {
  background: var(--color-primary-light);
  border-style: solid;
}

.voice-hint {
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  margin-left: auto;
}

/* Active recording state */
.voice-recording-active {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6);
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-divider);
  text-align: center;
}

.voice-reading-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.voice-pulse {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-error);
  animation: voicePulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes voicePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

.voice-mic-pulse {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent-light, rgba(255,107,129,0.15));
  color: var(--color-accent);
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.voice-mic-pulse.voice-pulse-active {
  background: var(--color-accent);
  color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(255,107,129,0.4);
}

.voice-recording-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.voice-reading-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
}

.voice-timer {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--color-primary);
  font-family: var(--font-heading);
  letter-spacing: 0.05em;
  line-height: 1;
  transition: color 0.3s ease;
}
.voice-timer-warning {
  color: #e53e3e;
  animation: voice-timer-pulse 0.8s ease-in-out infinite;
}
@keyframes voice-timer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.voice-reading-guide {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
}

.voice-guide-text {
  font-size: var(--text-xs);
}

/* Live transcript */
.voice-live-transcript {
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  min-height: 40px;
  width: 100%;
  max-width: 500px;
  line-height: 1.5;
  text-align: left;
  max-height: 80px;
  overflow-y: auto;
}

.voice-live-transcript.voice-live-waiting {
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
}

/* Buttons */
.voice-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 700;
  min-height: 44px;
}

.voice-btn.stop {
  background: var(--color-success);
  color: white;
}

.voice-btn.stop:hover {
  opacity: 0.9;
}

.voice-btn.secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.voice-btn.secondary:hover {
  background: var(--color-primary-light);
}

/* Results panel */
.voice-results {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  border: 1px solid var(--color-divider);
  animation: popupIn 0.3s ease;
}

.voice-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.voice-score-badge {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 700;
}

.voice-score-badge.great {
  background: var(--color-success-light);
  color: var(--color-success);
}

.voice-score-badge.good {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.voice-score-badge.needs-work {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.voice-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--color-text-faint);
  font-size: 1.2rem;
}

.voice-close-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.voice-feedback {
  font-size: var(--text-sm);
  color: var(--color-text);
  font-weight: 600;
  margin-bottom: var(--space-4);
  line-height: 1.5;
}

/* Stats row */
.voice-stats-row {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
}

.voice-stat-item {
  text-align: center;
}

.voice-stat-val {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-primary);
  font-family: var(--font-heading);
}

.voice-stat-lbl {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* Audio playback */
.voice-playback {
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.voice-playback-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.voice-audio-player {
  width: 100%;
  height: 40px;
  border-radius: var(--radius-md);
}

/* Word-by-word review */
.voice-word-review {
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.voice-word-review-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.voice-word-display {
  font-size: var(--text-sm);
  line-height: 2;
  color: var(--color-text);
}

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

.vw-close {
  color: var(--color-accent);
  text-decoration: underline dotted;
  cursor: help;
}

.vw-missed {
  color: var(--color-error);
  background: var(--color-error-light, rgba(239, 68, 68, 0.1));
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}

.vw-tappable {
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.vw-tappable:hover {
  opacity: 0.8;
}

.vw-tappable:active {
  opacity: 0.6;
}

.vw-tappable svg {
  opacity: 0.4;
  flex-shrink: 0;
}

.vw-tappable:hover svg {
  opacity: 1;
}

.voice-word-legend {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
}

.vw-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.vw-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.vw-dot-correct { background: var(--color-success); }
.vw-dot-close { background: var(--color-accent); }
.vw-dot-missed { background: var(--color-error); }

/* Practice words */
.voice-tip-box {
  background: var(--color-primary-surface);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text);
}

.voice-practice-words {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.voice-practice-word {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
}

/* Pronunciation cards */
.voice-practice-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.voice-pron-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  border: 1px solid var(--color-divider);
}

.voice-pron-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.voice-pron-word {
  font-size: var(--text-base);
  font-weight: 800;
  color: var(--color-primary);
  font-family: var(--font-heading);
}

.voice-pron-listen {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  transition: all var(--transition-interactive);
  flex-shrink: 0;
}

.voice-pron-listen:hover {
  background: var(--color-primary);
  color: white;
}

.voice-pron-phonetic {
  font-size: var(--text-sm);
  color: var(--color-text);
  font-style: italic;
  margin-bottom: var(--space-1);
  letter-spacing: 0.02em;
}

.voice-pron-syllables {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
}

.voice-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

/* Phoneme detail popups */
.vw-word-wrap {
  display: inline-block;
  position: relative;
}

.phone-detail-popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 100;
  min-width: 200px;
  max-width: 280px;
  animation: fadeSlideUp 0.15s ease;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.phone-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-divider);
}

.phone-detail-word {
  font-weight: 800;
  font-size: var(--text-base);
  color: var(--color-text);
}

.phone-detail-score {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.phone-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: var(--space-2);
}

.ph-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: monospace;
}

.ph-good {
  background: rgba(34, 197, 94, 0.15);
  color: var(--color-success);
}

.ph-fair {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

.ph-bad {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-error);
}

.ph-bad s {
  opacity: 0.6;
  text-decoration-color: var(--color-error);
}

.phone-tip {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
  line-height: 1.5;
}

.phone-detail-actions {
  display: flex;
  gap: var(--space-2);
}

.phone-listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-interactive);
  border: none;
}

.phone-listen-btn:hover {
  background: var(--color-primary);
  color: white;
}

/* Circular play buttons: left = correct (green), right = yours (teal) */
.phone-actions-compare {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  margin: var(--space-3) 0;
}

.phone-circle-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 2.5px solid;
  background: transparent;
  padding: 0;
}

.phone-circle-btn.correct-circle {
  border-color: #3d6b3d;
  color: #3d6b3d;
}
.phone-circle-btn.correct-circle:hover {
  background: #3d6b3d;
  color: white;
}

.phone-circle-btn.yours-circle {
  border-color: #1a9fb0;
  color: #1a9fb0;
}
.phone-circle-btn.yours-circle:hover {
  background: #1a9fb0;
  color: white;
}

.phone-compare-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.phone-compare-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-dim);
}

/* Phoneme table (SpeechAce-style) */
.ph-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.ph-table thead th {
  text-align: left;
  font-weight: 600;
  padding: 6px 10px;
  border-bottom: 2px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
}

.ph-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
}

.ph-td-syl b {
  font-weight: 700;
  color: var(--color-text);
}

.ph-td-phone {
  font-weight: 600;
  text-align: center;
}

.ph-td-phone.ph-table-bad {
  color: #dc2626;
}

.ph-score-good {
  color: #16a34a;
  font-weight: 600;
}

.ph-score-bad {
  color: #dc2626;
  font-weight: 600;
}

/* Fluency bar */
.voice-fluency-bar {
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}

.voice-fluency-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.voice-fluency-track {
  height: 8px;
  background: rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.voice-fluency-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-success), #22d3ee);
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.voice-fluency-stats {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.voice-fluency-tip {
  font-size: var(--text-xs);
  color: var(--color-text);
  margin-top: var(--space-2);
  font-style: italic;
}

/* ========== VIRTUAL PET (Phase 2) ========== */
.pet-page {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--space-6);
  align-items: start;
}

@media (max-width: 768px) {
  .pet-page {
    grid-template-columns: 1fr;
  }
}

.pet-display-card {
  background: transparent;
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  border: none;
  text-align: center;
}

.pet-stage-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-4);
}

.pet-avatar-area {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: 50%;
  border: none;
}

.pet-emoji {
  font-size: 4rem;
  line-height: 1;
  transition: transform 0.3s ease;
}

.pet-emoji.pet-bounce {
  animation: petBounce 0.6s ease;
}

@keyframes petBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  25% { transform: translateY(-16px) scale(1.1); }
  50% { transform: translateY(0) scale(0.95); }
  75% { transform: translateY(-6px) scale(1.02); }
}

/* Accessory worn ON the pet */
.pet-accessory {
  position: absolute;
  font-size: 1.6rem;
  z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
  pointer-events: none;
}

/* Default: top of head */
.pet-accessory.acc-top {
  top: 0px;
  left: 50%;
  transform: translateX(-50%);
}

/* Bow: top-right of head */
.pet-accessory.acc-bow {
  top: 2px;
  right: 10px;
  font-size: 1.4rem;
}

/* Scarf: around neck area */
.pet-accessory.acc-scarf {
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.5rem;
}

/* Glasses: over eyes — slightly above center */
.pet-accessory.acc-glasses {
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
}

/* Cape: behind, slightly left */
.pet-accessory.acc-cape {
  top: 10px;
  left: 2px;
  font-size: 1.4rem;
}

/* Tiara: top of head, centered */
.pet-accessory.acc-tiara {
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.5rem;
}

/* Magic wand: right side, mid */
.pet-accessory.acc-wand {
  top: 30px;
  right: 0px;
  font-size: 1.4rem;
  transform: rotate(-30deg);
}

.pet-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.pet-happiness-bar {
  margin-bottom: var(--space-4);
}

.pet-happiness-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: var(--space-2);
}

.pet-bar-track {
  height: 8px;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.pet-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.pet-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.pet-stat {
  padding: var(--space-2);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  text-align: center;
}

.pet-stat-val {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-primary);
}

.pet-stat-lbl {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.pet-next-stage {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  padding: var(--space-3);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.pet-next-stage.pet-maxed {
  background: var(--color-success-light);
  color: var(--color-success);
  font-weight: 700;
}

.pet-evolution {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
}

.pet-evo-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  opacity: 0.35;
}

.pet-evo-step.reached {
  opacity: 1;
}

.pet-evo-emoji {
  font-size: 1.5rem;
}

.pet-evo-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
}

.pet-evo-arrow {
  color: var(--color-text-faint);
  font-size: var(--text-sm);
}

.pet-actions-area {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.pet-section-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  border: 1px solid var(--color-divider);
}

.pet-section-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.pet-section-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.pet-food-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.pet-food-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  transition: all var(--transition-interactive);
}

.pet-food-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  transform: translateY(-2px);
}

.pet-food-btn.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.pet-food-emoji {
  font-size: 1.5rem;
}

.pet-food-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
}

.pet-food-info {
  font-size: var(--text-xs);
  color: var(--color-success);
  font-weight: 600;
}

.pet-food-cost {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-accent);
}

.pet-food-cost.free {
  color: var(--color-success);
}

.pet-tip {
  background: var(--color-primary-surface);
  border-color: var(--color-primary-light);
}

.pet-tips-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.pet-tips-list li {
  font-size: var(--text-sm);
  color: var(--color-text);
  padding-left: var(--space-5);
  position: relative;
}

.pet-tips-list li::before {
  content: "\2022";
  position: absolute;
  left: var(--space-2);
  color: var(--color-primary);
  font-weight: 700;
}

/* Pet Adoption Grid */
.pet-adoption-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}

.pet-adopt-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  border: 2px solid var(--color-divider);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-interactive);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.pet-adopt-card:hover:not(.locked) {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.pet-adopt-card.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.pet-adopt-emoji {
  font-size: 3rem;
}

.pet-adopt-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
}

.pet-adopt-preview {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.pet-adopt-cost {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-accent);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-accent-light);
}

.pet-adopt-cost.free {
  background: var(--color-success-light);
  color: var(--color-success);
}

.pet-adopt-cost.too-expensive {
  background: var(--color-error-light);
  color: var(--color-error);
}

/* ============================================================
   KID PICKER & SWITCHER
   ============================================================ */
.kid-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  justify-content: center;
  margin: var(--space-4) 0;
}
.kid-picker-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  border-radius: var(--radius-lg, 12px);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 130px;
  max-width: 160px;
  font-family: inherit;
  color: var(--color-text);
}
.kid-picker-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.kid-picker-add {
  border-style: dashed;
  background: var(--color-surface-2);
}
.kid-picker-add:hover {
  background: var(--color-surface);
}
.kid-picker-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  position: relative;
}
.kid-picker-avatar .avatar-hat {
  position: absolute;
  top: -8px;
  font-size: 1.2rem;
}
.kid-picker-name {
  font-weight: 700;
  font-size: var(--text-base);
  font-family: var(--font-display);
}
.kid-picker-info {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Sidebar kid switcher */
.kid-switcher {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  overflow-x: auto;
  scrollbar-width: none;
}
.kid-switcher::-webkit-scrollbar { display: none; }
.kid-switch-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md, 8px);
  border: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  color: var(--color-text-muted);
  min-width: 54px;
}
.kid-switch-btn:hover {
  background: var(--color-surface-2);
}
.kid-switch-btn.active {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.kid-switch-face {
  font-size: 1.3rem;
  line-height: 1;
}
.kid-switch-name {
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50px;
}
.kid-switch-add {
  opacity: 0.5;
}
.kid-switch-add:hover {
  opacity: 1;
}

/* ========== ANIMATED REWARD CELEBRATION SYSTEM ========== */

/* Overlay */
.reward-celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  animation: rewardOverlayIn 0.4s ease;
}

@keyframes rewardOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Card */
.reward-celebration {
  position: relative;
  background: var(--color-surface, #fff);
  border-radius: 24px;
  padding: 2.5rem 2rem 2rem;
  text-align: center;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: rewardCardPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: visible;
}

@keyframes rewardCardPop {
  0% { transform: scale(0.3) translateY(40px); opacity: 0; }
  60% { transform: scale(1.05) translateY(-5px); opacity: 1; }
  100% { transform: scale(1) translateY(0); }
}

/* Type-specific glow borders */
.reward-celebration.badge {
  border: 3px solid #FFD700;
  box-shadow: 0 0 30px rgba(255,215,0,0.3), 0 20px 60px rgba(0,0,0,0.3);
}
.reward-celebration.evolution {
  border: 3px solid #7C3AED;
  box-shadow: 0 0 30px rgba(124,58,237,0.3), 0 20px 60px rgba(0,0,0,0.3);
}
.reward-celebration.levelup {
  border: 3px solid var(--color-primary, #FF6B8A);
  box-shadow: 0 0 30px rgba(255,107,138,0.3), 0 20px 60px rgba(0,0,0,0.3);
}
.reward-celebration.perfect {
  border: 3px solid #10B981;
  box-shadow: 0 0 30px rgba(16,185,129,0.3), 0 20px 60px rgba(0,0,0,0.3);
}

/* Icon wrapper */
.reward-icon-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reward-icon {
  font-size: 4rem;
  animation: rewardIconBounce 1s ease infinite alternate;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
  position: relative;
  z-index: 2;
}

@keyframes rewardIconBounce {
  0% { transform: scale(1) translateY(0); }
  100% { transform: scale(1.08) translateY(-6px); }
}

/* Expanding rings */
.reward-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(255,215,0,0.5);
  animation: rewardRingExpand 2s ease-out infinite;
}
.reward-ring.ring-2 {
  animation-delay: 1s;
}

.reward-celebration.evolution .reward-ring { border-color: rgba(124,58,237,0.5); }
.reward-celebration.levelup .reward-ring { border-color: rgba(255,107,138,0.5); }
.reward-celebration.perfect .reward-ring { border-color: rgba(16,185,129,0.5); }

@keyframes rewardRingExpand {
  0% { transform: scale(0.5); opacity: 0.8; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* Sparkles */
.reward-sparkles {
  position: absolute;
  inset: -20px;
  pointer-events: none;
}

.reward-sparkle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #FFD700;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  animation: rewardSparkleFly 1.5s ease-out infinite;
  animation-delay: calc(var(--i) * 0.12s);
}

.reward-celebration.evolution .reward-sparkle { background: #A78BFA; }
.reward-celebration.levelup .reward-sparkle { background: #FF6B8A; }
.reward-celebration.perfect .reward-sparkle { background: #34D399; }

@keyframes rewardSparkleFly {
  0% {
    transform: translate(-50%, -50%) rotate(calc(var(--i) * 30deg)) translateX(0) scale(0);
    opacity: 1;
  }
  50% { opacity: 1; }
  100% {
    transform: translate(-50%, -50%) rotate(calc(var(--i) * 30deg)) translateX(70px) scale(1);
    opacity: 0;
  }
}

/* Title */
.reward-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  margin: 0.5rem 0 0.25rem;
  background: linear-gradient(135deg, #FFD700, #FF6B8A);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: rewardTitleShimmer 2s ease infinite;
  background-size: 200% 100%;
}

.reward-celebration.evolution .reward-title {
  background: linear-gradient(135deg, #7C3AED, #A78BFA, #7C3AED);
  -webkit-background-clip: text;
  background-clip: text;
  background-size: 200% 100%;
}

.reward-celebration.perfect .reward-title {
  background: linear-gradient(135deg, #10B981, #34D399, #10B981);
  -webkit-background-clip: text;
  background-clip: text;
  background-size: 200% 100%;
}

@keyframes rewardTitleShimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.reward-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  margin: 0 0 1.25rem;
}

/* Dismiss button */
.reward-dismiss-btn {
  display: inline-block;
  padding: 0.7rem 2rem;
  border: none;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #FFD700, #FF6B8A);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(255,107,138,0.3);
}

.reward-celebration.evolution .reward-dismiss-btn {
  background: linear-gradient(135deg, #7C3AED, #A78BFA);
  box-shadow: 0 4px 12px rgba(124,58,237,0.3);
}

.reward-celebration.perfect .reward-dismiss-btn {
  background: linear-gradient(135deg, #10B981, #34D399);
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}

.reward-dismiss-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(255,107,138,0.4);
}

/* Background particles */
.reward-particles {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  overflow: hidden;
  pointer-events: none;
}
.reward-particles::before,
.reward-particles::after {
  content: '';
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  opacity: 0.08;
  animation: rewardParticleFloat 4s ease-in-out infinite alternate;
}
.reward-particles::before {
  background: #FFD700;
  top: -40px;
  right: -40px;
}
.reward-particles::after {
  background: #FF6B8A;
  bottom: -40px;
  left: -40px;
  animation-delay: 2s;
}

@keyframes rewardParticleFloat {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(20px, -20px) scale(1.2); }
}

/* ========== PET IDLE ANIMATIONS ========== */

.pet-emoji {
  animation: petIdle 3s ease-in-out infinite;
}

@keyframes petIdle {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.02); }
}

.pet-emoji.pet-bounce {
  animation: petBounce 0.6s ease, petIdle 3s ease-in-out 0.6s infinite;
}

/* Pet happiness glow */
.pet-display {
  position: relative;
}
.pet-display::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,215,0,0.15), transparent 70%);
  animation: petGlow 3s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes petGlow {
  0% { opacity: 0.3; transform: scale(0.9); }
  100% { opacity: 0.7; transform: scale(1.1); }
}

/* ========== ANIMATED BADGE CARDS ========== */

.badge-card.earned {
  position: relative;
  overflow: hidden;
}

.badge-card.earned::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255,215,0,0.08) 40%,
    rgba(255,215,0,0.15) 50%,
    rgba(255,215,0,0.08) 60%,
    transparent 70%
  );
  animation: badgeShimmer 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes badgeShimmer {
  0% { transform: translateX(-100%) rotate(25deg); }
  100% { transform: translateX(100%) rotate(25deg); }
}

.badge-card.earned .badge-icon {
  animation: badgeIconFloat 3s ease-in-out infinite;
}

@keyframes badgeIconFloat {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.05) rotate(-3deg); }
  75% { transform: scale(1.05) rotate(3deg); }
}

/* ========== ENHANCED CONFETTI ========== */
.confetti-piece {
  filter: blur(0.3px);
  will-change: transform, opacity;
}

/* ========== LEGENDARY PET GLOW ========== */
.pet-emoji.pet-legendary {
  animation: petLegendary 3s ease-in-out infinite;
  filter: drop-shadow(0 0 12px rgba(255,215,0,0.6));
}

@keyframes petLegendary {
  0%, 100% {
    transform: translateY(0) scale(1);
    filter: drop-shadow(0 0 12px rgba(255,215,0,0.6));
  }
  25% {
    filter: drop-shadow(0 0 20px rgba(255,107,138,0.6));
  }
  50% {
    transform: translateY(-6px) scale(1.04);
    filter: drop-shadow(0 0 16px rgba(124,58,237,0.6));
  }
  75% {
    filter: drop-shadow(0 0 20px rgba(52,211,153,0.6));
  }
}

/* Maxed pet banner */
.pet-next-stage.pet-maxed {
  background: linear-gradient(135deg, #FFD700, #FF6B8A, #7C3AED);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  font-size: var(--text-lg);
  animation: legendaryTextShimmer 3s ease infinite;
  background-size: 200% 100%;
}

@keyframes legendaryTextShimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ========== MOBILE KID SWITCHER (in header bar) ========== */
.mobile-kid-switcher {
  display: none;
  margin-left: auto;
  gap: 6px;
  align-items: center;
}

@media (max-width: 768px), (min-width: 0px) {
  .mobile-kid-switcher {
    display: flex;
  }
}

.mobile-kid-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  font-family: inherit;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.mobile-kid-btn:hover {
  transform: scale(1.08);
  filter: brightness(1.1);
}

.mobile-kid-btn.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
  transform: scale(1.1);
}

.mobile-kid-face {
  font-size: 1.3rem;
  line-height: 1;
}

/* ======== PET COLLECTION GRID ======== */
.pet-collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.pet-collection-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-border);
  background: var(--color-surface-2);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.pet-collection-card:hover {
  transform: scale(1.05);
  border-color: var(--color-primary);
}

.pet-collection-card.active {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  box-shadow: 0 0 0 3px var(--color-primary-light), 0 4px 12px rgba(0,0,0,0.1);
}

.pet-coll-emoji {
  font-size: 2.5rem;
}

.pet-coll-name {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.pet-coll-stage {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.pet-coll-active {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-primary);
  margin-top: 2px;
}

.pet-coll-add {
  border-style: dashed;
  opacity: 0.7;
}

.pet-coll-add:hover {
  opacity: 1;
}

/* Owned badge on adoption card */
.pet-adopt-card.owned {
  opacity: 0.6;
  pointer-events: none;
  border-color: var(--color-success);
}

/* ===== PET STAGE VISUAL DIFFERENTIATION ===== */
/* Baby: small, gentle bob */
.pet-emoji.pet-stage-baby {
  font-size: 3rem;
  animation: petBabyBob 2.5s ease-in-out infinite;
}
@keyframes petBabyBob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.01); }
}

/* Growing/Teen: medium, slightly bouncy */
.pet-emoji.pet-stage-teen {
  font-size: 3.8rem;
  animation: petTeenBounce 2.2s ease-in-out infinite;
}
@keyframes petTeenBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-5px) scale(1.03); }
  60% { transform: translateY(-2px) scale(1.01); }
}

/* Grown Up: full size, gentle glow */
.pet-emoji.pet-stage-adult {
  font-size: 4.5rem;
  animation: petAdultIdle 3s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(255,182,193,0.4));
}
@keyframes petAdultIdle {
  0%, 100% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 6px rgba(255,182,193,0.4)); }
  50% { transform: translateY(-5px) scale(1.03); filter: drop-shadow(0 0 10px rgba(255,182,193,0.5)); }
}

/* Legendary: biggest, rainbow glow + sparkle */
.pet-emoji.pet-legendary {
  font-size: 5rem;
}

/* Pet collection card stage indicators */
.pet-coll-emoji { position: relative; }
.pet-coll-stage-baby .pet-coll-emoji { font-size: 1.8rem; }
.pet-coll-stage-teen .pet-coll-emoji { font-size: 2.2rem; }
.pet-coll-stage-adult .pet-coll-emoji { font-size: 2.5rem; filter: drop-shadow(0 0 4px rgba(255,182,193,0.4)); }
.pet-coll-stage-legendary .pet-coll-emoji { font-size: 2.5rem; filter: drop-shadow(0 0 8px rgba(255,215,0,0.5)); animation: petCollLegGlow 2s ease-in-out infinite; }
@keyframes petCollLegGlow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(255,215,0,0.5)); }
  50% { filter: drop-shadow(0 0 14px rgba(255,107,138,0.6)); }
}

/* Pet evolution step styling per stage */
.pet-evo-step.reached .pet-evo-emoji { filter: drop-shadow(0 0 4px rgba(255,182,193,0.5)); }

/* Pet Rename Button */
.pet-rename-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85em;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  opacity: 0.5;
  transition: opacity 0.2s, background 0.2s;
  vertical-align: middle;
}
.pet-rename-btn:hover {
  opacity: 1;
  background: var(--color-surface-raised);
}

/* Pet Custom Images */
.pet-img {
  width: 100%;
  height: 100%;
  max-width: 120px;
  max-height: 120px;
  object-fit: contain;
  border-radius: 0;
  image-rendering: auto;
  background: transparent;
}
.pet-emoji .pet-img {
  max-width: 100%;
  max-height: 100%;
}
.pet-evo-emoji .pet-img {
  width: 32px;
  height: 32px;
  max-width: 32px;
  max-height: 32px;
}
.pet-adopt-emoji .pet-img {
  width: 64px;
  height: 64px;
  max-width: 64px;
  max-height: 64px;
}
.pet-coll-emoji .pet-img {
  width: 48px;
  height: 48px;
  max-width: 48px;
  max-height: 48px;
}
.pet-adopt-preview .pet-img {
  width: 20px;
  height: 20px;
  max-width: 20px;
  max-height: 20px;
  display: inline-block;
  vertical-align: middle;
}

/* SpeechAce pronunciation scoring spinner */
.voice-scoring-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  margin: 0 auto;
  animation: voice-spin 0.8s linear infinite;
}
@keyframes voice-spin {
  to { transform: rotate(360deg); }
}
