:root {
    --rk-gold: var(--av-gold);
    --rk-ivory: var(--av-text);
    --rk-muted: var(--av-muted);
    --rk-blue: var(--av-blue);
}

.ranking-page {
    position: relative;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    color: var(--rk-ivory);
    font-family: 'Cinzel', serif;
}

.ranking-canvas {
    position: relative;
    width: min(100%, 1536px);
    min-width: 1000px;
    aspect-ratio: 1536 / 920;
    margin: 0 auto;
    overflow: hidden;
    background: transparent;
}

.ranking-hero {
    position: absolute;
    inset: 0 0 auto;
    height: 18%;
    display: grid;
    place-items: start center;
    pointer-events: none;
}

.ranking-hero__mist { display: none; }

.ranking-hero__content {
    width: 52%;
    padding-top: 1.2%;
    text-align: center;
    text-transform: uppercase;
}

.ranking-hero h1 {
    margin: 0;
    color: #e2bd73;
    font-size: clamp(34px, 4.1vw, 64px);
    font-weight: 500;
    letter-spacing: .04em;
    line-height: 1;
    text-shadow: 0 2px 2px #000, 0 0 10px rgba(207, 154, 70, .28);
}

.ranking-hero p {
    margin: 1.1% 0 0;
    color: #c8cbd0;
    font-size: clamp(9px, 1vw, 16px);
    letter-spacing: .1em;
}

.ranking-title-rule {
    display: none;
}

.ranking-title-rule--bottom {
    display: block;
    width: 78%;
    height: 12px;
    margin: 1.2% auto 0;
    background: url('/images/rankings/v2/icon-gem.webp') center / 16px 20px no-repeat;
    border-top: 1px solid rgba(211, 164, 89, .65);
}

.ranking-tabs {
    position: absolute;
    z-index: 8;
    top: 15.2%;
    left: 12.3%;
    width: 71.4%;
    height: 7.2%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}

.ranking-tab {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5%;
    overflow: visible;
    color: #d9b66f;
    font-size: clamp(9px, 1.05vw, 16px);
    letter-spacing: .03em;
    text-transform: uppercase;
    pointer-events: auto;
}

.ranking-tab__frame {
    position: absolute;
    z-index: -1;
    inset: -7% -3%;
    width: 106%;
    height: 114%;
    object-fit: fill;
    pointer-events: none;
}

.ranking-tab > img:not(.ranking-tab__frame) {
    width: clamp(22px, 2.2vw, 34px);
    height: clamp(22px, 2.2vw, 34px);
    object-fit: contain;
    pointer-events: none;
}

.ranking-tab span { pointer-events: none; }

.ranking-tab.is-active { color: #f5e8cf; }
.ranking-tab:focus-visible { outline: 2px solid #5ebcff; outline-offset: 3px; }

.ranking-shell,
.ranking-board {
    position: absolute;
    inset: 0;
}

.ranking-shell { z-index: 4; }

.ranking-realms {
    position: absolute;
    z-index: 12;
    top: 22.8%;
    left: 38%;
    width: 24%;
    display: flex;
    justify-content: center;
    gap: 6px;
}

.ranking-realms button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    color: var(--rk-muted);
    background: rgba(2, 10, 17, .96);
    border: 1px solid rgba(188, 145, 77, .4);
    font: 600 clamp(7px, .55vw, 10px) 'Cinzel', serif;
    text-transform: uppercase;
}

.ranking-realms button.is-active { color: #f1c571; border-color: #248ff5; }
.ranking-realms__crest, .ranking-realms__crest svg { width: 16px; height: 16px; }

.ranking-panel-raster {
    position: absolute;
    z-index: 0;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
}

.ranking-sidebar {
    position: absolute;
    z-index: 6;
    top: 23.8%;
    left: 4.8%;
    width: 12.3%;
    height: 53.3%;
}

.ranking-filter-list {
    position: absolute;
    z-index: 1;
    top: 3.5%;
    left: 7%;
    width: 86%;
    height: 61%;
    display: grid;
    grid-template-rows: repeat(5, 1fr);
}

.ranking-filter {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4% 0 10%;
    color: #bfc3c8;
    background: transparent;
    border: 0;
    font: 500 clamp(7px, .76vw, 12px) 'Cinzel', serif;
    text-align: left;
    text-transform: uppercase;
    direction: ltr !important;
    white-space: nowrap;
}

.ranking-filter::after {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 3% -6%;
    opacity: 0;
    background: url('/images/rankings/v2/tab-active.webp') center / 100% 100% no-repeat;
}

.ranking-filter.is-active { color: #f4e8d0; }
.ranking-filter.is-active::after { opacity: 1; }

.ranking-filter img {
    width: clamp(18px, 1.7vw, 27px);
    height: clamp(18px, 1.7vw, 27px);
    object-fit: contain;
    flex-shrink: 0;
}

.ranking-updated {
    position: absolute;
    z-index: 1;
    top: 67%;
    bottom: 3%;
    left: 10%;
    width: 80%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #cfc6b7;
    text-align: center;
    text-transform: uppercase;
}

.ranking-updated span { font-size: clamp(6px, .68vw, 11px); letter-spacing: .05em; }
.ranking-updated time { color: #d7c3a5; font-size: clamp(7px, .8vw, 13px); line-height: 1.4; }
.ranking-gem { width: clamp(14px, 1.6vw, 24px); height: auto; object-fit: contain; }

.ranking-table-panel {
    position: absolute;
    z-index: 7;
    top: 23.8%;
    left: 17.2%;
    width: 58.4%;
    height: 59.8%;
    overflow: hidden;
    background: transparent !important;
}

.ranking-table-scroll {
    position: absolute;
    z-index: 1;
    top: 8.7%;
    left: 3.7%;
    width: 92.6%;
    height: 84.5%;
    overflow: hidden;
}

.ranking-table {
    display: grid;
    grid-template-rows: 10% 90%;
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.ranking-table thead,
.ranking-table tbody,
.ranking-table tr {
    display: grid;
    min-width: 0;
    min-height: 0;
}

.ranking-table thead { grid-template-rows: 1fr; }
.ranking-table tbody { grid-template-rows: repeat(10, minmax(0, 1fr)); }
.ranking-table--guilds tr,
.ranking-table--levels tr,
.ranking-table--nobility tr,
.ranking-table--pvp tr {
    grid-template-columns: 11.8% 28.5% 18% 8.5% 13% 20.2%;
}

.ranking-table th,
.ranking-table td {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    padding: 0 2.2%;
    overflow: hidden;
    border: 0;
    color: #d0d1d0;
    font-size: clamp(8px, .84vw, 14px);
    font-weight: 500;
    line-height: 1;
    text-align: start;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.ranking-table th {
    color: #c4c7ca;
    font-size: clamp(7px, .72vw, 12px);
    letter-spacing: .04em;
    text-transform: uppercase;
}

.ranking-table tbody tr { background: transparent !important; }
.ranking-table tbody tr:hover { background: rgba(15, 65, 103, .2) !important; }
.ranking-table th:first-child, .ranking-table td:first-child { padding: 0; justify-content: center; text-align: center; }

.ranking-table th:nth-child(2) {
    justify-content: center !important;
    text-align: center !important;
    direction: ltr !important;
}
.ranking-table td:nth-child(2) {
    justify-content: flex-start !important;
    padding-left: 20% !important;
    padding-right: 0 !important;
    direction: ltr !important;
}

.ranking-table th:nth-child(3),
.ranking-table td:nth-child(3) {
    justify-content: flex-start !important;
    padding-inline: 4% !important;
    direction: ltr !important;
}

.ranking-table th:nth-child(4), .ranking-table td:nth-child(4),
.ranking-table th:nth-child(5), .ranking-table td:nth-child(5),
.ranking-table th:last-child, .ranking-table td:last-child {
    justify-content: center !important;
    text-align: center !important;
}

.ranking-position-image {
    width: auto;
    height: 92%;
    max-height: 54px;
    margin: 0 auto;
    object-fit: contain;
}

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

.ranking-position {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--rk-gold);
    font-size: clamp(8px, .9vw, 14px);
    line-height: 1;
    transform: translateY(-1px);
}

.ranking-name-cell {
    display: grid;
    grid-template-columns: clamp(20px, 2vw, 28px) minmax(0, 1fr);
    align-items: center;
    column-gap: clamp(5px, 0.5vw, 8px);
    width: 100%;
    height: 100%;
    min-width: 0;
    direction: ltr !important;
}

.ranking-crest-slot {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ranking-mini-crest {
    display: block;
    width: 100%;
    height: 78%;
    object-fit: contain;
}

.ranking-name-text {
    display: flex;
    align-items: center;
    min-width: 0;
    height: 100%;
}

.ranking-name-cell strong,
.ranking-name-cell a {
    display: block;
    width: 100%;
    overflow: hidden;
    color: #e3b761;
    font-size: clamp(8px, 0.78vw, 13px);
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left !important;
}

.ranking-name-cell a {
    height: 100%;
    display: flex;
    align-items: center;
}

.ranking-name-cell a:hover { color: #fff1c9; }
.ranking-score { color: #e5b659 !important; font-variant-numeric: tabular-nums; }
.ranking-empty { grid-column: 1 / -1; justify-content: center !important; color: #7f8992 !important; text-align: center !important; }
.ranking-empty i { display: block; margin-bottom: 8px; color: #9c773a; }

.ranking-pagination {
    position: absolute;
    z-index: 8;
    left: 50%;
    bottom: 1%;
    display: flex;
    gap: 5px;
    transform: translateX(-50%);
}

.ranking-pagination button {
    width: clamp(22px, 2.1vw, 32px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    color: #c9aa73;
    background: rgba(2, 9, 15, .92);
    border: 1px solid rgba(142, 112, 70, .45);
    min-width: 44px;
    min-height: 44px;
    font-family: var(--av-font-body);
    font-size: clamp(10px, .75vw, 12px);
    font-weight: 600;
}

.ranking-pagination button.is-active { color: #fff; border-color: var(--rk-blue); }
.ranking-pagination button:disabled { cursor: default; opacity: .38; }

.ranking-champion {
    position: absolute;
    z-index: 7;
    top: 23.8%;
    left: 76.3%;
    width: 18.5%;
    height: 57.2%;
    color: #d9c4a4;
    text-align: center;
}

.ranking-champion h2 {
    position: absolute;
    z-index: 1;
    top: 4%;
    left: 10%;
    width: 80%;
    margin: 0;
    color: #e4bd75;
    font-size: clamp(9px, 1.15vw, 18px);
    font-weight: 500;
    text-transform: uppercase;
}

.ranking-champion__crest {
    position: absolute;
    z-index: 1;
    top: 12%;
    left: 16%;
    width: 68%;
    height: 38%;
    object-fit: contain;
}

.ranking-champion > strong {
    position: absolute;
    z-index: 1;
    top: 49%;
    left: 8%;
    width: 84%;
    overflow: hidden;
    color: #e4b968;
    font-size: clamp(11px, 1.5vw, 23px);
    font-weight: 500;
    letter-spacing: .03em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
    text-shadow: 0 2px 3px #000;
}

.ranking-champion dl {
    position: absolute;
    z-index: 1;
    top: 58%;
    left: 10%;
    width: 80%;
    margin: 0;
}

.ranking-champion dl div { margin-bottom: 6%; }
.ranking-champion dt { color: #aeb0b1; font-size: clamp(6px, .63vw, 10px); letter-spacing: .04em; text-transform: uppercase; }
.ranking-champion dd { margin: 2% 0 0; overflow: hidden; color: #e2b968; font-size: clamp(8px, .96vw, 15px); text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }

.ranking-oaths {
    position: absolute;
    z-index: 5;
    top: 84.2%;
    left: 3.6%;
    width: 92.2%;
    height: 13.2%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 1.7% 2.5%;
}

.ranking-oaths article {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 6%;
    padding: 0 6%;
}

.ranking-oaths article > i {
    color: #168cff;
    font-size: clamp(18px, 2.3vw, 36px);
    text-shadow: 0 0 8px rgba(22, 140, 255, .7);
}

.ranking-oaths h3 { margin: 0; color: #d9b571; font-size: clamp(7px, .82vw, 13px); font-weight: 500; text-transform: uppercase; }
.ranking-oaths p { margin: 4px 0 0; color: #adb0b4; font: clamp(6px, .65vw, 10px)/1.45 serif; }

[dir='rtl'] .ranking-table th,
[dir='rtl'] .ranking-table td { justify-content: flex-start; text-align: right; }
[dir='rtl'] .ranking-table th:first-child,
[dir='rtl'] .ranking-table td:first-child { text-align: center; }
[dir='rtl'] .ranking-table th:last-child,
[dir='rtl'] .ranking-table td:last-child { justify-content: flex-end; text-align: left; }

@media (max-width: 999px) {
    .ranking-page {
        overflow: hidden;
        padding: 22px 12px 32px;
        background-position: center top;
    }

    .ranking-canvas {
        width: 100%;
        min-width: 0;
        aspect-ratio: auto;
        margin: 0;
        overflow: visible;
    }

    .ranking-hero,
    .ranking-tabs,
    .ranking-shell,
    .ranking-board,
    .ranking-sidebar,
    .ranking-table-panel,
    .ranking-table-scroll,
    .ranking-champion,
    .ranking-oaths {
        position: relative;
        inset: auto;
        width: 100%;
        height: auto;
    }

    .ranking-hero {
        display: block;
        padding: 10px 0 22px;
    }

    .ranking-hero__content {
        width: 100%;
        padding: 0;
    }

    .ranking-hero h1 { font-size: clamp(32px, 11vw, 52px); }
    .ranking-hero p { font-size: 13px; }

    .ranking-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 14px;
    }

    .ranking-tab {
        min-height: 52px;
        padding: 8px 10px;
        font-size: 12px;
        background: rgba(2, 10, 18, .94);
        border: 1px solid var(--av-line-soft);
    }

    .ranking-tab__frame { display: none; }
    .ranking-tab > img:not(.ranking-tab__frame) { width: 28px; height: 28px; }
    .ranking-tab.is-active { border-color: var(--rk-blue); background: rgba(22, 134, 255, .14); }

    .ranking-shell { display: block; }

    .ranking-realms {
        position: relative;
        inset: auto;
        width: 100%;
        margin: 0 0 12px;
        flex-wrap: wrap;
    }

    .ranking-realms button {
        min-height: 44px;
        padding: 8px 12px;
        font-size: 11px;
    }

    .ranking-board {
        display: grid;
        gap: 14px;
    }

    .ranking-panel-raster { display: none; }

    .ranking-sidebar,
    .ranking-table-panel,
    .ranking-champion,
    .ranking-oaths {
        overflow: hidden;
        background: rgba(3, 12, 22, .96) !important;
        border: 1px solid var(--av-line-soft);
    }

    .ranking-sidebar { padding: 14px; }

    .ranking-filter-list {
        position: relative;
        inset: auto;
        width: 100%;
        height: auto;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .ranking-filter {
        min-height: 46px;
        padding: 8px 12px;
        gap: 10px;
        color: var(--rk-muted);
        font: 600 11px var(--av-font-body);
        background: rgba(255, 255, 255, .025);
        border: 1px solid rgba(217, 179, 106, .16);
    }

    .ranking-filter::after { display: none; }
    .ranking-filter.is-active { background: rgba(22, 134, 255, .14); border-color: var(--rk-blue); }
    .ranking-filter img { width: 26px; height: 26px; }

    .ranking-updated {
        position: relative;
        inset: auto;
        width: 100%;
        margin-top: 12px;
        flex-direction: row;
        justify-content: center;
        gap: 10px;
    }

    .ranking-updated span,
    .ranking-updated time { margin: 0; font-size: 11px; }
    .ranking-updated time br,
    .ranking-gem { display: none; }

    .ranking-table-panel { padding: 12px; }

    .ranking-table-scroll {
        overflow-x: auto;
        overflow-y: hidden;
        overscroll-behavior-inline: contain;
        scrollbar-color: var(--rk-gold) var(--av-surface-strong);
    }

    .ranking-table {
        width: 680px;
        min-width: 680px;
        height: 540px;
    }

    .ranking-table th,
    .ranking-table td { font-size: 11px; }

    .ranking-pagination {
        position: relative;
        inset: auto;
        justify-content: center;
        margin-top: 12px;
        transform: none;
    }

    .ranking-pagination button { width: 44px; height: 44px; }

    .ranking-champion {
        min-height: auto !important;
        padding: 24px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }

    .ranking-champion h2 {
        position: static !important;
        font-size: 18px !important;
        margin-bottom: 16px !important;
    }

    .ranking-champion__crest {
        position: static !important;
        width: 120px !important;
        height: 120px !important;
        margin-bottom: 16px !important;
    }

    .ranking-champion > strong {
        position: static !important;
        font-size: 22px !important;
        margin-bottom: 16px !important;
        display: block !important;
    }

    .ranking-champion dl {
        position: static !important;
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
        width: 100% !important;
        margin-top: 10px !important;
    }

    .ranking-champion dl div {
        margin-bottom: 0 !important;
        background: rgba(255,255,255,0.02) !important;
        border: 1px solid rgba(198, 154, 88, 0.15) !important;
        padding: 8px !important;
        border-radius: 4px !important;
    }

    .ranking-champion dt {
        font-size: 9px !important;
    }

    .ranking-champion dd {
        font-size: 12px !important;
        margin-top: 4px !important;
    }

    .ranking-oaths {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1px;
        padding: 8px;
    }

    .ranking-oaths article {
        min-height: 92px;
        padding: 12px;
        border: 1px solid rgba(217, 179, 106, .12);
    }

    .ranking-oaths article > i { font-size: 26px; }
    .ranking-oaths h3 { font-size: 12px; }
    .ranking-oaths p { color: var(--rk-muted); font: 12px/1.45 var(--av-font-body); }
}

@media (max-width: 520px) {
    .ranking-filter-list,
    .ranking-oaths { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .ranking-table tbody tr { transition: none; }
}
