:root {
  --background: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --ink: #111827;
  --muted: #667085;
  --line: #e5e7eb;
  --line-strong: #d0d5dd;
  --primary: #18181b;
  --primary-hover: #27272a;
  --accent: #f97316;
  --accent-soft: #fff7ed;
  --success-soft: #ecfdf3;
  --danger: #b42318;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
  line-height: 1.45;
  font-size: 14px;
}

a { color: var(--primary); text-underline-offset: 3px; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.site-header {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1rem;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--ink);
  text-decoration: none;
  font-size: .98rem;
  font-weight: 750;
  letter-spacing: -.02em;
}

.brand::before {
  content: "";
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #18181b, #52525b);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}

nav { display: grid; gap: .2rem; }
nav a {
  color: #344054;
  text-decoration: none;
  font-weight: 600;
  font-size: .9rem;
  padding: .6rem .7rem;
  border-radius: 10px;
}
nav a:hover { background: var(--surface-muted); color: var(--ink); }

.account-actions {
  margin-top: auto;
  display: grid;
  gap: .6rem;
  color: var(--muted);
  font-weight: 600;
}
.account-actions a { text-decoration: none; }

.app-main { min-width: 0; }
main { width: min(1160px, calc(100% - 2rem)); margin: 0 auto; padding: 1rem 0 2rem; }

.hero, .page-hero { padding: 1.35rem 0 .9rem; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: stretch; }
.compact-hero { padding-bottom: .4rem; }

h1 { font-size: clamp(1.8rem, 3vw, 2.65rem); line-height: 1.08; letter-spacing: -.04em; margin: .15rem 0 .65rem; }
h2 { font-size: 1.05rem; letter-spacing: -.015em; }
h3 { font-size: .96rem; }
h2, h3 { line-height: 1.2; margin-top: 0; margin-bottom: .7rem; }
p { margin-top: 0; }

.eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-weight: 750; font-size: .72rem; margin-bottom: .35rem; }
.lede { color: var(--muted); font-size: .98rem; max-width: 720px; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: .9rem 0 0; }

.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--primary);
  border-radius: 10px;
  padding: .62rem .85rem;
  background: var(--primary);
  color: white;
  text-decoration: none;
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
.button:hover, button:hover { background: var(--primary-hover); }
.button.secondary, button.secondary { background: white; color: var(--ink); border-color: var(--line-strong); box-shadow: none; }
button.danger { background: var(--danger); border-color: var(--danger); }
.button.small { padding: .48rem .7rem; font-size: .84rem; }
.link-button { background: transparent; color: var(--primary); padding: 0; border: 0; box-shadow: none; }

.panel, .card, .hero-card, .placeholder, .empty-state, .stat-card, .band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.hero-card { display: grid; gap: .65rem; }
.metric { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); padding-top: .65rem; }
.metric:first-of-type { border-top: 0; padding-top: 0; }
.metric strong { font-size: 1.8rem; letter-spacing: -.04em; }
.metric span, .muted { color: var(--muted); }

.messages { margin-top: .75rem; }
.message { border-radius: 12px; padding: .7rem .85rem; background: #eff6ff; border: 1px solid #bfdbfe; font-weight: 600; }
.message.error { background: #fff1f3; color: #912018; border-color: #fecdd3; }
.message.success { background: var(--success-soft); color: #067647; border-color: #abefc6; }

label { display: grid; gap: .35rem; font-weight: 700; color: #344054; font-size: .86rem; }
input, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: .58rem .7rem;
  background: white;
  color: var(--ink);
  font: inherit;
}
input:focus, select:focus { outline: 2px solid #dbeafe; border-color: #93c5fd; }
input[type="checkbox"] { width: auto; }
.error { color: var(--danger); font-size: .84rem; font-weight: 700; }
.auth-card { width: min(520px, 100%); margin: 2rem auto; }

.grid { display: grid; gap: .9rem; margin: 1rem 0; }
.three { grid-template-columns: repeat(3, 1fr); }
.four { grid-template-columns: repeat(4, 1fr); }
.split, .team-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; align-items: start; margin: .9rem 0; }
.split.tight { margin: 0; }
.compact-panel { margin-bottom: .9rem; }
.league-list { display: grid; gap: .9rem; margin: 1rem 0; }
.card-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.card-heading span { color: var(--muted); font-weight: 500; font-size: .86rem; }

.pill-list { display: flex; flex-wrap: wrap; gap: .45rem; padding: 0; margin: .75rem 0 0; list-style: none; }
.pill-list li { background: var(--surface-muted); border: 1px solid var(--line); border-radius: 999px; padding: .38rem .58rem; font-weight: 600; font-size: .86rem; }
.pill-list li.random-pill, .random-row { background: var(--success-soft); border-color: #abefc6; }
.pill-list span, .row-heading em, .help-text { color: var(--muted); font-size: .82rem; font-weight: 500; }

.game-form { display: grid; gap: .9rem; }
.stat-panel { overflow: hidden; }
.player-stat-row { border: 1px solid var(--line); border-radius: 12px; padding: .75rem; display: grid; gap: .6rem; margin-top: .65rem; background: white; }
.add-player-row { display: grid; grid-template-columns: 1fr auto; gap: .65rem; align-items: end; }
.row-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: center; font-weight: 700; }
.checkbox { display: flex; align-items: center; gap: .45rem; }
.stat-inputs { display: grid; grid-template-columns: repeat(5, minmax(64px, 1fr)); gap: .45rem; }
.stat-inputs label { font-size: .74rem; color: var(--muted); }
.stat-inputs input { padding: .45rem; }
.band { margin: 1rem 0; }
.search-grid { display: grid; grid-template-columns: 1.1fr 1fr .7fr auto; align-items: end; gap: .65rem; }
.search-panel { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: .75rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: white; }
table { width: 100%; border-collapse: collapse; min-width: 760px; font-size: .86rem; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: .58rem .65rem; }
th { background: var(--surface-muted); color: #344054; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.totals td { font-weight: 750; background: var(--accent-soft); }
.stat-card span { color: var(--muted); font-weight: 800; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-card strong { display: block; font-size: 1.55rem; letter-spacing: -.04em; margin-top: .2rem; }
.leader-list { display: grid; gap: .55rem; padding-left: 1.1rem; margin-bottom: 0; }
.leader-list li { padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.leader-list span, .leader-list small { display: block; }
.leader-list strong { font-size: 1.15rem; }
.leader-list small { color: var(--muted); }
.vertical-split { display: grid; gap: .9rem; margin-bottom: 1.5rem; }
.profile-panel { max-width: 680px; }
.stacked-form { display: grid; gap: .9rem; }
.placeholder { min-height: 160px; display: grid; align-content: center; }
.site-footer { width: min(1160px, calc(100% - 2rem)); margin: 0 auto; padding: 1.25rem 0 1.75rem; border-top: 1px solid var(--line); color: var(--muted); }

@media (max-width: 980px) {
  .app-shell { display: block; }
  .site-header { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  nav { display: flex; flex-wrap: wrap; }
  .account-actions { margin-top: 0; display: flex; align-items: center; flex-wrap: wrap; }
  .hero, .split, .team-grid, .three, .four, .search-grid, .search-panel { grid-template-columns: 1fr; }
  .stat-inputs { grid-template-columns: repeat(3, minmax(64px, 1fr)); }
}

@media (max-width: 560px) {
  main, .site-footer { width: min(100% - 1rem, 1160px); }
  .site-header { padding: .75rem; }
  .add-player-row { grid-template-columns: 1fr; }
  .stat-inputs { grid-template-columns: repeat(2, minmax(64px, 1fr)); }
}

.team-results { display: grid; grid-template-columns: 1fr; gap: .9rem; margin: .9rem 0; }
.lookup-section { border-left: 4px solid #2563eb; }
.entry-section { border-left: 4px solid var(--accent); }
.section-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: start; margin-bottom: .9rem; padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin-bottom: 0; }
.section-heading .help-text { max-width: 420px; text-align: right; }
.video-embed { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); background: #000; margin: .75rem 0; }
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.fantasy-fields { display: grid; grid-template-columns: repeat(3, minmax(88px, 1fr)); gap: .55rem; padding: .65rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-muted); margin: .2rem 0 .7rem; }
.fantasy-fields .help-text { grid-column: 1 / -1; margin: 0; }

@media (max-width: 560px) {
  .fantasy-fields { grid-template-columns: repeat(2, minmax(88px, 1fr)); }
  .section-heading { display: grid; }
  .section-heading .help-text { text-align: left; }
}
