:root {
  --bg: #0d0d10;
  --card: rgba(22, 22, 26, 0.88);
  --card-2: rgba(28, 28, 33, 0.85);
  --border: #2a2a31;
  --border-soft: #232329;
  --text: #e8eaf0;
  --text-dim: #8b909c;
  --text-faint: #6a6f7a;
  --accent: #4a9eff;
  --gold: #e0a92b;
  --good: #4ade80;
  --bad: #ef4444;
  --warn: #fb923c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  font-size: 15px;
  position: relative;
  min-height: 100vh;
}
/* Fixed, heavily-dimmed background artwork (Siege Arena style): the image sits behind
   everything, doesn't scroll, and is faded far enough back that scoreboard text keeps
   full contrast. A gradient scrim on top darkens it further toward the edges. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--r6-bg, url('img/background.jpg'));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.18;
  filter: grayscale(100%) contrast(1.1);
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(13,13,16,0.22) 0%, rgba(13,13,16,0.72) 60%, rgba(13,13,16,0.92) 100%);
  pointer-events: none;
  z-index: 0;
}
.app { position: relative; z-index: 1; }
/* ---------- Layout: collapsible sidebar + centred main column ---------- */
.layout { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* Sidebar is transparent so the background artwork shows through, and collapses to zero
   width (closed by default) so the main column can centre in the full viewport. */
/* Only the OUTER width animates. Animating padding as well changed the content box on
   every frame, which made the nav labels re-wrap continuously and look like the text was
   resizing. The inner wrapper below holds a fixed width so its layout never reflows —
   the sidebar simply clips it as it opens. */
.sidebar {
  width: 0; flex-shrink: 0; opacity: 0;
  background: transparent; border-right: 1px solid transparent;
  position: sticky; top: 0; height: 100vh;
  overflow-x: hidden; overflow-y: auto;
  transition: width .22s ease, opacity .18s ease;
  padding: 0;
}
.sidebar-inner {
  width: 250px; flex-shrink: 0; box-sizing: border-box;
  /* Top padding clears the fixed toggle button (14px top + 34px tall = 48px). */
  padding: 60px 16px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
/* Fallback for an index.html that predates the .sidebar-inner wrapper: apply the same
   fixed box directly to the nav so the sidebar still renders correctly on its own.
   Only matches when .nav is a DIRECT child, i.e. when the wrapper is absent. */
.sidebar > .nav {
  width: 250px; flex-shrink: 0; box-sizing: border-box;
  padding: 60px 16px 24px;
}
.layout.sidebar-open .sidebar {
  width: 250px; opacity: 1;
  border-right: 1px solid var(--border-soft);
  backdrop-filter: blur(2px);
}
/* The main column always centres its content in whatever space is left over. */
.main { flex: 1; min-width: 0; padding: 24px 62px 60px; }
.main-inner { max-width: 1180px; margin: 0 auto; }

/* Hamburger toggle, pinned top-left above everything. */
/* Defensive: nothing in the sidebar may render at its natural size. Without this, a stray
   <img> (e.g. an old index.html still containing the removed brand block) renders at full
   resolution and fills the entire sidebar. */
.sidebar img { max-width: 100%; height: auto; }
.sidebar .brand { display: none; }

.sidebar-toggle {
  position: fixed; top: 14px; left: 14px; z-index: 30;
  width: 38px; height: 34px; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: rgba(28,28,33,0.82); border: 1px solid var(--border); border-radius: 7px;
  cursor: pointer; backdrop-filter: blur(3px);
}
.sidebar-toggle:hover { background: rgba(40,40,48,0.9); }
.sidebar-toggle span {
  display: block; width: 16px; height: 2px; background: var(--text-dim); border-radius: 1px;
  transition: transform .2s ease, opacity .2s ease;
}
.sidebar-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.sidebar-toggle.open span:nth-child(2) { opacity: 0; }
.sidebar-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.btn-new {
  width: 100%; background: rgba(28,28,33,0.8); color: var(--text); border: 1px solid var(--border);
  padding: 11px 14px; font-size: 0.75rem; letter-spacing: 0.07em; white-space: nowrap;
}
.btn-new:hover { background: rgba(40,40,48,0.9); }
.sidebar-heading {
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-faint); padding: 4px 2px 0; white-space: nowrap;
}
.saved-list { display: flex; flex-direction: column; gap: 6px; }
.saved-empty { color: var(--text-faint); font-size: 0.78rem; padding: 4px 2px; line-height: 1.45; }
.saved-item {
  background: rgba(28,28,33,0.72); border: 1px solid var(--border-soft); border-radius: 7px;
  padding: 9px 10px; cursor: pointer; position: relative; transition: border-color .12s, background .12s;
}
.saved-item:hover { border-color: #3a3a45; background: rgba(38,38,46,0.85); }
.saved-item.active { border-color: var(--accent); }
.saved-map { font-size: 0.76rem; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text); padding-right: 42px; }
.saved-score { font-size: 0.72rem; font-weight: 700; margin-top: 3px; }
.saved-date { font-size: 0.66rem; color: var(--text-faint); margin-top: 2px; }
.saved-actions { position: absolute; top: 5px; right: 5px; display: flex; gap: 1px; }
.saved-act {
  background: none; border: none; color: var(--text-faint);
  font-size: 0.78rem; padding: 2px 4px; cursor: pointer; line-height: 1; letter-spacing: 0;
}
.saved-act:hover { color: var(--text); }
.saved-del:hover { color: var(--bad); }
.saved-rename {
  width: 100%; box-sizing: border-box; background: #101014; color: var(--text);
  border: 1px solid var(--accent); border-radius: 4px; padding: 3px 6px;
  font-size: 0.76rem; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase;
  font-family: inherit; outline: none;
}
.viewing-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(74,158,255,0.07); border: 1px solid rgba(74,158,255,0.35);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 0.83rem; color: var(--text-dim);
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px 22px;
  margin-bottom: 20px;
}
.card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-title {
  margin: 0; font-size: 0.9rem; font-weight: 800; letter-spacing: 0.07em;
  text-transform: uppercase; color: #c8ccd4;
}
.card-desc { color: var(--text-dim); font-size: 0.85rem; margin: 0 0 16px; }
.card-desc b { color: var(--text); font-weight: 700; }

/* ---------- Drop zone ---------- */
.drop-zone {
  border: 2px dashed #3a3a42;
  border-radius: 10px;
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.015);
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone.dragover { border-color: #6f757f; background: rgba(255, 255, 255, 0.05); }
.drop-title { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.drop-sub { font-size: 0.82rem; color: var(--text-dim); margin-top: 4px; }

/* ---------- Selected-files summary ---------- */
.drop-summary {
  margin-top: 10px; font-size: 0.92rem; font-weight: 800; color: #dfe3ea;
  letter-spacing: 0.01em; min-height: 1.2em;
}
.drop-summary-warn { color: var(--warn); }
.empty-hint { color: var(--text-faint); font-size: 0.85rem; margin: 10px 0 0; }
.file-list { margin-top: 12px; }
.file-count-note { color: var(--warn); font-size: 0.82rem; margin: 0; }

/* ---------- Buttons ---------- */
.button-row { display: flex; gap: 10px; margin-top: 16px; }
button {
  border: none; border-radius: 6px; padding: 10px 22px; font-size: 0.82rem;
  cursor: pointer; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
}
.btn-primary { background: #d5d9e0; color: #15151a; }
.btn-primary:disabled { background: var(--card-2); color: var(--text-faint); cursor: not-allowed; }
.btn-secondary { background: var(--card-2); color: var(--text-dim); border: 1px solid var(--border); }
button:not(:disabled):hover { filter: brightness(1.08); }

/* ---------- Progress ---------- */
.progress-wrap { margin-top: 16px; }
.progress-track { height: 6px; background: var(--card-2); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: #9aa0ab; transition: width 0.2s; width: 0%; }
.progress-label { color: var(--text-dim); font-size: 0.82rem; margin: 6px 0 0; }

/* ---------- Warnings ---------- */
.warning-box {
  background: rgba(251, 146, 60, 0.07); border: 1px solid rgba(251, 146, 60, 0.4);
  border-radius: 10px; padding: 14px 18px; margin-bottom: 20px; font-size: 0.85rem;
}
.warning-box strong { color: var(--warn); }
.warning-box ul { margin: 8px 0 0; padding-left: 20px; }
.warning-box p { margin: 6px 0 0; }

/* ---------- Scoreboard panel ---------- */
.sb-panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 20px 10px; margin-bottom: 20px;
}
.sb-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding-bottom: 14px;
}
.sb-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 1.25rem; font-weight: 800; }
.sb-map { color: var(--text); text-transform: uppercase; letter-spacing: 0.04em; }
/* Vertical rule between the map name and the scoreline. */
.sb-sep {
  display: inline-block; width: 2px; height: 1.15em; margin: 0 6px; border-radius: 1px;
  background: #4a4a55; align-self: center;
}
.sb-team-name { color: var(--text); text-transform: uppercase; letter-spacing: 0.02em; }
.sb-score { font-variant-numeric: tabular-nums; }
/* "Your team" (the recording player's team) is white; the opposing team is red. */
.side-your { color: var(--text); }
.side-enemy { color: var(--bad); }
.sb-dash { color: var(--text-faint); font-weight: 500; margin: 0 1px; }
.sb-meta { color: var(--text-faint); font-size: 0.78rem; white-space: nowrap; }

/* ---------- Scoreboard table ---------- */
.team-table-wrap { overflow-x: auto; }
table.scoreboard { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 0.86rem; }
table.scoreboard th {
  text-align: right; padding: 9px 8px; color: var(--text-faint); font-weight: 700;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
table.scoreboard th:first-child, table.scoreboard td:first-child { text-align: left; }
table.scoreboard td { text-align: right; padding: 10px 8px; border-bottom: 1px solid #1a1a1e; color: var(--text); font-variant-numeric: tabular-nums; }
table.scoreboard .col-player { width: 19%; }
table.scoreboard .col-num { width: 6%; }
/* ENTRY carries "5-1 (+4)", so it needs more room than a plain number. */
table.scoreboard .col-entry { width: 9%; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
th.sorted { color: var(--text); }
.strong-cell { font-weight: 800; }

.team-header-row td { border-bottom: 1px solid var(--border-soft); padding: 15px 8px 7px; }
.team-header-name { font-size: 0.88rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.team-header-score { font-size: 0.88rem; font-weight: 800; margin-left: 9px; }

.win-badge {
  display: inline-block; margin-left: 9px; padding: 1px 7px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.1); color: #c8ccd4;
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.08em; vertical-align: 1px;
}

.player-row { cursor: pointer; }
.player-row:hover td { background: rgba(255,255,255,0.025); }
.player-name { font-weight: 700; }

.rating-detail.hidden { display: none; }
.rating-breakdown { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 6px; font-size: 0.78rem; color: var(--text-dim); }
.rating-breakdown b { color: var(--text); font-weight: 600; }


/* ---------- Export ---------- */
.sb-toolbar { display: flex; justify-content: flex-end; padding: 0 0 10px; }
.btn-export {
  background: var(--card-2); color: var(--text-dim); border: 1px solid var(--border);
  padding: 7px 14px; font-size: 0.7rem;
}
.btn-export:hover { color: var(--text); }
.combine-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 0.83rem; color: var(--text-dim); }
.combine-row input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.combine-row label { cursor: pointer; }

/* ================= Brand / nav ================= */
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-btn {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  white-space: nowrap;
  background: none; border: 1px solid transparent; color: var(--text-dim);
  padding: 9px 10px; border-radius: 7px; font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.02em; text-transform: none;
}
.nav-btn:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-btn.active { background: rgba(74,158,255,0.10); border-color: rgba(74,158,255,0.35); color: var(--text); }
.nav-ico { opacity: 0.8; width: 14px; display: inline-block; text-align: center; }

.sidebar-section { display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; }
.mini-btn {
  background: none; border: none; color: var(--text-faint); font-size: 0.66rem;
  padding: 2px 4px; cursor: pointer; letter-spacing: 0.04em; text-transform: none; font-weight: 700;
}
.mini-btn:hover { color: var(--text); }

/* ================= Map thumbnails ================= */
.thumb {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: linear-gradient(135deg, #24242c, #16161c); border-radius: 5px; overflow: hidden;
  position: relative; color: var(--text-faint); font-weight: 800;
}
.thumb::after { content: attr(data-initials); position: absolute; font-size: 0.62em; letter-spacing: 0.04em; }
.thumb img { width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 1; }
.thumb-sm { width: 26px; height: 18px; font-size: 12px; }
.thumb-lg { width: 92px; height: 54px; font-size: 22px; border-radius: 7px; }
.thumb-banner { position: absolute; inset: 0; width: 100%; height: 100%; font-size: 40px; border-radius: 0; }

/* ================= Pages ================= */
/* `.page { display:block }` beat the browser default for [hidden], which made every page
   render stacked on top of each other. Explicitly honour the hidden attribute. */
.page { display: block; }
.page[hidden] { display: none !important; }
.stack-heading {
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-dim); margin: 22px 0 8px;
}

/* Multi-match */
.multi-boxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 4px; }
.multi-box { border: 1px solid var(--border-soft); border-radius: 9px; padding: 10px; background: rgba(20,20,25,0.5); }
.multi-box-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-dim);
}
.drop-zone-sm { padding: 20px 12px; }
.drop-zone-sm .drop-title { font-size: 0.85rem; }

/* Library */
/* Header wraps as a whole rather than letting the button group fold back over the
   description. The text block is allowed to shrink; the controls never are. */
.lib-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px 18px; flex-wrap: wrap; margin-bottom: 14px;
}
.lib-head > div:first-child { flex: 1 1 340px; min-width: 0; }
.lib-title { margin: 0; font-size: 1.05rem; font-weight: 800; letter-spacing: 0.02em; }
.lib-count { color: var(--text-faint); font-weight: 700; font-size: 0.85rem; margin-left: 6px; }
.lib-sub { margin: 4px 0 0; color: var(--text-faint); font-size: 0.8rem; }
.lib-list { display: flex; flex-direction: column; gap: 8px; }
.lib-row {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  background: var(--card); border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px 14px;
}
.lib-row:hover { border-color: #3a3a45; background: rgba(30,30,36,0.9); }
.lib-meta { flex: 1; min-width: 0; }
.lib-name { font-size: 0.92rem; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lib-line { font-size: 0.76rem; color: var(--text-faint); margin-top: 3px; }
.lib-line .dot { margin: 0 5px; opacity: 0.6; }
.badge { font-size: 0.58rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-dim); border: 1px solid var(--border); border-radius: 4px; padding: 2px 5px; }
.badge-pin { color: var(--gold); border-color: rgba(224,169,43,0.45); }
.lib-open { background: none; border: none; color: var(--text-dim); font-size: 0.76rem; font-weight: 700;
  text-transform: none; letter-spacing: 0; padding: 6px 4px; }
.lib-open:hover { color: var(--accent); }
.lib-search-wrap { display: flex; justify-content: center; margin-top: 26px; }
.lib-search {
  width: 380px; max-width: 100%; background: var(--card-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 9px 16px; color: var(--text); font-size: 0.82rem; font-family: inherit; outline: none;
}
.lib-search:focus { border-color: var(--accent); }

/* Detail */
.detail-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.link-btn { background: none; border: none; color: var(--text-dim); font-size: 0.82rem; font-weight: 700;
  text-transform: none; letter-spacing: 0; padding: 4px; }
.link-btn:hover { color: var(--text); }
/* ================= Detail banner ================= */
.detail-banner {
  position: relative; border-radius: 12px; overflow: hidden; margin-bottom: 6px;
  min-height: 170px; border: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: center;
}
/* No gradient overlay — a flat scrim keeps the text readable without washing the map art
   unevenly across the banner. */
.detail-banner::after {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: rgba(10, 10, 13, 0.55);
}
.detail-banner-inner { position: relative; z-index: 2; text-align: center; padding: 22px; width: 100%; }
.detail-teams { display: flex; align-items: center; justify-content: center; gap: 14px; font-size: 1.5rem; font-weight: 800; flex-wrap: wrap; }
.detail-score { font-size: 2rem; font-weight: 900; }
.detail-colon { color: var(--text-faint); }
.detail-team { text-transform: uppercase; letter-spacing: 0.03em; font-size: 1.05rem; }
.detail-sub { color: var(--text-dim); font-size: 0.78rem; margin-top: 8px; }

/* ================= Library groups / drag & drop ================= */
.lib-group { margin-bottom: 18px; }
.lib-group-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.64rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-faint); padding: 0 2px 7px;
}
.lib-group-body { display: flex; flex-direction: column; gap: 8px; min-height: 34px; border-radius: 9px; }
.lib-group-body.drop-hover { outline: 1px dashed var(--accent); outline-offset: 4px; background: rgba(74,158,255,0.05); }
.lib-group-empty { font-size: 0.74rem; color: #4d525c; padding: 10px 12px; border: 1px dashed var(--border-soft); border-radius: 9px; }
.lib-row.active { border-color: var(--accent); }
.lib-row.dragging { opacity: 0.45; }
.lib-row[draggable=true] { cursor: grab; }
.lib-acts { display: flex; align-items: center; gap: 4px; }
.lib-acts .mini-btn { opacity: 0; font-size: 0.8rem; }
.lib-row:hover .lib-acts .mini-btn { opacity: 1; }

/* ================= PNG export menu ================= */
.export-wrap { position: relative; }
.export-menu {
  position: absolute; right: 0; top: calc(100% + 5px); z-index: 20; min-width: 190px;
  background: #17171c; border: 1px solid var(--border); border-radius: 8px; padding: 4px;
  display: flex; flex-direction: column; gap: 1px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.export-menu.hidden { display: none; }
.export-item {
  background: none; border: none; color: var(--text-dim); text-align: left;
  padding: 8px 10px; border-radius: 5px; font-size: 0.74rem; font-weight: 700;
  letter-spacing: 0; text-transform: none; white-space: nowrap;
}
.export-item:hover { background: rgba(255,255,255,0.06); color: var(--text); }

/* ================= Library header actions ================= */
.lib-head-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  justify-content: flex-end; flex: 0 0 auto;
}
.lib-head-actions .btn-secondary { padding: 8px 13px; font-size: 0.68rem; }

/* ================= Individual performance ================= */
.psearch-wrap { position: relative; max-width: 520px; margin-bottom: 14px; }
.psearch {
  width: 100%; background: var(--card-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 15px; color: var(--text); font-size: 0.85rem; font-family: inherit; outline: none;
}
.psearch:focus { border-color: var(--accent); }
.psearch-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 5px); z-index: 25; max-height: 340px;
  overflow-y: auto; background: #17171c; border: 1px solid var(--border); border-radius: 9px;
  padding: 4px; box-shadow: 0 10px 30px rgba(0,0,0,0.55);
}
.psearch-results.hidden { display: none; }
.psearch-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  background: none; border: none; color: var(--text); text-align: left; padding: 9px 11px;
  border-radius: 6px; font-size: 0.8rem; font-weight: 700; letter-spacing: 0; text-transform: none;
}
.psearch-item:hover { background: rgba(255,255,255,0.06); }
.psearch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.psearch-meta { color: var(--text-faint); font-size: 0.7rem; font-weight: 600; white-space: nowrap; }
.psearch-empty { color: var(--text-faint); font-size: 0.78rem; padding: 10px 11px; }

.player-favs { display: flex; flex-direction: column; gap: 5px; max-width: 520px; margin-bottom: 22px; }
.fav-label { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 2px; }
.fav-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: rgba(28,28,33,0.78); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 13px; color: var(--text); font-size: 0.82rem; font-weight: 700;
  letter-spacing: 0; text-transform: none;
}
.fav-btn:hover { background: rgba(40,40,48,0.9); }
.fav-btn.active { border-color: var(--accent); background: rgba(74,158,255,0.08); }
.fav-btn.stale { opacity: 0.5; }
.fav-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-meta { color: var(--text-faint); font-size: 0.7rem; font-weight: 600; white-space: nowrap; }

/* Star: grey when not favourited, gold when it is. */
.fav-star { font-size: 0.95rem; line-height: 1; cursor: pointer; }
.fav-star.on { color: var(--gold); }
.fav-star.off { color: var(--text-faint); }
.fav-star:hover { filter: brightness(1.25); }
.fav-toggle { display: inline-flex; align-items: center; gap: 7px; }

.pcard-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.pcard-name { font-size: 1.3rem; font-weight: 900; letter-spacing: 0.01em; }
.pcard-sub { color: var(--text-faint); font-size: 0.78rem; flex: 1; }
.pstat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; }
.pstat { background: var(--card); border: 1px solid var(--border-soft); border-radius: 9px; padding: 11px 12px; }
.pstat-k { font-size: 0.6rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-faint); }
.pstat-v { font-size: 1.15rem; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }

.pmatch-list { display: flex; flex-direction: column; gap: 8px; }
.pmatch {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  background: var(--card); border: 1px solid var(--border-soft); border-radius: 10px; padding: 10px 14px;
}
.pmatch:hover { border-color: #3a3a45; }
.pmatch-stats { display: flex; align-items: center; gap: 16px; font-weight: 800; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.badge-win { color: var(--good); border-color: rgba(74,222,128,0.4); }
.badge-loss { color: var(--bad); border-color: rgba(239,68,68,0.4); }

/* ================= Match filter (individual performance) ================= */
.match-filter-head { display: flex; align-items: center; gap: 12px; margin: 22px 0 8px; flex-wrap: wrap; }
.match-filter-count { font-size: 0.7rem; font-weight: 700; color: var(--text-faint); }
.match-filter-btns { display: flex; gap: 4px; margin-left: auto; }
.match-filter-btns .mini-btn {
  border: 1px solid var(--border); border-radius: 5px; padding: 5px 9px; font-size: 0.62rem;
}
.match-filter-btns .mini-btn:hover { background: rgba(255,255,255,0.05); }
.pmatch-check { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.pmatch.unchecked { opacity: 0.42; }
.pmatch.unchecked:hover { opacity: 0.7; }
.pmatch .thumb { cursor: pointer; }
.filter-tag {
  display: inline-block; margin-left: 7px; padding: 1px 6px; border-radius: 4px;
  background: rgba(74,158,255,0.15); color: var(--accent);
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.07em; vertical-align: 1px;
}

/* ================= Multi-player comparison ================= */
.player-picked { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.pick-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(74,158,255,0.12); border: 1px solid rgba(74,158,255,0.4); border-radius: 16px;
  padding: 5px 11px; font-size: 0.74rem; font-weight: 700; color: var(--text);
}
.pick-x { color: var(--text-faint); font-size: 0.66rem; cursor: pointer; }
.pick-x:hover { color: var(--bad); }
.common-toggle {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem;
  color: var(--text-dim); cursor: pointer; margin-left: 4px;
}
.common-toggle input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.fav-add, .psearch-add {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 6px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 1.25rem; font-weight: 800; line-height: 1;
  border: 1px solid var(--border);
}
.fav-add:hover, .psearch-add:hover { color: var(--text); background: rgba(255,255,255,0.07); }

.cmp-wrap { overflow-x: auto; }
.cmp-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.cmp-table th {
  text-align: right; padding: 9px 10px; color: var(--text-faint); font-weight: 700;
  font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-soft); white-space: nowrap;
}
.cmp-table td {
  text-align: right; padding: 11px 10px; border-bottom: 1px solid #1a1a1e;
  font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap;
}
.cmp-table th.cmp-player, .cmp-table td.cmp-player { text-align: left; font-weight: 800; }
.cmp-table tbody tr { cursor: pointer; }
.cmp-table tbody tr:hover td { background: rgba(255,255,255,0.03); }
.cmp-best { background: rgba(74,222,128,0.13); border-radius: 4px; }

/* ================= Folder reorder + folder filters ================= */
.lib-group-title { display: inline-flex; align-items: center; gap: 7px; }
.grip { color: #4d525c; letter-spacing: -2px; cursor: grab; font-size: 0.8rem; }
.lib-group-head[draggable=true] { cursor: grab; }
.lib-group-head.dragging { opacity: 0.45; }
.lib-group-head.folder-drop { outline: 1px dashed var(--accent); outline-offset: 3px; border-radius: 5px; }

.folder-filter { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.folder-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(28,28,33,0.75); border: 1px solid var(--border); border-radius: 15px;
  padding: 5px 11px; color: var(--text-dim); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0; text-transform: none;
}
.folder-chip:hover { background: rgba(40,40,48,0.9); color: var(--text); }
.folder-chip.on { border-color: var(--accent); color: var(--text); background: rgba(74,158,255,0.12); }
.folder-chip.partial { border-color: rgba(74,158,255,0.4); color: var(--text); }
.folder-tick { width: 9px; font-size: 0.68rem; color: var(--accent); }
.folder-count { color: var(--text-faint); font-size: 0.66rem; }

/* ================= Comparison affordances ================= */
.compare-hint { color: var(--text-faint); font-size: 0.76rem; margin: -6px 0 14px; }
/* Plain blue "+" — a bordered box never sits on the text baseline cleanly. */
.hint-plus { color: var(--accent); font-weight: 800; }
/* Make the add-to-comparison control read as an action rather than decoration. */
.fav-add, .psearch-add { border-color: rgba(74,158,255,0.45); color: var(--accent); }
.fav-add:hover, .psearch-add:hover { background: rgba(74,158,255,0.15); color: var(--accent); }
.fav-btn.active .fav-add, .psearch-item .psearch-add { opacity: 1; }

.cmp-mini-row { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 5px; }
.cmp-mini { font-size: 0.7rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.cmp-mini b { color: var(--text); font-weight: 700; }
.pmatch.locked { cursor: default; }
.pmatch.locked:hover { border-color: var(--border-soft); }

/* ================= Form & trends ================= */
.trend-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.trend-card { background: var(--card); border: 1px solid var(--border-soft); border-radius: 10px; padding: 13px 15px; }
.trend-title { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 10px; }
.trend-sub { font-weight: 600; letter-spacing: 0; text-transform: none; opacity: 0.75; }
.trend-line { font-size: 0.78rem; color: var(--text-dim); margin-top: 9px; }
.trend-line b { color: var(--text); }
.spark { width: 100%; height: 64px; display: block; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.spark-base { stroke: #3a3a45; stroke-width: 1; stroke-dasharray: 3 3; }
.cmp-table .thumb-sm { vertical-align: -4px; margin-right: 6px; }

/* ================= Editable map / team names ================= */
.sb-map.editable, .sb-team-name.editable { cursor: pointer; }
.sb-map.editable:hover, .sb-team-name.editable:hover {
  text-decoration: underline; text-decoration-style: dotted;
  text-underline-offset: 4px; opacity: 0.88;
}

/* ================= Library sort control ================= */
.lib-sort {
  background: var(--card-2); color: var(--text-dim); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px; font-size: 0.68rem; font-weight: 700;
  font-family: inherit; letter-spacing: 0.04em; text-transform: uppercase; cursor: pointer;
}
.lib-sort:hover { color: var(--text); }
.lib-sort:focus { outline: none; border-color: var(--accent); }

/* ================= MVP badge ================= */
.mvp-badge {
  display: inline-block; margin-left: 7px; padding: 1px 5px; border-radius: 4px;
  background: rgba(224,169,43,0.16); color: var(--gold);
  font-size: 0.55rem; font-weight: 800; letter-spacing: 0.08em; vertical-align: 1px;
}

/* ================= Undo toast ================= */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 14px;
  background: #1c1c22; border: 1px solid var(--border); border-radius: 9px;
  padding: 12px 16px; font-size: 0.82rem; color: var(--text);
  box-shadow: 0 10px 30px rgba(0,0,0,0.55);
}
.toast button {
  background: none; border: 1px solid var(--accent); color: var(--accent);
  border-radius: 5px; padding: 5px 11px; font-size: 0.68rem; letter-spacing: 0.05em;
}
.toast button:hover { background: rgba(74,158,255,0.12); }

/* ================= Backup reminder ================= */
.backup-note {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  border-radius: 8px; padding: 9px 14px; margin-bottom: 14px; font-size: 0.78rem;
  background: rgba(28,28,33,0.7); border: 1px solid var(--border-soft); color: var(--text-dim);
}
.backup-note.stale { border-color: rgba(251,146,60,0.4); background: rgba(251,146,60,0.06); }
.backup-note b { color: var(--text); }

/* ================= Operator table ================= */
.op-name { cursor: pointer; }
.op-name:hover { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.op-name.unnamed { color: var(--text-dim); font-style: italic; }
.op-side {
  display: inline-block; padding: 1px 7px; border-radius: 4px;
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.05em;
  background: rgba(255,255,255,0.05); color: var(--text-faint);
}
.op-side.attack { color: #ff8f5e; background: rgba(255,143,94,0.12); }
.op-side.defense { color: #5eb0ff; background: rgba(94,176,255,0.12); }


/* ================= Section tabs ================= */
.tab-bar { display: flex; gap: 4px; margin: 18px 0 16px; border-bottom: 1px solid var(--border-soft); }
.tab-btn {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-faint); padding: 9px 15px; font-size: 0.74rem; font-weight: 800;
  letter-spacing: 0.06em; text-transform: uppercase; border-radius: 0;
}
.tab-btn:hover { color: var(--text-dim); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }


/* ================= Settings ================= */
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: var(--card); border: 1px solid var(--border-soft); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 10px; max-width: 620px;
}
.settings-label { font-size: 0.86rem; font-weight: 700; color: var(--text); }
.settings-help { font-size: 0.76rem; color: var(--text-faint); margin-top: 3px; }
.theme-toggle { display: flex; gap: 4px; }
.theme-opt {
  background: var(--card-2); border: 1px solid var(--border); color: var(--text-dim);
  padding: 8px 15px; font-size: 0.7rem; border-radius: 6px;
}
.theme-opt.active { border-color: var(--accent); color: var(--text); background: rgba(74,158,255,0.10); }


/* ================= Active sort highlight ================= */
/* The sorted column is called out in the accent colour, header and cells, so the current
   ordering is obvious at a glance. */
th.sortable { color: var(--text-faint); }
th.sorted { color: var(--accent) !important; }
table.scoreboard th.sorted,
.cmp-table th.sorted { border-bottom-color: var(--accent); }
td.sorted-cell { background: rgba(74, 158, 255, 0.07); }
.player-row:hover td.sorted-cell { background: rgba(74, 158, 255, 0.11); }
.cmp-table tbody tr:hover td.sorted-cell { background: rgba(74, 158, 255, 0.11); }

/* ================= Operator icons ================= */
.op-icon {
  width: 22px; height: 22px; object-fit: contain; vertical-align: -6px;
  margin-right: 8px; flex-shrink: 0;
}
.cmp-table td.cmp-player { white-space: nowrap; }

/* ================= Replay path hint ================= */
.path-hint {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding: 9px 13px;
  background: rgba(255,255,255,0.025); border: 1px solid var(--border-soft); border-radius: 8px;
}
.path-hint-label {
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-faint); white-space: nowrap;
}
.path-hint code {
  flex: 1; min-width: 0; font-size: 0.74rem; color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-x: auto; white-space: nowrap; user-select: all;
}
.path-copy {
  border: 1px solid var(--border); border-radius: 5px; padding: 5px 11px;
  font-size: 0.62rem; white-space: nowrap;
}
.path-copy:hover { background: rgba(255,255,255,0.06); color: var(--text); }

/* ================= Folder heading actions ================= */
/* Compact icons grouped on the right, like the replay rows — text buttons spread across
   the heading made the folder name and its controls look unrelated. */
.lib-group-acts { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.lib-group-acts .mini-btn {
  opacity: 0; font-size: 0.82rem; line-height: 1; padding: 3px 6px; border-radius: 4px;
}
.lib-group:hover .lib-group-acts .mini-btn { opacity: 1; }
.lib-group-acts .mini-btn:hover { background: rgba(255,255,255,0.07); color: var(--text); }
.lib-group-acts .mini-btn:last-child:hover { color: var(--bad); }
