/* Make body fill viewport and remove defaults */
html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevent scrollbars */
    font-family: Arial, sans-serif;
    background-color: #f4f4f4; /* Fallback background */
}

/* Container for map and canvas - Full screen */
#map-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Leaflet map div - Takes full container size */
#leafletMap {
    width: 100%;
    height: 100%;
    z-index: 1; /* Below canvas and UI */
    cursor: grab; /* Default cursor when interactive */
}
#leafletMap.leaflet-dragging {
    cursor: grabbing; /* Cursor while panning */
}


/* Simulation Canvas - Overlay, size matches container */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%; /* Fill container */
    height: 100%; /* Fill container */
    background-color: rgba(0, 0, 0, 0); /* Fully transparent */
    z-index: 10; /* Above map tiles, below UI */
    pointer-events: none; /* *** CRITICAL: Let clicks pass through to the map *** */
    /* cursor: default; /* No cursor needed as it doesn't receive events */
}

/* UI Overlay Container - Bottom Left */
.ui-overlay {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 1000; /* Above map and canvas */
    background-color: rgba(255, 255, 255, 0.85); /* Semi-transparent white */
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    max-width: 300px; /* Limit width */
    max-height: 90vh; /* Limit height */
    overflow-y: auto; /* Allow scrolling if content overflows */
    display: flex;
    flex-direction: column;
    transition: height 0.3s ease-in-out, padding 0.3s ease-in-out, bottom 0.3s ease-in-out;
    overflow: hidden; /* Change from auto to hidden initially for collapse */
    height: auto; /* Start with auto height */
}

.ui-overlay h1 {
    color: #333;
    margin: 0 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
    font-size: 1.5em;
}


/* Styling for controls and info panels *inside* the overlay */
.controls, .info {
    background-color: transparent;
    border: none;
    border-radius: 0;
    padding: 5px 0;
    margin-bottom: 5px;
    width: 100%;
    max-width: none;
    box-shadow: none;
    text-align: left;
}

.controls:last-child, .info:last-child { margin-bottom: 0; }

.controls h3, .info h3 {
    margin-top: 0;
    color: #555;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.controls button, .controls input[type="range"] {
    margin: 4px 2px;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.controls button { display: inline-block; }

.controls input[type="range"] {
    vertical-align: middle;
    width: 120px;
}

.controls div { margin-bottom: 5px; } /* Spacing for label/slider groups */

.controls button:hover { background-color: #eee; }

.controls button.active {
    background-color: #aaddff;
    border-color: #5588cc;
    font-weight: bold;
}

.controls label { margin-right: 5px; font-size: 0.9em; }

.controls span { /* trafficValue, simSpeedValue */
    display: inline-block;
    text-align: right;
    font-weight: bold;
    font-size: 0.9em;
    vertical-align: middle;
}

.info p { margin: 6px 0; color: #444; font-size: 0.9em; }
.info span { font-weight: bold; color: #000; }
#messageLog { color: blue; font-style: italic; word-wrap: break-word; }

hr { border: none; border-top: 1px solid #eee; margin: 10px 0; }

/* UI Toggle Button */
.ui-toggle-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 22px;
    height: 22px;
    padding: 0;
    font-size: 1.2em;
    line-height: 22px;
    text-align: center;
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    z-index: 1001;
    transition: transform 0.3s ease-in-out;
}
.ui-toggle-button:hover { color: #000; }

/* Collapsed State for UI Overlay */
.ui-overlay.collapsed {
    height: 40px;
    padding-top: 7px; padding-bottom: 0px; padding-right: 41px; /* Space for button */
}
.ui-overlay.collapsed > *:not(h1):not(.ui-toggle-button) { display: none; }
/* Show scroll again when NOT collapsed */
.ui-overlay:not(.collapsed) { overflow-y: auto; }


/* --- Button Progress Bar Styles --- */
#btn-load-osm {
    position: relative; overflow: hidden; display: inline-block;
    margin: 4px 2px; padding: 6px 10px; border: 1px solid #ccc;
    border-radius: 4px; cursor: pointer; font-size: 0.9em;
    text-align: center; vertical-align: middle; background-color: #f8f8f8;
    color: #333; min-width: 180px; transition: background-color 0.2s ease;
}
#btn-load-osm:hover:not(:disabled) { background-color: #eee; }

#btn-load-osm .progress-fill {
    position: absolute; top: 0; left: 0; height: 100%; width: 0%;
    background-color: rgba(65, 131, 215, 0.5); /* Semi-transparent blue */
    border-radius: 4px; transition: width 0.2s ease-out; z-index: 1;
}
#btn-load-osm .progress-text { position: relative; z-index: 2; }

#btn-load-osm:disabled { cursor: not-allowed; background-color: #e0e0e0; }
#btn-load-osm:disabled .progress-text { color: #555; }


/* --- Copyright Footer --- */
.footer-copyright {
    position: fixed; bottom: 20px; right: 10px; width: auto; /* Let width be auto */
    text-align: right; z-index: 999; pointer-events: none;
}
.footer-copyright p {
    margin: 0; font-size: 0.7em; color: #000000;
    line-height: 1.2; /* Adjust line spacing */
    text-shadow: 1px 1px 1px #ffffff;
}

/* --- Leaflet Locate Control --- */
.leaflet-control-custom {
    box-shadow: 0 1px 5px rgba(0,0,0,0.65); font-size: 1.3em;
}
.leaflet-control-custom:hover { background-color: #f4f4f4; }

/* Hide hidden elements properly */
[style*="content-visibility:hidden"] {
    display: none; /* Fallback for browsers not supporting content-visibility */
    content-visibility: hidden;
}