/* ═══ Efectos: confeti, carteles y movimiento ═════════════════════════════
   Va detrás de estilo.css y del <style> de cada página. Lo cargan el móvil
   de los niños (index.html) y la tele (pantalla.html); por la tele, aquí no
   se usa inset, color-mix ni aspect-ratio. La parte de sonido y el confeti
   están en efectos.js.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── confeti ─────────────────────────────────────────────────────────── */

.lienzo-confeti {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 90; pointer-events: none;
}

/* ── cartel a pantalla completa (nivel nuevo) ────────────────────────── */

.cartel-efecto {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 85;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 6vmin; background: rgba(4, 7, 11, .86);
  animation: cartel-fondo .25s ease both;
}
.cartel-efecto.fuera { opacity: 0; transition: opacity .4s; }
.cartel-caja { animation: cartel-entra .6s cubic-bezier(.2, 1.5, .4, 1) both; }
.cartel-sello {
  position: relative; width: 38vmin; height: 38vmin; margin: 0 auto; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--ambar); color: var(--sobre-acento);
  box-shadow: 0 0 9vmin rgba(var(--ambar-rgb), .65),
    inset 0 -1.4vmin 0 rgba(0, 0, 0, .16), inset 0 0 0 1.1vmin rgba(255, 255, 255, .28);
}
.cartel-sello b { position: relative; font-family: var(--mono); font-size: 21vmin; line-height: 1; font-weight: 800; }
.cartel-sello i {                    /* dos ondas que salen del sello */
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; box-sizing: border-box;
  border-radius: 50%; border: .9vmin solid var(--ambar); opacity: 0;
  animation: cartel-onda 1.5s ease-out infinite;
}
.cartel-sello i + i { animation-delay: .5s; }
.cartel-titulo {
  margin-top: 6.5vmin; font-family: var(--titulos); font-size: 7vmin; font-weight: 800;
  line-height: 1.1; letter-spacing: .02em; color: var(--ambar);
  text-shadow: 0 0 5vmin rgba(var(--ambar-rgb), .5);
}
.cartel-sub { margin-top: 2.6vmin; font-size: 4.2vmin; line-height: 1.3; color: var(--texto); }
.cartel-efecto.calma, .cartel-efecto.calma .cartel-caja, .cartel-efecto.calma .cartel-sello i { animation: none; }

@keyframes cartel-fondo { from { opacity: 0; } }
@keyframes cartel-entra { from { opacity: 0; transform: scale(.35) rotate(-10deg); } }
@keyframes cartel-onda { from { opacity: .8; transform: scale(1); } to { opacity: 0; transform: scale(1.9); } }

/* ── la fiesta del nivel nuevo (Efectos.fiesta) ──────────────────────── */
/* Sin gap ni grid: la tele puede ser una Chrome 49. Medidas en vmin para
   que valga igual en el móvil en vertical y en la tele. */

.fiesta { background: radial-gradient(circle at 50% 30%, rgba(var(--ambar-rgb), .3), rgba(var(--ambar-rgb), 0) 55%), rgba(4, 7, 11, .96); }
.fiesta-caja { width: 100%; max-width: 900px; }
.fiesta-medalla { position: relative; width: 58vmin; height: 58vmin; margin: 0 auto; }
.fiesta-rayos {
  position: absolute; top: -18%; left: -18%; width: 136%; height: 136%; opacity: .32;
  animation: rayos-gira 14s linear infinite, rayos-entra .8s ease-out both;
}
.rayos-svg { width: 100%; height: 100%; display: block; }
.medalla-gira {
  position: absolute; top: 0; left: 8%; width: 84%; height: 100%;
  animation: medalla-gira 1.7s cubic-bezier(.15, .65, .25, 1) both, medalla-flota 3.2s ease-in-out 1.7s infinite;
}
.medalla-svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 2vmin 3vmin rgba(0, 0, 0, .55)); }
.fiesta-titulo { margin-top: 2.5vmin; animation: titulo-entra .7s cubic-bezier(.2, 1.5, .4, 1) .9s both; }

.fiesta-equipo { display: flex; justify-content: center; flex-wrap: wrap; margin-top: 3vmin; }
.fiesta-uno { margin: 0 2.2vmin 1vmin; animation: uno-entra .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.fiesta-retrato { width: 14vmin; height: 14vmin; margin: 0 auto; animation: retrato-salta .7s ease 3 both; }
.fiesta-retrato svg { width: 100%; height: 100%; display: block; border-radius: 50%; box-shadow: 0 0 0 .6vmin var(--ambar); }
.fiesta-nombre { margin-top: 1.4vmin; font-family: var(--titulos); font-weight: 800; font-size: 4.6vmin; color: var(--texto); white-space: nowrap; }
.fiesta-nombre i { display: inline-block; font-style: normal; animation: letra-salta .55s ease 2 both; }

.fiesta-abre {
  display: inline-block; margin-top: 3vmin; padding: 2vmin 4vmin; border-radius: 3vmin; text-align: left;
  background: rgba(255, 255, 255, .07); border: .3vmin solid rgba(var(--ambar-rgb), .45);
}
.fiesta-abre-titulo { font-family: var(--mono); letter-spacing: .3em; font-size: 2.6vmin; color: var(--ambar); margin-bottom: 1vmin; text-align: center; }
.fiesta-cosa { display: flex; align-items: center; font-size: 4.2vmin; line-height: 1.25; margin: 1vmin 0; animation: cosa-entra .5s ease-out both; }
.candado { position: relative; display: inline-block; width: 6vmin; height: 5vmin; margin-right: 1.5vmin; flex: none; }
.candado i { position: absolute; left: 0; top: 0; font-style: normal; }
.candado .cerrado { animation: candado-fuera .4s ease both; }
.candado .abierto { animation: candado-dentro .5s cubic-bezier(.2, 1.8, .4, 1) both; }
.fiesta-icono { margin-right: 1.5vmin; }
.fiesta-texto { font-weight: 700; color: var(--texto); }

@keyframes rayos-gira { to { transform: rotate(360deg); } }
@keyframes rayos-entra { from { opacity: 0; } }
@keyframes medalla-gira {
  0% { opacity: 0; transform: perspective(900px) translateY(-30vmin) rotateY(-1080deg) scale(.25); }
  15% { opacity: 1; }
  75% { transform: perspective(900px) translateY(0) rotateY(-40deg) scale(1.08); }
  100% { transform: perspective(900px) translateY(0) rotateY(0) scale(1); }
}
@keyframes medalla-flota { 50% { transform: translateY(-1.5vmin) rotate(3deg); } }
@keyframes titulo-entra { from { opacity: 0; transform: scale(.4); } }
@keyframes uno-entra { from { opacity: 0; transform: translateY(8vmin) scale(.5); } }
@keyframes retrato-salta { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-3vmin) rotate(-6deg); } 70% { transform: translateY(0) scale(1.05, .92); } }
@keyframes letra-salta { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-1.8vmin); color: var(--ambar); } }
@keyframes cosa-entra { from { opacity: 0; transform: translateX(-6vmin); } }
@keyframes candado-fuera { to { opacity: 0; transform: scale(1.6) rotate(-20deg); } }
@keyframes candado-dentro { from { opacity: 0; transform: scale(.2); } }

/* en horizontal (la tele) la medalla un poco más pequeña, para que quepa todo */
@media (min-aspect-ratio: 1/1) {
  .fiesta-medalla { width: 36vmin; height: 36vmin; }
  .fiesta-retrato { width: 12vmin; height: 12vmin; }
  .fiesta-titulo { font-size: 6.4vmin; }
}
.fiesta.calma .fiesta-rayos, .fiesta.calma .medalla-gira, .fiesta.calma .fiesta-titulo, .fiesta.calma .fiesta-uno,
.fiesta.calma .fiesta-retrato, .fiesta.calma .fiesta-nombre i, .fiesta.calma .fiesta-cosa { animation: none; }
.fiesta.calma .candado .cerrado { display: none; }
.fiesta.calma .candado .abierto { animation: none; }

/* ── el ambiente del móvil (ambiente.js): detrás de todo, sin tocar nada ── */
.capa-ambiente-movil { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: .75; }
.capa-ambiente-movil .lienzo-ambiente { display: block; width: 100%; height: 100%; }

/* ── gestos comunes ──────────────────────────────────────────────────── */

.salta { animation: salta .6s ease both; }
@keyframes salta { 35% { transform: scale(1.45); } 65% { transform: scale(.94); } }

.sacude { animation: sacude .42s ease both; }
@keyframes sacude {
  15% { transform: translateX(-9px); } 35% { transform: translateX(8px); }
  55% { transform: translateX(-6px); } 75% { transform: translateX(4px); }
}

/* ═══ El móvil de los niños ═══════════════════════════════════════════════ */

/* un resplandor del color de la aventura en lo alto: da fondo a la pantalla */
body[data-titulo="titulo_app"] {
  background-image: radial-gradient(560px 360px at 50% -70px, rgba(var(--ambar-rgb), .16), rgba(var(--ambar-rgb), 0) 70%);
  background-repeat: no-repeat;
}

/* cada pantalla entra de abajo arriba, una pieza detrás de otra */
.envoltorio.entra > * { animation: aparece .34s ease both; }
.envoltorio.entra > *:nth-child(2) { animation-delay: .05s; }
.envoltorio.entra > *:nth-child(3) { animation-delay: .1s; }
.envoltorio.entra > *:nth-child(4) { animation-delay: .15s; }
.envoltorio.entra > *:nth-child(5) { animation-delay: .2s; }
.envoltorio.entra > *:nth-child(6) { animation-delay: .25s; }
.envoltorio.entra > *:nth-child(n+7) { animation-delay: .3s; }
.envoltorio.entra .reto-fila { animation: aparece .34s ease both; }
.envoltorio.entra .reto-fila:nth-child(1) { animation-delay: .18s; }
.envoltorio.entra .reto-fila:nth-child(2) { animation-delay: .23s; }
.envoltorio.entra .reto-fila:nth-child(3) { animation-delay: .28s; }
.envoltorio.entra .reto-fila:nth-child(4) { animation-delay: .33s; }
.envoltorio.entra .reto-fila:nth-child(5) { animation-delay: .38s; }
.envoltorio.entra .reto-fila:nth-child(n+6) { animation-delay: .43s; }

.envoltorio .tarjeta {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, 0) 42%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
}

/* el botón principal brilla y le pasa un reflejo de vez en cuando */
.envoltorio .boton.principal, .fab {
  position: relative; overflow: hidden;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .24), rgba(255, 255, 255, 0) 58%);
  box-shadow: 0 6px 22px rgba(var(--ambar-rgb), .3), inset 0 -3px 0 rgba(0, 0, 0, .15);
}
.fab { position: fixed; box-shadow: 0 10px 28px rgba(0, 0, 0, .5), 0 0 22px rgba(var(--ambar-rgb), .35); }
.envoltorio .boton.principal::after {
  content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%; pointer-events: none;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .4), rgba(255, 255, 255, 0));
  transform: skewX(-18deg); animation: reflejo 3.8s ease-in-out infinite;
}
.envoltorio .boton.principal:disabled { box-shadow: none; }
.envoltorio .boton.principal:disabled::after { display: none; }
@keyframes reflejo { 0%, 62% { left: -60%; } 100% { left: 130%; } }

/* la lista de retos: el que se puede hacer late, el hecho queda en verde */
.reto-fila { transition: transform .1s; }
.reto-fila.abierto:active { transform: scale(.98); }
.reto-fila.abierto { animation: late 2.6s ease-in-out infinite; }
.envoltorio.entra .reto-fila.abierto { animation: aparece .34s ease both, late 2.6s ease-in-out .8s infinite; }
.reto-fila.abierto .icono { color: var(--ambar); animation: empuja 1.3s ease-in-out infinite; }
.reto-fila.hecho { opacity: .78; border-color: rgba(53, 208, 127, .5); background: rgba(53, 208, 127, .07); }
.reto-fila.hecho .icono { color: var(--verde); }
@keyframes late { 50% { box-shadow: 0 0 20px rgba(var(--ambar-rgb), .34); } }
@keyframes empuja { 50% { transform: translateX(4px); } }

/* cuánto llevan de la misión */
.progreso { display: flex; align-items: center; gap: 10px; margin: 16px 0 10px; }
.progreso .etiqueta { white-space: nowrap; }
.progreso .carril { flex: 1; height: 9px; border-radius: 5px; background: var(--panel); border: 1px solid var(--linea); overflow: hidden; }
.progreso .carril i {
  display: block; height: 100%; border-radius: 5px; background: var(--verde);
  box-shadow: 0 0 10px rgba(53, 208, 127, .6); transition: width .8s cubic-bezier(.2, .9, .3, 1);
}
.progreso b { font-family: var(--mono); font-size: 13px; color: var(--verde); }

/* la cabecera: los niveles se encienden con un salto y los puntos brincan */
.nivel .puntos i.recien { animation: enciende .8s ease both; }
@keyframes enciende { 30% { transform: scale(2.2, 1.9); } 60% { transform: scale(.9); } }
.marcador { display: inline-block; }

.aviso.bien { animation: salta-suave .5s ease both; }
@keyframes salta-suave { from { opacity: 0; transform: scale(.8); } 60% { transform: scale(1.05); } }

/* el final: el trofeo cae rebotando y se queda flotando */
.trofeo { display: inline-block; animation: trofeo-cae .9s cubic-bezier(.2, 1.6, .4, 1) both, trofeo-flota 3s ease-in-out .9s infinite; }
.trofeo-halo { position: relative; display: inline-block; }
.trofeo-halo::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 170px; height: 170px; margin: -85px 0 0 -85px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(var(--ambar-rgb), .45), rgba(var(--ambar-rgb), 0) 68%);
  animation: halo 2.4s ease-in-out infinite;
}
@keyframes trofeo-cae { from { opacity: 0; transform: translateY(-70px) scale(.3) rotate(-25deg); } }
@keyframes trofeo-flota { 50% { transform: translateY(-7px) rotate(4deg); } }
@keyframes halo { 50% { transform: scale(1.25); opacity: .6; } }
.cifra-final { text-shadow: 0 0 26px rgba(var(--ambar-rgb), .5); }

/* ═══ La tele ═════════════════════════════════════════════════════════════ */

body[data-titulo="titulo_pantalla"] {
  background-image: radial-gradient(90vw 70vh at 20% -20vh, rgba(var(--ambar-rgb), .13), rgba(var(--ambar-rgb), 0) 70%);
  background-repeat: no-repeat;
}

.fila-sala { transition: border-color .5s, color .5s, opacity .5s; }
.fila-sala.recien { animation: fila-lograda 1.3s ease both; }
@keyframes fila-lograda {
  20% { transform: scale(1.04); background: rgba(53, 208, 127, .3); box-shadow: 0 0 calc(var(--u) * 5) rgba(53, 208, 127, .6); }
}
.fila-sala.actual .marca { animation: empuja 1.3s ease-in-out infinite; }
.niveles i.recien { animation: salta .9s ease both; }
#puntos-sala { display: inline-block; }

#capa-final.vista #icono-final { display: inline-block; animation: trofeo-cae 1s cubic-bezier(.2, 1.6, .4, 1) both, trofeo-flota 3s ease-in-out 1s infinite; }
#capa-final.vista #titulo-final { animation: cartel-entra .7s cubic-bezier(.2, 1.5, .4, 1) .25s both; text-shadow: 0 0 calc(var(--u) * 5) rgba(53, 208, 127, .5); }
#capa-final.vista .podio div { animation: cartel-entra .7s cubic-bezier(.2, 1.5, .4, 1) both; }
#capa-final.vista .podio div:nth-child(1) { animation-delay: .7s; }
#capa-final.vista .podio div:nth-child(2) { animation-delay: .9s; }
#capa-final.vista .podio div:nth-child(3) { animation-delay: 1.1s; }
#capa-final.vista .podio div:nth-child(4) { animation-delay: 1.3s; }
#capa-final.vista .podio div:nth-child(5) { animation-delay: 1.5s; }
#capa-final.vista .podio div:nth-child(6) { animation-delay: 1.7s; }

/* la tele no suena hasta que alguien pulsa algo: se le dice una vez */
.aviso-sonido {
  position: fixed; right: 3vw; bottom: calc(var(--u) * 3); z-index: 60;
  padding: calc(var(--u) * 1.4) calc(var(--u) * 2.6); border-radius: calc(var(--u) * 4);
  border: 2px solid var(--ambar); background: var(--panel); color: var(--ambar);
  font-family: var(--sans); font-size: calc(var(--u) * 2.8); font-weight: 600; cursor: pointer;
}

/* ── quien pide menos movimiento ─────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .envoltorio.entra > *, .envoltorio.entra .reto-fila, .reto-fila.abierto, .reto-fila.abierto .icono,
  .envoltorio .boton.principal::after, .trofeo, .trofeo-halo::before, .fila-sala.actual .marca,
  #capa-final.vista #icono-final, #capa-final.vista #titulo-final, #capa-final.vista .podio div,
  .salta, .sacude, .aviso.bien, .nivel .puntos i.recien, .niveles i.recien, .fila-sala.recien {
    animation: none;
  }
}
