:root {
    --rank-bg: #020c15;
    --rank-panel: #071725;
    --rank-panel-deep: #04111d;
    --rank-border: #203b50;
    --rank-border-soft: rgba(51, 82, 104, 0.56);
    --rank-text: #ffffff;
    --rank-muted: #94adbf;
    --rank-blue: #319cff;
    --rank-gold: #ffb800;
    --rank-green: #36de73;
    --rank-red: #ff4f57;
    --rank-purple: #a863ff;
    --rank-silver: #b8d2e8;
    --rank-bronze: #d88442;
}

/* =========================================================
   PAGE SHELL
   ========================================================= */

.rankings-main {
    min-width: 0;
    min-height: calc(100vh - var(--header-height, 82px));
    padding: 25px 28px 18px;
    background:
        radial-gradient(circle at 47% 38%, rgba(255, 184, 0, 0.055), transparent 25%),
        radial-gradient(circle at 79% 17%, rgba(49, 156, 255, 0.06), transparent 28%),
        linear-gradient(145deg, #020a12, var(--rank-bg));
    color: var(--rank-text);
}

.rankings-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 14px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.rankings-page-header h1 {
    margin: 0 0 5px;
    color: #fff;
    font-size: 34px;
    line-height: 1.05;
}

.rankings-page-header p {
    margin: 0;
    color: #9fcaf0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 16px;
    font-style: italic;
}

.ranking-period-status {
    display: flex;
    min-width: 215px;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border: 1px solid var(--rank-border);
    border-radius: 8px;
    background: linear-gradient(145deg, rgba(8, 26, 41, 0.98), rgba(4, 15, 25, 0.98));
}

.ranking-period-status > i {
    color: var(--rank-blue);
    font-size: 22px;
}

.ranking-period-status > div {
    display: grid;
    gap: 3px;
}

.ranking-period-status strong {
    font-size: 13px;
}

.ranking-period-status span {
    color: var(--rank-muted);
    font-size: 10px;
}

/* Keep the driver card near the navigation. */
.dashboard-sidebar .sidebar-driver-card {
    margin-top: 24px;
}

/* =========================================================
   DRIVER / VTC TABS
   ========================================================= */

.ranking-type-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--rank-border);
    border-radius: 8px;
    background: var(--rank-panel-deep);
}

.ranking-type-tabs button {
    display: flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 0;
    border-right: 1px solid var(--rank-border);
    background: transparent;
    color: #a9bac7;
    cursor: pointer;
    font: inherit;
    font-size: 15px;
    font-weight: 800;
}

.ranking-type-tabs button:last-child {
    border-right: 0;
}

.ranking-type-tabs button.active {
    background: linear-gradient(90deg, rgba(255, 184, 0, 0.09), rgba(255, 184, 0, 0.025));
    color: var(--rank-gold);
    box-shadow: inset 0 -2px 0 var(--rank-gold);
}

.ranking-type-tabs button:disabled {
    cursor: default;
    opacity: 0.76;
}

.ranking-type-tabs button span {
    padding: 3px 7px;
    border: 1px solid rgba(49, 156, 255, 0.55);
    border-radius: 4px;
    background: rgba(49, 156, 255, 0.14);
    color: #6cbaff;
    font-size: 8px;
    text-transform: uppercase;
}

.ranking-type-tabs .ranking-vtc-link {
    display: flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    background: transparent;
    color: #a9bac7;
    font-size: 15px;
    font-weight: 800;
    text-decoration: none;
}

.ranking-type-tabs .ranking-vtc-link:hover {
    background: rgba(49, 156, 255, 0.08);
    color: #6cbaff;
}

.ranking-type-tabs .ranking-vtc-link + .ranking-vtc-link {
    border-left: 1px solid var(--rank-border);
}

.ranking-type-tabs .ranking-vtc-link.active {
    background: linear-gradient(90deg, rgba(255, 184, 0, 0.09), rgba(255, 184, 0, 0.025));
    box-shadow: inset 0 -2px 0 var(--rank-gold);
    color: var(--rank-gold);
    cursor: default;
    pointer-events: none;
}

/* =========================================================
   TOOLBAR
   ========================================================= */

.ranking-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.ranking-period-tabs {
    display: flex;
    padding: 4px;
    border: 1px solid var(--rank-border);
    border-radius: 7px;
    background: rgba(5, 17, 29, 0.96);
}

.ranking-period-tabs button {
    min-height: 34px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: #d4e0e8;
    cursor: pointer;
    font: inherit;
    font-size: 10px;
}

.ranking-period-tabs button.active {
    border-color: var(--rank-gold);
    background: rgba(255, 184, 0, 0.09);
    color: var(--rank-gold);
    font-weight: 800;
}

.ranking-category-select {
    position: relative;
    display: flex;
    width: min(330px, 100%);
    min-height: 43px;
    align-items: center;
    border: 1px solid var(--rank-border);
    border-radius: 7px;
    background: rgba(5, 17, 29, 0.98);
}

.ranking-category-select > i:first-of-type {
    position: absolute;
    left: 14px;
    color: #aac1d1;
    pointer-events: none;
}

.ranking-category-select > i:last-of-type {
    position: absolute;
    right: 14px;
    color: #aac1d1;
    font-size: 10px;
    pointer-events: none;
}

.ranking-category-select select {
    width: 100%;
    height: 41px;
    padding: 0 40px;
    border: 0;
    outline: 0;
    appearance: none;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 11px;
}

/* =========================================================
   MAIN GRID
   ========================================================= */

.rankings-content-grid {
    display: grid;
    grid-template-columns: minmax(780px, 1fr) minmax(315px, 350px);
    align-items: start;
    gap: 14px;
}

.rankings-primary-column,
.ranking-sidebar {
    display: grid;
    min-width: 0;
    align-content: start;
    gap: 12px;
}

/* =========================================================
   PODIUM
   ========================================================= */

.ranking-podium {
    position: relative;
    display: grid;
    min-height: 266px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
    gap: 16px;
    overflow: hidden;
    border: 1px solid var(--rank-border);
    border-radius: 9px;
    background:
        radial-gradient(circle at 50% 60%, rgba(255, 184, 0, 0.16), transparent 25%),
        linear-gradient(160deg, rgba(6, 21, 34, 0.99), rgba(3, 13, 23, 0.99));
}

.ranking-podium::before {
    position: absolute;
    width: 420px;
    height: 420px;
    top: -60px;
    left: 50%;
    border-radius: 50%;
    background: repeating-conic-gradient(from 0deg, rgba(255, 184, 0, 0.09) 0 2deg, transparent 2deg 13deg);
    content: "";
    opacity: 0.54;
    transform: translateX(-50%);
    pointer-events: none;
}

.podium-driver {
    position: relative;
    z-index: 1;
    display: grid;
    justify-items: center;
    align-content: end;
    padding-top: 28px;
}

.first-place { transform: translateY(-18px); }
.second-place { transform: translateY(7px); }
.third-place { transform: translateY(13px); }

.podium-medal {
    position: relative;
    display: grid;
    width: 39px;
    height: 39px;
    margin-bottom: -4px;
    place-items: center;
}

.podium-medal i {
    position: absolute;
    inset: 0;
    font-size: 39px;
}

.podium-medal span {
    position: relative;
    z-index: 1;
    margin-top: -7px;
    color: #07101a;
    font-size: 14px;
    font-weight: 900;
}

.first-place .podium-medal { color: #ffca3d; filter: drop-shadow(0 0 9px rgba(255, 184, 0, 0.55)); }
.second-place .podium-medal { color: var(--rank-silver); }
.third-place .podium-medal { color: var(--rank-bronze); }

.podium-avatar {
    width: 90px;
    height: 90px;
    margin-bottom: 7px;
    overflow: hidden;
    border: 3px solid;
    border-radius: 50%;
    background: #081b2a;
}

.first-place .podium-avatar {
    width: 103px;
    height: 103px;
    border-color: var(--rank-gold);
    box-shadow: 0 0 24px rgba(255, 184, 0, 0.34);
}

.second-place .podium-avatar { border-color: var(--rank-silver); }
.third-place .podium-avatar { border-color: var(--rank-bronze); }

.podium-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.podium-driver > strong {
    color: #fff;
    font-size: 16px;
}

.podium-driver > span {
    margin-top: 2px;
    font-size: 13px;
    font-weight: 900;
}

.first-place > span { color: var(--rank-gold); }
.second-place > span { color: var(--rank-silver); }
.third-place > span { color: #f1a263; }

.podium-base {
    display: grid;
    width: 88%;
    margin-top: 8px;
    gap: 0;
}

.podium-base span {
    height: 8px;
    border-radius: 50% 50% 0 0;
}

.podium-base span:nth-child(2) { width: 88%; margin-inline: auto; }
.podium-base span:nth-child(3) { width: 74%; margin-inline: auto; }
.first-place .podium-base span { background: linear-gradient(90deg, #815300, #ffbd1f, #815300); }
.second-place .podium-base span { background: linear-gradient(90deg, #4c6d88, #bdd8ec, #4c6d88); }
.third-place .podium-base span { background: linear-gradient(90deg, #6e351b, #d98043, #6e351b); }

/* =========================================================
   LEADERBOARD
   ========================================================= */

.leaderboard-card {
    overflow: hidden;
    border: 1px solid var(--rank-border);
    border-radius: 9px;
    background: linear-gradient(145deg, rgba(8, 24, 38, 0.99), rgba(4, 15, 25, 0.99));
}

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

.leaderboard-card table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.leaderboard-card th,
.leaderboard-card td {
    padding: 8px 11px;
    border-bottom: 1px solid rgba(46, 75, 96, 0.5);
    font-size: 10px;
    text-align: left;
    white-space: nowrap;
}

.leaderboard-card th {
    background: rgba(18, 39, 55, 0.78);
    color: #dce8f0;
    font-size: 9px;
    text-transform: uppercase;
}

.leaderboard-card th:first-child,
.leaderboard-card td:first-child { width: 58px; text-align: center; }
.leaderboard-card th:nth-child(2) { width: 20%; }

.leaderboard-card tbody tr:hover:not(.current-driver) {
    background: rgba(49, 156, 255, 0.05);
}

.leaderboard-card .current-driver {
    background: linear-gradient(90deg, rgba(49, 156, 255, 0.12), rgba(255, 184, 0, 0.055));
    box-shadow: inset 3px 0 0 var(--rank-blue), inset -1px 0 0 var(--rank-gold);
}

.leaderboard-card .current-driver td {
    border-top: 1px solid rgba(255, 184, 0, 0.7);
    border-bottom: 1px solid rgba(255, 184, 0, 0.7);
    color: #66b9ff;
    font-weight: 800;
}

.current-driver td:nth-child(2) span {
    color: var(--rank-muted);
    font-size: 8px;
}

.rank-up { color: var(--rank-green); }
.rank-down { color: var(--rank-red); }
.rank-neutral { color: #899cab; }
.rank-up i,
.rank-down i { margin-right: 5px; }

.leaderboard-card footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 13px;
    color: #8da7ba;
    font-size: 9px;
}

.leaderboard-card footer i {
    color: var(--rank-blue);
}

/* =========================================================
   RANKING SIDEBAR
   ========================================================= */

.ranking-side-card {
    overflow: hidden;
    border: 1px solid var(--rank-border);
    border-radius: 9px;
    background: linear-gradient(145deg, rgba(8, 24, 38, 0.99), rgba(4, 15, 25, 0.99));
}

.ranking-side-card h2 {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    padding: 13px 15px;
    border-bottom: 1px solid var(--rank-border-soft);
    background: transparent;
    color: #fff;
    font-size: 14px;
}

.current-rank-card {
    padding-bottom: 15px;
    border-color: rgba(49, 156, 255, 0.74);
    background: linear-gradient(145deg, rgba(10, 38, 59, 0.98), rgba(4, 17, 29, 0.98));
}

.current-rank-card h2 {
    border: 0;
    color: var(--rank-blue);
}

.current-rank-card > strong {
    display: block;
    padding: 0 15px;
    color: var(--rank-blue);
    font-size: 31px;
}

.current-rank-card p {
    margin: 3px 0 0;
    padding: 0 15px;
    color: #c0d0dc;
    font-size: 11px;
    font-style: italic;
}

.current-rank-card p b {
    color: #fff;
    font-style: normal;
}

.category-leaders {
    border-color: rgba(255, 184, 0, 0.42);
}

.category-leaders h2,
.category-leaders h2 i {
    color: var(--rank-gold);
}

.category-leaders ul,
.eligibility-card ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.category-leaders li {
    display: grid;
    grid-template-columns: 37px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(48, 77, 98, 0.44);
}

.category-leaders li:last-child { border-bottom: 0; }

.leader-icon {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid rgba(255, 184, 0, 0.45);
    border-radius: 50%;
    background: rgba(255, 184, 0, 0.08);
    color: var(--rank-gold);
}

.category-leaders li > span:nth-child(2) {
    display: grid;
    gap: 2px;
}

.category-leaders small {
    color: var(--rank-muted);
    font-size: 8px;
}

.category-leaders strong {
    font-size: 10px;
}

.category-leaders li > b {
    color: var(--rank-blue);
    font-size: 9px;
    white-space: nowrap;
}

.eligibility-card {
    border-color: rgba(54, 222, 115, 0.48);
}

.eligibility-card h2,
.eligibility-card h2 i {
    color: var(--rank-green);
}

.eligibility-card ul {
    display: grid;
    gap: 10px;
    padding: 13px 15px 15px;
}

.eligibility-card li {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #dbe7ee;
    font-size: 10px;
}

.eligibility-card li i {
    color: var(--rank-green);
}

.ranking-privacy-card {
    border-color: rgba(168, 99, 255, 0.52);
}

.ranking-privacy-card h2,
.ranking-privacy-card h2 i {
    color: var(--rank-purple);
}

.ranking-privacy-card > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 15px;
}

.ranking-privacy-card span {
    color: #d9e4eb;
    font-size: 10px;
}

.ranking-privacy-card a {
    padding: 8px 12px;
    border: 1px solid var(--rank-blue);
    border-radius: 5px;
    color: var(--rank-blue);
    font-size: 9px;
    font-weight: 800;
    text-decoration: none;
}

.ranking-privacy-card a:hover {
    background: var(--rank-blue);
    color: #03111d;
}

/* =========================================================
   CAPS SIGNATURE
   ========================================================= */

.rankings-caps-signature {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    margin-top: 17px;
    padding-top: 15px;
    border-top: 1px solid rgba(45, 73, 93, 0.52);
}

.rankings-caps-icon {
    display: grid;
    width: 40px;
    height: 44px;
    place-items: center;
    clip-path: polygon(50% 0, 92% 23%, 92% 76%, 50% 100%, 8% 76%, 8% 23%);
    background: rgba(49, 156, 255, 0.18);
    color: var(--rank-blue);
    font-size: 18px;
}

.rankings-caps-signature > div:last-child {
    display: grid;
    gap: 3px;
}

.rankings-caps-signature strong { font-size: 12px; }
.rankings-caps-signature strong span { color: var(--rank-blue); }
.rankings-caps-signature small { color: #8299aa; font-size: 9px; }

/* =========================================================
   ACCESSIBILITY
   ========================================================= */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =========================================================
   RESPONSIVE LAYOUT
   ========================================================= */

@media (max-width: 1500px) {
    .rankings-content-grid {
        grid-template-columns: minmax(690px, 1fr) 310px;
    }

    .leaderboard-card th,
    .leaderboard-card td {
        padding-inline: 8px;
        font-size: 9px;
    }
}

@media (max-width: 1280px) {
    .rankings-content-grid {
        grid-template-columns: 1fr;
    }

    .ranking-sidebar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .current-rank-card,
    .category-leaders {
        min-height: 100%;
    }
}

@media (max-width: 960px) {
    .rankings-main {
        padding: 22px 17px;
    }

    .ranking-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .ranking-period-tabs,
    .ranking-category-select {
        width: 100%;
    }

    .ranking-period-tabs {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .ranking-period-tabs button {
        padding-inline: 8px;
    }
}

@media (max-width: 700px) {
    .rankings-page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .rankings-page-header h1 { font-size: 28px; }
    .ranking-period-status { min-width: 0; }

    .ranking-type-tabs,
    .ranking-sidebar {
        grid-template-columns: 1fr;
    }

    .ranking-podium {
        min-height: 0;
        grid-template-columns: 1fr;
        padding: 20px;
    }

    .podium-driver,
    .first-place,
    .second-place,
    .third-place {
        grid-template-columns: 45px 58px minmax(0, 1fr) auto;
        align-items: center;
        justify-items: start;
        gap: 10px;
        width: 100%;
        padding: 0;
        transform: none;
    }

    .first-place { order: -1; }
    .podium-medal { margin: 0; }
    .podium-avatar,
    .first-place .podium-avatar { width: 56px; height: 56px; margin: 0; }
    .podium-driver > span { justify-self: end; }
    .podium-base { display: none; }

    .ranking-period-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Rankings page readability increase */

.ranking-period-status span,
.ranking-period-tabs button,
.ranking-category-select select {
    font-size: 12px;
}

.leaderboard-card th {
    font-size: 11px;
}

.leaderboard-card td {
    font-size: 12px;
}

.leaderboard-card footer {
    font-size: 11px;
}

.current-driver td:nth-child(2) span {
    font-size: 10px;
}

.category-leaders small {
    font-size: 10px;
}

.category-leaders strong,
.category-leaders li > b {
    font-size: 11px;
}

.eligibility-card li,
.ranking-privacy-card span {
    font-size: 11px;
}

.ranking-privacy-card a {
    font-size: 10px;
}

.rankings-caps-signature small {
    font-size: 10px;
}

/* Fix sidebar Achievement Points row */

.sidebar-achievement-points {
    display: grid;
    grid-template-columns: 20px auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    margin: 12px 0;
    padding: 9px 10px;
    border: 1px solid rgba(255, 189, 36, 0.28);
    border-radius: 5px;
    background: rgba(255, 189, 36, 0.06);
}

    .sidebar-achievement-points i {
        position: static;
        width: 20px;
        color: #ffbd24;
        font-size: 14px;
        text-align: center;
    }

    .sidebar-achievement-points strong {
        color: #ffbd24;
        font-size: 13px;
        white-space: nowrap;
    }

    .sidebar-achievement-points span {
        color: #9eb0bd;
        font-size: 9px;
        line-height: 1.2;
    }

/* =========================================================
   RANKINGS SELECT DROPDOWN FIX
   ========================================================= */

.ranking-category-select select {
    color-scheme: dark;
}

    .ranking-category-select select option {
        background: #06111d;
        color: #ffffff;
    }

        .ranking-category-select select option:checked {
            background: #12324b;
            color: #ffb800;
        }
