/* ---------------------------------------------------------------------
   KIDS' PLAYLAND: PLAYFUL KID-FRIENDLY CSS DESIGN SYSTEM
   --------------------------------------------------------------------- */

/* Google Fonts - Fredoka is perfect for playful, rounded, child-friendly designs */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@300..700&family=Share+Tech+Mono&display=swap');

:root {
  --bg-pastel-yellow: #fffdf0;
  --primary-pink: #ff6b8b;
  --primary-blue: #4da3ff;
  --primary-green: #4ade80;
  --primary-yellow: #facc15;
  --primary-orange: #fb923c;
  --primary-purple: #c084fc;
  
  --text-dark: #2c3e50;
  --text-light: #f8fafc;
  
  --shadow-bubbly: 0 8px 0px #2c3e50, 0 15px 25px rgba(0, 0, 0, 0.04);
  --border-radius-bubbly: 28px;
  
  --focus-outline-color: var(--primary-pink);
}

/* Starry Night Mode Variables */
body.starry-mode {
  --bg-pastel-yellow: #0d122b;
  --text-dark: #f1f5f9;
  --shadow-bubbly: 0 8px 0px #050611, 0 15px 25px rgba(0, 0, 0, 0.25);
  --focus-outline-color: var(--primary-purple);
}

body.starry-mode .game-card {
  background: #18223f;
  border-color: #2c3a63;
  color: #f1f5f9;
}

body.starry-mode #app-header {
  background: rgba(24, 34, 63, 0.85);
  border-color: #2c3a63;
  box-shadow: 0 8px 0px #050611;
}

body.starry-mode .bubble-btn {
  background: #1e293b;
  border-color: #475569;
  box-shadow: 0 6px 0px #475569;
}

body.starry-mode .bubble-btn svg {
  fill: #e2e8f0;
}

body.starry-mode .bubble-btn.pink { border-color: var(--primary-pink); box-shadow: 0 6px 0px var(--primary-pink); }
body.starry-mode .bubble-btn.pink svg { fill: var(--primary-pink); }
body.starry-mode .bubble-btn.blue { border-color: var(--primary-blue); box-shadow: 0 6px 0px var(--primary-blue); }
body.starry-mode .bubble-btn.blue svg { fill: var(--primary-blue); }
body.starry-mode .bubble-btn.yellow { border-color: var(--primary-yellow); box-shadow: 0 6px 0px var(--primary-yellow); }
body.starry-mode .bubble-btn.yellow svg { fill: var(--primary-yellow); }

body.starry-mode .tab-btn {
  background: #1e293b;
  border-color: #475569;
  box-shadow: 0 6px 0px #475569;
  color: #f1f5f9;
}

body.starry-mode .tab-btn.active {
  background: var(--primary-purple);
  border-color: var(--primary-purple);
  box-shadow: 0 6px 0px #8b5cf6;
  color: white;
}
}



/* =====================================================================
   STARRY BEDTIME MODE OVERRIDES FOR GAMES & COMPONENTS
   ===================================================================== */
body.starry-mode .game-card {
  --accent-bg: rgba(255, 255, 255, 0.08); /* Dark background for icons */
}
body.starry-mode .game-card[data-category="baby"]:hover,
body.starry-mode .game-card[data-category="baby"]:focus-visible {
  border-color: var(--primary-pink);
  box-shadow: 0 12px 0px var(--primary-pink), 0 0 30px rgba(255, 107, 139, 0.4);
}
body.starry-mode .game-card[data-category="toddler"]:hover,
body.starry-mode .game-card[data-category="toddler"]:focus-visible {
  border-color: var(--primary-blue);
  box-shadow: 0 12px 0px var(--primary-blue), 0 0 30px rgba(77, 163, 255, 0.4);
}
body.starry-mode .game-card[data-category="preschool"]:hover,
body.starry-mode .game-card[data-category="preschool"]:focus-visible {
  border-color: var(--primary-green);
  box-shadow: 0 12px 0px var(--primary-green), 0 0 30px rgba(74, 222, 128, 0.4);
}
body.starry-mode .game-card[onclick*="car-game"]:hover,
body.starry-mode .game-card[onclick*="car-game"]:focus-visible {
  border-color: var(--primary-purple);
  box-shadow: 0 12px 0px var(--primary-purple), 0 0 30px rgba(192, 132, 252, 0.4);
}

/* Game Window & Headers */
body.starry-mode .game-window {
  background: #0f172a;
  border-color: #2c3a63;
  box-shadow: 0 8px 0px #050611;
}
body.starry-mode .game-window-header {
  background: #1e293b;
  border-bottom: 3px solid #2c3a63;
  color: #f1f5f9;
}

/* Jigsaw Canvas & Guides */
body.starry-mode .puzzle-canvas {
  background: #0f172a;
}

/* Shape Sorter Canvas */
body.starry-mode .shapesorter-canvas {
  background: #0f172a;
}

/* Keypress Zoo Dark/Bedtime Mode */
body.starry-mode .keypress-zoo-view {
  background: linear-gradient(135deg, #0d122b, #1e1b4b);
}
body.starry-mode .keypress-zoo-card {
  background: #18223f;
  border-color: #2c3a63;
  color: #f1f5f9;
}
body.starry-mode .keypress-zoo-card:hover {
  box-shadow: 0 12px 0px var(--primary-purple), 0 0 25px rgba(192, 132, 252, 0.35);
  border-color: var(--primary-purple);
}
body.starry-mode .keypress-zoo-card:active {
  box-shadow: 0 2px 0px var(--primary-purple);
  border-color: var(--primary-purple);
}
body.starry-mode .keypress-zoo-giant-char {
  color: var(--primary-purple);
}
body.starry-mode .kids-keyboard {
  background: rgba(24, 34, 63, 0.65);
  border-color: #2c3a63;
}
body.starry-mode .kids-key {
  background: #1e293b;
  border-color: #2c3a63;
  color: #e2e8f0;
  box-shadow: 0 3px 0 #2c3a63;
}
body.starry-mode .kids-key:active,
body.starry-mode .kids-key.active-press {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #2c3a63;
}
body.starry-mode .kids-key.key-letter {
  background-color: #1e1b4b;
  border-color: var(--primary-purple);
  box-shadow: 0 3px 0 var(--primary-purple);
}
body.starry-mode .kids-key.key-number {
  background-color: #0c4a6e;
  border-color: var(--primary-blue);
  box-shadow: 0 3px 0 var(--primary-blue);
}
body.starry-mode .kids-key.key-special {
  background-color: #701a75;
  border-color: var(--primary-pink);
  box-shadow: 0 3px 0 var(--primary-pink);
}
body.starry-mode .keypress-zoo-prompt {
  color: #94a3b8;
}

/* Animal Sounds (Soundboard) Cards */
body.starry-mode .soundboard-card {
  background: #18223f;
  color: #f1f5f9;
  border-color: #2c3a63;
  box-shadow: 0 6px 0 #2c3a63;
}
body.starry-mode .soundboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #2c3a63;
}
body.starry-mode .soundboard-card:active,
body.starry-mode .soundboard-card.bouncing {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #2c3a63;
}

/* Memory Match Cards */
body.starry-mode .memory-card-back {
  background: #1e293b;
  color: #f1f5f9;
  border-color: #475569;
}
body.starry-mode .memory-card-front {
  background: var(--primary-purple);
  border-color: #475569;
}

/* Magic Coloring Book */
body.starry-mode .coloring-view {
  background: radial-gradient(circle, #1e293b 0%, #0d122b 100%);
}
body.starry-mode .coloring-palette {
  background: #1e293b;
  border-right-color: #2c3a63;
  box-shadow: inset -8px 0 16px rgba(0, 0, 0, 0.25), inset 4px 4px 0 rgba(255, 255, 255, 0.05);
}
body.starry-mode .coloring-canvas-container {
  background: #18223f;
  border-color: #2c3a63;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25), 0 4px 0 #2c3a63;
}
body.starry-mode .coloring-canvas-container::before {
  filter: drop-shadow(0 3px 2px rgba(0,0,0,0.4));
}
body.starry-mode .coloring-reference-box {
  background: #1e293b;
  border-color: #2c3a63;
  box-shadow: 0 4px 0 #2c3a63;
}
body.starry-mode .coloring-reference-svg path {
  stroke: #e2e8f0;
}
body.starry-mode .coloring-footer-row .tab-btn {
  background: #1e293b;
  border-color: #475569;
  box-shadow: 0 5px 0 #475569;
  color: #f1f5f9;
}
body.starry-mode .coloring-footer-row .tab-btn:active {
  box-shadow: 0 0px 0 #475569;
}
body.starry-mode .coloring-footer-row .tab-btn.active {
  background: var(--primary-purple);
  border-color: var(--primary-purple);
  box-shadow: 0 5px 0 #8b5cf6;
}

/* Victory Overlay */
body.starry-mode .victory-overlay {
  background: rgba(13, 18, 43, 0.9);
  color: #f1f5f9;
}
body.starry-mode .victory-title {
  color: var(--primary-purple);
  text-shadow: 0 0 15px rgba(192, 132, 252, 0.4);
}
body.starry-mode .victory-btn {
  background: var(--primary-purple);
  border-color: var(--primary-purple);
  box-shadow: 0 6px 0px #8b5cf6;
  color: white;
}
body.starry-mode .victory-btn:hover {
  box-shadow: 0 4px 0px #8b5cf6;
}
body.starry-mode .victory-btn:active {
  box-shadow: 0 0px 0px #8b5cf6;
}

/* Cyber Theme for Car Game HUD & Overlays */
.toy-dashboard {
  position: absolute;
  bottom: 24px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  z-index: 10;
  pointer-events: none;
}
.toy-dashboard.neon-theme .toy-btn {
  pointer-events: auto;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  background: rgba(18, 18, 24, 0.9);
  transition: transform 0.05s ease, box-shadow 0.05s ease, border-color 0.1s ease;
}
.toy-dashboard.neon-theme .cyber-steer {
  width: 60px;
  height: 60px;
  border: 3.5px solid #00f2fe;
  color: #00f2fe;
  font-size: 24px;
  box-shadow: 0 5px 0 #0099ab, 0 4px 15px rgba(0, 242, 254, 0.35);
}
.toy-dashboard.neon-theme .cyber-steer:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #0099ab, 0 2px 10px rgba(0, 242, 254, 0.2);
}
.toy-dashboard.neon-theme .cyber-horn {
  width: 68px;
  height: 68px;
  border: 3.5px solid #facc15;
  color: #facc15;
  font-size: 28px;
  box-shadow: 0 5px 0 #ca8a04, 0 4px 15px rgba(250, 204, 21, 0.35);
}
.toy-dashboard.neon-theme .cyber-horn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #ca8a04, 0 2px 10px rgba(250, 204, 21, 0.2);
}

.car-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 5;
  pointer-events: none;
}
.car-hud .hud-left,
.car-hud .hud-right {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.car-hud .hud-right {
  flex-direction: column;
  align-items: flex-end;
}
.hud-card {
  background: rgba(18, 18, 24, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2.5px solid #2c3a63;
  border-radius: 14px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}
.hud-card-lbl {
  font-size: 0.65rem;
  color: #94a3b8;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.hud-card-val {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.15rem;
  font-weight: 700;
}
.hud-card-val.cyan {
  color: #00f2fe;
}
.hud-card-val.yellow {
  color: #facc15;
}
.hud-pause-btn {
  pointer-events: auto;
  cursor: pointer;
  background: rgba(18, 18, 24, 0.85);
  border: 2.5px solid #2c3a63;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 #1e293b;
  transition: all 0.05s ease;
}
.hud-pause-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #1e293b;
}
.hud-pause-btn svg {
  fill: #f1f5f9;
  width: 14px;
  height: 14px;
}

/* Cyber Game Overlays */
.cyber-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 14, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: white;
}
.cyber-overlay h1 {
  color: #00f2fe;
  text-transform: uppercase;
  font-size: 2.2rem;
  margin-bottom: 8px;
  text-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}
.cyber-overlay p {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-bottom: 20px;
  max-width: 85%;
  line-height: 1.4;
}
.cyber-panel {
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 0.78rem;
  margin-bottom: 24px;
  line-height: 1.6;
  color: #cbd5e1;
  max-width: 90%;
}
.cyber-panel strong {
  color: #00f2fe;
}
.cyber-key {
  color: #00f2fe;
  border: 1px solid #00f2fe;
  padding: 1px 4px;
  border-radius: 4px;
  font-family: monospace;
  background: rgba(0, 242, 254, 0.1);
  margin: 0 1px;
}
.cyber-btn-primary {
  background: #00f2fe;
  color: #0b0b0e;
  border: none;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: var(--border-radius-bubbly);
  box-shadow: 0 5px 0 #0099ab;
  transition: all 0.05s ease;
  cursor: pointer;
}
.cyber-btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #0099ab;
}
.cyber-btn-secondary {
  background: #475569;
  color: white;
  border: none;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: var(--border-radius-bubbly);
  box-shadow: 0 5px 0 #1e293b;
  transition: all 0.05s ease;
  cursor: pointer;
}
.cyber-btn-secondary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #1e293b;
}



/* ----------------------------------------------------
   RESET & BASE STYLING
   ---------------------------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  font-family: 'Fredoka', sans-serif;
}

/* Custom kid-friendly visible focus outlines */
:focus-visible {
  outline: 4px dashed var(--focus-outline-color);
  outline-offset: 4px;
}

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

/* Skip to main content link (keyboard accessibility) */
.skip-link {
  position: fixed;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  background: var(--primary-pink);
  color: white;
  padding: 12px 24px;
  border-radius: 0 0 16px 16px;
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  border: 3px solid white;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 4px dashed white;
  outline-offset: 2px;
}

body {
  background: radial-gradient(circle at 50% 50%, #fffdf0 0%, #fff7d6 100%);
  color: var(--text-dark);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Lock landing page to viewport (no outer page scrolling) */
  transition: background 0.5s ease, color 0.5s ease;
}

/* Lock body to viewport when a game is active — no scrollbars */
body:has(#game-viewport:not(.hidden-view)) {
  overflow: hidden;
  height: 100dvh;
}

/* Custom Kid-friendly Cursor */
.custom-cursor {
  display: none; /* hidden on touch devices by default */
}

@media (pointer: fine) {
  .custom-cursor {
    display: block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--primary-pink);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition: width 0.1s, height 0.1s, border-color 0.1s;
    background: rgba(255, 107, 139, 0.15);
    box-shadow: 0 0 0 2px #ffffff, 0 4px 10px rgba(0, 0, 0, 0.15);
  }

  .custom-cursor.active {
    width: 34px;
    height: 34px;
    border-color: var(--primary-blue);
    background: rgba(77, 163, 255, 0.25);
  }

  .custom-cursor.coloring-mode {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transform: translate(-3px, -3px);
    transition: none;
    display: none; /* hidden by default, shown only when hovering canvas container */
  }

  /* Hide default cursor on desktop */
  body {
    cursor: none;
  }
  a, button, .game-card, .clickable, .tab-btn {
    cursor: none;
  }
  
  /* Restore default cursor when in Magic Coloring screen but NOT hovering the canvas container */
  body:has(.coloring-view) {
    cursor: default;
  }
  body:has(.coloring-view) a,
  body:has(.coloring-view) button,
  body:has(.coloring-view) .clickable,
  body:has(.coloring-view) .crayon-color {
    cursor: pointer;
  }
  body:has(.coloring-view) .coloring-canvas-container:hover,
  body:has(.coloring-view) .coloring-canvas-container:hover * {
    cursor: none;
  }

  /* Show custom coloring brush cursor only when hovering inside the drawing canvas */
  body:has(.coloring-canvas-container:hover) .custom-cursor.coloring-mode {
    display: block;
  }
}

/* ----------------------------------------------------
   PORTAL SHELL & LAYOUT
   ---------------------------------------------------- */
#app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 16px;
  margin: 16px 24px 8px 24px;
  z-index: 100;
  border-radius: var(--border-radius-bubbly);
  border: 3.5px solid var(--text-dark);
  box-shadow: var(--shadow-bubbly);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-text {
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-pink), var(--primary-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Bubble Buttons */
.bubble-btn {
  background: white;
  border: 3px solid var(--text-dark);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 0px var(--text-dark);
  transition: all 0.1s ease;
  position: relative;
}

.bubble-btn:hover {
  transform: translateY(2px);
  box-shadow: 0 4px 0px var(--text-dark);
}

.bubble-btn:active {
  transform: translateY(6px);
  box-shadow: 0 0px 0px var(--text-dark);
}

.bubble-btn svg {
  width: 24px;
  height: 24px;
  fill: var(--text-dark);
}

.bubble-btn.pink { border-color: var(--primary-pink); box-shadow: 0 6px 0px var(--primary-pink); }
.bubble-btn.pink svg { fill: var(--primary-pink); }
.bubble-btn.blue { border-color: var(--primary-blue); box-shadow: 0 6px 0px var(--primary-blue); }
.bubble-btn.blue svg { fill: var(--primary-blue); }
.bubble-btn.yellow { border-color: var(--primary-yellow); box-shadow: 0 6px 0px var(--primary-yellow); }
.bubble-btn.yellow svg { fill: var(--primary-yellow); }

.home-link-btn {
  border-radius: var(--border-radius-bubbly);
  width: auto;
  padding: 0 20px;
  font-weight: 700;
  gap: 8px;
}

/* Category Filtering Tabs Container */
#categories-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
}

#categories-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 8px 0 24px 0;
  flex-wrap: wrap;
  width: 100%;
}

.tab-btn {
  background: white;
  border: 3px solid var(--text-dark);
  padding: 10px 24px;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 40px;
  box-shadow: 0 6px 0px var(--text-dark);
  transition: all 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.1);
  cursor: pointer;
  position: relative;
}

.tab-btn:hover {
  transform: translateY(2px);
  box-shadow: 0 4px 0px var(--text-dark);
}

.tab-btn:active {
  transform: translateY(6px);
  box-shadow: 0 0px 0px var(--text-dark);
}

.tab-btn.active {
  background: var(--primary-pink);
  color: white;
  border-color: var(--primary-pink);
  box-shadow: 0 6px 0px #c9405d;
}

/* ----------------------------------------------------
   DASHBOARD / GAME GRID
   ---------------------------------------------------- */
#dashboard-view {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 0px 24px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Enable internal scrolling */
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  padding-bottom: 24px;
  overflow-y: auto; /* Scroll internally if needed */
  flex: 1;
  min-height: 0; /* Enable internal scrolling */
}

/* Custom scrollbar for games grid */
.games-grid::-webkit-scrollbar {
  width: 8px;
}
.games-grid::-webkit-scrollbar-track {
  background: transparent;
}
.games-grid::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}
.games-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}
body.starry-mode .games-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}
body.starry-mode .games-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.game-card {
  background: white;
  border: 4px solid var(--text-dark);
  border-radius: var(--border-radius-bubbly);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 80px 1fr;
  grid-template-rows: auto auto 1fr;
  grid-template-areas:
    "icon tag"
    "icon title"
    "icon desc";
  align-items: center;
  text-align: left;
  gap: 4px 16px;
  box-shadow: var(--shadow-bubbly);
  transition: transform 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.28), box-shadow 0.22s ease, border-color 0.22s ease;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.game-card:hover {
  transform: translateY(-6px) scale(1.015);
  box-shadow: 0 12px 0px var(--text-dark), 0 18px 30px rgba(0, 0, 0, 0.08);
}

.game-card:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0px var(--text-dark);
}

.game-card-icon {
  grid-area: icon;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  border: 3px solid var(--text-dark);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.1);
  margin-bottom: 0;
  justify-self: center;
  transition: transform 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.28);
}

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

/* Category-specific Bouncy Halo Glow Effects */
.game-card[data-category="baby"]:hover,
.game-card[data-category="baby"]:focus-visible {
  border-color: var(--primary-pink);
  box-shadow: 0 12px 0px var(--primary-pink), 0 0 20px rgba(255, 107, 139, 0.25);
}
.game-card[data-category="toddler"]:hover,
.game-card[data-category="toddler"]:focus-visible {
  border-color: var(--primary-blue);
  box-shadow: 0 12px 0px var(--primary-blue), 0 0 20px rgba(77, 163, 255, 0.25);
}
.game-card[data-category="preschool"]:hover,
.game-card[data-category="preschool"]:focus-visible {
  border-color: var(--primary-green);
  box-shadow: 0 12px 0px var(--primary-green), 0 0 20px rgba(74, 222, 128, 0.25);
}
.game-card[onclick*="car-game"]:hover,
.game-card[onclick*="car-game"]:focus-visible {
  border-color: var(--primary-purple);
  box-shadow: 0 12px 0px var(--primary-purple), 0 0 20px rgba(192, 132, 252, 0.25);
}

.game-card-title {
  grid-area: title;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0;
  color: var(--text-dark);
}

.game-card-tag {
  grid-area: tag;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 8px;
  color: white;
  margin-bottom: 0;
  width: max-content;
  align-self: flex-start;
}

.tag-baby { background-color: var(--primary-pink); }
.tag-toddler { background-color: var(--primary-blue); }
.tag-preschool { background-color: var(--primary-green); }
.tag-car { background-color: var(--primary-purple); }

.game-card-desc {
  grid-area: desc;
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.3;
  margin-bottom: 0;
  align-self: start;
}

@media (max-width: 480px) {
  .games-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .game-card {
    grid-template-columns: 64px 1fr;
    gap: 4px 12px;
    padding: 10px 12px;
  }
  .game-card-icon {
    width: 60px;
    height: 60px;
    font-size: 2.2rem;
    border-width: 2px;
  }
  .game-card-title {
    font-size: 1.05rem;
  }
  .game-card-desc {
    font-size: 0.8rem;
  }
}



/* ----------------------------------------------------
   GAME VIEW & CONTAINERS
   ---------------------------------------------------- */
#game-viewport {
  flex: 1;
  min-height: 0;          /* Allow flex shrink below content size */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;          /* Maximizes space on desktop */
  width: 100%;
  overflow: hidden;       /* Prevent game content from causing scroll */
}

.hidden-view, .hidden {
  display: none !important;
}

.game-window {
  width: 100%;
  /*
   * max-width uses min() to pick whichever is tighter:
   *   - 95% of screen width (desktop), OR
   *   - the width that would produce a height equal to available viewport
   *     (100dvh - ~90px header - 32px viewport padding) at 4:3 ratio
   * This guarantees the game window always fits within one screen and maximizes space.
   */
  max-width: min(95%, calc((100dvh - 90px - 32px) * 4 / 3));
  aspect-ratio: 4 / 3;
  background: white;
  border: 4px solid var(--text-dark);
  border-radius: var(--border-radius-bubbly);
  box-shadow: var(--shadow-bubbly);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* For portrait car game */
.game-window.car-layout {
  /* 5:8 portrait ratio: width = height * (5/8) */
  max-width: min(500px, calc((100dvh - 90px - 48px) * 5 / 8));
  aspect-ratio: 5 / 8;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Game Title Overlay/Header inside window */
.game-window-header {
  padding: 12px 24px;
  background: #f1f5f9;
  border-bottom: 3px solid var(--text-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-window-title {
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-window-content {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column; /* Stack modes-bar + canvas vertically */
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

/* ----------------------------------------------------
   GAME-SPECIFIC STYLES
   ---------------------------------------------------- */

/* GAME 1: BALLOON POP */
.balloon-pop-canvas {
  flex: 1;           /* Grow to fill space below modes bar */
  width: 100%;
  min-height: 0;     /* Allow shrink in flex column */
  background: linear-gradient(to bottom, #dff0ff, #fffdf0);
  display: block;
}

/* GAME 2: KEYPRESS ZOO */
.keypress-zoo-view {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #e0f2fe, #fef08a);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  text-align: center;
  box-sizing: border-box;
}

.keypress-zoo-card {
  background: white;
  border: 4px solid var(--text-dark);
  border-radius: var(--border-radius-bubbly);
  padding: 12px 16px;
  box-shadow: var(--shadow-bubbly);
  transform: scale(0);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  width: 220px;
  height: 260px;
  box-sizing: border-box;
  flex-shrink: 0;
  overflow: hidden;
}

.keypress-zoo-card.zoom-in {
  transform: scale(1);
}

.keypress-zoo-emoji {
  font-size: 4.2rem;
  margin-bottom: 0;
  animation: float 3s ease-in-out infinite;
}

.keypress-zoo-name {
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dark);
  letter-spacing: 1.5px;
  line-height: 1.2;
  white-space: nowrap;
}

.keypress-zoo-prompt {
  font-size: 1.1rem;
  font-weight: 600;
  color: #64748b;
  position: static;
  margin-top: 8px;
  animation: heartbeat 2s infinite;
}

/* GAME 3: ANIMAL SOUNDBOARD */
.soundboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  padding: 24px;
  width: 100%;
  height: 100%;
}

.soundboard-card {
  background: white;
  border: 3px solid var(--text-dark);
  border-radius: var(--border-radius-bubbly);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-shadow: 0 6px 0 var(--text-dark);
  transition: all 0.1s ease;
}

.soundboard-card:hover {
  transform: translateY(2px);
  box-shadow: 0 4px 0 var(--text-dark);
}

.soundboard-card:active, .soundboard-card.bouncing {
  transform: translateY(6px);
  box-shadow: 0 0px 0 var(--text-dark);
}

.soundboard-emoji {
  font-size: 4rem;
  margin-bottom: 8px;
}

.soundboard-label {
  font-size: 1.1rem;
  font-weight: 700;
}

/* GAME 4: SHAPE SORTER */
.shapesorter-canvas {
  flex: 1;
  width: 100%;
  min-height: 0;
  background: #fdfbf7;
  display: block;
}

/* GAME 5: MEMORY MATCH */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 24px;
  width: 100%;
  max-width: 600px;
}

.memory-card {
  aspect-ratio: 1;
  perspective: 1000px;
  cursor: pointer;
}

.memory-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.memory-card.flipped .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card-front, .memory-card-back {
  width: 100%;
  height: 100%;
  position: absolute;
  backface-visibility: hidden;
  border-radius: 16px;
  border: 3px solid var(--text-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

.memory-card-front {
  background: var(--primary-pink);
  color: white;
  font-size: 2.5rem;
  font-weight: 700;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.2);
}

.memory-card-back {
  background: white;
  transform: rotateY(180deg);
  font-size: 3rem;
}

/* GAME 6: MAGIC COLORING BOOK */
.coloring-view {
  display: flex;
  flex-direction: row; /* Palette on left, Canvas area on right */
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, #fffef4 0%, #fef08a 100%);
}

.coloring-canvas-area {
  display: flex;
  flex-direction: column; /* Canvas on top, footer at bottom */
  flex: 1;
  min-height: 0;
  height: 100%;
}

.coloring-footer-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 6px 12px 12px 12px;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}

.coloring-palette {
  width: 140px;
  background: #f8fafc;
  border-right: 4px solid var(--text-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 12px;
  overflow-y: auto;
  border-radius: 24px 0 0 24px;
  box-shadow: inset -8px 0 16px rgba(0, 0, 0, 0.03), inset 4px 4px 0 #ffffff;
}

.crayon-color {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid #ffffff;
  box-shadow: 0 0 0 3px var(--text-dark), 0 6px 0 3px rgba(0, 0, 0, 0.1);
  transition: all 0.1s ease;
  position: relative;
  overflow: visible;
}

.crayon-color:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 0 0 3px var(--text-dark), 0 8px 0 3px rgba(0, 0, 0, 0.08);
}

.crayon-color.active {
  transform: translateY(4px);
  box-shadow: 0 0 0 3px var(--text-dark), 0 2px 0 3px rgba(0, 0, 0, 0.15);
}

.crayon-color.active::after {
  content: '🖌️';
  filter: drop-shadow(2px 0 0 white) drop-shadow(-2px 0 0 white) drop-shadow(0 2px 0 white) drop-shadow(0 -2px 0 white) drop-shadow(2px 2px 2px rgba(0,0,0,0.3));
  position: absolute;
  top: -14px;
  right: -14px;
  font-size: 1.4rem;
  pointer-events: none;
  animation: paint-wiggle 1s ease-in-out infinite alternate;
}

@keyframes paint-wiggle {
  0% { transform: rotate(-5deg); }
  100% { transform: rotate(15deg) translateY(-2px); }
}

/* Paint well gloss effect */
.crayon-color::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 6px;
  width: 12px;
  height: 8px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  transform: rotate(-30deg);
  pointer-events: none;
}

.crayon-color.crayon-eraser {
  background: linear-gradient(135deg, #ff9eb5 50%, #38bdf8 50%) !important;
}

.coloring-canvas-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: #ffffff;
  margin: 12px 12px 6px 12px; /* reduced bottom margin */
  border-radius: 12px;
  border: 4px solid var(--text-dark);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.06), 0 4px 0 var(--text-dark);
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.coloring-canvas-container::before {
  content: '📎';
  font-size: 2.2rem;
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%) rotate(90deg);
  z-index: 10;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,0.15));
}

.coloring-svg {
  width: 100%;
  height: 100%;
  max-width: 95%;
  max-height: 95%;
}

.coloring-svg path,
.coloring-svg circle,
.coloring-svg rect,
.coloring-svg polygon,
.coloring-svg line {
  fill: #ffffff;
  stroke: #2c3e50;
  stroke-width: 3;
  stroke-linejoin: round;
  transition: fill 0.2s ease;
  pointer-events: none;
}

.coloring-svg .color-zone {
  pointer-events: auto;
  cursor: pointer;
}

.coloring-svg .color-zone:hover {
  fill: rgba(0, 0, 0, 0.05);
}

.coloring-svg .color-zone:focus {
  outline: none;
}

.coloring-svg .color-zone:focus-visible {
  outline: none;
  stroke: var(--focus-outline-color);
  stroke-width: 5;
  filter: drop-shadow(0 0 6px var(--focus-outline-color));
}

/* GAME 7: TODDLER & PRESCHOOL JIGSAW PUZZLE */
.puzzle-game-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #f0fdf4 0%, #e0f2fe 100%);
  border-radius: var(--border-radius-card, 16px);
  overflow: hidden;
  position: relative;
}

body.starry-mode .puzzle-game-wrapper {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
}

.puzzle-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  z-index: 10;
}

body.starry-mode .puzzle-toolbar {
  background: rgba(30, 41, 59, 0.85);
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.puzzle-toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.puzzle-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-right: 2px;
}

body.starry-mode .puzzle-label {
  color: #94a3b8;
}

.puzzle-pill-btn {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.puzzle-pill-btn:hover {
  transform: translateY(-2px) scale(1.04);
  border-color: #3b82f6;
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.2);
}

.puzzle-pill-btn.active {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  border-color: #1d4ed8;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

body.starry-mode .puzzle-pill-btn {
  background: #334155;
  border-color: #475569;
  color: #f8fafc;
}

body.starry-mode .puzzle-pill-btn.active {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  border-color: #4338ca;
  color: #ffffff;
}

/* Reference Image Card ("Reference Image for Kid") */
.puzzle-ref-card {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 95px;
  background: #ffffff;
  border: 2px solid #3b82f6;
  border-radius: 10px;
  padding: 3px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  z-index: 20;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  user-select: none;
}

.puzzle-ref-card:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.25);
}

body.starry-mode .puzzle-ref-card {
  background: #1e293b;
  border-color: #818cf8;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.puzzle-ref-card-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.62rem;
  font-weight: 800;
  color: #1e40af;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

body.starry-mode .puzzle-ref-card-header {
  color: #c7d2fe;
}

.puzzle-ref-canvas {
  width: 100%;
  height: 68px;
  border-radius: 5px;
  display: block;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}
  border: 1px solid #e2e8f0;
}

body.starry-mode .puzzle-ref-canvas {
  background: #0f172a;
  border-color: #334155;
}

.puzzle-canvas-area {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
}

.puzzle-canvas {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  touch-action: none;
  cursor: grab;
}

.puzzle-canvas:active {
  cursor: grabbing;
}


/* ----------------------------------------------------
   UTILITIES & GENERAL ANIMATIONS
   ---------------------------------------------------- */

/* Confetti overlay for completion */
.victory-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.85);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

.victory-title {
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary-pink);
  margin-bottom: 20px;
  animation: bounce 1s infinite alternate;
}

.victory-btn {
  background: var(--primary-blue);
  color: white;
  border: 3px solid var(--text-dark);
  border-radius: var(--border-radius-bubbly);
  padding: 12px 30px;
  font-size: 1.2rem;
  font-weight: 700;
  box-shadow: 0 6px 0 var(--text-dark);
  transition: all 0.1s ease;
}

.victory-btn:hover {
  transform: translateY(2px);
  box-shadow: 0 4px 0 var(--text-dark);
}

.victory-btn:active {
  transform: translateY(6px);
  box-shadow: 0px 0px 0 var(--text-dark);
}

/* Generic floating animation */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.float {
  animation: float 4s ease-in-out infinite;
}

/* Bouncing animation */
@keyframes bounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-15px); }
}

.bounce {
  animation: bounce 0.6s infinite alternate;
}

/* Heartbeat animation */
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Confetti particles */
.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  pointer-events: none;
  animation: confetti-fall 2s linear forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(500px) rotate(360deg); opacity: 0; }
}

/* ----------------------------------------------------
   MEDIA QUERIES FOR RESPONSIVENESS
   ---------------------------------------------------- */
@media (max-width: 768px) {
  body {
    overflow-y: auto; /* Allow outer page scrolling on mobile */
    height: auto;
    min-height: 100dvh;
  }
  body:has(#game-viewport:not(.hidden-view)) {
    overflow: hidden !important;
    height: 100dvh !important;
  }
  #dashboard-view {
    flex: none;
    height: auto;
    min-height: 0;
  }
  .games-grid {
    overflow-y: visible; /* Scroll using the body scrollbar instead of internal */
    height: auto;
    flex: none;
    padding-bottom: 32px;
    -webkit-overflow-scrolling: touch;
  }
  .game-window-header {
    padding: 8px 12px;
  }
  .game-window-title {
    font-size: 1.05rem;
  }
  .game-window-header .home-link-btn {
    padding: 0 12px;
    font-size: 0.9rem;
    height: 36px;
  }

  #app-header {
    padding: 10px 18px;
    margin: 12px 16px 4px 16px;
    top: 12px;
    border-width: 2.5px;
    box-shadow: 0 5px 0 var(--text-dark);
  }
  body.starry-mode #app-header {
    box-shadow: 0 5px 0 #050611;
  }
  .logo-text {
    font-size: 1.6rem;
  }
  .nav-controls {
    gap: 8px;
  }
  .bubble-btn {
    width: 42px;
    height: 42px;
    border-width: 2.5px;
    box-shadow: 0 4px 0 var(--text-dark);
  }
  .bubble-btn svg {
    width: 20px;
    height: 20px;
  }
  
  /* Horizontal Swipeable capsule bar on mobile */
  #categories-container {
    padding: 0 16px;
  }
  #categories-bar {
    display: flex;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 8px 4px 16px 4px;
    gap: 10px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #categories-bar::-webkit-scrollbar {
    display: none;
  }
  #categories-container::before,
  #categories-container::after {
    content: '';
    position: absolute;
    top: 8px;
    bottom: 16px;
    width: 32px;
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.3s ease, background 0.5s ease;
    opacity: 0;
  }
  #categories-container.mask-left::before {
    opacity: 1;
  }
  #categories-container.mask-right::after {
    opacity: 1;
  }
  #categories-container::before {
    left: 16px;
    background: linear-gradient(to right, #fffdf0, rgba(255, 255, 240, 0));
  }
  #categories-container::after {
    right: 16px;
    background: linear-gradient(to left, #fffdf0, rgba(255, 255, 240, 0));
  }
  
  body.starry-mode #categories-container::before {
    background: linear-gradient(to right, #0d122b, rgba(13, 18, 43, 0));
  }
  body.starry-mode #categories-container::after {
    background: linear-gradient(to left, #0d122b, rgba(13, 18, 43, 0));
  }
  
  .tab-btn {
    flex-shrink: 0;
    padding: 8px 18px;
    font-size: 0.95rem;
    border-width: 2.5px;
    box-shadow: 0 4px 0 var(--text-dark);
  }
  .tab-btn.active {
    box-shadow: 0 4px 0 #c9405d;
  }
  body.starry-mode .tab-btn {
    box-shadow: 0 4px 0 #475569;
  }
  body.starry-mode .tab-btn.active {
    box-shadow: 0 4px 0 #8b5cf6;
  }
  .soundboard-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 8px;
  }
  .soundboard-card {
    padding: 6px;
    border-radius: 12px;
    border-width: 2px;
    box-shadow: 0 3px 0 var(--text-dark);
  }
  .soundboard-emoji {
    font-size: 2.2rem;
    margin-bottom: 2px;
  }
  .soundboard-label {
    font-size: 0.75rem;
  }
  .memory-grid {
    gap: 8px;
    padding: 12px;
  }
  .memory-card-front {
    font-size: 1.8rem;
  }
  .memory-card-back {
    font-size: 2.2rem;
  }

  /* Game viewport: no hardcoded heights — let flex handle it */
  #game-viewport {
    padding: 8px;
    min-height: 0;
    overflow: hidden;
  }

  /* Mobile: full-screen game window (no aspect-ratio constraint) */
  .game-window {
    max-width: 100%;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    display: flex;
    flex-direction: column;
  }

  /* Car-game stays portrait, centered, auto-height */
  .game-window.car-layout {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 5 / 8;
    margin: auto;
  }

  /* Stretch content to fill full mobile game window */
  .game-window-content {
    align-items: stretch !important;
    justify-content: stretch !important;
  }

  /* Keypress Zoo Mobile Sizing */
  .keypress-zoo-view {
    padding: 8px;
  }
  .keypress-zoo-card {
    padding: 8px 12px;
    border-width: 3px;
    width: 180px;
    height: 220px;
    justify-content: space-evenly;
  }
  .keypress-zoo-giant-char {
    font-size: 2.8rem !important;
  }
  .keypress-zoo-emoji {
    font-size: 2.8rem;
    margin-bottom: 0;
  }
  .keypress-zoo-name {
    font-size: 1.2rem;
    white-space: nowrap;
  }
  .count-star {
    font-size: 1.6rem;
  }
  .kids-keyboard {
    margin-top: 8px;
    padding: 6px;
    border-width: 2px;
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
  }
  .keyboard-row {
    gap: 3px;
  }
  .kids-key {
    padding: 2px 1px;
    border-width: 2px;
    border-radius: 6px;
    box-shadow: 0 2px 0 var(--text-dark);
    flex: 0 1 32px;
    aspect-ratio: 1 / 1.15;
    gap: 1px;
  }
  .kids-key .key-label {
    font-size: 0.75rem;
  }
  .kids-key .key-icon {
    font-size: 0.65rem;
  }
  .kids-key.key-special {
    flex: 0 1 120px;
    aspect-ratio: auto;
    height: 32px;
    gap: 4px;
    flex-direction: row;
  }
  .keypress-zoo-prompt {
    font-size: 0.85rem;
    margin-top: 4px;
  }

  /* Coloring palette goes horizontal on mobile */
  .coloring-view {
    flex-direction: column;
    height: 100%;
    width: 100%;
    min-height: 0;
  }
  .coloring-workspace {
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
  }
  .coloring-palette {
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
    border-right: none;
    border-bottom: 4px solid var(--text-dark);
    border-radius: 20px 20px 0 0;
    gap: 8px;
    justify-content: start;
    flex-shrink: 0;
  }
  .crayon-color {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
  }
  .coloring-canvas-container {
    margin: 8px;
    padding: 8px;
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  .coloring-svg {
    max-width: 100%;
    max-height: 100%;
  }
  .coloring-footer-row {
    padding: 4px 8px 8px 8px;
    gap: 8px;
  }
  .coloring-footer-row .tab-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    box-shadow: 0 4px 0px var(--text-dark);
  }
}

/* Keyboard badge for coloring book */
.key-badge {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-dark);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  pointer-events: none;
  z-index: 5;
}

/* Magic coloring sparkles */
.sparkle {
  position: fixed;
  pointer-events: none;
  width: 14px;
  height: 14px;
  background: var(--sparkle-color, #facc15);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  z-index: 10000;
  animation: sparkle-fade 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes sparkle-fade {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
    opacity: 1;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2) rotate(180deg);
    opacity: 0;
  }
}

/* Kids learning UI styles */
.keypress-zoo-giant-char {
  font-size: 4rem;
  font-weight: 800;
  color: var(--primary-pink);
  margin-bottom: 0;
  line-height: 1;
  animation: bounce 0.6s ease;
}

.kids-keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 95%;
  max-width: 750px;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(4px);
  padding: 8px;
  border-radius: 16px;
  border: 3px dashed var(--text-dark);
  z-index: 10;
  box-shadow: 0 6px 0px rgba(0,0,0,0.05);
  box-sizing: border-box;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: nowrap;
  width: 100%;
  box-sizing: border-box;
}

.kids-key {
  background: white;
  border: 2.5px solid var(--text-dark);
  border-radius: 10px;
  padding: 6px 4px;
  color: var(--text-dark);
  box-shadow: 0 2.5px 0 var(--text-dark);
  transition: all 0.05s ease;
  flex: 0 1 50px;
  aspect-ratio: 1 / 1.15;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  box-sizing: border-box;
}

.key-label {
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
}

.key-icon {
  font-size: 0.85rem;
  line-height: 1;
}

.kids-key:active, .kids-key.active-press {
  transform: translateY(2px);
  box-shadow: 0 0.5px 0 var(--text-dark);
}

.kids-key.key-letter {
  background-color: #fef08a; /* yellow */
}

.kids-key.key-number {
  background-color: #bfdbfe; /* blue */
}

.kids-key.key-special {
  background-color: #fbcfe8; /* pink */
  flex: 0 1 180px;
  aspect-ratio: auto;
  height: 48px;
  flex-direction: row;
  gap: 8px;
}

/* Balloon Game Mode Selector */
.balloon-modes-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
  z-index: 10;
  padding: 0 10px;
}

.mode-btn {
  background: white;
  border: 3px solid var(--text-dark);
  border-radius: 20px;
  padding: 8px 18px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-dark);
  box-shadow: 0 4px 0 var(--text-dark);
  transition: all 0.1s ease;
  cursor: pointer;
}

.mode-btn:hover {
  transform: translateY(1px);
  box-shadow: 0 3px 0 var(--text-dark);
}

.mode-btn.active {
  background-color: var(--primary-pink);
  color: white;
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--text-dark);
}

/* Bubble touch cursor trails */
.bubble-trail {
  position: fixed;
  width: 18px;
  height: 18px;
  background: radial-gradient(circle, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0) 70%);
  border: 2px solid var(--trail-color, #4da3ff);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9998;
  animation: bubble-float 0.8s ease-out forwards;
}

@keyframes bubble-float {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1.8);
    opacity: 0;
  }
}

.count-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: 100%;
  margin: 0;
}

.count-star {
  font-size: 2rem;
  animation: bounce 0.5s ease infinite alternate;
}

/* Coloring Reference Image Thumbnail */
.coloring-reference-box {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 90px;
  height: 90px;
  background: #ffffff;
  border: 3px solid var(--text-dark);
  border-radius: 12px;
  box-shadow: 0 4px 0 var(--text-dark);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}

.coloring-reference-svg {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  display: block;
}

.coloring-reference-svg path {
  stroke: #2c3e50;
  stroke-width: 3;
  stroke-linejoin: round;
}

.coloring-reference-title {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-dark);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

@media (max-width: 768px) {
  .coloring-reference-box {
    width: 60px;
    height: 60px;
    top: 8px;
    right: 8px;
    border-width: 2px;
    border-radius: 8px;
  }
  .coloring-reference-title {
    font-size: 0.5rem;
    top: -15px;
    padding: 1px 4px;
  }
}

/* Dashboard Toy Buttons */
.dashboard-btn {
  transition: transform 0.05s ease, background 0.05s ease;
}
.dashboard-btn:active {
  transform: scale(0.9);
}

@media (max-width: 360px) {
  .kids-key {
    flex: 0 1 26px;
  }
  .kids-key .key-label {
    font-size: 0.65rem;
  }
  .kids-key .key-icon {
    font-size: 0.55rem;
  }
  .keypress-zoo-giant-char {
    font-size: 2.2rem !important;
  }
  .keypress-zoo-emoji {
    font-size: 2.2rem;
  }
  .keypress-zoo-card {
    width: 150px;
    height: 180px;
  }
}
