/*
 * Modern UI Styles for Webcam Game V2
 * Comprehensive, responsive, and animated interface
 */

:root {
  /* --- Color System --- */
  --color-brand: #6C5CE7;
  --color-brand-light: #A29BFE;
  --color-brand-dark: #4834D4;
  --color-accent: #FF6B6B;
  --color-accent-warm: #FECA57;
  --color-success: #00D2D3;
  --color-educational: #1DD1A1;
  --color-card-bg: #FFFFFF;
  --color-card-edu: #F0FFF4;
  --color-text-dark: #2D3436;
  --color-text-muted: #4A5568;
  --color-text-light: #FFFFFF;

  /* --- Typography ---
   * Fredoka leads the display face — it's a rounded "toy" face that pairs
   * with the hand-drawn Hoppo mascot. Nunito (the previous choice) reads as
   * SaaS-dashboard type next to illustrated kids' art. Baloo 2 is the iOS
   * fallback (Fredoka renders less crisp on iOS pre-17 for some reason).
   * Body copy stays on Inter — Fredoka at 12px loses too much legibility. */
  --font-display: 'Fredoka', 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

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

  /* --- Radii --- */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1.25rem;
  --radius-pill: 624rem;

  /* --- Shadows --- */
  --shadow-card: 0 2px 0 0 rgba(0,0,0,0.06), 0 4px 8px rgba(0,0,0,0.08), 0 12px 24px rgba(0,0,0,0.12);
  --shadow-card-hover: 0 4px 0 0 rgba(0,0,0,0.06), 0 8px 16px rgba(0,0,0,0.1), 0 20px 40px rgba(0,0,0,0.15);
  --shadow-card-active: 0 1px 0 0 rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.08);

  /* --- Transitions --- */
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  /* --- Legacy aliases (backward compat for HUD, settings, gameplay) --- */
  --primary-color: var(--color-brand);
  --primary-hover: var(--color-brand-dark);
  --secondary-color: #6b7280;
  --secondary-hover: #4b5563;
  --danger-color: var(--color-accent);
  --danger-hover: #e84040;
  --success-color: var(--color-success);
  --warning-color: var(--color-accent-warm);
  --bg-dark: rgba(0, 0, 0, 0.85);
  --bg-light: rgba(255, 255, 255, 0.1);
  --text-primary: #ffffff;
  --text-secondary: #e5e7eb;
  --border-radius: 12px;
  --transition-speed: 0.3s;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.3);

  /* iOS safe area support */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* Screen reader only - visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Control Panel */
.control-panel {
  position: fixed;
  top: calc(20px + var(--safe-area-top));
  left: calc(20px + var(--safe-area-left));
  width: 320px;
  background: var(--bg-dark);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-radius: var(--border-radius);
  padding: 20px;
  color: var(--text-primary);
  box-shadow: var(--shadow-xl);
  z-index: 100;
  transition: transform var(--transition-speed), opacity var(--transition-speed);
}

.control-panel.minimized {
  transform: translateX(-280px);
  opacity: 0.5;
}

.control-panel:hover.minimized {
  transform: translateX(0);
  opacity: 1;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--bg-light);
}

.game-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--color-brand-light) 0%, var(--color-brand) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.icon-btn {
  background: var(--bg-light);
  border: none;
  border-radius: 10px;
  width: 48px;  /* Increased for touch accessibility (was 36px) */
  height: 48px; /* Minimum 48px for kids apps - WCAG 2.5 */
  cursor: pointer;
  font-size: 20px;
  transition: all var(--transition-speed);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--bg-light);
  transform: scale(1.1);
}

.control-section {
  margin-bottom: 16px;
}

.control-label {
  display: block;
  font-size: 14px; /* Increased for kids readability (was 13px) */
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.select-input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.select-input:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.select-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.select-input option {
  background: #1f2937;
  color: var(--text-primary);
}

/* Buttons */
.control-actions {
  display: flex;
  gap: 8px;
  margin: 20px 0 16px;
}

.btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-speed);
  box-shadow: var(--shadow-sm);
  text-transform: none;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, #8b5cf6 100%);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--secondary-hover);
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

/* Status Text */
.status-text {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.status-info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.status-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.status-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* HUD (Heads-Up Display) */
.hud {
  position: fixed;
  top: calc(68px + var(--safe-area-top));
  left: calc(12px + var(--safe-area-left, 0px));
  z-index: 100;
}

/* HUD Controls Container - fixed top-left toolbar */
.hud-controls {
  position: fixed;
  top: calc(12px + var(--safe-area-top));
  left: calc(12px + var(--safe-area-left, 0px));
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 101;
}

/* Exit/Back Button */
.exit-btn {
  width: 52px;  /* Increased for kids accessibility (was 44px) */
  height: 52px; /* Larger than minimum for critical action */
  background: rgba(239, 68, 68, 0.9);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 26px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exit-btn:hover {
  background: rgba(220, 38, 38, 1);
  transform: scale(1.1);
}

.exit-btn:active {
  transform: scale(0.95);
}

/* HUD Settings Button */
.hud-settings-btn {
  width: 44px;
  height: 44px;
  background: rgba(107, 114, 128, 0.9);
  border: none;
  border-radius: 22px;
  color: white;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hud-settings-btn:hover {
  background: rgba(75, 85, 99, 1);
  transform: scale(1.1);
}

.hud-settings-btn:active {
  transform: scale(0.95);
}

/* HUD Tracking Mode Selector */
.hud-tracking-select {
  height: 44px;
  padding: 0 12px;
  background: rgba(59, 130, 246, 0.9);
  border: none;
  border-radius: 22px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.hud-tracking-select:hover {
  background: rgba(37, 99, 235, 1);
  transform: scale(1.05);
}

.hud-tracking-select:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

.hud-top {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-dark);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding: 16px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-xl);
  min-width: 200px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-label {
  font-size: 14px; /* Increased for kids readability (was 11px) */
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hud-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

.hud-value.score {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hud-value.fps-value {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 18px;
  transition: color 0.3s ease;
}

.hud-value.pulse {
  animation: pulse 0.3s ease-out;
}

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

/* Health Bar */
.health-bar {
  position: relative;
  width: 100%;
  height: 24px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.health-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
  transition: width 0.3s ease, background 0.3s ease;
  border-radius: 12px;
}

.health-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  z-index: 1;
}

/* Level/XP Display */
.hud-level {
  min-width: 80px;
}

.level-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-number {
  font-size: 1.4em;
  font-weight: 800;
  color: #a78bfa;
  text-shadow: 0 0 10px rgba(167, 139, 250, 0.5);
  min-width: 24px;
  text-align: center;
}

.xp-bar {
  position: relative;
  width: 60px;
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(167, 139, 250, 0.3);
}

.xp-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, #8b5cf6 0%, #a78bfa 50%, #c4b5fd 100%);
  border-radius: 4px;
  transition: width 0.4s ease-out;
  box-shadow: 0 0 6px rgba(139, 92, 246, 0.6);
}

.xp-fill.animate {
  animation: xp-pulse 0.5s ease-out;
}

@keyframes xp-pulse {
  0% {
    box-shadow: 0 0 6px rgba(139, 92, 246, 0.6);
  }
  50% {
    box-shadow: 0 0 15px rgba(139, 92, 246, 1), 0 0 25px rgba(167, 139, 250, 0.8);
  }
  100% {
    box-shadow: 0 0 6px rgba(139, 92, 246, 0.6);
  }
}

/* Streak Display */
.hud-streak {
  min-width: 60px;
}

.streak-value {
  font-size: 1.1em;
  font-weight: 700;
  color: #fbbf24;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.streak-value.has-streak {
  animation: streak-glow 2s ease-in-out infinite;
}

@keyframes streak-glow {
  0%, 100% {
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
  }
  50% {
    text-shadow: 0 0 12px rgba(251, 191, 36, 0.8), 0 0 20px rgba(251, 191, 36, 0.4);
  }
}

/* Tracking Indicator */
.tracking-indicator {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 8px;
  font-size: 14px; /* Increased for kids readability (was 12px) */
  font-weight: 600;
  text-align: center;
  color: #34d399; /* Improved contrast (was #6ee7b7) - meets WCAG AA */
}

.tracking-indicator.active {
  animation: pulse-glow 2s infinite;
  /* iOS: GPU acceleration for box-shadow animation */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: box-shadow, opacity;
}

@keyframes pulse-glow {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.3);
  }
  50% {
    opacity: 0.9;
    box-shadow: 0 0 12px rgba(52, 211, 153, 0.5);
  }
}

/* Power-Up Bar */
.power-bar {
  position: fixed;
  bottom: calc(30px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 100;
  align-items: flex-end;
}

.power-card {
  background: var(--bg-dark);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 12px 16px;
  min-width: 100px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 2px solid rgba(255, 255, 255, 0.1);
  animation: slideUp 0.3s ease-out;
  position: relative;
  overflow: hidden;
}

.power-card.expired {
  animation: slideDown 0.3s ease-out;
  opacity: 0;
}

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

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

.power-icon {
  font-size: 32px;
  margin-bottom: 4px;
}

.power-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.power-timer {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.power-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
}

.power-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--success-color));
  transition: width 0.1s linear;
}

/* Overlays */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 0;
  box-sizing: border-box;
}

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

.overlay-content {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.02) 100%),
    #1c1c24;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 22px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.06);
  animation: scaleIn 0.3s ease;
  text-align: center;
  margin: auto;
  flex-shrink: 0;
}

@keyframes scaleIn {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.overlay-content h3 {
  margin: 0 0 16px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(180deg, #ffffff 0%, #d8dbff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.overlay-content p {
  margin: 0 0 20px;
  font-size: 16px;
  line-height: 1.55;
  color: rgba(255,255,255,0.78);
}

.overlay-content button {
  background: linear-gradient(180deg, #7DD3FC 0%, #0EA5E9 60%, #0369A1 100%);
  color: white;
  border: none;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 700;
  padding: 13px 34px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(14,165,233,0.35), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform 0.15s, filter 0.15s;
}

.overlay-content button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

/* Tutorial tip card — appears inside overlay-content for tutorial overlay */
.tutorial-content {
  text-align: left;
}

.tutorial-content h3 {
  text-align: center;
}

.tutorial-content > p {
  text-align: center;
}

.tutorial-tip {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 18px 0 22px;
  padding: 14px 16px;
  background:
    linear-gradient(180deg, rgba(129, 140, 248, 0.16) 0%, rgba(99, 102, 241, 0.08) 100%),
    rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(129, 140, 248, 0.32);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tutorial-tip-icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(165, 180, 252, 0.32) 0%, rgba(99, 102, 241, 0.22) 100%);
  border: 1px solid rgba(165, 180, 252, 0.4);
  color: #e0e7ff;
  filter: drop-shadow(0 2px 6px rgba(99, 102, 241, 0.45));
}

.tutorial-tip-icon svg {
  width: 26px;
  height: 26px;
  display: block;
}

.tutorial-tip-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tutorial-tip-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: linear-gradient(90deg, #c7d2fe 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.tutorial-tip-desc {
  font-size: 15px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.82);
}

/* Recap Overlay - z-index above start-screen (5000) but below parental-gate (6000) */
.recap-overlay {
  z-index: 5500;
}

.recap-stats {
  display: flex;
  gap: 20px;
  margin: 20px 0;
  justify-content: center;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  min-width: 100px;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: center;
}

.stat-icon {
  font-size: 20px;
  margin-bottom: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  height: 24px;
  color: #c7d2fe;
}
.stat-icon svg { width: 24px; height: 24px; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35)); }
.stat.highlight .stat-icon { color: #fbbf24; }
.stat.highlight .stat-icon svg { filter: drop-shadow(0 0 8px rgba(251,191,36,0.55)); }

.high-score-icon svg { width: 28px; height: 28px; color: #fde047; filter: drop-shadow(0 0 8px rgba(253,224,71,0.6)); }
.coin-icon svg { width: 22px; height: 22px; vertical-align: -5px; }
.streak-flame svg { width: 22px; height: 22px; color: #fb923c; vertical-align: -5px; filter: drop-shadow(0 0 6px rgba(251,146,60,0.55)); }
.challenge-check { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; }
.challenge-check svg { width: 18px; height: 18px; }
.challenge-item .challenge-check { color: rgba(255,255,255,0.35); }
.challenge-item.completed .challenge-check { color: #34d399; }
.challenge-progress svg { width: 16px; height: 16px; color: #fde047; vertical-align: -3px; }
.share-btn-icon { display: inline-flex; align-items: center; justify-content: center; }
.share-btn-icon svg { width: 18px; height: 18px; }
.achievement-banner-reward svg { width: 16px; height: 16px; vertical-align: -3px; margin-left: 2px; }

.stat.highlight {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.2));
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.stat.highlight .stat-value {
  color: #fbbf24;
}

/* High Score Banner */
.high-score-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  border-radius: 12px;
  margin-bottom: 16px;
  animation: high-score-pulse 1.5s ease-in-out infinite;
}

.high-score-icon {
  font-size: 32px;
  animation: trophy-bounce 0.6s ease-in-out infinite;
}

.high-score-text {
  font-size: 18px;
  font-weight: 800;
  color: #000;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.previous-score {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.6);
}

@keyframes high-score-pulse {
  0%, 100% {
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.4);
  }
  50% {
    box-shadow: 0 4px 25px rgba(251, 191, 36, 0.7);
  }
}

@keyframes trophy-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.results-screen.new-high-score h3 {
  color: #fbbf24;
}

/* Results Screen Progression */
.results-screen {
  max-width: 400px;
}

.progression-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  padding: 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
  border-radius: 16px;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.level-badge {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 50%;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.level-number {
  font-size: 18px;
  font-weight: 800;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.xp-section {
  width: 100%;
  text-align: center;
}

.xp-earned {
  font-size: 20px;
  font-weight: 700;
  color: #a5b4fc;
  margin-bottom: 8px;
  animation: xpPop 0.5s ease;
}

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

.xp-bar-container {
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 6px;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  border-radius: 6px;
  transition: width 0.5s ease;
  position: relative;
}

.xp-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.xp-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #f97316, #ef4444);
  border-radius: 20px;
  animation: streakGlow 2s ease infinite;
  /* iOS: GPU acceleration for box-shadow animation */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: box-shadow;
}

@keyframes streakGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(249, 115, 22, 0.4); }
  50% { box-shadow: 0 0 20px rgba(249, 115, 22, 0.6); }
}

.streak-flame {
  font-size: 20px;
  animation: flicker 0.3s ease infinite alternate;
}

@keyframes flicker {
  from { transform: scale(1) rotate(-5deg); }
  to { transform: scale(1.1) rotate(5deg); }
}

.streak-count {
  font-size: 22px;
  font-weight: 800;
  color: white;
}

.streak-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
}

/* Challenges Section */
.challenges-section {
  width: 100%;
  margin: 16px 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
}

.challenges-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.challenges-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.challenges-count {
  font-size: 14px;
  font-weight: 600;
  color: #10b981;
}

.challenges-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.challenge-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.challenge-item.completed {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.challenge-check {
  font-size: 16px;
  color: var(--text-secondary);
  width: 20px;
}

.challenge-item.completed .challenge-check {
  color: #10b981;
}

.challenge-desc {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: left;
}

.challenge-item.completed .challenge-desc {
  color: var(--text-primary);
}

.challenge-progress {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.challenge-item.completed .challenge-progress {
  color: #10b981;
}

/* Coins Display */
.coins-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  margin: 16px 0;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.15));
  border-radius: 12px;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.coin-icon {
  font-size: 24px;
}

.coin-count {
  font-size: 24px;
  font-weight: 800;
  color: #fbbf24;
}

/* Achievement Unlocked Section */
.achievements-unlocked-section {
  padding: 16px;
  margin: 8px 0;
}

.achievements-unlocked-header {
  font-size: 16px;
  font-weight: 700;
  color: #fbbf24;
  text-align: center;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.achievement-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(245, 158, 11, 0.08));
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 10px;
  animation: achievementSlideIn 0.4s ease;
}

.achievement-banner:last-child {
  margin-bottom: 0;
}

.achievement-banner-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.achievement-banner-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.achievement-banner-name {
  font-size: 14px;
  font-weight: 700;
  color: #fbbf24;
}

.achievement-banner-desc {
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.achievement-banner-reward {
  font-size: 13px;
  font-weight: 600;
  color: #fbbf24;
  white-space: nowrap;
  flex-shrink: 0;
}

@keyframes achievementSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Next Achievement Progress Section */
.next-achievement-section {
  padding: 12px 16px;
  margin: 4px 0;
}

.next-achievement-header {
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.next-achievement-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.next-achievement-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.next-achievement-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 4px;
}

.next-achievement-name {
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
}

.next-achievement-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.next-achievement-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.next-achievement-progress {
  font-size: 12px;
  color: #94a3b8;
}

/* Shop Nudge */
.shop-nudge {
  text-align: center;
  font-size: 13px;
  color: #a855f7;
  padding: 8px 16px;
  margin: 4px 0;
}

/* Recap Actions */
.recap-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 20px 0;
}

.recap-actions .btn {
  flex: 1;
  max-width: 150px;
}

.btn-secondary {
  background: var(--bg-light);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Level Up Celebration */
.level-up-celebration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  animation: celebrationFade 0.3s ease;
}

.level-up-content {
  text-align: center;
  animation: celebrationPop 0.5s ease;
}

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

.level-up-text {
  font-size: 48px;
  font-weight: 900;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 20px rgba(251, 191, 36, 0.5);
  margin-bottom: 16px;
}

.level-up-level {
  font-size: 72px;
  font-weight: 900;
  color: white;
  text-shadow: 0 0 30px rgba(99, 102, 241, 0.8);
}

/* Loading Overlay */
.loading-overlay .overlay-content {
  background: transparent;
  box-shadow: none;
}

.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.loading-dots {
  display: flex;
  gap: 0.5rem;
}

.loading-dot {
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  background: var(--color-text-light);
  animation: loadingBounce 1.2s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.15s; }
.loading-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes loadingBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.loading-text {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text-light);
  opacity: 0.9;
}

/* Settings Panel */
.settings-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.settings-content {
  background: #1f2937;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 10px 12px;
  min-width: 44px;
  min-height: 44px;
  transition: color var(--transition-speed);
}

.close-btn:hover {
  color: var(--text-primary);
}

.settings-body {
  padding: 24px;
}

.setting-item {
  margin-bottom: 24px;
}

.setting-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  cursor: pointer;
}

.setting-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.setting-description {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  border: none;
}

.settings-footer {
  padding: 20px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: flex-end;
}

/* Letter Trace Settings */
.letter-trace-settings {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.settings-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-color);
  margin: 0 0 16px 0;
}

.slider-value {
  display: inline-block;
  min-width: 50px;
  text-align: right;
  color: var(--text-muted);
  font-size: 14px;
  margin-left: 12px;
}

/* Category Selection Buttons */
.category-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.category-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  min-width: 80px;
}

.category-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.category-btn.active {
  background: rgba(74, 222, 128, 0.15);
  border-color: #4ade80;
}

.category-emoji {
  font-size: 24px;
}

.category-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-color);
}

/* Theme Selection Buttons */
.theme-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.theme-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid transparent;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  color: var(--text-color);
}

.theme-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.theme-btn.active {
  background: rgba(100, 181, 246, 0.15);
  border-color: #64B5F6;
}

.theme-btn span {
  font-size: 16px;
}

/* Floating Text */
.floating-text {
  position: fixed;
  font-size: 24px;
  font-weight: 800;
  pointer-events: none;
  z-index: 500;
  opacity: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.floating-text.animate {
  animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateY(-100px);
    opacity: 0;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .control-panel {
    width: calc(100% - 40px);
    max-width: 320px;
  }

  .hud-top {
    min-width: 160px;
    padding: 12px;
  }

  .hud-value {
    font-size: 20px;
  }

  .power-bar {
    bottom: 20px;
    gap: 8px;
  }

  .power-card {
    min-width: 80px;
    padding: 10px 12px;
  }

  .power-icon {
    font-size: 24px;
  }

  .overlay-content {
    padding: 20px;
  }

  .recap-stats {
    flex-direction: column;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .control-panel {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
  }

  .game-title {
    font-size: 16px;
  }

  .btn {
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Compact mobile HUD — horizontal bar instead of tall column */
  .hud {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
  }

  .hud-top {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 8px 12px;
    border-radius: 12px 12px 0 0;
    justify-content: space-around;
  }

  .hud-item {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
  }

  .hud-label {
    font-size: 10px;
    letter-spacing: 0;
  }

  .hud-value {
    font-size: 16px;
  }

  /* Hide less critical items on mobile */
  .hud-streak,
  .hud-level {
    display: none;
  }

  .tracking-indicator {
    display: none;
  }

  /* Health bar compact */
  .health-bar {
    width: 50px;
    height: 16px;
  }

  .health-text {
    font-size: 9px;
  }

  /* Controls stay at top but compact */
  .hud-controls {
    top: calc(8px + var(--safe-area-top));
    left: calc(8px + var(--safe-area-left, 0px));
  }

  .exit-btn {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }

  .hud-settings-btn {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }

  .hud-tracking-select {
    height: 44px;
    font-size: 12px;
    padding: 0 8px;
  }
}

/* Dark mode adjustments (body already has dark bg) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-dark: rgba(0, 0, 0, 0.9);
  }
}

/* Mobile Landscape - critical for iPhone/Android in landscape mode */
@media (max-height: 500px) and (orientation: landscape) {
  .control-panel {
    top: calc(8px + var(--safe-area-top));
    left: calc(8px + var(--safe-area-left));
    width: 280px;
    max-height: calc(100vh - 16px - var(--safe-area-top) - var(--safe-area-bottom));
    overflow-y: auto;
    padding: 12px;
  }

  .panel-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
  }

  .game-title {
    font-size: 16px;
  }

  .control-section {
    margin-bottom: 8px;
  }

  .control-label {
    font-size: 11px;
    margin-bottom: 4px;
  }

  .select-input {
    padding: 6px 8px;
    font-size: 13px;
  }

  .control-actions {
    margin: 10px 0 8px;
    gap: 6px;
  }

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

  .status-text {
    padding: 6px 8px;
    font-size: 11px;
  }

  .free-time-display {
    margin-top: 8px;
    padding: 6px 8px;
    font-size: 11px;
  }

  /* HUD adjustments for landscape */
  .hud {
    top: calc(56px + var(--safe-area-top));
    left: calc(8px + var(--safe-area-left, 0px));
  }

  .hud-top {
    padding: 10px;
    gap: 8px;
    min-width: 140px;
  }

  .hud-value {
    font-size: 18px;
  }

  .health-bar {
    height: 20px;
  }

  /* Power bar adjustments */
  .power-bar {
    bottom: 8px;
  }

  .power-card {
    padding: 8px 10px;
    min-width: 70px;
  }

  .power-icon {
    font-size: 20px;
  }
}

/* Extra compact for very small landscape screens (iPhone SE, older phones) */
@media (max-height: 400px) and (orientation: landscape) {
  .control-panel {
    top: calc(6px + var(--safe-area-top));
    left: calc(6px + var(--safe-area-left));
    width: 250px;
    max-height: calc(100vh - 12px - var(--safe-area-top) - var(--safe-area-bottom));
    padding: 10px;
  }

  .panel-header {
    margin-bottom: 8px;
    padding-bottom: 6px;
  }

  .game-title {
    font-size: 14px;
  }

  .control-section {
    margin-bottom: 6px;
  }

  .select-input {
    padding: 5px 6px;
    font-size: 12px;
  }

  .btn {
    padding: 6px 8px;
    font-size: 11px;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .game-btn,
  .start-subtitle,
  .permission-content {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Skeleton loading shimmer */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 25%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.06) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--border-radius);
}

/* Focus styles for keyboard navigation */
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Free Time Display */
.free-time-display {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: #fcd34d;
}

.free-time-display.unlimited {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

/* Upgrade Modal */
.upgrade-modal .overlay-content {
  max-width: 600px;
}

.upgrade-modal h2 {
  margin: 0 0 12px;
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
}

.upgrade-modal > .overlay-content > p {
  margin: 0 0 24px;
  font-size: 16px;
  color: var(--text-secondary);
}

.upgrade-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.upgrade-option {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: all var(--transition-speed);
}

.upgrade-option:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.upgrade-option.highlight {
  border-color: var(--primary-color);
  background: rgba(59, 130, 246, 0.1);
}

.upgrade-option h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.upgrade-option p {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.upgrade-option .price {
  font-size: 32px;
  font-weight: 800;
  color: var(--success-color);
  margin-bottom: 16px;
}

.upgrade-option .btn {
  width: 100%;
}

.input-field {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 12px;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary-color);
}

.input-field::placeholder {
  color: var(--text-secondary);
}

.license-key-section {
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 4px;
}

.license-key-section p {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.license-key-section .input-field {
  max-width: 300px;
  display: inline-block;
  margin-right: 8px;
  margin-bottom: 0;
}

.upgrade-modal .close-btn {
  margin-top: 20px;
  padding: 10px 24px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.upgrade-modal .close-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

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

  .license-key-section .input-field {
    display: block;
    max-width: 100%;
    margin-right: 0;
    margin-bottom: 12px;
  }
}

/* Sponsor Display Styles */
.sponsor-display {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  margin-top: 20px;
  transition: all var(--transition-speed);
}

.sponsor-display:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sponsor-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.sponsor-tier {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.sponsor-logo {
  max-width: 150px;
  max-height: 50px;
  object-fit: contain;
}

.sponsor-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.sponsor-tagline {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

.sponsor-loading {
  margin-top: 30px;
}

.sponsor-gameover {
  margin-top: 24px;
  padding: 20px 32px;
}

/* Sponsor Corner Badge */
.sponsor-badge {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding: 8px 16px;
  border-radius: 100px;
  z-index: 50;
  transition: all var(--transition-speed);
}

.sponsor-badge:hover {
  background: rgba(0, 0, 0, 0.85);
}

.sponsor-badge-text {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
}

/* Payment Notification */
.payment-notification {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dark);
  padding: 16px 32px;
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  z-index: 2000;
  text-align: center;
  animation: slideUp 0.3s ease-out;
}

.payment-notification p {
  margin: 4px 0;
  font-size: 14px;
  color: var(--text-primary);
}

/* Activation Success */
.activation-success {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  animation: fadeIn 0.3s ease;
}

.success-content {
  text-align: center;
  color: white;
}

.success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  background: var(--success-color);
  border-radius: 50%;
  font-size: 40px;
  margin: 0 auto 20px;
  animation: scaleIn 0.5s ease;
}

.success-content h3 {
  font-size: 28px;
  margin-bottom: 8px;
}

.success-content p {
  font-size: 16px;
  opacity: 0.8;
}

.activation-success.fade-out {
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* Input Error State */
.input-field.error {
  border-color: var(--danger-color) !important;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* Payment Demo Modal */
.payment-demo-modal .overlay-content {
  max-width: 500px;
}

.payment-demo-modal ol {
  line-height: 1.8;
}

.payment-demo-modal a {
  color: var(--primary-color);
}

.payment-demo-modal code {
  font-family: monospace;
  font-size: 14px;
  color: var(--success-color);
}

/* ========================================
   Kid-Friendly Start Screen
   ======================================== */

.start-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(253, 121, 168, 0.25) 0%, transparent 70%),
    linear-gradient(145deg, #6C5CE7 0%, #A29BFE 45%, #FD79A8 100%);
  z-index: 5000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(60px + env(safe-area-inset-top, 0px)) var(--safe-area-right) var(--safe-area-bottom) var(--safe-area-left);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.start-screen.hidden {
  display: none;
}

.start-content {
  text-align: center;
  max-width: 100%;
  padding: 20px;
}

.start-title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-text-light);
  margin: 0 0 8px;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  animation: titleDrop 0.5s var(--ease-out-back) forwards;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

/* Hoppo head logo inside .start-title / .game-title. Was a 🎮 emoji that
 * rendered three different ways across iOS/Android/Safari. The PNG keeps
 * brand consistency at the cost of one image fetch (negligible). */
.start-title-icon,
.game-title-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  object-fit: contain;
}

@keyframes titleDrop {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Idle wobble + breath for the home-screen mascot. ~3s loop, GPU-friendly,
 * transform-origin set on the inline style so the pivot sits at Hoppo's
 * feet. The combined rotate + scale produces a subtle "breathing-while-
 * standing" effect rather than a metronome wobble. */
@keyframes hoppoMascotIdle {
  0%   { transform: rotate(-2deg) scale(1); }
  50%  { transform: rotate(2deg)  scale(1.03); }
  100% { transform: rotate(-2deg) scale(1); }
}
.hoppo-mascot-idle {
  animation: hoppoMascotIdle 3.2s ease-in-out infinite;
  will-change: transform;
}
/* Respect users who prefer reduced motion (per-iOS Accessibility setting). */
@media (prefers-reduced-motion: reduce) {
  .hoppo-mascot-idle { animation: none; }
}

.start-subtitle {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.9);
  margin: 0 0 24px;
  opacity: 0;
  animation: fadeInUp 0.4s ease forwards;
  animation-delay: 0.15s;
}

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

.game-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  max-width: 640px;
  margin: 0 auto 1.5rem;
  padding: 0 1rem;
}

.game-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 20px;
  background: var(--color-card-bg);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  position: relative;
  min-height: 140px;
  box-shadow: var(--shadow-card);
  border-bottom: 4px solid rgba(0, 0, 0, 0.08);
  transition:
    transform 0.15s var(--ease-out-smooth),
    box-shadow 0.15s ease,
    border-bottom-width 0.1s ease;
  opacity: 0;
  animation: cardEnter 0.4s var(--ease-out-smooth) forwards;
}

@media (hover: hover) {
  .game-btn:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
  }
}

.game-btn:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  box-shadow: var(--shadow-card-active);
  transition-duration: 0.05s;
}

.game-btn:nth-child(1) { animation-delay: 0.05s; }
.game-btn:nth-child(2) { animation-delay: 0.1s; }
.game-btn:nth-child(3) { animation-delay: 0.15s; }
.game-btn:nth-child(4) { animation-delay: 0.2s; }
.game-btn:nth-child(5) { animation-delay: 0.25s; }
.game-btn:nth-child(6) { animation-delay: 0.3s; }
.game-btn:nth-child(7) { animation-delay: 0.35s; }
.game-btn:nth-child(8) { animation-delay: 0.4s; }
.game-btn:nth-child(9) { animation-delay: 0.45s; }
.game-btn:nth-child(10) { animation-delay: 0.5s; }

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

.game-btn.game-btn--coming-soon {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.6);
}
.game-btn.game-btn--coming-soon:hover {
  transform: none;
  box-shadow: var(--shadow-card);
}

.game-btn.educational {
  background: var(--color-card-edu);
  border-left: 4px solid var(--color-educational);
  border-bottom: 4px solid rgba(29, 209, 161, 0.2);
}

.game-emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 8px;
  animation: emojiBreath 3s ease-in-out infinite;
}

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

.game-btn:nth-child(1) .game-emoji { animation-delay: 0s; }
.game-btn:nth-child(2) .game-emoji { animation-delay: 0.3s; }
.game-btn:nth-child(3) .game-emoji { animation-delay: 0.6s; }
.game-btn:nth-child(4) .game-emoji { animation-delay: 0.9s; }
.game-btn:nth-child(5) .game-emoji { animation-delay: 1.2s; }
.game-btn:nth-child(6) .game-emoji { animation-delay: 1.5s; }
.game-btn:nth-child(7) .game-emoji { animation-delay: 1.8s; }
.game-btn:nth-child(8) .game-emoji { animation-delay: 2.1s; }
.game-btn:nth-child(9) .game-emoji { animation-delay: 2.4s; }
.game-btn:nth-child(10) .game-emoji { animation-delay: 2.7s; }

.game-name {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--color-text-dark);
}

.game-description {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.game-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
  padding: 0.1875rem 0.5rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.game-badge--hands {
  background: rgba(108, 92, 231, 0.12);
  color: var(--color-brand);
}

.game-badge--movement {
  background: rgba(255, 107, 107, 0.12);
  color: var(--color-accent);
}

.game-badge--learn {
  background: rgba(29, 209, 161, 0.12);
  color: #0A8F6E;
}

/* Tracking Mode Toggle on Start Screen */
.tracking-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px 0;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.toggle-label {
  color: white;
  font-size: 16px;
  font-weight: 600;
}

.quick-select {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a2e;
  cursor: pointer;
  min-width: 120px;
}

.quick-select:focus {
  outline: 2px solid #4ade80;
  outline-offset: 2px;
}

.more-options-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  color: white;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 24px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.more-options-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Camera Permission Overlay
   Positioning & opacity handled by .screen-overlay in transitions.css.
   Background was rgba(0,0,0,0.85) — 15% see-through let the launcher
   cards bleed through, making the prompt feel half-rendered on a busy
   purple gradient. Bumped to 0.96 + a backdrop blur so the launcher
   below softens into an unreadable wash, keeping the kid focused on
   the camera-permission decision. */
.camera-permission {
  background: rgba(0, 0, 0, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.permission-content {
  text-align: center;
  color: white;
  padding: 32px;
  max-width: 400px;
  opacity: 0;
  transform: translateY(30px);
  animation: contentSlideUp 0.4s var(--ease-out-smooth) forwards;
  animation-delay: 0.1s;
}

@keyframes contentSlideUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.permission-emoji {
  font-size: 80px;
  display: block;
  margin-bottom: 16px;
  animation: bounce 1s ease infinite;
}

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

.permission-content h2 {
  font-size: 32px;
  margin: 0 0 12px;
  font-weight: 800;
}

.permission-content p {
  font-size: 18px;
  margin: 0 0 24px;
  opacity: 0.9;
  line-height: 1.5;
}

/* Camera Tips */
.camera-tips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0 24px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
}

.tip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
}

.tip-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* Allow Button with Loading State */
.allow-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 16px;
  font-size: 24px;
  font-weight: 700;
  padding: 16px 48px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
  min-width: 220px;
}

.allow-btn .btn-loading {
  display: none;
}

.allow-btn.loading .btn-text {
  display: none;
}

.allow-btn.loading .btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.spinner-small {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.allow-btn:hover {
  transform: scale(1.05);
}

.allow-btn:active {
  transform: scale(0.98);
}

.cancel-btn {
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  padding: 12px 32px;
  margin-top: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cancel-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: white;
}

/* Parental Gate Overlay
   Same opacity bump as the camera permission overlay — at 0.9 the launcher
   gradient and game cards were faintly visible behind, making the math
   problem feel like it was floating on a busy backdrop. 0.96 + blur keeps
   the parent's attention on the math input. */
.parental-gate {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6000; /* Must be above start-screen (5000) */
}

.gate-content {
  text-align: center;
  color: white;
  padding: 32px;
  max-width: 400px;
}

.gate-content h2 {
  font-size: 28px;
  margin: 0 0 16px;
  font-weight: 700;
}

.gate-content p {
  font-size: 16px;
  margin: 0 0 16px;
  opacity: 0.9;
}

.math-problem {
  font-size: 32px;
  font-weight: 800;
  color: #3b82f6;
  margin: 24px 0;
}

.math-input {
  width: 120px;
  height: 60px;
  font-size: 28px;
  text-align: center;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  margin-bottom: 24px;
}

.math-input:focus {
  outline: none;
  border-color: #3b82f6;
  background: rgba(255, 255, 255, 0.15);
}

.gate-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.gate-note {
  font-size: 12px;
  opacity: 0.6;
  margin-top: 24px;
}

/* Back button for control panel */
.back-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 8px;
}

.back-btn:hover {
  background: var(--bg-light);
  color: var(--text-primary);
}

/* Mobile portrait */
@media (max-width: 600px) {
  .start-title {
    font-size: 2.25rem;
  }

  .start-subtitle {
    font-size: 1.125rem;
  }

  .game-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .game-btn {
    padding: 16px 12px 14px;
    min-height: 120px;
  }

  .game-emoji {
    font-size: 2.5rem;
  }

  .game-name {
    font-size: 1rem;
  }

  .game-description {
    font-size: 0.75rem;
  }

  .game-badge {
    font-size: 0.625rem;
  }
}

/* Very small phones */
@media (max-width: 374px) {
  .game-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile Landscape - Start Screen */
@media (max-height: 500px) and (orientation: landscape) {
  .start-content {
    padding: 10px;
  }

  .start-title {
    font-size: 28px;
    margin-bottom: 4px;
  }

  .start-subtitle {
    font-size: 16px;
    margin-bottom: 12px;
  }

  .game-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.625rem;
    max-width: 100%;
  }

  .game-btn {
    padding: 12px 8px;
    border-radius: 14px;
    min-height: auto;
  }

  .game-emoji {
    font-size: 32px;
    margin-bottom: 4px;
  }

  .game-name {
    font-size: 12px;
  }

  .game-description {
    display: none;
  }

  .game-badge {
    display: none;
  }

  .more-options-btn {
    font-size: 14px;
    padding: 8px 16px;
  }

  .permission-emoji {
    font-size: 48px;
  }

  .permission-content h2 {
    font-size: 24px;
  }

  .permission-content p {
    font-size: 14px;
    margin-bottom: 16px;
  }

  .allow-btn {
    font-size: 18px;
    padding: 12px 32px;
  }
}

/* Extra small landscape */
@media (max-height: 400px) and (orientation: landscape) {
  .start-title {
    font-size: 24px;
  }

  .start-subtitle {
    font-size: 14px;
    margin-bottom: 8px;
  }

  .game-btn {
    padding: 8px 6px;
    border-radius: 12px;
  }

  .game-emoji {
    font-size: 28px;
  }

  .game-name {
    font-size: 11px;
  }

  .game-description {
    display: none;
  }

  .game-badge {
    display: none;
  }
}

/* ========================================
   Share & Viral Features
   ======================================== */

.share-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

.share-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.share-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
}

.share-btn:active {
  transform: translateY(0);
}

.share-btn.primary {
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  border-color: transparent;
}

.share-btn.primary:hover {
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.share-btn-icon {
  font-size: 20px;
}

/* Referral Code Display */
.referral-section {
  margin-top: 24px;
  padding: 16px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 12px;
}

.referral-section h4 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--success-color);
}

.referral-code {
  display: inline-block;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  font-family: monospace;
  font-size: 16px;
  font-weight: 700;
  color: white;
  letter-spacing: 1px;
}

.referral-stats {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.referral-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Create Character Button */
.create-character-btn {
  margin-top: 16px;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 18px;
  font-weight: 700;
  padding: 14px 28px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(240, 147, 251, 0.4);
}

.create-character-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(240, 147, 251, 0.5);
}

.create-character-btn:active {
  transform: scale(0.98);
}

/* Teacher Link */
.teacher-link {
  display: block;
  margin-top: 16px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}

.teacher-link:hover {
  color: white;
  text-decoration: underline;
}

/* Sponsor Multi Display */
.sponsor-multi {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.sponsor-compact {
  flex-direction: row;
  gap: 8px;
}

.sponsor-compact .sponsor-tier {
  font-size: 9px;
}

.sponsor-compact .sponsor-name {
  font-size: 13px;
}

/* Local Sponsor Badge */
.local-sponsor-badge {
  display: inline-block;
  padding: 4px 10px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  color: white;
  margin-bottom: 8px;
}

/* Game Over Share CTA */
.game-over-share-cta {
  margin-top: 20px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.2) 0%, rgba(124, 58, 237, 0.2) 100%);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 12px;
  text-align: center;
}

.game-over-share-cta p {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-dark);
  padding: 14px 24px;
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  color: white;
  font-size: 14px;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.toast.error {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

/* Viral Streak Display */
.streak-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-radius: 100px;
  font-size: 14px;
  font-weight: 700;
  color: white;
}

.streak-display .streak-icon {
  font-size: 20px;
}

.streak-display .streak-count {
  font-size: 18px;
}

/* Achievement Unlock Animation */
.achievement-unlock {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  background: var(--bg-dark);
  padding: 32px 48px;
  border-radius: 20px;
  text-align: center;
  z-index: 10000;
  opacity: 0;
  animation: achievementPop 0.5s ease forwards;
  box-shadow: 0 0 60px rgba(245, 158, 11, 0.5);
}

@keyframes achievementPop {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.achievement-unlock .achievement-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.achievement-unlock h3 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 800;
  color: #fbbf24;
}

.achievement-unlock p {
  margin: 0;
  font-size: 16px;
  color: var(--text-secondary);
}

/* =============================================================================
   Asteroids Fire Button (Touch Controls)
   ============================================================================= */

.asteroids-fire-btn {
  position: fixed;
  bottom: calc(100px + var(--safe-area-bottom));
  right: calc(30px + var(--safe-area-right));
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border: 4px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  z-index: 1000;
  box-shadow:
    0 4px 15px rgba(239, 68, 68, 0.5),
    0 0 30px rgba(239, 68, 68, 0.3),
    inset 0 -3px 0 rgba(0, 0, 0, 0.2);
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  /* iOS: GPU acceleration for box-shadow transitions */
  -webkit-transform: translateZ(0);
  will-change: transform, box-shadow;
}

.asteroids-fire-btn:active {
  transform: scale(0.92);
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow:
    0 2px 10px rgba(239, 68, 68, 0.6),
    0 0 40px rgba(239, 68, 68, 0.5),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.asteroids-fire-btn:hover {
  transform: scale(1.05);
  box-shadow:
    0 6px 20px rgba(239, 68, 68, 0.6),
    0 0 40px rgba(239, 68, 68, 0.4),
    inset 0 -3px 0 rgba(0, 0, 0, 0.2);
}

/* Pulse animation when button is visible */
@keyframes fire-btn-pulse {
  0%, 100% {
    box-shadow:
      0 4px 15px rgba(239, 68, 68, 0.5),
      0 0 30px rgba(239, 68, 68, 0.3),
      inset 0 -3px 0 rgba(0, 0, 0, 0.2);
  }
  50% {
    box-shadow:
      0 4px 20px rgba(239, 68, 68, 0.7),
      0 0 50px rgba(239, 68, 68, 0.5),
      inset 0 -3px 0 rgba(0, 0, 0, 0.2);
  }
}

.asteroids-fire-btn:not(:active) {
  animation: fire-btn-pulse 2s ease-in-out infinite;
}

/* Mobile responsive - larger on smaller screens */
@media (max-width: 768px) {
  .asteroids-fire-btn {
    width: 90px;
    height: 90px;
    font-size: 16px;
    bottom: calc(80px + var(--safe-area-bottom));
    right: calc(20px + var(--safe-area-right));
  }
}

/* Landscape mode on mobile - position on the side */
@media (max-height: 500px) and (orientation: landscape) {
  .asteroids-fire-btn {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    right: calc(20px + var(--safe-area-right));
  }

  .asteroids-fire-btn:active {
    transform: translateY(-50%) scale(0.92);
  }

  .asteroids-fire-btn:hover {
    transform: translateY(-50%) scale(1.05);
  }
}

/* =============================================
   Stickiness & Engagement UI Components
   ============================================= */

/* Streak Claim Overlay */
.streak-claim-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.7); display: flex;
  align-items: center; justify-content: center;
}
.streak-claim-card {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border-radius: 20px; padding: 2rem; text-align: center;
  color: white; max-width: 320px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.streak-claim-emoji { font-size: 3rem; margin-bottom: 0.5rem; }
.streak-claim-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 0.5rem; }
.streak-claim-coins { font-size: 1.2rem; color: #fbbf24; }
.streak-claim-btn {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1a1a2e; border: none; border-radius: 12px;
  padding: 0.75rem 2rem; font-size: 1.1rem; font-weight: 700;
  cursor: pointer; margin-top: 1rem; min-height: 44px;
}

/* Welcome Banner */
.welcome-banner { text-align: center; padding: 1rem 0 0.5rem; }
.welcome-text { font-size: 1.3rem; font-weight: 700; }
.welcome-subtext { font-size: 0.85rem; color: #86868b; margin-top: 0.25rem; }

/* Challenge Card */
.challenge-card {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 0.75rem 1rem; margin: 0.5rem 1rem;
}
.challenge-header { display: flex; justify-content: space-between; font-size: 0.75rem; margin-bottom: 0.5rem; }
.challenge-label { text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.6; }
.challenge-reward { color: #fbbf24; }
.challenge-name { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.5rem; }
.challenge-bar { flex: 1; background: rgba(255,255,255,0.1); border-radius: 4px; height: 6px; }
.challenge-fill { background: linear-gradient(90deg, #34d399, #059669); border-radius: 4px; height: 100%; transition: width 0.3s; }
.challenge-progress { display: flex; align-items: center; gap: 0.5rem; }
.challenge-count { font-size: 0.8rem; opacity: 0.7; }

/* Streak Calendar */
.streak-calendar {
  background: rgba(255,255,255,0.04); border-radius: 12px;
  padding: 0.75rem 1rem; margin: 0.5rem 1rem;
}
.streak-header { display: flex; justify-content: space-between; font-size: 0.75rem; margin-bottom: 0.5rem; }
.streak-status { color: #fb923c; }
.streak-days { display: flex; justify-content: space-between; }

/* Coin Display in HUD */
.hud-coins { display: flex; align-items: center; gap: 0.25rem; }
.coin-value { color: #fbbf24; font-weight: 600; }

/* In-game challenge progress indicator */
.hud-challenge-progress {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: opacity 0.3s;
  z-index: 10;
}
.hud-challenge-progress.hud-challenge-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Onboarding */
.onboarding-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background:
    radial-gradient(circle at 20% 10%, rgba(124, 58, 237, 0.35), transparent 55%),
    radial-gradient(circle at 80% 90%, rgba(14, 165, 233, 0.30), transparent 60%),
    linear-gradient(135deg, #1a1a2e, #0f3460);
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.onboarding-container {
  text-align: center; padding: 1.75rem 1.5rem; max-width: 420px; position: relative;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
}
.onboarding-step h2 {
  font-size: 1.5rem; margin: 1rem 0 0.5rem;
  font-weight: 800; letter-spacing: -0.01em;
  background: linear-gradient(180deg, #ffffff 0%, #d8dbff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.onboarding-step p { opacity: 0.78; font-size: 0.95rem; line-height: 1.45; max-width: 32ch; margin: 0 auto; }
.onboarding-emoji {
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35));
}
.onboarding-icons { letter-spacing: 0; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35)); }
.onboarding-next {
  background: linear-gradient(180deg, #7DD3FC 0%, #0EA5E9 60%, #0369A1 100%);
  color: white; border: none;
  border-radius: 14px; padding: 0.85rem 2.2rem;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  margin-top: 1.5rem; min-height: 48px;
  letter-spacing: 0.02em;
  box-shadow:
    0 6px 18px rgba(14, 165, 233, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.onboarding-next:hover {
  transform: translateY(-1px);
  box-shadow:
    0 10px 24px rgba(14, 165, 233, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.onboarding-skip {
  position: absolute; top: 0.85rem; right: 0.85rem;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255,255,255,0.65); font-size: 0.8rem; cursor: pointer;
  padding: 0.35rem 0.8rem; border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.15s ease, background 0.15s ease;
}
.onboarding-skip:hover { color: rgba(255,255,255,0.95); background: rgba(255, 255, 255, 0.12); }
.onboarding-modes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; margin-top: 1.25rem;
}
.onboarding-mode-btn {
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px; padding: 0.9rem 0.5rem; color: white;
  font-size: 0.95rem; cursor: pointer; min-height: 96px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.onboarding-mode-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}
.onboarding-email-form { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.onboarding-email-input {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  color: white;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.onboarding-email-input::placeholder { color: rgba(255,255,255,0.45); }
.onboarding-email-input:focus {
  border-color: #7DD3FC;
  background: rgba(255,255,255,0.12);
}
.onboarding-email-save {
  background: linear-gradient(180deg, #34D399 0%, #059669 100%);
  color: white; border: none;
  border-radius: 12px; padding: 0.75rem 1.5rem;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  min-height: 44px;
  letter-spacing: 0.02em;
  box-shadow:
    0 4px 14px rgba(5, 150, 105, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.onboarding-email-skip {
  background: transparent;
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 40px;
}
/* pointer-events none: the mascot is decorative, but its bounding box overlaps
   the top-right Skip button and was stealing taps in that region (surfaced by
   the e2e-smoke gate once the offline runner stopped masking this spec). */
.onboarding-mascot { filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.4)); pointer-events: none; }

/* Learn mode toast */
.learn-toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #667eea; color: white; padding: 0.75rem 1.5rem;
  border-radius: 12px; font-weight: 600; z-index: 10000;
  animation: toast-slide 0.3s ease;
}
@keyframes toast-slide { from { opacity: 0; transform: translateX(-50%) translateY(-20px); } }

/* Parent link */
.parent-link {
  display: block; text-align: center; padding: 0.5rem;
  font-size: 0.75rem; color: #86868b; text-decoration: none;
}

/* Parent Dashboard Modal */
.parent-dashboard {
  position: fixed; inset: 0; z-index: 9000;
  background: radial-gradient(ellipse at center, rgba(40,30,75,0.78) 0%, rgba(8,8,16,0.92) 75%);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.parent-dashboard-content {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.02) 100%),
    #1c1c24;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 24px 64px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.06);
  border-radius: 22px;
  padding: 1.5rem; max-width: 440px; width: 90%; max-height: 88vh; overflow-y: auto;
  color: white;
}
.parent-dashboard-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem;
}
.parent-dashboard-header h2 {
  margin: 0; font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em;
  background: linear-gradient(180deg, #ffffff 0%, #d8dbff 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.parent-close-btn {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.85); font-size: 1.05rem; cursor: pointer;
  width: 32px; height: 32px; padding: 0; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.parent-close-btn:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.2);
  transform: scale(1.05);
}
.parent-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
}
.parent-stat {
  background: linear-gradient(160deg, rgba(124,156,255,0.12) 0%, rgba(255,255,255,0.03) 100%);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 0.9rem 0.85rem;
  text-align: center;
  transition: border-color 0.2s, transform 0.15s;
}
.parent-stat:hover {
  border-color: rgba(124,156,255,0.28);
  transform: translateY(-1px);
}
.parent-stat-label {
  font-size: 0.68rem; color: rgba(255,255,255,0.55);
  letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 0.35rem;
  font-weight: 600;
}
.parent-stat-value {
  font-size: 1.45rem; font-weight: 800; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff 0%, #c7d2fe 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.parent-achievements {
  margin-top: 1.25rem;
}
.parent-achievements-title {
  font-size: 0.78rem; color: rgba(255,255,255,0.6);
  margin: 0 0 0.6rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700;
}
.parent-achievement {
  background: linear-gradient(180deg, rgba(253,224,71,0.1) 0%, rgba(253,224,71,0.04) 100%);
  border: 1px solid rgba(253,224,71,0.22);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
  display: flex; align-items: center; gap: 8px;
  color: #fef3c7;
}
.parent-achievement::before {
  content: '';
  width: 16px; height: 16px; flex-shrink: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fbbf24' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 12 10 18 20 6'/></svg>");
  background-size: contain; background-repeat: no-repeat; background-position: center;
}
.parent-no-achievements {
  font-size: 0.85rem; color: rgba(255,255,255,0.45);
  text-align: center; margin: 0.5rem 0; padding: 0.75rem;
  border: 1px dashed rgba(255,255,255,0.12); border-radius: 10px;
}

/* Parent dashboard - audio & errors sections (styled via CSS so they match the glass card language) */
#parentAudio, #parentErrors {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(160deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.02) 100%);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
}
#parentAudio h3, #parentErrors h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: #e0e7ff;
}
#parentAudio label {
  border-radius: 8px;
  padding: 8px 6px !important;
  margin: 0 -6px;
  transition: background 0.15s;
}
#parentAudio label:hover {
  background: rgba(255,255,255,0.04);
}
#parentAudio input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: #7DD3FC;
}
#parentAudio button {
  border-radius: 999px !important;
  font-weight: 700 !important;
  transition: transform 0.15s, filter 0.15s;
}
#parentAudio button:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}
#parentErrors > div:first-child > button {
  background: rgba(255,255,255,0.08) !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
  transition: background 0.15s;
}
#parentErrors > div:first-child > button:hover {
  background: rgba(255,255,255,0.14) !important;
}

/* ===== Phase 3: New HUD Styles ===== */

.hud-score-main {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  font-size: 52px;
  font-weight: 900;
  font-family: 'Inter', system-ui;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #ffffff 0%, #d8dbff 60%, #a5b4fc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.55)) drop-shadow(0 0 14px rgba(124,156,255,0.25));
  z-index: 100;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.18s ease-out;
  pointer-events: none;
}

.hud-score-main.hud-score-bump {
  transform: translateX(-50%) scale(1.18);
  filter: drop-shadow(0 3px 10px rgba(0,0,0,0.55)) drop-shadow(0 0 24px rgba(253,224,71,0.65));
}

.hud-hearts {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  z-index: 100;
  pointer-events: none;
}

.hud-heart {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.hud-heart svg { width: 100%; height: 100%; display: block; }
.hud-heart.heart-full svg { color: #ef4444; filter: drop-shadow(0 0 6px rgba(239,68,68,0.55)); }
.hud-heart.heart-empty svg { color: rgba(255,255,255,0.25); }
.hud-heart.heart-losing { animation: heart-lost 0.45s ease-out forwards; }

@keyframes heart-lost {
  0% { transform: scale(1); }
  30% { transform: scale(1.35); }
  100% { transform: scale(0); opacity: 0; }
}

.hud-streak-badge {
  position: fixed;
  top: max(72px, calc(68px + env(safe-area-inset-top)));
  left: 50%;
  transform: translateX(-50%) scale(0);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 6px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(254, 215, 170, 0.95) 0%, rgba(251, 146, 60, 0.95) 100%);
  border: 1px solid rgba(255, 237, 213, 0.7);
  font-size: 22px;
  font-weight: 800;
  color: #7c2d12;
  text-shadow: 0 1px 2px rgba(255,255,255,0.4);
  box-shadow: 0 6px 18px rgba(234, 88, 12, 0.45), inset 0 1px 0 rgba(255,255,255,0.5);
  z-index: 100;
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.hud-streak-badge svg { width: 22px; height: 22px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2)); }

.hud-streak-badge.visible { display: inline-flex !important; transform: translateX(-50%) scale(1); }
.hud-streak-badge.fading { transition: opacity 1.5s ease-out; opacity: 0; }

.hud-timer {
  position: fixed;
  top: max(72px, calc(68px + env(safe-area-inset-top)));
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  z-index: 100;
  pointer-events: none;
  font-family: 'Inter', system-ui;
}

.hud-timer.timer-critical { animation: timer-pulse 0.5s ease-in-out infinite alternate; }
@keyframes timer-pulse {
  from { color: white; box-shadow: 0 0 0 rgba(239,68,68,0); }
  to { color: #fecaca; box-shadow: 0 0 18px rgba(239,68,68,0.6); }
}

@media (max-width: 768px) {
  .hud-score-main { font-size: 42px; }
  .hud-heart { width: 24px; height: 24px; }
  .hud-hearts { padding: 6px 10px; gap: 4px; }
  .hud-timer { font-size: 18px; padding: 3px 10px; }
  .hud-streak-badge { font-size: 18px; padding: 5px 12px 5px 8px; }
  .hud-streak-badge svg { width: 18px; height: 18px; }
}
