/* Leaderboard: purchased identity styles sit inside a stable match sheet. */
.leaderboard-scene-with-nav {
    --lb-rank-gold: #ffd700;
    --lb-rank-silver: #c0c0c0;
    --lb-rank-bronze: #e5a465;
}

.lb-header-col { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lb-title-m0 { margin-bottom: 0; }
.lb-container { max-width: 980px; margin: 0 auto; width: 100%; }

.leaderboard-scene-with-nav .lb-filters {
    padding: 16px;
    margin-bottom: 8px;
    border-radius: var(--product-radius-control);
    background: var(--broadcast-surface);
    box-shadow: none;
    transform: none;
    will-change: auto;
}

.leaderboard-scene-with-nav .lb-filters::before { display: none; }

.leaderboard-scene-with-nav .lb-filter-row {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 16px;
}

.leaderboard-scene-with-nav .lb-filters .setting-group-inline {
    flex: 1 1 220px;
    gap: 8px;
}

.leaderboard-scene-with-nav .lb-filters .setting-group-inline > label {
    padding: 0;
    color: var(--broadcast-muted);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.4;
}

.leaderboard-scene-with-nav .lb-filters .cyber-select.select-sm {
    width: 100%;
    height: var(--product-control-compact) !important;
    min-height: var(--product-control-compact) !important;
    padding: 0 36px 0 12px;
    border-radius: var(--product-radius-control) !important;
    background-position: right 12px center;
    background-size: 12px auto;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0;
}

.leaderboard-scene-with-nav .lb-filters .cyber-select:focus-visible {
    outline: 3px solid var(--product-focus);
    outline-offset: 2px;
}

.leaderboard-scene-with-nav .scoreboard-table {
    flex: 1;
    min-height: 200px;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid var(--broadcast-line);
    border-radius: var(--product-radius-control);
    background: var(--broadcast-bg);
}

.lb-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0 4px;
    color: var(--broadcast-text);
    font-variant-numeric: tabular-nums;
}

.lb-col-rank { width: 48px; }
.lb-col-rating { width: 104px; }
.lb-col-matches { width: 100px; }
.lb-heading-short { display: none; }

.leaderboard-scene-with-nav .lb-table .sb-header {
    height: 40px;
    color: var(--broadcast-muted);
    font-family: var(--font-body);
    font-size: 0.875rem;
    line-height: 1.4;
}

.lb-table th {
    padding: 8px 4px;
    font-family: var(--font-body);
    font-weight: 600;
    letter-spacing: 0;
    text-align: center;
    overflow-wrap: anywhere;
}

.lb-table th.sb-rating,
.lb-table th.sb-matches {
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
}

.lb-table .sb-player-heading {
    padding-left: 12px;
    text-align: left;
}

.leaderboard-scene-with-nav .sb-row {
    height: 58px;
    background: var(--broadcast-surface);
}

.leaderboard-scene-with-nav .sb-row:nth-child(even) {
    background: var(--broadcast-surface-strong);
}

.lb-table td {
    padding: 0 4px;
    text-align: center;
    vertical-align: middle;
}

/* Rank and numeric cells never inherit a player's purchased background. */
.lb-table .sb-pos {
    font-size: 1rem;
    font-family: var(--font-body);
    font-weight: 700;
}

.lb-table .rank-1 .sb-pos { color: var(--lb-rank-gold); }
.lb-table .rank-2 .sb-pos { color: var(--lb-rank-silver); }
.lb-table .rank-3 .sb-pos { color: var(--lb-rank-bronze); }

.lb-table .sb-player {
    padding: 0;
    text-align: left;
}

.lb-table .sb-theme-zone {
    --sb-slant: 24px;
    isolation: isolate;
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
    height: 58px;
    padding: 0 calc(var(--sb-slant) + 8px) 0 12px;
    overflow: hidden;
}

.lb-table .sb-theme-bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    clip-path: polygon(0 0, 100% 0, calc(100% - var(--sb-slant)) 100%, 0 100%);
}

.lb-table .sb-avatar {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    margin-right: 12px;
    border: 1px solid var(--broadcast-line);
    border-radius: 50%;
    background-color: var(--broadcast-surface);
    background-position: center;
    background-size: cover;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2);
}

.lb-table .sb-name {
    min-width: 0;
    overflow: hidden;
    color: var(--broadcast-text);
    font-size: 1rem;
    font-weight: 700;
    text-align: left;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.lb-table .sb-name-backed {
    padding: 2px 6px;
    box-shadow: none;
    text-shadow: none;
}

.lb-table tbody .sb-rating,
.lb-table tbody .sb-matches {
    color: var(--broadcast-text);
    font-family: var(--font-body);
    font-weight: 700;
    overflow-wrap: anywhere;
    line-height: 1.3;
}

.lb-table tbody .sb-rating { font-size: 1.25rem; }
.lb-table tbody .sb-matches { font-size: 1rem; }

.lb-state {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px 16px;
    color: var(--broadcast-muted);
    font: 0.875rem/1.5 var(--font-body);
    text-align: center;
}

.lb-placeholder {
    height: 48px;
    border-radius: 4px;
    background: var(--broadcast-surface-strong);
}

.lb-error h2 { color: var(--broadcast-text); font-size: 1.25rem; }
.lb-error p { margin: 0; }
.lb-retry {
    align-self: center;
    padding: 8px 16px;
    color: var(--broadcast-text);
    font: 600 1rem/1.4 var(--font-body);
    cursor: pointer;
}

.lb-retry:focus-visible {
    outline: 3px solid var(--product-focus);
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .leaderboard-scene-with-nav .lb-filters { padding: 12px; }
    .leaderboard-scene-with-nav .lb-filter-row { gap: 12px; }
    .lb-col-rank { width: 32px; }
    .lb-col-rating { width: 70px; }
    .lb-col-matches { width: 70px; }
    .lb-heading-full { display: none; }
    .lb-heading-short { display: inline; }

    /* Keep the match sheet horizontal at every width, including narrow phones. */
    .leaderboard-scene-with-nav .lb-table .sb-row { height: 56px; }
    .lb-table .sb-player-heading { padding-left: 4px; }

    .lb-table .sb-theme-zone {
        --sb-slant: 8px;
        height: 56px;
        padding: 0 12px 0 4px;
    }

    .lb-table .sb-avatar {
        width: 28px;
        height: 28px;
        margin-right: 6px;
    }

    .lb-table .sb-name {
        flex: 1 1 auto;
        display: block;
        max-width: 100%;
        line-height: 1.2;
    }

    .lb-table .sb-name,
    .lb-table .sb-pos,
    .lb-table tbody .sb-rating,
    .lb-table tbody .sb-matches {
        font-size: 0.875rem;
        white-space: nowrap;
        overflow-wrap: normal;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 360px) {
    .lb-table .sb-avatar { width: 24px; height: 24px; }
}

/* The scene owns phone scrolling so every ranking remains reachable. */
@media (max-width: 700px) {
    .leaderboard-account-nav:has(#nav-user.hidden):has(#nav-profile.hidden) {
        display: none;
    }

    .leaderboard-scene-with-nav {
        box-sizing: border-box;
        align-items: flex-start;
        justify-content: flex-start;
        height: 100dvh;
        min-height: 100dvh;
        max-height: none;
        padding: calc(62px + env(safe-area-inset-top)) 0 max(24px, env(safe-area-inset-bottom)) !important;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior-y: contain;
    }

    .leaderboard-account-nav:has(#nav-user.hidden):has(#nav-profile.hidden) + .leaderboard-scene-with-nav {
        padding-top: max(8px, env(safe-area-inset-top)) !important;
    }

    .leaderboard-scene-with-nav .settings-view {
        position: relative;
        inset: auto;
        width: 100%;
        height: auto;
        min-height: 0;
        max-height: none;
        margin: 0;
        padding: 10px 14px 24px !important;
        overflow: visible !important;
    }

    .leaderboard-scene-with-nav .settings-header-wrapper { padding-bottom: 12px; }

    .leaderboard-scene-with-nav .settings-rounds-container {
        flex: 0 0 auto;
        width: 100%;
        height: auto;
        min-height: 0;
        max-height: none;
        padding: 0 !important;
        overflow: visible;
    }

    .leaderboard-scene-with-nav .lb-grid {
        flex: 0 0 auto;
        min-height: 200px;
        height: auto;
        max-height: none;
        overflow: hidden;
    }
}

/* Compact phone match sheet; keep rank, identity and both numbers on one row. */
@media (max-width: 700px) {
    .leaderboard-scene-with-nav {
        height: var(--app-visible-viewport-height, 100dvh);
        min-height: 0;
        padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
    }

    .leaderboard-scene-with-nav .settings-view { padding: 6px 8px 12px !important; }
    .leaderboard-scene-with-nav .settings-header-wrapper { padding-bottom: 6px; }
    .leaderboard-scene-with-nav .lb-filters { padding: 8px; }
    .leaderboard-scene-with-nav .lb-filter-row { gap: 6px 8px; }
    .leaderboard-scene-with-nav .lb-filters .setting-group-inline { gap: 4px; }
    .leaderboard-scene-with-nav .lb-filters .setting-group-inline > label { font-size: 0.75rem; }
    .leaderboard-scene-with-nav .lb-table .sb-header { min-height: 30px; height: 30px; font-size: 0.75rem; }
    .lb-table th { padding-block: 5px; }
    .lb-table { border-spacing: 0 3px; }
    .leaderboard-scene-with-nav .lb-table .sb-row { min-height: 44px; height: 44px; }
    .lb-table .sb-theme-zone { height: 44px; }
}
