:root {
  --crema: #fffaf0;
  --tinta: #3d2f22;
  --oro: #f6c453;
  --rosa: #e8456b;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --mano: "Caveat", "Segoe Print", "Bradley Hand", cursive;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: #f4d9a0; color: var(--tinta); }
body { font-family: var(--serif); overscroll-behavior-y: none; }
body.locked { overflow: hidden; height: 100%; }
html:has(body.locked) { overflow: hidden; height: 100%; }

#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; z-index: 0; }
#scroller { width: 1px; height: 100vh; pointer-events: none; }

.fade { opacity: 0; transition: opacity .6s ease, transform .6s ease; pointer-events: none; }
.fade.on { opacity: 1; }

/* ---------- Portada ---------- */
#intro {
  position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column;
  justify-content: space-between; align-items: center; text-align: center;
  padding: max(5vh, 26px) 20px max(8vh, 36px); pointer-events: none;
  transition: opacity .9s ease; color: #4a2f16;
}
#intro.out { opacity: 0; }
#intro::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 46%; z-index: -1;
  background: linear-gradient(rgba(255, 247, 228, .97) 0%, rgba(255, 247, 228, .93) 62%, rgba(255, 247, 228, 0) 100%);
}
#intro .pre { font-family: var(--mano); font-size: clamp(26px, 6vw, 38px); margin: 0; }
#intro h1 { font-size: clamp(52px, 14vw, 92px); font-weight: 600; font-style: italic; margin: -6px 0 4px; line-height: 1;
  text-shadow: 0 2px 18px rgba(255, 250, 235, .9); }
#intro .sub { font-size: clamp(15px, 3.8vw, 20px); letter-spacing: .1em; margin: 6px 0 0; font-weight: 600; }
#abrir {
  pointer-events: auto; cursor: pointer; border: 0; border-radius: 999px;
  font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: .04em;
  padding: 15px 38px; color: #fff; background: var(--rosa);
  box-shadow: 0 10px 30px rgba(232, 69, 107, .45); animation: late 2.2s ease-in-out infinite;
}
@keyframes late { 50% { transform: scale(1.06); } }
#intro .mini { font-family: var(--mano); font-size: 20px; margin: 14px 0 0; color: #fff; text-shadow: 0 1px 8px rgba(40, 20, 0, .8); }

/* ---------- HUD ---------- */
#hud[hidden] { display: none; }
#anio {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 16px; z-index: 4;
  font-size: 30px; font-weight: 600; font-style: italic; color: #fff;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .45); transition: opacity .5s;
}
#musica, #auto {
  position: fixed; z-index: 4; border: 0; cursor: pointer; color: #fff;
  background: rgba(40, 28, 16, .38); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-family: var(--serif); border-radius: 999px;
}
#musica { top: max(12px, env(safe-area-inset-top)); right: 14px; width: 44px; height: 44px; font-size: 22px; }
#musica.off { opacity: .55; text-decoration: line-through; }
#auto { right: 14px; bottom: max(22px, env(safe-area-inset-bottom)); padding: 11px 18px; font-size: 16px; font-weight: 600; }
#auto.on { background: rgba(232, 69, 107, .85); }
#barra { position: fixed; left: 0; right: 0; bottom: 0; height: 3px; z-index: 4; background: rgba(255, 255, 255, .18); }
#barra i { display: block; height: 100%; width: 0; background: var(--oro); }

#capitulo {
  position: fixed; top: 15vh; left: 0; right: 0; z-index: 3; text-align: center; padding: 0 22px;
  font-size: clamp(32px, 8.5vw, 62px); font-style: italic; font-weight: 600; color: #fff; line-height: 1.05;
  text-shadow: 0 2px 22px rgba(60, 30, 0, .55), 0 0 2px rgba(60, 30, 0, .4); transform: translateY(-10px);
}
#capitulo.on { transform: none; }
#linea {
  position: fixed; top: 34vh; left: 0; right: 0; z-index: 3; text-align: center; padding: 0 30px;
  font-size: clamp(24px, 6.2vw, 40px); font-style: italic; color: #fdf3d6; line-height: 1.25;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .7); max-width: 760px; margin: 0 auto;
}
#cap {
  position: fixed; left: 50%; bottom: max(78px, calc(env(safe-area-inset-bottom) + 70px)); z-index: 3;
  transform: translate(-50%, 8px); width: min(calc(100vw - 168px), 520px); text-align: center;
  background: rgba(255, 250, 240, .92); border-radius: 14px; padding: 10px 16px 12px;
  box-shadow: 0 8px 30px rgba(40, 20, 0, .25);
}
#cap.on { transform: translate(-50%, 0); }
#cap .fecha { display: block; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; opacity: .6; }
#cap .txt { display: block; font-family: var(--mano); font-size: clamp(22px, 5.6vw, 27px); line-height: 1.1; }
#hint {
  position: fixed; left: 0; right: 0; bottom: 24vh; z-index: 3; text-align: center; color: #fff;
  font-size: 21px; font-weight: 600; text-shadow: 0 2px 14px rgba(40, 20, 0, .7); padding: 0 20px;
}
#hint small { font-family: var(--mano); font-size: 19px; font-weight: 500; }

/* ---------- Foto grande ---------- */
#lightbox[hidden] { display: none; }
#lightbox {
  position: fixed; inset: 0; z-index: 20; background: rgba(18, 12, 8, .93);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 54px 10px 20px;
}
.lb-media { max-width: 100%; display: flex; }
.lb-media img, .lb-media video {
  max-width: min(94vw, 900px); max-height: 70vh; border: 8px solid var(--crema); border-radius: 4px;
  background: #222; box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
.lb-cap { font-family: var(--mano); color: #fff3d6; font-size: 25px; text-align: center; margin: 16px 12px 0; max-width: 640px; line-height: 1.15; }
.lb-x, .lb-nav { position: absolute; border: 0; background: rgba(255, 255, 255, .14); color: #fff; cursor: pointer; border-radius: 999px; }
.lb-x { top: max(12px, env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; font-size: 19px; }
.lb-nav { top: 50%; width: 44px; height: 64px; font-size: 34px; line-height: 1; transform: translateY(-50%); z-index: 2; }
.lb-nav.prev { left: 6px; } .lb-nav.next { right: 6px; }

/* ---------- Final ---------- */
#final {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; max-height: 66vh; overflow-y: auto;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: linear-gradient(rgba(255, 250, 240, .96), rgba(255, 247, 232, .99));
  border-radius: 26px 26px 0 0; box-shadow: 0 -12px 50px rgba(0, 0, 0, .45);
  transform: translateY(105%); transition: transform 1.1s cubic-bezier(.2, .8, .2, 1); visibility: hidden;
}
#final.on { transform: none; visibility: visible; }
.final-inner { padding: 26px 24px max(30px, env(safe-area-inset-bottom)); max-width: 620px; margin: 0 auto; }
#final h2 { font-family: var(--mano); font-size: 40px; margin: 0 0 6px; color: #8a68cc; }
#final-msg p { font-size: 20px; line-height: 1.45; margin: 0 0 14px; }
.firma { font-family: var(--mano); font-size: 30px; text-align: right; margin: 0; }
.firma:empty { display: none; }
#final hr { border: 0; height: 1px; background: rgba(61, 47, 34, .18); margin: 22px 0 18px; }
.invita { font-style: italic; font-size: 19px; margin: 0 0 12px; line-height: 1.35; }
#form textarea, #form input {
  width: 100%; font: 17px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--tinta);
  background: #fff; border: 1px solid rgba(61, 47, 34, .25); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px;
}
#form textarea:focus, #form input:focus { outline: 2px solid var(--oro); border-color: transparent; }
#form button, #volver {
  width: 100%; border: 0; border-radius: 999px; cursor: pointer; font-family: var(--serif);
  font-size: 20px; font-weight: 600; padding: 13px;
}
#form button { color: #fff; background: var(--rosa); }
#form button:disabled { opacity: .6; }
.nota { font-size: 14px; opacity: .6; text-align: center; margin: 8px 0 0; }
#form-ok { font-family: var(--mano); font-size: 28px; text-align: center; color: var(--rosa); margin: 10px 0; }
#form-ok a { color: inherit; }
.opciones { display: grid; gap: 10px; margin-bottom: 12px; }
.opciones label { cursor: pointer; }
.opciones input { position: absolute; opacity: 0; pointer-events: none; }
.opciones span {
  display: block; text-align: center; font-size: 20px; font-weight: 600; padding: 13px;
  border: 2px solid rgba(138, 104, 204, .45); border-radius: 14px; background: #fff; transition: .2s;
}
.opciones input:checked + span { background: #8a68cc; border-color: #8a68cc; color: #fff; }
.opciones input:focus-visible + span { outline: 2px solid var(--oro); }
.falta { color: #c0304f; font-size: 16px; margin: -4px 0 10px; text-align: center; }
.campo { display: block; font-size: 15px; opacity: .85; }
.campo input { margin-top: 4px; }
#mandos { position: fixed; left: 14px; bottom: max(22px, env(safe-area-inset-bottom)); z-index: 4; display: flex; flex-direction: column; gap: 8px; }
#mandos button {
  width: 58px; height: 58px; border: 0; border-radius: 16px; font-size: 22px; color: #fff; cursor: pointer;
  background: rgba(40, 28, 16, .42); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#mandos #adelante { background: rgba(232, 69, 107, .85); height: 66px; font-size: 26px; }
#mandos button:active { transform: scale(.94); }
#volver { margin-top: 18px; background: transparent; color: var(--tinta); border: 1px solid rgba(61, 47, 34, .3); font-size: 17px; }

@media (min-width: 900px) {
  #final { left: auto; right: 28px; bottom: 28px; top: 28px; width: 440px; max-height: none; border-radius: 22px; transform: translateX(115%); }
  #cap { bottom: 46px; }
  #capitulo { top: 12vh; }
}

#yt-wrap { position: fixed; left: -400px; bottom: 0; width: 220px; height: 220px; opacity: 0; pointer-events: none; z-index: -1; }
@media (prefers-reduced-motion: reduce) { #abrir { animation: none; } }

/* celular acostado y pantallas bajitas */
@media (orientation: landscape) and (max-height: 520px) {
  #intro { padding: 10px 20px 14px; }
  #intro::before { height: 60%; }
  #intro .pre { font-size: 20px; }
  #intro h1 { font-size: clamp(34px, 15vh, 60px); margin: -4px 0 0; }
  #intro .sub { font-size: 13px; margin-top: 2px; }
  #abrir { font-size: 17px; padding: 10px 28px; }
  #intro .mini { font-size: 16px; margin-top: 6px; }
  #final { left: auto; right: 0; top: 0; bottom: 0; width: 52vw; max-height: none; border-radius: 22px 0 0 22px; transform: translateX(105%); }
  #final-msg p { font-size: 17px; }
  #capitulo { top: 8vh; font-size: 30px; }
  #linea { top: 22vh; font-size: 24px; }
  #cap, #cap.on { left: auto; right: 12px; bottom: 66px; transform: none; width: min(42vw, 340px); padding: 6px 14px 8px; }
  #cap .txt { font-size: 21px; }
  #mandos { flex-direction: row; }
  #mandos button, #mandos #adelante { width: 54px; height: 54px; }
  #hint { bottom: 30vh; font-size: 17px; }
  .lb-media img, .lb-media video { max-height: 62vh; }
  .lb-cap { font-size: 19px; margin-top: 8px; }
}
@media (max-width: 380px) {
  #cap .txt { font-size: 21px; }
  #auto { padding: 10px 13px; font-size: 14px; }
  #final-msg p { font-size: 18px; }
}
