* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overscroll-behavior-y: none;
    font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f5f5;
}

#map {
    position: fixed;
    top: 0;
    right: 0;
    width: 60%;
    height: 100vh;
    z-index: 1;
}

.title-section {
    min-height: 100vh;
    width: 100%;
    background: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.6)), 
                url('images/vintage_train.jpg');
    background-size: cover;
    background-position: center;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.title-content {
    max-width: 600px;
}

.title-section h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.title-section .subtitle {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: #e74c3c;
    font-weight: 500;
}

.title-section .intro-text {
    margin-bottom: 2rem;
    line-height: 1.6;
}

.title-section .intro-text p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.title-section .instructions {
    background: rgba(0, 0, 0, 0.5);
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 2rem;
}

.title-section .instructions p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
}

.story-container {
    width: 40%;
    background: white;
    position: relative;
    z-index: 2;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

.story-section {
    min-height: 100vh;
    padding: 3rem;
    opacity: 0.3;
    transition: all 0.5s ease;
    background-color: white;
    border-bottom: 1px solid #eee;
}

.story-section.active {
    opacity: 1;
}

.story-section h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    line-height: 1.2;
    font-weight: 700;
}

.story-section h3 {
    font-size: 1.5rem;
    margin: 2rem 0 1rem;
    color: #34495e;
    font-weight: 600;
}

.story-section h4 {
    font-size: 1.1rem;
    margin: 1rem 0;
    color: #2c3e50;
    font-weight: 600;
}

.timeline-marker {
    display: inline-block;
    padding: 0.3rem 1rem;
    background: #e74c3c;
    color: white;
    border-radius: 20px;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.intro {
    font-size: 1.2rem;
    font-weight: 500;
    color: #34495e;
    margin-bottom: 2rem;
    line-height: 1.6;
    border-left: 4px solid #e74c3c;
    padding-left: 1rem;
}

.key-facts {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin: 2rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.key-facts ul {
    list-style-type: none;
    padding-left: 0;
}

.key-facts li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: #34495e;
}

.key-facts li:before {
    content: "•";
    color: #e74c3c;
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* Progress indicator */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 40%;
    height: 4px;
    background: #e74c3c;
    z-index: 3;
    transform-origin: 0 50%;
    transition: transform 0.2s ease;
}

/* Popup Styles */
.route-popup, .station-popup {
    padding: 10px;
    max-width: 300px;
}

.route-popup h3, .station-popup h3 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 1.2em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

.route-popup p, .station-popup p {
    margin: 5px 0;
    color: #34495e;
}

/* Scrollbar Styles */
.story-container::-webkit-scrollbar {
    width: 8px;
}

.story-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.story-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.story-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Golden Spike and Railgun Styles */
.scrollable-popup .popup-content {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 15px;
}

.golden-spike-popup img, .railgun-popup img {
    border-radius: 8px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    max-width: 100%;
    height: auto;
    transition: transform 0.3s ease;
}

/* Conclusion Section */
.conclusion-section {
    min-height: 80vh;
    width: 100%;
    background-color: #f8f9fa;
    padding: 3rem;
    border-top: 4px solid #e74c3c;
}

.conclusion-content {
    max-width: 800px;
    margin: 0 auto;
}

/* Responsive Design */
@media (max-width: 1024px) {
    #map {
        width: 55%;
    }
    .story-container {
        width: 45%;
    }
    .progress-bar {
        width: 45%;
    }
}

/* Keep all your existing CSS but replace the media query for mobile devices with this: */

@media (max-width: 768px) {
        body {
            overflow-x: hidden;
        }
    
        #map {
            position: fixed;
            width: 100%;
            height: 50vh;
            top: 0;
            left: 0;
            right: 0;
            z-index: 10;  /* Increased z-index */
        }
    
        .progress-bar {
            position: fixed;
            width: 100%;
            top: calc(50vh - 4px);
            left: 0;
            z-index: 11;  /* Higher than map */
            height: 4px;
            background: #e74c3c;
            transform-origin: 0 50%;
        }
    
        .story-container {
            position: relative;  /* Changed to relative */
            width: 100%;
            margin-top: 50vh;   /* Use margin instead of absolute positioning */
            background: white;
            z-index: 1;         /* Lower than map and progress bar */
        }
    
        .story-section {
            min-height: auto;
            padding: 2rem;
            background: white;
        }
    
        .title-section {
            width: 100%;
            margin-top: 0;
            padding: 2rem;
        }
    
    .title-section h1 {
        font-size: 2rem;
    }

    .title-section .subtitle {
        font-size: 1.2rem;
    }

    .progress-bar {
        position: fixed;
        width: 100%;
        top: calc(50vh - 4px);
        left: 0;
        z-index: 3;
    }

    .route-popup, .station-popup {
        max-width: 200px;
    }

    .scrollable-popup .popup-content {
        max-height: 200px;
    }

    .conclusion-section {
        padding: 2rem;
    }

    .conclusion-section h2 {
        font-size: 2rem;
    }

    .conclusion-section h3 {
        font-size: 1.5rem;
    }
}

/* Reference List Styles */
.reference-list {
    list-style: none;
    padding: 0;
}

.reference-list li {
    margin-bottom: 1.5rem;
}

.reference-list a {
    color: #e74c3c;
    text-decoration: none;
    transition: color 0.3s ease;
}

.reference-list a:hover {
    color: #c0392b;
    text-decoration: underline;
}

/* Copyright Section */
.copyright {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #ddd;
    text-align: center;
    color: #666;
}

.disclaimer {
    font-size: 0.9rem;
    margin-top: 0.5rem;
    color: #888;
}

/* Historical Marker Mobile Popup Styles */
@media (max-width: 768px) {
    .golden-spike-popup,
    .railgun-popup {
        width: 220px !important;  /* Force smaller width */
    }

    .golden-spike-popup .leaflet-popup-content,
    .railgun-popup .leaflet-popup-content {
        margin: 8px !important;
        width: auto !important;
    }

    /* Make popup content more compact */
    .golden-spike-popup .popup-text,
    .railgun-popup .popup-text {
        flex: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Simplify popup content structure */
    .golden-spike-popup .scrollable-popup,
    .railgun-popup .scrollable-popup {
        display: block !important;
        max-width: 100% !important;
    }

    /* Adjust image size */
    .golden-spike-popup .popup-image,
    .railgun-popup .popup-image {
        margin: 5px 0 !important;
    }

    .golden-spike-popup img,
    .railgun-popup img {
        max-height: 120px !important;
        width: auto !important;
        margin: 5px auto !important;
    }

    /* Hide less important content */
    .golden-spike-popup p:not(:first-of-type),
    .railgun-popup p:not(:first-of-type),
    .popup-text p[style*="font-size: 0.8em"] {
        display: none !important;
    }

    /* Adjust text sizes */
    .golden-spike-popup h3,
    .railgun-popup h3 {
        font-size: 1em !important;
        margin-bottom: 4px !important;
    }

    .golden-spike-popup p,
    .railgun-popup p {
        font-size: 0.9em !important;
        margin: 2px 0 !important;
    }
}