:root {
    --bg: #101214;
    --surface: #171a1d;
    --surface-2: #1d2125;
    --border: #2b3137;
    --text: #f2f4f5;
    --muted: #9da6ae;
    --soft: #68727c;
    --accent: #70b8ff;
    --accent-strong: #9bd0ff;
    --danger: #ff7b72;
    --success: #7ee787;
    --warning: #f2cc60;
    --radius: 8px;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
}

.shell {
    width: min(1360px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    gap: 28px;
    align-items: flex-start;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 3.35rem);
    line-height: 1.04;
    letter-spacing: 0;
}

.lede {
    max-width: 720px;
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 1rem;
}

.header-side {
    display: grid;
    gap: 14px;
    justify-items: end;
}

.nav-links {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.nav-links a {
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
    background: var(--surface-2);
    color: var(--text);
}

.last-update {
    display: grid;
    gap: 2px;
    margin: 0;
    color: var(--muted);
    text-align: right;
    font-size: 0.82rem;
}

.last-update strong {
    color: var(--text);
    font-size: 0.92rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 24px 0;
}

.metric,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.metric {
    padding: 18px;
}

.metric > span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 650;
    text-transform: uppercase;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 1.9rem;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
    padding: 16px;
}

.filters label {
    display: grid;
    gap: 7px;
}

.filters span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 650;
}

.recent-change-filters {
    grid-template-columns: minmax(220px, 320px);
    margin-bottom: 0;
}

input,
select {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #0d0f11;
    color: var(--text);
    padding: 8px 10px;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.table-panel {
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
}

.table-toolbar p {
    margin: 0;
}

.table-scroll {
    max-height: 70vh;
    overflow: auto;
}

table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
    text-transform: uppercase;
}

th[data-sort] {
    cursor: pointer;
}

th[data-sort]::after {
    content: "";
    display: inline-block;
    width: 0.55rem;
}

th.sorted-asc::after {
    content: "↑";
    color: var(--accent);
}

th.sorted-desc::after {
    content: "↓";
    color: var(--accent);
}

td {
    color: #dce2e6;
    font-size: 0.94rem;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.025);
}

.rank,
.time,
.days,
.improvement {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}

.rank {
    color: var(--warning);
    font-weight: 700;
}

.time {
    color: var(--success);
    font-weight: 700;
}

.numeric {
    text-align: right;
}

.days {
    display: inline-block;
    min-width: 4ch;
    color: var(--text);
    text-align: right;
}

.map-link {
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration: none;
}

.map-link:hover {
    text-decoration: underline;
}

.state-cell,
.empty-state {
    padding: 48px 18px;
    color: var(--muted);
    text-align: center;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid var(--border);
}

.pagination button {
    min-width: 76px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    padding: 8px 10px;
    cursor: pointer;
}

.pagination button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.pagination span {
    color: var(--muted);
    font-size: 0.9rem;
}

.changes-list {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}

.change-card {
    padding: 18px;
}

.change-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.change-title {
    margin: 0;
    font-size: 1.15rem;
}

.change-meta,
.change-date {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.comparison {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}

.record-box {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #0d0f11;
}

.record-label {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 750;
    text-transform: uppercase;
}

.record-time {
    margin: 0;
    color: var(--text);
    font-family: var(--mono);
    font-size: 1.25rem;
    font-weight: 750;
}

.record-player {
    margin: 4px 0 0;
    color: var(--muted);
}

.improvement {
    color: var(--success);
    font-weight: 750;
    text-align: center;
}

.footer-link {
    display: inline-block;
    margin-top: 2px;
}

@media (max-width: 860px) {
    .shell {
        width: min(100% - 24px, 1360px);
        padding: 20px 0;
    }

    .page-header {
        display: grid;
    }

    .header-side {
        justify-items: start;
    }

    .last-update {
        text-align: left;
    }

    .stats-grid,
    .filters,
    .comparison {
        grid-template-columns: 1fr;
    }

    .change-header {
        display: grid;
    }

    .pagination {
        flex-wrap: wrap;
    }
}
