/* =========================================================================
   HotS Replay Analyzer
   Sections: tokens · base · landing · match header · tabs · overview ·
             tables · charts · timeline · talents · minimap · responsive
   ========================================================================= */

/* ---------- tokens ---------- */
:root {
    /* Nocturne: deep plum ground, violet accent. Teams stay blue / red; roles have their own colours. */
    --bg: #0f0d16;
    --panel: #171424;
    --panel-2: #1f1b30;
    --panel-3: #28233d;
    --border: #2c2742;
    --border-soft: #2c2742aa;
    --text: #ece9f5;
    --muted: #a39cbb;
    --faint: #7a7392;
    --accent: #b69cff;
    --accent-ink: #140f22;
    --blue: #4ea7ff;
    --red: #ff6479;
    --purple: var(--accent);
    --gold: #ffcf66;
    --green: #4bd6a0;
    --radius: 10px;
    --role-tank: #4c9aff;
    --role-damage: #ff5a5f;
    --role-support: #3ddc97;
    --role-bruiser: #ff9f43;
    --role-utility: #b25cff;   /* Abathur, Medivh, The Lost Vikings, Zarya */
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}
button, input, select { font: inherit; }
h1 { font-size: 23px; margin: 4px 0 0; }
h2 { margin: 0; font-size: clamp(34px, 5vw, 58px); line-height: 1; letter-spacing: -.04em; }
h3 { margin: 0; font-size: 17px; }
h4 { margin: 0 0 10px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
code { color: #d7c6ff; background: #1d1a28; padding: 2px 6px; border-radius: 5px; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-icon {
    width: 18px; height: 18px;
    fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
    vertical-align: -3px;
}

.shell { width: min(1540px, calc(100% - 44px)); margin: auto; padding: 28px 0 70px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.eyebrow { color: #c5a8ff; font-size: 11px; letter-spacing: .18em; font-weight: 900; }

.pill {
    display: inline-flex; padding: 7px 11px; margin-bottom: 14px;
    border: 1px solid #35445f; border-radius: 999px; background: #141d2a;
    font-size: 10px; letter-spacing: .12em; font-weight: 900; color: #c3d2e7;
}

.ghost-btn, .primary-btn { border: 0; border-radius: 10px; cursor: pointer; font-weight: 800; }
.ghost-btn { padding: 10px 14px; background: #171f2c; color: #d4deed; border: 1px solid var(--border); }
.primary-btn { width: 100%; padding: 13px 18px; background: #f3f6fb; color: #0d1219; }
.primary-btn:disabled { opacity: .35; cursor: not-allowed; }

.team-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; flex: none; }
.team-dot.blue { background: var(--blue); }
.team-dot.red { background: var(--red); }

/* Hero portrait (_HeroPortrait.cshtml). The fallback initials sit under the image. */
.portrait { position: relative; flex: none; overflow: hidden; background: #202b3c; border: 1px solid #34425a; }
.portrait img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; object-position: center 23%; display: block; }
.portrait-fallback { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; color: #dce7f7; }
.portrait-sm { width: 34px; height: 34px; border-radius: 9px; font-size: 11px; }
.portrait-md { width: 48px; height: 48px; border-radius: 12px; font-size: 14px; }
.portrait-lg { width: 64px; height: 64px; border-radius: 14px; font-size: 18px; }

/* Player summary (Overview) */
.summary-card { margin-top: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.summary-card .table-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
#playerPick { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px; min-width: 260px; }
.player-summary { margin-top: 14px; --team: var(--blue); }
.player-summary.red { --team: var(--red); }
.summary-head { display: flex; align-items: center; gap: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.summary-head strong { display: block; font-size: 20px; color: var(--team); }
.summary-head span { color: var(--muted); font-size: 13px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.summary-block h5 { margin: 0 0 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.summary-line { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 13px; }
.summary-line span { color: #c9d2df; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-line b { font-weight: 800; white-space: nowrap; }
.summary-line.top b { color: var(--team); }
.portrait-lg { width: 62px; height: 62px; border-radius: 14px; font-size: 17px; }
.portrait.blue { box-shadow: inset 0 0 0 1px #4ea7ff35; }
.portrait.red { box-shadow: inset 0 0 0 1px #ff647935; }

.empty-card { padding: 28px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); text-align: center; }

/* ---------- landing ---------- */
.landing { min-height: 70vh; display: grid; align-content: center; gap: 28px; }
.landing-copy { max-width: 790px; }
.landing-copy p { max-width: 690px; color: var(--muted); font-size: 18px; line-height: 1.6; }
.upload-card {
    width: min(700px, 100%); padding: 14px;
    background: rgba(17, 24, 36, .9); border: 1px solid var(--border); border-radius: 20px;
    box-shadow: 0 28px 90px #0006;
}
.drop-zone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    min-height: 245px; border: 1px dashed #435372; border-radius: 15px; cursor: pointer; transition: .15s;
    background: linear-gradient(180deg, #6679b00b, #0f141d0a);
}
.drop-zone:hover, .drop-zone.dragging { border-color: var(--purple); background: #aa7bff12; transform: translateY(-1px); }
.drop-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 15px; background: #202b3d; font-size: 28px; }
.drop-zone strong { font-size: 19px; }
.drop-zone span { color: var(--muted); }
.drop-zone small { color: #617086; margin-top: 14px; }
.selected-file { color: #c7d2e3; padding: 12px 4px 4px; min-height: 34px; font-size: 13px; }
.error-card {
    display: flex; flex-direction: column; gap: 5px; max-width: 700px; padding: 14px 16px;
    background: #ff657812; border: 1px solid #ff65784d; border-radius: 12px; color: #ffc0c8; white-space: pre-wrap;
}

/* ---------- match header ---------- */
.match-hero {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
    padding: 32px 36px; border: 1px solid var(--border); border-radius: 21px; overflow: hidden;
    background: linear-gradient(125deg, #182234, #111722 70%);
}
.hero-main { min-width: 0; }
.hero-main h2 { font-size: 46px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.composition-strip { display: flex; align-items: center; gap: 13px; margin-top: 24px; }
.comp-team { display: flex; gap: 7px; }
.versus { font-size: 10px; font-weight: 900; color: var(--faint); letter-spacing: .12em; }
.winner-box {
    display: flex; flex-direction: column; min-width: 210px; padding: 17px 19px; text-align: right;
    border-radius: 14px; background: #1c2738; border: 1px solid #30405a;
}
.winner-box span { font-size: 10px; letter-spacing: .14em; color: var(--muted); }
.winner-box strong { font-size: 24px; margin-top: 3px; }
.winner-box.blue strong { color: var(--blue); }
.winner-box.red strong { color: var(--red); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; padding: 17px 0 13px; margin-bottom: 20px; border-bottom: 1px solid var(--border); overflow: auto; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 11px 15px; cursor: pointer; border-radius: 10px; font-weight: 800; }
.tab.active { color: var(--text); background: #1a2433; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- overview: one column per team ---------- */
.team-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.team-panel {
    --team: var(--blue);
    border: 1px solid var(--border); border-top: 3px solid var(--team); border-radius: var(--radius);
    background: linear-gradient(180deg, color-mix(in srgb, var(--team) 7%, var(--panel)) 0, var(--panel) 160px);
    overflow: hidden;
}
.team-panel.red { --team: var(--red); }
.team-panel-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 14px; }
.team-label { display: block; font-size: 11px; font-weight: 900; letter-spacing: .14em; color: var(--team); }
.result { display: block; font-size: 26px; margin-top: 4px; letter-spacing: -.02em; }
.result.loss { color: var(--muted); }
.team-level { display: flex; flex-direction: column; align-items: center; padding: 8px 14px; border-radius: 12px; background: #0d131c; border: 1px solid var(--border); }
.team-level span { font-size: 9px; letter-spacing: .14em; color: var(--muted); }
.team-level b { font-size: 26px; color: var(--team); }

.team-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--border); border-block: 1px solid var(--border); }
.team-stat { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 8px; padding: 11px 18px; background: var(--panel); font-size: 13px; }
.team-stat .ui-icon { width: 16px; height: 16px; color: #73849b; }
.team-stat span { color: var(--muted); }
.team-stat b { font-size: 15px; font-variant-numeric: tabular-nums; }
.team-stat.lead b { color: var(--team); }
.team-stat.lead b::after { content: "▲"; font-size: 8px; margin-left: 5px; vertical-align: 2px; }

.team-players-head, .team-player {
    display: grid; grid-template-columns: minmax(0, 1fr) 92px 62px 62px 62px; align-items: center; gap: 8px;
    padding: 0 18px;
}
.team-players-head { padding-top: 12px; padding-bottom: 8px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.team-players-head span:not(:first-child), .team-player > span { text-align: right; font-variant-numeric: tabular-nums; }
.team-player { padding-top: 10px; padding-bottom: 10px; border-top: 1px solid var(--border-soft); font-size: 13px; }
.team-player-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.team-player-id > div { display: flex; flex-direction: column; min-width: 0; }
.team-player-id strong { font-size: 15px; }
.team-player-id span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kda b { font-weight: 800; }
.kda b.d.best { color: var(--team); }   /* the team's fewest deaths */

/* ---------- tables ---------- */
.table-card, .chart-card, .timeline-card {
    margin-bottom: 14px; overflow: hidden;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.table-head, .chart-head {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.table-head > div span, .table-head > span, .chart-head span { color: var(--muted); font-size: 12px; }
.table-head > div span { display: block; margin-top: 4px; }
.table-scroll { overflow: auto; }
table { width: 100%; min-width: 1250px; border-collapse: collapse; font-size: 12px; }
th {
    padding: 11px 12px; text-align: right; color: #8999af; background: #0f1620;
    border-bottom: 1px solid var(--border); font-size: 10px; text-transform: uppercase; letter-spacing: .055em;
}
td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
th:nth-child(-n+3), td:nth-child(-n+3) { text-align: left; }
tbody tr:hover { background: var(--panel-2); }
.th-inner { display: inline-flex; align-items: center; gap: 6px; }
.th-inner .ui-icon { width: 14px; height: 14px; color: #6f819a; }
.table-hero { display: flex; align-items: center; gap: 9px; }

#scoreboardTable th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
#scoreboardTable th.sortable::after { content: "↕"; display: inline-block; margin-left: 7px; opacity: .25; font-size: .85em; }
#scoreboardTable th.sortable:hover::after { opacity: .8; }
#scoreboardTable th.sortable.sort-asc::after { content: "↑"; opacity: 1; }
#scoreboardTable th.sortable.sort-desc::after { content: "↓"; opacity: 1; }

/* ---------- charts ---------- */
.chart-head h3 { display: flex; gap: 8px; align-items: center; }
.chart-head h3 .ui-icon { color: #9dcaff; }
.legend { display: flex; gap: 15px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 3px; }
.blue-line { background: var(--blue); }
.red-line { background: var(--red); }
.chart { display: block; width: 100%; height: auto; padding: 3px 6px 0; }
.chart-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.chart-row .chart-card { margin: 0; }
.chart-empty { padding: 30px 16px; text-align: center; }
@media (max-width: 960px) { .chart-row { grid-template-columns: 1fr; } }
.grid-line { stroke: #28364a; stroke-width: 1; }
.grid-line.vertical { stroke-dasharray: 3 7; opacity: .7; }
.axis-label { fill: #718096; font-size: 11px; }
.series { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.blue-series { stroke: var(--blue); }
.red-series { stroke: var(--red); }
.point { stroke: #0e121a; stroke-width: 2; }
.blue-point { fill: var(--blue); }
.red-point { fill: var(--red); }
.core-point { stroke-width: 1.5; }
.team-toggles button { display: flex; align-items: center; gap: 6px; padding: 3px 8px; border: 1px solid #2c3a50; border-radius: 6px; background: transparent; color: inherit; font: inherit; font-size: 12px; cursor: pointer; }
.team-toggles button[aria-pressed="false"] { opacity: .4; }
.team-toggles button[aria-pressed="false"] i { background: #4a5568; }
.chart.hide-blue .blue-series, .chart.hide-blue .blue-point, .chart.hide-red .red-series, .chart.hide-red .red-point { display: none; }

/* ---------- event timeline ---------- */
.event-filters { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.event-filters label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.timeline-list { max-height: 520px; overflow: auto; }
.timeline-row {
    display: grid; grid-template-columns: 52px 14px 72px 1fr; align-items: center; gap: 8px;
    padding: 9px 18px; border-bottom: 1px solid var(--border-soft); font-size: 12px; cursor: pointer;
}
.timeline-row:hover, .timeline-row:focus-visible { background: var(--panel-2); outline: none; }
.timeline-row[hidden] { display: none; }
.timeline-row time { color: #7f8b9d; font-variant-numeric: tabular-nums; }
.timeline-row b { font-size: 10px; text-transform: uppercase; color: #aab6c9; }
.timeline-row[data-type="Kill"] b { color: #ff9aa8; }
.timeline-row[data-type="Structure"] b { color: var(--gold); }
.timeline-row[data-type="Camp"] b { color: var(--green); }

/* ---------- talents ---------- */
.talent-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.talent-column { display: grid; gap: 14px; }
.talent-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.talent-card.blue { border-top: 2px solid var(--blue); }
.talent-card.red { border-top: 2px solid var(--red); }
.talent-player { display: flex; align-items: center; gap: 12px; padding: 14px 15px; border-bottom: 1px solid var(--border); }
.talent-player > div:last-child { display: flex; flex-direction: column; }
.talent-player span { color: var(--muted); font-size: 11px; margin-top: 2px; }
.talent-list > div { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 10px 15px; border-bottom: 1px solid #26324799; font-size: 12px; }
.talent-list time { color: #7f8b9d; font-variant-numeric: tabular-nums; align-self: center; }
.talent-name { display: flex; align-items: center; gap: 9px; }
.talent-name img { width: 26px; height: 26px; border-radius: 6px; border: 1px solid #3a4a64; }
.empty-note { padding: 18px; color: var(--muted); font-size: 12px; }

/* ---------- minimap ---------- */
/* The minimap tab uses the whole window width: objectives | map | heroes. */
body { overflow-x: clip; }
#minimap.tab-panel { width: calc(100vw - 48px); margin-left: calc(50% - 50vw + 24px); }
.minimap-layout {
    display: grid; gap: 16px; align-items: start;
    grid-template-columns: 300px minmax(0, 1fr) 320px;
    grid-template-areas: "left stage right";
}
.minimap-left { grid-area: left; position: sticky; top: 12px; }
#eventHero { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; font: inherit; font-size: 12px; }
.side-levels .alive { display: block; margin-top: 4px; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }
.side-levels .alive.down { color: #ff9aa8; }
.minimap-stage { grid-area: stage; }
.minimap-right { grid-area: right; }
.minimap-stage { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.minimap-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.segmented { display: inline-flex; padding: 3px; gap: 3px; border-radius: 11px; background: #0c121b; border: 1px solid var(--border); }
.segmented button {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
    border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 800; cursor: pointer;
}
.segmented button .ui-icon { width: 15px; height: 15px; }
.segmented button.active { background: var(--panel-3); color: var(--text); }
.segmented button.blue.active { background: #4ea7ff26; color: var(--blue); }
.segmented button.red.active { background: #ff647926; color: var(--red); }
.minimap-toggles { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.minimap-toggles label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.minimap-toggles select { padding: 2px 6px; border-radius: 6px; background: #0c121b; color: var(--text); border: 1px solid var(--border); font-size: 13px; }

.minimap-canvas-wrap { position: relative; display: flex; justify-content: center; padding: 10px; background: #070b11; min-width: 0; }
.minimap-canvas-wrap canvas { touch-action: none; }
.minimap-canvas-wrap canvas.is-dragging { cursor: grabbing !important; }
.zoom-controls { position: absolute; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 4px; }
.zoom-controls button {
    width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
    background: rgba(11, 17, 26, 0.85); color: var(--text); font-size: 17px; font-weight: 800; line-height: 1; cursor: pointer;
}
.zoom-controls button:hover { background: rgba(40, 54, 76, 0.95); }
#minimapCanvas { display: block; border-radius: 10px; }

.transport { display: flex; align-items: center; gap: 12px; padding: 14px 16px 6px; }
.play-btn {
    display: grid; place-items: center; width: 42px; height: 42px; flex: none;
    border: 0; border-radius: 50%; background: #f3f6fb; color: #0d1219; cursor: pointer;
}
.play-btn .ui-icon { width: 18px; height: 18px; stroke: none; }
.play-btn .icon-pause, .play-btn.playing .icon-play { display: none; }
.play-btn.playing .icon-pause { display: block; }
.clock { min-width: 44px; font-variant-numeric: tabular-nums; font-weight: 800; }
.clock.muted { color: var(--muted); font-weight: 600; text-align: right; }
.transport select { padding: 7px 8px; border-radius: 8px; background: #0c121b; color: var(--text); border: 1px solid var(--border); }
.transport-hint { padding: 0 16px 12px 70px; font-size: 11px; color: var(--faint); }

.scrubber { position: relative; flex: 1; height: 42px; display: flex; align-items: center; }
.scrubber input[type="range"] { position: relative; z-index: 2; width: 100%; margin: 0; accent-color: #f3f6fb; cursor: pointer; }
.scrub-markers { position: absolute; inset: 0 7px; pointer-events: none; }
.scrub-marker {
    position: absolute; top: 2px; width: 3px; height: 9px; padding: 0; margin-left: -1px;
    border: 0; border-radius: 2px; background: var(--muted); cursor: pointer; pointer-events: auto;
}
.scrub-marker.blue { background: var(--blue); }
.scrub-marker.red { background: var(--red); }
.scrub-marker.structure { top: auto; bottom: 2px; height: 11px; width: 4px; box-shadow: 0 0 0 1px #0007; }
.scrub-marker.camp { top: auto; bottom: 4px; width: 6px; height: 6px; border-radius: 50%; opacity: .75; }
.scrub-tooltip {
    position: absolute; bottom: 100%; transform: translateX(-50%); padding: 3px 7px; border-radius: 6px;
    background: #f3f6fb; color: #0d1219; font-size: 11px; font-weight: 800; pointer-events: none; opacity: 0; transition: opacity .1s;
}
.scrub-tooltip.show { opacity: 1; }

.minimap-side { display: grid; gap: 12px; }
.side-card { padding: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.side-levels { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; text-align: center; }
.side-levels > div:not(.side-levels-label) { display: flex; flex-direction: column; }
.side-levels span { font-size: 10px; letter-spacing: .14em; color: var(--muted); }
.side-levels b { font-size: 30px; }
.side-levels .blue b { color: var(--blue); }
.side-levels .red b { color: var(--red); }
.side-levels-label { font-size: 9px; letter-spacing: .14em; color: var(--faint); }

.roster { display: grid; gap: 4px; }
.roster-row {
    display: grid; grid-template-columns: 32px minmax(0, 1fr) auto auto; align-items: center; gap: 9px;
    padding: 5px 8px 5px 5px; border: 1px solid transparent; border-left: 3px solid var(--blue); border-radius: 9px;
    background: #0e151f; color: var(--text); text-align: left; cursor: pointer;
}
.roster-row.red { border-left-color: var(--red); }
.roster-row:hover { background: var(--panel-2); }
.roster-row.focused { border-color: #f3f6fb55; background: var(--panel-2); }
.roster-row.blue + .roster-row.red { margin-top: 8px; }
.roster-row.dead .roster-portrait { filter: grayscale(1) brightness(.5); }
.roster-portrait { position: relative; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; background: #202b3c; }
.roster-portrait img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; object-position: center 23%; }
.roster-portrait i { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 900; }
.roster-name { display: flex; flex-direction: column; min-width: 0; }
.roster-name strong { font-size: 13px; }
.roster-name small { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-status { font-size: 11px; font-weight: 800; white-space: nowrap; }
.roster-status.is-dead { color: #ff9aa8; }
.roster-status.is-seen { color: var(--gold); }
.roster-status.is-special { color: #ffcf66; font-style: italic; }
.roster-status.is-hidden { color: var(--faint); }

.recent-events { display: grid; gap: 2px; }
.recent-row {
    display: grid; grid-template-columns: 38px 12px 1fr; align-items: center; gap: 4px;
    padding: 6px 4px; border: 0; border-radius: 6px; background: transparent; color: #cfd8e6; font-size: 12px; text-align: left; cursor: pointer;
}
.recent-row:hover { background: var(--panel-2); }
.recent-row time { color: var(--faint); font-variant-numeric: tabular-nums; }
.recent-empty { color: var(--faint); font-size: 12px; }
.side-note { margin: 0; padding: 0 4px; color: var(--faint); font-size: 11px; line-height: 1.5; }

h4 small { font-size: 10px; letter-spacing: 0; text-transform: none; color: var(--faint); font-weight: 600; }
h5 { margin: 14px 0 8px; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* Ability icon with a clock-wipe while on cooldown (minimap.js sets --p and the seconds). */
.ability-icon {
    --size: 30px;
    position: relative; display: inline-grid; place-items: center; flex: none;
    width: var(--size); height: var(--size); border-radius: 7px; overflow: hidden;
    background: #202b3c; border: 1px solid #3a4a64;
}
.ability-icon.none { visibility: hidden; }
.ability-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ability-icon .hotkey {
    position: absolute; left: 2px; bottom: 1px; z-index: 3;
    font-style: normal; font-size: 9px; font-weight: 900; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000;
}
.ability-icon .wipe {
    position: absolute; inset: 0; z-index: 1; opacity: 0;
    background: conic-gradient(rgba(5, 8, 12, .78) var(--p, 0%), transparent 0);
}
.ability-icon.cooling .wipe { opacity: 1; }
.ability-icon.locked { filter: grayscale(1) brightness(.45); }
.ability-icon.unknown { filter: saturate(.5) brightness(.8); }
h6 { margin: 10px 0 6px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
h6 small { text-transform: none; letter-spacing: 0; font-weight: 600; }
.ability-row.is-locked { opacity: .5; }
.ability-row.is-form .ability-text strong { color: #cfd8e6; }
.ability-state.unknown { color: var(--faint); }
.ability-icon .cd { position: relative; z-index: 2; font-size: 11px; font-weight: 900; color: #fff; text-shadow: 0 0 4px #000; }
.ability-icon:not(.cooling):not(.locked) { box-shadow: 0 0 0 1px #ffcf6655; }

/* Selected player */
.player-card[hidden] { display: none; }
.player-head { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.player-head > div { display: flex; flex-direction: column; min-width: 0; }
.player-head strong { font-size: 16px; }
.player-head small { color: var(--muted); font-size: 12px; }
.player-head.blue strong { color: var(--blue); }
.player-head.red strong { color: var(--red); }
.player-head .close { border: 0; background: transparent; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
.roster-portrait.big { width: 44px; height: 44px; }
.player-now { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.player-now > div { display: flex; flex-direction: column; align-items: center; padding: 7px 4px; border-radius: 8px; background: #0e151f; }
.player-now span { font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.player-now b { font-size: 16px; }
.ability-list { display: grid; gap: 6px; }
.ability-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; }
.ability-text { display: flex; flex-direction: column; min-width: 0; }
.ability-text strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ability-text small { font-size: 11px; color: var(--faint); }
.ability-state { font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ability-state.ready { color: var(--green); }
.ability-state.cooldown { color: var(--gold); }
.ability-state.locked { color: var(--faint); }
.talent-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.talent-chips span { padding: 3px 8px; border-radius: 999px; background: #1a2433; border: 1px solid var(--border); font-size: 11px; }
.talent-chips .muted { color: var(--faint); background: transparent; border: 0; padding: 0; }
.player-card details { margin-top: 12px; }
.player-card summary, .camps summary { cursor: pointer; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.player-final { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; margin-top: 8px; font-size: 12px; }
.player-final div { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--border-soft); }
.player-final span { color: var(--muted); }

/* Map objective panel */
.objectives { display: grid; gap: 2px; }
.objective-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 5px 2px; border-bottom: 1px solid var(--border-soft); font-size: 12px; }
.objective-row:last-child { border-bottom: 0; }
.objective-label { color: var(--muted); }
.objective-value { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.objective-value.blue, .objective-value b.blue, .objectives b.blue { color: var(--blue); }
.objective-value.red, .objectives b.red { color: var(--red); }
.objective-row.idle .objective-value { color: var(--faint); font-weight: 600; }
.camps { margin-top: 10px; }
.camps .objectives { margin-top: 6px; }
.scrub-marker.objective { top: auto; bottom: 3px; width: 7px; height: 7px; border-radius: 2px; transform: rotate(45deg); }

/* ---------- responsive ---------- */
@media (max-width: 1500px) {
    .minimap-layout { grid-template-columns: minmax(0, 1fr) 300px; grid-template-areas: "stage right" "left right"; }
    .minimap-left { position: static; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 1180px) {
    #minimap.tab-panel { width: auto; margin-left: 0; }
    .minimap-layout { grid-template-columns: 1fr; grid-template-areas: "stage" "right" "left"; }
    .minimap-side { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 960px) {
    .team-columns, .talent-columns { grid-template-columns: 1fr; }
    .match-hero { align-items: flex-start; flex-direction: column; }
    .winner-box { text-align: left; min-width: 0; }
    .hero-main h2 { font-size: 38px; }
    .composition-strip { flex-wrap: wrap; }
}
@media (max-width: 600px) {
    .shell { width: min(100% - 24px, 1540px); padding-top: 20px; }
    .match-hero { padding: 22px; }
    .composition-strip { display: none; }
    .team-stats { grid-template-columns: 1fr; }
    .team-players-head, .team-player { grid-template-columns: minmax(0, 1fr) 80px 54px; }
    .team-players-head span:nth-child(n+4), .team-player > span:nth-child(n+4) { display: none; }
    .timeline-row { grid-template-columns: 48px 12px 60px 1fr; padding-inline: 10px; }
    .transport-hint { display: none; }
}

/* ---------- sign-in ---------- */
.landing.login { display: flex; justify-content: center; }
.login-card { display: flex; flex-direction: column; gap: 12px; width: min(360px, 100%); }
.login-card input[type=password] { padding: 10px 12px; border: 1px solid #2c3a50; border-radius: 8px; background: #0e1520; color: inherit; font: inherit; }


/* =========================================================================
   Theme: Nocturne — flat panels, violet accent for active / primary controls
   ========================================================================= */
.eyebrow { color: var(--accent); }
.pill { background: transparent; border-color: var(--border); color: var(--muted); }
.ghost-btn { background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); font-weight: 600; }
.ghost-btn:hover { border-color: var(--accent); }
.primary-btn { background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); font-weight: 700; }

.match-hero { background: var(--panel); border-radius: var(--radius); }
.winner-box { background: var(--panel-2); border-color: var(--border); border-radius: var(--radius); }

.tabs { gap: 18px; }
.tab { font-weight: 600; }
.tab.active { background: transparent; color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }

.team-panel { background: var(--panel); border-top-width: 2px; }
.team-level { background: var(--panel-2); border-radius: var(--radius); }
th { background: var(--panel-2); color: var(--muted); }
#playerPick, #eventHero, .minimap-toggles select, .transport select { background: var(--panel-2); border-color: var(--border); border-radius: var(--radius); }
.minimap-toggles input, .event-filters input { accent-color: var(--accent); }
.segmented { background: var(--bg); border-radius: var(--radius); }
.segmented button { font-weight: 600; border-radius: calc(var(--radius) - 2px); }
.segmented button.active { background: var(--accent); color: var(--accent-ink); }
.segmented button.blue.active { background: #4ea7ff2b; color: #8cc6ff; }
.segmented button.red.active { background: #ff647929; color: #ff9aa6; }
.minimap-canvas-wrap { background: #0a0910; }
.play-btn { background: var(--accent); color: var(--accent-ink); }
.zoom-controls button { background: var(--panel-2); border-radius: var(--radius); }
.upload-card { background: var(--panel); border-radius: var(--radius); }
.drop-zone { background: transparent; border-radius: var(--radius); }
.drop-icon { background: var(--panel-2); }

/* Role colours: the portrait border shows the hero's role (teams are shown by text, dots and the minimap). */
.portrait { border: 2px solid var(--role, var(--border)); box-shadow: none !important; background: var(--panel-2); }
.role-tank { --role: var(--role-tank); }
.role-damage { --role: var(--role-damage); }
.role-support { --role: var(--role-support); }
.role-bruiser { --role: var(--role-bruiser); }
.role-utility { --role: var(--role-utility); }
.roster-portrait[class*="role-"] { box-shadow: 0 0 0 2px var(--role); }

/* Match header: each hero as portrait, hero name, player. */
.composition-strip { align-items: flex-start; }
.comp-team { gap: 10px; }
.comp-hero { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 72px; text-align: center; }
.comp-hero strong { font-size: 12px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comp-hero span { font-size: 11px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.versus { align-self: center; margin-top: -26px; }

/* =========================================================================
   Minimap tab layout
     objective · settings · camps
     blue team · map      · red team
   The two side columns have the same width, so the team blocks are symmetric.
   ========================================================================= */
.minimap-layout {
    grid-template-columns: 330px minmax(0, 1fr) 330px;
    grid-template-areas: "obj tools camps" "blue stage red" "note note note";
    align-items: stretch;
}
.mm-objective { grid-area: obj; }
.mm-tools { grid-area: tools; }
.mm-camps { grid-area: camps; }
.mm-team.blue { grid-area: blue; }
.mm-team.red { grid-area: red; }
.minimap-stage { grid-area: stage; align-self: start; }
.mm-note { grid-area: note; }
.mm-team { align-content: start; }
.mm-tools {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    align-items: center; align-content: center;
}
.mm-full-btn {
    margin-left: auto; width: 32px; height: 32px; flex: none; display: grid; place-items: center; cursor: pointer;
    background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
}
.mm-full-btn:hover { border-color: var(--accent); color: var(--accent); }
.mm-full-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mm-full-btn .when-full, body.mm-full .mm-full-btn .when-normal { display: none; }
body.mm-full .mm-full-btn .when-full { display: block; }
.mm-team.red .roster-row { border-left: 1px solid transparent; border-right: 3px solid var(--red); }

/* Objective rows: the value wraps under its own width instead of running over the label. */
.objective-row { grid-template-columns: auto minmax(0, 1fr); gap: 12px; }
.objective-label { white-space: nowrap; }
.objective-value { overflow-wrap: anywhere; }

/* Team bar above the map: portraits and alive count at each end, both team levels in the middle. */
.team-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.team-bar-side { display: flex; align-items: center; gap: 14px; min-width: 0; }
.team-bar-side.red { justify-content: flex-end; }
.team-bar-levels { display: flex; gap: 22px; }
.team-bar-level { display: flex; flex-direction: column; align-items: center; min-width: 54px; }
.team-bar-level b { font-size: 26px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.team-bar-level span { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.team-bar-level.blue b { color: var(--blue); }
.team-bar-level.red b { color: var(--red); }
.team-bar-alive { display: flex; flex-direction: column; align-items: center; min-width: 54px; }
.team-bar-alive b { font-size: 20px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.team-bar-alive span { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.team-bar-alive.down b { color: #ff9aa8; }
.team-bar-heroes { display: flex; gap: 6px; }
.bar-hero {
    position: relative; width: 38px; height: 38px; padding: 0; border-radius: 50%; overflow: hidden; cursor: pointer;
    border: 0; background: var(--panel-2); box-shadow: 0 0 0 2px var(--role, var(--border));
}
.bar-hero img { width: 100%; height: 100%; object-fit: cover; object-position: center 23%; display: block; }
.bar-hero i { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 14px; font-weight: 800; color: #fff; text-shadow: 0 0 4px #000; }
.bar-hero.dead img { filter: grayscale(1) brightness(.35); }
.bar-hero.dead { box-shadow: 0 0 0 2px #4a4560; }

.mm-recent { padding: 4px 16px 14px; border-top: 1px solid var(--border); }
.mm-recent h4 { margin-top: 12px; }
.mm-recent .recent-events { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }

/* Full-screen mode: the page header, match header and tabs go away. */
body.mm-full .topbar, body.mm-full .match-hero, body.mm-full .tabs { display: none; }
body.mm-full .shell { padding-top: 12px; }

@media (max-width: 1500px) {
    .minimap-layout { grid-template-columns: 280px minmax(0, 1fr) 280px; grid-template-areas: "obj tools camps" "blue stage red" "note note note"; }
    .bar-hero { width: 30px; height: 30px; }
    .team-bar-side { gap: 10px; }
}
@media (max-width: 1180px) {
    .minimap-layout { grid-template-columns: 1fr 1fr; grid-template-areas: "tools tools" "stage stage" "obj camps" "blue red" "note note"; }
    .minimap-left { position: static; }
}
@media (max-width: 700px) {
    .minimap-layout { grid-template-columns: 1fr; grid-template-areas: "tools" "stage" "obj" "camps" "blue" "red" "note"; }
    .team-bar { grid-template-columns: 1fr; }
    .team-bar-side.red { justify-content: flex-start; flex-direction: row-reverse; }
    .mm-recent .recent-events { grid-template-columns: 1fr; }
}

/* Compact top row: the settings on one line, smaller side boxes, so the map and its timeline fit on screen. */
.minimap-layout { row-gap: 12px; }
.mm-tools { flex-wrap: nowrap; padding: 8px 10px; gap: 12px; }
.mm-tools .segmented button { padding: 5px 10px; font-size: 12px; }
.mm-tools .minimap-toggles { flex: 1 1 auto; gap: 4px 12px; font-size: 12px; }
.mm-tools .minimap-toggles select { font-size: 12px; padding: 1px 4px; }
.mm-objective, .mm-camps { padding: 10px 12px; }
.mm-objective h4, .mm-camps h4 { margin-bottom: 6px; }
.mm-objective .objective-row, .mm-camps .objective-row { padding: 3px 2px; }
.minimap-canvas-wrap { padding: 6px; }
.transport { padding-top: 8px; }
@media (max-width: 1500px) { .mm-tools { flex-wrap: wrap; } }
.mm-tools .segmented { flex: none; }
.segmented button { white-space: nowrap; }
@media (max-width: 1500px) {
    .mm-tools .segmented { order: 1; }
    .mm-full-btn { order: 2; }
    .mm-tools .minimap-toggles { order: 3; flex-basis: 100%; }
}

/* Bigger team bar on top of the map: portraits, alive counts, levels. */
.team-bar { padding: 10px 16px; }
.team-bar .bar-hero { width: 48px; height: 48px; }
.team-bar .bar-hero i { font-size: 17px; }
.team-bar-heroes { gap: 8px; }
.team-bar-level b { font-size: 34px; }
.team-bar-level span { font-size: 10px; }
.team-bar-levels { gap: 30px; }
.team-bar-alive b { font-size: 28px; }
.team-bar-alive span { font-size: 10px; }
@media (max-width: 1500px) {
    .team-bar .bar-hero { width: 38px; height: 38px; }
    .team-bar-level b { font-size: 28px; }
    .team-bar-alive b { font-size: 22px; }
}

/* Narrow settings box; the team bar (its own grid row) ends level with the objective and camps boxes
   and is glued to the top of the map panel. */
.minimap-layout { grid-template-areas: "obj tools camps" "obj bar camps" "blue stage red" "note note note"; }
.mm-tools { align-self: start; }
.mm-bar {
    grid-area: bar; align-self: end;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
}
.minimap-stage { border-top: 0; border-radius: 0 0 var(--radius) var(--radius); margin-top: -12px; }
@media (max-width: 1500px) {
    .minimap-layout { grid-template-areas: "obj tools camps" "obj bar camps" "blue stage red" "note note note"; }
}
@media (max-width: 1180px) {
    .minimap-layout { grid-template-areas: "tools tools" "bar bar" "stage stage" "obj camps" "blue red" "note note"; }
}
@media (max-width: 700px) {
    .minimap-layout { grid-template-areas: "tools" "bar" "stage" "obj" "camps" "blue" "red" "note"; }
}

/* Team list headings stay on one line: the "(approximate*)" note shrinks to "*" on narrower screens. */
.mm-team h4 { white-space: nowrap; }
.mm-team h4 .narrow-only { display: none; }
@media (max-width: 1500px) {
    .mm-team h4 .wide-only { display: none; }
    .mm-team h4 .narrow-only { display: inline; }
}

/* Extra height from a tall objective/camps box goes to the team bar row (it stretches, content centred),
   never to the settings row, so the settings and the team bar stay together. */
.minimap-layout { grid-template-rows: auto 1fr auto auto; }
.mm-bar { align-self: stretch; }
.mm-tools { gap: 10px; }
.mm-tools .minimap-toggles { gap: 4px 10px; }
.mm-tools .minimap-toggles { gap: 4px 8px; }
.mm-tools .minimap-toggles label { gap: 5px; }

/* Team takedowns, between the alive count and the levels. */
.team-bar-td { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.team-bar-td b { font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.team-bar-td span { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 1500px) { .team-bar-td b { font-size: 22px; } .team-bar-td { min-width: 54px; } }
/* Takedowns sit centred in the space between the alive count and the levels. */
.team-bar-side .team-bar-td { margin: 0 auto; }
@media (max-width: 1500px) {
    /* Narrower screens: smaller portraits, gaps and captions so takedowns fit beside the levels. */
    .team-bar.mm-bar { gap: 8px; padding: 8px 10px; }
    .team-bar.mm-bar .bar-hero { width: 32px; height: 32px; }
    .team-bar.mm-bar .team-bar-heroes { gap: 4px; }
    .team-bar.mm-bar .team-bar-side { gap: 8px; }
    .team-bar.mm-bar .team-bar-levels { gap: 12px; }
    .team-bar.mm-bar .team-bar-level, .team-bar.mm-bar .team-bar-alive, .team-bar.mm-bar .team-bar-td { min-width: 0; }
    .team-bar.mm-bar .team-bar-level span, .team-bar.mm-bar .team-bar-alive span, .team-bar.mm-bar .team-bar-td span { font-size: 8px; letter-spacing: .04em; }
}
.team-bar b { white-space: nowrap; }
@media (max-width: 1350px) {
    .team-bar.mm-bar .bar-hero { width: 26px; height: 26px; }
    .team-bar.mm-bar .bar-hero i { font-size: 12px; }
    .team-bar.mm-bar .team-bar-heroes { gap: 3px; }
    .team-bar.mm-bar .team-bar-alive b, .team-bar.mm-bar .team-bar-td b { font-size: 18px; }
    .team-bar.mm-bar .team-bar-level b { font-size: 22px; }
}
@media (min-width: 1181px) and (max-width: 1260px) {
    .team-bar.mm-bar .bar-hero { width: 22px; height: 22px; }
    .team-bar.mm-bar .team-bar-heroes { gap: 2px; }
    .team-bar.mm-bar .team-bar-side { gap: 6px; }
    .team-bar.mm-bar .team-bar-levels { gap: 8px; }
}

/* =========================================================================
   Replay library: start page cards, then the library (filters, tiles, tables, games list)
   ========================================================================= */
.landing-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; max-width: 1100px; }
.landing-actions .upload-card { width: auto; display: flex; flex-direction: column; }
.landing-actions .drop-zone { flex: 1; }
.drop-icon .ui-icon { width: 26px; height: 26px; }
.folder-btn { display: block; text-align: center; margin-top: 34px; }
@media (max-width: 800px) { .landing-actions { grid-template-columns: 1fr; } }

.library { display: grid; gap: 16px; padding-bottom: 40px; }
.lib-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.lib-head h2 { margin: 4px 0 0; font-size: 26px; }
.lib-head h2 small { font-size: 15px; color: var(--muted); font-weight: 500; }
.lib-head-actions { display: flex; gap: 8px; }
.lib-head-actions .ghost-btn { cursor: pointer; }

.lib-progress { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.lib-progress-bar { height: 8px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.lib-progress-bar span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.lib-progress-text { margin-top: 8px; font-size: 13px; color: var(--muted); }

.lib-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.lib-filters label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.lib-filters select { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font: inherit; max-width: 240px; }
.lib-clear { background: transparent; color: var(--accent); border: 0; cursor: pointer; font: inherit; font-size: 13px; }
.lib-viewing { margin-left: auto; font-size: 13px; color: var(--muted); }
.lib-viewing b { color: var(--text); }

.lib-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.lib-tile { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.lib-tile span { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.lib-tile b { font-size: 24px; font-variant-numeric: tabular-nums; }
.lib-tile small { color: var(--muted); font-size: 12px; }

.lib-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.lib-side { display: grid; gap: 16px; }
.lib-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.lib-card h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.lib-card h3 small { text-transform: none; letter-spacing: 0; color: var(--faint); font-weight: 500; }
.lib-hint { margin: -4px 0 8px; font-size: 12px; color: var(--faint); }

.lib-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lib-table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.lib-table th[data-sort] { cursor: pointer; user-select: none; }
.lib-table th[data-sort]:hover { color: var(--text); }
.lib-table th.desc::after { content: " ▾"; } .lib-table th.asc::after { content: " ▴"; }
.lib-table td { padding: 6px 8px; border-bottom: 1px solid #2c274266; vertical-align: middle; }
.lib-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.lib-table td small { color: var(--faint); margin-left: 4px; }
.lib-table tbody tr { cursor: pointer; }
.lib-table tbody tr:hover { background: var(--panel-2); }
.lib-name { font-weight: 600; }
.lib-tag { margin-left: 2px; }
.lib-face { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; object-position: center 23%; border: 2px solid var(--role, var(--border)); background: var(--panel-2); vertical-align: middle; }
.lib-hero { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.lib-hero-chip { display: inline-flex; align-items: center; gap: 2px; margin-right: 6px; }
.lib-hero-chip small { margin-left: 0 !important; font-size: 11px; }
.lib-more { margin-top: 8px; background: transparent; color: var(--accent); border: 0; cursor: pointer; font: inherit; font-size: 13px; padding: 4px 0; }

.lib-games-table td { white-space: nowrap; }
.lib-teams { display: flex; align-items: center; gap: 8px; }
.lib-team { display: flex; gap: 3px; padding: 2px 4px; border-radius: 99px; border: 1px solid transparent; }
.lib-team.won { border-color: #4bd6a055; background: #4bd6a00f; }
.lib-pick.me .lib-face { box-shadow: 0 0 0 2px var(--text); }
.lib-vs { font-size: 11px; color: var(--faint); }
.lib-result { font-weight: 700; }
.lib-result.win { color: var(--green); }
.lib-result.loss { color: #ff8a9a; }
.lib-result.blue { color: var(--blue); }
.lib-result.red { color: var(--red); }
.lib-open { padding: 4px 10px; font-size: 12px; }
.lib-failed summary { cursor: pointer; color: var(--muted); }
.lib-failed ul { margin: 8px 0 0; padding-left: 18px; font-size: 12px; color: var(--muted); }

@media (max-width: 1300px) { .lib-grid { grid-template-columns: 1fr; } .lib-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .lib-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .lib-card { overflow-x: auto; } }
.lib-games { overflow-x: auto; }
.landing[hidden], .library[hidden] { display: none; }
/* Library tables: not the scoreboard's wide table defaults. */
.lib-table { min-width: 0; }
.lib-table th { background: transparent; }
.lib-table td { text-align: left; white-space: nowrap; }
.lib-table td.num, .lib-table th.num { text-align: right; }

/* Match header: each team's heroes under a "Blue team" / "Red team" label and a line in the team colour. */
.comp-side { display: flex; flex-direction: column; gap: 8px; }
.comp-label { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; padding-bottom: 6px; border-bottom: 2px solid currentColor; }
.comp-side.blue .comp-label { color: var(--blue); }
.comp-side.red .comp-label { color: var(--red); }
.composition-strip .versus { margin-top: 0; align-self: center; }

/* Library: combine players panel. */
.lib-combine-btn { padding: 6px 12px; font-size: 13px; }
.lib-combine { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; }
.lib-combine-title { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-right: 6px; }
.lib-combine-pick { display: inline-flex; align-items: center; gap: 4px; }
.lib-combine select { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 13px; max-width: 260px; }
.lib-combine-x { background: transparent; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; padding: 0 4px; }
.lib-combine-x:hover { color: var(--red); }
.lib-combine-plus { color: var(--faint); font-weight: 700; }
.lib-combine-actions { display: inline-flex; gap: 8px; margin-left: auto; }
.lib-combine-actions .primary-btn { width: auto; padding: 7px 16px; }
.lib-combine-actions .ghost-btn { padding: 7px 14px; }

/* Library: grouped columns (With / Against), each a short games + win % pair inside a tinted band. */
.lib-table th.grp-head { text-align: center; color: var(--text); padding-bottom: 2px; border-bottom: 0; }
.lib-table .grp { background: #ffffff05; width: 1%; padding-left: 12px; padding-right: 12px; }
.lib-table .grp-start { border-left: 1px solid var(--border); }
.lib-table th.grp { font-size: 10px; }
.lib-none { color: var(--faint); }
.lib-good { color: var(--green); }
.lib-bad { color: #ff8a9a; }
/* Team bar: portraits shrink to fit when a side has more of them (The Lost Vikings: three portraits for one player). */
.team-bar .team-bar-side { min-width: 0; }
.team-bar .team-bar-heroes { min-width: 0; flex: 0 1 auto; }
.team-bar .bar-hero { flex: 0 1 48px; min-width: 22px; height: auto !important; aspect-ratio: 1; }
@media (max-width: 1500px) { .team-bar .bar-hero { flex-basis: 32px; } }
@media (max-width: 1350px) { .team-bar .bar-hero { flex-basis: 26px; } }
.team-bar-alive b { white-space: nowrap; }

/* Library: player search next to the players heading. */
.lib-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.lib-card-head h3 { margin: 0; }
.lib-search { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px; width: 220px; }
.lib-search:focus { outline: none; border-color: var(--accent); }
