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

/* ── Design tokens ── */
:root {
  --bg:       #0D0F14;
  --bg2:      #13161E;
  --bg3:      #1A1E29;
  --bg-row:   #111420;
  --border:   rgba(255,255,255,0.06);
  --border2:  rgba(255,255,255,0.1);
  --text:     #EAE8E0;
  --muted:    #6B6E7A;
  --accent:   #C8F060;
  --green:    #3ECFA0;
  --red:      #F05C5C;
  --purple:   #8B7FF5;
  --orange:   #F0924A;
  --blue:     #4AB4F0;
  --font:     'Syne', sans-serif;
  --mono:     'DM Mono', monospace;
}

/* ── Base ── */
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

/* ── Player stats: variable overrides ── */
body.page-player {
  --muted:  #7A7D8A;
  --border: rgba(255,255,255,0.07);
}

/* ── Gedeelde layout ── */
.wrap {
  position: relative;
  z-index: 1;
  padding: 2.5rem 2rem;
}

/* ── Select (gemeenschappelijke basis) ── */
select {
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

/* ════════════════════════════════════════════
   Index pagina  (body.page-index)
   ════════════════════════════════════════════ */

body.page-index::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

body.page-index select {
  background: var(--bg2);
  border: 1px solid var(--border2);
}
body.page-index select:hover,
body.page-index select:focus { border-color: var(--accent); }

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 2.5rem;
}
.logo-line {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 6px;
}
.logo {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
}
.site-nav { display: flex; gap: 4px; }
.site-nav a {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 3px 10px;
  border-radius: 100px;
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.site-nav a:hover { color: var(--text); border-color: var(--border2); }
.site-nav a.active { color: var(--accent); border-color: rgba(200,240,96,0.25); }
h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}
h1 span { color: var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.total-badge {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--muted);
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 6px;
}
.total-badge strong { color: var(--text); }

.table-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead tr {
  background: var(--bg3);
  border-bottom: 1px solid var(--border2);
}

th {
  padding: 13px 18px;
  text-align: left;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.15s;
}
th:hover { color: var(--text); }
th.active { color: var(--accent); }

.sort-icon {
  display: inline-block;
  margin-left: 5px;
  font-size: 10px;
  opacity: 0.4;
  transition: opacity 0.15s, transform 0.15s;
}
th.active .sort-icon { opacity: 1; }
th.active.asc .sort-icon { transform: rotate(180deg); }

.surf-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  animation: rowIn 0.3s ease both;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }

@keyframes rowIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: none; }
}

td {
  padding: 13px 18px;
  font-size: 14px;
  vertical-align: middle;
}

.td-rank {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  width: 40px;
}

.td-name a {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  transition: color 0.15s;
}
.td-name a:hover { color: var(--accent); }
.td-matches {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 2px;
}

.td-pct { text-align: right; }
.pct-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 70px;
}
.pct-num {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
}
.pct-bar {
  width: 60px;
  height: 3px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}
.pct-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.null-cell {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--bg3);
  text-align: right;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.page-btn {
  background: var(--bg2);
  border: 1px solid var(--border2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  padding: 7px 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 38px;
  text-align: center;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.page-btn.active { background: var(--accent); color: #0D0F14; border-color: var(--accent); font-weight: 700; }
.page-btn:disabled { opacity: 0.3; cursor: default; }
.page-ellipsis { color: var(--muted); font-family: var(--mono); font-size: 13px; padding: 0 4px; }

.skeleton-row td { padding: 16px 18px; }
.skel {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg2) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.empty {
  padding: 4rem;
  text-align: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
}

/* ════════════════════════════════════════════
   Player stats pagina  (body.page-player)
   ════════════════════════════════════════════ */

body.page-player select {
  background: var(--bg3);
  border: 1px solid var(--border);
}
body.page-player select:hover { border-color: var(--accent); }

#loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60vh;
  font-size: 14px;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.05em;
}
#loading span { animation: blink 1.2s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }

#dashboard { display: none; }

.header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.avatar {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #0D0F14;
  flex-shrink: 0;
}
.player-name { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.player-sub  { font-size: 13px; color: var(--muted); margin-top: 3px; font-family: var(--mono); }

.filters {
  margin-left: auto;
  display: flex;
  gap: 10px;
}

/* ── Filter chips ────────────────────────────────────────────────────────── */
.filter-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.filter-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.filter-sep {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,0.12);
  flex-shrink: 0;
}
.filter-chip {
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid var(--chip-color, rgba(255,255,255,0.2));
  background: transparent;
  color: var(--chip-color, var(--muted));
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.filter-chip:hover {
  background: rgba(255,255,255,0.07);
}
.filter-chip.active {
  background: var(--chip-color, rgba(255,255,255,0.85));
  border-color: var(--chip-color, rgba(255,255,255,0.85));
  color: #13161E;
  font-weight: 500;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}
.kpi {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--kpi-color, var(--border));
}
.kpi:hover { border-color: var(--kpi-color, var(--border)); }
.kpi-label { font-size: 11px; color: var(--muted); font-family: var(--mono); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 8px; }
.kpi-value { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; color: var(--kpi-color, var(--text)); }

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}
.card-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.surface-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.donut-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  flex-shrink: 0;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.donut-center-pct  { font-size: 22px; font-weight: 700; color: var(--accent); }
.donut-center-label { font-size: 10px; color: var(--muted); font-family: var(--mono); letter-spacing: 0.05em; }
.surface-legend { flex: 1; }
.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.legend-info { flex: 1; }
.legend-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.legend-name { color: var(--text); font-weight: 500; }
.legend-score { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.legend-bar { background: var(--bg3); border-radius: 2px; height: 3px; }
.legend-fill { height: 100%; border-radius: 2px; transition: width 0.6s ease; }

.geo-list { display: flex; flex-direction: column; gap: 6px; }
.geo-continent {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
  cursor: pointer;
}
.geo-continent.open { border-color: var(--geo-color); }
.geo-cont-header {
  display: grid;
  grid-template-columns: 130px 1fr 110px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  transition: background 0.2s;
}
.geo-continent.open .geo-cont-header { background: color-mix(in srgb, var(--geo-color) 10%, transparent); }
.geo-cont-name { font-size: 13px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.geo-chevron { font-size: 10px; color: var(--muted); transition: transform 0.2s; }
.geo-continent.open .geo-chevron { transform: rotate(90deg); }
.geo-bar-wrap { background: var(--bg3); border-radius: 3px; height: 5px; }
.geo-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.geo-score { font-size: 12px; color: var(--muted); font-family: var(--mono); text-align: right; }

.geo-countries { display: none; border-top: 1px solid var(--border); }
.geo-continent.open .geo-countries { display: block; }
.geo-country-row {
  display: grid;
  grid-template-columns: 130px 1fr 110px;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 8px 30px;
  border-bottom: 1px solid var(--border);
}
.geo-country-row:last-child { border-bottom: none; }
.geo-country-name { font-size: 12px; color: var(--muted); }

.month-wrap { position: relative; width: 100%; height: 240px; }

.fade-in {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeUp 0.4s ease forwards;
}
@keyframes fadeUp { to { opacity: 1; transform: none; } }
.fade-in:nth-child(1) { animation-delay: 0s; }
.fade-in:nth-child(2) { animation-delay: 0.05s; }
.fade-in:nth-child(3) { animation-delay: 0.1s; }
.fade-in:nth-child(4) { animation-delay: 0.15s; }

/* ── History grid (toernooien + wedstrijden) ── */
.history-grid {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  align-items: flex-start;
}

.history-card {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.history-card-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 1.25rem;
}
.history-card-header .card-title { margin-bottom: 0; }

.hist-table-wrap { overflow-x: auto; }

.hist-table {
  width: 100%;
  border-collapse: collapse;
}
.hist-table th {
  cursor: default;
  padding: 9px 14px;
}
.hist-table td {
  padding: 10px 14px;
  font-size: 13px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.hist-table tbody tr:last-child td { border-bottom: none; }

.hist-row {
  cursor: pointer;
  transition: background 0.15s;
}
.hist-row:hover { background: var(--bg3); }

.hist-active td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.hist-active td:first-child { border-left: 2px solid var(--accent); padding-left: 12px; }

.hist-td-name  { font-weight: 600; color: var(--text); }
.hist-sub      { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 2px; font-weight: 400; }
.hist-muted    { color: var(--muted); }
.hist-mono     { font-family: var(--mono); }
.hist-result   { text-align: right; font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.hist-score    { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

.wl-won  { color: var(--green); }
.wl-sep  { color: var(--muted); }
.wl-lost { color: var(--red); }

.surf-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid;
  white-space: nowrap;
}

.res-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}
.res-won  { background: rgba(62,207,160,0.12); color: var(--green); }
.res-lost { background: rgba(240,92,92,0.12);  color: var(--red); }

.hist-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding-top: 0.75rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.hist-clear {
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  line-height: 1.6;
}
.hist-clear:hover { color: var(--text); border-color: var(--text); }

/* ════════════════════════════════════════════
   Head-to-Head pagina  (body.page-h2h)
   ════════════════════════════════════════════ */

body.page-h2h {
  --muted: #7A7D8A;
  --border: rgba(255,255,255,0.07);
}
/* ── Tom Select theme ── */
body.page-h2h .ts-wrapper { width: 220px; }
body.page-h2h .ts-control {
  background: var(--bg3) !important;
  border: 1px solid var(--border2) !important;
  border-radius: 8px !important;
  color: var(--text) !important;
  font-family: var(--font);
  font-size: 14px;
  padding: 6px 10px !important;
  box-shadow: none !important;
  cursor: pointer;
}
body.page-h2h .ts-control:hover,
body.page-h2h .ts-wrapper.focus .ts-control { border-color: var(--accent) !important; }
body.page-h2h .ts-dropdown {
  background: var(--bg3) !important;
  border: 1px solid var(--border2) !important;
  border-radius: 8px !important;
  color: var(--text) !important;
  font-family: var(--font);
  font-size: 14px;
  margin-top: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5) !important;
}
body.page-h2h .ts-dropdown .option { padding: 8px 12px; color: var(--text); }
body.page-h2h .ts-dropdown .option:hover,
body.page-h2h .ts-dropdown .option.active { background: rgba(200,240,96,0.12) !important; color: var(--accent) !important; }
body.page-h2h .ts-dropdown .option.selected { color: var(--accent); }
body.page-h2h .ts-dropdown-content { max-height: 260px; }
body.page-h2h .ts-wrapper .ts-control input { color: var(--text) !important; font-family: var(--font); font-size: 14px; background: transparent !important; }
body.page-h2h .ts-wrapper .ts-control input::placeholder { color: var(--muted); }

/* ── Player comparison header ── */
.h2h-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 2rem;
  margin-bottom: 1.5rem;
}
.h2h-player {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.h2h-p1 { align-items: flex-start; }
.h2h-p2 { align-items: flex-end; text-align: right; }

.h2h-pname {
  font-family: var(--font);
  font-size: clamp(1.25rem, 2.5vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}
.h2h-p1 .h2h-pname { color: var(--accent); }
.h2h-p2 .h2h-pname { color: var(--purple); }
.h2h-pname.placeholder { color: var(--muted); font-weight: 400; font-size: 1rem; }

.h2h-record {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.h2h-record-nums {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font);
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}
.h2h-record-nums .p1c { color: var(--accent); }
.h2h-record-nums .p2c { color: var(--purple); }
.h2h-record-nums .dash { color: var(--border2); font-size: 0.6em; }
.h2h-record-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.h2h-no-data {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  margin-top: 0.5rem;
}

/* ── Surface H2H bars ── */
.h2h-surf-row {
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.h2h-surf-row:last-child { margin-bottom: 0; }
.h2h-surf-bar {
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg3);
  display: flex;
}
.h2h-surf-bar-p1 { background: var(--accent); transition: width 0.4s ease; }
.h2h-surf-bar-p2 { background: var(--purple); transition: width 0.4s ease; flex: 1; }
.h2h-surf-nums {
  font-family: var(--mono);
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

/* ── Year chart ── */
.h2h-year-wrap { position: relative; width: 100%; height: 220px; }

/* ── Match table ── */
.h2h-winner-cell {
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
}
