:root {
  /* Color Palette - Vibrant Gaming Themes */
  --bg-primary: #0e1322;
  --bg-surface: #171f38;
  --bg-surface-elevated: #212c4e;
  --bg-card: rgba(27, 37, 65, 0.85);
  
  --brand-primary: #58cc02; /* Duolingo energetic green */
  --brand-primary-hover: #46a302;
  --brand-primary-shadow: #3b8800;
  
  --lego-red: #e3000b;
  --lego-yellow: #ffd500;
  --lego-blue: #0055bf;
  --lego-green: #00852b;
  
  --minecraft-green: #5b8731;
  --minecraft-brown: #866043;
  --minecraft-diamond: #4dedf4;
  --minecraft-nether: #801d1d;
  --minecraft-gold: #fcee4b;
  
  --phonk-purple: #9d4edd;
  --phonk-pink: #ff007f;
  --phonk-cyan: #00f0ff;
  --phonk-neon-glow: 0 0 18px rgba(255, 0, 127, 0.6);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #0f172a;
  
  --accent-aura: #fbbf24;
  --accent-streak: #ff5722;
  --accent-gem: #38bdf8;
  --accent-xp: #a855f7;
  
  --border-subtle: rgba(255, 255, 255, 0.12);
  --border-glow: rgba(56, 189, 248, 0.35);
  
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 9999px;
  
  --font-game: 'Fredoka', cursive, sans-serif;
  --font-mono: 'Space Grotesk', monospace;
  --font-ui: 'Outfit', sans-serif;
  
  --shadow-pressable: 0 5px 0 0 rgba(0, 0, 0, 0.35);
  --shadow-active: 0 2px 0 0 rgba(0, 0, 0, 0.35);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-game);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Canvas Overlay for Confetti and Hype Aura */
#effects-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   TOP NAVIGATION BAR (Duolingo / Gaming HUD style)
   ========================================================================== */
.top-nav {
  height: 72px;
  background: var(--bg-surface);
  border-bottom: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface-elevated);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 4px 14px 4px 6px;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  color: var(--text-main);
  box-shadow: var(--shadow-pressable);
}

.avatar-pill:hover {
  transform: translateY(-2px);
  border-color: var(--accent-gem);
}

.avatar-pill:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-active);
}

.avatar-icon-wrap {
  width: 44px;
  height: 44px;
  background: #2a3b68;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--lego-yellow);
}

.avatar-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.user-name {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
}

.user-rank-tag {
  font-size: 11px;
  color: var(--accent-aura);
  font-weight: 600;
}

/* Nav Stats Badges */
.nav-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-elevated);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  border: 2px solid var(--border-subtle);
}

.stat-icon {
  font-size: 18px;
}

.aura-badge {
  color: var(--accent-aura);
  border-color: rgba(251, 191, 36, 0.4);
}

.streak-badge {
  color: var(--accent-streak);
  border-color: rgba(255, 87, 34, 0.4);
}

.shield-indicator {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 6px;
  border-radius: 8px;
  margin-left: 4px;
}

.gem-badge {
  color: var(--accent-gem);
  border-color: rgba(56, 189, 248, 0.4);
}

.level-badge {
  color: var(--accent-xp);
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-xp-bar-wrap {
  width: 60px;
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  overflow: hidden;
}

.mini-xp-fill {
  height: 100%;
  background: var(--accent-xp);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Nav Right & Action Buttons */
.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 2px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.icon-btn:hover {
  transform: scale(1.05);
  border-color: var(--accent-gem);
}

.action-pill-btn {
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  box-shadow: var(--shadow-pressable);
  transition: transform var(--transition-fast);
  color: #fff;
}

.action-pill-btn:hover {
  transform: translateY(-2px);
}

.action-pill-btn:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-active);
}

.phonk-glow-btn {
  background: linear-gradient(135deg, var(--phonk-purple), var(--phonk-pink));
  box-shadow: 0 4px 14px rgba(255, 0, 127, 0.4), var(--shadow-pressable);
}

.logic-glow-btn {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4), var(--shadow-pressable);
}

/* Audio Dropdown */
.audio-dropdown {
  position: absolute;
  top: 54px;
  right: 120px;
  background: var(--bg-surface-elevated);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 230px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 200;
}

.audio-dropdown.hidden {
  display: none;
}

.audio-option-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.audio-option-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.audio-option-item.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-gem);
  font-weight: 700;
}

.audio-volume-slider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
}

.audio-volume-slider input {
  flex: 1;
  cursor: pointer;
}

/* ==========================================================================
   MAIN VIEWPORT & VIEW PANELS
   ========================================================================== */
.main-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
}

.view-panel {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.view-panel.hidden {
  display: none !important;
  opacity: 0;
}

/* Reusable UI Buttons */
.continue-pill-btn {
  background: var(--brand-primary);
  color: #fff;
  border: none;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  padding: 14px 32px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: 0 5px 0 var(--brand-primary-shadow);
  transition: transform var(--transition-fast), background var(--transition-fast);
  text-align: center;
}

.continue-pill-btn:hover {
  background: var(--brand-primary-hover);
  transform: translateY(-2px);
}

.continue-pill-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--brand-primary-shadow);
}

.hint-pill-btn {
  background: var(--bg-surface-elevated);
  border: 2px solid var(--lego-yellow);
  color: var(--lego-yellow);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: var(--shadow-pressable);
  transition: transform var(--transition-fast);
}

.hint-pill-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 213, 0, 0.1);
}

.close-arena-btn, .close-lesson-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s ease;
}

.close-arena-btn:hover, .close-lesson-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 15, 30, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.hidden {
  display: none !important;
}

.modal-overlay.hidden {
  display: none !important;
  opacity: 0;
}

.reward-card-content {
  background: var(--bg-surface);
  border: 3px solid var(--lego-yellow);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 90%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 30px rgba(255, 213, 0, 0.3);
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.reward-flair-icon {
  font-size: 64px;
  margin-bottom: 12px;
  animation: bounce 1s infinite alternate ease-in-out;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-10px); }
}

.reward-title {
  font-family: var(--font-mono);
  font-size: 26px;
  color: var(--lego-yellow);
  margin-bottom: 8px;
}

.reward-sub {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 24px;
}

.reward-prizes-row {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.prize-pill {
  background: var(--bg-surface-elevated);
  border: 2px solid var(--border-subtle);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
}

.aura-prize {
  border-color: var(--accent-aura);
  color: var(--accent-aura);
}

.reward-stars-display {
  display: flex;
  gap: 12px;
  font-size: 36px;
  margin-bottom: 28px;
}

.star-pop {
  animation: starPulse 0.6s ease;
}

@keyframes starPulse {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   MOBILE BOTTOM NAVIGATION BAR (iOS / Android)
   ========================================================================== */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 64px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 2px solid rgba(255, 255, 255, 0.12);
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 4px);
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  }

  .mobile-nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #94a3b8;
    font-family: var(--font-game);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 12px;
    transition: all 0.15s ease;
    flex: 1;
    max-width: 76px;
  }

  .mobile-nav-item:active {
    transform: scale(0.92);
  }

  .mob-nav-icon {
    font-size: 22px;
    line-height: 1;
    filter: grayscale(0.4);
    transition: all 0.15s ease;
  }

  .mob-nav-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: -0.2px;
  }

  .mobile-nav-item.active {
    color: #fde047;
  }

  .mobile-nav-item.active .mob-nav-icon {
    filter: none;
    transform: scale(1.15);
    text-shadow: 0 0 12px rgba(253, 224, 71, 0.6);
  }

  .mobile-nav-item.active .mob-nav-label {
    color: #fde047;
    font-weight: 800;
  }

  /* Adjust Main Viewport and Views for Bottom Bar */
  .main-viewport {
    padding-bottom: 68px !important;
  }

  .view-panel {
    padding-bottom: 74px !important;
  }

  /* Compact Top Navbar on Mobile */
  .top-nav {
    height: 60px;
    padding: 0 10px;
    gap: 6px;
  }

  .nav-left {
    gap: 6px;
  }

  .avatar-pill {
    padding: 2px 8px 2px 4px;
    gap: 6px;
  }

  .avatar-icon-wrap {
    width: 34px;
    height: 34px;
  }

  .user-name {
    font-size: 13px;
  }

  .user-rank-tag {
    font-size: 10px;
  }

  .nav-stats {
    gap: 5px;
  }

  .stat-badge {
    padding: 3px 6px;
    font-size: 12px;
    gap: 4px;
    border-radius: 8px;
  }

  .stat-badge .stat-lbl {
    display: none;
  }

  .level-badge {
    display: none; /* Conserve space, level shown on map/avatar */
  }

  /* Hide quick buttons from top bar on mobile (now in bottom nav) */
  .action-pill-btn {
    display: none !important;
  }

  .audio-control-group {
    margin-left: auto;
  }

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

/* Tablet & iPad Responsive Tweaks */
@media (min-width: 769px) and (max-width: 1024px) {
  .nav-stats {
    gap: 8px;
  }
  .stat-badge {
    padding: 4px 8px;
    font-size: 13px;
  }
  .mini-xp-bar-wrap {
    display: none;
  }
  .world-tab-name {
    display: none;
  }
}
