@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;700;900&family=Outfit:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --bg:        #06080d;
  --bg-2:      #0c1018;
  --bg-3:      #141b26;
  --border:    rgba(255,255,255,0.06);
  --border-hi: rgba(255,255,255,0.12);
  --text:      #dde4f0;
  --text-dim:  #8796b0;
  --text-muted:#4a5870;
  --accent:    #f59e0b;
  --accent-lo: rgba(245,158,11,0.12);
  --accent-glow: rgba(245,158,11,0.25);
  --win:       #22c55e;
  --win-lo:    rgba(34,197,94,0.12);
  --loss:      #ef4444;
  --loss-lo:   rgba(239,68,68,0.12);
  --gold:      #fbbf24;
  --silver:    #94a3b8;
  --bronze:    #c97c3a;
  --radius:    8px;
  --radius-lg: 14px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* NAV */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 60px;
  background: rgba(6,8,13,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: var(--text);
}
.nav-logo span { color: var(--accent); }

.nav-links { display: flex; gap: 28px; }
.nav-links a {
  text-decoration: none;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--text); }

/* MAIN LAYOUT */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* HERO */
.hero {
  padding: 52px 0 36px;
  text-align: center;
}
.hero-eyebrow {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  letter-spacing: 0.25em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 14px;
}
.hero h1 {
  font-family: 'Orbitron', monospace;
  font-size: clamp(32px, 6vw, 56px);
  font-weight: 900;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 10px;
}
.hero h1 span { color: var(--accent); }
.hero-sub {
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 400;
}

/* SEARCH */
.search-wrap {
  max-width: 420px;
  margin: 28px auto 0;
  position: relative;
}
.search-wrap input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border-hi);
  border-radius: 99px;
  padding: 11px 20px 11px 44px;
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-wrap input::placeholder { color: var(--text-muted); }
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-lo);
}
.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* TABS */
.tabs-wrap {
  margin: 40px 0 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-wrap::-webkit-scrollbar { display: none; }
.tabs {
  display: flex;
  gap: 2px;
  width: max-content;
  min-width: 100%;
}
.tab-btn {
  background: none;
  border: none;
  padding: 12px 20px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: color 0.2s;
}
.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.2s;
  border-radius: 2px 2px 0 0;
}
.tab-btn:hover { color: var(--text-dim); }
.tab-btn.active { color: var(--text); }
.tab-btn.active::after { transform: scaleX(1); }

/* TABLE */
.table-wrap {
  margin: 28px 0 60px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  padding: 13px 18px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
}
thead th:first-child { width: 52px; text-align: center; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  cursor: pointer;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }

tbody td {
  padding: 13px 18px;
  font-size: 14px;
}
tbody td:first-child { text-align: center; }

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-3);
  color: var(--text-muted);
}
.rank-1 .rank-badge { background: rgba(251,191,36,0.15); color: var(--gold); }
.rank-2 .rank-badge { background: rgba(148,163,184,0.12); color: var(--silver); }
.rank-3 .rank-badge { background: rgba(201,124,58,0.12); color: var(--bronze); }
.rank-1 { border-left: 2px solid var(--gold); }
.rank-2 { border-left: 2px solid var(--silver); }
.rank-3 { border-left: 2px solid var(--bronze); }

.player-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.player-head {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  image-rendering: pixelated;
}
.player-name {
  font-weight: 600;
  color: var(--text);
}

.rating-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
}

.wl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-dim);
}
.wl .w { color: var(--win); }
.wl .l { color: var(--loss); }

.winrate-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}
.winrate-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-3);
  border-radius: 99px;
  overflow: hidden;
}
.winrate-fill {
  height: 100%;
  background: var(--win);
  border-radius: 99px;
  transition: width 0.4s ease;
}
.winrate-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
  min-width: 38px;
}

.kit-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-3);
  color: var(--text-dim);
}

/* LOADING / EMPTY */
.loading-row td, .empty-row td {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 14px;
}
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border-hi);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* PLAYER PAGE */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  margin: 28px 0 0;
  transition: color 0.2s;
}
.back-link:hover { color: var(--accent); }

.profile-hero {
  display: flex;
  align-items: flex-end;
  gap: 28px;
  padding: 40px 0 36px;
  border-bottom: 1px solid var(--border);
}
.profile-skin {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  image-rendering: pixelated;
  border: 2px solid var(--border-hi);
}
.profile-info { flex: 1; }
.profile-username {
  font-family: 'Orbitron', monospace;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.profile-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.profile-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.profile-stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}
.profile-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}
.profile-stat-value.accent { color: var(--accent); }

/* KIT CARDS */
.kit-cards {
  display: flex;
  gap: 12px;
  padding: 28px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.kit-cards::-webkit-scrollbar { display: none; }
.kit-card {
  flex-shrink: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  min-width: 120px;
}
.kit-card:hover { border-color: var(--border-hi); background: var(--bg-3); }
.kit-card.active {
  border-color: var(--accent);
  background: var(--accent-lo);
}
.kit-card-name {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.kit-card.active .kit-card-name { color: var(--accent); }
.kit-card-rating {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}
.kit-card-wl {
  font-size: 12px;
  color: var(--text-muted);
}

/* CHART */
.chart-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}
.section-title {
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 20px;
}
#eloChart { width: 100% !important; }

/* MATCH HISTORY */
.matches-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 60px;
}
.matches-section .section-title {
  padding: 20px 24px 0;
}
.match-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 24px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.match-row:last-child { border-bottom: none; }
.match-row:hover { background: rgba(255,255,255,0.02); }
.match-result {
  width: 42px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 0;
  border-radius: 4px;
  flex-shrink: 0;
}
.match-result.win { background: var(--win-lo); color: var(--win); }
.match-result.loss { background: var(--loss-lo); color: var(--loss); }
.match-vs { color: var(--text-muted); font-size: 12px; flex-shrink: 0; }
.match-opponent {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
  cursor: pointer;
  transition: color 0.15s;
}
.match-opponent:hover { color: var(--accent); }
.match-rating {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-dim);
}
.match-time {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 70px;
  text-align: right;
}

/* NO KIT STATE */
.no-kit {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

/* RESPONSIVE */
@media (max-width: 640px) {
  nav { padding: 0 16px; }
  .container { padding: 0 16px; }
  .hero h1 { font-size: 30px; }
  .tab-btn { padding: 12px 14px; font-size: 13px; }
  thead th, tbody td { padding: 11px 12px; }
  .winrate-wrap { display: none; }
  .profile-hero { flex-direction: column; align-items: flex-start; }
}