/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    /* Prevents the 'pull-to-refresh' and bounce effect */
    overscroll-behavior-y: none; 
    /* Ensures the container is exactly the visible height */
    height: 100dvh; 
    width: 100vw;
    overflow: hidden;
}

body {
    /* Cozy Background: Deep Burgundy/Brown Gradient */
    background: linear-gradient(135deg, #4d0000 0%, #6e2020 50%, #4d0000 100%);
    font-family: 'Mountains of Christmas', cursive; 
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; 
    color: #f7f7f7; /* Soft off-white text color */
    padding: 20px;
    /* Disables Safari's bounce and pull-to-refresh */
    overscroll-behavior: none; 
    /* Prevents accidental text selection which can cause UI jumps */
    -webkit-user-select: none;
}

/* --- STORY CONTAINER (Cozy Glassmorphism frame) --- */
.story-container {
    width: 100%;
    height: 100%;
    max-width: 450px; 
    max-height: 90%; 
    position: relative;
    border-radius: 25px; 
    overflow: hidden;
    /* Muted Glassmorphism Effect */
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px); 
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
    /* Warm Bronze/Cream Border */
    border: 3px solid #dac49f; 
}

/* Slideshow Styling */
.slideshow-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.mySlides {
    display: none;
    width: 100%;
    height: 100%;
    overflow: hidden; 
}

img {
    vertical-align: middle;
    width: 100%;
    height: 100%;
    object-fit: cover; 
    filter: brightness(0.8) saturate(0.9); 
    
    transform: scale(1) rotate(0deg);
    transition: all 5s ease-out; 
}

/* Image Motion Animation */
.mySlides.active img {
    transform: scale(1.04) rotate(0.5deg); 
}

/* Caption Text (MOVED TO BOTTOM) */
.text {
    color: #f7f7f7; /* Soft off-white text */
    font-size: 1.3rem; 
    padding: 12px 20px; 
    position: absolute;
    bottom: 100px; /* NEW POSITION: Moved from top 70px */
    left: 50%; /* Center horizontally */
    transform: translateX(-50%); /* Center horizontally */
    white-space: nowrap; /* Keep text on one line if possible */
    
    /* Deep Muted Red Background */
    background: rgba(85, 0, 0, 0.9); 
    border-radius: 25px; 
    font-weight: 700;
    text-shadow: 1px 1px 2px #000;
    border: 1px solid rgba(255, 255, 255, 0.2); 
    
    /* Text Animation Properties */
    opacity: 0;
    transform: translateY(100px) translateX(-50%); /* Adjusted for new position */
    animation-fill-mode: forwards;
}

/* Text Entrance Animation */
.mySlides.active .text {
    /* Adjusted transform property in the keyframe to keep it centered */
    animation: text-pop-in 0.8s ease-out 0.5s 1 forwards; 
}

/* Updated Keyframe to center the text properly */
@keyframes text-pop-in {
    0% { 
        opacity: 0; 
        transform: translateY(100px) translateX(-50%) scale(0.9);
    }
    100% { 
        opacity: 1; 
        transform: translateY(0) translateX(-50%) scale(1);
    }
}


/* Story Progress Bar (Muted Cream/Bronze) */
.progress-bar-container {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 5px; 
    display: flex;
    gap: 4px;
    z-index: 20;
    border-radius: 3px;
}

.progress-bar {
    flex-grow: 1;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: #dac49f; 
    transition: width 0.1s linear; 
}

.progress-bar.completed .progress-bar-fill {
    width: 100%;
}

/* Navigation Tap Zones (No visual change needed) */
.nav-tap-zone {
    position: absolute;
    top: 0;
    height: 100%;
    z-index: 15;
    cursor: pointer;
}

.nav-tap-zone.prev {
    left: 0;
    width: 30%; 
}

.nav-tap-zone.next {
    right: 0;
    width: 70%; 
}

/* Romantic Message Overlay (The Ending Story Slide) */
.story-message-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: transparent; /* MODIFIED: Set to transparent */
    z-index: 10;
    opacity: 0; 
    transition: opacity 0.3s ease-in-out; 
    padding: 20px;
}

.story-message-overlay p {
    font-family: 'Great Vibes', cursive;
    font-size: 4rem; 
    font-weight: 700;
    color: #dac49f; 
    margin-bottom: 20px;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 1);
    line-height: 1.5;
}

.story-message-overlay .subtitle {
    font-size: 1.7rem; 
    color: #f7f7f7; 
    opacity: 0.9;
    font-family: 'Mountains of Christmas', cursive;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
}

/* --- RESTART BUTTON STYLING --- */
.restart-button {
    margin-top: 40px;
    padding: 12px 25px;
    font-family: 'Mountains of Christmas', cursive;
    font-size: 1.2rem;
    font-weight: 700;
    
    color: #f7f7f7; 
    background-color: #6e2020; 
    
    border: 3px solid #dac49f; 
    border-radius: 50px; 
    cursor: pointer;
    
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.7);
}

.restart-button:hover {
    background-color: #883333; 
    transform: translateY(-2px); 
}


/* --- FALLING SNOW --- */
.snowflake {
    position: absolute;
    top: -10px;
    color: #f7f7f7; 
    font-size: 1em;
    user-select: none;
    z-index: 18;
    animation-name: snow-fall;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

@keyframes snow-fall {
    0% { transform: translateY(0); }
    100% { transform: translateY(95vh); }
}

#snow-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 90%; 
    overflow: hidden; 
    pointer-events: none;
    z-index: 18;
    will-change: transform; 
}

/* --- PAUSE/PLAY BUTTON STYLING --- */
#pausePlayBtn {
    position: absolute;
    top: 25px; /* MOVED DOWN: Added 10px spacing below progress bar (which is at top: 10px) */
    right: 20px; /* MOVED RIGHT: Positioned on the right side */
    z-index: 25; 
    width: 35px;
    height: 35px;
    background: rgba(85, 0, 0, 0.9); /* Deep Muted Red */
    color: #f7f7f7; /* Soft Off-White */
    border: 2px solid #dac49f; /* Warm Bronze/Cream Border */
    border-radius: 50%; /* Circle shape */
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease;
}

#pausePlayBtn:hover {
    background: #6e2020; /* Slightly darker Muted Red on hover */
}

/* --- LANDING SLIDE STYLING --- */
#landingSlide {
    /* Ensure the landing slide has a high z-index when active */
    z-index: 100;
    /* Ensure it covers the full container */
    width: 100%;
    height: 100%;
    /* Must maintain position relative for the text to position absolutely against it */
    position: relative; 
}

#landingSlide img {
    /* Keep the image dark and cozy */
    filter: brightness(0.6) saturate(0.9);
}

.landing-text {
    /* MODIFIED: Using Flexbox for centering within the container */
    position: relative; /* Keep relative position */
    top: 50%;
    transform: translateY(-50%);
    
    /* NEW: Flexbox layout for internal content centering */
    display: flex;
    flex-direction: column;
    align-items: center; /* Center horizontally */
    justify-content: center; /* Center vertically (if needed) */
    
    text-align: center;
    width: 90%;
    margin: 0 auto; /* Center the entire block horizontally */
}

.landing-text .title-text {
    font-family: 'Great Vibes', cursive;
    font-size: 3.8rem;
    color: #dac49f; /* Warm Bronze */
    margin-bottom: 10px;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 1);
}

.landing-text .subtitle-text {
    font-size: 1.7rem; 
    color: #f7f7f7; 
    opacity: 0.9;
    font-family: 'Mountains of Christmas', cursive;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
}

/* --- PASSWORD SCREEN --- */
#password-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 110; 
    background: rgba(45, 0, 0, 0.95); 
    
    /* These three lines handle the centering */
    display: flex;
    justify-content: center;
    align-items: center;
}

#password-overlay .landing-text {
    /* Resetting the absolute positioning from your general landing-text class */
    position: static; 
    transform: none;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#passwordInput {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #dac49f;
    border-radius: 15px;
    padding: 12px;
    color: #f7f7f7;
    font-family: 'Mountains of Christmas', cursive;
    font-size: 1.5rem;
    text-align: center;
    margin: 20px 0;
    width: 80%;
    max-width: 300px; /* Prevents it from being too wide on landscape */
    outline: none;
    transition: border-color 0.3s;
}