/* HoopStat Design System: adaptive light/dark bleachers contrast + touch-first stat pad */

:root {
  color-scheme: light dark;
  --target-size: 44px;
  --topbar-h: 44px;
  --dock-closed-h: 108px;
  --dock-tabs-only-h: 64px;

  --bg-app: #f4f6f9;
  --bg-surface: #ffffff;
  --bg-subtle: #e9eef5;
  --bg-banner: #0f172a;
  --fg-banner: #f8fafc;
  --fg-text: #0f172a;
  --fg-muted: #475569;
  --border-color: #cbd5e1;
  --table-stripe: #f8fafc;
  --table-hi-bg: #fff7ed;

  --accent: #ea580c;
  --accent-fg: #ffffff;
  --accent-soft: #ffedd5;
  --accent-soft-fg: #9a3412;

  --make-bg: #15803d;
  --make-fg: #ffffff;
  --miss-bg: #e2e8f0;
  --miss-fg: #1e293b;
  --hustle-bg: #eff6ff;
  --hustle-fg: #1e3a8a;
  --hustle-border: #bfdbfe;
  --warn-bg: #fef3c7;
  --warn-fg: #92400e;
  --danger-bg: #dc2626;
  --danger-fg: #ffffff;
  --danger-soft: #fee2e2;
  --danger-soft-fg: #991b1b;
  --chart-grid: #cbd5e1;
  --shadow-card: 0 2px 10px rgba(15, 23, 42, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-app: #090e1a;
    --bg-surface: #111827;
    --bg-subtle: #1e293b;
    --bg-banner: #030712;
    --fg-banner: #f8fafc;
    --fg-text: #f1f5f9;
    --fg-muted: #94a3b8;
    --border-color: #334155;
    --table-stripe: #0d1424;
    --table-hi-bg: #1f1612;

    --accent: #f97316;
    --accent-fg: #090e1a;
    --accent-soft: #431407;
    --accent-soft-fg: #fdba74;

    --make-bg: #16a34a;
    --make-fg: #03150a;
    --miss-bg: #1e293b;
    --miss-fg: #cbd5e1;
    --hustle-bg: #172554;
    --hustle-fg: #dbeafe;
    --hustle-border: #1d4ed8;
    --warn-bg: #451a03;
    --warn-fg: #fcd34d;
    --danger-bg: #ef4444;
    --danger-fg: #ffffff;
    --danger-soft: #450a0a;
    --danger-soft-fg: #fca5a5;
    --chart-grid: #334155;
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.35);
  }
}

@supports (color: light-dark(white, black)) {
  :root {
    --bg-app: light-dark(#f4f6f9, #090e1a);
    --bg-surface: light-dark(#ffffff, #111827);
    --bg-subtle: light-dark(#e9eef5, #1e293b);
    --fg-text: light-dark(#0f172a, #f1f5f9);
    --fg-muted: light-dark(#475569, #94a3b8);
    --border-color: light-dark(#cbd5e1, #334155);
    --table-stripe: light-dark(#f8fafc, #0d1424);
    --table-hi-bg: light-dark(#fff7ed, #1f1612);
    --accent: light-dark(#ea580c, #f97316);
    --accent-soft: light-dark(#ffedd5, #431407);
    --accent-soft-fg: light-dark(#9a3412, #fdba74);
    --make-bg: light-dark(#15803d, #16a34a);
    --miss-bg: light-dark(#e2e8f0, #1e293b);
    --miss-fg: light-dark(#1e293b, #cbd5e1);
    --hustle-bg: light-dark(#eff6ff, #172554);
    --hustle-fg: light-dark(#1e3a8a, #dbeafe);
    --hustle-border: light-dark(#bfdbfe, #1d4ed8);
    --warn-bg: light-dark(#fef3c7, #451a03);
    --warn-fg: light-dark(#92400e, #fcd34d);
    --danger-bg: light-dark(#dc2626, #ef4444);
    --danger-soft: light-dark(#fee2e2, #450a0a);
    --danger-soft-fg: light-dark(#991b1b, #fca5a5);
    --chart-grid: light-dark(#cbd5e1, #334155);
  }
}

@media (pointer: coarse) {
  :root {
    --target-size: 44px;
  }
}

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg-app);
  color: var(--fg-text);
  line-height: 1.45;
}

h1,
h2,
h3 {
  text-wrap: balance;
  margin: 0;
}

p,
li {
  text-wrap: pretty;
}

[hidden]:not([hidden="until-found"]) {
  display: none !important;
}

section[role="tabpanel"][hidden="until-found"] {
  padding: 0;
  border: 0;
  margin: 0;
  background: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Interactive control sizing */
.btn,
.tab-btn,
.select-control,
.input-control,
.sync-pill {
  min-block-size: var(--target-size);
  min-inline-size: var(--target-size);
  touch-action: manipulation;
  font: inherit;
}

.btn,
.sync-pill,
.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0.5rem 0.85rem;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 80ms ease, opacity 120ms ease, background-color 120ms ease;
}

.btn:active,
.stat-btn:active {
  transform: scale(0.97);
}

.btn:disabled,
.stat-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--fg-text);
  border-color: var(--border-color);
}

.btn-secondary[aria-pressed="true"] {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--fg-text);
  border-color: var(--border-color);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger-fg);
}

.btn-danger-outline {
  background: var(--danger-soft);
  color: var(--danger-soft-fg);
  border-color: var(--danger-bg);
}

.select-control,
.input-control {
  background: var(--bg-surface);
  color: var(--fg-text);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
}

.sync-pill {
  border-radius: 999px;
  padding-inline: 0.9rem;
  font-size: 0.84rem;
}

.sync-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-block-size: 26px;
  min-inline-size: var(--target-size);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}

/* Expand vertical hit area >= 44px without overlapping adjacent strip buttons */
.sync-chip::after,
.totals-reopen-btn::after {
  content: "";
  position: absolute;
  inset: -9px 0;
}

.sync-pill.is-synced,
.sync-chip.is-synced {
  background: var(--make-bg);
  color: var(--make-fg);
}

.sync-pill.is-offline,
.sync-chip.is-offline {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-color: var(--accent);
}

.sync-pill.is-error,
.sync-chip.is-error {
  background: var(--danger-bg);
  color: var(--danger-fg);
}

/* Floating notice bar */
.notice-bar {
  position: fixed;
  inset-block-start: max(0.5rem, env(safe-area-inset-top));
  inset-inline: max(0.75rem, env(safe-area-inset-left));
  max-width: 720px;
  margin-inline: auto;
  z-index: 40;
  padding: 0.6rem 0.9rem;
  background: var(--warn-bg);
  color: var(--warn-fg);
  border: 1px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Main shell, single-line top bar, & viewports */
.main-shell,
.app-shell {
  width: 100%;
}

.main-shell {
  padding: max(1rem, env(safe-area-inset-top, 0px)) 1rem;
}

.top-bar {
  position: sticky;
  inset-block-start: 0;
  z-index: 30;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding-block-start: env(safe-area-inset-top, 0px);
  padding-inline: max(0.5rem, env(safe-area-inset-left, 0px)) max(0.5rem, env(safe-area-inset-right, 0px));
}

.top-bar-inner {
  max-width: 1120px;
  margin-inline: auto;
  block-size: var(--topbar-h);
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
  overflow: hidden;
}

.top-leading-cluster {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
  min-inline-size: 0;
  flex-shrink: 1;
}

.topbar-icon {
  flex-shrink: 0;
  inline-size: 24px;
  block-size: 24px;
  display: block;
}

.top-inline-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.top-inline-actions:empty {
  display: none;
}

.top-trailing-cluster {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
  margin-inline-start: auto;
}

.btn-topbar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-block-size: 28px;
  min-inline-size: var(--target-size);
  padding: 0.18rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--fg-text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-topbar-icon {
  padding-inline: 0.45rem;
}

.hamburger-svg {
  display: block;
  flex-shrink: 0;
  pointer-events: none;
}

.btn-topbar.is-player-btn {
  flex-shrink: 1;
  min-inline-size: 72px;
  gap: 0.3rem;
  max-inline-size: clamp(140px, 48vw, 260px);
}

.btn-topbar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-inline-size: 0;
}

.btn-topbar-num {
  flex-shrink: 0;
  opacity: 0.82;
  font-variant-numeric: tabular-nums;
}

.btn-topbar::after {
  content: "";
  position: absolute;
  inset: -8px 0;
}

.btn-topbar.is-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
}

.btn-topbar.is-danger {
  background: var(--danger-soft);
  color: var(--danger-soft-fg);
  border-color: var(--danger-bg);
}

.btn-topbar[aria-pressed="true"] {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-color: var(--accent);
}

.more-trigger {
  anchor-name: --more-trigger;
}

.player-trigger {
  anchor-name: --player-trigger;
}

.player-caret {
  inline-size: 8px;
  block-size: 6px;
  flex-shrink: 0;
  background-color: currentColor;
  opacity: 0.7;
  clip-path: polygon(10% 20%, 90% 20%, 50% 85%);
}

.more-popover {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-surface);
  color: var(--fg-text);
  padding: 0.35rem;
  min-inline-size: 190px;
  max-inline-size: min(260px, calc(100vw - 1rem));
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.more-popover:is(:popover-open, .\:popover-open) {
  display: block;
}

@supports not (position-area: block-end) {
  .more-popover {
    position: fixed;
    inset: auto;
    inset-block-start: calc(env(safe-area-inset-top, 0px) + var(--topbar-h) + 0.25rem);
    inset-inline-start: max(0.5rem, env(safe-area-inset-left, 0px));
    margin: 0;
  }

  .player-popover {
    inset-inline-start: max(4.25rem, env(safe-area-inset-left, 0px));
  }
}

@supports (position-area: block-end) {
  .more-popover {
    inset: auto;
    margin: 0;
    margin-block-start: 0.25rem;
    position-anchor: --more-trigger;
    position-area: block-end span-inline-end;
    position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
  }

  .player-popover {
    position-anchor: --player-trigger;
  }
}

.more-popover-list {
  display: grid;
  gap: 0.25rem;
}

.popover-section-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  padding: 0.25rem 0.65rem 0.1rem;
}

.popover-divider {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 0.2rem 0.35rem;
}

.more-popover-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  inline-size: 100%;
  min-block-size: var(--target-size);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.more-popover-btn:hover,
.more-popover-btn:focus-visible {
  background: var(--bg-subtle);
}

.more-popover-btn[aria-current="true"] {
  background: var(--accent-soft);
  color: var(--accent-soft-fg);
  font-weight: 800;
}

.more-popover-btn.is-primary {
  color: var(--accent);
  font-weight: 700;
}

.more-popover-btn.is-danger {
  color: var(--danger-soft-fg);
}

.more-popover-btn[aria-pressed="true"] {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-color: var(--accent);
}

.views-viewport {
  max-width: 1120px;
  margin-inline: auto;
}

.panel-inner {
  padding: 0.75rem max(0.75rem, env(safe-area-inset-right, 0px)) calc(var(--dock-tabs-only-h) + 1rem + env(safe-area-inset-bottom, 0px)) max(0.75rem, env(safe-area-inset-left, 0px));
  display: grid;
  gap: 0.85rem;
}

.live-panel-inner {
  padding: 0.3rem max(0.5rem, env(safe-area-inset-right, 0px)) 0.3rem max(0.5rem, env(safe-area-inset-left, 0px));
  block-size: calc(100dvh - var(--topbar-h) - 1px - env(safe-area-inset-top, 0px) - var(--dock-closed-h) - env(safe-area-inset-bottom, 0px));
  min-block-size: 368px;
  max-block-size: 840px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.32rem;
}

@media (max-height: 545px) {
  .live-panel-inner {
    block-size: auto;
    padding-block-end: calc(var(--dock-closed-h) + 0.5rem + env(safe-area-inset-bottom, 0px));
  }
}

.surface-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: var(--shadow-card);
}

.setup-card {
  max-width: 600px;
  inline-size: 100%;
  margin: 1rem auto;
  display: grid;
  gap: 0.85rem;
}

.code-box {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: var(--bg-banner);
  color: var(--fg-banner);
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Thin top totals strip on Live view */
.live-totals-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  min-block-size: 40px;
  padding: 0.25rem 0.4rem;
  border-radius: 12px;
  background: var(--bg-banner);
  color: var(--fg-banner);
  border: 1px solid var(--border-color);
}

.live-boxscore-trigger {
  position: relative;
  appearance: none;
  flex: 1 1 auto;
  min-inline-size: 0;
  width: 100%;
  margin: 0;
  padding: 0.1rem 0.05rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.live-boxscore-trigger::after {
  content: "";
  position: absolute;
  inset: -6px 0;
}

.live-boxscore-trigger:focus-visible {
  outline: 2px solid #fb923c;
  outline-offset: 2px;
}

.live-boxscore-trigger:active {
  opacity: 0.9;
}

.live-totals-metrics {
  width: 100%;
  min-inline-size: 0;
  display: grid;
  grid-template-columns: 0.95fr 1.35fr 1.35fr 1.25fr repeat(6, 0.9fr);
  gap: 0.1rem;
  text-align: center;
}

.total-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  padding: 0.12rem 0.05rem;
  border-radius: 6px;
}

.total-chip-label {
  font-size: 0.56rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #94a3b8;
}

.total-chip-val {
  font-size: clamp(0.72rem, 2.55vw, 0.94rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.total-chip.is-pts .total-chip-val {
  color: #fb923c;
}

.total-chip.is-foul-warn {
  background: #b45309;
  color: #ffffff;
}

.total-chip.is-foul-warn .total-chip-label {
  color: #fef3c7;
}

.total-chip.is-foul-out {
  background: #dc2626;
  color: #ffffff;
}

.total-chip.is-foul-out .total-chip-label {
  color: #fee2e2;
}

.totals-reopen-btn {
  position: relative;
  flex-shrink: 0;
  min-block-size: 26px;
  min-inline-size: var(--target-size);
  padding: 0.15rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

/* Unified 6-row iPhone Stat Pad */
.live-pad-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(6, minmax(52px, 1fr));
  gap: 0.3rem;
  min-block-size: 0;
}

.stat-btn {
  min-block-size: 52px;
  min-inline-size: 52px;
  touch-action: manipulation;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.35rem;
  font: inherit;
  font-weight: 800;
  font-size: clamp(0.88rem, 2.8vw, 1.02rem);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  line-height: 1.1;
  text-align: center;
  transition: transform 80ms ease, opacity 120ms ease;
}

.stat-btn.span-3 {
  grid-column: span 3;
}

.stat-btn.span-2 {
  grid-column: span 2;
}

.stat-btn-sub {
  font-size: clamp(0.65rem, 2.1vw, 0.75rem);
  font-weight: 600;
  opacity: 0.88;
  max-inline-size: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-btn.is-make {
  background: var(--make-bg);
  color: var(--make-fg);
  border-color: transparent;
}

.stat-btn.is-miss {
  background: var(--miss-bg);
  color: var(--miss-fg);
}

.stat-btn.is-hustle {
  background: var(--hustle-bg);
  color: var(--hustle-fg);
  border-color: var(--hustle-border);
}

.stat-btn.is-warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-color: var(--accent);
}

.stat-btn.is-foul {
  background: var(--danger-soft);
  color: var(--danger-soft-fg);
  border-color: var(--danger-bg);
}

.stat-btn.is-undo {
  background: var(--bg-surface);
  color: var(--danger-soft-fg);
  border-color: var(--danger-bg);
}

/* Persistent bottom dock: collapsible player bar + bottom tablist */
.bottom-dock {
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  z-index: 25;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.14);
  padding-block-end: env(safe-area-inset-bottom, 0px);
}

.player-drawer {
  max-width: 1120px;
  margin-inline: auto;
}

.player-drawer[hidden] {
  display: none;
}

.player-drawer-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-block-size: var(--target-size);
  padding: 0.25rem max(0.75rem, env(safe-area-inset-right)) 0.25rem max(0.75rem, env(safe-area-inset-left));
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.player-drawer-summary::-webkit-details-marker {
  display: none;
}

.drawer-chevron {
  inline-size: 16px;
  block-size: 16px;
  flex-shrink: 0;
  background-color: currentColor;
  color: var(--fg-muted);
  clip-path: polygon(15% 68%, 50% 28%, 85% 68%, 74% 78%, 50% 50%, 26% 78%);
  transition: transform 150ms ease;
}

.player-drawer[open] .drawer-chevron {
  transform: rotate(180deg);
}

.drawer-summary-main {
  flex: 1 1 auto;
  min-inline-size: 0;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  overflow: hidden;
}

.drawer-summary-player {
  font-weight: 800;
  font-size: 0.92rem;
  white-space: nowrap;
}

.drawer-summary-context {
  font-size: 0.82rem;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-summary-badges {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.player-drawer-body {
  max-block-size: min(62dvh, 460px);
  overflow-y: auto;
  padding: 0.65rem max(0.75rem, env(safe-area-inset-right)) 0.85rem max(0.75rem, env(safe-area-inset-left));
  border-top: 1px solid var(--border-color);
  display: grid;
  gap: 0.6rem;
}

.drawer-minimal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.drawer-minimal-identity {
  min-inline-size: 0;
  display: grid;
  gap: 0.12rem;
}

.drawer-minimal-player {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--fg-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-pbp-section,
.dialog-pbp-section {
  display: grid;
  gap: 0.45rem;
}

.pad-group-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}

.drawer-pbp-scroll {
  max-block-size: min(46dvh, 320px);
  overflow-y: auto;
}

.dialog-pbp-scroll {
  max-block-size: 260px;
  overflow-y: auto;
}

.pbp-seq {
  display: inline-block;
  min-inline-size: 1.9rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.bottom-tablist {
  max-width: 1120px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--border-color);
  padding-inline: max(0.35rem, env(safe-area-inset-left)) max(0.35rem, env(safe-area-inset-right));
}

.player-drawer[hidden] + .bottom-tablist {
  border-top: 0;
}

.tab-btn {
  position: relative;
  border-radius: 0;
  background: transparent;
  color: var(--fg-muted);
  border: 0;
  padding: 0.35rem 0.25rem;
  font-size: 0.86rem;
  white-space: nowrap;
}

.tab-btn[aria-selected="true"] {
  color: var(--accent);
  font-weight: 800;
}

.tab-btn[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset-inline: 18%;
  inset-block-start: 0;
  border-block-start: 3px solid var(--accent);
}

.bottom-brand {
  max-width: 1120px;
  margin-inline: auto;
  block-size: 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  user-select: none;
}

/* Badges & Foul Dots */
.player-badge-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.jersey-pill {
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

.team-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-subtle);
  color: var(--fg-text);
  border: 1px solid var(--border-color);
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.status-pill {
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-pill.is-live {
  background: #16a34a;
  color: #ffffff;
}

.status-pill.is-final {
  background: #475569;
  color: #ffffff;
}

.status-pill.is-archived {
  background: #991b1b;
  color: #ffffff;
}

.demo-badge {
  background: var(--accent);
  color: var(--accent-fg);
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.foul-cluster {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.84rem;
  font-weight: 700;
}

.foul-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1.5px solid #94a3b8;
  display: inline-block;
}

.foul-dot.is-active {
  background: #f59e0b;
  border-color: #fde68a;
}

.foul-dot.is-danger {
  background: #ef4444;
  border-color: #fecaca;
}

.foul-warning {
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 700;
}

.foul-warning.is-warn {
  background: #b45309;
  color: #ffffff;
}

.foul-warning.is-out {
  background: #dc2626;
  color: #ffffff;
}

/* Play-by-Play */
.pbp-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.pbp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.4rem 0.65rem;
  border-radius: 10px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
}

.pbp-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.muted-text {
  color: var(--fg-muted);
  font-size: 0.88rem;
}

/* Filters, Metrics, Summary Cards */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.controls-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-block-size: var(--target-size);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.segmented-group {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

.segmented-group .btn {
  border-radius: 0;
  border: 0;
}

.segmented-group .btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-fg);
}

/* ESPN-style player bio banner & section containers */
.unentered-text {
  color: var(--fg-muted);
  font-style: italic;
  font-weight: 500;
}

.espn-player-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 0.5rem 0.7rem;
  box-shadow: var(--shadow-card);
}

.espn-player-identity {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-inline-size: 0;
}

.espn-jersey-badge {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 900;
  font-size: 1.05rem;
  padding: 0.28rem 0.58rem;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.espn-player-meta {
  display: grid;
  gap: 0.1rem;
  min-inline-size: 0;
}

.espn-player-name {
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.15;
}

.espn-player-sub {
  font-size: 0.8rem;
  color: var(--fg-muted);
  font-weight: 600;
}

.espn-headline-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(46px, 1fr));
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-app);
  flex: 1 1 300px;
  max-inline-size: 460px;
}

.espn-headline-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.25rem;
  border-right: 1px solid var(--border-color);
  text-align: center;
}

.espn-headline-cell:last-child {
  border-right: 0;
}

.espn-headline-label {
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}

.espn-headline-val {
  font-size: 0.92rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.espn-section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.espn-section-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.espn-section-title {
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-text);
}

.btn-table-xs {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 26px;
  min-inline-size: 38px;
  padding: 0.14rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--fg-text);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-table-xs::after {
  content: "";
  position: absolute;
  inset: -9px -3px;
}

.btn-table-xs:hover {
  border-color: var(--accent);
}

.opp-cell-stack {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.team-name-stack {
  display: grid;
  gap: 0.06rem;
  line-height: 1.15;
}

.team-level-sub {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--fg-muted);
}

/* ESPN Sticky Column/Row Responsive Tables */
.table-wrapper {
  container-type: inline-size;
  overflow: auto;
  max-block-size: min(68dvh, 620px);
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-surface);
}

.espn-section-card .table-wrapper {
  border: 0;
  border-radius: 0;
}

.stat-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
  font-size: 0.84rem;
}

.stat-table thead th {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: var(--bg-subtle);
  color: var(--fg-muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.48rem 0.55rem;
  border-bottom: 2px solid var(--border-color);
  text-align: left;
  white-space: nowrap;
}

.stat-table thead th:first-child {
  inset-inline-start: 0;
  z-index: 3;
  border-right: 1px solid var(--border-color);
}

.stat-table tbody tr {
  background-color: var(--bg-surface);
}

.stat-table tbody tr:nth-child(even) {
  background-color: var(--table-stripe);
}

.stat-table tbody tr[data-clickable="true"],
.stat-table tbody tr.is-clickable-row {
  cursor: pointer;
}

.stat-table tbody tr[data-clickable="true"]:hover,
.stat-table tbody tr.is-clickable-row:hover {
  background-color: var(--bg-subtle);
}

.stat-table tbody tr[data-clickable="true"]:focus-visible,
.stat-table tbody tr.is-clickable-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.stat-table tbody th[scope="row"] {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background-color: inherit;
  font-weight: 700;
  text-align: left;
  border-right: 1px solid var(--border-color);
}

.stat-table tbody th,
.stat-table tbody td {
  padding: 0.48rem 0.55rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  white-space: nowrap;
}

.stat-table th.num,
.stat-table td.num {
  text-align: right;
}

.stat-table td.is-stat-hi {
  font-weight: 800;
  background-color: var(--table-hi-bg);
}

.stat-table tbody tr.is-summary-row {
  background-color: var(--bg-subtle);
  font-weight: 700;
}

.stat-table tbody tr.is-summary-row td.is-stat-hi {
  background-color: inherit;
}

.stat-table tbody tr.is-career-row {
  background-color: var(--accent-soft);
  color: var(--accent-soft-fg);
  font-weight: 800;
}

.stat-table tbody tr.is-career-row td.is-stat-hi {
  background-color: inherit;
}

@container (width < 600px) {
  .stat-table {
    font-size: 0.78rem;
  }

  .stat-table thead th,
  .stat-table tbody th,
  .stat-table tbody td {
    padding: 0.4rem 0.44rem;
  }
}

/* SVG Chart */
.chart-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-svg.is-scrollable {
  width: auto;
  max-width: none;
}

.chart-axis {
  stroke: var(--border-color);
  stroke-width: 1.5;
}

.chart-grid-line {
  stroke: var(--chart-grid);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-point {
  fill: var(--accent);
  stroke: var(--bg-surface);
  stroke-width: 2;
}

.chart-label {
  fill: var(--fg-muted);
  font-size: 11px;
  font-family: inherit;
}

.chart-opp-label {
  fill: var(--fg-text);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
}

.chart-opp-label.is-unentered {
  fill: var(--fg-muted);
  font-style: italic;
  font-weight: 500;
}

.chart-date-label {
  fill: var(--fg-muted);
  font-size: 10.5px;
  font-family: inherit;
}

.chart-value-label {
  fill: var(--fg-text);
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
}

/* Native Dialogs */
.modal-dialog {
  width: min(760px, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: var(--bg-surface);
  color: var(--fg-text);
  padding: 1.15rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.modal-compact {
  width: min(440px, calc(100vw - 1.5rem));
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(2, 6, 23, 0.65);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-block-end: 0.9rem;
}

.dialog-body {
  display: grid;
  gap: 1rem;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-block-start: 0.5rem;
}

.modal-form {
  display: grid;
  gap: 0.75rem;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.65rem;
}

.field-group {
  display: grid;
  gap: 0.3rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.form-error {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger-soft-fg);
  font-weight: 600;
  font-size: 0.88rem;
}

.manage-list {
  display: grid;
  gap: 0.5rem;
  margin-block-end: 1rem;
}

.manage-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.sub-heading {
  font-size: 1rem;
  margin-block-start: 0.35rem;
}

@media (max-width: 640px) {
  .total-chip-label {
    font-size: 0.58rem;
  }

  .stat-btn {
    padding: 0.2rem 0.25rem;
  }
}

/* Spec 002 Auth Shell, Banners, View-Only Badge & Access Dialog */
.auth-shell {
  min-block-size: 100dvh;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: max(1.25rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px)) max(1.5rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
  gap: 0.9rem;
}

.auth-shell[hidden] {
  display: none;
}

.auth-card {
  width: min(480px, 100%);
  display: grid;
  gap: 0.85rem;
  background: light-dark(#ffffff, #1e293b);
  border: 1px solid light-dark(#cbd5e1, #334155);
}

.auth-card[hidden] {
  display: none;
}

.auth-banners {
  display: grid;
  gap: 0.5rem;
  width: min(960px, calc(100% - 1rem));
  margin-inline: auto;
  padding-block: 0.35rem;
}

.auth-banners[hidden] {
  display: none;
}

.auth-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  background: light-dark(#fffbeb, #2a2008);
  color: light-dark(#92400e, #fde68a);
  border: 1px solid light-dark(#f59e0b, #b45309);
}

.auth-banner.is-info {
  background: light-dark(#eff6ff, #0f1f3a);
  color: light-dark(#1e40af, #bfdbfe);
  border-color: light-dark(#93c5fd, #1d4ed8);
}

.auth-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: light-dark(#e2e8f0, #334155);
  color: light-dark(#334155, #e2e8f0);
  border: 1px solid light-dark(#cbd5e1, #475569);
}

.role-badge[hidden] {
  display: none;
}

.access-section {
  display: grid;
  gap: 0.65rem;
  padding: 0.85rem;
  border-radius: 12px;
  background: light-dark(#f8fafc, #0f172a);
  border: 1px solid var(--border-color);
}

.access-section-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.access-member-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
}

.access-member-meta {
  display: grid;
  gap: 0.15rem;
  min-inline-size: 0;
}

.access-member-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.copy-link-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: light-dark(#ecfdf5, #052e16);
  border: 1px solid light-dark(#6ee7b7, #166534);
}

.copy-link-input {
  inline-size: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--fg-text);
}
