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;
}

/* Landscape mode: Equal split (50/50) */
@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; 
    }
}

/* Portrait mode: Map on top, details below with safe dynamic viewport */
@media (orientation: portrait) {
    #container { 
        flex-direction: column; 
        height: 100vh;
        height: 100dvh;
    }
    #map-container { 
        width: 100vw; 
        height: 60vh; 
        height: 60dvh; 
        flex-shrink: 0; 
        position: relative;
    }
    #details { 
        width: 100vw; 
        height: 40vh; 
        height: 40dvh; 
        flex: 1;
        min-height: 0;
        padding: 15px; 
        padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
        background: #f8f8f8; 
        overflow-y: auto; 
        box-sizing: border-box; 
        -webkit-overflow-scrolling: touch;
    }
    #portrait-message { 
        display: none; 
    }
}

/* Game Mode Fullscreen */
#container.game-mode-active #map-container {
    display: none;
}

#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;
}

/* Map Controls & State Labels */
.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);
}

.state-label {
    color: black;
    text-align: center;
    text-shadow: 
        -1px -1px 0 #FFF,  
         1px -1px 0 #FFF,
        -1px  1px 0 #FFF,
         1px  1px 0 #FFF;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

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

/* Leaflet Attribution */
.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(6em, calc(4em + env(safe-area-inset-bottom, 0px)));
    box-sizing: border-box;
}