:root {
  color-scheme: light;
  --sage-bg: #E7EFE2;
  --green: #52785A;
  --cream: #FFFDF5;
  --dark: #365C40;
  --sage: #B8CDB4;
  --shadow: 0 22px 60px rgba(54, 92, 64, .13);
  font-family: 'Avenir Next', Avenir, 'Segoe UI', sans-serif;
  color: var(--dark);
  background: var(--sage-bg);
}

* { box-sizing: border-box; }
html { min-width: 320px; overflow-x: clip; }
body { min-width: 320px; min-height: 100vh; margin: 0; overflow-x: clip; }
button { font: inherit; }
.page-shell { position: relative; z-index: 1; width: min(100% - 40px, 1080px); min-height: 100svh; margin: 0 auto; padding: clamp(42px, 8vh, 90px) 0 28px; display: flex; flex-direction: column; align-items: center; }
.page-heading { text-align: center; }
.eyebrow, .note-kicker { margin: 0 0 13px; color: var(--green); font-size: .72rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; }
h1 { margin: 0; color: var(--dark); font-family: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Georgia, serif; font-size: clamp(2.55rem, 8vw, 5.6rem); font-weight: 600; letter-spacing: .035em; line-height: 1.08; overflow-wrap: anywhere; }
.intro { margin: 16px 0 0; color: #617b64; font-family: 'Iowan Old Style', 'Palatino Linotype', Georgia, serif; font-size: clamp(1rem, 2vw, 1.25rem); font-style: italic; }
.surprise { position: relative; display: flex; width: 100%; flex: 1; min-height: 460px; align-items: center; justify-content: center; padding: 30px 0 24px; }
.envelope { position: relative; display: grid; place-items: center; width: min(390px, 78vw); aspect-ratio: 1.46; padding: 0; border: 0; border-radius: 9px; background: transparent; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; filter: drop-shadow(0 22px 22px rgba(54, 92, 64, .16)); transition: transform .58s cubic-bezier(.22,.85,.28,1), opacity .4s ease; isolation: isolate; }
.envelope:focus-visible, .reveal-button:focus-visible { outline: 3px solid #789b72; outline-offset: 6px; }
.envelope-back { position: absolute; inset: 0; border-radius: 9px; background: #f5f2e7; border: 1px solid rgba(54,92,64,.1); }
.letter-peek { position: absolute; z-index: -1; top: 7%; left: 11%; width: 78%; height: 80%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; border-radius: 5px; background: var(--cream); color: #68846a; font-family: 'Iowan Old Style', 'Palatino Linotype', Georgia, serif; font-size: clamp(.8rem, 2vw, 1rem); font-style: italic; transition: transform .75s cubic-bezier(.2,.8,.2,1); }
.letter-flower { color: #8ca88b; font-size: 1.5rem; }
.envelope-pocket { position: absolute; z-index: 1; inset: 0; border-radius: 9px; background: linear-gradient(145deg, #d8e4d2 0 49.7%, transparent 50%), linear-gradient(215deg, #e4ebdd 0 49.7%, transparent 50%); clip-path: polygon(0 0, 50% 57%, 100% 0, 100% 100%, 0 100%); }
.envelope-flap { position: absolute; z-index: 2; inset: 0; border-radius: 9px; background: linear-gradient(145deg, #edf1e7, #dfe8da); clip-path: polygon(0 0, 100% 0, 50% 58%); transform-origin: 50% 0; transition: transform .72s cubic-bezier(.2,.7,.2,1), opacity .3s ease; backface-visibility: hidden; }
.seal { position: absolute; z-index: 3; top: 47%; left: 50%; display: grid; width: 46px; height: 46px; place-items: center; border: 1px solid rgba(255,255,255,.55); border-radius: 50%; background: var(--green); color: var(--cream); font-size: 1.25rem; box-shadow: 0 5px 13px rgba(54,92,64,.2); transform: translate(-50%,-50%); transition: opacity .25s ease, transform .3s ease; }
.click-label { position: absolute; z-index: 4; left: 50%; bottom: -40px; display: inline-flex; gap: 8px; align-items: center; color: var(--dark); font-size: .84rem; font-weight: 700; letter-spacing: .06em; transform: translateX(-50%); white-space: nowrap; }
.click-label span { color: var(--green); font-size: 1.05rem; }
.envelope.is-open { position: absolute; top: 50%; left: 50%; opacity: 0; pointer-events: none; transform: translate(-50%, -50%) translateY(35px) scale(.92); }
.envelope.is-open .envelope-flap { opacity: 0; transform: rotateX(180deg); }
.envelope.is-open .letter-peek { transform: translateY(-24%); }
.envelope.is-open .seal { opacity: 0; transform: translate(-50%,-70%) scale(.7); }
.page-shell.is-revealed { padding: 20px 0; }
.page-shell.is-revealed .page-heading,
.page-shell.is-revealed > .footer-note { display: none; }
.page-shell.is-revealed .surprise { min-height: 0; padding: 0; }
.letter-scene { --photo-width: min(284px, calc((100vw - 166px) / 2)); --right-width: min(384px, calc(100vw - var(--photo-width) - 190px)); display: none; width: max-content; max-width: 100%; grid-template-columns: calc(var(--photo-width) + 26px) var(--right-width); align-items: center; justify-content: center; gap: clamp(30px, 7vw, 76px); }
.letter-scene.is-visible { display: grid; animation: scene-in .9s cubic-bezier(.2,.75,.2,1) both; }
@keyframes scene-in { from { opacity: 0; transform: translateY(26px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.polaroid { width: calc(var(--photo-width) + 26px); margin: 0; padding: 13px 13px 19px; border-radius: 4px; background: var(--cream); box-shadow: var(--shadow); transform: rotate(-3.5deg); }
.photo-window { position: relative; display: grid; width: var(--photo-width); aspect-ratio: 1 / 1.08; overflow: hidden; place-items: center; background: linear-gradient(155deg, #d9e8d2, #bfd3bb 55%, #91ae8f); }
.photo-window img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; transition: opacity .65s ease; }
.photo-window .final-photo { opacity: 0; }
.polaroid.is-final .photo-window .main-photo { opacity: 0; }
.polaroid.is-final .photo-window .final-photo { opacity: 1; }
.note-area { display: flex; width: var(--right-width); flex-direction: column; align-items: center; text-align: center; }
.note-prompt { width: 100%; margin: 0 0 12px; color: var(--dark); font-family: 'Iowan Old Style', 'Palatino Linotype', Georgia, serif; font-size: clamp(1rem, 2vw, 1.2rem); line-height: 1.4; }
.small-photo { display: block; width: min(180px, 100%); height: auto; max-width: 100%; object-fit: contain; border-radius: 3px; }
.reveal-button { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; margin-top: 8px; padding: 0 25px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; background: var(--green); color: var(--cream); box-shadow: 0 8px 18px rgba(54,92,64,.18); font-size: .91rem; font-weight: 700; cursor: pointer; transition: transform .2s ease, background .2s ease, box-shadow .2s ease; }
.reveal-button:hover { background: #43694b; box-shadow: 0 10px 22px rgba(54,92,64,.23); transform: translateY(-2px); }
.reveal-button:active { transform: translateY(1px); }
.reveal-button span { color: #e7f0df; }
.love-message { display: none; margin: 18px 0 0; color: var(--dark); font-family: 'Iowan Old Style', 'Palatino Linotype', Georgia, serif; font-size: clamp(1.8rem, 5vw, 2.7rem); font-weight: 600; }
.love-message.is-visible { display: block; animation: message-in .75s cubic-bezier(.18,.8,.25,1.3) both; }
.note-area.is-final .note-prompt,
.note-area.is-final .small-photo,
.note-area.is-final .reveal-button { display: none; }
.message-heart { display: inline-block; margin-left: 9px; color: var(--green); animation: heartbeat 1.1s ease-in-out infinite; }
@keyframes message-in { from { opacity: 0; transform: translateY(13px) scale(.82); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes heartbeat { 50% { transform: scale(1.22); } }
.footer-note { margin: auto 0 0; padding-top: 24px; color: #819982; font-size: .75rem; letter-spacing: .08em; }
.footer-note span { color: var(--green); }
.ambient { position: fixed; z-index: 0; color: rgba(82,120,90,.16); pointer-events: none; animation: drift 8s ease-in-out infinite; }
.ambient-one { top: 17%; left: 8%; font-size: 30px; }.ambient-two { top: 24%; right: 10%; font-size: 19px; animation-delay: -3s; }.ambient-three { bottom: 17%; left: 15%; font-size: 20px; animation-delay: -5s; }.ambient-four { right: 16%; bottom: 12%; font-size: 28px; animation-delay: -2s; }
@keyframes drift { 50% { transform: translateY(-15px) rotate(9deg); } }
.heart-layer { position: fixed; z-index: 5; inset: 0; overflow: hidden; pointer-events: none; }
.floating-heart { position: absolute; bottom: -40px; color: var(--green); opacity: 0; font-size: var(--size, 20px); animation: float-heart var(--duration, 3.6s) ease-out forwards; }
@keyframes float-heart { 10% { opacity: .82; } 100% { opacity: 0; transform: translate3d(var(--drift, 20px), -105vh, 0) rotate(var(--rotate, 22deg)) scale(.7); } }

@media (max-width: 650px) {
  .page-shell { width: min(100% - 32px, 480px); min-height: 100svh; padding-top: max(42px, 8svh); }
  h1 { font-size: clamp(1.25rem, 7.2vw, 2.55rem); white-space: nowrap; overflow-wrap: normal; }
  .surprise { min-height: 400px; }
  .page-shell.is-revealed { padding: 20px 0; }
  .letter-scene { --photo-width: min(238px, calc(100vw - 64px)); --right-width: min(384px, 100%); grid-template-columns: minmax(0, 1fr); width: 100%; gap: 20px; padding: 0; }
  .polaroid { width: calc(var(--photo-width) + 22px); justify-self: center; padding: 11px 11px 15px; }
  .note-area { width: var(--photo-width); justify-self: center; }
  .note-prompt { margin-bottom: 12px; font-size: 1rem; }
  .love-message { margin-top: 18px; }
  .ambient-one { left: 4%; }.ambient-two { right: 4%; }.ambient-three { left: 6%; }.ambient-four { right: 7%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
