:root {
  --night: #0f0a08;
  --night-2: #1a120e;
  --ember: #2a1a12;
  --gold: #f2c879;
  --gold-soft: #e9b96a;
  --blush: #eab3a4;
  --cream: #f7ecdf;
  --muted: #bfa996;
  --paper: #fbf6ee;
  --ink: #3a2a20;
  --script: "Great Vibes", "Brush Script MT", cursive;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Jost", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--night);
  color: var(--cream);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
[hidden] { display: none !important; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.script { font-family: var(--script); font-weight: 400; line-height: 1.1; }
.eyebrow {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--gold);
}

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* ---------- full-screen scenes ---------- */
.screen {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px 16px;
  background: radial-gradient(ellipse at 50% 60%, var(--ember) 0%, var(--night) 65%);
  transition: opacity 1.2s ease;
}
.screen.fade-out { opacity: 0; pointer-events: none; }

/* lock */
.lock-glow, .candle-glow {
  position: absolute; left: 50%; top: 55%; width: 120vmax; height: 120vmax;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(242, 200, 121, .16) 0%, rgba(242, 200, 121, 0) 40%);
  animation: breathe 5s ease-in-out infinite;
  pointer-events: none;
}
.lock-inner { position: relative; max-width: 420px; }
#lock h1 { font-size: clamp(64px, 18vw, 110px); color: var(--cream); margin: 8px 0 12px; }
.lock-text { color: var(--muted); font-style: italic; font-size: 20px; margin-bottom: 32px; }
#lock-form { display: flex; gap: 8px; justify-content: center; }
#lock-code {
  width: 180px; padding: 12px 16px;
  font-family: var(--sans); font-size: 15px; letter-spacing: .2em; text-transform: uppercase; text-align: center;
  color: var(--cream); background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(242, 200, 121, .35); border-radius: 999px; outline: none;
}
#lock-code::placeholder { letter-spacing: .05em; text-transform: none; color: rgba(191, 169, 150, .6); }
#lock-code:focus { border-color: var(--gold); }
#lock-form button {
  padding: 12px 22px; border-radius: 999px;
  font-family: var(--sans); font-size: 13px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--night); background: var(--gold);
}
.shake { animation: shake .45s; }
.code-box { display: flex; flex-direction: column; align-items: center; margin-top: 14px; }
.code-toggle { font-family: var(--sans); font-size: 12px; letter-spacing: .1em; color: rgba(191, 169, 150, .5); padding: 8px; }

/* candles on her birthday photo */
.candle-eyebrow { position: relative; }
.candle-title { position: relative; font-size: clamp(38px, 10vw, 72px); margin: 4px 0 18px; color: var(--cream); }
.cake-photo {
  position: relative; container-type: inline-size;
  height: min(58vh, 640px); height: min(58svh, 640px); aspect-ratio: 3 / 4; max-width: 100%;
  border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  transform-origin: 50% 0;
  transition: filter 1.2s ease, transform 1.2s var(--ease);
}
.cake-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 14px; pointer-events: none; }
.candles { position: absolute; inset: 0; }
/* warm candlelight on the photo; --lit goes from 1 to 0 as they go out */
.cake-photo::after {
  content: ""; position: absolute; inset: 0; border-radius: 14px; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse 60% 26% at 43% 82%, rgba(255, 170, 70, .34), rgba(255, 150, 60, .12) 55%, transparent 80%);
  mix-blend-mode: screen; opacity: var(--lit, 1); transition: opacity .6s ease;
}
.candles { z-index: 2; }
/* one unit --s is 0.25% of the photo width, scaled by depth (--k) */
.c {
  --s: calc(.25cqw * var(--k, 1));
  position: absolute; width: calc(var(--s) * 7); height: calc(var(--s) * 40 * var(--h, 1));
  transform: translate(-50%, -100%) rotate(var(--tilt, 0deg)); transform-origin: 50% 100%;
  transition: opacity 1s ease;
}
.c > span { position: absolute; display: block; }
/* light the flame throws on the plate, and the candle's contact shadow */
.c .glow {
  left: 50%; bottom: calc(var(--s) * -8); width: calc(var(--s) * 60); height: calc(var(--s) * 18); margin-left: calc(var(--s) * -30);
  background: radial-gradient(ellipse, rgba(255, 190, 90, .55), rgba(255, 160, 60, .18) 45%, transparent 70%);
  mix-blend-mode: screen; transition: opacity .5s ease;
}
.c .shadow {
  left: 50%; bottom: calc(var(--s) * -1.5); width: calc(var(--s) * 12); height: calc(var(--s) * 3.5); margin-left: calc(var(--s) * -3);
  background: radial-gradient(ellipse, rgba(40, 20, 10, .55), transparent 70%); filter: blur(1px);
}
.c .stick {
  bottom: 0; left: 0; width: 100%; height: calc(100% - var(--s) * 5); border-radius: 40% 40% 2px 2px / calc(var(--s) * 1.6) calc(var(--s) * 1.6) 2px 2px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .28) 0%, rgba(255, 255, 255, .0) 22%, rgba(255, 255, 255, .45) 34%, rgba(255, 255, 255, 0) 52%, rgba(0, 0, 0, .35) 100%),
    linear-gradient(180deg, rgba(255, 220, 150, .45) 0%, transparent 18%),
    repeating-linear-gradient(150deg, transparent 0 calc(var(--s) * 4), rgba(255, 255, 255, .55) calc(var(--s) * 4) calc(var(--s) * 6.5)),
    var(--wax, #f3b8c4);
}
.c .wick {
  bottom: calc(100% - var(--s) * 6.5); left: 50%; width: calc(var(--s) * 1.3); height: calc(var(--s) * 5); margin-left: calc(var(--s) * -.65);
  background: linear-gradient(#111, #3a2a20); border-radius: 40% 40% 0 0; transform: rotate(6deg);
}
.c .halo {
  left: 50%; bottom: calc(100% - var(--s) * 4); width: calc(var(--s) * 34); height: calc(var(--s) * 40); margin-left: calc(var(--s) * -17);
  background: radial-gradient(circle at 50% 62%, rgba(255, 200, 110, .5), rgba(255, 170, 70, .14) 35%, transparent 62%);
  mix-blend-mode: screen; animation: halo var(--f, 1.2s) ease-in-out var(--d, 0s) infinite alternate;
  transition: opacity .4s ease;
}
.c .flame {
  left: 50%; bottom: calc(100% - var(--s) * 3.5); width: calc(var(--s) * 6.5); height: calc(var(--s) * 17); margin-left: calc(var(--s) * -3.25);
  border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%;
  background:
    radial-gradient(ellipse 45% 22% at 50% 88%, rgba(70, 110, 255, .85), rgba(70, 110, 255, 0) 100%),
    radial-gradient(ellipse 38% 46% at 50% 66%, #fff 0%, #fff7d6 45%, rgba(255, 240, 190, 0) 100%),
    radial-gradient(ellipse at 50% 70%, #ffd36b 0%, #ffad33 48%, rgba(255, 120, 30, .6) 70%, rgba(255, 100, 20, 0) 82%);
  filter: drop-shadow(0 0 calc(var(--s) * 2) rgba(255, 180, 80, .9));
  transform-origin: 50% 92%;
  animation: flame var(--f, 1.2s) ease-in-out var(--d, 0s) infinite;
  transition: transform .25s ease, opacity .25s ease;
}
.c .smoke {
  left: 50%; bottom: calc(100% - var(--s) * 1); width: calc(var(--s) * 3); height: calc(var(--s) * 10); margin-left: calc(var(--s) * -1.5);
  border-radius: 50%; background: rgba(225, 218, 210, .55); filter: blur(2px); opacity: 0;
}
.c.out .flame { transform: scale(.1, .25); opacity: 0; animation: none; }
.c.out .halo, .c.out .glow { opacity: 0; animation: none; }
.c.out .smoke { animation: wisp 2s ease-out forwards; }
.c.gone { opacity: 0; }
@keyframes flame {
  0%, 100% { transform: scale(1, 1) rotate(-1deg); }
  25% { transform: scale(.94, 1.06) rotate(1.5deg); }
  50% { transform: scale(1.04, .95) rotate(-.5deg); }
  75% { transform: scale(.97, 1.04) rotate(2deg); }
}
@keyframes halo { from { opacity: .75; } to { opacity: 1; } }
@keyframes wisp {
  0% { opacity: 0; transform: translateY(0) scale(.6); }
  15% { opacity: .9; }
  100% { opacity: 0; transform: translate(calc(var(--s) * 4), calc(var(--s) * -40)) scale(2.4, 3); }
}
.candle-hint { position: relative; margin-top: 18px; min-height: 1.6em; color: var(--muted); font-style: italic; font-size: 19px; }
#candle.all-out .candle-glow, #candle.dark .candle-glow { opacity: 0; transition: opacity 1s; }

/* the padlock that opens after the tap */
.padlock {
  position: absolute; left: 50%; top: 50%; z-index: 5; pointer-events: none;
  transform: translate(-50%, -40%) scale(.8); opacity: 0;
  transition: opacity .6s ease, transform .6s var(--ease);
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, .6)) drop-shadow(0 0 24px rgba(242, 200, 121, .35));
}
.padlock .shackle { transition: transform .5s cubic-bezier(.3, 1.6, .5, 1); transform-origin: 48px 38px; }
#candle.unlocking .padlock { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#candle.unlocking .lock-card { opacity: 0; transform: translateY(30px); }
#candle.unlocking .cake-photo { filter: brightness(.35); }
#candle.unlocked-lock .padlock .shackle { transform: translateY(-9px) rotate(-28deg); }
#candle.unlocked-lock .padlock { animation: lockpop .5s ease; }
@keyframes lockpop { 40% { transform: translate(-50%, -50%) scale(1.08); } }

/* the lock: tap the lid */
.lock-card {
  position: absolute; left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom));
  max-width: 420px; margin: 0 auto; padding: 22px 20px 10px;
  background: rgba(15, 10, 8, .86); border: 1px solid rgba(242, 200, 121, .3); border-radius: 18px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: 0; transform: translateY(30px); transition: opacity 1s var(--ease), transform 1s var(--ease);
}
#candle.show-lock .lock-card { opacity: 1; transform: none; }
#candle.show-lock .cake-photo { filter: brightness(.55); transform: scale(.8); }
.lock-card .lock-text { color: var(--cream); font-style: italic; font-size: 19px; line-height: 1.45; margin: 10px 0 0; }
.tap-icon { position: relative; width: 76px; height: 64px; margin: 14px auto 0; }
.tap-icon .phone {
  position: absolute; left: 4px; top: 6px; width: 30px; height: 52px; border: 2px solid var(--gold); border-radius: 7px;
  animation: tapphone 2.4s ease-in-out infinite;
}
.tap-icon .wave {
  position: absolute; left: 44px; top: 50%; border: 2px solid var(--gold); border-left-color: transparent; border-bottom-color: transparent;
  border-radius: 50%; transform: translateY(-50%) rotate(45deg); opacity: 0; animation: tapwave 2.4s ease-out infinite;
}
.tap-icon .w1 { width: 12px; height: 12px; margin-left: -6px; }
.tap-icon .w2 { width: 24px; height: 24px; margin-left: -12px; animation-delay: .25s; }
.tap-icon .w3 { width: 36px; height: 36px; margin-left: -18px; animation-delay: .5s; }
@keyframes tapphone { 0%, 100% { transform: translateX(0); } 40%, 60% { transform: translateX(6px); } }
@keyframes tapwave { 0%, 35% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- hero ---------- */
#hero {
  position: relative; min-height: 100vh; min-height: 100svh; overflow: hidden;
  display: grid; grid-template-columns: 1fr; align-items: end;
}
.hero-backdrop { position: absolute; inset: 0; }
.hero-backdrop img { width: 100%; height: 100%; object-fit: cover; filter: blur(30px) brightness(.45) saturate(1.2); transform: scale(1.15); }
.hero-photo { position: absolute; inset: 0; margin: 0; }
.hp-in { position: relative; width: 100%; height: 100%; overflow: hidden; }
.hero-photo img {
  width: 100%; height: 100%; object-fit: cover; object-position: 50% 35%;
  opacity: 0; filter: blur(16px) brightness(.3);
  transition: opacity 2.4s ease, filter 2.8s ease;
}
.hero-photo::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(15,10,8,.15) 0%, rgba(15,10,8,0) 30%, rgba(15,10,8,.55) 62%, var(--night) 100%);
}
#hero.lit .hero-photo img { opacity: 1; filter: none; animation: kenburns 24s ease-out forwards; }
.hero-text { position: relative; z-index: 2; padding: 0 16px calc(48px + env(safe-area-inset-bottom)); text-align: center; }
.hero-title { display: flex; flex-direction: column; align-items: center; font-weight: 400; margin: 6px 0 28px; }
.hero-title .script { font-size: clamp(60px, 17vw, 132px); color: var(--cream); text-shadow: 0 4px 40px rgba(0,0,0,.5); }
.hero-name {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: clamp(30px, 7vw, 52px); letter-spacing: .12em; color: var(--gold);
  margin-top: -4px;
}
.hero-text > * { opacity: 0; transform: translateY(18px); transition: opacity 1.4s var(--ease), transform 1.4s var(--ease); }
#hero.lit .hero-text > * { opacity: 1; transform: none; }
#hero.lit .hero-text > :nth-child(1) { transition-delay: 1.2s; }
#hero.lit .hero-text > :nth-child(2) { transition-delay: 1.7s; }
#hero.lit .hero-text > :nth-child(3) { transition-delay: 2.6s; }
.scroll-cue {
  display: inline-flex; flex-direction: column; align-items: center; gap: 10px;
  font-family: var(--sans); font-size: 12px; letter-spacing: .3em; text-transform: uppercase;
  color: var(--cream); text-decoration: none;
}
.scroll-cue i { width: 1px; height: 44px; background: linear-gradient(var(--gold), transparent); animation: drip 2.2s ease-in-out infinite; }

@media (min-width: 900px) {
  #hero { grid-template-columns: 1.1fr 1fr; align-items: center; padding: 0 6vw; gap: 4vw; }
  .hero-photo {
    position: relative; inset: auto; grid-column: 2; grid-row: 1; justify-self: center;
    height: min(84vh, 900px); aspect-ratio: 3 / 4;
    padding: 14px 14px 56px; background: var(--paper);
    border-radius: 4px; box-shadow: 0 30px 80px rgba(0,0,0,.55);
    transform: rotate(2.5deg);
  }
  .hero-photo::after { display: none; }
  .hero-photo img { border-radius: 2px; }
  .hero-text { grid-column: 1; grid-row: 1; padding: 0; }
}

/* ---------- timeline ---------- */
#story { position: relative; padding: 96px 16px 40px; background: var(--night); }
.story-head { text-align: center; margin-bottom: 64px; }
.story-head h2 { font-size: clamp(52px, 12vw, 96px); color: var(--cream); }
#timeline { list-style: none; position: relative; max-width: 1080px; margin: 0 auto; }
#timeline::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 11px; width: 1px;
  background: linear-gradient(transparent, rgba(242,200,121,.5) 4%, rgba(242,200,121,.5) 96%, transparent);
}
.year { position: relative; padding: 24px 0 24px 40px; }
.year span {
  font-family: var(--serif); font-style: italic; font-size: 44px; color: var(--gold);
}
.year::before {
  content: ""; position: absolute; left: 5px; top: 50%; width: 13px; height: 13px; margin-top: -6px;
  border-radius: 50%; background: var(--gold); box-shadow: 0 0 18px rgba(242,200,121,.8);
}
.moment { position: relative; padding: 0 0 72px 40px; }
.moment::before {
  content: ""; position: absolute; left: 7px; top: 9px; width: 9px; height: 9px;
  border-radius: 50%; border: 1px solid var(--gold); background: var(--night);
}
.m-date { font-family: var(--sans); font-size: 12px; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); }
.m-title { font-family: var(--serif); font-style: italic; font-weight: 500; font-size: clamp(30px, 6vw, 44px); line-height: 1.15; margin: 4px 0 6px; color: var(--cream); }
.m-line { color: var(--muted); font-size: 19px; max-width: 560px; margin-bottom: 8px; }
.m-photos { margin-top: 24px; }

/* polaroids (1-3 photos) */
.polaroids { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.polaroid {
  position: relative; background: var(--paper); padding: 10px 10px 34px; border-radius: 3px;
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
  transform: rotate(var(--r, 0deg)); transition: transform .5s var(--ease), box-shadow .5s;
  cursor: zoom-in; width: min(100%, 340px);
}
.polaroid.wide { width: min(100%, 520px); }
.polaroid:hover { transform: rotate(0deg) scale(1.02); box-shadow: 0 26px 60px rgba(0,0,0,.6); z-index: 2; }
.polaroids.two .polaroid, .polaroids.three .polaroid { width: calc(50% - 9px); }
.ph { position: relative; overflow: hidden; background: #2a2019; }
.ph img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .8s ease; }
.ph img.ready { opacity: 1; }

/* grid (4+ photos) */
.grid { columns: 2; column-gap: 10px; }
.grid .tile { break-inside: avoid; margin-bottom: 10px; border-radius: 6px; overflow: hidden; cursor: zoom-in; transition: transform .5s var(--ease); }
.grid .tile:hover { transform: scale(1.015); }

@media (min-width: 720px) {
  .polaroids.three .polaroid { width: calc(33.333% - 12px); }
  .grid { columns: 3; column-gap: 12px; }
  .grid .tile { margin-bottom: 12px; }
}
@media (min-width: 900px) {
  #timeline::before { left: 50%; }
  .year { padding: 32px 0; text-align: center; }
  .year::before { left: 50%; margin-left: -6px; top: -4px; }
  .year span { background: var(--night); padding: 0 18px; position: relative; }
  .moment { width: 50%; padding: 0 56px 96px 0; text-align: right; }
  .moment::before { left: auto; right: -5px; }
  .moment .m-line { margin-left: auto; }
  .moment .polaroids { justify-content: flex-end; }
  .moment.right { margin-left: 50%; padding: 0 0 96px 56px; text-align: left; }
  .moment.right::before { right: auto; left: -4px; }
  .moment.right .m-line { margin-left: 0; }
  .moment.right .polaroids { justify-content: flex-start; }
  .moment.full { width: 100%; margin-left: 0; padding: 0 0 96px; text-align: center; }
  .moment.full::before { left: 50%; right: auto; margin-left: -4px; top: -24px; }
  .moment.full .m-line { margin: 0 auto 8px; }
  .moment.full .m-head { background: var(--night); display: inline-block; padding: 8px 24px; position: relative; }
  .moment.full .grid { columns: 4; text-align: left; }
}

/* scroll reveal */
.reveal { opacity: 0; transform: translateY(40px); transition: opacity 1.1s var(--ease), transform 1.1s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.polaroid.reveal { transform: translateY(40px) rotate(var(--r, 0deg)); }
.polaroid.reveal.in { transform: rotate(var(--r, 0deg)); }
.polaroid.reveal.in:hover { transform: rotate(0deg) scale(1.02); }

/* ---------- finale ---------- */
#finale {
  position: relative; padding: 120px 16px calc(120px + env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 0%, var(--ember) 0%, var(--night) 70%);
  text-align: center;
}
.finale-inner { max-width: 640px; margin: 0 auto; }
#finale h2 { font-size: clamp(56px, 14vw, 104px); color: var(--cream); margin: 6px 0 40px; }
/* the card: photo on the front, his message on the back */
#cards { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 40px 28px; margin-bottom: 48px; }
.card.small { width: min(76vw, 300px); }
.card.small .card-back { justify-content: center; text-align: center; }
.card.small .para { font-size: 24px; }
.card {
  display: block; width: min(86vw, 380px); aspect-ratio: 5 / 7; margin: 0;
  perspective: 1400px; -webkit-tap-highlight-color: transparent; text-align: center;
}
.card-in {
  position: relative; display: block; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform 1s cubic-bezier(.3, .9, .3, 1.05);
  transform: rotate(var(--r, -3deg));
}
.card:hover .card-in { transform: rotate(-1deg) scale(1.01); }
.card.flipped .card-in { transform: rotateY(180deg) rotate(2deg); }
.card-face {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--paper); border-radius: 6px; box-shadow: 0 30px 60px rgba(0, 0, 0, .55);
}
.card-front { padding: 14px 14px 0; }
.card-photo { display: block; flex: 1; overflow: hidden; background: #222; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.card-hint { display: block; padding: 14px 0 16px; font-family: "Caveat", var(--script); font-size: 24px; color: var(--ink); }
.card-back {
  transform: rotateY(180deg); padding: 40px 24px 24px; overflow-y: auto; justify-content: flex-start;
  color: var(--ink); text-align: left;
  background: repeating-linear-gradient(180deg, var(--paper) 0 29px, rgba(58, 42, 32, .1) 29px 30px), var(--paper);
  background-attachment: local; -webkit-overflow-scrolling: touch;
}
.card .para { display: block; font-family: "Caveat", var(--script); font-size: 21px; line-height: 30px; margin-bottom: 30px; }
.card-back .signoff { display: flex; flex-direction: column; align-items: flex-end; margin-top: 0; line-height: 30px; font-family: "Caveat", var(--script); font-size: 22px; color: var(--ink); }
.card-back .signoff .script { font-size: 44px; color: #a3473a; }
.wish-btn {
  margin-top: 40px; padding: 16px 30px; border-radius: 999px;
  border: 1px solid rgba(242, 200, 121, .55); color: var(--gold);
  font-family: var(--sans); font-size: 13px; letter-spacing: .24em; text-transform: uppercase;
  transition: background .3s, color .3s;
}
.wish-btn:hover { background: var(--gold); color: var(--night); }

/* ---------- viewer ---------- */
#viewer {
  position: fixed; inset: 0; z-index: 70; background: rgba(8, 5, 4, .96);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fadein .3s ease;
}
#viewer img { max-width: 100%; max-height: calc(100vh - 100px); max-height: calc(100svh - 100px); border-radius: 4px; box-shadow: 0 20px 80px rgba(0,0,0,.7); }
.v-close { position: absolute; top: 12px; right: 16px; font-size: 40px; line-height: 1; color: var(--cream); padding: 8px; }
.v-prev, .v-next { position: absolute; top: 50%; transform: translateY(-50%); font-size: 54px; color: var(--cream); padding: 12px; opacity: .7; }
.v-prev { left: 4px; } .v-next { right: 4px; }
.v-prev:hover, .v-next:hover { opacity: 1; }
.v-caption { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 16px; right: 16px; text-align: center; font-style: italic; color: var(--muted); }

/* ---------- motion ---------- */
@keyframes flicker {
  0%, 100% { transform: scale(1, 1) rotate(-1deg); }
  25% { transform: scale(.94, 1.06) rotate(1.5deg); }
  50% { transform: scale(1.04, .95) rotate(-.5deg); }
  75% { transform: scale(.97, 1.04) rotate(1deg); }
}
@keyframes smoke {
  0% { opacity: 0; transform: translate(0, 0) scale(1); }
  15% { opacity: .8; }
  100% { opacity: 0; transform: translate(14px, -170px) scale(6); }
}
@keyframes breathe { 0%, 100% { opacity: .65; } 50% { opacity: 1; } }
@keyframes kenburns { from { transform: scale(1.12); } to { transform: scale(1); } }
@keyframes drip { 0% { transform: scaleY(0); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }
@keyframes shake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes fadein { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .3s !important; }
  html { scroll-behavior: auto; }
}

/* scrapbook photos taped into the letter */
.snap {
  position: relative; display: block; width: 72%; margin: 26px auto 14px; padding: 8px 8px 24px;
  background: #fff; box-shadow: 0 6px 16px rgba(58, 42, 32, .28); transform: rotate(var(--r, -3deg));
}
.snap img { width: 100%; object-fit: cover; background: #ddd; }
.snap .tape {
  position: absolute; top: -11px; left: 50%; width: 76px; height: 24px; margin-left: -38px;
  background: rgba(246, 232, 190, .75); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); transform: rotate(-5deg);
}
.snap .tape.t2 { top: auto; bottom: -9px; left: auto; right: -14px; width: 60px; margin: 0; transform: rotate(38deg); }
