/* Ralph Wilson Jr. founded the Buffalo Bills, so the league wears their colors. */
:root {
  --navy: #00338d;
  --navy-lift: #0b45ad;
  --red: #c60c30;
  --bg: #0c1018;
  --panel: #141b27;
  --panel-2: #1a2331;
  --line: #26314400;
  --border: #253046;
  --ink: #e8edf6;
  --ink-dim: #97a3b8;
  --ink-faint: #6b7688;
  --gold: #e0b040;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  /* Ordinal ramp for season finish: one hue, monotone lightness. On a dark
     surface the light end anchors the strong value, so 1st is brightest and
     10th recedes. Every cell also prints its number, so color is never the
     only encoding. Steps 1-5 take dark ink, 6-10 light ink. */
  --f1:  #dbe9ff;  --f2:  #b6d2f8;  --f3:  #93bbef;  --f4:  #74a4e2;  --f5:  #5b8ed0;
  --f6:  #4678b8;  --f7:  #37629c;  --f8:  #2c4f7f;  --f9:  #253e62;  --f10: #22324a;

  --accent: var(--ink-dim);   /* overridden per franchise from its logo hue */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(1180px, calc(100% - 2rem)); margin-inline: auto; }

/* ---------------------------------------------------------------- chrome */

/* The banner echoes the hero rather than sitting on a flat block of Bills
   navy: same dark base, same navy glow, with the red kept as a thin accent
   rule and the active-tab marker. */
.topbar {
  background:
    radial-gradient(700px 120px at 8% 130%, rgba(0,51,141,.5), transparent 70%),
    linear-gradient(180deg, #16203a 0%, #0f1626 100%);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--red) 0%, var(--navy-lift) 38%, transparent 72%);
}
.topbar .wrap { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; padding: .7rem 0; position: relative; z-index: 1; }

.brand { text-decoration: none; color: #fff; }
.brand strong { font-size: 15.5px; font-weight: 650; letter-spacing: -.1px; }

#nav { display: flex; gap: .15rem; margin-left: auto; flex-wrap: wrap; }
#nav a {
  position: relative;
  color: #a8b8d8; text-decoration: none; font-size: 13px; font-weight: 550;
  padding: .4rem .7rem; border-radius: 6px;
  transition: color .12s ease, background .12s ease;
}
#nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
#nav a.active { background: rgba(255,255,255,.07); color: #fff; }
#nav a.active::after {
  content: ""; position: absolute; left: .7rem; right: .7rem; bottom: 1px; height: 2px;
  background: var(--red); border-radius: 2px;
}

.footer { margin: 3rem 0 2.5rem; color: var(--ink-faint); font-size: 12.5px; }
.footer p { margin: .35rem 0; }
.fine { max-width: 70ch; }

/* ---------------------------------------------------------------- layout */

main { padding-top: 1.6rem; min-height: 60vh; }
.loading { color: var(--ink-dim); padding: 3rem 0; }

h1 { font-size: 25px; margin: 0 0 .2rem; letter-spacing: -.2px; }
h2 { font-size: 17px; margin: 2.2rem 0 .8rem; letter-spacing: -.1px; }
h2:first-of-type { margin-top: 1.4rem; }
.sub { color: var(--ink-dim); margin: 0 0 1.4rem; font-size: 14px; }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }

/* ---------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: .5rem .7rem; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th.l, td.l { text-align: left; }
/* No sticky headers: every table lives inside .scroller, which is a scroll
   container, so a `top` offset would push the header down over the first row
   instead of pinning it to the viewport. */
thead th {
  background: var(--panel-2); color: var(--ink-dim);
  font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
}
tbody tr { border-top: 1px solid var(--border); }
tbody tr:hover { background: rgba(255,255,255,.028); }
td.num, th.num { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }
.scroller { overflow-x: auto; }

a.team { color: var(--ink); text-decoration: none; font-weight: 550; }
a.team:hover { color: #fff; text-decoration: underline; text-underline-offset: 2px; }

/* Team logos are user uploads of wildly different shapes, so they're always
   cropped square rather than trusted to fit. */
.logo {
  display: inline-block; vertical-align: middle;
  width: 22px; height: 22px; border-radius: 5px;
  object-fit: cover; background: var(--panel-2);
  border: 1px solid var(--border); margin-right: .45rem;
}
.logo.lg { width: 30px; height: 30px; border-radius: 6px; }
/* NB: not named .hero — that class is the page-hero panel, and an <img> that
   matched both inherited its 1.6rem padding and shrank to a third of its box. */
.logo.xl {
  width: 72px; height: 72px; border-radius: 12px; margin: 0;
  border-width: 2px;
}
.hero-head { display: flex; align-items: center; gap: 1rem; margin-bottom: .2rem; }
.hero-head > div { min-width: 0; }
.hero-head h1 { margin: 0; }
.logo-fallback {
  display: inline-grid; place-items: center;
  font: 700 9px/1 var(--mono); color: var(--ink-faint); letter-spacing: .3px;
}
.logo-fallback.xl { font-size: 22px; }
td .team-cell { display: flex; align-items: center; }

.rank { color: var(--ink-faint); font-family: var(--mono); font-size: 12px; width: 2.2rem; }
.dim { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.pos { color: var(--ink-faint); font-family: var(--mono); font-size: 11.5px; }

/* ---------------------------------------------------------------- bits */

.pill {
  display: inline-block; padding: .1rem .45rem; border-radius: 4px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  background: var(--panel-2); color: var(--ink-dim); border: 1px solid var(--border);
}
.pill.sf { background: rgba(0,51,141,.5); color: #9fbdf5; border-color: #24417e; }
.pill.qb1 { background: rgba(198,12,48,.18); color: #f0919f; border-color: #6b2030; }
.pill.gold { background: rgba(224,176,64,.15); color: var(--gold); border-color: #6a5423; }
.pill.playoff { background: rgba(0,51,141,.5); color: #9fbdf5; border-color: #24417e; }
.pill.consolation { background: rgba(255,255,255,.04); color: var(--ink-faint); }

.rings { color: var(--gold); letter-spacing: -1px; font-size: 12px; }

.stat { padding: .9rem 1rem; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-faint); }
.stat .v { font-size: 23px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.stat .n { font-size: 12px; color: var(--ink-dim); }

.toggle { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; padding: 2px; gap: 2px; }
.toggle button {
  background: none; border: 0; color: var(--ink-dim); cursor: pointer;
  font: inherit; font-size: 12.5px; padding: .3rem .7rem; border-radius: 5px;
}
.toggle button.on { background: var(--navy-lift); color: #fff; }
.controls { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin-bottom: .9rem; }

/* champions rail */
.champ-row {
  display: flex; align-items: center; gap: .9rem;
  padding: .6rem .9rem; border-top: 1px solid var(--border);
}
.champ-row:first-child { border-top: 0; }
.champ-year { font: 600 13px var(--mono); color: var(--ink-faint); width: 3.2rem; flex: 0 0 3.2rem; }
.champ-name { font-weight: 600; }
.champ-beat { color: var(--ink-faint); font-size: 12.5px; margin-left: auto; text-align: right; }

/* head to head matrix */
.h2h { font-size: 12px; }
.h2h th, .h2h td { padding: .35rem .4rem; text-align: center; }
.h2h th:first-child, .h2h td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); z-index: 1; }
.h2h thead th { font-size: 10px; letter-spacing: .3px; }
.h2h td.self { background: var(--panel-2); color: var(--ink-faint); }
.h2h td.win { color: #7ddc9a; }
.h2h td.loss { color: #f28b9b; }
.h2h td.even { color: var(--ink-dim); }

.note { color: var(--ink-faint); font-size: 12.5px; margin: .6rem 0 0; }

@media (max-width: 640px) {
  .brand strong { font-size: 13.5px; }
  h1 { font-size: 21px; }
}

/* ================================================================ polish */

h1 { font-weight: 750; letter-spacing: -.5px; }
h2 {
  font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  font-size: 12px; color: var(--ink-dim);
  display: flex; align-items: center; gap: .7rem;
}
h2::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.panel { transition: border-color .15s ease, transform .15s ease; }
.stat {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, rgba(255,255,255,.028), transparent 60%);
}
.stat::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 2px;
  background: var(--accent); opacity: .8;
}
.stat .v { letter-spacing: -.5px; }

/* ---------------------------------------------------------------- hero */

.hero {
  position: relative; overflow: hidden;
  border: 1px solid var(--border); border-radius: 14px;
  background:
    radial-gradient(1100px 300px at 12% -40%, rgba(0,51,141,.55), transparent 70%),
    linear-gradient(150deg, #16203a 0%, var(--panel) 55%);
  padding: 1.6rem 1.5rem 1.5rem;
  margin-bottom: 1rem;
}
/* Faint yard lines — enough to read as a field, not enough to fight the text. */
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 58px, rgba(255,255,255,.045) 58px 59px);
  mask-image: linear-gradient(90deg, transparent, #000 40%, #000 75%, transparent);
}
.hero h1 { font-size: clamp(26px, 4.4vw, 40px); line-height: 1.05; max-width: 18ch; }
.hero .kicker {
  font: 700 11px/1 var(--mono); letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--gold); margin-bottom: .7rem;
}
.hero .lede { color: var(--ink-dim); margin: .6rem 0 0; max-width: 56ch; font-size: 14px; }

/* ---------------------------------------------------------- trophy case */

.trophies { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: .6rem; align-items: stretch; }
.trophy {
  position: relative; display: block; text-decoration: none; color: inherit;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: .85rem .8rem .75rem;
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
}
.trophy::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  border-radius: 10px 10px 0 0; background: var(--accent);
}
.trophy:hover { transform: translateY(-2px); border-color: var(--accent); background: var(--panel-2); }
.trophy .yr { font: 700 20px/1 var(--mono); letter-spacing: -1px; }
.trophy .who { display: flex; align-items: center; gap: .4rem; margin-top: .55rem; font-weight: 650; font-size: 13px; }
.trophy .who .logo { width: 26px; height: 26px; margin: 0; flex: 0 0 26px; }
.trophy .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trophy .beat { color: var(--ink-faint); font-size: 11.5px; margin-top: .4rem; }
.trophy { display: flex; flex-direction: column; }
.trophy .beat { margin-top: auto; padding-top: .4rem; }
.trophy .beat b { color: var(--ink-dim); font-weight: 550; }

/* --------------------------------------------------------- dynasty grid */

.dyn { width: 100%; max-width: 840px; border-collapse: separate; border-spacing: 3px; }
.dyn th {
  background: none; font: 600 10px/1 var(--mono); letter-spacing: .4px;
  color: var(--ink-faint); text-transform: none; padding: 0 0 .35rem;
}
/* Shrink-to-fit so a team's name sits beside its own row of cells; the
   year columns then share the remaining width evenly. */
.dyn th.team-h { text-align: left; padding-right: .8rem; width: 1%; white-space: nowrap; }
.dyn td { padding: 0; text-align: center; }
.dyn tbody tr { border: 0; }
.dyn tbody tr:hover { background: none; }
.dyn .cell {
  position: relative; display: grid; place-items: center;
  height: 30px; min-width: 32px; border-radius: 5px;
  font: 700 11.5px/1 var(--mono);
  cursor: default; transition: transform .1s ease, box-shadow .1s ease;
}
.dyn .cell:hover { transform: scale(1.12); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--ink-dim); z-index: 3; }
.dyn .cell.champ { box-shadow: inset 0 0 0 2px var(--gold); }
.dyn .cell.champ::after {
  content: "★"; position: absolute; top: -4px; right: -3px;
  font-size: 10px; color: var(--gold); text-shadow: 0 0 3px var(--bg);
}
.dyn .cell.absent { background: repeating-linear-gradient(45deg, transparent 0 4px, rgba(255,255,255,.04) 4px 8px); }
.dyn .team-c { display: flex; align-items: center; font-size: 12.5px; }

.legend { display: flex; align-items: center; gap: .5rem; margin-top: .9rem; font-size: 11.5px; color: var(--ink-faint); }
.legend .steps { display: flex; gap: 2px; }
.legend .steps i { width: 17px; height: 10px; border-radius: 2px; display: block; }

#tip {
  position: fixed; z-index: 60; pointer-events: none; opacity: 0;
  transition: opacity .1s ease;
  background: #0a0e16; border: 1px solid var(--border); border-radius: 8px;
  padding: .5rem .65rem; font-size: 12px; line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0,0,0,.55); max-width: 250px;
}
#tip.on { opacity: 1; }
#tip .t { font-weight: 700; margin-bottom: .15rem; }
#tip .r { color: var(--ink-dim); }
#tip .g { color: var(--gold); }

/* ------------------------------------------------------- franchise page */

.hero-head { position: relative; }
.hero-head .logo.xl { box-shadow: 0 0 0 1px var(--border), 0 6px 22px -6px var(--accent); border-color: var(--accent); }
.accent-rule { height: 2px; background: linear-gradient(90deg, var(--accent), transparent 70%); border-radius: 2px; margin: .9rem 0 1.2rem; }

/* A franchise's ten finishes as one strip — the dynasty arc at a glance. */
.arc { display: flex; gap: 3px; align-items: flex-end; }
.arc i { flex: 1; border-radius: 2px 2px 0 0; min-width: 6px; display: block; }

@media (max-width: 640px) {
  .dyn th.team-h { min-width: 108px; }
  .dyn .cell { min-width: 27px; }
  .dyn .cell { height: 26px; font-size: 10.5px; }
  .hero { padding: 1.2rem 1rem; }
}

.pill.inj { background: rgba(198,12,48,.18); color: #f0919f; border-color: #6b2030; }
.pill.own { background: rgba(0,51,141,.42); color: #9fbdf5; border-color: #24417e; }

/* ------------------------------------------------------- franchise subnav */

.subnav {
  display: flex; gap: .2rem; flex-wrap: wrap;
  margin: 1.6rem 0 1.2rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;          /* the strip scrolls on narrow screens; */
}
.subnav::-webkit-scrollbar { display: none; }   /* the bar itself is noise */
.subnav a {
  position: relative;
  color: var(--ink-dim); text-decoration: none;
  font-size: 13px; font-weight: 600; letter-spacing: .2px;
  padding: .5rem .85rem .6rem; white-space: nowrap;
  border-radius: 6px 6px 0 0;
  transition: color .12s ease, background .12s ease;
}
.subnav a:hover { color: var(--ink); background: rgba(255,255,255,.04); }
.subnav a.on { color: var(--ink); }
.subnav a.on::after {
  content: ""; position: absolute; left: .5rem; right: .5rem; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0;
}
.tabpanel > h2:first-child { margin-top: 0; }

/* "still on the roster" — green rather than the neutral pill grey */
.pill.live { background: rgba(125,220,154,.14); color: #7ddc9a; border-color: #2f6b45; }
