*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  background: #0f1117;
  color: #e2e8f0;
  min-height: 100vh;
}

/* ── Header ── */
header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid #1e2433;
}

/* ── Page nav (Table / Visualize) ── */
.page-nav { display:flex; gap:8px; margin-top:14px; }
.page-nav a {
  font-size:14px; font-weight:700;
  padding:8px 24px; border-radius:8px;
  border:1px solid #2a3347;
  color:#64748b; text-decoration:none;
  transition:all .15s;
  letter-spacing:0.02em;
  text-transform:uppercase;
}
.page-nav a:hover { border-color:#3b82f6; color:#93c5fd; background:#0d1928; }
.page-nav a.active {
  background:#1e3a5f; border-color:#2563eb; color:#93c5fd;
  box-shadow:0 0 0 1px #1d4ed8;
}
header h1 {
  font-size: 18px;
  font-weight: 600;
  color: #f8fafc;
  letter-spacing: -0.01em;
}
#meta {
  margin-top: 4px;
  font-size: 11px;
  color: #64748b;
}

/* ── Filter bar ── */
#filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0;
  padding: 12px 24px;
  border-bottom: 1px solid #1e2433;
  background: #0d1018;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 16px 4px 0;
}

.filter-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #475569;
}

.filter-divider {
  width: 1px;
  background: #1e2433;
  margin: 0 16px 0 0;
  align-self: stretch;
  min-height: 40px;
}

/* ── Chips ── */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid #2a3347;
  background: transparent;
  color: #64748b;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.chip:hover { border-color: #3b4f6a; color: #94a3b8; }
.chip.active {
  background: #1e3a5f;
  border-color: #2563eb;
  color: #93c5fd;
}
.chip[data-on="true"] {
  background: #1e3a5f;
  border-color: #2563eb;
  color: #93c5fd;
}

/* ── Player filter ── */
.player-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  max-width: 480px;
}

#player-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.player-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 10px;
  background: #1e3a5f;
  border: 1px solid #2563eb;
  border-radius: 20px;
  font-size: 11px;
  color: #93c5fd;
  white-space: nowrap;
}
.player-tag.is-fav { background: #2d2a00; border-color: #ca8a04; color: #fde68a; }
.player-tag button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  opacity: 0.7;
}
.player-tag button:hover { opacity: 1; }

.player-search-wrap {
  position: relative;
}
#player-search {
  background: #141820;
  border: 1px solid #2a3347;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 12px;
  padding: 4px 10px;
  width: 180px;
  outline: none;
}
#player-search:focus { border-color: #3b82f6; }
#player-search::placeholder { color: #475569; }

.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  background: #141e2e;
  border: 1px solid #2a3347;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 100;
  max-height: 280px;
  overflow-y: auto;
}
.dropdown-section {
  padding: 6px 0 2px;
}
.dropdown-section-label {
  padding: 2px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #475569;
}
.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  cursor: pointer;
  gap: 8px;
}
.dropdown-item:hover { background: #1e2d45; }
.dropdown-item.selected { color: #60a5fa; }
.dropdown-item .di-name { flex: 1; font-size: 12px; }
.dropdown-item .di-rank { font-size: 11px; color: #475569; }
.dropdown-item .di-star {
  font-size: 13px;
  opacity: 0.4;
  cursor: pointer;
  padding: 0 2px;
}
.dropdown-item .di-star:hover { opacity: 1; }
.dropdown-item .di-star.active { opacity: 1; }

/* ── Date range ── */
.date-range {
  display: flex;
  align-items: center;
  gap: 6px;
}
.date-sep { color: #475569; font-size: 11px; }
.date-range select {
  background: #141820;
  border: 1px solid #2a3347;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 11px;
  padding: 4px 6px;
  outline: none;
  cursor: pointer;
}
.date-range select:focus { border-color: #3b82f6; }

/* ── Reset ── */
.reset-btn {
  align-self: flex-end;
  margin-left: auto;
  padding: 4px 12px;
  background: none;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #64748b;
  font-size: 11px;
  cursor: pointer;
}
.reset-btn:hover { border-color: #ef4444; color: #f87171; }

/* ── Status bar ── */
#row-count {
  padding: 6px 24px;
  font-size: 11px;
  color: #475569;
  border-top: 1px solid #141820;
}

/* ── Loading / error ── */
#loading, #error {
  padding: 40px 24px;
  color: #64748b;
}
#error { color: #f87171; }

/* ── Table ── */
.scroll-x {
  overflow-x: auto;
  width: 100%;
}

table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
}

thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #0f1117;
}

th {
  padding: 8px 10px;
  text-align: right;
  font-weight: 500;
  font-size: 11px;
  color: #64748b;
  border-bottom: 1px solid #1e2433;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
th:hover { color: #94a3b8; }
th.sorted { color: #60a5fa; }

th.col-rank, th.col-name { text-align: left; }
th.col-rank { width: 48px; }
th.col-name {
  position: sticky;
  left: 0;
  background: #0f1117;
  z-index: 11;
  min-width: 160px;
}

td {
  padding: 6px 10px;
  text-align: right;
  border-bottom: 1px solid #141820;
  white-space: nowrap;
}
td.col-rank { color: #64748b; font-size: 11px; }
td.col-name {
  text-align: left;
  position: sticky;
  left: 0;
  background: #0f1117;
  font-weight: 500;
  color: #f1f5f9;
  z-index: 5;
}
td.col-name .star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  margin-right: 4px;
  opacity: 0.25;
  vertical-align: middle;
  padding: 0;
  line-height: 1;
}
td.col-name .star-btn:hover { opacity: 0.7; }
td.col-name .star-btn.active { opacity: 1; }

tr:hover td { background: #141e2e; }
tr:hover td.col-name { background: #141e2e; }

td.pts-total { font-weight: 600; color: #f1f5f9; }
td.pts-total.filtered { color: #60a5fa; }

td.pts-tourney { color: #94a3b8; }
td.pts-tourney.has-pts { color: #e2e8f0; }

td.tier-gs  { color: #fbbf24; }
td.tier-m   { color: #34d399; }
td.tier-500 { color: #60a5fa; }
td.tier-250 { color: #a78bfa; }
td.tier-f   { color: #f472b6; }

td.empty { color: #1e2433; }

/* ── Column header two-line ── */
th .th-label { display: inline; }
th.col-tourney .th-label {
  display: block;
  line-height: 1.3;
}
.th-date {
  display: block;
  font-size: 10px;
  color: #475569;
  font-weight: 400;
  line-height: 1.2;
  margin-top: 1px;
}
th.sorted .th-date { color: #3b82f6; }

.sort-arrow {
  display: inline-block;
  margin-left: 3px;
  opacity: 0.4;
  font-size: 9px;
}
th.sorted .sort-arrow { opacity: 1; }
