/* ============================================================
   Black Legion S.T.A.L.K.E.R.S — Stats UI
   Dark military / S.T.A.L.K.E.R. aesthetic
   ============================================================ */

:root {
  --bg-base:      #0d0d0d;
  --bg-panel:     #141414;
  --bg-row:       #181818;
  --bg-row-alt:   #111111;
  --bg-hover:     #1f2a1a;
  --border:       #2a3a20;
  --accent:       #6abf45;
  --accent-dim:   #4a8a2e;
  --accent-glow:  rgba(106,191,69,0.15);
  --danger:       #c0392b;
  --warning:      #e67e22;
  --text-primary: #d4d4c0;
  --text-muted:   #666;
  --text-heading: #b0c080;
  --font-mono:    'Courier New', Courier, monospace;
  --font-ui:      'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --radius:       4px;
  --shadow:       0 2px 12px rgba(0,0,0,0.6);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────── */
header {
  background: linear-gradient(180deg, #0a1208 0%, #0d0d0d 100%);
  border-bottom: 2px solid var(--accent-dim);
  padding: 1.5rem 2rem;
  text-align: center;
}

.site-title {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-heading);
  text-transform: uppercase;
}

.site-title span { color: var(--accent); }

.site-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-top: 0.25rem;
}

/* ── Kill Feed ──────────────────────────────────────────────── */
.killfeed-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #0a0f08;
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1.5rem;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.killfeed-label {
  flex-shrink: 0;
  color: var(--accent);
  font-weight: bold;
  letter-spacing: 0.1em;
  border-right: 1px solid var(--border);
  padding-right: 1rem;
}

.killfeed-track {
  display: flex;
  gap: 3rem;
  white-space: nowrap;
  animation: scroll-left 40s linear infinite;
  overflow: visible;
}

.killfeed-track:hover { animation-play-state: paused; }

@keyframes scroll-left {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.feed-item { color: var(--text-primary); cursor: pointer; }
.feed-item:hover { color: var(--accent); }
.feed-item .feed-killer { color: var(--accent); font-weight: bold; }
.feed-item .feed-victim  { color: var(--danger); }
.feed-item .feed-weapon  { color: var(--warning); }
.killfeed-loading { color: var(--text-muted); }

/* ── Main ───────────────────────────────────────────────────── */
main { max-width: 1600px; margin: 0 auto; padding: 1.5rem 1rem; }

/* ── Controls Row ───────────────────────────────────────────── */
.controls-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.search-input,
.sort-select {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input { flex: 1; min-width: 200px; }
.search-input:focus,
.sort-select:focus { border-color: var(--accent); }

.sort-select option { background: var(--bg-panel); }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.leaderboard {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: fixed;
}

.leaderboard thead tr {
  background: #0d1a0a;
  border-bottom: 2px solid var(--accent-dim);
}

.leaderboard th {
  padding: 0.65rem 0.75rem;
  text-align: right;
  color: var(--text-heading);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
  cursor: default;
  user-select: none;
}

.leaderboard th.col-player,
.leaderboard th.col-rank { text-align: left; }

.leaderboard th.sortable { cursor: pointer; }
.leaderboard th.sortable:hover { color: var(--accent); }
.leaderboard th.sort-asc::after  { content: ' ▲'; color: var(--accent); }
.leaderboard th.sort-desc::after { content: ' ▼'; color: var(--accent); }

.leaderboard tbody tr {
  border-bottom: 1px solid #1a1a1a;
  transition: background 0.15s;
}

.leaderboard tbody tr:nth-child(even) { background: var(--bg-row-alt); }
.leaderboard tbody tr:nth-child(odd)  { background: var(--bg-row); }
.leaderboard tbody tr:hover           { background: var(--bg-hover); }

.leaderboard td {
  padding: 0.55rem 0.75rem;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard td.col-rank { text-align: left; color: var(--text-muted); font-family: var(--font-mono); width: 40px; }
.leaderboard td.col-player { text-align: left; }

/* Column widths */
.col-rank    { width: 40px; }
.col-player  { width: 180px; }
.col-num     { width: 70px; }
.col-text    { width: 110px; }

.player-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.player-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  object-fit: cover;
  flex-shrink: 0;
}

.player-name {
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-name:hover { text-decoration: underline; }

.kd-high  { color: var(--accent); font-weight: bold; }
.kd-low   { color: var(--danger); }

.loading-row { text-align: center; color: var(--text-muted); padding: 2rem; }

/* ── Charts Section ─────────────────────────────────────────── */
.charts-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.chart-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.chart-card h2 {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  color: var(--text-heading);
  text-transform: uppercase;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  box-shadow: 0 0 40px rgba(106,191,69,0.12);
  max-width: 860px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1rem;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.modal-close:hover { color: var(--danger); border-color: var(--danger); }

.modal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.modal-avatar {
  width: 72px;
  height: 72px;
  border-radius: 4px;
  border: 2px solid var(--accent-dim);
  object-fit: cover;
}

.modal-header-info { flex: 1; }
.modal-header-info h2 { font-size: 1.4rem; color: var(--accent); }

.modal-faction,
.modal-last-active {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  margin-right: 0.75rem;
}

.btn-steam {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #1b2838;
  color: #c7d5e0;
  border: 1px solid #2a475e;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.8rem;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-steam:hover { background: #2a475e; }

/* Stats grid */
.modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-box {
  background: var(--bg-row);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
}

.stat-box .stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
}

.stat-box .stat-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--text-primary);
}

.stat-box.highlight .stat-value { color: var(--accent); }

/* Modal charts */
.modal-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.modal-chart-wrap h3 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-heading);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

/* Weapon kills list */
.weapon-kills-list { display: flex; flex-direction: column; gap: 0.4rem; }

.weapon-kill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius);
  background: var(--bg-row);
  border: 1px solid var(--border);
}

.weapon-kill-row .wk-name  { color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weapon-kill-row .wk-count { color: var(--accent); font-family: var(--font-mono); font-weight: bold; flex-shrink: 0; margin-left: 0.5rem; }
.weapon-kill-row.top-weapon { border-color: var(--accent-dim); background: #1a2a12; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }

  .modal-charts-row { grid-template-columns: 1fr; }

  .site-title { font-size: 1.2rem; }

  .chart-card { padding: 1rem; }

  .modal { padding: 1rem; }
}
