:root {
    --bg: #06090a;
    --panel: #10151a;
    --panel-strong: #151b20;
    --line: #293139;
    --text: #eef3f5;
    --muted: #a8b0b7;
    --gold: #f7c23d;
    --silver: #c7d0d8;
    --bronze: #c8874a;
    --green: #5cff28;
    --green-soft: #1fbf57;
    --green-dim: rgba(92, 255, 40, 0.2);
    --blue: #74b9ff;
    --red: #eb1a0a;
    --shadow: rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(90deg, rgba(92, 255, 40, 0.035) 1px, transparent 1px),
        linear-gradient(180deg, #070a0c 0%, #11171b 48%, #070a0c 100%);
    background-size: 26px 26px, 100% 100%;
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

.site-shell {
    margin: 0 auto;
    max-width: 1620px;
    overflow-x: hidden;
    padding: 36px;
}

.masthead {
    align-items: center;
    display: flex;
    justify-content: center;
    height: 235px;
    margin: -52px 0 -34px;
    overflow: hidden;
}

h1,
h2 {
    color: var(--gold);
    font-weight: 800;
    letter-spacing: 0;
    margin: 0;
}

h1 {
    font-size: clamp(28px, 4.4vw, 52px);
    line-height: 0.95;
}

.leaderboard-title-logo {
    display: block;
    height: auto;
    max-width: 760px;
    min-width: 0;
    object-fit: contain;
    object-position: center;
    width: min(41.6vw, 608px);
}

.sr-only {
    height: 1px;
    margin: -1px;
    overflow: hidden;
    position: absolute;
    width: 1px;
}

h2 {
    font-size: 22px;
}

.logo-on-dark,
.broker-cell img.logo-on-dark {
    background: #05070b;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.filter-details,
.leaderboard-panel {
    background: linear-gradient(145deg, rgba(19, 25, 30, 0.98), rgba(8, 12, 14, 0.98));
    border: 1px solid rgba(92, 255, 40, 0.18);
    border-radius: 8px;
    box-shadow: 0 18px 40px var(--shadow);
}

.filter-details {
    margin-bottom: 16px;
    overflow: hidden;
}

.filter-summary {
    align-items: center;
    color: var(--text);
    cursor: pointer;
    display: flex;
    font-size: 13px;
    font-weight: 800;
    gap: 12px;
    justify-content: space-between;
    list-style: none;
    min-height: 50px;
    padding: 14px 16px;
    text-transform: uppercase;
}

.filter-summary::-webkit-details-marker {
    display: none;
}

.filter-summary span:last-child {
    color: var(--muted);
    font-size: 11px;
}

.filter-summary::after {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--green);
    content: "+";
    display: inline-flex;
    flex: 0 0 28px;
    height: 28px;
    justify-content: center;
}

.filter-details[open] .filter-summary {
    border-bottom: 1px solid var(--line);
}

.filter-details[open] .filter-summary::after {
    content: "-";
}

.filter-summary:focus-visible {
    outline: 3px solid rgba(92, 255, 40, 0.28);
    outline-offset: -3px;
}

.control-panel {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(340px, 1.25fr) minmax(270px, 1fr) minmax(230px, 0.85fr) minmax(260px, 0.95fr) 140px;
    padding: 14px;
}

fieldset {
    border: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    min-width: 0;
    padding: 0;
}

legend {
    color: #85d879;
    display: block;
    font-size: 11px;
    font-weight: 800;
    margin-bottom: 8px;
    text-transform: uppercase;
}

label {
    align-items: center;
    background: #080d13;
    border: 1px solid #313941;
    border-radius: 7px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    font-size: 13px;
    font-weight: 800;
    gap: 7px;
    min-height: 36px;
    padding: 8px 10px;
}

.code-field {
    align-items: stretch;
    background: transparent;
    border: 0;
    cursor: default;
    display: grid;
    gap: 8px;
    min-height: 0;
    padding: 0;
}

.code-field span {
    color: #85d879;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.code-field input {
    background: #080d13;
    border: 1px solid #313941;
    border-radius: 7px;
    color: #ffffff;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    min-height: 38px;
    min-width: 0;
    outline: none;
    padding: 8px 10px;
}

.code-field input:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(92, 255, 40, 0.14);
}

label:has(input:checked) {
    background: rgba(92, 255, 40, 0.12);
    border-color: var(--green-soft);
    color: #ffffff;
}

input {
    accent-color: var(--green-soft);
}

button {
    background: #23bf6b;
    border: 1px solid #23bf6b;
    border-radius: 7px;
    color: var(--bg);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    min-height: 38px;
    text-transform: uppercase;
}

button:hover {
    filter: brightness(1.08);
}

button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.leaderboard-panel {
    overflow: hidden;
}

.panel-heading {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 16px;
}

.status-pill {
    border: 1px solid rgba(92, 255, 40, 0.45);
    border-radius: 999px;
    color: var(--green);
    font-size: 11px;
    font-weight: 800;
    padding: 6px 10px;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-pill.is-error {
    border-color: rgba(235, 26, 10, 0.72);
    color: #ffb5b0;
}

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
    text-align: left;
    white-space: nowrap;
}

th {
    color: #85d879;
    font-size: 12px;
    text-transform: uppercase;
}

td {
    color: var(--text);
    font-size: 14px;
}

.rank {
    color: #b4bec7;
    font-size: 18px;
    font-weight: 800;
}

.runner-name {
    color: #ffffff;
    font-weight: 800;
}

.broker-cell {
    align-items: center;
    display: flex;
    gap: 10px;
}

.broker-cell img {
    background: #ffffff;
    border-radius: 5px;
    height: 30px;
    object-fit: contain;
    padding: 4px 6px;
    width: 58px;
}

.fallback-logo {
    align-items: center;
    background: #05070b;
    border: 1px solid rgba(92, 255, 40, 0.45);
    border-radius: 5px;
    color: #85d879;
    display: inline-flex;
    font-size: 13px;
    font-weight: 800;
    height: 30px;
    justify-content: center;
    min-width: 58px;
    padding: 4px 6px;
}

.metric-value {
    color: #55e48a;
    font-family: Consolas, "Courier New", monospace;
    font-weight: 800;
}

.empty-row td {
    color: var(--muted);
    padding: 28px 14px;
    text-align: center;
}

.first-place {
    background: linear-gradient(90deg, rgba(247, 194, 61, 0.17), rgba(92, 255, 40, 0.055) 45%, transparent 100%);
}

.first-place td {
    border-bottom-color: rgba(247, 194, 61, 0.45);
}

.first-place .rank,
.first-place .runner-name,
.first-place .metric-value {
    color: var(--gold);
}

.first-place .rank {
    font-size: 22px;
}

.second-place {
    background: linear-gradient(90deg, rgba(199, 208, 216, 0.13), rgba(92, 255, 40, 0.035) 45%, transparent 100%);
}

.second-place td {
    border-bottom-color: rgba(199, 208, 216, 0.34);
}

.second-place .rank,
.second-place .runner-name,
.second-place .metric-value {
    color: var(--silver);
}

.third-place {
    background: linear-gradient(90deg, rgba(200, 135, 74, 0.14), rgba(92, 255, 40, 0.03) 45%, transparent 100%);
}

.third-place td {
    border-bottom-color: rgba(200, 135, 74, 0.36);
}

.third-place .rank,
.third-place .runner-name,
.third-place .metric-value {
    color: var(--bronze);
}

@media (max-width: 980px) {
    .masthead {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        height: auto;
        margin: 0 0 14px;
        overflow: visible;
    }

    .leaderboard-title-logo {
        height: auto;
        max-width: 448px;
        object-fit: contain;
        width: min(100%, 448px);
    }

    .control-panel {
        grid-template-columns: 1fr;
    }

    button {
        width: 100%;
    }
}

@media (max-width: 620px) {
    .site-shell {
        padding: 12px;
    }

    .leaderboard-title-logo {
        flex: 0 0 auto;
        height: auto !important;
        margin: -46px auto -46px !important;
        max-width: 224px !important;
        object-fit: contain !important;
        width: min(224px, calc(100vw - 64px)) !important;
    }

    .panel-heading {
        align-items: flex-start;
        flex-direction: column;
        padding: 12px;
    }

    h2 {
        font-size: 18px;
    }

    .filter-summary {
        padding: 12px;
    }

    .filter-summary span:last-child {
        display: none;
    }

    .control-panel {
        padding: 12px;
    }

    fieldset {
        gap: 6px;
    }

    label {
        flex: 1 1 auto;
        justify-content: center;
        padding: 8px;
    }

    .code-field {
        justify-content: stretch;
        width: 100%;
    }

    table {
        min-width: 640px;
    }

    th,
    td {
        padding: 10px 8px;
    }

    .rank {
        font-size: 16px;
    }

    .first-place .rank {
        font-size: 18px;
    }

    .broker-cell {
        gap: 6px;
    }

    .broker-cell img,
    .fallback-logo {
        height: 24px;
        min-width: 44px;
        padding: 3px 5px;
        width: 44px;
    }

    .broker-cell span:last-child {
        max-width: 112px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

}
