:root {
  --night-1: #070b1f;
  --night-2: #13204d;
  --night-3: #2a3d7c;
  --gold: #ffd36b;
  --red: #e23b4a;
  --red-dark: #b5202f;
  --green: #2fa36b;
  --snow: #f4f8ff;
  --ink: #2b2118;
  --glass: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.18);
  --radius: 22px;
  --font-title: 'Mountains of Christmas', cursive;
  --font-body: 'Nunito', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  color: var(--snow);
  background: radial-gradient(ellipse at 70% 0%, var(--night-3) 0%, var(--night-2) 40%, var(--night-1) 100%) fixed;
  min-height: 100svh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; }

/* ---------- Escena ---------- */
.scene { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
#sky { position: absolute; inset: 0; width: 100%; height: 100%; }
.moon {
  position: absolute; top: 7%; right: 9%;
  width: clamp(70px, 12vw, 140px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffbe8, #f3e6b5 60%, #d9c98c);
  box-shadow: 0 0 60px 20px rgba(255, 240, 190, .25), 0 0 140px 60px rgba(255, 240, 190, .1);
  transition: transform .3s ease-out;
}
.hills { position: absolute; left: -5%; width: 110%; bottom: 0; transition: transform .3s ease-out; }
.hills-back { height: 34vh; fill: #1d2c5e; opacity: .9; }
.hills-front { height: 28vh; }
.hills-front .snowfield { fill: #e9f0ff; }
.hills-front .trees, .hills-front .house { fill: #0e1838; }
.hills-front .window { fill: #ffcf5a; filter: drop-shadow(0 0 6px #ffcf5a); animation: flicker 4s infinite; }
@keyframes flicker { 0%, 100% { opacity: 1; } 45% { opacity: .85; } 50% { opacity: .6; } 55% { opacity: .9; } }

/* ---------- Luna (tócala para llamar a Santa) ---------- */
.moon { pointer-events: auto; cursor: pointer; }
.moon:hover { filter: brightness(1.08); }
.moon.called { animation: moonPulse .6s ease-out; }
@keyframes moonPulse { 50% { box-shadow: 0 0 90px 40px rgba(255, 240, 190, .55), 0 0 160px 80px rgba(255, 240, 190, .2); } }
.secret { margin: 18px 0 0; font-size: .85rem; opacity: .6; }

/* ---------- Botón de música ---------- */
.music-btn {
  position: fixed; z-index: 4;
  top: max(14px, env(safe-area-inset-top)); left: 14px;
  display: flex; align-items: center; gap: 8px;
  padding: 9px 15px 9px 12px; border-radius: 999px; cursor: pointer;
  color: var(--snow); font-weight: 800; font-size: .9rem;
  background: rgba(13, 20, 50, .55); border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background .2s, transform .15s;
}
.music-btn:hover { background: rgba(255, 255, 255, .15); }
.music-btn:active { transform: scale(.95); }
.music-btn .note { font-size: 1.1rem; animation: wiggle 1.6s ease-in-out infinite; display: inline-block; }
@keyframes wiggle { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(10deg) translateY(-2px); } }
.music-btn .eq { display: none; align-items: flex-end; gap: 2px; height: 16px; }
.music-btn .eq i { width: 4px; background: var(--gold); border-radius: 2px; animation: eq .8s ease-in-out infinite alternate; }
.music-btn .eq i:nth-child(2) { animation-delay: -.3s; }
.music-btn .eq i:nth-child(3) { animation-delay: -.55s; }
@keyframes eq { from { height: 4px; } to { height: 16px; } }
.music-btn.on { border-color: var(--gold); }
.music-btn.on .eq { display: flex; }
.music-btn.on .note { display: none; }

/* ---------- Trineo 3D ---------- */
#sleigh3d { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }

/* ---------- Segundo hero: mensaje navideño para la familia ---------- */
.scroll-cue {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  margin-top: 26px; color: var(--snow); text-decoration: none; font-weight: 700; font-size: .9rem; opacity: .85;
}
.scroll-cue span { font-size: 1.8rem; line-height: .8; animation: bounce 1.4s infinite; color: var(--gold); }
body:not([data-screen=home]) .home-extra { display: none; }

.message {
  position: relative; z-index: 2; overflow: hidden;
  min-height: 100vh; min-height: 100svh;
  display: grid; place-items: center; padding: 14vh 22px 12vh;
  background:
    radial-gradient(ellipse at 50% 38%, #6b1426 0%, #3a0d22 38%, transparent 75%),
    linear-gradient(180deg, var(--night-1) 0%, #1a0b24 45%, #16224a 100%);
}
.message::before { /* fundido suave desde la portada */
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 140px; z-index: 1;
  background: linear-gradient(var(--night-1), transparent); pointer-events: none;
}
.msg-fx, .msg-fx > div { position: absolute; inset: 0; pointer-events: none; }
.msg-fx i { position: absolute; font-style: normal; }

/* Luces desenfocadas (bokeh) */
.msg-bokeh i {
  border-radius: 50%; opacity: .22;
  animation: bokehDrift linear infinite alternate, bokehPulse ease-in-out infinite alternate;
}
@keyframes bokehDrift { from { transform: translate(0, 0); } to { transform: translate(60px, -90px); } }
@keyframes bokehPulse { from { opacity: .25; } to { opacity: .6; } }

/* Nieve */
.msg-snow i { top: -5%; color: #fff; animation: msgFall linear infinite, msgSway ease-in-out infinite alternate; }
@keyframes msgFall { to { top: 105%; } }
@keyframes msgSway { from { margin-left: -14px; } to { margin-left: 14px; } }

/* Corazones que suben */
.msg-hearts i { bottom: -40px; opacity: 0; animation: heartRise linear infinite; }
@keyframes heartRise {
  0% { transform: translateY(0) scale(.6) rotate(-10deg); opacity: 0; }
  10% { opacity: .85; }
  80% { opacity: .5; }
  100% { transform: translateY(-110vh) scale(1.1) rotate(15deg); opacity: 0; }
}

/* Guirnalda */
.msg-lights { z-index: 2; height: 60px; }
.msg-lights::before {
  content: ''; position: absolute; left: 0; right: 0; top: 10px; height: 34px;
  border-bottom: 2px solid #2c3a2c; border-radius: 0 0 50% 50% / 0 0 100% 100%; opacity: .7;
}
.msg-lights i {
  width: 11px; height: 15px; margin-left: -5px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: #ff4757; color: #ff4757; box-shadow: 0 0 12px 2px currentColor; animation: bulb 1.3s ease-in-out infinite alternate;
}
.msg-lights i:nth-child(5n+2) { background: #ffd36b; color: #ffd36b; }
.msg-lights i:nth-child(5n+3) { background: #54a0ff; color: #54a0ff; }
.msg-lights i:nth-child(5n+4) { background: #2ed573; color: #2ed573; }
.msg-lights i:nth-child(5n+5) { background: #ff6bcb; color: #ff6bcb; }

/* Contenido */
.msg-inner { position: relative; z-index: 2; max-width: 900px; text-align: center; }
.msg-eyebrow, .msg-icon { opacity: 0; transform: translateY(20px); transition: opacity .8s, transform .8s cubic-bezier(.2, .9, .3, 1.3); }
.message.in .msg-eyebrow, .message.in .msg-icon { opacity: 1; transform: none; }
.message.in .msg-icon { transition-delay: .2s; }
.msg-icon { position: relative; display: inline-grid; place-items: center; width: 120px; height: 120px; margin: 18px 0 10px; }
.msg-icon::before { /* anillo de luz girando */
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, #ffd36b, transparent 35%, #ff4757, transparent 65%, #2ed573, transparent);
  -webkit-mask: radial-gradient(circle, transparent 54%, #000 56%, #000 62%, transparent 64%);
  mask: radial-gradient(circle, transparent 54%, #000 56%, #000 62%, transparent 64%);
  animation: spin 6s linear infinite; filter: drop-shadow(0 0 8px #ffd36b);
}
.msg-icon::after {
  content: ''; position: absolute; inset: 18%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 211, 107, .45), transparent 70%);
  animation: halo 2.6s ease-in-out infinite;
}
.msg-icon span { position: relative; z-index: 1; font-size: 3.6rem; animation: bounce 3s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.msg-quote { position: relative; margin: 0; padding: 0 clamp(8px, 4vw, 40px); }
.msg-quote::before, .msg-quote::after {
  position: absolute; font-family: var(--font-title); font-size: clamp(5rem, 14vw, 9rem); line-height: 1;
  color: var(--gold); opacity: 0; transition: opacity 1.2s .4s; text-shadow: 0 0 30px rgba(255, 211, 107, .5);
}
.msg-quote::before { content: '“'; left: -10px; top: -40px; }
.msg-quote::after { content: '”'; right: -10px; bottom: 30px; }
.message.in .msg-quote::before, .message.in .msg-quote::after { opacity: .35; }

.msg-line {
  margin: 0 0 .9em; font-size: clamp(1.15rem, 2.9vw, 1.65rem); line-height: 1.65; font-weight: 600;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .5);
}
.msg-line .w {
  display: inline-block; opacity: 0; transform: translateY(18px) scale(.96); filter: blur(8px);
  transition: opacity .7s ease, transform .7s cubic-bezier(.2, .9, .3, 1.3), filter .7s ease;
}
.message.in .msg-line .w { opacity: 1; transform: none; filter: none; transition-delay: var(--d); }
.msg-line em {
  font-style: normal; font-weight: 800;
  background: linear-gradient(100deg, #ffd36b 20%, #fff6d0 40%, #ffb347 50%, #fff6d0 60%, #ffd36b 80%) 0 0 / 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: nameShine 4s linear infinite;
}

.msg-final {
  margin: 1.2em 0 0; font-family: var(--font-title); font-size: clamp(2.1rem, 6.5vw, 3.8rem); line-height: 1.15;
  text-shadow: 0 4px 0 rgba(0, 0, 0, .3), 0 0 30px rgba(255, 107, 107, .6);
  opacity: 0; transform: scale(.7); filter: blur(10px);
  transition: opacity 1s ease, transform 1.1s cubic-bezier(.2, .9, .3, 1.4), filter 1s ease;
}
.message.in .msg-final {
  opacity: 1; transform: none; filter: none; transition-delay: var(--final-d);
  animation: finalGlow 3s ease-in-out calc(var(--final-d) + 1.2s) infinite;
}
@keyframes finalGlow {
  0%, 100% { text-shadow: 0 4px 0 rgba(0, 0, 0, .3), 0 0 24px rgba(255, 107, 107, .5); }
  50% { text-shadow: 0 4px 0 rgba(0, 0, 0, .3), 0 0 46px rgba(255, 211, 107, .9); }
}
.msg-final .beat, .msg-final .sway { display: inline-block; margin-left: .15em; }
.msg-final .beat { animation: heartbeat 1.3s ease-in-out infinite; }
.msg-final .sway { animation: swing 2.4s ease-in-out infinite; }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.3); } 30% { transform: scale(1); } 45% { transform: scale(1.2); } }

@media (max-width: 600px) {
  .msg-quote::before { left: -6px; top: -50px; }
  .msg-quote::after { right: -4px; bottom: 60px; }
  .msg-line { line-height: 1.55; }
}
.has-3d .sleigh { display: none; }
.hoho {
  position: fixed; top: 0; left: 0; z-index: 3; pointer-events: none;
  background: #fff; color: var(--red-dark); font-weight: 800; font-size: 15px;
  padding: 6px 12px; border-radius: 14px; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  opacity: 0; transition: opacity .25s;
}
.hoho::after { content: ''; position: absolute; left: 50%; bottom: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: #fff; transform: translateX(-50%); }
.hoho.show { opacity: 1; }

/* ---------- Árbol de Navidad ---------- */
.xmas-tree {
  position: fixed; z-index: 1; left: 5%; bottom: 3vh;
  height: min(50vh, 440px); width: auto; aspect-ratio: 2 / 3;
  cursor: pointer; overflow: visible;
  filter: drop-shadow(0 0 24px rgba(255, 211, 107, .18));
  transition: opacity .5s, transform .5s;
  transform-origin: 50% 100%;
}
.xmas-tree.shake { animation: treeShake .5s; }
@keyframes treeShake { 25% { transform: rotate(-2.5deg); } 50% { transform: rotate(2deg); } 75% { transform: rotate(-1deg); } }
.xmas-tree .star { transform-box: fill-box; transform-origin: center; animation: starSpin 6s ease-in-out infinite; }
@keyframes starSpin { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.12) rotate(12deg); } }
.xmas-tree .halo { transform-box: fill-box; transform-origin: center; animation: halo 2.4s ease-in-out infinite; }
@keyframes halo { 0%, 100% { opacity: .55; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.15); } }
.xmas-tree .light { transform-box: fill-box; transform-origin: center; }
.xmas-tree[data-mode=twinkle] .light { animation: twinkle 1.6s ease-in-out infinite; animation-delay: calc(var(--r) * -1.6s); }
@keyframes twinkle { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .25; transform: scale(.7); } }
.xmas-tree[data-mode=chase] .light { animation: chase 1.4s linear infinite; animation-delay: calc(var(--i) * .07s); }
@keyframes chase { 0%, 70%, 100% { opacity: .2; } 10%, 30% { opacity: 1; transform: scale(1.3); } }
.xmas-tree[data-mode=rainbow] .light { animation: rainbow 2.4s linear infinite; animation-delay: calc(var(--i) * -.12s); }
@keyframes rainbow { 0%, 100% { fill: #ff4757; } 20% { fill: #ffd36b; } 40% { fill: #2ed573; } 60% { fill: #54a0ff; } 80% { fill: #ff6bcb; } }
.xmas-tree[data-mode=warm] .light { fill: #ffd98a !important; animation: twinkle 3s ease-in-out infinite; animation-delay: calc(var(--r) * -3s); }
.tree-tip {
  position: fixed; z-index: 3; pointer-events: none; font-size: .8rem; font-weight: 700;
  background: rgba(255, 255, 255, .92); color: var(--night-2); padding: 4px 10px; border-radius: 999px;
  opacity: 0; transition: opacity .3s; transform: translate(-50%, 0);
}
.tree-tip.show { opacity: 1; }

/* ---------- Trineo (respaldo con emojis) ---------- */
.sleigh {
  position: fixed; top: 0; left: 0; z-index: 5;
  display: flex; align-items: flex-end; gap: 2px;
  font-size: clamp(26px, 4.5vw, 44px);
  background: none; border: 0; padding: 0; cursor: pointer;
  transform: translate(-999px, -999px);
  filter: drop-shadow(0 0 10px rgba(255, 230, 160, .35));
  will-change: transform;
}
.sleigh .deer { display: inline-block; animation: gallop .5s ease-in-out infinite alternate; }
.sleigh .deer:nth-child(2) { animation-delay: .15s; }
.sleigh .deer:nth-child(3) { animation-delay: .3s; }
@keyframes gallop { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-8px) rotate(4deg); } }
.sleigh .rope { width: 14px; height: 2px; background: #c9a35a; margin-bottom: .45em; }
.santa-sled { position: relative; display: inline-block; }
.santa-sled .santa { position: absolute; left: 50%; bottom: 45%; transform: translateX(-50%); font-size: .8em; }
.sleigh .bubble {
  position: absolute; bottom: 110%; right: 0;
  background: #fff; color: var(--red-dark); font-weight: 800;
  font-size: 15px; padding: 6px 12px; border-radius: 14px; white-space: nowrap;
  opacity: 0; transform: scale(.6); transition: .25s;
}
.sleigh.talk .bubble { opacity: 1; transform: scale(1); }

/* ---------- Layout ---------- */
.app {
  position: relative; z-index: 2;
  min-height: 100svh;
  display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.app { pointer-events: none; }
.screen { display: none; width: 100%; max-width: 640px; pointer-events: auto; }
.screen.active { display: block; animation: enter .55s cubic-bezier(.2, .9, .3, 1.2) both; }
.screen.leaving { display: block; animation: leave .3s ease-in both; }
@keyframes enter { from { opacity: 0; transform: translateY(30px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes leave { to { opacity: 0; transform: translateY(-20px) scale(.97); } }

#screen-home { text-align: center; margin-bottom: 18vh; }
.eyebrow { letter-spacing: .25em; text-transform: uppercase; font-size: .8rem; color: var(--gold); margin: 0; }
.title {
  font-family: var(--font-title); font-size: clamp(3.4rem, 14vw, 7rem); line-height: .95;
  margin: .1em 0 .2em; text-shadow: 0 4px 0 rgba(0, 0, 0, .25), 0 0 30px rgba(255, 211, 107, .35);
}
.title span { color: var(--red); text-shadow: 0 4px 0 var(--red-dark), 0 0 40px rgba(226, 59, 74, .5); display: inline-block; animation: swing 3s ease-in-out infinite; }
@keyframes swing { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
.lead { font-size: clamp(1rem, 3.6vw, 1.2rem); line-height: 1.55; opacity: .92; }

.countdown { display: flex; justify-content: center; gap: 10px; margin: 22px 0 30px; flex-wrap: wrap; }
.countdown .box {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 16px;
  padding: 10px 14px; min-width: 74px; backdrop-filter: blur(6px);
}
.countdown .num { font-size: 1.8rem; font-weight: 800; color: var(--gold); display: block; font-variant-numeric: tabular-nums; }
.countdown .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; opacity: .8; }
.countdown .today { font-family: var(--font-title); font-size: 2rem; color: var(--gold); }

.panel {
  background: rgba(13, 20, 50, .62); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: clamp(20px, 5vw, 36px);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.panel h2, .screen > h2 { font-family: var(--font-title); font-size: clamp(1.9rem, 7vw, 2.6rem); margin: 0 0 .2em; line-height: 1.1; }
.hint { margin: 0 0 18px; opacity: .75; }
.center { text-align: center; }

/* ---------- Botones e inputs ---------- */
.btn {
  border: 0; border-radius: 999px; cursor: pointer;
  padding: 13px 24px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, #f2515f, var(--red-dark));
  box-shadow: 0 5px 0 #7d1520, 0 10px 24px rgba(226, 59, 74, .35);
  transition: transform .12s, box-shadow .12s, filter .2s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #7d1520, 0 4px 12px rgba(226, 59, 74, .3); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-big { font-size: 1.15rem; padding: 17px 34px; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 5px 0 #7d1520, 0 0 0 0 rgba(255, 211, 107, .5); } 50% { box-shadow: 0 5px 0 #7d1520, 0 0 0 14px rgba(255, 211, 107, 0); } }
.btn-ghost { background: transparent; box-shadow: none; border: 1px solid var(--glass-border); }
.btn-ghost:active { box-shadow: none; }
.btn-green { background: linear-gradient(180deg, #3cc283, #1f7c50); box-shadow: 0 5px 0 #11502f; }

.input {
  width: 100%; padding: 13px 16px; border-radius: 14px;
  border: 1px solid var(--glass-border); background: rgba(255, 255, 255, .1); color: var(--snow);
  outline: none; transition: border-color .2s, background .2s;
}
.input::placeholder { color: rgba(244, 248, 255, .5); }
.input:focus { border-color: var(--gold); background: rgba(255, 255, 255, .14); }
textarea.input { resize: vertical; min-height: 60px; }
.field { display: block; margin-top: 18px; position: relative; }
.field > span:first-child { display: block; margin-bottom: 8px; font-weight: 600; }
.field em { opacity: .6; font-weight: 400; }
.counter { position: absolute; right: 12px; bottom: 10px; font-size: .78rem; opacity: .6; }
.error { color: #ff9aa4; min-height: 1.2em; margin: 10px 0 0; font-weight: 600; }
.warn { display: none; text-align: center; color: var(--gold); margin: 14px 0 0; }
.warn.show { display: block; }

.nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.center .nav, #screen-review .nav { justify-content: center; }

.steps { display: flex; gap: 8px; justify-content: center; margin-bottom: 18px; }
.steps i { width: 34px; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .2); transition: .3s; }
.steps i.on { background: var(--gold); box-shadow: 0 0 10px var(--gold); }

/* ---------- Familia ---------- */
.search { margin-bottom: 16px; }
.family-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; max-height: 52vh; overflow-y: auto; padding: 4px; margin: -4px; }
.member {
  position: relative; text-align: center; cursor: pointer;
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 18px;
  padding: 16px 10px 14px; color: var(--snow);
  transition: transform .2s, background .2s, border-color .2s;
  animation: pop .45s cubic-bezier(.2, .9, .3, 1.4) both;
}
.member:hover, .member:focus-visible { transform: translateY(-4px) rotate(-1deg); background: rgba(255, 255, 255, .15); border-color: var(--gold); outline: none; }
.member .emoji { font-size: 2.4rem; display: block; margin-bottom: 6px; transition: transform .3s; }
.member:hover .emoji { transform: scale(1.2) rotate(8deg); }
.member .name { font-weight: 800; line-height: 1.2; display: block; }
.member .nick { font-size: .78rem; color: var(--gold); display: block; margin-top: 4px; font-style: italic; }
.member .sent { position: absolute; top: 8px; right: 8px; font-size: .9rem; }
@keyframes pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }
.empty { opacity: .7; text-align: center; grid-column: 1 / -1; }

/* ---------- Portómetro ---------- */
.meter { text-align: center; margin-top: 8px; }
.meter-face { font-size: 5rem; line-height: 1; transition: transform .2s; display: inline-block; }
.meter-face.bump { animation: bump .35s; }
@keyframes bump { 50% { transform: scale(1.25) rotate(-8deg); } }
.meter-label { font-weight: 800; font-size: 1.2rem; margin: 8px 0 16px; color: var(--gold); min-height: 1.5em; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 14px; border-radius: 10px;
  background: linear-gradient(90deg, #7b2cbf, #e23b4a 30%, #ffd36b 60%, #2fa36b); outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 38px; height: 38px; border-radius: 50%;
  background: #fff url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text x='50' y='70' font-size='60' text-anchor='middle'>⭐</text></svg>") center/80% no-repeat;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .4); cursor: grab;
}
input[type=range]::-moz-range-thumb {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .4); cursor: grab;
}
.meter-scale { display: flex; justify-content: space-between; font-size: .85rem; opacity: .8; margin-top: 8px; }
.santa-says { display: flex; gap: 12px; align-items: center; text-align: left; margin-top: 18px; }
.santa-says > span { font-size: 2.4rem; }
.santa-says p {
  margin: 0; flex: 1; background: #fff; color: var(--ink); padding: 12px 16px; border-radius: 16px 16px 16px 4px;
  font-weight: 600; position: relative; min-height: 3em;
}

/* ---------- Regalos ---------- */
.add-gift { display: flex; gap: 10px; }
.add-gift .input { flex: 1; min-width: 0; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip {
  border: 1px dashed var(--glass-border); background: transparent; color: var(--snow);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: .9rem; transition: .2s;
}
.chip:hover { border-color: var(--gold); background: rgba(255, 211, 107, .1); }
.gift-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.gift-list li {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(90deg, rgba(47, 163, 107, .25), rgba(255, 255, 255, .06));
  border: 1px solid rgba(47, 163, 107, .5); border-radius: 14px; padding: 10px 12px;
  animation: drop .45s cubic-bezier(.2, .9, .3, 1.4) both;
}
.gift-list li .g { flex: 1; word-break: break-word; }
.gift-list li button { background: none; border: 0; color: #ff9aa4; font-size: 1.2rem; cursor: pointer; padding: 0 4px; }
.gift-list li.removing { animation: leave .25s ease-in both; }
@keyframes drop { from { opacity: 0; transform: translateY(-20px) rotate(-3deg); } to { opacity: 1; transform: none; } }

/* ---------- Carta ---------- */
.letter-wrap { perspective: 1200px; }
.letter {
  position: relative; color: var(--ink);
  background:
    repeating-linear-gradient(transparent 0 31px, rgba(180, 140, 90, .25) 31px 32px),
    linear-gradient(135deg, #fffaf0, #f6ead2);
  border-radius: 6px; padding: 34px clamp(20px, 6vw, 44px) 30px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, .45), inset 0 0 60px rgba(160, 110, 50, .15);
  font-size: 1.05rem; line-height: 32px;
  transform-style: preserve-3d; transition: transform .15s ease-out;
  border: 8px solid transparent;
  border-image: repeating-linear-gradient(45deg, var(--red) 0 12px, #fff 12px 24px, var(--green) 24px 36px, #fff 36px 48px) 8;
}
.letter p { margin: 0 0 4px; }
.letter-hi { font-family: var(--font-title); font-size: 2rem; color: var(--red-dark); margin-bottom: 8px !important; }
.letter-date { text-align: right; font-size: .9rem; opacity: .7; }
.letter-note { font-style: italic; opacity: .85; }
.letter-note:empty { display: none; }
.letter ul { margin: 0 0 6px; padding-left: 1.4em; }
.letter li::marker { content: '🎁 '; }
.letter blockquote { margin: 0 0 10px; padding-left: 14px; border-left: 3px solid var(--gold); font-style: italic; word-break: break-word; }
.letter-sign { text-align: right; font-family: var(--font-title); font-size: 1.5rem; margin-top: 10px !important; line-height: 1.3; }
.stamp {
  position: absolute; top: 14px; left: 14px; font-size: 1.8rem; width: 52px; height: 60px;
  display: grid; place-items: center; background: #fff; border: 2px dashed var(--red); transform: rotate(-8deg);
}

.letter.send { animation: sendLetter 1.4s cubic-bezier(.5, 0, .7, .4) forwards; }
@keyframes sendLetter {
  0% { transform: none; }
  25% { transform: scale(.55) rotateX(70deg); filter: brightness(.95); }
  45% { transform: scale(.35) rotateX(0deg) rotateZ(-8deg); }
  100% { transform: translate(60vw, -110vh) scale(.08) rotateZ(-40deg); opacity: .3; }
}

/* ---------- Final ---------- */
.done-icon { font-size: 5rem; animation: bounce 1.2s infinite; display: inline-block; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }

/* ---------- Responsive ---------- */
/* ---------- Heroes de la familia ---------- */
.fam-intro, .fam-outro {
  position: relative; z-index: 2; text-align: center;
  padding: 18vh 20px 12vh;
  background: linear-gradient(180deg, #16224a 0%, var(--night-1) 100%);
}
.fam-outro { padding: 14vh 20px 18vh; background: linear-gradient(180deg, var(--night-1), #13204d); }
.fam-outro h2, .fam-intro-title { font-family: var(--font-title); font-size: clamp(2.6rem, 10vw, 5rem); margin: .15em 0 .3em; line-height: 1; }
.fam-outro h2 { font-size: clamp(2.2rem, 8vw, 3.8rem); }
.fam-intro-title span { color: var(--gold); text-shadow: 0 0 30px rgba(255, 211, 107, .45); }
.fam-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 820px; margin: 26px auto 0; }
.fam-chip {
  color: var(--snow); text-decoration: none; font-weight: 800;
  padding: 10px 16px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-border);
  animation: pop .5s cubic-bezier(.2, .9, .3, 1.4) both; transition: background .2s, transform .2s;
}
.fam-chip:hover { background: rgba(255, 255, 255, .16); transform: translateY(-3px); }

.fam-hero {
  --k: 0;
  position: relative; z-index: 2; overflow: hidden;
  min-height: 100vh; min-height: 100svh;
  display: grid; place-items: center; padding: 9vh 20px;
  background: var(--night-1);
}
/* Fondo: una mitad por integrante, con su foto difuminada y su color, fundidas al centro */
.fam-bg { position: absolute; inset: 0; }
.bgh { position: absolute; top: -8%; bottom: -8%; }
.bgh:first-child { left: -8%; right: 38%; -webkit-mask-image: linear-gradient(90deg, #000 55%, transparent); mask-image: linear-gradient(90deg, #000 55%, transparent); }
.bgh:last-child:not(:first-child) { left: 38%; right: -8%; -webkit-mask-image: linear-gradient(270deg, #000 55%, transparent); mask-image: linear-gradient(270deg, #000 55%, transparent); }
.fam-hero.single .bgh { left: -8%; right: -8%; -webkit-mask-image: none; mask-image: none; }
.bgh::before {
  content: ''; position: absolute; inset: 0;
  background: var(--bg) center / cover no-repeat;
  filter: blur(34px) saturate(1.4) brightness(.55);
  transform: scale(1.15) translateY(calc(var(--k) * 40px));
  will-change: transform;
}
.bgh::after {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--c1) 50%, transparent), transparent 65%),
    linear-gradient(180deg, color-mix(in srgb, var(--c2) 80%, transparent) 0%, rgba(7, 11, 31, .8) 75%, var(--night-1) 100%);
}
.fam-sparkles { position: absolute; inset: 0; pointer-events: none; }
.fam-sparkles i {
  position: absolute; font-style: normal; color: #fff8d6;
  text-shadow: 0 0 10px #ffd36b, 0 0 18px #fff3b0;
  animation: sparkleFloat 6s ease-in-out infinite;
}
@keyframes sparkleFloat {
  0%, 100% { opacity: 0; transform: translateY(20px) scale(.5) rotate(0); }
  40%, 60% { opacity: .95; transform: translateY(-10px) scale(1) rotate(45deg); }
}

.fam-pair {
  position: relative; width: 100%; max-width: 1180px;
  display: grid; grid-template-columns: 1fr 1fr; gap: clamp(30px, 6vw, 90px); align-items: start;
}
.fam-hero.single .fam-pair { grid-template-columns: minmax(0, 560px); justify-content: center; }
.fam-card { display: grid; gap: 30px; text-align: center; }

.fam-photos { position: relative; width: min(100%, 460px); margin: 0 auto; aspect-ratio: 1 / .92; }
.par { will-change: transform; }
.par-a { position: absolute; left: 0; top: 0; width: 66%; transform: translateY(calc(var(--k) * -50px)); }
.par-b { position: absolute; right: 0; bottom: 0; width: 46%; transform: translateY(calc(var(--k) * 70px)); }
.par-t { transform: translateY(calc(var(--k) * -20px)); }
.fam-card.rev .par-a { left: auto; right: 0; }
.fam-card.rev .par-b { right: auto; left: 0; }

.ph { margin: 0; position: relative; }
.ph img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ph-a {
  aspect-ratio: 4 / 5; border-radius: 24px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .15);
  opacity: 0; transform: translateX(-70px) rotate(-12deg) scale(.86); filter: blur(12px);
  transition: opacity 1s ease, transform 1.2s cubic-bezier(.2, .9, .3, 1.15), filter 1s ease;
}
.fam-card.rev .ph-a { transform: translateX(70px) rotate(12deg) scale(.86); }
.ph-clip { position: absolute; inset: 0; overflow: hidden; border-radius: 24px; }
.ph-clip img { animation: kenburns 16s ease-in-out infinite alternate; }
.ph-clip::after { /* degradado inferior + destello que cruza la foto */
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(to top, color-mix(in srgb, var(--c2) 90%, transparent) 0%, transparent 50%),
              linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, .28) 45%, transparent 60%) no-repeat;
  background-size: 100% 100%, 250% 100%;
  animation: shine 6s ease-in-out infinite;
}
.fam-card.rev .ph-clip::after { animation-delay: -3s; }
@keyframes shine { 0%, 55% { background-position: 0 0, 160% 0; } 100% { background-position: 0 0, -60% 0; } }
@keyframes kenburns { from { transform: scale(1) translate(0, 0); } to { transform: scale(1.14) translate(-2%, -3%); } }
.ph-lights { position: absolute; left: 5%; right: 5%; top: -9px; display: flex; justify-content: space-between; z-index: 2; }
.ph-lights::before { content: ''; position: absolute; left: -2%; right: -2%; top: 6px; height: 2px; background: #2c3a2c; border-radius: 2px; }
.ph-lights i {
  position: relative; width: 10px; height: 14px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: #ff4757; box-shadow: 0 0 12px 2px currentColor; color: #ff4757;
  animation: bulb 1.4s ease-in-out infinite alternate;
}
.ph-lights i:nth-child(5n+2) { background: #ffd36b; color: #ffd36b; animation-delay: -.3s; }
.ph-lights i:nth-child(5n+3) { background: #54a0ff; color: #54a0ff; animation-delay: -.6s; }
.ph-lights i:nth-child(5n+4) { background: #2ed573; color: #2ed573; animation-delay: -.9s; }
.ph-lights i:nth-child(5n+5) { background: #ff6bcb; color: #ff6bcb; animation-delay: -1.2s; }
@keyframes bulb { from { opacity: .35; } to { opacity: 1; } }

.ph-b {
  background: #fffaf0; padding: 10px 10px 40px; border-radius: 6px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, .5);
  opacity: 0; transform: translateX(70px) rotate(16deg) scale(.85); filter: blur(10px);
  transition: opacity 1s ease .35s, transform 1.2s cubic-bezier(.2, .9, .3, 1.2) .35s, filter 1s ease .35s;
}
.fam-card.rev .ph-b { transform: translateX(-70px) rotate(-16deg) scale(.85); }
.ph-b img { aspect-ratio: 1; border-radius: 2px; }
.ph-b figcaption {
  position: absolute; left: 0; right: 0; bottom: 7px; text-align: center;
  font-family: var(--font-title); font-size: 1.2rem; color: var(--red-dark);
}
/* Entrada: la tarjeta derecha llega un poco después que la izquierda */
.fam-card.rev .ph-a, .fam-card.rev .ph-b, .fam-card.rev .fam-text > * { transition-delay: .3s; }
.fam-card.rev .ph-b { transition-delay: .65s; }
.fam-hero.in .ph-a { opacity: 1; transform: rotate(-3deg); filter: none; }
.fam-hero.in .ph-b { opacity: 1; transform: rotate(5deg); filter: none; animation: polaroidFloat 6s ease-in-out 1.8s infinite; }
.fam-hero.in .fam-card.rev .ph-a { transform: rotate(3deg); }
.fam-hero.in .fam-card.rev .ph-b { transform: rotate(-5deg); animation-name: polaroidFloatRev; }
@keyframes polaroidFloat { 0%, 100% { transform: rotate(5deg) translateY(0); } 50% { transform: rotate(2deg) translateY(-12px); } }
@keyframes polaroidFloatRev { 0%, 100% { transform: rotate(-5deg) translateY(0); } 50% { transform: rotate(-2deg) translateY(-12px); } }

.fam-text > * { opacity: 0; transform: translateY(24px); transition: opacity .8s ease, transform .8s cubic-bezier(.2, .9, .3, 1.2); }
.fam-hero.in .fam-text > * { opacity: 1; transform: none; }
.fam-hero.in .fam-text > :nth-child(2) { transition-delay: .5s; }
.fam-hero.in .fam-text > :nth-child(3) { transition-delay: .65s; }
.fam-hero.in .fam-text > :nth-child(4) { transition-delay: .8s; }
.fam-hero.in .fam-text > :nth-child(5) { transition-delay: .95s; }
.fam-hero.in .fam-card.rev .fam-text > :nth-child(2) { transition-delay: .8s; }
.fam-hero.in .fam-card.rev .fam-text > :nth-child(3) { transition-delay: .95s; }
.fam-hero.in .fam-card.rev .fam-text > :nth-child(4) { transition-delay: 1.1s; }
.fam-hero.in .fam-card.rev .fam-text > :nth-child(5) { transition-delay: 1.25s; }
.fam-idx { display: block; font-weight: 800; letter-spacing: .3em; font-size: .78rem; color: var(--gold); }
.fam-name {
  font-family: var(--font-title); font-size: clamp(2.1rem, 4.4vw, 3.3rem); line-height: 1.05; margin: 8px 0 0;
}
.fam-emoji { display: inline-block; }
.fam-hero.in .fam-emoji { animation: swing 3s ease-in-out 1.2s infinite; }
.fam-name .txt {
  background: linear-gradient(100deg, #fff 20%, #ffe9a8 40%, var(--c1) 50%, #ffe9a8 60%, #fff 80%) 0 0 / 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: nameShine 5s linear infinite;
}
@keyframes nameShine { to { background-position: -250% 0; } }
.fam-nick { margin: 6px 0 0; font-style: italic; font-weight: 700; color: var(--gold); }
.fam-nick:empty { display: none; }
.fam-phrase {
  margin: 14px auto 0; max-width: 440px; padding: 12px 16px; font-size: clamp(1rem, 2vw, 1.15rem); line-height: 1.45;
  background: rgba(255, 255, 255, .08); border-top: 3px solid var(--c1); border-radius: 0 0 14px 14px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.fam-status {
  display: inline-block; margin-top: 14px; padding: 7px 13px; border-radius: 999px; font-weight: 800; font-size: .85rem;
  background: rgba(255, 255, 255, .1); border: 1px dashed rgba(255, 255, 255, .35);
}
.fam-status.done { background: rgba(47, 163, 107, .3); border: 1px solid #3cc283; }

/* Celular: los dos integrantes uno debajo del otro (fondo partido arriba/abajo) */
@media (max-width: 760px) {
  .fam-hero { padding: 10vh 18px; }
  .fam-pair { grid-template-columns: 1fr; gap: 64px; }
  .fam-photos { width: min(100%, 340px); }
  .bgh:first-child { left: -8%; right: -8%; top: -8%; bottom: 42%; -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent); mask-image: linear-gradient(180deg, #000 60%, transparent); }
  .bgh:last-child:not(:first-child) { left: -8%; right: -8%; top: 42%; bottom: -8%; -webkit-mask-image: linear-gradient(0deg, #000 60%, transparent); mask-image: linear-gradient(0deg, #000 60%, transparent); }
  .bgh::before { filter: blur(22px) saturate(1.3) brightness(.55); }
}

/* En pantallas angostas el árbol se achica y se esconde fuera de la portada */
@media (max-width: 900px) {
  body:not([data-screen=home]) .xmas-tree { opacity: 0; transform: translateY(40px); pointer-events: none; }
}
@media (max-width: 700px) {
  .xmas-tree { left: 2%; height: min(28vh, 260px); bottom: 2vh; }
}
@media (max-width: 700px) and (max-height: 700px) {
  .xmas-tree { height: 22vh; }
}

@media (max-width: 480px) {
  .family-grid { grid-template-columns: repeat(2, 1fr); max-height: 56vh; }
  .member .emoji { font-size: 2rem; }
  .nav .btn { flex: 1; }
  .btn-big { width: 100%; }
  .countdown .box { min-width: 64px; padding: 8px 10px; }
  .countdown .num { font-size: 1.5rem; }
  .letter { font-size: .98rem; }
}

@media (prefers-reduced-motion: reduce) {
  .screen.active { animation-duration: .2s; }
  .moon, .hills { transition: none; }
}

/* ================= Rendimiento ================= */
/* Las secciones fuera de pantalla no se dibujan (gran ahorro en celulares) */
.message, .fam-hero, .fam-intro, .fam-outro { content-visibility: auto; contain-intrinsic-size: auto 900px; }
/* Y sus animaciones quedan en pausa hasta que vuelven a verse */
.message:not(.in) *, .fam-hero:not(.in) * { animation-play-state: paused !important; }

/* ---------- Modo liviano (Android / equipos modestos / pocos FPS) ---------- */
.lite .panel, .lite .countdown .box, .lite .music-btn, .lite .fam-phrase, .lite .fam-chip {
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
}
.lite .panel { background: rgba(13, 20, 50, .94); }
.lite .countdown .box, .lite .music-btn { background: rgba(13, 20, 50, .8); }
/* Sin filtros que obligan a redibujar en cada cuadro */
.lite .xmas-tree, .lite .xmas-tree .lights, .lite .xmas-tree .star, .lite .sleigh { filter: none; }
.lite .ph-a, .lite .ph-b, .lite .msg-line .w, .lite .msg-final { filter: none !important; }
/* Fondo de los heroes solo con degradados (sin la foto difuminada) */
.lite .bgh::before { display: none; }
/* Menos partículas */
.lite .fam-sparkles i:nth-child(2n), .lite .msg-snow i:nth-child(2n),
.lite .msg-bokeh i:nth-child(2n), .lite .msg-hearts i:nth-child(2n) { display: none; }
/* Animaciones continuas más pesadas, desactivadas */
.lite .fam-name .txt, .lite .msg-line em, .lite .ph-clip::after, .lite .ph-clip img,
.lite .xmas-tree .halo, .lite .fam-sparkles i:nth-child(3n) { animation: none; }
.lite .fam-name .txt, .lite .msg-line em { background-position: 0 0; }
