:root {
    --pink-1: #e9f0fa;
    --pink-2: #cadcf2;
    --pink-3: #8fb0dc;
    --pink-4: #5b8dd8;
    --pink-5: #1e3a72;
    --cream: #f1f6fc;
    --gold: #a98a1f;
    --gold-soft: #d7c374;
    --ink: #223048;
    --ink-soft: #54668a;
    --bg-grad: linear-gradient(-45deg, #e6eefa, #eef3fb, #dce7f6, #eaf0fa);
}

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

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

body {
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: var(--ink);
    background: var(--bg-grad);
    background-size: 400% 400%;
    animation: gradientBG 18s ease infinite;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-env: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body.env-closed {
    overflow: hidden;
    height: 100vh;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.page {
    max-width: 640px;
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top) + 1.5rem) 1.25rem calc(env(safe-area-inset-bottom) + 3rem);
    position: relative;
    z-index: 1;
}

section {
    margin-bottom: 3.5rem;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
}

section.is-visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 1s ease, transform 1s ease;
}

.eyebrow, .section-eyebrow {
    font-family: 'Playfair Display', serif;
    color: var(--ink-soft);
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.section-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.25em;
    font-size: 0.78rem;
    color: var(--pink-5);
    margin-bottom: 1.5rem;
}

/* HERO */
.hero {
    padding-top: 2rem;
}

.names {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: clamp(2.4rem, 9vw, 3.8rem);
    color: var(--pink-5);
    line-height: 1.1;
    letter-spacing: 0.02em;
    margin: 0.5rem 0 1rem;
    text-shadow: 0 2px 20px rgba(91, 141, 216, 0.2);
}

.names .name {
    display: inline-block;
}

.names .amp {
    display: block;
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 0.55em;
    color: var(--pink-4);
    margin: 0.15em 0;
}

.tagline {
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    color: var(--ink);
    margin-bottom: 2.5rem;
}

.save-the-date {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.sd-line {
    flex: 0 0 auto;
    width: 48px;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--gold), transparent);
}

.sd-text {
    font-family: 'Playfair Display', serif;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    font-size: 0.8rem;
    color: var(--gold);
}

.date-block {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--gold-soft);
    border-bottom: 1px solid var(--gold-soft);
}

.date-day {
    font-family: 'Playfair Display', serif;
    color: var(--ink-soft);
    font-size: 1rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.date-main {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.date-num {
    font-family: 'Great Vibes', cursive;
    font-size: 5rem;
    color: var(--pink-5);
    line-height: 1;
}

.date-month-year {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}

.date-month {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.date-year {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    color: var(--ink-soft);
    letter-spacing: 0.2em;
}

/* COUNTDOWN */
.countdown {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    max-width: 480px;
    margin: 0 auto;
}

.cd-unit {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 14px;
    padding: 1rem 0.4rem;
    box-shadow: 0 8px 24px rgba(91, 141, 216, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.cd-num {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.6rem, 7vw, 2.4rem);
    font-weight: 500;
    color: var(--pink-5);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    transition: transform 0.25s ease;
}

.cd-num.tick {
    transform: scale(1.12);
}

.cd-label {
    font-family: 'Playfair Display', serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--ink-soft);
}

.countdown-msg {
    margin-top: 1.25rem;
    font-family: 'Playfair Display', serif;
    color: var(--ink-soft);
    min-height: 1.5em;
}

/* GALLERY */
.welcome-title {
    font-family: 'Playfair Display', serif;
    font-weight: 500;
    font-size: clamp(1.5rem, 5.5vw, 1.9rem);
    color: var(--pink-5);
    line-height: 1.25;
    margin-bottom: 1rem;
}

.welcome-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.12rem;
    font-weight: 500;
    color: var(--ink);
    line-height: 1.6;
    max-width: 36ch;
    margin: 0 auto 1rem;
    padding: 0 0.25rem;
}

.welcome-signoff {
    font-family: 'Playfair Display', serif;
    color: var(--pink-5);
    font-size: 1rem;
    letter-spacing: 0.02em;
    margin-bottom: 1.75rem;
}

.photos {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    max-width: 380px;
    margin: 0 auto;
}

.photo {
    width: 100%;
}

.photo {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--pink-2), var(--pink-1));
    box-shadow: 0 12px 28px rgba(91, 141, 216, 0.2);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.photo:nth-child(1) { transform: rotate(-1deg); }
.photo:nth-child(2) { transform: rotate(0.8deg); }
.photo:nth-child(3) { transform: rotate(-0.6deg); }

.photo:hover {
    box-shadow: 0 18px 36px rgba(91, 141, 216, 0.32);
}

.photo img {
    width: 100%;
    height: auto;
    display: block;
}

.photo.placeholder {
    aspect-ratio: 4 / 5;
}

.photo.placeholder::after {
    content: '💗 Add photo';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    color: var(--pink-5);
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--pink-2), var(--pink-1));
}

.photo.placeholder img {
    opacity: 0;
}

/* CEREMONY (its own prominent card) */
.ceremony-time {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: clamp(1.4rem, 5.5vw, 1.8rem);
    color: var(--pink-5);
    letter-spacing: 0.02em;
    line-height: 1.3;
    margin-bottom: 0.6rem;
}

.ceremony-date-line {
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.22em;
    position: relative;
    display: inline-block;
    padding: 0 1.25rem;
}

.ceremony-date-line::before,
.ceremony-date-line::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 36px;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--pink-3), transparent);
}

.ceremony-date-line::before { right: 100%; }
.ceremony-date-line::after { left: 100%; }

/* VENUE */
.venue-name {
    font-family: 'Playfair Display', serif;
    font-weight: 500;
    font-size: 1.65rem;
    color: var(--pink-5);
    line-height: 1.2;
    margin-bottom: 0.5rem;
    letter-spacing: 0.01em;
}

.venue-address {
    font-family: 'Playfair Display', serif;
    color: var(--ink);
    font-size: 1.05rem;
    margin-bottom: 0.25rem;
    padding: 0 0.5rem;
}

.venue-time {
    font-family: 'Playfair Display', serif;
    color: var(--pink-5);
    font-weight: 500;
    font-size: 1.15rem;
    letter-spacing: 0.02em;
    margin-bottom: 1.5rem;
}

.map-embed {
    position: relative;
    display: block;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    aspect-ratio: 4 / 3;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 12px 28px rgba(91, 141, 216, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.map-embed:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 36px rgba(91, 141, 216, 0.3);
}

.map-embed:active {
    transform: scale(0.99);
}

.map-embed iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    pointer-events: none;
}

.map-overlay {
    position: absolute;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    font-family: 'Playfair Display', serif;
    font-size: 0.9rem;
    letter-spacing: 0.03em;
    color: white;
    background: linear-gradient(135deg, var(--pink-4), var(--pink-3));
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(91, 141, 216, 0.45);
    white-space: nowrap;
    pointer-events: none;
}

/* CLOSING */
.closing {
    padding-top: 1rem;
}

.closing-line {
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    color: var(--ink);
    margin-bottom: 1rem;
}

.closing-heart {
    font-size: 2rem;
    animation: beat 1.4s ease-in-out infinite;
}

@keyframes beat {
    0%, 100% { transform: scale(1); }
    20% { transform: scale(1.15); }
    40% { transform: scale(0.95); }
    60% { transform: scale(1.1); }
}

.closing-message {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--ink);
    line-height: 1.6;
    max-width: 36ch;
    margin: 0.5rem auto 1.25rem;
    padding: 0 0.25rem;
}

.closing-together {
    font-family: 'Playfair Display', serif;
    font-size: 0.78rem;
    color: var(--pink-5);
    text-transform: uppercase;
    letter-spacing: 0.25em;
    margin-bottom: 1rem;
    position: relative;
    display: inline-block;
    padding: 0 1rem;
}

.closing-together::before,
.closing-together::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 28px;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--pink-3), transparent);
}

.closing-together::before { right: 100%; }
.closing-together::after { left: 100%; }

.closing-names {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--pink-5);
    letter-spacing: 0.02em;
    margin-top: 0.5rem;
}

/* PETALS */
.petals {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.petal {
    position: absolute;
    top: -20px;
    font-size: 18px;
    opacity: 0;
    animation: fall linear infinite;
    will-change: transform;
}

@keyframes fall {
    0% {
        transform: translate3d(0, -10vh, 0) rotate(0deg);
        opacity: 0;
    }
    10% { opacity: 0.7; }
    90% { opacity: 0.6; }
    100% {
        transform: translate3d(var(--drift, 40px), 110vh, 0) rotate(var(--spin, 360deg));
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .petals { display: none; }
    body { animation: none; }
    .closing-heart { animation: none; }
}

/* =====================================================
   SECTION CARDS (each section is its own stationery card)
   ===================================================== */
.page > section {
    position: relative;
    background:
        radial-gradient(ellipse at top, rgba(255, 255, 255, 0.6), transparent 70%),
        linear-gradient(180deg, #fdfeff 0%, #eef4fc 60%, #e0ebf7 100%);
    border-radius: 20px;
    padding: 2rem 1.1rem 2.25rem;
    margin-bottom: 1.5rem;
    box-shadow:
        0 20px 45px -22px rgba(30, 58, 114, 0.3),
        0 4px 14px rgba(91, 141, 216, 0.12),
        0 0 0 1px rgba(91, 141, 216, 0.18);
    overflow: hidden;
}

.page > section::before {
    content: '';
    position: absolute;
    inset: 9px;
    border: 1px solid rgba(91, 141, 216, 0.32);
    border-radius: 14px;
    pointer-events: none;
}

.page > section::after {
    content: '';
    position: absolute;
    inset: 13px;
    border: 1px solid rgba(91, 141, 216, 0.15);
    border-radius: 12px;
    pointer-events: none;
}

.page > section.hero {
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
}

@media (min-width: 640px) {
    .page > section {
        padding: 2.75rem 2rem 3rem;
        margin-bottom: 1.75rem;
    }
    .page > section::before { inset: 12px; }
    .page > section::after { inset: 18px; }
}

/* =====================================================
   EMOJI BURST (on seal tap)
   ===================================================== */
.burst-particle {
    position: fixed;
    pointer-events: none;
    z-index: 200;
    user-select: none;
    will-change: transform, opacity;
    line-height: 1;
}

/* =====================================================
   ENVELOPE OPENING SCREEN
   ===================================================== */
.envelope-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--bg-grad);
    background-size: 400% 400%;
    animation: gradientBG 18s ease infinite;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
    padding: 2rem;
    perspective: 1400px;
    opacity: 1;
    transition: opacity 0.7s ease, visibility 0.7s ease;
}

.envelope-screen.is-gone {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.envelope {
    position: relative;
    width: min(80vw, 340px);
    aspect-ratio: 3 / 2;
    transform-style: preserve-3d;
}

.env-back {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(145deg, #cadcf2, #a8c2e3 60%, #8fb0dc);
    border-radius: 8px;
    box-shadow: 0 22px 50px rgba(30, 58, 114, 0.28);
}

.env-note {
    position: absolute;
    inset: 7% 7% 12% 7%;
    background: linear-gradient(135deg, #fdfeff, #ffffff 60%, #e0ebf7);
    border-radius: 5px;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.08),
        inset 0 0 0 1px rgba(91, 141, 216, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.75rem;
    z-index: 1;
    will-change: transform, opacity;
}

.env-note-eyebrow {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    color: var(--gold);
    font-size: 0.7rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-bottom: 0.4rem;
}

.env-note-names {
    font-family: 'Great Vibes', cursive;
    color: var(--pink-5);
    font-size: clamp(1.5rem, 6vw, 2rem);
    line-height: 1;
    margin-bottom: 0.35rem;
}

.env-note-date {
    font-family: 'Playfair Display', serif;
    color: var(--ink-soft);
    font-size: 0.75rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
}

.env-front {
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg, #a8c2e3, #8fb0dc 70%, #6f95c9);
    border-radius: 8px;
    clip-path: polygon(0% 100%, 100% 100%, 100% 22%, 50% 72%, 0% 22%);
    z-index: 2;
    box-shadow: inset 0 -1px 2px rgba(30, 58, 114, 0.2);
}

.env-flap {
    position: absolute;
    inset: 0;
    background: linear-gradient(200deg, #bfd2ec, #9fbbe0 70%, #7aa0cf);
    border-radius: 8px 8px 0 0;
    clip-path: polygon(0% 0%, 100% 0%, 50% 52%);
    transform-origin: top center;
    transform: rotateX(0deg);
    transition: transform 0.8s cubic-bezier(0.7, 0, 0.3, 1);
    z-index: 3;
    backface-visibility: hidden;
    box-shadow: 0 2px 4px rgba(30, 58, 114, 0.15);
}

.env-seal {
    position: absolute;
    left: 50%;
    top: 55%;
    width: 72px;
    height: 72px;
    padding: 0;
    transform: translate(-50%, -50%);
    background:
        radial-gradient(circle at 32% 30%, #7aa3e0, #2f63b3 55%, #1e3a72);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    cursor: pointer;
    box-shadow:
        0 8px 24px rgba(30, 58, 114, 0.55),
        inset 0 -6px 10px rgba(0, 0, 0, 0.18),
        inset 0 4px 8px rgba(255, 255, 255, 0.25);
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: sealPulse 1.8s ease-in-out infinite;
    -webkit-tap-highlight-color: transparent;
}

.env-seal svg {
    width: 58%;
    height: 58%;
    fill: #eef3fb;
    filter: drop-shadow(0 1px 1px rgba(20, 40, 80, 0.45));
}

.env-seal:hover { transform: translate(-50%, -50%) scale(1.06); }
.env-seal:active { transform: translate(-50%, -50%) scale(0.95); }

@keyframes sealPulse {
    0%, 100% { box-shadow: 0 8px 24px rgba(30, 58, 114, 0.55), inset 0 -6px 10px rgba(0,0,0,0.18), inset 0 4px 8px rgba(255,255,255,0.25), 0 0 0 0 rgba(91, 141, 216, 0.5); }
    70% { box-shadow: 0 8px 24px rgba(30, 58, 114, 0.55), inset 0 -6px 10px rgba(0,0,0,0.18), inset 0 4px 8px rgba(255,255,255,0.25), 0 0 0 18px rgba(91, 141, 216, 0); }
}

.envelope-hint {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    color: var(--pink-5);
    font-size: 1rem;
    letter-spacing: 0.02em;
    opacity: 0.85;
    animation: hintBob 2.2s ease-in-out infinite;
}

@keyframes hintBob {
    0%, 100% { transform: translateY(0); opacity: 0.85; }
    50% { transform: translateY(4px); opacity: 1; }
}

/* Opening animation states */
.envelope.is-opening .env-seal {
    animation: sealBreak 0.35s ease forwards;
    pointer-events: none;
}

@keyframes sealBreak {
    40% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}

.envelope.is-opening .env-flap {
    transform: rotateX(-180deg);
    transition-delay: 0.25s;
}

.envelope.is-opening .env-note {
    box-shadow: 0 30px 50px rgba(30, 58, 114, 0.3),
                inset 0 0 0 1px rgba(201, 162, 39, 0.25);
}

@media (prefers-reduced-motion: reduce) {
    .env-seal { animation: none; }
    .envelope-hint { animation: none; }
    .env-flap,
    .env-note { transition-duration: 0.3s; }
}

