* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* ADD THIS */
}

#header {
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

#info {
    font-size: 14px;
    opacity: 0.9;
}

#controls {
    background: #34495e;
    color: white;
    padding: 10px 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

button {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

button:hover {
    background: #2980b9;
}

button:disabled {
    background: #7f8c8d;
    cursor: not-allowed;
}

button.lounge-btn {
    background: #9b59b6;
}

button.lounge-btn:hover {
    background: #8e44ad;
}

button.toggle-btn {
    background: #16a085;
}

button.toggle-btn:hover {
    background: #138d75;
}

#status {
    flex: 1;
    text-align: right;
    font-size: 14px;
}

#map {
    flex: 1;
    width: 100%;
    overflow: hidden; /* ADD THIS */
}

/* Popup styles */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.station-popup {
    min-width: 200px;
}

.station-popup h3 {
    margin: 0 0 8px 0;
    color: #2c3e50;
    font-size: 16px;
}

.station-popup p {
    margin: 4px 0;
    font-size: 13px;
    color: #555;
}

.station-popup .code {
    display: inline-block;
    background: #3498db;
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 12px;
}

.lounge-popup {
    min-width: 220px;
}

.lounge-popup h3 {
    margin: 0 0 8px 0;
    color: #8e44ad;
    font-size: 16px;
}

.lounge-popup p {
    margin: 4px 0;
    font-size: 13px;
    color: #555;
}

.lounge-popup .label {
    display: inline-block;
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 12px;
    margin-right: 5px;
}

.lounge-popup .label.near {
    background: #27ae60;
}

.lounge-popup .label.medium {
    background: #e67e22;
}

.lounge-popup .label.far {
    background: #9b59b6;
}

.lounge-popup .label.visited {
    background: #95a5a6;
}

.lounge-popup a {
    color: #9b59b6;
    text-decoration: none;
}

.lounge-popup a:hover {
    text-decoration: underline;
}

.lounge-popup button {
    margin-top: 5px;
    padding: 5px 10px;
    font-size: 12px;
}

/*
#legend {
    position: absolute;
    bottom: 30px;
    right: 10px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    z-index: 1000;
    font-size: 13px;
    max-width: 260px;
    transition: transform 0.3s ease;
}
*/
.legend-item {
    display: flex;
    align-items: center;
    margin: 5px 0;
}

.legend-marker {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 8px;
    border: 2px solid white;
    box-shadow: 0 0 3px rgba(0,0,0,0.3);
}

.legend-marker.station {
    background: #e74c3c;
}

.legend-marker.lounge-near {
    background: #27ae60;
}

.legend-marker.lounge-medium {
    background: #e67e22;
}

.legend-marker.lounge-far {
    background: #9b59b6;
}

.legend-marker.lounge-visited {
    background: #95a5a6;
}

.legend-marker.home {
    background: #3498db;
    width: 20px;
    height: 20px;
}

#progress {
    margin-top: 5px;
    font-size: 12px;
    opacity: 0.8;
}

.zone-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

#legend .legend-section-title {
    margin-top: 10px;
    font-weight: bold;
    text-transform: uppercase;
    opacity: 0.85;
    font-size: 0.8em;
}

#legend .legend-rewards {
    font-size: 0.8em;
    line-height: 1.3em;
    margin-left: 4px;
}

.legend-rewards-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
}

.legend-rewards-label {
    opacity: 0.8;
}

.legend-rewards-value {
    text-align: right;
}

/* Bus zone legend markers */
.legend-marker.zone-bristol {
    background-color: rgba(39, 174, 96, 0.2);
    border: 2px dashed #27ae60;
    border-radius: 2px;
}

.legend-marker.zone-west {
    background-color: rgba(52, 152, 219, 0.2);
    border: 2px dashed #3498db;
    border-radius: 2px;
}

.legend-marker.zone-plus {
    background-color: rgba(155, 89, 182, 0.2);
    border: 2px dashed #9b59b6;
    border-radius: 2px;
}

.legend-separator {
    border-top: 1px solid #ddd;
    margin: 8px 0;
}

#legend.collapsed {
    transform: translateX(calc(100% - 30px));
}

#legend-toggle:hover,
#legend-toggle:active {
    background: #34495e;
}

#legend-container {
    position: absolute;
    bottom: 30px;
    right: 10px;
    z-index: 1000;
    transition: transform 0.3s ease;
}

#legend-container.collapsed {
    transform: translateX(calc(100% - 30px));
}


#legend {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    font-size: 13px;
    max-width: 260px;
}


#legend-toggle {
    position: absolute;
    left: -30px;
    top: 10px;
    width: 30px;
    height: 40px;
    background: #2c3e50;
    border: none;
    border-radius: 4px 0 0 4px;
    color: white;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Dropdown container */
.dropdown {
    position: relative;
    display: inline-block;
}

/* Dropdown content (hidden by default) */
.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #34495e;
    min-width: 200px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 1000;
    border-radius: 4px;
    margin-top: 2px;
}

.dropdown-content button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 15px;
    border-radius: 0;
    background: transparent;
    margin: 0;
}

.dropdown-content button:hover {
    background: #2c3e50;
}

.dropdown-content button:first-child {
    border-radius: 4px 4px 0 0;
}

.dropdown-content button:last-child {
    border-radius: 0 0 4px 4px;
}

/* Show dropdown on click */
.dropdown.active .dropdown-content {
    display: block;
}

/* Cluster controls specific styling */
.cluster-controls {
    padding: 15px;
    min-width: 250px;
}

.cluster-controls label {
    display: block;
    margin-bottom: 5px;
    color: white;
    font-size: 13px;
}

.cluster-controls input[type="range"] {
    width: 100%;
    margin-bottom: 15px;
}

.cluster-controls button {
    width: 100%;
    margin-top: 5px;
}

/* My Location control */
.leaflet-control-mylocation {
    background: white;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}

.leaflet-control-mylocation a {
    display: block;
    width: 34px;
    height: 34px;
    line-height: 34px;
    text-align: center;
    text-decoration: none;
    color: #333;
    font-size: 18px;
}

.leaflet-control-mylocation a:hover {
    background: #f4f4f4;
}

.leaflet-control-mylocation.locating a {
    color: #3498db;
}

.leaflet-control-mylocation.active a {
    color: #3498db;
    background: #e3f2fd;
}