@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&display=swap');

:root {
  --bg-gradient: linear-gradient(135deg, #1e1b4b 0%, #311b92 40%, #4a148c 70%, #1a237e 100%);
  --font-main: 'Fredoka', cursive, sans-serif;
  --text-color: #ffffff;
  --panel-bg: rgba(255, 255, 255, 0.15);
  --panel-border: rgba(255, 255, 255, 0.25);
  --panel-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-color);
  touch-action: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-container.pseudo-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 999999 !important;
}

/* Background Canvas for Particles, Trails & Balloons */
#particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: auto;
}

/* =========================================================
   1. LANDING PAGE / GAME SELECTION HUB
   ========================================================= */
#landing-page {
  position: absolute;
  inset: 0;
  z-index: 15;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  background: radial-gradient(circle at center, rgba(49, 27, 146, 0.5) 0%, rgba(15, 23, 42, 0.9) 100%);
  backdrop-filter: blur(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#landing-page.hidden {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
}

.hub-header {
  text-align: center;
  margin-bottom: 25px;
}

.hub-title {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 700;
  background: linear-gradient(45deg, #ff4081, #ffd700, #00e5ff, #00e676);
  background-size: 300% 300%;
  animation: gradientShift 6s ease infinite;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

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

.hub-subtitle {
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
  color: rgba(255, 255, 255, 0.85);
  margin-top: 6px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  width: 100%;
  max-width: 1100px;
  margin-bottom: 30px;
}

.game-card {
  position: relative;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 28px;
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease, border-color 0.3s ease;
  overflow: hidden;
}

.game-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--card-gradient, linear-gradient(135deg, #ff4081, #7c4dff));
}

.game-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.2);
}

.card-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  filter: drop-shadow(0 5px 10px rgba(0,0,0,0.3));
}

.game-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #fff;
}

.game-card p {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.4;
  margin-bottom: 20px;
  flex-grow: 1;
}

.play-card-btn {
  background: var(--card-gradient, linear-gradient(135deg, #ff4081, #7c4dff));
  color: white;
  border: none;
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 10px 24px;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  transition: transform 0.2s;
}

.game-card:hover .play-card-btn {
  transform: scale(1.08);
}

.hub-footer {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 20px;
  border-radius: 20px;
  backdrop-filter: blur(5px);
}

/* =========================================================
   2. GAME PLAYGROUND VIEW
   ========================================================= */
#game-playground {
  position: absolute;
  inset: 0;
  z-index: 5;
  transition: opacity 0.4s ease;
}

#game-playground.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Main Display Layer for Key Smashing & Emojis */
#smash-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 25;
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: center;
}

.smash-item {
  position: absolute;
  font-size: clamp(4rem, 15vw, 12rem);
  font-weight: 700;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 40px currentColor;
  animation: popAndFade 1.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 30;
}

.smash-item .sub-label {
  font-size: clamp(1.2rem, 3vw, 2.5rem);
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 16px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
  color: #fff;
  letter-spacing: 1px;
}

@keyframes popAndFade {
  0% { opacity: 0; transform: scale(0.2) rotate(-25deg); }
  20% { opacity: 1; transform: scale(1.3) rotate(10deg); }
  40% { transform: scale(1) rotate(-5deg); }
  75% { opacity: 1; transform: scale(1.05) translateY(-20px); }
  100% { opacity: 0; transform: scale(0.6) translateY(-80px) rotate(15deg); }
}

/* Glassmorphism Parent Header Bar */
#parent-bar {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
  padding: 8px 18px;
  border-radius: 50px;
  transition: all 0.3s ease;
}

.home-btn {
  background: linear-gradient(135deg, #ff4081, #ff9100) !important;
  border-color: #fff !important;
  box-shadow: 0 4px 12px rgba(255, 64, 129, 0.4);
}

.game-title-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffd700;
  padding: 0 8px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.mode-btn, .icon-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 14px;
  border-radius: 25px;
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  outline: none;
}

.mode-btn:hover, .icon-btn:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: translateY(-2deg);
}

/* =========================================================
   3. OVERLAY LEARNING GRIDS (Alphabet & Foods)
   ========================================================= */
#alphabet-container, #food-container {
  position: absolute;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 92%;
  max-width: 1000px;
  max-height: 70vh;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 16px;
  padding: 15px;
  z-index: 5;
  transition: opacity 0.4s ease, transform 0.4s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.4) transparent;
}

#alphabet-container.hidden, #food-container.hidden {
  opacity: 0;
  transform: translate(-50%, -40%) scale(0.9);
  pointer-events: none;
}

.learn-card {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--panel-shadow);
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.learn-card:hover, .learn-card.active {
  transform: scale(1.08);
  background: rgba(255, 255, 255, 0.35);
  border-color: #fff;
  box-shadow: 0 10px 25px rgba(255, 255, 255, 0.4);
}

.learn-card .card-main-symbol {
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1;
}

.learn-card .card-sub-emoji {
  font-size: 1.8rem;
  margin-top: 4px;
}

.learn-card .card-sub-label {
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 4px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Rainbow Piano Overlay (Mode 5) */
#piano-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 25vh;
  min-height: 180px;
  z-index: 5;
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  padding: 10px;
  gap: 8px;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#piano-container.hidden {
  transform: translateY(120%);
  pointer-events: none;
}

.piano-key {
  flex: 1;
  border-radius: 16px 16px 8px 8px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 15px;
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 15px rgba(0,0,0,0.3), inset 0 -6px 0 rgba(0,0,0,0.2);
  transition: transform 0.1s, filter 0.1s, box-shadow 0.1s;
}

.piano-key:active, .piano-key.active {
  transform: translateY(8px) scale(0.98);
  box-shadow: 0 2px 5px rgba(0,0,0,0.3), inset 0 -2px 0 rgba(0,0,0,0.2);
  filter: brightness(1.3);
}

.piano-key .key-label {
  font-size: 1rem;
  opacity: 0.8;
  margin-top: 4px;
}

/* Peek-a-Boo Grid (Mode 6) */
#peekaboo-container {
  position: absolute;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 900px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 20px;
  z-index: 5;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#peekaboo-container.hidden {
  opacity: 0;
  transform: translate(-50%, -40%) scale(0.9);
  pointer-events: none;
}

.peek-card {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  cursor: pointer;
  box-shadow: var(--panel-shadow);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.peek-card:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 0.25);
}

.peek-card.open {
  animation: cardFlip 0.6s ease forwards;
  background: linear-gradient(135deg, rgba(255,255,255,0.4), rgba(255,255,255,0.1));
}

@keyframes cardFlip {
  0% { transform: scale(1) rotateY(0deg); }
  50% { transform: scale(1.2) rotateY(90deg); }
  100% { transform: scale(1.1) rotateY(0deg); }
}

.peek-card .card-name {
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 8px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Prompt Banner / Toddler Instruction Overlay */
#instruction-prompt {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  padding: 10px 24px;
  border-radius: 30px;
  font-size: 1.2rem;
  font-weight: 600;
  color: #fff;
  pointer-events: none;
  letter-spacing: 0.5px;
  animation: pulsePrompt 2s infinite alternate ease-in-out;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

@keyframes pulsePrompt {
  0% { transform: translateX(-50%) scale(1); opacity: 0.8; }
  100% { transform: translateX(-50%) scale(1.04); opacity: 1; text-shadow: 0 0 10px rgba(255, 255, 255, 0.8); }
}

/* Audio Start Prompt Overlay */
#audio-start-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(15px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#audio-start-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-box {
  text-align: center;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  padding: 40px 50px;
  border-radius: 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.start-box h1 {
  font-size: 3rem;
  margin-bottom: 10px;
  background: linear-gradient(45deg, #ff4081, #ffd700, #00e5ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.start-box p {
  font-size: 1.3rem;
  margin-bottom: 25px;
  color: rgba(255, 255, 255, 0.9);
}

.big-start-btn {
  background: linear-gradient(135deg, #00e676, #00b0ff);
  color: white;
  border: none;
  font-family: var(--font-main);
  font-size: 1.8rem;
  font-weight: 700;
  padding: 16px 45px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(0, 230, 118, 0.5);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: bounceBtn 1.5s infinite;
}

.big-start-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 15px 35px rgba(0, 230, 118, 0.7);
}

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

@media (max-width: 768px) {
  #parent-bar {
    top: 10px;
    padding: 6px 12px;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 25px;
    max-width: 95%;
  }

  .mode-btn, .icon-btn {
    padding: 6px 10px;
    font-size: 0.85rem;
  }

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