/* Stats & Strats (specs/stats-overhaul-plan.md). Dark workbench look: a veil over the galaxy
   background, solid panels, cards shown with their art, and every rate drawn as a meter
   (win rates as a bar out from the 50% line with the margin of error as a bracket). */

.stats-body {
    --st-gold: #ffbf00;
    --st-gold-soft: #ffd970;
    --st-ink: #f2eee8;
    --st-ink-2: rgba(242, 238, 232, 0.72);
    --st-ink-3: rgba(242, 238, 232, 0.5);
    --st-surface: #131215;
    --st-surface-2: #1b1a1e;
    --st-line: rgba(255, 255, 255, 0.07);
    --st-line-gold: rgba(255, 191, 0, 0.22);
    --st-up: #4cc79a;
    --st-down: #f07b5f;
    --st-radius: 14px;
}

body.stats-body {
    background-color: #070605;
}

/* ── Shell: rail + content ─────────────────────────────────── */
.stats-shell {
    display: flex;
    align-items: flex-start;
    width: 100%;
    max-width: 1560px;
    margin: 0 auto;
    text-align: left;
}

.stats-sidebar {
    position: sticky;
    top: 140px; /* below fixed site header (70px) + action bar (70px) */
    flex: 0 0 230px;
    height: calc(100vh - 242px);
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(24, 22, 26, 0.96), rgba(14, 13, 15, 0.96));
    border: 1px solid var(--st-line);
    border-radius: var(--st-radius);
    margin: 16px 0 16px 16px;
    padding: 12px 10px 18px;
    box-sizing: border-box;
    scrollbar-width: thin;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

/* main.css sets a global `nav { display:flex; justify-content:center }` for the site header */
.stats-nav {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    text-align: left;
}

.stats-nav-group {
    margin-bottom: 6px;
}

.stats-nav-group-label {
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.6rem;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--st-ink-3);
    padding: 14px 12px 6px;
}

.stats-tab {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    height: auto; /* override global button height */
    background: transparent;
    border: none;
    border-radius: 10px;
    padding: 11px 12px;
    color: var(--st-ink-2);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.8rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s, color 0.2s;
    box-sizing: border-box;
}

.stats-tab > i:first-child {
    width: 18px;
    text-align: center;
    font-size: 0.82rem;
    color: rgba(255, 191, 0, 0.55);
    transition: color 0.2s;
    flex-shrink: 0;
}

.stats-tab > span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-tab:hover {
    color: var(--st-ink);
    background: rgba(255, 255, 255, 0.05);
}

.stats-tab.active {
    background: linear-gradient(90deg, rgba(255, 191, 0, 0.2), rgba(255, 191, 0, 0.04));
    color: var(--st-gold);
}

.stats-tab.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 3px;
    background: var(--st-gold);
    box-shadow: 0 0 10px rgba(255, 191, 0, 0.6);
}

.stats-tab.active > i:first-child {
    color: var(--st-gold);
}

.stats-tab:focus-visible {
    outline: 2px solid var(--st-gold);
    outline-offset: -2px;
}

.stats-lock-icon {
    font-size: 0.62rem;
    opacity: 0.6;
    flex-shrink: 0;
}

/* Subscriber lock/crown: non-subscribers see a lock, subscribers a crown, never both */
.stats-crown-icon {
    display: none;
    font-size: 0.62rem;
    color: rgba(255, 191, 0, 0.85);
    flex-shrink: 0;
}

.stats-tab-premium.stats-unlocked .stats-lock-icon {
    display: none;
}

.stats-tab-premium.stats-unlocked .stats-crown-icon {
    display: inline-block;
}

/* ── Content column, heading, filters ──────────────────────── */
.stats-content-col,
.stats-page {
    flex: 1;
    min-width: 0;
}

.stats-topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px 24px;
    padding: 22px 24px 0;
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
}

.stats-hero {
    flex: 1 1 320px;
    min-width: 0;
}

.stats-heading {
    font-family: 'DragonSlayer', serif;
    font-weight: normal;
    color: var(--st-gold);
    font-size: 2.2rem;
    letter-spacing: 4px;
    line-height: 1;
    margin: 0 0 10px;
    text-align: left;
    text-shadow: 0 0 24px rgba(255, 191, 0, 0.25);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-scope {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 28px;
}

.stats-scope-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--st-line);
    color: var(--st-ink-2);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.74rem;
    letter-spacing: 0.8px;
}

.stats-scope-chip i {
    color: var(--st-gold);
    font-size: 0.72rem;
}

.stats-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.stats-filter {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.62rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--st-ink-3);
}

.stats-seg {
    display: inline-flex;
    flex-wrap: wrap;
    padding: 3px;
    gap: 2px;
    background: rgba(10, 10, 12, 0.9);
    border: 1px solid var(--st-line);
    border-radius: 10px;
}

.stats-seg button {
    height: auto;
    padding: 7px 12px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--st-ink-2);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.74rem;
    letter-spacing: 0.6px;
    text-transform: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.stats-seg button:hover {
    color: var(--st-ink);
    background: rgba(255, 255, 255, 0.06);
}

.stats-seg button.active {
    background: var(--st-gold);
    color: #141006;
    box-shadow: 0 2px 10px rgba(255, 191, 0, 0.3);
}

.stats-seg button:focus-visible {
    outline: 2px solid var(--st-gold);
    outline-offset: 1px;
}

.stats-tagline {
    flex: 1 1 100%;
    margin: 0;
    padding: 0 0 2px;
    color: var(--st-ink-3);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.74rem;
    letter-spacing: 0.4px;
    line-height: 1.4;
}

.stats-tagline i {
    color: rgba(255, 191, 0, 0.7);
    margin-right: 4px;
}

.stats-page {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 18px 24px 80px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    box-sizing: border-box;
}

.stats-page [hidden],
.stats-filter[hidden],
.stats-filter select[hidden],
.stats-drawer[hidden],
.stats-drawer-backdrop[hidden] {
    display: none !important;
}

/* Admin-only recompute control (stats.js reveals it; the endpoint enforces admin too) */
.stats-admin-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    background: var(--st-surface);
    border: 1px dashed rgba(255, 191, 0, 0.3);
    border-radius: 10px;
    padding: 10px 14px;
}

.stats-admin-info {
    flex: 1;
    color: var(--st-ink-2);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.78rem;
    letter-spacing: 0.5px;
}

.stats-admin-btn {
    height: auto;
    background: rgba(255, 191, 0, 0.18);
    border: 1px solid rgba(255, 191, 0, 0.45);
    color: var(--st-gold);
    padding: 7px 14px;
    border-radius: 8px;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.72rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: background 0.2s;
}

.stats-admin-btn:hover { background: rgba(255, 191, 0, 0.3); }
.stats-admin-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Panels, surfaces, locks ───────────────────────────────── */
.stats-panel {
    display: none;
    position: relative;
    animation: statsIn 0.25s ease;
}

.stats-panel.active {
    display: block;
}

@keyframes statsIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.stats-table-wrap,
.stats-chart-wrap,
.stats-ov-tile,
.stats-matchup-card,
.stats-lock-card {
    background: linear-gradient(180deg, var(--st-surface-2), var(--st-surface));
    border: 1px solid var(--st-line);
    border-radius: var(--st-radius);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.stats-lock-card {
    position: relative;
    margin: 12px auto 20px;
    padding: 30px 36px;
    text-align: center;
    max-width: 420px;
    border-color: var(--st-line-gold);
    overflow: hidden;
}

.stats-lock-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--st-gold), transparent);
}

.stats-lock-card i.fas.fa-lock {
    font-size: 1.6rem;
    color: var(--st-gold);
    width: 58px;
    height: 58px;
    line-height: 58px;
    border-radius: 50%;
    background: rgba(255, 191, 0, 0.1);
    border: 1px solid var(--st-line-gold);
    margin-bottom: 10px;
}

.stats-lock-card h3 {
    font-family: 'DragonSlayer', serif;
    font-weight: normal;
    color: var(--st-gold);
    margin: 6px 0 10px;
    letter-spacing: 1px;
}

.stats-lock-card p {
    font-family: 'HwyGothic', Arial, sans-serif;
    color: var(--st-ink-2);
    margin: 0 0 18px;
    font-size: 0.86rem;
    line-height: 1.5;
}

.stats-subscribe-btn {
    display: inline-block;
    background: linear-gradient(180deg, #ffcf3d, #e6a800);
    border: none;
    color: #141006;
    padding: 11px 30px;
    border-radius: 10px;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-weight: bold;
    letter-spacing: 2px;
    text-decoration: none;
    font-size: 0.85rem;
    box-shadow: 0 6px 18px rgba(255, 191, 0, 0.25);
    transition: transform 0.15s, box-shadow 0.15s;
}

.stats-subscribe-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(255, 191, 0, 0.35);
}

/* ── Section titles, notes ─────────────────────────────────── */
.stats-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'DragonSlayer', serif;
    font-weight: normal;
    color: var(--st-gold);
    font-size: 1.15rem;
    letter-spacing: 1.5px;
    margin: 4px 0 10px;
}

.stats-section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--st-line-gold), transparent);
}

.stats-gap {
    margin-top: 30px;
}

.stats-section-note {
    display: block;
    color: var(--st-ink-2);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.78rem;
    line-height: 1.45;
    letter-spacing: 0.4px;
    margin: 0 0 12px;
    max-width: 100%;
}

.stats-section-note:empty {
    display: none;
}

.stats-lock-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255, 191, 0, 0.08);
    border: 1px solid var(--st-line-gold);
    color: var(--st-gold-soft);
}

.stats-lock-note a {
    margin-left: auto;
    color: #141006;
    background: var(--st-gold);
    border-radius: 7px;
    padding: 5px 12px;
    font-weight: bold;
    letter-spacing: 1px;
    text-decoration: none;
}

.stats-signin {
    padding: 40px 0;
}

/* ── Search, buttons ───────────────────────────────────────── */
.stats-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.stats-search,
.stats-select,
.stats-matchup-pick select {
    flex: 1;
    min-width: 200px;
    height: auto;
    background: rgba(10, 10, 12, 0.9);
    border: 1px solid var(--st-line);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--st-ink);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.86rem;
    letter-spacing: 0.4px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.stats-search {
    padding-left: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23ffbf00' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px center;
}

.stats-search:focus,
.stats-select:focus,
.stats-matchup-pick select:focus {
    border-color: rgba(255, 191, 0, 0.55);
    box-shadow: 0 0 0 3px rgba(255, 191, 0, 0.12);
}

.stats-search::placeholder {
    color: var(--st-ink-3);
}

.stats-actions .stats-select {
    flex: 0 0 auto;
    width: auto;
    min-width: 170px;
    padding-left: 14px;
}

.stats-btn-primary,
.stats-btn-secondary {
    height: auto;
    border-radius: 10px;
    padding: 10px 16px;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.78rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: background 0.2s;
}

.stats-btn-primary {
    background: rgba(255, 191, 0, 0.15);
    border: 1px solid rgba(255, 191, 0, 0.3);
    color: var(--st-gold);
}

.stats-btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--st-ink);
    border: 1px solid var(--st-line);
}

.stats-btn-primary:hover { background: rgba(255, 191, 0, 0.28); }
.stats-btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }

/* ── Tables ────────────────────────────────────────────────── */
.stats-table-wrap {
    max-width: 100%;
    overflow: auto;
}

/* long card lists scroll inside their panel so the header row stays in view */
#panel-cards .stats-table-wrap,
#panel-arena .stats-table-wrap[data-unlocked] {
    max-height: calc(100vh - 250px);
    min-height: 320px;
}

.stats-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.stats-table th,
.stats-table td {
    padding: 8px 14px;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.84rem;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--st-line);
    text-align: left;
    white-space: nowrap;
    line-height: 1.2;
    vertical-align: middle;
}

.stats-table th {
    background: #1f1d22;
    color: var(--st-ink-3);
    font-size: 0.64rem;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 2;
    padding-top: 11px;
    padding-bottom: 11px;
    border-bottom: 1px solid var(--st-line-gold);
}

.stats-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.stats-table th.sortable:hover {
    color: var(--st-ink);
}

.stats-table th.sortable::after {
    content: '\2195';
    margin-left: 5px;
    font-size: 0.9em;
    opacity: 0.35;
}

.stats-table th.sortable.sorted-asc,
.stats-table th.sortable.sorted-desc {
    color: var(--st-gold);
}

.stats-table th.sortable.sorted-asc::after {
    content: '\25B2';
    opacity: 1;
}

.stats-table th.sortable.sorted-desc::after {
    content: '\25BC';
    opacity: 1;
}

.stats-table td {
    color: var(--st-ink);
}

.stats-table tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.015);
}

.stats-table tbody tr:hover td {
    background: rgba(255, 191, 0, 0.06);
}

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

.stats-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.stats-table .stats-num {
    text-align: right;
}

.stats-dim {
    color: var(--st-ink-2) !important;
}

.stats-loading {
    text-align: center !important;
    color: var(--st-ink-3) !important;
    font-style: italic;
    padding: 28px 16px !important;
}

.stats-table tr.stats-row-low td {
    opacity: 0.55;
}

.stats-table tr.stats-clickable {
    cursor: pointer;
}

.stats-table tr.stats-clickable:focus-visible,
.stats-table tr.stats-deck-row:focus-visible {
    outline: 2px solid var(--st-gold);
    outline-offset: -2px;
}


/* ── Card chip (thumbnail + name) ──────────────────────────── */
.stats-chip-card {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    max-width: 100%;
    color: var(--st-ink);
    text-decoration: none;
    font-family: 'HwyGothic', Arial, sans-serif;
    letter-spacing: 0.8px;
}

.stats-chip-card img,
.stats-chip-noart {
    flex: 0 0 auto;
    width: 30px;
    height: 42px;
    object-fit: cover;
    border-radius: 4px;
    background: #222;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
    transition: transform 0.15s;
}

.stats-chip-card span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-chip-card:hover {
    color: var(--st-gold);
}

.stats-chip-card:hover img {
    transform: scale(1.08) rotate(-2deg);
}

.stats-card-link {
    color: var(--st-ink);
    text-decoration: none;
    border-bottom: 1px dotted rgba(255, 191, 0, 0.35);
}

.stats-card-link:hover {
    color: var(--st-gold);
}

/* ── Rates and meters ──────────────────────────────────────── */
.stats-rc {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    min-width: 112px;
}

.stats-rc-top {
    white-space: nowrap;
}

.stats-rate {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-size: 0.95em;
}

.stats-margin {
    margin-left: 4px;
    font-size: 0.78em;
    color: var(--st-ink-3);
}

.stats-low {
    color: var(--st-ink-3);
    font-style: italic;
}

.stats-change {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 5px;
    border-radius: 5px;
    font-size: 0.72em;
    white-space: nowrap;
    vertical-align: 1px;
}

.stats-change.up { color: var(--st-up); background: rgba(76, 199, 154, 0.12); }
.stats-change.down { color: var(--st-down); background: rgba(240, 123, 95, 0.12); }
.stats-change.flat { color: var(--st-ink-3); }

.stats-cell-lock {
    color: var(--st-ink-3);
    font-size: 0.8rem;
}

.stats-meter {
    position: relative;
    display: block;
    width: 112px;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
}

.stats-meter-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    border-radius: 3px;
    background: linear-gradient(90deg, rgba(255, 191, 0, 0.55), var(--st-gold));
    transition: width 0.4s ease, left 0.4s ease;
}

.stats-meter-win .stats-meter-fill.up { background: var(--st-up); }
.stats-meter-win .stats-meter-fill.down { background: var(--st-down); }
.stats-meter-win.low .stats-meter-fill { opacity: 0.45; }

/* the 50% line */
.stats-meter-mid {
    position: absolute;
    left: 50%;
    top: -3px;
    bottom: -3px;
    width: 2px;
    margin-left: -1px;
    border-radius: 1px;
    background: rgba(255, 255, 255, 0.4);
}

/* margin of error: a bracket over the end of the bar */
.stats-meter-ci {
    position: absolute;
    top: -3px;
    bottom: -3px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-top: none;
    border-bottom: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1px;
    box-sizing: border-box;
}

.stats-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    letter-spacing: 0.4px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--st-ink-2);
}

.stats-pill.up { color: var(--st-up); background: rgba(76, 199, 154, 0.12); }
.stats-pill.down { color: var(--st-down); background: rgba(240, 123, 95, 0.12); }

.stats-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--st-line);
    color: var(--st-ink);
    font-size: 0.72rem;
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
}

.stats-badge-constructed { color: #8fc1ff; border-color: rgba(57, 135, 229, 0.4); background: rgba(57, 135, 229, 0.12); }
.stats-badge-split { color: #f3a77f; border-color: rgba(217, 89, 38, 0.4); background: rgba(217, 89, 38, 0.12); }

.stats-stat-label {
    display: block;
    font-family: 'HwyGothic', Arial, sans-serif;
    color: var(--st-ink-3);
    font-size: 0.64rem;
    letter-spacing: 1.8px;
    text-transform: uppercase;
}

.stats-stat-value {
    font-family: 'HwyGothic', Arial, sans-serif;
    color: var(--st-ink);
    font-size: 1.5rem;
    letter-spacing: 0.5px;
    font-variant-numeric: tabular-nums;
}

.stats-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--st-line);
    min-width: 0;
}

.stats-tile .stats-rc {
    align-items: flex-start;
    font-size: 1.25rem;
}

.stats-tile .stats-meter {
    width: 100%;
    min-width: 120px;
}

/* ── Overview ──────────────────────────────────────────────── */
.stats-ov-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
}

.stats-ov-tile {
    padding: 16px 18px;
    min-width: 0;
    color: var(--st-ink);
}

.stats-ov-kpi { grid-column: span 2; }
.stats-ov-feature { grid-column: span 4; }
.stats-ov-half { grid-column: span 3; }
.stats-ov-wide { grid-column: 1 / -1; }

.stats-ov-title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 14px;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-weight: normal;
    font-size: 0.7rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--st-ink-2);
}

.stats-ov-title i {
    width: 26px;
    height: 26px;
    line-height: 26px;
    text-align: center;
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--st-gold);
    background: rgba(255, 191, 0, 0.12);
}

.stats-ov-title-up i { color: var(--st-up); background: rgba(76, 199, 154, 0.12); }
.stats-ov-title-down i { color: var(--st-down); background: rgba(240, 123, 95, 0.12); }

.stats-ov-kpi {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.stats-ov-big {
    font-family: 'DragonSlayer', serif;
    font-size: 3.6rem;
    color: var(--st-gold);
    line-height: 1;
    margin: auto 0 12px;
    text-shadow: 0 0 30px rgba(255, 191, 0, 0.25);
}

.stats-ov-sub {
    font-size: 0.85rem;
    color: var(--st-ink-2);
}

.stats-ov-card {
    display: flex;
    gap: 20px;
    align-items: center;
}

.stats-ov-card img {
    width: 118px;
    border-radius: 8px;
    display: block;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 191, 0, 0.25);
    transform: rotate(-3deg);
    transition: transform 0.2s;
}

.stats-ov-card a:hover img {
    transform: rotate(0) scale(1.04);
}

.stats-ov-card-body {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, auto));
    justify-content: start;
    gap: 14px 30px;
    align-items: end;
}

.stats-ov-card-name {
    grid-column: 1 / -1;
    font-family: 'DragonSlayer', serif;
    font-size: 2rem;
    letter-spacing: 2px;
    color: var(--st-gold);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-ov-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.stats-ov-stat .stats-rc {
    align-items: flex-start;
    font-size: 1.2rem;
}

.stats-ov-stat .stats-stat-value {
    font-size: 1.2rem;
    line-height: 1.2;
}

.stats-ov-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 4px;
    color: var(--st-ink);
}

.stats-ov-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.15s;
}

.stats-ov-list li:hover {
    background: rgba(255, 255, 255, 0.04);
}

.stats-ov-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-ov-name small {
    display: block;
    color: var(--st-ink-3);
    font-size: 0.75rem;
}

.stats-ov-val {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* lists: the meter sits beside the number */
.stats-ov-list .stats-rc {
    flex-direction: row-reverse;
    align-items: center;
    gap: 14px;
}

.stats-ov-list .stats-rc-top {
    min-width: 118px;
    text-align: right;
}

.stats-ov-list .stats-meter {
    width: 150px;
}

.stats-ov-empty {
    color: var(--st-ink-3);
    font-size: 0.85rem;
    padding: 6px 0;
}

.stats-deck-line {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.stats-deck-line i {
    color: var(--st-gold);
    opacity: 0.8;
}

/* how games were won: ranked bars, two columns on wide screens */
.stats-bars {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 36px;
    color: var(--st-ink);
}

.stats-bar-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 54px;
    grid-template-rows: auto auto;
    gap: 5px 10px;
    align-items: center;
}

.stats-bar-label {
    font-size: 0.86rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-bar-val {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--st-ink-2);
}

.stats-bar-row .stats-wc-bar {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    height: 8px;
}

.stats-wc-cell {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    min-width: 110px;
}

.stats-wc-num {
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.stats-wc-bar {
    display: block;
    width: 110px;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.stats-wc-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255, 191, 0, 0.5), var(--st-gold));
    transition: width 0.5s ease;
}

/* ── Charts ────────────────────────────────────────────────── */
.stats-chart-wrap {
    padding: 18px;
    height: 360px;
    margin-bottom: 16px;
    box-sizing: border-box;
}

.stats-chart-small {
    height: 250px;
}

/* ── Decks ─────────────────────────────────────────────────── */
.stats-deck-row {
    cursor: pointer;
}

.stats-deck-name-cell {
    white-space: nowrap;
}

.stats-deck-chevron {
    font-size: 0.7rem;
    color: rgba(255, 191, 0, 0.6);
    margin-right: 8px;
    transition: transform 0.18s ease;
    display: inline-block;
}

.stats-deck-row.expanded .stats-deck-chevron {
    transform: rotate(90deg);
    color: var(--st-gold);
}

.stats-table tr.stats-deck-row.expanded > td {
    background: rgba(255, 191, 0, 0.08);
}

.stats-deck-detail > td,
.stats-table tr.stats-deck-detail:hover > td {
    padding: 0;
    background: #0f0e10;
}

.stats-deck-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px;
}

.stats-deck-card {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.stats-deck-card img {
    width: 70px;
    height: 98px;
    border-radius: 6px;
    display: block;
}

.stats-deck-card-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    background: var(--st-gold);
    color: #0e0e0e;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.6rem;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 8px;
    min-width: 14px;
    text-align: center;
    line-height: 1.2;
}

/* ── Card pairs ────────────────────────────────────────────── */
.stats-matchup-pickers {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.stats-matchup-pick {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    flex: 0 1 260px;
    min-width: 180px;
}

.stats-pick-art {
    align-self: center;
    width: 150px;
    border-radius: 10px;
    margin-bottom: 8px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 191, 0, 0.25);
}

.stats-matchup-pick label {
    color: var(--st-ink-3);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.64rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.stats-matchup-pick select {
    flex: none;
    min-width: 0;
}

.stats-matchup-vs {
    align-self: center;
    width: 44px;
    height: 44px;
    line-height: 44px;
    text-align: center;
    border-radius: 50%;
    background: var(--st-gold);
    color: #141006;
    font-family: 'DragonSlayer', serif;
    font-size: 1.4rem;
    box-shadow: 0 0 20px rgba(255, 191, 0, 0.35);
}

.stats-matchup-card {
    padding: 22px 24px;
    color: var(--st-ink);
}

.stats-matchup-pair {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-family: 'DragonSlayer', serif;
    font-size: 1.5rem;
    color: var(--st-gold);
    letter-spacing: 1.5px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.stats-matchup-amp {
    color: var(--st-ink-3);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.95rem;
}

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

.stats-matchup-solo {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--st-line);
    text-align: center;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.8rem;
    letter-spacing: 0.4px;
    color: var(--st-ink-2);
}

/* ── Me ────────────────────────────────────────────────────── */
.stats-me-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
    margin-top: 10px;
    color: var(--st-ink);
}

#meSummary {
    font-size: 0.9rem;
    color: var(--st-ink);
}

/* ── Card detail drawer ────────────────────────────────────── */
.stats-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    z-index: 1100;
}

.stats-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(560px, 100vw);
    overflow-y: auto;
    background:
        radial-gradient(ellipse 100% 40% at 50% 0%, rgba(255, 191, 0, 0.08), transparent 70%),
        #111013;
    border-left: 1px solid var(--st-line-gold);
    box-shadow: -24px 0 60px rgba(0, 0, 0, 0.7);
    z-index: 1101;
    padding: 22px 22px 40px;
    box-sizing: border-box;
    color: var(--st-ink);
    animation: statsDrawerIn 0.25s ease;
}

@keyframes statsDrawerIn {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.stats-drawer-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    margin-bottom: 18px;
}

.stats-drawer-art {
    width: 104px;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 191, 0, 0.3);
    transform: rotate(-3deg);
}

.stats-drawer-art[hidden] {
    display: none;
}

.stats-drawer-title {
    margin: 0 0 8px;
    font-family: 'DragonSlayer', serif;
    font-weight: normal;
    color: var(--st-gold);
    font-size: 2rem;
    letter-spacing: 2px;
    overflow-wrap: anywhere;
}

.stats-drawer-close {
    align-self: start;
    height: auto;
    width: 38px;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 1px solid var(--st-line);
    background: rgba(255, 255, 255, 0.05);
    color: var(--st-ink);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.stats-drawer-close:hover {
    background: rgba(255, 191, 0, 0.15);
    color: var(--st-gold);
}

.stats-drawer-close:focus-visible {
    outline: 2px solid var(--st-gold);
    outline-offset: 2px;
}

.stats-drawer-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.stats-drawer .stats-section-title {
    font-size: 1rem;
}

.stats-drawer .stats-ov-list {
    margin-bottom: 18px;
}

/* ── Rail becomes a chip bar (tablet, touch) ───────────────── */
@media only screen and (max-width: 1024px), only screen and (hover: none) {
    .stats-shell {
        flex-direction: column;
    }

    .stats-content-col {
        width: 100%;
    }

    .stats-sidebar {
        position: static;
        flex: none;
        width: auto;
        height: auto;
        overflow: visible;
        margin: 10px 10px 0;
        padding: 8px;
        border-radius: 12px;
    }

    .stats-nav {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }

    .stats-nav-group {
        display: contents;
    }

    .stats-nav-group-label {
        display: none;
    }

    .stats-tab {
        width: auto;
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 8px 13px;
        gap: 7px;
        font-size: 0.68rem;
        border: 1px solid var(--st-line);
        border-radius: 999px;
    }

    .stats-tab.active {
        border-color: rgba(255, 191, 0, 0.55);
    }

    .stats-tab.active::before {
        display: none;
    }

    .stats-tab > i:first-child {
        width: auto;
    }

    .stats-topbar {
        padding: 14px 12px 0;
    }

    .stats-heading {
        font-size: 1.6rem;
        letter-spacing: 3px;
    }
}

/* ── Phone ─────────────────────────────────────────────────── */
@media only screen and (max-width: 767px), only screen and (hover: none) and (max-width: 1024px) {
    .stats-page {
        padding: 12px 12px 60px;
    }

    .stats-filters,
    .stats-filter,
    .stats-seg {
        width: 100%;
    }

    .stats-seg {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
        box-sizing: border-box;
    }

    .stats-seg button {
        padding: 8px 4px;
        font-size: 0.68rem;
        white-space: normal;
    }

    .stats-ov-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

    .stats-ov-kpi,
    .stats-ov-feature,
    .stats-ov-half {
        grid-column: auto;
    }

    .stats-ov-big {
        font-size: 2.8rem;
        margin-top: 0;
    }

    .stats-ov-card {
        gap: 14px;
        align-items: flex-start;
    }

    .stats-ov-card img {
        width: 84px;
    }

    .stats-ov-card-body {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }

    .stats-ov-card-name {
        font-size: 1.5rem;
    }

    .stats-bars {
        grid-template-columns: minmax(0, 1fr);
    }

    .stats-ov-list li {
        padding: 6px 2px;
    }

    .stats-rc {
        min-width: 92px;
    }

    .stats-meter {
        width: 92px;
    }

    .stats-table th,
    .stats-table td {
        padding: 7px 9px;
        font-size: 0.78rem;
    }

    .stats-chip-card {
        gap: 8px;
    }

    /* the card column stays put while the rest scrolls sideways */
    .stats-table td.stats-td-card {
        position: sticky;
        left: 0;
        z-index: 1;
        background: #161518;
    }

    .stats-table tbody tr:hover td.stats-td-card {
        background: #221d12;
    }

    .stats-ov-list .stats-rc {
        flex-direction: column;
        align-items: flex-end;
        gap: 5px;
    }

    .stats-ov-list .stats-rc-top {
        min-width: 0;
    }

    .stats-ov-list .stats-meter {
        width: 80px;
    }

    .stats-chip-card img,
    .stats-chip-noart {
        width: 24px;
        height: 34px;
    }

    #panel-cards .stats-table-wrap,
    #panel-arena .stats-table-wrap[data-unlocked] {
        max-height: 70vh;
    }

    .stats-matchup-stats {
        grid-template-columns: minmax(0, 1fr);
    }

    .stats-pick-art {
        width: 110px;
    }

    .stats-chart-wrap {
        height: 280px;
        padding: 12px;
    }

    .stats-drawer {
        padding: 18px 14px 40px;
    }

    .stats-drawer-art {
        width: 78px;
    }

    .stats-drawer-title {
        font-size: 1.5rem;
    }

    .stats-tile .stats-meter {
        min-width: 0;
    }
}
