/* ShuttleIQ v6.3 — three switchable themes, one structural system.
   Midnight (default): dark, volt accent — night-match energy.
   Court: deep-green varsity light. Clean: soft minimal light.
   All color flows through tokens; structure below is theme-agnostic. */

/* ================= themes ================= */

:root, [data-theme="midnight"] {
  color-scheme: dark;
  --bg: #0b0e0d;
  --card: #151a18;
  --card-2: #1b211e;
  --line: #242c28;
  --line-2: #35403a;

  --ink: #eef3ef;
  --ink-2: #c6d1ca;
  --muted: #93a49a;
  --faint: #657469;

  --accent: #c6ef55;          /* volt — buttons, highlights */
  --on-accent: #101508;
  --accent-soft: rgba(198, 239, 85, 0.13);
  --link: #bde84e;
  --ring-c: rgba(198, 239, 85, 0.35);

  --header-bg: linear-gradient(180deg, #131816, #0e1210);
  --header-ink: #eef3ef;
  --header-dim: #93a49a;
  --header-line: rgba(255, 255, 255, 0.14);
  --header-active-bg: #c6ef55;
  --header-active-ink: #101508;

  --sb-bg: linear-gradient(155deg, #182019, #10150f);
  --sb-inner: rgba(198, 239, 85, 0.18);
  --sb-num: #eef3ef;
  --sb-num-hi: #c6ef55;
  --sb-label: #8ba090;
  --sb-line: rgba(255, 255, 255, 0.14);

  --win: #3ba873;
  --win-soft: rgba(59, 168, 115, 0.16);
  --loss: #e0654f;
  --loss-soft: rgba(224, 101, 79, 0.15);
  --loss-dot: #6b4038;
  --warn: #c08828;
  --warn-soft: rgba(192, 136, 40, 0.15);
  --warn-line: rgba(192, 136, 40, 0.4);

  --chart-ink: #c6d1ca;
  --chart-accent: #3ba873;
  --chart-faint: #26302b;
  --chart-muted: #93a49a;
  --chart-dot-ring: #151a18;

  --bar-fill-a: #9ccf3e;
  --bar-fill-b: #c6ef55;
  --art-line: #4d6154;
  --art-accent: #c6ef55;
  --video-bg: #000;

  --toast-bg: #c6ef55;
  --toast-ink: #101508;

  --r-card: 14px;
  --r-ctl: 9px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 6px 16px rgba(0, 0, 0, 0.5), 0 18px 40px rgba(0, 0, 0, 0.5);
  --speed: 140ms;
}

[data-theme="court"] {
  color-scheme: light;
  --bg: #f2efe8;
  --card: #ffffff;
  --card-2: #f7f5ee;
  --line: #e4e1d5;
  --line-2: #cfccbd;

  --ink: #1a2620;
  --ink-2: #45544b;
  --muted: #6b7a70;
  --faint: #98a69b;

  --accent: #10714a;
  --on-accent: #ffffff;
  --accent-soft: #e3efe7;
  --link: #0c5c39;
  --ring-c: rgba(16, 113, 74, 0.30);

  --header-bg: linear-gradient(180deg, #124b31, #0d3b26);
  --header-ink: #f4f2ea;
  --header-dim: rgba(244, 242, 234, 0.64);
  --header-line: rgba(255, 255, 255, 0.22);
  --header-active-bg: #f2efe8;
  --header-active-ink: #0d3b26;

  --sb-bg: linear-gradient(155deg, #125134, #0b3421);
  --sb-inner: rgba(255, 255, 255, 0.10);
  --sb-num: #f4f2ea;
  --sb-num-hi: #e6c36a;
  --sb-label: rgba(244, 242, 234, 0.64);
  --sb-line: rgba(255, 255, 255, 0.22);

  --win: #0e7a4e;
  --win-soft: #e0efe7;
  --loss: #b3402e;
  --loss-soft: #f9e9e5;
  --loss-dot: #e0b3a9;
  --warn: #9a6a13;
  --warn-soft: #f9efdc;
  --warn-line: #ecd9a8;

  --chart-ink: #45544b;
  --chart-accent: #10714a;
  --chart-faint: #e2dfd2;
  --chart-muted: #6b7a70;
  --chart-dot-ring: #ffffff;

  --bar-fill-a: #16855a;
  --bar-fill-b: #10714a;
  --art-line: #0d3b26;
  --art-accent: #c9932e;
  --video-bg: #0a120d;

  --toast-bg: #0d3b26;
  --toast-ink: #f4f2ea;

  --r-card: 12px;
  --r-ctl: 8px;
  --shadow-1: 0 1px 2px rgba(26, 38, 32, 0.05), 0 4px 14px rgba(26, 38, 32, 0.05);
  --shadow-2: 0 4px 8px rgba(26, 38, 32, 0.08), 0 14px 32px rgba(26, 38, 32, 0.14);
  --speed: 140ms;
}

[data-theme="clean"] {
  color-scheme: light;
  --bg: #f5f7f6;
  --card: #ffffff;
  --card-2: #f2f5f3;
  --line: #e2e8e5;
  --line-2: #ccd6d0;

  --ink: #16211c;
  --ink-2: #41514a;
  --muted: #64756d;
  --faint: #93a49b;

  --accent: #10714a;
  --on-accent: #ffffff;
  --accent-soft: #e0efe7;
  --link: #0c5c39;
  --ring-c: rgba(16, 113, 74, 0.30);

  --header-bg: #ffffff;
  --header-ink: #16211c;
  --header-dim: #64756d;
  --header-line: #ccd6d0;
  --header-active-bg: #e0efe7;
  --header-active-ink: #0c5c39;

  --sb-bg: #ffffff;
  --sb-inner: rgba(20, 122, 77, 0.14);
  --sb-num: #16211c;
  --sb-num-hi: #10714a;
  --sb-label: #64756d;
  --sb-line: #e2e8e5;

  --win: #0e7a4e;
  --win-soft: #e0efe7;
  --loss: #b3402e;
  --loss-soft: #f9e9e5;
  --loss-dot: #ddb1a7;
  --warn: #9a6a13;
  --warn-soft: #fdf3dc;
  --warn-line: #ecd9a8;

  --chart-ink: #41514a;
  --chart-accent: #10714a;
  --chart-faint: #e2e8e5;
  --chart-muted: #64756d;
  --chart-dot-ring: #ffffff;

  --bar-fill-a: #16855a;
  --bar-fill-b: #10714a;
  --art-line: #10714a;
  --art-accent: #d9a13b;
  --video-bg: #0d1512;

  --toast-bg: #16211c;
  --toast-ink: #ffffff;

  --r-card: 12px;
  --r-ctl: 8px;
  --shadow-1: 0 1px 2px rgba(22, 33, 28, 0.06);
  --shadow-2: 0 6px 18px rgba(22, 33, 28, 0.12);
  --speed: 140ms;
}

/* ================= base ================= */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { line-height: 1.12; margin: 0 0 0.45em; letter-spacing: -0.015em; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 750; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0 0 0.85em; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring-c);
  border-radius: var(--r-ctl);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ================= header ================= */

#topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
}

#topnav .nav-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  max-width: 1200px;
  margin: 0 auto;
}

#topnav .logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--header-ink);
}
#topnav .logo:hover { text-decoration: none; }
#topnav .logo svg { display: block; border-radius: 8px; }

#topnav .nav-spacer { flex: 1; }

#topnav .nav-role, #topnav .nav-theme {
  border: 1px solid var(--header-line);
  background: transparent;
  color: var(--header-ink);
  border-radius: 999px;
  padding: 5px 14px;
  font: 600 13px/1.3 inherit;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--speed), border-color var(--speed);
}
#topnav .nav-theme { padding: 5px 10px; display: inline-flex; align-items: center; }
#topnav .nav-role:hover, #topnav .nav-theme:hover { background: var(--header-line); border-color: var(--header-dim); }

#topnav .nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 0 0 10px;
  max-width: 1200px;
  margin: 0 auto;
}

#topnav a[data-nav] {
  padding: 6px 13px;
  border-radius: 999px;
  color: var(--header-dim);
  font-size: 14px;
  font-weight: 600;
  transition: color var(--speed), background var(--speed);
}
#topnav a[data-nav]:hover { color: var(--header-ink); background: var(--header-line); text-decoration: none; }
#topnav a[data-nav].active {
  color: var(--header-active-ink);
  background: var(--header-active-bg);
}

/* ================= bottom tab bar (phones) ================= */

#tabbar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: var(--card);
  border-top: 1px solid var(--line-2);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-2);
}
#tabbar:empty { display: none !important; }

#tabbar .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px 5px;
  border: none;
  background: none;
  border-radius: 10px;
  color: var(--muted);
  font: 600 10.5px/1.2 inherit;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--speed), background var(--speed);
  min-width: 0;
}
#tabbar .tab:hover { text-decoration: none; }
#tabbar .tab.active { color: var(--link); background: var(--accent-soft); }
#tabbar .tab svg { flex-shrink: 0; }

#tabbar .more-sheet {
  position: absolute;
  right: 10px;
  bottom: calc(100% + 8px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  padding: 6px;
  min-width: 190px;
}
#tabbar .sheet-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 9px;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14.5px;
}
#tabbar .sheet-row:hover { background: var(--card-2); text-decoration: none; }
#tabbar .sheet-row.active { color: var(--link); background: var(--accent-soft); }
#tabbar .sheet-row svg { color: var(--muted); }
#tabbar .sheet-row.active svg { color: var(--link); }

/* ================= layout ================= */

#view {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 90px;
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head p { margin: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 880px) {
  .grid3, .grid4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 580px) {
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  h1 { font-size: 25px; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
  padding: 18px;
  margin-bottom: 16px;
}
.card > :last-child { margin-bottom: 0; }

.card-title {
  font-size: 11.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 12px;
}

.section { margin-top: 28px; }

/* ---------- scoreboard ---------- */

.scoreboard {
  background: var(--sb-bg);
  border-radius: 16px;
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--sb-inner);
  padding: 20px 24px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.sb-item { border-left: 1px solid var(--sb-line); padding-left: 20px; min-width: 0; }
.sb-item:first-child { border-left: none; padding-left: 0; }
.sb-num {
  font-size: clamp(30px, 3.6vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--sb-num);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.sb-num.gold { color: var(--sb-num-hi); }
.sb-label {
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sb-label);
  margin-top: 4px;
}
.sb-label a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

@media (max-width: 680px) {
  .scoreboard { grid-template-columns: 1fr 1fr; padding: 16px 18px; }
  .sb-item:nth-child(odd) { border-left: none; padding-left: 0; }
  .sb-item:nth-child(even) { padding-left: 16px; }
}

/* ---------- dashboard main + rail ---------- */

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.dash-main { min-width: 0; }
.dash-rail { min-width: 0; }
@media (max-width: 980px) {
  .dash-grid { grid-template-columns: 1fr; }
}

.rail-actions { display: flex; flex-direction: column; gap: 8px; }
.rail-actions .btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-align: left;
}
.rail-actions .btn::after { content: '→'; color: var(--faint); font-weight: 600; }
.rail-actions .btn:hover::after { color: var(--link); }

.stat .stat-num {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .stat-label { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* ================= buttons ================= */

.btn {
  display: inline-block;
  border: 1px solid var(--line-2);
  background: var(--card);
  color: var(--ink-2);
  border-radius: var(--r-ctl);
  padding: 8px 15px;
  font: 600 14px/1.4 inherit;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: border-color var(--speed), color var(--speed), background var(--speed), transform var(--speed);
}
.btn:hover { border-color: var(--accent); color: var(--link); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-1);
}
.btn-primary:hover { filter: brightness(1.07); color: var(--on-accent); border-color: var(--accent); }

.btn-danger { color: var(--loss); background: none; border-color: var(--line-2); }
.btn-danger:hover { border-color: var(--loss); color: var(--loss); background: var(--loss-soft); }

.btn-sm { padding: 4px 11px; font-size: 13px; border-radius: 7px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: 10px; }

.btn-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.btn-row.center { justify-content: center; }

/* ================= chips / tags / trends ================= */

.chip {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  vertical-align: middle;
}
.chip-w { background: var(--win-soft); color: var(--win); }
.chip-l { background: var(--loss-soft); color: var(--loss); }
.chip-neutral { background: var(--card-2); color: var(--muted); border: 1px solid var(--line); font-weight: 600; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  margin-right: 5px;
}
.tag-accent { background: var(--accent-soft); border-color: transparent; color: var(--link); font-weight: 700; }

.trend-up { color: var(--win); font-weight: 800; }
.trend-down { color: var(--loss); font-weight: 800; }
.trend-flat { color: var(--faint); font-weight: 600; }

.wl-dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.wl-dots i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.wl-dots .w { background: var(--win); }
.wl-dots .l { background: var(--loss-dot); }

.filter-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-chip {
  border: 1px solid var(--line-2);
  background: var(--card);
  border-radius: 999px;
  padding: 5px 14px;
  font: 600 13px/1.4 inherit;
  font-family: inherit;
  cursor: pointer;
  color: var(--muted);
  transition: all var(--speed);
}
.filter-chip:hover { border-color: var(--accent); color: var(--link); }
.filter-chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.rank-num { font-weight: 800; color: var(--faint); width: 28px; display: inline-block; font-variant-numeric: tabular-nums; }
.player-link { font-weight: 650; color: var(--ink); }
.player-link:hover { color: var(--link); }

/* ================= forms ================= */

label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }

input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="url"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-ctl);
  background: var(--card);
  font: inherit;
  color: var(--ink);
  transition: border-color var(--speed), box-shadow var(--speed);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring-c);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="file"] { font-size: 13px; color: var(--muted); }
textarea { resize: vertical; min-height: 64px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 12px; margin-bottom: 12px; }

.inline-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
  padding: 15px 18px;
  margin-bottom: 16px;
}

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-ctl); overflow: hidden; }
.seg button {
  border: none;
  background: var(--card);
  padding: 8px 18px;
  font: 600 14px/1.4 inherit;
  font-family: inherit;
  cursor: pointer;
  color: var(--muted);
  transition: background var(--speed), color var(--speed);
}
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.active { background: var(--ink); color: var(--bg); }
.seg button.active.seg-w { background: var(--win); color: #fff; }
.seg button.active.seg-l { background: var(--loss); color: #fff; }

/* tap-to-rate dots (1-5) */
.rate-row { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.rate-row .rate-label { width: 110px; font-size: 13px; color: var(--ink-2); font-weight: 600; flex-shrink: 0; }
.rate-dots { display: flex; gap: 6px; }
.rate-dots button {
  width: 25px; height: 25px;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
  background: var(--card);
  cursor: pointer;
  padding: 0;
  transition: border-color var(--speed), background var(--speed), transform var(--speed);
}
.rate-dots button:hover { border-color: var(--accent); transform: scale(1.1); }
.rate-dots button.on { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 2.5px var(--card); }

/* ================= tables ================= */

.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 750;
  padding: 8px 10px;
  border-bottom: 1.5px solid var(--line-2);
  white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--speed); }
tbody tr:hover { background: var(--card-2); }

/* ================= skill bars ================= */

.bar-row { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.bar-label { width: 92px; font-size: 13px; color: var(--ink-2); font-weight: 600; flex-shrink: 0; }
.bar-track {
  flex: 1;
  height: 9px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(to right, var(--bar-fill-a), var(--bar-fill-b));
  border-radius: 999px;
  min-width: 2px;
}
.bar-val { width: 32px; text-align: right; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ================= feedback cards ================= */

.fb-card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--faint);
  border-radius: 9px;
  background: var(--card);
  padding: 11px 15px;
  margin: 9px 0;
  cursor: pointer;
  transition: box-shadow var(--speed), border-color var(--speed);
}
.fb-card:hover { box-shadow: var(--shadow-1); border-color: var(--line-2); }
.fb-positive { border-left-color: var(--win); }
.fb-critical { border-left-color: var(--loss); }
.fb-suggestion { border-left-color: var(--warn); }
.fb-head { font-weight: 700; font-size: 14px; display: flex; gap: 9px; align-items: baseline; flex-wrap: wrap; }
.fb-time {
  color: var(--link);
  background: var(--accent-soft);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 750;
  padding: 0 7px;
  border-radius: 5px;
}
.fb-type { font-size: 10.5px; letter-spacing: 0.08em; color: var(--faint); font-weight: 750; }
.fb-body { font-size: 14px; margin-top: 4px; color: var(--ink-2); }
.fb-tip { font-size: 13px; color: var(--link); margin-top: 6px; font-weight: 600; }

/* ================= video / recorder ================= */

video { width: 100%; max-height: 420px; background: var(--video-bg); border-radius: 10px; display: block; }
.rec-timer {
  display: inline-flex;
  align-items: center;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--loss);
  font-size: 18px;
  margin-left: 8px;
  vertical-align: middle;
}
.rec-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--loss); margin-right: 7px; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.compare-grid video { max-height: 320px; }

/* ================= notices, empty states, toast ================= */

.notice {
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  border-radius: 10px;
  padding: 11px 15px;
  font-size: 14px;
  margin-bottom: 16px;
}
.notice-info { background: var(--accent-soft); border-color: var(--line-2); }

.empty {
  text-align: center;
  padding: 44px 24px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card);
  box-shadow: var(--shadow-1);
}
.empty h3 { color: var(--ink); font-size: 18px; }
.empty p { max-width: 460px; margin-left: auto; margin-right: auto; }

#toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--toast-bg);
  color: var(--toast-ink);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 650;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 50;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================= details/summary ================= */

details {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-2);
  padding: 0 15px;
  margin: 9px 0;
}
details summary {
  cursor: pointer;
  padding: 11px 0;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-2);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: '';
  width: 7px; height: 7px;
  border-right: 2px solid var(--faint);
  border-bottom: 2px solid var(--faint);
  transform: rotate(-45deg);
  transition: transform var(--speed);
  flex-shrink: 0;
}
details[open] summary::before { transform: rotate(45deg); }
details[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
details > :last-child { margin-bottom: 14px; }

hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

/* ================= demo banner + guided tour ================= */

.demo-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 7px 16px;
  background: var(--warn-soft);
  color: var(--warn);
  border-bottom: 1px solid var(--warn-line);
  font-size: 13px;
  font-weight: 600;
}
body.has-demo #topnav { top: 38px; }
body.has-demo { padding-top: 38px; }

.tour-panel {
  position: fixed;
  z-index: 45;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.tour-progress { height: 3px; background: var(--line); }
.tour-progress span { display: block; height: 100%; background: var(--accent); transition: width 200ms; }
.tour-body { padding: 14px 18px 4px; }
.tour-step {
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 5px;
}
.tour-body h3 { margin: 0 0 5px; font-size: 17px; }
.tour-body p { font-size: 14px; color: var(--ink-2); margin: 0; }
.tour-actions { display: flex; align-items: center; gap: 8px; padding: 12px 18px 14px; }

/* keep the tour panel clear of the mobile tab bar */
@media (max-width: 879px) {
  .tour-panel { bottom: calc(78px + env(safe-area-inset-bottom)); }
  body.has-tour #toast { display: none; }
}

/* ================= AI analysis progress ================= */

.ai-progress { margin-top: 12px; }
.ai-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.ai-bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(to right, var(--bar-fill-a), var(--bar-fill-b));
  transition: width 300ms ease;
}
/* while the model is thinking there is no honest percentage — show a moving
   stripe instead of inventing one */
.ai-bar > span.indeterminate {
  background: repeating-linear-gradient(
    115deg,
    var(--bar-fill-b) 0 14px,
    var(--bar-fill-a) 14px 28px
  );
  background-size: 200% 100%;
  animation: ai-slide 1.1s linear infinite;
}
@keyframes ai-slide { from { background-position: 0 0; } to { background-position: -56px 0; } }
.ai-progress-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  .ai-bar > span.indeterminate { animation: none; opacity: 0.75; }
}

/* ================= live scorer ================= */

.scorer { max-width: 760px; margin: 0 auto; }
.scorer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

.scorer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0; }

.score-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: min(46vh, 320px);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  font-family: inherit;
  padding: 16px;
  transition: transform var(--speed), border-color var(--speed);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.score-panel:active { transform: scale(0.985); }
.score-us { border-color: var(--accent); }
.score-name { font-size: 14px; font-weight: 700; color: var(--ink-2); text-align: center; }
.score-num {
  font-size: clamp(64px, 18vw, 128px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.score-us .score-num { color: var(--link); }
.score-hint { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); font-weight: 700; }

/* ================= landing ================= */

.landing { max-width: 1040px; margin: 5vh auto 0; }

.hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 44px;
  align-items: center;
}
.hero-kicker {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--art-accent);
  margin-bottom: 12px;
}
.hero h1 {
  font-size: clamp(34px, 4.6vw, 48px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.06;
}
.hero .lead { font-size: 17px; color: var(--muted); margin: 14px 0 24px; max-width: 480px; }
.hero-trust { font-size: 13px; color: var(--muted); margin-top: 14px; }
.hero-trust b { color: var(--ink-2); font-weight: 650; }

.hero-art { color: var(--art-line); min-width: 0; }
.hero-art svg { width: 100%; height: auto; display: block; }

.hero-points {
  margin-top: 52px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 24px;
}
.point { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-2); font-weight: 550; }
.point svg { flex-shrink: 0; color: var(--link); margin-top: 2px; }

@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; gap: 28px; }
  .hero .lead { max-width: none; }
  .hero-art { max-width: 420px; margin: 0 auto; }
  .hero-points { grid-template-columns: 1fr 1fr; margin-top: 36px; }
}
@media (max-width: 580px) {
  .landing { margin-top: 2vh; }
  .hero-points { grid-template-columns: 1fr; }
}

/* ================= gate / login ================= */

.gate { max-width: 400px; margin: 8vh auto 0; }
.gate .card { padding: 26px; border-top: 4px solid var(--accent); }

/* ================= misc ================= */

.pro-card .watchfor { padding-left: 20px; margin: 6px 0; font-size: 13px; color: var(--ink-2); }
.pro-card .watchfor li { margin-bottom: 5px; }

/* theme picker (settings) */
.theme-row { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-opt {
  border: 2px solid var(--line-2);
  background: var(--card-2);
  border-radius: 10px;
  padding: 10px 16px;
  font: 650 14px/1.3 inherit;
  font-family: inherit;
  color: var(--ink-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  transition: border-color var(--speed);
}
.theme-opt:hover { border-color: var(--accent); }
.theme-opt.active { border-color: var(--accent); color: var(--ink); }
.theme-dot { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(128, 128, 128, 0.4); }

/* ---------- phones: tab bar replaces the pill row ----------
   (kept after the base #view/#toast rules so it wins the cascade) */

@media (max-width: 879px) {
  #topnav .nav-links { display: none; }
  #tabbar { display: flex; }
  #view { padding-bottom: calc(108px + env(safe-area-inset-bottom)); }
  #toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
}

/* ---------- touch devices: bigger courtside tap targets ---------- */

@media (pointer: coarse) {
  .rate-dots button { width: 31px; height: 31px; }
  .rate-dots { gap: 8px; }
  .btn { padding: 10px 17px; }
  .btn-sm { padding: 7px 13px; }
}

/* ---------- print ---------- */

@media print {
  #topnav, #tabbar, .no-print, #toast { display: none !important; }
  /* print is always on white paper, whatever the screen theme is */
  :root {
    --card: #fff; --card-2: #fff; --bg: #fff;
    --ink: #111; --ink-2: #333; --muted: #555; --faint: #777;
    --line: #ddd; --line-2: #bbb;
    --accent-soft: #f0f0f0; --link: #111;
  }
  body { background: #fff; color: #111; }
  .card { box-shadow: none; break-inside: avoid; border-color: #ddd; }
  #view { padding: 0; max-width: none; }
  details { border-color: #ddd; }
  details summary { color: #111; }
  /* charts are drawn with the screen theme's colors baked in — re-ink for paper
     (CSS wins over SVG presentation attributes) */
  .c-grid { stroke: #d4d4d4 !important; }
  .c-line { stroke: #222 !important; }
  .c-area { stroke: #222 !important; fill: rgba(0, 0, 0, 0.08) !important; }
  .c-mark { fill: #222 !important; stroke: #fff !important; }
  .c-label { fill: #444 !important; }
  .bar-track { border: 1px solid #ccc; }
  .bar-fill { background: #444 !important; }
  .scoreboard { background: #fff !important; border: 1px solid #bbb; }
  .sb-num, .sb-num.gold { color: #111 !important; }
  .sb-label { color: #555 !important; }
  body.print-one #view > *:not(#roster-list) { display: none !important; }
  body.print-one #roster-list .card:not(.print-target) { display: none !important; }
}

/* ================= level, rank, badges ================= */

.level-card { padding: 18px; }
.level-top { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.level-top .ring { flex-shrink: 0; }
.level-meta { min-width: 0; flex: 1; }

.rank-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
}
.rank-rookie   { background: #6b7a70; }
.rank-starter  { background: #2f7fa8; }
.rank-varsity  { background: #157a4e; }
.rank-captain  { background: #a2761b; }
.rank-elite    { background: linear-gradient(100deg, #8e44ad, #c0392b); }

.level-xp { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin-top: 6px; }

.xp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.xp-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--link);
}

.badge-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 650;
}
.badge.on { background: var(--accent-soft); border-color: transparent; color: var(--link); }
.badge.off { opacity: 0.42; }
.badge.off .badge-ico { filter: grayscale(1); }
.badge-ico { font-size: 14px; line-height: 1; }

/* ================= skill tier tiles ================= */

.tier-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 560px) { .tier-grid { grid-template-columns: 1fr 1fr; } }

.tier-card {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  background: var(--card-2);
  border-top: 3px solid var(--line-2);
  min-width: 0;
}
.tier-head {
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tier-val {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.tier-delta { font-size: 12px; font-weight: 750; }
.tier-meter { height: 5px; background: var(--bg); border-radius: 999px; overflow: hidden; margin: 6px 0 5px; }
.tier-meter > span { display: block; height: 100%; border-radius: 999px; background: currentColor; }
.tier-foot { font-size: 11px; font-weight: 750; letter-spacing: 0.05em; text-transform: uppercase; }

/* tier colours: grey -> bronze -> silver -> gold -> green */
.tier-0 { color: var(--faint); border-top-color: var(--line-2); }
.tier-1 { color: #8b8f94; border-top-color: #8b8f94; }
.tier-2 { color: #a9702f; border-top-color: #a9702f; }
.tier-3 { color: #6f7f8c; border-top-color: #92a3b0; }
.tier-4 { color: #a2761b; border-top-color: #c9932e; }
.tier-5 { color: var(--win); border-top-color: var(--win); }
.tier-card .tier-foot { color: currentColor; }

/* ================= analysis result hero ================= */

.score-hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.score-hero .ring { flex-shrink: 0; }
.score-hero-meta { flex: 1; min-width: 0; }
.hero-tier {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.fb-counts { display: flex; flex-wrap: wrap; gap: 14px; }
.fb-count { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 700; }
.fb-count.fb-critical { color: var(--loss); }
.fb-count.fb-suggestion { color: var(--warn); }
.fb-count.fb-positive { color: var(--win); }

/* ================= compact coaching points ================= */

.fb-list { display: flex; flex-direction: column; gap: 7px; }
.fb-item {
  border: 1px solid var(--line);
  border-left: 3px solid var(--faint);
  border-radius: 10px;
  background: var(--card);
  overflow: hidden;
}
.fb-item.fb-positive { border-left-color: var(--win); }
.fb-item.fb-critical { border-left-color: var(--loss); }
.fb-item.fb-suggestion { border-left-color: var(--warn); }

.fb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 13px;
  border: none;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}
.fb-row:hover { background: var(--card-2); }

.fb-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
}
.fb-positive .fb-dot { background: var(--win-soft); color: var(--win); }
.fb-critical .fb-dot { background: var(--loss-soft); color: var(--loss); }
.fb-suggestion .fb-dot { background: var(--warn-soft); color: var(--warn); }

.fb-row .fb-time {
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--link);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 5px;
  flex-shrink: 0;
}
.fb-title { font-weight: 650; font-size: 14.5px; flex: 1; min-width: 0; }
.fb-chev { color: var(--faint); flex-shrink: 0; transition: transform var(--speed); }
.fb-row[aria-expanded="true"] .fb-chev { transform: rotate(180deg); }

.fb-detail { padding: 0 13px 12px 49px; }
.fb-detail p { font-size: 14px; color: var(--ink-2); margin: 0 0 6px; }
.fb-detail .fb-tip { color: var(--link); font-size: 13px; margin: 0; }

@media (max-width: 460px) {
  .fb-detail { padding-left: 13px; }
  .fb-title { font-size: 14px; }
}
