/* =============================================================================
   MATCH DETAILS — Scoreboard, tabs, draft, stats, rankings, player popup
   Reference: DESIGN_REVAMP.md § 6
   ============================================================================= */

/* --- Tooltip Logic --- */
[data-tooltip] {
    position: relative;
    cursor: pointer;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.88);
    color: #fff;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-xs);
    font-size: var(--text-caption);
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    margin-bottom: 5px;
    box-shadow: var(--shadow-md);
}

/* --- Navigation --- */
.back-nav {
    margin-bottom: var(--space-8);
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text-secondary);
    font-weight: var(--weight-bold);
    text-decoration: none;
    font-size: var(--text-footnote);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    transition: color var(--duration-fast) var(--ease-decel);
    background: transparent;
    padding: var(--space-2) 0;
}

.btn-back svg {
    transition: transform var(--duration-fast) var(--ease-decel);
}

.btn-back:hover {
    color: var(--color-text-primary);
}

.btn-back:hover svg {
    transform: translateX(-4px);
    color: var(--color-accent);
}

/* --- Layout --- */
.match-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-4);
}

/* --- Hero Section (Scoreboard) --- */
.match-hero {
    position: relative;
    display: flex;
    align-items: center;
    padding: var(--space-10) 0;
    background-color: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-8);
    box-shadow: var(--shadow-md);
}

.match-hero__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.match-hero__nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast) var(--ease-decel),
                background-color var(--duration-fast) var(--ease-decel);
}

.match-hero__nav:hover {
    color: var(--color-accent);
    background-color: var(--color-bg-base);
}

.match-hero__nav--prev {
    margin-left: var(--space-4);
}

.match-hero__nav--next {
    margin-right: var(--space-4);
}

.match-meta {
    text-transform: uppercase;
    font-size: var(--text-caption);
    letter-spacing: var(--tracking-caps);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-8);
    display: flex;
    gap: var(--space-6);
    align-items: center;
    font-weight: var(--weight-semibold);
}

.match-status {
    padding: 2px var(--space-3);
    border-radius: var(--radius-full);
    background: var(--color-bg-base);
    border: 1px solid var(--color-border);
    font-size: var(--text-caption);
}

.match-status.live {
    color: #fff;
    background-color: var(--color-live);
    border-color: var(--color-live);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.scoreboard {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-16);
    width: 100%;
}

.team-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-5);
    width: 200px;
    text-align: center;
}

.team-logo-large {
    width: 100px;
    height: 100px;
    object-fit: contain;
    background: transparent;
    padding: 0;
    border: none;
    border-radius: 0;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.team-name {
    font-weight: var(--weight-heavy);
    font-size: 1.4rem;
    color: var(--color-text-primary);
    line-height: 1.2;
}

.score-display {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    font-family: var(--font-family);
    font-weight: var(--weight-heavy);
    font-size: 4.5rem;
    color: var(--color-text-primary);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.score-divider {
    color: var(--color-text-secondary);
    font-size: 2rem;
    font-weight: var(--weight-regular);
    margin-top: -10px;
}

/* --- Tabs --- */
.match-tabs {
    display: flex;
    justify-content: center;
    gap: var(--space-2);
    margin-bottom: var(--space-8);
    border-bottom: 1px solid var(--color-separator);
    padding-bottom: 1px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.match-tabs::-webkit-scrollbar {
    display: none;
}

.match-tab {
    padding: var(--space-3) var(--space-8);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-secondary);
    font-weight: var(--weight-bold);
    font-size: var(--text-subhead);
    cursor: pointer;
    transition: color var(--duration-fast) var(--ease-decel);
    flex-shrink: 0;
}

.match-tab:hover {
    color: var(--color-text-primary);
}

.match-tab.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

/* --- Content Areas --- */
.tab-content {
    display: none;
    animation: fadeUp var(--duration-normal) var(--ease-decel);
}

.tab-content.active {
    display: block;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Overview Tab --- */
.overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-8);
}

.mvp-section {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-8);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.section-title {
    text-transform: uppercase;
    font-size: var(--text-footnote);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-caps);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-6);
}

.mvp-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.mvp-portrait {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 1px solid var(--color-accent);
    box-shadow: var(--shadow-md);
}

.mvp-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mvp-info h3 {
    font-size: var(--text-title-3);
    font-weight: var(--weight-heavy);
    margin-bottom: var(--space-1);
}

.mvp-hero {
    font-size: var(--text-subhead);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-4);
}

.mvp-kda-box {
    display: flex;
    justify-content: center;
    gap: var(--space-6);
    background: var(--color-bg-base);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    margin-top: var(--space-2);
}

.kda-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.kda-val {
    font-size: 1.4rem;
    font-weight: var(--weight-heavy);
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

.kda-lbl {
    font-size: var(--text-caption);
    font-weight: var(--weight-bold);
    color: var(--color-text-secondary);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
}

.mvp-subsection-title {
    font-size: var(--text-caption);
    color: var(--color-text-secondary);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    margin-top: var(--space-5);
    margin-bottom: var(--space-2);
}

.mvp-played-heroes {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
}

.played-hero-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.played-hero-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: 2px solid var(--color-border);
    object-fit: cover;
    transition: transform var(--duration-fast) var(--ease-decel);
    display: block;
}

.played-hero-wrapper:hover .played-hero-icon {
    transform: scale(1.15);
    border-color: var(--color-accent);
}

.games-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.game-summary-card {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-4) var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.game-summary-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.gs-title {
    font-weight: var(--weight-heavy);
    font-size: var(--text-headline);
}

.gs-meta {
    font-size: var(--text-footnote);
    color: var(--color-text-secondary);
}

.gs-result {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex: 1;
    justify-content: center;
}

.gs-team-mini {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-weight: var(--weight-bold);
    font-size: var(--text-subhead);
    color: var(--color-text-primary);
}

.gs-team-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: var(--radius-full);
}

.gs-team-score {
    font-size: var(--text-headline);
    font-weight: var(--weight-medium);
    width: 22px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.gs-team-mini:first-child .gs-sword-wrapper {
    margin-left: -6px;
    margin-right: 2px;
}

.gs-team-mini:last-child .gs-sword-wrapper {
    margin-right: -6px;
    margin-left: 2px;
}

.gs-sword-wrapper {
    width: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.gs-sword-icon {
    width: 14px;
    height: 14px;
    opacity: 0.8;
}

html.dark-mode .gs-sword-icon {
    filter: invert(1);
}

.gs-bars {
    display: flex;
    gap: 4px;
    align-items: center;
}

.win-bar {
    width: 4px;
    height: 14px;
    background: var(--color-dead);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(var(--color-accent-rgb), 0.4);
}

.empty-bar {
    width: 4px;
    height: 14px;
    background: var(--color-bg-base);
    border-radius: 2px;
}

.gs-divider {
    font-weight: var(--weight-regular);
    color: var(--color-text-secondary);
    font-size: 1.2rem;
    opacity: 0.5;
}

.gs-mvp-mini {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-align: right;
}

.gs-mvp-text {
    display: flex;
    flex-direction: column;
    font-size: var(--text-caption);
}

.gs-mvp-img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 2px solid var(--color-border);
}

/* --- Game Details --- */
.draft-container {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-8);
    margin-bottom: var(--space-8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-8);
    box-shadow: var(--shadow-sm);
}

.draft-phase-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    flex: 1;
    position: relative;
    padding: var(--space-4);
    border-radius: var(--radius-sm);
    transition: background-color var(--duration-fast) var(--ease-standard);
}

.first-pick-indicator {
    position: absolute;
    top: -10px;
    left: var(--space-4);
    background: var(--color-dead);
    color: #fff;
    font-size: var(--text-caption);
    font-weight: var(--weight-heavy);
    padding: 2px var(--space-2);
    border-radius: var(--radius-xs);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.draft-phase-wrapper:last-child .first-pick-indicator {
    left: auto;
    right: var(--space-4);
}

.draft-team {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    flex-wrap: wrap;
}

.picks-row {
    padding-top: var(--space-2);
    border-top: 1px dashed var(--color-separator);
}

.draft-team-b {
    flex-direction: row-reverse;
}

.draft-label {
    font-size: var(--text-caption);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--color-text-secondary);
    width: 120px;
    flex-shrink: 0;
}

.draft-team-b .draft-label {
    text-align: right;
}

.draft-team:not(.draft-team-b) .draft-label {
    margin-right: var(--space-4);
}

.draft-team-b .draft-label {
    margin-left: var(--space-4);
}

.ban-wrapper, .pick-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ban-img, .pick-img {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
    transition: filter var(--duration-fast) var(--ease-standard),
                transform var(--duration-fast) var(--ease-standard),
                border-color var(--duration-fast) var(--ease-standard);
    object-fit: cover;
    display: block;
}

.ban-img {
    filter: grayscale(100%);
    opacity: 0.8;
}

.ban-wrapper:hover .ban-img,
.pick-wrapper:hover .pick-img {
    filter: grayscale(0%);
    opacity: 1;
    transform: scale(1.1);
    border-color: var(--color-accent);
}

.game-duration-badge {
    background: var(--color-bg-elevated);
    padding: var(--space-3) var(--space-10);
    border-radius: var(--radius-xl);
    font-weight: var(--weight-bold);
    font-size: var(--text-headline);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: var(--space-8);
    box-shadow: var(--shadow-sm);
}

.game-meta-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
    min-width: 120px;
}

.gm-time {
    font-size: var(--text-headline);
    font-weight: var(--weight-heavy);
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

.gm-map {
    font-size: var(--text-caption);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    font-weight: var(--weight-bold);
    margin-top: 2px;
}

.draft-score-side {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.draft-score-side .gs-sword-icon {
    width: 16px;
    height: 16px;
    opacity: 0.9;
}

.draft-score-val {
    font-size: 1.4rem;
    font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums;
    width: 32px;
    text-align: center;
}

.draft-score-side .win-bar,
.draft-score-side .empty-bar {
    height: 18px;
    width: 5px;
}

/* Stats Table */
.game-stats-container {
    margin-top: var(--space-8);
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 1fr;
    gap: var(--space-6);
    align-items: stretch;
}

.stats-table-container {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.stats-table-container .table-wrapper {
    flex: 1;
    display: inline-grid;
}

.stats-table-header {
    padding: var(--space-5);
    background: var(--color-bg-elevated);
    border-bottom: 1px solid var(--color-separator);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-weight: var(--weight-bold);
    font-size: var(--text-title-3);
}

.stats-team-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    background: transparent;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.win-loss-tag {
    font-size: var(--text-caption);
    padding: 2px var(--space-2);
    border-radius: var(--radius-xs);
    text-transform: uppercase;
    margin-left: auto;
    font-weight: var(--weight-heavy);
    letter-spacing: var(--tracking-caps);
}

.win-loss-tag.win  { background: var(--color-win); color: #fff; }
.win-loss-tag.loss { background: var(--color-loss); color: #fff; }

.table-wrapper {
    overflow: hidden;
}

.custom-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-footnote);
    white-space: nowrap;
    table-layout: fixed;
}

.custom-stats-table th:nth-child(1) { width: 8%;  text-align: center; }
.custom-stats-table th:nth-child(2) { width: 27%; text-align: left; }
.custom-stats-table th:nth-child(3) { width: 8%;  text-align: center; }
.custom-stats-table th:nth-child(4) { width: 8%;  text-align: center; }
.custom-stats-table th:nth-child(5) { width: 17%; text-align: center; }
.custom-stats-table th:nth-child(6) { width: 16%; text-align: center; }
.custom-stats-table th:nth-child(7) { width: 16%; text-align: center; }

.custom-stats-table th {
    padding: var(--space-3) var(--space-1);
    color: var(--color-text-secondary);
    font-size: var(--text-caption);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    font-weight: var(--weight-bold);
    border-bottom: 1px solid var(--color-separator);
    white-space: normal;
    vertical-align: bottom;
    line-height: 1.1;
}

.custom-stats-table th:first-child {
    padding-left: var(--space-3);
}

.custom-stats-table td {
    padding: var(--space-3) var(--space-1);
    text-align: center;
    border-bottom: 1px solid var(--color-separator);
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

.custom-stats-table td:first-child {
    text-align: center;
    padding-left: var(--space-3);
}

.p-spell-icon {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
    object-fit: cover;
    display: block;
    margin: 0 auto;
}

.p-role-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.spell-wrapper, .role-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.flex-badge {
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-primary) 40%, transparent);
    border-radius: 3px;
    padding: 1px 3px;
    line-height: 1.2;
    position: absolute;
    bottom: -4px;
    right: -4px;
    pointer-events: none;
}

.custom-stats-table tr:last-child td {
    border-bottom: none;
}

.player-flex {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.p-hero-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 1px solid var(--color-border);
}

.p-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.p-ign {
    font-weight: var(--weight-bold);
    font-size: var(--text-subhead);
    align-self: flex-start;
}

.p-hero-name {
    font-size: var(--text-caption);
    color: var(--color-text-secondary);
    align-self: flex-start;
}

.p-hero-wrapper {
    position: relative;
    flex-shrink: 0;
}

.mvp-badge-overlay {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: #ffd60a;
    color: #000;
    font-size: 0.55rem;
    font-weight: var(--weight-heavy);
    padding: 1px 3px;
    border-radius: 3px;
    line-height: 1;
    z-index: 2;
    text-transform: uppercase;
    box-shadow: var(--shadow-sm);
}

.mvp-row {
    background: linear-gradient(to right, rgba(255, 214, 10, 0.08), transparent);
}

/* Responsive */
@media (max-width: 1200px) {
    .game-stats-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .match-hero__nav { display: none; }
    .match-hero { padding: var(--space-6) 0; margin-bottom: var(--space-6); }
    .match-meta {
        flex-direction: column;
        gap: var(--space-1);
        margin-bottom: var(--space-5);
        font-size: var(--text-caption);
        align-items: center;
    }
    .scoreboard { gap: var(--space-4); padding: 0 var(--space-4); }
    .score-display { font-size: 2.5rem; gap: var(--space-4); }
    .team-logo-large { width: 56px; height: 56px; }
    .team-display { width: auto; min-width: 0; gap: var(--space-3); }
    .team-name { font-size: var(--text-subhead); }
    .match-container { padding: var(--space-4); }
    .match-tabs {
        justify-content: flex-start;
        padding: 0 var(--space-2);
    }
    .overview-grid { grid-template-columns: 1fr; }

    /* Draft section — stack vertically */
    .draft-container {
        flex-direction: column;
        gap: var(--space-4);
        padding: var(--space-4);
        align-items: stretch;
    }
    .draft-phase-wrapper {
        padding: var(--space-3);
    }
    .draft-team {
        flex-wrap: wrap;
        gap: var(--space-2);
    }
    .draft-team-b {
        flex-direction: row;
    }
    .draft-team-b .draft-label {
        text-align: left;
        margin-left: 0;
        margin-right: var(--space-4);
    }
    .draft-label {
        width: 100%;
        margin-right: 0;
    }
    .ban-img, .pick-img {
        width: 34px;
        height: 34px;
    }
    .game-duration-badge {
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--space-4);
        padding: var(--space-3) var(--space-4);
    }
    .game-meta-badge {
        min-width: auto;
    }
    .draft-score-val {
        font-size: 1.1rem;
        width: auto;
    }

    /* Game stats — horizontal scroll */
    .game-stats-container { grid-template-columns: 1fr; gap: var(--space-4); }
    .stats-table-header {
        font-size: var(--text-headline);
        padding: var(--space-4);
    }
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .custom-stats-table {
        table-layout: auto;
        min-width: 560px;
    }
    .player-flex {
        gap: var(--space-2);
    }
    .p-hero-icon {
        width: 32px;
        height: 32px;
    }
    .p-role-icon {
        width: 26px;
        height: 26px;
    }

    /* Game summary cards */
    .game-summary-card { flex-direction: column; align-items: flex-start; gap: var(--space-5); }
    .gs-result { justify-content: flex-start; width: 100%; gap: var(--space-3); }
    .gs-team-mini { font-size: var(--text-footnote); }
    .gs-divider { font-size: var(--text-caption); opacity: 0.5; }
    .gs-mvp-mini { align-self: flex-start; text-align: left; }
    .gs-mvp-mini { flex-direction: row-reverse; }
}

/* --- Head to Head Stats --- */
.h2h-container {
    width: 100%;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-8);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.h2h-header {
    font-size: var(--text-footnote);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-8);
    text-align: center;
}

.h2h-chart {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    width: 100%;
    flex: 1;
    justify-content: center;
}

.h2h-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-size: var(--text-footnote);
}

.h2h-val {
    font-weight: var(--weight-bold);
    width: 45px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.h2h-val-a {
    text-align: right;
    color: var(--color-text-primary);
}

.h2h-val-b {
    text-align: left;
    color: var(--color-text-primary);
}

.h2h-bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 var(--space-4);
}

.h2h-label {
    font-size: var(--text-caption);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    font-weight: var(--weight-bold);
    margin-bottom: 6px;
    line-height: 1;
    letter-spacing: var(--tracking-caps);
}

.h2h-bars {
    display: flex;
    width: 100%;
    height: 8px;
    border-radius: var(--radius-xs);
    background: var(--color-bg-inset);
    overflow: hidden;
}

.h2h-bar {
    height: 100%;
}

.h2h-bar-a {
    background-color: var(--color-dead);
}

.h2h-bar-b {
    background-color: var(--color-live);
}

/* --- Damage Breakdown (Split Layout) --- */
.h2h-container.dmg-card {
    margin-top: 0;
    padding: var(--space-8) var(--space-6);
}

.h2h-container.dmg-card > .h2h-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-align: left;
}

.dmg-card-title {
    flex: 1;
}

.dmg-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs);
    overflow: hidden;
    flex-shrink: 0;
}

.dmg-toggle-btn {
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-size: var(--text-caption);
    font-weight: var(--weight-bold);
    padding: 4px var(--space-2);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    transition: background var(--duration-fast) var(--ease-standard),
                color var(--duration-fast) var(--ease-standard);
    line-height: 1;
}

.dmg-toggle-btn:not(:last-child) {
    border-right: 1px solid var(--color-border);
}

.dmg-toggle-btn.active {
    background: var(--color-accent);
    color: #fff;
}

.dmg-toggle-btn:hover:not(.active) {
    background: var(--color-bg-inset);
    color: var(--color-text-primary);
}

.dmg-chart-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    width: 100%;
    flex: 1;
    justify-content: center;
}

.dmg-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px dashed var(--color-separator);
}

.dmg-summary-side {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.dmg-summary-side.left { align-items: flex-start; }
.dmg-summary-side.right { align-items: flex-end; }

.dmg-summary-lbl {
    font-size: var(--text-caption);
    font-weight: var(--weight-bold);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
}

.dmg-summary-val {
    font-size: var(--text-title-3);
    font-weight: var(--weight-heavy);
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

.dmg-summary-val.team-a { color: var(--color-accent); }
.dmg-summary-val.team-b { color: var(--color-live); }

.dmg-row {
    display: grid;
    grid-template-columns: 90px 1fr 24px 1fr 90px;
    align-items: center;
    gap: var(--space-4);
    padding: 6px 0;
}

.dmg-edge {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
}

.dmg-edge.left  { justify-content: flex-start; }
.dmg-edge.right { justify-content: flex-end; }

.dmg-name-edge {
    font-size: var(--text-caption);
    font-weight: var(--weight-bold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dmg-hero-edge-img {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 1px solid var(--color-border);
    background: var(--color-bg-inset);
    flex-shrink: 0;
}

.dmg-bar-area {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
}

.dmg-pct-text {
    font-size: var(--text-caption);
    color: var(--color-text-secondary);
    font-weight: var(--weight-semibold);
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}

.dmg-track {
    flex: 1;
    height: 16px;
    background: var(--color-border);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    min-width: 0;
}

.dmg-fill {
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 6px;
    white-space: nowrap;
}

.dmg-fill.team-a {
    background-color: var(--color-dead);
    color: #fff;
    justify-content: flex-start;
    margin-right: auto;
    border-radius: 3px 0 0 3px;
}

.dmg-fill.team-b {
    background-color: var(--color-live);
    color: #fff;
    justify-content: flex-end;
    margin-left: auto;
    border-radius: 0 3px 3px 0;
}

.dmg-val-overlay {
    position: absolute;
    width: 100%;
    text-align: center;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--text-caption);
    font-weight: var(--weight-heavy);
    line-height: 1;
    z-index: 2;
    color: #fff;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.dmg-role-center {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.8;
}

.dmg-role-icon-img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    filter: invert(1) brightness(0.9);
}

@media (prefers-color-scheme: light) {
    .dmg-role-icon-img {
        filter: brightness(0.2);
    }
}

@media (max-width: 1400px) {
    .dmg-row {
        grid-template-columns: 70px 1fr 24px 1fr 70px;
        gap: var(--space-2);
    }
}

@media (max-width: 768px) {
    .dmg-row {
        grid-template-columns: 26px 1fr 20px 1fr 26px;
        gap: var(--space-1);
    }
    .dmg-name-edge {
        display: none;
    }
    .dmg-track {
        height: 14px;
    }
}

/* --- Player Rankings Table --- */
.player-ranking-container {
    grid-column: 1 / -1;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.ranking-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--color-separator);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ranking-title {
    font-weight: var(--weight-bold);
    font-size: var(--text-footnote);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--color-text-secondary);
}

.ranking-table-wrapper {
    overflow-x: auto;
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-footnote);
    white-space: nowrap;
    table-layout: fixed;
}

.ranking-table th {
    padding: var(--space-2) var(--space-2);
    color: var(--color-text-secondary);
    font-size: var(--text-caption);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    font-weight: var(--weight-bold);
    border-bottom: 1px solid var(--color-separator);
    vertical-align: middle;
}

.ranking-th-team   { width: 54px;  text-align: center; }
.ranking-th-role   { width: 40px;  text-align: center; }
.ranking-th-player { width: 160px; text-align: left; }
.ranking-th-hero   { width: 50px;  text-align: center; }
.ranking-th-sortable {
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: color var(--duration-fast) var(--ease-decel);
}
.ranking-th-narrow  { width: 42px; }
.ranking-kda-col    { width: 58px; }
.ranking-kills-col  { padding-left: var(--space-5); }
.ranking-gpm-col    { padding-left: var(--space-5); }
.ranking-th-sortable:hover {
    color: var(--color-accent);
}
.ranking-th-sortable.sort-active {
    color: var(--color-accent);
}

.sort-icon {
    display: inline-block;
    margin-left: 2px;
    font-size: 0.55rem;
    opacity: 0.4;
    transition: opacity var(--duration-fast) var(--ease-standard);
}
.sort-icon::after { content: '▼'; }
.ranking-th-sortable.sort-asc .sort-icon::after  { content: '▲'; }
.ranking-th-sortable.sort-desc .sort-icon::after { content: '▼'; }
.ranking-th-sortable.sort-active .sort-icon { opacity: 1; }

.ranking-row {
    transition: background var(--duration-fast) var(--ease-standard);
}

.ranking-row:hover {
    background: var(--color-bg-inset);
}

.ranking-row td {
    padding: var(--space-2) var(--space-2);
    border-bottom: 1px solid var(--color-separator);
    font-variant-numeric: tabular-nums;
    vertical-align: middle;
}

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

.ranking-td-team {
    text-align: center;
    padding-left: var(--space-3);
}

.ranking-team-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.ranking-td-role {
    text-align: center;
}

.ranking-role-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.ranking-td-player {
    font-weight: var(--weight-bold);
    font-size: var(--text-footnote);
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-td-hero {
    text-align: center;
    vertical-align: middle;
}

.ranking-hero-img {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 1px solid var(--color-border);
    display: block;
    margin: 0 auto;
    flex-shrink: 0;
}

.ranking-td-rating {
    text-align: center;
}

.ranking-td-num {
    text-align: center;
    font-weight: var(--weight-semibold);
    font-size: var(--text-caption);
    color: var(--color-text-primary);
}

/* Rating Badges */
.rating-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px var(--space-2);
    border-radius: var(--radius-xs);
    font-weight: var(--weight-heavy);
    font-size: var(--text-caption);
    line-height: 1;
    letter-spacing: 0.3px;
}

.rating-red {
    background: rgba(255, 59, 48, 0.12);
    color: var(--color-loss);
    border: 1px solid rgba(255, 59, 48, 0.25);
}

.rating-amber {
    background: rgba(255, 159, 10, 0.12);
    color: var(--color-warning);
    border: 1px solid rgba(255, 159, 10, 0.25);
}

.rating-green {
    background: rgba(52, 199, 89, 0.10);
    color: var(--color-win);
    border: 1px solid rgba(52, 199, 89, 0.20);
}

.rating-blue {
    background: rgba(10, 132, 255, 0.10);
    color: var(--color-dead);
    border: 1px solid rgba(10, 132, 255, 0.20);
}

.rating-neutral {
    background: var(--color-bg-base);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

/* Team row accent strip */
.team-a-row td:first-child {
    border-left: 3px solid var(--color-dead);
}
.team-b-row td:first-child {
    border-left: 3px solid var(--color-live);
}

@media (max-width: 768px) {
    .ranking-table {
        font-size: var(--text-caption);
        table-layout: auto;
    }
    .ranking-td-player {
        max-width: 110px;
    }
}

/* --- Player Popup Modal --- */
.player-popup-trigger {
    cursor: pointer;
}

.player-popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: var(--space-4);
}

.player-popup-overlay.active {
    display: flex;
}

.player-popup {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 28px var(--space-6) var(--space-6);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: ppIn var(--duration-normal) var(--ease-decel);
    text-align: center;
}

@keyframes ppIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.pp-close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    background: var(--color-bg-inset);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: var(--text-headline);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--duration-fast) var(--ease-standard),
                color var(--duration-fast) var(--ease-standard);
    line-height: 1;
}

.pp-close:hover {
    background: var(--color-border);
    color: var(--color-text-primary);
}

/* Photo + badge */
.pp-photo-wrapper {
    position: relative;
    width: 96px;
    height: 96px;
    margin: 0 auto var(--space-3);
}

.pp-photo {
    width: 96px;
    height: 96px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 3px solid var(--color-accent);
    background: var(--color-bg-inset);
    display: block;
}

.pp-rating-badge {
    position: absolute;
    bottom: 2px;
    right: -6px;
    font-size: var(--text-caption);
    font-weight: var(--weight-heavy);
    padding: 3px var(--space-1);
    border-radius: var(--radius-xs);
    line-height: 1;
    letter-spacing: 0.3px;
}

.pp-rating-badge.rating-red    { background: var(--color-loss); color: #fff; }
.pp-rating-badge.rating-amber  { background: var(--color-warning); color: #fff; }
.pp-rating-badge.rating-green  { background: var(--color-win); color: #fff; }
.pp-rating-badge.rating-blue   { background: var(--color-accent); color: #fff; }
.pp-rating-badge.rating-neutral { background: var(--color-bg-base); color: var(--color-text-secondary); border: 1px solid var(--color-border); }

/* IGN */
.pp-ign-name {
    font-size: var(--text-title-3);
    font-weight: var(--weight-heavy);
    color: var(--color-text-primary);
    line-height: 1.1;
    margin-bottom: var(--space-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Team | Role | Hero identity row */
.pp-identity-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-6);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-5);
    border-bottom: 1px solid var(--color-separator);
}

.pp-identity-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
}

.pp-identity-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.pp-identity-img--round {
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 1px solid var(--color-border);
}

.pp-identity-lbl {
    font-size: var(--text-caption);
    color: var(--color-text-secondary);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pp-identity-sep {
    width: 1px;
    height: 36px;
    background: var(--color-separator);
    flex-shrink: 0;
}

/* Market value amount in identity row */
.pp-identity-mv-amount {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    font-size: var(--text-body);
    font-weight: var(--weight-heavy);
    color: var(--color-text-primary);
    white-space: nowrap;
}


/* KDA Row */
.pp-kda-section {
    display: flex;
    background: var(--color-bg-base);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    margin-bottom: var(--space-2);
    overflow: hidden;
}

.pp-kda-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-2) 0;
    gap: var(--space-1);
}

.pp-kda-item:not(:last-child) {
    border-right: 1px solid var(--color-separator);
}

.pp-kda-val {
    font-size: 1.5rem;
    font-weight: var(--weight-heavy);
    color: var(--color-text-primary);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.pp-kda-lbl {
    font-size: var(--text-caption);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--color-text-secondary);
}

/* Quick stats */
.pp-quick-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.pp-stat-cell {
    background: var(--color-bg-base);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-1);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    align-items: center;
    text-align: center;
}

.pp-stat-lbl {
    font-size: var(--text-caption);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--color-text-secondary);
    line-height: 1.2;
}

.pp-stat-val {
    font-size: var(--text-subhead);
    font-weight: var(--weight-heavy);
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

/* Damage section */
.pp-dmg-section {
    border-top: 1px solid var(--color-separator);
    padding-top: var(--space-3);
}

.pp-dmg-title {
    font-size: var(--text-caption);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-2);
    text-align: left;
}

.pp-dmg-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
}

.pp-dmg-cell {
    background: var(--color-bg-base);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-1);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    align-items: center;
    text-align: center;
}

@media (max-width: 480px) {
    .player-popup {
        padding: var(--space-6) var(--space-4);
        border-radius: var(--radius-md);
    }
    .pp-photo-wrapper { width: 80px; height: 80px; }
    .pp-photo { width: 80px; height: 80px; }
    .pp-kda-val { font-size: 1.2rem; }
    .pp-dmg-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- Static List Layout --- */
.pp-pillars-container {
    border-top: 1px solid var(--color-separator);
    padding-top: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.pp-pillar-item.static-view {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-base);
    overflow: hidden;
}

.pp-pillar-head-static {
    padding: var(--space-2) var(--space-4);
    background: var(--color-bg-inset);
    border-bottom: 1px solid var(--color-separator);
}

.pp-pillar-title {
    font-size: var(--text-caption);
    font-weight: var(--weight-heavy);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--color-accent);
}

.pp-pillar-body-static {
    display: block;
    padding: var(--space-1) var(--space-4) var(--space-2);
    background: var(--color-bg-inset);
}

.pp-list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-1) 0;
    border-bottom: 1px dashed var(--color-separator);
}

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

.pp-list-row .lbl {
    font-size: var(--text-caption);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    font-weight: var(--weight-semibold);
}

.pp-list-row .val {
    font-size: var(--text-footnote);
    font-weight: var(--weight-bold);
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}
