body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: #0f2027;
    background: linear-gradient(to right, #2c5364, #203a43, #0f2027);
}

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    z-index: 1;
}

.animation-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 15px 25px;
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 18px;
}

.control-btn {
    background: #2c3e50;
    color: #ecf0f1;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 18px;
    cursor: pointer;
    transition: 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: #1a252f;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.6);
}

.play-btn {
    width: 55px;
    height: 55px;
    font-size: 24px;
    background: #e74c3c;
    transition: all 0.3s;
}

.play-btn:hover {
    background: #c0392b;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.speed-btn {
    background: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: 0.3s ease;
}

.speed-btn:hover {
    background: #2980b9;
}

.year-display {
    font-size: 22px;
    font-weight: 600;
    min-width: 120px;
    text-align: center;
    color: #fff;
}

.progress-container {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    z-index: 1000;
}

.progress-bar {
    height: 10px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #9b59b6);
    width: 0%;
    transition: width 0.4s ease;
}

.timeline-container {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 12px;
    display: flex;
    gap: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.timeline-marker {
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    color: #ffffff;
    background: transparent;
    min-width: 50px;
    text-align: center;
    transition: all 0.3s;
    font-weight: 500;
}

.timeline-marker:hover {
    background: #3498db;
    color: white;
}

.timeline-marker.active {
    background: #2c3e50;
    color: #fff;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

.pulse-effect {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    100% {
        opacity: 0.6;
        transform: scale(1);
    }
}

.glow-border {
    filter: drop-shadow(0 0 10px rgba(52, 152, 219, 0.8));
    transition: filter 0.5s ease;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 15, 0.8);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 24px;
    flex-direction: column;
}

.spinner {
    border: 6px solid #f3f3f3;
    border-top: 6px solid #3498db;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* --- Language Switcher: Desktop & Mobile --- */
.language-switcher {
    display: flex;
    gap: 8px;
    box-shadow: 0 4px 24px rgba(58, 134, 255, 0.13);
    border-radius: 24px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.90);
    backdrop-filter: blur(8px);
    border: 1.5px solid rgba(58, 134, 255, 0.10);
    align-items: center;
    z-index: 3000;
    min-width: 100px;
    max-width: 160px;
    width: auto;
    justify-content: center;
}

.lang-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    text-align: center;
    border: none;
    border-radius: 16px;
    padding: 7px 14px;
    font-weight: 700;
    font-size: 15px;
    background: transparent;
    color: #2c3e50;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, box-shadow 0.18s, transform 0.18s;
    min-width: 40px;
    max-width: 80px;
    letter-spacing: 0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lang-btn.active {
    background: linear-gradient(90deg, #3a86ff, #8338ec);
    color: #fff;
    box-shadow: 0 2px 12px rgba(58, 134, 255, 0.18);
    transform: scale(1.08);
}

/* --- Main Page Button (back-btn-inline) --- */
.back-btn-inline {
    min-width: 130px !important;
    padding: 8px 24px !important;
    font-size: 15px !important;
    border-radius: 20px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    line-height: 1.2;
}

.back-btn-text {
    display: inline !important;
}

@media (max-width: 600px) {
    .language-switcher {
        min-width: 80px;
        max-width: 120px;
        padding: 2px 6px;
    }

    .lang-btn {
        font-size: 13px;
        padding: 5px 8px;
        min-width: 32px;
        max-width: 60px;
    }

    .back-btn-inline {
        min-width: 110px !important;
        padding: 7px 12px !important;
        font-size: 13px !important;
    }
}

.leaflet-interactive {
    transition: stroke-opacity 0.5s ease, fill-opacity 0.5s ease;
}

.leaflet-interactive:focus {
    outline: none;
}

/* Mobile: Fit-content bottom bar */
@media (max-width: 600px) {
    .animation-controls {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        z-index: 2000;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        background: #ffffff;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        padding: 10px 8px;
        gap: 10px;
    }

    .control-btn,
    .play-btn,
    .back-btn-inline {
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
        border-radius: 10px !important;
    }

    .speed-control {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .speed-btn {
        font-size: 13px;
        padding: 5px 10px;
        border-radius: 6px;
    }

    .year-display {
        font-size: 16px;
        color: #2c3e50;
        min-width: auto;
    }

    .language-switcher {
        position: fixed;
        right: 18px;
        bottom: 90px;
        width: 56px;
        min-width: 56px;
        max-width: 56px;
        padding: 2px 3px;
        border-radius: 14px;
        gap: 1px;
        font-size: 10px;
        background: linear-gradient(135deg, #fff 80%, #f3f6fa 100%);
        box-shadow: 0 2px 6px rgba(44, 83, 100, 0.08);
        border: 1px solid #e0e0e0;
        display: flex;
        align-items: center;
        z-index: 3000;
    }

    .lang-btn {
        font-size: 10px;
        padding: 3px 0;
        border-radius: 8px;
        min-width: 0;
        font-weight: 700;
        background: transparent;
        color: #2c3e50;
        border: none;
        outline: none;
        flex: 1 1 0;
        text-align: center;
        transition: background 0.18s, color 0.18s, box-shadow 0.18s, transform 0.18s;
        box-shadow: none;
        letter-spacing: 0.5px;
    }

    .lang-btn.active {
        background: linear-gradient(90deg, #3a86ff, #8338ec);
        color: #fff;
        box-shadow: 0 1px 6px rgba(58, 134, 255, 0.12);
        transform: scale(1.08);
        z-index: 1;
    }

    .lang-btn:not(.active):hover {
        background: rgba(58, 134, 255, 0.10);
        color: #3a86ff;
        transform: scale(1.04);
    }

    .back-btn-inline {
        position: fixed;
        bottom: 120px;
        left: 15px;
        width: 70px !important;
        height: 35px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
        background: linear-gradient(135deg, #3a86ff, #8338ec);
        color: #fff;
        padding: 0;
        gap: 0;
        z-index: 2000;
        box-shadow: 0 2px 8px rgba(58, 134, 255, 0.2);
    }

    .back-btn-text {
        display: none !important;
    }

    .leaflet-control-zoom,
    .leaflet-control-layers {
        display: none !important;
    }

    .timeline-container {
        position: absolute;
        top: 8px;
        left: 45%;
        transform: translateX(-50%);
        width: 90vw;
        max-width: 400px;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        padding: 8px 12px;
        font-size: 13px;
        gap: 6px;
        border-radius: 12px;
        box-sizing: border-box;
        display: flex;
        flex-wrap: nowrap;
        justify-content: flex-start;
        align-items: center;
        margin: 0 auto;
        text-align: center;
        background: rgba(255, 255, 255, 0.2);
        backdrop-filter: blur(12px);
        border: 1px solid rgba(255, 255, 255, 0.3);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
        scrollbar-width: thin;
        scrollbar-color: #3a86ff #e0e0e0;
        position: relative;
    }

    .timeline-container::before {
        content: '‹';
        position: absolute;
        left: 4px;
        top: 50%;
        transform: translateY(-50%);
        color: #3a86ff;
        font-size: 16px;
        z-index: 10;
        pointer-events: none;
        opacity: 0.7;
    }

    .timeline-container::after {
        content: '›';
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
        color: #3a86ff;
        font-size: 16px;
        z-index: 10;
        pointer-events: none;
        opacity: 0.7;
    }

    .timeline-marker {
        font-size: 11px;
        padding: 4px 10px;
        min-width: 35px;
        max-width: 80px;
        display: inline-block;
        white-space: nowrap;
        margin: 0 3px;
        border-radius: 6px;
        background: rgba(255, 255, 255, 0.15);
        color: #fff;
        font-weight: 500;
        transition: all 0.2s ease;
        cursor: pointer;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        flex-shrink: 0;
    }

    .timeline-marker:hover {
        background: #3498db !important;
        color: white !important;
        transform: scale(1.05) !important;
        box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3) !important;
    }

    .timeline-marker.active {
        background: #3a86ff;
        color: #fff;
        box-shadow: 0 2px 8px rgba(58, 134, 255, 0.4);
    }

    .timeline-container::-webkit-scrollbar {
        height: 4px;
        background: transparent;
    }

    .timeline-container::-webkit-scrollbar-thumb {
        background: #3a86ff;
        border-radius: 2px;
    }
}

@media (min-width: 601px) {
    #map {
        padding-top: 50px;
        box-sizing: border-box;
    }

    .timeline-container {
        position: absolute;
        top: 14px;
        left: 50%;
        transform: translateX(-50%);

        z-index: 1000;
        background: rgba(255, 255, 255, 0.15);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);

        will-change: transform, width, max-width;
        padding: 7px 12px;

        border-radius: 11px;
        display: flex;
        align-items: center;
        gap: 5px;
        font-size: 13px;

        overflow-x: scroll; 
        overflow-y: hidden;
        white-space: nowrap;
        min-width: 0;

        max-width: calc(100vw - 290px); 
        width: fit-content; 
        width: -moz-fit-content; 
        min-width: 200px; 

        box-sizing: border-box;
        scrollbar-width: none;
        -ms-overflow-style: none; 
        cursor: grab; 
    }
    .timeline-container::-webkit-scrollbar {
        display: none;
    }

    .timeline-container.is-dragging {
        cursor: grabbing; 
    }

    .timeline-marker {
        font-size: 14px;
        padding: 2.5px 8px;
        min-width: 26px;
        max-width: 85px;
        display: inline-block;
        white-space: nowrap;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        flex-shrink: 0;
        user-select: none;
    }
}

@media (max-width: 600px) {
    .timeline-container {
        overflow-x: scroll;
        overflow-y: hidden;
        white-space: nowrap;
        scrollbar-width: none;
        -ms-overflow-style: none;
        cursor: grab;
        padding: 7px 12px;
        max-width: calc(100% - 30px);
        left: 50%;
        transform: translateX(-50%);
    }

    .timeline-container::-webkit-scrollbar {
        display: none;
    }

    .timeline-container.is-dragging {
        cursor: grabbing;
    }

    .timeline-marker {
        user-select: none;
    }
}