:root {
  --ivory: #f4ece0;
  --ivory-dim: rgba(244, 236, 224, .72);
  --gold: #d6b475;
  --gold-soft: rgba(214, 180, 117, .55);
  --night: #0d0b0a;
  --display: 'Cormorant Garamond', Georgia, serif;
  --script: 'Pinyon Script', cursive;
  --sans: 'Jost', system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--night); }
body {
  color: var(--ivory); font-family: var(--display);
  overflow: hidden; overscroll-behavior: none;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

/* desktop backdrop: blurred current photo */
.backdrop {
  position: fixed; inset: -60px; background: center / cover no-repeat;
  filter: blur(40px) brightness(.38) saturate(1.1); transform: scale(1.1);
  transition: background-image 1.2s ease;
}

.stage {
  position: relative; margin: 0 auto;
  width: min(100vw, 480px); height: 100svh; overflow: hidden;
  background: var(--night); touch-action: none; cursor: pointer;
}
@media (min-width: 560px) and (min-height: 700px) {
  .stage { height: min(100svh - 48px, 940px); top: 24px; border-radius: 28px; box-shadow: 0 30px 90px rgba(0, 0, 0, .6); }
}

/* ───────── stories ───────── */
.stories, .story { position: absolute; inset: 0; }
.story { opacity: 0; visibility: hidden; transition: opacity .9s ease, transform 1.1s var(--ease), visibility 0s linear .9s; transform: scale(1.04); }
.story.active { opacity: 1; visibility: visible; transform: none; transition: opacity .9s ease, transform 1.1s var(--ease), visibility 0s; z-index: 2; }
.story.leaving { opacity: 0; visibility: visible; transform: scale(1.1); z-index: 1; }
.story.leaving.back { transform: scale(.94); }

.bg { position: absolute; inset: -4%; background: center / cover no-repeat; will-change: transform; }
.shade { position: absolute; inset: 0; background:
  radial-gradient(120% 80% at 50% 45%, transparent 35%, rgba(0, 0, 0, .55) 100%),
  linear-gradient(to bottom, rgba(0, 0, 0, .55) 0%, rgba(0, 0, 0, .05) 22%, rgba(0, 0, 0, .28) 52%, rgba(0, 0, 0, .86) 100%); }
.story.dim .shade { background: radial-gradient(120% 80% at 50% 45%, rgba(0, 0, 0, .35) 20%, rgba(0, 0, 0, .75) 100%), rgba(10, 8, 7, .45); }

/* Ken Burns */
.story.active .bg.kb-in    { animation: kbIn 9s linear forwards; }
.story.active .bg.kb-out   { animation: kbOut 9s linear forwards; }
.story.active .bg.kb-left  { animation: kbLeft 9s linear forwards; }
.story.active .bg.kb-right { animation: kbRight 9s linear forwards; }
.story.active .bg.kb-up    { animation: kbUp 11s linear forwards; }
@keyframes kbIn    { from { transform: scale(1); }    to { transform: scale(1.14); } }
@keyframes kbOut   { from { transform: scale(1.16); } to { transform: scale(1.02); } }
@keyframes kbLeft  { from { transform: scale(1.12) translateX(3%); }  to { transform: scale(1.12) translateX(-3%); } }
@keyframes kbRight { from { transform: scale(1.12) translateX(-3%); } to { transform: scale(1.12) translateX(3%); } }
@keyframes kbUp    { from { transform: scale(1.1) translateY(3%); }   to { transform: scale(1.16) translateY(-2%); } }

/* film grain */
.grain { position: absolute; inset: -50%; pointer-events: none; opacity: .13; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain .9s steps(6) infinite; }
@keyframes grain { 0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -4%); } 60% { transform: translate(-4%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); } }

.content {
  position: absolute; left: 0; right: 0; bottom: 0; top: 0;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center; text-align: center;
  padding: 120px 28px calc(64px + env(safe-area-inset-bottom, 0px));
  text-shadow: 0 2px 24px rgba(0, 0, 0, .45);
}
.content.center { justify-content: center; }

.kicker { font-family: var(--sans); font-weight: 400; font-size: 11px; font-weight: 500; letter-spacing: .42em; text-transform: uppercase; color: var(--gold); margin-bottom: 18px; padding-left: .42em; text-shadow: 0 1px 12px rgba(0, 0, 0, .8), 0 0 2px rgba(0, 0, 0, .5); }
.rule { width: 0; height: 1px; background: var(--gold-soft); margin: 18px auto; }
.story.active .rule { animation: rule 1.4s var(--ease) forwards .6s; }
@keyframes rule { to { width: 72px; } }

.big { font-weight: 300; font-size: clamp(54px, 17vw, 80px); line-height: .95; letter-spacing: .01em; }
.amp { font-family: var(--script); color: var(--gold); font-size: 54px; line-height: 1; display: block; margin: 4px 0 2px; }
.script-line { font-family: var(--script); font-size: clamp(46px, 13vw, 62px); line-height: 1.1; color: var(--ivory); }
.sub { font-style: italic; font-weight: 300; font-size: 20px; color: var(--ivory-dim); }

/* kinetic typography — every animated unit is .u with --i */
.u { display: inline-block; opacity: 0; white-space: pre; }
.story.active .fx-rise   .u { animation: rise 1.1s var(--ease) forwards; animation-delay: calc(.35s + var(--i) * .06s); }
.story.active .fx-blur   .u { animation: blurIn 1.4s ease forwards; animation-delay: calc(.4s + var(--i) * .22s); }
.story.active .fx-slide  .u { animation: slideIn 1s var(--ease) forwards; animation-delay: calc(.3s + var(--i) * .12s); }
.story.active .fx-scale  .u { animation: scaleIn 1.3s var(--ease) forwards; animation-delay: calc(.3s + var(--i) * .28s); }
.story.active .fx-spread .u { animation: spread 1.8s var(--ease) forwards; animation-delay: calc(.35s + var(--i) * .03s); }
.story.active .fx-fade { animation: fadeUp 1.1s var(--ease) both; animation-delay: var(--d, .2s); }
.fx-fade { opacity: 0; }
@keyframes rise    { from { opacity: 0; transform: translateY(.55em) rotate(4deg); } to { opacity: 1; transform: none; } }
@keyframes blurIn  { from { opacity: 0; filter: blur(14px); transform: scale(1.08); } to { opacity: 1; filter: blur(0); transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(1.6); filter: blur(6px); } to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes spread  { from { opacity: 0; letter-spacing: -.12em; filter: blur(8px); } to { opacity: 1; letter-spacing: .02em; filter: blur(0); } }
@keyframes fadeUp  { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* date story */
.date-stack { display: flex; align-items: baseline; justify-content: center; gap: 4px; font-weight: 300; }
.date-stack .u { font-size: clamp(64px, 21vw, 96px); line-height: 1; font-variant-numeric: lining-nums; }
.date-stack .dot { font-size: 46px; color: var(--gold); padding: 0 12px; align-self: center; }
.date-stack .yr { display: block; }
.weekday { font-family: var(--sans); font-weight: 300; font-size: 12px; letter-spacing: .3em; text-transform: uppercase; color: var(--ivory-dim); margin-top: 18px; padding-left: .3em; }

/* place story */
.place-title { white-space: nowrap; font-weight: 300; font-size: clamp(44px, 13.5vw, 66px); line-height: 1; text-transform: uppercase; letter-spacing: .02em; }
.place-sub { font-family: var(--script); font-size: 44px; color: var(--gold); margin-top: 6px; }
.address { font-family: var(--sans); font-weight: 300; font-size: 12px; letter-spacing: .18em; color: var(--ivory-dim); margin-top: 14px; line-height: 1.8; text-transform: uppercase; }

/* timeline story */
.tl-title { font-family: var(--script); font-size: 58px; line-height: 1; margin-bottom: 26px; }
.tl { list-style: none; width: 100%; max-width: 340px; text-align: left; padding: 6px 20px; border-radius: 20px; background: rgba(13, 11, 10, .42); border: 1px solid rgba(244, 236, 224, .12); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.tl li { display: grid; grid-template-columns: 86px 1fr; gap: 14px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid rgba(244, 236, 224, .16); opacity: 0; }
.tl li:last-child { border-bottom: 0; }
.story.active .tl li { animation: slideIn .9s var(--ease) forwards; animation-delay: calc(.6s + var(--i) * .9s); }
.tl time { font-family: var(--sans); font-size: 12px; letter-spacing: .14em; color: var(--gold); white-space: nowrap; }
.tl span { font-size: 21px; font-weight: 400; line-height: 1.2; }

/* countdown story */
.cd { display: flex; justify-content: center; gap: 10px; padding: 22px 16px; border-radius: 20px; background: rgba(13, 11, 10, .4); border: 1px solid rgba(244, 236, 224, .12); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.cd > div { min-width: 64px; }
.cd b { display: block; font-weight: 300; font-size: clamp(46px, 14vw, 64px); line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.cd small { display: block; font-family: var(--sans); font-size: 10px; letter-spacing: .3em; text-transform: uppercase; color: var(--gold); margin-top: 8px; padding-left: .3em; }
.cd-sub { font-family: var(--script); font-size: 40px; margin-top: 22px; }

/* final card */
.mono { font-family: var(--script); font-size: 64px; color: var(--gold); line-height: 1; margin-bottom: 10px; }
.final-title { font-weight: 300; font-size: clamp(40px, 12vw, 54px); line-height: 1.05; }
.actions { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 300px; margin-top: 30px; }
.btn {
  display: block; padding: 15px 20px; border-radius: 999px; text-decoration: none; text-align: center;
  font-family: var(--sans); font-weight: 400; font-size: 12px; letter-spacing: .3em; text-transform: uppercase; padding-left: calc(20px + .3em);
  color: var(--ivory); border: 1px solid rgba(244, 236, 224, .45); background: rgba(13, 11, 10, .25);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); cursor: pointer;
  transition: background .3s, color .3s, transform .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a140c; }
.btn:hover { background: rgba(244, 236, 224, .14); }
.btn.primary:hover { background: #e3c48a; }
.again { margin-top: 18px; background: none; border: 0; color: var(--ivory-dim); font-family: var(--sans); font-size: 11px; letter-spacing: .3em; text-transform: uppercase; cursor: pointer; padding: 8px; }
.again svg { width: 12px; height: 12px; vertical-align: -1px; margin-right: 6px; fill: none; stroke: currentColor; stroke-width: 2; }
.sign { font-style: italic; font-size: 16px; color: var(--ivory-dim); margin-top: 18px; }

/* ───────── HUD ───────── */
.hud { position: absolute; left: 0; right: 0; top: 0; z-index: 10; padding: calc(var(--top) + 10px) 10px 0; opacity: 0; transition: opacity .6s; pointer-events: none; }
.stage.playing .hud { opacity: 1; }
.bars { display: flex; gap: 4px; }
.bar { flex: 1; height: 2.5px; border-radius: 2px; background: rgba(244, 236, 224, .3); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--ivory); border-radius: 2px; }
.hud-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 0 2px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--gold); display: grid; place-items: center; font-family: var(--script); font-size: 12px; letter-spacing: -.02em; color: var(--gold); background: rgba(13, 11, 10, .35); backdrop-filter: blur(6px); }
.who { display: flex; flex-direction: column; line-height: 1.15; font-family: var(--sans); text-shadow: 0 1px 8px rgba(0, 0, 0, .5); }
.who b { font-weight: 500; font-size: 13px; letter-spacing: .02em; }
.who span { font-size: 11px; color: var(--ivory-dim); letter-spacing: .04em; }
.paused-tag { margin-left: auto; font-family: var(--sans); font-size: 10px; letter-spacing: .3em; text-transform: uppercase; color: var(--ivory-dim); opacity: 0; transition: opacity .2s; }
.stage.paused .paused-tag { opacity: 1; }
.icon-btn { pointer-events: auto; width: 34px; height: 34px; border: 0; background: none; color: var(--ivory); cursor: pointer; display: grid; place-items: center; }
.paused-tag + .icon-btn { margin-left: 4px; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.icon-btn svg path:first-child { fill: currentColor; }
.icon-btn:not(.on) .wave { opacity: .25; }

.stage.paused .story.active *, .stage.paused .story.active { animation-play-state: paused !important; }

.tap-hint { position: absolute; left: 0; right: 0; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); z-index: 9; text-align: center; font-family: var(--sans); font-size: 10px; letter-spacing: .35em; text-transform: uppercase; color: var(--ivory-dim); opacity: 0; transition: opacity .6s; pointer-events: none; }
.tap-hint.show { opacity: 1; animation: breathe 2.4s ease-in-out infinite 1s; }
@keyframes breathe { 50% { opacity: .35; } }

/* ───────── intro ───────── */
.intro { position: absolute; inset: 0; z-index: 20; transition: opacity 1.1s ease, transform 1.4s var(--ease), visibility 0s linear 1.4s; }
.intro.gone { opacity: 0; transform: scale(1.08); visibility: hidden; pointer-events: none; }
.intro-bg { position: absolute; inset: -30px; background: center / cover no-repeat; filter: blur(14px) brightness(.42); transform: scale(1.08); animation: kbIn 18s linear infinite alternate; }
.intro-inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.intro .kicker { animation: fadeUp 1.2s var(--ease) both .3s; }
.intro-names { font-weight: 300; font-size: clamp(50px, 15vw, 70px); line-height: 1; animation: blurIn 1.8s ease both .5s; }
.intro-names em { display: block; font-family: var(--script); font-style: normal; color: var(--gold); font-size: .78em; line-height: 1; margin: .02em 0 .06em; }
.intro-date { font-family: var(--sans); font-weight: 300; font-size: 12px; letter-spacing: .45em; color: var(--ivory-dim); margin-top: 20px; padding-left: .45em; animation: fadeUp 1.2s var(--ease) both 1s; }
.play {
  position: relative; margin-top: 56px; width: 76px; height: 76px; border-radius: 50%;
  border: 1px solid var(--gold); background: rgba(214, 180, 117, .12); color: var(--gold); cursor: pointer;
  display: grid; place-items: center; animation: fadeUp 1.2s var(--ease) both 1.3s;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.play svg { width: 24px; height: 24px; fill: currentColor; margin-left: 4px; }
.play::before, .play::after { content: ''; position: absolute; inset: -1px; border-radius: 50%; border: 1px solid var(--gold-soft); animation: ring 2.6s ease-out infinite 2s; }
.play::after { animation-delay: 3.3s; }
@keyframes ring { from { transform: scale(1); opacity: .9; } to { transform: scale(1.9); opacity: 0; } }
.intro-cta { font-family: var(--sans); font-size: 11px; letter-spacing: .4em; text-transform: uppercase; margin-top: 22px; padding-left: .4em; animation: fadeUp 1.2s var(--ease) both 1.5s; }
.intro-sound { font-style: italic; font-size: 15px; color: var(--ivory-dim); margin-top: 10px; animation: fadeUp 1.2s var(--ease) both 1.7s; }

@media (prefers-reduced-motion: reduce) {
  .bg, .intro-bg, .grain { animation: none !important; }
  .story, .story.active, .story.leaving { transform: none !important; }
  .story.active .u, .story.active .tl li, .story.active .fx-fade, .story.active .rule { animation: fadeUp .6s ease forwards !important; animation-delay: .1s !important; }
  .story.active .rule { width: 72px; }
}
.icon-btn[hidden] { display: none; }

button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
