/* Lectura Divertida — estilos
 * Principios: paleta pastel limitada, fondo liso, objetivos táctiles grandes (≥ 72 px),
 * animaciones cortas y con propósito. Ver .claude/skills/ux-infantil/SKILL.md */

:root {
  --fondo: #FFF8EC;
  --superficie: #FFFFFF;
  --tinta: #3B3355;
  --tinta-suave: #7A7290;
  --lila: #C3B1FF;
  --lila-fuerte: #7B6CF6;
  --sol: #FFD166;
  --rosa: #FF9EBB;
  --menta: #7ED6C1;
  --cielo: #8EC5FF;
  --durazno: #FFB38A;
  --sombra: 0 6px 0 rgba(59, 51, 85, .12), 0 10px 24px rgba(59, 51, 85, .08);
  --radio: 28px;
  --letra: 'Andika', 'Comic Sans MS', 'Trebuchet MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--fondo);
  color: var(--tinta);
  font-family: var(--letra);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body { display: flex; flex-direction: column; overflow: hidden; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible { outline: 4px solid var(--lila-fuerte); outline-offset: 4px; }

/* ---------- Barra superior ---------- */
.barra {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 6px;
}
.btn-barra {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--superficie);
  box-shadow: var(--sombra);
  font-size: 30px;
  flex: none;
}
body[data-pantalla="inicio"] #btn-inicio { visibility: hidden; }
#btn-ajustes { font-size: 24px; width: 52px; height: 52px; opacity: .6; position: relative; }
#btn-ajustes.cargando { opacity: 1; animation: cargar 2s linear forwards; }
@keyframes cargar { to { transform: rotate(360deg); } }

.mascota { flex: none; margin-left: 4px; transform-origin: 50% 80%; }
.mascota.feliz { animation: saltito .6s ease-out; }
.mascota.pensando { animation: ladeo .7s ease-in-out; }
.mascota.hablando .boca { animation: hablar .3s ease-in-out infinite alternate; transform-origin: 50px 62px; }
@keyframes saltito {
  0%, 100% { transform: none; }
  35% { transform: translateY(-14px) rotate(-8deg); }
  65% { transform: translateY(0) scale(1.08, .92); }
}
@keyframes ladeo { 0%, 100% { transform: none; } 40% { transform: rotate(-14deg); } 70% { transform: rotate(8deg); } }
@keyframes hablar { to { transform: scaleY(1.6); } }

.estrellas {
  margin-left: auto;
  font-size: 28px;
  font-weight: 700;
  background: var(--superficie);
  padding: 8px 18px;
  border-radius: 999px;
  box-shadow: var(--sombra);
}

#pantalla { flex: 1; display: flex; min-height: 0; }
#pantalla > section { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 16px 20px; min-height: 0; }

/* ---------- Portada ---------- */
.portada {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  background: var(--fondo);
}
.portada-estrella { font-size: 110px; animation: flotar 3s ease-in-out infinite; }
.portada-titulo { font-size: clamp(36px, 7vw, 64px); font-weight: 700; }
.portada-jugar {
  width: 120px; height: 120px; border-radius: 50%;
  background: var(--lila-fuerte); color: white; font-size: 52px;
  display: grid; place-items: center; padding-left: 10px;
  box-shadow: 0 8px 0 #5a4fd1;
}
@keyframes flotar { 50% { transform: translateY(-12px); } }

/* ---------- Tarjetas grandes ---------- */
.titulo { font-size: clamp(32px, 6vw, 56px); margin: 8px 0 24px; text-align: center; }
.subtitulo { font-size: clamp(30px, 5vw, 46px); margin: 4px 0 16px; }
.tarjetas {
  display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; align-items: stretch;
  width: 100%; max-width: 900px;
}
.tarjeta {
  flex: 1 1 260px; max-width: 400px; min-height: 200px;
  border-radius: var(--radio);
  background: var(--superficie);
  box-shadow: var(--sombra);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 24px;
  transition: transform .15s;
}
.tarjeta:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(59, 51, 85, .12); }
.tarjeta .muestra { font-size: clamp(44px, 8vw, 72px); font-weight: 700; letter-spacing: .06em; }
.tarjeta .nombre { font-size: 30px; font-weight: 700; }
.tarjeta .icono { font-size: 64px; }
.tarjeta-vocales { background: #FFF1C7; }
.tarjeta-silabas { background: #E6F7F2; }
.tarjeta-modo:nth-child(1) { background: #EEE9FF; }
.tarjeta-modo:nth-child(2) { background: #FFE9F0; }

.familias { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 22px; }
.familia {
  min-height: 64px; padding: 10px 20px;
  border-radius: 999px;
  background: var(--superficie);
  font-size: 26px; font-weight: 700;
  box-shadow: var(--sombra);
  border: 4px solid transparent;
}
.familia.activa { background: var(--color); border-color: var(--tinta); }

/* ---------- Juego ---------- */
.niveles { display: flex; gap: 12px; margin-bottom: 10px; }
.nivel {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--superficie); box-shadow: var(--sombra);
  font-size: 24px; font-weight: 700;
}
.nivel.activo { background: var(--lila-fuerte); color: white; }
.area-juego { flex: 1; width: 100%; max-width: 1000px; display: flex; min-height: 0; }

/* Arrastra y junta */
.emp { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 20px; touch-action: none; }
.emp-destinos, .emp-bandeja {
  display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(10px, 2.5vw, 24px);
}
.destino, .ficha {
  width: clamp(76px, 15vw, 132px); height: clamp(76px, 15vw, 132px);
  border-radius: 26px;
  display: grid; place-items: center;
  position: relative;
}
.destino {
  border: 5px dashed var(--lila);
  background: rgba(255, 255, 255, .6);
  transition: transform .15s, background .15s, border-color .15s;
}
.destino .texto { color: var(--tinta-suave); }
.destino.encima { transform: scale(1.08); background: #F3EFFF; border-color: var(--lila-fuerte); }
.destino.completo { border-style: solid; border-color: var(--menta); background: #E6F7F2; }
.destino.completo .texto { color: var(--tinta); }
.destino.pista { animation: brillo 1.4s ease-in-out infinite; }
.destino .etiqueta {
  position: absolute; bottom: -18px;
  background: var(--menta); color: var(--tinta);
  font-size: 22px; font-weight: 700; padding: 0 12px; border-radius: 999px;
}
.ficha {
  background: var(--sol);
  box-shadow: 0 6px 0 #E8B23F, 0 10px 18px rgba(59, 51, 85, .12);
  touch-action: none;
  z-index: 1;
}
.ficha:nth-child(5n+2) { background: var(--rosa); box-shadow: 0 6px 0 #E57E9E, 0 10px 18px rgba(59, 51, 85, .12); }
.ficha:nth-child(5n+3) { background: var(--cielo); box-shadow: 0 6px 0 #6AA6E6, 0 10px 18px rgba(59, 51, 85, .12); }
.ficha:nth-child(5n+4) { background: var(--menta); box-shadow: 0 6px 0 #57B8A1, 0 10px 18px rgba(59, 51, 85, .12); }
.ficha:nth-child(5n+5) { background: var(--durazno); box-shadow: 0 6px 0 #E8936A, 0 10px 18px rgba(59, 51, 85, .12); }
.ficha.arrastrando { z-index: 10; cursor: grabbing; transition: none; filter: drop-shadow(0 12px 10px rgba(59, 51, 85, .2)); }
.ficha.usada { visibility: hidden; }
.texto { font-size: clamp(40px, 8vw, 72px); font-weight: 700; line-height: 1; }
.dibujo { font-size: clamp(44px, 9vw, 80px); line-height: 1; }

@keyframes brillo {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 209, 102, 0); }
  50% { box-shadow: 0 0 0 12px rgba(255, 209, 102, .6); }
}

/* Encuentra y encierra */
.cir { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative; }
.cir-progreso { display: flex; gap: 10px; }
.cir-progreso .punto { width: 16px; height: 16px; border-radius: 50%; background: #E7E1F5; }
.cir-progreso .punto.actual { background: var(--lila); transform: scale(1.25); }
.cir-progreso .punto.hecho { background: var(--menta); }
.cir-tablero {
  flex: 1; width: 100%;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
  gap: clamp(36px, 7vw, 72px);
  padding: 24px;
  touch-action: none;
  border-radius: var(--radio);
}
.opcion {
  width: clamp(96px, 17vw, 150px); height: clamp(96px, 17vw, 150px);
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--superficie);
  box-shadow: var(--sombra);
  transform: translateY(var(--dy)) rotate(var(--giro));
  position: relative;
  pointer-events: none; /* el tablero recibe el trazo */
}
.opcion::after {
  content: ''; position: absolute; inset: -14px; border-radius: 50%;
  border: 6px solid transparent;
}
.opcion.correcta { background: #E6F7F2; }
.opcion.correcta::after { border-color: var(--menta); animation: aparecer .4s ease-out; }
.opcion.incorrecta { animation: nego .5s ease-in-out; }
.opcion.pista { animation: brillo 1.4s ease-in-out infinite; }
@keyframes aparecer { from { transform: scale(.6); opacity: 0; } }
@keyframes nego {
  0%, 100% { transform: translateY(var(--dy)) rotate(var(--giro)); }
  25% { transform: translateY(var(--dy)) translateX(-8px) rotate(var(--giro)); }
  75% { transform: translateY(var(--dy)) translateX(8px) rotate(var(--giro)); }
}
.btn-escuchar {
  position: absolute; right: 0; bottom: 0;
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--sol); box-shadow: 0 6px 0 #E8B23F;
  font-size: 32px;
}

/* ---------- Celebración ---------- */
.celebracion {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(255, 248, 236, .85);
  animation: entrar .3s ease-out;
}
.celebracion-caja {
  background: var(--superficie); border-radius: 36px; box-shadow: var(--sombra);
  padding: 28px 36px; text-align: center; max-width: calc(100vw - 32px);
}
.estrella-grande { font-size: 110px; animation: saltito 1s ease-out; }
.celebracion-texto { font-size: 40px; font-weight: 700; margin: 6px 0 20px; }
.celebracion-botones { display: flex; gap: 18px; justify-content: center; }
.btn-redondo {
  width: 84px; height: 84px; border-radius: 50%;
  background: #F3EFFF; font-size: 36px; box-shadow: var(--sombra);
}
.btn-redondo.principal { background: var(--lila-fuerte); width: 100px; height: 100px; font-size: 44px; }
@keyframes entrar { from { opacity: 0; } }

/* ---------- Premio al acertar: el dibujo "cobra vida" ---------- */
.premio {
  position: fixed; z-index: 26; pointer-events: none;
  width: 0; height: 0;
  animation: premio-vida 1.6s ease-out forwards;
}
.premio-halo {
  position: absolute; left: -75px; top: -75px; width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 209, 102, .55) 0%, rgba(255, 209, 102, 0) 70%);
}
.premio-dibujo {
  position: absolute; left: -60px; top: -60px; width: 120px; height: 120px;
  display: grid; place-items: center; font-size: 92px; line-height: 1;
  filter: drop-shadow(0 6px 6px rgba(59, 51, 85, .18));
}
@keyframes premio-vida {
  0% { transform: scale(.2); opacity: 0; }
  15% { transform: scale(1.1); opacity: 1; }
  25%, 80% { transform: scale(1); opacity: 1; }
  100% { transform: scale(.85) translateY(-20px); opacity: 0; }
}

/* Bailes (≈ 1 s, sin parpadeos). El nombre viene de `baile` en js/datos.js */
.baile-saltar { animation: b-saltar .5s ease-in-out .2s 2; }
.baile-volar { animation: b-volar 1.1s ease-in-out .2s; }
.baile-balancear { animation: b-balancear .55s ease-in-out .2s 2; transform-origin: 50% 90%; }
.baile-girar { animation: b-girar .9s ease-in-out .2s; }
.baile-latir { animation: b-latir .45s ease-in-out .2s 2; }
.baile-rodar { animation: b-rodar 1s ease-in-out .2s; }
.baile-vibrar { animation: b-vibrar .1s linear .2s 8; }
.baile-rebotar { animation: b-rebotar .5s cubic-bezier(.3, .7, .4, 1) .2s 2; transform-origin: 50% 100%; }
.baile-saludar { animation: b-saludar .4s ease-in-out .2s 3; transform-origin: 70% 90%; }
@keyframes b-saltar { 50% { transform: translateY(-34px); } }
@keyframes b-volar {
  25% { transform: translate(-26px, -22px) rotate(-12deg); }
  50% { transform: translate(0, -34px); }
  75% { transform: translate(26px, -22px) rotate(12deg); }
}
@keyframes b-balancear { 25% { transform: rotate(-14deg); } 75% { transform: rotate(14deg); } }
@keyframes b-girar { to { transform: rotate(360deg); } }
@keyframes b-latir { 50% { transform: scale(1.22); } }
@keyframes b-rodar { 40% { transform: translateX(-24px) rotate(-90deg); } 80% { transform: translateX(16px) rotate(30deg); } }
@keyframes b-vibrar { 25% { transform: translateX(-3px) rotate(-3deg); } 75% { transform: translateX(3px) rotate(3deg); } }
@keyframes b-rebotar { 30% { transform: scale(1.15, .8); } 60% { transform: translateY(-26px) scale(.92, 1.1); } }
@keyframes b-saludar { 50% { transform: rotate(-22deg); } }

/* ---------- Álbum de calcomanías ---------- */
.btn-album {
  margin-top: 26px; min-height: 72px; padding: 12px 28px;
  border-radius: 999px; background: var(--superficie); box-shadow: var(--sombra);
  font-size: 26px; font-weight: 700; display: flex; align-items: center; gap: 12px;
}
.album-cuenta { font-size: 18px; background: #F3EFFF; border-radius: 999px; padding: 4px 12px; }
.album-paginas { width: 100%; max-width: 900px; overflow-y: auto; padding-bottom: 20px; }
.album-grupo h3 { margin: 10px 0 8px; font-size: 22px; color: var(--tinta-suave); letter-spacing: .08em; }
.album-fila { display: flex; flex-wrap: wrap; gap: 14px; }
.calcomania {
  width: clamp(80px, 16vw, 116px); height: clamp(80px, 16vw, 116px);
  border-radius: 24px; background: var(--superficie); box-shadow: var(--sombra);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 4px solid #FFF1C7;
}
.calcomania .dibujo { font-size: clamp(36px, 7vw, 54px); }
.calcomania .etiqueta { font-size: 20px; font-weight: 700; }
.calcomania.vacia { background: #F1ECE2; border: 4px dashed #E2D9C8; box-shadow: none; color: #CFC5B3; font-size: 36px; font-weight: 700; }
.calcomania-nueva {
  display: inline-flex; flex-direction: column; align-items: center;
  background: #FFF1C7; border-radius: 28px; padding: 14px 26px;
  transform: rotate(-4deg); animation: aparecer .5s ease-out;
}
.calcomania-nueva .dibujo { font-size: 96px; display: inline-block; }
.calcomania-nueva .etiqueta { font-size: 30px; font-weight: 700; }

/* ---------- Ajustes ---------- */
.ajustes {
  border: 0; border-radius: 24px; padding: 24px; width: min(460px, calc(100vw - 32px));
  color: var(--tinta); font-family: var(--letra); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  user-select: text;
}
.ajustes::backdrop { background: rgba(59, 51, 85, .4); }
.ajustes h2 { margin-top: 0; }
.ajustes label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 18px; }
.ajustes label.fila { flex-direction: row; align-items: center; gap: 10px; }
.ajustes select { font: inherit; padding: 8px; border-radius: 10px; border: 2px solid #E7E1F5; }
.ajustes input[type="checkbox"] { width: 24px; height: 24px; }
.ajustes-botones { display: flex; flex-wrap: wrap; gap: 10px; }
.ajustes-botones button { padding: 10px 16px; border-radius: 12px; background: #F3EFFF; font-size: 17px; }
.ajustes-botones .principal { background: var(--lila-fuerte); color: white; margin-left: auto; }
.nota { font-size: 14px; color: var(--tinta-suave); margin-bottom: 0; }

/* Lienzo de efectos encima de todo, sin capturar toques */
#lienzo-estela { position: fixed; inset: 0; pointer-events: none; z-index: 25; }

/* ---------- Pantallas pequeñas / horizontal baja ---------- */
@media (max-height: 520px) {
  .btn-barra { width: 52px; height: 52px; font-size: 24px; }
  .mascota svg { width: 48px; height: 48px; }
  .titulo { margin-bottom: 12px; }
  .tarjeta { min-height: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
