/* ============ Base ============ */
:root {
  --night: #150d2b;
  --purple: #7c4ddb;
  --lilac: #cbb6ff;
  --lav: #e9defe;
  --pink: #ff7eb6;
  --paper: #fffaf2;
  --ink: #2b1d45;
  --gold: #ffd166;

  --f-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-hand: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive;
  --f-pixel: 'Press Start 2P', ui-monospace, 'Courier New', monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, a { touch-action: manipulation; }
img { -webkit-touch-callout: none; }
body {
  background: var(--night);
  color: #fff;
  font-family: var(--f-body);
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.pixel { font-family: var(--f-pixel); }

/* ============ Fondos ============ */
#bgs { position: fixed; inset: 0; z-index: 0; }
.bg { position: absolute; inset: 0; opacity: 0; transition: opacity 1s ease; overflow: hidden; }
.bg.active { opacity: 1; }

.bg-intro {
  background:
    radial-gradient(120% 60% at 50% 115%, #6a3399 0%, transparent 60%),
    radial-gradient(70% 40% at 85% 5%, #3a2270 0%, transparent 70%),
    linear-gradient(#0f0822, #221345 65%, #3a1e62);
}
.bg-intro::after {
  content: ''; position: absolute; top: 9%; right: 13%;
  width: 58px; height: 58px; border-radius: 50%;
  box-shadow: inset -15px 7px 0 0 #fff1c9;
  filter: drop-shadow(0 0 18px rgba(255, 241, 201, .55));
}
.bg-music {
  background:
    radial-gradient(90% 55% at 50% 30%, #4b2a8c, transparent 70%),
    linear-gradient(160deg, #1a0e35, #2d1757 60%, #45216d);
}
.bg-garden {
  background:
    radial-gradient(60% 25% at 80% 12%, rgba(255,255,255,.6), transparent 70%),
    linear-gradient(#ffc8d8 0%, #f3b3dc 22%, #c9aef5 38%, #a8dcaf 39%, #6cc08a 70%, #449a67 100%);
}
.bg-rolls { background: linear-gradient(#8fd0f7 0%, #b7e2fb 45%, #e4f4fe 100%); }
.cloud {
  position: absolute; width: 180px; height: 60px; border-radius: 60px; background: #fff; opacity: .9;
  animation: cloudDrift linear infinite;
}
.cloud::before, .cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 80px; height: 80px; left: 26px; top: -40px; }
.cloud::after { width: 100px; height: 100px; right: 22px; top: -54px; }
.bg-dino { background: linear-gradient(#0c231c, #143a2c 55%, #1d4a33); }
.bg-dino svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.bg-letter {
  background:
    radial-gradient(100% 55% at 50% 0%, #3d2072, transparent 70%),
    linear-gradient(#0c0720, #1c1040 60%, #2e1856);
}
.bg-gift {
  background:
    radial-gradient(80% 50% at 50% 45%, #5b2a7e, transparent 70%),
    linear-gradient(#0e0822, #25124a 60%, #3d1a5c);
}
.float-tulip {
  position: absolute; bottom: -140px; opacity: .55;
  animation: floatUp linear infinite;
}

#fx { position: fixed; inset: 0; z-index: 1; width: 100%; height: 100%; pointer-events: none; }
#confetti { position: fixed; inset: 0; z-index: 60; width: 100%; height: 100%; pointer-events: none; }

/* ============ Escenas ============ */
.scene {
  position: fixed; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  padding: calc(env(safe-area-inset-top) + 74px) 18px calc(env(safe-area-inset-bottom) + 20px);
  opacity: 0; visibility: hidden; transform: scale(1.03);
  transition: opacity .7s ease, transform .7s ease, visibility 0s linear .7s;
}
.scene.active {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .7s ease, transform .7s ease, visibility 0s;
}
.scene.scroll { justify-content: flex-start; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ============ Botones y piezas comunes ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 30px; border-radius: 999px;
  font-weight: 800; letter-spacing: .06em;
  transition: transform .15s ease, opacity .3s;
}
.btn:active { transform: scale(.95); }
.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff;
  box-shadow: 0 12px 30px -10px rgba(255,126,182,.7), inset 0 1px 0 rgba(255,255,255,.35);
}
.btn-ghost {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.25);
  min-height: 44px; font-weight: 600; letter-spacing: 0; color: #fff; text-decoration: none;
}
.btn-small { min-height: 40px; padding: 0 18px; font-size: .9rem; }
.btn-dark { color: #fff; font-family: var(--f-pixel); font-size: 12px; }
.btn-warn { background: var(--gold); color: #1a1a12; font-family: var(--f-pixel); font-size: 11px; margin: 16px 0 22px; }
.btn-pulse { animation: pulse 2.2s ease-in-out infinite; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 16px; border-radius: 999px;
  background: rgba(255,255,255,.75); color: var(--ink); font-weight: 800;
  box-shadow: 0 6px 16px -8px rgba(0,0,0,.35);
}
.pill-dark { background: rgba(0,0,0,.35); color: #fff; border: 1px solid rgba(255,255,255,.18); }
.pill.bump { animation: boing .5s; }

.hint { margin: 0; font-size: .85rem; opacity: .75; text-align: center; }

/* ============ HUD ============ */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 8px;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
.hud-dots {
  display: flex; gap: 4px; padding: 5px 8px; border-radius: 999px;
  background: rgba(20,10,40,.4); border: 1px solid rgba(255,255,255,.15);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.hud-dots { transition: opacity .3s, transform .3s; }
#hud.tucked .hud-dots { opacity: 0; transform: translateY(-12px); pointer-events: none; }
.hud-dots span {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%;
  font-size: 15px; opacity: .35; filter: grayscale(1); transition: all .4s;
}
.hud-dots span.done { opacity: .95; filter: none; }
.hud-dots span.current { opacity: 1; filter: none; background: rgba(255,255,255,.22); transform: scale(1.08); }
#muteBtn {
  width: 42px; height: 42px; border-radius: 50%; font-size: 17px;
  background: rgba(20,10,40,.4); border: 1px solid rgba(255,255,255,.15);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

/* ============ Tarjeta de capítulo ============ */
#titleCard {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 0 20px;
  background: rgba(12,6,26,.94); opacity: 0; pointer-events: none; transition: opacity .45s;
}
#titleCard.show { opacity: 1; pointer-events: auto; }
.tc-inner { text-align: center; }
.tc-kicker { font-size: 11px; letter-spacing: .2em; color: var(--pink); margin: 0; }
.tc-title { font-family: var(--f-hand); font-size: clamp(2.8rem, 13vw, 4.4rem); margin: .25em 0 0; line-height: 1; }
#titleCard.show .tc-inner > * { animation: rise .6s both; }
#titleCard.show .tc-title { animation-delay: .2s; }

/* ============ Intro ============ */
#scene-intro { padding-top: calc(env(safe-area-inset-top) + 20px); }
.intro-content {
  position: relative; z-index: 2; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  margin-bottom: 20vh;
}
.intro-content > * { opacity: 0; animation: rise 1s ease forwards; }
.intro-content > :nth-child(1) { animation-delay: .3s; }
.intro-content > :nth-child(2) { animation-delay: 1s; }
.intro-content > :nth-child(3) { animation-delay: 1.9s; }
.intro-content > :nth-child(4) { animation-delay: 2.7s; }
.kicker { font-family: var(--f-pixel); font-size: 9px; letter-spacing: .18em; color: var(--lilac); margin: 0; }
.hey {
  font-family: var(--f-hand); font-weight: 700;
  font-size: clamp(3.2rem, 16vw, 5.4rem); line-height: 1; margin: 0;
  text-shadow: 0 0 34px rgba(203,182,255,.55);
}
.intro-sub { font-size: 1.15rem; margin: 0 0 16px; color: var(--lav); }
.intro-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.tulip-row { position: absolute; left: 0; right: 0; bottom: 0; height: 32vh; pointer-events: none; }
.tulip-row svg {
  position: absolute; bottom: -12px; transform-origin: 50% 100%;
  animation: sway 4s ease-in-out infinite alternate;
}

/* ============ Nivel 1 · Reproductor ============ */
.player {
  width: min(100%, 380px);
  padding: 20px 20px 22px; border-radius: 30px;
  background: linear-gradient(180deg, rgba(255,255,255,.13), rgba(255,255,255,.04));
  border: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.55);
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  max-height: 100%; overflow-y: auto;
}
.eyebrow { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--lilac); margin: 0; }
.vinyl-wrap { position: relative; width: min(46vw, 190px, 26vh); aspect-ratio: 1; margin: 4px 0; }
.vinyl {
  position: absolute; inset: 0; border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 30%, rgba(0,0,0,0) 31%),
    repeating-radial-gradient(circle, #1b1230 0 2px, #2a1d45 3px 4px);
  box-shadow: 0 0 0 5px rgba(255,255,255,.06), 0 20px 40px -10px rgba(0,0,0,.6);
  display: grid; place-items: center;
}
.vinyl::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 30deg, transparent 0 10%, rgba(255,255,255,.14) 14%, transparent 20% 60%, rgba(255,255,255,.09) 64%, transparent 70%);
}
.vinyl-label {
  width: 40%; aspect-ratio: 1; border-radius: 50%; z-index: 1;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  display: grid; place-items: center;
}
.vinyl-label svg { width: 40%; height: 70%; color: #fff; }
.playing .vinyl { animation: spin 2.4s linear infinite; }
.tonearm {
  position: absolute; top: -4%; right: -6%; width: 7px; height: 58%;
  background: linear-gradient(#eee, #9a93a8); border-radius: 4px;
  transform-origin: 50% 5%; transform: rotate(-6deg); transition: transform .8s ease;
}
.tonearm::before { content: ''; position: absolute; top: -8px; left: 50%; width: 20px; height: 20px; margin-left: -10px; border-radius: 50%; background: #d9d3e6; }
.tonearm::after { content: ''; position: absolute; bottom: -6px; left: 50%; width: 14px; height: 18px; margin-left: -7px; border-radius: 3px; background: #cfc8dd; }
.playing .tonearm { transform: rotate(24deg); }
.track-title { font-family: var(--f-hand); font-size: 2.4rem; margin: 0; line-height: 1; }
.track-sub { margin: 0; color: var(--lav); font-size: .95rem; min-height: 2.6em; }
.eq { display: flex; gap: 4px; align-items: flex-end; height: 26px; }
.eq i { display: block; width: 5px; height: 18%; border-radius: 3px; background: linear-gradient(var(--pink), var(--purple)); }
.playing .eq i { animation: eq .7s ease-in-out infinite alternate; animation-delay: var(--d); }
.progress { width: 100%; height: 6px; background: rgba(255,255,255,.15); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--pink), var(--lilac)); border-radius: 3px; }
.times { width: 100%; display: flex; justify-content: space-between; font-size: .72rem; color: var(--lilac); font-variant-numeric: tabular-nums; margin-top: -4px; }
.play-btn {
  width: 70px; height: 70px; flex: none; border-radius: 50%;
  background: #fff; color: var(--night); display: grid; place-items: center;
  animation: pulseWhite 2s ease-out infinite;
}
.play-btn:active { transform: scale(.94); }
.play-icon {
  width: 0; height: 0; margin-left: 6px;
  border-left: 22px solid currentColor; border-top: 14px solid transparent; border-bottom: 14px solid transparent;
}
.playing .play-btn { animation: none; }
.playing .play-icon {
  border: 0; margin: 0; width: 20px; height: 24px;
  background: linear-gradient(90deg, currentColor 0 35%, transparent 35% 65%, currentColor 65%);
}
.unlocked .track-sub { color: var(--gold); font-weight: 800; }
.unlocked .play-btn { display: none; }
.playlist {
  width: 100%; text-align: left; border-radius: 16px; padding: 10px 14px;
  background: rgba(0,0,0,.2); border: 1px solid rgba(255,255,255,.08);
}
.playlist summary { cursor: pointer; font-weight: 800; font-size: .9rem; list-style: none; }
.playlist summary::-webkit-details-marker { display: none; }
.playlist summary::after { content: ' ▾'; opacity: .6; }
.playlist[open] summary::after { content: ' ▴'; }
.playlist ol { margin: 8px 0 12px; padding: 0; list-style: none; }
.playlist li a {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.08);
  color: #fff; text-decoration: none; font-size: .92rem;
}
.playlist li small { color: var(--lilac); font-size: .72rem; }
.playlist .btn { width: 100%; }

/* ============ Nivel 2 · Jardín ============ */
#scene-garden { justify-content: flex-start; color: var(--ink); }
.scene-top { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.scene-title { font-family: var(--f-hand); font-size: 2.7rem; margin: 0; line-height: 1; }
.scene-text { margin: 0; font-weight: 700; }
.field { position: relative; flex: 1; width: 100%; max-width: 460px; min-height: 300px; }
.tulip-btn {
  position: absolute; height: 33%; aspect-ratio: 1 / 2; max-height: 180px;
  transform: translateX(-50%);
}
.tulip-btn::after {
  content: ''; position: absolute; left: 20%; right: 20%; bottom: -3px; height: 8px;
  border-radius: 50%; background: rgba(0,0,0,.14);
}
.tulip-btn svg {
  width: 100%; height: 100%; display: block; transform-origin: 50% 100%;
  animation: sway 3.4s ease-in-out infinite alternate; animation-delay: var(--d);
}
.tulip-btn.tapped svg { animation: boing .6s ease; }
.tulip-btn.tapped { pointer-events: none; }
.tulip-btn.tapped:not(.found) svg { opacity: .75; }
.reveal {
  position: absolute; left: 50%; top: -6px; font-size: 1.8rem;
  transform: translate(-50%, 0) scale(0); pointer-events: none;
}
.tulip-btn.tapped .reveal { animation: revealUp 1.2s ease forwards; }
.tulip-btn.found .reveal { animation: revealStay .7s cubic-bezier(.2,1.6,.4,1) forwards, floaty 2s 0.7s ease-in-out infinite; }

/* ============ Modal / Polaroid ============ */
.modal {
  position: fixed; inset: 0; z-index: 55;
  display: grid; place-items: center; padding: 24px 20px;
  background: rgba(15,8,30,.78);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .3s;
}
.modal.show { opacity: 1; }
.modal-inner {
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  transform: scale(.8) rotate(-4deg); transition: transform .55s cubic-bezier(.2,1.4,.4,1);
}
.modal.show .modal-inner { transform: none; }
.modal-head { font-family: var(--f-pixel); font-size: 11px; line-height: 1.8; color: var(--gold); text-align: center; margin: 0; }

.polaroid {
  position: relative; width: 100%; margin: 0;
  background: var(--paper); color: var(--ink);
  padding: 12px 12px 10px; border-radius: 3px;
  box-shadow: 0 22px 40px -14px rgba(0,0,0,.6);
  transform: rotate(var(--r, -2deg));
}
.polaroid::before {
  content: ''; position: absolute; top: -12px; left: 50%; width: 92px; height: 26px;
  transform: translateX(-50%) rotate(-4deg);
  background: repeating-linear-gradient(45deg, rgba(255,179,209,.85) 0 8px, rgba(255,207,226,.85) 8px 16px);
  box-shadow: 0 2px 4px rgba(0,0,0,.08);
}
.polaroid img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: #eee3d6; border-radius: 2px; }
.modal .polaroid img { aspect-ratio: auto; height: min(48vh, 380px); }
.polaroid figcaption { font-family: var(--f-hand); font-size: 1.65rem; text-align: center; margin-top: 8px; line-height: 1.1; min-height: 1.1em; }

.quest { text-align: center; }
.quest-title {
  font-family: var(--f-pixel); font-size: clamp(22px, 8vw, 32px); line-height: 1.5; margin: 0;
  color: var(--gold); text-shadow: 4px 4px 0 var(--pink);
  animation: boing .8s ease;
}
.quest p:last-child { font-weight: 800; font-size: 1.1rem; }

/* ============ Nivel 3 · Cinnamon rolls ============ */
#scene-rolls { justify-content: flex-start; color: var(--ink); }
.mission {
  width: min(100%, 360px); text-align: center;
  background: #fff; border: 3px solid #2f5f99; border-radius: 16px;
  box-shadow: 5px 5px 0 #2f5f99; padding: 12px 16px;
}
.mission .pixel { font-size: 11px; color: #3d73b8; }
.mission p { margin: 8px 0 10px; font-weight: 800; }
.roll-meter { display: flex; justify-content: center; gap: 8px; }
.roll-meter img { width: 46px; height: 32px; object-fit: contain; filter: grayscale(1) brightness(.8); opacity: .35; transition: all .4s; }
.roll-meter img.got { filter: none; opacity: 1; animation: boing .5s; }
.arena { position: relative; flex: 1; width: 100%; max-width: 480px; }
.arena-start {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; text-align: center;
}
.big-roll { width: min(62vw, 230px); animation: floaty 2.4s ease-in-out infinite; filter: drop-shadow(0 14px 14px rgba(47,95,153,.25)); }
.big-roll img { width: 100%; height: auto; animation: tilt 1.6s ease-in-out infinite alternate; }
.roll img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.arena-text { margin: 0; font-weight: 700; max-width: 260px; }
.btn-dark { background: #2f5f99; box-shadow: 4px 4px 0 #b9d9f2; }
.roll {
  position: absolute; width: 112px; height: 96px; margin: -48px 0 0 -56px;
  animation: rollIn .35s cubic-bezier(.2,1.6,.4,1) both, drift 2.8s ease-in-out both;
  filter: drop-shadow(0 8px 10px rgba(47,95,153,.28));
}
.roll img { animation: tilt 1.2s ease-in-out infinite alternate; }
.stickered { position: relative; width: 100%; }
.stickered .sticker {
  position: absolute; right: -6px; bottom: 34px; width: 40%; max-width: 140px;
  transform: rotate(10deg); filter: drop-shadow(0 6px 8px rgba(0,0,0,.3));
  animation: stickOn .5s .25s cubic-bezier(.2,1.6,.4,1) both;
}
.quest-img { width: min(60vw, 220px); margin: 0 auto 10px; animation: floaty 2.4s ease-in-out infinite; }
.roll.leaving { animation: rollOut .35s forwards; pointer-events: none; }
.roll.caught { animation: caught .35s forwards; pointer-events: none; }
.plus {
  position: absolute; font-family: var(--f-pixel); font-size: 14px; color: #2f5f99;
  transform: translate(-50%, -50%); pointer-events: none; animation: plusUp .9s ease-out forwards;
}

/* ============ Nivel 4 · Dinosaurios ============ */
#scene-dino { justify-content: flex-start; }
.warning {
  margin: auto; width: min(100%, 360px); text-align: center; overflow: hidden;
  background: #17170f; border: 3px solid var(--gold); border-radius: 14px;
  box-shadow: 0 0 50px rgba(255,209,102,.25);
  animation: rise .6s both;
}
.warn-stripe {
  height: 18px;
  background: repeating-linear-gradient(-45deg, var(--gold) 0 12px, #17170f 12px 24px);
  background-size: 34px 34px;
  animation: stripes 1s linear infinite;
}
.warn-title { color: var(--gold); font-size: 17px; margin: 24px 0 14px; }
.warning p { margin: 6px 20px; line-height: 1.4; }
.blink { animation: blink 1s steps(2, start) infinite; }
.forest { flex: 1; width: 100%; max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.forest-stage { position: relative; flex: 1; width: 100%; }
.spot {
  position: absolute; width: clamp(104px, 32vw, 150px); aspect-ratio: 5 / 4;
  transform: translateX(-50%);
}
.spot .bush { position: absolute; left: 0; bottom: 0; width: 100%; height: 75%; z-index: 2; transform-origin: 50% 100%; }
.spot .dino-wrap { position: absolute; left: -20%; right: -20%; top: -160%; bottom: 14%; z-index: 1; overflow: hidden; pointer-events: none; }
.spot .dino { position: absolute; left: 26%; bottom: 0; width: 48%; transform: translateY(45%); }
.spot .dino svg { width: 100%; height: auto; display: block; }
.spot.has-dino .dino { animation: peek var(--p, 5s) ease-in-out infinite; animation-delay: var(--pd, 0s); }
.spot.found .dino { animation: jumpOut .6s cubic-bezier(.2,1.6,.4,1) forwards; }
.spot.flip .dino svg { transform: scaleX(-1); }
.spot.rustle .bush { animation: rustle .5s ease; }
.spot .tag {
  position: absolute; left: 50%; top: -58%; z-index: 3; white-space: nowrap;
  transform: translateX(-50%); font-size: 1.3rem; pointer-events: none;
  animation: revealUp 1.1s ease forwards;
}

.big-dino-layer {
  position: fixed; inset: 0; z-index: 45; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px;
  padding: 0 20px;
  background: radial-gradient(circle at 50% 45%, rgba(40,90,60,.55), rgba(5,15,10,.85));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.big-dino-layer.shake { animation: screenShake .55s; }
.walker { position: relative; width: min(74vw, 340px); animation: walkIn 2.6s ease-out both; }
.walker svg { width: 100%; height: auto; display: block; animation: bob .35s ease-in-out infinite alternate; }
.walker .leg { transform-box: fill-box; transform-origin: 50% 0%; }
.walker .leg-a { animation: step .35s ease-in-out infinite alternate; }
.walker .leg-b { animation: step .35s ease-in-out infinite alternate-reverse; }
.walker.stopped svg { animation: roar .1s linear 8; }
.walker.stopped .leg { animation: none; }
.bubble {
  position: absolute; top: -26%; left: 52%; z-index: 2;
  background: #fff; color: var(--ink); font-family: var(--f-pixel);
  font-size: clamp(18px, 6.5vw, 30px); padding: 14px 18px; border-radius: 18px;
  transform: scale(0); transform-origin: 10% 100%;
}
.bubble::after {
  content: ''; position: absolute; left: 18%; bottom: -14px;
  border-top: 16px solid #fff; border-right: 16px solid transparent;
}
.walker.stopped .bubble { animation: bubblePop .45s .05s cubic-bezier(.2,1.8,.4,1) forwards; }
.translation { text-align: center; opacity: 0; transform: translateY(16px); transition: all .7s ease; pointer-events: none; }
.translation.show { opacity: 1; transform: none; pointer-events: auto; }
.t-small { margin: 0; font-size: .9rem; opacity: .7; letter-spacing: .1em; text-transform: uppercase; }
.t-big { margin: 4px 0 20px; font-family: var(--f-hand); font-size: clamp(2.4rem, 11vw, 3.4rem); line-height: 1; }

/* ============ Carta ============ */
#scene-letter { gap: 18px; padding-bottom: calc(env(safe-area-inset-bottom) + 60px); user-select: text; -webkit-user-select: text; }
.made-it {
  font-family: var(--f-hand); font-weight: 700;
  font-size: clamp(3.2rem, 15vw, 4.8rem); margin: 3vh 0 0; line-height: 1;
  text-shadow: 0 0 34px rgba(203,182,255,.6);
  animation: rise 1s ease both;
}
.envelope {
  position: relative; flex: none; width: min(78vw, 300px); aspect-ratio: 3 / 2; margin-top: 7vh;
  perspective: 900px; animation: floaty 3s ease-in-out infinite;
}
.envelope > span { position: absolute; }
.env-back { inset: 0; background: #9f7ee6; border-radius: 10px; }
.env-letter {
  left: 7%; right: 7%; top: 7%; bottom: 8%; border-radius: 5px;
  background: repeating-linear-gradient(transparent 0 13px, rgba(124,77,219,.18) 13px 14px), var(--paper);
  transition: transform .8s .25s ease;
}
.env-front {
  inset: 0; z-index: 2; border-radius: 10px;
  background: linear-gradient(#cbb5fb, #b89bf6);
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
}
.env-flap {
  left: 0; right: 0; top: 0; height: 60%; z-index: 3;
  background: #b08ff4; clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top; transition: transform .6s ease;
}
.seal {
  left: 50%; top: 56%; z-index: 4; width: 54px; height: 54px; margin: -27px 0 0 -27px;
  border-radius: 50%; display: grid; place-items: center; font-size: 22px;
  background: radial-gradient(circle at 35% 35%, #ff9cc8, #cf3f7c);
  box-shadow: 0 4px 10px rgba(0,0,0,.3), inset 0 -3px 0 rgba(0,0,0,.15);
  transition: opacity .3s, transform .3s;
}
.envelope.open { animation: none; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .seal { opacity: 0; transform: scale(1.6); }
.envelope.open .env-letter { transform: translateY(-48%); z-index: 1; }

.letter {
  position: relative; flex: none; width: min(100%, 420px);
  background: repeating-linear-gradient(transparent 0 33px, rgba(124,77,219,.15) 33px 34px) 0 30px / 100% 100% no-repeat, var(--paper);
  color: var(--ink); border-radius: 6px; padding: 30px 24px 26px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.65);
  font-family: var(--f-hand); font-size: 1.5rem; line-height: 34px;
  animation: unfold .9s cubic-bezier(.2,1,.3,1) both;
  transform-origin: top center;
}
.letter::before {
  content: ''; position: absolute; top: -13px; left: 50%; width: 110px; height: 28px;
  transform: translateX(-50%) rotate(3deg);
  background: repeating-linear-gradient(-45deg, rgba(203,182,255,.9) 0 8px, rgba(230,218,255,.9) 8px 16px);
}
.letter p { margin: 0 0 34px; white-space: pre-line; opacity: 0; animation: ink .9s ease forwards; animation-delay: calc(var(--i) * .85s + .6s); }
.letter p.sign { text-align: right; margin: 0; font-weight: 700; }
.letter p.big { font-size: 1.9rem; font-weight: 700; }

.gallery-wrap {
  --slide: min(66vw, 270px);
  flex: none; width: calc(100% + 36px); max-width: 620px; text-align: center; animation: rise .8s both;
}
.gallery-wrap h3 { font-family: var(--f-hand); font-size: clamp(1.9rem, 8.5vw, 2.4rem); margin: 10px 0 0; line-height: 1.1; padding: 0 18px; }
.gallery-sub { margin: 4px 0 0; font-size: .85rem; color: var(--lav); opacity: .8; padding: 0 18px; }
.carousel { position: relative; }
.gallery {
  position: relative; display: flex; gap: 10px;
  overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  padding: 30px calc(50% - var(--slide) / 2) 24px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery .slide {
  flex: 0 0 var(--slide); scroll-snap-align: center; scroll-snap-stop: always;
  padding-bottom: 4px; cursor: zoom-in;
  transform: rotate(var(--r)) scale(.84); opacity: .5;
  transition: transform .4s cubic-bezier(.2,1,.3,1), opacity .4s;
}
.gallery .slide.active { transform: rotate(var(--r)) scale(1); opacity: 1; }
.gallery .slide:nth-child(odd) { --r: 2deg; }
.gallery .slide:nth-child(even) { --r: -2deg; }
.gallery .slide:nth-child(3n)::before { background: repeating-linear-gradient(45deg, rgba(255,209,102,.85) 0 8px, rgba(255,230,170,.85) 8px 16px); }
.gallery .slide img { pointer-events: none; }
.car-arrow {
  position: absolute; top: 50%; z-index: 2; width: 44px; height: 44px; margin-top: -22px;
  border-radius: 50%; display: grid; place-items: center; padding-bottom: 3px;
  background: rgba(255,255,255,.92); color: var(--ink); font-size: 30px; line-height: 1; font-weight: 700;
  box-shadow: 0 8px 20px -6px rgba(0,0,0,.5); transition: opacity .3s, transform .15s;
}
.car-arrow:active { transform: scale(.9); }
.car-arrow.prev { left: max(8px, calc(50% - var(--slide) / 2 - 30px)); }
.car-arrow.next { right: max(8px, calc(50% - var(--slide) / 2 - 30px)); }
.car-arrow:disabled { opacity: 0; pointer-events: none; }
.gal-counter { margin: 0 0 12px; font-size: 10px; color: var(--lilac); letter-spacing: .1em; }
.thumbs {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 18px 10px;
  scrollbar-width: none; scroll-behavior: smooth;
}
.thumbs::-webkit-scrollbar { display: none; }
.thumbs::before, .thumbs::after { content: ''; margin: auto; }
.thumb {
  flex: 0 0 54px; height: 54px; border-radius: 12px; overflow: hidden;
  border: 2px solid rgba(255,255,255,.15); opacity: .5; transition: all .3s;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.active { opacity: 1; border-color: var(--pink); transform: translateY(-3px); box-shadow: 0 6px 14px -4px rgba(255,126,182,.6); }

/* Visor */
.lightbox {
  position: fixed; inset: 0; z-index: 58;
  background: rgba(8,4,18,.95);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; transition: opacity .25s;
}
.lightbox.show { opacity: 1; }
.lb-stage {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top) + 64px) 14px calc(env(safe-area-inset-bottom) + 96px);
}
.lb-img {
  max-width: 100%; max-height: calc(100vh - 170px); max-height: calc(100dvh - 170px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  object-fit: contain; background: var(--paper); padding: 8px; border-radius: 6px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.8);
  touch-action: pan-y; -webkit-user-drag: none; user-select: none; cursor: grab;
  transition: transform .3s cubic-bezier(.2,1,.3,1), opacity .3s;
}
.lb-img.dragging { transition: none; cursor: grabbing; }
.lb-close {
  position: absolute; z-index: 2; top: calc(env(safe-area-inset-top) + 14px); right: 14px;
  width: 44px; height: 44px; border-radius: 50%; font-size: 18px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2);
}
.lb-arrow {
  position: absolute; z-index: 2; top: 50%; width: 48px; height: 48px; margin-top: -24px;
  border-radius: 50%; font-size: 32px; line-height: 1; padding-bottom: 4px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2);
}
.lb-arrow.prev { left: 10px; }
.lb-arrow.next { right: 10px; }
.lb-bottom { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 18px); text-align: center; pointer-events: none; }
.lb-caption { margin: 0; font-size: 1.6rem; }
.lb-count { margin: 6px 0 0; font-size: 10px; color: var(--lilac); letter-spacing: .1em; }
@media (max-width: 520px) {
  .lb-arrow { top: auto; bottom: calc(env(safe-area-inset-bottom) + 20px); margin-top: 0; width: 46px; height: 46px; }
  .lb-arrow.prev { left: 20px; }
  .lb-arrow.next { right: 20px; }
}
.one-last { text-align: center; padding: 6px 0 30px; animation: rise .8s .4s both; }
.one-last p { font-family: var(--f-hand); font-size: 2.3rem; margin: 0 0 14px; }

/* ============ Regalo ============ */
#scene-gift { gap: 16px; }
.gift-kicker { font-family: var(--f-hand); font-size: 2.5rem; margin: 0; }
.gift-box { position: relative; width: 180px; height: 190px; margin-top: 30px; animation: giftWiggle 2.4s ease-in-out infinite; }
.gift-box .box {
  position: absolute; left: 10px; right: 10px; bottom: 0; height: 128px;
  background: linear-gradient(135deg, #ff8fc0, #de4f95); border-radius: 8px;
  box-shadow: inset 0 -14px 0 rgba(0,0,0,.08), 0 20px 30px -10px rgba(0,0,0,.5);
}
.gift-box .box::before, .gift-box .lid::before {
  content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 26px; margin-left: -13px; background: var(--gold);
}
.gift-box .lid {
  position: absolute; left: 0; right: 0; top: 32px; height: 42px; z-index: 2;
  background: linear-gradient(135deg, #ffa6cf, #e862a7); border-radius: 8px;
  transition: transform .8s cubic-bezier(.3,1.3,.5,1), opacity .8s;
}
.bow { position: absolute; left: 50%; top: -30px; }
.bow::before, .bow::after {
  content: ''; position: absolute; top: 0; width: 42px; height: 34px;
  border: 9px solid var(--gold); border-radius: 50% 50% 8px 50%;
}
.bow::before { right: -2px; transform: rotate(-12deg); }
.bow::after { left: -2px; transform: rotate(12deg) scaleX(-1); }
.gift-box.open { animation: giftOpen .9s ease forwards; pointer-events: none; }
.gift-box.open .lid { transform: translateY(-150px) rotate(-30deg); opacity: 0; }

.gift-card {
  position: relative; width: min(100%, 360px); text-align: center;
  background: var(--paper); color: var(--ink); border-radius: 20px; padding: 24px 22px 22px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.6);
  animation: cardRise .9s cubic-bezier(.2,1.3,.4,1) both;
  max-height: calc(100% - 60px); overflow-y: auto;
}
.gift-card::before, .gift-card::after {
  content: ''; position: absolute; top: var(--notch, 96px); width: 26px; height: 26px; border-radius: 50%; background: #2a1450;
}
.gift-card::before { left: -13px; }
.gift-card::after { right: -13px; }
.gc-label { font-size: 11px; color: var(--purple); letter-spacing: .15em; margin: 0; }
.gc-title { font-family: var(--f-hand); font-size: 2.6rem; line-height: 1; margin: 12px 0 18px; }
.gc-divider { border: 0; border-top: 2px dashed rgba(124,77,219,.35); margin: 0 0 16px; }
.gc-text { margin: 0 0 10px; font-size: 1.05rem; line-height: 1.45; }
.gc-detail { margin: 0 0 16px; font-weight: 800; color: var(--purple); }
.gc-photo { border-radius: 12px; width: 100%; max-height: 32vh; object-fit: cover; margin-bottom: 16px; }
.gc-bday { font-family: var(--f-hand); font-size: 1.8rem; margin: 6px 0 14px; }
.gift-card .btn-ghost { color: var(--ink); border-color: rgba(43,29,69,.25); background: rgba(43,29,69,.05); }

/* ============ Animaciones ============ */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes sway { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes eq { from { height: 15%; } to { height: 100%; } }
@keyframes pulse {
  0%, 100% { box-shadow: 0 12px 30px -10px rgba(255,126,182,.7), 0 0 0 0 rgba(255,126,182,.45); }
  50% { box-shadow: 0 12px 30px -10px rgba(255,126,182,.7), 0 0 0 14px rgba(255,126,182,0); }
}
@keyframes pulseWhite { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.5); } 100% { box-shadow: 0 0 0 18px rgba(255,255,255,0); } }
@keyframes boing { 0% { transform: scale(1); } 30% { transform: scale(1.25, .85); } 55% { transform: scale(.9, 1.12); } 80% { transform: scale(1.05, .97); } 100% { transform: scale(1); } }
@keyframes revealUp {
  0% { transform: translate(-50%, 10px) scale(0); opacity: 0; }
  30% { transform: translate(-50%, -24px) scale(1.2); opacity: 1; }
  75% { transform: translate(-50%, -38px) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -52px) scale(.9); opacity: 0; }
}
@keyframes revealStay { from { transform: translate(-50%, 10px) scale(0); } to { transform: translate(-50%, -30px) scale(1.2); } }
@keyframes floaty { 0%, 100% { translate: 0 0; } 50% { translate: 0 -10px; } }
@keyframes rollIn { from { transform: scale(0) rotate(-90deg); } to { transform: scale(1) rotate(0); } }
@keyframes drift { from { translate: 0 0; } to { translate: var(--dx) var(--dy); } }
@keyframes rollOut { to { transform: scale(0); opacity: 0; } }
@keyframes caught { to { transform: scale(1.6); opacity: 0; } }
@keyframes plusUp { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -60px; } }
@keyframes stickOn { from { opacity: 0; transform: scale(1.8) rotate(-10deg); } to { opacity: 1; transform: rotate(10deg); } }
@keyframes tilt { from { transform: rotate(-7deg); } to { transform: rotate(7deg); } }
@keyframes cloudDrift { from { transform: translateX(-220px); } to { transform: translateX(calc(100vw + 40px)); } }
@keyframes stripes { from { background-position: 0 0; } to { background-position: 34px 0; } }
@keyframes blink { to { visibility: hidden; } }
@keyframes peek {
  0%, 68%, 100% { transform: translateY(45%); }
  76%, 90% { transform: translateY(-20%); }
}
@keyframes jumpOut { 0% { transform: translateY(45%); } 60% { transform: translateY(-95%); } 100% { transform: translateY(-70%); } }
@keyframes rustle { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-6deg); } 45% { transform: rotate(5deg); } 70% { transform: rotate(-3deg); } }
@keyframes walkIn { from { transform: translateX(-130vw); } to { transform: translateX(0); } }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-6px); } }
@keyframes step { from { transform: rotate(-22deg); } to { transform: rotate(22deg); } }
@keyframes roar { 0% { transform: translate(0, 0); } 25% { transform: translate(-3px, 1px); } 50% { transform: translate(3px, -1px); } 75% { transform: translate(-2px, -1px); } }
@keyframes bubblePop { from { transform: scale(0) rotate(-12deg); } to { transform: scale(1) rotate(-4deg); } }
@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-8px, 4px); } 30% { transform: translate(7px, -5px); }
  45% { transform: translate(-6px, -3px); } 60% { transform: translate(5px, 4px); } 80% { transform: translate(-3px, 2px); }
}
@keyframes unfold { from { opacity: 0; transform: scaleY(.3) translateY(-30px); } to { opacity: 1; transform: none; } }
@keyframes ink { from { opacity: 0; filter: blur(4px); transform: translateY(6px); } to { opacity: 1; filter: none; transform: none; } }
@keyframes floatUp {
  0% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-65vh) rotate(8deg); }
  100% { transform: translateY(-130vh) rotate(-8deg); }
}
@keyframes giftWiggle {
  0%, 70%, 100% { transform: rotate(0); }
  75% { transform: rotate(-7deg); } 80% { transform: rotate(6deg); } 85% { transform: rotate(-5deg); } 90% { transform: rotate(3deg); }
}
@keyframes giftOpen { 0% { transform: scale(1); } 20% { transform: scale(1.15, .85); } 60% { transform: scale(1); opacity: 1; } 100% { transform: scale(.6) translateY(40px); opacity: 0; } }
@keyframes cardRise { from { opacity: 0; transform: translateY(80px) scale(.7) rotate(-6deg); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .tulip-row svg, .tulip-btn svg, .float-tulip, .envelope, .gift-box, .big-roll, .btn-pulse { animation: none !important; }
}

@media (max-height: 700px) {
  .player { gap: 7px; padding: 16px 18px; }
  .vinyl-wrap { width: min(40vw, 150px, 22vh); }
  .track-sub { font-size: .88rem; min-height: 0; }
  .play-btn { width: 60px; height: 60px; }
  .made-it { margin-top: 1vh; }
  .envelope { margin-top: 4vh; }
}
@media (max-height: 640px) {
  .scene { padding-top: calc(env(safe-area-inset-top) + 62px); gap: 10px; }
  .track-title { font-size: 2rem; }
  .scene-title { font-size: 2.2rem; }
  .big-roll { width: 110px; height: 110px; }
}
