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

:root {
  --bg: #0f0f13;
  --surface: #1a1a22;
  --surface2: #22222e;
  --border: #2e2e3e;
  --text: #e8e8f0;
  --muted: #888899;
  --red: #e05555;
  --blue: #4a90d9;
  --gold: #f0b429;
  --green: #4caf7d;
  --accent: #7c5cbf;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--gold);
  text-decoration: none;
}

.nav-links { display: flex; gap: 1.5rem; }
.nav-links a { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
.nav-links a:hover { color: var(--text); text-decoration: none; }

.nav-search { display: flex; align-items: center; gap: 0; }
.nav-search input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 6px 0 0 6px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  outline: none;
  width: 160px;
  transition: border-color 0.15s;
}
.nav-search input:focus { border-color: var(--accent); }
.nav-search input::placeholder { color: var(--muted); }
.nav-search button {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 0 6px 6px 0;
  color: #fff;
  font-size: 0.9rem;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  line-height: 1;
}
.nav-search button:hover { opacity: 0.85; }

/* Main */
main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  background: var(--surface2);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  text-align: left;
}

td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

tr:hover td { background: rgba(255,255,255,0.02); }

.empty { color: var(--muted); text-align: center; padding: 2rem; }

/* Page header */
.page-header { margin-bottom: 1.25rem; }
.page-header h1, .page-header h2 { font-size: 1.5rem; font-weight: 700; }

/* Avatar */
.avatar {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 8px;
  image-rendering: pixelated;
}

.player-head {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  image-rendering: pixelated;
}

/* Teams */
.team-red { color: var(--red); }
.team-blue { color: var(--blue); }

/* Match header */
.match-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.match-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
}

.score-side {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.score-side small { font-size: 0.9rem; font-weight: 500; color: var(--muted); }

.map-name { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.4rem; }
.match-winner { color: var(--muted); margin-bottom: 0.25rem; }
.match-date { color: var(--muted); font-size: 0.85rem; }

/* Top stats */
.top-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.top-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.top-stat-icon { font-size: 1.6rem; line-height: 1; }

.top-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.top-stat-player {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
}

.top-stat-value {
  font-size: 0.82rem;
  color: var(--gold);
  font-weight: 600;
}

/* Teams layout */
.teams { display: flex; flex-direction: column; gap: 1rem; }

.team-title {
  padding: 0.9rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  background: var(--surface2);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avg-elo { color: var(--muted); font-weight: 400; font-size: 0.85rem; }

.winner-badge {
  background: var(--gold);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-left: auto;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ELO colors */
.elo-gain { color: var(--green); }
.elo-loss { color: var(--red); }

/* Player page */
.player-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem;
}

.player-header > .player-head {
  flex-shrink: 0;
  align-self: center;
}

.player-info { flex: 1; }
.player-info h1 { font-size: 1.6rem; margin-bottom: 0.6rem; }

.player-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.player-elo-block {
  text-align: right;
  flex-shrink: 0;
  align-self: flex-start;
}

.player-elo { font-size: 1.1rem; color: var(--gold); font-weight: 600; }

.player-stats-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.stat-box .label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.2rem; }
.stat-box .value { font-size: 1.2rem; font-weight: 700; }

/* Not found */
.not-found { text-align: center; padding: 4rem; }
.not-found h2 { margin-bottom: 1rem; color: var(--muted); }

/* Rank badges */
.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid;
  border-radius: 5px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-sm {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
}

.badge-lg {
  font-size: 1rem;
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
}

.badge-icon { font-size: 0.9em; }

/* Rank grid page */
.rank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.rank-card {
  border: 1px solid;
  border-radius: 12px;
  padding: 1.5rem 1rem;
  text-align: center;
}

.rank-card-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.rank-card-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.3rem; }
.rank-card-range { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.5rem; }
.rank-card-players { font-size: 0.8rem; color: var(--muted); }

/* Match cards (recent matches on profile) */
.match-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.match-card {
  border-radius: 10px;
  padding: 1rem 0.75rem;
  text-align: center;
  border: 1px solid var(--border);
}

.match-win { background: rgba(76, 175, 125, 0.08); border-color: rgba(76, 175, 125, 0.3); }
.match-loss { background: rgba(224, 85, 85, 0.08); border-color: rgba(224, 85, 85, 0.3); }

.match-card-result { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.4rem; }
.match-win .match-card-result { color: var(--green); }
.match-loss .match-card-result { color: var(--red); }
.match-card-map { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-card-kd { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
.match-card-elo { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; }
.match-card-time { font-size: 0.7rem; color: var(--muted); }

/* Profile two-column grid */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Section title inside a card */
.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}

/* Stat list rows (like the screenshot) */
.stat-section { padding: 1.25rem; }

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.stat-row:last-child { border-bottom: none; }

.stat-row-label { color: var(--muted); }

.stat-row-value { font-weight: 600; }

/* Owner badge — same size as rank badge-lg */
.owner-badge-lg {
  color: #f87171 !important;
  background: rgba(224, 85, 85, 0.12) !important;
  border-color: rgba(224, 85, 85, 0.5) !important;
}

/* Player rank position (#1, #2 ...) */
.player-rank-pos {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 0.25rem;
  display: block;
}

/* Player header */
.player-head-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}


@media (max-width: 700px) {
  .match-score { gap: 1.5rem; }
  .score-side { font-size: 1.8rem; }
  .player-header { flex-direction: column; }
  .profile-grid { grid-template-columns: 1fr; }
  nav { padding: 0 1rem; }
  main { padding: 1rem; }
}
