:root {
  --cream: #fbf5e9;
  --cream-2: #f3e8d2;
  --navy: #13306b;
  --night: #0b1a3d;
  --blue: #2e6db4;
  --sky: #8fb8e3;
  --yellow: #f2c14e;
  --red: #e2574c;
  --green: #7e9d6b;
  --ink: #1d2b4f;
  --script: "Lobster Two", "Georgia", serif;
  --ui: "Fredoka", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--ui);
  color: var(--ink);
  background: var(--night);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* ---------- escenas ---------- */
.scene {
  position: fixed;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity .8s ease, visibility 0s linear .8s;
}
.scene.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity .8s ease, visibility 0s;
}

/* ---------- botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4em;
  border: 0;
  border-radius: 999px;
  padding: .8em 1.4em;
  font: 600 1rem/1 var(--ui);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.btn-primary { background: var(--red); }
.btn-blue { background: var(--blue); }
.btn-green { background: var(--green); }
.btn-big { font-size: 1.25rem; padding: .9em 1.8em; }
.link-btn {
  background: none; border: 0; padding: 0;
  font: inherit; color: inherit; text-decoration: underline; cursor: pointer; opacity: .75;
}
.skip-btn {
  position: absolute;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 10;
  background: rgba(255,255,255,.16);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px;
  padding: .5em 1em;
  font: 500 .9rem var(--ui);
  backdrop-filter: blur(6px);
  cursor: pointer;
}

/* ---------- 1 · entrada ---------- */
#gate {
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 20% 15%, rgba(242,193,78,.18), transparent 40%),
    radial-gradient(circle at 80% 85%, rgba(143,184,227,.18), transparent 45%),
    var(--night);
}
.gate-card {
  width: min(420px, 100%);
  text-align: center;
  background: var(--cream);
  border: 3px solid var(--blue);
  outline: 2px solid var(--yellow);
  outline-offset: -12px;
  border-radius: 18px;
  padding: 44px 24px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  animation: float 4s ease-in-out infinite;
  /* muescas de boleto */
  -webkit-mask: radial-gradient(circle 16px at 0 50%, #0000 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle 16px at 100% 50%, #0000 98%, #000) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 16px at 0 50%, #0000 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle 16px at 100% 50%, #0000 98%, #000) right / 51% 100% no-repeat;
}
.gate-kicker { margin: 0; letter-spacing: .3em; text-transform: uppercase; font-size: .75rem; color: var(--blue); font-weight: 600; }
.gate-title { margin: .15em 0 0; font: 700 clamp(2.8rem, 12vw, 3.6rem)/1 var(--script); color: var(--navy); }
.gate-sub { margin: .4em 0 1.6em; font: italic 700 1.05rem var(--script); color: var(--green); }
.gate-hint { margin: 1em 0 1.2em; font-size: .9rem; opacity: .7; }
#skip-all { font-size: .85rem; color: var(--blue); }
@keyframes float { 50% { transform: translateY(-6px); } }

/* ---------- 2 · intro ---------- */
#intro { background: linear-gradient(#050d24, #0b1a3d 55%, #1c3570); overflow: hidden; }
#sky { position: absolute; inset: 0; width: 100%; height: 100%; }
#castle {
  position: absolute;
  left: 50%;
  bottom: -2%;
  width: min(92vw, 560px);
  transform: translate(-50%, 30px);
  opacity: 0;
  overflow: visible;
  filter: drop-shadow(0 0 30px rgba(143,184,227,.25));
}
#intro.run #castle { animation: castle-in 2.2s .3s cubic-bezier(.2,.7,.2,1) forwards; }
@keyframes castle-in { to { opacity: 1; transform: translate(-50%, 0); } }
.windows { opacity: 0; }
#intro.run .windows { animation: lights 1s 1.6s forwards; }
@keyframes lights { to { opacity: 1; } }

.intro-title {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 16px;
  pointer-events: none;
  opacity: 0;
}
.intro-presents {
  margin: 0;
  color: #fff;
  font: italic 700 clamp(1.1rem, 4.5vw, 1.5rem) var(--script);
  text-shadow: 0 0 18px rgba(255,217,122,.7);
}
.intro-logo {
  width: min(88vw, 620px);
  border-radius: 14px;
  box-shadow: 0 0 0 4px rgba(255,255,255,.15), 0 0 80px rgba(255,217,122,.45);
}
#intro.reveal .intro-title { animation: reveal 1.6s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes reveal {
  0% { opacity: 0; transform: scale(.85); filter: blur(10px) brightness(2); }
  60% { opacity: 1; filter: blur(0) brightness(1.2); }
  100% { opacity: 1; transform: scale(1); filter: none; }
}

/* ---------- 3 · juego ---------- */
#game { background: linear-gradient(#bfe0fb, #e9f4ff 60%, var(--cream)); touch-action: none; }
#play { position: absolute; inset: 0; width: 100%; height: 100%; }
.hud {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 16px; right: 16px;
  display: flex; align-items: center; gap: 12px;
  pointer-events: none;
}
.hud-score {
  background: var(--cream);
  border: 2px solid var(--blue);
  border-radius: 999px;
  padding: .35em .9em;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
}
.hud-bar { flex: 1; height: 12px; background: rgba(255,255,255,.7); border-radius: 999px; overflow: hidden; border: 2px solid var(--blue); }
#bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--yellow), var(--red)); transition: width .3s ease; }

.overlay {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(11,26,61,.45);
  backdrop-filter: blur(3px);
}
.overlay-card {
  width: min(380px, 100%);
  background: var(--cream);
  border: 3px solid var(--blue);
  border-radius: 22px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
  animation: pop-in .5s cubic-bezier(.2,1.4,.4,1);
}
.overlay-card h2 { margin: 0 0 .3em; font: 700 2rem var(--script); color: var(--navy); }
.overlay-card p { margin: 0 0 1.2em; line-height: 1.45; }
.howto-faces { display: flex; justify-content: center; gap: 10px; margin-bottom: 1.4em; }
.howto-faces img { width: 64px; height: 64px; object-fit: contain; animation: bob 1.6s ease-in-out infinite; }
.howto-faces img:nth-child(2) { animation-delay: .25s; }
.howto-faces img:nth-child(3) { animation-delay: .5s; }
.win-face { width: 120px; margin: -70px auto 6px; filter: drop-shadow(0 8px 14px rgba(0,0,0,.25)); }
@keyframes pop-in { from { transform: scale(.6); opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }

/* ---------- 4 · invitación ---------- */
#invite {
  background:
    radial-gradient(circle at 10% 0%, rgba(242,193,78,.25), transparent 35%),
    radial-gradient(circle at 100% 30%, rgba(143,184,227,.3), transparent 40%),
    var(--cream);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.invite-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 16px calc(32px + env(safe-area-inset-bottom, 0px));
  text-align: center;
}
.booth { position: relative; padding-top: 10px; }
.booth-slot {
  height: 14px;
  margin: 0 4%;
  border-radius: 999px;
  background: var(--navy);
  box-shadow: inset 0 3px 6px rgba(0,0,0,.6);
  position: relative;
  z-index: 2;
}
.ticket {
  display: block;
  width: 92%;
  margin: -7px auto 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  clip-path: inset(0 0 100% 0);
  transform: translateY(-40%);
}
.ticket img { border-radius: 8px; box-shadow: 0 14px 30px rgba(19,48,107,.25); }
#invite.is-active .ticket { animation: print 2.2s .4s cubic-bezier(.3,.7,.3,1) forwards; }
@keyframes print {
  0% { clip-path: inset(0 0 100% 0); transform: translateY(-40%); }
  80% { clip-path: inset(0 0 0 0); transform: translateY(0) rotate(0); }
  100% { clip-path: inset(0 0 0 0); transform: translateY(0) rotate(-1.2deg); }
}
.zoom-hint { margin: .8em 0 0; font-size: .8rem; opacity: .6; }

.invite-heading {
  margin: 1.2em 0 .6em;
  font: 700 clamp(1.4rem, 5vw, 2rem)/1.2 var(--script);
  color: var(--navy);
}
.invite-heading span { color: var(--blue); }

.countdown { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 0 0 1.4em; }
.countdown div {
  min-width: 70px;
  background: #fff;
  border: 2px solid var(--blue);
  border-radius: 14px;
  padding: 10px 8px 8px;
}
.countdown div:nth-child(2) { border-color: var(--yellow); }
.countdown div:nth-child(3) { border-color: var(--green); }
.countdown div:nth-child(4) { border-color: var(--red); }
.countdown b { display: block; font-size: 1.7rem; color: var(--navy); font-variant-numeric: tabular-nums; }
.countdown span { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; opacity: .7; }

.details {
  list-style: none;
  margin: 0 auto 1.4em;
  padding: 0;
  max-width: 420px;
  display: grid;
  gap: 10px;
  text-align: left;
}
.details li {
  display: flex; gap: 14px; align-items: center;
  background: #fff;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 2px 0 var(--cream-2);
}
.details .ic { font-size: 1.6rem; }
.details b { display: block; color: var(--blue); font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 520px; margin: 0 auto; }
.actions .btn { flex: 1 1 140px; padding-inline: .8em; }
.actions .btn-primary { flex-basis: 100%; font-size: 1.15rem; }

.faces { display: flex; justify-content: center; gap: 4px; margin: 2em 0 .5em; }
.faces img { width: 22%; max-width: 110px; animation: bob 2.4s ease-in-out infinite; }
.faces img:nth-child(2) { animation-delay: .3s; }
.faces img:nth-child(3) { animation-delay: .6s; }
.faces img:nth-child(4) { animation-delay: .9s; }

.footer { font-size: .85rem; opacity: .7; }

.lightbox {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(11,26,61,.92);
  display: grid; place-items: center;
  padding: 16px;
  overflow: auto;
}
.lightbox img { max-width: none; width: min(1600px, 100%); border-radius: 8px; }
.lightbox-close {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  background: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}
/* En celular vertical el boleto se ve mejor girado */
@media (orientation: portrait) and (max-width: 700px) {
  .lightbox { overflow: hidden; }
  .lightbox img {
    position: absolute; left: 50%; top: 50%;
    width: 88vh; width: 88dvh;
    transform: translate(-50%, -50%) rotate(90deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}
#game .skip-btn { background: rgba(19,48,107,.75); border-color: transparent; }
/* las fotos recortadas terminan en línea recta: se difumina el borde de abajo */
.win-face, .faces img, .howto-faces img {
  -webkit-mask-image: linear-gradient(#000 72%, transparent);
          mask-image: linear-gradient(#000 72%, transparent);
}
#game.won .skip-btn { display: none; }
.music-btn {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 15;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid var(--blue);
  background: var(--cream);
  font-size: 1.3rem;
  box-shadow: 0 6px 16px rgba(19,48,107,.25);
  cursor: pointer;
}
/* Netlify pone su badge abajo a la derecha: nuestros botones flotantes van a la izquierda */
.skip-btn, .music-btn { right: auto; left: 16px; }
.invite-wrap { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
/* instrucciones: quién suma y quién resta */
.howto-faces figure { margin: 0; position: relative; animation: bob 1.6s ease-in-out infinite; }
.howto-faces figure:nth-child(2) { animation-delay: .25s; }
.howto-faces figure:nth-child(3) { animation-delay: .5s; }
.howto-faces figure img { animation: none; }
.howto-faces figcaption {
  position: absolute; right: -6px; bottom: -4px;
  min-width: 30px; padding: 2px 6px;
  border-radius: 999px;
  font-weight: 700; font-size: .85rem; color: #fff;
}
.howto-faces .ok figcaption { background: var(--green); }
.howto-faces .no figcaption { background: var(--red); }

#game.shake #play { animation: shake .35s ease; }
@keyframes shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}
/* papá y mamá ya vienen recortados hasta la barbilla: sin difuminado */
.howto-faces .no img { -webkit-mask-image: none; mask-image: none; }
