* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0b0710;
    --bg2: #160c16;
    --text: #fff8fc;
    --muted: #d9c7d1;
    --accent: #ed9fbe;
    --accent-soft: #ffd7e6;
    --line: rgba(255,255,255,.13);
    --glass: rgba(255,255,255,.065);
}

html,
body {
    width: 100%;
    min-height: 100%;
}

body {
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 15%, rgba(238,157,191,.12), transparent 30%),
        radial-gradient(circle at 15% 85%, rgba(153,90,135,.12), transparent 30%),
        var(--bg);
    color: var(--text);
    font-family: "Montserrat", sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button {
    font: inherit;
    -webkit-tap-highlight-color: transparent;
}

.experience {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

.scene {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 36px 18px 84px;
    opacity: 0;
    visibility: hidden;
    transform: translate3d(30px, 0, 0) scale(.985);
    transition:
        opacity 1.0s cubic-bezier(.22,1,.36,1),
        transform 1.15s cubic-bezier(.22,1,.36,1),
        visibility 1.0s;
    overflow: hidden;
}

.scene.active {
    opacity: 1;
    visibility: visible;
    transform: translate3d(0,0,0) scale(1);
}

.scene-content {
    position: relative;
    z-index: 4;
    width: min(760px, 100%);
    max-height: 100%;
    overflow-y: auto;
    padding: 12px;
    text-align: center;
    scrollbar-width: none;
}

.scene-content::-webkit-scrollbar {
    display: none;
}

.ambient {
    position: fixed;
    z-index: 0;
    width: 45vw;
    height: 45vw;
    max-width: 500px;
    max-height: 500px;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .18;
    pointer-events: none;
}

.ambient-one {
    top: -20%;
    left: -15%;
    background: #c45a91;
    animation: breathe 8s ease-in-out infinite;
}

.ambient-two {
    right: -15%;
    bottom: -20%;
    background: #7c3f80;
    animation: breathe 10s ease-in-out infinite reverse;
}

.grain {
    position: fixed;
    inset: -50%;
    z-index: 10;
    pointer-events: none;
    opacity: .035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
    transform: rotate(8deg);
}

h1,
h2,
p {
    overflow-wrap: break-word;
}

h1,
h2 {
    font-family: "Cormorant Garamond", serif;
    font-weight: 600;
}

.eyebrow,
.final-intro {
    font-family: "Cormorant Garamond", serif;
    font-size: clamp(1.4rem, 5vw, 2.1rem);
    color: var(--muted);
    letter-spacing: .04em;
}

.scene-number {
    display: inline-block;
    margin-bottom: 7px;
    color: var(--accent);
    font-size: .68rem;
    letter-spacing: .3em;
}

/* ---------- Letter opening ---------- */

.letter-scene {
    perspective: 1200px;
}

.letter-wrap {
    position: relative;
    width: min(620px, 94vw);
    min-height: 460px;
    display: grid;
    place-items: center;
}

.letter-glow {
    position: absolute;
    width: 70%;
    height: 60%;
    border-radius: 50%;
    background: rgba(237,159,190,.16);
    filter: blur(55px);
    animation: breathe 5s ease-in-out infinite;
}

.envelope {
    position: absolute;
    width: min(420px, 82vw);
    height: 270px;
    border-radius: 10px;
    background: linear-gradient(145deg, #6b334e, #3c1c31);
    box-shadow: 0 40px 100px rgba(0,0,0,.55);
    transform: translateY(35px) rotateX(5deg);
    transition: transform 1.65s cubic-bezier(.22,1,.36,1), opacity 1.1s;
}

.envelope-back {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, #7f3d5c, #4a2138);
}

.envelope-flap {
    position: absolute;
    inset: 0 0 auto;
    height: 58%;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    background: #8e4565;
    transform-origin: top;
    transition: transform 1.65s cubic-bezier(.22,1,.36,1);
    z-index: 3;
}

.wax-seal {
    position: absolute;
    z-index: 5;
    left: 50%;
    top: 50%;
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    transform: translate(-50%,-20%);
    background: #c45b78;
    color: #ffe9f2;
    font-size: 1.35rem;
    box-shadow: 0 8px 25px rgba(0,0,0,.35);
    transition: opacity .7s, transform 1.1s;
}

.letter-card {
    position: absolute;
    z-index: 2;
    width: min(430px, 82vw);
    min-height: 330px;
    padding: 46px 30px 34px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    background:
        linear-gradient(rgba(255,255,255,.96), rgba(255,247,251,.96));
    color: #2b1722;
    box-shadow: 0 35px 100px rgba(0,0,0,.42);
    transform: translateY(45px) scale(.92);
    opacity: 0;
    transition:
        transform 1.65s cubic-bezier(.22,1,.36,1),
        opacity 1.2s;
}

.letter-lines {
    position: absolute;
    inset: 0;
    opacity: .28;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 30px,
        rgba(128,75,98,.12) 31px
    );
    pointer-events: none;
}

.letter-card h1 {
    position: relative;
    margin: 3px 0 12px;
    font-size: clamp(3.8rem, 14vw, 6.5rem);
    line-height: .8;
    letter-spacing: .05em;
    color: #5c2942;
}

.letter-subtitle {
    position: relative;
    max-width: 330px;
    margin-bottom: 30px;
    color: #78596a;
    font-family: "Cormorant Garamond", serif;
    font-size: clamp(1.15rem, 4vw, 1.5rem);
    font-style: italic;
}

.open-letter {
    position: relative;
    border-color: rgba(92,41,66,.22);
    background: #5c2942;
    color: white;
}

.letter-wrap.open .envelope {
    transform: translateY(120px) scale(.9);
    opacity: 0;
}

.letter-wrap.open .envelope-flap {
    transform: rotateX(165deg);
}

.letter-wrap.open .wax-seal {
    opacity: 0;
    transform: translate(-50%,-20%) scale(.5);
}

.letter-wrap.open .letter-card {
    transform: translateY(-5px) scale(1);
    opacity: 1;
}

.letter-wrap.ready .envelope {
    animation: envelopeFloat 3s ease-in-out infinite;
}

/* ---------- Memories ---------- */

h2 {
    margin: 8px auto 22px;
    max-width: 680px;
    font-size: clamp(2.1rem, 7vw, 4rem);
    line-height: .96;
}

.memory-card {
    width: min(580px, 100%);
    margin: 0 auto 24px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--glass);
    box-shadow: 0 30px 80px rgba(0,0,0,.28);
    backdrop-filter: blur(16px);
}

.photo-frame {
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 4 / 5;
    border-radius: 15px;
    background: #21131e;
}

.photo-frame::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(12,6,12,.28), transparent 35%);
    pointer-events: none;
}

.photo-frame img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
    transform: scale(1.08);
    opacity: 0;
    filter: saturate(.95) contrast(1.02);
    transition:
        transform 1.4s cubic-bezier(.22,1,.36,1),
        opacity 1s ease;
}

.scene.active .photo-frame img {
    transform: scale(1);
    opacity: 1;
}

.memory-card > p {
    padding: 19px 8px 10px;
    color: var(--muted);
    font-family: "Cormorant Garamond", serif;
    font-size: clamp(1.25rem, 4.5vw, 1.7rem);
    line-height: 1.32;
}

.intimate .photo-frame {
    aspect-ratio: 1 / 1;
}

.intimate .photo-frame img {
    object-position: center;
}

/* ---------- Buttons ---------- */

.primary-btn,
.yes-btn,
.think-btn {
    min-height: 48px;
    border-radius: 999px;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,.16);
    transition:
        transform .25s ease,
        box-shadow .25s ease,
        background .25s ease;
}

.primary-btn {
    padding: 12px 22px;
    background: rgba(255,255,255,.08);
    color: var(--text);
}

.primary-btn:hover,
.primary-btn:focus-visible {
    transform: translateY(-3px);
    background: rgba(255,255,255,.14);
    box-shadow: 0 12px 35px rgba(237,159,190,.15);
    outline: none;
}

.primary-btn span {
    margin-left: 7px;
}

.final-transition {
    background: linear-gradient(135deg, rgba(237,159,190,.16), rgba(255,255,255,.06));
}

/* ---------- Final scene ---------- */

.final-scene {
    background:
        radial-gradient(circle at 50% 35%, rgba(237,159,190,.11), transparent 36%);
}

.final-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, transparent 25%, rgba(0,0,0,.4) 100%);
    pointer-events: none;
}

.final-content {
    text-align: center;
}

.final-heart {
    width: 54px;
    height: 54px;
    margin: 0 auto 8px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(237,159,190,.3);
    border-radius: 50%;
    color: var(--accent-soft);
    box-shadow: 0 0 35px rgba(237,159,190,.12);
    animation: heartPulse 2.2s ease-in-out infinite;
}

.final-title {
    max-width: 620px;
}

.question {
    max-width: 650px;
    margin: 28px auto;
    color: var(--accent-soft);
    font-family: "Cormorant Garamond", serif;
    font-size: clamp(2.25rem, 8vw, 4.1rem);
    line-height: .98;
    animation: finalText 1.2s .35s both;
}

.answer-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 11px;
}

.yes-btn,
.think-btn {
    padding: 13px 22px;
}

.yes-btn {
    background: var(--accent);
    color: #2b1220;
    font-weight: 600;
    box-shadow: 0 12px 35px rgba(237,159,190,.16);
}

.think-btn {
    background: rgba(255,255,255,.06);
    color: var(--text);
}

.yes-btn:hover,
.yes-btn:focus-visible,
.think-btn:hover,
.think-btn:focus-visible {
    transform: translateY(-3px) scale(1.02);
    outline: none;
}

.response {
    position: relative;
    width: min(620px, 100%);
    margin: 30px auto 0;
    padding: 28px 16px;
    border-top: 1px solid var(--line);
    animation: reveal .75s ease both;
}

.response-icon {
    font-size: 3rem;
    margin-bottom: 5px;
}

.response h2 {
    font-size: clamp(2.1rem, 7vw, 3.2rem);
    margin-bottom: 9px;
}

.response p {
    color: var(--muted);
    line-height: 1.55;
}

.plan {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 11px;
    margin: 18px 0;
}

.plan > div {
    padding: 17px 10px;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: rgba(255,255,255,.045);
}

.plan span,
.plan strong,
.plan small {
    display: block;
}

.plan span {
    font-size: 2rem;
    margin-bottom: 7px;
}

.plan strong {
    margin-bottom: 3px;
}

.plan small {
    color: var(--muted);
    font-size: .72rem;
}

.signature {
    margin-top: 14px;
    font-family: "Cormorant Garamond", serif;
    font-size: 1.45rem;
}

.celebration {
    position: absolute;
    left: 0;
    right: 0;
    top: -8px;
    display: flex;
    justify-content: center;
    gap: 25px;
    pointer-events: none;
}

.celebration span {
    display: inline-block;
    color: var(--accent);
    opacity: 0;
    animation: celebrate 1.8s ease forwards;
}

.celebration span:nth-child(1) { animation-delay: .05s; }
.celebration span:nth-child(2) { animation-delay: .16s; }
.celebration span:nth-child(3) { animation-delay: .27s; }
.celebration span:nth-child(4) { animation-delay: .38s; }
.celebration span:nth-child(5) { animation-delay: .49s; }

.hidden {
    display: none !important;
}

/* ---------- Progress ---------- */

.progress {
    position: fixed;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 20;
    display: flex;
    gap: 7px;
    transform: translateX(-50%);
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,.22);
    transition: all .35s ease;
}

.dot.active {
    width: 22px;
    border-radius: 999px;
    background: var(--accent);
}

/* ---------- Floating hearts ---------- */

.hearts {
    position: fixed;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.heart {
    position: absolute;
    bottom: -30px;
    opacity: 0;
    color: var(--accent-soft);
    animation: floatUp linear forwards;
}

/* ---------- Animations ---------- */

@keyframes envelopeFloat {
    0%, 100% { transform: translateY(35px) rotateX(5deg); }
    50% { transform: translateY(22px) rotateX(5deg); }
}

@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: .15; }
    50% { transform: scale(1.12); opacity: .23; }
}

@keyframes reveal {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes finalText {
    from { opacity: 0; transform: translateY(22px) scale(.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes heartPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.09); }
}

@keyframes celebrate {
    0% { opacity: 0; transform: translateY(15px) scale(.4) rotate(-20deg); }
    25% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-90px) scale(1.4) rotate(25deg); }
}

@keyframes floatUp {
    0% {
        opacity: 0;
        transform: translateY(0) rotate(0deg) scale(.7);
    }
    12% { opacity: .28; }
    80% { opacity: .12; }
    100% {
        opacity: 0;
        transform: translateY(-110vh) rotate(30deg) scale(1.15);
    }
}

/* ---------- Phone optimization ---------- */

@media (max-width: 600px) {
    .scene {
        align-items: center;
        padding: 22px 12px 72px;
    }

    .scene-content {
        padding: 6px;
    }

    .letter-wrap {
        min-height: 420px;
    }

    .envelope {
        height: 245px;
    }

    .letter-card {
        min-height: 310px;
        padding: 38px 22px 28px;
    }

    .memory-card {
        padding: 9px;
        border-radius: 19px;
    }

    .photo-frame {
        aspect-ratio: 4 / 5;
        border-radius: 13px;
    }

    .memory-card > p {
        padding: 16px 6px 7px;
    }

    .plan {
        grid-template-columns: 1fr;
    }

    .answer-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .yes-btn,
    .think-btn {
        width: 100%;
    }

    .progress {
        bottom: max(13px, env(safe-area-inset-bottom));
    }
}

@media (max-height: 700px) and (max-width: 600px) {
    .scene {
        align-items: flex-start;
        overflow-y: auto;
    }

    .scene-content {
        margin-top: 15px;
    }

    .photo-frame {
        aspect-ratio: 16 / 17;
    }

    .memory-card > p {
        font-size: 1.18rem;
    }

    .letter-wrap {
        min-height: 380px;
    }
}

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