[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; color: #f3effc;
  font-family: var(--cr-font); background: #0d1640;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: var(--cr-violet-300); }
:focus-visible { outline: 3px solid var(--cr-violet-400); outline-offset: 3px; border-radius: 10px; }

/* ---------- Cielo nocturno ---------- */
.sky { position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: radial-gradient(120% 80% at 50% 0%, #3a2280 0%, #1f1550 40%, #120d22 80%); }
.sky video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1.5s; }
.sky.has-video video { opacity: 0.55; }
.sky.has-video .moon, .sky.has-video .sleigh, .sky.has-video .caravan, .sky.has-video .hills, .sky.has-video .star-guide { display: none; }
.stars { position: absolute; inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 10% 20%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 70%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 55% 15%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 75% 40%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 12%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 20% 45%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 65% 60%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 42% 35%, #fff 50%, transparent 51%);
  background-size: 420px 420px; opacity: 0.8; animation: twinkle 6s ease-in-out infinite alternate; }
@keyframes twinkle { to { opacity: 0.45; } }
.moon { position: absolute; top: 9%; right: 12%; width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff8e0, #ffe3a3 60%, #f6c96b);
  box-shadow: 0 0 60px 20px rgba(255, 214, 107, 0.25); }
.star-guide { display: none; position: absolute; top: 10%; left: 18%; width: 14px; height: 14px; background: #fff;
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  box-shadow: 0 0 40px 18px rgba(255, 214, 107, 0.7); transform: scale(2.4); animation: pulse 3s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(2.9); } }
.sleigh, .caravan { position: absolute; font-size: 34px; white-space: nowrap; filter: drop-shadow(0 0 10px rgba(255,255,255,.35)); display: none; }
.sleigh { top: 22%; animation: fly 26s linear infinite; }
.caravan { bottom: 13%; font-size: 30px; animation: walk 60s linear infinite; }
@keyframes fly { from { transform: translateX(-30vw) translateY(0) rotate(-6deg) scaleX(-1); } to { transform: translateX(130vw) translateY(-60px) rotate(-6deg) scaleX(-1); } }
@keyframes walk { from { transform: translateX(110vw) scaleX(1); } to { transform: translateX(-40vw) scaleX(1); } }
.hills { position: absolute; left: -5%; right: -5%; bottom: -40px; height: 26vh;
  background: radial-gradient(60% 100% at 25% 100%, #2a1c5c 60%, transparent 61%), radial-gradient(70% 100% at 80% 100%, #23184f 60%, transparent 61%); }
#snow { position: absolute; inset: 0; width: 100%; height: 100%; }
body.scene .sleigh { display: block; }
body.scene.reyes .sleigh { display: none; }
body.scene.reyes .caravan { display: block; }
body.reyes .star-guide { display: block; }
body.reyes .moon { width: 60px; height: 60px; opacity: .7; }
@media (prefers-reduced-motion: reduce) { .sleigh, .caravan, .stars, .star-guide { animation: none !important; } }

/* ---------- Layout ---------- */
.top { display: flex; justify-content: center; padding: 20px 16px 0; }
.brand-mini img { height: 24px; width: auto; filter: brightness(1.6) saturate(.9); }
.stage { width: min(760px, 100% - 32px); margin: 24px auto 80px; }
.glass-dark { background: rgba(38, 28, 66, 0.45); border: 1px solid rgba(184, 134, 254, 0.22); border-radius: var(--cr-radius-lg);
  backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 24px 60px -24px rgba(0,0,0,.6); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer; text-decoration: none;
  font: 700 15px/1 var(--cr-font); color: #fff; background: var(--cr-gradient); padding: 14px 22px; border-radius: 999px;
  box-shadow: 0 10px 24px -10px rgba(127, 66, 235, .8), inset 0 1px 0 rgba(255,255,255,.35); transition: transform .15s; }
.btn:hover { transform: translateY(-1px); }
.btn-sm { padding: 10px 16px; font-size: 14px; }
.btn-glass { background: rgba(255,255,255,.1); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }

/* ---------- Espera ---------- */
.waiting { text-align: center; padding: 48px 24px; margin-top: 10vh; }
.waiting h1 { font-family: var(--cr-font-display); font-size: 28px; margin: 18px 0 8px; }
.waiting p { color: #cfc6ea; margin: 0 auto 20px; max-width: 40ch; }
.orb { width: 84px; height: 84px; margin: 0 auto; border-radius: 50%; background: var(--cr-gradient); position: relative;
  box-shadow: 0 0 60px 10px rgba(184, 134, 254, .45); animation: breathe 2.2s ease-in-out infinite; }
.orb span { position: absolute; inset: -10px; border-radius: 50%; border: 2px dashed rgba(255,255,255,.4); animation: spin 8s linear infinite; }
@keyframes breathe { 50% { transform: scale(1.08); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Carta ---------- */
.letter-wrap { animation: rise .9s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(30px) scale(.98); } }
.from { text-align: center; font-family: var(--cr-font-display); font-size: clamp(22px, 4vw, 30px); margin: 10px 0 20px; }
.from .grad { background: linear-gradient(90deg, #ffd66b, #ffb38a); -webkit-background-clip: text; background-clip: text; color: transparent; }

.audio { display: flex; align-items: center; gap: 16px; padding: 14px 18px 14px 14px; margin-bottom: 18px; border-radius: 999px; }
.play-btn { width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer; flex: none; color: #fff; background: var(--cr-gradient);
  display: grid; place-items: center; box-shadow: 0 0 0 6px rgba(184,134,254,.18), 0 10px 30px -8px rgba(127,66,235,.9); animation: call 2.4s ease-in-out infinite; }
.play-btn.playing { animation: none; }
@keyframes call { 50% { box-shadow: 0 0 0 14px rgba(184,134,254,.08), 0 10px 30px -8px rgba(127,66,235,.9); } }
.audio-meta { flex: 1; min-width: 0; }
.audio-meta b { display: block; margin-bottom: 8px; font-size: 15px; }
.progress { height: 6px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; cursor: pointer; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd66b, #b886fe); }
.audio-pending { text-align: center; color: #e4dcff; font-size: 14px; }

.paper { position: relative; background: #fffdf7; color: #3a2c5a; border-radius: 22px; padding: clamp(28px, 6vw, 56px) clamp(22px, 6vw, 60px);
  box-shadow: 0 40px 80px -30px rgba(0,0,0,.7), inset 0 0 0 1px rgba(127,66,235,.08);
  background-image: radial-gradient(circle at 100% 0, rgba(184,134,254,.12), transparent 40%), radial-gradient(circle at 0 100%, rgba(255,214,107,.15), transparent 40%); }
.paper::before { content: ''; position: absolute; inset: 12px; border: 1.5px dashed rgba(127,66,235,.18); border-radius: 14px; pointer-events: none; }
.paper-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.seal { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 28px;
  background: radial-gradient(circle at 35% 30%, #c9a5ff, #7f42eb); box-shadow: 0 6px 16px -6px rgba(127,66,235,.8); }
.place { font-family: var(--cr-font-hand); font-size: 22px; color: var(--cr-violet-700); }
.body { font-family: var(--cr-font-letter); font-size: clamp(17px, 2.3vw, 19px); line-height: 1.75; }
.body p { margin: 0 0 16px; }
.body p:first-child { font-size: 1.1em; }
.signature { font-family: var(--cr-font-hand); font-size: clamp(30px, 5vw, 38px); color: var(--cr-violet-700); margin: 24px 0 0; text-align: right; }

.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 26px 0; }
.upsell { display: flex; gap: 18px; align-items: center; justify-content: space-between; padding: 20px 22px; flex-wrap: wrap; }
.upsell p { margin: 4px 0 0; color: #cfc6ea; font-size: 14px; max-width: 46ch; }
.made { text-align: center; color: #b4aec8; font-size: 13px; margin-top: 28px; }

/* ---------- Impresión / PDF ---------- */
@media print {
  @page { size: letter; margin: 14mm; }
  body { background: #fff; }
  .sky, .no-print { display: none !important; }
  .stage { margin: 0; width: 100%; }
  .letter-wrap { animation: none; }
  .paper { box-shadow: none; border-radius: 0; padding: 18mm 16mm; }
  .paper::before { border-color: rgba(127,66,235,.35); }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (max-width: 640px) {
  .moon { top: 74px; right: -18px; width: 56px; height: 56px; opacity: .6; }
  .star-guide { top: 18px; left: 10%; transform: scale(1.4); }
  @keyframes pulse { 50% { transform: scale(1.7); } }
}

/* =========================================================
   Navidad: escena ilustrada, luces de serie y papel con acebo
   ========================================================= */
.sky { background: #0d1640 url('/img/escena-santa.jpg') center bottom / cover no-repeat; }
body.reyes .sky { background-image: url('/img/escena-reyes.jpg'); }
@media (max-width: 760px) {
  .sky { background-image: url('/img/escena-santa-m.jpg'); background-position: 72% bottom; }
  body.reyes .sky { background-image: url('/img/escena-reyes-m.jpg'); background-position: 60% bottom; }
}
.sky::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(90% 60% at 50% 40%, rgba(8, 12, 36, .35), transparent 70%), linear-gradient(to bottom, rgba(8,12,36,.15), transparent 30%, transparent 70%, rgba(8,12,36,.35)); }
.sky .moon, .sky .hills, .sky .star-guide, .sky .sleigh, .sky .caravan { display: none !important; }
.stars { opacity: .55; }
/* Aurora que respira sobre la ilustración */
.aurora { position: absolute; inset: -10% -10% 45% -10%; pointer-events: none; mix-blend-mode: screen; opacity: .55;
  background: radial-gradient(40% 50% at 30% 30%, rgba(120, 255, 200, .35), transparent 70%), radial-gradient(35% 45% at 70% 20%, rgba(190, 120, 255, .35), transparent 70%);
  filter: blur(30px); animation: aurora 14s ease-in-out infinite alternate; }
body.reyes .aurora { background: radial-gradient(35% 45% at 75% 18%, rgba(255, 214, 120, .45), transparent 70%), radial-gradient(45% 50% at 30% 25%, rgba(170, 120, 255, .3), transparent 70%); }
@keyframes aurora { 50% { transform: translateX(4%) skewX(-6deg); opacity: .8; } 100% { transform: translateX(-3%) skewX(4deg); opacity: .5; } }
/* Estrella fugaz de vez en cuando */
.shooting { position: absolute; top: 14%; left: 10%; width: 140px; height: 2px; border-radius: 2px; opacity: 0;
  background: linear-gradient(90deg, rgba(255,255,255,0), #fff); transform: rotate(-18deg); animation: shoot 9s ease-in 3s infinite; }
@keyframes shoot { 0% { opacity: 0; transform: translate(0, 0) rotate(-18deg); } 3% { opacity: 1; } 10% { opacity: 0; transform: translate(420px, 130px) rotate(-18deg); } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .aurora, .shooting { animation: none !important; } .shooting { display: none; } }

.top { padding-top: 46px; }
.from { text-shadow: 0 2px 16px rgba(0,0,0,.6); }
.from .grad { background: linear-gradient(90deg, var(--xm-gold-2), var(--xm-gold)); -webkit-background-clip: text; background-clip: text; }
.glass-dark { background: rgba(14, 20, 52, .55); border-color: rgba(255, 217, 138, .22); }
.btn { background: var(--xm-gradient); box-shadow: 0 10px 24px -10px rgba(200, 32, 47, .8), inset 0 1px 0 rgba(255,255,255,.35); }
.btn-glass { background: rgba(255,255,255,.12); box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); }
.play-btn { background: var(--xm-gradient); box-shadow: 0 0 0 6px rgba(232,65,79,.2), 0 10px 30px -8px rgba(200,32,47,.9); }
@keyframes call { 50% { box-shadow: 0 0 0 14px rgba(232,65,79,.08), 0 10px 30px -8px rgba(200,32,47,.9); } }
.progress span { background: linear-gradient(90deg, var(--xm-gold-2), var(--xm-red-2)); }
.orb { background: radial-gradient(circle at 35% 30%, var(--xm-gold-2), var(--xm-red) 70%); box-shadow: 0 0 60px 10px rgba(255, 196, 100, .45); }

.paper.stationery { border-radius: 0; padding: calc(var(--pw) * .27) calc(var(--pw) * .15) calc(var(--pw) * .27); box-shadow: none; }
.paper.stationery::before { display: none; }
.paper.stationery .paper-head { flex-direction: column; gap: 6px; margin-bottom: 18px; }
.seal { background: radial-gradient(circle at 35% 30%, #ff6a6f, var(--xm-red) 55%, #7d0f1b); box-shadow: 0 6px 14px -4px rgba(125, 15, 27, .8), inset 0 -3px 6px rgba(0,0,0,.25); }
.place { color: var(--xm-green); }
.body { color: var(--xm-ink); }
.signature { color: var(--xm-red); }
@media (max-width: 640px) {
  .paper.stationery { padding: calc(var(--pw) * .3) calc(var(--pw) * .11) calc(var(--pw) * .3); }
  .body { font-size: 16px; line-height: 1.65; }
}
@media print {
  .paper.stationery { --pw: 180mm; padding: 46mm 26mm 48mm; filter: none; }
  .lights { display: none; }
}
.brand-mini img { filter: brightness(0) invert(1); opacity: .95; }
.made { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 24px 20px; margin-top: 28px; color: #fff; }
.made b { font-family: var(--cr-font-display); font-size: 19px; }
.made small { font-size: 13px; color: rgba(255, 255, 255, .8); }
.made small a { color: var(--xm-gold-2); }
.upsell { color: #fff; }
.upsell p { color: rgba(255, 255, 255, .82); }
.made.glass-dark, .upsell.glass-dark, .audio.glass-dark { background: rgba(10, 16, 44, .84); }
.btn-glass { background: rgba(10, 16, 44, .7); }
.seal { width: 92px; height: 92px; padding: 6px 6px 0; overflow: hidden; background: radial-gradient(circle at 50% 35%, #fffaf0, #f4e4c4); border: 3px solid var(--xm-red); box-shadow: 0 0 0 4px rgba(233, 180, 76, .55), 0 8px 18px -6px rgba(125, 15, 27, .55); }
.seal img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; display: block; }
.audio-pending .ico, .actions .ico { vertical-align: -.35em; }

/* ---------- Imagen para redes ---------- */
.btn-gold { background: linear-gradient(135deg, var(--xm-gold-2), var(--xm-gold)); color: #4a2e00; box-shadow: 0 10px 24px -10px rgba(233, 180, 76, .8), inset 0 1px 0 rgba(255,255,255,.5); }
.share-modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(5, 8, 24, .7); backdrop-filter: blur(6px); }
.share-panel { position: relative; width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 22px 20px 20px; text-align: center; background: rgba(10, 16, 44, .95); }
.share-panel h2 { font-family: var(--cr-font-display); margin: 0 0 12px; font-size: 22px; }
.share-x { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 22px; cursor: pointer; }
.share-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(255,255,255,.1); margin-bottom: 14px; }
.share-tabs button { border: 0; background: none; color: #fff; font: 700 14px var(--cr-font); padding: 8px 16px; border-radius: 999px; cursor: pointer; }
.share-tabs button.on { background: var(--xm-gradient); }
#shareCanvas { display: block; width: auto; max-width: 100%; max-height: 52dvh; margin: 0 auto; border-radius: 14px; box-shadow: 0 20px 40px -16px rgba(0,0,0,.7); }
.share-hide { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 14px 0; font-size: 14px; color: rgba(255,255,255,.85); cursor: pointer; }
.share-hide input { width: 18px; height: 18px; accent-color: var(--xm-red); }
.share-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Sobre en acuarela con sello de cera ----------
   Capas: interior, carta, bolsillo, solapa 3D (frente con timbre / reverso) y sello en 4 pedazos.
   --tip es la punta de la solapa; la geometría sale de la ilustración (img/sobre.webp). */
.envelope-stage { min-height: calc(100dvh - 160px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 20px 0 40px; transition: opacity .5s, transform .5s; }
.envelope-stage.gone { opacity: 0; transform: translateY(-24px) scale(.97); }
.envelope { --flap: polygon(0 0, 18.2% 27.7%, 37.7% 51%, 50.4% 62.2%, 62% 50.5%, 81.8% 25.5%, 100% 0);
  position: relative; width: min(500px, 92vw); aspect-ratio: 1100 / 775; padding: 0; border: 0; background: none; cursor: pointer;
  perspective: 1600px; animation: env-float 4.5s ease-in-out infinite; -webkit-tap-highlight-color: transparent; }
@keyframes env-float { 50% { transform: translateY(-8px) rotate(-.7deg); } }
.envelope > span, .env-flap > span, .flap-front > span { position: absolute; display: block; inset: 0; }
.env-inside { background: url('/img/sobre.webp') center / 100% 100%; filter: brightness(.72) sepia(.25) drop-shadow(0 26px 30px rgba(0, 0, 0, .55)); }
.env-paper { inset: 5% 5.5% 6% !important; z-index: 1; border-radius: 4px; overflow: hidden;
  background: #fbf3e0 url('/img/papel.webp') center top / 100% auto no-repeat; box-shadow: 0 2px 10px rgba(80, 50, 20, .25);
  transition: transform 1s cubic-bezier(.25,.8,.25,1) 1.05s; }
.env-greet { position: absolute; left: 14%; top: 46%; font: 400 clamp(13px, 3.6vw, 19px) var(--cr-font-letter); color: var(--xm-ink); opacity: .85; }
.env-pocket { z-index: 2; background: url('/img/sobre.webp') center / 100% 100%;
  clip-path: polygon(0 0, 18.2% 27.7%, 37.7% 51%, 50.4% 62.2%, 62% 50.5%, 81.8% 25.5%, 100% 0, 100% 100%, 0 100%); }
.env-name { position: absolute; left: 0; right: 0; top: 76.5%; text-align: center; font: 600 clamp(30px, 8.4vw, 46px)/1 var(--cr-font-hand); color: #b3192a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5); transform: rotate(-2deg); }
.env-sub { position: absolute; left: 0; right: 0; top: 89.5%; text-align: center; font: italic 400 clamp(11px, 2.8vw, 14px) var(--cr-font-letter); color: rgba(70, 45, 25, .75); }
.env-flap { z-index: 3; transform-origin: 50% 0; transform-style: preserve-3d; transition: transform .85s cubic-bezier(.55,0,.25,1) .45s, z-index 0s .9s; }
.flap-front, .flap-back { -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.flap-front { clip-path: none; }
.flap-front::before { content: ''; position: absolute; inset: 0; background: url('/img/sobre.webp') center / 100% 100%; clip-path: var(--flap);
  filter: drop-shadow(0 2px 2px rgba(90, 60, 25, .35)); }
.flap-back { background: url('/img/sobre.webp') center / 100% 100%; filter: brightness(.86) sepia(.2); clip-path: var(--flap); transform: rotateY(180deg); }
.flap-front > .env-stamp { inset: 3.57% auto auto 63.38%; width: 34%; height: 37.57%; background: url('/img/sobre-timbre.webp') center / 100% 100% no-repeat; }
.env-stamp svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pm-text { font: 700 10.5px var(--cr-font); fill: rgba(60, 60, 66, .78); letter-spacing: .5px; }
.pm-star { font-size: 16px; fill: rgba(60, 60, 66, .6); }

/* Sello: un lienzo con la inicial grabada, repartido en 4 pedazos que se separan al abrir */
.envelope > .env-seal { inset: 61% auto auto 50.4%; width: 21.5%; aspect-ratio: 1; z-index: 5; transform: translate(-50%, -50%) rotate(-6deg);
  filter: drop-shadow(0 6px 8px rgba(70, 0, 8, .5)); animation: seal-breathe 2.4s ease-in-out infinite; }
.env-seal i { position: absolute; inset: 0; background: var(--seal, url('/img/sello.webp')) center / 100% 100%; transition: transform .7s cubic-bezier(.2,.7,.3,1), opacity .6s ease-in .15s; }
.env-seal i:nth-child(1) { clip-path: polygon(50% 47%, 47% 0, 0 0, 0 41%); --to: translate(-38%, -44%) rotate(-38deg); }
.env-seal i:nth-child(2) { clip-path: polygon(50% 47%, 47% 0, 100% 0, 100% 55%); --to: translate(42%, -36%) rotate(31deg); }
.env-seal i:nth-child(3) { clip-path: polygon(50% 47%, 100% 55%, 100% 100%, 58% 100%); --to: translate(36%, 46%) rotate(44deg); }
.env-seal i:nth-child(4) { clip-path: polygon(50% 47%, 58% 100%, 0 100%, 0 41%); --to: translate(-44%, 38%) rotate(-27deg); }
.seal-glow { position: absolute; inset: -30%; border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(255, 236, 180, .95) 0%, rgba(255, 200, 110, .45) 30%, transparent 62%); }
@keyframes seal-breathe { 50% { filter: drop-shadow(0 6px 8px rgba(70, 0, 8, .5)) drop-shadow(0 0 14px rgba(255, 210, 130, .75)); } }
.env-hint { margin: 0; color: #fff; font: 700 16px var(--cr-font); text-shadow: 0 2px 10px rgba(0, 0, 0, .7); animation: hint 2.2s ease-in-out infinite; }
@keyframes hint { 50% { opacity: .6; } }

/* Abrir: el sello se agrieta y vuela en pedazos, la solapa gira en 3D y la carta sube */
.cracking .env-seal { animation: seal-shake .22s linear 2; }
@keyframes seal-shake { 25% { transform: translate(-52%, -50%) rotate(-9deg); } 75% { transform: translate(-48%, -50%) rotate(-3deg); } }
.opening .envelope { animation: none; }
.opening .env-seal { animation: none; filter: none; }
.opening .env-seal i { transform: var(--to); opacity: 0; }
.opening .seal-glow { animation: glow-burst .8s ease-out; }
@keyframes glow-burst { 0% { opacity: 0; transform: scale(.4); } 30% { opacity: 1; } 100% { opacity: 0; transform: scale(1.6); } }
.opening .env-flap { transform: rotateX(180deg); z-index: 0; }
.opening .env-paper { transform: translateY(-58%); }
.opening .env-hint { opacity: 0; animation: none; transition: opacity .3s; }
.dust { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }
@media (prefers-reduced-motion: reduce) { .envelope, .env-seal, .env-hint { animation: none !important; } }

/* ---------- Cuenta regresiva ---------- */
.countdown { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 16px; margin: 26px 0 0; text-align: center; background: rgba(10, 16, 44, .84); color: #fff; }
.cd-label { font: 700 15px var(--cr-font); letter-spacing: .02em; color: var(--xm-gold-2); }
.cd-boxes { display: flex; gap: 10px; }
.cd-boxes span { min-width: 64px; padding: 10px 6px 8px; border-radius: 14px; background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.04)); box-shadow: inset 0 0 0 1px rgba(255, 217, 138, .25); }
.cd-boxes b { display: block; font: 800 clamp(24px, 6vw, 32px)/1 var(--cr-font-display); font-variant-numeric: tabular-nums; }
.cd-boxes small { display: block; margin-top: 4px; font-size: 12px; color: rgba(255,255,255,.75); }
.cd-note { font-size: 14px; color: rgba(255,255,255,.88); transition: opacity .35s; }
.cd-note.swap { opacity: 0; }
@media (max-width: 400px) { .cd-boxes { gap: 6px; } .cd-boxes span { min-width: 56px; } }

/* ---------- Certificado de la Lista de Niños Buenos ---------- */
.cert-panel { width: min(720px, 100%); }
.cert { container-type: inline-size; width: 100%; aspect-ratio: 11 / 8.5; margin: 0 auto 16px; padding: 2.2cqw; border-radius: 6px; color: var(--xm-ink);
  background: radial-gradient(120% 90% at 50% 40%, #fffaf0 0%, #f6e8c9 70%, #ecd6a6 100%); box-shadow: 0 20px 40px -16px rgba(0,0,0,.7); }
.cert-in { position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 3cqw 8cqw;
  border: .5cqw double var(--xm-gold); outline: .25cqw solid rgba(200, 32, 47, .55); outline-offset: -1.6cqw; }
.cert-corner { position: absolute; width: 9cqw; height: 9cqw; background: url('/img/ico/arbol.webp') center / contain no-repeat; }
.cert-corner.tl { top: 1.4cqw; left: 1.4cqw; } .cert-corner.tr { top: 1.4cqw; right: 1.4cqw; background-image: url('/img/ico/estrella.webp'); }
.cert-corner.bl { bottom: 1.4cqw; left: 1.4cqw; background-image: url('/img/ico/regalo.webp'); } .cert-corner.br { bottom: 1.4cqw; right: 1.4cqw; background-image: url('/img/ico/campana.webp'); }
.cert p, .cert h3 { margin: 0; }
.cert-kicker { font: 700 1.9cqw var(--cr-font); letter-spacing: .25em; text-transform: uppercase; color: var(--xm-green); }
.cert-title { font: 400 6.4cqw/1.05 var(--cr-font-letter); color: var(--xm-red); margin: 1.2cqw 0 2cqw !important; }
.cert-pre, .cert-post { font: 400 2.4cqw/1.45 var(--cr-font-letter); max-width: 62cqw; }
.cert-name { font: 600 9cqw/1 var(--cr-font-hand); color: var(--xm-red); margin: .6cqw 0 .4cqw !important; padding: 0 4cqw .4cqw; border-bottom: .2cqw solid rgba(233, 180, 76, .8); }
.cert-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 3cqw; width: 100%; margin-top: 3.2cqw; }
.cert-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .6cqw; }
.cert-col small { width: 100%; padding-top: .6cqw; border-top: .15cqw solid rgba(59, 42, 32, .5); font: 600 1.5cqw var(--cr-font); color: rgba(59, 42, 32, .7); text-transform: uppercase; letter-spacing: .12em; }
.cert-sign { font: 600 4.4cqw/1 var(--cr-font-hand); color: var(--xm-red); }
.cert-place { font: italic 400 2cqw var(--cr-font-letter); }
.cert-medal { position: relative; width: 14cqw; aspect-ratio: 1; flex: none; border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #fffaf0, #f4e4c4); border: .6cqw solid var(--xm-gold); box-shadow: 0 0 0 .5cqw var(--xm-red), 0 1cqw 2cqw rgba(0,0,0,.25); }
.cert-medal img { width: 84%; height: 84%; object-fit: contain; object-position: center bottom; align-self: end; }
.cert-faces { display: none; }
.cert.reyes #certFace { display: none; }
.cert.reyes .cert-faces { display: flex; width: 100%; height: 100%; align-items: flex-end; justify-content: center; }
.cert.reyes .cert-faces img { width: 40%; height: 70%; margin: 0 -4%; }
.actions .btn-glass .ico-regalo { vertical-align: -.35em; }

@media print {
  #certModal { display: none !important; }
  body.print-cert > * { display: none !important; }
  body.print-cert #certModal { display: block !important; position: static; padding: 0; background: none; backdrop-filter: none; }
  body.print-cert .cert-panel { width: 100%; max-height: none; padding: 0; background: none; border: 0; box-shadow: none; backdrop-filter: none; overflow: visible; }
  body.print-cert .cert-panel > :not(.cert) { display: none !important; }
  body.print-cert .cert { page: cert; width: 250mm; margin: 0 auto; box-shadow: none; break-inside: avoid; }
  @page cert { size: letter landscape; margin: 10mm; }
}
.share-panel h2 { padding: 0 34px; }
.cert.reyes .cert-sign { font-size: 3.2cqw; }

/* ---------- Responsive: celulares en horizontal y tablets ---------- */
.envelope { width: min(580px, 92vw, (100dvh - 190px) * 1.42); }
.share-x { width: 44px; height: 44px; }
.cert { max-width: calc((100dvh - 190px) * 11 / 8.5); }
@media (max-height: 520px) and (orientation: landscape) {
  .top { padding-top: 34px; }
  .envelope-stage { min-height: calc(100dvh - 90px); gap: 12px; padding: 4px 0 16px; }
  .envelope { width: min(92vw, (100dvh - 120px) * 1.42); }
  .env-hint { font-size: 14px; }
  .share-modal { padding: 10px; }
  .share-panel { width: min(760px, 100%); max-height: calc(100dvh - 20px); padding: 14px 16px; }
  .share-panel h2 { font-size: 18px; margin-bottom: 8px; }
  /* Imagen para redes: vista previa a la izquierda, controles a la derecha */
  #shareModal .share-panel { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto 1fr auto; column-gap: 20px; align-items: start; text-align: left; }
  #shareModal #shareCanvas { grid-column: 1; grid-row: 1 / 5; max-height: calc(100dvh - 48px); margin: 0; }
  #shareModal h2, #shareModal .share-tabs, #shareModal .share-hide, #shareModal .share-actions { grid-column: 2; justify-self: start; }
  #shareModal .share-hide { justify-content: flex-start; margin: 10px 0; }
  #shareModal .share-actions { justify-content: flex-start; }
  .cert { max-width: calc((100dvh - 120px) * 11 / 8.5); margin-bottom: 10px; }
  .cert-panel h2 { display: none; }
}
@media (min-width: 700px) and (min-height: 700px) {
  #shareCanvas { max-height: 60dvh; }
  .share-panel { width: min(480px, 100%); }
  .cert-panel { width: min(820px, 100%); }
}
/* El texto del sobre escala con el propio sobre */
.envelope { container-type: inline-size; }
.env-name { font-size: 9.2cqw; }
.env-sub { font-size: 2.8cqw; }
.env-greet { font-size: 3.6cqw; }
