body {
    margin: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    background-color: #1a1a1a; /* Dark background */
    color: #e0e0e0; /* Light text */
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#controls {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background-color: rgba(30, 30, 30, 0.9); /* Dark translucent background */
    color: #e0e0e0;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 1001;
    max-width: 320px; /* Fixed max width for larger screens */
    width: 30%; /* Responsive width */
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-sizing: border-box; /* Include padding in width */
    transition: all 0.3s ease; /* Smooth transitions */
}

#earthquake-list {
    position: absolute;
    top: 16px;
    left: 16px;
    background-color: rgba(30, 30, 30, 0.9); /* Dark translucent background */
    color: #e0e0e0;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 1001;
    max-width: 320px; /* Fixed max width for larger screens */
    width: 30%; /* Responsive width */
    max-height: calc(50vh - 40px); /* Reduced height to prevent overlap with news feed */
    overflow-y: auto;
    box-sizing: border-box; /* Include padding in width */
    transition: all 0.3s ease; /* Smooth transitions */
}

/* Scrollbar for dark theme */
#earthquake-list::-webkit-scrollbar {
    width: 8px;
}

#earthquake-list::-webkit-scrollbar-track {
    background: rgba(50, 50, 50, 0.5);
    border-radius: 4px;
}

#earthquake-list::-webkit-scrollbar-thumb {
    background: rgba(100, 100, 100, 0.8);
    border-radius: 4px;
}

#earthquake-list::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 120, 120, 0.9);
}

#earthquake-list h3 {
    margin-top: 0;
    font-size: 1.2em;
    text-align: center;
    border-bottom: 1px solid rgba(200, 200, 200, 0.2); /* Lighter border */
    padding-bottom: 10px;
    margin-bottom: 15px;
    color: #ffffff;
}

.quake-list-item {
    background: rgba(50, 50, 50, 0.6); /* Darker item background */
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border-left: 6px solid #555; /* Default border color */
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quake-list-item:hover {
    background: rgba(60, 60, 60, 0.7);
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.quake-list-item.active {
    background: rgba(0, 120, 200, 0.3); /* Highlight color */
    box-shadow: 0 2px 5px rgba(0, 120, 200, 0.4);
    border-left-color: #007bff; /* Active border color */
}

.quake-list-item.estimated {
    background: rgba(255, 193, 7, 0.2); /* Yellow tint for estimated earthquakes */
    border-left-color: #ffc107; /* Yellow border for estimated */
}

.quake-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* Subtle separator */
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.mag-place-group {
    display: flex;
    align-items: baseline; /* Align mag and place text baselines */
    gap: 8px; /* Space between magnitude and place */
    flex-wrap: wrap; /* Allow wrapping if text is too long */
    flex-shrink: 1; /* Allow the group to shrink */
    margin-right: 10px; /* Space between mag/place group and time */
}

.quake-mag {
    font-weight: bold;
    font-size: 1.4em; /* Slightly larger magnitude */
    color: #ffffff;
    display: inline-flex; /* Use inline-flex to keep mag and aftershock label together */
    align-items: center;
    gap: 5px;
    white-space: nowrap; /* Prevent magnitude/aftershock from wrapping */
}

.quake-mag .aftershock-label {
    font-size: 0.7em; /* Smaller font for aftershock */
    font-weight: normal;
    color: #b0b0b0; /* Lighter color */
    background-color: rgba(128, 128, 128, 0.3); /* Subtle background */
    padding: 2px 5px;
    border-radius: 4px;
    white-space: nowrap; /* Prevent aftershock label from wrapping */
}

.quake-mag .estimated-label {
    font-size: 0.7em; /* Smaller font for estimated */
    font-weight: normal;
    color: #ffc107; /* Yellow color for estimated */
    background-color: rgba(255, 193, 7, 0.3); /* Subtle yellow background */
    padding: 2px 5px;
    border-radius: 4px;
    white-space: nowrap; /* Prevent estimated label from wrapping */
}

.quake-time {
    font-size: 0.8em;
    color: #b0b0b0; /* Lighter grey */
    white-space: nowrap; /* Prevent time from wrapping */
    flex-shrink: 0; /* Prevent time from shrinking */
}

.quake-details {
    display: flex;
    flex-direction: column; /* Stack details vertically */
    gap: 6px; /* Reduce gap */
    font-size: 0.9em; /* Slightly larger detail font */
    color: #c0c0c0; /* Light grey */
}

.quake-details .quake-depth,
.quake-details .quake-mmi,
.quake-details .stations-count {
     display: block;
}

.quake-place {
    font-style: italic;
    color: #d0d0d0; /* Slightly brighter for place name */
    flex-shrink: 1; /* Allow place name to shrink */
    min-width: 0; /* Allow text to shrink below intrinsic width */
}

.quake-mmi {
     font-weight: bold;
     color: #fff; /* White for MMI number */
}

.quake-mmi span {
    font-weight: normal;
     color: #c0c0c0; /* Light grey for MMI label */
}

.stations-count {
    font-size: 0.85em; /* Slightly smaller for station count */
    color: #b0b0b0;
}

.no-quakes {
    color: #808080; /* Grey */
    text-align: center;
    font-style: italic;
    padding: 20px 0;
}

#controls h2 {
    margin-top: 0;
    font-size: 1.3em;
    text-align: center;
    color: #ffffff;
    margin-bottom: 15px;
}

.control-group {
    display: flex;
    flex-direction: column; /* Default: stack label and input vertically */
    gap: 8px;
}

.control-group .control-label-row {
    display: flex; /* Layout label and value in a row */
    justify-content: space-between; /* Space between label and value */
    align-items: center; /* Vertically align */
}

.control-group label {
    font-size: 0.95em;
    color: #c0c0c0;
}

.control-group .control-label-row span {
     font-size: 1em;
     font-weight: bold;
     color: #ffffff;
}

.control-group input[type="range"] {
    width: 100%;
    -webkit-appearance: none; /* Override default look */
    appearance: none;
    height: 6px;
    background: #555; /* Darker track */
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
    border-radius: 3px;
}

.control-group input[type="range"]:hover {
    opacity: 1;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #007bff; /* Blue thumb */
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #007bff; /* Blue thumb */
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

.control-group input[type="number"] {
    padding: 8px;
    border: 1px solid #555;
    border-radius: 4px;
    background-color: #444; /* Dark input background */
    color: #e0e0e0;
    font-size: 1em;
    box-sizing: border-box;
    width: 100%;
}

#button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap; /* Allow buttons to wrap on small screens */
    justify-content: center; /* Center buttons in the group */
}

#controls button {
    flex-grow: 1; /* Allow buttons to fill space */
    padding: 10px 15px;
    border: none;
    border-radius: 6mm; /* Slightly more rounded corners */
    cursor: pointer;
    font-size: 0.95em; /* Slightly smaller font */
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease; /* Add box-shadow to transition */
    color: #fff;
    background-color: #007bff; /* Primary blue */
    box-shadow: 0 3px 8px rgba(0, 123, 255, 0.4); /* Stronger initial shadow */
    min-width: 100px; /* Minimum width for buttons */
}

#controls button:hover {
    background-color: #0056b3; /* Darker blue on hover */
    transform: translateY(-2px); /* Lift slightly more on hover */
    box-shadow: 0 5px 12px rgba(0, 123, 255, 0.5); /* Stronger shadow on hover */
}

#controls button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); /* Reset shadow on click */
    background-color: #004085; /* Even darker blue on active */
}

#controls button.active {
    background-color: #0056b3; /* Default darker blue for active */
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2); /* Inset shadow for active */
}

#add-earthquake-button.active {
    background-color: #dc3545; /* Red color */
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}

/* Style for the new stop animation button */
#stop-animation-button {
    background-color: #ffc107; /* Yellow/Orange color */
    color: #212529; /* Dark text for contrast */
    box-shadow: 0 3px 8px rgba(255, 193, 7, 0.4);
}

#stop-animation-button:hover {
    background-color: #e0a800; /* Darker yellow/orange */
    box-shadow: 0 5px 12px rgba(255, 193, 7, 0.5);
}

#stop-animation-button:active {
    background-color: #c69500; /* Even darker yellow/orange */
     box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

#clear-map-button {
    width: 100%; /* Full width */
    background-color: #dc3545; /* Red for danger */
    box-shadow: 0 2px 5px rgba(220, 53, 69, 0.3);
    margin-top: 15px; /* Space above clear button */
}

#clear-map-button:hover {
    background-color: #c82333; /* Darker red */
}

#map.add-mode {
    cursor: crosshair;
}

#map.add-station-mode {
    cursor: url('/static-dot-blue.png') 10 10, crosshair; /* Use blue dot cursor, fallback to crosshair */
}

#map.move-mode {
    cursor: grab;
}

#map.move-mode:active {
    cursor: grabbing;
}

.station-icon {
    /* Basic icon styles handled by Leaflet L.icon */
}

.station-icon.p-wave-detected {
    animation: pulse-glow 1.5s infinite alternate ease-in-out;
}

@keyframes pulse-glow {
    from {
        filter: brightness(1) drop-shadow(0 0 3px rgba(0, 123, 255, 0.3));
        opacity: 1;
    }
    to {
        filter: brightness(1.3) drop-shadow(0 0 8px rgba(0, 123, 255, 0.8));
        opacity: 0.9;
    }
}

.archived-quake {
     fill-opacity: 0.3 !important;
}

.leaflet-tooltip {
    background: rgba(30, 30, 30, 0.8) !important;
    color: #e0e0e0 !important;
    border: none !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
    font-size: 0.9em !important;
    line-height: 1.4 !important;
    padding: 6px 10px !important;
    border-radius: 6px !important;
}

.leaflet-tooltip.leaflet-tooltip-top:before {
    border-top-color: rgba(30, 30, 30, 0.8) !important;
}
.leaflet-tooltip.leaflet-tooltip-bottom:before {
    border-bottom-color: rgba(30, 30, 30, 0.8) !important;
}
.leaflet-tooltip.leaflet-tooltip-left:before {
    border-left-color: rgba(30, 30, 30, 0.8) !important;
}
.leaflet-tooltip.leaflet-tooltip-right:before {
    border-right-color: rgba(30, 30, 30, 0.8) !important;
}

#news-feed {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background-color: rgba(30, 30, 30, 0.9);
    color: #e0e0e0;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 1001;
    max-width: 320px;
    width: 30%;
    max-height: 200px;
    overflow-y: auto;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

#news-feed h3 {
    margin-top: 0;
    font-size: 1.2em;
    text-align: center;
    border-bottom: 1px solid rgba(200, 200, 200, 0.2);
    padding-bottom: 10px;
    margin-bottom: 15px;
    color: #ffffff;
}

.news-item {
    background: rgba(50, 50, 50, 0.6);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border-left: 6px solid #555;
    line-height: 1.4;
}

.news-item.tsunami-warning {
    background: rgba(220, 53, 69, 0.3);
    border-left: 6px solid #dc3545;
    font-weight: bold;
    animation: warning-pulse 2s infinite alternate;
}

.news-item.revised-info {
    color: cyan;
}

@keyframes warning-pulse {
    from {
        background: rgba(220, 53, 69, 0.3);
    }
    to {
        background: rgba(220, 53, 69, 0.5);
    }
}

.news-item.final-report {
    background: rgba(40, 167, 69, 0.3); /* Soft green background */
    border-left: 6px solid #28a745; /* Darker green border */
    color: #e0e0e0; /* Light text for readability */
    font-weight: bold;
    animation: final-report-pulse 2s infinite alternate;
}

@keyframes final-report-pulse {
    from {
        background: rgba(40, 167, 69, 0.3);
    }
    to {
        background: rgba(40, 167, 69, 0.5);
    }
}

.news-item.twitter-alert {
    background: rgba(29, 161, 242, 0.15); /* Twitter blue, very light */
    border-left: 6px solid #1DA1F2; /* Twitter blue */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.9em;
}

.news-item.twitter-alert::before {
    content: "🔄";
    margin-right: 5px;
}

.news-item.lastquake-notification {
    background: rgba(29, 161, 242, 0.2); /* Light blue background */
    border-left: 6px solid #3A86FF; /* EMSC blue */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.9em;
}

.news-item.lastquake-notification::before {
    content: "📱";
    margin-right: 5px;
}

@media (max-width: 768px) {
    #controls {
        width: 90%;
        max-width: none;
        left: 5%;
        right: 5%;
        bottom: 10px;
        top: auto; /* Position at the bottom */
        padding: 15px;
        border-radius: 8px;
        gap: 10px;
    }

    #earthquake-list {
        width: 90%;
        max-width: none;
        left: 5%;
        right: 5%;
        top: 10px;
        bottom: auto; /* Position at the top */
        max-height: 30vh; /* Further reduced height for mobile to prevent overlap */
        padding: 10px;
        border-radius: 8px;
    }

    #earthquake-list h3 {
        font-size: 1.1em;
        padding-bottom: 5px;
        margin-bottom: 10px;
    }

    .quake-list-item {
        padding: 8px;
        margin-bottom: 6px;
        gap: 5px;
    }

    .quake-mag {
        font-size: 1.1em;
    }

    .quake-time, .quake-details {
        font-size: 0.8em;
        gap: 5px;
    }

    #controls h2 {
        font-size: 1.2em;
        margin-bottom: 10px;
    }

    .control-group label {
        font-size: 0.9em;
    }

    #button-group {
        flex-direction: column; /* Stack buttons vertically */
        gap: 8px;
    }

    #controls button {
        width: 100%; /* Full width stacked buttons */
        flex-grow: 0;
        padding: 12px;
    }

    #clear-map-button {
         margin-top: 8px;
    }

    #news-feed {
        position: absolute;
        left: 5%;
        right: 5%;
        bottom: calc(10px + 140px); /* Position above controls with more spacing */
        max-height: 100px; /* Reduced height for mobile */
        width: 90%; /* Take full width minus padding */
        overflow-y: auto;
        border-radius: 8px;
        padding: 10px;
    }

    #news-feed h3 {
         font-size: 1.1em;
         padding-bottom: 5px;
         margin-bottom: 8px;
         text-align: center;
    }

    .news-item {
        font-size: 0.8em;
        padding: 6px;
        margin-bottom: 5px;
    }
}