/* ==========================================
   DESIGN SYSTEM & THEME VARIABLES
   ========================================== */
:root {
    --bg-gradient: linear-gradient(135deg, #12072b 0%, #2b1154 50%, #0a0318 100%);
    --text-white: #ffffff;
    --accent-purple: #c084fc;
    --accent-purple-light: #e9d5ff;
    --accent-purple-dark: #7e22ce;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    
    /* Heart Key Fill Colors */
    --key-fill: rgba(216, 180, 254, 0.12);      /* Soft semi-trans lavender */
    --key-fill-hover: rgba(244, 114, 182, 0.35); /* Glowing rose pink */
    --key-fill-pressed: rgba(167, 139, 250, 0.6);/* Vivid lilac */
    
    --polaroid-shadow: 0 15px 35px rgba(0, 0, 0, 0.35);
    --btn-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    --btn-hover-shadow: 0 8px 22px rgba(192, 132, 252, 0.35);
    
    --cute-font: 'Fredoka', 'Quicksand', sans-serif;
    --title-font: 'Outfit', sans-serif;
    --handwriting-font: 'Caveat', cursive;
}

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

/* ── Global pointer-events safety guard ──────────────────────────────────────
   CSS pointer-events:none on a parent does NOT cascade to children with their
   default pointer-events:auto. A child element inside a hidden z-index:90
   screen can silently eat clicks meant for elements on lower z-index screens.
   This rule cascades none to EVERY descendant of each hidden screen wrapper,
   removing all ghost-click traps in one shot.
   ─────────────────────────────────────────────────────────────────────────── */
.birthday-screen-wrapper:not(.show) *,
.wish-screen-wrapper:not(.show) *,
.gallery-screen-wrapper:not(.show) *,
.letter-screen-wrapper:not(.show) * {
    pointer-events: none !important;
}


body {
    background: var(--bg-gradient);
    font-family: var(--cute-font);
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    color: var(--text-white);
}

/* Floating Particles Background */
.hearts-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.heart-particle {
    position: absolute;
    bottom: -60px;
    opacity: 0.5;
    animation: floatUp 7s linear infinite;
    user-select: none;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) rotate(0deg) scale(0.7);
        opacity: 0;
    }
    10% {
        opacity: 0.5;
    }
    90% {
        opacity: 0.5;
    }
    100% {
        transform: translateY(-110vh) rotate(360deg) scale(1.3);
        opacity: 0;
    }
}

/* ==========================================
   PAGE 1: PASSCODE PROTECTION GATE
   ========================================== */

.main-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 7vw;
    width: 95%;
    max-width: 1100px;
    height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    margin: auto;
    z-index: 10;
    padding: 20px;
    overflow: hidden;
}

/* Polaroid Wrapper (Left Side) */
.polaroid-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 420px;
}

.polaroid-card {
    background-color: #ffffff;
    padding: 16px 16px 45px 16px;
    border-radius: 4px;
    box-shadow: var(--polaroid-shadow);
    transform: rotate(-3deg);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.polaroid-card:hover {
    transform: rotate(-1deg) scale(1.02);
}

.photo-container {
    width: 100%;
    aspect-ratio: 1.15;
    overflow: hidden;
    border: 1px solid #e9d5ff;
    background-color: #faf5ff;
    border-radius: 2px;
}

.couple-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.polaroid-caption {
    margin-top: 15px;
    font-size: 24px;
    color: #4c1d95;
    font-family: var(--handwriting-font);
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.heart-icon {
    display: inline-block;
    animation: heartbeat 1.5s infinite;
}

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

.ribbon-bow {
    position: absolute;
    top: -25px;
    right: -25px;
    z-index: 15;
    transform: rotate(15deg);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    pointer-events: none;
}

.mascot-butterfly {
    position: absolute;
    bottom: -35px;
    left: -40px;
    z-index: 20;
    pointer-events: none;
    animation: butterflyBreath 4s ease-in-out infinite alternate;
}

@keyframes butterflyBreath {
    0% { transform: scale(1) translateY(0) rotate(-10deg); }
    100% { transform: scale(1.08) translateY(-6px) rotate(5deg); }
}

/* Passcode Inputs & Keyboard */
.passcode-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 400px;
    text-align: center;
}

.passcode-title {
    font-family: var(--title-font);
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 25px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
    color: var(--accent-purple-light);
}

.dots-container {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 35px;
    transition: transform 0.1s ease;
}

.dot-box {
    width: 50px;
    height: 50px;
    border: 3px solid var(--accent-purple-light);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dot-box.filled {
    background-color: var(--accent-purple-light);
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent-purple);
}

.dot-box.filled::after {
    content: "💜";
    font-size: 1.5rem;
}

.keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px 25px;
    margin-bottom: 35px;
    width: 100%;
    max-width: 290px;
}

/* HEART SHAPED BUTTONS STYLING */
.key-btn {
    position: relative;
    background: none;
    border: none;
    width: 75px;
    height: 75px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    user-select: none;
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.key-btn:hover {
    transform: scale(1.12);
}

.key-btn:active, .key-btn.pressed {
    transform: scale(0.92);
}

.key-btn .heart-svg {
    position: absolute;
    width: 100%;
    height: 100%;
    fill: var(--key-fill);
    stroke: var(--accent-purple-light);
    stroke-width: 1.5;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.25));
    transition: fill 0.2s, stroke 0.2s, filter 0.2s;
    pointer-events: none; /* Let clicks pass through to parent <button> */
}

.key-btn:hover .heart-svg {
    fill: var(--key-fill-hover);
    stroke: #ffffff;
    filter: drop-shadow(0 0 10px rgba(244, 114, 182, 0.5));
}

.key-btn:active .heart-svg, .key-btn.pressed .heart-svg {
    fill: var(--key-fill-pressed);
    stroke: #ffffff;
    filter: drop-shadow(0 0 14px rgba(167, 139, 250, 0.6));
}

.key-btn .key-text {
    position: relative;
    z-index: 2;
    font-family: var(--title-font);
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-white);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    margin-top: -4px; /* Center inside the top bulb of the heart */
    pointer-events: none; /* Let clicks pass through to parent <button> */
}

/* Shake/Error Feedback */
.shake {
    animation: shakeAnim 0.4s ease-in-out;
}

@keyframes shakeAnim {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

.dot-box.error {
    border-color: #f87171;
    background-color: rgba(239, 68, 68, 0.25);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.passcode-hint {
    font-size: 1.05rem;
    font-style: italic;
    opacity: 0.8;
    letter-spacing: 0.5px;
    margin-top: 10px;
    color: var(--accent-purple-light);
}

/* ==========================================
   PAGE 2: BIRTHDAY CELEBRATION (BALLOON POP)
   ========================================== */

.birthday-screen-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #2e1065 0%, #12072b 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
}

.birthday-screen-wrapper.show {
    opacity: 1;
    pointer-events: auto;
}

.birthday-inner {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 550px;
    padding: 20px;
    text-align: center;
    z-index: 5;
}

.birthday-gif {
    width: 260px;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    border: 4px solid var(--accent-purple-light);
    margin-bottom: 25px;
}

.celebration-heading {
    font-family: var(--title-font);
    font-size: 2.8rem;
    color: #ffffff;
    text-shadow: 0 0 20px rgba(192, 132, 252, 0.8);
    margin-bottom: 10px;
}

.celebration-subheading {
    font-size: 1.2rem;
    color: var(--accent-purple-light);
    opacity: 0.9;
}

/* Balloon Physics CSS */
.balloons-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none; /* OFF by default — the full-screen z-index:90 stacking context
                             would otherwise swallow ALL clicks on the page, killing keypad
                             and blow button. Only enable when the screen is actually visible. */
    z-index: 2;
}

/* Only allow balloon interactions when the birthday screen is shown */
.birthday-screen-wrapper.show .balloons-container {
    pointer-events: auto;
}

.balloon {
    position: absolute;
    bottom: -100px;
    width: 55px;
    height: 70px;
    border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
    cursor: pointer;
    animation: floatUpBalloon 9s linear forwards;
    box-shadow: inset -6px -10px 15px rgba(0,0,0,0.15), 0 5px 15px rgba(0,0,0,0.25);
    user-select: none;
}

.balloon::after {
    content: "";
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 7px solid currentColor;
}

.balloon-string {
    position: absolute;
    bottom: -45px;
    left: 50%;
    transform: translateX(-50%);
    width: 1.5px;
    height: 45px;
    background-color: rgba(255,255,255,0.4);
}

@keyframes floatUpBalloon {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg);
    }
    50% {
        transform: translateY(-55vh) translateX(15px) rotate(5deg);
    }
    100% {
        transform: translateY(-115vh) translateX(-15px) rotate(-5deg);
    }
}

/* Balloon Popping States */
.balloon.popped {
    animation: none !important;
    transform: scale(1.4) !important;
    opacity: 0 !important;
    transition: transform 0.1s ease-out, opacity 0.1s ease-out !important;
    pointer-events: none;
}

/* Pop Ripple Effect */
.pop-ripple {
    position: absolute;
    border: 3px solid var(--accent-purple-light);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0);
    animation: rippleEffect 0.35s ease-out forwards;
    z-index: 25;
}

@keyframes rippleEffect {
    0% {
        width: 10px;
        height: 10px;
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.1);
    }
    100% {
        width: 130px;
        height: 130px;
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* Balloon pop confetti particles */
.pop-particle {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 20;
}

/* NEXT Button */
.next-btn {
    position: fixed;
    bottom: 40px;
    right: 40px;
    background-color: var(--accent-purple-light);
    color: var(--accent-purple-dark);
    border: none;
    border-radius: 50px;
    padding: 12px 35px;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--cute-font);
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: var(--btn-shadow);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 95;
    outline: none;
    border: 2px solid rgba(255,255,255,0.25);
    /* CRITICAL: CSS pointer-events:none on a parent does NOT cascade to children
       with their default pointer-events:auto. So a .next-btn inside a hidden
       z-index:90 screen silently intercepts all page clicks. Disable by default. */
    pointer-events: none;
}

/* Only re-enable each NEXT button when its own parent screen is actually visible */
.birthday-screen-wrapper.show .next-btn {
    pointer-events: auto;
}

.gallery-screen-wrapper.show .next-btn {
    pointer-events: auto;
}

/* .wish-next-btn is controlled by its own .show class (see below) */

.next-btn:hover {
    transform: scale(1.08);
    background-color: #ffffff;
    box-shadow: var(--btn-hover-shadow);
}

.next-btn:active {
    transform: scale(0.95);
}

/* ==========================================
   PAGE 3: MAKE A WISH SCREEN (CAKE & TIMER)
   ========================================== */

.wish-screen-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-gradient);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 85;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
    color: var(--text-white);
    text-align: center;
    overflow-y: auto;
    padding: 30px 15px;
}

.wish-screen-wrapper.show {
    opacity: 1;
    pointer-events: auto;
}

.wish-title {
    font-family: var(--title-font);
    font-size: 2.6rem;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: 0.5px;
    transition: opacity 0.8s ease, transform 0.8s ease;
    transform: translateY(0);
    opacity: 1;
    color: var(--accent-purple-light);
    text-shadow: 0 0 10px rgba(192, 132, 252, 0.4);
}

.wish-title.fade-out {
    opacity: 0;
    transform: translateY(-15px);
}

.cake-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 25px;
    transition: transform 0.3s ease;
}

.cake-container:hover {
    transform: scale(1.02);
}

/* Sparkles animation */
.sparkle {
    animation: sparkleShimmer 2.5s infinite ease-in-out;
    transform-origin: center;
}

.sparkle:nth-child(2) { animation-delay: 0.8s; }
.sparkle:nth-child(3) { animation-delay: 1.5s; }

@keyframes sparkleShimmer {
    0%, 100% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); opacity: 0.95; }
}

/* SVG Flame flickering */
.flame {
    animation: flameFlicker 0.15s infinite alternate ease-in-out;
    transform-origin: 50% 90%;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.flame-inner {
    animation: flameFlicker 0.1s infinite alternate-reverse ease-in-out;
    transform-origin: 50% 90%;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

@keyframes flameFlicker {
    0% { transform: scale(1) rotate(-2deg); }
    100% { transform: scale(1.08) rotate(3deg) skewX(2deg); }
}

/* Blow effects on flame */
.flame.blowing, .flame-inner.blowing {
    animation: none !important;
    transform: scaleX(0.6) scaleY(0.4) rotate(35deg) translate(14px, -10px) !important;
    transform-origin: 50% 90% !important;
    transition: transform 0.15s ease !important;
}

.flame.extinguished, .flame-inner.extinguished {
    transform: scale(0) translateY(-10px) !important;
    opacity: 0 !important;
}

/* Wind overlay stream */
.wind-gust {
    position: absolute;
    height: 8px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(233, 213, 255, 0.7) 30%, rgba(233, 213, 255, 0.8) 70%, rgba(255, 255, 255, 0) 100%);
    border-radius: 10px;
    opacity: 0;
    pointer-events: none;
    z-index: 15;
    filter: blur(1.5px);
    width: 140px;
}

@keyframes blowWind {
    0% {
        left: -160px;
        opacity: 0;
        transform: scaleY(1.3) skewX(-25deg);
    }
    15% {
        opacity: 0.8;
    }
    85% {
        opacity: 0.8;
    }
    100% {
        left: calc(100% + 60px);
        opacity: 0;
        transform: scaleY(0.3) skewX(-25deg) translateY(-12px);
    }
}

/* Candle rising smoke */
.smoke-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background-color: rgba(220, 220, 220, 0.65);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
}

/* BLOW Button */
.blow-btn {
    background-color: var(--accent-purple-dark);
    color: var(--text-white);
    border: none;
    border-radius: 50px;
    padding: 12px 55px;
    font-size: 1.3rem;
    font-weight: 700;
    font-family: var(--cute-font);
    cursor: pointer;
    box-shadow: var(--btn-shadow);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 95;
    outline: none;
    border: 2px solid rgba(255,255,255,0.1);
}

.blow-btn:hover {
    transform: scale(1.08);
    background-color: #6b21a8;
    box-shadow: 0 6px 20px rgba(126, 34, 206, 0.4);
}

.blow-btn:active {
    transform: scale(0.95);
}

.blow-btn.hide {
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
    display: none;
}

/* Live Lifetime Counter (Glassmorphism layout) */
.timer-container {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 100%;
    max-width: 520px;
    display: none;
}

.timer-container.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    margin-top: 15px;
    display: block;
}

.timer-label {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--accent-purple-light);
}

.timer-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    width: 100%;
}

.timer-box {
    background-color: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 14px;
    padding: 10px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.timer-num {
    font-family: var(--title-font);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-white);
    line-height: 1.2;
}

.timer-unit {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-purple-light);
    margin-top: 2px;
}

/* Next button bottom-right on Wish screen */
.wish-next-btn {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.wish-next-btn.show {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

/* ==========================================
   PAGE 4: PHOTO GALLERY SECTION
   ========================================== */

.gallery-screen-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-gradient);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 82;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
    overflow-y: auto;
    padding: 40px 20px;
}

.gallery-screen-wrapper.show {
    opacity: 1;
    pointer-events: auto;
}

.gallery-title {
    font-family: var(--title-font);
    font-size: 2.6rem;
    color: var(--accent-purple-light);
    text-shadow: 0 0 15px rgba(192, 132, 252, 0.5);
    margin-bottom: 5px;
    text-align: center;
}

.gallery-subtitle {
    font-size: 1.1rem;
    color: #ffffff;
    opacity: 0.8;
    margin-bottom: 30px;
    text-align: center;
}

/* Polaroid Collage Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 35px;
    width: 100%;
    max-width: 720px;
    z-index: 5;
    margin-bottom: 60px;
}

.polaroid-card-gallery {
    background-color: #ffffff;
    padding: 12px 12px 35px 12px;
    border-radius: 4px;
    box-shadow: var(--polaroid-shadow);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.2), box-shadow 0.3s ease;
    max-width: 250px;
    width: 100%;
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Scatter Polaroid layout */
.polaroid-card-gallery:nth-child(1) { transform: rotate(-4deg); }
.polaroid-card-gallery:nth-child(2) { transform: rotate(3deg); }
.polaroid-card-gallery:nth-child(3) { transform: rotate(-2deg); }
.polaroid-card-gallery:nth-child(4) { transform: rotate(5deg); }

.polaroid-card-gallery:hover {
    transform: scale(1.08) rotate(0deg) !important;
    box-shadow: 0 18px 40px rgba(192, 132, 252, 0.35);
    z-index: 10;
}

.polaroid-card-gallery .photo-container {
    aspect-ratio: 1; /* Square images look perfect in gallery */
    border: 1px solid #e2e8f0;
}

.polaroid-card-gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: filter 0.3s ease;
}

.polaroid-card-gallery:hover img {
    filter: brightness(1.03);
}

.polaroid-card-gallery .polaroid-caption {
    margin-top: 10px;
    font-size: 19px;
    color: #5b21b6;
    font-family: var(--handwriting-font);
}

/* Premium Lightbox Modal */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(10, 3, 24, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    padding: 20px;
}

.lightbox-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-content {
    position: relative;
    max-width: 520px;
    width: 100%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.15);
}

.lightbox-overlay.show .lightbox-content {
    transform: scale(1);
}

.lightbox-content img {
    max-width: 100%;
    max-height: 65vh;
    border-radius: 6px;
    box-shadow: 0 15px 45px rgba(0,0,0,0.6);
    border: 8px solid #ffffff;
    object-fit: contain;
}

.lightbox-quote {
    margin-top: 20px;
    font-family: var(--handwriting-font);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-purple-light);
    text-shadow: 0 2px 6px rgba(0,0,0,0.4);
    padding: 0 10px;
    line-height: 1.3;
}

.lightbox-close {
    position: absolute;
    top: -45px;
    right: 0;
    color: #ffffff;
    font-size: 2.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    user-select: none;
}

.lightbox-close:hover {
    color: var(--accent-purple);
    transform: scale(1.1);
}

/* ==========================================
   PAGE 5: SCRAPBOOK CARD LAYOUT (LETTER)
   ========================================== */

.letter-screen-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #583c74; /* Soft elegant dark orchid/grape base */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 80;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
    overflow: hidden;
}

.letter-screen-wrapper.show {
    opacity: 1;
    pointer-events: auto;
}

.scrapbook-card {
    position: relative;
    width: 90%;
    max-width: 440px;
    height: 84vh;
    max-height: 620px;
    z-index: 5;
    transform: translateY(35px) scale(0.95);
    opacity: 0;
    transition: transform 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 1.2s ease;
}

.letter-screen-wrapper.show .scrapbook-card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.torn-paper-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.pink-bow-decor {
    position: absolute;
    top: -22px;
    left: -22px;
    z-index: 10;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.25));
    transform: scale(0) rotate(-45deg);
    transition: transform 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.3s;
}

.letter-screen-wrapper.show .pink-bow-decor {
    transform: scale(1) rotate(0deg);
}

.letter-content {
    position: relative;
    z-index: 5;
    padding: 60px 35px 35px 35px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.title-brush-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 25px;
}

/* Premium brush paint stroke */
.brush-stroke {
    position: relative;
    background: linear-gradient(90deg, rgba(167, 139, 250, 0) 0%, rgba(167, 139, 250, 0.28) 15%, rgba(167, 139, 250, 0.28) 85%, rgba(167, 139, 250, 0) 100%);
    padding: 8px 45px;
    border-radius: 4px;
    transform: scaleX(0.8);
    opacity: 0;
    transition: transform 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 1.2s ease;
}

.letter-screen-wrapper.show .brush-stroke {
    transform: scaleX(1);
    opacity: 1;
    transition-delay: 0.4s;
}

.pink-butterfly {
    position: absolute;
    left: -5px;
    top: -12px;
    z-index: 15;
    animation: butterflyFloat 3s infinite ease-in-out alternate;
    transform-origin: center;
}

@keyframes butterflyFloat {
    0% { transform: translateY(0) rotate(-5deg) scale(1); }
    100% { transform: translateY(-4px) rotate(5deg) scale(1.05); }
}

.letter-heading {
    font-family: 'Pacifico', cursive;
    color: #2e1065;
    font-size: 2rem;
    font-weight: 400;
    text-shadow: 0 1px 1px rgba(255,255,255,0.6);
    white-space: nowrap;
}

.letter-body-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.letter-text {
    font-family: var(--handwriting-font);
    color: #3b1764;
    font-size: clamp(1.3rem, 2.7vh, 1.7rem);
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    letter-spacing: 0.1px;
}

/* Staggered word animation styles */
.letter-word {
    display: inline-block;
    margin-right: 0.23em;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.15), transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.15);
}

.letter-screen-wrapper.show .letter-word {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.hibiscus-decor {
    position: absolute;
    bottom: -22px;
    right: -22px;
    z-index: 10;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.22));
    transform: scale(0) rotate(-45deg);
    transition: transform 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.5s;
}

.letter-screen-wrapper.show .hibiscus-decor {
    transform: scale(1) rotate(0deg);
}

/* Play Again / Restart Button */
.restart-btn {
    position: fixed;
    bottom: 35px;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: #ffffff;
    border: 2px solid rgba(255,255,255,0.25);
    border-radius: 50px;
    padding: 13px 38px;
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--cute-font);
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 6px 25px rgba(124, 58, 237, 0.5);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: nowrap;
    z-index: 95;
    outline: none;
    /* OFF by default — the letter screen is z-index:80 but still wraps clickable content.
       Disable until the letter screen is actually visible. */
    pointer-events: none;
    opacity: 0;
}

.restart-btn-icon {
    pointer-events: none;
}

/* Reveal + enable when letter screen shows (with a slight delay so letter text animates first) */
.letter-screen-wrapper.show .restart-btn {
    pointer-events: auto;
    opacity: 1;
    transform: translateX(-50%) scale(1);
    transition-delay: 1.2s;
}

.restart-btn:hover {
    background: linear-gradient(135deg, #6d28d9, #9333ea);
    box-shadow: 0 10px 35px rgba(124, 58, 237, 0.7);
    transform: translateX(-50%) scale(1.08);
}

.restart-btn:active {
    transform: translateX(-50%) scale(0.96);
}

/* ==========================================
   MUSIC TOGGLE FLOATING BUTTON
   ========================================== */
.music-toggle-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-white);
    font-size: 1.4rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 200;
    outline: none;
    user-select: none;
}

.music-toggle-btn:hover {
    transform: scale(1.12);
    background-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 6px 16px rgba(192, 132, 252, 0.4);
}

.music-toggle-btn.playing {
    animation: musicPulse 1.8s infinite ease-in-out alternate;
}

@keyframes musicPulse {
    0% { transform: scale(1) rotate(0deg); box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
    100% { transform: scale(1.08) rotate(15deg); box-shadow: 0 0 18px rgba(192, 132, 252, 0.5); }
}

.music-toggle-btn:active {
    transform: scale(0.92);
}

/* ==========================================
   RESPONSIVE DESIGN SYSTEM
   ========================================== */

@media (max-width: 850px) {
    .main-container {
        flex-direction: column;
        gap: 3vh;
        padding: 15px;
        justify-content: space-around;
        height: 100dvh;
    }
    
    .polaroid-wrapper {
        max-width: min(260px, 32vh);
    }

    .polaroid-card {
        padding: 10px 10px 30px 10px;
    }

    .polaroid-caption {
        margin-top: 6px;
        font-size: 18px;
    }

    .mascot-butterfly {
        width: 32px;
        bottom: -20px;
        left: -20px;
    }
    
    .ribbon-bow {
        top: -15px;
        right: -15px;
    }

    .ribbon-bow svg {
        width: 60px;
        height: 60px;
    }
    
    .passcode-wrapper {
        max-height: 52vh;
        width: 100%;
    }

    .passcode-title {
        font-size: 1.5rem;
        margin-bottom: 12px;
    }

    .dots-container {
        margin-bottom: 15px;
        gap: 12px;
    }

    .dot-box {
        width: 38px;
        height: 38px;
        border-width: 2px;
        border-radius: 10px;
    }

    .dot-box.filled::after {
        font-size: 1.2rem;
    }

    .keypad-grid {
        gap: 10px 18px;
        max-width: 220px;
        margin-bottom: 15px;
    }

    .key-btn {
        width: 55px;
        height: 55px;
    }

    .key-btn .key-text {
        font-size: 1.35rem;
        margin-top: -3px;
    }

    .next-btn {
        bottom: 25px;
        right: 25px;
        padding: 10px 28px;
        font-size: 1rem;
    }

    .celebration-heading {
        font-size: 2.1rem;
    }

    .celebration-subheading {
        font-size: 1rem;
    }

    .birthday-gif {
        width: 200px;
    }

    .wish-title {
        font-size: 1.8rem;
    }

    #cakeSvg {
        width: min(240px, 35vh);
        height: min(240px, 35vh);
    }

    .timer-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .timer-box {
        padding: 8px 4px;
        border-radius: 10px;
    }

    .timer-num {
        font-size: 1.3rem;
    }

    /* Gallery Mobile */
    .gallery-title {
        font-size: 1.8rem;
    }

    .gallery-subtitle {
        font-size: 0.95rem;
        margin-bottom: 15px;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        max-height: 60vh;
        overflow-y: auto;
        padding: 10px;
        margin-bottom: 50px;
    }

    .polaroid-card-gallery {
        max-width: 200px;
        padding: 10px 10px 25px 10px;
    }

    .polaroid-card-gallery .polaroid-caption {
        font-size: 16px;
    }

    .lightbox-content img {
        max-height: 50vh;
        border-width: 4px;
    }

    .lightbox-quote {
        font-size: 1.4rem;
    }

    /* Letter Mobile */
    .scrapbook-card {
        width: 90%;
        max-width: 375px;
        height: 82vh;
        max-height: 540px;
    }
    
    .letter-content {
        padding: 40px 20px 20px 20px;
    }

    .title-brush-wrapper {
        margin-bottom: 12px;
    }

    .letter-heading {
        font-size: clamp(1.2rem, 3vh, 1.5rem);
    }

    .brush-stroke {
        padding: 4px 25px;
    }

    .letter-body-container {
        gap: 2px;
    }

    .letter-text {
        font-size: clamp(1rem, 2.6vh, 1.3rem);
        line-height: 1.3;
    }
    
    .hibiscus-decor {
        bottom: -15px;
        right: -15px;
    }

    .hibiscus-decor svg {
        width: 70px;
        height: 70px;
    }
    
    .pink-bow-decor {
        top: -15px;
        left: -15px;
    }

    .pink-bow-decor svg {
        width: 70px;
        height: 70px;
    }

    .music-toggle-btn {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}
