@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=League+Gothic&family=Lora:wght@400;600&family=Unbounded:wght@700&display=swap');

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #1A1208;
}
::-webkit-scrollbar-thumb {
    background: #3A2518;
    border-radius: 4px;
    border: 1px solid #6B5A3A;
}
::-webkit-scrollbar-thumb:hover {
    background: #6B5A3A;
}

/* Firefox scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: #3A2518 #1A1208;
}

/* Leaflet Zoom Controls */
.leaflet-bar {
    border: 1px solid #6B5A3A !important;
    box-shadow: none !important;
}
.leaflet-bar a {
    background-color: #2E2010 !important;
    color: #CFC3A3 !important;
    border-bottom: 1px solid #6B5A3A !important;
}
.leaflet-bar a:hover {
    background-color: #3A2518 !important;
    color: #C9901A !important;
}
.leaflet-bar a.leaflet-disabled {
    background-color: #1A1208 !important;
    color: #3A2518 !important;
}
.leaflet-control-zoom-in, .leaflet-control-zoom-out {
    font-family: 'IBM Plex Mono', monospace !important;
    font-weight: bold !important;
}

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

body {
    font-family: 'IBM Plex Mono', monospace;
    background: #1A1208;
    color: #CFC3A3;
}

.container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: #2E2010;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-header {
    border-bottom: 2px solid #C9901A;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.sidebar h1 {
    font-family: 'League Gothic', sans-serif;
    font-size: 2em;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 0.9;
    color: #C9901A;
    margin-bottom: 4px;
}

.showing-count {
    font-size: 0.75em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #6B5A3A;
}

.showing-count span {
    color: #C9901A;
    font-weight: 600;
}

.sidebar h2 {
    font-size: 0.75em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #6B5A3A;
    margin-bottom: 10px;
}

/* Featured Categories */
.featured-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.featured-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75em;
    font-weight: 600;
    letter-spacing: 0.05em;
    transition: all 0.2s;
}

.featured-btn.oil-gas {
    background: #3A2518;
    color: #ff6b6b;
    border: 2px solid #ff6b6b;
}

.featured-btn.oil-gas.active {
    background: #ff6b6b;
    color: #fff;
}

.featured-btn.radioactive {
    background: #3A2518;
    color: #ffd93d;
    border: 2px solid #ffd93d;
}

.featured-btn.radioactive.active {
    background: #ffd93d;
    color: #1A1208;
}

.featured-btn.arsenic {
    background: #3A2518;
    color: #6bcb77;
    border: 2px solid #6bcb77;
}

.featured-btn.arsenic.active {
    background: #6bcb77;
    color: #1A1208;
}

.featured-btn.all {
    background: #C9901A;
    color: #1A1208;
    border: 2px solid #C9901A;
}

.featured-btn.all:not(.active) {
    background: #3A2518;
    color: #C9901A;
}

/* Filter Section */
.filter-section {
    background: #1A1208;
    padding: 15px;
    border-radius: 8px;
}

.filter-section h3 {
    font-size: 0.75em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #C9901A;
    margin-bottom: 12px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.8em;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* Sliders */
.slider-group {
    margin-bottom: 15px;
}

.slider-group label {
    display: block;
    font-size: 0.8em;
    margin-bottom: 8px;
}

.slider-group input[type="range"] {
    width: 100%;
    accent-color: #C9901A;
}

.slider-value {
    text-align: center;
    font-size: 0.8em;
    color: #C9901A;
    margin-top: 4px;
}

/* Dual-handle range slider */
.dual-range {
    position: relative;
    height: 20px;
    margin: 8px 0;
}

.dual-range input[type="range"] {
    position: absolute;
    width: 100%;
    height: 6px;
    top: 7px;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

.dual-range input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #C9901A;
    cursor: pointer;
    pointer-events: auto;
    border: 2px solid #2E2010;
}

.dual-range input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #C9901A;
    cursor: pointer;
    pointer-events: auto;
    border: 2px solid #2E2010;
}

.dual-range-track {
    position: absolute;
    top: 7px;
    left: 0;
    right: 0;
    height: 6px;
    background: #3A2518;
    border-radius: 3px;
}

.dual-range-fill {
    position: absolute;
    top: 7px;
    height: 6px;
    background: #C9901A;
    border-radius: 3px;
}

/* Toggle */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-group span {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75em;
    letter-spacing: 0.05em;
    color: #CFC3A3;
    text-transform: uppercase;
}

.toggle {
    position: relative;
    width: 36px;
    height: 20px;
    background: #3A2518;
    border-radius: 10px;
    cursor: pointer;
}

.toggle input {
    display: none;
}

.toggle .slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #6B5A3A;
    border-radius: 50%;
    transition: all 0.2s;
}

.toggle input:checked + .slider {
    left: 19px;
    background: #C44B22;
}

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

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

.leaflet-tile-pane {
    filter: sepia(0.6) brightness(0.85);
}

/* Map Legend */
.map-legend {
    position: absolute;
    bottom: 30px;
    left: 10px;
    background: rgba(26, 18, 8, 0.95);
    border: 1px solid #3A2518;
    padding: 12px;
    border-radius: 8px;
    z-index: 1000;
    font-size: 0.75em;
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: 0.05em;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

/* Info Panel */
.info-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    bottom: 10px;
    width: 350px;
    background: rgba(26, 18, 8, 0.98);
    border: 1px solid #3A2518;
    border-radius: 8px;
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.info-panel.active {
    display: flex;
    flex-direction: column;
}

.info-header {
    padding: 15px;
    background: #C44B22;
    color: #fff;
}

.info-header h3 {
    font-family: 'League Gothic', sans-serif;
    font-weight: 400;
    font-size: 1.4em;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 0.9;
    margin-bottom: 4px;
}

.info-header .system-id {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8em;
    opacity: 0.8;
    letter-spacing: 0.1em;
}

.info-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5em;
    cursor: pointer;
}

.info-body {
    padding: 15px;
    flex: 1;
    overflow-y: auto;
}

.info-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.info-meta-item {
    background: #2E2010;
    padding: 10px;
    border-radius: 6px;
}

.info-meta-item .label {
    font-size: 0.7em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #6B5A3A;
}

.info-meta-item .value {
    font-size: 1em;
    color: #CFC3A3;
    margin-top: 2px;
}

.contaminant-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8em;
}

.contaminant-table th {
    text-align: left;
    padding: 8px;
    background: #2E2010;
    color: #6B5A3A;
    font-weight: 600;
    font-size: 0.75em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.contaminant-table td {
    padding: 8px;
    border-bottom: 1px solid #3A2518;
}

.contaminant-table tr.violation td {
    color: #ff6b6b;
}

.contaminant-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.contaminant-table tbody tr:hover {
    background: #3A2518;
}

.contaminant-table tbody tr.selected {
    background: #3A2010;
}

.contaminant-table tbody tr.selected td:first-child::before {
    content: '▼ ';
    color: #C9901A;
}

/* Inline chart row */
.contaminant-table tbody tr.chart-row {
    cursor: default;
}

.contaminant-table tbody tr.chart-row:hover {
    background: transparent;
}

.contaminant-chart-cell {
    padding: 10px 8px !important;
    background: #2E2010;
}

.contaminant-chart-cell svg {
    width: 100%;
    height: 100px;
}

.chart-label {
    font-size: 0.75em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6B5A3A;
    margin-bottom: 5px;
}

.level-bar {
    height: 6px;
    background: #3A2518;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.level-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.level-bar-fill.safe {
    background: #6bcb77;
}

.level-bar-fill.warning {
    background: #ffd93d;
}

.level-bar-fill.danger {
    background: #ff6b6b;
}

/* Trend Chart */
.trend-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #3A2518;
}

.trend-section h4 {
    font-size: 0.7em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #6B5A3A;
    margin-bottom: 10px;
}

#trend-chart {
    width: 100%;
    height: 120px;
}

/* Loading */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 2000;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #6B5A3A;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #3A2518;
    border-top-color: #C9901A;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* Welcome Modal */
.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.welcome-overlay.hidden {
    display: none;
}

.welcome-modal {
    background: #F2EEE3; /* Cream */
    border-radius: 8px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    color: #1A1208; /* Dark Brown */
}

.welcome-header {
    background: #C44B22; /* Rust */
    padding: 16px 24px; /* Reduced vertical padding */
    color: #fff;
    text-align: center;
}

.welcome-header h2 {
    font-family: 'League Gothic', sans-serif;
    font-weight: 400;
    font-size: 38px; /* Slightly smaller */
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 0.9;
    margin-bottom: 4px;
}

.welcome-header p {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.85;
}

.welcome-body {
    padding: 16px 24px; /* Reduced vertical padding */
    font-family: 'Lora', serif;
}

.welcome-body p {
    margin-bottom: 12px; /* Reduced margin */
    line-height: 1.5; /* Slightly tighter line height */
    color: #1A1208;
    font-size: 0.95em;
}

.welcome-stats {
    display: flex;
    justify-content: space-around;
    margin: 12px 0; /* Reduced margin */
    padding: 12px;
    background: rgba(196, 75, 34, 0.05); /* Light rust tint */
    border-radius: 8px;
}

.welcome-stat {
    text-align: center;
}

.welcome-stat-value {
    font-family: 'Unbounded', sans-serif;
    font-size: 1.5em;
    font-weight: 700;
    color: #C44B22; /* Rust */
}

.welcome-stat-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75em;
    text-transform: uppercase;
    color: #6B5A3A;
    margin-top: 4px;
}

.welcome-legend {
    display: flex;
    gap: 16px;
    margin: 16px 0;
    font-size: 0.8em;
    font-family: 'IBM Plex Mono', monospace;
    color: #6B5A3A;
}

.welcome-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.welcome-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px; /* Reduced from 20 */
    padding: 12px 24px 16px 24px; /* Reduced vertical padding */
    border-top: 1px solid #CFC3A3;
}

.welcome-footer label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85em;
    color: #3A2518; /* Darker brown for better contrast on cream */
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.welcome-footer input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.welcome-btn {
    background: #C44B22;
    color: #fff;
    border: none;
    padding: 8px 24px;
    border-radius: 4px;
    font-family: 'League Gothic', sans-serif;
    font-size: 1.4em;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s;
}

.welcome-btn:hover {
    background: #C9901A;
}

/* Year tabs */
.year-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.year-tab {
    padding: 4px 10px;
    background: #3A2518;
    border: none;
    border-radius: 4px;
    font-family: 'IBM Plex Mono', monospace;
    color: #6B5A3A;
    cursor: pointer;
    font-size: 0.75em;
    letter-spacing: 0.05em;
}

.year-tab.active {
    background: #C9901A;
    color: #1A1208;
}

.year-tab.has-violation {
    color: #ff6b6b;
}

.year-tab.has-violation.active {
    background: #ff6b6b;
    color: #fff;
}

/* Contaminant Picker */
.contaminant-picker { margin-top: 12px; max-height: 300px; overflow-y: auto; }
.contaminant-picker.hidden { display: none; }
.contaminant-search,
.search-container { position: relative; width: 100%; }
.search-input,
.contaminant-search { 
    width: 100%; 
    padding: 8px; 
    background: #D6CFB4; /* Caliche */
    border: 1px solid #6B5A3A; 
    border-radius: 4px; 
    color: #1A1208; /* Dark brown for readability on light background */
    font-family: 'IBM Plex Mono', monospace; 
    font-size: 0.8em; 
}
.search-input:focus,
.contaminant-search:focus { outline: none; border-color: #C9901A; }
.search-input::placeholder,
.contaminant-search::placeholder { color: #6B5A3A; opacity: 0.8; }

.checkbox-group input[type="checkbox"],
.welcome-footer input[type="checkbox"],
body.leaderboard .controls input[type="checkbox"],
.category-items input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    background-color: #D6CFB4; /* Caliche */
    margin: 0;
    width: 16px;
    height: 16px;
    border: 1px solid #3A2518;
    border-radius: 3px;
    display: grid;
    place-content: center;
    cursor: pointer;
    vertical-align: middle;
}

.checkbox-group input[type="checkbox"]::before,
.welcome-footer input[type="checkbox"]::before,
body.leaderboard .controls input[type="checkbox"]::before,
.category-items input[type="checkbox"]::before {
    content: "";
    width: 10px;
    height: 10px;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    background-color: #C9901A; /* Gold checkmark */
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.checkbox-group input[type="checkbox"]:checked,
.welcome-footer input[type="checkbox"]:checked,
body.leaderboard .controls input[type="checkbox"]:checked,
.category-items input[type="checkbox"]:checked {
    background-color: #1A1208; /* Dark background when checked */
    border-color: #C9901A; /* Gold border when checked */
}

.checkbox-group input[type="checkbox"]:checked::before,
.welcome-footer input[type="checkbox"]:checked::before,
body.leaderboard .controls input[type="checkbox"]:checked::before,
.category-items input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #2D1B0E;
    border: 1px solid #6B5A3A;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 5000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.search-results.hidden { display: none; }

.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #3A2518;
    transition: background 0.2s;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: #3A2518; }

.search-result-item .name {
    display: block;
    font-size: 0.9em;
    font-weight: 600;
    color: #C9901A; /* Gold theme color */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-item .meta {
    display: block;
    font-size: 0.75em;
    color: #6B5A3A;
    margin-top: 2px;
}
.category-group { margin-bottom: 8px; }
.accordion-header,
.category-header { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    cursor: pointer; 
    padding: 8px 12px; 
    background: #2E2010; 
    border-radius: 4px; 
    font-family: 'IBM Plex Mono', monospace; 
    font-size: 0.75em; 
    letter-spacing: 0.08em; 
    text-transform: uppercase; 
    color: #C9901A; 
    border: 1px solid #3A2518;
    margin-top: 10px;
}

.category-header {
    font-size: 0.7em; /* Slightly smaller as requested */
    padding: 6px 10px;
    background: #241a0d;
}

.accordion-header .chevron,
.category-header .chevron { transition: transform 0.2s; font-size: 0.7em; }

.accordion-header.expanded .chevron,
.category-header.expanded .chevron { transform: rotate(90deg); }

.accordion-content { display: none; padding: 15px 5px; border-left: 1px solid #3A2518; margin-left: 5px; }
.accordion-content.expanded { display: block; }
.category-items { padding-left: 20px; display: none; }
.category-items.expanded { display: block; }
.category-items label { 
    display: flex; 
    align-items: center; 
    gap: 8px;
    padding: 3px 0; 
    font-size: 0.8em; 
}
.picker-footer { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid #3A2518; }
.picker-btn { padding: 4px 10px; background: #3A2518; border: 1px solid #6B5A3A; border-radius: 4px; font-family: 'IBM Plex Mono', monospace; color: #6B5A3A; cursor: pointer; font-size: 0.75em; letter-spacing: 0.05em; }
.picker-btn:hover { color: #C9901A; border-color: #C9901A; }
#selected-count { font-size: 0.75em; color: #6B5A3A; margin-left: auto; letter-spacing: 0.05em; }
.gradient-legend { display: none; }
.gradient-legend.active { display: block; }
.gradient-bar { height: 12px; border-radius: 6px; background: linear-gradient(to right, #6bcb77, #ffd93d, #ff6b6b); margin-bottom: 6px; }
.gradient-labels { display: flex; justify-content: space-between; font-size: 0.7em; letter-spacing: 0.08em; color: #6B5A3A; }

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
    }

    .info-panel {
        width: calc(100% - 20px);
        top: auto;
        bottom: 10px;
        max-height: 50vh;
    }
}

/* ---------- Leaderboard page ---------------------------------------
   Scoped to body.leaderboard so these table/h1/body rules don't leak
   into the map page (index.html), which also uses this stylesheet. */

body.leaderboard { padding: 20px; }

body.leaderboard header {
    border-bottom: 2px solid #C9901A;
    padding-bottom: 12px;
    margin-bottom: 16px;
}
body.leaderboard h1 {
    font-family: 'League Gothic', sans-serif;
    font-weight: 400;
    font-size: 2.4em;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 0.9;
    color: #C9901A;
    margin-bottom: 6px;
}
body.leaderboard .sub {
    font-size: 0.75em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #6B5A3A;
}
body.leaderboard .sub a { color: #C9901A; text-decoration: none; }
body.leaderboard .sub a:hover { color: #C44B22; }

body.leaderboard .controls {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
body.leaderboard .controls input[type="text"] {
    background: #D6CFB4; /* Caliche */
    color: #1A1208; /* Dark brown */
    border: 1px solid #6B5A3A;
    padding: 8px 12px;
    border-radius: 4px;
    min-width: 280px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85em;
}
body.leaderboard .controls input[type="text"]:focus {
    outline: none;
    border-color: #C9901A;
}
body.leaderboard .controls input[type="text"]::placeholder {
    color: #6B5A3A;
    opacity: 0.8;
}
body.leaderboard .controls label {
    font-size: 0.75em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #6B5A3A;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
body.leaderboard .controls input[type="checkbox"] {
    width: 16px;
    height: 16px;
}
body.leaderboard .stats {
    font-size: 0.75em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #6B5A3A;
    margin-left: auto;
}
body.leaderboard .stats span { color: #C9901A; font-weight: 600; }

body.leaderboard table {
    width: 100%;
    border-collapse: collapse;
    background: #2E2010;
    font-size: 0.8em;
}
body.leaderboard thead th {
    background: #1A1208;
    color: #6B5A3A;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    border-bottom: 2px solid #C9901A;
    position: sticky;
    top: 0;
}
body.leaderboard thead th:hover { color: #C9901A; }
body.leaderboard thead th.sorted-asc,
body.leaderboard thead th.sorted-desc { color: #C9901A; }
body.leaderboard thead th.sorted-asc::after { content: " ▲"; }
body.leaderboard thead th.sorted-desc::after { content: " ▼"; }
body.leaderboard thead th.num,
body.leaderboard td.num { text-align: right; font-variant-numeric: tabular-nums; }
body.leaderboard tbody tr { transition: background 0.15s; }
body.leaderboard tbody tr:nth-child(even) { background: #3A2010; }
body.leaderboard tbody tr:hover { background: #3A2518; }
body.leaderboard td {
    padding: 10px 12px;
    border-bottom: 1px solid #3A2518;
    vertical-align: top;
}
body.leaderboard .sid {
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: 0.05em;
}
body.leaderboard td a.sid-link,
body.leaderboard td a.name-link {
    color: #CFC3A3;
    text-decoration: none;
    border-bottom: 1px dotted #6B5A3A;
}
body.leaderboard td a.sid-link { color: #6B5A3A; }
body.leaderboard td a.sid-link:hover,
body.leaderboard td a.name-link:hover {
    color: #C9901A;
    border-bottom-color: #C9901A;
}
body.leaderboard .no-map {
    color: #6B5A3A;
    font-style: italic;
}
body.leaderboard .no-map-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    background: #3A2518;
    color: #6B5A3A;
    font-size: 0.7em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-radius: 3px;
    vertical-align: 1px;
}
body.leaderboard .severity-high {
    color: #ff6b6b;
    font-weight: 600;
}
body.leaderboard .worst {
    color: #6B5A3A;
    font-size: 0.85em;
    margin-top: 2px;
    letter-spacing: 0.05em;
}
body.leaderboard .explainer-text {
    font-family: 'Lora', serif;
    font-size: 0.9em;
    color: #C44B22;
    margin-top: 6px;
    line-height: 1.3;
    font-style: italic;
}
body.leaderboard .empty {
    padding: 40px;
    text-align: center;
    color: #6B5A3A;
    font-size: 0.75em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
body.leaderboard .unknown-pop {
    color: #6B5A3A;
    font-style: italic;
    cursor: help;
}
body.leaderboard .no-impact {
    color: #6B5A3A;
    cursor: help;
}

body.leaderboard {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    overflow-x: hidden;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
}

/* Explanation Popover */
.popover-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.popover-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.popover-content {
    background: #2E2010;
    border: 1px solid #C9901A;
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    position: relative;
}
.popover-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: #6B5A3A;
    font-size: 1.8em;
    cursor: pointer;
    line-height: 1;
}
.popover-close:hover { color: #C9901A; }
.popover-content h2 {
    font-family: 'League Gothic', sans-serif;
    font-size: 2em;
    color: #C9901A;
    text-transform: uppercase;
    margin-bottom: 20px;
    border-bottom: 1px solid #3A2518;
    padding-bottom: 10px;
}
.popover-section { margin-bottom: 12px; }

.popover-section h3 {
    font-family: 'League Gothic', sans-serif;
    font-size: 1.5em; /* Slightly smaller */
    color: #C9901A;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.popover-content p,
.popover-section p {
    font-family: 'Lora', serif;
    font-size: 0.9em;
    line-height: 1.6;
    color: #CFC3A3;
}

.popover-instruction {
    font-size: 0.8em !important;
    color: #6B5A3A !important;
    margin-top: -15px;
    margin-bottom: 25px;
}
.popover-section code {
    background: #1A1208;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85em;
    color: #C9901A;
}
.explain-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #3A2518;
    border: 1px solid #6B5A3A;
    color: #C9901A;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    margin-left: 10px;
    transition: all 0.2s;
}
.explain-trigger:hover {
    background: #C9901A;
    color: #1A1208;
    border-color: #C9901A;
}
