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

:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --primary: #1e3a5f;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 8px 28px rgba(0,0,0,0.13);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* HEADER */
header {
  background: linear-gradient(135deg, #0f2847 0%, #1e3a5f 60%, #2d5a8e 100%);
  color: white;
  padding: 1.75rem 2rem 2rem;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.handedness-toggle {
  margin-left: auto;
  display: flex;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.hand-btn {
  padding: 0.4rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s;
}

.hand-btn:hover {
  color: white;
  background: rgba(255,255,255,0.15);
}

.hand-btn.active {
  background: white;
  color: var(--primary);
}

.header-ball {
  font-size: 3rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
  flex-shrink: 0;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.3rem;
}

header p {
  font-size: 0.88rem;
  opacity: 0.7;
}

/* FILTER BAR */
.filter-bar {
  background: var(--primary);
  padding: 0.65rem 2rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.filter-btn {
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s, color 0.15s;
}

.filter-btn:hover {
  background: rgba(255,255,255,0.22);
  color: white;
}

.filter-btn.active {
  background: white;
  color: var(--primary);
  font-weight: 700;
}

.cat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.cat-fastball { background: #dc2626; }
.cat-breaking { background: #2563eb; }
.cat-offspeed { background: #16a34a; }
.cat-specialty { background: #d97706; }

/* LEGEND BAR */
.legend-bar {
  background: #e8edf4;
  border-bottom: 1px solid #d1d9e4;
  padding: 0.45rem 2rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-label {
  font-weight: 600;
  color: var(--text);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-sep {
  color: #cbd5e1;
}

.legend-note {
  color: #7c3aed;
  font-weight: 500;
}

/* MAIN GRID */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

.pitch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(540px, 1fr));
  gap: 1.25rem;
}

/* PITCH CARD */
.pitch-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.18s;
}

.pitch-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

/* CARD HEADER */
.card-header {
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.category-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: white;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.pitch-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.mph-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.mph-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.mph-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

/* CARD BODY */
.card-body {
  display: flex;
}

.diagram-section {
  padding: 1.1rem 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-width: 182px;
  border-right: 1px solid #f0f4f8;
  background: #fafbfd;
}

.ball-svg {
  width: 152px;
  height: 152px;
}

.view-label {
  font-size: 0.6rem;
  color: #94a3b8;
  text-align: center;
  line-height: 1.3;
}

.special-note {
  font-size: 0.67rem;
  color: #7c3aed;
  font-weight: 600;
}

/* INFO SECTION */
.info-section {
  padding: 1.1rem 1.15rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-width: 0;
}

.info-block h3 {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.28rem;
  font-weight: 700;
}

.info-block p {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
}

.stats-row {
  display: flex;
  gap: 0.65rem;
}

.stat {
  flex: 1;
  background: #f8fafc;
  border: 1px solid #e8edf4;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  min-width: 0;
}

.stat-label {
  display: block;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
  font-weight: 700;
}

.stat-value {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.tip-block {
  display: flex;
  gap: 0.5rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  margin-top: auto;
}

.tip-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.tip-block p {
  font-size: 0.78rem;
  line-height: 1.5;
  color: #78350f;
}

/* FOOTER */
footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  border-top: 1px solid #e2e8f0;
  margin-top: 1rem;
}

/* RESPONSIVE */
@media (max-width: 640px) {
  header { padding: 1.25rem 1rem; }
  header h1 { font-size: 1.3rem; }
  .header-ball { font-size: 2.2rem; }
  .filter-bar { padding: 0.6rem 1rem; }
  .legend-bar { padding: 0.4rem 1rem; gap: 0.6rem; }
  main { padding: 1rem 0.75rem 3rem; }
  .pitch-grid { grid-template-columns: 1fr; gap: 1rem; }
  .card-body { flex-direction: column; }
  .diagram-section {
    border-right: none;
    border-bottom: 1px solid #f0f4f8;
    padding: 1rem;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    min-width: unset;
  }
  .stats-row { flex-direction: column; gap: 0.5rem; }
}
