/* =========================================
   1. GLOBAL THEME & STORYBOOK SNAP
   ========================================= */
:root {
    --rose-primary: #ff4b6e;
    --crimson-deep: #b71c1c;
    --berry-dark: #880e4f;
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.9);
    --bg-start: #fff5f7;
    --bg-end: #fce4ec;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

html {
    scroll-behavior: smooth;
    scroll-snap-type: y proximity;
    scrollbar-width: none;
}

html::-webkit-scrollbar {
    display: none;
}

body {
    font-family: 'Quicksand', sans-serif;
    min-height: 100dvh;
    color: #4a3b40;
    overflow-x: hidden;
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
    transition: background 1.2s ease;
}

/* Top Progress Ribbon */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3.5px;
    background: linear-gradient(90deg, #ff8fa3, #ff4b6e, #b71c1c);
    z-index: 99999;
    transition: width 0.12s ease-out;
    box-shadow: 0 0 12px rgba(255, 75, 110, 0.6);
}

/* =========================================
   2. DYNAMIC AMBIENT AURORA & BOKEH LAYER
   ========================================= */
.ambient-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.aurora-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(75px);
    opacity: 0.55;
    will-change: transform, background;
    transition: background 1.4s ease, opacity 1.4s ease;
}

.orb-1 {
    width: 46vw;
    height: 46vw;
    max-width: 520px;
    max-height: 520px;
    top: -10%;
    left: -10%;
    background: radial-gradient(circle, rgba(255, 143, 163, 0.55), transparent 70%);
}

.orb-2 {
    width: 50vw;
    height: 50vw;
    max-width: 560px;
    max-height: 560px;
    bottom: -12%;
    right: -12%;
    background: radial-gradient(circle, rgba(255, 204, 188, 0.6), transparent 70%);
}

.orb-3 {
    width: 36vw;
    height: 36vw;
    max-width: 400px;
    max-height: 400px;
    top: 42%;
    left: 32%;
    background: radial-gradient(circle, rgba(248, 187, 208, 0.45), transparent 70%);
}

/* Candlelit Twilight Vignette for Final Chapter */
.spotlight-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(255, 240, 244, 0) 28%, rgba(74, 14, 36, 0.24) 100%);
    opacity: 0;
    transition: opacity 1.2s ease;
}

body.finale-atmosphere .spotlight-vignette {
    opacity: 1;
}

body.finale-atmosphere .orb-1 {
    background: radial-gradient(circle, rgba(255, 75, 110, 0.45), transparent 70%);
}

body.finale-atmosphere .orb-2 {
    background: radial-gradient(circle, rgba(183, 28, 28, 0.32), transparent 70%);
}

.floating-hearts {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.heart-bg {
    position: absolute;
    bottom: -10vh;
    color: rgba(255, 75, 110, 0.22);
    animation: floatUp linear infinite, sway ease-in-out infinite alternate;
}

@keyframes floatUp {
    0% { bottom: -10vh; opacity: 0; }
    15% { opacity: 1; }
    100% { bottom: 110vh; opacity: 0; }
}

@keyframes sway {
    0% { transform: translateX(-22px) rotate(-12deg); }
    100% { transform: translateX(22px) rotate(12deg); }
}

/* =========================================
   3. CHAPTER SPINE RAIL & STORY CHAPTERS
   ========================================= */


.container {
    position: relative;
    z-index: 2;
    max-width: 820px;
    margin: auto;
    padding: 0 22px;
    transition: filter 0.8s ease, opacity 0.8s ease;
}

.container.blur-out {
    filter: blur(10px) grayscale(0.2);
    opacity: 0.45;
    pointer-events: none;
}

/* Each Section is an Unwrappable Full-Viewport Chapter */
.story-chapter {
    min-height: 100dvh;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 64px 0;
    perspective: 1200px;
}

.chapter-stage {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chapter-kicker {
    display: inline-block;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3.5px;
    color: #d81b60;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 75, 110, 0.22);
    padding: 5px 14px;
    border-radius: 20px;
    margin-bottom: 14px;
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.story-chapter.active .chapter-kicker {
    opacity: 1;
    transform: translateY(0);
}

h1 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2.5rem, 7.5vw, 3.8rem);
    color: var(--crimson-deep);
    text-align: center;
    font-weight: 700;
    line-height: 1.15;
    text-shadow: 0 6px 24px rgba(183, 28, 28, 0.12);
}

h2 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.85rem, 5.2vw, 2.35rem);
    color: var(--berry-dark);
    margin: 0 0 22px 0;
    text-align: center;
    font-weight: 600;
    letter-spacing: 0.5px;
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.75s ease 0.08s, transform 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.08s;
}

.story-chapter.active h2 {
    opacity: 1;
    transform: translateY(0);
}

.subtitle {
    text-align: center;
    color: #7d626b;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-bottom: 28px;
}

.instruction {
    text-align: center;
    font-size: 0.88rem;
    color: #7f656e;
    margin-top: 8px;
    margin-bottom: 20px;
    letter-spacing: 0.6px;
}

/* =========================================
   4. CHAPTER I: PROLOGUE & 3D LOVE TIMER
   ========================================= */
.hero-title {
    max-width: 100%;
    overflow-wrap: anywhere;
    opacity: 0;
    filter: blur(8px);
    transform: scale(0.94) translateY(16px);
    transition: opacity 1s ease 0.1s, filter 1s ease 0.1s, transform 1s cubic-bezier(0.22, 1, 0.36, 1) 0.1s;
}

.chapter-hero.active .hero-title {
    opacity: 1;
    filter: blur(0);
    transform: scale(1) translateY(0);
}

.title-flourish {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 14px 0 12px;
    color: var(--rose-primary);
    font-size: 0.95rem;
}

.title-flourish::before,
.title-flourish::after {
    content: '';
    height: 1.5px;
    width: 0px;
    background: linear-gradient(90deg, transparent, #ff4b6e, transparent);
    transition: width 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.35s;
}

.chapter-hero.active .title-flourish::before,
.chapter-hero.active .title-flourish::after {
    width: 68px;
}

#love-timer {
    display: flex;
    justify-content: center;
    gap: 14px;
    width: 100%;
    max-width: 460px;
    margin: 10px 0 36px;
    perspective: 900px;
}

.time-box {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.92);
    border-radius: 18px;
    padding: 18px 12px;
    flex: 1;
    text-align: center;
    box-shadow: 0 10px 28px rgba(183, 28, 28, 0.06);
    opacity: 0;
    transform: rotateX(-35deg) translateY(24px);
    transition:
        opacity 0.7s ease calc(0.25s + var(--stagger) * 0.1s),
        transform 0.8s cubic-bezier(0.22, 1, 0.36, 1) calc(0.25s + var(--stagger) * 0.1s),
        box-shadow 0.3s ease;
}

.chapter-hero.active .time-box {
    opacity: 1;
    transform: rotateX(0deg) translateY(0);
}

.time-box span {
    display: block;
    font-size: 2rem;
    font-weight: 600;
    color: var(--crimson-deep);
    font-family: 'Playfair Display', serif;
}

.time-box p {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #8a6c75;
    margin-top: 4px;
}

.scroll-cue {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: #9e4764;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    cursor: pointer;
    opacity: 0.85;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.scroll-cue:hover {
    transform: translateY(3px);
    opacity: 1;
}

.scroll-cue i {
    animation: bounce 2s infinite;
}

/* =========================================
   5. CHAPTER II: TIMELINE (CENTERED DOTS + SWING)
   ========================================= */
.timeline-container {
    position: relative;
    width: 100%;
    max-width: 780px;
    margin: 10px auto 0;
    padding: 16px 0;
}

.timeline-container::before {
    content: '';
    position: absolute;
    width: 2px;
    background: rgba(255, 75, 110, 0.16);
    top: 0;
    bottom: 0;
    left: 50%;
    margin-left: -1px;
}

.timeline-container::after {
    content: '';
    position: absolute;
    width: 2px;
    top: 0;
    left: 50%;
    margin-left: -1px;
    height: var(--line-progress, 0%);
    max-height: 100%;
    background: linear-gradient(to bottom, #ff4b6e, #ff8fa3);
    transition: height 0.7s cubic-bezier(0.25, 1, 0.5, 1);
}

.timeline-card {
    padding: 12px 40px;
    position: relative;
    width: 50%;
    opacity: 0;
    transition: opacity 0.75s ease, transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

.timeline-card.left {
    left: 0;
    text-align: right;
    transform: translateX(-45px) rotate(-3.5deg);
}

.timeline-card.right {
    left: 50%;
    text-align: left;
    transform: translateX(45px) rotate(3.5deg);
}

.timeline-card.in-view {
    opacity: 1;
    transform: translateX(0) rotate(0deg);
}

/* Centered Dots on Desktop Spine */
.timeline-card::after {
    content: '';
    box-sizing: border-box;
    position: absolute;
    width: 14px;
    height: 14px;
    left: 100%;
    transform: translateX(-50%);
    background: white;
    border: 3px solid #ff4b6e;
    top: 24px;
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 0 10px rgba(255, 75, 110, 0.4);
}

.timeline-card.right::after {
    left: 0;
    transform: translateX(-50%);
}

@keyframes magneticPing {
    0% { box-shadow: 0 0 0 0 rgba(255, 75, 110, 0.85); }
    70% { box-shadow: 0 0 0 18px rgba(255, 75, 110, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 75, 110, 0); }
}

.timeline-card.ping-active::after {
    animation: magneticPing 1.5s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
    background: #ff4b6e;
    border-color: white;
}

.content {
    padding: 22px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 18px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 24px rgba(183, 28, 28, 0.05);
}

.content h3 {
    font-family: 'Playfair Display', serif;
    color: var(--crimson-deep);
    margin: 10px 0 6px;
}

.content p {
    line-height: 1.55;
    color: #5a4a50;
}

.date-badge {
    display: inline-block;
    background: rgba(255, 75, 110, 0.12);
    color: #d81b60;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.8px;
}

/* =========================================
   6. CHAPTER III: FANNED POLAROID GALLERY
   ========================================= */
.gallery-grid {
    --gallery-gap: 20px;
    --gallery-columns: 3;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--gallery-gap);
    perspective: 1100px;
}

.gallery-card {
    width: calc((100% + var(--gallery-gap)) / var(--gallery-columns) - var(--gallery-gap));
    height: 270px;
    position: relative;
    transform-style: preserve-3d;
    cursor: pointer;
    border-radius: 18px;
    box-shadow: 0 12px 30px rgba(136, 14, 79, 0.09);
    opacity: 0;
    transform: translateY(45px) rotate(var(--deal-rot, -6deg)) scale(0.86);
    transition:
        opacity 0.65s ease calc(var(--card-idx, 0) * 0.11s),
        transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) calc(var(--card-idx, 0) * 0.11s);
}

.chapter-gallery.active .gallery-card {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
}

/* Remove stagger delay once dealt so flipping responds instantaneously */
.chapter-gallery.dealt .gallery-card {
    transition: transform 0.75s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chapter-gallery.dealt .gallery-card.flipped {
    transform: rotateY(180deg);
}

.gallery-front, .gallery-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 18px;
}

.gallery-front {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(255, 232, 238, 0.62));
    border: 1px solid rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    overflow: hidden;
}

.gallery-front::before {
    content: '\f25a';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: 1rem;
    color: rgba(255, 75, 110, 0.6);
    animation: bounce 2s infinite;
}

.gallery-front::after {
    content: '\f004';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 2.3rem;
    color: rgba(255, 75, 110, 0.35);
    transition: transform 0.3s ease, color 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
    .gallery-card:not(.flipped):hover .gallery-front::after {
        transform: scale(1.18);
        color: rgba(255, 75, 110, 0.65);
    }
}

.gallery-back {
    transform: rotateY(180deg);
    background: #ffffff;
    padding: 9px 9px 26px 9px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.gallery-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

/* =========================================
   7. CHAPTER IV: WOVEN BUCKET LIST
   ========================================= */
.bucket-list {
    width: 100%;
    max-width: 640px;
}

.bucket-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    margin-bottom: 14px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(183, 28, 28, 0.04);
    opacity: 0;
    transform: translateX(var(--slide-from, -36px));
    transition:
        opacity 0.6s ease calc(var(--item-idx, 0) * 0.1s),
        transform 0.65s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--item-idx, 0) * 0.1s),
        background 0.25s ease;
}

.chapter-bucket.active .bucket-item {
    opacity: 1;
    transform: translateX(0);
}

@media (hover: hover) and (pointer: fine) {
    .chapter-bucket.active .bucket-item:hover {
        transform: translateX(6px);
        background: rgba(255, 255, 255, 0.94);
    }
}

.checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--rose-primary);
    border-radius: 50%;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: 0.3s;
    flex-shrink: 0;
}

.bucket-item.done .checkbox {
    background: var(--rose-primary);
    border-color: var(--rose-primary);
    animation: heartPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bucket-item.done .checkbox::after {
    content: '\f00c';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: white;
    font-size: 11px;
}

.bucket-item span {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

.bucket-item.done span {
    color: var(--berry-dark);
    font-weight: 600;
}

.mini-heart-spark {
    position: fixed;
    pointer-events: none;
    font-size: 1rem;
    z-index: 9999;
    animation: sparkRise 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes sparkRise {
    0% { opacity: 1; transform: translate(0, 0) scale(0.7); }
    100% { opacity: 0; transform: translate(var(--dx), -55px) scale(1.35); }
}

/* =========================================
   8. CHAPTER V: 3D LEVITATING SCRATCH CARD
   ========================================= */
.scratch-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 12px 0;
    perspective: 1000px;
}

.scratch-card {
    position: relative;
    width: 100%;
    max-width: 360px;
    height: 185px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 18px 42px rgba(183, 28, 28, 0.14);
    border: 2px solid rgba(255, 255, 255, 0.95);
    opacity: 0;
    transform: rotateX(24deg) translateY(36px) scale(0.88);
    transition: opacity 0.8s ease 0.15s, transform 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.15s;
}

.chapter-scratch.active .scratch-card {
    opacity: 1;
    transform: rotateX(0deg) translateY(0) scale(1);
}

/* Diagonal Metallic Shimmer Sweep across unscratched foil */
.scratch-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -120%;
    width: 65%;
    height: 100%;
    background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, 0.55) 50%, transparent 80%);
    transform: skewX(-20deg);
    pointer-events: none;
    animation: foilShimmer 3.6s ease-in-out infinite;
}

.scratch-card.scratched::after {
    display: none;
}

@keyframes foilShimmer {
    0%, 55% { left: -120%; }
    100% { left: 160%; }
}

.scratch-content {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #ffffff 0%, #fff0f4 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 22px;
}

.scratch-content h3 {
    font-family: 'Playfair Display', serif;
    color: var(--rose-primary);
    font-size: 1.5rem;
    margin-bottom: 8px;
}

#coupon-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    overflow-y: auto;
    font-size: 0.96rem;
    line-height: 1.48;
    color: #5c0a36;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

/* =========================================
   9. CHAPTER VI: WAX-SEALED ENVELOPE DECK
   ========================================= */
.envelope-container {
    height: 395px;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    perspective: 1100px;
    margin-bottom: 10px;
    opacity: 0;
    transform: translateY(45px) scale(0.92);
    transition: opacity 0.8s ease 0.15s, transform 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.15s;
}

.chapter-letter.active .envelope-container {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.envelope-wrapper {
    width: 100%;
    max-width: 345px;
    height: 205px;
    position: relative;
    cursor: pointer;
    animation: envelopeHoverFloat 3.8s ease-in-out infinite;
}

.envelope-wrapper.open {
    animation: none;
}

@keyframes envelopeHoverFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-7px); }
}

.envelope-body, .envelope-pocket, .envelope-flap {
    border: 1px solid rgba(255, 255, 255, 0.88);
}

.envelope-body {
    position: absolute;
    inset: 0;
    border-radius: 0 0 18px 18px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.62);
    backdrop-filter: blur(10px);
    border-top: none;
    box-shadow: 0 16px 38px rgba(183, 28, 28, 0.1);
}

.envelope-pocket {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%);
    background: linear-gradient(to bottom right, rgba(255, 255, 255, 0.94), rgba(255, 236, 241, 0.82));
    backdrop-filter: blur(6px);
    border-radius: 0 0 18px 18px;
}

.envelope-flap {
    position: absolute;
    inset: 0;
    z-index: 30;
    transform-origin: top;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    clip-path: polygon(0 0, 50% 55%, 100% 0);
    background: rgba(255, 240, 244, 0.95);
    backdrop-filter: blur(6px);
}

.envelope-wrapper.open .envelope-flap {
    transform: rotateX(180deg);
    z-index: 1;
    opacity: 0.35;
}

.heart-seal {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 38px;
    height: 38px;
    background: var(--rose-primary);
    clip-path: path('M17.5 31.3l-2.5-2.3C6 20.8 0 15.4 0 8.8 0 3.9 3.9 0 8.8 0c2.7 0 5.3 1.3 7.1 3.3 1.8-2 4.4-3.3 7.1-3.3 4.9 0 8.8 3.9 8.8 8.8 0 6.6-6 12-15 20.3l-2.5 2.2z');
    z-index: 40;
    transition: opacity 0.3s, transform 0.3s;
    animation: sealPulse 2.2s infinite ease-in-out;
}

@keyframes sealPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.12); }
}

.envelope-wrapper.open .heart-seal {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
    pointer-events: none;
    animation: none;
}

.card-stack {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    height: 225px;
    z-index: 5;
    pointer-events: none;
}

.envelope-wrapper.open .card-stack {
    z-index: 35;
}

.letter-card {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: linear-gradient(135deg, #ffffff 0%, #fff5f7 100%);
    border-radius: 16px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.07), inset 0 0 15px rgba(255, 255, 255, 1);
    border: 1px solid rgba(255, 75, 110, 0.24);
    padding: 24px 22px 28px 22px;
    text-align: center;
    overflow-y: auto;
    scrollbar-width: none;
    cursor: pointer;
    opacity: 0;
    transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.45s ease;
}

.letter-card::-webkit-scrollbar {
    display: none;
}

.letter-card::before {
    content: '\f10d';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 1.05rem;
    color: rgba(255, 75, 110, 0.3);
    margin-bottom: 10px;
    flex-shrink: 0;
}

.letter-card p {
    font-family: 'Playfair Display', serif;
    color: #5c0a36;
    font-size: 1.02rem;
    line-height: 1.72;
    margin: 0;
    letter-spacing: 0.2px;
    font-weight: 500;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.card-count-badge {
    margin-top: auto;
    padding-top: 12px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #b56576;
    flex-shrink: 0;
}

.card-peek {
    opacity: 1;
    transform: translateY(-148px) rotate(var(--rot)) scale(1.02);
    pointer-events: auto !important;
    box-shadow: 0 22px 44px rgba(136, 14, 79, 0.14), 0 5px 15px rgba(255, 75, 110, 0.08) !important;
}

.card-slide-away {
    transform: translateY(-190px) translateX(95px) rotate(18deg) scale(0.92) !important;
    opacity: 0 !important;
}

.scroll-indicator {
    position: sticky;
    bottom: -10px;
    color: var(--rose-primary);
    opacity: 0.65;
    font-size: 1rem;
    animation: bounce 2s infinite;
    transition: opacity 0.3s ease;
    pointer-events: none;
    margin-top: 8px;
}

/* =========================================
   10. CHAPTER VII: LIQUID GLASS FINALE
   ========================================= */
.liquid-glass-card {
    position: relative;
    width: 100%;
    max-width: 490px;
    padding: 46px 28px;
    border-radius: 26px;
    text-align: center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.34));
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: inset 0 0 24px rgba(255, 255, 255, 0.7), 0 18px 45px rgba(183, 28, 28, 0.14);
    opacity: 0;
    transform: scale(0.88) translateY(30px);
    transition: opacity 0.85s ease 0.15s, transform 0.95s cubic-bezier(0.22, 1, 0.36, 1) 0.15s;
}

.chapter-finale.active .liquid-glass-card {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.liquid-content {
    position: relative;
    z-index: 2;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.85), rgba(255, 75, 110, 0.18));
    pointer-events: none;
    transition: transform 0.3s ease-out;
    will-change: transform;
    z-index: 1;
}

.bubble.b1 {
    width: 92px;
    height: 92px;
    top: -18px;
    left: -18px;
}

.bubble.b2 {
    width: 124px;
    height: 124px;
    bottom: -24px;
    right: -16px;
}

.glowing-text {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.85rem, 5.5vw, 2.3rem);
    color: var(--crimson-deep);
    margin: 0 0 28px 0;
    line-height: 1.3;
    opacity: 1;
    transform: none;
}

.btn-group {
    position: relative;
    min-height: 52px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

@keyframes magneticGlow {
    0%, 100% {
        box-shadow: 0 8px 22px rgba(255, 75, 110, 0.42);
    }
    50% {
        box-shadow: 0 10px 34px rgba(255, 75, 110, 0.8), 0 0 18px rgba(255, 75, 110, 0.55);
    }
}

.yes-btn {
    padding: 13px 40px;
    font-size: 1.12rem;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #ff4b6e, #e91e63);
    color: white;
    cursor: pointer;
    position: relative;
    z-index: 5;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    transform: scale(var(--yes-scale, 1));
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: magneticGlow 2.5s infinite ease-in-out;
}

.no-btn {
    padding: 12px 28px;
    font-size: 1.05rem;
    border: 1px solid #e0cfd4;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.94);
    color: #6b565d;
    cursor: pointer;
    position: relative;
    z-index: 6;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    white-space: nowrap;
}

.ghost-trail {
    position: absolute;
    pointer-events: none;
    opacity: 0.55;
    z-index: 2;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.ghost-fade {
    opacity: 0;
    transform: scale(0.6) !important;
}

/* =========================================
   11. MUSIC TOGGLE & CELEBRATION MODAL
   ========================================= */
.music-btn {
    position: fixed;
    bottom: 22px;
    right: 22px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--rose-primary);
    font-size: 1.1rem;
    box-shadow: 0 6px 22px rgba(183, 28, 28, 0.14);
    cursor: pointer;
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.9);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.music-btn:hover {
    transform: scale(1.07);
}

.music-btn.playing {
    box-shadow: 0 0 0 6px rgba(255, 75, 110, 0.16), 0 6px 20px rgba(255, 75, 110, 0.3);
}

.modal-hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

#celebration-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.86) 0%, rgba(253, 240, 244, 0.92) 100%);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 14px;
    padding: 20px;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

#celebration-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.celebration-glass-card {
    position: relative;
    width: 100%;
    max-width: 500px;
    padding: 48px 34px 40px;
    text-align: center;
    border-radius: 26px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.6));
    border: 1px solid rgba(255, 255, 255, 1);
    box-shadow:
        0 40px 80px rgba(255, 75, 110, 0.18),
        inset 0 0 40px rgba(255, 255, 255, 0.85);
    transform: translateY(30px) scale(0.95);
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#celebration-overlay.visible .celebration-glass-card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.close-celebration {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 75, 110, 0.22);
    background: rgba(255, 255, 255, 0.85);
    color: var(--berry-dark);
    font-size: 0.95rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.close-celebration:hover {
    background: #fff0f4;
    transform: scale(1.08);
}

.celebration-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.9rem, 6vw, 2.4rem);
    background: linear-gradient(45deg, #b71c1c, #ff4b6e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 15px;
    font-weight: 700;
    line-height: 1.2;
    opacity: 1;
    transform: none;
}

.celebration-divider {
    width: 50px;
    height: 3px;
    background: rgba(255, 75, 110, 0.4);
    margin: 0 auto 22px auto;
    border-radius: 5px;
}

#celebration-text {
    font-family: 'Quicksand', sans-serif;
    font-size: 1.1rem;
    color: #554248;
    line-height: 1.75;
    margin-bottom: 24px;
    font-weight: 500;
    max-height: 42vh;
    overflow-y: auto;
    padding-right: 8px;
    text-align: center;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.celebration-credit {
    color: #795463;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
}

.final-heart {
    font-size: 2.8rem;
    color: var(--rose-primary);
    filter: drop-shadow(0 0 15px rgba(255, 75, 110, 0.5));
    animation: heartbeat 1.5s infinite;
}

/* =========================================
   12. SHARED KEYFRAMES & RESPONSIVE QUERIES
   ========================================= */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
    60% { transform: translateY(-3px); }
}

@keyframes heartPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.32); }
    100% { transform: scale(1); }
}

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

@media (max-width: 640px) {
    

    .timeline-container::before,
    .timeline-container::after {
        left: 20px;
    }

    .timeline-card {
        width: 100%;
        padding-left: 48px;
        padding-right: 8px;
    }

    .timeline-card.left,
    .timeline-card.right {
        text-align: left;
        left: 0;
        transform: translateX(30px) rotate(2deg);
    }

    .timeline-card.in-view {
        transform: translateX(0) rotate(0deg);
    }

    .timeline-card::after,
    .timeline-card.right::after {
        left: 20px;
        transform: translateX(-50%);
    }

    .gallery-grid {
        --gallery-columns: 2;
        --gallery-gap: 14px;
    }

    .gallery-card {
        height: 220px;
    }
}

@media (max-width: 450px) {
    #love-timer {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
}

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



/* =========================================
   MINIMAL PIN LOCK
   ========================================= */

#gift-content[hidden],
#access-screen[hidden],
#access-screen [hidden] {
    display: none !important;
}

#gift-content {
    overflow-x: clip;
}

body:has(#access-screen:not([hidden])) {
    overflow: hidden;
}

#demo-label {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
    z-index: 100;
    padding: 8px 12px;
    border-radius: 999px;
    background: #7c2346;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    pointer-events: none;
}

.pin-lock {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    background: linear-gradient(
        135deg,
        #fff5f7 0%,
        #fce4ec 100%
    );
}

.pin-wrapper {
    width: 100%;
    max-width: 360px;
    text-align: center;
    animation: pinAppear 0.7s ease both;
}

.pin-kicker {
    display: inline-block;
    padding: 6px 15px;
    margin-bottom: 22px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 75, 110, 0.22);
    color: #d81b60;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.pin-heart {
    margin-bottom: 16px;
    color: var(--rose-primary);
    font-size: 2rem;
}

.pin-lock h1 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 6vw, 2.6rem);
    font-weight: 600;
    color: var(--berry-dark);
    margin-bottom: 10px;
    text-shadow: none;
}

.pin-subtitle {
    color: #7d626b;
    font-size: 0.88rem;
    line-height: 1.6;
    margin-bottom: 28px;
}

.pin-card {
    padding: 26px 24px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.92);
    box-shadow: 0 12px 35px rgba(183, 28, 28, 0.07);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.pin-label {
    display: block;
    margin-bottom: 14px;
    color: #8a6c75;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 1.8px;
    text-transform: uppercase;
}

.pin-input {
    display: block;
    width: 100%;
    height: 58px;
    padding: 0 12px;
    border: 1px solid rgba(255, 75, 110, 0.2);
    border-radius: 14px;
    outline: none;
    background: rgba(255, 255, 255, 0.88);
    color: var(--berry-dark);
    text-align: center;
    font-family: 'Quicksand', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 12px;
    -webkit-user-select: text;
    user-select: text;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.pin-input::placeholder {
    color: #d8b5c1;
}

.pin-input:focus {
    border-color: var(--rose-primary);
    box-shadow: 0 0 0 4px rgba(255, 75, 110, 0.09);
}

.pin-input[aria-invalid="true"] {
    border-color: #d81b60;
}

.pin-error {
    min-height: 18px;
    margin: 9px 0 12px;
    color: #c62850;
    font-size: 0.76rem;
    font-weight: 600;
}

.pin-submit {
    width: 100%;
    min-height: 48px;
    padding: 13px 18px;
    border: none;
    border-radius: 30px;
    background: linear-gradient(135deg, #ff4b6e, #e91e63);
    color: white;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.25s, box-shadow 0.25s;
}

.pin-submit i {
    margin-left: 7px;
    font-size: 0.76rem;
}

.pin-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(255, 75, 110, 0.25);
}

.pin-submit:active {
    transform: scale(0.98);
}

.pin-submit:focus-visible {
    outline: 3px solid #880e4f;
    outline-offset: 3px;
}

.pin-footer {
    margin-top: 25px;
    color: #a47a87;
    font-size: 0.76rem;
    letter-spacing: 0.5px;
}

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

@media (max-width: 450px) {
    .pin-lock {
        padding: 20px;
    }

    .pin-card {
        padding: 22px 20px;
    }
}
