body, html { 
    margin: 0; 
    padding: 0; 
    height: 100%; 
    height: 100dvh;
    font-family: Arial, sans-serif; 
    overflow: hidden; 
}

/* --- GLOBAL THEME VARIABLES --- */
:root {
    --color-dark-green: #006d2c;
    --color-medium-green: #31a354;
    --color-yellow-green: #74c476;
    --color-yellow: #ffffcc;
    --color-orange: #fd8d3c;
    --color-reddish-orange: #f03b20;
    --color-red: #bd0026;
    --color-no-data: #e0e0e0;
    --primary-blue: #3388ff;
    --primary-blue-dark: #2968cc;
    --primary-blue-light: #e6f3ff;
}

#container { 
    display: flex; 
    height: 100vh; 
    height: 100dvh; 
    width: 100vw; 
    overflow: hidden;
    position: relative;
}

/* Landscape mode: Equal split (50/50), Hide Resizer */
@media (orientation: landscape) {
    #map-container { 
        width: 50vw; 
        height: 100vh; 
        height: 100dvh;
        flex-shrink: 0; 
        position: relative;
    }
    #details { 
        width: 50vw; 
        height: 100vh; 
        height: 100dvh;
        padding: 20px; 
        background: #f8f8f8; 
        overflow-y: auto; 
        box-sizing: border-box;
        -webkit-overflow-scrolling: touch;
    }
    #portrait-message { 
        display: none; 
    }
    .panel-resizer-btn {
        display: none !important;
    }
}

/* Portrait mode: Map on top, details below with animated split */
@media (orientation: portrait) {
    #container { 
        flex-direction: column; 
        height: 100vh;
        height: 100dvh;
    }

    #map-container { 
        width: 100vw; 
        height: 60vh; 
        height: 60dvh; 
        flex-shrink: 0; 
        position: relative;
        transition: height 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }
    #details { 
        width: 100vw; 
        height: 40vh; 
        height: 40dvh; 
        flex: 1;
        min-height: 0;
        padding: 14px; 
        padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
        background: #f8f8f8; 
        overflow-y: auto; 
        box-sizing: border-box; 
        -webkit-overflow-scrolling: touch;
        transition: height 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }

    #container.details-expanded #map-container {
        height: 22vh;
        height: 22dvh;
    }
    #container.details-expanded #details {
        height: 78vh;
        height: 78dvh;
    }

    .panel-resizer-btn {
        position: absolute;
        z-index: 1002;
        right: 14px;
        top: 60vh;
        top: 60dvh;
        transform: translateY(-50%);
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background-color: #ffffff;
        border: 1.5px solid var(--primary-blue, #3388ff);
        color: var(--primary-blue, #3388ff);
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        padding: 0;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
        transition: top 0.28s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease, border-color 0.2s ease;
    }

    .panel-resizer-btn::before {
        content: '';
        position: absolute;
        inset: -6px;
        border-radius: 50%;
    }

    .panel-resizer-btn:active {
        transform: translateY(-50%) scale(0.95);
        background-color: var(--primary-blue-light, #e6f3ff);
    }

    .resizer-icon {
        font-size: 17px;
        font-weight: 800;
        line-height: 1;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        display: inline-block;
        pointer-events: none;
    }

    #container.details-expanded .panel-resizer-btn {
        top: 22vh;
        top: 22dvh;
        background-color: #0f172a;
        border-color: #0f172a;
        color: #ffffff;
        box-shadow: 0 4px 12px rgba(15, 23, 42, 0.35);
    }

    #container.details-expanded .resizer-icon {
        transform: rotate(180deg);
    }

    #portrait-message { 
        display: none; 
    }
}

/* Game Mode Fullscreen & Resizer Button Collision Guard */
#container.game-mode-active #map-container {
    display: none;
}

#container.game-mode-active .panel-resizer-btn,
#container.quiz-active .panel-resizer-btn,
#container:has(#game-panel) .panel-resizer-btn,
body:has(#game-panel) .panel-resizer-btn {
    display: none !important;
}

#container.game-mode-active #details {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* Top-Right Search Trigger */
.map-controls-top-right {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    gap: 10px;
}

.map-control-button {
    padding: 8px 12px;
    border: 1.5px solid rgba(0, 0, 0, 0.4);
    background-color: rgba(255, 255, 255, 0.9);
    color: #333;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 1px 7px rgba(0,0,0,0.3);
    transition: all 0.15s ease;
}

.map-control-button:hover {
    background-color: #f4f4f4;
}

.map-control-button.active {
    background-color: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

/* Semi-bold 600 weight State Code Halo */
.state-label {
    color: #1e293b;
    text-align: center;
    text-shadow: 
        -1px -1px 0 rgba(255, 255, 255, 0.92),  
         1px -1px 0 rgba(255, 255, 255, 0.92),
        -1px  1px 0 rgba(255, 255, 255, 0.92),
         1px  1px 0 rgba(255, 255, 255, 0.92);
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.state-label b {
    font-weight: 600;
}

.state-label-large b { font-size: 14px; }
.state-label-medium b { font-size: 11px; }
.state-label-small b { font-size: 9px; }

.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8) !important;
    padding: 3px 8px !important;
    border-radius: 4px;
    margin: 0 0 5px 10px !important;
    box-shadow: 0 1px 5px rgba(0,0,0,0.2);
}

#details {
    position: relative;
}

#details-content {
    min-height: 100%;
    padding-bottom: max(5em, calc(3.5em + env(safe-area-inset-bottom, 0px)));
    box-sizing: border-box;
}

/* Leaflet Vector Panes & SVG Hit-Testing */
.leaflet-pane > svg {
    pointer-events: none !important;
}

.leaflet-pane path.leaflet-interactive,
.leaflet-pane circle.leaflet-interactive,
.leaflet-pane polygon.leaflet-interactive {
    pointer-events: all !important;
    cursor: pointer !important;
}

.leaflet-marker-pane,
.leaflet-markerPinsPane-pane {
    pointer-events: none;
}

.leaflet-marker-pane .leaflet-marker-icon,
.leaflet-markerPinsPane-pane .leaflet-marker-icon {
    pointer-events: auto !important;
    cursor: pointer !important;
}