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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    background: #1e1e1e;
    color: #d4d4d4;
    min-height: 100vh;
}

a {
    color: #4ec9b0;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

a.platform-card:hover {
    text-decoration: none;
}

/* Header */
.header {
    background: #252526;
    border-bottom: 1px solid #3e3e42;
    padding: 20px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.header .logo {
    font-size: 36px;
}

.header .title {
    font-size: 26px;
    font-weight: bold;
    color: #4ec9b0;
}

.header .subtitle {
    font-size: 15px;
    color: #858585;
    margin-top: 2px;
}

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 15px;
    color: #858585;
}

.header-right a {
    color: #858585;
}

.header-right a:hover {
    color: #4ec9b0;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 32px;
}

/* Landing page grid */
.platforms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.platform-card {
    background: #252526;
    border: 1px solid #3e3e42;
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    text-decoration: none;
}

.platform-card:hover {
    border-color: #4ec9b0;
    background: #2a2d2e;
    text-decoration: none;
}

.platform-card .card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    gap: 8px;
}

.platform-card .card-labels {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.card-label {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-label-saturated {
    background: #3a3a4a;
    color: #9090c0;
    border: 1px solid #5a5a8a;
}

.platform-card .card-last-updated {
    display: block;
    font-size: 14px;
    color: #6a6a6a;
    margin-top: 8px;
}

.platform-card .card-name {
    font-size: 18px;
    font-weight: 600;
    color: #e0e0e0;
}

.platform-card .card-desc {
    font-size: 14px;
    color: #858585;
    margin-bottom: 12px;
    line-height: 1.4;
}

.platform-card .card-stats {
    display: flex;
    gap: 16px;
    font-size: 14px;
    margin-bottom: 12px;
}

.platform-card .stat-item {
    display: flex;
    flex-direction: column;
}

.platform-card .stat-value {
    font-weight: 600;
    color: #e0e0e0;
    font-size: 20px;
}

.platform-card .stat-label {
    color: #858585;
    font-size: 13px;
}

.progress-bar {
    height: 6px;
    background: #3e3e42;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Platform page */
.breadcrumb {
    font-size: 14px;
    color: #858585;
    margin-bottom: 16px;
}

.platform-header {
    margin-bottom: 32px;
}

.platform-header h1 {
    font-size: 26px;
    color: #e0e0e0;
    margin-bottom: 4px;
}

.platform-header .platform-desc {
    font-size: 15px;
    color: #858585;
    margin-bottom: 24px;
    line-height: 1.6;
}

.platform-header .platform-desc ul {
    margin: 8px 0 8px 20px;
    padding: 0;
}

.platform-header .platform-desc li {
    margin-bottom: 4px;
}

.platform-header .platform-desc em {
    color: #FFAF31;
}

.global-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.global-stats .stat-box {
    background: #252526;
    border: 1px solid #3e3e42;
    border-radius: 6px;
    padding: 12px 20px;
    min-width: 140px;
}

.global-stats .stat-box .stat-value {
    font-size: 26px;
    font-weight: 700;
    color: #4ec9b0;
}

.global-stats .stat-box .stat-label {
    font-size: 13px;
    color: #858585;
    margin-top: 2px;
}

.global-stats .stat-box-wide {
    min-width: 0;
    max-width: 280px;
}

.stat-value-model {
    font-size: 15px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.platform-card .stat-item-wide {
    min-width: 0;
    flex: 1;
    max-width: 200px;
}

.platform-card .stat-value-model {
    font-size: 13px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #4ec9b0;
}

/* Section headers */
.section-title {
    font-size: 17px;
    font-weight: 600;
    color: #e0e0e0;
    margin: 40px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #3e3e42;
}

/* Leaderboard */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    margin-bottom: 24px;
}

.leaderboard-table th {
    text-align: left;
    padding: 8px 12px;
    background: #2d2d30;
    color: #858585;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #3e3e42;
}

.leaderboard-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #2d2d30;
}

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

.leaderboard-table tbody tr:hover {
    background: #2a2d2e;
}

.leaderboard-table tbody tr.active {
    background: #1a3a2a;
    border-left: 3px solid #4ec9b0;
}

.leaderboard-table .completion-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.leaderboard-table .bar-bg {
    width: 80px;
    height: 6px;
    background: #3e3e42;
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
}

.leaderboard-table .bar-fill {
    display: block;
    height: 100%;
    border-radius: 3px;
}

/* Controls bar */
.controls-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-label {
    font-size: 13px;
    color: #858585;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

select.filter-select {
    background: #2d2d30;
    border: 1px solid #3e3e42;
    color: #d4d4d4;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

select.filter-select:focus {
    outline: none;
    border-color: #4ec9b0;
}

.view-toggle {
    display: flex;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    overflow: hidden;
    margin-left: auto;
}

.view-toggle button {
    background: #2d2d30;
    border: none;
    color: #858585;
    padding: 4px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.view-toggle button:not(:last-child) {
    border-right: 1px solid #3e3e42;
}

.view-toggle button.active {
    background: #3e3e42;
    color: #4ec9b0;
}

.view-toggle button:hover:not(.active) {
    background: #353535;
}

.clear-filters-btn {
    background: none;
    border: 1px solid #3e3e42;
    color: #858585;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.clear-filters-btn:hover {
    color: #4ec9b0;
    border-color: #4ec9b0;
}

.active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #1a3a2a;
    border: 1px solid #4ec9b0;
    color: #4ec9b0;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 13px;
}

.active-filter-tag .remove-filter {
    cursor: pointer;
    font-weight: bold;
    margin-left: 2px;
}

/* Challenge table */
.challenge-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

.challenge-table th {
    text-align: left;
    padding: 8px 10px;
    background: #2d2d30;
    color: #858585;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #3e3e42;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.challenge-table th:hover {
    color: #4ec9b0;
}

.challenge-table th .sort-arrow {
    margin-left: 4px;
    font-size: 11px;
    opacity: 0.5;
}

.challenge-table th.sorted .sort-arrow {
    opacity: 1;
    color: #4ec9b0;
}

.challenge-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #2d2d30;
    white-space: nowrap;
}

.challenge-table tbody tr:hover {
    background: #2a2d2e;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 600;
}

.badge-success {
    background: rgba(46, 204, 64, 0.15);
    color: #2ECC40;
}

.badge-failed {
    background: rgba(255, 65, 54, 0.15);
    color: #FF4136;
}

.badge-error {
    background: rgba(255, 65, 54, 0.15);
    color: #FF4136;
}

.badge-running {
    background: rgba(30, 144, 255, 0.15);
    color: #1E90FF;
}

.badge-stopped {
    background: rgba(255, 133, 27, 0.15);
    color: #FF851B;
}

/* Difficulty badges */
.diff-very-easy, .diff-easy, .diff-apprentice, .diff-tier-0, .diff-tier-1, .diff-tier-2 {
    color: #2ECC40;
}
.diff-medium, .diff-practitioner {
    color: #FFAF31;
}
.diff-hard, .diff-expert {
    color: #FF4136;
}
.diff-insane {
    color: #B22222;
}

/* Links cell (replay + report) */
.links-cell {
    white-space: nowrap;
}

.links-cell a {
    font-size: 16px;
    margin-right: 4px;
    text-decoration: none;
}

/* Row count */
.row-count {
    font-size: 13px;
    color: #858585;
    margin-bottom: 8px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px;
    color: #858585;
}

.loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #3e3e42;
    border-top-color: #4ec9b0;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

/* Solves Over Time chart */
.chart-container {
    background: #252526;
    border: 1px solid #3e3e42;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}

.chart-wrap {
    position: relative;
    height: 460px;
}

.chart-legend {
    display: inline-flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 10px;
    background: #1a1a1a;
    border: 1px solid #2d2d30;
    border-radius: 4px;
    font-size: 11px;
    font-style: italic;
    color: #5a5a5a;
    line-height: 1.5;
}

.chart-legend::before {
    content: 'ℹ';
    font-style: normal;
    color: #3e3e42;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Matrix view */
.matrix-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #858585;
}

.matrix-toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.matrix-count {
    color: #5a5a5a;
    font-size: 12px;
    margin-left: auto;
}

.matrix-table {
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13px;
}

.matrix-ch-header {
    position: sticky;
    left: 0;
    z-index: 3;
    width: 240px;
    background: #2d2d30;
    text-align: left;
    padding: 8px 12px;
    color: #858585;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid #3e3e42;
    vertical-align: bottom;
}

th.matrix-model-header {
    width: 36px;
    height: 130px;
    vertical-align: bottom;
    padding: 4px 4px 8px;
    border: 1px solid #3e3e42;
    background: #2d2d30;
    overflow: hidden;
    text-align: center;
}

th.matrix-model-header > div {
    writing-mode: vertical-lr;
    transform: rotate(180deg);
    font-size: 11px;
    font-weight: 500;
    color: #858585;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 120px;
    cursor: default;
    display: inline-block;
}

.matrix-ch-name {
    position: sticky;
    left: 0;
    background: #1e1e1e;
    z-index: 1;
    padding: 4px 12px;
    border: 1px solid #2d2d30;
    min-width: 220px;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #d4d4d4;
    border-right: 2px solid #3e3e42;
}

.matrix-ch-name .matrix-diff {
    font-size: 11px;
}

.matrix-table tbody tr:hover .matrix-ch-name {
    background: #2a2d2e;
}

.matrix-table tbody tr:hover .matrix-cell {
    filter: brightness(1.3);
}

.matrix-cell {
    text-align: center;
    padding: 3px 2px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #2d2d30;
    width: 36px;
    min-width: 36px;
}

.matrix-na {
    background: transparent;
}

.matrix-solved {
    background: rgba(46, 204, 64, 0.15);
    color: #2ECC40;
}

.matrix-failed {
    background: rgba(255, 65, 54, 0.08);
    color: #FF4136;
}

.matrix-partial {
    background: rgba(255, 175, 49, 0.15);
    color: #FFAF31;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    .header {
        padding: 16px;
    }
    .platforms-grid {
        grid-template-columns: 1fr;
    }
    .global-stats {
        gap: 12px;
    }
    .controls-bar {
        gap: 8px;
    }
    .challenge-table {
        font-size: 13px;
    }
}
