* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

:root {
    --warm-cream: #FFF5E8;
    --soft-peach: #FFD4B8;
    --warm-coral: #FFB4A2;
    --gentle-rose: #FFCAD4;
    --soft-lavender: #E8C4E0;
    --warm-gold: #F4D58D;
}

body {
    font-family: 'Quicksand', sans-serif;
    background: linear-gradient(135deg, var(--warm-cream) 0%, var(--soft-peach) 50%, var(--gentle-rose) 100%);
    min-height: 100vh;
}

/* Page container - FIXED */
.page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.6s ease, visibility 0.6s ease;
    overflow: hidden;
    display: none;
}

.page.active {
    opacity: 1;
    visibility: visible;
    display: flex;
    z-index: 10;
}

/* Opening Photo Mosaic Page - FIXED LAYOUT */
.photo-mosaic-page {
    padding: 0;
    position: relative;
}

/* Magical floating particles background */
.floating-hearts {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.heart {
    position: absolute;
    font-size: 20px;
    opacity: 0.3;
    animation: floatUp 8s infinite ease-in-out;
}

@keyframes floatUp {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.3;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

/* Photo Grid Container - FIXED */
.photo-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    grid-auto-rows: minmax(150px, 1fr);
    gap: 12px;
    padding: 20px;
    z-index: 2;
}

.photo-item {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 15px rgba(255, 180, 162, 0.3);
    animation: fadeInPhoto 0.8s ease-out backwards;
}

.photo-item:hover {
    transform: scale(1.15) translateY(-10px);
    box-shadow: 0 20px 40px rgba(255, 138, 174, 0.5);
    z-index: 50;
    border-radius: 20px;
}

@keyframes fadeInPhoto {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Different sizes for mosaic effect - FIXED */
.photo-item:nth-child(1) { grid-column: span 2; grid-row: span 2; }
.photo-item:nth-child(2) { grid-column: span 1; grid-row: span 2; }
.photo-item:nth-child(3) { grid-column: span 2; grid-row: span 1; }
.photo-item:nth-child(4) { grid-column: span 1; grid-row: span 2; }
.photo-item:nth-child(5) { grid-column: span 1; grid-row: span 1; }
.photo-item:nth-child(6) { grid-column: span 1; grid-row: span 1; }
.photo-item:nth-child(7) { grid-column: span 1; grid-row: span 2; }
.photo-item:nth-child(8) { grid-column: span 2; grid-row: span 1; }
.photo-item:nth-child(9) { grid-column: span 1; grid-row: span 1; }
.photo-item:nth-child(10) { grid-column: span 2; grid-row: span 1; }
.photo-item:nth-child(11) { grid-column: span 1; grid-row: span 1; }
.photo-item:nth-child(12) { grid-column: span 1; grid-row: span 1; }
.photo-item:nth-child(13) { grid-column: span 2; grid-row: span 1; }
.photo-item:nth-child(14) { grid-column: span 1; grid-row: span 1; }
.photo-item:nth-child(15) { grid-column: span 1; grid-row: span 1; }
.photo-item:nth-child(16) { grid-column: span 2; grid-row: span 1; }
.photo-item:nth-child(17) { grid-column: span 1; grid-row: span 1; }
.photo-item:nth-child(18) { grid-column: span 1; grid-row: span 1; }

.photo-item .photo-content {
    width: 100%;
    height: 100%;
    transition: transform 0.5s ease;
}

.photo-item:hover {
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 12px 35px rgba(255, 180, 162, 0.5);
    z-index: 10;
}

.photo-item:hover .photo-content {
    transform: scale(1.1);
}

/* Gentle floating animation */
.photo-item:nth-child(odd) {
    animation: fadeInPhoto 0.8s ease-out backwards, gentleFloat 4s ease-in-out infinite;
}

.photo-item:nth-child(even) {
    animation: fadeInPhoto 0.8s ease-out backwards, gentleFloat 4s ease-in-out infinite 1s;
}

@keyframes gentleFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-8px);
    }
}

/* Stagger animation delays */
.photo-item:nth-child(1) { animation-delay: 0s; }
.photo-item:nth-child(2) { animation-delay: 0.1s; }
.photo-item:nth-child(3) { animation-delay: 0.2s; }
.photo-item:nth-child(4) { animation-delay: 0.3s; }
.photo-item:nth-child(5) { animation-delay: 0.4s; }
.photo-item:nth-child(6) { animation-delay: 0.5s; }
.photo-item:nth-child(7) { animation-delay: 0.6s; }
.photo-item:nth-child(8) { animation-delay: 0.7s; }
.photo-item:nth-child(9) { animation-delay: 0.8s; }
.photo-item:nth-child(10) { animation-delay: 0.9s; }
.photo-item:nth-child(n+11) { animation-delay: 1s; }

/* Center Button Container - FIXED */
.center-button-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    text-align: center;
}

/* Glowing backdrop for button */
.button-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(255, 212, 184, 0.4) 40%, transparent 70%);
    border-radius: 50%;
    filter: blur(40px);
    animation: pulseGlow 3s ease-in-out infinite;
    z-index: -1;
}

@keyframes pulseGlow {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
}

.start-button {
    background: linear-gradient(135deg, #FFB4A2 0%, #FFCAD4 100%);
    border: none;
    padding: 22px 55px;
    font-size: 28px;
    font-weight: 600;
    font-family: 'Caveat', cursive;
    color: #fff;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(255, 180, 162, 0.5);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    letter-spacing: 1px;
    animation: fadeInButton 1.2s ease-out 1.2s backwards;
}

@keyframes fadeInButton {
    from {
        opacity: 0;
        transform: scale(0.5) translateY(30px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.start-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.start-button:hover::before {
    width: 300px;
    height: 300px;
}

.start-button:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 15px 45px rgba(255, 180, 162, 0.7);
}

.start-button:active {
    transform: scale(1.05) translateY(-2px);
}

/* Sparkles around button */
.sparkle {
    position: absolute;
    font-size: 16px;
    animation: sparkleFloat 2s ease-in-out infinite;
    pointer-events: none;
}

.sparkle:nth-child(1) {
    top: -30px;
    left: -30px;
    animation-delay: 0s;
}

.sparkle:nth-child(2) {
    top: -35px;
    right: -25px;
    animation-delay: 0.5s;
}

.sparkle:nth-child(3) {
    bottom: -30px;
    left: -25px;
    animation-delay: 1s;
}

.sparkle:nth-child(4) {
    bottom: -35px;
    right: -30px;
    animation-delay: 1.5s;
}

@keyframes sparkleFloat {
    0%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    50% {
        transform: translateY(-10px) scale(1.2);
        opacity: 1;
    }
}

/* === ELEGANT PAGE TRANSITION === */
.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, rgba(255, 245, 232, 0.95) 0%, rgba(255, 212, 184, 0.95) 50%, rgba(255, 202, 212, 0.95) 100%);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.page-transition.active {
    opacity: 1;
}

/* Floating transition hearts */
.transition-heart {
    position: absolute;
    font-size: 40px;
    opacity: 0;
    animation: transitionHeartFloat 2s ease-out;
}

@keyframes transitionHeartFloat {
    0% {
        opacity: 0;
        transform: translateY(100vh) scale(0.5) rotate(0deg);
    }
    50% {
        opacity: 0.8;
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(1.5) rotate(360deg);
    }
}

/* === WELCOME PAGE === */
.welcome-page {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.welcome-content {
    max-width: 700px;
    text-align: center;
    background: rgba(255, 255, 255, 0.85);
    padding: 60px 50px;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(255, 180, 162, 0.3);
    backdrop-filter: blur(10px);
    animation: welcomeFadeIn 1s ease-out;
    position: relative;
    overflow: hidden;
    z-index: 10;
}

/* Faded hearts pattern on welcome - BIGGER */
.welcome-content::before {
    content: '💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-size: 45px;
    opacity: 0.12;
    word-spacing: 15px;
    line-height: 90px;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

/* Additional gradient hearts */
.welcome-content::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle, rgba(255, 202, 212, 0.18) 12%, transparent 12%),
        radial-gradient(circle, rgba(255, 180, 162, 0.12) 18%, transparent 18%);
    background-size: 70px 70px, 100px 100px;
    background-position: 0 0, 50px 50px;
    z-index: 0;
    pointer-events: none;
}

.welcome-content > * {
    position: relative;
    z-index: 1;
}

@keyframes welcomeFadeIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.welcome-title {
    font-family: 'Pacifico', cursive;
    font-size: 48px;
    color: #FF8AAE;
    margin-bottom: 30px;
    line-height: 1.3;
    text-shadow: 2px 2px 4px rgba(255, 138, 174, 0.2);
}

.welcome-message {
    font-size: 20px;
    line-height: 1.8;
    color: #555;
    margin-bottom: 40px;
    font-weight: 400;
}

.continue-button {
    background: linear-gradient(135deg, #FFB4A2 0%, #FFCAD4 100%);
    border: none;
    padding: 18px 45px;
    font-size: 22px;
    font-weight: 600;
    font-family: 'Caveat', cursive;
    color: #fff;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(255, 180, 162, 0.4);
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

.continue-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(255, 180, 162, 0.6);
}

.continue-button:active {
    transform: translateY(-1px);
}

/* Decorative elements on welcome page */
.welcome-decor {
    position: absolute;
    font-size: 40px;
    opacity: 0.3;
    animation: floatDecor 4s ease-in-out infinite;
}

.welcome-decor:nth-child(1) {
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.welcome-decor:nth-child(2) {
    top: 15%;
    right: 12%;
    animation-delay: 1s;
}

.welcome-decor:nth-child(3) {
    bottom: 15%;
    left: 15%;
    animation-delay: 2s;
}

.welcome-decor:nth-child(4) {
    bottom: 20%;
    right: 10%;
    animation-delay: 1.5s;
}

@keyframes floatDecor {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-20px) rotate(10deg);
    }
}

/* === CAKE GAME PAGE === */
.cake-game-page {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: 600px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(255, 180, 162, 0.3);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: welcomeFadeIn 1s ease-out;
    overflow: hidden;
    z-index: 10;
}

/* Faded hearts pattern background - BIGGER AND MORE VISIBLE */
.game-container::before {
    content: '💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-size: 50px;
    opacity: 0.15;
    word-spacing: 20px;
    line-height: 100px;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
}

/* Additional gradient hearts layer */
.game-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle, rgba(255, 202, 212, 0.2) 15%, transparent 15%),
        radial-gradient(circle, rgba(255, 180, 162, 0.15) 20%, transparent 20%),
        radial-gradient(circle, rgba(255, 202, 212, 0.25) 10%, transparent 10%);
    background-size: 80px 80px, 120px 120px, 60px 60px;
    background-position: 0 0, 40px 40px, 60px 20px;
    z-index: 0;
    pointer-events: none;
}

/* Circular character with face */
.blow-character {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, #FFD4B8 0%, #FFCAD4 100%);
    border-radius: 50%;
    border: 4px solid #FF8AAE;
    box-shadow: 0 8px 25px rgba(255, 138, 174, 0.3);
    z-index: 15;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.blow-character > * {
    position: relative;
    z-index: 1;
}

.blow-character.hide {
    opacity: 0;
    transform: translateX(-50%) scale(0.5);
}

/* Character eyes - WIDER SPACING */
.char-eye {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #333;
    border-radius: 50%;
    top: 40px;
}

.char-eye.left {
    left: 25px;
}

.char-eye.right {
    right: 25px;
}

/* Character expressions */
.char-mouth {
    position: absolute;
    width: 30px;
    height: 15px;
    border: 3px solid #FF8AAE;
    border-top: none;
    border-radius: 0 0 30px 30px;
    top: 65px;
    left: 50%;
    transform: translateX(-50%);
    transition: all 0.3s ease;
}

/* Surprised mouth */
.blow-character.surprised .char-mouth {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid #FF8AAE;
    top: 60px;
}

/* Annoyed eyes */
.blow-character.annoyed .char-eye {
    height: 4px;
    border-radius: 2px;
    top: 45px;
}

.blow-character.annoyed .char-mouth {
    border-radius: 30px 30px 0 0;
    border-top: 3px solid #FF8AAE;
    border-bottom: none;
    top: 70px;
}

/* Angry expression */
.blow-character.angry .char-eye {
    height: 3px;
    width: 15px;
    border-radius: 0;
    background: #D32F2F;
}

.blow-character.angry .char-eye.left {
    transform: rotate(-20deg);
}

.blow-character.angry .char-eye.right {
    transform: rotate(20deg);
}

.blow-character.angry .char-mouth {
    width: 40px;
    border-color: #D32F2F;
    border-radius: 30px 30px 0 0;
    border-top: 3px solid #D32F2F;
    border-bottom: none;
}

/* Happy expression */
.blow-character.happy .char-mouth {
    width: 40px;
    height: 20px;
}

/* Wind animation - blows from character to cake */
.wind-effect {
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translate(-50%, 0);
    font-size: 30px;
    opacity: 0;
    pointer-events: none;
}

.wind-effect.active {
    animation: windBlowTowardsCake 1s ease-out forwards;
}

@keyframes windBlowTowardsCake {
    0% {
        opacity: 0;
        transform: translate(-50%, 0) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, 20px) scale(1);
    }
    40% {
        opacity: 0.9;
        transform: translate(-50%, 80px) scale(1.3) rotate(10deg);
    }
    60% {
        opacity: 0.7;
        transform: translate(-50%, 140px) scale(1.5) rotate(-10deg);
    }
    80% {
        opacity: 0.4;
        transform: translate(-50%, 200px) scale(1.7) rotate(5deg);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, 250px) scale(2);
    }
}

/* Birthday Cake with Details - SMALLER AND LOWER */
.birthday-cake {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    cursor: default;
}

.cake-base {
    position: relative;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #FFA07A 0%, #FF8C69 100%);
    border-radius: 12px 12px 6px 6px;
    box-shadow: 0 6px 15px rgba(255, 140, 105, 0.4);
}

/* Cake layers */
.cake-layer {
    position: absolute;
    width: 100%;
    height: 5px;
    background: #FFE4E1;
    left: 0;
}

.cake-layer:nth-child(1) { top: 18px; }
.cake-layer:nth-child(2) { top: 38px; }
.cake-layer:nth-child(3) { bottom: 18px; }

/* Frosting top */
.frosting {
    position: absolute;
    top: -12px;
    left: 0;
    width: 100%;
    height: 18px;
    background: #FFE4E1;
    border-radius: 50% 50% 0 0;
    box-shadow: 0 -3px 10px rgba(255, 228, 225, 0.5);
}

/* Candles container - centered on top of frosting */
.candles-container {
    position: absolute;
    top: -42px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
}

.candle {
    position: relative;
    width: 6px;
    height: 25px;
    background: linear-gradient(180deg, #FFD700 0%, #FFA500 100%);
    border-radius: 2px 2px 0 0;
    box-shadow: 0 2px 5px rgba(255, 165, 0, 0.3);
}

/* Candle wick */
.wick {
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 1.5px;
    height: 5px;
    background: #333;
}

/* Animated flame */
.flame {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 16px;
    background: radial-gradient(circle, #FFD700 0%, #FF6347 60%, transparent 100%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: flicker 0.3s infinite alternate;
    filter: blur(1px);
}

@keyframes flicker {
    0% {
        transform: translateX(-50%) scale(1) translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) scale(1.1) translateY(-2px);
        opacity: 0.9;
    }
}

/* Flame glow */
.flame::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 20px;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.6) 0%, transparent 70%);
    border-radius: 50%;
    animation: glow 0.4s infinite alternate;
}

@keyframes glow {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Flames blown out */
.flame.out {
    animation: blowOut 0.5s ease-out forwards;
}

@keyframes blowOut {
    0% {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
    50% {
        transform: translateX(-50%) scale(1.3) translateY(-10px);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) scale(0.5) translateY(-20px);
    }
}

/* Smoke after blowing */
.smoke {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    opacity: 0;
}

.smoke.show {
    animation: smokeRise 2s ease-out forwards;
}

@keyframes smokeRise {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(0);
    }
    30% {
        opacity: 0.6;
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-50px);
    }
}

/* Cake dodge animations */
.birthday-cake.dodge-left {
    animation: dodgeLeft 0.6s ease-out;
}

.birthday-cake.dodge-right {
    animation: dodgeRight 0.6s ease-out;
}

.birthday-cake.dodge-up {
    animation: dodgeUp 0.6s ease-out;
}

.birthday-cake.dodge-spin {
    animation: dodgeSpin 0.6s ease-out;
}

@keyframes dodgeLeft {
    0% { transform: translate(-50%, -50%); }
    50% { transform: translate(-200%, -50%) rotate(-20deg) scale(1.1); }
    100% { transform: translate(-150%, -50%); }
}

@keyframes dodgeRight {
    0% { transform: translate(-50%, -50%); }
    50% { transform: translate(100%, -50%) rotate(20deg) scale(1.1); }
    100% { transform: translate(50%, -50%); }
}

@keyframes dodgeUp {
    0% { transform: translate(-50%, -50%); }
    30% { transform: translate(-50%, -200%) rotate(360deg) scale(1.2); }
    60% { transform: translate(20%, -180%) rotate(720deg); }
    100% { transform: translate(-50%, -150%); }
}

@keyframes dodgeSpin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(720deg) scale(0); }
}

/* Candles go out */
.birthday-cake.blown-out {
    animation: blownOut 0.8s ease-out forwards;
}

@keyframes blownOut {
    0% { 
        filter: brightness(1);
        transform: translate(-50%, -50%) scale(1);
    }
    50% { 
        filter: brightness(0.7);
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% { 
        filter: brightness(1);
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Blow button */
.blow-button {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #FFB4A2 0%, #FFCAD4 100%);
    border: none;
    padding: 20px 50px;
    font-size: 32px;
    font-weight: 700;
    font-family: 'Caveat', cursive;
    color: #fff;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(255, 180, 162, 0.4);
    transition: all 0.3s ease;
    z-index: 20;
}

.blow-button:hover {
    transform: translateX(-50%) translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(255, 180, 162, 0.6);
}

.blow-button:active {
    transform: translateX(-50%) translateY(-1px) scale(1.02);
}

/* Success message */
.success-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    text-align: center;
    opacity: 0;
    z-index: 30;
}

.success-message.show {
    animation: successAppear 0.8s ease-out forwards;
}

@keyframes successAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
    60% {
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.success-title {
    font-family: 'Pacifico', cursive;
    font-size: 56px;
    color: #FF8AAE;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(255, 138, 174, 0.3);
}

.success-subtitle {
    font-size: 24px;
    color: #666;
    margin-bottom: 30px;
    font-weight: 500;
}

/* Confetti */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #FFB4A2;
    opacity: 0;
}

.confetti.burst {
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg);
    }
}

/* === LETTER PAGE === */
.letter-page {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.letter-container {
    max-width: 750px;
    width: 100%;
    max-height: 80vh;
    background: rgba(255, 255, 255, 0.9);
    padding: 70px 60px;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(255, 180, 162, 0.25);
    backdrop-filter: blur(10px);
    animation: welcomeFadeIn 1s ease-out;
    position: relative;
    overflow-y: auto;
    z-index: 10;
}

/* Beautiful hearts background for letter - SAME AS OTHER PAGES */
.letter-container::before {
    content: '💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝 💕 💖 💗 💓 💝';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-size: 45px;
    opacity: 0.12;
    word-spacing: 15px;
    line-height: 90px;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

/* Additional gradient hearts for letter */
.letter-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle, rgba(255, 202, 212, 0.18) 12%, transparent 12%),
        radial-gradient(circle, rgba(255, 180, 162, 0.12) 18%, transparent 18%);
    background-size: 70px 70px, 100px 100px;
    background-position: 0 0, 50px 50px;
    z-index: 0;
    pointer-events: none;
}

.letter-container > * {
    position: relative;
    z-index: 1;
}

.letter-text {
    font-size: 19px;
    line-height: 1.9;
    color: #444;
    font-weight: 400;
    letter-spacing: 0.3px;
    white-space: pre-wrap;
    font-family: 'Quicksand', sans-serif;
}

/* Placeholder styling */
.letter-text.placeholder {
    color: #999;
    font-style: italic;
}

.to-gallery-button {
    background: linear-gradient(135deg, #FFB4A2 0%, #FFCAD4 100%);
    border: none;
    padding: 18px 45px;
    font-size: 22px;
    font-weight: 600;
    font-family: 'Caveat', cursive;
    color: #fff;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(255, 180, 162, 0.4);
    transition: all 0.3s ease;
    letter-spacing: 1px;
    margin-top: 50px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.to-gallery-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(255, 180, 162, 0.6);
}

.to-gallery-button:active {
    transform: translateY(-1px);
}

/* === MEMORY BOOK PAGE === */
.memory-book-page {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

/* Closed book */
.book-closed {
    position: relative;
    width: 400px;
    height: 500px;
    background: linear-gradient(135deg, #8B4513 0%, #A0522D 100%);
    border-radius: 10px;
    box-shadow: 
        0 20px 60px rgba(139, 69, 19, 0.4),
        inset 0 2px 10px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease;
    border: 3px solid #654321;
    z-index: 10;
}

.book-closed:hover {
    transform: scale(1.05);
}

.book-cover-title {
    font-family: 'Playfair Display', serif;
    font-size: 42px;
    color: #FFD700;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    font-weight: 700;
}

.book-cover-subtitle {
    font-family: 'Caveat', cursive;
    font-size: 24px;
    color: #FFEFD5;
    text-align: center;
    margin-bottom: 40px;
}

.open-book-button {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border: none;
    padding: 18px 45px;
    font-size: 22px;
    font-weight: 600;
    font-family: 'Caveat', cursive;
    color: #654321;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.4);
    transition: all 0.3s ease;
}

.open-book-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(255, 215, 0, 0.6);
}

/* Book container */
.book-container {
    display: none;
    perspective: 2000px;
    position: relative;
    width: 90vw;
    max-width: 1200px;
    height: 80vh;
    max-height: 700px;
}

.book-container.active {
    display: block;
    animation: bookOpen 1s ease-out;
}

@keyframes bookOpen {
    from {
        opacity: 0;
        transform: scale(0.8) rotateY(-30deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotateY(0deg);
    }
}

/* Book spread (2 pages) */
.book-spread {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    background: #FFFEF9;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    transform-style: preserve-3d;
}

.book-spread.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 10;
}

/* Individual page */
.book-page {
    flex: 1;
    padding: 50px 40px;
    position: relative;
    background: #FFFEF9;
    overflow-y: auto;
}

.book-page.left {
    border-right: 2px solid #E8E8E8;
}

/* Page title */
.page-title {
    font-family: 'Pacifico', cursive;
    font-size: 32px;
    color: #FF8AAE;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 1px 1px 2px rgba(255, 138, 174, 0.2);
}

/* Photo grid on page */
.page-photos {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.photo-placeholder {
    aspect-ratio: 4/3;
    background: linear-gradient(135deg, #FFE4E1 0%, #FFD4E5 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #999;
    font-style: italic;
    border: 2px dashed #FFB4A2;
    transition: transform 0.3s ease;
    background-size: cover;
    background-position: center;
}

.photo-placeholder:hover {
    transform: scale(1.05);
}

/* Final message page */
.final-message {
    padding: 80px 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.final-message-text {
    font-size: 22px;
    line-height: 1.8;
    color: #555;
    font-family: 'Quicksand', sans-serif;
    white-space: pre-wrap;
    margin-bottom: 30px;
}

/* Navigation arrows */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 180, 162, 0.9);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(255, 180, 162, 0.4);
}

.nav-arrow:hover {
    background: rgba(255, 138, 174, 1);
    transform: translateY(-50%) scale(1.1);
}

.nav-arrow.prev {
    left: -70px;
}

.nav-arrow.next {
    right: -70px;
}

.nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Page flip animation - GPU accelerated */
.book-spread {
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.book-spread.page-turn-out {
    animation: pageTurnOut 0.6s cubic-bezier(0.645, 0.045, 0.355, 1) forwards;
}

.book-spread.page-turn-in {
    animation: pageTurnIn 0.6s cubic-bezier(0.645, 0.045, 0.355, 1) forwards;
}

@keyframes pageTurnOut {
    0% {
        opacity: 1;
        transform: translateX(0) rotateY(0deg);
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 0;
        transform: translateX(-100px) rotateY(-20deg);
    }
}

@keyframes pageTurnIn {
    0% {
        opacity: 0;
        transform: translateX(100px) rotateY(20deg);
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
        transform: translateX(0) rotateY(0deg);
    }
}

/* Close book button */
.close-book-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 180, 162, 0.9);
    border: none;
    padding: 12px 30px;
    font-size: 18px;
    font-weight: 600;
    font-family: 'Caveat', cursive;
    color: white;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 200;
}

.close-book-button:hover {
    background: rgba(255, 138, 174, 1);
    transform: scale(1.05);
}

/* Responsive */
@media (max-width: 768px) {
    .photo-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(6, 1fr);
        height: 60vh;
    }

    .photo-item:nth-child(1) { grid-column: span 2; grid-row: span 2; }
    .photo-item:nth-child(2) { grid-column: span 1; grid-row: span 1; }
    .photo-item:nth-child(3) { grid-column: span 1; grid-row: span 1; }
    .photo-item:nth-child(4) { grid-column: span 1; grid-row: span 2; }
    .photo-item:nth-child(5) { grid-column: span 1; grid-row: span 1; }
    .photo-item:nth-child(6) { grid-column: span 1; grid-row: span 1; }
    .photo-item:nth-child(7) { grid-column: span 2; grid-row: span 1; }
    .photo-item:nth-child(8) { grid-column: span 1; grid-row: span 1; }
    .photo-item:nth-child(9) { grid-column: span 1; grid-row: span 1; }
    .photo-item:nth-child(10) { grid-column: span 2; grid-row: span 1; }
    .photo-item:nth-child(n+11) { display: none; }

    .start-button {
        padding: 18px 40px;
        font-size: 24px;
    }

    .button-glow {
        width: 250px;
        height: 250px;
    }

    .game-container {
        height: 500px;
    }

    .blow-character {
        width: 90px;
        height: 90px;
        top: 60px;
    }

    .birthday-cake {
        font-size: 90px;
    }

    .blow-button {
        padding: 16px 40px;
        font-size: 26px;
        bottom: 60px;
    }

    .success-title {
        font-size: 42px;
    }

    .letter-container {
        padding: 50px 35px;
    }

    .letter-text {
        font-size: 17px;
        line-height: 1.8;
    }

    .to-gallery-button {
        padding: 16px 35px;
        font-size: 20px;
    }

    .book-closed {
        width: 300px;
        height: 400px;
    }

    .book-cover-title {
        font-size: 32px;
    }

    .book-cover-subtitle {
        font-size: 20px;
    }

    .book-container {
        width: 95vw;
        height: 70vh;
    }

    .book-page {
        padding: 30px 20px;
    }

    .page-title {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .page-photos {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .nav-arrow {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .nav-arrow.prev {
        left: -50px;
    }

    .nav-arrow.next {
        right: -50px;
    }

    .final-message {
        padding: 40px 30px;
    }

    .final-message-text {
        font-size: 16px;
    }

    .welcome-content {
        padding: 40px 30px;
    }

    .welcome-title {
        font-size: 36px;
    }

    .welcome-message {
        font-size: 18px;
    }

    .continue-button {
        padding: 16px 35px;
        font-size: 20px;
    }
}