/* Default (Dark Theme) - applied if no specific theme class is present or if system prefers dark */
:root {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --primary-text-color: #e0e0e0;
    --secondary-text-color: #b0b0b0;
    --border-color: #333;
    --accent-color: #4a90e2;
    --hover-bg-color: #2a2a2a;
    --rank-gold: #ffd700;
    --rank-silver: #c0c0c0;
    --rank-bronze: #cd7f32;
}

/* Light Theme Overrides - applied when body has 'light-theme' class */
body.light-theme {
    --bg-color: #f0f2f5;
    --surface-color: #ffffff;
    --primary-text-color: #333333;
    --secondary-text-color: #666666;
    --border-color: #e0e0e0;
    --accent-color: #1a73e8; /* A slightly different blue for light mode */
    --hover-bg-color: #f5f5f5;
    --rank-gold: #d4af37; /* Darker gold for contrast */
    --rank-silver: #a8a8a8;
    --rank-bronze: #b06b2a;
}

/* System Theme Handling: If system prefers light AND no explicit theme class is set */
@media (prefers-color-scheme: light) {
    body:not(.dark-theme):not(.light-theme) {
        /* Apply light theme variables */
        --bg-color: #f0f2f5;
        --surface-color: #ffffff;
        --primary-text-color: #333333;
        --secondary-text-color: #666666;
        --border-color: #e0e0e0;
        --accent-color: #1a73e8;
        --hover-bg-color: #f5f5f5;
        --rank-gold: #d4af37;
        --rank-silver: #a8a8a8;
        --rank-bronze: #b06b2a;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    background-color: var(--bg-color); /* Now uses variable */
    color: var(--primary-text-color); /* Now uses variable */
    margin: 0;
    padding: 2rem;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease; /* Smooth transition for theme change */
}

.container {
    width: 100%;
    padding: 0 0.25rem;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

h1 {
    font-size: 2.5rem;
    color: var(--primary-text-color);
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1.1rem;
    color: var(--secondary-text-color);
    max-width: 800px;
    margin: 0 auto;
}

/* Theme Switcher Styles */
.theme-switcher {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 1rem; /* Add some space above the switcher within the footer */
    margin-bottom: 0.5rem; /* Add a small space below it if needed, or remove if footer p handles it */
}

.theme-btn {
    background-color: var(--surface-color);
    color: var(--secondary-text-color);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.theme-btn:hover {
    background-color: var(--hover-bg-color);
    border-color: var(--accent-color);
}

.theme-btn.active {
    background-color: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}


/*  Filter Section and Controls  */
.filter-section {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

.filter-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-text-color);
    white-space: nowrap; /* Prevent label from wrapping */
}

.filter-controls {
    display: flex;
    flex-wrap: wrap; /* Allow buttons to wrap on smaller screens */
    justify-content: center;
    gap: 0.5rem;
}

.filter-btn {
    background-color: var(--surface-color);
    color: var(--secondary-text-color);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background-color: var(--hover-bg-color);
    border-color: var(--accent-color);
}

.filter-btn.active {
    background-color: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

/*  Table Wrapper for Horizontal Scroll  */
.table-wrapper {
    overflow-x: auto; /* Enables horizontal scrolling for the table */
    -webkit-overflow-scrolling: touch; /* Improves scrolling on iOS */
    margin-bottom: 2rem; /* Add some space below the table */
}

/*  Leaderboard Table  */
.leaderboard-table {
    width: 100%; /* Ensure table takes full width of its wrapper */
    min-width: 900px; /* Set a minimum width to prevent excessive squishing */
    border-collapse: collapse;
    background-color: var(--surface-color);
    border-radius: 8px;
    overflow: hidden; /* For rounded corners */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.leaderboard-table th, .leaderboard-table td {
    padding: 0.75rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.leaderboard-table thead {
    background-color: rgba(0,0,0,0.2); /* Still a bit transparent for dark/light */
}

.leaderboard-table th {
    font-weight: 600;
    color: var(--secondary-text-color);
    cursor: pointer;
    user-select: none;
    position: relative;
    white-space: nowrap; /* Prevent header text from wrapping */
}

.leaderboard-table th.sortable::after {
    content: ' ▲';
    opacity: 0.2;
    font-size: 0.8em;
}

.leaderboard-table th.sortable.asc::after { content: ' ▲'; opacity: 1; }
.leaderboard-table th.sortable.desc::after { content: ' ▼'; opacity: 1; }

.leaderboard-table tbody tr:hover {
    background-color: var(--hover-bg-color);
}

.leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

.rank {
    font-weight: bold;
    font-size: 1.2rem;
    text-align: center;
    width: 5%; /* Keep rank column narrow */
}

.model-name {
    font-weight: 500;
    font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
}

.model-name a {
    color: var(--primary-text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.model-name a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.score {
    text-align: center;
    font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
    font-size: 0.95rem; /* Slightly smaller font for scores */
    white-space: nowrap; /* Prevent scores from wrapping */
}

.overall-score {
    font-weight: bold;
    color: var(--accent-color);
}

footer {
    text-align: center;
    margin-top: 3rem;
    color: var(--secondary-text-color);
    font-size: 0.9rem;
}