#matchups-table-wrap {
    overflow: auto;
    min-height: calc(100vh - 220px);
    max-height: calc(100vh - 220px);
    border: 1px solid var(--bulma-border, #eee);
    border-radius: 6px;
    background: var(--bulma-scheme-main, #fff);
}

/* While re-fetching after a variant/era switch we keep the old table in place
 * and just dim it — avoids the wrap collapsing and the page jumping. */
#matchups-table-wrap.is-loading > .matchups-table {
    opacity: 0.55;
    transition: opacity 0.12s ease;
    pointer-events: none;
}

@media screen and (max-width: 768px) {
    .section .container.is-fluid {
        padding-left: 0;
        padding-right: 0;
    }

    #era-switcher.buttons,
    #variant-switcher.buttons {
        gap: 4px;
    }

    #era-switcher.buttons .button,
    #variant-switcher.buttons .button {
        font-size: 0.65rem;
    }
}
.matchups-loading {
    padding: 2rem;
    text-align: center;
    color: var(--bulma-grey, #999);
}

.matchups-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 11px;
    table-layout: fixed;
}

.matchups-table th,
.matchups-table td {
    box-sizing: border-box;
    width: 56px;
    min-width: 56px;
    max-width: 56px;
    height: 56px;
    padding: 2px;
    text-align: center;
    border-right: 1px solid var(--bulma-border, #eee);
    border-bottom: 1px solid var(--bulma-border, #eee);
    overflow: hidden;
    vertical-align: middle;
}

.matchups-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bulma-scheme-main-bis, #fafafa);
    height: 110px;
    vertical-align: bottom;
}

.matchups-table thead th.corner {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 5;
    width: 130px;
    min-width: 130px;
    max-width: 130px;
    padding: 0;
    color: var(--bulma-text, #222);
    font-weight: 600;
}

.matchups-table thead th.corner .corner-inner {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 6px 8px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
}

.matchups-table thead th.corner.corner-diagonal {
    background:
        linear-gradient(
            to top right,
            transparent calc(50% - 0.5px),
            var(--bulma-border, #ddd) calc(50% - 0.5px),
            var(--bulma-border, #ddd) calc(50% + 0.5px),
            transparent calc(50% + 0.5px)
        ),
        var(--bulma-scheme-main-bis, #fafafa);
}

.matchups-table thead th.corner .corner-col,
.matchups-table thead th.corner .corner-vs {
    position: absolute;
    color: var(--bulma-text, #222);
}

.matchups-table thead th.corner .corner-col,
.matchups-table thead th.corner .corner-row {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bulma-text, #222);
}

.matchups-table thead th.corner .corner-col {
    top: 6px;
    right: 8px;
}

.matchups-table thead th.corner .corner-row-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 13px;
    width: 100%;
}

.matchups-table thead th.corner .corner-hint {
    font-size: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    color: var(--bulma-text-weak, #888);
    white-space: nowrap;
}

.matchups-table thead th.corner .corner-vs {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--bulma-text-strong, #222);
    background: var(--bulma-scheme-main-bis, #fafafa);
    padding: 2px 8px;
    border-radius: 3px;
}

.matchups-table th.col-head {
    font-weight: 600;
    padding: 4px 0;
    text-align: center;
    vertical-align: bottom;
}

.matchups-table th.col-head .col-head-inner {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.matchups-table th.col-head .swatch {
    margin: 0;
}

.matchups-table tbody th.row-head {
    position: sticky;
    left: 0;
    z-index: 1;
    width: 130px;
    min-width: 130px;
    max-width: 130px;
    text-align: left;
    padding-left: 8px;
    background: var(--bulma-scheme-main-bis, #fafafa);
    font-weight: 600;
    display: flex;
    align-items: center;
    height: 56px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.matchups-table tbody th.row-head:hover {
    background: var(--bulma-scheme-main-ter, #f0f0f0);
}

.matchups-table.has-focused-row tbody tr:not(.focused-row) {
    opacity: 0.55;
    transition: opacity 0.2s ease;
}

.matchups-table.has-focused-row tbody tr:not(.focused-row) > td.cell {
    filter: blur(1.5px);
}

.matchups-table.has-focused-row tbody tr:not(.focused-row) > th.row-head {
    filter: grayscale(0.4);
}

.matchups-table tbody tr.focused-row {
    position: sticky;
    top: 110px;
    z-index: 3;
}

.matchups-table tbody tr.focused-row > th.row-head,
.matchups-table tbody tr.focused-row > td.cell {
    position: sticky;
    top: 110px;
    z-index: 2;
    background-color: var(--bulma-scheme-main, #fff);
}

.matchups-table tbody tr.focused-row > th.row-head {
    background: var(--bulma-link-light, #eef1fb);
    color: var(--bulma-link-dark, #1d2d8a);
    box-shadow: inset 1px 0 0 0 var(--bulma-link, #485fc7);
    z-index: 4;
}

.theme-dark .matchups-table tbody tr.focused-row > td.cell {
    background-color: var(--bulma-scheme-main, #1a1a1a);
}

.theme-dark .matchups-table tbody tr.focused-row > th.row-head {
    background: #2a3358;
    color: #cdd6ff;
    box-shadow: inset 1px 0 0 0 #6384ff;
}

.matchups-table .swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

.matchups-table .head-label {
    display: inline-block;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

.matchups-table tbody th.row-head .turn-legend {
    margin-left: auto;
    display: flex;
    align-items: stretch;
    gap: 2px;
    font-size: 8px;
    font-weight: 700;
    line-height: 1;
    color: var(--bulma-text-weak, #888);
    height: 100%;
    padding: 2px 0;
}

.matchups-table tbody th.row-head .turn-legend .turn-word {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.matchups-table tbody th.row-head .turn-legend .turn-nums {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 10px;
    color: var(--bulma-text, #333);
}

.matchups-table td.cell {
    cursor: default;
    font-weight: 600;
}

.matchups-table td.cell.dual {
    padding: 0;
}

.matchups-table td.cell.dual .cell-half {
    height: 50%;
    line-height: 1;
    font-size: 11px;
    font-weight: 600;
    color: #111;
    background: hsl(var(--cell-hue, 0), 65%, 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.theme-dark .matchups-table td.cell.dual .cell-half {
    background: hsl(var(--cell-hue, 0), 55%, 58%);
}

.matchups-table td.cell.dual .cell-first {
    border-bottom: 1px solid rgba(0, 0, 0, 0.18);
}

.matchups-table td.cell.dual .cell-half.half-empty {
    background: transparent;
    color: var(--bulma-grey-light, #bbb);
    font-weight: 400;
    opacity: 0.5;
}

.matchups-table td.cell .pct {
    font-size: 12px;
    line-height: 1.1;
}

.matchups-table td.cell .cnt {
    font-size: 9px;
    line-height: 1.1;
    opacity: 0.8;
    font-weight: 500;
}

.matchups-table td.cell.empty,
.matchups-table td.cell.low-sample {
    background: transparent;
    color: var(--bulma-grey-light, #bbb);
    font-weight: 400;
}

.matchups-table td.cell.low-sample {
    opacity: 0.6;
}

.matchups-table td.cell:hover {
    outline: 2px solid var(--bulma-link, #485fc7);
    outline-offset: -2px;
}

/* Shared cell tooltip (one DOM node, positioned via floatingUI) */
.matchups-tooltip {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    opacity: 0;
    transform: translateZ(0);
    transition: opacity 0.12s ease;
    background: var(--bulma-scheme-main, #fff);
    color: var(--bulma-text, #222);
    border: 1px solid var(--bulma-border, #ddd);
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    padding: 8px 10px;
    font-size: 12px;
    z-index: 1000;
    min-width: 220px;
    max-width: 320px;
}

.matchups-tooltip.is-visible {
    opacity: 1;
}

.matchups-tooltip .tip-header {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--bulma-border, #eee);
}

.matchups-tooltip .tip-vs {
    color: var(--bulma-text-weak, #888);
    font-weight: 400;
    margin: 0 4px;
}

.matchups-tooltip .tip-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.matchups-tooltip .tip-section {
    padding: 4px 0;
}

.matchups-tooltip .tip-section + .tip-section {
    border-top: 1px solid var(--bulma-border, #eee);
    margin-top: 2px;
    padding-top: 6px;
}

.matchups-tooltip .tip-row-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.matchups-tooltip .tip-label {
    color: var(--bulma-text-strong, #222);
    font-weight: 700;
}

.matchups-tooltip .tip-sub {
    color: var(--bulma-text-weak, #888);
    font-size: 11px;
}

.matchups-tooltip .tip-tags {
    display: flex;
    gap: 4px;
}

.matchups-tooltip .tip-tags .tag {
    flex: 1;
    justify-content: center;
    font-weight: 600;
}

.matchups-tooltip .tip-dim,
.matchups-tooltip .tip-empty,
.matchups-tooltip .tip-section-dim .tip-label {
    color: var(--bulma-grey-light, #aaa);
}

.matchups-tooltip .tip-empty {
    text-align: center;
    padding: 4px 0;
}

@media screen and (max-width: 768px) {
    .matchups-table th,
    .matchups-table td {
        width: 36px;
        min-width: 36px;
        max-width: 36px;
    }

    .matchups-table thead th.corner,
    .matchups-table tbody th.row-head {
        width: 96px;
        min-width: 96px;
        max-width: 96px;
    }

    .matchups-table .head-label {
        max-width: 70px;
    }
}
