/* ===== Phase 3 — Popup (after card opens) + Finale (float-up with neon) ===== */

/* Dim backdrop covering the whole #phase-2 view */
.popup-overlay {
    position: absolute;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    background: rgba(40, 20, 25, 0);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s var(--ease-in-out), background-color 0.5s var(--ease-in-out);
    padding: 16px;
    /* Chỉ cuộn dọc khi cần — chặn scrollbar ngang (thanh xám dưới thiệp) */
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.popup-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
    background: rgba(40, 20, 25, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.popup-overlay.is-leaving { opacity: 0; }

/* ===== Lá thư tay — giấy kraft xé mép, băng giấy xanh, cành hoa vàng =====
   .popup chỉ là khung (không clip) để băng giấy + cành hoa tràn ra ngoài
   mép giấy; drop-shadow đặt ở đây vì clip-path của .letter-paper sẽ cắt
   mất bóng nếu đặt trên chính tờ giấy. */
.popup {
    --letter-ink: #34302c;
    position: relative;
    width: min(460px, 86vw);
    margin: 72px 0 24px;
    filter: drop-shadow(0 22px 30px rgba(30, 14, 8, 0.5)) drop-shadow(0 3px 5px rgba(30, 14, 8, 0.3));
    transform-origin: 50% 60%;
    opacity: 0;
    -webkit-tap-highlight-color: transparent;
}

/* Rút ra từ phong bì (giữa màn hình, hơi thấp) → nâng lên → mở phẳng */
.popup-overlay.is-visible .popup {
    animation: letter-emerge 1.25s cubic-bezier(0.22, 0.8, 0.25, 1) forwards;
}

@keyframes letter-emerge {
    0% {
        opacity: 0;
        transform: perspective(1400px) translateY(-6vh) scale(0.42, 0.3) rotateX(38deg) rotate(0deg);
    }
    14% {
        opacity: 1;
    }
    48% {
        opacity: 1;
        transform: perspective(1400px) translateY(-16vh) scale(0.66, 0.62) rotateX(18deg) rotate(-4deg);
    }
    100% {
        opacity: 1;
        transform: perspective(1400px) translateY(0) scale(1) rotateX(0deg) rotate(-1.6deg);
    }
}

.popup-overlay.is-leaving .popup {
    animation: letter-leave 0.45s var(--ease-in-out) forwards;
}

@keyframes letter-leave {
    from { opacity: 1; transform: rotate(-1.6deg); }
    to   { opacity: 0; transform: translateY(-14px) scale(0.94) rotate(-2.4deg); }
}

.letter-paper {
    position: relative;
    z-index: 2;
    max-height: calc(88vh - 80px);
    padding: 70px 34px 22px 38px;
    color: var(--letter-ink);
    background-color: #d9c8a8;
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.36  0 0 0 0 0.27  0 0 0 0 0.17  0 0 0 0.55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>"),
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><filter id='b'><feTurbulence type='fractalNoise' baseFrequency='0.012' numOctaves='3' seed='7'/><feColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.34  0 0 0 0 0.2  0 0 0 0.42 0'/></filter><rect width='100%25' height='100%25' filter='url(%23b)'/></svg>"),
        radial-gradient(ellipse at 30% 20%, rgba(250, 240, 218, 0.7) 0%, transparent 60%),
        radial-gradient(ellipse at 90% 95%, rgba(120, 90, 55, 0.3) 0%, transparent 55%),
        radial-gradient(ellipse at 0% 60%, rgba(120, 90, 55, 0.22) 0%, transparent 40%);
    background-size: 220px 220px, 600px 600px, 100% 100%, 100% 100%, 100% 100%;
    /* Mép giấy xé tay — răng không đều, lượn nhỏ */
    clip-path: polygon(
        0% 1.6%, 2.4% 0.9%, 4.1% 1.9%, 6.8% 0.4%, 8.9% 1.4%, 11.5% 0.7%, 13.2% 2%, 16.4% 1%, 18.3% 0.2%,
        21.7% 1.5%, 24.1% 0.6%, 26.9% 1.8%, 29.5% 0.9%, 32.2% 0.3%, 35.4% 1.6%, 37.1% 0.8%, 40.6% 2.1%,
        43.3% 0.5%, 46% 1.3%, 48.7% 0.2%, 51.9% 1.7%, 54.2% 0.9%, 57.3% 0.3%, 59.8% 1.9%, 62.5% 0.7%,
        65.4% 1.4%, 68.2% 0.2%, 70.9% 1.6%, 73.3% 0.8%, 76.6% 2%, 79.1% 0.5%, 81.8% 1.2%, 84.7% 0.3%,
        87.2% 1.8%, 90.1% 0.6%, 92.6% 1.5%, 95.3% 0.4%, 97.8% 1.7%, 100% 0.8%,
        99.1% 4.5%, 100% 8.2%, 98.9% 12.1%, 99.7% 16.8%, 98.6% 21.4%, 99.8% 25.9%, 99% 30.2%, 100% 34.8%,
        98.7% 39.6%, 99.6% 44.1%, 98.8% 48.7%, 99.9% 53.2%, 98.9% 57.9%, 99.7% 62.4%, 98.6% 67.1%,
        99.8% 71.6%, 99% 76.2%, 100% 80.9%, 98.8% 85.3%, 99.6% 89.8%, 98.9% 94.4%, 99.8% 98.2%,
        97.6% 99.3%, 94.9% 98.4%, 92.1% 99.8%, 89.4% 98.7%, 86.8% 99.5%, 83.9% 98.2%, 81.2% 99.7%,
        78.3% 98.9%, 75.6% 100%, 72.8% 98.5%, 70.1% 99.4%, 67.3% 98.1%, 64.4% 99.8%, 61.8% 98.8%,
        58.9% 99.6%, 56.2% 98.3%, 53.4% 100%, 50.6% 98.7%, 47.9% 99.5%, 45.1% 98.2%, 42.2% 99.9%,
        39.6% 98.6%, 36.8% 99.4%, 33.9% 98.1%, 31.3% 99.8%, 28.5% 98.9%, 25.7% 99.7%, 22.8% 98.3%,
        20.1% 99.9%, 17.4% 98.6%, 14.6% 99.5%, 11.8% 98.2%, 9.1% 99.8%, 6.3% 98.8%, 3.6% 99.6%, 0.9% 98.4%,
        0.2% 94.1%, 1.2% 89.7%, 0% 85.2%, 0.9% 80.6%, 0.1% 76.1%, 1.3% 71.5%, 0.3% 66.9%, 1.1% 62.3%,
        0% 57.8%, 1% 53.1%, 0.2% 48.6%, 1.4% 44%, 0.1% 39.5%, 0.9% 34.9%, 0% 30.4%, 1.2% 25.8%,
        0.3% 21.2%, 1.1% 16.7%, 0% 12.1%, 0.8% 7.6%, 0.1% 4.2%
    );
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.letter-paper::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

/* Mảnh giấy xanh xé dán phía sau góc phải trên */
.letter-tape {
    position: absolute;
    z-index: 1;
    top: -34px;
    right: 6%;
    width: 46%;
    height: 118px;
    background-color: #93b39a;
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.2  0 0 0 0 0.3  0 0 0 0 0.22  0 0 0 0.35 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>"),
        linear-gradient(160deg, rgba(255, 255, 255, 0.28) 0%, transparent 45%, rgba(40, 70, 50, 0.18) 100%);
    clip-path: polygon(3% 12%, 18% 4%, 34% 9%, 52% 1%, 70% 7%, 86% 0%, 100% 6%, 97% 38%, 100% 70%, 96% 100%, 0% 100%, 4% 64%, 0% 36%);
    transform: rotate(7deg);
    pointer-events: none;
}

/* Cành hoa vàng (tách từ mẫu thư tay) — đè lên góc phải trên của giấy */
.letter-flower {
    position: absolute;
    z-index: 3;
    top: -76px;
    right: -46px;
    width: 52%;
    max-width: 220px;
    height: auto;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: 30% 20%;
    filter: drop-shadow(2px 4px 3px rgba(40, 30, 10, 0.35));
}

.popup-overlay.is-visible .letter-flower {
    animation: letter-flower-sway 5.5s ease-in-out 1.3s infinite;
}

@keyframes letter-flower-sway {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(-2.5deg); }
}

/* Nút X — nhỏ, chìm vào giấy, góc trái trên (góc phải đã có hoa) */
.popup-close {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 6;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(60, 45, 30, 0.3);
    background: rgba(255, 248, 232, 0.45);
    color: #4d3e30;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
    transition: transform 0.18s var(--ease-out-strong), background 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

.popup-close svg {
    width: 12px;
    height: 12px;
    display: block;
}

.popup-close:hover,
.popup-close:focus-visible {
    background: rgba(255, 248, 232, 0.8);
    transform: scale(1.08) rotate(90deg);
    outline: none;
}

.popup-close:active {
    transform: scale(0.94);
}

.popup-text {
    position: relative;
    z-index: 2;
    color: var(--letter-ink);
    font-family: "Pangolin", "Shantell Sans", "Segoe Print", cursive;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    display: block;
    word-break: break-word;
    overflow-wrap: anywhere;
    /* Mực bút dạ hơi loang trên giấy kraft */
    text-shadow: 0 0 0.6px rgba(40, 32, 26, 0.55);
}

.popup-text p {
    margin: 0;
    font-size: 23px;
    letter-spacing: 0.01em;
}

.popup-text p + p {
    margin-top: 12px;
}

/* Chừa chỗ cho cành hoa rủ xuống góc phải — chữ chảy vòng quanh như thư thật */
.popup-text::before {
    content: '';
    float: right;
    width: 30%;
    height: 3.4em;
    font-size: 23px;
}

/* Typewriter: each character lives in a <span> the JS injects after the
   popup opens. Hidden by default; the JS un-hides them one at a time. */
.popup-text .pt-char {
    opacity: 0;
    transition: opacity 0.06s linear;
}

.popup-text .pt-char.is-on {
    opacity: 1;
}

.popup-text .pt-caret {
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 2px;
    background: currentColor;
    vertical-align: -2px;
    animation: pt-caret-blink 0.7s steps(2, end) infinite;
    opacity: 0.7;
}

@keyframes pt-caret-blink {
    50% { opacity: 0; }
}

/* Chữ ký người gửi — hiện sau khi thư viết xong */
.letter-signature {
    position: relative;
    z-index: 2;
    margin: 16px 4px 0 auto;
    width: max-content;
    max-width: 100%;
    font-family: "Pangolin", "Shantell Sans", cursive;
    font-size: 24px;
    color: var(--letter-ink);
    text-align: right;
    overflow-wrap: anywhere;
    opacity: 0;
    transform: translateY(4px) rotate(-2deg);
    transition: opacity 0.8s ease, transform 0.8s var(--ease-out-strong);
}

.popup.is-ready .letter-signature {
    opacity: 1;
    transform: translateY(0) rotate(-2deg);
}

/* Heart action button — bottom of the letter, click to dismiss + finale.
   Hidden until the typewriter finishes (JS adds .is-ready on .popup). */
.popup-heart {
    position: relative;
    z-index: 2;
    display: block;
    margin: 10px auto 4px;
    padding: 6px;
    width: 50px;
    height: 50px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
    -webkit-tap-highlight-color: transparent;
    animation: popup-heart-beat 1.4s ease-in-out infinite;
    transition:
        transform 0.18s var(--ease-out-strong),
        filter    0.18s ease,
        opacity   0.6s  ease,
        scale     0.6s  var(--ease-out-strong);
    filter: drop-shadow(0 4px 10px rgba(193, 74, 93, 0.35));
    opacity: 0;
    scale: 0.7;
    pointer-events: none;
}

.popup.is-ready .popup-heart {
    opacity: 1;
    scale: 1;
    pointer-events: auto;
}

.popup-heart img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.popup-heart:hover,
.popup-heart:focus-visible {
    transform: scale(1.15);
    filter: drop-shadow(0 6px 16px rgba(193, 74, 93, 0.6));
    outline: none;
    animation-play-state: paused;
}

.popup-heart:active {
    transform: scale(0.92);
}

@keyframes popup-heart-beat {
    0%, 100% { transform: scale(1);    }
    18%      { transform: scale(1.12); }
    32%      { transform: scale(1);    }
    50%      { transform: scale(1.06); }
    70%      { transform: scale(1);    }
}

/* ===== Finale sky — night gradient + Milky Way + twinkling star canvas =====
   Under the flower stages (z 20/25) and the finale (z 90), above the phase
   background; the "for you" line (z 50) stays readable on top. */
.finale-sky {
    position: absolute;
    inset: 0;
    z-index: 15;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    transition: opacity 2.8s var(--ease-in-out);
    background:
        radial-gradient(ellipse at 50% 115%, rgba(120, 52, 110, 0.75) 0%, transparent 55%),
        radial-gradient(ellipse at 15% 10%, rgba(40, 40, 110, 0.55) 0%, transparent 50%),
        linear-gradient(180deg, #060414 0%, #120a2c 48%, #2a1238 100%);
}

.finale-sky.is-visible { opacity: 1; }

.star-canvas {
    position: absolute;
    inset: 0;
    display: block;
}

/* Milky Way — a tilted band of layered nebula light with dark dust lanes */
.milky-way {
    position: absolute;
    left: 50%;
    top: 42%;
    width: 170vmax;
    height: 44vmin;
    transform: translate(-50%, -50%) rotate(-28deg);
    mix-blend-mode: screen;
    animation: milky-way-drift 60s ease-in-out infinite alternate;
}

.milky-way::before,
.milky-way-core,
.milky-way-dust {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
}

.milky-way::before {
    background:
        radial-gradient(ellipse 50% 50% at 50% 50%, rgba(150, 120, 230, 0.4) 0%, transparent 70%),
        radial-gradient(ellipse 22% 60% at 30% 46%, rgba(255, 140, 200, 0.32) 0%, transparent 70%),
        radial-gradient(ellipse 26% 55% at 72% 55%, rgba(110, 170, 255, 0.3) 0%, transparent 70%);
    filter: blur(22px);
}

.milky-way-core {
    inset: 28% 6%;
    background:
        radial-gradient(ellipse 18% 70% at 46% 50%, rgba(255, 244, 225, 0.62) 0%, transparent 70%),
        radial-gradient(ellipse 38% 55% at 50% 50%, rgba(255, 220, 240, 0.34) 0%, transparent 75%),
        radial-gradient(ellipse 12% 50% at 62% 48%, rgba(255, 236, 200, 0.4) 0%, transparent 70%);
    filter: blur(14px);
    animation: milky-way-glow 7s ease-in-out infinite;
}

.milky-way-dust {
    inset: 38% 10%;
    mix-blend-mode: multiply;
    background:
        radial-gradient(ellipse 30% 22% at 40% 52%, rgba(20, 8, 30, 0.7) 0%, transparent 75%),
        radial-gradient(ellipse 22% 16% at 64% 46%, rgba(20, 8, 30, 0.55) 0%, transparent 75%);
    filter: blur(10px);
}

@keyframes milky-way-drift {
    from { transform: translate(-50%, -50%) rotate(-28deg); }
    to   { transform: translate(-48%, -51%) rotate(-25deg); }
}

@keyframes milky-way-glow {
    0%, 100% { opacity: 0.8; }
    50%      { opacity: 1; }
}

/* ===== Finale — love photos + flowers float up from below =====
   Photos wear a single-colour hot-pink neon halo that breathes (dim ↔
   bloom) while they drift slowly upward through a 3-point sway curve. */
.finale-stage {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 90;
    contain: layout style paint;
}

.finale-item {
    position: absolute;
    top: 100%;
    left: 50%;
    --fx-start: 0px;
    --fx-end:   0px;
    --fy:       110vh;
    --frot:     0deg;
    --sway:     0px;
    --fdur:     8s;
    --fdelay:   0s;
    opacity: 0;
    will-change: transform, opacity;
    animation:
        finale-rise var(--fdur) cubic-bezier(0.33, 0.05, 0.4, 1) var(--fdelay) forwards,
        finale-fade var(--fdur) linear var(--fdelay) forwards;
}

/* Photo — single-colour soft-red neon tube + halo, gently breathing.
   The neon stays one warm light-red shade; only intensity pulses (dim ↔
   bright) so it reads as a steady glowing love-letter frame. */
.finale-item--photo {
    width: var(--photo-size, 200px);
    border-radius: 18px;
    overflow: hidden;
    border: 3px solid #ff7878;
    aspect-ratio: 4 / 5;
    /* Above the heart cluster (z 4) and drifters (z 2) — with up to 12
       photos rising, faces must never be hidden behind flowers. */
    z-index: 5;
    background: #fff;
    /* 3 animations: rise + fade (per finale-item) + neon-pulse (per photo) */
    /* Linear rise: rows keep constant spacing (see spawnPhotoCycle) */
    animation:
        finale-rise  var(--fdur) linear var(--fdelay) forwards,
        finale-fade  var(--fdur) linear var(--fdelay) forwards,
        neon-breathe 2.8s ease-in-out infinite;
}

.finale-item--photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    -webkit-user-drag: none;
    /* Tiny inset white edge so the neon tube sits flush against the photo
       instead of touching colourful pixels directly */
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.finale-item--flower {
    width: var(--flower-size, 140px);
    height: var(--flower-size, 140px);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2;
    /* Add a gentle breathing pulse so flowers feel alive as they drift up.
       Individual `scale` property composes cleanly with the `transform`
       shorthand used by finale-rise (translate + rotate). */
    animation:
        finale-rise  var(--fdur) cubic-bezier(0.33, 0.05, 0.4, 1) var(--fdelay) forwards,
        finale-fade  var(--fdur) linear var(--fdelay) forwards,
        flower-pulse var(--pulse-dur, 4s) ease-in-out var(--pulse-delay, 0s) infinite;
}

@keyframes flower-pulse {
    0%, 100% { scale: 1; }
    50%      { scale: 1.05; }
}

/* ===== Heart-formation flowers — 2-phase + permanent hold =====
   Phase A — RISE     ( 0 % →  67 % /  0 → 6 s) : float up from bottom
   Phase B — CONVERGE (67 % → 100 % /  6 → 9 s) : drift to heart point
   Then `forwards` fill keeps the flower locked at its heart-x/heart-y
   indefinitely, while heart-pulse infinite continues the heartbeat. */
.finale-item--heart {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--flower-size, 100px);
    height: var(--flower-size, 100px);
    margin-left: calc(-1 * var(--flower-size, 100px) / 2);
    margin-top:  calc(-1 * var(--flower-size, 100px) / 2);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0;
    /* Heart cluster sits ABOVE photos (z 3) and drifters (z 2) so the
       silhouette reads clearly. */
    z-index: 4;
    will-change: transform, opacity;
    animation:
        heart-form  9s cubic-bezier(0.45, 0.05, 0.4, 0.95) var(--heart-delay, 0ms) forwards,
        heart-pulse 1.6s ease-in-out calc(9s + var(--heart-delay, 0ms)) infinite;
}

@keyframes heart-form {
    /* Phase A — rise from bottom */
    0%   { transform: translate(var(--start-x), var(--start-y));   opacity: 0; }
    5%   { transform: translate(var(--start-x), var(--start-y));   opacity: var(--max-opacity, 1); }
    67%  { transform: translate(var(--mid-x),   var(--mid-y));     opacity: var(--max-opacity, 1); }
    /* Phase B — converge into the heart shape (final, held by `forwards`) */
    100% { transform: translate(var(--heart-x), var(--heart-y));   opacity: var(--max-opacity, 1); }
}

@keyframes heart-pulse {
    0%, 100% { scale: 1;    }
    50%      { scale: 1.07; }
}

/* Rise with a 3-point horizontal wobble (in → out → in) so the item drifts
   like it's caught in a slow breeze instead of going straight up. The
   easeInOut curve on the parent animation keeps the Y motion smooth. */
@keyframes finale-rise {
    0% {
        transform:
            translate(calc(-50% + var(--fx-start)), 0)
            rotate(0deg);
    }
    33% {
        transform:
            translate(
                calc(-50% + var(--fx-start) + (var(--fx-end) - var(--fx-start)) * 0.33 + var(--sway)),
                calc(-1 * var(--fy) * 0.33)
            )
            rotate(calc(var(--frot) * 0.33));
    }
    66% {
        transform:
            translate(
                calc(-50% + var(--fx-start) + (var(--fx-end) - var(--fx-start)) * 0.66 - var(--sway)),
                calc(-1 * var(--fy) * 0.66)
            )
            rotate(calc(var(--frot) * 0.66));
    }
    100% {
        transform:
            translate(calc(-50% + var(--fx-end)), calc(-1 * var(--fy)))
            rotate(var(--frot));
    }
}

@keyframes finale-fade {
    0%   { opacity: 0; }
    10%  { opacity: var(--max-opacity, 1); }
    85%  { opacity: var(--max-opacity, 1); }
    100% { opacity: 0; }
}

/* Single-colour neon breath — soft warm red tube + halo, intensity pulses
   between resting glow (#ff7878) and bloom (#ff9e9e). Multi-layer shadow
   stack (hard 6/14px + soft 28/55px) reads as a classic neon-sign glow
   instead of a fuzzy blur. */
@keyframes neon-breathe {
    0%, 100% {
        border-color: #ff7878;
        box-shadow:
            0 0 6px  rgba(255, 120, 120, 0.95),
            0 0 14px rgba(255, 120, 120, 0.85),
            0 0 28px rgba(255, 120, 120, 0.55),
            0 0 55px rgba(255, 120, 120, 0.30);
    }
    50% {
        border-color: #ff9e9e;
        box-shadow:
            0 0 10px rgba(255, 158, 158, 1),
            0 0 24px rgba(255, 158, 158, 0.95),
            0 0 46px rgba(255, 120, 120, 0.75),
            0 0 88px rgba(255, 120, 120, 0.45);
    }
}

/* Tablet / phone — thư giữ tỉ lệ, chữ tay nhỏ lại cân đối */
@media (max-width: 700px) {
    .popup            { width: min(370px, 88vw); }
    .letter-paper     { padding: 64px 26px 18px 30px; }
    .popup-text p + p { margin-top: 10px; }
    .popup-text::before { font-size: 19px; }
    .popup-text p     { font-size: 19px; }
    .letter-signature { font-size: 20px; }
    .popup-heart      { width: 46px; height: 46px; }
}

@media (max-width: 480px) {
    .popup            { width: 86vw; margin-top: 64px; }
    .letter-paper     { padding: 60px 20px 16px 24px; }
    .popup-text p     { font-size: 17px; line-height: 1.45; }
    .popup-text::before { font-size: 17px; width: 30%; height: 5.2em; }
    .letter-signature { font-size: 18px; margin-top: 12px; }
    .letter-flower    { top: -72px; right: -26px; width: 46%; }
    .letter-tape      { top: -26px; height: 96px; }
    .popup-close      { top: 12px; left: 12px; width: 26px; height: 26px; }
    .popup-heart      { width: 42px; height: 42px; }
}

@media (max-width: 360px) {
    .letter-paper     { padding: 56px 16px 14px 20px; }
    .popup-text p     { font-size: 16px; }
    .letter-signature { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
    .popup-overlay.is-visible .popup { animation: none; opacity: 1; transform: rotate(-1.6deg); transition: opacity 0.4s linear; }
    .popup-overlay.is-visible .letter-flower { animation: none; }
    .popup-heart { animation: none; }
    .milky-way, .milky-way-core { animation: none; }
    .finale-item { animation-duration: 6s, 6s; }
    .finale-item--photo  { animation-duration: 6s, 6s, 2.8s; }
    .finale-item--flower { animation-duration: 6s, 6s, 4s; }
}
