/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:        #0b0e14;
  --surface:   #13161f;
  --card:      #1a1f2c;
  --border:    #252c3d;
  --ct:        #5599e8;
  --ct-dim:    rgba(85, 153, 232, 0.10);
  --ct-header: rgba(85, 153, 232, 0.18);
  --t:         #e89240;
  --t-dim:     rgba(232, 146, 64, 0.10);
  --t-header:  rgba(232, 146, 64, 0.18);
  --text:      #dde2f0;
  --muted:     #6e7a99;
  --green:     #4db87a;
  --yellow:    #e8c44a;
  --red:       #e8504a;
  --radius:    8px;
}

/* ── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  color: var(--text);
}

/* ── Site nav ────────────────────────────────────────────────────────────── */
.site-nav { display: flex; gap: 2px; }
.nav-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: color 0.15s, background 0.15s;
}
.nav-btn:hover  { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-btn.active { color: var(--ct); background: var(--ct-dim); }
.brand svg { stroke: var(--ct); }

.header-actions { display: flex; gap: 8px; align-items: center; }

/* Admin modal */
.admin-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.admin-modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  width: 100%; max-width: 440px;
  display: flex; flex-direction: column; gap: 16px;
  max-height: 90vh; overflow-y: auto;
}
.admin-modal-header {
  display: flex; align-items: center; justify-content: space-between;
}
.admin-modal-header h3 { font-size: 16px; font-weight: 700; }
.admin-close {
  background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; line-height: 1;
  padding: 2px 6px; border-radius: 4px;
}
.admin-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.admin-modal-box input {
  width: 100%; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px;
}
.admin-modal-box input:focus { outline: none; border-color: var(--ct); }

.admin-section { display: flex; flex-direction: column; gap: 8px; }
.admin-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}

/* 2-column button grid */
.admin-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.admin-btn {
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.admin-btn:hover       { color: var(--text); border-color: var(--ct); background: var(--ct-dim); }
.admin-btn-accent      { border-color: var(--ct); color: var(--ct); }
.admin-btn-accent:hover{ background: var(--ct-dim); }
.admin-btn-warn        { border-color: var(--yellow); color: var(--yellow); }
.admin-btn-warn:hover  { background: rgba(232,196,74,0.1); }
.admin-btn-green       { border-color: var(--green); color: var(--green); }
.admin-btn-green:hover { background: rgba(77,184,122,0.1); }
.admin-btn-danger      { background: var(--red); color: #fff; border-color: var(--red); }
.admin-btn-danger:hover{ opacity: 0.85; }

/* Keep btn-danger for other uses */
.btn-danger {
  background: var(--red); color: #fff; border: none;
  padding: 7px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s;
}
.btn-danger:hover { opacity: 0.85; }

.admin-error { color: var(--red); font-size: 12px; }

.admin-pool-grid { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-pool-check {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 5px;
  cursor: pointer; font-size: 12px; font-weight: 600;
  user-select: none; transition: border-color 0.15s;
}
.admin-pool-check:has(input:checked) { border-color: var(--ct); color: var(--ct); }
.admin-pool-check input { display: none; }
.admin-pool-shortcuts { display: flex; gap: 8px; }
.admin-link { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 2px 0; text-decoration: underline; }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: color 0.15s, border-color 0.15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--ct); }

/* ── Views ──────────────────────────────────────────────────────────────── */
.view { width: 100%; }
.hidden { display: none !important; }

/* ── Drop zone ──────────────────────────────────────────────────────────── */
#view-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 53px);
  padding: 24px;
}

.drop-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 480px;
}

.or-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 16px 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.or-row::before, .or-row::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-browse-server {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn-browse-server svg { stroke: var(--ct); }
.btn-browse-server:hover { border-color: var(--ct); background: var(--ct-dim); }

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 480px;
  padding: 64px 48px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  user-select: none;
}
.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--ct);
  background: var(--ct-dim);
}
.drop-zone.dragging { border-style: solid; }

.drop-icon {
  width: 56px;
  height: 56px;
  stroke: var(--muted);
  transition: stroke 0.2s;
}
.drop-zone:hover .drop-icon,
.drop-zone.dragging .drop-icon { stroke: var(--ct); }

.drop-zone h2 { font-size: 20px; font-weight: 600; }
.accent { color: var(--ct); }

.drop-sub { color: var(--muted); font-size: 13px; }
.browse-link {
  color: var(--ct);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.browse-link input { display: none; }

.drop-hint { font-size: 12px; color: var(--muted); opacity: 0.6; }

.error-toast {
  margin-top: 16px;
  padding: 10px 18px;
  background: rgba(232, 80, 74, 0.15);
  border: 1px solid rgba(232, 80, 74, 0.4);
  border-radius: var(--radius);
  color: #f08080;
  font-size: 13px;
}

/* ── Loading ────────────────────────────────────────────────────────────── */
#view-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 53px);
}
.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 64px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-align: center;
}
.loading-title { font-size: 17px; font-weight: 600; }
.loading-sub { color: var(--muted); font-size: 13px; max-width: 300px; word-break: break-all; }

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--ct);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress bar */
.progress-wrap {
  position: relative;
  width: 260px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: visible;
}
.progress-fill {
  height: 100%;
  background: var(--ct);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}
.progress-pct {
  position: absolute;
  right: 0;
  top: -18px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ── Browse view ─────────────────────────────────────────────────────────── */
#view-browse { padding: 0 0 48px; }

.browse-header {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  color: var(--muted);
}
.breadcrumb span { color: var(--text); font-weight: 600; }
.breadcrumb .sep { margin: 0 6px; }

.browse-content { padding: 24px; }

/* Pool grid */
.pool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.pool-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-weight: 700;
  font-size: 18px;
}
.pool-card:hover { border-color: var(--ct); background: var(--ct-dim); }
.pool-card-sub { font-size: 11px; font-weight: 400; color: var(--muted); }

/* Batch button */
.batch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.batch-bar h3 { font-size: 14px; color: var(--muted); font-weight: 400; }
.btn-batch {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: none;
  border: 1px solid var(--ct);
  border-radius: var(--radius);
  color: var(--ct);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-batch:hover { background: var(--ct-dim); }
.btn-batch:disabled { opacity: 0.4; cursor: not-allowed; }

/* Demo table */
.demo-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13px;
}
.demo-table thead tr { background: var(--surface); border-bottom: 1px solid var(--border); }
.demo-table th {
  padding: 8px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.demo-table th:last-child { text-align: right; }
.demo-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.demo-table tbody tr:last-child { border-bottom: none; }
.demo-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.demo-table td { padding: 10px 14px; }
.demo-table td:last-child { text-align: right; white-space: nowrap; }

.demo-match   { font-weight: 600; }
.demo-sub     { font-size: 12px; color: var(--muted); margin-top: 2px; }
.demo-weapon  {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  margin-right: 4px;
}
.demo-size    { color: var(--muted); font-size: 12px; white-space: nowrap; }
.cached-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--green);
  font-weight: 600;
}

.btn-parse, .btn-view {
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}
.btn-parse { background: var(--ct); color: #fff; }
.btn-parse:hover { opacity: 0.85; }
.btn-view  { background: var(--surface); border: 1px solid var(--green); color: var(--green); }
.btn-view:hover { background: rgba(77,184,122,0.1); }

/* ── Select & Parse view ─────────────────────────────────────────────────── */
#view-select { padding: 0 0 48px; }
.select-header {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.select-header-left { display: flex; align-items: center; gap: 12px; }
.select-header-title { font-weight: 700; font-size: 15px; }
.select-summary { font-size: 12px; color: var(--muted); }
.select-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.select-content { padding: 24px; display: flex; flex-direction: column; gap: 16px; }

.select-group {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.select-group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.select-group-label { font-weight: 700; font-size: 13px; }
.select-group-meta  { font-size: 12px; color: var(--muted); flex: 1; }
.select-group-actions { display: flex; gap: 8px; }

.select-group-demos { display: flex; flex-direction: column; }

.select-demo-row {
  display: grid;
  grid-template-columns: 20px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.select-demo-row:last-child { border-bottom: none; }
.select-demo-row:hover { background: rgba(255,255,255,0.03); }
.select-demo-row.is-cached { opacity: 0.6; }
.select-demo-row input[type="checkbox"] { cursor: pointer; accent-color: var(--ct); width: 14px; height: 14px; }
.select-demo-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-demo-map  { font-size: 12px; color: var(--muted); white-space: nowrap; }
.select-uncached-tag {
  font-size: 11px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 2px 6px; white-space: nowrap;
}

/* ── Batch progress view ─────────────────────────────────────────────────── */
#view-batch { padding: 0 0 48px; }
.batch-header {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.batch-header-title { font-weight: 700; font-size: 15px; }
.batch-summary { font-size: 12px; color: var(--muted); }

.batch-list {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.batch-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.batch-item-icon { font-size: 14px; text-align: center; }
.batch-item-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-item-status { font-size: 11px; color: var(--muted); white-space: nowrap; }
.batch-item.status-done    { border-color: rgba(77,184,122,0.3); }
.batch-item.status-error   { border-color: rgba(232,80,74,0.3); }
.batch-item.status-active  { border-color: var(--ct); }

/* ── Stats view ─────────────────────────────────────────────────────────── */
#view-stats { padding: 0 0 48px; }

/* Match header */
.match-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.team-block {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 120px;
}
.ct-block { justify-content: flex-end; }
.t-block  { justify-content: flex-start; }

.team-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
}
.ct-block .team-label { background: var(--ct-header); color: var(--ct); }
.t-block  .team-label { background: var(--t-header);  color: var(--t);  }

.team-score { font-size: 42px; font-weight: 800; line-height: 1; }
.ct-block .team-score { color: var(--ct); }
.t-block  .team-score { color: var(--t);  }

.match-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.match-map {
  font-size: 18px;
  font-weight: 700;
  text-transform: lowercase;
  letter-spacing: 0.03em;
}
.match-rounds-total { font-size: 12px; color: var(--muted); }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 12px 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--ct); border-bottom-color: var(--ct); }

/* Tab panes */
.tab-pane { padding: 24px; }

/* ── Scoreboard ─────────────────────────────────────────────────────────── */
.team-section { margin-bottom: 28px; }

.team-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.ct-section-header { background: var(--ct-header); color: var(--ct); border: 1px solid rgba(85,153,232,0.25); }
.t-section-header  { background: var(--t-header);  color: var(--t);  border: 1px solid rgba(232,146,64,0.25); }

.scoreboard-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  font-size: 13px;
}
.ct-section-header + .scoreboard-table { border-top: none; }
.t-section-header  + .scoreboard-table { border-top: none; }

.scoreboard-table thead tr {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.scoreboard-table th {
  padding: 8px 12px;
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.scoreboard-table th:first-child { text-align: left; padding-left: 14px; min-width: 140px; }

.scoreboard-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.scoreboard-table tbody tr:last-child { border-bottom: none; }
.scoreboard-table tbody tr:hover { background: rgba(255,255,255,0.03); }

.scoreboard-table td {
  padding: 10px 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.scoreboard-table td:first-child { text-align: left; padding-left: 14px; font-weight: 600; }

/* Rating color coding */
.rating-great { color: var(--green); }
.rating-good  { color: #8de870; }
.rating-avg   { color: var(--text); }
.rating-below { color: var(--yellow); }
.rating-bad   { color: var(--red); }

/* KD color coding */
.kd-pos { color: var(--green); }
.kd-neg { color: var(--red); }

/* Multi-kill badges */
.mk-cell { display: flex; justify-content: flex-end; gap: 4px; }
.mk-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  opacity: 0.85;
}
.mk-3k  { background: rgba(78,158,232,0.2);  color: #4e9ee8; }
.mk-4k  { background: rgba(232,196,74,0.2);  color: #e8c44a; }
.mk-ace { background: rgba(232,80,74,0.2);   color: #e8504a; }

/* Clutch cell */
.clutch-cell {
  cursor: default;
  text-decoration: underline dotted var(--muted);
  text-underline-offset: 2px;
}

/* ── Rounds ──────────────────────────────────────────────────────────────── */
.rounds-grid {
  display: grid;
  gap: 8px;
}

.round-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.round-header {
  display: grid;
  grid-template-columns: 64px auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.round-header:hover { background: rgba(255,255,255,0.03); }

.round-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.winner-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.winner-ct { background: var(--ct-header); color: var(--ct); }
.winner-t  { background: var(--t-header);  color: var(--t);  }

.entry-kill-text {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-name { color: var(--text); font-weight: 500; }

.round-kill-count {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.round-chevron {
  font-size: 11px;
  color: var(--muted);
  transition: transform 0.2s;
  width: 16px;
  text-align: center;
}
.round-card.open .round-chevron { transform: rotate(180deg); }

.round-kills {
  border-top: 1px solid var(--border);
  padding: 8px 0;
  display: none;
}
.round-card.open .round-kills { display: block; }

.kill-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  font-size: 13px;
  transition: background 0.1s;
}
.kill-row:hover { background: rgba(255,255,255,0.02); }

.kill-killer  { font-weight: 600; min-width: 140px; }
.kill-weapon  {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}
.kill-victim  { color: var(--muted); min-width: 140px; }
.kill-hs      { font-size: 10px; font-weight: 700; color: var(--yellow); letter-spacing: 0.06em; }
.kill-assist  { font-size: 12px; color: var(--muted); }

/* ── CSC player enrichment ───────────────────────────────────────────────── */
.player-cell { display: flex; flex-direction: column; gap: 2px; }
.player-csc-name { font-weight: 600; }
.player-ingame-name { font-size: 11px; color: var(--muted); }

.tier-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}
.tier-Recruit    { background: rgba(110,122,153,0.2); color: #6e7a99; border: 1px solid rgba(110,122,153,0.3); }
.tier-Prospect   { background: rgba(77,184,122,0.15); color: #4db87a; border: 1px solid rgba(77,184,122,0.3); }
.tier-Challenger { background: rgba(85,153,232,0.15); color: #5599e8; border: 1px solid rgba(85,153,232,0.3); }
.tier-Contender  { background: rgba(168,85,247,0.15); color: #a855f7; border: 1px solid rgba(168,85,247,0.3); }
.tier-Elite      { background: rgba(232,196,74,0.15); color: #e8c44a; border: 1px solid rgba(232,196,74,0.3); }
.tier-Premier    { background: rgba(232,80,74,0.15);  color: #e8504a; border: 1px solid rgba(232,80,74,0.3); }

.unreg-badge {
  display: inline-block;
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  opacity: 0.6;
}

/* ── Player profile ──────────────────────────────────────────────────────── */
.player-profile-header {
  padding: 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.player-profile-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.player-profile-name { font-size: 24px; font-weight: 800; }
.player-profile-cscid { font-size: 12px; color: var(--muted); }

.player-stat-row {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}
.player-stat-block { display: flex; flex-direction: column; gap: 2px; }
.player-stat-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.player-stat-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

.player-content { padding: 24px; }

.player-match-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13px;
}
.player-match-table thead tr { background: var(--surface); border-bottom: 1px solid var(--border); }
.player-match-table th {
  padding: 8px 12px;
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.player-match-table th:first-child { text-align: left; }
.player-match-table th:nth-child(2) { text-align: left; }
.player-match-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.player-match-table tbody tr:last-child { border-bottom: none; }
.player-match-table tbody tr:hover { background: rgba(85,153,232,0.05); }
.player-match-table td { padding: 10px 12px; text-align: right; font-variant-numeric: tabular-nums; }
.player-match-table td:first-child { text-align: left; }
.player-match-table td:nth-child(2) { text-align: left; }

.pmt-map   { font-weight: 600; }
.pmt-teams { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pmt-side-ct { color: var(--ct); font-weight: 700; font-size: 11px; }
.pmt-side-t  { color: var(--t);  font-weight: 700; font-size: 11px; }

/* Make leaderboard player names look clickable */
.lb-player-link {
  cursor: pointer;
  color: var(--text);
  text-decoration: underline dotted var(--muted);
  text-underline-offset: 3px;
  transition: color 0.15s;
}
.lb-player-link:hover { color: var(--ct); }

/* ── Shared leaderboard / matches header ─────────────────────────────────── */
.lb-header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.lb-title   { font-size: 18px; font-weight: 700; }
.lb-subtitle{ font-size: 13px; color: var(--muted); }

/* Tier tab strip */
.tier-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.tier-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tier-tab:hover { color: var(--text); }
.tier-tab.active { border-bottom-color: var(--ct); color: var(--ct); }
.tier-tab .tier-count { font-size: 11px; opacity: 0.6; margin-left: 4px; }

/* ── Leaderboard search ──────────────────────────────────────────────────── */
.lb-search-bar {
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
#lb-search {
  width: 100%;
  max-width: 280px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
#lb-search:focus { border-color: var(--ct); }
#lb-search::placeholder { color: var(--muted); }

/* ── Matches search (centered) ───────────────────────────────────────────── */
#matches-search-bar {
  display: flex;
  justify-content: center;
  padding: 14px 24px;
}
#matches-search {
  width: 100%;
  max-width: 420px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
#matches-search:focus { border-color: var(--ct); }
#matches-search::placeholder { color: var(--muted); }

/* ── Leaderboard table ───────────────────────────────────────────────────── */
.lb-content  { padding: 24px; }

.lb-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}
.lb-table thead tr {
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 var(--border);
}
.lb-table th {
  padding: 8px 12px;
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.lb-table th:first-child  { text-align: center; width: 40px; }
.lb-table th:nth-child(2) { text-align: left; min-width: 160px; }
.lb-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.lb-table tbody tr:last-child { border-bottom: none; }
.lb-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.lb-table td { padding: 10px 12px; text-align: right; font-variant-numeric: tabular-nums; }
.lb-table td:first-child  { text-align: center; color: var(--muted); font-size: 12px; }
.lb-table td:nth-child(2) { text-align: left; }

.lb-rank-1 { color: #e8c44a; font-weight: 700; }
.lb-rank-2 { color: #b0bec5; font-weight: 700; }
.lb-rank-3 { color: #cd7f32; font-weight: 700; }

.lb-player-name { font-weight: 600; }
.lb-matches-badge {
  display: inline-block;
  font-size: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--muted);
  margin-left: 6px;
}

/* ── Matches grid ────────────────────────────────────────────────────────── */
.matches-content { padding: 24px; }

.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}

.match-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.match-card:hover { border-color: var(--ct); background: rgba(85,153,232,0.04); }

.match-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.match-card-map { font-size: 12px; color: var(--muted); }
.match-card-score {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.mc-ct { color: var(--ct); }
.mc-sep { color: var(--muted); margin: 0 4px; font-size: 14px; }
.mc-t  { color: var(--t); }

.match-card-teams {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}
.match-card-teams .vs { color: var(--muted); font-weight: 400; margin: 0 4px; }

.match-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}
.match-card-view2d {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 5px 0;
  font-size: 11px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, color 0.15s;
}
.match-card-view2d:hover { border-color: var(--ct); color: var(--ct); }
.match-pool-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ── Weekly Recap ────────────────────────────────────────────────────────── */
#view-recap { padding: 0 0 48px; }
.recap-content { padding: 24px; }
.recap-generated { font-size: 12px; color: var(--muted); margin-bottom: 20px; }

.recap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 14px;
}

.recap-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}
.recap-card:hover { border-color: var(--ct); }

.recap-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.recap-rank {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
  flex-shrink: 0;
}
.recap-rank-1 { background: rgba(232,196,74,0.2); color: #e8c44a; border: 1px solid rgba(232,196,74,0.4); }
.recap-rank-2 { background: rgba(176,190,197,0.2); color: #b0bec5; border: 1px solid rgba(176,190,197,0.4); }
.recap-rank-3 { background: rgba(205,127,50,0.2);  color: #cd7f32; border: 1px solid rgba(205,127,50,0.4); }
.recap-rank-n { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }

.recap-team-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.recap-team-name { font-size: 15px; font-weight: 700; }

.recap-meta-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.recap-meta-record {
  font-size: 11px; font-weight: 600;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 6px;
}
.recap-meta-item {
  font-size: 11px; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px;
}
.adj-pos { color: #5cb85c; border-color: rgba(92,184,92,0.3); }
.adj-neg { color: #d9534f; border-color: rgba(217,83,79,0.3); }

.recap-body { padding: 12px 16px; font-size: 13px; line-height: 1.6; color: var(--muted); }

.recap-section {
  display: flex;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
}
.recap-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  align-self: flex-start;
  margin-top: 1px;
}
.recap-strength .recap-section-label { background: rgba(77,184,122,0.15); color: var(--green); }
.recap-weakness .recap-section-label { background: rgba(232,196,74,0.15); color: var(--yellow); }
.recap-section-text { color: var(--muted); }

.recap-no-data {
  padding: 48px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.recap-player-link {
  color: var(--ct);
  cursor: pointer;
  text-decoration: underline dotted var(--ct);
  text-underline-offset: 2px;
  transition: color 0.15s;
}
.recap-player-link:hover { color: #fff; }

.stats-disclaimer {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 12px;
  border-left: 2px solid var(--border);
}

/* ── Utility Rating legend ───────────────────────────────────────────────── */
.util-legend {
  margin-top: 20px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
}
.util-legend-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.util-legend-formula {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.util-term {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 11px;
}
.util-term span { color: var(--muted); font-size: 10px; margin-top: 2px; }
.util-plus   { color: var(--muted); font-size: 14px; font-weight: 300; }
.util-divider {
  width: 100%;
  color: var(--muted);
  font-size: 11px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 2px;
}
.util-legend-scale {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.util-scale-item { font-size: 12px; font-weight: 600; }
.util-scale-item em { font-style: normal; font-weight: 400; color: var(--muted); margin-left: 3px; }

/* ── 2D Demo Viewer ─────────────────────────────────────────────────────── */
#view-viewer { height: calc(100vh - 53px); display: flex; flex-direction: column; }

/* Upload state */
.viewer-upload {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.viewer-upload-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 48px; max-width: 480px; width: 100%; text-align: center;
  display: flex; flex-direction: column; gap: 14px;
}
.viewer-icon { font-size: 48px; }
.viewer-upload-card h2 { font-size: 22px; font-weight: 700; }
.viewer-upload-card p  { font-size: 13px; color: var(--muted); }
.viewer-note { font-size: 11px !important; opacity: 0.6; }
.viewer-upload-btn {
  display: inline-block; padding: 10px 24px; background: var(--ct); color: #fff;
  border-radius: var(--radius); cursor: pointer; font-size: 14px; font-weight: 600;
  transition: opacity 0.15s;
}
.viewer-upload-btn:hover { opacity: 0.85; }
.viewer-upload-btn input { display: none; }
.viewer-status { font-size: 13px; color: var(--muted); padding: 8px; }
.btn-view2d { background: none; border: none; cursor: pointer; font-size: 15px; padding: 2px 4px; opacity: 0.7; vertical-align: middle; }
.btn-view2d:hover { opacity: 1; }
.viewer-progress-wrap { width: 260px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.viewer-progress-fill { height: 100%; width: 0%; background: var(--ct); border-radius: 2px; transition: width 0.25s ease, background 0.3s; }

/* Viewer app layout */
.viewer-app {
  flex: 1; display: flex; overflow: hidden;
}
.viewer-sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.viewer-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.viewer-map-name { font-size: 13px; font-weight: 700; text-transform: lowercase; }
.viewer-close-btn { font-size: 11px; padding: 4px 8px; }

.viewer-rounds { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 3px; }
.viewer-round-btn {
  width: 100%; text-align: left; padding: 6px 10px; border-radius: 5px;
  background: none; border: 1px solid transparent; cursor: pointer;
  font-size: 12px; color: var(--muted); transition: all 0.1s;
  display: flex; justify-content: space-between; align-items: center;
}
.viewer-round-btn:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.viewer-round-btn.active { background: var(--ct-dim); border-color: var(--ct); color: var(--ct); }
.viewer-round-winner { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px; }
.vr-ct { background: var(--ct-header); color: var(--ct); }
.vr-t  { background: var(--t-header);  color: var(--t);  }

.viewer-legend { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; max-height: 240px; overflow-y: auto; }
.viewer-legend-title { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.viewer-player-entry { display: flex; align-items: center; gap: 7px; font-size: 11px; }
.viewer-player-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-ct { background: #5599e8; border: 1.5px solid #fff; }
.dot-t  { background: #e89240; border: 1.5px solid #fff; }
.dot-dead { opacity: 0.3; }

/* Canvas area */
.viewer-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.viewer-canvas { display: block; background: #0b0e14; align-self: center; }
.viewer-controls {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: var(--surface); border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.viewer-ctrl-btn {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 5px 10px; border-radius: 5px; cursor: pointer; font-size: 13px;
  transition: background 0.1s;
}
.viewer-ctrl-btn:hover { background: var(--border); }
.viewer-ctrl-play { min-width: 36px; }
.viewer-scrub { flex: 1; accent-color: var(--ct); cursor: pointer; }
.viewer-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.viewer-speed {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 4px 6px; border-radius: 5px; font-size: 12px; cursor: pointer;
}
