/* Pet Soccer Stats — Design System matching the game's art direction */
/* Based on: metallic beveled rings, gradient discs, text-on-arc, emblems, laurels, crowns, glass glare */

:root {
  /* Core palette from game assets */
  --bg: #0d1018;
  --bg-deep: #07090e;
  --card: #141824;
  --card-elevated: #1a1f2e;
  --border: #2a2f3e;
  --border-bright: #3a4052;

  /* Metallic colors from ring bevels */
  --metal-light: #e1e2e8;
  --metal-mid: #a8abb8;
  --metal-dark: #4a4d58;
  --metal-rim: #282a2c;

  /* Gold (laurels, crown, Or rank) */
  --gold-light: #fff4a0;
  --gold-mid: #ecba28;
  --gold-dark: #8c5800;
  --gold-rim: #5a3a00;

  /* Accent colors by rank */
  --bois: #a67c52;
  --bois-light: #e2c08c;
  --bois-dark: #543a20;
  --bronze: #cd7f32;
  --bronze-light: #ffcc96;
  --bronze-dark: #6e3f14;
  --argent: #c0c0c0;
  --argent-light: #fff;
  --argent-dark: #686e7e;
  --or: #ffd700;
  --or-light: #fff4a0;
  --or-dark: #783c0c;
  --platine: #78e6cc;
  --platine-light: #e1fff8;
  --platine-dark: #188c74;
  --diamant: #70a6ff;
  --diamant-light: #dce6ff;
  --diamant-dark: #1842c8;
  --challenger: #e654d6;
  --challenger-light: #ffc4fa;
  --challenger-dark: #681256;

  /* Result colors */
  --win: #3dba78;
  --loss: #e74c5a;
  --draw: #f5a623;

  /* Text */
  --text: #d8dce8;
  --text-dim: #8a92a8;
  --text-muted: #5a6278;
  --white: #fff;

  /* Shadows */
  --shadow-soft: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-hard: 0 2px 8px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 32px rgba(236,186,40,0.15);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 350ms ease;
}

/* CSS Custom Properties for team colors (set via inline style) */
.team-badge { --team-color: var(--text); }
.team-badge .team-color-indicator { background: var(--team-color); }

/* Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Georgia', 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(236,186,40,0.03) 0%, transparent 60%),
    radial-gradient(circle at 20% 80%, rgba(112,166,255,0.02) 0%, transparent 50%);
}

/* Typography */
h1, h2, h3, h4, h5, h6 { font-family: 'Georgia', serif; font-weight: 700; color: var(--white); }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); letter-spacing: 0.5px; }
h2 { font-size: clamp(1.25rem, 3vw, 1.5rem); letter-spacing: 0.3px; }
h3 { font-size: 1rem; font-weight: 600; }
p { color: var(--text-dim); }
a { color: var(--gold-mid); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--gold-light); text-decoration: underline; }
strong { color: var(--white); }

/* Layout */
.nav {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-elevated) 100%);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-soft);
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Georgia', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.5px;
  text-decoration: none;
}
.nav-brand:hover { color: var(--gold-light); text-decoration: none; }
.nav-brand svg { width: 36px; height: 36px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
.nav-brand span:last-child { color: var(--gold-mid); }
.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-link {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
}
.nav-link:hover, .nav-link.active {
  color: var(--white);
  border-bottom-color: var(--gold-mid);
  background: rgba(236,186,40,0.1);
  text-decoration: none;
}
.nav-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 24px;
  padding-left: 24px;
  border-left: 1px solid var(--border);
}
.nav-search input {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  color: var(--text);
  font-size: 0.9rem;
  width: 220px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.nav-search input:focus { outline: none; border-color: var(--gold-mid); box-shadow: 0 0 0 3px rgba(236,186,40,0.15); }
.nav-search input::placeholder { color: var(--text-muted); }

.container { max-width: 1200px; margin: 0 auto; padding: 28px 20px; }

/* Cards — metallic ring aesthetic */
.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-elevated) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  position: relative;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-mid), transparent);
  opacity: 0.6;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.card-title { font-size: 1.125rem; font-weight: 700; color: var(--white); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; padding: 12px 14px; color: var(--text-muted); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; border-bottom: 1px solid var(--border); background: rgba(0,0,0,0.2); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; transition: background var(--transition-fast); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
tr td:first-child { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
tr td:last-child { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }

/* Rank badge — game-style metallic badge */
.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}
.rank-badge::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--badge-rim-light), var(--badge-rim-dark));
  z-index: -1;
  opacity: 0.8;
}
.rank-badge img { width: 24px; height: 24px; border-radius: 50%; box-shadow: var(--shadow-hard); }

/* Rank colors for CSS badges (fallback when no image) */
.rank-bois { --badge-rim-light: var(--bois-light); --badge-rim-dark: var(--bois-dark); background: linear-gradient(135deg, var(--bois-light) 0%, var(--bois) 50%, var(--bois-dark) 100%); color: #fff; }
.rank-bronze { --badge-rim-light: var(--bronze-light); --badge-rim-dark: var(--bois-dark); background: linear-gradient(135deg, var(--bronze-light) 0%, var(--bronze) 50%, var(--bois-dark) 100%); color: #fff; }
.rank-argent { --badge-rim-light: var(--argent-light); --badge-rim-dark: var(--argent-dark); background: linear-gradient(135deg, var(--argent-light) 0%, var(--argent) 50%, var(--argent-dark) 100%); color: #1a1a1a; }
.rank-or { --badge-rim-light: var(--or-light); --badge-rim-dark: var(--or-dark); background: linear-gradient(135deg, var(--or-light) 0%, var(--or) 50%, var(--or-dark) 100%); color: #1a1a1a; }
.rank-platine { --badge-rim-light: var(--platine-light); --badge-rim-dark: var(--platine-dark); background: linear-gradient(135deg, var(--platine-light) 0%, var(--platine) 50%, var(--platine-dark) 100%); color: #1a1a1a; }
.rank-diamant { --badge-rim-light: var(--diamant-light); --badge-rim-dark: var(--diamant-dark); background: linear-gradient(135deg, var(--diamant-light) 0%, var(--diamant) 50%, var(--diamant-dark) 100%); color: #fff; }
.rank-challenger { --badge-rim-light: var(--challenger-light); --badge-rim-dark: var(--challenger-dark); background: linear-gradient(135deg, var(--challenger-light) 0%, var(--challenger) 50%, var(--challenger-dark) 100%); color: #fff; }

/* Rank number */
.rank-num { font-weight: 700; font-size: 0.85rem; color: var(--text-dim); width: 36px; text-align: right; }
.rank-num.top-1 { color: var(--gold-mid); }
.rank-num.top-2 { color: var(--argent); }
.rank-num.top-3 { color: var(--bronze); }

/* Elo value */
.elo-val { font-size: 1.125rem; font-weight: 700; color: var(--white); font-family: 'Georgia', serif; }

/* Team tag */
.team-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.team-tag img { width: 20px; height: 20px; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.4); }
.team-tag .team-name { font-weight: 500; color: var(--text); }
.team-tag .team-emoji { font-size: 1rem; }

/* Score */
.score { font-size: 1.25rem; font-weight: 800; color: var(--white); font-family: 'Georgia', serif; letter-spacing: 1px; }
.score-sep { color: var(--text-muted); margin: 0 4px; }

/* Delta */
.delta { font-weight: 700; font-size: 0.85rem; }
.delta-pos { color: var(--win); }
.delta-neg { color: var(--loss); }
.delta-zero { color: var(--text-dim); }

/* Forfeit tag */
.forfeit-tag {
  background: rgba(231,76,90,0.15);
  color: var(--loss);
  border: 1px solid rgba(231,76,90,0.3);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Date cell */
.date-cell { color: var(--text-muted); font-size: 0.8rem; white-space: nowrap; }

/* Player link */
.player-link { font-weight: 600; color: var(--white); transition: color var(--transition-fast); }
.player-link:hover { color: var(--gold-mid); text-decoration: none; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 16px; }
.stat-box {
  background: linear-gradient(180deg, var(--card-elevated) 0%, var(--card) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  text-align: center;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.stat-box:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); border-color: var(--border-bright); }
.stat-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 700; }
.stat-val { font-size: 1.75rem; font-weight: 800; color: var(--white); margin-top: 6px; font-family: 'Georgia', serif; line-height: 1.2; }
.stat-val.win { color: var(--win); }
.stat-val.loss { color: var(--loss); }
.stat-val.draw { color: var(--draw); }
.stat-val.gold { color: var(--gold-mid); }
.stat-val.rank { color: var(--rank-color, var(--white)); }

/* Profile header */
.profile-header { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--card-elevated) 0%, var(--card) 100%);
  border: 3px solid var(--gold-mid);
  box-shadow: 0 0 0 1px var(--border), 0 8px 32px rgba(0,0,0,0.4), inset 0 2px 4px rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.profile-avatar::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  z-index: -1;
  opacity: 0.5;
  filter: blur(4px);
}
.profile-info { flex: 1; min-width: 200px; }
.profile-name { font-size: 2rem; font-weight: 800; color: var(--white); margin-bottom: 6px; }
.profile-meta { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 12px; }
.profile-rank { display: inline-flex; align-items: center; gap: 10px; }
.profile-rank-badge {
  font-size: 1rem;
  padding: 8px 18px;
  border-radius: 999px;
}
.profile-peak { color: var(--text-muted); font-size: 0.85rem; margin-left: 8px; }
.profile-peak strong { color: var(--gold-mid); }

/* Elo chart */
.elo-chart-wrap { position: relative; height: 100px; margin: 16px 0; }
.elo-chart-wrap svg { width: 100%; height: 100%; overflow: visible; }

/* Match row (player profile) */
.match-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.match-row:last-child { border-bottom: none; }
.match-result-tag {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 800; flex-shrink: 0;
  box-shadow: var(--shadow-hard);
}
.result-W { background: linear-gradient(135deg, rgba(61,186,120,0.3), rgba(61,186,120,0.1)); color: var(--win); border: 1px solid rgba(61,186,120,0.3); }
.result-L { background: linear-gradient(135deg, rgba(231,76,90,0.3), rgba(231,76,90,0.1)); color: var(--loss); border: 1px solid rgba(231,76,90,0.3); }
.result-D { background: linear-gradient(135deg, rgba(245,166,35,0.3), rgba(245,166,35,0.1)); color: var(--draw); border: 1px solid rgba(245,166,35,0.3); }
.match-main { flex: 1; min-width: 0; }
.match-score-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.match-score { font-size: 1.25rem; font-weight: 800; color: var(--white); min-width: 50px; text-align: center; font-family: 'Georgia', serif; }
.match-opp-row { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.match-date { color: var(--text-muted); font-size: 0.75rem; }
.match-opp-name { color: var(--text-dim); font-weight: 500; }
.match-opp-name a { color: var(--text-dim); font-weight: 600; }
.match-opp-name a:hover { color: var(--gold-mid); }
.match-elo-delta { font-size: 1rem; font-weight: 700; text-align: right; min-width: 50px; }

/* Team favorite chips */
.team-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.team-chip {
  background: linear-gradient(180deg, var(--card-elevated) 0%, var(--card) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.team-chip:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); border-color: var(--border-bright); }
.team-chip img { width: 28px; height: 28px; border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,0.4); }
.team-chip-info { display: flex; flex-direction: column; }
.team-chip-name { font-weight: 600; color: var(--white); font-size: 0.85rem; }
.team-chip-stats { color: var(--text-muted); font-size: 0.7rem; }

/* Pagination */
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--card-elevated);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  transition: all var(--transition-fast);
  text-decoration: none;
}
.pagination a:hover { background: var(--border); color: var(--white); text-decoration: none; border-color: var(--border-bright); }
.pagination .current { background: linear-gradient(135deg, var(--gold-mid), var(--gold-dark)); color: #1a1a1a; border-color: var(--gold-dark); box-shadow: var(--shadow-glow); }

/* Search bar */
.search-bar { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.search-bar input {
  flex: 1; min-width: 200px;
  background: var(--card-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.search-bar input:focus { outline: none; border-color: var(--gold-mid); box-shadow: 0 0 0 3px rgba(236,186,40,0.15); }
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar button {
  background: linear-gradient(135deg, var(--gold-mid), var(--gold-dark));
  color: #1a1a1a;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 22px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.search-bar button:hover { transform: translateY(-1px); box-shadow: var(--shadow-glow); }

/* Empty state */
.empty { color: var(--text-muted); text-align: center; padding: 60px 20px; font-size: 1rem; }

/* Leaderboard specific */
.leaderboard-row { transition: background var(--transition-fast); }
.leaderboard-row:hover { background: rgba(255,255,255,0.03); }
.leaderboard-row.top-1 td { background: linear-gradient(90deg, rgba(236,186,40,0.06), transparent); }
.leaderboard-row.top-2 td { background: linear-gradient(90deg, rgba(192,192,192,0.05), transparent); }
.leaderboard-row.top-3 td { background: linear-gradient(90deg, rgba(205,127,50,0.06), transparent); }

/* Win/Loss/Draw bars */
.wl-bar { display: flex; gap: 4px; height: 6px; margin-top: 4px; }
.wl-segment { border-radius: 3px; flex: 1; }
.wl-win { background: var(--win); }
.wl-draw { background: var(--draw); }
.wl-loss { background: var(--loss); }

/* Focus visible */
:focus-visible { outline: 2px solid var(--gold-mid); outline-offset: 2px; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }
::-webkit-scrollbar-corner { background: var(--bg-deep); }

/* Print */
@media print {
  .nav, .pagination, .search-bar, .card::before { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  body { background: white; color: black; }
}