:root {
  color-scheme: light;
  --ink: #392b29;
  --rose: #925456;
  --gold: #a87e4e;
  --paper: #fff9ef;
  --sans: 'Avenir Next', 'Segoe UI', sans-serif;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
body { margin: 0; min-width: 280px; min-height: 100svh; font-family: var(--sans); color: var(--ink); background: radial-gradient(ellipse at 20% 5%,#fff9ec,transparent 56%),linear-gradient(137deg,#e9e6d5,#f1d9d3); }
.experience { width: min(1180px, calc(100% - 96px)); margin: 0 auto; padding: 26px 0 48px; }
.masthead { display: flex; align-items: center; gap: 10px; padding: 0 1px 19px; font: 22px var(--serif); border-bottom: 1px solid #84654a55; }
.monogram { color: var(--rose); font-size: 28px; line-height: 1; }
.date { margin-left: auto; font: 13px var(--sans); letter-spacing: .15em; text-transform: uppercase; }
.spread { margin-top: 24px; display: grid; grid-template-columns: 1.13fr 1fr; background: var(--paper); box-shadow: 0 24px 65px #69483324; border-radius: 3px; overflow: hidden; }
.scene { position: relative; align-self: stretch; aspect-ratio: 1; isolation: isolate; overflow: hidden; background: #dac0a5; }
.art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .65s ease, transform 2.4s ease; pointer-events: none; }
.walk { opacity: 1; }
.gift { transform: none; }
[data-state="gift"] .gift { opacity: 1; transform: scale(1); }
[data-state="opening"] .opening { opacity: 1; transition: opacity .34s ease; }
[data-state="birthday"] .cake, [data-state="blown"] .cake { opacity: 1; }
.letter { position: relative; text-align: center; display: flex; flex-direction: column; justify-content: center; align-items: center; min-width: 0; padding: 50px 30px; background: radial-gradient(ellipse at center,#fffcf6,#fcf2e5); }
.letter::before { content: ''; position: absolute; inset: 14px; border: 1px solid #b48e6563; pointer-events: none; }
.ornament { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--gold); font-size: 21px; margin-bottom: 23px; }
.ornament span { width: 29px; height: 1px; background: #b48e6588; }
h1, h2 { font: 400 clamp(44px, 6vw, 93px)/.99 var(--serif); letter-spacing: -.06em; margin: 0; text-wrap: balance; }
h2 { font-size: clamp(30px, 4vw, 62px); letter-spacing: -.055em; }
h2 em { font-size: 1.28em; display: inline-block; margin-top: 5px; }
em { color: var(--rose); font-weight: 400; }
p { font-size: 16px; line-height: 1.5; margin: 20px auto 23px; max-width: 29ch; }
button { font: 600 14px var(--sans); cursor: pointer; }
button:focus-visible { outline: 3px solid #59654a; outline-offset: 4px; }
.primary { border-radius: 2px; min-height: 48px; padding: 0 25px; color: #fff9ef; background: #784446; border: 1px solid #784446; box-shadow: inset 0 0 0 3px #e4ba8d4f, 0 5px 15px #6c373528; transition: background .2s ease, opacity .2s ease; }
.primary:hover { background: #643336; }
.primary:disabled { opacity: .61; cursor: default; }
.gift-target { position: absolute; top: 30%; left: 44%; width: 49%; height: 55%; padding: 0; color: transparent; background: transparent; border: 0; border-radius: 16px; }
.gift-target:hover { box-shadow: inset 0 0 25px #ffefbd75; }
.gift-target:focus-visible { outline-color: #fff9ef; outline-offset: -5px; }
#birthday { animation: enter .7s ease both; }
#wish:empty { display: none; }
#wish { font: italic 400 clamp(27px,3.1vw,45px)/1.05 var(--serif); color: var(--rose); animation: enter .9s ease both; margin-bottom: 12px; }
.birthday-letter {
  font: 400 clamp(15px, 2vw, 18px)/1.6 var(--serif);
  max-width: 34ch;
  margin: 14px auto 5px;
  animation: enter .9s .18s ease both;
}
.replay { background: none; color: #684646; border: 0; padding: 12px; text-decoration: underline; text-underline-offset: 4px; min-height: 44px; }
.candles { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
[data-state="birthday"] .candles, [data-state="blown"] .candles { opacity: 1; transition: opacity .55s .12s; }
.candle { position: absolute; width: 1.15%; min-width: 3px; height: var(--height, 9%); transform: translate(-50%,-100%); border-radius: 45% 45% 12% 12% / 5% 5% 2% 2%; background: repeating-linear-gradient(145deg,#fff6da 0 5px,#c99a77 6px 8px,#eacda5 9px 10px); box-shadow: inset -2px 0 2px #7a524577,1px 2px 2px #4b331e50; }
.flame { position: absolute; left: 50%; bottom: calc(100% + 1px); width: clamp(6px,1.1vw,13px); aspect-ratio: .49; transform-origin: center bottom; border-radius: 65% 35% 54% 46% / 70% 48% 52% 30%; background: radial-gradient(ellipse at 50% 73%,#ffffed 0 32%,#fff2a4 48%,#ffb951 77%,#ff8b31); box-shadow: 0 0 12px 4px #ffc576a1,0 0 32px 11px #fbc87a53; animation: flicker .57s var(--delay) ease-in-out infinite alternate; }
[data-state="blown"] .flame { visibility: hidden; }
#effects { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }
@keyframes flicker { from { transform: translateX(-50%) rotate(-6deg) scale(.88,1.04); } to { transform: translateX(-50%) rotate(8deg) scale(1.06,.94); } }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 760px) {
  .experience { width: min(540px, calc(100% - 28px)); padding: 13px 0 23px; }
  .masthead { padding-bottom: 10px; }
  .spread { margin-top: 13px; grid-template-columns: minmax(0,1fr); }
  .scene { aspect-ratio: 1.06; }
  .letter { padding: 28px 19px 34px; min-height: 237px; }
  .letter::before { inset: 9px; }
  .ornament { margin-bottom: 12px; }
  p { margin-top: 12px; margin-bottom: 15px; }
  h1 { font-size: clamp(44px,12vw,63px); }
  h2 { font-size: clamp(28px,8vw,47px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.candle::before { content: ''; position: absolute; left: 50%; bottom: 99%; width: 1px; height: 4px; background: #4b3027; transform: translateX(-50%); }

/* Keep the artwork and controls together on narrow and touch-first screens. */
body { position: relative; isolation: isolate; }
body::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse at 20% 18%, #514448, transparent 62%), #201b2b;
  opacity: 0; transition: opacity .9s ease;
}
body.night::before { opacity: 1; }
.experience { position: relative; z-index: 1; }
.night .masthead { color: #f9e8d2; border-color: #d3ab7b70; }
.night .monogram { color: #e5b48f; }

.night .letter { color: #fff4de; background: radial-gradient(ellipse at 50% 35%,#392c38,#231d2a); }
.night .letter::before { border-color: #d8b58a70; }
.night em, .night #wish, .night .replay { color: #f7cbbd; }
.night .ornament { color: #f0c68a; }
.night .replay:focus-visible { outline-color: #f7cbbd; }
[data-state="birthday"] .cake { filter: brightness(.91) saturate(.94); }
[data-state="blown"] .cake { filter: brightness(.47) saturate(.8); }
.celebration { filter: brightness(.53) saturate(.82); }
[data-state="blown"] .celebration { opacity: 1; }
[data-state="blown"] .candle { filter: brightness(.67); }
.art { transition-property: opacity, transform, filter; transition-duration: .65s, 1.1s, .85s; }

@media (min-width: 761px) and (orientation: portrait) and (max-width: 1100px) {
  .experience { width: min(680px, calc(100% - 72px)); }
  .spread { grid-template-columns: minmax(0,1fr); }
  .scene { aspect-ratio: 1.13; }
  .letter { min-height: 260px; padding: 32px 24px 38px; }
}
@media (max-width: 430px) {
  .scene { aspect-ratio: 1.04; }
  .letter { min-height: 225px; }
}
@media (orientation: landscape) and (max-height: 560px) and (min-width: 580px) {
  .experience { width: min(740px, calc(100% - 44px), calc(200svh - 130px)); padding-block: 10px 16px; }
  .masthead { padding-bottom: 8px; }
  .spread { margin-top: 10px; }
  .spread { grid-template-columns: 1fr 1fr; }
  .letter { padding: 23px 14px; min-height: 0; }
  .ornament { margin-bottom: 8px; }
  h1 { font-size: clamp(35px,6.5vw,60px); }
  h2 { font-size: clamp(27px,4.2vw,46px); }
}

.curtain-closed { overflow: hidden; }
.curtain {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  isolation: isolate;
  overflow: hidden;
}
.drape {
  position: absolute;
  inset-block: 0;
  width: calc(50% + 1px);
  z-index: -1;
  background:
    linear-gradient(0deg, #210d19b8, transparent 82%),
    repeating-linear-gradient(90deg, #351420, #783749 11%, #8c4657 17%, #481c31 26%);
  box-shadow: inset 0 -5px #b48155, inset 0 -9px #d0a16a, inset 0 -11px #774a37;
  transition: transform 1.2s cubic-bezier(.62,.02,.25,1);
}
.drape-left { left: 0; border-right: 2px solid #be8d62; }
.drape-right { right: 0; border-left: 2px solid #be8d62; }
.curtain-card {
  width: min(100%, 480px);
  text-align: center;
  background: #fcf0e3;
  padding: clamp(24px, 6vw, 54px) 16px;
  outline: 1px solid #bc9266;
  outline-offset: -10px;
  box-shadow: 0 20px 70px #18091280;
  transition: opacity .32s ease, transform .32s ease;
}
.curtain-card h1 { font-size: clamp(38px, 8vw, 65px); }
.curtain-card h1 em { display: block; }
.curtain-card p { letter-spacing: .08em; }
.rising .curtain-card { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.rising .drape-left { transform: translateX(-100%); }
.rising .drape-right { transform: translateX(100%); }
