/* ========================================================
   Fusion Food Family Lab - Premium Illustrated Cookbook Theme
   Supports: Light (Parchment & Terracotta) / Dark (Espresso & Saffron)
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@600;700&family=Fraunces:ital,opsz,wght@0,9..144,600;0,9..144,700;0,9..144,800;0,9..144,900;1,9..144,600&family=Kalam:wght@400;700&family=Outfit:wght@400;500;600;700;800;900&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Rozha+One&display=swap');

:root {
  /* ========================================================
     CRISP SKY / OCEANIC LIGHT-BLUE THEME (LIGHT MODE)
     ======================================================== */
  --bg-main: #F0F7FF;           /* Refreshing ice sky-blue canvas */
  --bg-parchment: #E0F0FE;      /* Soft light-blue section backdrops */
  --bg-card: #FFFFFF;           /* Crisp pristine white card surfaces */
  --bg-card-subtle: #F4F9FE;    /* Elevated subtle light-blue section */
  --border-color: #C5E0F8;      /* Clean soft powder-blue border */
  --border-dashed: #9EC7EE;     /* Dashed light-blue */
  --border-gold: #D97706;       /* Warm amber contrast */
  
  --shadow-warm: 0 4px 20px -2px rgba(2, 132, 199, 0.08), 0 2px 6px -1px rgba(2, 132, 199, 0.04);
  --shadow-hover: 0 14px 34px -4px rgba(2, 132, 199, 0.20), 0 4px 12px -2px rgba(2, 132, 199, 0.10);
  --shadow-glow: 0 0 26px rgba(2, 132, 199, 0.28);
  
  --primary: #0284C7;          /* Radiant Pacific Blue */
  --primary-hover: #0369A1;
  --primary-light: #E0F2FE;
  --primary-glow: rgba(2, 132, 199, 0.32);
  --primary-text: #0C4A6E;     /* Deep Aegean Blue - 9.46:1 WCAG AAA Pass against white/cards */
  --text-link: #075985;        /* 7.56:1 WCAG AAA Pass */
  
  --secondary: #F43F5E;        /* Electric Coral / Rose Accent */
  --secondary-hover: #E11D48;
  --secondary-light: #FFE4E6;
  --secondary-glow: rgba(244, 63, 94, 0.28);
  --secondary-text: #881337;   /* Deep Garnet Rose - 9.57:1 WCAG AAA Pass against white/cards */
  
  --accent-green: #059669;     /* Fresh Cardamom & Basil */
  --accent-green-light: #ECFDF5;
  --accent-green-text: #064E3B;/* 9.72:1 WCAG AAA Pass */
  --accent-blue: #0284C7;
  --accent-purple: #7C3AED;
  
  --text-main: #0B132B;        /* Deepest slate navy (18.38:1 WCAG AAA against white) */
  --text-muted: #1E293B;       /* Deep slate charcoal (14.63:1 WCAG AAA) */
  --text-light: #334155;       /* Substantial mid slate (10.35:1 WCAG AAA) */
  
  --tag-veg-bg: #ECFDF5;
  --tag-veg-text: #064E3B;     /* Deep Emerald - 9.72:1 WCAG AAA Pass against white/cards */
  --tag-veg-border: #6EE7B7;

  /* Gaming RGB Gradient (Reserved strictly for Master Chef XP Progress & Rewards) */
  --rgb-gradient: linear-gradient(
    90deg,
    #ff0055 0%,
    #ff6600 16%,
    #ffea00 33%,
    #00ff66 50%,
    #00e5ff 66%,
    #7928ca 83%,
    #ff00cc 92%,
    #ff0055 100%
  );
  --theme-gradient: linear-gradient(135deg, #0284C7 0%, #38BDF8 50%, #6366F1 100%);
  --theme-gradient-h: linear-gradient(90deg, #0284C7 0%, #38BDF8 50%, #6366F1 100%);
  --theme-glow: 0 4px 20px var(--primary-glow);

  --font-serif: 'Fraunces', 'Rozha One', 'Playfair Display', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-hand: 'Kalam', 'Caveat', cursive;
  
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --transition: transform 0.14s ease, opacity 0.14s ease, background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
  --bounce: transform 0.15s ease-out, box-shadow 0.15s ease-out, border-color 0.12s ease;
}

[data-theme="dark"] {
  /* ========================================================
     SLEEK OBSIDIAN BLACKISH THEME (DARK MODE)
     ======================================================== */
  --bg-main: #07080B;          /* Pitch Obsidian Black Canvas */
  --bg-parchment: #0E1017;     /* Deep Midnight Charcoal Layer */
  --bg-card: #12141D;          /* Sleek Pitch Black Card */
  --bg-card-subtle: #181B26;   /* Elevated Charcoal Card */
  --border-color: #242838;     /* Clean Obsidian Border */
  --border-dashed: #353B52;
  --border-gold: #F59E0B;
  
  --shadow-warm: 0 4px 28px -2px rgba(0, 0, 0, 0.75);
  --shadow-hover: 0 16px 44px -4px rgba(0, 0, 0, 0.90);
  --shadow-glow: 0 0 32px rgba(56, 189, 248, 0.35);
  
  --primary: #38BDF8;          /* Electric Sky / Cyan Neon */
  --primary-hover: #7DD3FC;
  --primary-light: #0C2333;
  --primary-glow: rgba(56, 189, 248, 0.42);
  --primary-text: #38BDF8;     /* 8.57:1 WCAG AAA Pass on Obsidian */
  --text-link: #38BDF8;        /* 8.57:1 WCAG AAA Pass */
  
  --secondary: #F43F5E;        /* Vivid Neon Coral / Magenta */
  --secondary-hover: #FB7185;
  --secondary-light: #33111B;
  --secondary-glow: rgba(244, 63, 94, 0.40);
  --secondary-text: #FB7185;   /* 7.5:1 WCAG AAA Pass on Obsidian */
  --secondary-mist: #FDA4AF;   /* 9.71:1 High Contrast Soft Rose */
  
  --accent-green: #34D399;     /* Luminous Mint Green */
  --accent-green-light: #062818;
  --accent-green-text: #34D399;/* 9.55:1 WCAG AAA Pass */
  --accent-blue: #38BDF8;
  --accent-purple: #C084FC;
  
  --text-main: #FFFFFF;        /* Pure Crisp White (18.36:1 WCAG AAA on Obsidian) */
  --text-muted: #E2E8F0;       /* Bright Crisp Silver Slate (14.90:1 WCAG AAA) */
  --text-light: #CBD5E1;       /* Crisp Pale Slate (12.37:1 WCAG AAA Pass) */
  
  --tag-veg-bg: #062615;
  --tag-veg-text: #4ADE80;     /* 10.54:1 WCAG AAA Pass */
  --tag-veg-border: #166534;

  --theme-gradient: linear-gradient(135deg, #0284C7 0%, #38BDF8 50%, #818CF8 100%);
  --theme-gradient-h: linear-gradient(90deg, #0284C7 0%, #38BDF8 50%, #818CF8 100%);
}

/* ========================================================
   RGB LIGHTING EFFECT KEYFRAMES
   ======================================================== */
@keyframes rgbFlow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  scrollbar-gutter: stable;
  overflow-x: hidden !important;
  max-width: 100vw !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  transition: none; /* Synchronous theme switch eliminates mid-interpolation white-on-white text flashes */
  min-height: 100vh;
  position: relative;
  overflow-x: hidden !important;
  max-width: 100vw !important;
  width: 100% !important;
  box-sizing: border-box !important;
  background-image: 
    radial-gradient(var(--border-color) 1.2px, transparent 1.2px),
    radial-gradient(circle at 10% 20%, rgba(2, 132, 199, 0.05) 0%, transparent 45%),
    radial-gradient(circle at 90% 80%, rgba(244, 63, 94, 0.04) 0%, transparent 45%);
  background-size: 32px 32px, 100% 100%, 100% 100%;
}

[data-theme="dark"] body {
  background-image: 
    radial-gradient(var(--border-color) 1.1px, transparent 1.1px),
    radial-gradient(circle at 15% 25%, rgba(56, 189, 248, 0.07) 0%, transparent 50%),
    radial-gradient(circle at 85% 75%, rgba(244, 63, 94, 0.06) 0%, transparent 50%);
}

/* Typography */
h1, h2, h3, h4, .font-serif {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

.handwritten {
  font-family: var(--font-hand);
  font-size: 1.55rem;
  color: var(--primary-text);
  transform: rotate(-2deg);
  display: inline-block;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  outline: none;
  background: transparent;
  transition: var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* General Button Styles with RGB Hover Aura */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.45rem;
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--bounce);
  position: relative;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #FFFFFF !important;
  box-shadow: 0 4px 14px var(--primary-glow);
  border: 1px solid transparent;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.5), 0 0 35px rgba(255, 0, 128, 0.35);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1.5px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary-text);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

/* Container */
.container {
  width: 100%;
  max-width: 1260px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ========================================================
   STICKY FLOATING HEADER & INSTANT TAB SWITCHER
   ======================================================== */
.site-header {
  position: sticky;
  top: 0.75rem;
  z-index: 999;
  margin: 0 auto;
  max-width: 1260px;
  padding: 0 1rem;
  min-height: 64px;
  contain: layout;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background-color: rgba(240, 247, 255, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0.55rem 1.25rem;
  box-shadow: 0 8px 26px -4px rgba(2, 132, 199, 0.12), 0 2px 6px -1px rgba(0,0,0,0.03);
  transition: var(--transition);
  position: relative;
  min-height: 52px;
  contain: layout;
}

[data-theme="dark"] .header-inner {
  background-color: rgba(14, 16, 23, 0.94);
  box-shadow: 0 8px 34px -4px rgba(0, 0, 0, 0.85), 0 0 24px rgba(56, 189, 248, 0.15);
  border-color: rgba(36, 40, 56, 0.95);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  cursor: pointer;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: var(--theme-gradient);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: transform 0.3s ease;
  position: relative;
}

.brand-icon::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  background: var(--theme-gradient);
  z-index: -1;
  opacity: 0.4;
  filter: blur(4px);
}

.brand-logo:hover .brand-icon {
  transform: rotate(-6deg) scale(1.08);
  filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.6));
}

.brand-text h1 {
  font-size: 1.28rem;
  margin-bottom: -2px;
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary-text);
}

/* Tab Navigation Buttons with RGB Active Glow */
.site-nav {
  display: flex;
  align-items: center;
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0.25rem;
  position: relative;
  gap: 0.25rem;
}

.mobile-bottom-nav {
  display: none;
}

.nav-link {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-muted);
  padding: 0.5rem 1.15rem;
  min-height: 44px;
  min-width: 44px;
  box-sizing: border-box;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  position: relative;
  z-index: 2;
  transition: color 0.25s ease, background-color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
  white-space: nowrap;
  cursor: pointer;
}

.nav-link:hover {
  color: var(--primary-text);
}

.nav-link.active {
  color: #FFFFFF !important;
  background: linear-gradient(135deg, #0284C7 0%, #0369A1 50%, #4F46E5 100%) !important;
  box-shadow: 0 4px 16px var(--primary-glow);
  transform: scale(1.03);
  position: relative;
  font-weight: 800;
}

[data-theme="dark"] .nav-link.active {
  color: #FFFFFF !important;
  background: linear-gradient(135deg, #0284C7 0%, #0369A1 45%, #6366F1 100%) !important;
  box-shadow: 0 4px 20px rgba(2, 132, 199, 0.45);
}

/* Header Action Controls */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-card);
  border: 1.5px solid var(--border-color);
  color: var(--text-muted);
  font-size: 1.05rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  transition: var(--bounce);
}

.icon-btn:hover {
  color: var(--primary-text);
  border-color: var(--primary);
  transform: translateY(-2px) scale(1.08);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.profile-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  transition: var(--bounce);
}

.profile-pill span {
  color: inherit;
}

[data-theme="dark"] .profile-pill {
  color: #FFFFFF !important;
  background: #12141D;
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .profile-pill span {
  color: #FFFFFF !important;
}

.profile-rank-badge {
  background: var(--primary-light);
  color: var(--primary-text);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}

[data-theme="dark"] .profile-rank-badge {
  background: rgba(56, 189, 248, 0.16) !important;
  color: #7DD3FC !important;
  border: 1px solid rgba(56, 189, 248, 0.35) !important;
}

.profile-pill:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px var(--primary-glow);
}

.profile-avatar {
  font-size: 1.25rem;
}

/* ========================================================
   TAB PANE ARCHITECTURE (ZERO ENDLESS VERTICAL SCROLLING)
   ======================================================== */
.main-tab-pane {
  display: none;
}

.main-tab-pane.active {
  display: block;
  animation: tabFadeIn 0.12s ease-out;
}

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

/* Games Welcome Banner */
.games-welcome-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.banner-quick-chips {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* ========================================================
   HORIZONTAL SCROLLABLE GAME SELECTOR CAROUSEL
   ======================================================== */
.games-scroll-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  width: 100%;
  min-height: 120px;
  contain: layout;
}

.games-scroll-track {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0.65rem 0.35rem 1.15rem;
  width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  -webkit-overflow-scrolling: touch;
}

.games-scroll-track::-webkit-scrollbar {
  height: 6px;
}
.games-scroll-track::-webkit-scrollbar-track {
  background: transparent;
}
.games-scroll-track::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px;
}

.game-card-tab {
  flex: 0 0 250px;
  min-width: 250px;
  scroll-snap-align: start;
  background: var(--bg-card);
  border: 2.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  text-align: left;
  position: relative;
  overflow: hidden;
  transition: var(--bounce);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-warm);
  cursor: pointer;
}

.game-card-tab:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: var(--shadow-hover);
}

.game-card-tab.active {
  border: 2.5px solid var(--primary) !important;
  background: var(--bg-card) !important;
  box-shadow: 0 12px 30px -4px rgba(2, 132, 199, 0.28), 0 0 18px var(--primary-glow) !important;
  transform: translateY(-5px);
  position: relative;
}

.game-card-tab.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4.5px;
  background: var(--theme-gradient-h);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 2;
}

.game-card-tab > * {
  position: relative;
  z-index: 1;
}

.game-tab-icon {
  font-size: 2.25rem;
  margin-bottom: 0.75rem;
  display: inline-block;
  transition: transform 0.3s ease;
}

.game-card-tab:hover .game-tab-icon {
  transform: scale(1.15) rotate(4deg);
}

.game-card-tab h3 {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
  color: var(--text-main);
  font-weight: 800;
}

.game-card-tab p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  line-height: 1.45;
}

.game-card-tab.active h3 {
  color: var(--text-main) !important;
}

.game-card-tab.active p {
  color: var(--text-muted) !important;
}

.game-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--primary-text);
  border-top: 1px dashed var(--border-dashed);
  padding-top: 0.65rem;
}

.game-card-tab.active .game-card-meta {
  color: var(--primary) !important;
}

[data-theme="dark"] .game-card-tab h3,
[data-theme="dark"] .game-card-tab.active h3 {
  color: #FFFFFF !important;
}

[data-theme="dark"] .game-card-tab p,
[data-theme="dark"] .game-card-tab.active p {
  color: #E2E8F0 !important;
}

[data-theme="dark"] .game-card-tab .game-card-meta,
[data-theme="dark"] .game-card-tab.active .game-card-meta {
  color: #38BDF8 !important;
}

.scroll-arrow-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  color: var(--text-main);
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-warm);
  cursor: pointer;
  z-index: 5;
  flex-shrink: 0;
  transition: var(--bounce);
}

.scroll-arrow-btn:hover {
  border-color: var(--primary);
  color: var(--primary-text);
  transform: scale(1.12);
  box-shadow: var(--shadow-hover);
}

.active-live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--primary-text);
  font-weight: 800;
}

.live-beacon {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
  animation: pulseBeacon 2s infinite;
  display: inline-block;
}

@keyframes pulseBeacon {
  0% { transform: scale(0.9); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.4; }
  100% { transform: scale(0.9); opacity: 1; }
}

/* ========================================================
   KITCHEN LAB RECIPES CAROUSEL
   ======================================================== */
.view-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.cuisine-filter-chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
}

.scroll-controls {
  display: flex;
  gap: 0.5rem;
}

.recipes-scroll-track {
  display: flex;
  gap: 1.5rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0.65rem 0.35rem 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  -webkit-overflow-scrolling: touch;
}

.recipes-scroll-track::-webkit-scrollbar {
  height: 6px;
}
.recipes-scroll-track::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px;
}

.recipes-scroll-track .cookbook-recipe-card {
  flex: 0 0 350px;
  min-width: 350px;
  scroll-snap-align: start;
}

/* Global Progress Strip */
.progress-strip-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.5rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-warm);
  position: relative;
  overflow: hidden;
  min-height: 72px;
  contain: layout;
}

.progress-strip-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: var(--rgb-gradient);
  background-size: 100% 300%;
  animation: rgbFlow 4s linear infinite;
}

.progress-strip-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.5rem;
}

.chef-avatar-box {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--secondary-light), var(--primary-light));
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  transition: transform 0.3s ease;
}

.chef-avatar-box:hover {
  transform: scale(1.1) rotate(5deg);
}

.progress-info h4 {
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.progress-info h4 .pill-badge {
  background: var(--bg-card);
  border: 1.5px solid transparent;
  background-image: linear-gradient(var(--bg-card), var(--bg-card)), var(--rgb-gradient);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  font-weight: 800;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.35);
}

.progress-bar-track {
  width: 100%;
  height: 12px;
  background-color: var(--bg-parchment);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 0.45rem;
  border: 1px solid var(--border-color);
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--rgb-gradient);
  background-size: 250% 100%;
  animation: rgbFlow 3s linear infinite;
  border-radius: var(--radius-full);
  transition: width 0.3s ease-out;
  position: relative;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

.progress-bar-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmerBar 2.2s infinite;
}

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

.streak-counter {
  text-align: right;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--secondary-text);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* Section Head */
.section-head {
  text-align: center;
  margin-bottom: 2rem;
}

.section-head h2 {
  font-size: 2.35rem;
  margin-bottom: 0.45rem;
  letter-spacing: -0.02em;
}

.section-head p {
  color: var(--text-muted);
  max-width: 650px;
  margin: 0 auto;
  font-size: 1.05rem;
}

/* Badges */
.veg-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background-color: var(--tag-veg-bg);
  color: var(--tag-veg-text);
  border: 1.5px solid var(--tag-veg-border);
  font-weight: 800;
  font-size: 0.78rem;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
}

.veg-icon-dot {
  width: 11px;
  height: 11px;
  border: 2px solid #2E7D32;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.veg-icon-dot::after {
  content: "";
  width: 5px;
  height: 5px;
  background-color: #2E7D32;
  border-radius: 50%;
}

.pill-badge {
  font-size: 0.82rem;
  font-weight: 800;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  background: var(--bg-parchment);
  color: var(--text-muted);
  border: 1.5px solid var(--border-color);
}

.game-disabled-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(246, 240, 230, 0.92);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-weight: 800;
  font-size: 0.9rem;
  z-index: 10;
  gap: 0.35rem;
}

[data-theme="dark"] .game-disabled-overlay {
  background: rgba(14, 16, 23, 0.94);
}

/* Main Interactive Play Arena with Top RGB Neon Ribbon */
.play-arena {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-hover);
  margin-bottom: 2.5rem;
  position: relative;
  min-height: 520px;
  overflow: hidden;
  contain: layout style;
}

.play-arena::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--theme-gradient-h);
  z-index: 10;
}

.arena-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px dashed var(--border-dashed);
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}

.arena-title-group {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.arena-icon {
  font-size: 2.4rem;
}

.arena-badges {
  display: flex;
  gap: 0.6rem;
}

/* ========================================================
   GAME 1: BUILD-A-DISH
   ======================================================== */
.build-dish-container {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.recipe-selector-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  overflow-x: auto;
  padding-bottom: 0.65rem;
}

.recipe-chip {
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-color);
  background: var(--bg-card-subtle);
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
  cursor: pointer;
  transition: var(--bounce);
}

.recipe-chip:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.recipe-chip.active {
  background: var(--primary) !important;
  color: #FFFFFF !important;
  border-color: var(--primary) !important;
  box-shadow: 0 4px 14px var(--primary-glow);
}

/* WCAG AAA Dark Mode Contrast for Cuisine and Leaderboard Filter Chips */
[data-theme="dark"] .recipe-chip,
[data-theme="dark"] #cuisine-filter-chips .recipe-chip,
[data-theme="dark"] .cuisine-filter-chips .recipe-chip,
[data-theme="dark"] #leaderboard-filter-tabs .recipe-chip,
[data-theme="dark"] button.recipe-chip {
  background: #181B26 !important;
  border-color: #334155 !important;
  color: #F8FAFC !important;
  font-weight: 700 !important;
}

[data-theme="dark"] .recipe-chip:hover,
[data-theme="dark"] #cuisine-filter-chips .recipe-chip:hover,
[data-theme="dark"] .cuisine-filter-chips .recipe-chip:hover,
[data-theme="dark"] #leaderboard-filter-tabs .recipe-chip:hover {
  background: #232838 !important;
  border-color: #38BDF8 !important;
  color: #FFFFFF !important;
}

[data-theme="dark"] .recipe-chip.active,
[data-theme="dark"] #cuisine-filter-chips .recipe-chip.active,
[data-theme="dark"] .cuisine-filter-chips .recipe-chip.active,
[data-theme="dark"] #leaderboard-filter-tabs .recipe-chip.active {
  background: #0284C7 !important;
  color: #FFFFFF !important;
  font-weight: 800 !important;
  border-color: #38BDF8 !important;
  box-shadow: 0 0 16px rgba(2, 132, 199, 0.45) !important;
}

/* WCAG AAA dark mode contrast enhancements (verified >= 7.5:1 across gradient) */
[data-theme="dark"] .btn-primary {
  background: linear-gradient(135deg, #075985, #831843) !important;
  color: #FFFFFF !important;
  font-weight: 800 !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
  box-shadow: 0 4px 14px rgba(7, 89, 133, 0.45) !important;
}

[data-theme="dark"] .chat-bubble.user {
  background: linear-gradient(135deg, #075985, #831843) !important;
  color: #FFFFFF !important;
  font-weight: 600 !important;
}

.admin-error-text, #pin-error-msg {
  color: #991B1B;
}

[data-theme="dark"] .admin-error-text,
[data-theme="dark"] #pin-error-msg {
  color: #FCA5A5 !important;
}

/* Landscape mode: prevent nav from blocking game canvas */
@media (orientation: landscape) and (max-height: 600px) {
  .site-header {
    position: relative !important;
    top: 0 !important;
  }
  .mobile-bottom-nav {
    display: none !important;
  }
  body {
    padding-bottom: 0 !important;
  }
}

.cooking-board-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.25rem;
}

@media (max-width: 900px) {
  .cooking-board-layout {
    grid-template-columns: 1fr;
  }
}

.pantry-shelf {
  background: var(--bg-parchment);
  border: 2px dashed var(--border-dashed);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.pantry-shelf h4 {
  font-size: 1.18rem;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pantry-shelf p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.pantry-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.85rem;
}

.ingredient-btn {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.95rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  box-shadow: 0 3px 8px rgba(0,0,0,0.04);
  transition: var(--bounce);
}

.ingredient-btn * {
  color: inherit;
}

[data-theme="dark"] .ingredient-btn {
  background: var(--bg-card-subtle, #181B26);
  border-color: rgba(255, 255, 255, 0.16);
  color: #FFFFFF !important;
}

[data-theme="dark"] .ingredient-btn * {
  color: #FFFFFF !important;
}

.ingredient-btn:hover:not(:disabled) {
  border-color: var(--secondary);
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 6px 14px var(--secondary-glow);
}

.ingredient-btn.selected {
  border-color: var(--accent-green);
  background: var(--accent-green-light);
  color: var(--accent-green);
  opacity: 0.65;
  transform: none;
}

.ingredient-btn.wrong-shake {
  animation: shake 0.22s ease-in-out;
  border-color: #DC2626 !important;
  background: #FEF2F2 !important;
}

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

.ingredient-btn .ing-emoji {
  font-size: 2rem;
}

.prep-board {
  background: var(--bg-card-subtle);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.steps-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 1.25rem 0;
}

.step-card {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  font-size: 0.88rem;
  transition: var(--transition);
}

.step-card.completed {
  border-color: var(--accent-green);
  background: var(--accent-green-light);
  box-shadow: 0 2px 10px rgba(32, 135, 89, 0.12);
}

.step-number {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--border-color);
  color: var(--text-main);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.step-card.completed .step-number {
  background: var(--accent-green);
  color: white;
}

/* ========================================================
   GAME 2: PRONUNCIATION CHALLENGE
   ======================================================== */
.pronounce-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  max-width: 820px;
  margin: 0 auto;
  text-align: center;
}

.dish-pronounce-card {
  background: var(--bg-parchment);
  border: 2.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.25rem 1.75rem;
  box-shadow: var(--shadow-warm);
}

.ipa-badge {
  font-family: monospace;
  font-size: 1.35rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  padding: 0.45rem 1.25rem;
  border-radius: var(--radius-full);
  display: inline-block;
  margin: 0.65rem 0;
  color: var(--primary-text);
  font-weight: 700;
}

.audio-listen-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.listen-btn {
  background: linear-gradient(135deg, var(--primary), #E66548);
  color: white;
  padding: 0.75rem 1.65rem;
  border-radius: var(--radius-full);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.listen-btn:hover {
  transform: translateY(-2px) scale(1.04);
}

.mic-check-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 2px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.mic-check-btn:hover {
  border-color: var(--secondary);
  color: var(--secondary-text);
  transform: translateY(-2px);
}

.syllable-builder-box {
  margin-top: 1.5rem;
  text-align: left;
}

.syllable-drop-target {
  min-height: 72px;
  background: var(--bg-card);
  border: 2.5px dashed var(--border-dashed);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.5rem;
}

.syllable-chip {
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--secondary-light);
  border: 2px solid var(--secondary);
  color: var(--secondary-text);
  font-weight: 800;
  font-size: 1.12rem;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.syllable-chip:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px var(--secondary-glow);
}

.syllable-pool {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

/* ========================================================
   GAME 3: FAMILY TAG-TEAM TRIVIA
   ======================================================== */
.trivia-container {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  max-width: 840px;
  margin: 0 auto;
}

.trivia-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.5rem;
}

.timer-soft-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  color: var(--secondary-text);
  font-size: 1.05rem;
}

.question-box {
  background: var(--bg-parchment);
  border: 2.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  position: relative;
  box-shadow: var(--shadow-warm);
}

.question-dish-tag {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--primary-text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.65rem;
}

.question-box h3 {
  font-size: 1.45rem;
  margin-bottom: 1.5rem;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.option-btn {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  cursor: pointer;
  transition: var(--bounce);
}

.option-btn * {
  color: inherit;
}

/* Crisp Pure White Text for Options in Dark Mode */
[data-theme="dark"] .option-btn,
[data-theme="dark"] .science-q-btn {
  background: var(--bg-card-subtle, #181B26);
  border-color: rgba(255, 255, 255, 0.16);
  color: #FFFFFF !important;
}

[data-theme="dark"] .option-btn *,
[data-theme="dark"] .science-q-btn * {
  color: #FFFFFF !important;
}

[data-theme="dark"] .option-btn span:first-child {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.22) !important;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-text);
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

[data-theme="dark"] .option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: #FFFFFF !important;
  background: rgba(56, 189, 248, 0.16);
  box-shadow: 0 0 16px var(--primary-glow);
}

.option-btn.correct,
[data-theme="dark"] .option-btn.correct,
[data-theme="dark"] .option-btn.correct * {
  border-color: var(--accent-green) !important;
  background: rgba(52, 211, 153, 0.22) !important;
  color: #34D399 !important;
}

.option-btn.wrong,
[data-theme="dark"] .option-btn.wrong,
[data-theme="dark"] .option-btn.wrong * {
  border-color: #F43F5E !important;
  background: rgba(244, 63, 94, 0.22) !important;
  color: #FB7185 !important;
}

.parent-hint-box {
  margin-top: 1.5rem;
  padding: 1.2rem;
  background: var(--secondary-light);
  border-left: 5px solid var(--secondary);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  box-shadow: 0 2px 8px var(--secondary-glow);
}

/* ========================================================
   GAME 4: HOT POTATO RUSH (PROMPT POTATO ARCADE)
   ======================================================== */
.hot-potato-arena-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

.hot-potato-canvas-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  border: 3px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 20px var(--primary-glow);
  background: #080A10;
  touch-action: none;
  aspect-ratio: 800 / 460;
  display: flex;
  align-items: center;
  justify-content: center;
}

#hot-potato-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: pointer;
}

.hot-potato-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 8, 11, 0.90);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10;
  overflow-y: auto;
  animation: tabFadeIn 0.2s ease-out;
}

.hp-overlay-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  text-align: center;
  max-width: 480px;
  width: 92%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  max-height: 92%;
  overflow-y: auto;
}

.hp-overlay-icon {
  font-size: 2.8rem;
  margin-bottom: 0.25rem;
  line-height: 1;
}

.hp-overlay-title {
  font-size: 1.45rem;
  margin-bottom: 0.35rem;
}

.hp-overlay-desc {
  color: var(--text-muted);
  font-size: 0.86rem;
  max-width: 420px;
  margin: 0 auto 1.15rem;
  line-height: 1.45;
}

@media (max-width: 650px) {
  .hot-potato-canvas-container {
    border-radius: var(--radius-md);
    aspect-ratio: 16 / 11;
  }
  .hp-overlay-card {
    padding: 1.1rem 1.15rem;
    max-height: 95%;
  }
  .hp-overlay-icon {
    font-size: 2.2rem;
  }
  .hp-overlay-title {
    font-size: 1.2rem;
  }
  .hp-overlay-desc {
    font-size: 0.78rem;
    margin-bottom: 0.85rem;
    line-height: 1.35;
  }
  #hp-start-btn, #hp-restart-btn {
    padding: 0.6rem 1.4rem !important;
    font-size: 0.92rem !important;
  }
}

@keyframes hpTumble {
  0% { transform: translateY(0) rotate(0deg) scale(1); }
  50% { transform: translateY(-12px) rotate(18deg) scale(1.1); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}

.hp-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  padding: 1rem 1.4rem;
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

.hp-action-btn {
  padding: 0.9rem 2rem;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 20px var(--primary-glow);
  flex: 1;
  min-width: 240px;
}

.hp-action-btn:active {
  transform: scale(0.96);
}

.hp-status-strip {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 200px;
  flex: 1;
}

.hp-meter-outer {
  width: 100%;
  height: 14px;
  background: var(--bg-parchment);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.hp-meter-fill {
  width: 0%;
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.12s linear, background 0.2s ease;
}

@media (max-width: 600px) {
  .hp-controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .hp-action-btn {
    width: 100%;
    padding: 1.1rem;
    font-size: 1.1rem;
  }
}

/* ========================================================
   GAME 5: SPIN THE WHEEL & CULINARY FOOD SCIENCE
   ======================================================== */
.wheel-science-layout {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 2.75rem;
  align-items: center;
}

@media (max-width: 900px) {
  .wheel-science-layout {
    grid-template-columns: 1fr;
  }
}

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

.wheel-outer {
  position: relative;
  width: 320px;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wheel-outer::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: var(--theme-gradient);
  z-index: 0;
  opacity: 0.9;
  box-shadow: 0 0 20px var(--primary-glow);
}

.wheel-pointer {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-top: 26px solid var(--primary);
  z-index: 10;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.35));
}

#science-wheel-canvas {
  width: 320px;
  height: 320px;
  border-radius: 50%;
  position: relative;
  z-index: 1;
  box-shadow: 0 10px 36px rgba(0,0,0,0.3), 0 0 0 6px var(--bg-card);
  transition: transform 1.35s cubic-bezier(0.12, 0.9, 0.2, 1);
}

.spin-trigger-btn {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 1rem 2.4rem;
  font-size: 1.15rem;
  font-weight: 800;
  border-radius: var(--radius-full);
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  transition: var(--bounce);
  position: relative;
}

.spin-trigger-btn:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 0 25px rgba(0, 229, 255, 0.6), 0 0 45px rgba(255, 0, 128, 0.4);
}

.science-explainer-card {
  background: var(--bg-parchment);
  border: 2.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-warm);
}

/* ========================================================
   KITCHEN LAB RECIPE CARDS
   ======================================================== */
.cookbook-recipe-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-warm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--bounce);
  position: relative;
}

.cookbook-recipe-card:hover {
  transform: translateY(-6px);
  border-color: var(--secondary);
  box-shadow: var(--shadow-hover);
}

.substitutes-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.88rem;
}

.substitutes-table th, .substitutes-table td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.substitutes-table th {
  color: var(--text-main);
  font-weight: 800;
  letter-spacing: 0.02em;
  background: var(--bg-card-subtle);
}

.substitutes-table td {
  color: var(--text-main);
}

.substitutes-table td strong {
  color: #047857;
  font-weight: 800;
}

[data-theme="dark"] .substitutes-table th {
  color: #FFFFFF !important;
  background: #181B26 !important;
}

[data-theme="dark"] .substitutes-table td {
  color: #F1F5F9 !important;
}

[data-theme="dark"] .substitutes-table td strong {
  color: #4ADE80 !important;
}

.substitutes-table .sub-col-reason {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

[data-theme="dark"] .substitutes-table .sub-col-reason {
  color: #E2E8F0 !important;
}

/* Recipe Semantic Badges */
.badge-kid-safe {
  font-size: 0.76rem;
  font-weight: 800;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
  background: var(--tag-veg-bg);
  color: #047857;
  border: 1px solid var(--tag-veg-border);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

[data-theme="dark"] .badge-kid-safe {
  background: rgba(34, 197, 94, 0.16) !important;
  color: #4ADE80 !important;
  border-color: rgba(74, 222, 128, 0.35) !important;
}

.badge-parent-assist {
  font-size: 0.76rem;
  font-weight: 800;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
  background: #FFF1F2;
  color: #BE123C;
  border: 1px solid #FECDD3;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

[data-theme="dark"] .badge-parent-assist {
  background: rgba(225, 29, 72, 0.16) !important;
  color: #FDA4AF !important;
  border-color: rgba(251, 113, 133, 0.35) !important;
}

/* Recipe Content Boxes with Contrast Guarantee */
.recipe-heritage-box {
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.5rem;
}

.recipe-heritage-title {
  font-size: 0.98rem;
  font-weight: 800;
  margin-bottom: 0.45rem;
  color: var(--primary-text);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

[data-theme="dark"] .recipe-heritage-title {
  color: #38BDF8 !important;
}

.recipe-heritage-text {
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.6;
}

.recipe-substitutes-title {
  font-size: 1.12rem;
  font-weight: 800;
  margin-bottom: 0.45rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.recipe-substitutes-intro {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  line-height: 1.45;
}

[data-theme="dark"] .recipe-substitutes-intro {
  color: #CBD5E1 !important;
}

.recipe-chemistry-card {
  background: var(--bg-card-subtle);
  border: 2px dashed var(--border-dashed);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  margin-top: 1.5rem;
}

.recipe-chemistry-title {
  font-size: 0.98rem;
  font-weight: 800;
  margin-bottom: 0.45rem;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

[data-theme="dark"] .recipe-chemistry-title {
  color: #FB7185 !important;
}

.recipe-chemistry-text {
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.6;
}

.ai-header-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

[data-theme="dark"] .ai-header-subtitle {
  color: #E2E8F0 !important;
}

/* ========================================================
   GLOBAL LEADERBOARD
   ======================================================== */
.scoreboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 960px;
  margin: 0 auto;
  gap: 2.25rem;
}

@media (max-width: 800px) {
  .scoreboard-grid {
    grid-template-columns: 1fr;
  }
}

.family-roster-card {
  background: var(--bg-card);
  border: 2.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-warm);
}

.rank-tier-item {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.65rem;
  border: 1.5px solid transparent;
  transition: var(--transition);
}

.rank-tier-item.current-tier {
  background: var(--primary-light);
  border-color: var(--primary);
  font-weight: 800;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.active-rank-tag {
  color: var(--primary-text) !important;
  font-weight: 900;
}

[data-theme="dark"] .active-rank-tag {
  color: #38BDF8 !important;
}

.rank-tier-item.locked {
  opacity: 0.5;
}

/* ========================================================
   ADMIN MODAL
   ======================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100001 !important;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease;
}

body.has-modal-open .mobile-bottom-nav {
  display: none !important;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: var(--bg-card);
  border: 2.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2.25rem;
  box-shadow: 0 24px 48px rgba(0,0,0,0.35);
  position: relative;
  transform: translateY(10px);
  transition: transform 0.15s ease-out;
}

#admin-modal .modal-dialog {
  max-width: 660px;
}

.admin-subtab-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
}

.api-token-reveal-card {
  background: #FEF3C7;
  border: 2px solid #F59E0B;
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

[data-theme="dark"] .api-token-reveal-card {
  background: #2D2310;
  border-color: #D97706;
}

[data-theme="dark"] .api-token-reveal-card #newly-generated-token-text {
  color: #FDE68A !important;
}

.api-keys-table-container {
  max-height: 240px;
  overflow-y: auto;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}

.api-keys-table {
  width: 100%;
  border-collapse: collapse;
}

.api-keys-table th {
  background: var(--bg-parchment);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

[data-theme="dark"] .api-keys-table th {
  background: #181C2E;
}

.api-keys-table td {
  border-bottom: 1px solid var(--border-color);
}

.admin-ai-config-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .admin-ai-config-card {
  background: #141724;
  border-color: #2D3348;
}

.modal-overlay.open .modal-dialog {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-close-btn {
  font-size: 1.6rem;
  color: var(--text-muted);
}

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

.pin-input-group {
  display: flex;
  gap: 0.65rem;
  margin: 1.5rem 0;
}

.pin-input {
  flex: 1;
  padding: 0.85rem 1.15rem;
  font-size: 1.15rem;
  letter-spacing: 0.2em;
  background: var(--bg-parchment);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  text-align: center;
}

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

.admin-toggles-list {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  margin: 1.75rem 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-parchment);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
}

/* Switch UI */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-dashed);
  transition: .3s;
  border-radius: 26px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: var(--accent-green);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
  contain: strict !important;
  height: 0 !important;
  width: 0 !important;
  overflow: visible !important;
}

.toast {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  padding: 0.85rem 1.4rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hover);
  font-size: 0.92rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  pointer-events: auto;
  transform: translateY(20px);
  opacity: 0;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  contain: layout style;
}

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

.toast-success {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

/* Footer */
.site-footer {
  border-top: 2px solid var(--border-color);
  background-color: var(--bg-parchment);
  padding: 3rem 0 2rem;
  margin-top: 4rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2.5rem;
  margin-bottom: 2rem;
}

/* ========================================================
   CROSS-PLATFORM & MOBILE RESPONSIVE ENGINE (iOS, Android, Tablets, Portrait)
   ======================================================== */
@media (max-width: 1024px) and (orientation: portrait), (max-width: 500px) {
  body {
    padding-bottom: 5.5rem; /* Dedicated clearance for the thumb-friendly bottom nav bar */
  }

  .site-header {
    position: relative !important;
    top: 0 !important;
    padding: 0 0.5rem;
  }

  /* Compact Single-Row Mobile & Landscape Header (Never wraps or covers content!) */
  .header-inner {
    padding: 0.35rem 0.55rem;
    gap: 0.35rem;
    flex-wrap: nowrap !important;
    justify-content: space-between;
    border-radius: var(--radius-full);
  }

  .brand-logo {
    gap: 0.4rem;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .brand-text h1 {
    font-size: 0.95rem;
    white-space: nowrap;
  }

  .brand-text span {
    display: none !important; /* Hide subtitle on mobile/landscape to preserve single-line elegance */
  }

  .header-actions {
    gap: 0.25rem;
    flex-shrink: 0;
  }

  .profile-pill {
    padding: 0.2rem 0.45rem;
    font-size: 0.72rem;
    gap: 0.25rem;
  }

  .profile-pill .profile-rank-badge {
    display: none !important;
  }

  .profile-pill span:not(.profile-avatar) {
    max-width: 58px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .icon-btn {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
  }

  /* Hide Desktop Header Tabs on Mobile/Compact Views */
  .site-header .site-nav {
    display: none !important;
  }

  /* Floating Bottom Navigation Bar for Mobile & Landscape (Thumb-Friendly, Zero Content Overlap) */
  .mobile-bottom-nav {
    position: fixed !important;
    bottom: 0.75rem !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: calc(100% - 1.2rem) !important;
    max-width: 440px !important;
    z-index: 99999 !important;
    background: rgba(240, 247, 255, 0.95) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 2px solid var(--border-color) !important;
    border-radius: var(--radius-full) !important;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.22), 0 0 16px var(--primary-glow) !important;
    padding: 0.35rem !important;
    display: flex !important;
    justify-content: space-around !important;
    gap: 0.3rem !important;
  }

  [data-theme="dark"] .mobile-bottom-nav {
    background: rgba(14, 16, 23, 0.96) !important;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.85), 0 0 20px rgba(56, 189, 248, 0.25) !important;
    border-color: rgba(36, 40, 56, 0.95) !important;
  }

  .nav-link {
    flex: 1;
    min-height: 44px;
    min-width: 44px;
    box-sizing: border-box;
    padding: 0.5rem 0.4rem;
    font-size: 0.78rem;
    justify-content: center;
    border-radius: var(--radius-full);
    text-align: center;
    gap: 0.3rem;
  }

  .nav-link span:first-child {
    font-size: 1.05rem;
  }

  /* Touch-Optimized Horizontal Scroll Carousels */
  .scroll-arrow-btn {
    display: none !important; /* Mobile users swipe with touch natively */
  }

  .games-scroll-container {
    gap: 0;
    margin-bottom: 1.25rem;
  }

  .games-scroll-track {
    padding: 0.4rem 0.15rem 0.85rem;
    gap: 0.85rem;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }

  .game-card-tab {
    flex: 0 0 215px;
    min-width: 215px;
    padding: 1.15rem;
  }

  .recipes-scroll-track {
    padding: 0.4rem 0.15rem 0.85rem;
    gap: 1rem;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }

  .recipes-scroll-track .cookbook-recipe-card {
    flex: 0 0 285px;
    min-width: 285px;
    padding: 1.25rem;
  }

  .cuisine-filter-chips {
    width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .view-mode-bar .scroll-controls {
    display: none;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }
}

@media (max-width: 650px) {
  .container {
    padding: 0 0.85rem;
  }

  /* Progress Strip */
  .progress-strip-card {
    padding: 0.95rem 1rem;
    margin-bottom: 1.25rem;
  }

  .progress-strip-inner {
    grid-template-columns: auto 1fr;
    gap: 0.85rem;
  }

  .streak-counter {
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-top: 0.35rem;
    border-top: 1px dashed var(--border-color);
  }

  .chef-avatar-box {
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
  }

  .progress-info h4 {
    font-size: 0.98rem;
  }

  /* Interactive Arena */
  .play-arena {
    padding: 1.25rem 0.85rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    min-height: auto;
  }

  .arena-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
  }

  .arena-title-group {
    gap: 0.65rem;
  }

  .arena-icon {
    font-size: 1.85rem;
  }

  .arena-title-group h2 {
    font-size: 1.35rem !important;
  }

  .cooking-board-layout {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .pantry-items-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }

  .pantry-shelf, .prep-board {
    padding: 1rem;
  }

  .recipe-step-card {
    padding: 0.95rem 0.9rem;
  }

  .step-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }

  .scoreboard-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .family-roster-card {
    padding: 1.25rem 1rem;
  }

  .wheel-outer {
    width: 270px;
    height: 270px;
  }

  #science-wheel-canvas {
    width: 270px;
    height: 270px;
  }

  .spin-trigger-btn {
    padding: 0.85rem 1.85rem;
    font-size: 1rem;
  }

  /* Hot Potato Mobile Responsive Optimizations */
  .hot-potato-arena-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .hot-potato-canvas-container {
    width: 100%;
    height: auto;
    max-width: 100%;
    overflow: hidden;
    border-radius: var(--radius-md);
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    touch-action: none;
  }

  #hot-potato-canvas {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 800 / 460;
    display: block;
  }

  .hp-controls-bar {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    width: 100%;
  }

  .hp-action-btn {
    width: 100% !important;
    padding: 1rem !important;
    font-size: 1.15rem !important;
    font-weight: 900 !important;
    border-radius: var(--radius-md) !important;
    letter-spacing: 0.02em;
    touch-action: manipulation;
  }

  .hp-status-strip {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  .hp-meter-outer {
    width: 100%;
    height: 14px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-full);
    overflow: hidden;
    border: 1px solid var(--border-color);
  }

  .hp-meter-fill {
    height: 100%;
    width: 0%;
    transition: width 0.1s linear, background 0.2s ease;
  }
}

/* Hot Potato Game Desktop Defaults */
.hot-potato-arena-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hot-potato-canvas-container {
  width: 100%;
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  background: #080A10;
}

#hot-potato-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 800 / 460;
  display: block;
}

.hot-potato-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 16, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 1.5rem;
}

@media (orientation: landscape) and (max-height: 600px) {
  .mobile-bottom-nav {
    display: none !important;
  }
}

.hp-overlay-card {
  text-align: center;
  max-width: 480px;
  max-height: 90%;
  overflow-y: auto;
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-color);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.hp-overlay-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.hp-overlay-title {
  font-size: 1.55rem;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.hp-overlay-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.hp-controls-bar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.hp-action-btn {
  font-size: 1rem;
  font-weight: 800;
  padding: 0.75rem 1.75rem;
}

.hp-status-strip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.hp-meter-outer {
  flex: 1;
  height: 16px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1.5px solid var(--border-color);
}

.hp-meter-fill {
  height: 100%;
  width: 0%;
  background: #38BDF8;
  transition: width 0.1s linear, background 0.2s ease;
}

/* Hot Potato Dual Mode and Itch Embed */
.hp-mode-switch-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--secondary)) !important;
  color: #FFFFFF !important;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.hp-itch-frame-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  background: #222;
}

/* Profile Onboarding Modal Inputs & Cards */
.profile-role-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.profile-role-card {
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  cursor: pointer;
  text-align: center;
  transition: var(--bounce);
}

.profile-role-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.profile-role-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 4px 16px var(--primary-glow);
}

[data-theme="dark"] .profile-role-card.selected {
  background: rgba(0, 229, 255, 0.15);
}

.profile-form-group {
  margin-bottom: 1.25rem;
}

.profile-form-group label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.45rem;
  color: var(--text-main);
}

.profile-form-input, .profile-form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  background: var(--bg-parchment);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease;
}

.profile-form-input:focus, .profile-form-select:focus {
  border-color: var(--primary);
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ========================================================
   RECIPE POP-OUT MODAL & GEMINI AI SOUS-CHEF CHATBOT
   ======================================================== */
.recipe-popout-dialog {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 95%;
  max-width: 1200px;
  height: 90vh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.7), 0 0 24px var(--primary-glow);
  position: relative;
  overflow: hidden;
  transform: scale(0.97) translateY(8px);
  transition: transform 0.16s ease-out, opacity 0.14s ease;
}

.modal-overlay.open .recipe-popout-dialog {
  transform: scale(1) translateY(0);
}

.recipe-popout-dialog::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--theme-gradient-h);
  z-index: 20;
}

.recipe-popout-header {
  padding: 1.25rem 2rem;
  border-bottom: 1.5px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-card-subtle);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.recipe-popout-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.recipe-popout-meta-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.recipe-popout-title-wrap h2 {
  font-size: 1.65rem;
  margin: 0;
  line-height: 1.25;
  word-break: break-word;
}

.recipe-popout-phonetic-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.modal-close-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--bounce);
}

.modal-close-btn:hover {
  color: var(--primary-text);
  border-color: var(--primary);
  transform: scale(1.08);
}

.table-responsive-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.85rem 0 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.table-responsive-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.table-responsive-wrapper .substitutes-table {
  margin: 0;
  min-width: 480px;
}

.recipe-popout-dialog {
  box-sizing: border-box;
  max-width: 100vw;
  overflow-x: hidden;
}

.recipe-popout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.95fr);
  flex: 1;
  overflow: hidden;
  height: calc(100% - 75px);
  min-height: 0;
  min-width: 0;
  box-sizing: border-box;
}

.recipe-steps-column {
  padding: 1.75rem 2rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-right: 1.5px solid var(--border-color);
  height: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.recipe-step-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.15rem;
  transition: var(--bounce);
  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}

.recipe-step-card.completed {
  border-color: var(--accent-green);
  background: var(--tag-veg-bg);
  opacity: 0.92;
}

.step-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
  gap: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
}

.step-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  min-width: 0;
}

.step-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Mobile & Tablet Recipe Modal Responsive Architecture (Zero Overflow & Zero Text Clipping) */
@media (max-width: 920px) {
  .modal-overlay {
    padding: 0 !important;
  }
  .recipe-popout-dialog {
    width: 100% !important;
    max-width: 100vw !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  .recipe-popout-header {
    padding: 0.85rem 1rem !important;
    gap: 0.75rem !important;
    box-sizing: border-box !important;
  }
  .recipe-popout-title-wrap h2 {
    font-size: 1.25rem !important;
  }
  .recipe-popout-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    height: calc(100vh - 85px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 2rem !important;
    min-width: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  .recipe-steps-column {
    padding: 1rem 0.85rem !important;
    border-right: none !important;
    border-bottom: 2px solid var(--border-color) !important;
    overflow-y: visible !important;
    height: auto !important;
    min-width: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  .recipe-ai-column {
    min-height: 520px !important;
    height: auto !important;
    overflow: visible !important;
    min-width: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  .recipe-ai-column .api-key-box,
  #api-key-config-box {
    display: none;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0.75rem 0.85rem !important;
    overflow-x: hidden !important;
  }
  .api-key-box > div:first-child {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 0.4rem !important;
    width: 100% !important;
  }
  .api-key-input-row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.4rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .api-key-input {
    min-width: 0 !important;
    flex: 1 1 180px !important;
    box-sizing: border-box !important;
  }
  .recipe-step-card {
    padding: 0.95rem 0.85rem !important;
    margin-bottom: 1rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  .step-header-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.45rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .step-header-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.45rem !important;
    width: 100% !important;
    flex-wrap: wrap !important;
    box-sizing: border-box !important;
  }
  .step-checkbox-btn {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    margin-left: auto !important;
  }
  .chat-chip-suggestions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.4rem !important;
    padding: 0.5rem 0.75rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .chat-chip {
    white-space: normal !important;
    text-align: left !important;
    flex-shrink: 1 !important;
  }
}

.step-num-pill {
  font-weight: 800;
  font-size: 0.82rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary-text);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.recipe-step-card.completed .step-num-pill {
  background: #dcfce7;
  color: #15803d;
}

.step-checkbox-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-color);
  background: var(--bg-card);
  transition: var(--transition);
}

.step-checkbox-btn:hover {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.step-checkbox-btn.checked {
  background: var(--accent-green);
  color: white;
  border-color: var(--accent-green);
}

/* AI Sous-Chef Chatbot Column */
.recipe-ai-column {
  display: flex;
  flex-direction: column;
  background: var(--bg-card-subtle);
  overflow: hidden;
  height: 100%;
}

.ai-header-bar {
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1.5px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}

.api-key-pill {
  font-size: 0.76rem;
  font-weight: 800;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  color: var(--text-muted);
}

.api-key-pill.active {
  background: rgba(34, 197, 94, 0.15);
  color: #15803D;
  border-color: #86efac;
}

[data-theme="dark"] .api-key-pill.active {
  color: #4ADE80 !important;
  border-color: rgba(74, 222, 128, 0.4) !important;
  background: rgba(34, 197, 94, 0.2) !important;
}

.api-key-box {
  background: var(--bg-card);
  border-bottom: 1.5px solid var(--border-color);
  padding: 0.85rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.82rem;
  transition: all 0.3s ease;
}

.api-key-input-row {
  display: flex;
  gap: 0.5rem;
}

.api-key-input {
  flex: 1;
  background: var(--bg-parchment);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  font-family: monospace;
  font-size: 0.84rem;
  color: var(--text-main);
  outline: none;
}

.api-key-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-bubble {
  max-width: 88%;
  padding: 0.85rem 1.15rem;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.chat-bubble.ai {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.05);
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.chat-chip-suggestions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-chip {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--bounce);
  white-space: nowrap;
}

.chat-chip:hover {
  border-color: var(--primary);
  color: var(--primary-text);
  transform: translateY(-2px);
}

.chat-input-bar {
  display: flex;
  gap: 0.6rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-card);
  border-top: 1.5px solid var(--border-color);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0.65rem 1.2rem;
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
  font-family: var(--font-sans);
}

.chat-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}

.chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: var(--bounce);
  border: none;
  flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
  transform: scale(1.12) rotate(6deg);
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.6);
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-5px); opacity: 1; }
}

/* ========================================================
   GLOBAL HIGH-CONTRAST & TYPOGRAPHY ENHANCEMENTS
   ======================================================== */
[data-theme="dark"] .pill-badge {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
  color: #FFFFFF !important;
}

[data-theme="dark"] .chat-chip {
  color: #FFFFFF !important;
  background: #181D2A;
  border-color: rgba(255, 255, 255, 0.22);
}

[data-theme="dark"] .chat-chip:hover {
  background: var(--primary);
  color: #07080B !important;
}

[data-theme="dark"] .tutorial-step-card {
  background: #151926;
  border-color: rgba(255, 255, 255, 0.16);
}

[data-theme="dark"] .tutorial-step-card p {
  color: #CBD5E1 !important;
}

[data-theme="dark"] .step-card,
[data-theme="dark"] .recipe-step-card {
  background: #141724;
  border-color: #2D3348;
}

[data-theme="dark"] .step-card p,
[data-theme="dark"] .recipe-step-card p {
  color: #E2E8F0 !important;
}

[data-theme="dark"] .pro-tip-note,
[data-theme="dark"] .recipe-pro-tip {
  color: #FDE047 !important;
  font-family: var(--font-hand);
  font-size: 1.15rem;
}

/* ========================================================
   MILESTONE M1: SCROLLTIDE LANDING SHOWCASE & 2.5D DEPTH
   ======================================================== */
.scrolltide-hero-showcase {
  position: relative;
  padding: 3.5rem 0 2rem;
  margin-bottom: 1.5rem;
  perspective: 1200px;
  overflow: visible;
  contain: layout style;
  min-height: 480px;
}

/* Ambient Glowing Aura Background */
.scrolltide-aura-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 1000px;
  height: 480px;
  background: radial-gradient(circle at 30% 40%, rgba(2, 132, 199, 0.22) 0%, transparent 60%),
              radial-gradient(circle at 70% 60%, rgba(244, 63, 94, 0.18) 0%, transparent 60%),
              radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.14) 0%, transparent 70%);
  filter: blur(50px);
  pointer-events: none;
  z-index: 0;
  contain: strict !important;
  animation: scrolltideAuraPulse 7s ease-in-out infinite alternate;
}

[data-theme="dark"] .scrolltide-aura-glow {
  background: radial-gradient(circle at 30% 40%, rgba(56, 189, 248, 0.28) 0%, transparent 60%),
              radial-gradient(circle at 70% 60%, rgba(244, 63, 94, 0.25) 0%, transparent 60%),
              radial-gradient(circle at 50% 50%, rgba(192, 132, 252, 0.20) 0%, transparent 70%);
  filter: blur(65px);
}

@keyframes scrolltideAuraPulse {
  0% { transform: translate(-50%, -50%) scale(0.92) rotate(0deg); opacity: 0.7; }
  50% { transform: translate(-50%, -48%) scale(1.08) rotate(3deg); opacity: 1; }
  100% { transform: translate(-50%, -52%) scale(0.96) rotate(-2deg); opacity: 0.8; }
}

.scrolltide-hero-inner {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 980px;
  margin: 0 auto;
  contain: layout style;
}

.scrolltide-badge-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  min-height: 188px;
  contain: layout style;
}

.scrolltide-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.84rem;
  font-weight: 800;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  color: var(--primary-text);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.10);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  will-change: transform;
  transform: translateZ(0);
  contain: layout style;
}

[data-theme="dark"] .scrolltide-badge {
  background: var(--bg-card-subtle);
  border-color: rgba(56, 189, 248, 0.28);
  color: #38BDF8 !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
}

.scrolltide-badge:hover {
  transform: translateY(-3px) scale(1.05);
  border-color: var(--primary);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.scrolltide-badge.badge-float-1 {
  animation: badgeFloat1 4.5s ease-in-out infinite alternate;
}
.scrolltide-badge.badge-float-2 {
  animation: badgeFloat2 5.2s ease-in-out infinite alternate 0.4s;
}
.scrolltide-badge.badge-float-3 {
  animation: badgeFloat1 4.8s ease-in-out infinite alternate 0.8s;
}
.scrolltide-badge.badge-float-4 {
  animation: badgeFloat2 5.5s ease-in-out infinite alternate 1.2s;
}

@keyframes badgeFloat1 {
  0% { transform: translateY(0px) rotate(0deg); }
  100% { transform: translateY(-7px) rotate(-1.5deg); }
}

@keyframes badgeFloat2 {
  0% { transform: translateY(0px) rotate(0deg); }
  100% { transform: translateY(-8px) rotate(1.8deg); }
}

.scrolltide-hero-title {
  font-size: clamp(2.2rem, 5.2vw, 3.8rem);
  font-family: var(--font-serif);
  font-weight: 900;
  line-height: 1.15;
  margin-bottom: 1rem;
  color: var(--text-main);
  letter-spacing: -0.02em;
  min-height: 2.3em;
  contain: layout style;
}

.scrolltide-gradient-text {
  background: linear-gradient(135deg, var(--primary) 0%, #38BDF8 40%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

.scrolltide-hero-desc {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: var(--text-muted);
  max-width: 760px;
  margin: 0 auto 2rem;
  line-height: 1.65;
  min-height: 4.8em;
  contain: layout style;
}

/* 2.5D Stats Counters Grid */
.scrolltide-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin: 2rem 0 2.5rem;
  min-height: 180px;
  contain: layout;
}

@media (max-width: 860px) {
  .scrolltide-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

@media (max-width: 440px) {
  .scrolltide-stats-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

.scrolltide-stat-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-warm);
  transform-style: preserve-3d;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.3s ease;
  contain: layout style;
  min-height: 160px;
}

[data-theme="dark"] .scrolltide-stat-card {
  background: var(--bg-card-subtle);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.65);
}

.scrolltide-stat-card:hover {
  transform: translateY(-6px) translateZ(20px) rotateX(2deg);
  border-color: var(--primary);
  box-shadow: var(--shadow-hover), 0 0 20px var(--primary-glow);
}

.scrolltide-stat-icon {
  font-size: 1.8rem;
  margin-bottom: 0.45rem;
  display: inline-block;
  transform: translateZ(10px);
}

.scrolltide-stat-num {
  font-size: clamp(2rem, 3.8vw, 2.75rem);
  font-family: var(--font-serif);
  font-weight: 900;
  color: var(--primary-text);
  line-height: 1.1;
  margin-bottom: 0.25rem;
  display: block;
  transform: translateZ(15px);
  font-variant-numeric: tabular-nums;
  min-width: 2.2ch;
}

[data-theme="dark"] .scrolltide-stat-num {
  color: #38BDF8 !important;
}

.scrolltide-stat-label {
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-main);
  display: block;
}

.scrolltide-stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  display: block;
}

/* 2.5D Feature Preview Cards (Spotlights for Arcade Labs) */
.scrolltide-preview-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin: 1.5rem 0 2rem;
}

@media (max-width: 860px) {
  .scrolltide-preview-cards {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.scrolltide-preview-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: left;
  position: relative;
  cursor: pointer;
  box-shadow: var(--shadow-warm);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.3s ease;
  transform-style: preserve-3d;
}

[data-theme="dark"] .scrolltide-preview-card {
  background: var(--bg-card-subtle);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.65);
}

.scrolltide-preview-card:hover {
  transform: translateY(-6px) translateZ(15px);
  border-color: var(--primary);
  box-shadow: var(--shadow-hover), 0 0 24px var(--primary-glow);
}

.scrolltide-preview-tag {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--primary-text);
  margin-bottom: 0.4rem;
  display: inline-block;
}

[data-theme="dark"] .scrolltide-preview-tag {
  color: #38BDF8 !important;
}

.scrolltide-preview-title {
  font-size: 1.18rem;
  font-family: var(--font-serif);
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.45rem;
}

.scrolltide-preview-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 0.85rem;
}

.scrolltide-preview-action {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--text-link);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: gap 0.2s ease;
}

.scrolltide-preview-card:hover .scrolltide-preview-action {
  gap: 0.65rem;
}

/* ========================================================
   SCROLL-DRIVEN ANIMATIONS (CSS Timeline + Fallback)
   ======================================================== */
@supports (animation-timeline: view()) {
  .scroll-reveal {
    animation: scrollReveal linear both;
    animation-timeline: view();
    animation-range: entry 10% cover 35%;
  }
  .scroll-fade-up {
    animation: scrollFadeUp linear both;
    animation-timeline: view();
    animation-range: entry 5% cover 30%;
  }
}

@keyframes scrollReveal {
  from {
    opacity: 0.2;
    transform: translateY(22px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes scrollFadeUp {
  from {
    opacity: 0.2;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fallback for browsers without animation-timeline */
@supports not (animation-timeline: view()) {
  .scroll-reveal,
  .scroll-fade-up {
    transition: opacity 0.5s ease, transform 0.5s ease;
  }
}

/* ========================================================
   THREE.JS CONTAINERS: LAYOUT CONTAINMENT & ZERO CLS
   ======================================================== */
#hp-canvas-container,
.hot-potato-canvas-container {
  width: 100%;
  max-width: 800px;
  aspect-ratio: 800 / 460;
  min-height: 280px;
  position: relative;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  contain: layout style paint;
}

#tandoor-3d-stage,
.tandoor-3d-stage-container {
  width: 100%;
  max-width: 1000px;
  aspect-ratio: 16 / 7;
  min-height: 200px;
  max-height: 340px;
  margin: 1.25rem auto 1.5rem;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-color);
  background: radial-gradient(circle at 50% 60%, rgba(245, 158, 11, 0.18) 0%, rgba(220, 38, 38, 0.12) 40%, rgba(14, 16, 23, 0.85) 100%);
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35), 0 0 24px rgba(245, 158, 11, 0.2);
  contain: layout style paint;
  display: block;
}

[data-theme="dark"] #tandoor-3d-stage,
[data-theme="dark"] .tandoor-3d-stage-container {
  background: radial-gradient(circle at 50% 60%, rgba(245, 158, 11, 0.25) 0%, rgba(220, 38, 38, 0.22) 45%, #07080B 100%);
  border-color: rgba(245, 158, 11, 0.35);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.75), 0 0 30px rgba(245, 158, 11, 0.28);
}

#molecule-3d-canvas,
.molecule-3d-canvas {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1 / 1;
  min-height: 220px;
  margin: 0.75rem auto;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-color);
  background: var(--bg-card-subtle);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-warm);
  contain: layout style paint;
  display: block;
}

/* ========================================================
   MOBILE LANDSCAPE (844x390, 667x375) NAVIGATION DOCKING & OVERFLOW FIX
   ======================================================== */
@media (orientation: landscape) and (max-height: 600px) {
  body {
    padding-bottom: 0 !important;
  }

  .mobile-bottom-nav {
    display: none !important;
  }

  /* Make header relative in mobile landscape so it never hovers over or covers game canvas */
  .site-header {
    position: relative !important;
    top: 0 !important;
    padding: 0 0.5rem !important;
    margin: 0 auto 0.4rem !important;
    min-height: 42px !important;
  }

  .header-inner {
    padding: 0.2rem 0.65rem !important;
    gap: 0.4rem !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
    height: 42px !important;
    min-height: 42px !important;
    justify-content: space-between !important;
  }

  .brand-logo {
    gap: 0.35rem !important;
    flex-shrink: 0 !important;
  }

  .brand-icon {
    width: 32px !important;
    height: 32px !important;
    font-size: 1.05rem !important;
    border-radius: 8px !important;
  }

  /* Universally hide brand text in mobile landscape (<960px) to prevent multi-line collision */
  .brand-text {
    display: none !important;
  }

  .site-header .site-nav {
    display: flex !important;
    gap: 0.3rem !important;
    padding: 0.15rem !important;
    flex-shrink: 0 !important;
  }

  .site-header .site-nav .nav-link {
    padding: 0.25rem 0.65rem !important;
    min-height: 32px !important;
    font-size: 0.8rem !important;
    border-radius: var(--radius-full) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
  }

  .header-actions {
    gap: 0.25rem !important;
    flex-shrink: 0 !important;
  }

  .header-actions .profile-pill span:not(.profile-avatar) {
    display: none !important;
  }

  .header-actions .icon-btn {
    width: 30px !important;
    height: 30px !important;
    font-size: 0.85rem !important;
  }

  /* Universal Landscape Constraint (All viewport widths including > 750px e.g. 844x390, 915x412) */
  #hp-canvas-container, .hot-potato-canvas-container {
    min-height: 180px !important;
    max-height: 52vh !important;
  }
  .cooking-board-layout {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Ultra-Narrow Landscape Phones (e.g. 640x360) Nav Icon-Only Mode */
  @media (max-width: 720px) {
    .site-header .site-nav .nav-link span:last-child {
      display: none !important;
    }
    .site-header .site-nav {
      gap: 0.2rem !important;
    }
    .site-header .site-nav .nav-link {
      padding: 0.25rem 0.5rem !important;
      min-width: 30px !important;
    }
  }

  .scrolltide-hero-showcase {
    padding: 1.25rem 0 1rem !important;
    min-height: auto !important;
  }

  .scrolltide-stats-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    margin: 1rem 0 !important;
    gap: 0.65rem !important;
  }

  .scrolltide-stat-card {
    padding: 0.75rem 0.5rem !important;
  }

  .scrolltide-stat-num {
    font-size: 1.6rem !important;
  }
}

/* ========================================================
   LEADERBOARD SCOPE TOGGLE (Family Roster vs Global Hall of Fame)
   ======================================================== */
.leaderboard-scope-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-full);
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-warm);
}

.leaderboard-scope-toggle .scope-btn {
  padding: 0.5rem 1.15rem;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-muted);
  border: 1.5px solid transparent;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.leaderboard-scope-toggle .scope-btn:hover {
  color: var(--text-main);
  background: rgba(2, 132, 199, 0.08);
}

.leaderboard-scope-toggle .scope-btn.active {
  background: var(--primary);
  color: #FFFFFF !important;
  border-color: var(--primary);
  box-shadow: 0 2px 10px var(--primary-glow);
}

[data-theme="dark"] .leaderboard-scope-toggle {
  background: var(--bg-card);
  border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .leaderboard-scope-toggle .scope-btn {
  color: var(--text-muted);
}

[data-theme="dark"] .leaderboard-scope-toggle .scope-btn:hover {
  color: #FFFFFF;
  background: rgba(56, 189, 248, 0.12);
}

[data-theme="dark"] .leaderboard-scope-toggle .scope-btn.active {
  background: var(--primary);
  color: #07080B !important;
  font-weight: 900;
  border-color: var(--primary);
  box-shadow: 0 0 16px var(--primary-glow);
}

/* 3D Tandoor Controls Bar */
.tandoor-heat-controls {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  background: rgba(18, 20, 29, 0.85);
  backdrop-filter: blur(8px);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 10;
}

.tandoor-heat-btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 800;
  border-radius: var(--radius-full);
  color: #CBD5E1;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tandoor-heat-btn.active {
  background: #991B1B;
  color: #FFFFFF;
  box-shadow: 0 0 10px rgba(153, 27, 27, 0.7);
}

/* 3D Model HUD Elements */
.model-3d-hud {
  position: absolute;
  top: 0.65rem;
  left: 0.75rem;
  right: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.model-3d-badge {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.55);
  color: #FFFFFF;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.model-3d-hint {
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  color: var(--text-muted);
  pointer-events: none;
  background: rgba(0, 0, 0, 0.4);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* Docking and Touch Ergonomics */
.site-nav .nav-link {
  min-height: 38px !important;
  min-width: 38px !important;
}

.mobile-bottom-nav .nav-link {
  min-height: 44px !important;
  min-width: 44px !important;
}

.mobile-nav-docked {
  display: none !important;
}

.site-nav-hidden {
  display: none !important;
}

/* Ultra-Narrow Responsive Ergonomics (Zero Overflow at 320px) */
@media (max-width: 480px) {
  .cookbook-recipe-card,
  .recipes-scroll-track .cookbook-recipe-card {
    flex: 0 0 calc(100vw - 32px) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 32px) !important;
  }
}

@media (max-width: 380px) {
  .site-header {
    padding: 0 0.25rem !important;
    min-height: 64px !important;
  }
  .header-inner {
    padding: 0.25rem 0.35rem !important;
    gap: 0.2rem !important;
    min-height: 52px !important;
  }
  .brand-logo {
    gap: 0.25rem !important;
  }
  .brand-text h1 {
    font-size: 0.8rem !important;
  }
  .brand-icon {
    width: 26px !important;
    height: 26px !important;
    font-size: 0.95rem !important;
  }
  .profile-pill {
    padding: 0.15rem 0.3rem !important;
    font-size: 0.68rem !important;
  }
  .profile-pill span:not(.profile-avatar) {
    max-width: 36px !important;
  }
  .icon-btn {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.78rem !important;
  }
  .scrolltide-hero-showcase {
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
  .scrolltide-stats-grid {
    grid-template-columns: 1fr !important;
  }
}

