/* CSS Reset and Base Styles - OPTIMIZED */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #ff6b9d;
    --secondary-color: #ff9a8b;
    --accent-color: #fecfef;
    --text-dark: #4a4a4a;
    --text-light: #6b4e3d;
    --white: #ffffff;
    --shadow-light: rgba(0, 0, 0, 0.08);
    --shadow-medium: rgba(0, 0, 0, 0.12);
    --shadow-heavy: rgba(0, 0, 0, 0.18);
    
    --border-radius: 16px;
    --transition-fast: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    /* --- SMOOTHER SLIDING --- */
    --transition-medium: 0.6s ease-in-out; 
    --transition-slow: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Playfair Display', serif;
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--primary-color) 50%, var(--secondary-color) 100%);
    background-size: 300% 300%;
    animation: gradientShift 15s ease infinite;
    color: var(--text-dark);
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
    line-height: 1.6;
}

/* Optimized Background Animations */
@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.background-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.floating-heart, .floating-star {
    position: absolute;
    opacity: 0.08;
    animation: floatUp linear infinite;
    will-change: transform;
    transform: translateZ(0);
}

.floating-heart {
    width: 20px;
    height: 18px;
    left: calc(var(--random-x, 10%) * 100%);
}

.floating-heart::before,
.floating-heart::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: 10px 10px 0 0;
    transform: rotate(-45deg);
    left: 10px;
}

.floating-heart::after {
    transform: rotate(45deg);
    left: 0;
    border-radius: 10px 0 0 10px;
}

.floating-star {
    width: 12px;
    height: 12px;
    background: var(--white);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    left: calc(var(--random-x-star, 20%) * 100%);
}

@keyframes floatUp {
    0% { transform: translateY(100vh) rotate(0deg) scale(0); opacity: 0; }
    10% { opacity: 0.08; transform: scale(1); }
    90% { opacity: 0.08; }
    100% { transform: translateY(-50px) rotate(360deg) scale(0); opacity: 0; }
}

/* Screen System - Optimized */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 1000;
    padding: 20px;
    transition: opacity var(--transition-slow);
    will-change: opacity;
}

.hidden {
    display: none !important;
}

/* Audio Controls */
.audio-controls {
    position: fixed;
    bottom: 25px;
    right: 25px;
    display: flex;
    gap: 12px;
    z-index: 1001;
    animation: slideInRight 0.6s ease 1.5s both;
}

.audio-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    color: var(--text-dark);
    box-shadow: 0 6px 20px var(--shadow-light);
}

.audio-btn:hover,
.audio-btn.active {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px) scale(1.05);
    border-color: var(--primary-color);
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(60px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Password Screen */
#password-screen { background: rgba(255, 255, 255, 0.95); }
.password-container {
    max-width: 450px;
    width: 90%;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(8px);
    border-radius: var(--border-radius);
    padding: 40px 30px;
    box-shadow: 0 20px 50px var(--shadow-medium);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: fadeInUp 0.8s ease 0.3s both;
}
.password-header { margin-bottom: 35px; }
.password-title { font-family: 'Dancing Script', cursive; font-size: clamp(2.2rem, 4.5vw, 3rem); font-weight: 700; color: var(--primary-color); margin-bottom: 12px; line-height: 1.2; text-shadow: 1px 1px 6px var(--shadow-light); }
.password-subtitle { color: var(--text-dark); font-size: 1em; font-style: italic; opacity: 0.85; }
.password-input { width: 100%; padding: 18px 22px; font-size: 1.2em; font-family: 'Playfair Display', serif; background: rgba(255, 255, 255, 0.9); border: 2px solid transparent; border-radius: 40px; text-align: center; transition: all var(--transition-fast); box-shadow: 0 8px 25px var(--shadow-light); letter-spacing: 0.5px; }
.password-input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 4px rgba(255, 107, 157, 0.2); transform: scale(1.01); background: white; }
.password-hint { min-height: 25px; color: var(--primary-color); font-style: italic; font-size: 1em; margin-bottom: 15px; animation: fadeIn 0.5s ease; }
.password-footer { margin-top: 15px; padding-top: 15px; border-top: 1px solid rgba(255, 107, 157, 0.15); }
.password-footer p { color: var(--text-dark); font-size: 0.95em; opacity: 0.75; font-style: italic; }

/* Main Screen */
#main-screen { background: transparent; }
.main-content { max-width: 550px; width: 90%; text-align: center; animation: fadeInUp 1s ease both; }
.birthday-title { font-family: 'Dancing Script', cursive; font-size: clamp(2.8rem, 7vw, 4.5rem); font-weight: 700; background: linear-gradient(135deg, white 0%, rgba(255, 255, 255, 0.9) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 40px; line-height: 1.1; text-shadow: 0 3px 15px var(--shadow-medium); animation: titlePulse 2.5s ease-in-out infinite 1s; position: relative; }
.birthday-title::after { content: ''; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); width: 80px; height: 3px; background: linear-gradient(90deg, var(--primary-color), var(--secondary-color)); border-radius: 2px; }
@keyframes titlePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.01); } }
.main-card-container { margin: 30px 0; }
.envelope-icon { font-size: clamp(5rem, 12vw, 8rem); cursor: pointer; transition: transform var(--transition-medium), filter var(--transition-medium); display: block; filter: drop-shadow(0 12px 25px rgba(0, 0, 0, 0.15)); }
.envelope-icon:hover { transform: scale(1.08) rotate(3deg); filter: drop-shadow(0 18px 35px rgba(255, 107, 157, 0.25)); }
.main-subtitle { color: white; font-size: 1.2em; margin-top: 25px; font-style: italic; text-shadow: 2px 2px 8px var(--shadow-medium); opacity: 0.95; animation: fadeInUp 0.8s ease 0.6s both; }
.main-footer { margin-top: 35px; animation: fadeInUp 0.8s ease 1s both; }
.main-footer p { color: white; font-size: 1em; font-style: italic; text-shadow: 1px 1px 4px var(--shadow-medium); opacity: 0.9; }

/* Card Screen */
#card-screen { background: rgba(255, 255, 255, 0.95); }
.card-container { max-width: 850px; width: 95%; max-height: 95vh; background: white; border-radius: var(--border-radius); box-shadow: 0 25px 70px var(--shadow-heavy); overflow-y: auto; position: relative; animation: cardSlideIn 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; border: 2px solid rgba(255, 107, 157, 0.15); scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
.close-button { position: sticky; top: 15px; float: right; z-index: 100; background: var(--primary-color); color: white; border: none; border-radius: 50%; width: 40px; height: 40px; font-size: 1.3em; cursor: pointer; transition: all var(--transition-fast); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 15px rgba(255, 107, 157, 0.25); margin: 10px; }
.close-button:hover { background: #ff4d82; transform: scale(1.08) rotate(90deg); }
.card-header { padding: 50px 40px 30px; text-align: center; background: linear-gradient(135deg, rgba(255, 107, 157, 0.04) 0%, rgba(255, 154, 139, 0.04) 100%); border-radius: var(--border-radius) var(--border-radius) 0 0; }
.card-title { font-family: 'Dancing Script', cursive; font-size: clamp(2.2rem, 5.5vw, 3.2rem); font-weight: 700; color: var(--primary-color); margin-bottom: 12px; line-height: 1.2; text-shadow: 1px 1px 8px var(--shadow-light); }
.card-subtitle { color: var(--text-dark); font-size: 1.1em; font-style: italic; opacity: 0.85; font-weight: 400; }
.message-container { padding: 0 40px 30px; max-width: 650px; margin: 0 auto; clear: both; }
.birthday-message { font-size: 1.2em; line-height: 1.7; color: var(--text-dark); margin-bottom: 20px; font-style: italic; animation: fadeInUp 0.8s ease 0.2s both; }
.birthday-message.continuation { font-size: 1.1em; margin-top: 20px; opacity: 0.95; animation: fadeInUp 0.8s ease 0.4s both; }

/* Gallery Styles */
.gallery-container { padding: 0 40px 40px; background: linear-gradient(180deg, rgba(255, 107, 157, 0.02) 0%, transparent 100%); margin-top: 20px; }
.gallery-header { text-align: center; margin-bottom: 40px; padding: 30px 0; }
.gallery-title { font-family: 'Dancing Script', cursive; font-size: 2.2rem; color: var(--primary-color); margin-bottom: 12px; font-weight: 600; }
.gallery-subtitle { color: var(--text-dark); font-size: 1em; font-style: italic; opacity: 0.85; }

.carousel-wrapper { position: relative; max-width: 750px; margin: 0 auto; padding: 0 50px; }
.carousel-container { position: relative; overflow: hidden; border-radius: 12px; box-shadow: 0 12px 35px var(--shadow-medium); background: white; }

.carousel-track {
    display: flex;
    /* --- SMOOTHER SLIDING --- */
    transition: transform var(--transition-medium);
    height: 320px;
    gap: 25px;
    padding: 25px 0;
    box-sizing: content-box;
}

.carousel-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 107, 157, 0.9); color: white; border: none; border-radius: 50%; width: 45px; height: 45px; font-size: 1.6em; cursor: pointer; z-index: 20; transition: all var(--transition-fast); box-shadow: 0 6px 20px rgba(255, 107, 157, 0.25); display: flex; align-items: center; justify-content: center; }
.carousel-btn:hover:not(:disabled) { background: var(--primary-color); transform: translateY(-50%) scale(1.08); }
.carousel-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.prev-btn { left: 8px; }
.next-btn { right: 8px; }

/* Memory Cards (TITLES REMOVED) */
.memory-card { flex: 0 0 260px; height: 100%; position: relative; perspective: 800px; cursor: pointer; border-radius: 10px; box-shadow: 0 8px 25px var(--shadow-light); transform-style: preserve-3d; transition: transform 0.6s ease-in-out, box-shadow 0.3s ease; }
.memory-card:hover { transform: scale(1.015); box-shadow: 0 15px 40px var(--shadow-medium); }
.memory-card.flipped { transform: rotateY(180deg) scale(1.015); }

.memory-front,
.memory-back { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 10px; overflow: hidden; }
.memory-front { display: flex; flex-direction: column; }
.memory-back { background: linear-gradient(135deg, #fff7f7 0%, #fce4ec 100%); transform: rotateY(180deg); }
.memory-image { position: relative; width: 100%; height: 100%; /* Image fills the entire card */ }
.memory-image img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--transition-fast); display: block; }
.memory-card:hover .memory-image img { transform: scale(1.03); }

/* Carousel Indicators */
.carousel-indicators { display: flex; justify-content: center; gap: 10px; margin-top: 35px; padding: 15px 0; flex-wrap: wrap; }
.indicator { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 107, 157, 0.3); cursor: pointer; transition: all var(--transition-fast); }
.indicator.active, .indicator:hover { background: var(--primary-color); transform: scale(1.15); box-shadow: 0 0 8px rgba(255, 107, 157, 0.4); }

/* Card Footer */
.card-footer { padding: 30px 40px 40px; text-align: center; background: linear-gradient(180deg, rgba(255, 107, 157, 0.03) 0%, transparent 100%); border-top: 1px solid rgba(255, 107, 157, 0.08); }
.footer-message { font-size: 1em; color: var(--text-dark); font-style: italic; margin-bottom: 20px; opacity: 0.9; }
.love-signature { margin-top: 25px; }
.love-signature p { font-size: 1em; color: var(--text-dark); line-height: 1.5; }
.signature-name { font-family: 'Dancing Script', cursive; font-size: 1.4em; color: var(--primary-color); font-weight: 700; }

/* Core Animations */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes cardSlideIn { from { opacity: 0; transform: scale(0.9) translateY(30px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* Responsive Design */
@media (max-width: 768px) {
    .screen { padding: 15px; }
    .password-container, .card-container { padding: 25px 20px; margin: 8px; }
    .password-title, .birthday-title, .card-title { font-size: 2.2rem; }
    .carousel-track { height: 280px; gap: 18px; padding: 20px 0; }
    .memory-card { flex: 0 0 220px; }
    .carousel-wrapper { padding: 0 35px; }
    .carousel-btn { width: 40px; height: 40px; font-size: 1.4em; }
    .audio-controls { bottom: 15px; right: 15px; gap: 8px; }
    .audio-btn { width: 42px; height: 42px; font-size: 1em; }
    .gallery-container, .message-container, .card-header, .card-footer { padding-left: 20px; padding-right: 20px; }
    .birthday-message { font-size: 1.05em; line-height: 1.6; }
    .gallery-container { margin-top: 15px; padding-bottom: 30px; }
}

@media (max-width: 480px) {
    .carousel-track { height: 240px; gap: 15px; }
    .memory-card { flex: 0 0 190px; }
    .password-input { padding: 15px 18px; font-size: 1.1em; }
    .card-header { padding: 30px 15px 20px; }
    .message-container { padding: 0 15px 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        animation-delay: 0 !important;
    }
}

