/* Public leaderboard layout and table. Loaded after bundle.css to keep it isolated. */
body:not([data-active-page]) #rating-page,
body[data-active-page="rating"] #rating-page {
    background: none !important;
}

body #rating-page .rating-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 400px !important;
    grid-template-areas:
        "toolbar ."
        "main sidebar"
        "matches matches" !important;
    gap: 16px !important;
    align-items: start !important;
    background: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

body #rating-page .players-header {
    grid-area: toolbar !important;
    position: relative !important;
    min-height: 62px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

body #rating-page .players-header-title {
    width: 100% !important;
    min-height: 62px !important;
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

body #rating-page .players-header h2 {
    margin: 0 !important;
    color: #f0cf7a !important;
    font-family: "Cormorant Garamond", Georgia, serif !important;
    font-size: 34px !important;
    line-height: 38px !important;
    font-weight: 700 !important;
    letter-spacing: 0 !important;
    white-space: nowrap !important;
    order: 1 !important;
}

body #rating-page .season-button {
    height: 38px !important;
    margin-left: 4px !important;
    padding: 0 15px !important;
    flex: 0 0 auto !important;
    order: 2 !important;
}

body #rating-page .players-header-actions {
    position: static !important;
    margin-left: auto !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex: 0 0 auto !important;
    order: 3 !important;
}

body #rating-page .players-activity-filter {
    display: inline-flex !important;
    align-items: center !important;
    gap: 12px !important;
    flex: 0 0 auto !important;
}

body #rating-page .players-activity-filter-caption {
    color: #cba84f !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
}

body #rating-page .players-activity-filter-options {
    height: 38px !important;
    padding: 3px !important;
    display: inline-flex !important;
    align-items: stretch !important;
    border: 1px solid rgba(218, 166, 72, 0.3) !important;
    border-radius: 12px !important;
    background: rgba(7, 15, 24, 0.76) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035) !important;
}

body #rating-page .players-activity-filter-option {
    min-width: 96px !important;
    padding: 0 15px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    border: 1px solid transparent !important;
    border-radius: 9px !important;
    background: transparent !important;
    color: #c7ced8 !important;
    font: 700 11px/1 "Manrope", system-ui, sans-serif !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease !important;
}

body #rating-page .players-activity-filter-option:hover {
    color: #f5df9e !important;
}

body #rating-page .players-activity-filter-option.is-selected {
    border-color: rgba(228, 177, 64, 0.52) !important;
    background: linear-gradient(180deg, rgba(101, 75, 21, 0.9), rgba(59, 43, 14, 0.92)) !important;
    color: #ffd66b !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 236, 163, 0.18),
        0 0 13px rgba(226, 166, 42, 0.25) !important;
}

body #rating-page .players-activity-filter-option:focus-visible {
    outline: 2px solid rgba(255, 214, 107, 0.8) !important;
    outline-offset: 2px !important;
}

body #rating-page .players-activity-filter-indicator {
    width: 17px !important;
    height: 17px !important;
    flex: 0 0 auto !important;
    fill: currentColor !important;
    filter: drop-shadow(0 0 4px currentColor) !important;
}

body #rating-page .players-activity-filter > #active-players-filter {
    display: none !important;
}

body #rating-page .players-search-panel,
body #rating-page .players-filter-panel,
body #rating-page .players-add-panel {
    top: calc(100% + 8px) !important;
    right: 0 !important;
    left: auto !important;
    z-index: 30 !important;
}

body #rating-page .rating-main {
    grid-area: main !important;
    min-width: 0 !important;
}

body #rating-page .rating-sidebar {
    grid-area: sidebar !important;
    min-width: 0 !important;
    margin-top: 0 !important;
}

body #rating-page .recent-matches-panel {
    grid-area: matches !important;
}

body #rating-page .rating-players-list {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid rgba(218, 166, 72, 0.22) !important;
    border-radius: 10px !important;
    background: linear-gradient(180deg, rgba(8, 17, 27, 0.92), rgba(5, 12, 20, 0.88)) !important;
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.3) !important;
    overflow: hidden !important;
}

body #rating-page .rating-players-list::before,
body #rating-page .rating-players-list::after {
    content: none !important;
    display: none !important;
}

body #rating-page .rating-players-list > .table-container {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: hidden !important;
}

body #rating-page .rating-players-list > .table-container::before,
body #rating-page .rating-players-list > .table-container::after {
    content: none !important;
    display: none !important;
}

body #rating-page #players-table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    background: transparent !important;
}

body #rating-page #players-table thead th {
    height: 42px !important;
    padding: 0 9px !important;
    min-width: 0 !important;
    max-width: none !important;
    border-top: 0 !important;
    border-right: 0 !important;
    border-bottom: 1px solid rgba(218, 166, 72, 0.18) !important;
    border-left: 0 !important;
    box-shadow: none !important;
}

body #rating-page #players-table tbody tr {
    height: 35px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.055) !important;
}

body #rating-page #players-table tbody tr:last-child {
    border-bottom: 0 !important;
}

body #rating-page #players-table tbody td {
    height: 35px !important;
    padding: 2px 9px !important;
    min-width: 0 !important;
    max-width: none !important;
    border-top: 0 !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
    font-size: 13px !important;
    line-height: 16px !important;
}

body #rating-page #players-table th[data-column="position"],
body #rating-page #players-table td:nth-child(1) {
    width: 9% !important;
    padding-left: 7px !important;
}

body #rating-page #players-table th[data-column="nickname"],
body #rating-page #players-table td:nth-child(2) {
    width: 30.36% !important;
    min-width: 0 !important;
}

body #rating-page #players-table th[data-column="rating"],
body #rating-page #players-table td:nth-child(3) {
    width: 12% !important;
}

body #rating-page #players-table th[data-column="gamesPlayed"],
body #rating-page #players-table td.player-cell-games {
    width: 9% !important;
}

body #rating-page #players-table th[data-column="winLoss"],
body #rating-page #players-table td.player-cell-winloss {
    width: 15% !important;
}

body #rating-page #players-table th[data-column="winrate"],
body #rating-page #players-table td.winrate-cell {
    width: 15.64% !important;
    min-width: 0 !important;
    max-width: none !important;
}

body #rating-page #players-table .winrate-container,
body #rating-page #players-table .winrate-container.winrate-high {
    width: 83.33% !important;
    height: 9.18px !important;
    margin: 13px auto 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    max-width: none !important;
    border-radius: 2px !important;
    box-sizing: border-box !important;
}

body #rating-page #players-table .winrate-container .winrate-fill {
    border-radius: 1px !important;
}

body #rating-page #players-table .winrate-container .winrate-text {
    position: absolute !important;
    inset: auto 0 calc(100% + 2px) !important;
    display: block !important;
    height: 11px !important;
    color: #f8f0df !important;
    font-size: 11px !important;
    line-height: 11px !important;
    text-align: center !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85) !important;
    white-space: nowrap !important;
}

body #rating-page #players-table th[data-column="streak"],
body #rating-page #players-table tbody td:last-child {
    width: 9% !important;
    min-width: 0 !important;
    max-width: none !important;
}

body #rating-page #players-table.show-hideout-rating th[data-column="position"],
body #rating-page #players-table.show-hideout-rating td:nth-child(1) {
    width: 8% !important;
}

body #rating-page #players-table.show-hideout-rating th[data-column="nickname"],
body #rating-page #players-table.show-hideout-rating td:nth-child(2) {
    width: 25% !important;
}

body #rating-page #players-table.show-hideout-rating th[data-column="rating"],
body #rating-page #players-table.show-hideout-rating td:nth-child(3),
body #rating-page #players-table.show-hideout-rating th[data-column="rating2"],
body #rating-page #players-table.show-hideout-rating td.player-cell-hideout {
    width: 10% !important;
    min-width: 0 !important;
    max-width: none !important;
}

body #rating-page #players-table.show-hideout-rating th[data-column="gamesPlayed"],
body #rating-page #players-table.show-hideout-rating td.player-cell-games {
    width: 8% !important;
}

body #rating-page #players-table.show-hideout-rating th[data-column="winLoss"],
body #rating-page #players-table.show-hideout-rating td.player-cell-winloss {
    width: 13% !important;
}

body #rating-page #players-table.show-hideout-rating th[data-column="winrate"],
body #rating-page #players-table.show-hideout-rating td.winrate-cell {
    width: 17% !important;
}

body #rating-page #players-table.show-hideout-rating th[data-column="streak"],
body #rating-page #players-table.show-hideout-rating tbody td:last-child {
    width: 9% !important;
}

body #rating-page #players-table tbody tr.players-more-row {
    height: 24px !important;
    border-top: 1px solid rgba(218, 166, 72, 0.16) !important;
    border-bottom: 0 !important;
    background: linear-gradient(180deg, rgba(10, 21, 32, 0.82), rgba(7, 16, 25, 0.94)) !important;
}

body #rating-page #players-table tbody tr.players-more-row:hover {
    background: linear-gradient(180deg, rgba(13, 27, 40, 0.9), rgba(8, 18, 28, 0.98)) !important;
}

body #rating-page #players-table tbody tr.players-more-row td.players-more-cell {
    width: auto !important;
    height: 24px !important;
    padding: 0 !important;
    text-align: center !important;
}

body #rating-page .players-more-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 22px;
    padding: 0 20px;
    border: 0;
    background: transparent;
    color: #f0cf7a;
    font: 700 13px/18px "Manrope", system-ui, sans-serif;
    cursor: pointer;
    transition: color 160ms ease, text-shadow 160ms ease;
}

body #rating-page .players-more-button:hover,
body #rating-page .players-more-button:focus-visible {
    color: #ffe39a;
    text-shadow: 0 0 12px rgba(218, 166, 72, 0.26);
    outline: none;
}

body #rating-page .players-more-icon {
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    flex: 0 0 auto;
}

body #rating-page .players-more-icon--down {
    transform: translateY(-2px) rotate(45deg);
}

body #rating-page .players-more-icon--up {
    transform: translateY(2px) rotate(225deg);
}

body #rating-page .players-add-button[hidden],
body #rating-page .players-add-button[aria-hidden="true"] {
    display: none !important;
}

body #rating-page #players-table td:nth-child(2) .player-nickname {
    font-size: 13.65px !important;
}

@media (max-width: 1180px) {
    body #rating-page .rating-layout {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
        grid-template-areas:
            "toolbar"
            "main"
            "sidebar"
            "matches" !important;
    }

    body #rating-page .rating-sidebar {
        margin-top: 0 !important;
    }
}

@media (max-width: 768px) {
    body #rating-page .players-header-title {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    body #rating-page .players-header h2 {
        font-size: 28px !important;
        line-height: 32px !important;
    }

    body #rating-page .players-header-actions {
        width: 100% !important;
        margin-left: 0 !important;
        justify-content: flex-end !important;
    }

    body #rating-page .players-activity-filter {
        margin-right: auto !important;
    }

    body #rating-page .rating-players-list > .table-container {
        overflow-x: auto !important;
    }

    body #rating-page #players-table {
        min-width: 820px !important;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    body #rating-page .players-header-title {
        flex-wrap: nowrap !important;
        align-items: center !important;
    }

    body #rating-page .players-header-actions {
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 0 !important;
        justify-content: flex-end !important;
    }
}

@media (max-width: 480px) {
    body #rating-page .rating-layout {
        gap: 12px !important;
    }

    body #rating-page .players-header {
        min-height: auto !important;
        padding: 4px 2px 2px !important;
    }

    body #rating-page .players-header-title {
        min-height: auto !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    body #rating-page .players-header h2 {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        font-size: clamp(20px, 5.5vw, 26px) !important;
        line-height: 30px !important;
        white-space: nowrap !important;
    }

    body #rating-page .season-button {
        display: none !important;
    }

    body #rating-page .players-header-actions {
        width: 100% !important;
        flex: 1 0 100% !important;
        margin-left: 0 !important;
        gap: 6px !important;
        justify-content: flex-end !important;
    }

    body #rating-page .players-activity-filter {
        gap: 0 !important;
    }

    body #rating-page .players-activity-filter-caption {
        display: none !important;
    }

    body #rating-page .players-activity-filter-options {
        height: 36px !important;
    }

    body #rating-page .players-activity-filter-option {
        min-width: 0 !important;
        padding: 0 11px !important;
        font-size: 10px !important;
    }

    body #rating-page .players-search-button,
    body #rating-page .players-filter-button,
    body #rating-page .players-add-button {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }

    body #rating-page .rating-players-list {
        border-radius: 12px !important;
    }

    body #rating-page .rating-players-list > .table-container {
        overflow-x: auto !important;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(218, 166, 72, 0.42) rgba(255, 255, 255, 0.035);
    }

    body #rating-page #players-table {
        min-width: 760px !important;
    }

    body #rating-page #players-table thead th,
    body #rating-page #players-table tbody td {
        height: 44px !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
        font-size: 12px !important;
    }

    body #rating-page #players-table th[data-column="position"],
    body #rating-page #players-table td:nth-child(1) {
        width: 56px !important;
    }

    body #rating-page #players-table th[data-column="nickname"],
    body #rating-page #players-table td:nth-child(2) {
        width: 210px !important;
    }

    body #rating-page #players-table td:nth-child(2) .player-avatar-frame,
    body #rating-page #players-table td:nth-child(2) .player-avatar {
        width: 28px !important;
        height: 28px !important;
    }

    body #rating-page #players-table td:nth-child(2) .player-nickname {
        font-size: 12.6px !important;
    }

    body #rating-page #players-table td:nth-child(3) .player-rating-value,
    body #rating-page #players-table td.player-cell-hideout .player-rating-value {
        font-size: 18px !important;
    }
}

/* Mobile leaderboard toolbar: readable title and 44px touch targets. */
@media (max-width: 768px) {
    body #rating-page .players-header {
        min-height: 0 !important;
        padding: 6px 2px 4px !important;
    }

    body #rating-page .players-header-title {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "title season"
            "actions actions";
        align-items: center !important;
        min-height: 0 !important;
        gap: 10px 8px !important;
    }

    body #rating-page .players-header h2 {
        grid-area: title;
        min-width: 0 !important;
        font-size: clamp(22px, 4.5vw, 28px) !important;
        line-height: 1.15 !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    body #rating-page .season-button {
        grid-area: season;
        height: 44px !important;
        min-height: 44px !important;
        margin: 0 !important;
        padding-inline: 12px !important;
    }

    body #rating-page .players-header-actions {
        grid-area: actions;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    body #rating-page .players-activity-filter {
        min-width: 0 !important;
        margin-right: auto !important;
    }

    body #rating-page .players-activity-filter-options {
        height: 44px !important;
        min-height: 44px !important;
    }

    body #rating-page .players-activity-filter-option {
        min-height: 36px !important;
        padding-inline: 12px !important;
        font-size: 11px !important;
    }

    body #rating-page .players-search-button,
    body #rating-page .players-filter-button,
    body #rating-page .players-add-button {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }

    body #rating-page .players-search-panel,
    body #rating-page .players-filter-panel,
    body #rating-page .players-add-panel {
        width: min(360px, calc(100vw - 24px)) !important;
        max-height: min(70dvh, 520px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

@media (max-width: 640px) {
    body #rating-page .players-activity-filter {
        gap: 0 !important;
    }

    body #rating-page .players-activity-filter-caption {
        display: none !important;
    }
}

@media (max-width: 420px) {
    body #rating-page .players-header-title {
        grid-template-columns: 1fr;
        grid-template-areas:
            "title"
            "actions";
    }

    body #rating-page .season-button {
        display: none !important;
    }

    body #rating-page .players-header-actions {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) repeat(3, 44px);
    }

    body #rating-page .players-activity-filter,
    body #rating-page .players-activity-filter-options {
        width: 100% !important;
    }

    body #rating-page .players-activity-filter-option {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        padding-inline: 8px !important;
    }
}

/* Match the space above the toolbar at every viewport width. */
body #rating-page .rating-layout {
    row-gap: var(--page-section-spacing, 9.648px) !important;
}
/* Sidebar cards share a quiet, consistent content rhythm. */
body #rating-page .rating-sidebar > .support-banner {
    padding: 16px;
    gap: 16px;
}

body #rating-page .support-banner-copy {
    gap: 8px;
}

body #rating-page .support-banner-text {
    margin: 0;
    line-height: 1.5;
}

body #rating-page .support-banner-link {
    min-height: 40px;
    padding: 10px 16px;
    border-radius: 8px;
    line-height: 18px;
}

body #rating-page .top-week-card .rating-widget-header,
body #rating-page .popular-civs-card .rating-widget-header {
    height: auto;
    min-height: 52px;
    padding: 16px 16px 12px;
    flex-wrap: wrap;
    row-gap: 8px;
}

body #rating-page .top-week-heading {
    gap: 4px;
}

body #rating-page .top-week-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 20px;
    text-align: center;
}

body #rating-page .top-week-empty-icon {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    margin-bottom: 4px;
    color: rgba(243, 234, 215, 0.35);
}

body #rating-page .top-week-empty-title {
    margin: 0;
    color: rgba(243, 234, 215, 0.88);
    font-size: 13px;
    line-height: 20px;
    font-weight: 600;
}

body #rating-page .top-week-empty-description {
    max-width: 320px;
    margin: 0;
    color: rgba(243, 234, 215, 0.5);
    font-size: 12px;
    line-height: 18px;
}

body #rating-page .popular-civs-list {
    padding-block: 4px 12px;
}

@media (max-width: 480px) {
    body #rating-page .rating-sidebar > .support-banner {
        padding: 14px;
    }

    body #rating-page .top-week-card .rating-widget-header,
    body #rating-page .popular-civs-card .rating-widget-header {
        padding-inline: 14px;
    }
}