body,
html {
    overflow: hidden;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    font-family: 'Lekton', sans-serif;
    background-color: #ffffff;
    /* pure white background overall */
}

/* MapLibre reset */
.maplibregl-map {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-family: "Lekton", sans-serif !important;
}

/* Main Layout Setup */
.container {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: 100%;
}

.top-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    z-index: 2000;
}

.top-controls span {
    color: #252e6b;
    font-size: 18px;
    margin-right: 15px;
    font-weight: 400;
}

/* Custom Dropdown Styles */
.custom-select-wrapper {
    position: relative;
    display: inline-block;
    font-family: 'Lekton', monospace;
    font-size: 20px;
    color: #252e6b;
    z-index: 1000;
}

.custom-select-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 25px 2px 10px;
    font-weight: 400;
    cursor: pointer;
    border-bottom: 2px solid #252e6b;
    background: url("data:image/svg+xml;utf8,<svg viewBox='0 0 140 140' width='20' height='20' xmlns='http://www.w3.org/2000/svg'><g><polyline points='0,40 50,100 100,40' fill='none' stroke='rgb(37,46,107)' stroke-width='12px'/></g></svg>") no-repeat right 5px center;
    background-size: 14px;
    min-width: 260px;
    transition: all 150ms ease;
    text-align: center;
    box-sizing: border-box;
    white-space: nowrap;
    line-height: 1.4;
}

.trigger-text {
    position: absolute;
    left: 10px;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
}

.longest-option-ghost {
    visibility: hidden;
    pointer-events: none;
}

.custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    margin-top: 5px;
    background: #ffffff;
    border: 2px solid #252e6b;
    display: none;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    box-sizing: border-box;
}

.custom-select-wrapper.open .custom-select-options {
    display: flex;
}

.custom-option {
    padding: 10px 20px;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
    background: #ffffff;
    white-space: nowrap;
}

.custom-option:hover {
    background: #e6e6e6;
}

.custom-option.selected {
    background: #f0f0f0;
}

.container-map {
    flex-grow: 1;
    position: relative;
    /* important so absolute children stick here */
}

#maplibre-map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    background-color: #ffffff;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

#maplibre-map.loaded {
    opacity: 1;
}

.sidebar-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: 10px;
    z-index: 10;
    max-height: calc(100% - 140px);
}


/* Legend */
.event-counter {
    text-shadow: none;
    pointer-events: none;
    user-select: none;
    display: inline-flex;
    flex-direction: column;
}

.event-counter.legend {
    background: #252E6B;
    color: #ffd500;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    position: relative;
    top: auto;
    left: auto;
    width: 300px;
    /* Increased to fit labels */
    pointer-events: auto;
    /* Enable interaction */
}

.event-counter.legend .counter-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.event-counter.legend .counter-item:hover {
    opacity: 0.8;
}

.event-counter.legend .counter-item.inactive {
    opacity: 0.3;
}

.event-counter.legend .counter-item:last-child {
    margin-bottom: 0;
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
}

.legend-label {
    flex-grow: 1;
    margin-right: 8px;
    color: #ffd500;
    white-space: normal;
    /* Allow wrapping or full display */
    word-break: break-word;
}

.event-counter.legend .counter-item-value {
    text-align: right;
    font-weight: 500;
    font-size: 14px;
    min-width: 35px;
    /* Fixed space for numbers */
    flex-shrink: 0;
}

/* Map Title and Subtitle */
.map-title {
    pointer-events: none;
    text-align: center;
    margin: 0;
    padding: 16px 0 9px 0;
    /* Increased by 5px from 4px */
    font-family: "Lekton", sans-serif;
    font-weight: 400;
    font-size: clamp(18px, 4vw, 24px);
    letter-spacing: 0.5px;
    background: #fff;
    color: #252E6B;
    z-index: 1000;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transform: translateZ(0);
    position: relative;
}

.map-subtitle {
    font-family: "Lekton", sans-serif;
    text-align: center;
    margin: 0;
    padding: 0 0 16px 0;
    font-size: clamp(14px, 3vw, 19px);
    letter-spacing: 0.5px;
    color: #252E6B;
    background: #fff;
    font-weight: 300;
    z-index: 1000;
    position: relative;
    /* Force hardware acceleration and clean rendering to prevent accent glitches on Mac */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transform: translateZ(0);
}

/* MapLibre Tooltip Styles */
.mapboxgl-popup {
    z-index: 1000;
    filter: url(#dropshadow-1000) !important;
    overflow: visible !important;
}

.mapboxgl-popup-content {
    padding: 15px 20px !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    background: #fff !important;
    font-family: 'Source Sans Pro', sans-serif !important;
    font-size: 14px !important;
    color: #333 !important;
    pointer-events: none;
    line-height: 1.1;
    border: none !important;
}

.mapboxgl-popup-tip {
    border-top-color: #fff !important;
    border-bottom-color: #fff !important;
}

.mapboxgl-popup-content strong {
    font-weight: 700;
    color: #444;
}

.mapboxgl-popup-close-button {
    display: none;
}

/* ========================================== */
/* Mobile Responsiveness                      */
/* ========================================== */
@media (max-width: 768px) {
    .top-controls span {
        font-size: 16px !important;
    }

    .custom-select-wrapper {
        font-size: 15px !important;
        min-width: 0 !important;
    }

    .custom-select-trigger {
        min-width: 0 !important;
        padding: 2px 25px 2px 10px;
    }

    .custom-option {
        font-size: 15px !important;
    }

    .event-counter.legend {
        width: 160px;
        padding: 8px 12px;
        font-size: 11px;
    }

    .sidebar-controls {
        top: 10px;
        left: 10px;
    }
}