:root {
  --wine: #4a1c2a;
  --rose: #8b3a4a;
  --blush: #e8b4b8;
  --gold: #c9a36a;
  --gold-2: #ead9b2;
  --cream: #faf4ea;
  --ink: #4a3040;
  --ink-soft: #6d4e5c;
  --paper: #fbf6ee;
  --shadow: 0 30px 80px rgba(20, 4, 12, .45);
  --radius: 18px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { -webkit-tap-highlight-color: transparent; }
body {
  font-family: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: #1a0810;
  overflow: hidden;
  min-height: 100dvh;
  overscroll-behavior: none;
}

button, input, textarea { font-family: inherit; }
[hidden] { display: none !important; }

/* ===== SKY ===== */
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, #5a2038 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 80% 80%, #3a1528 0%, transparent 50%),
    linear-gradient(180deg, #14060c 0%, #2a0e18 45%, #1a0810 100%);
}
#sparkles { position: absolute; inset: 0; width: 100%; height: 100%; }
.bokeh { position: absolute; inset: 0;
  background:
    radial-gradient(circle at 12% 22%, rgba(233,180,188,.22) 0 2px, transparent 3px),
    radial-gradient(circle at 78% 18%, rgba(201,163,106,.2) 0 3px, transparent 4px),
    radial-gradient(circle at 22% 78%, rgba(255,220,230,.12) 0 2px, transparent 3px),
    radial-gradient(circle at 88% 72%, rgba(233,180,188,.18) 0 2px, transparent 4px);
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { to { opacity: .55; } }

.petals span {
  position: absolute; top: -40px; width: 14px; height: 18px;
  background: radial-gradient(circle at 30% 30%, #f7d4d8, #c96a7a);
  border-radius: 80% 0 80% 0; opacity: .75;
  animation: fall linear infinite;
}
@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: .8; }
  100% { transform: translateY(110vh) rotate(360deg); opacity: 0; }
}

/* ===== INTRO ===== */
.intro {
  position: relative; z-index: 2;
  min-height: 100dvh; display: grid; place-items: center;
  padding: 24px 20px 40px; text-align: center; color: #f8ecee;
}
.intro-inner { max-width: 420px; width: 100%; }
.whisper {
  letter-spacing: .28em; text-transform: uppercase; font-size: 11px;
  color: var(--blush);
}
.intro-title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 500; font-size: clamp(32px, 8vw, 48px); line-height: 1.15;
  margin: 14px 0 12px;
}
.intro-sub { color: #e8cfd4; font-weight: 300; font-size: 14px; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.name-gate {
  margin-top: 28px; display: grid; gap: 10px;
}
.name-gate label { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-2); }
.name-gate input {
  background: rgba(255,255,255,.08); border: 1px solid rgba(233,196,176,.35);
  color: #fff; padding: 14px 16px; border-radius: 999px; text-align: center;
  font-size: 16px; outline: none;
}
.name-gate input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(201,163,106,.18); }
.gate-hint { min-height: 20px; font-size: 13px; color: #ffd0d8; }
.shake { animation: shake .4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.btn-gold {
  cursor: pointer; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #e8d5a8, #c9a36a);
  color: #3b2418; font-weight: 600; padding: 12px 22px;
  box-shadow: 0 8px 24px rgba(201,163,106,.28);
  transition: transform .2s, filter .2s;
}
.btn-gold:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-gold:active { transform: translateY(1px); }

/* envelope */
.envelope-stage { margin-top: 18px; perspective: 900px; }
.envelope-caption { font-size: 13px; color: var(--gold-2); margin-bottom: 16px; }
.envelope {
  position: relative; width: min(280px, 78vw); height: 180px; margin: 0 auto;
  border: 0; background: transparent; cursor: pointer; display: block;
  transform-style: preserve-3d;
}
.env-pocket {
  position: absolute; inset: 40px 0 0; background: linear-gradient(180deg, #8b3a4a, #5c2232);
  border-radius: 0 0 14px 14px; box-shadow: var(--shadow); z-index: 2;
}
.env-flap {
  position: absolute; top: 0; left: 0; right: 0; height: 92px; z-index: 4;
  background: linear-gradient(180deg, #a34b5c, #7a3142);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center; transition: transform 1s ease;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.2));
}
.envelope.open .env-flap { transform: rotateX(-158deg); z-index: 1; }
.env-letter {
  position: absolute; left: 18px; right: 18px; top: 58px; height: 110px; z-index: 1;
  background: var(--cream); border-radius: 4px; display: grid; place-content: center; gap: 4px;
  transform: translateY(16px); transition: transform 1.1s .2s ease, z-index 0s .2s;
  box-shadow: 0 8px 16px rgba(0,0,0,.2); color: var(--ink);
}
.envelope.open .env-letter { transform: translateY(-62px); z-index: 3; }
.letter-line { font-family: "Great Vibes", cursive; font-size: 26px; }
.letter-line.thin { font-family: "Be Vietnam Pro", sans-serif; font-size: 11px; letter-spacing: .08em; }
.wax-seal {
  position: absolute; left: 50%; top: 72px; transform: translateX(-50%); z-index: 5;
  width: 48px; height: 48px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c45a5a, #7a1f2a);
  color: #f8d9a8; font-size: 22px; display: grid; place-items: center;
  box-shadow: 0 4px 0 #4a1018, 0 8px 16px rgba(0,0,0,.3);
  transition: transform .4s, opacity .4s;
}
.envelope.open .wax-seal { opacity: 0; transform: translateX(-50%) scale(.4); }
.env-shadow { position: absolute; inset: 48px -8px -12px; background: radial-gradient(ellipse, rgba(0,0,0,.4), transparent 70%); z-index: 0; }

/* ===== APP / BOOK ===== */
.app {
  position: relative; z-index: 2;
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; padding: 12px 8px 96px;
}
.topbar { text-align: center; color: #f3e2e6; margin-bottom: 8px; }
.for-her { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--blush); }
.for-her span { font-style: normal; color: var(--gold-2); }
.page-indicator { font-family: "Cormorant Garamond", serif; font-size: 15px; opacity: .85; margin-top: 4px; }

.book-stage {
  flex: 1; width: 100%; max-width: 1100px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.book-frame {
  width: min(920px, calc(100vw - 88px));
  height: min(640px, calc(100dvh - 160px));
  filter: drop-shadow(0 28px 50px rgba(0,0,0,.5));
  overflow: hidden;
  touch-action: pan-y;
}
#book { width: 100%; height: 100%; touch-action: pan-y; }
.stf__parent { width: 100% !important; height: 100% !important; min-width: 0 !important; min-height: 0 !important; }
.stf__wrapper { width: 100% !important; height: 100% !important; padding-bottom: 0 !important; }
.stf__block { width: 100% !important; height: 100% !important; touch-action: pan-y; }

.page {
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}
.page::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(80,40,40,.07), transparent 8%, transparent 92%, rgba(80,40,40,.08)),
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(160,120,100,.05) 32px);
  mix-blend-mode: multiply;
}

.sheet {
  height: 100%; padding: 28px 26px 24px;
  display: flex; flex-direction: column; gap: 10px;
  position: relative; z-index: 1;
}
.folio {
  position: absolute; bottom: 14px; right: 18px;
  font-size: 11px; letter-spacing: .2em; color: #b08990;
}
.kicker {
  font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--rose);
}
.sheet h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(22px, 3.2vw, 30px); font-weight: 600; line-height: 1.2;
  color: var(--wine);
}
.sheet p, .sheet li { font-size: 13.5px; line-height: 1.65; color: var(--ink-soft); font-weight: 300; }
.sheet p.italic, .italic, .ask { font-style: italic; color: var(--rose); }
.quote {
  margin-top: auto; padding: 12px 0 28px;
  font-family: "Cormorant Garamond", serif; font-style: italic;
  font-size: 16px; color: var(--wine); border-top: 1px solid rgba(139,58,74,.18);
}
.sign { margin-top: auto; padding-bottom: 22px; font-family: "Great Vibes", cursive; font-size: 28px; color: var(--rose); }

/* cover */
.page-cover {
  background:
    radial-gradient(ellipse at 50% 20%, rgba(233,180,188,.18), transparent 50%),
    linear-gradient(165deg, #6b2436 0%, #3d1320 55%, #2a0c16 100%) !important;
  color: #f8ece8;
}
.page-cover::after { display: none; }
.cover-inner {
  height: 100%; padding: 36px 28px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 10px;
  border: 1px solid rgba(233, 212, 170, .28); margin: 14px; border-radius: 8px;
}
.cover-kicker { letter-spacing: .32em; text-transform: uppercase; font-size: 11px; color: var(--gold-2); }
.cover-name {
  font-family: "Great Vibes", cursive; font-size: clamp(42px, 8vw, 64px);
  font-weight: 400; background: linear-gradient(180deg, #fff6e0, #e0c48a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1.1; text-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.cover-name.small { font-size: clamp(28px, 5vw, 40px); }
.cover-line { font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 18px; color: #f0d0d4; }
.cover-heart { font-size: 22px; color: var(--gold); margin: 8px 0; animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }
.cover-foot { font-size: 12px; letter-spacing: .12em; color: #e8c8ce; margin-top: 12px; }
.cover-ornament { width: 88px; height: 10px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: .7;
}
.cover-ornament.top { margin-bottom: 8px; }
.cover-ornament.bot { margin-top: 8px; }

/* polaroid */
.photo-page { align-items: center; justify-content: center; }
.polaroid {
  background: #fff; padding: 10px 10px 12px;
  width: min(86%, 280px);
  box-shadow: 0 18px 40px rgba(70, 30, 40, .22);
  display: flex; flex-direction: column;
}
.polaroid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #eee; flex: none; }
.polaroid.portrait { width: min(68%, 210px); }
.polaroid.portrait img { aspect-ratio: 3 / 4; object-position: center 18%; }
.polaroid figcaption {
  position: static;
  margin: 0;
  padding: 10px 8px 4px;
  font-family: "Great Vibes", cursive;
  font-size: 20px;
  line-height: 1.2;
  text-align: center;
  color: #6a3a48;
}
.tilt-left { transform: rotate(-3.2deg); }
.tilt-right { transform: rotate(2.8deg); }

.bday { align-items: center; text-align: center; }
.bday-name { font-family: "Great Vibes", cursive; font-size: 36px; color: var(--rose); }
.script { font-family: "Great Vibes", cursive !important; font-size: 40px !important; font-weight: 400 !important; color: var(--wine); }
.cake { position: relative; width: 84px; height: 78px; margin: 8px auto 4px; }
.layer { position: absolute; bottom: 0; left: 8px; right: 8px; height: 36px;
  background: linear-gradient(#f2d4c8, #e8b4b8); border-radius: 6px 6px 10px 10px;
  box-shadow: inset 0 8px 0 #fff6f0;
}
.candle { position: absolute; left: 50%; bottom: 36px; width: 8px; height: 22px; margin-left: -4px;
  background: linear-gradient(#fff, #f0e0c0); border-radius: 2px;
}
.flame { position: absolute; left: 50%; bottom: 56px; width: 10px; height: 16px; margin-left: -5px;
  background: radial-gradient(circle at 50% 70%, #fff6c8, #ff9a3c 60%, transparent 70%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  animation: flicker .8s ease-in-out infinite;
}
@keyframes flicker { 50% { transform: scaleY(1.15) translateY(-1px); opacity: .85; } }

.flirts { list-style: none; display: grid; gap: 12px; padding-bottom: 24px; }
.flirts li {
  padding: 10px 12px 10px 14px; border-left: 2px solid var(--gold);
  background: rgba(201,163,106,.08); border-radius: 0 10px 10px 0;
}

.hint-pill {
  margin-top: auto; margin-bottom: 24px; align-self: center;
  font-size: 12px !important; letter-spacing: .08em;
  padding: 8px 14px; border-radius: 999px; background: rgba(139,58,74,.08); color: var(--rose) !important;
}

/* quiz */
.quiz { gap: 14px; overflow: auto; }
.q h4 { font-size: 13px; font-weight: 600; color: var(--wine); line-height: 1.4; margin-bottom: 8px; }
.opts { display: grid; gap: 6px; }
.opts button {
  text-align: left; background: rgba(255,255,255,.55); border: 1px solid rgba(139,58,74,.14);
  border-radius: 10px; padding: 8px 10px; font-size: 12px; color: var(--ink-soft); cursor: pointer;
  transition: .2s;
}
.opts button:hover { border-color: var(--gold); background: #fff; }
.opts button.picked {
  border-color: var(--rose);
  background: #f4dce1;
  color: var(--wine);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--rose);
}
.opts button.picked::before { content: "♡  "; color: var(--rose); }

.open-q { gap: 10px; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--wine); font-weight: 500; }
.field input[type="text"], .field textarea {
  width: 100%; border: 1px solid rgba(139,58,74,.18); background: rgba(255,255,255,.7);
  border-radius: 10px; padding: 8px 10px; font-size: 12px; color: var(--ink); resize: none; outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--gold); }
.field input[type="range"] { accent-color: var(--rose); width: 100%; }
.range-val { font-style: italic; font-weight: 400; color: var(--rose); font-size: 12px; }

.answer-sheet {
  flex: 1; overflow: auto; background: rgba(255,255,255,.55);
  border: 1px dashed rgba(139,58,74,.25); border-radius: 12px;
  padding: 10px; font-size: 11px; line-height: 1.55; white-space: pre-wrap;
  font-family: "Be Vietnam Pro", sans-serif; color: var(--ink-soft); min-height: 120px;
}
.copy-ok { font-size: 12px; color: #2f7a4a; }

.finale { text-align: center; }
.finale .quote { border: 0; }

.nav-btn {
  flex: 0 0 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(233,212,170,.35);
  background: rgba(255,255,255,.08); color: #f8ece8; font-size: 28px; cursor: pointer; line-height: 1;
  backdrop-filter: blur(8px);
}
.nav-btn:hover { background: rgba(201,163,106,.25); }
.nav-btn:disabled { opacity: .3; cursor: default; }
.swipe-hint { color: #e8c8ce; font-size: 12px; margin-top: 10px; opacity: .8; }

/* player */
.player {
  position: fixed; z-index: 30; left: 16px; bottom: 16px;
  display: flex; align-items: center; gap: 10px;
  background: rgba(42, 12, 24, .82); border: 1px solid rgba(255, 182, 193, .35);
  backdrop-filter: blur(12px); padding: 8px 16px 8px 8px; border-radius: 22px;
  color: #f8ece8; box-shadow: var(--shadow);
}
.yt-mini {
  width: 240px; height: 135px; border-radius: 12px; overflow: hidden;
  flex: 0 0 240px; background: #2a1018; box-shadow: 0 0 0 2px rgba(255,182,193,.35);
  position: relative;
}
.yt-mini iframe { width: 100% !important; height: 100% !important; border: 0; display: block; }
.yt-open {
  display: inline-block; margin-top: 4px; font-size: 10px; color: #ffc5d0;
  text-decoration: none; letter-spacing: .02em; opacity: .85;
}
.yt-open:hover { opacity: 1; text-decoration: underline; }
.vinyl {
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 50% 50%, #d9b36a 0 7px, #1a1a1a 8px 18px, #111 19px 24px);
  position: relative;
}
.vinyl .disc {
  position: absolute; inset: 0; border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 4px, rgba(255,255,255,.06) 5px);
}
.vinyl.spin .disc { animation: spin 3.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.player-info { min-width: 148px; max-width: 200px; }
.track-kicker { font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: #ffc5d0; }
.track-name { font-size: 14px; font-family: "Cormorant Garamond", serif; line-height: 1.2; }
.track-artist { font-size: 11px; color: #f0c8d0; font-weight: 300; margin-top: 1px; }
.player-controls { display: flex; gap: 6px; margin-top: 2px; }
.player-controls button {
  background: transparent; border: 0; color: var(--gold-2); cursor: pointer; font-size: 12px;
}

@media (max-width: 820px), (max-height: 560px) {
  .intro { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .app {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding: 6px 0 calc(74px + env(safe-area-inset-bottom));
  }
  .topbar { margin-bottom: 2px; flex: none; }
  .book-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: none;
    gap: 0;
  }
  .book-frame {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 10px 18px rgba(0,0,0,.35));
  }
  .nav-btn {
    position: absolute;
    top: 50%;
    z-index: 6;
    width: 40px;
    height: 40px;
    flex: none;
    transform: translateY(-50%);
    background: rgba(42, 12, 24, .45);
  }
  .nav-btn.prev { left: 6px; }
  .nav-btn.next { right: 6px; }
  .swipe-hint {
    margin: 0;
    font-size: 11px;
    flex: none;
  }
  .sheet { padding: 16px 42px 20px; gap: 6px; overflow: auto; -webkit-overflow-scrolling: touch; }
  .sheet p, .sheet li { font-size: 13px; line-height: 1.5; }
  .polaroid { width: min(78%, 230px); }
  .polaroid.portrait { width: min(62%, 190px); }
  .polaroid figcaption { font-size: 18px; padding: 8px 6px 2px; }
  .player {
    left: 8px;
    right: 8px;
    bottom: calc(6px + env(safe-area-inset-bottom));
    height: 58px;
    max-height: 58px;
    padding: 4px 10px 4px 6px;
    gap: 8px;
    flex-wrap: nowrap;
    overflow: hidden;
    align-items: center;
    background: #2a0c18;
  }
  .yt-mini {
    position: relative;
    width: 72px;
    height: 48px;
    flex: 0 0 72px;
    overflow: hidden;
    pointer-events: none;
    border-radius: 8px;
    box-shadow: none;
    z-index: 0;
  }
  .yt-mini iframe {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 240px !important;
    height: 135px !important;
    transform: translate(-50%, -50%);
    pointer-events: none;
  }
  .vinyl, .player-info { position: relative; z-index: 1; }
  .yt-open { display: none; }
  .vinyl { width: 40px; height: 40px; flex: none; }
  .player-info { flex: 1; min-width: 0; max-width: none; }
  .track-name, .track-artist {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .player-controls { gap: 2px; }
  .player-controls button { font-size: 16px; padding: 6px 8px; }
}

@media (prefers-reduced-motion: no-preference) {
  .whisper { animation: fadeUp .9s .2s both; }
  .intro-title { animation: fadeUp .9s .45s both; }
  .intro-sub { animation: fadeUp .9s .7s both; }
  .name-gate { animation: fadeUp .9s .95s both; }
}
@media (prefers-reduced-motion: reduce) {
  .cover-heart, .flame, .vinyl.spin .disc, .petals span { animation: none !important; }
}
