:root {
  --bg: #ffffff;
  --fg: #1f1f1f;
  --muted: #757575;
  --faint: #9a9a9a;
  --border: #d9d9d9;
  --border-soft: #e8e8e8;
  --border-hover: #bfbfbf;
  --surface: #f7f7f7;
  --track: #ececec;
  --ring: #171717;
  --accent: #cc785c;
  --btn-bg: #171717;
  --btn-bg-hover: #333333;
  --btn-fg: #ffffff;
  --blue: #0089f4;
  --blue-tint: #e5f3fd;
  --blue-tint-fg: #0a63ad;
  --orange: #e05d00;
  --orange-tint: #fdeee2;
  --orange-tint-fg: #a34300;
  --win: #1a7f37;
  --win-tint: #e7f4ea;
  --loss: #c03434;
  --loss-tint: #fbeaea;
  --draw: #6b7280;
  --draw-tint: #f0f1f2;
  --mvp: #b45309;
  --warn-border: #e8d49a;
  --warn-bg: #fdf6e0;
  --warn-fg: #7a5c14;
  --err-border: #eababa;
  --err-bg: #fbeeee;
  --err-fg: #9c2f2f;
  --ok-border: #b9dcbf;
  --ok-bg: #edf7ef;
  --ok-fg: #22683a;
  --spinner-track: #d4d4d4;
  --radius: 8px;
  --font: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #191919;
  --fg: #ededed;
  --muted: #a0a0a0;
  --faint: #7a7a7a;
  --border: #3a3a3a;
  --border-soft: #2c2c2c;
  --border-hover: #565656;
  --surface: #222222;
  --track: #2f2f2f;
  --ring: #e8e8e8;
  --btn-bg: #ededed;
  --btn-bg-hover: #ffffff;
  --btn-fg: #171717;
  --blue: #4da6f0;
  --blue-tint: #1d2c3a;
  --blue-tint-fg: #8fc7f2;
  --orange: #ef8a3d;
  --orange-tint: #33251a;
  --orange-tint-fg: #f0a868;
  --win: #57b26f;
  --win-tint: #1f2e23;
  --loss: #e07a7a;
  --loss-tint: #332222;
  --draw: #9aa0a6;
  --draw-tint: #26282b;
  --mvp: #d99a4e;
  --warn-border: #5c4d24;
  --warn-bg: #2b2413;
  --warn-fg: #e8c877;
  --err-border: #5c3030;
  --err-bg: #2b1919;
  --err-fg: #eda7a7;
  --ok-border: #2f5a3a;
  --ok-bg: #16261b;
  --ok-fg: #8fd0a3;
  --spinner-track: #3d3d3d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: var(--fg); text-decoration: none; }
a:hover { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
  border-radius: 3px;
}

main {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* ---------- nav ---------- */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1060px;
  margin: 0 auto;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-soft);
}

.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--fg); }
.brand:hover { color: var(--fg); }
.brand:hover .brand-name { color: var(--accent); }

.brand-mark { width: 22px; height: 22px; }

.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  transition: color 0.15s ease;
}

.nav-right { display: flex; align-items: center; gap: 14px; }

.nav-link { font-size: 13px; color: var(--muted); }
.nav-link:hover { color: var(--fg); }

.theme-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-btn:hover { color: var(--fg); border-color: var(--border-hover); }
.theme-btn svg { width: 15px; height: 15px; }
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ---------- page head ---------- */

.page-head { padding: 36px 0 20px; }

.page-head h1 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0;
  max-width: 68ch;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- compare form ---------- */

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  padding: 20px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.field { display: grid; gap: 6px; min-width: 0; }

.field label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg);
}

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-blue { background: var(--blue); }
.dot-orange { background: var(--orange); }

.field input {
  width: 100%;
  padding: 9px 12px;
  color: var(--fg);
  font: inherit;
  font-weight: 500;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.field input::placeholder { color: var(--faint); font-weight: 400; }
.field input:hover { border-color: var(--border-hover); }
.field input:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 0;
  border-color: var(--ring);
}

/* name autocomplete */

.combo { position: relative; min-width: 0; }

.ac-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  max-height: 230px;
  overflow-y: auto;
}
[data-theme="dark"] .ac-panel { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55); }

.ac-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.ac-opt .dot { width: 7px; height: 7px; }
.ac-opt b { font-weight: 600; color: var(--fg); }
.ac-ok { margin-left: auto; color: var(--win); font-size: 11px; font-weight: 700; flex: none; }
.ac-opt[aria-selected="true"] { background: var(--surface); }
.field-blue .ac-opt[aria-selected="true"] { background: var(--blue-tint); }
.field-orange .ac-opt[aria-selected="true"] { background: var(--orange-tint); }

.files { display: flex; align-items: center; gap: 10px; min-width: 0; }

.files-btn {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.field-blue .files-btn:hover { color: var(--blue); border-color: var(--blue); }
.field-orange .files-btn:hover { color: var(--orange); border-color: var(--orange); }

.files-note {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.files-note.warn { color: var(--loss); }

.cta {
  justify-self: end;
  padding: 9px 22px;
  border: 1px solid var(--btn-bg);
  border-radius: 6px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.cta:hover { background: var(--btn-bg-hover); border-color: var(--btn-bg-hover); }
.cta:active { transform: translateY(1px); }
.cta:disabled { opacity: 0.55; cursor: progress; }

.hint {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- notices ---------- */

.notice {
  margin: 0 0 24px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  color: var(--fg);
}

.notice-warn { border-color: var(--warn-border); background: var(--warn-bg); color: var(--warn-fg); }
.notice-error { border-color: var(--err-border); background: var(--err-bg); color: var(--err-fg); }
.notice-ok { border-color: var(--ok-border); background: var(--ok-bg); color: var(--ok-fg); }
.notice-loading { color: var(--muted); }

.notice ul { margin: 6px 0 0; padding: 0 0 0 18px; }
.notice li { margin-top: 2px; }

.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 9px;
  border: 2px solid var(--spinner-track);
  border-top-color: var(--ring);
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* "Getting bored?" pill inside the loading notice */
.bored-btn {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  vertical-align: baseline;
}
.bored-btn:hover { border-color: var(--accent); }

/* ---------- mini rocket league (loading time-killer) ---------- */

.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(8, 12, 18, 0.62);
  padding: 12px;
}
.game-panel {
  width: min(780px, 96vw);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px 16px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.4);
}
.game-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.game-head h3 { margin: 0; font-size: 15px; }
.game-sub { color: var(--muted); font-weight: 400; font-size: 12px; }
.game-score { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.game-score .s-blue { color: var(--blue-tint-fg); }
.game-score .s-orange { color: var(--accent); }
.game-stage { position: relative; }
.game-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 720 / 420;
  border-radius: 6px;
  background: #0e1c30;
  touch-action: none;
  cursor: crosshair;
}
.game-banner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 16px;
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}
.game-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.game-hint { color: var(--muted); font-size: 12px; }
.game-actions { display: inline-flex; align-items: center; gap: 10px; }
.game-loading {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}
.get-scores.pulse { animation: bs-pulse 1.4s ease-in-out infinite; }
@keyframes bs-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(204, 120, 92, 0.45); }
  50% { box-shadow: 0 0 0 7px rgba(204, 120, 92, 0); }
}

/* ---------- results ---------- */

.results { display: grid; gap: 20px; }

.verdict {
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.v-label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.verdict p { margin: 0; font-size: 14.5px; max-width: 85ch; }

.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid;
  gap: 18px;
  min-width: 0;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.who-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who-line .dot { width: 10px; height: 10px; }

.who h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.platform { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }

.tier {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.tier-blue { background: var(--blue-tint); color: var(--blue-tint-fg); }
.tier-orange { background: var(--orange-tint); color: var(--orange-tint-fg); }

.score-block { text-align: right; flex: none; }
.score-cap { display: block; font-size: 11px; color: var(--muted); }
.score-line { display: flex; align-items: baseline; gap: 4px; justify-content: flex-end; }
.score-num {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.score-max { font-size: 13px; color: var(--muted); }
.score-bar {
  width: 120px;
  height: 4px;
  margin-top: 6px;
  border-radius: 2px;
  background: var(--track);
  overflow: hidden;
}
.score-fill {
  height: 100%;
  border-radius: 2px;
  width: 0;
  transition: width 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.card-blue .score-fill { background: var(--blue); }
.card-orange .score-fill { background: var(--orange); }

.summary { margin: 0; color: var(--fg); max-width: 62ch; }

.playstyle { margin: 0; font-size: 13.5px; color: var(--muted); max-width: 62ch; }
.playstyle strong { color: var(--fg); font-weight: 600; }

/* category bars */

.cats { display: grid; gap: 8px; }
.cat { display: grid; grid-template-columns: 112px 1fr 34px; gap: 12px; align-items: center; }
.cat-name { font-size: 12.5px; color: var(--muted); }
.cat-track { height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.cat-fill {
  height: 100%;
  border-radius: 2px;
  width: 0;
  transition: width 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.card-blue .cat-fill { background: var(--blue); }
.card-orange .cat-fill { background: var(--orange); }
.cat-val { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* strengths / weaknesses */

.lists { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.lists h3, .recent h3 { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.lists ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.lists li { position: relative; padding-left: 15px; font-size: 13px; overflow-wrap: anywhere; }
.lists li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.strengths li::before { background: var(--win); }
.weaknesses li::before { background: var(--loss); }

/* recent matches */

.recent { border-top: 1px solid var(--border-soft); padding-top: 16px; display: grid; gap: 14px; }

table.matches { width: 100%; border-collapse: collapse; }
.matches th {
  padding: 0 8px 6px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
}
.matches td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
  vertical-align: middle;
}
.matches td.m-date { white-space: nowrap; color: var(--muted); }
.matches td.m-mode { color: var(--muted); max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matches td.m-score { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.matches td.m-mvp { color: var(--mvp); font-weight: 600; white-space: nowrap; }

.res {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
}
.res-win { background: var(--win-tint); color: var(--win); }
.res-loss { background: var(--loss-tint); color: var(--loss); }
.res-draw { background: var(--draw-tint); color: var(--draw); }

/* Tracker Network rows (newer than the player's BallChasing uploads) */
.t-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  color: var(--muted);
  vertical-align: 1px;
  cursor: help;
}
.muted-cell { color: var(--muted); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border-soft);
}
.stat { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); min-width: 0; }
.stat b {
  display: block;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat span { font-size: 11px; color: var(--muted); }

.recent-analysis {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  color: var(--fg);
  max-width: 70ch;
}

/* ---------- footer ---------- */

.footer {
  max-width: 1060px;
  margin: 0 auto;
  padding: 20px 24px 36px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 12px;
}
.footer p { margin: 0; max-width: 85ch; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .cards { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .compare { grid-template-columns: 1fr; }
  .cta { justify-self: stretch; }
  .lists { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .matches td.m-mode { white-space: normal; }
  .page-head { padding-top: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .score-fill, .cat-fill, .cta, .brand-name, body { transition: none; }
  .spinner { animation-duration: 1.6s; }
  .get-scores.pulse { animation: none; }
}
