/* ============================================================
   Viaje a un nuevo mundo — estilos
   Stack: CSS vanilla + tokens (custom properties) + BEM
   Estética: bebé, dibujado con plastidecor, pastel, muy cuqui
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* Paleta pastel */
  --rosa:        #ffb3d1;
  --rosa-suave:  #ffd9e8;
  --azul:        #a9d6ff;
  --azul-suave:  #d4ecff;
  --amarillo:    #ffe9a8;
  --crema:       #fff6e3;
  /* Espacio */
  --noche:       #1b1640;
  --noche-claro: #2a2456;
  /* Texto */
  --texto-claro:  #fff8ee;
  --texto-oscuro: #3a2d5a;

  /* Tipografía */
  --font-display: "Baloo 2", "Segoe UI", system-ui, sans-serif;
  --fs-titulo:    clamp(2rem, 7vw, 3.5rem);
  --fs-sub:       clamp(1.2rem, 4vw, 1.8rem);
  --fs-base:      clamp(1rem, 3.2vw, 1.25rem);

  /* Espaciado / radios */
  --radio:        1.5rem;
  --radio-sm:     0.9rem;
  --sombra-suave: 0 8px 24px rgba(0,0,0,0.25);

  /* Easing bounce (overshoot) */
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-bounce: 0.6s;
  --dur-rapida: 0.25s;
}

/* ---------- Reset mínimo ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-display);
  color: var(--texto-claro);
  background-color: var(--noche);
  /* Fondo estrellado en mosaico + tinte noche suave */
  background-image:
    linear-gradient(180deg, rgba(27,22,64,0.45), rgba(27,22,64,0.15)),
    url("../assets/fondo-estrellas.jpg");
  background-size: cover, clamp(320px, 90vw, 600px) clamp(320px, 90vw, 600px);
  background-repeat: no-repeat, repeat;
  background-attachment: fixed, fixed;
  text-align: center;
  user-select: none;
  overflow: hidden;
}

img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ---------- Pantallas (se muestran/ocultan) ---------- */
.pantalla {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: clamp(1rem, 5vw, 2.5rem);
  z-index: 1;
}
.pantalla[hidden] { display: none !important; }
.pantalla--activa { display: flex; }

/* ---------- Icono secreto papás ---------- */
.icono-papas {
  position: fixed;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 50;
  color: var(--texto-claro);
  opacity: 0.15;
  padding: 0.35rem;
  border-radius: 50%;
  transition: opacity var(--dur-rapida) ease, background var(--dur-rapida) ease;
}
.icono-papas:hover, .icono-papas:focus-visible {
  opacity: 0.55;
  background: rgba(255,255,255,0.08);
  outline: none;
}

/* ---------- Tipografía común ---------- */
.titulo {
  font-size: var(--fs-titulo);
  font-weight: 800;
  line-height: 1.05;
  text-shadow: 0 2px 0 rgba(0,0,0,0.15), 0 6px 18px rgba(0,0,0,0.35);
}
.subtitulo {
  font-size: var(--fs-sub);
  font-weight: 500;
  margin-top: 0.4rem;
  opacity: 0.92;
}

/* ---------- Pantalla 0: Puerta de papás ---------- */
#pantalla-papas { background: linear-gradient(180deg, rgba(27,22,64,0.7), rgba(27,22,64,0.55)); }
.papas-contenedor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  max-width: 28rem;
  width: 100%;
}
.titulo--papas { font-size: clamp(1.6rem, 6vw, 2.4rem); }
.papas-subtitulo { font-size: var(--fs-base); opacity: 0.85; }
.input-codigo {
  width: 100%;
  max-width: 16rem;
  padding: 0.85rem 1rem;
  font-size: 1.1rem;
  font-family: inherit;
  color: var(--texto-oscuro);
  background: var(--crema);
  border: 3px solid var(--azul);
  border-radius: var(--radio-sm);
  text-align: center;
  letter-spacing: 0.08em;
}
.input-codigo:focus { outline: 3px solid var(--rosa); border-color: var(--rosa); }
.papas-error {
  color: #ffd6e0;
  font-weight: 700;
  background: rgba(180, 40, 70, 0.35);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radio-sm);
}
.papas-ayuda { font-size: 0.95rem; opacity: 0.75; margin-top: 0.5rem; }

/* ---------- Botones ---------- */
.boton {
  font-family: inherit;
  font-weight: 700;
  font-size: var(--fs-base);
  padding: 0.8rem 1.6rem;
  border-radius: var(--radio);
  background: var(--crema);
  color: var(--texto-oscuro);
  box-shadow: var(--sombra-suave);
  transition: transform var(--dur-rapida) var(--bounce), filter var(--dur-rapida) ease;
}
.boton:active { transform: scale(0.94); }
.boton--chico { background: var(--azul); color: var(--texto-oscuro); }
.boton--chica { background: var(--rosa); color: var(--texto-oscuro); }
.boton--secundario { background: transparent; color: var(--texto-claro); border: 2px solid rgba(255,255,255,0.4); box-shadow: none; }
.boton--repetir { margin-top: 1.5rem; font-size: 1rem; padding: 0.6rem 1.3rem; }

/* ---------- Pantalla 1: Inicio ---------- */
.inicio-contenedor { display: flex; flex-direction: column; align-items: center; }
.naves {
  display: flex;
  gap: clamp(0.8rem, 4vw, 2rem);
  margin-top: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}
.nave {
  width: clamp(7rem, 30vw, 11rem);
  background: rgba(255,255,255,0.06);
  border: 3px solid transparent;
  border-radius: var(--radio);
  padding: 0.6rem;
  transition: transform var(--dur-rapida) var(--bounce), border-color var(--dur-rapida) ease, background var(--dur-rapida) ease;
}
.nave:hover, .nave:focus-visible { transform: scale(1.08); }
.nave:active { transform: scale(0.96); }
.nave--rosa { border-color: var(--rosa); }
.nave--azul { border-color: var(--azul); }
.nave--rosa:hover { background: rgba(255,179,209,0.18); }
.nave--azul:hover { background: rgba(169,214,255,0.18); }
/* Animación bounce al tocar/elegir */
.nave--elegida { animation: bounce-salto var(--dur-bounce) var(--bounce); }
@keyframes bounce-salto {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.22); }
  70%  { transform: scale(0.94); }
  100% { transform: scale(1); }
}

/* ---------- Pantalla 2: Juego ---------- */
#pantalla-juego { padding: 0; background: var(--noche); }
#canvas-juego {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.barra-progreso {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: clamp(0.7rem, 2.5vw, 1rem);
  background: rgba(255,255,255,0.15);
  z-index: 10;
  border-bottom: 2px solid rgba(255,255,255,0.25);
}
.barra-progreso__relleno {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--azul), var(--rosa), var(--amarillo));
  transition: width 0.1s linear;
  border-radius: 0 0.5rem 0.5rem 0;
}
.barra-progreso__texto {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 800;
  font-size: 0.9rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.aviso-asteroides {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  font-weight: 800;
  color: var(--texto-claro);
  background: rgba(0,0,0,0.35);
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.aviso-asteroides--oculto { opacity: 0; }

/* ---------- Pantalla 3: Final ---------- */
.final-contenedor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: fade-in 0.4s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.final-planeta {
  width: clamp(11rem, 42vw, 18rem);
  height: auto;
  animation: planeta-bounce 0.8s var(--bounce) both;
}
@keyframes planeta-bounce {
  0%   { transform: scale(0.2); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}
.titulo--final {
  animation: rotulo-bounce 0.7s var(--bounce) both;
  animation-delay: 0.25s;
  padding: 0 1rem;
}
@keyframes rotulo-bounce {
  0%   { transform: scale(0.4) translateY(20px); opacity: 0; }
  60%  { transform: scale(1.1) translateY(0); opacity: 1; }
  100% { transform: scale(1) translateY(0); }
}
/* Variantes de color por sexo definidas por JS vía atributo */
#pantalla-final[data-sexo="chica"] .titulo--final { color: var(--rosa-suave); }
#pantalla-final[data-sexo="chico"] .titulo--final { color: var(--azul-suave); }

/* ---------- Overlay papás (cambio/reset) ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(10,8,30,0.75);
  backdrop-filter: blur(4px);
  animation: fade-in 0.25s ease;
}
.overlay[hidden] { display: none; }
.overlay__card {
  background: var(--noche-claro);
  border: 3px solid var(--azul);
  border-radius: var(--radio);
  padding: clamp(1.2rem, 5vw, 2rem);
  max-width: 26rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: var(--sombra-suave);
  text-align: left;
}
.overlay__titulo { font-size: clamp(1.4rem, 5vw, 1.9rem); text-align: center; }
.overlay__texto { font-size: var(--fs-base); opacity: 0.9; line-height: 1.4; }
.overlay__botones { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.overlay__botones .boton { flex: 1; min-width: 6rem; }
.overlay__eleccion { display: flex; flex-direction: column; gap: 0.6rem; border-top: 1px solid rgba(255,255,255,0.15); padding-top: 0.9rem; }
.overlay__selector { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.overlay__selector .boton { flex: 1; min-width: 5rem; padding: 0.6rem 0.8rem; font-size: 0.95rem; }

/* ---------- Accesibilidad: respeta reduce motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}