:root {
  --navy: #0e2240;
  --navy-2: #13294b;
  --navy-3: #1b3560;
  --gold: #fec524;
  --red: #8b2131;
  --sky: #1d428a;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #0e2240;
  --ink-2: #4a5876;
  --line: #e2e7f0;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(14, 34, 64, .06), 0 8px 24px rgba(14, 34, 64, .06);
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--body);
}
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(14, 34, 64, .92);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--gold); color: var(--navy);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text { font: 700 22px/1 var(--display); letter-spacing: .04em; text-transform: uppercase; }
.brand-text b { color: var(--gold); font-weight: 700; }
.season-pill {
  font: 600 13px/1 var(--body); color: var(--gold);
  border: 1px solid rgba(254, 197, 36, .4); border-radius: 999px; padding: 7px 12px;
}

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(1200px 400px at 85% -10%, rgba(29, 66, 138, .9), transparent 60%),
    linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  padding: 48px 0 92px;
}
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 64px;
  background: linear-gradient(90deg, var(--gold) 0 33%, var(--red) 33% 66%, var(--sky) 66% 100%);
  clip-path: polygon(0 100%, 100% 30%, 100% 100%);
  opacity: .95;
}
.eyebrow {
  margin: 0 0 6px; color: var(--gold);
  font: 600 13px/1 var(--body); letter-spacing: .14em; text-transform: uppercase;
}
.hero h1 {
  margin: 0; font: 800 clamp(48px, 9vw, 88px)/.9 var(--display);
  text-transform: uppercase; letter-spacing: .01em;
}
.hero-sub { margin: 12px 0 28px; color: rgba(255, 255, 255, .72); max-width: 560px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; max-width: 760px; }
.stat {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 14px; padding: 14px 16px;
}
.stat-val { font: 700 32px/1 var(--display); color: #fff; }
.stat-label { margin-top: 4px; font-size: 12px; color: rgba(255, 255, 255, .6); text-transform: uppercase; letter-spacing: .08em; }

/* ---------- Controls ---------- */
.controls {
  position: relative; z-index: 2;
  margin-top: -44px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px;
}
.search {
  flex: 1 1 260px; display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px;
}
.search svg { width: 18px; height: 18px; color: var(--ink-2); flex: none; }
.search input { width: 100%; border: 0; background: transparent; padding: 11px 0; outline: none; }
.search:focus-within { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(29, 66, 138, .15); }

.chips { display: flex; gap: 4px; background: var(--bg); border-radius: 12px; padding: 4px; }
.chip {
  border: 0; background: transparent; cursor: pointer;
  padding: 7px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--ink-2);
  white-space: nowrap;
}
.chip:hover { color: var(--ink); }
.chip.active { background: var(--navy); color: #fff; }

.controls-right { display: flex; gap: 8px; margin-left: auto; }
select {
  appearance: none; cursor: pointer;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%234a5876' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 34px 9px 12px; font-size: 13px; font-weight: 600;
}
.view-toggle { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; gap: 2px; }
.view-toggle button {
  display: grid; place-items: center; width: 36px; height: 32px;
  border: 0; border-radius: 9px; background: transparent; cursor: pointer; color: var(--ink-2);
}
.view-toggle svg { width: 16px; height: 16px; fill: currentColor; }
.view-toggle button.active { background: var(--navy); color: #fff; }

.result-count { margin: 22px 2px 12px; font-size: 13px; color: var(--ink-2); }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card {
  position: relative; overflow: hidden; cursor: pointer; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover, .card:focus-visible {
  transform: translateY(-3px); border-color: var(--gold);
  box-shadow: 0 2px 4px rgba(14, 34, 64, .08), 0 16px 32px rgba(14, 34, 64, .12);
  outline: none;
}
.card-top {
  position: relative; height: 170px;
  background: linear-gradient(160deg, var(--navy-3), var(--navy));
  display: flex; align-items: flex-end; justify-content: center;
}
.card-num {
  position: absolute; top: 4px; left: 14px;
  font: 800 92px/1 var(--display); color: transparent;
  -webkit-text-stroke: 1.5px rgba(254, 197, 36, .45);
  letter-spacing: -.01em; pointer-events: none;
}
.card-top img { position: relative; height: 160px; width: auto; object-fit: contain; }
.initials {
  position: relative; align-self: center;
  display: grid; place-items: center; width: 92px; height: 92px; border-radius: 50%;
  background: rgba(255, 255, 255, .08); border: 2px solid rgba(254, 197, 36, .5);
  font: 700 36px/1 var(--display); color: #fff; letter-spacing: .04em;
}
.badge {
  position: absolute; top: 12px; right: 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  padding: 4px 8px; border-radius: 999px;
  background: var(--red); color: #fff;
}
.card-body { padding: 14px 16px 16px; }
.card-name { margin: 0; font: 700 26px/1 var(--display); text-transform: uppercase; }
.card-name span { display: block; font-size: 15px; font-weight: 600; color: var(--ink-2); letter-spacing: .04em; margin-bottom: 2px; }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tag {
  font-size: 12px; font-weight: 600; color: var(--ink-2);
  background: var(--bg); border-radius: 8px; padding: 4px 8px;
}
.tag.pos { background: var(--gold); color: var(--navy); }

/* ---------- Table ---------- */
.table-wrap {
  overflow-x: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.roster-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 900px; }
.roster-table th {
  text-align: left; padding: 12px 14px; cursor: pointer; user-select: none; white-space: nowrap;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-2); background: #f8fafc; border-bottom: 1px solid var(--line);
}
.roster-table th:hover { color: var(--ink); }
.roster-table th.sorted { color: var(--sky); }
.roster-table th.sorted::after { content: " \2193"; }
.roster-table th.sorted.asc::after { content: " \2191"; }
.roster-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.roster-table tbody tr { cursor: pointer; }
.roster-table tbody tr:hover { background: #fbf6e3; }
.roster-table tbody tr:last-child td { border-bottom: 0; }
.t-num { font: 700 20px/1 var(--display); color: var(--sky); }
.t-player { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.t-avatar {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex: none;
  background: var(--navy); color: #fff; display: grid; place-items: center;
  font: 700 14px/1 var(--display);
}
.t-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.pill-2w { font-size: 11px; font-weight: 600; color: var(--red); }

.empty { text-align: center; color: var(--ink-2); padding: 48px 0; }

/* ---------- Modal ---------- */
.modal {
  width: min(720px, calc(100% - 32px)); max-height: calc(100% - 32px);
  padding: 0; border: 0; border-radius: 20px; overflow: auto;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
.modal::backdrop { background: rgba(8, 18, 36, .6); backdrop-filter: blur(3px); }
.modal[open] { animation: pop .2s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 24px; line-height: 1;
}
.modal-close:hover { background: rgba(255, 255, 255, .26); }
.m-head {
  position: relative; display: grid; grid-template-columns: 220px 1fr; align-items: end;
  background:
    radial-gradient(500px 200px at 100% 0, rgba(29, 66, 138, .9), transparent 70%),
    linear-gradient(160deg, var(--navy-3), var(--navy));
  color: #fff; min-height: 200px; overflow: hidden;
}
.m-head .card-num { font-size: 160px; top: -6px; left: auto; right: 18px; -webkit-text-stroke-color: rgba(254, 197, 36, .3); }
.m-photo { display: flex; align-items: flex-end; justify-content: center; height: 100%; padding-top: 16px; }
.m-photo img { height: 190px; width: auto; }
.m-photo .initials { margin-bottom: 40px; }
.m-title { position: relative; padding: 24px 24px 24px 0; }
.m-title .eyebrow { margin-bottom: 8px; }
.m-title h2 { margin: 0; font: 800 46px/.9 var(--display); text-transform: uppercase; }
.m-title h2 span { display: block; font-size: 22px; font-weight: 600; color: rgba(255, 255, 255, .7); }
.m-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px; background: var(--line);
}
.m-cell { background: var(--surface); padding: 14px 18px; }
.m-cell dt { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.m-cell dd { margin: 2px 0 0; font-weight: 600; }
.m-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; flex-wrap: wrap; }
.m-foot a {
  color: var(--navy); background: var(--gold); text-decoration: none;
  font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: 10px;
}
.m-nav { display: flex; gap: 8px; }
.m-nav button {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px;
  padding: 8px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.m-nav button:hover { border-color: var(--sky); }

/* ---------- Live bar ---------- */
.livebar {
  position: sticky; top: 60px; z-index: 19;
  background: #0a1a33; color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  font-size: 14px;
}
.livebar.is-live { background: linear-gradient(90deg, #3a0d16, #0a1a33 55%); }
.lb-row { display: flex; align-items: center; gap: 12px; min-height: 44px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.lb-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em;
  color: var(--navy); background: var(--gold); border-radius: 6px; padding: 4px 8px;
}
.lb-tag.live { background: #e0313f; color: #fff; }
.lb-pulse { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.lb-score { font: 700 22px/1 var(--display); letter-spacing: .02em; }
.lb-score b { color: var(--gold); font-weight: 700; }
.lb-score i { font-style: normal; color: rgba(255, 255, 255, .5); padding: 0 2px; }
.lb-text { font-weight: 600; }
.lb-meta { color: rgba(255, 255, 255, .65); }
.lb-toggle {
  margin-left: auto; cursor: pointer;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18); color: #fff;
  border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600;
}
.lb-toggle:hover { background: rgba(255, 255, 255, .18); }
.lb-box { overflow: auto; max-height: 50vh; padding-bottom: 12px; }
.lb-box table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 13px; }
.lb-box th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: rgba(255, 255, 255, .55); padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.lb-box td { padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, .06); white-space: nowrap; }
.lb-box b { color: var(--gold); }
.lb-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 8px; background: transparent; vertical-align: middle; }
.lb-dot.on { background: #3ddc84; }

/* ---------- Stats ---------- */
.card-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  margin-top: 12px; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.card-stats div { text-align: center; }
.card-stats b { display: block; font: 700 24px/1 var(--display); color: var(--navy); }
.card-stats span { font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--ink-2); }
.card-stats.empty-stats { display: block; text-align: center; font-size: 12px; color: var(--ink-2); }
.t-stat { font-weight: 600; }

.m-season { padding: 18px 18px 6px; border-bottom: 1px solid var(--line); }
.m-season h3 { margin: 0 0 10px; font: 700 18px/1 var(--display); text-transform: uppercase; letter-spacing: .04em; }
.m-season h3 + .m-log { margin-bottom: 12px; }
.m-muted { margin: 0 0 12px; color: var(--ink-2); }
.m-avgs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.m-avgs div { background: var(--bg); border-radius: 10px; padding: 10px 6px; text-align: center; }
.m-avgs b { display: block; font: 700 22px/1 var(--display); }
.m-avgs span { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--ink-2); }
.m-log { overflow-x: auto; margin-bottom: 12px; }
.m-log table { width: 100%; min-width: 460px; border-collapse: collapse; font-size: 13px; }
.m-log th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--ink-2); padding: 6px; border-bottom: 1px solid var(--line); }
.m-log td { padding: 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.m-log .win { color: #1a7f45; font-weight: 600; }
.m-log .loss { color: var(--red); font-weight: 600; }

/* ---------- Footer ---------- */
.footer { margin-top: 56px; padding: 24px 0 36px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 13px; }
.footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 36px 0 84px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls { gap: 10px; }
  .chips { overflow-x: auto; max-width: 100%; }
  .controls-right { margin-left: 0; width: 100%; }
  .controls-right select { flex: 1; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card-top { height: 140px; }
  .card-top img { height: 132px; }
  .card-num { font-size: 72px; }
  .initials { width: 72px; height: 72px; font-size: 28px; }
  .card-name { font-size: 21px; }
  .m-head { grid-template-columns: 1fr; }
  .m-photo { order: 2; padding-top: 0; }
  .m-photo img { height: 170px; }
  .m-title { padding: 24px 20px 0; }
  .m-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .m-avgs { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .m-avgs b { font-size: 18px; }
  .lb-score { font-size: 19px; }
  .lb-toggle { margin-left: 0; }
}
@media (max-width: 420px) {
  .grid { grid-template-columns: 1fr; }
  .brand-text { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .modal[open], .lb-pulse { transition: none; animation: none; }
}
