:root {
    --primary: #dc2626;
    --primary-dark: #b91c1c;
    --secondary: #7f1d1d;
    --danger: #ef4444;
    --warning: #eab308;
    --success: #22c55e;
    --orange: #f97316;
    --bg-dark: #111111;
    --bg-card: rgba(30, 30, 30, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --gradient: linear-gradient(135deg, #dc2626 0%, #4a4a4a 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow: hidden;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

/* Header Styles */
.header {
    background: rgba(15, 15, 35, 0.98);
    border-bottom: none;
    padding: 1rem 2rem;
    z-index: 100;
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(185, 28, 28, 0.3) 20%,
            rgba(185, 28, 28, 0.8) 50%,
            rgba(185, 28, 28, 0.3) 80%,
            transparent 100%);
    box-shadow: 0 0 15px rgba(185, 28, 28, 0.4),
        0 0 30px rgba(185, 28, 28, 0.2);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1920px;
    margin: 0 auto;
}

/* Header Logo - Responsive */
.header-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    background: transparent;
}

.logo-img {
    height: 60px;
    width: auto;
    max-width: 250px;
    object-fit: contain;
    transition: opacity 0.2s ease;
    background: transparent;
}

.header-logo:hover .logo-img {
    opacity: 0.85;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #b91c1c;
    margin-bottom: 0.1rem;
}

.logo-subtitle {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
}

/* Pulse Indicator */
.pulse-indicator {
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.pulse-indicator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background: #ef4444;
    border-radius: 50%;
    animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

.pulse-small {
    width: 8px;
    height: 8px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.4rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.filters-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.time-filter {
    display: flex;
    background: var(--bg-glass);
    border-radius: 8px;
    padding: 3px;
    border: 1px solid var(--border-color);
}

/* Close button style matching Mapbox Zoom buttons */
.close-table-btn {
    background: rgba(30, 30, 50, 0.6) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: white !important;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    /* Slightly rounded like map controls */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.close-table-btn:active {
    transform: translateY(1px);
    background: rgba(255, 255, 255, 0.1) !important;
}

.filter-btn {
    padding: 0.4rem 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s ease;
}

.filter-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.filter-btn.active {
    background: var(--gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Archive Filter Container */
.archive-filter {
    display: flex;
    align-items: center;
    flex-wrap: nowrap !important;
    gap: 0.5rem;
    background: rgba(25, 25, 50, 0.4);
    padding: 0.3rem 0.3rem 0.3rem 0.5rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.date-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.date-group label {
    font-size: 0.7rem;
    color: white;
    font-weight: bold;
    margin-left: 2px;
}

.date-separator {
    color: var(--text-secondary);
    font-weight: bold;
    margin-bottom: 8px;
    /* Align with input center */
}

/* Archive Search Button */
.archive-search-btn {
    background: var(--primary);
    border: 1px solid var(--border-color);
    color: white;
    padding: 0.4rem 0.5rem !important;
    height: 36px;
    width: 36px !important;
    min-width: unset !important;
    max-width: 36px !important;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s ease;
    margin-left: auto !important;
}

/* Archive Stats Panel */
.archive-stats-panel {
    background: rgba(20, 20, 35, 0.6);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
    margin-bottom: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1rem;
    font-weight: bold;
    color: white;
}

.stat-value.highlight {
    color: #ef4444;
    /* Red for magnitude */
    font-size: 1.1rem;
}

.archive-reset-btn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.6rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.archive-reset-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.archive-search-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

/* Archive Date Input */
.archive-date-input {
    background: rgba(25, 25, 50, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.3rem 0.5rem;
    border-radius: 8px;
    font-size: 0.75rem;
    outline: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    height: 32px;
    width: 110px;
}

.archive-date-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.7;
    transform: scale(0.8);
}

.archive-date-input:hover,
.archive-date-input:focus {
    background: rgba(40, 40, 70, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

/* Placeholder styles for date inputs */
.archive-date-input::placeholder {
    color: var(--text-muted);
    opacity: 1;
    font-size: 0.7rem;
}

.archive-date-input::-webkit-input-placeholder {
    color: var(--text-muted);
    opacity: 1;
    font-size: 0.7rem;
}

.archive-date-input::-moz-placeholder {
    color: var(--text-muted);
    opacity: 1;
    font-size: 0.7rem;
}

.archive-date-input:-ms-input-placeholder {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* Date Input Wrapper for overlay placeholder */
.date-input-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.date-input-wrapper .archive-date-input {
    width: 100%;
}

.date-placeholder {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    pointer-events: none;
    white-space: nowrap;
}

/* Hide placeholder when input has value */
.date-input-wrapper .archive-date-input:not(:placeholder-shown)+.date-placeholder,
.date-input-wrapper .archive-date-input:focus+.date-placeholder,
.date-input-wrapper .archive-date-input.has-value+.date-placeholder {
    display: none;
}

/* City Select in Header */
.city-select-header {
    padding: 0.4rem 0.6rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    min-width: 130px;
    transition: all 0.2s ease;
}

.city-select-header:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.city-select-header:focus {
    outline: none;
    border-color: var(--primary);
}

.city-select-header option {
    background: rgba(25, 25, 50, 0.98);
    color: var(--text-primary);
}

.view-toggles {
    display: flex;
    gap: 0.5rem;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.toggle-btn .icon {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.heatmap-btn-icon {
    width: 24px;
    height: 18px;
    object-fit: cover;
    border-radius: 4px;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.toggle-btn.active {
    background: var(--gradient);
    border-color: transparent;
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Stats Panel */
.stats-panel {
    width: 380px;
    background: rgba(25, 25, 50, 0.98);
    border: 2px solid transparent;
    border-image: linear-gradient(180deg,
            rgba(185, 28, 28, 0.2) 0%,
            rgba(185, 28, 28, 0.6) 50%,
            rgba(185, 28, 28, 0.2) 100%) 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 0 0 20px rgba(185, 28, 28, 0.15),
        inset 0 0 30px rgba(185, 28, 28, 0.05);
}

.panel-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

/* System Status Box */
.system-status-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: center;
}

.status-line-primary {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: #4ade80;
    /* Green */
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 8px #22c55e;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.status-separator {
    color: #b91c1c;
    font-size: 0.5rem;
}

.status-highlight {
    color: white;
    font-weight: normal;
}

.status-active {
    color: #4ade80;
    font-weight: 700;
}

.status-line-secondary {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    width: 100%;
    text-align: center;
}

.status-line-secondary #updateTime {
    color: white;
    font-weight: 600;
    margin-left: 0.3rem;
    display: inline-block;
    transition: all 0.3s ease;
}

/* Time update animation */
.status-line-secondary #updateTime.time-updating {
    animation: timeUpdatePulse 0.6s ease-out;
}

@keyframes timeUpdatePulse {
    0% {
        transform: scale(1);
        color: white;
    }

    30% {
        transform: scale(1.15);
        color: #4ade80;
        text-shadow: 0 0 10px rgba(74, 222, 128, 0.8);
    }

    100% {
        transform: scale(1);
        color: white;
        text-shadow: none;
    }
}

/* Mobile Toggle Button */
.mobile-quakes-btn {
    display: none;
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 1rem;
}

.mobile-quakes-btn:active {
    transform: scale(0.98);
}

/* Table Header Row */
.table-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.table-header-row h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.close-table-btn {
    display: none;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.8), rgba(185, 28, 28, 0.9));
    border: 2px solid rgba(255, 100, 100, 0.8);
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
}

.close-table-btn:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(220, 38, 38, 1));
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.7), 0 4px 12px rgba(0, 0, 0, 0.4);
    transform: scale(1.08);
}

.close-table-btn:active {
    transform: scale(0.95);
    box-shadow: 0 0 10px rgba(220, 38, 38, 0.6);
}

/* Table Time Filter Buttons */
.table-time-filter {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.table-filter-btn {
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.table-filter-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.table-filter-btn.active {
    background: var(--gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Earthquake Table */
.earthquake-table-container {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1rem;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.earthquake-table-container h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.earthquake-table-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.earthquake-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.earthquake-table thead {
    position: sticky;
    top: 0;
    background: rgba(25, 25, 50, 0.98);
    z-index: 1;
}

.earthquake-table th {
    text-align: left;
    padding: 0.5rem 0.4rem;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.earthquake-table td {
    padding: 0.5rem 0.4rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.earthquake-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
}

.earthquake-table .mag-cell {
    font-weight: 700;
    text-align: center;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
}

.earthquake-table .mag-low {
    color: #22c55e;
}

.earthquake-table .mag-medium {
    color: #eab308;
}

.earthquake-table .mag-high {
    color: #f97316;
}

.earthquake-table .mag-critical {
    color: #ef4444;
}

.earthquake-table .depth-cell {
    color: var(--text-muted);
    text-align: right;
}

/* Recent Quakes List */
.recent-quakes {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.recent-quakes h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.quakes-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.quake-item {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
}

.quake-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.quake-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.quake-magnitude {
    font-size: 1.25rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 8px;
    background: var(--success);
    color: white;
}

.quake-magnitude.medium {
    background: var(--warning);
}

.quake-magnitude.high {
    background: var(--orange);
}

.quake-magnitude.critical {
    background: var(--danger);
}

.quake-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.quake-location {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.quake-depth {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Map Wrapper */
.map-wrapper {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

.map-legend {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    background: rgba(25, 25, 50, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    z-index: 10;
}

.map-legend h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* Global Footer Styles (Desktop/Large Screens) */
.mobile-footer {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 35px;
    background: rgba(10, 10, 25, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 500;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
}

.mobile-footer a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.2s ease;
}

.mobile-footer a:hover {
    color: white;
    text-decoration: underline;
}

.footer-separator {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.5rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    z-index: 1000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* Home Control Button */
.mapboxgl-ctrl-home {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 29px;
    height: 29px;
    background: white;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

.mapboxgl-ctrl-home:hover {
    background: #f0f0f0;
}

.mapboxgl-ctrl-home .home-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    filter: brightness(0) invert(1) drop-shadow(0 0 1px rgba(0, 0, 0, 0.5));
}

/* Mapbox Popup Styles */
.mapboxgl-popup-content {
    background: rgba(25, 25, 50, 0.98) !important;
    border: 1px solid var(--border-color);
    border-radius: 16px !important;
    padding: 1rem !important;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    min-width: 200px;
}

.mapboxgl-popup-tip {
    border-top-color: var(--bg-card) !important;
}

.mapboxgl-popup-close-button {
    color: white;
    font-size: 1.4rem;
    font-weight: bold;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.9), rgba(185, 28, 28, 1));
    border: 2px solid rgba(255, 100, 100, 0.8);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.6), 0 2px 6px rgba(0, 0, 0, 0.4);
    margin: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    animation: popupCloseGlow 1.5s ease-in-out infinite;
}

@keyframes popupCloseGlow {

    0%,
    100% {
        box-shadow: 0 0 12px rgba(220, 38, 38, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
    }

    50% {
        box-shadow: 0 0 25px rgba(239, 68, 68, 0.8), 0 2px 8px rgba(0, 0, 0, 0.5);
    }
}

.mapboxgl-popup-close-button:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 1), rgba(220, 38, 38, 1));
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.8), 0 4px 10px rgba(0, 0, 0, 0.5);
    transform: scale(1.1);
    animation: none;
}

.mapboxgl-popup-close-button:active {
    transform: scale(0.95);
    box-shadow: 0 0 10px rgba(220, 38, 38, 0.6);
}

/* Hide Mapbox attribution */
.mapboxgl-ctrl-attrib {
    display: none !important;
}

.mapboxgl-ctrl-logo {
    display: none !important;
}

/* Latest earthquake pulse marker */
.pulse-marker {
    width: 30px;
    height: 30px;
    position: relative;
}

.pulse-marker .pulse-dot {
    width: 16px;
    height: 16px;
    background: #ef4444;
    border: 3px solid #fff;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    cursor: pointer;
}

.pulse-marker .pulse-ring {
    width: 40px;
    height: 40px;
    background: rgba(239, 68, 68, 0.4);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: pulse-animation 2s ease-out infinite;
}

.pulse-marker .pulse-ring-2 {
    animation-delay: 0.5s;
}

@keyframes pulse-animation {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

.popup-content {
    text-align: center;
}

.popup-magnitude {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.popup-location {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.popup-details {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Distance Button in Popup */
.distance-btn {
    display: block;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.6rem 0.8rem;
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.distance-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

.distance-btn:active {
    transform: scale(0.98);
}

/* Distance Result Popup */
.distance-popup .mapboxgl-popup-content {
    background: rgba(17, 17, 17, 0.95);
    border: 2px solid #ef4444;
    border-radius: 12px;
    padding: 1rem;
}

.distance-result {
    text-align: center;
    min-width: 180px;
}

.distance-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.distance-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.distance-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #ef4444;
    margin-bottom: 0.3rem;
}

.distance-location {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.distance-timer {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Liquid Glass Effect Utilities */
.liquid-glass {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.liquid-glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.1),
            transparent);
    transition: 0.5s;
}

.liquid-glass:hover::before {
    left: 100%;
}

.liquid-glass:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.liquid-glass:active {
    transform: translateY(1px);
    background: rgba(255, 255, 255, 0.05);
}

/* Apply Liquid Glass to All Buttons */
.filter-btn,
.toggle-btn,
.city-select-header,
.archive-search-btn,
.archive-reset-btn,
.distance-btn,
.mobile-quakes-btn,
.mapboxgl-ctrl-group button {
    background: rgba(30, 30, 50, 0.6) !important;
    /* Base dark tint */
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    position: relative !important;
    overflow: hidden !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Specific Shimmer for all buttons */
.filter-btn::after,
.toggle-btn::after,
.city-select-header::after,
.archive-search-btn::after,
.mobile-quakes-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.2),
            transparent);
    transform: skewX(-20deg);
    transition: none;
}

.filter-btn:hover::after,
.toggle-btn:hover::after,
.city-select-header:hover::after,
.archive-search-btn:hover::after,
.mobile-quakes-btn:hover::after {
    left: 150%;
    transition: 0.7s;
}

/* Active States Override */
.filter-btn.active,
.toggle-btn.active {
    background: var(--gradient) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
}

/* Primary Button Override for Mobile Quakes */
.mobile-quakes-btn {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.8), rgba(127, 29, 29, 0.8)) !important;
}

/* Mapbox Controls Glass - Distinct White/Glass Style */
.mapboxgl-ctrl-group {
    background: transparent !important;
    box-shadow: none !important;
}

.mapboxgl-ctrl-group button {
    margin-bottom: 6px !important;
    border-radius: 12px !important;
    width: 36px !important;
    height: 36px !important;
    background: rgba(255, 255, 255, 0.12) !important;
    /* Lighter glass base */
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    /* Distinct white border */
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    transition: all 0.3s ease !important;
}

.mapboxgl-ctrl-group button:hover {
    background: rgba(255, 255, 255, 0.25) !important;
    border-color: rgba(255, 255, 255, 0.9) !important;
    /* Bright white on hover */
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3) !important;
}

/* Make icons bright white */
.mapboxgl-ctrl-icon {
    filter: invert(1) brightness(10) drop-shadow(0 0 2px rgba(255, 255, 255, 0.5));
}

/* Archive Date Input Glass */
.archive-date-input {
    background: rgba(30, 30, 50, 0.4) !important;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}


/* Archive Loading Overlay */
#archiveLoadingOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#archiveLoadingOverlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.archive-loading-card {
    background: rgba(30, 30, 50, 0.6);
    backdrop-filter: blur(16px);
    padding: 2rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 80%;
    text-align: center;
}

.archive-loading-card p {
    color: white;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    margin: 0;
}

.archive-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #fff;
    border-radius: 50%;
    animation: archive-spin 1s linear infinite;
}

@keyframes archive-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design - Mobile Only (phones, not tablets) */
@media (max-width: 600px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 0.75rem;
    }

    .logo h1 {
        font-size: 1.2rem;
    }

    .logo-icon {
        font-size: 1.5rem;
    }

    .header-controls {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .filters-row {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .time-filter {
        justify-content: center;
    }

    .filter-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .city-select-header {
        font-size: 0.75rem;
        padding: 0.4rem 0.5rem;
        min-width: 120px;
    }

    .view-toggles {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        justify-content: stretch;
        background: transparent;
        padding: 0;
        border: none;
    }

    .toggle-btn,
    .iso-toggle-btn {
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 0.2rem !important;
        font-size: 0.7rem !important;
        margin: 0 !important;
        white-space: nowrap;
        height: 36px !important;
        min-height: 36px !important;
        max-height: 36px !important;
        box-sizing: border-box !important;
        border-radius: 8px !important;
    }

    .toggle-btn .btn-text,
    .iso-toggle-btn .btn-text {
        font-size: 0.7rem !important;
        display: inline-block !important;
        /* Ensure text visible */
    }

    .iso-toggle-btn {
        min-width: 0 !important;
        gap: 4px !important;
    }

    .iso-icon {
        width: 16px !important;
        height: 16px !important;
    }

    .main-content {
        flex-direction: column;
    }

    .stats-panel {
        width: 100%;
        max-height: none;
        height: auto;
        padding: 0.5rem 1rem;
        gap: 0.5rem;
        order: 2;
        overflow: visible;
    }

    /* Mobile Footer Container - Desktop: show centered */
    .mobile-footer {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 35px;
        background: rgba(10, 10, 25, 0.98);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 500;
        justify-content: center;
        align-items: center;
        gap: 1rem;
        font-size: 0.75rem;
    }

    .mobile-footer a {
        color: rgba(255, 255, 255, 0.7);
        text-decoration: none;
        transition: color 0.2s ease;
    }

    .mobile-footer a:hover {
        color: white;
        text-decoration: underline;
    }

    .footer-separator {
        color: rgba(255, 255, 255, 0.3);
        font-size: 0.5rem;
    }

    /* Hide earthquake table in stats panel on mobile - use floating button instead */
    .stats-panel .earthquake-table-container {
        display: none;
    }

    /* Mobile footer status bar - single line, minimal */
    .stats-panel {
        position: fixed;
        bottom: 35px !important;
        left: 0;
        right: 0;
        width: 100%;
        padding: 0.1rem 0;
        z-index: 400;
        background: rgba(15, 15, 35, 0.98);
        border-top: 1px solid var(--border-color);
    }

    .mobile-footer {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 35px;
        background: rgba(10, 10, 25, 0.98);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 500;
        justify-content: center;
        align-items: center;
        gap: 0.5rem;
        color: white;
        font-size: 0.65rem;
    }

    .mobile-footer a {
        color: rgba(255, 255, 255, 0.7);
        text-decoration: none;
        transition: color 0.2s ease;
    }

    .mobile-footer a:hover {
        color: white;
        text-decoration: underline;
    }

    .footer-separator {
        color: rgba(255, 255, 255, 0.3);
        font-size: 0.5rem;
    }

    .stats-panel .panel-header {
        padding: 0;
        border: none;
        margin: 0;
    }

    .stats-panel .system-status-box {
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: center;
        padding: 0.1rem 0;
        gap: 0.3rem;
        background: transparent;
        border: none;
        width: 100%;
    }

    .stats-panel .status-line-primary {
        font-size: clamp(0.5rem, 2.5vw, 0.7rem);
        gap: 0.15rem;
        white-space: nowrap;
    }

    .stats-panel .status-line-secondary {
        font-size: clamp(0.5rem, 2.5vw, 0.7rem);
        padding: 0;
        background: transparent;
        white-space: nowrap;
    }

    .stats-panel .status-dot {
        width: 5px;
        height: 5px;
        flex-shrink: 0;
    }

    .stats-panel .status-separator {
        font-size: clamp(0.3rem, 1.5vw, 0.5rem);
    }

    /* Adjust mobile button position above footer */
    .mobile-quakes-btn {
        bottom: 145px !important;
    }

    .map-wrapper {
        order: 1;
        min-height: 50vh;
    }

    .stats-header {
        flex-direction: row;
        align-items: center;
    }

    .stats-header h2 {
        font-size: 1.1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.75rem;
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }

    .stat-icon {
        font-size: 1.25rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .earthquake-table-container {
        max-height: 180px;
    }

    .earthquake-table-container h3 {
        font-size: 0.9rem;
    }

    .earthquake-table {
        font-size: 0.7rem;
    }

    .earthquake-table th,
    .earthquake-table td {
        padding: 0.4rem 0.3rem;
    }

    /* Mobile: Show toggle button as fixed button at bottom */
    .mobile-quakes-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: fixed !important;
        bottom: 85px !important;
        left: 48% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        width: auto !important;
        min-width: 140px !important;
        min-height: 44px !important;
        padding: 0.6rem 1.2rem !important;
        z-index: 99999 !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
        border-radius: 22px !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3) !important;
        user-select: none !important;
        pointer-events: auto !important;
        cursor: pointer !important;
        background: linear-gradient(135deg, #dc2626 0%, #7f1d1d 100%) !important;
        color: white !important;
        border: none !important;
        font-size: 0.9rem !important;
        font-weight: 600 !important;
        -webkit-appearance: none !important;
        appearance: none !important;
    }

    .mobile-quakes-btn * {
        pointer-events: none !important;
    }

    .mobile-quakes-btn.hidden {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }

    /* Mobile modal - keep fullscreen */
    .stats-panel .earthquake-table-container,
    .earthquake-table-container {
        display: flex !important;
        /* Specificity Fix: Override tablet 'display: none' */
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 100vh;
        z-index: 1000;
        border-radius: 0;
        padding: 0.75rem;
        background: rgba(20, 20, 35, 0.95);
        /* Ensure glass bg is here */
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.5);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        opacity: 0;
        transform: translateY(100%);
        pointer-events: none;
        transition: transform 0.7s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.5s ease;
    }

    .earthquake-table-container.visible {
        /* Container Visible State */
        display: flex;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    /* Liquid Glass Container Style */
    .earthquake-table-container {
        /* Override background for glass effect */
        background: rgba(20, 20, 35, 0.95);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.5);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* List Items as Liquid Glass Cards */
    .earthquake-table {
        border-collapse: separate;
        border-spacing: 0 8px;
        /* Card spacing */
    }

    .earthquake-table tbody tr {
        background: rgba(255, 255, 255, 0.03);
        backdrop-filter: blur(5px);
        transition: transform 0.2s, background 0.2s;
    }

    .earthquake-table tbody tr:active {
        transform: scale(0.98);
        background: rgba(255, 255, 255, 0.08);
    }

    /* Rounded Cells */
    .earthquake-table td:first-child {
        border-top-left-radius: 10px;
        border-bottom-left-radius: 10px;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
    }

    .earthquake-table td:last-child {
        border-top-right-radius: 10px;
        border-bottom-right-radius: 10px;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }

    .earthquake-table td {
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding: 0.8rem 0.5rem;
    }

    .close-table-btn {
        display: block;
    }

    .recent-quakes {
        display: none;
    }

    .map-legend {
        bottom: 145px;
        right: 0.75rem;
        padding: 0.75rem;
        border-radius: 12px;
    }

    .map-legend h4 {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .legend-item {
        font-size: 0.65rem;
    }

    .legend-dot {
        width: 10px;
        height: 10px;
    }

    /* Mapbox controls mobile optimization */
    .mapboxgl-ctrl-top-left,
    .mapboxgl-ctrl-top-right {
        top: 0 !important;
        /* Move very close to header */
        margin-top: 2px !important;
    }

    .mapboxgl-ctrl-group {
        margin: 0 0 10px 0 !important;
        /* Increase gap between groups */
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .mapboxgl-ctrl-group button {
        width: 28px !important;
        height: 28px !important;
    }

    .mapboxgl-ctrl-icon {
        transform: scale(0.75);
    }

    /* Force Fullscreen Button Visibility on iOS/Mobile */
    .mapboxgl-ctrl-fullscreen {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Responsive Design - Mobile Portrait */
@media (max-width: 480px) {
    .header {
        padding: 0.5rem 0.75rem;
    }

    .logo {
        gap: 0.5rem;
    }

    /* Compact Header Layout */
    .header-content {
        gap: 0.5rem;
    }

    /* Logo scaling */
    .logo h1 {
        font-size: 0.95rem;
        letter-spacing: -0.5px;
    }

    .logo-subtitle {
        display: none;
        /* Hide subtitle on mobile to save space */
    }

    /* Archive Filter - Grid Layout */
    .archive-filter {
        display: grid;
        grid-template-columns: 1fr auto 1fr auto;
        gap: 0.5rem;
        align-items: center;
        width: 100%;
        background: rgba(0, 0, 0, 0.2);
        padding: 0.5rem;
        border: 1px solid rgba(255, 255, 255, 0.05);
    }

    .date-group {
        width: 100%;
    }

    .date-group label {
        font-size: 0.6rem;
        color: var(--text-muted);
        margin-bottom: 2px;
        white-space: nowrap;
    }

    .archive-date-input {
        width: 100%;
        height: 32px;
        font-size: 0.75rem;
        padding: 0 0.4rem;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .date-separator {
        margin-top: 12px;
        color: var(--text-muted);
        font-size: 0.8rem;
    }

    .archive-search-btn {
        width: 32px;
        height: 32px;
        margin-top: 12px;
        border-radius: 6px;
    }

    /* Control Row: City + Toggles */
    .filters-row {
        gap: 0.5rem;
    }

    .city-select-header {
        width: 100%;
        height: 36px;
        font-size: 0.85rem;
        background: rgba(30, 30, 50, 0.8);
        border: 1px solid rgba(255, 255, 255, 0.15);
    }

    /* Modern Segmented Toggles */
    .view-toggles {
        width: 100%;
        background: rgba(0, 0, 0, 0.2);
        padding: 4px;
        border-radius: 8px;
        gap: 0;
        border: 1px solid rgba(255, 255, 255, 0.05);
    }

    .toggle-btn {
        flex: 1;
        justify-content: center;
        padding: 0.4rem;
        background: transparent;
        border: none;
        border-radius: 6px;
    }

    .toggle-btn.active {
        background: rgba(255, 255, 255, 0.1);
        box-shadow: none;
        color: white;
    }

    .toggle-btn .icon {
        display: inline-flex;
        /* Show icon even on mobile */
        font-size: 1rem;
    }

    .toggle-btn .btn-text {
        font-size: 0.75rem;
        margin-left: 4px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.6rem;
        border-radius: 10px;
    }

    .stat-icon {
        font-size: 1rem;
    }

    .stat-value {
        font-size: 1rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .stats-panel {
        max-height: 40vh;
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .map-wrapper {
        min-height: 55vh;
    }

    /* Mobile modal - keep fullscreen */
    .earthquake-table-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 100vh;
        padding: 0.75rem;
        border-radius: 0;
        background: #1a1a2e;
    }

    .earthquake-table-container h3,
    .table-header-row h3 {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
    }

    .earthquake-table {
        font-size: 0.65rem;
    }

    .earthquake-table th {
        padding: 0.35rem 0.25rem;
    }

    .earthquake-table td {
        padding: 0.4rem 0.25rem;
    }

    .map-legend {
        bottom: 210px;
        right: 0.5rem;
        padding: 0.4rem 0.6rem;
        border-radius: 8px;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        z-index: 2000;
        display: flex;
        flex-direction: column;
        transform: scale(0.75);
        transform-origin: bottom right;
    }

    .map-legend h4 {
        font-size: 0.7rem;
    }

    .legend-items {
        gap: 0.35rem;
        display: flex;
        flex-direction: column;
    }

    .legend-item {
        font-size: 0.6rem;
        gap: 0.35rem;
    }

    .legend-dot {
        width: 8px;
        height: 8px;
    }

    /* Popup mobile optimization */
    .mapboxgl-popup-content {
        padding: 0.75rem !important;
        min-width: 160px;
        border-radius: 12px !important;
    }

    .popup-magnitude {
        font-size: 1.5rem;
    }

    .popup-location {
        font-size: 0.75rem;
    }

    .popup-details {
        flex-direction: column;
        gap: 0.25rem;
        font-size: 0.65rem;
    }
}

/* Isoseismal Toggle Button Styles */
.iso-toggle-btn {
    width: auto;
    /* Removed fixed min-width/height to match standard toggle-btn scaling */
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    /* Flex to center icon */
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* margin-left: 6px; Removed margin as it's now in toggles group */
    flex-shrink: 0;

    /* Desktop: Make it appear first in the toggles group (next to select) */
    order: -1;
}

.iso-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.iso-toggle-btn.active {
    background: rgba(220, 38, 38, 0.25);
    border-color: rgba(220, 38, 38, 0.6);
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.3);
}

.iso-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.iso-toggle-btn .btn-text {
    font-size: 0.8rem;
    font-weight: 500;
    color: white;
    letter-spacing: 0;
}

.iso-toggle-btn.active .iso-icon {
    transform: scale(1.1);
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.6));
}

@media (min-width: 1024px) {
    .iso-toggle-btn {
        height: 100%;
        /* Fill container height on desktop */
    }
}

/* Mobile Adjustment */
@media (max-width: 480px) {
    .iso-toggle-btn {
        min-width: auto;
        padding: 0 8px;
        gap: 6px;
    }

    .iso-toggle-btn .btn-text {
        font-size: 0.75rem;
    }

    .iso-icon {
        width: 18px;
        height: 18px;
    }
}

/* Extra Small Devices */
@media (max-width: 360px) {
    .logo h1 {
        font-size: 0.9rem;
    }

    .filter-btn {
        padding: 0.4rem 0.3rem;
        font-size: 0.65rem;
    }

    .toggle-btn {
        padding: 0.4rem;
        font-size: 0.7rem;
    }

    .stats-grid {
        gap: 0.4rem;
    }

    .stat-card {
        padding: 0.5rem;
    }

    .stat-value {
        font-size: 0.9rem;
    }

    /* Mobile modal - extra small optimization */
    .mobile-quakes-btn {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .earthquake-table-container {
        padding: 0.5rem;
        padding-top: env(safe-area-inset-top, 0.5rem);
        padding-bottom: env(safe-area-inset-bottom, 0.5rem);
    }

    .table-header-row {
        margin-bottom: 0.5rem;
    }

    .table-header-row h3 {
        font-size: 0.8rem;
    }

    .close-table-btn {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .earthquake-table {
        font-size: 0.6rem;
    }

    .earthquake-table th,
    .earthquake-table td {
        padding: 0.3rem 0.2rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {

    .filter-btn,
    .toggle-btn {
        min-height: 44px;
    }

    .quake-item {
        padding: 1rem;
    }

    .earthquake-table tbody tr {
        min-height: 44px;
    }

    .earthquake-table td {
        padding: 0.6rem 0.4rem;
    }
}

/* Landscape mode on small devices */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 0.4rem 1rem;
    }

    .logo h1 {
        font-size: 1rem;
    }

    .main-content {
        flex-direction: row;
    }

    .stats-panel {
        width: 280px;
        max-height: 100%;
        order: 1;
    }

    .map-wrapper {
        order: 2;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .earthquake-table-container {
        max-height: 120px;
    }
}

/* Mobile Status Box Styles */
.mobile-status-box {
    display: none;
}

@media (max-width: 600px) {
    .mobile-status-box {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        padding: 8px;
        margin-bottom: 12px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
    }

    .mobile-status-box .status-line-primary {
        font-size: 0.75rem;
        color: #e2e8f0;
        display: flex;
        align-items: center;
        gap: 6px;
        justify-content: center;
        flex-wrap: wrap;
    }

    .mobile-status-box .status-line-secondary {
        font-size: 0.7rem;
        color: #94a3b8;
        margin-top: 3px;
        display: block;
    }

    .mobile-status-box .status-dot {
        width: 6px;
        height: 6px;
        background: #22c55e;
        border-radius: 50%;
        box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
    }

    .mobile-status-box .status-separator {
        color: #64748b;
        font-size: 0.6rem;
    }

    .mobile-status-box .status-active {
        color: #22c55e;
        font-weight: 600;
    }
}

/* Daily Max Earthquake Box Styles */
.daily-max-earthquake-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.15), rgba(185, 28, 28, 0.1));
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.1);
}

.daily-max-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.daily-max-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #f87171;
}

.daily-max-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fef2f2;
    background: rgba(220, 38, 38, 0.2);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(220, 38, 38, 0.4);
}

@media (max-width: 600px) {
    .daily-max-earthquake-box {
        padding: 8px 10px;
        margin-bottom: 10px;
    }

    .daily-max-label {
        font-size: 0.7rem;
    }

    .daily-max-value {
        font-size: 0.8rem;
        padding: 3px 8px;
    }
}

/* FORCE OVERRIDE for Close Button to match Mapbox Zoom (Liquid Glass) */
@media (max-width: 600px) {
    .close-table-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 36px !important;
        height: 36px !important;
        background: linear-gradient(135deg, rgba(220, 38, 38, 0.9), rgba(185, 28, 28, 1)) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        border: 2px solid rgba(255, 100, 100, 0.8) !important;
        border-radius: 8px !important;
        color: white !important;
        font-size: 1.2rem !important;
        font-weight: bold !important;
        box-shadow: 0 0 20px rgba(220, 38, 38, 0.6), 0 4px 8px rgba(0, 0, 0, 0.4) !important;
        margin: 0 !important;
        padding: 0 !important;
        cursor: pointer !important;
        line-height: 1 !important;
        animation: mobileCloseBtnGlow 1.5s ease-in-out infinite !important;
    }

    @keyframes mobileCloseBtnGlow {

        0%,
        100% {
            box-shadow: 0 0 15px rgba(220, 38, 38, 0.5), 0 4px 8px rgba(0, 0, 0, 0.4);
        }

        50% {
            box-shadow: 0 0 30px rgba(239, 68, 68, 0.8), 0 4px 12px rgba(0, 0, 0, 0.5);
        }
    }

    .close-table-btn:active {
        background: linear-gradient(135deg, rgba(239, 68, 68, 1), rgba(220, 38, 38, 1)) !important;
        transform: scale(0.95);
        box-shadow: 0 0 10px rgba(220, 38, 38, 0.7) !important;
        animation: none !important;
    }

    /* Mobile "Son Depremler" Button Pulse Animation (Centered) */
    @keyframes pulse-intense-centered {
        0% {
            box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.8);
            transform: translateX(-50%) scale(1);
        }

        50% {
            box-shadow: 0 0 0 15px rgba(220, 38, 38, 0);
            transform: translateX(-50%) scale(1.05);
        }

        100% {
            box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
            transform: translateX(-50%) scale(1);
        }
    }

    .mobile-quakes-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: fixed !important;
        bottom: 85px !important;
        /* Secure visibility */
        left: 48% !important;
        width: auto !important;
        min-width: 180px !important;
        z-index: 9999 !important;

        animation: pulse-intense-centered 1.5s infinite ease-in-out !important;

        background: linear-gradient(135deg, rgba(220, 38, 38, 0.95), rgba(153, 27, 27, 0.95)) !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        border-radius: 50px !important;

        text-transform: uppercase !important;
        letter-spacing: 1px !important;
        font-weight: 800 !important;
        font-size: 0.95rem !important;
    }

    .mobile-quakes-btn:active {
        animation: none !important;
        transform: translateX(-50%) scale(0.95) !important;
        background: rgba(220, 38, 38, 1) !important;
    }

    /* Flashing Live Dot Animation */
    @keyframes dot-flash {
        0% {
            background-color: #ffffff;
            box-shadow: 0 0 10px rgba(255, 255, 255, 0.9);
            transform: scale(1);
        }

        100% {
            background-color: #991b1b;
            box-shadow: 0 0 2px rgba(153, 27, 27, 0.5);
            transform: scale(0.85);
        }
    }

    .live-indicator-dot {
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: white;
        margin-right: 10px;
        animation: dot-flash 0.4s infinite alternate ease-in-out !important;
    }
}

/* Mobile Header Optimization V2 */
@media (max-width: 600px) {
    .header {
        padding: 0.5rem 4px 0.5rem 4px;
        /* Reduced bottom padding, using height instead */
        min-height: 200px;
        /* Force header to be tall */
    }

    .header-content {
        flex-direction: column;
        gap: 0.25rem;
        height: 100%;
        /* Fill the header height */
        justify-content: space-between;
        /* Logo Top, Controls Bottom */
    }

    /* Mobile Logo */
    .header-logo {
        margin-bottom: 0.5rem;
        background: transparent;
        display: block !important;
        /* Changed from flex to block for stability */
        visibility: visible !important;
        opacity: 1 !important;
        flex: 0 0 auto !important;
        /* Prevent shrinking */
        width: 100% !important;
        height: auto !important;
        min-height: 65px !important;
        text-align: center;
        /* Center the logo */
        position: relative !important;
        z-index: 200 !important;
    }

    .logo-img {
        height: 65px !important;
        width: auto !important;
        max-width: 280px !important;
        display: inline-block !important;
        /* Inline block to respect text-align */
        visibility: visible !important;
        opacity: 1 !important;
        object-fit: contain !important;
    }

    .logo {
        justify-content: center;
        margin-bottom: 0.25rem;
    }

    .header-controls {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    /* FLEX LAYOUT for Filters - Single Row */
    .filters-row {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 4px;
        width: 100%;
        align-items: flex-end;
    }

    /* Unwrap containers so order works */
    .archive-filter {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: flex-end !important;
        gap: 2px;
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        order: 1;
    }

    .input-group {
        display: contents !important;
    }

    /* Keep date-group as block so order works */
    .date-group {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .date-separator {
        display: none;
    }

    /* 3. CITY SELECT */
    .city-select-header {
        order: 3;
        width: auto;
        min-width: 80px;
        height: 32px;
        font-size: 0.65rem;
        padding: 0 4px;
        text-overflow: ellipsis;
    }

    /* ========================================
       PROFESSIONAL 4x2 GRID LAYOUT
       All buttons equal size (25% width each)
       ======================================== */

    /* Main filters container - 4 columns grid */
    .filters-row {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: auto auto;
        gap: 6px;
        width: 100%;
        align-items: end;
    }

    /* Unwrap all containers for grid placement */
    .archive-filter,
    .input-group,
    .view-toggles {
        display: contents !important;
    }

    /* Keep date-input-wrapper as a block element for placeholder positioning */
    .date-input-wrapper {
        display: block !important;
        position: relative !important;
        width: 100% !important;
        height: 40px !important;
    }

    .date-group {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Hide unnecessary elements */
    .date-separator {
        display: none !important;
    }

    .date-group label {
        display: block !important;
        font-size: 0.6rem;
        color: var(--text-muted);
        text-align: center;
        margin-bottom: 2px;
        font-weight: 500;
    }

    /* ========== ROW 1: City, Dates, Search ========== */

    /* 1. City Select (First) */
    .city-select-header {
        order: 1;
        grid-column: 1;
        grid-row: 1;
        width: 100% !important;
        height: 40px !important;
        border-radius: 8px;
        font-size: 0.6rem;
        padding: 0 6px;
        min-width: 0;
    }

    /* 2. Start Date */
    .archive-filter .date-group:nth-of-type(1) {
        order: 2;
        grid-column: 2;
        grid-row: 1;
    }

    .archive-filter .date-group:nth-of-type(1) .archive-date-input {
        width: 100%;
        height: 40px;
        border-radius: 8px;
        font-size: 0.7rem;
        padding: 0 4px;
    }

    /* 3. End Date */
    .archive-filter .date-group:nth-of-type(2) {
        order: 3;
        grid-column: 3;
        grid-row: 1;
    }

    .archive-filter .date-group:nth-of-type(2) .archive-date-input {
        width: 100%;
        height: 40px;
        border-radius: 8px;
        font-size: 0.7rem;
        padding: 0 4px;
    }

    /* Mobile placeholder styles for date inputs */
    .archive-date-input::placeholder {
        color: rgba(255, 255, 255, 0.6) !important;
        opacity: 1 !important;
        font-size: 0.65rem;
        text-align: center;
    }

    .archive-date-input::-webkit-input-placeholder {
        color: rgba(255, 255, 255, 0.6) !important;
        opacity: 1 !important;
        font-size: 0.65rem;
        text-align: center;
    }

    /* Force show date placeholder span on mobile */
    .date-input-wrapper {
        position: relative !important;
        display: block !important;
        width: 100% !important;
        height: 40px !important;
    }

    /* Hide browser default date picker text when empty */
    .archive-date-input:not(:focus):invalid::-webkit-datetime-edit {
        color: transparent !important;
    }

    .archive-date-input::-webkit-datetime-edit-text,
    .archive-date-input::-webkit-datetime-edit-month-field,
    .archive-date-input::-webkit-datetime-edit-day-field,
    .archive-date-input::-webkit-datetime-edit-year-field {
        color: transparent !important;
    }

    .archive-date-input:focus::-webkit-datetime-edit-text,
    .archive-date-input:focus::-webkit-datetime-edit-month-field,
    .archive-date-input:focus::-webkit-datetime-edit-day-field,
    .archive-date-input:focus::-webkit-datetime-edit-year-field {
        color: var(--text-primary) !important;
    }

    .date-placeholder {
        display: block !important;
        position: absolute !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        color: rgba(255, 255, 255, 0.8) !important;
        font-size: 0.6rem !important;
        pointer-events: none !important;
        z-index: 100 !important;
        white-space: nowrap !important;
        visibility: visible !important;
        opacity: 1 !important;
        background: transparent !important;
    }

    /* 4. Search Button (Last) */
    .archive-search-btn {
        order: 4;
        grid-column: 4;
        grid-row: 1;
        width: 100% !important;
        max-width: 100% !important;
        height: 40px !important;
        border-radius: 8px;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.1rem;
    }

    /* ========== ROW 2: Toggle Buttons ========== */

    /* Common styles for all toggle buttons */
    .toggle-btn,
    .iso-toggle-btn {
        height: 40px !important;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 0 6px;
        font-size: 0.75rem;
        font-weight: 500;
    }

    /* 5. Fay Button */
    #toggleFaultLines {
        order: 5;
        grid-column: 1;
        grid-row: 2;
    }

    /* 6. 3D Button */
    #toggle3D {
        order: 6;
        grid-column: 2;
        grid-row: 2;
    }

    /* 7. Heat Button */
    #toggleHeatmap {
        order: 7;
        grid-column: 3;
        grid-row: 2;
    }

    /* 8. Isoseist Button */
    #toggleIsoMap {
        order: 8;
        grid-column: 4;
        grid-row: 2;
    }

    /* Button text and icons */
    .toggle-btn .btn-text,
    .iso-toggle-btn .btn-text {
        font-size: 0.7rem;
    }

    .toggle-btn .icon,
    .iso-toggle-btn .iso-icon {
        font-size: 0.9rem;
    }

    .btn-icon,
    .heatmap-btn-icon,
    .iso-icon {
        width: 18px;
        height: 18px;
        object-fit: contain;
    }
}

/* SEO Content Section - Visually hidden but accessible for search engines */
.seo-h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.seo-content-section {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.seo-content-section h2,
.seo-content-section h3,
.seo-content-section p {
    margin: 0;
    padding: 0;
}

.seo-disclaimer,
.seo-cta-links,
.seo-contact {
    margin: 0;
    padding: 0;
}

.seo-cta-links a {
    display: inline;
}

/* CSS Fallback for iOS Fullscreen */
.force-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 9999 !important;
    background: #0f0f23 !important;
    /* Theme background */
    margin: 0 !important;
    padding: 0 !important;
}

/* Ensure controls stay on top in fake fullscreen */
.force-fullscreen .mapboxgl-control-container {
    z-index: 10000 !important;
}