.period-tabs {
    display: none;
    align-items: center;
    gap: 3px;
    padding: 2px 3px;
    height: 32px;
    min-height: 32px;
    max-height: 32px;
    box-sizing: border-box;
    border-radius: 10px;
    border: 1px solid rgba(71, 85, 105, .55);
    background: linear-gradient(180deg, rgba(15, 23, 42, .92), rgba(2, 6, 23, .98));
    box-shadow: inset 0 1px 0 rgba(148, 163, 184, .08), 0 8px 24px rgba(2, 6, 23, .34);
}

.period-tab {
    border: 1px solid transparent;
    background: transparent;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    border-radius: 7px;
    height: 26px;
    min-height: 26px;
    max-height: 26px;
    line-height: 24px;
    padding: 0 11px;
    cursor: pointer;
    transition: all .2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    box-sizing: border-box;
}

.period-tab:hover {
    color: #e2e8f0;
    background: rgba(148, 163, 184, .08);
    border-color: rgba(100, 116, 139, .42);
}

.period-tab.active {
    color: #fef08a;
    border-color: rgba(234, 179, 8, .55);
    background: linear-gradient(180deg, rgba(120, 53, 15, .75), rgba(92, 37, 8, .7));
    box-shadow: 0 0 0 1px rgba(250, 204, 21, .18) inset, 0 6px 16px rgba(146, 64, 14, .3);
}

.period-tab:focus-visible {
    outline: 2px solid transparent;
    box-shadow: 0 0 0 2px rgba(250, 204, 21, .35);
}

.period-filter-wrap {
    display: none !important;
    width: 116px;
    height: 32px;
    min-height: 32px;
    max-height: 32px;
    position: relative;
    flex-shrink: 0;
    box-sizing: border-box;
}

.period-filter {
    width: 100%;
    height: 32px;
    min-height: 32px;
    max-height: 32px;
    line-height: 30px;
    box-sizing: border-box;
    border-radius: 10px;
    border: 1px solid rgba(71, 85, 105, .65);
    background: linear-gradient(180deg, rgba(13, 23, 42, .94), rgba(7, 14, 30, .98));
    color: #f8fafc;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 0 24px 0 10px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    box-shadow: inset 0 1px 0 rgba(148, 163, 184, .08);
    transition: border-color .2s ease, box-shadow .2s ease;
    cursor: pointer;
}

.period-filter:hover {
    border-color: rgba(100, 116, 139, .8);
}

.period-filter:focus,
.period-filter:focus-visible {
    outline: none !important;
    border-color: rgba(148, 163, 184, .85);
    box-shadow: none !important;
}

.period-filter:focus-visible {
    outline: 2px solid rgba(250, 204, 21, .65) !important;
    outline-offset: 2px;
    border-color: #eab308;
    box-shadow: 0 0 0 2px rgba(234, 179, 8, .25) !important;
}

.period-filter-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: #94a3b8;
    pointer-events: none;
    transition: transform .2s ease;
}

.period-filter option {
    background: #0f172a;
    color: #f8fafc;
    font-weight: 700;
}

/* ── Curriculum Division Switcher Override (styles.css hides .curriculum-filter-wrap at >=768px for profile tabs; leaderboard keeps it visible) ── */
.curriculum-filter-wrap {
    display: inline-flex !important;
}

.curriculum-filter option {
    background: #0f172a;
    color: #f8fafc;
    font-weight: 700;
    padding: 6px 10px;
}

.leaderboard-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: start
}

@media(min-width:1024px) {
    .leaderboard-layout {
        grid-template-columns: minmax(300px, 34%) minmax(0, 66%);
        gap: 16px
    }

    .leaderboard-layout .top4-shell {
        order: 1
    }

    .leaderboard-layout .rankings-shell {
        order: 2
    }
}

.top4-shell {
    border: 1px solid rgba(51, 65, 85, .7);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(15, 23, 42, .95), rgba(2, 6, 23, .98));
    overflow: hidden
}

.top4-head {
    padding: 13px 14px;
    border-bottom: 1px solid rgba(51, 65, 85, .5);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px
}

.top4-title {
    font-size: 12px;
    font-weight: 900;
    color: #f8fafc;
    letter-spacing: .16em;
    text-transform: uppercase
}

.top4-sub {
    font-size: 9px;
    color: #64748b;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .12em
}

.top4-list {
    padding: 10px;
    display: grid;
    gap: 8px
}

.top4-item {
    --top4-media-size: 96px;
    border: 1px solid rgba(51, 65, 85, .6);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(12, 18, 36, .96), rgba(7, 12, 28, .96));
    overflow: hidden;
    display: grid;
    grid-template-columns: var(--top4-media-size) 1fr;
    align-items: stretch;
    min-height: var(--top4-media-size);
    height: var(--top4-media-size)
}

.top4-media {
    position: relative;
    width: var(--top4-media-size);
    height: var(--top4-media-size);
    aspect-ratio: 1/1;
    border-right: 1px solid rgba(51, 65, 85, .45);
    background: linear-gradient(145deg, rgba(30, 41, 59, .75), rgba(15, 23, 42, .96))
}

.top4-photo {
    width: 100%;
    height: 100%;
    object-fit: cover
}

.top4-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 900;
    color: #f8fafc
}

.top4-rank {
    position: absolute;
    top: 7px;
    left: 7px;
    min-width: 28px;
    height: 28px;
    border-radius: 9px;
    border: 1px solid;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 900;
    background: rgba(2, 6, 23, .45);
    color: #f8fafc
}

.top4-item.rank-1 .top4-rank {
    color: #111827;
    border-color: rgba(251, 191, 36, .75);
    background: linear-gradient(135deg, #fde68a, #fbbf24)
}

.top4-item.rank-2 .top4-rank {
    color: #0f172a;
    border-color: rgba(203, 213, 225, .82);
    background: linear-gradient(135deg, #e2e8f0, #94a3b8)
}

.top4-item.rank-3 .top4-rank {
    color: #111827;
    border-color: rgba(217, 119, 6, .72);
    background: linear-gradient(135deg, #fbbf24, #b45309)
}

.top4-body {
    padding: 7px 10px 6px;
    min-width: 0
}

.top4-name {
    font-size: 12px;
    font-weight: 900;
    line-height: 1.1;
    color: #f8fafc;
    text-transform: uppercase;
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.top4-id {
    margin-top: 1px;
    font-size: 9px;
    line-height: 1.2;
    color: #64748b;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace
}

.top4-score {
    margin-top: 4px;
    font-size: 24px;
    line-height: 1;
    font-weight: 900
}

.top4-meta {
    margin-top: 4px;
    font-size: 8px;
    line-height: 1.1;
    color: #64748b;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em
}

.rankings-shell {
    border: 1px solid rgba(51, 65, 85, .7);
    border-radius: 18px;
    background: transparent;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0
}

.rank-shell-head {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(51, 65, 85, .45);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap
}

.rank-shell-title {
    font-size: 12px;
    font-weight: 900;
    color: #f8fafc;
    letter-spacing: .15em;
    text-transform: uppercase
}

.rank-shell-count {
    font-size: 10px;
    color: #64748b;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase
}

.rankings-list {
    display: grid;
    width: 100%;
    min-height: 0;
    overflow: visible;
}

.rankings-shell .rankings-list {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, .45) transparent;
}

.rankings-list::-webkit-scrollbar {
    width: 8px
}

.rankings-list::-webkit-scrollbar-track {
    background: transparent
}

.rankings-list::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, .35);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box
}

.rankings-list::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, .55)
}

.rank-row {
    transition: background-color .2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid rgba(51, 65, 85, .36)
}

.rank-row:hover {
    background: rgba(255, 255, 255, .02)
}

.rank-row.is-you {
    background: rgba(234, 179, 8, .05);
    border-left: 3px solid #eab308;
    padding-left: 11px
}

.rank-medal {
    min-width: 28px;
    width: auto;
    height: 28px;
    padding: 0 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 900;
    flex-shrink: 0;
    border: 1px solid rgba(51, 65, 85, .8);
    color: #94a3b8;
    background: rgba(15, 23, 42, .8)
}

.rank-medal.rank-gold {
    color: #111827;
    border-color: rgba(251, 191, 36, .75);
    background: linear-gradient(135deg, #fde68a, #fbbf24)
}

.rank-medal.rank-silver {
    color: #0f172a;
    border-color: rgba(203, 213, 225, .8);
    background: linear-gradient(135deg, #e2e8f0, #94a3b8)
}

.rank-medal.rank-bronze {
    color: #111827;
    border-color: rgba(217, 119, 6, .7);
    background: linear-gradient(135deg, #fbbf24, #b45309)
}

.rank-avatar {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    border: 1px solid rgba(51, 65, 85, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    color: #fff
}

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

.rank-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center
}

.rank-meta {
    flex: 1;
    min-width: 0
}

.rank-name {
    font-size: 13px;
    color: #f8fafc;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.rank-id {
    margin-top: 2px;
    font-size: 10px;
    color: #64748b;
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.rank-attempts {
    margin-top: 2px;
    font-size: 10px;
    color: #64748b;
    font-weight: 600
}

.rank-score {
    text-align: right;
    flex-shrink: 0
}

.rank-score-main {
    font-size: 20px;
    font-weight: 900;
    line-height: 1
}

.rank-score-sub {
    margin-top: 2px;
    font-size: 9px;
    color: #475569;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase
}

.viewer-rank-extra {
    margin: 10px 12px 12px;
    border: 1px solid rgba(234, 179, 8, .34);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(120, 53, 15, .2), rgba(15, 23, 42, .5));
    overflow: hidden
}

.viewer-rank-card {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 64px;
    padding: 11px 12px
}

.viewer-rank-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 0;
    height: 28px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid rgba(250, 204, 21, .45);
    background: rgba(146, 64, 14, .3);
    color: #facc15;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .05em;
    text-transform: uppercase;
    flex-shrink: 0;
    white-space: nowrap
}

.viewer-rank-meta {
    flex: 1;
    min-width: 0
}

.viewer-rank-name {
    color: #f8fafc;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.viewer-rank-sub {
    margin-top: 2px;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 700;
    white-space: normal;
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: anywhere
}

.viewer-rank-score {
    text-align: right;
    flex-shrink: 0
}

.viewer-rank-score .score {
    font-size: 22px;
    font-weight: 900;
    line-height: 1
}

.viewer-rank-score .label {
    margin-top: 1px;
    color: #94a3b8;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase
}

@media(min-width:768px) {
    .period-tabs {
        display: inline-flex
    }

    .period-filter-wrap {
        display: none
    }
}

@media(max-width:1023px) {
    .top4-shell {
        position: static
    }
}

@media(max-width:640px) {
    .top4-item {
        --top4-media-size: 92px
    }

    .rank-row {
        padding: 11px 12px;
        gap: 8px
    }

    .rank-score-main {
        font-size: 18px
    }
}

@media(max-width:360px) {
    .top4-item {
        --top4-media-size: 76px
    }

    .top4-fallback {
        font-size: 24px
    }

    .top4-score {
        font-size: 20px
    }
}

/* ── Extra-compact for narrow phones (≤ 400px) ───────────────── */
@media(max-width:400px) {
    .rank-row {
        padding: 9px 10px;
        gap: 7px
    }

    .rank-medal {
        min-width: 24px;
        width: auto;
        height: 24px;
        padding: 0 6px;
        font-size: 11px;
        border-radius: 7px
    }

    .rank-avatar {
        width: 30px;
        height: 30px;
        border-radius: 8px;
        font-size: 11px
    }

    .rank-name {
        font-size: 12px
    }

    .rank-id {
        font-size: 9px
    }

    .rank-attempts {
        font-size: 9px
    }

    .rank-score-main {
        font-size: 16px
    }

    .rank-score-sub {
        font-size: 8px
    }

    .rank-shell-head {
        padding: 10px 12px
    }

    .rank-shell-title {
        font-size: 11px;
        letter-spacing: .1em
    }

    .rank-shell-count {
        font-size: 9px
    }

    .viewer-rank-card {
        gap: 8px;
        padding: 9px 10px
    }

    .viewer-rank-pill {
        min-width: 0;
        width: auto;
        height: 24px;
        font-size: 10px;
        padding: 0 6px
    }

    .viewer-rank-name {
        font-size: 12px
    }

    .viewer-rank-sub {
        font-size: 9px
    }

    .viewer-rank-score .score {
        font-size: 18px
    }
}

/* ── Ultra-compact for very narrow phones (≤ 340px) ──────────── */
@media(max-width:340px) {
    .rank-row {
        padding: 8px 8px;
        gap: 5px
    }

    .rank-medal {
        min-width: 22px;
        height: 22px;
        padding: 0 5px;
        font-size: 10px;
        border-radius: 6px
    }

    .rank-avatar {
        width: 26px;
        height: 26px;
        font-size: 10px
    }

    .rank-name {
        font-size: 11px
    }

    .rank-id {
        font-size: 8px
    }

    .rank-attempts {
        font-size: 8px;
        margin-top: 1px
    }

    .rank-score-main {
        font-size: 14px
    }

    .rank-score-sub {
        font-size: 7px
    }

    .top4-item {
        --top4-media-size: 66px
    }

    .top4-name {
        font-size: 10px
    }

    .top4-score {
        font-size: 18px
    }

    .top4-meta {
        font-size: 7px
    }
}

@media(min-width:1024px) {
    .top4-head {
        padding: 14px 16px
    }

    .top4-title {
        font-size: 13px
    }

    .top4-sub {
        font-size: 10px
    }

    .top4-list {
        padding: 12px;
        gap: 10px
    }

    .top4-item {
        --top4-media-size: 104px;
        border-radius: 16px
    }

    .top4-body {
        padding: 9px 12px 8px
    }

    .top4-name {
        font-size: 13px
    }

    .top4-id {
        margin-top: 2px;
        font-size: 10px
    }

    .top4-score {
        margin-top: 5px;
        font-size: 27px
    }

    .top4-meta {
        margin-top: 5px;
        font-size: 9px;
        letter-spacing: .09em
    }

    .rank-shell-head {
        padding: 14px 16px
    }

    .rank-shell-title {
        font-size: 13px
    }

    .rank-shell-count {
        font-size: 11px
    }

    .rank-row {
        gap: 10px;
        padding: 10px 15px
    }

    .rank-row.is-you {
        padding-left: 12px
    }

    .rank-medal {
        min-width: 29px;
        height: 29px;
        font-size: 12px;
        border-radius: 9px
    }

    .rank-avatar {
        width: 35px;
        height: 35px;
        border-radius: 11px;
        font-size: 12px
    }

    .rank-name {
        font-size: 13px;
        font-weight: 800
    }

    .rank-id {
        margin-top: 2px;
        font-size: 10px
    }

    .rank-attempts {
        margin-top: 2px;
        font-size: 10px
    }

    .rank-score-main {
        font-size: 22px
    }

    .rank-score-sub {
        margin-top: 2px;
        font-size: 9px
    }

    .viewer-rank-extra {
        margin: 12px 14px 14px
    }

    .viewer-rank-card {
        min-height: 64px;
        padding: 10px 12px;
        gap: 10px
    }

    .viewer-rank-pill {
        min-width: 0;
        width: auto;
        height: 28px;
        font-size: 11px;
        padding: 0 8px
    }

    .viewer-rank-name {
        font-size: 13px
    }

    .viewer-rank-sub {
        font-size: 10px
    }

    .viewer-rank-score .score {
        font-size: 22px
    }

    .viewer-rank-score .label {
        font-size: 9px
    }
}

/* ── Professional Leaderboard Grid (Left: 35% Top 5 / Right: 65% Rankings) ── */
:root {
    --site-header-height: 74px;
    --leaderboard-gap: 16px;
}

.leaderboard-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

@media (min-width: 1024px) {
    #main-content {
        padding-top: var(--leaderboard-gap, 16px) !important;
    }

    .leaderboard-grid {
        display: grid;
        grid-template-columns: clamp(340px, 35%, 430px) minmax(0, 1fr);
        gap: 24px;
        align-items: start;
    }

    .leaderboard-grid .top5-panel {
        order: 1;
        position: sticky;
        top: calc(var(--site-header-height, 74px) + var(--leaderboard-gap, 16px));
        align-self: start;
        z-index: 20;
    }

    .leaderboard-grid .rankings-area {
        order: 2;
        min-width: 0;
    }

    .leaderboard-grid .top5-head,
    .leaderboard-grid .rank-area-head {
        height: 66px;
        min-height: 66px;
    }
}

@media (max-width: 1023px) {
    .leaderboard-grid .top5-panel {
        order: 1;
    }

    .leaderboard-grid .rankings-area {
        order: 2;
    }
}

/* ── Left Side: Rankings Area ────────────────────────────────── */
.rankings-area {
    background: linear-gradient(145deg, #0f172a, #020617);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    overflow: hidden;
    /* backdrop-filter removed for performance */
    box-shadow: 0 12px 36px -10px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.rank-area-head {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.4);
    background: rgba(15, 23, 42, 0.65);
    display: flex;
    align-items: center;
    box-sizing: border-box;
    min-height: 66px;
}

.rank-area-title {
    font-size: 13px;
    font-weight: 900;
    color: #f8fafc;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    display: block;
}

.rank-area-count {
    margin-top: 2px;
    font-size: 10.5px;
    color: #94a3b8;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ── Rankings List (Full Natural Flow, No Nested Scrollbars) ── */
.rankings-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: visible;
    height: auto;
    max-height: none !important;
}

.rank-row {
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 18px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.3);
}

.rank-row:last-child {
    border-bottom: none;
}

.rank-row:hover {
    background: rgba(255, 255, 255, 0.035);
    transform: translateX(3px);
}

.rank-row.is-you {
    background: linear-gradient(90deg, rgba(234, 179, 8, 0.12), rgba(234, 179, 8, 0.02));
    border-left: 3px solid #eab308;
    padding-left: 15px;
}

.rank-avatar {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1.5px solid rgba(71, 85, 105, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

.rank-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 900;
    color: #f8fafc;
}

.rank-meta {
    flex: 1;
    min-width: 0;
}

.rank-name {
    font-size: 14px;
    font-weight: 800;
    color: #f8fafc;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-id {
    margin-top: 3px;
    font-size: 11px;
    color: #94a3b8;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.02em;
}

.rank-medal {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12.5px;
    font-weight: 900;
    flex-shrink: 0;
    border: 1px solid rgba(51, 65, 85, 0.8);
    color: #cbd5e1;
    background: rgba(15, 23, 42, 0.85);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.rank-medal.rank-gold {
    color: #111827;
    border-color: rgba(251, 191, 36, .75);
    background: linear-gradient(135deg, #fde68a, #fbbf24);
}

.rank-medal.rank-silver {
    color: #0f172a;
    border-color: rgba(203, 213, 225, .8);
    background: linear-gradient(135deg, #e2e8f0, #94a3b8);
}

.rank-medal.rank-bronze {
    color: #111827;
    border-color: rgba(217, 119, 6, .7);
    background: linear-gradient(135deg, #fbbf24, #b45309);
}

/* ── Right Side: Top 5 Hall of Fame Panel ─────────────────────── */
.top5-panel {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.86), rgba(2, 6, 23, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 20px;
    overflow: hidden;
    /* backdrop-filter removed for performance */
    box-shadow: 0 14px 40px -10px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.top5-head {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.45);
    background: linear-gradient(90deg, rgba(234, 179, 8, 0.09), transparent);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-sizing: border-box;
    min-height: 66px;
}

.top5-crown-icon {
    font-size: 20px;
    line-height: 1;
    filter: drop-shadow(0 0 10px rgba(234, 179, 8, 0.45));
}

.top5-title {
    font-size: 13px;
    font-weight: 900;
    color: #f8fafc;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    line-height: 1.1;
}

.top5-sub {
    font-size: 10px;
    color: #eab308;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.top5-badge-pill {
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(234, 179, 8, 0.15);
    border: 1px solid rgba(234, 179, 8, 0.35);
    color: #facc15;
}

.top5-list {
    padding: 14px 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 11px;
    overflow: visible;
}

/* ── Top 5 Individual Cards ───────────────────────────────────── */
.top5-card {
    border-radius: 16px;
    padding: 13px 15px;
    display: flex;
    align-items: center;
    gap: 13px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.top5-card:hover {
    transform: translateY(-2px);
}

/* Rank 1: Gold Champion */
.top5-card.rank-1 {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.15), rgba(15, 23, 42, 0.95));
    border: 1px solid rgba(234, 179, 8, 0.55);
    box-shadow: 0 6px 20px -4px rgba(234, 179, 8, 0.22);
}

.top5-card.rank-1::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #fbbf24, transparent);
}

/* Rank 2: Silver Runner-Up */
.top5-card.rank-2 {
    background: linear-gradient(135deg, rgba(203, 213, 225, 0.1), rgba(15, 23, 42, 0.95));
    border: 1px solid rgba(203, 213, 225, 0.38);
    box-shadow: 0 4px 16px -4px rgba(203, 213, 225, 0.14);
}

/* Rank 3: Bronze */
.top5-card.rank-3 {
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.1), rgba(15, 23, 42, 0.95));
    border: 1px solid rgba(217, 119, 6, 0.38);
    box-shadow: 0 4px 16px -4px rgba(217, 119, 6, 0.14);
}

/* Rank 4 & 5: Elite Performers */
.top5-card.rank-4,
.top5-card.rank-5 {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(51, 65, 85, 0.6);
}

.top5-card-badge {
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 900;
    flex-shrink: 0;
}

.top5-card.rank-1 .top5-card-badge {
    background: linear-gradient(135deg, #fde68a, #fbbf24);
    color: #111827;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.45);
}

.top5-card.rank-2 .top5-card-badge {
    background: linear-gradient(135deg, #f1f5f9, #94a3b8);
    color: #0f172a;
    box-shadow: 0 0 10px rgba(203, 213, 225, 0.3);
}

.top5-card.rank-3 .top5-card-badge {
    background: linear-gradient(135deg, #fcd34d, #b45309);
    color: #111827;
    box-shadow: 0 0 10px rgba(217, 119, 6, 0.3);
}

.top5-card.rank-4 .top5-card-badge,
.top5-card.rank-5 .top5-card-badge {
    background: rgba(30, 41, 59, 0.95);
    color: #94a3b8;
    border: 1px solid rgba(71, 85, 105, 0.6);
}

.top5-card-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.top5-card.rank-1 .top5-card-avatar {
    border: 2px solid rgba(251, 191, 36, 0.85);
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.35);
}

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

.top5-card-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 900;
    color: #f8fafc;
}

.top5-card-info {
    flex: 1;
    min-width: 0;
}

.top5-card-name {
    font-size: 13.5px;
    font-weight: 800;
    color: #f8fafc;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top5-card-meta {
    margin-top: 3px;
    font-size: 10.5px;
    color: #94a3b8;
    font-family: ui-monospace, monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top5-card-score {
    text-align: right;
    flex-shrink: 0;
}

.top5-card-score-val {
    font-size: 16px;
    font-weight: 900;
    line-height: 1;
}

.top5-card-score-sub {
    margin-top: 2px;
    font-size: 8px;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Bottom nav is defined in styles.css as .mobile-nav */

/* ── Avatar image safety: never let a profile photo escape its frame ── */
.rank-avatar img,
.top5-card-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    object-position: center;
}

/* ── Responsive avatar sizing (placed last so it wins over base rules) ── */
@media (max-width: 640px) {
    .top5-card {
        padding: 11px 12px;
        gap: 10px;
    }

    .top5-card-avatar {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .rank-row {
        padding: 11px 12px;
        gap: 10px;
    }

    .rank-row.is-you {
        padding-left: 9px;
    }
}

@media (max-width: 400px) {
    .rank-row {
        gap: 8px;
        padding: 9px 10px;
    }

    .rank-avatar {
        width: 32px;
        height: 32px;
        border-radius: 9px;
    }

    .rank-avatar-fallback {
        font-size: 12px;
    }

    .top5-card-avatar {
        width: 34px;
        height: 34px;
        border-radius: 9px;
    }

    .top5-card-badge {
        min-width: 30px;
        height: 30px;
        font-size: 12px;
    }
}

@media (max-width: 340px) {
    .rank-avatar {
        width: 28px;
        height: 28px;
        border-radius: 8px;
    }

    .top5-card-avatar {
        width: 30px;
        height: 30px;
    }
}

/* ── Leaderboard 1:1 Skeleton States ──────────────────────────── */
.top5-card.is-skeleton,
.rank-row.is-skeleton {
    pointer-events: none;
}

.top5-card.is-skeleton .top5-card-avatar,
.rank-row.is-skeleton .rank-avatar {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgba(51, 65, 85, 0.65);
    box-shadow: none;
}

.top5-card.rank-1.is-skeleton .top5-card-avatar {
    border-color: rgba(234, 179, 8, 0.45);
}

.top5-card.is-skeleton .top5-card-badge,
.rank-row.is-skeleton .rank-medal {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(51, 65, 85, 0.65);
    box-shadow: none;
    color: transparent;
}

.top5-card.rank-1.is-skeleton .top5-card-badge {
    background: rgba(234, 179, 8, 0.18);
    border-color: rgba(234, 179, 8, 0.4);
}

.top5-card.rank-2.is-skeleton .top5-card-badge {
    background: rgba(148, 163, 184, 0.16);
    border-color: rgba(148, 163, 184, 0.35);
}

.top5-card.rank-3.is-skeleton .top5-card-badge {
    background: rgba(217, 119, 6, 0.18);
    border-color: rgba(217, 119, 6, 0.38);
}