:root {
  --cielo-1: #7cc8f2;
  --cielo-2: #d4f0ff;
  --texto: #1e3a5f;
  --rojo: #e63946;
  --azul: #2563eb;
  --amarillo: #fbbf24;
  --verde: #22c55e;
  --pasto: #4caf50;
  --whatsapp: #25d366;
}

* { box-sizing: border-box; margin: 0; }

body {
  font-family: "Nunito", system-ui, sans-serif;
  font-weight: 500;
  color: var(--texto);
  text-align: center;
  line-height: 1.5;
  background: linear-gradient(var(--cielo-1), var(--cielo-2) 60vh, #eaf8e6 100vh);
  background-attachment: fixed;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: "Fredoka", sans-serif; font-weight: 700; }

.oculto { display: none !important; }

.estado {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: 1.25rem;
}
.emoji { font-size: 3rem; }

.spinner {
  width: 46px; height: 46px;
  border: 5px solid #fff;
  border-top-color: var(--rojo);
  border-radius: 50%;
  animation: girar 1s linear infinite;
}

/* Nubes */
.nubes { position: fixed; inset: 0; pointer-events: none; z-index: -1; }
.nube {
  position: absolute;
  width: 90px; height: 30px;
  background: #fff;
  border-radius: 30px;
  opacity: .9;
  animation: flotar linear infinite;
}
.nube::before, .nube::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}
.nube::before { width: 44px; height: 44px; top: -22px; left: 12px; }
.nube::after { width: 34px; height: 34px; top: -14px; left: 44px; }
.n1 { top: 8%; animation-duration: 38s; }
.n2 { top: 22%; transform: scale(.7); animation-duration: 52s; animation-delay: -20s; }
.n3 { top: 40%; transform: scale(1.2); animation-duration: 64s; animation-delay: -40s; }

/* Portada */
.portada {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2.5rem 1.25rem 220px;
  position: relative;
  overflow: hidden;
  background:
    repeating-conic-gradient(from 0deg at 50% 38%, rgba(255, 255, 255, .16) 0 9deg, transparent 9deg 18deg),
    radial-gradient(circle at 50% 38%, #f0fbff 0, #7dd3fc 35%, #38bdf8 75%);
}
.tipo {
  font-family: "Fredoka", sans-serif;
  font-size: 1.2rem;
  color: #fff;
  background: var(--rojo);
  padding: .4rem 1.2rem;
  border-radius: 999px;
  box-shadow: 0 4px 0 #b91c2c;
  animation: rebote 1s ease both;
}
.portada h1 {
  font-size: clamp(2.8rem, 13vw, 4rem);
  line-height: 1.05;
  margin: 1rem 0 .5rem;
  color: var(--azul);
  -webkit-text-stroke: 2px #fff;
  paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(30, 58, 95, .2);
  animation: rebote 1s .15s ease both;
}
.foto-marco {
  position: relative;
  width: 210px; height: 210px;
  margin-top: .5rem;
  animation: rebote 1s .3s ease both;
}
.foto-marco img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 57% 36%;
  border-radius: 50%;
  border: 7px solid #fff;
  box-shadow: 0 0 0 7px var(--rojo), 0 0 0 14px var(--amarillo), 0 0 0 21px var(--azul), 0 16px 30px rgba(0, 0, 0, .25);
  animation: flotarFoto 4s 1.3s ease-in-out infinite;
}
.edad {
  position: absolute;
  right: -22px; bottom: -14px;
  width: 92px; height: 92px;
  border-radius: 50%;
  background: var(--amarillo);
  border: 5px solid #fff;
  box-shadow: 0 6px 0 #d99a0b, 0 10px 20px rgba(0, 0, 0, .2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--rojo);
  animation: balanceo 3s 1.3s ease-in-out infinite;
}
.edad span { font-family: "Fredoka", sans-serif; font-size: 3rem; font-weight: 700; line-height: 1; }
.edad small { font-family: "Fredoka", sans-serif; font-size: .8rem; margin-top: -.15rem; }
.frase { font-size: 1.15rem; font-weight: 700; max-width: 360px; margin-top: 2.25rem; animation: rebote 1s .45s ease both; }

/* Las animaciones de la portada esperan a que se abra la invitación */
body:not(.abierta) .portada,
body:not(.abierta) .portada * { animation-play-state: paused; }
body.bloqueado { overflow: hidden; }

/* Pantalla de bienvenida */
.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 2.5rem 1.25rem calc(2rem + env(safe-area-inset-bottom));
  overflow: hidden;
  background:
    repeating-conic-gradient(from 0deg at 50% 45%, rgba(255, 255, 255, .16) 0 9deg, transparent 9deg 18deg),
    radial-gradient(circle at 50% 45%, #f0fbff 0, #7dd3fc 35%, #38bdf8 75%);
  transition: opacity .8s ease .2s;
}
.intro.saliendo { opacity: 0; pointer-events: none; }
.intro-texto { position: relative; z-index: 2; animation: rebote 1s ease both; }
.intro-chip {
  display: inline-block;
  font-family: "Fredoka", sans-serif;
  color: #fff;
  background: var(--rojo);
  padding: .4rem 1.1rem;
  border-radius: 999px;
  box-shadow: 0 4px 0 #b91c2c;
}
.intro-texto h2 {
  font-size: 2.1rem;
  margin-top: .75rem;
  color: var(--azul);
  -webkit-text-stroke: 1.5px #fff;
  paint-order: stroke fill;
}

.intro-escena {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.via-perspectiva {
  position: absolute;
  bottom: -2.5rem;
  left: 50%;
  width: 150%;
  height: 45%;
  transform: translateX(-50%);
  clip-path: polygon(40% 0, 60% 0, 100% 100%, 0 100%);
  background:
    linear-gradient(90deg, transparent 47%, #6b7280 47% 49%, transparent 49% 51%, #6b7280 51% 53%, transparent 53%),
    repeating-linear-gradient(0deg, #8d5a3b 0 10px, #4caf50 10px 26px);
}
.bob {
  position: relative;
  width: min(68vw, 290px);
  margin-bottom: 2rem;
  transform-origin: 50% 100%;
  animation: llegar 2.2s cubic-bezier(.2, .8, .3, 1) both, traqueteo .35s 2.2s ease-in-out infinite alternate;
}
.bob svg { display: block; width: 100%; height: auto; }
.bob .ojos { transform-box: fill-box; transform-origin: center; animation: parpadeo 4s 2.5s infinite; }
.intro.saliendo .bob { animation: acercarse .9s ease-in forwards; }

.letras-cayendo { position: absolute; inset: 0; pointer-events: none; }
.letras-cayendo span {
  position: absolute;
  top: -15%;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  -webkit-text-stroke: 2px #fff;
  paint-order: stroke fill;
  text-shadow: 3px 3px 0 rgba(30, 58, 95, .35);
  animation: caer linear infinite;
}

.btn-abrir {
  position: relative;
  z-index: 2;
  border: 0;
  cursor: pointer;
  width: 100%;
  max-width: 340px;
  padding: 1.1rem;
  border-radius: 999px;
  background: var(--rojo);
  color: #fff;
  font-family: "Fredoka", sans-serif;
  font-size: 1.4rem;
  box-shadow: 0 6px 0 #b91c2c, 0 12px 24px rgba(0, 0, 0, .2);
  animation: latido 1.6s 2.2s ease-in-out infinite;
}
.btn-abrir:active { transform: translateY(4px); box-shadow: 0 2px 0 #b91c2c; }
.intro { cursor: pointer; }
.intro-pista {
  position: relative;
  z-index: 2;
  font-family: "Fredoka", sans-serif;
  font-size: 1.3rem;
  color: #fff;
  -webkit-text-stroke: 1px var(--azul);
  paint-order: stroke fill;
  text-shadow: 0 3px 0 rgba(30, 58, 95, .35);
  margin-bottom: .4rem;
  animation: saltito 1s 2.2s ease-in-out infinite both;
}

/* Desfile: Bob pasa y las letras suben a los vagones */
.desfile {
  position: fixed;
  inset: 0;
  z-index: 55;
  overflow: hidden;
  background: linear-gradient(var(--cielo-1), var(--cielo-2) 75%);
  transition: opacity .7s ease;
}
.desfile.saliendo { opacity: 0; pointer-events: none; }
.desfile .paisaje { height: 230px; }
.globo-dialogo {
  position: absolute;
  top: calc(16% + env(safe-area-inset-top));
  left: 0;
  right: 0;
  width: min(86vw, 380px);
  margin: 0 auto;
  padding: 1rem 1.25rem;
  border-radius: 26px;
  background: #fff;
  color: var(--azul);
  font-family: "Fredoka", sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.25;
  box-shadow: 0 8px 0 rgba(30, 58, 95, .15), 0 14px 30px rgba(0, 0, 0, .15);
  animation: rebote .8s ease both;
}
.globo-dialogo::after {
  content: "";
  position: absolute;
  bottom: -18px;
  left: 30%;
  border: 12px solid transparent;
  border-top: 14px solid #fff;
}
.desfile-tren { position: absolute; left: 0; bottom: 44px; will-change: transform; }
.desfile-tren svg { display: block; height: 170px; width: auto; overflow: visible; }
.anden {
  position: absolute;
  bottom: 0;
  left: calc(50% - 22px);
  display: flex;
  gap: 4px;
  transition: transform .35s ease;
}
.anden span {
  width: 44px;
  font-family: "Fredoka", sans-serif;
  font-size: 2.3rem;
  font-weight: 700;
  line-height: 1.1;
  -webkit-text-stroke: 2px #fff;
  paint-order: stroke fill;
  animation: saltito .7s ease-in-out infinite;
  transition: opacity .15s;
}
.anden span.salto { opacity: 0; }
.desfile .carga { opacity: 0; transform-box: fill-box; transform-origin: 50% 100%; }
.desfile .carga.subio { opacity: 1; animation: aVagon .65s cubic-bezier(.3, .7, .4, 1) both; }
.desfile .foto-diego.subio { transform-origin: 50% 70%; animation: aparecer .8s cubic-bezier(.3, 1.6, .5, 1) both; }
.btn-saltar {
  position: absolute;
  top: calc(.9rem + env(safe-area-inset-top));
  right: .9rem;
  padding: .5rem 1rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .85);
  color: var(--azul);
  font-family: "Fredoka", sans-serif;
  font-size: 1rem;
  cursor: pointer;
}

/* Aviso para deslizar hacia los detalles */
.pista-deslizar {
  position: fixed;
  left: 50%;
  bottom: calc(.9rem + env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(88vw, 340px);
  padding: .7rem 1rem .5rem;
  border: 3px solid var(--amarillo);
  border-radius: 22px;
  background: rgba(255, 255, 255, .94);
  color: var(--azul);
  font: inherit;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(30, 58, 95, .25);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 140%);
  transition: transform .45s cubic-bezier(.2, .9, .3, 1.3), opacity .3s ease;
}
.pista-deslizar.mostrar { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.pista-deslizar strong { font-family: "Fredoka", sans-serif; font-size: 1.3rem; line-height: 1.2; }
.pista-deslizar small { font-size: .9rem; font-weight: 700; color: var(--texto); }
.pista-deslizar .flecha { font-size: 1.5rem; animation: saltito 1s ease-in-out infinite; }

/* Globos de fondo */
.globos { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
.globo {
  position: absolute;
  bottom: -140px;
  width: 46px; height: 56px;
  border-radius: 50% 50% 48% 48%;
  background: radial-gradient(circle at 32% 30%, rgba(255, 255, 255, .55) 0 12%, transparent 13%), var(--color);
  opacity: .85;
  animation: subir linear infinite;
}
.globo::after {
  content: "";
  position: absolute;
  top: 100%; left: 50%;
  width: 1.5px; height: 60px;
  background: rgba(30, 58, 95, .35);
}

/* Confeti al abrir */
.confeti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confeti i {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  animation: confeti ease-in forwards;
}

/* Aparición al hacer scroll */
.revelar { opacity: 0; transform: translateY(40px) scale(.96); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .9, .3, 1.3); }
.revelar.visible { opacity: 1; transform: none; }

.pop { animation: pop .35s ease; }

.despedida {
  font-family: "Fredoka", sans-serif;
  font-size: 1.4rem;
  color: var(--azul);
  margin: 1rem 0 2rem;
}

.pie {
  padding: 1.1rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  background: rgba(30, 58, 95, .08);
  border-top: 1px solid rgba(30, 58, 95, .12);
  font-size: .78rem;
  line-height: 1.6;
  color: #64748b;
}
.pie strong { color: var(--texto); white-space: nowrap; }

.btn-musica {
  position: fixed;
  top: calc(.9rem + env(safe-area-inset-top));
  right: .9rem;
  z-index: 40;
  width: 48px; height: 48px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--amarillo);
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
}

/* Paisaje con el tren */
.paisaje { position: absolute; left: 0; right: 0; bottom: 0; height: 210px; }
.colina { position: absolute; bottom: 0; border-radius: 50% 50% 0 0; }
.c1 { left: -20%; width: 90%; height: 120px; background: #66bb6a; }
.c2 { right: -25%; width: 95%; height: 95px; background: var(--pasto); }
.via {
  position: absolute;
  left: 0; right: 0; bottom: 34px;
  height: 14px;
  border-top: 4px solid #6b7280;
  background: repeating-linear-gradient(90deg, #8d5a3b 0 12px, transparent 12px 30px);
}
.tren {
  position: absolute;
  left: 0;
  bottom: 44px;
  animation: viajar 16s linear infinite;
}
.tren svg { display: block; height: 120px; width: auto; overflow: visible; }
.rueda { transform-box: fill-box; transform-origin: center; animation: girar .8s linear infinite reverse; }
.humo { transform-box: fill-box; transform-origin: center; animation: humo 1.8s ease-out infinite; opacity: 0; }
.humo.h2 { animation-delay: .6s; }
.humo.h3 { animation-delay: 1.2s; }

/* Contenido */
.contenido { max-width: 480px; margin: 0 auto; padding: 1.5rem 1.25rem 0; }

.boleto {
  background: #fff8db;
  border: 3px dashed var(--rojo);
  border-radius: 20px;
  padding: 1.75rem 1.5rem;
  margin-bottom: 2.5rem;
  box-shadow: 0 8px 20px rgba(30, 58, 95, .12);
}
.boleto-titulo {
  font-family: "Fredoka", sans-serif;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .85rem;
  color: var(--rojo);
}
.saludo { font-family: "Fredoka", sans-serif; font-size: 1.6rem; color: var(--azul); margin-top: .5rem; }
.boleto h2 { font-size: 1.9rem; margin-bottom: .5rem; }
.cupos { font-family: "Fredoka", sans-serif; font-size: 2.3rem; font-weight: 700; color: var(--rojo); }

.tarjeta {
  background: #fff;
  border-radius: 22px;
  padding: 1.75rem 1.5rem;
  border: 5px solid;
  box-shadow: 0 8px 20px rgba(30, 58, 95, .12);
}
.tarjeta h3 { font-size: 1.5rem; margin-bottom: .5rem; }
.tarjeta.amarillo { border-color: var(--amarillo); }
.tarjeta.verde { border-color: var(--verde); }
.tarjeta.azul { border-color: var(--azul); }

/* Ruedas debajo de cada tarjeta para que parezcan vagones */
.vagon { position: relative; margin-bottom: 2.75rem; }
.vagon::before, .vagon::after {
  content: "";
  position: absolute;
  bottom: -22px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #334155;
  border: 6px solid var(--amarillo);
}
.vagon::before { left: 18%; }
.vagon::after { right: 18%; }

.fecha, .lugar { font-family: "Fredoka", sans-serif; font-size: 1.5rem; line-height: 1.3; }
.fecha::first-letter { text-transform: uppercase; }
.hora { font-size: 1.2rem; font-weight: 700; color: var(--rojo); }
.faltan { font-family: "Fredoka", sans-serif; margin-top: 1rem; color: #64748b; }

.cuenta { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: .5rem; }
.cuenta div { border-radius: 14px; padding: .55rem 0; color: #fff; }
.cuenta .rojo { background: var(--rojo); }
.cuenta .azul { background: var(--azul); }
.cuenta .verde { background: var(--verde); }
.cuenta .amarillo { background: var(--amarillo); color: var(--texto); }
.cuenta span { display: block; font-family: "Fredoka", sans-serif; font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.cuenta small { font-size: .7rem; font-weight: 700; text-transform: uppercase; }

.btn-secundario {
  display: inline-block;
  margin-top: 1rem;
  padding: .7rem 1.6rem;
  border-radius: 999px;
  background: var(--azul);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 0 #1e40af;
}

.tarjeta.rojo { border-color: var(--rojo); }
.confirmar { padding-bottom: 2.75rem; }
.confirmar .limite { font-weight: 700; color: var(--rojo); margin-bottom: .75rem; }
#pregunta-personas { font-weight: 700; margin-bottom: .75rem; }

.selector-personas { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-bottom: 1rem; }
.selector-personas button {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 3px solid var(--azul);
  background: #fff;
  color: var(--azul);
  font-family: "Fredoka", sans-serif;
  font-size: 1.4rem;
  cursor: pointer;
  transition: transform .15s ease;
}
.selector-personas button[aria-checked="true"] { background: var(--azul); color: #fff; transform: scale(1.12); }

.confirmar textarea {
  width: 100%;
  border: 2px solid #cbd5e1;
  border-radius: 14px;
  padding: .7rem .9rem;
  font: inherit;
  resize: vertical;
  margin-bottom: 1.1rem;
}
.confirmar textarea:focus { outline: none; border-color: var(--azul); }

.confirmar button.btn-asistire { width: 100%; border: 0; cursor: pointer; }
.confirmar button.btn-asistire:disabled, .btn-no-asistire:disabled { opacity: .6; animation: none; }
.btn-no-asistire, .btn-cambiar {
  margin-top: 1rem;
  background: none;
  border: 0;
  color: #64748b;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}
.error-respuesta { color: var(--rojo); font-weight: 700; margin-top: .75rem; min-height: 1.2em; }

.resultado-emoji { font-size: 3rem; line-height: 1.2; }
.resultado-titulo { font-family: "Fredoka", sans-serif; font-size: 1.6rem; color: var(--azul); }
.resultado p { margin-bottom: .5rem; }
.resultado .btn-asistire { margin-top: 1rem; animation: none; font-size: 1.1rem; }

.foto-marco.sin-foto { width: auto; height: auto; }
.foto-marco.sin-foto img { display: none; }
.foto-marco.sin-foto .edad { position: static; width: 130px; height: 130px; }

.btn-asistire {
  display: block;
  padding: 1.1rem;
  border-radius: 999px;
  background: var(--whatsapp);
  color: #fff;
  font-family: "Fredoka", sans-serif;
  font-size: 1.35rem;
  text-decoration: none;
  box-shadow: 0 6px 0 #179c48, 0 10px 20px rgba(37, 211, 102, .35);
  animation: latido 2.5s ease-in-out infinite;
}
.btn-asistire:active { transform: translateY(4px); box-shadow: 0 2px 0 #179c48; }

@keyframes girar { to { transform: rotate(360deg); } }
@keyframes flotar { from { left: -140px; } to { left: 110%; } }
@keyframes viajar { from { transform: translateX(100vw); } to { transform: translateX(-100%); } }
@keyframes humo {
  0% { opacity: .9; transform: translate(0, 0) scale(.5); }
  100% { opacity: 0; transform: translate(18px, -40px) scale(1.6); }
}
@keyframes rebote {
  0% { opacity: 0; transform: translateY(-30px) scale(.8); }
  60% { opacity: 1; transform: translateY(6px) scale(1.03); }
  100% { transform: none; }
}
@keyframes balanceo { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes latido { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }
@keyframes flotarFoto { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes llegar { from { transform: scale(.15) translateY(-120%); opacity: 0; } 20% { opacity: 1; } to { transform: none; } }
@keyframes traqueteo { from { transform: translateY(0) rotate(-.6deg); } to { transform: translateY(-4px) rotate(.6deg); } }
@keyframes acercarse { to { transform: scale(3.5) translateY(10%); opacity: 0; } }
@keyframes parpadeo { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes caer {
  from { transform: translateY(0) rotate(0deg) rotateY(0deg); }
  to { transform: translateY(125vh) rotate(300deg) rotateY(540deg); }
}
@keyframes subir { from { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-60vh) rotate(4deg); } to { transform: translateY(-125vh) rotate(-4deg); } }
@keyframes confeti {
  to { transform: translate(var(--deriva), 110vh) rotate(var(--giro)); opacity: .9; }
}
@keyframes saltito { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes aVagon {
  0% { transform: translateY(70px) scale(.6); }
  55% { transform: translateY(-40px) scale(1.05); }
  100% { transform: none; }
}
@keyframes aparecer { from { transform: scale(0) rotate(-30deg); } to { transform: none; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

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