:root {
  --paper: #fbf5e9;
  --paper-2: #f3e8d2;
  --heading: #13306b;
  --deep: #0b1a3d;
  --c2: #2e6db4;
  --soft: #8fb8e3;
  --accent: #f2c14e;
  --c1: #e2574c;
  --c3: #7e9d6b;
  --ink: #1d2b4f;
  --script: "Lobster Two", "Georgia", serif;
  --ui: "Fredoka", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* fondos de cada escena: los temas los redefinen */
  --gate-bg:
    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(--deep);
  --intro-bg: linear-gradient(#050d24, #0b1a3d 55%, #1c3570);
  --game-bg: linear-gradient(#bfe0fb, #e9f4ff 60%, var(--paper));
  --invite-bg:
    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(--paper);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--ui);
  color: var(--ink);
  background: var(--deep);
  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(--c1); }
.btn-blue { background: var(--c2); }
.btn-green { background: var(--c3); }
.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: var(--gate-bg);
}
.gate-card {
  width: min(420px, 100%);
  text-align: center;
  background: var(--paper);
  border: 3px solid var(--c2);
  outline: 2px solid var(--accent);
  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(--c2); font-weight: 600; }
.gate-title { margin: .15em 0 0; font: 700 clamp(2.8rem, 12vw, 3.6rem)/1 var(--script); color: var(--heading); }
.gate-sub { margin: .4em 0 1.6em; font: italic 700 1.05rem var(--script); color: var(--c3); }
.gate-hint { margin: 1em 0 1.2em; font-size: .9rem; opacity: .7; }
#skip-all { font-size: .85rem; color: var(--c2); }
@keyframes float { 50% { transform: translateY(-6px); } }

/* ---------- 2 · intro ---------- */
#intro { background: var(--intro-bg); overflow: hidden; }
#sky { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene-art {
  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 .scene-art { 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: var(--game-bg); 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(--paper);
  border: 2px solid var(--c2);
  border-radius: 999px;
  padding: .35em .9em;
  font-weight: 700;
  color: var(--heading);
  white-space: nowrap;
}
.hud-bar { flex: 1; height: 12px; background: rgba(255,255,255,.7); border-radius: 999px; overflow: hidden; border: 2px solid var(--c2); }
#bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--c1)); 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(--paper);
  border: 3px solid var(--c2);
  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(--heading); }
.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: var(--invite-bg);
  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(--heading);
  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(--heading);
}
.invite-heading span { color: var(--c2); }

.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(--c2);
  border-radius: 14px;
  padding: 10px 8px 8px;
}
.countdown div:nth-child(2) { border-color: var(--accent); }
.countdown div:nth-child(3) { border-color: var(--c3); }
.countdown div:nth-child(4) { border-color: var(--c1); }
.countdown b { display: block; font-size: 1.7rem; color: var(--heading); 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(--paper-2);
}
.details .ic { font-size: 1.6rem; }
.details b { display: block; color: var(--c2); 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(--c2);
  background: var(--paper);
  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(--c3); }
.howto-faces .no figcaption { background: var(--c1); }

#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; }

/* ---------- confirmación de asistencia ---------- */
.rsvp-modal {
  position: fixed; inset: 0; z-index: 25;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(11,26,61,.55);
  backdrop-filter: blur(3px);
}
.rsvp-modal form, .rsvp-modal .rsvp-done { display: grid; gap: 12px; text-align: left; }
.rsvp-modal label { display: grid; gap: 4px; font-weight: 600; color: var(--heading); }
.rsvp-modal input, .rsvp-modal textarea {
  font: 400 1rem var(--ui);
  padding: .7em .9em;
  border: 2px solid var(--paper-2);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
.rsvp-modal input:focus, .rsvp-modal textarea:focus { outline: none; border-color: var(--c2); }
.rsvp-modal .rsvp-done { text-align: center; }
.rsvp-modal .link-btn { justify-self: center; font-size: .9rem; }

/* ---------- piezas en HTML para temas sin arte ilustrado ---------- */
.logo-text {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .08em;
  font: 400 clamp(2.6rem, 13vw, 5rem)/1 var(--script);
  color: #fff;
}
.logo-text { column-gap: .4em; row-gap: .15em; }
/* cada palabra se mantiene junta; solo se parte entre palabras */
.logo-text .w { display: inline-flex; gap: .08em; white-space: nowrap; }
.logo-text .w span { display: inline-block; }
.logo-tag {
  margin: .3em 0 0;
  font: 600 clamp(1rem, 4.5vw, 1.4rem) var(--ui);
  color: var(--accent);
  text-align: center;
}
.intro-title .logo-wrap { width: min(92vw, 620px); }

.ticket-card {
  display: flex;
  text-align: left;
  background: var(--paper);
  border: 3px solid var(--c2);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 14px 30px rgba(0,0,0,.18);
}
.tc-main { flex: 1; padding: 20px 18px 18px 22px; }
.tc-kicker { margin: 0; font: 600 .95rem var(--ui); color: var(--c2); }
.tc-name { margin: .1em 0 .25em; font: 400 clamp(2.2rem, 10vw, 3.2rem)/1 var(--script); color: var(--heading); }
.tc-info { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .95rem; color: var(--ink); }
.tc-stub {
  width: 54px;
  display: grid; place-items: center;
  background: var(--c2);
  border-left: 3px dashed var(--paper);
  color: #fff;
  font: 700 .8rem var(--ui);
  letter-spacing: .25em;
}
.tc-stub span { writing-mode: vertical-rl; transform: rotate(180deg); }
.ticket.is-card { cursor: default; }
/* la animación de impresión recorta las sombras: el boleto HTML va sin sombra */
.ticket.is-card .ticket-card { box-shadow: none; }

/* enlace a la marca al pie de cada invitación */
.made-by { margin: 4px 0 0; font-size: .8rem; }
.made-by a { color: inherit; opacity: .7; text-decoration: none; border-bottom: 1px dashed currentColor; }
.made-by a:hover { opacity: 1; }

/* etiqueta de la vista previa del wizard */
.preview-badge {
  position: fixed; z-index: 30;
  top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font: 700 .7rem var(--ui);
  letter-spacing: .14em;
  text-transform: uppercase;
  pointer-events: none;
}

/* ---------- minijuego de memoria ---------- */
.memo-board {
  position: absolute;
  inset: calc(70px + env(safe-area-inset-top, 0px)) 16px calc(76px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 10px;
  max-width: 460px;
  margin: 0 auto;
  z-index: 2;
}
.memo-card {
  position: relative;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  perspective: 600px;
}
.memo-card > span {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: 16px;
  backface-visibility: hidden;
  transition: transform .45s cubic-bezier(.3,.7,.3,1);
  box-shadow: 0 6px 14px rgba(0,0,0,.15);
}
.memo-back {
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,.35), transparent 40%),
    linear-gradient(150deg, var(--c2), var(--c1));
  border: 3px solid rgba(255,255,255,.7);
}
.memo-back::after { content: "✦"; color: rgba(255,255,255,.85); font-size: 1.6rem; }
.memo-front {
  background: var(--paper);
  border: 3px solid var(--accent);
  transform: rotateY(180deg);
  overflow: hidden;
}
.memo-front img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 38%; }
.memo-front b { font-size: clamp(2.6rem, 13vw, 3.8rem); }
.memo-card.flip .memo-back { transform: rotateY(-180deg); }
.memo-card.flip .memo-front { transform: rotateY(0); }
.memo-card.done .memo-front { border-color: var(--c3); box-shadow: 0 0 0 4px rgba(255,255,255,.6), 0 6px 14px rgba(0,0,0,.15); }

/* botón para salir de una demo (solo en /demo/…) */
.demo-back {
  position: fixed; z-index: 40;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  padding: .5em 1em;
  border-radius: 999px;
  background: rgba(20,24,40,.72);
  color: #fff;
  font: 600 .9rem var(--ui);
  text-decoration: none;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
