:root {
    --bg: #0b1d15;
    --panel: rgba(18, 48, 36, .78);
    --panel-strong: rgba(20, 55, 41, .88);
    --line: rgba(92, 211, 154, .22);
    --line-soft: rgba(255, 255, 255, .08);
    --text: #f4f8ef;
    --muted: #a9c3b8;
    --active: #27e59a;
    --danger: #ff6d73;
    --gold: #f5c84b;
    --bronze: #bf7a42;
    --silver: #c9d3df;
}

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(8, 26, 18, .50), rgba(6, 22, 16, .68)),
        url("../img/chernarus-landscapes.jpg") center/cover fixed no-repeat;
}

.rank-shell {
    width: min(1380px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 44px;
}

.rank-hero,
.rank-panel,
.podium-card {
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(20, 55, 41, .84), rgba(12, 36, 27, .84));
    box-shadow: 0 24px 70px rgba(0, 0, 0, .24);
}

.rank-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 118px;
    padding: 20px 24px;
    border-radius: 8px;
}

.rank-brand {
    display: flex;
    align-items: center;
    gap: 18px;
}

.fallen-titan-logo {
    width: 78px;
    height: 78px;
    object-fit: contain;
}

.rank-kicker {
    display: inline-flex;
    margin-bottom: 6px;
    color: var(--active);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.rank-hero h1,
.rank-panel h2 {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
}

.rank-status {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.rank-status > span,
.rank-panel__hint,
.rank-home-link {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    padding: 0 14px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, .06);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.rank-home-link {
    gap: 8px;
    border-color: rgba(39, 229, 154, .45);
    background: rgba(39, 229, 154, .12);
    color: var(--text);
    text-decoration: none;
    transition: background .16s ease, border-color .16s ease, color .16s ease;
}

.rank-home-link span {
    display: inline;
    min-height: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
}

.rank-home-link:hover,
.rank-home-link:focus {
    border-color: rgba(39, 229, 154, .78);
    background: rgba(39, 229, 154, .2);
    color: var(--text);
    text-decoration: none;
}

.rank-home-link svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: var(--active);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.9;
}

.podium-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 16px 0;
}

.podium-card {
    position: relative;
    min-height: 224px;
    padding: 22px;
    border-radius: 8px;
    text-align: center;
}

.podium-card--gold {
    order: 2;
    border-color: rgba(245, 200, 75, .56);
}

.podium-card--bronze {
    order: 1;
    border-color: rgba(191, 122, 66, .56);
}

.podium-card--silver {
    order: 3;
    border-color: rgba(201, 211, 223, .56);
}

.podium-card__icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 14px;
}

.podium-card__icon img {
    width: 100%;
    height: 100%;
}

.podium-card--gold .podium-card__icon {
    width: 112px;
    height: 112px;
    margin-bottom: 12px;
}

.podium-card--bronze .podium-card__icon {
    width: 88px;
    height: 88px;
    margin-bottom: 12px;
}

.podium-card--silver .podium-card__icon {
    width: 76px;
    height: 76px;
}

.podium-card__rank {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.podium-card h2 {
    margin: 8px 0 16px;
    overflow-wrap: anywhere;
    font-size: 24px;
    line-height: 1.1;
}

.podium-card dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    text-align: left;
}

.podium-card dl div {
    padding: 10px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(0, 0, 0, .18);
}

.podium-card dt {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.podium-card dd {
    margin: 4px 0 0;
    font-size: 15px;
    font-weight: 900;
}

.rank-panel {
    padding: 18px;
    border-radius: 8px;
}

.rank-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.table {
    margin: 0;
    overflow: hidden;
    border-radius: 8px;
}

.table-dark {
    background: rgba(6, 17, 13, .74);
}

.table-dark th,
.table-dark td {
    border-color: var(--line-soft) !important;
    color: var(--text);
    vertical-align: middle;
}

.table-dark thead th {
    border-top: 0;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.accordion-button {
    background: rgba(12, 30, 24, .74);
    cursor: pointer;
    transition: background .16s ease, transform .16s ease;
}

.accordion-button:hover {
    background: rgba(24, 61, 45, .82);
}

.rank-row--1 td:first-child { box-shadow: inset 4px 0 0 var(--gold); }
.rank-row--2 td:first-child { box-shadow: inset 4px 0 0 var(--bronze); }
.rank-row--3 td:first-child { box-shadow: inset 4px 0 0 var(--silver); }

.accordion-body {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--panel-strong);
    color: var(--text);
}

.accordion-body ul {
    padding-left: 0;
    list-style-type: none;
    color: var(--text);
}

.accordion-body li {
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
}

.detail-layout {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
}

.detail-statbar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.detail-stat,
.detail-panel {
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    background: rgba(2, 20, 14, .38);
}

.detail-stat {
    min-height: 74px;
    padding: 12px 14px;
}

.detail-stat span,
.detail-label,
.detail-count {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.detail-stat strong {
    display: block;
    margin-top: 8px;
    color: var(--text);
    font-size: 20px;
    font-variant-numeric: tabular-nums;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(320px, .88fr) minmax(460px, 1.12fr);
    gap: 14px;
    align-items: start;
}

.detail-panel {
    padding: 14px;
}

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

.detail-panel h4 {
    margin: 3px 0 0;
    font-size: 18px;
    font-weight: 900;
}

.kill-total-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 54px;
    padding: 12px 14px;
    border: 1px solid rgba(39, 229, 154, .22);
    border-radius: 8px;
    background: rgba(39, 229, 154, .08);
}

.kill-total-line span {
    color: var(--muted);
    font-weight: 800;
    text-transform: uppercase;
}

.kill-total-line strong {
    color: var(--active);
    font-size: 20px;
    font-variant-numeric: tabular-nums;
}

.detail-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: min(100%, 280px);
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid rgba(39, 229, 154, .34);
    border-radius: 8px;
    background: rgba(39, 229, 154, .08);
    color: var(--text);
    font-weight: 900;
    cursor: pointer;
}

.detail-toggle--compact {
    width: auto;
    min-width: 154px;
}

.detail-toggle:hover {
    border-color: rgba(39, 229, 154, .7);
    background: rgba(39, 229, 154, .14);
}

.detail-toggle__icon {
    display: inline-flex;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    color: var(--active);
}

.detail-toggle__icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.kill-breakdown {
    margin-top: 10px;
}

.kill-breakdown ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 6px;
    margin: 0;
}

.kill-breakdown li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 8px;
    background: rgba(0, 0, 0, .16);
}

.kill-breakdown strong {
    color: var(--active);
    font-variant-numeric: tabular-nums;
}

.empty-state {
    color: var(--muted);
    font-weight: 700;
}

.detail-loading,
.detail-error {
    display: flex;
    min-height: 74px;
    align-items: center;
    justify-content: center;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    background: rgba(0, 0, 0, .14);
    color: var(--muted);
    font-weight: 800;
}

.detail-error {
    border-color: rgba(255, 109, 115, .38);
    color: var(--danger);
}

.achievement-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 8px;
    margin: 0;
}

.achievement-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 8px;
    background: rgba(0, 0, 0, .14);
}

.achievement-list strong {
    color: var(--active);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.loadout-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.loadout-panel {
    min-width: 0;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    background: rgba(2, 20, 14, .38);
}

.loadout-panel--perks {
    grid-column: 1 / -1;
}

.loadout-panel__head,
.loadout-panel__title,
.loadout-count,
.loadout-icon,
.perk-group__head,
.perk-chip,
.gear-item {
    display: flex;
    align-items: center;
}

.loadout-panel__head {
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.loadout-panel__title {
    gap: 10px;
    min-width: 0;
}

.loadout-icon {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    justify-content: center;
    border: 1px solid rgba(39, 229, 154, .26);
    border-radius: 8px;
    background: rgba(39, 229, 154, .08);
    color: var(--active);
}

.loadout-icon svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.loadout-panel h5 {
    margin: 2px 0 0;
    font-size: 18px;
    font-weight: 900;
}

.loadout-count {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 999px;
    background: rgba(0, 0, 0, .16);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.perk-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
}

.perk-group {
    min-width: 0;
    padding: 11px;
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 8px;
    background: rgba(0, 0, 0, .14);
}

.perk-group__head {
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.perk-group__head strong {
    color: var(--text);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.perk-group__head span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.perk-chip-grid {
    display: grid;
    gap: 7px;
}

.perk-chip {
    min-width: 0;
    align-items: flex-start;
    gap: 8px;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid rgba(39, 229, 154, .14);
    border-radius: 8px;
    background: rgba(39, 229, 154, .06);
}

.perk-chip__dot {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--active);
    box-shadow: 0 0 16px rgba(39, 229, 154, .48);
}

.perk-chip__name {
    min-width: 0;
    color: var(--text);
    font-weight: 900;
    line-height: 1.25;
    overflow-wrap: anywhere;
    white-space: normal;
}

.perk-chip__raw {
    flex: 0 0 auto;
    max-width: 42%;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gear-list {
    display: grid;
    gap: 8px;
    margin: 0;
}

.gear-item {
    justify-content: space-between;
    gap: 14px;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 8px;
    background: rgba(0, 0, 0, .14);
}

.gear-item__name {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gear-item strong {
    flex: 0 0 auto;
    min-width: 42px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(39, 229, 154, .12);
    color: var(--active);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.table-details {
    width: 100%;
    display: none;
}

.table-details th,
.table-details td {
    border: 1px solid var(--line-soft);
    color: var(--text);
}

.player-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
}

.player-name i {
    margin-left: auto;
    color: var(--muted);
}

.gold {
    color: var(--gold) !important;
}

.number {
    min-width: 34px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
    .rank-hero,
    .rank-panel__head {
        align-items: flex-start;
        flex-direction: column;
    }

    .rank-status {
        justify-content: flex-start;
    }

    .podium-grid {
        grid-template-columns: 1fr;
    }

    .podium-card--gold,
    .podium-card--bronze,
    .podium-card--silver {
        order: initial;
    }

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

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .loadout-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .rank-shell {
        width: min(100% - 20px, 1380px);
        padding-top: 12px;
    }

    .rank-hero h1 {
        font-size: 23px;
    }

    .fallen-titan-logo {
        width: 60px;
        height: 60px;
    }

    .podium-card dl {
        grid-template-columns: 1fr;
    }

    .table {
        min-width: 760px;
    }

    .rank-panel {
        overflow-x: auto;
    }

    .detail-statbar,
    .achievement-list,
    .kill-breakdown ul {
        grid-template-columns: 1fr;
    }

    .detail-panel__head {
        align-items: flex-start;
        flex-direction: column;
    }

    .detail-toggle--compact {
        width: 100%;
    }
}
