body.app {
  background:
    radial-gradient(ellipse at 50% -10%, #1f6144 0%, transparent 60%),
    radial-gradient(ellipse at 100% 100%, #5a0c1b 0%, transparent 55%),
    var(--green-dark);
  background-attachment: fixed;
}
#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
main { position: relative; z-index: 1; }

.preview-banner {
  position: sticky; top: 0; z-index: 50; background: var(--gold); color: var(--ink);
  text-align: center; font-weight: 700; padding: 0.5em 1em;
}
.preview-banner a { color: var(--red-dark); }

/* ---------- Pantalla de codigo ---------- */
.gate { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card {
  width: min(100%, 440px); text-align: center; padding: 36px 24px;
  background: linear-gradient(160deg, rgba(122, 16, 34, 0.92), rgba(78, 10, 22, 0.95));
  border: 2px solid var(--gold); border-radius: 22px; box-shadow: var(--shadow);
}
.gate-star { font-size: 3rem; line-height: 1; color: var(--gold); margin-bottom: 8px; }
.gate-card h1 { font-size: clamp(1.7rem, 6vw, 2.2rem); color: var(--cream); }
.gate-card p { color: var(--cream-dim); }
.gate-card form { margin-top: 20px; text-align: left; }
#code-input { text-align: center; font-size: 1.6rem; letter-spacing: 0.2em; text-transform: uppercase; font-family: ui-monospace, Consolas, monospace; font-weight: 700; }
.gate-card .btn { width: 100%; margin-top: 14px; }

/* ---------- Cabecera ---------- */
.hero { text-align: center; padding: 36px 16px 8px; max-width: 760px; margin: 0 auto; }
.hero .year { color: var(--gold); letter-spacing: 0.3em; font-size: 0.85rem; text-transform: uppercase; }
.hero h1 { font-size: clamp(2rem, 8vw, 3.4rem); color: var(--cream); text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4); margin-bottom: 0.2em; }
.hero .for { font-family: var(--font-title); font-style: italic; font-size: 1.3rem; color: var(--gold); margin-bottom: 0.8em; }
.hero .welcome { white-space: pre-line; color: var(--cream); font-size: 1.05rem; background: rgba(0, 0, 0, 0.2); border-left: 3px solid var(--gold); padding: 0.8em 1em; border-radius: 0 12px 12px 0; text-align: left; }
.hero .from { font-family: var(--font-title); font-style: italic; color: var(--cream-dim); margin-top: 0.8em; }
.countdown { margin: 18px auto 0; color: var(--gold); font-weight: 600; min-height: 1.5em; }

/* ---------- Cuadricula de puertas ---------- */
.doors {
  list-style: none; margin: 0 auto; padding: 24px 14px 40px; max-width: 980px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: clamp(84px, 24vw, 130px);
  grid-auto-flow: dense; gap: 12px;
}
@media (min-width: 640px) { .doors { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
@media (min-width: 900px) { .doors { grid-template-columns: repeat(6, 1fr); grid-auto-rows: 125px; } }
.door-cell { perspective: 900px; position: relative; }
.door-cell.big { grid-column: span 2; grid-row: span 2; }
.door {
  all: unset; box-sizing: border-box; cursor: pointer; display: block;
  width: 100%; height: 100%; position: relative; border-radius: 10px;
}
.door:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.door-back {
  position: absolute; inset: 0; border-radius: 10px;
  background: radial-gradient(circle at 50% 60%, #ffe9a8, #d4af5a 60%, #8a6a22);
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.55);
  display: grid; place-items: center; color: var(--red-dark); font-size: 1.8rem;
}
.door-front {
  position: absolute; inset: 0; border-radius: 10px; transform-origin: left center;
  background: linear-gradient(145deg, var(--red-bright), var(--red) 55%, var(--red-dark));
  border: 2px solid var(--gold);
  box-shadow: var(--shadow), inset 0 0 0 4px rgba(212, 175, 90, 0.18);
  display: grid; place-items: center; color: var(--cream);
  transition: transform 0.8s cubic-bezier(0.3, 0.7, 0.2, 1), filter 0.3s;
  backface-visibility: hidden;
}
.door-cell:nth-child(3n) .door-front { background: linear-gradient(145deg, #22714d, var(--green) 55%, var(--green-dark)); }
.door-cell:nth-child(5n) .door-front { background: linear-gradient(145deg, #f0e2bd, var(--cream-dim) 55%, #cdb887); color: var(--red); }
.door-num { font-family: var(--font-title); font-weight: 700; font-size: clamp(1.5rem, 6vw, 2.3rem); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); }
.door-cell.big .door-num { font-size: clamp(2.4rem, 9vw, 3.6rem); }
.door-cell:nth-child(5n) .door-num { text-shadow: none; }
.door-front::after { content: ""; position: absolute; right: 10%; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 4px rgba(0, 0, 0, 0.5); }
.door:hover .door-front { filter: brightness(1.12); }
.door.is-opening .door-front, .door.is-open .door-front { transform: rotateY(-115deg); }
.door.is-open .door-front { transform: rotateY(-70deg); }
.door.is-open .door-back { background: radial-gradient(circle at 50% 60%, #fff3cf, #e5c46f 60%, #a98531); }
.door.is-locked .door-front { filter: saturate(0.65) brightness(0.85); }
.door.is-locked:hover .door-front { filter: saturate(0.65) brightness(0.95); }
.door .lock { position: absolute; left: 8px; top: 6px; font-size: 0.9rem; opacity: 0.85; }
.door.shake { animation: shake 0.5s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px) rotate(-1deg); }
  40% { transform: translateX(6px) rotate(1deg); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
.door-state { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; font-size: 0.7rem; color: var(--ink); font-weight: 700; pointer-events: none; }
.door.is-open .door-back { font-size: 1.5rem; }

.footer-bar { position: relative; z-index: 1; text-align: center; padding: 8px 16px 32px; }
.footer-bar .btn { font-size: 0.85rem; opacity: 0.8; }

/* ---------- Modal de dia ---------- */
dialog { border: none; padding: 0; color: var(--ink); background: transparent; max-width: 100vw; max-height: 100dvh; }
dialog::backdrop { background: rgba(10, 18, 12, 0.82); }
.day-dialog { width: min(100vw, 680px); margin: auto; }
.day-sheet {
  background: var(--cream); border-radius: 20px 20px 0 0; border: 2px solid var(--gold);
  max-height: 92dvh; overflow-y: auto; padding: 22px 18px 28px; position: relative;
  animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (min-width: 700px) { .day-sheet { border-radius: 20px; } }
@keyframes rise { from { transform: translateY(40px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
.day-close { position: absolute; top: 10px; right: 10px; }
.day-sheet .day-badge { display: inline-block; background: var(--red); color: var(--cream); font-family: var(--font-title); border-radius: 999px; padding: 0.15em 0.9em; font-size: 0.95rem; }
.day-sheet h2 { color: var(--red); font-size: clamp(1.5rem, 5vw, 2rem); margin: 0.3em 2em 0.4em 0; }
.day-note { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.08rem; line-height: 1.65; margin-bottom: 1.2em; }
.empty-day { font-style: italic; color: #6b5a4a; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 1em; }
.gallery figure { margin: 0; }
.gallery .thumb { all: unset; display: block; cursor: zoom-in; width: 100%; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 3px solid #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3); background: #ddd; }
.gallery .thumb:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.gallery .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery figcaption, .media-item figcaption { font-size: 0.85rem; color: #4a382c; margin-top: 4px; overflow-wrap: anywhere; }
.media-item { margin: 0 0 1em; background: #fffaf0; border: 1px solid var(--cream-dim); border-radius: 14px; padding: 12px; }
.media-item audio, .media-item video { width: 100%; display: block; border-radius: 10px; }
.media-item video { background: #000; max-height: 60dvh; }
.media-label { font-weight: 700; color: var(--red); margin-bottom: 6px; display: flex; align-items: center; gap: 0.4em; }
.media-item.voice { border-color: var(--gold); background: linear-gradient(135deg, #fff7df, #fffaf0); }

/* ---------- Lightbox ---------- */
.lightbox { width: 100vw; height: 100dvh; margin: 0; }
.lightbox::backdrop { background: rgba(0, 0, 0, 0.94); }
.lb-body { width: 100%; height: 100dvh; display: grid; grid-template-rows: 1fr auto; touch-action: pan-y; }
.lb-stage { display: grid; place-items: center; min-height: 0; padding: 48px 8px 8px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; user-select: none; -webkit-user-drag: none; }
.lb-caption { color: var(--cream); text-align: center; padding: 6px 16px 18px; min-height: 2.5em; }
.lb-btn { position: absolute; z-index: 2; background: rgba(0, 0, 0, 0.55); color: #fff; border-color: rgba(255, 255, 255, 0.6); width: 48px; padding: 0; min-height: 48px; font-size: 1.4rem; }
.lb-close { top: 10px; right: 10px; }
.lb-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; top: 18px; left: 16px; color: var(--cream); font-size: 0.9rem; }
