:root {
  --bg0: #050505;
  --bg1: #0e0e0e;
  --bg2: #1a1a1a;
  --line: #3a3a3a;
  --text: #e8e8e8;
  --muted: #9a9a9a;
  --accent: #c8c8c8;
  --accent-dim: #7a7a7a;
  --board: #2a2a2a;
  --board-border: #000;
  --font-display: "Bebas Neue", "Arial Narrow", Impact, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #000 0%, #111 100%);
  color: var(--text);
  font-family: var(--font-body);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.92);
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 3.2vw, 1.75rem);
  letter-spacing: 0.05em;
  line-height: 1.05;
  max-width: min(100%, 36rem);
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}
.brand span { color: var(--accent); }
.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.45));
}
.brand-text {
  display: inline;
  white-space: normal;
}

.hero-football {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin: 0 auto 1.25rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(180, 80, 40, 0.18), transparent 55%),
    linear-gradient(180deg, #121212 0%, #0a0a0a 100%);
}
.hero-football img {
  width: min(220px, 42vw);
  height: auto;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,0.55));
}
.hero-football-copy {
  text-align: left;
  max-width: 22rem;
}
.hero-football-copy .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.35rem;
}
.hero-football-copy h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: 0.04em;
  margin: 0;
  font-weight: 400;
  line-height: 0.95;
}
.hero-football-copy h1 span { color: var(--accent); }
.hero-football-copy p {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.nav a {
  color: var(--muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.nav a.active, .nav a:hover { color: var(--text); text-decoration: none; }

.meta {
  color: var(--muted);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.pulse {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.pulse i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(200, 200, 200, 0.55);
  animation: ping 1.6s infinite;
}
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(200, 200, 200, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(200, 200, 200, 0); }
  100% { box-shadow: 0 0 0 0 rgba(200, 200, 200, 0); }
}

/* ---- H2H scoreboard (spreadsheet matchup layout) ---- */
.h2h {
  margin-bottom: 1.15rem;
  overflow-x: auto;
}

.h2h-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr);
  min-width: 720px;
  border: 2px solid #000;
  color: #111;
}

/* Matchup colors from league sheet */
.h2h.theme-0 .h2h-grid { background: #e8a020; }
.h2h.theme-1 .h2h-grid { background: #f0d44a; }
.h2h.theme-2 .h2h-grid { background: #6eb8e0; }
.h2h.theme-3 .h2h-grid { background: #9b6bb8; }
.h2h.theme-4 .h2h-grid { background: #3d5fd0; color: #0a0a0a; }
.h2h.theme-5 .h2h-grid { background: #c44e28; }
.h2h.theme-6 .h2h-grid { background: #b8b8b8; }
.h2h.theme-7 .h2h-grid { background: #4a7fd4; }
.h2h.theme-8 .h2h-grid { background: #d43d3d; }

.h2h-side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: inherit;
}

.h2h-name {
  text-align: center;
  font-weight: 700;
  font-size: 1.2rem;
  padding: 0.55rem 0.45rem;
  border-bottom: 2px solid #000;
  background: rgba(255, 255, 255, 0.12);
}

.h2h-cols {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  border-bottom: 1px solid #000;
  min-height: 2.2rem;
  align-items: stretch;
}
.h2h-cols.mirror {
  grid-template-columns: minmax(0, 1fr) 72px;
}
.h2h-cols.head {
  font-weight: 700;
  text-align: center;
  background: rgba(0, 0, 0, 0.08);
}
.h2h-cols.head > div,
.h2h-cols > div {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.45rem;
  border-right: 1px solid #000;
  color: #111;
}
.h2h-cols > div:last-child { border-right: 0; }
.h2h-cols.mirror > div:first-child {
  justify-content: flex-start;
  text-align: left;
}
.h2h-cols:not(.mirror) > div:last-child {
  justify-content: flex-start;
  text-align: left;
}

.h2h-pts {
  font-weight: 700;
  font-size: 1.05rem;
}
.h2h-player {
  font-size: 0.98rem;
  font-weight: 600;
}

.h2h-total {
  text-align: center;
  font-family: var(--font-display);
  font-size: 2.35rem;
  letter-spacing: 0.04em;
  padding: 0.45rem 0.5rem;
  background: rgba(0, 0, 0, 0.1);
  border-top: 2px solid #000;
  color: #111;
}

.h2h-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.12);
  border-left: 2px solid #000;
  border-right: 2px solid #000;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  color: #111;
}

.h2h-editors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.85rem;
}

.solo-side {
  max-width: 520px;
  margin: 0 auto;
  border: 2px solid #000;
  background: #e8a020;
  color: #111;
}

.roster-edit {
  background: #111;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}
.roster-edit h3 {
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  margin: 0 0 0.55rem;
  font-weight: 400;
}
.edit-row {
  display: grid;
  grid-template-columns: 52px 1.2fr 1fr;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
  align-items: center;
}
.edit-row-def {
  grid-template-columns: 52px 1fr;
}
.edit-row .slot {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.edit-row input { width: 100%; }

.card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.card h2, .card h3 {
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  margin: 0 0 0.75rem;
  font-weight: 400;
}
label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.25rem; }
input, select, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg0);
  color: var(--text);
  padding: 0.5rem 0.65rem;
}
button, .btn {
  background: var(--accent);
  color: #0a0a0a;
  border: 0;
  font-weight: 700;
  cursor: pointer;
  padding: 0.55rem 0.9rem;
}
button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 500;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: end;
  margin-bottom: 0.65rem;
}
.row > * { flex: 1 1 140px; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.member-block { scroll-margin-top: 80px; }
.slot-form {
  display: grid;
  grid-template-columns: 70px 1.2fr 1fr 90px auto;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
  align-items: center;
}
.muted { color: var(--muted); }
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty a { font-weight: 700; }

.standings-card h2 { margin-bottom: 0.35rem; }
.standings-wrap { overflow-x: auto; margin-top: 1rem; }
.standings-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  font-size: 0.98rem;
}
.standings-table th,
.standings-table td {
  border: 1px solid var(--line);
  padding: 0.65rem 0.75rem;
  text-align: left;
}
.standings-table th {
  background: #1f1f1f;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.standings-table td.num,
.standings-table th.num {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.standings-table td.rank {
  font-weight: 700;
  color: var(--accent);
}
.standings-table td.name { font-weight: 600; }
.standings-table td.total { font-weight: 700; }
.standings-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.03); }
.standings-table tbody tr.me {
  background: rgba(200, 200, 200, 0.12);
  outline: 1px solid var(--accent-dim);
}
.standings-table tbody tr:hover { background: rgba(255, 255, 255, 0.06); }

.week-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}
.week-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.6rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  line-height: 1.2;
}
.week-chip:hover { color: var(--text); border-color: #666; text-decoration: none; background: rgba(255,255,255,0.06); }
.week-chip.current {
  color: #111;
  background: #c8c8c8;
  border-color: #c8c8c8;
  font-weight: 700;
}
.week-chip.mine:not(.current) {
  border-color: #8a8a8a;
  color: var(--text);
}
.week-chip.preseason {
  min-width: 2.8rem;
  letter-spacing: 0.04em;
}
.week-chip.playoffs {
  min-width: auto;
  padding-inline: 0.7rem;
  color: var(--text);
  border-color: #9a9a9a;
}
.badge-playoffs {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #9a9a9a;
  color: var(--text);
  font-weight: 700;
}
.playoffs-week {
  border-color: #6a6a6a;
}

.my-schedule-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.my-schedule-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}
.my-schedule-row:hover { border-color: #666; text-decoration: none; }
.my-schedule-row.current {
  border-color: #9a9a9a;
  background: rgba(200, 200, 200, 0.1);
}
.my-week {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.my-vs { font-weight: 600; }

.schedule-week-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.55rem 0.85rem;
  margin-bottom: 0.75rem;
}
.schedule-week-head h2 { margin: 0; }
.badge-current,
.badge-mine {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge-current {
  color: #111;
  background: #c8c8c8;
  border-color: #c8c8c8;
  font-weight: 700;
}
.badge-mine { color: var(--text); border-color: #8a8a8a; }
.schedule-week.is-current {
  border-color: #6a6a6a;
}
.schedule-matchups {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
.schedule-matchup {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.55rem;
  align-items: center;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
}
.schedule-matchup.mine {
  background: rgba(200, 200, 200, 0.12);
  border-color: #8a8a8a;
}
.sched-home { text-align: right; font-weight: 600; }
.sched-away { text-align: left; font-weight: 600; }
.sched-vs {
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  color: var(--muted);
  font-size: 0.95rem;
}
@media (max-width: 820px) {
  .schedule-matchup {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 0.2rem;
  }
  .sched-home,
  .sched-away { text-align: center; }
}

.err-msg { color: #d0a0a0; font-weight: 600; }
.ok-msg { color: var(--accent); font-weight: 600; }
.taken-list {
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.taken-list summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}
.taken-list ul {
  margin: 0.55rem 0 0;
  padding-left: 1.2rem;
  max-height: 220px;
  overflow-y: auto;
}
.taken-list li { margin-bottom: 0.25rem; }

.rules-card h2 { margin-bottom: 0.35rem; }
.rules-body {
  margin-top: 1rem;
  line-height: 1.55;
  font-size: 0.98rem;
  color: var(--text);
  max-width: 46rem;
}
.rules-body .rules-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2rem);
  letter-spacing: 0.04em;
  font-weight: 400;
  margin: 0 0 1rem;
  color: var(--text);
}
.rules-body h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.05em;
  font-weight: 400;
  margin: 1.45rem 0 0.45rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  color: #f0f0f0;
}
.rules-body h3:first-child,
.rules-body .rules-title + h3 {
  border-top: 0;
  padding-top: 0;
  margin-top: 0.35rem;
}
.rules-body h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0.95rem 0 0.3rem;
  color: #d8d8d8;
  letter-spacing: 0.02em;
}
.rules-body p {
  margin: 0 0 0.7rem;
  color: #d0d0d0;
}
.rules-body ul {
  margin: 0 0 0.85rem;
  padding-left: 1.2rem;
}
.rules-body li {
  margin: 0.28rem 0;
  color: #d0d0d0;
}
.rules-body .rules-callout {
  margin: 0.75rem 0 1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid #5a5a5a;
  border-left: 3px solid #c8c8c8;
  background: rgba(255, 255, 255, 0.04);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f2f2f2;
}
.rules-editor {
  width: 100%;
  min-height: 18rem;
  max-height: min(60vh, 34rem);
  margin-top: 0.4rem;
  font-family: var(--font-body);
  line-height: 1.45;
  resize: vertical;
  overflow-y: auto;
  display: block;
}
.rules-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin: 0.75rem 0;
}
.rules-actions.sticky-actions {
  position: sticky;
  top: 0.65rem;
  z-index: 5;
  padding: 0.55rem 0;
  background: linear-gradient(180deg, var(--bg2) 70%, transparent);
}
.err-msg {
  color: #f0a0a0;
  margin: 0.5rem 0;
}
.lineup-actions,
.lineup-clear-form {
  display: inline-block;
  margin-top: 0.75rem;
  margin-right: 0.55rem;
  vertical-align: middle;
}

.history-week-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.history-week-head h3 {
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  margin: 0;
  font-weight: 400;
}
.history-week-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  font-weight: 600;
}
.history-total { font-family: var(--font-mono); }
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.history-table th,
.history-table td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.6rem;
  text-align: left;
}
.history-table th {
  background: #1f1f1f;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.history-table .num,
.history-table th.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.history-table .pos {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  width: 3.5rem;
}
.history-table tfoot td {
  font-weight: 700;
  background: rgba(255, 255, 255, 0.04);
}
.result {
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--line);
}
.result-w { color: #b8d4b8; }
.result-l { color: #d0a0a0; }
.result-t { color: var(--muted); }
.used-list {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
}
.used-list li { margin-bottom: 0.35rem; }

a.btn.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 500;
  text-decoration: none;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
}

@media (max-width: 820px) {
  .topbar {
    padding: 0.75rem 1rem;
    gap: 0.65rem;
  }
  .brand {
    font-size: 1.05rem;
    max-width: 100%;
  }
  .brand-mark {
    width: 2.1rem;
    height: 2.1rem;
  }
  .nav {
    width: 100%;
    gap: 0.55rem 0.85rem;
  }
  .nav a {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
  }
  .meta {
    font-size: 0.72rem;
  }
  .wrap {
    padding: 0.85rem 0.75rem 2.5rem;
  }
  .hero-football {
    flex-direction: column;
    text-align: center;
    padding: 0.85rem;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
  }
  .hero-football img {
    width: min(120px, 38vw);
  }
  .hero-football-copy {
    text-align: center;
    max-width: none;
  }
  .hero-football-copy h1 {
    font-size: clamp(1.55rem, 7vw, 2.1rem);
  }
  .hero-football-copy p {
    font-size: 0.88rem;
  }

  /* Keep true side-by-side H2H on phones; shrink to fit the viewport */
  .h2h {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    margin-bottom: 1rem;
  }
  .h2h-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr) !important;
    min-width: 0 !important;
    width: 100%;
  }
  .h2h-side {
    min-width: 0;
    width: auto;
  }
  .h2h-vs {
    writing-mode: horizontal-tb;
    transform: none;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
  }
  .h2h-name {
    font-size: 0.92rem;
    padding: 0.35rem 0.2rem;
    line-height: 1.15;
  }
  .h2h-cols {
    display: grid !important;
    grid-template-columns: 40px minmax(0, 1fr) !important;
    min-height: 1.85rem;
  }
  .h2h-cols.mirror {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 40px !important;
  }
  .h2h-cols > div {
    padding: 0.22rem 0.25rem;
    font-size: 0.78rem;
  }
  .h2h-pts {
    font-size: 0.9rem;
  }
  .h2h-player {
    font-size: 0.74rem;
    overflow-wrap: anywhere;
    line-height: 1.2;
  }
  .h2h-total {
    font-size: 1.45rem;
    padding: 0.25rem;
  }

  .h2h-editors, .grid-2 { grid-template-columns: 1fr; }
  .edit-row { grid-template-columns: 52px 1fr; }
  .edit-row-def { grid-template-columns: 52px 1fr; }
  .edit-row input:last-child { grid-column: 2; }
  .edit-row-def input { grid-column: 2; }
  .slot-form { grid-template-columns: 1fr 1fr; }
}
