/* ESTILOS. El primer bloque define colores, tipos y madera; el resto es el diseño de cada parte. */
/* Base para uso fuera de Claude (la plataforma la añade sola al publicar) */
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
img { max-width: 100%; }

/* Concepto: una aurora violeta, rosa y menta sobre fondo índigo. Un sobre sellado hasta el 23 de octubre (con PIN de vista previa), y tras abrirlo cinco secciones: carta con tarta 3D, vales, recuerdos, detalles y el regalo en camino. */
:root {
  --paper: #f6f4ff;
  --ink: #1d1a3b;
  --rose: #ff4f87;
  --gold: #ffd45e;
  --indigo: #5b4bff;
  --teal: #0b8f78;
  --muted: #6b6890;
  --line: #d9d5f2;
  --tint: #ece9ff;
  --f-display: "Gloock", Georgia, serif;
  --f-body: "Figtree", system-ui, sans-serif;
  --f-hand: "Caveat", "Segoe Script", cursive;
  --w1: #e6c493;
  --w2: #cf9f63;
  --w3: #b4814a;
  --w4: #8a5d31;
  --brown: #4a2f12;
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='n' x='0' y='0' width='100%25' height='100%25'><feTurbulence type='fractalNoise' baseFrequency='0.008 0.3' numOctaves='3' seed='7'/><feColorMatrix values='0 0 0 0 0.42  0 0 0 0 0.25  0 0 0 0 0.09  0 0 0 1.15 -0.3'/></filter><rect width='300' height='300' filter='url(%23n)'/></svg>");
  --planks: repeating-linear-gradient(0deg, transparent 0 33px, rgba(70,40,12,.30) 33px 35px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background-color: #15133a;
  background-image:
    radial-gradient(60% 45% at 12% 6%, rgba(139,124,255,.80), transparent 70%),
    radial-gradient(55% 40% at 95% 30%, rgba(25,195,161,.38), transparent 70%),
    radial-gradient(75% 55% at 82% 100%, rgba(255,95,150,.70), transparent 70%),
    linear-gradient(180deg, #15133a 0%, #2a1f6e 60%, #3b2a8c 100%);
  background-attachment: fixed;
  color: var(--paper);
  font-family: var(--f-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 24px;
  overflow-x: hidden;
}
body.has-bar { padding-bottom: 150px; }
#stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.star { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff; opacity: .7; animation: twinkle 3.2s ease-in-out infinite; }
@keyframes twinkle { 0%,100% { opacity: .15; transform: scale(.7); } 50% { opacity: .95; transform: scale(1.2); } }

main { position: relative; z-index: 1; min-height: calc(100vh - 48px); display: grid; align-content: center; justify-items: center; }
.scene { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 26px; text-align: center; }
[hidden] { display: none !important; }

/* ---------- Sobre y bloqueo ---------- */
.intro-title { font-family: var(--f-hand); font-size: clamp(30px, 8vw, 40px); margin: 0; text-wrap: balance; line-height: 1.1; }
.env-btn { all: unset; cursor: pointer; display: block; width: min(82vw, 360px); -webkit-tap-highlight-color: transparent; }
.env-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 8px; border-radius: 8px; }
.env { position: relative; width: min(82vw, 360px); aspect-ratio: 3 / 2; background: #e3deff; border-radius: 8px; box-shadow: 0 24px 50px rgba(10,8,40,.5); perspective: 900px; animation: float 4.5s ease-in-out infinite; }
.env-btn .env { width: 100%; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.env .letter { position: absolute; left: 7%; right: 7%; top: 8%; height: 80%; background: #fff; border-radius: 4px; transition: transform .9s cubic-bezier(.3,.9,.3,1) .35s; z-index: 1; }
.env .letter::before, .env .letter::after { content: ""; position: absolute; left: 14%; right: 14%; height: 3px; background: #d9d5f2; border-radius: 2px; }
.env .letter::before { top: 24%; }
.env .letter::after { top: 40%; right: 38%; }
.env .pocket { position: absolute; inset: 0; background: #efecff; z-index: 2; border-radius: 8px; clip-path: polygon(0 0, 50% 52%, 100% 0, 100% 100%, 0 100%); }
.env .flap { position: absolute; left: 0; right: 0; top: 0; height: 56%; background: #cbc3ff; z-index: 3; clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top center; transition: transform .6s ease, z-index 0s .3s; }
.env .seal { position: absolute; left: 50%; top: 46%; width: 54px; height: 54px; margin: -27px 0 0 -27px; z-index: 4; border-radius: 50%; background: var(--rose); display: grid; place-items: center; box-shadow: 0 6px 14px rgba(255,79,135,.5); transition: opacity .3s; }
.env .seal svg { width: 26px; height: 26px; fill: #fff; }
.env.open { animation: none; }
.env.open .flap { transform: rotateX(180deg); z-index: 0; }
.env.open .letter { transform: translateY(-62%); }
.env.open .seal { opacity: 0; }
.env.sealed { animation: none; filter: saturate(.8); }
.hint { font-size: 14px; letter-spacing: .14em; text-transform: uppercase; opacity: .85; margin: 0; }
.lock-title { font-family: var(--f-display); font-size: clamp(28px, 8vw, 40px); margin: 0; line-height: 1.1; text-wrap: balance; }
.lock-count { margin: 0; font-size: 17px; font-variant-numeric: tabular-nums; opacity: .92; }
.early { font: 600 13px var(--f-body); letter-spacing: .08em; text-transform: uppercase; color: var(--paper); background: transparent; border: 1px solid rgba(246,244,255,.4); border-radius: 999px; padding: 9px 16px; cursor: pointer; opacity: .75; }
.early:hover { opacity: 1; }
.pinform { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }
.pinform input { font: 600 20px var(--f-body); letter-spacing: .4em; text-align: center; width: 9em; padding: 12px; border-radius: 12px; border: 2px solid rgba(246,244,255,.5); background: rgba(246,244,255,.12); color: var(--paper); }
.pinform input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.pinerr { margin: 0; color: #ffc2d6; font-size: 14px; }

/* ---------- Estructura ---------- */
.app { width: min(100%, 640px); display: flex; flex-direction: column; gap: 20px; align-items: stretch; text-align: left; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.tab { font: 600 15px var(--f-body); color: var(--paper); background: rgba(246,244,255,.12); border: 1px solid rgba(246,244,255,.35); padding: 10px 18px; border-radius: 999px; cursor: pointer; backdrop-filter: blur(6px); }
.tab[aria-selected="true"] { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.tab:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.panel { display: flex; flex-direction: column; gap: 20px; }

.card { background: var(--paper); color: var(--ink); border-radius: 14px; padding: clamp(24px, 6vw, 40px); box-shadow: 0 30px 60px rgba(10,8,40,.5); display: flex; flex-direction: column; gap: 20px; text-align: left; min-width: 0; }
.card h1, .card h2 { font-family: var(--f-display); font-weight: 400; margin: 0; line-height: 1.08; text-wrap: balance; color: var(--ink); }
.card h1 { font-size: clamp(34px, 9vw, 52px); }
.card h2 { font-size: clamp(28px, 7.5vw, 40px); }
.card h3.sub { font-family: var(--f-display); font-weight: 400; font-size: 24px; margin: 0; color: var(--ink); }
.card h1 em { font-style: normal; color: var(--rose); }
.lead { margin: 0; font-size: 16px; line-height: 1.55; max-width: 60ch; }
.note { font-family: var(--f-hand); font-size: clamp(23px, 5.6vw, 28px); line-height: 1.35; margin: 0; }
.note + .note { margin-top: -6px; }
.sign { font-family: var(--f-hand); font-size: 30px; color: var(--rose); margin: 0; }
.since { margin: 0; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--indigo); }
.ej { display: inline-block; font: 600 11px var(--f-body); letter-spacing: .12em; text-transform: uppercase; color: #8a5a00; background: #ffe9a8; border-radius: 999px; padding: 3px 9px; }

/* ---------- Tarta ---------- */
.cake-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 4px; }
.cake3d { width: min(100%, 400px); aspect-ratio: 1 / 1.02; touch-action: pan-y; cursor: grab; border-radius: 14px; background: radial-gradient(70% 55% at 50% 40%, #ece9ff, #f6f4ff 70%); user-select: none; -webkit-user-select: none; }
.cake3d:active { cursor: grabbing; }
.cake3d canvas { display: block; width: 100%; height: 100%; }
.cake { width: min(86%, 310px); height: auto; overflow: visible; cursor: pointer; }
.small { margin: 0; font-size: 13px; color: var(--muted); letter-spacing: .04em; }
.flame { transform-origin: 50% 100%; transform-box: fill-box; animation: flick .45s ease-in-out infinite alternate; transition: opacity .35s, transform .35s; }
@keyframes flick { from { transform: scale(1,1) rotate(-3deg); } to { transform: scale(.92,1.1) rotate(3deg); } }
.glow { animation: pulse 1.3s ease-in-out infinite alternate; transition: opacity .35s; }
@keyframes pulse { from { opacity: .55; } to { opacity: 1; } }
.out .flame { opacity: 0; transform: scale(.2); animation: none; }
.out .glow { opacity: 0; animation: none; }
.smoke { opacity: 0; }
.out .smoke { animation: smoke 1.8s ease-out forwards; }
@keyframes smoke { 0% { opacity: .85; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-28px); } }
.spark { transform-box: fill-box; transform-origin: center; animation: spark 2.6s ease-in-out infinite; }
@keyframes spark { 0%,100% { transform: scale(.4); opacity: .3; } 50% { transform: scale(1); opacity: 1; } }
.wish { font-family: var(--f-display); font-size: 24px; margin: 0; text-align: center; color: var(--rose); text-wrap: balance; }
.afterblow { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.btn { font: 600 16px var(--f-body); padding: 14px 26px; border: 0; border-radius: 999px; cursor: pointer; background: var(--rose); color: #fff; box-shadow: 0 8px 20px rgba(255,79,135,.4); }
.btn:hover { filter: brightness(1.06); }
.btn:focus-visible, .ghost:focus-visible, .chip:focus-visible, .mini:focus-visible, .flip:focus-visible, .opt:focus-visible, summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.ghost { font: 600 15px var(--f-body); padding: 12px 22px; border-radius: 999px; cursor: pointer; background: transparent; color: var(--ink); border: 2px solid var(--ink); text-decoration: none; display: inline-block; }

/* ---------- Vales ---------- */
.vales-head { display: flex; flex-direction: column; gap: 14px; }
.counter { margin: 0; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--indigo); font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font: 600 14px var(--f-body); padding: 8px 16px; border-radius: 999px; cursor: pointer; background: transparent; color: var(--ink); border: 1.5px solid #c9c4ea; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.list { display: flex; flex-direction: column; gap: 16px; }

.scratch { position: relative; border-radius: 14px; overflow: hidden; min-height: 150px; background: var(--paper); color: var(--ink); box-shadow: 0 20px 40px rgba(10,8,40,.4); }
.scratch .under { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 6px; padding: 18px; }
.scratch .under b { font-family: var(--f-display); font-weight: 400; font-size: 24px; text-wrap: balance; }
.scratch .under span { font-size: 15px; line-height: 1.4; }
.scratch canvas { position: relative; display: block; width: 100%; height: 150px; touch-action: none; cursor: crosshair; }

.ticket { --stub: 84px; --c: var(--indigo); --on: #fff; position: relative; display: grid; grid-template-columns: var(--stub) minmax(0, 1fr); background: #fff; color: var(--ink); border-radius: 12px; min-height: 132px; filter: drop-shadow(0 8px 14px rgba(10,8,40,.28)); -webkit-mask: radial-gradient(circle 9px at var(--stub) 0, #0000 98%, #000) top / 100% 51% no-repeat, radial-gradient(circle 9px at var(--stub) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat; mask: radial-gradient(circle 9px at var(--stub) 0, #0000 98%, #000) top / 100% 51% no-repeat, radial-gradient(circle 9px at var(--stub) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat; }
.ticket.cat-planes { --c: var(--indigo); }
.ticket.cat-mimos { --c: #e8346f; }
.ticket.cat-divertidos { --c: var(--teal); }
.ticket.cat-especial { --c: var(--gold); --on: #1d1a3b; }
.stub { background: var(--c); color: var(--on); display: grid; place-items: center; border-radius: 12px 0 0 12px; padding: 10px 4px; }
.stub span { writing-mode: vertical-rl; transform: rotate(180deg); font-weight: 600; letter-spacing: .2em; text-transform: uppercase; font-size: 13px; }
.tbody { padding: 16px 16px 16px 20px; display: flex; flex-direction: column; gap: 8px; border-left: 2px dashed var(--line); min-width: 0; }
.tbody h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 22px; line-height: 1.15; text-wrap: balance; }
.tbody p { margin: 0; font-size: 15px; line-height: 1.45; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; align-items: center; }
.mini { font: 600 14px var(--f-body); padding: 9px 16px; border-radius: 999px; cursor: pointer; border: 0; background: var(--c); color: var(--on); text-decoration: none; display: inline-block; }
.mini.alt { background: transparent; color: var(--ink); border: 1.5px solid #c9c4ea; }
.mini[disabled] { opacity: .45; cursor: not-allowed; }
.ticket.done .tbody h3, .ticket.done .tbody p { opacity: .55; }
.ticket.locked { filter: drop-shadow(0 8px 14px rgba(10,8,40,.2)) grayscale(.6); }
.stamp { position: absolute; right: 14px; top: 12px; transform: rotate(-9deg); border: 3px solid var(--rose); color: #e8346f; padding: 2px 10px; border-radius: 6px; font-weight: 600; letter-spacing: .14em; font-size: 14px; background: rgba(255,255,255,.75); animation: stampin .35s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes stampin { from { transform: rotate(-9deg) scale(2); opacity: 0; } to { transform: rotate(-9deg) scale(1); opacity: 1; } }
.copybox { width: 100%; font: 14px var(--f-body); padding: 8px 10px; border-radius: 8px; border: 1.5px solid #c9c4ea; color: var(--ink); background: #fff; }
.tip { font-size: 13px; color: var(--muted); margin: 0; }

/* ---------- Recuerdos ---------- */
.gal { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
.gal figure { margin: 0; flex: 0 0 min(78%, 300px); scroll-snap-align: start; display: flex; flex-direction: column; gap: 8px; }
.gal .ph { aspect-ratio: 4 / 5; width: 100%; border-radius: 12px; overflow: hidden; background: var(--tint); border: 2px dashed #b9b1e8; display: grid; place-items: center; color: var(--muted); font-size: 14px; text-align: center; padding: 12px; }
.gal img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal figcaption { font-family: var(--f-hand); font-size: 24px; line-height: 1.2; }
.tl { list-style: none; margin: 0; padding: 0 0 0 22px; display: flex; flex-direction: column; gap: 22px; border-left: 3px solid var(--line); }
.tl li { position: relative; }
.tl li::before { content: ""; position: absolute; left: -31px; top: 6px; width: 15px; height: 15px; border-radius: 50%; background: var(--rose); border: 3px solid var(--paper); box-shadow: 0 0 0 2px var(--rose); }
.tl .d { margin: 0; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--indigo); }
.tl h4 { margin: 2px 0 4px; font-family: var(--f-display); font-weight: 400; font-size: 22px; }
.tl p { margin: 0; font-size: 15px; line-height: 1.45; }

/* ---------- Detalles ---------- */
.when { border: 1.5px solid #c9c4ea; border-radius: 12px; background: #fff; }
.when + .when { margin-top: 10px; }
.when summary { cursor: pointer; padding: 14px 16px; font-family: var(--f-display); font-size: 19px; list-style: none; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.when summary::-webkit-details-marker { display: none; }
.when summary::after { content: "+"; font: 600 22px var(--f-body); color: var(--rose); }
.when[open] summary::after { content: "\2212"; }
.when p { margin: 0; padding: 0 16px 16px; font-family: var(--f-hand); font-size: 25px; line-height: 1.3; }
.flipgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.flip { perspective: 800px; background: none; border: 0; padding: 0; cursor: pointer; height: 150px; font: inherit; color: inherit; }
.flip .in { position: relative; width: 100%; height: 100%; transition: transform .6s; transform-style: preserve-3d; }
.flip[aria-pressed="true"] .in { transform: rotateY(180deg); }
.flip .f, .flip .b { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; border-radius: 12px; backface-visibility: hidden; -webkit-backface-visibility: hidden; text-align: center; }
.flip .f { background: var(--ink); color: var(--paper); font-family: var(--f-display); font-size: 30px; }
.flip .b { background: var(--tint); color: var(--ink); transform: rotateY(180deg); font-size: 15px; line-height: 1.35; }
.capsule { display: flex; flex-direction: column; gap: 10px; background: var(--tint); border-radius: 12px; padding: 18px; }
.capsule p { margin: 0; line-height: 1.5; }
.capsule .big { font-family: var(--f-display); font-size: 28px; color: var(--rose); }
.gamecv { width: 100%; height: 300px; border-radius: 12px; background: #1d1a3b; touch-action: none; display: block; cursor: pointer; }
.gameinfo { margin: 0; font-size: 15px; }
.qtext { font-family: var(--f-display); font-size: 22px; margin: 0; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { font: 600 15px var(--f-body); text-align: left; padding: 12px 14px; border-radius: 10px; border: 1.5px solid #c9c4ea; background: #fff; color: var(--ink); cursor: pointer; }
.opt.ok { background: #d8f5ec; border-color: var(--teal); }
.opt.no { background: #ffe0ea; border-color: #e8346f; }
.dashed { border: 2px dashed #b9b1e8; border-radius: 12px; padding: 16px; color: var(--muted); font-size: 14px; }
audio { width: 100%; }
.song-player { display: block; width: 100%; max-width: 360px; aspect-ratio: 16 / 9; border: 0; border-radius: 12px; }

/* ---------- En camino ---------- */
.parcel { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr); gap: 22px; align-items: center; }
.parcel svg { width: 100%; height: auto; }
.days { font-family: var(--f-display); font-size: clamp(56px, 16vw, 88px); line-height: .95; color: var(--rose); font-variant-numeric: tabular-nums; margin: 0; }
.days small { font-family: var(--f-body); font-size: 15px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink); display: block; margin-top: 6px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.steps li { position: relative; padding-top: 22px; font-size: 14px; line-height: 1.3; color: var(--muted); }
.steps li::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 4px; border-radius: 2px; background: var(--line); }
.steps li.on { color: var(--ink); }
.steps li.on::before { background: var(--rose); }
.steps li b { display: block; font-weight: 600; }
.today { background: var(--ink); color: var(--paper); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.today .lab { margin: 0; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); font-variant-numeric: tabular-nums; }
.today .msg { margin: 0; font-family: var(--f-hand); font-size: 28px; line-height: 1.25; }
details.past summary { cursor: pointer; font-size: 14px; color: var(--indigo); font-weight: 600; }
details.past ul { margin: 10px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.4; }
.reveal { background: var(--tint); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.reveal p { margin: 0; font-size: 16px; line-height: 1.5; }
.reveal .big { font-family: var(--f-display); font-size: 24px; line-height: 1.2; color: #e8346f; }
.reveal figure { align-self: center; margin: 0; width: min(100%, 320px); }
.funko3d { width: 100%; height: 360px; min-height: 300px; overflow: hidden; border-radius: 18px; touch-action: pan-y; background: radial-gradient(ellipse at 50% 50%, #f4fffb 0%, #ccefe8 58%, #8fcfc4 100%); }
.funko3d-hint { margin-top: 6px; text-align: center; font-size: .9rem; opacity: .75; }
@media (max-width: 460px) { .parcel { grid-template-columns: 1fr; justify-items: start; } .parcel svg { max-width: 150px; } }

/* ---------- Vista previa ---------- */
.pbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff; color: var(--ink); border-top: 3px solid var(--rose); padding: 12px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: center; font-size: 14px; box-shadow: 0 -8px 24px rgba(10,8,40,.3); }
.pbar b { color: #e8346f; }
.pbar label { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.pbar input[type="date"] { font: 14px var(--f-body); padding: 7px 8px; border: 1.5px solid #c9c4ea; border-radius: 8px; color: var(--ink); background: #fff; }
.pbar button { font: 600 13px var(--f-body); padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; }
.pbar button:focus-visible, .pbar input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.fade-in { animation: fadein .7s ease both; }
@keyframes fadein { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.fade-out { animation: fadeout .5s ease forwards; }
@keyframes fadeout { to { opacity: 0; transform: translateY(-10px); } }

@media (prefers-reduced-motion: reduce) {
  .star, .env, .flame, .glow, .spark, .stamp { animation: none !important; }
  .fade-in { animation-duration: .01s; }
  .env .letter, .env .flap, .flip .in { transition-duration: .01s; }
}

/* ---------- Caja de madera ---------- */
.box-btn { all: unset; cursor: pointer; display: block; -webkit-tap-highlight-color: transparent; }
.box-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 8px; border-radius: 12px; }
.stage { --k: 1; position: relative; width: calc(400px * var(--k)); height: calc(380px * var(--k)); }
.box-btn .stage { animation: float 4.5s ease-in-out infinite; }
.box-btn.opened .stage { animation: none; }
.stage-in { position: absolute; left: 0; top: 0; width: 400px; height: 380px; transform: scale(var(--k)); transform-origin: 0 0; perspective: 1300px; }
.stage-in::before { content: ""; position: absolute; left: 50%; bottom: 24px; width: 340px; height: 54px; margin-left: -170px; background: radial-gradient(closest-side, rgba(8,5,30,.55), transparent); }
.box3d { position: absolute; left: 50%; top: 60%; width: 0; height: 0; transform-style: preserve-3d; transform: rotateX(-27deg) rotateY(-24deg); transition: transform 1.5s cubic-bezier(.4,.1,.2,1); }
.box3d.open { transform: rotateX(-40deg) rotateY(-10deg); }
.f { position: absolute; left: calc(var(--fw) / -2); top: calc(var(--fh) / -2); width: var(--fw); height: var(--fh); background-color: var(--w2); background-image: var(--shade, linear-gradient(transparent, transparent)), var(--planks), var(--grain); background-size: auto, auto, 300px 300px; }
.sh-front { --shade: linear-gradient(rgba(255,240,210,.10), rgba(255,240,210,.10)); }
.sh-right { --shade: linear-gradient(rgba(60,30,8,.26), rgba(60,30,8,.26)); }
.sh-left { --shade: linear-gradient(rgba(60,30,8,.34), rgba(60,30,8,.34)); }
.sh-back { --shade: linear-gradient(rgba(60,30,8,.30), rgba(60,30,8,.30)); }
.sh-top { --shade: linear-gradient(rgba(255,245,220,.22), rgba(255,245,220,.06)); }
.sh-in { --shade: linear-gradient(rgba(60,30,8,.45), rgba(60,30,8,.45)); }
.b-front { --fw: 290px; --fh: 100px; transform: translateZ(90px); }
.b-back { --fw: 290px; --fh: 100px; transform: rotateY(180deg) translateZ(90px); }
.b-right { --fw: 180px; --fh: 100px; transform: rotateY(90deg) translateZ(145px); }
.b-left { --fw: 180px; --fh: 100px; transform: rotateY(-90deg) translateZ(145px); }
.in-floor { --fw: 278px; --fh: 168px; transform: rotateX(90deg) translateZ(-40px); --shade: linear-gradient(rgba(50,26,6,.5), rgba(50,26,6,.5)); background-image: radial-gradient(60% 60% at 50% 50%, rgba(255,232,170,.75), rgba(255,232,170,0)), var(--shade), var(--planks), var(--grain); }
.in-back { --fw: 278px; --fh: 90px; transform: translate3d(0,-5px,-84px); --shade: linear-gradient(rgba(50,26,6,.5), rgba(50,26,6,.5)); }
.in-left { --fw: 168px; --fh: 90px; transform: translate3d(-139px,-5px,0) rotateY(90deg); --shade: linear-gradient(rgba(50,26,6,.58), rgba(50,26,6,.58)); }
.in-right { --fw: 168px; --fh: 90px; transform: translate3d(139px,-5px,0) rotateY(90deg); --shade: linear-gradient(rgba(50,26,6,.45), rgba(50,26,6,.45)); }
.rim { background-color: var(--w1); }
.rim-f { --fw: 290px; --fh: 6px; transform: translate3d(0,-49.5px,87px) rotateX(90deg); }
.rim-b { --fw: 290px; --fh: 6px; transform: translate3d(0,-49.5px,-87px) rotateX(90deg); }
.rim-l { --fw: 6px; --fh: 168px; transform: translate3d(-142px,-49.5px,0) rotateX(90deg); }
.rim-r { --fw: 6px; --fh: 168px; transform: translate3d(142px,-49.5px,0) rotateX(90deg); }
.lidpivot { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; transform: translate3d(0,-50px,-96px) rotateX(0deg); transition: transform 1.3s cubic-bezier(.45,.05,.2,1) .35s; }
.box3d.open .lidpivot { transform: translate3d(0,-50px,-96px) rotateX(110deg); }
.lid { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; transform: translate3d(0,-15px,96px); }
.l-top { --fw: 302px; --fh: 192px; transform: rotateX(90deg) translateZ(15px); }
.l-bottom { --fw: 302px; --fh: 192px; transform: rotateX(90deg) translateZ(-15px); }
.l-front { --fw: 302px; --fh: 30px; transform: translateZ(96px); }
.l-back { --fw: 302px; --fh: 30px; transform: rotateY(180deg) translateZ(96px); }
.l-left { --fw: 192px; --fh: 30px; transform: rotateY(-90deg) translateZ(151px); }
.l-right { --fw: 192px; --fh: 30px; transform: rotateY(90deg) translateZ(151px); }
.clasp { position: absolute; left: 50%; top: 8px; width: 30px; height: 30px; margin-left: -15px; border-radius: 5px; background: linear-gradient(145deg, #f7e3a0, #b98a2f); box-shadow: 0 2px 3px rgba(40,22,4,.5), inset 0 1px 0 rgba(255,255,255,.6); display: grid; place-items: center; }
.clasp i { width: 7px; height: 10px; border-radius: 4px 4px 2px 2px; background: #5a3a0e; display: block; }
.hasp { position: absolute; left: 50%; top: 10px; width: 20px; height: 38px; margin-left: -10px; border-radius: 3px 3px 9px 9px; background: linear-gradient(145deg, #f7e3a0, #b98a2f); box-shadow: 0 2px 3px rgba(40,22,4,.5), inset 0 1px 0 rgba(255,255,255,.6); }
.tag { position: absolute; left: 50%; top: 44px; width: 78px; height: 44px; margin-left: -39px; white-space: nowrap; transform: rotate(5deg); background: #fff8ea; border-radius: 4px; box-shadow: 0 3px 5px rgba(40,22,4,.4); display: grid; place-items: center; transition: opacity .4s; }
.tag::before { content: ""; position: absolute; top: 5px; left: 50%; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: #b98a2f; }
.tag b { font-family: var(--f-hand); font-weight: 700; font-size: 24px; color: #8a4b2a; line-height: 1; margin-top: 8px; }
.box3d.open .tag { opacity: 0; }
.padlock { display: none; position: absolute; left: 50%; top: 10px; width: 30px; height: 36px; margin-left: -15px; z-index: 2; filter: drop-shadow(0 2px 2px rgba(40,22,4,.5)); }
#introTitle { transition: opacity .6s; }
.locked-box .padlock { display: block; }
.locked-box .clasp i { display: none; }

/* ---------- Marco de madera y bandeja ---------- */
.woodbox { width: 100%; padding: 14px; border-radius: 22px; background-color: var(--w2); background-image: linear-gradient(180deg, rgba(255,245,220,.2), rgba(70,40,12,.12)), var(--planks), var(--grain); background-size: auto, auto, 300px 300px; box-shadow: 0 34px 60px rgba(8,5,30,.55), inset 0 2px 0 rgba(255,240,205,.55), inset 0 -4px 0 rgba(70,40,12,.45); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.liner { border-radius: 12px; padding: 14px; background-color: #a87c47; background-image: linear-gradient(rgba(60,34,10,.18), rgba(60,34,10,.3)), var(--grain); background-size: auto, 300px 300px; box-shadow: inset 0 6px 18px rgba(40,22,6,.65), inset 0 0 0 2px rgba(60,34,10,.35); display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.tabs { justify-content: flex-start; gap: 8px; }
.tab { font: 600 14px var(--f-body); color: var(--brown); background: rgba(255,244,220,.6); border: 1px solid rgba(70,40,12,.5); padding: 8px 14px; border-radius: 8px 8px 4px 4px; cursor: pointer; backdrop-filter: none; box-shadow: 0 2px 0 rgba(70,40,12,.4); }
.tab[aria-selected="true"] { background: #fff8ea; box-shadow: 0 -1px 0 rgba(70,40,12,.3) inset; color: #1d1a3b; border-color: rgba(70,40,12,.6); }
.tray-title { margin: 0; text-align: center; font-family: var(--f-hand); font-size: 27px; color: #fff6df; text-shadow: 0 2px 0 rgba(60,34,10,.65); }
.tray { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cell { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; min-height: 160px; padding: 14px 10px 10px; border: 0; border-radius: 12px; cursor: pointer; color: #fff6df; font: inherit; background: rgba(50,28,8,.3); box-shadow: inset 0 4px 10px rgba(30,16,4,.55), 0 1px 0 rgba(255,235,200,.3); animation: rise .75s cubic-bezier(.2,.9,.3,1.15) both; animation-delay: calc(var(--i, 0) * 110ms); -webkit-tap-highlight-color: transparent; min-width: 0; }
.cell.wide, .cell.solo { grid-column: 1 / -1; }
.cell.wide { min-height: 180px; }
.cell:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.cell .art { width: 100%; display: grid; place-items: center; transition: transform .25s ease; }
.cell .art svg { width: min(100%, 150px); height: auto; filter: drop-shadow(0 8px 6px rgba(30,16,4,.45)); }
.cell.wide .art svg { width: min(100%, 190px); }
.cell:hover .art, .cell:focus-visible .art { transform: translateY(-8px) rotate(-1.5deg); }
.cell .lab { font-family: var(--f-hand); font-size: 28px; line-height: 1; text-shadow: 0 2px 0 rgba(60,34,10,.7); }
.badge { position: absolute; top: 10px; right: 10px; background: #fff6df; color: #4a2f12; font: 600 12px var(--f-body); padding: 4px 9px; border-radius: 999px; box-shadow: 0 2px 0 rgba(60,34,10,.4); font-variant-numeric: tabular-nums; }
@keyframes rise { from { opacity: 0; transform: translateY(40px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes pullup { from { opacity: 0; transform: translateY(70px) rotate(-1.2deg) scale(.96); } to { opacity: 1; transform: none; } }
.pull { animation: pullup .6s cubic-bezier(.2,.9,.3,1) both; }
.card { position: relative; }
.card::before { content: ""; position: absolute; top: -11px; left: 50%; width: 96px; height: 24px; transform: translateX(-50%) rotate(-3deg); background: rgba(255,236,170,.75); box-shadow: 0 2px 4px rgba(60,34,10,.25); pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .cell, .pull { animation: none !important; }
  .box-btn .stage { animation: none !important; }
  .box3d, .lidpivot { transition-duration: .01s !important; transition-delay: 0s !important; }
}
