/* ==========================================================================
   Estilos del Entorno de Juego (Motor Gráfico & Ergonomía Infantil)
   ========================================================================== */

#game-screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-primary);
}

/* Barra superior discreta para el niño */
.game-top-bar {
  height: 60px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 20;
}

.game-back-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.game-back-btn svg {
  width: 24px;
  height: 24px;
  fill: var(--text-main);
}

.screen-indicator-pills {
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(255, 255, 255, 0.85);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.screen-pill {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #DCE3E8;
  transition: all 0.3s ease;
}

.screen-pill.done {
  background: var(--color-verde);
}

.screen-pill.active {
  background: var(--color-celeste);
  transform: scale(1.3);
}

/* Área central de juego: Escenario / Lienzo */
.game-stage-wrapper {
  flex: 1;
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 10px 20px;
}

#game-canvas {
  width: 100%;
  height: 100%;
  max-width: 1080px;
  max-height: 560px;
  background-color: #FFFFFF;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  display: block;
  object-fit: contain;
}

/* Bandeja de Figuras (Bottom Drawer / Tray) */
.figures-tray {
  height: 165px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 44px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-top: 2px solid var(--border-subtle);
  padding: 10px 20px;
  z-index: 30;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
}

.tray-item {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 3px solid #E1EFF6;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.tray-item:hover {
  transform: scale(1.05);
}

.tray-item.selected-tap {
  border-color: var(--color-celeste);
  box-shadow: 0 0 0 4px var(--color-celeste-light);
  transform: scale(1.1);
  animation: pulseSoft 1.5s infinite ease-in-out;
}

.tray-item.dragging {
  opacity: 0.2;
  cursor: grabbing;
}

.tray-item img, .tray-item svg {
  max-width: 80%;
  max-height: 80%;
  pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

/* Elemento arrastrado flotante */
.floating-drag-piece {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%) scale(1.15);
  filter: drop-shadow(0 14px 20px rgba(0, 0, 0, 0.25));
  will-change: left, top, transform;
}

.floating-drag-piece img, .floating-drag-piece svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Capa de Celebración & Confeti */
.celebration-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.celebration-star {
  position: absolute;
  animation: starBurst 1.2s ease-out forwards;
}

@keyframes starBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.2) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(1.5) rotate(360deg);
  }
}

/* ==========================================================================
   Minijuego Interactivo: Globos Flotantes al Completar Pantalla (15 Globos)
   ========================================================================== */
#balloon-celebration-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1000;
  overflow: hidden;
}

.interactive-balloon {
  position: absolute;
  bottom: -150px;
  width: 85px;
  height: 115px;
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.15));
  will-change: transform, bottom;
  animation: floatUpSlowly var(--duration) linear forwards, swaySide var(--sway-duration) ease-in-out infinite alternate;
  user-select: none;
  -webkit-user-select: none;
}

.interactive-balloon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.interactive-balloon:active {
  transform: scale(1.15);
}

@keyframes floatUpSlowly {
  0% {
    bottom: -150px;
    opacity: 0.95;
  }
  85% {
    opacity: 0.95;
  }
  100% {
    bottom: 110vh;
    opacity: 0;
  }
}

@keyframes swaySide {
  0% {
    transform: translateX(calc(var(--sway-dist) * -1)) rotate(-6deg);
  }
  100% {
    transform: translateX(var(--sway-dist)) rotate(6deg);
  }
}

/* Animación de explosión (POP!) */
.balloon-pop-particle {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  pointer-events: none;
  animation: popParticleBurst 0.6s ease-out forwards;
}

@keyframes popParticleBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1.3);
  }
  100% {
    opacity: 0;
    transform: translate(var(--p-tx), var(--p-ty)) scale(0.2);
  }
}

/* ==========================================================================
   Ajustes de Juego para Celular Vertical (Portrait)
   ========================================================================== */
@media (max-width: 820px), (orientation: portrait) {
  .game-top-bar {
    height: 52px !important;
    padding: 0 12px !important;
  }

  .game-back-btn {
    width: 40px !important;
    height: 40px !important;
  }

  .game-back-btn svg {
    width: 20px !important;
    height: 20px !important;
  }

  .screen-indicator-pills {
    padding: 6px 12px !important;
    gap: 6px !important;
  }

  .screen-pill {
    width: 9px !important;
    height: 9px !important;
  }

  .game-stage-wrapper {
    padding: 6px 8px !important;
    flex: 1 !important;
    min-height: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  #game-canvas {
    max-width: 100% !important;
    max-height: calc(100vh - 195px) !important;
    border-radius: var(--radius-md) !important;
  }

  /* Bandeja adaptada a ancho móvil */
  .figures-tray {
    height: 125px !important;
    gap: 16px !important;
    padding: 6px 10px !important;
  }

  .tray-item {
    width: 92px !important;
    height: 92px !important;
    border-width: 2px !important;
  }

  .floating-drag-piece {
    width: 105px !important;
    height: 105px !important;
  }

  /* Globos en móvil */
  .interactive-balloon {
    width: 68px !important;
    height: 92px !important;
  }
}


