:root {
  --bg: #070b10;
  --bg-elev: #0e151c;
  --bg-panel: #121a22;
  --line: #243040;
  --text: #e8eef5;
  --muted: #8b97a8;
  --accent: #3d8bfd;
  --accent-strong: #1e6fe0;
  --good: #3ecf8e;
  --warn: #f0b429;
  --chart: #0b1020;
  --font: "Manrope", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 420px at 8% -10%, rgba(61, 139, 253, 0.14), transparent 55%),
    radial-gradient(700px 380px at 92% 0%, rgba(62, 207, 142, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
}

a {
  color: var(--accent);
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.top {
  margin-bottom: 1.25rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}

.brand strong {
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.brand em {
  font-style: normal;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--good);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.lede {
  margin: 0;
  max-width: 46rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.player-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  margin-bottom: 1.15rem;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.player-bar-main {
  min-width: min(100%, 22rem);
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.player-select-label {
  display: block;
  margin-top: 0.55rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.player-select {
  display: block;
  width: min(100%, 22rem);
  margin-top: 0.35rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(61, 139, 253, 0.45);
  background: #0b1220;
  color: var(--text);
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #8b97a8 50%),
    linear-gradient(135deg, #8b97a8 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.player-select:focus {
  outline: 2px solid rgba(61, 139, 253, 0.55);
  outline-offset: 2px;
}

.player-bar h1 {
  margin: 0.55rem 0 0.2rem;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.base-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.base-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.base-field select {
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b1220;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}

.base-field select:focus {
  outline: 2px solid rgba(61, 139, 253, 0.45);
  outline-offset: 1px;
}

.hint.tight-hint {
  margin: 0.55rem 0 0;
}

.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.source-pill {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  border: 1px solid rgba(61, 139, 253, 0.35);
  background: rgba(61, 139, 253, 0.1);
  color: #b6d4ff;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.9fr);
  gap: 1.1rem;
  align-items: start;
}

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

.panel {
  background: #0f1424;
  border: 1px solid #2a3550;
  border-radius: 14px;
  padding: 1rem 1.1rem 1.2rem;
  box-shadow: 0 10px 28px rgba(8, 12, 24, 0.35);
}

.panel-head h2 {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-head.tight {
  margin-top: 0.85rem;
}

.num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  background: var(--good);
  color: #062010;
  font-size: 0.72rem;
  font-weight: 800;
}

.hint {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  aspect-ratio: 36 / 40;
  background: var(--chart);
  border-radius: 12px;
  border: 1px solid #2a3550;
  overflow: hidden;
}

.chart-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.marker {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
  user-select: none;
}

.marker--glove {
  /* width set in JS: 9.5″ face × px/in from zone scale */
  width: 12%;
  height: auto;
  z-index: 3;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.marker--ball {
  /* width/height set in JS: 2.9″ × px/in (regulation baseball) */
  width: 3%;
  height: 3%;
  z-index: 4;
  border-radius: 50%;
  object-fit: cover;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
  -webkit-mask-image: radial-gradient(closest-side, #000 99%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 99%, transparent 100%);
}

.scale-caption {
  margin: 6px 2px 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.chart-labels {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  font-size: 10px;
  color: var(--muted);
  z-index: 1;
}

.miss-row {
  margin-top: 0.85rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.miss-row strong {
  color: var(--accent);
  font-size: 1.35rem;
}

.miss-vec {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.miss-vec strong {
  color: var(--text);
  font-size: 0.95rem;
}

.marker.is-muted {
  opacity: 0.45;
  filter: grayscale(0.35) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.key-panel {
  margin-top: 0.95rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid #2a3550;
  border-radius: 12px;
  background: #161c2e;
}

.key-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.key-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.key-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem 1rem;
}

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

.key-heading {
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.key-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  font: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.28rem;
  padding: 0.28rem 0.4rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

button.key-item:hover {
  border-color: #2a3550;
  background: rgba(255, 255, 255, 0.03);
}

button.key-item.is-active {
  color: var(--text);
  border-color: rgba(61, 139, 253, 0.45);
  background: rgba(61, 139, 253, 0.12);
}

button.key-item.is-off {
  opacity: 0.38;
  color: var(--muted);
  border-color: transparent;
  background: transparent;
  text-decoration: line-through;
  text-decoration-color: rgba(148, 163, 184, 0.55);
}

.key-item--static {
  cursor: default;
  padding-left: 0.4rem;
}

.key-item--static:hover {
  border-color: transparent;
  background: transparent;
}

.key-mark {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  position: relative;
}

.key-x::before,
.key-x::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}

.key-x::before {
  transform: translate(-50%, -50%) rotate(45deg);
}
.key-x::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.key-x--whiff {
  color: #ef4444;
}
.key-x--hit {
  color: #22c55e;
}
.key-x--out {
  color: #3b82f6;
}
.key-x--foul {
  color: #f59e0b;
}

.key-dot {
  border-radius: 50%;
  background: currentColor;
  width: 10px;
  height: 10px;
  margin: 2px;
}

.key-dot--ball {
  color: #3b82f6;
  background: #3b82f6;
}
.key-dot--strike {
  color: #ef4444;
  background: #ef4444;
}

.key-img {
  width: 18px;
  height: auto;
}
.key-img--ball {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  object-fit: cover;
}

.pitch-detail {
  margin-bottom: 0.85rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid #2a3550;
  border-radius: 12px;
  background: #161c2e;
  min-height: 7.5rem;
}

.pitch-detail-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.pitch-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 0.65rem;
  margin-bottom: 0.75rem;
}

.pitch-detail-grid .metric span {
  font-size: 0.65rem;
}

.pitch-detail-grid .metric strong {
  font-size: 0.95rem;
}

.pitch-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  border: 1px solid #2a3550;
  color: var(--muted);
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 14, 0.72);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  background: #0f1424;
  border: 1px solid #2a3550;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #2a3550;
}

.modal-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.modal-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 1rem;
}

.modal-body p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.modal-body a {
  font-weight: 650;
}

.chart-wrap {
  cursor: crosshair;
}

.seg {
  display: flex;
  background: #161c2e;
  border: 1px solid #2a3550;
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 0.9rem;
}

.seg-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
}

.seg-btn.is-active {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
}

.filter-block {
  margin-bottom: 0.85rem;
}

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.filter-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.filter-actions {
  display: flex;
  gap: 0.55rem;
}

.linkish {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 650;
  cursor: pointer;
  padding: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  border: 1px solid #2a3550;
  background: #161c2e;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip .n {
  opacity: 0.75;
  font-weight: 500;
  margin-left: 0.2rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
}

.summary {
  margin: 0 0 0.65rem;
  font-size: 0.86rem;
  color: var(--muted);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.metric {
  background: #161c2e;
  border: 1px solid #2a3550;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
}

.metric span {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.metric strong {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 0.75rem;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
}

.stats {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  color: #111;
}

.stats th,
.stats td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  white-space: nowrap;
}

.stats th {
  background: #f3f4f6;
  font-weight: 700;
}

.stats tbody tr:hover td {
  background: #f9fafb;
}

.foot {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}

.foot p {
  margin: 0 0 0.4rem;
}

.foot code {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: #c7d2fe;
}

.muted {
  opacity: 0.85;
}
