/* ==========================================================================
   Janafari — Madden 27 ratings tracker
   v3 (2026-09-12): one stylesheet, three breakpoints, no overlap.
     phone   ≤ 600px   one column of row-cards, bottom tab bar, sticky search
     tablet  601–1024  header in one row, search on its own row, 2–3 columns
     desktop > 1024    one-row toolbar, 4 columns, 1240px wrap
   Rules that keep the old iPad working: no flex `gap` (margins instead),
   every `gap` on a grid has a `grid-gap` twin, plain colour fallbacks sit
   before every var(), no webfonts, ES5 in app.js.
   ========================================================================== */

:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --line: #d9e0e8;
  --text: #0b1f3a;
  --muted: #5b6b7c;
  --navy: #041c38;
  --navy-2: #0b2a4f;
  --gold: #fdbb30;
  --gold-ink: #0b1f3a;
  --scarlet: #ba0c2f;
  --up: #1b8f4a;
  --down: #c0392b;
  --shadow: 0 6px 20px rgba(4, 28, 56, .10);
  --radius: 14px;
  --gutter: 12px;
  --tabbar: 0px;
}
html[data-theme="dark"] {
  --bg: #07111f;
  --surface: #0f1d31;
  --surface-2: #14243b;
  --line: #22344d;
  --text: #eef3f9;
  --muted: #9aacc0;
  --navy: #05101f;
  --navy-2: #0b1d36;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { background: #eef1f5; background: var(--bg); color-scheme: light; -webkit-text-size-adjust: 100%; }
html[data-theme="dark"] { color-scheme: dark; }
body {
  margin: 0;
  min-width: 320px;
  color: #0b1f3a; color: var(--text);
  background: #eef1f5; background: var(--bg);
  font-family: "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--tabbar);
}
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button { -webkit-tap-highlight-color: transparent; }
/* Focus: always visible by default; only browsers that know :focus-visible hide it for mouse clicks
   (an unknown pseudo-class voids a rule, so old Safari simply keeps the ring — the safe direction). */
:focus { outline: 3px solid #fdbb30; outline: 3px solid var(--gold); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 3px solid #fdbb30; outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 12px; padding: 0 var(--gutter); }

/* ---------- header ---------- */
.topbar { background: #041c38; background: var(--navy); color: #fff; }
.masthead {
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between;
  min-height: 56px;
  padding: 4px 0;
}
.brand { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; min-height: 44px; color: #fff; text-decoration: none; min-width: 0; }
/* One line: mark · wordmark · descriptor, all sharing one vertical centre. The descriptor used to sit UNDER
   the wordmark, which pushed the emblem's centre off the wordmark's centre (owner: "the emblem needs to be
   centered"). Now the mark is 36px and the wordmark's cap-height sits on the mark's midline. */
.j-mark { -webkit-flex: 0 0 auto; flex: 0 0 auto; width: 36px; height: 36px; margin-right: 10px; display: block; }
.brand-text { min-width: 0; display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; }
.brand-name { margin: 0; line-height: 0; -webkit-flex: 0 0 auto; flex: 0 0 auto; }   /* the heading IS the wordmark (SVG paths, no font) */
.brand-name .wordmark { display: block; height: 22px; width: auto; }
.brand-desc { display: none; margin: 2px 0 0 12px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.25); font-size: 12px; line-height: 1.2; color: rgba(255,255,255,.72); white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 1100px) { .brand-desc { display: block; } }   /* only where it can never meet the buttons (a half-width desktop window is ~900px) */

.header-actions { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; -webkit-flex: 0 0 auto; flex: 0 0 auto; }
.header-actions > * + * { margin-left: 8px; }

.button {
  display: -webkit-inline-box; display: -webkit-inline-flex; display: inline-flex;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center;
  min-height: 44px; min-width: 44px; padding: 0 14px;
  border: 0; border-radius: 12px;
  font-weight: 700; font-size: 15px; white-space: nowrap;
  color: #fff; background: rgba(255,255,255,.12);
}
.button:active { -webkit-transform: scale(.97); transform: scale(.97); }
.button-gold { color: #0b1f3a; color: var(--gold-ink); background: #fdbb30; background: var(--gold); }
.button-icon { padding: 0; width: 44px; font-size: 20px; }
.button-quiet { color: #0b1f3a; color: var(--text); background: #f4f6f9; background: var(--surface-2); border: 1px solid #d9e0e8; border-color: var(--line); }
.button .icon { font-size: 18px; line-height: 1; }
.button .icon + .label { margin-left: 7px; }

/* ---------- the one-line stat strip ---------- */
.statline {
  display: -webkit-box; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  margin: 0 -4px; padding: 0 0 6px;
  color: rgba(255,255,255,.78); font-size: 13px;
}
.statline .stat-source { margin: 4px 6px; font-size: 12px; color: rgba(255,255,255,.6); white-space: nowrap; }
.statline .stat { margin: 4px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.08); white-space: nowrap; }
.statline .stat b { color: #fff; font-size: 15px; margin-right: 4px; }
.statline .stat.gold b { color: #fdbb30; color: var(--gold); }

/* ---------- tabs ---------- */
.tabs { display: -webkit-box; display: -webkit-flex; display: flex; }
.tablist { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-flex: 1; -webkit-flex: 1 1 auto; flex: 1 1 auto; }
.tab {
  -webkit-box-flex: 1; -webkit-flex: 1 1 0; flex: 1 1 0;
  min-height: 44px; padding: 0 10px;
  border: 0; border-bottom: 3px solid transparent;
  background: transparent; color: rgba(255,255,255,.72);
  font-weight: 700; font-size: 15px;
  display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center;
}
.tab .tab-icon { font-size: 18px; line-height: 1; margin-right: 7px; }
.tab.active { color: #fff; border-bottom-color: #fdbb30; border-bottom-color: var(--gold); }
.tab-count { margin-left: 7px; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: rgba(255,255,255,.14); }
.tab.active .tab-count { background: #fdbb30; background: var(--gold); color: #0b1f3a; }
.tab-add { display: none; }

/* ---------- board ---------- */
.board { padding-top: 6px; }
.toolbar {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 5;
  margin: 0 -12px; margin: 0 calc(var(--gutter) * -1); padding: 8px 12px; padding: 8px var(--gutter);
  background: #eef1f5; background: var(--bg);
}
.toolbar-row { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; }
.toolbar-row + .toolbar-row { margin-top: 8px; }
/* phone + tablet: the search owns its row; chips and the view toggle share the next one */
.toolbar-row.merge { -webkit-flex-wrap: wrap; flex-wrap: wrap; }
.toolbar-row.merge .search-box { -webkit-flex: 1 1 100%; flex: 1 1 100%; }
.toolbar-row.merge .chips-wrap, .toolbar-row.merge .view-group { margin-top: 8px; }
.search-box {
  position: relative; display: block; -webkit-box-flex: 1; -webkit-flex: 1 1 auto; flex: 1 1 auto; min-width: 0;
}
.search-box .search-icon { position: absolute; left: 14px; top: 50%; margin-top: -11px; font-size: 20px; line-height: 22px; color: #5b6b7c; color: var(--muted); pointer-events: none; }
.search-box input {
  width: 100%; min-height: 48px; padding: 0 44px 0 42px;
  border: 1px solid #d9e0e8; border-color: var(--line); border-radius: 12px;
  background: #fff; background: var(--surface); color: #0b1f3a; color: var(--text);
  font-size: 16px; /* 16px stops iOS zooming into the field */
  -webkit-appearance: none; appearance: none;
}
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-clear {
  position: absolute; right: 2px; top: 2px; width: 44px; height: 44px;
  border: 0; background: transparent; color: #5b6b7c; color: var(--muted); font-size: 22px; border-radius: 10px;
}
.chips-wrap { position: relative; -webkit-box-flex: 1; -webkit-flex: 1 1 auto; flex: 1 1 auto; min-width: 0; }
.chips-wrap:after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 28px; pointer-events: none; background: -webkit-linear-gradient(left, rgba(238,241,245,0), #eef1f5); background: linear-gradient(to right, rgba(238,241,245,0), #eef1f5); background: linear-gradient(to right, rgba(238,241,245,0), var(--bg)); opacity: 0; -webkit-transition: opacity .15s; transition: opacity .15s; }
.chips-wrap.has-more:after { opacity: 1; }
html[data-theme="dark"] .chips-wrap:after { background: -webkit-linear-gradient(left, rgba(7,17,31,0), #07111f); background: linear-gradient(to right, rgba(7,17,31,0), #07111f); }
.chips { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-flex: 1; -webkit-flex: 1 1 auto; flex: 1 1 auto; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips > * + * { margin-left: 8px; }
.chip {
  -webkit-flex: 0 0 auto; flex: 0 0 auto;
  min-height: 44px; padding: 0 14px;
  border: 1px solid #d9e0e8; border-color: var(--line); border-radius: 999px;
  background: #fff; background: var(--surface); color: #0b1f3a; color: var(--text);
  font-weight: 700; font-size: 14px; white-space: nowrap;
}
.chip .chip-count { margin-left: 6px; color: #5b6b7c; color: var(--muted); font-weight: 600; }
.chip.active { background: #041c38; background: var(--navy); border-color: #041c38; border-color: var(--navy); color: #fff; }
.chip.active .chip-count { color: #fdbb30; color: var(--gold); }
.chip-team { padding-left: 10px; }
.chip-team img { width: 22px; height: 22px; margin-right: 7px; vertical-align: middle; }
.chip-team .chip-caret { margin-left: 6px; font-size: 11px; opacity: .7; }
.chip-team.active { background: #0057b8; border-color: #0057b8; color: #fff; }

/* team picker: a grid of logos a kid can tap */
.team-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-gap: 8px; gap: 8px; }
.team-cell {
  display: block; width: 100%; min-height: 84px; padding: 10px 4px 8px;
  border: 1px solid #d9e0e8; border-color: var(--line); border-radius: 12px;
  background: #fff; background: var(--surface); color: #0b1f3a; color: var(--text);
  text-align: center; font-weight: 700; font-size: 12px;
}
.team-cell img, .team-cell .team-mono { display: block; width: 40px; height: 40px; margin: 0 auto 6px; }
.team-cell .team-mono { border-radius: 50%; line-height: 40px; color: #fff; font-size: 14px; background: #5b6b7c; }
.team-cell span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-cell.active { border-color: #0057b8; box-shadow: 0 0 0 2px #0057b8 inset; }
.team-cell.team-all { grid-column: 1 / -1; min-height: 52px; padding: 12px; font-size: 15px; }
.team-cell.team-all.active { background: #041c38; background: var(--navy); color: #fff; }
@media (min-width: 601px) { .team-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (min-width: 1025px) { .team-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); } }

.view-group { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-flex: 0 0 auto; flex: 0 0 auto; margin-left: 10px; }
.view-btn { min-width: 44px; min-height: 44px; padding: 0 12px; border: 1px solid #d9e0e8; border-color: var(--line); background: #fff; background: var(--surface); color: #5b6b7c; color: var(--muted); font-size: 18px; }
.view-btn:first-child { border-radius: 12px 0 0 12px; }
.view-btn:last-child { border-radius: 0 12px 12px 0; margin-left: -1px; }
.view-btn.active { background: #041c38; background: var(--navy); border-color: #041c38; border-color: var(--navy); color: #fff; }

.week-row .chip { -webkit-box-flex: 1; -webkit-flex: 1 1 auto; flex: 1 1 auto; min-width: 0; width: 100%; max-width: 360px; }   /* a select must shrink on a 320px phone */
.invite {
  position: relative; display: -webkit-box; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  margin: 6px 0 2px; padding: 8px 44px 8px 12px;
  border-radius: 14px; border: 1px solid #fdbb30; border-color: var(--gold);
  background: #fff8e3; color: #0b1f3a;
}
html[data-theme="dark"] .invite { background: #1a2740; color: #eef3f9; }
.invite-text { -webkit-box-flex: 1; -webkit-flex: 1 1 180px; flex: 1 1 180px; margin: 2px 12px 2px 0; font-size: 14px; line-height: 1.35; }
.invite .button { margin: 4px 0; }
.invite-close { position: absolute; top: 4px; right: 4px; width: 44px; height: 44px; border: 0; background: transparent; color: inherit; font-size: 24px; border-radius: 10px; opacity: .7; }
.board-note { margin: 8px 0 0; color: #5b6b7c; color: var(--muted); font-size: 13px; }

/* ---------- cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-gap: 10px; gap: 10px;
  margin-top: 10px;
}
.pcard {
  position: relative;
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  width: 100%; min-width: 0; min-height: 84px; padding: 10px 12px 10px 10px;
  border: 1px solid #d9e0e8; border-color: var(--line); border-radius: 14px; border-radius: var(--radius);
  background: #fff; background: var(--surface);
  text-align: left; cursor: pointer;
  -webkit-transition: box-shadow .15s; transition: box-shadow .15s;
}
.pcard:hover { box-shadow: 0 6px 20px rgba(4,28,56,.10); box-shadow: var(--shadow); }
.pcard:active { -webkit-transform: scale(.99); transform: scale(.99); }
.pcard.is-watched { border-left: 4px solid #fdbb30; border-left-color: var(--gold); }

.portrait {
  position: relative; -webkit-flex: 0 0 auto; flex: 0 0 auto; overflow: hidden;
  width: 60px; height: 60px; border-radius: 50%;
  background: #174a6e; color: #fff; text-align: center;
  border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.06);
}
html[data-theme="dark"] .portrait { border-color: #14243b; }
.portrait .portrait-mono { display: block; line-height: 56px; font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.portrait img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; -webkit-transition: opacity .2s; transition: opacity .2s; }
.portrait.has-photo img { opacity: 1; }
.portrait.has-photo .portrait-mono { visibility: hidden; }

.pcard-body { -webkit-box-flex: 1; -webkit-flex: 1 1 auto; flex: 1 1 auto; min-width: 0; margin-left: 12px; }
.pcard-name { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard-meta { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; margin-top: 5px; min-width: 0; color: #5b6b7c; color: var(--muted); font-size: 13px; }
.pcard-meta > * + * { margin-left: 8px; }
.pos-pill { -webkit-flex: 0 0 auto; flex: 0 0 auto; padding: 2px 7px; border-radius: 6px; background: #f4f6f9; background: var(--surface-2); color: #0b1f3a; color: var(--text); font-size: 12px; font-weight: 800; letter-spacing: .5px; }
.team-logo { -webkit-flex: 0 0 auto; flex: 0 0 auto; width: 20px; height: 20px; }
.pcard-team { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard-rank { display: block; margin-bottom: 2px; font-size: 11px; font-weight: 700; color: #5b6b7c; color: var(--muted); }   /* in the right column, in flow — never over the portrait */

.pcard-right { -webkit-flex: 0 0 auto; flex: 0 0 auto; margin-left: 10px; text-align: center; min-width: 52px; }
.ovr { display: block; font-size: 30px; line-height: 1; font-weight: 900; letter-spacing: -1px; font-family: "Avenir Next Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif; }
.ovr small { display: block; margin-top: 2px; font-size: 10px; letter-spacing: 1.5px; font-weight: 700; color: #5b6b7c; color: var(--muted); }
.is-99 .ovr { color: #b8860b; }
html[data-theme="dark"] .is-99 .ovr { color: #fdbb30; color: var(--gold); }
.change { display: inline-block; margin-top: 4px; padding: 1px 6px; border-radius: 6px; font-size: 12px; font-weight: 800; }
.change-up { color: #1b8f4a; color: var(--up); background: rgba(27,143,74,.12); }
.change-down { color: #c0392b; color: var(--down); background: rgba(192,57,43,.12); }
.change-flat { color: #5b6b7c; color: var(--muted); }
.pcard .change-flat { display: none; }   /* on a card, "no change" is silence; the list still shows the dash */
.change-new { color: #0057b8; background: rgba(0,87,184,.12); }
.change-none { display: none; }
.watch-star { color: #b8860b; font-size: 12px; }
html[data-theme="dark"] .watch-star { color: #fdbb30; color: var(--gold); }

/* ---------- list ---------- */
.table-wrap { margin-top: 10px; border: 1px solid #d9e0e8; border-color: var(--line); border-radius: 14px; background: #fff; background: var(--surface); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 12px; text-align: left; font-size: 11px; letter-spacing: 1px; color: #5b6b7c; color: var(--muted); border-bottom: 1px solid #d9e0e8; border-bottom-color: var(--line); }
td { padding: 8px 12px; border-bottom: 1px solid #d9e0e8; border-bottom-color: var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.prow { cursor: pointer; }
tr.prow:hover { background: #f4f6f9; background: var(--surface-2); }
tr.prow:focus-visible { outline: 3px solid #fdbb30; outline-offset: -3px; }
.rank-col { width: 44px; color: #5b6b7c; color: var(--muted); font-weight: 700; }
.center { text-align: center; }
.player-wrap { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; min-height: 48px; }
.player-wrap .portrait { width: 44px; height: 44px; }
.player-wrap .portrait .portrait-mono { line-height: 40px; font-size: 15px; }
.player-info { margin-left: 10px; min-width: 0; }
.player-name { display: block; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-sub { display: block; font-size: 12px; color: #5b6b7c; color: var(--muted); }
.ovr-badge { display: inline-block; min-width: 44px; padding: 6px 8px; border-radius: 10px; background: #041c38; background: var(--navy); color: #fff; font-weight: 900; font-size: 17px; text-align: center; }
.ovr-badge.ovr-99 { background: #fdbb30; background: var(--gold); color: #0b1f3a; }
.col-trend, .col-change { width: 90px; }
.sparkline { width: 90px; height: 28px; display: block; }
.sparkline line { stroke: #d9e0e8; stroke: var(--line); stroke-width: 1; }
.sparkline polyline { fill: none; stroke: #0057b8; stroke-width: 2; }
.sparkline circle { fill: #fdbb30; fill: var(--gold); }

/* ---------- show more / empty / footer ---------- */
.more-row { text-align: center; margin: 14px 0 4px; }
.empty-state { margin-top: 14px; padding: 36px 20px; border-radius: 14px; background: #fff; background: var(--surface); border: 1px dashed #d9e0e8; border-color: var(--line); text-align: center; }
.empty-icon { font-size: 40px; line-height: 1; }
.empty-title { display: block; margin-top: 10px; font-size: 17px; }
.empty-hint { margin: 6px auto 0; max-width: 360px; color: #5b6b7c; color: var(--muted); font-size: 14px; }
.empty-state .button { margin-top: 14px; }
footer { padding: 26px 0 30px; color: #5b6b7c; color: var(--muted); font-size: 12px; text-align: center; line-height: 1.7; }
footer a { color: inherit; display: inline-block; min-height: 44px; line-height: 44px; padding: 0 6px; }

/* ---------- toast ---------- */
.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; bottom: calc(24px + var(--tabbar)); max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; background: #0b1f3a; color: #fff; font-weight: 700; font-size: 14px; opacity: 0; -webkit-transform: translate(-50%, 12px); transform: translate(-50%, 12px); -webkit-transition: opacity .2s, -webkit-transform .2s; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; -webkit-transform: translate(-50%, 0); transform: translate(-50%, 0); }
html[data-theme="dark"] .toast { background: #fdbb30; color: #0b1f3a; }

/* ---------- modals ---------- */
.modal { position: fixed; z-index: 20; top: 0; right: 0; bottom: 0; left: 0; }
.modal-backdrop { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: rgba(4,28,56,.62); }
.modal-sheet {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;   /* phone: full screen */
  display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-orient: vertical; -webkit-flex-direction: column; flex-direction: column;
  background: #fff; background: var(--surface); color: #0b1f3a; color: var(--text);
  padding-top: env(safe-area-inset-top);
}
.modal-head { -webkit-flex: 0 0 auto; flex: 0 0 auto; display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; padding: 10px 12px 10px 16px; border-bottom: 1px solid #d9e0e8; border-bottom-color: var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; }
.kicker { font-size: 11px; letter-spacing: 1.4px; font-weight: 800; color: #5b6b7c; color: var(--muted); text-transform: uppercase; }
.close-button { width: 44px; height: 44px; border: 0; border-radius: 12px; background: #f4f6f9; background: var(--surface-2); color: #0b1f3a; color: var(--text); font-size: 26px; line-height: 1; }
.modal-body { -webkit-box-flex: 1; -webkit-flex: 1 1 auto; flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px 24px; }
.modal-foot { -webkit-flex: 0 0 auto; flex: 0 0 auto; padding: 10px 16px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid #d9e0e8; border-top-color: var(--line); background: #fff; background: var(--surface); }
.modal-foot .button { width: 100%; }
.modal-copy { margin: 0 0 12px; color: #5b6b7c; color: var(--muted); font-size: 14px; }
body.modal-open { position: fixed; left: 0; right: 0; overflow: hidden; }

/* add-player results */
.roster-list .roster-row {
  display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  width: 100%; min-height: 64px; padding: 8px 4px; border: 0; border-bottom: 1px solid #d9e0e8; border-bottom-color: var(--line);
  background: transparent; text-align: left;
}
.roster-row .portrait { width: 44px; height: 44px; }
.roster-row .portrait .portrait-mono { line-height: 40px; font-size: 15px; }
.roster-info { -webkit-box-flex: 1; -webkit-flex: 1 1 auto; flex: 1 1 auto; min-width: 0; margin: 0 10px; }
.roster-info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-info small { display: block; color: #5b6b7c; color: var(--muted); font-size: 12px; }

/* player card modal */
.bio-hero { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; margin: -14px -16px 14px; padding: 18px 16px; color: #fff; }
.bio-hero .portrait { width: 76px; height: 76px; }
.bio-hero .portrait .portrait-mono { line-height: 72px; font-size: 26px; }
.bio-headline { -webkit-box-flex: 1; -webkit-flex: 1 1 auto; flex: 1 1 auto; min-width: 0; margin: 0 12px; }
.bio-headline b { display: block; font-size: 19px; line-height: 1.15; }
.bio-headline span { display: block; margin-top: 4px; font-size: 13px; opacity: .9; }
.bio-headline .change { margin-top: 6px; background: rgba(255,255,255,.18); color: #fff; }
.bio-ovr { -webkit-flex: 0 0 auto; flex: 0 0 auto; text-align: center; font-size: 44px; line-height: 1; font-weight: 900; font-family: "Avenir Next Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif; }
.bio-ovr small { display: block; font-size: 10px; letter-spacing: .8px; text-transform: uppercase; opacity: .85; white-space: nowrap; }
.bio-list { margin: 0; }
.bio-row { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: baseline; -webkit-align-items: baseline; align-items: baseline; padding: 8px 0; border-bottom: 1px solid #d9e0e8; border-bottom-color: var(--line); }
.bio-row dt { -webkit-flex: 0 0 96px; flex: 0 0 96px; color: #5b6b7c; color: var(--muted); font-size: 13px; }
.bio-row dd { margin: 0; -webkit-box-flex: 1; -webkit-flex: 1; flex: 1; font-weight: 700; }
.bio-row dd small { display: block; font-weight: 500; color: #5b6b7c; color: var(--muted); font-size: 12px; }
.bio-none { font-weight: 500; color: #5b6b7c; color: var(--muted); }
.bio-row-abilities dd dd { margin: 0; }
.bio-dt-with-info { -webkit-flex: 0 0 96px; flex: 0 0 96px; color: #5b6b7c; color: var(--muted); font-size: 13px; display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; }
.info-btn { width: 44px; height: 44px; margin: -12px 0 -12px 2px; padding: 0; border: 0; background: transparent; color: #0057b8; display: -webkit-inline-box; display: -webkit-inline-flex; display: inline-flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center; }
.info-btn span { display: block; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #0057b8; font: 900 12px/16px Georgia, "Times New Roman", serif; text-align: center; font-style: italic; }
.info-btn[aria-expanded="true"] span { background: #0057b8; color: #fff; }
.ability-help { margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: #f4f6f9; background: var(--surface-2); font-weight: 500; font-size: 13px; line-height: 1.45; }
.ability-help p { margin: 0 0 6px; }
.ability-help p:last-child { margin-bottom: 0; }
.game-ini-skip { margin-left: 8px; vertical-align: top; min-height: 56px; }
.bio-year, .bio-ring, .ability { display: inline-block; margin: 0 6px 6px 0; padding: 3px 8px; border-radius: 6px; background: #f4f6f9; background: var(--surface-2); font-size: 12px; font-weight: 700; }
.bio-ring { background: #fdbb30; background: var(--gold); color: #0b1f3a; }
.ability-x { background: #ba0c2f; background: var(--scarlet); color: #fff; }
.bio-stats { margin-top: 16px; }
.bio-stats .kicker { margin-bottom: 8px; }
.stat-row { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; padding: 6px 0; }
.stat-label { -webkit-flex: 0 0 140px; flex: 0 0 140px; font-size: 13px; }
.stat-bar { -webkit-box-flex: 1; -webkit-flex: 1; flex: 1; height: 10px; border-radius: 5px; background: #e6ebf1; overflow: hidden; }
html[data-theme="dark"] .stat-bar { background: #22344d; }
.stat-fill { display: block; height: 100%; border-radius: 5px; background: #0057b8; }
.stat-elite { background: #fdbb30; background: var(--gold); }
.stat-value { -webkit-flex: 0 0 64px; flex: 0 0 64px; text-align: right; font-weight: 800; font-size: 14px; }

/* backup / more */
.backup-action { display: block; width: 100%; margin-top: 10px; padding: 14px 16px; border: 1px solid #d9e0e8; border-color: var(--line); border-radius: 12px; background: #f4f6f9; background: var(--surface-2); color: #0b1f3a; color: var(--text); text-align: left; position: relative; }
.backup-action b { display: block; }
.backup-action span { display: block; margin-top: 2px; font-size: 13px; color: #5b6b7c; color: var(--muted); }
.file-action input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.danger-zone { margin-top: 22px; padding-top: 14px; border-top: 1px solid #d9e0e8; border-top-color: var(--line); }
.danger-zone button { min-height: 44px; padding: 0 14px; border: 1px solid #ba0c2f; border-radius: 12px; background: transparent; color: #ba0c2f; font-weight: 700; }
.more-info { margin-top: 18px; font-size: 13px; color: #5b6b7c; color: var(--muted); line-height: 1.5; }
.more-info a { color: #0057b8; font-weight: 700; }

/* ---------- Playbook (help) ---------- */
.help-body { padding-top: 10px; }
.help-nav { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 0 -4px 6px; }
.help-nav .chip { margin: 4px; text-decoration: none; min-height: 44px; font-size: 13px; padding: 0 12px; display: -webkit-inline-box; display: -webkit-inline-flex; display: inline-flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; }
.help-intro { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; -webkit-box-align: center; -webkit-align-items: center; align-items: center; -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; padding: 8px 0 4px; }
.help-intro p { margin: 4px 12px 4px 0; font-weight: 700; }
.help-section { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: start; -webkit-align-items: flex-start; align-items: flex-start; padding: 14px 0; border-top: 1px solid #d9e0e8; border-top-color: var(--line); }
.help-icon { -webkit-flex: 0 0 64px; flex: 0 0 64px; display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center; padding-top: 2px; }
.help-icon-wide { -webkit-flex: 0 0 100%; flex: 0 0 100%; margin-bottom: 8px; }
.help-section-wide { -webkit-flex-wrap: wrap; flex-wrap: wrap; }   /* no :has() — old Safari */
.help-text { -webkit-box-flex: 1; -webkit-flex: 1 1 200px; flex: 1 1 200px; min-width: 0; }
.help-text h3 { margin: 0 0 4px; font-size: 16px; }
.help-text p { margin: 0 0 8px; font-size: 15px; line-height: 1.45; max-width: 40em; }   /* tablet measure (Ava) */
.help-note { font-size: 13px; color: #5b6b7c; color: var(--muted); }
.help-go { min-height: 44px; font-size: 14px; }
.help-btn { display: -webkit-inline-box; display: -webkit-inline-flex; display: inline-flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; background: #041c38; background: var(--navy); color: #fff; font-size: 20px; font-weight: 700; }
.help-btn.gold { background: #fdbb30; background: var(--gold); color: #0b1f3a; }
.help-chip { display: inline-block; padding: 10px 12px; border-radius: 999px; border: 1px solid #d9e0e8; border-color: var(--line); background: #fff; background: var(--surface); font-weight: 700; font-size: 13px; white-space: nowrap; }
.help-chip.dark { background: #041c38; background: var(--navy); border-color: #041c38; color: #fff; }
.help-card { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; width: 100%; max-width: 360px; padding: 10px 12px 10px 10px; border: 1px solid #d9e0e8; border-color: var(--line); border-radius: 14px; background: #fff; background: var(--surface); }
.help-portrait { width: 48px; height: 48px; background: #0057b8; }
.help-portrait .portrait-mono { line-height: 44px; font-size: 18px; }
.help-card-body { -webkit-box-flex: 1; -webkit-flex: 1 1 auto; flex: 1 1 auto; min-width: 0; margin: 0 10px; }
.help-card-body b { display: block; font-size: 15px; }
.help-card-body span { display: block; margin-top: 4px; font-size: 13px; color: #5b6b7c; color: var(--muted); }
.help-card-body .pos-pill { font-style: normal; margin-right: 6px; }
.help-card-ovr { text-align: center; }
.help-card-ovr b { display: block; font-size: 24px; line-height: 1; font-family: "Avenir Next Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif; }
.help-card-ovr small { display: block; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: #5b6b7c; color: var(--muted); }
.invite-tour { margin-left: 8px; }

/* ---------- quick tour ---------- */
.tour-art { min-height: 120px; padding: 14px; margin: 0 0 14px; border-radius: 14px; background: #f4f6f9; background: var(--surface-2); display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center; }
.tour-copy { margin: 0; font-size: 17px; line-height: 1.45; }
.tour-foot { display: -webkit-box; display: -webkit-flex; display: flex; }
.tour-foot .button { width: auto; -webkit-box-flex: 1; -webkit-flex: 1 1 0; flex: 1 1 0; }
.tour-foot .button + .button { margin-left: 8px; }
.tour-tabbar { display: -webkit-box; display: -webkit-flex; display: flex; width: 100%; max-width: 320px; border-radius: 12px; background: #041c38; background: var(--navy); color: #fff; padding: 8px 0; }
.tour-tabbar span { -webkit-box-flex: 1; -webkit-flex: 1 1 0; flex: 1 1 0; text-align: center; font-size: 12px; font-weight: 700; opacity: .8; }
.tour-tabbar span i { display: block; font-style: normal; font-size: 20px; margin-bottom: 2px; }
.tour-tabbar span.hot { opacity: 1; color: #fdbb30; color: var(--gold); }
.tour-search { width: 100%; max-width: 320px; }
.tour-search .fake-input { display: block; padding: 12px 14px; border-radius: 12px; border: 1px solid #d9e0e8; border-color: var(--line); background: #fff; background: var(--surface); color: #5b6b7c; color: var(--muted); }
.tour-search .fake-row { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; margin-top: 10px; padding: 8px 10px; border-radius: 12px; background: #fff; background: var(--surface); border: 1px solid #d9e0e8; border-color: var(--line); }
.tour-search .fake-row b { -webkit-box-flex: 1; -webkit-flex: 1; flex: 1; margin-left: 10px; }
.tour-pill { padding: 8px 12px; border-radius: 10px; background: #fdbb30; background: var(--gold); color: #0b1f3a; font-weight: 800; font-size: 13px; white-space: nowrap; }

/* ---------- End Zone Run ---------- */
.footer-egg { margin-top: 6px; background: transparent; font-size: 22px; opacity: .8; }
.footer-egg:hover { opacity: 1; }
.game-sheet { max-width: 760px; }
@media (min-width: 601px) { .modal-sheet.game-sheet { bottom: auto; max-height: calc(100% - 40px); } }   /* the sheet hugs the game instead of a blank column below it (specificity beats the base tablet rule) */
.game-body { padding-bottom: 16px; }
.game-hud { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; margin-bottom: 8px; font-weight: 800; font-size: 15px; }
.game-lives { color: #ba0c2f; color: var(--scarlet); letter-spacing: 2px; }
.game-stage { position: relative; width: 100%; border-radius: 14px; overflow: hidden; background: #0b2a4f; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.game-stage canvas { display: block; width: 100%; touch-action: manipulation; }
.game-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-orient: vertical; -webkit-flex-direction: column; flex-direction: column; -webkit-box-align: center; -webkit-align-items: center; align-items: center; -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center; padding: 16px; text-align: center; color: #fff; background: rgba(4,28,56,.78); }
.game-overlay b { font-size: 22px; font-family: "Avenir Next Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif; letter-spacing: 1px; text-transform: uppercase; }
.game-overlay p { margin: 6px 0 10px; max-width: 34em; font-size: 13px; line-height: 1.35; }
@media (min-width: 601px) { .game-overlay b { font-size: 26px; } .game-overlay p { font-size: 14px; } }
.game-jump { width: 100%; min-height: 64px; margin-top: 10px; font-size: 22px; letter-spacing: 2px; touch-action: manipulation; }

.game-actions { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 6px -4px 0; }
.game-actions .button { margin: 4px; -webkit-box-flex: 1; -webkit-flex: 1 1 auto; flex: 1 1 auto; font-size: 14px; }
.game-note { margin: 10px 0 0; }
.game-tds { color: #fdbb30; color: var(--gold); }
.game-drive { margin: -4px 0 8px; font-size: 13px; color: #5b6b7c; color: var(--muted); font-weight: 700; }
.game-overlay { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.game-overlay p { max-width: 36em; }
.game-initials { margin: 4px 0 10px; }
.game-ini {
  width: 5.2em; min-height: 56px; padding: 0 8px; text-align: center;
  font: 900 30px/1 "Courier New", Courier, monospace; letter-spacing: .35em; text-transform: uppercase;
  color: #fdbb30; color: var(--gold); background: #041c38; background: var(--navy); border: 2px solid #fdbb30; border-color: var(--gold); border-radius: 10px;
}
.game-board { width: 100%; max-width: 360px; margin: 12px auto 0; padding: 8px 12px 6px; border-radius: 10px; background: #041c38; background: var(--navy); border: 1px solid rgba(253,187,48,.6); font-family: "Courier New", Courier, monospace; }
.game-board-title { font-weight: 900; font-size: 13px; letter-spacing: 3px; color: #fdbb30; color: var(--gold); margin-bottom: 4px; }
.game-board ol { list-style: none; margin: 0; padding: 0; text-align: left; }
.game-board li { display: -webkit-box; display: -webkit-flex; display: flex; font-size: 13px; line-height: 1.7; color: #fff; }
.game-board li.board-you { color: #fdbb30; color: var(--gold); }
.game-board li.board-empty { color: rgba(255,255,255,.7); }
.board-rank { -webkit-flex: 0 0 2em; flex: 0 0 2em; opacity: .7; }
.board-ini { -webkit-flex: 0 0 3.6em; flex: 0 0 3.6em; letter-spacing: .2em; font-weight: 900; }
.board-score { -webkit-box-flex: 1; -webkit-flex: 1; flex: 1; text-align: right; }

/* easter egg: a tiny runner sprints across the top of the page now and then — tap him to play */
.egg-runner {
  position: absolute; z-index: 3; top: 4px; left: -60px;
  width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; font-size: 24px; line-height: 44px; text-align: center;
  -webkit-transform: scaleX(-1); transform: scaleX(-1);   /* he runs to the right */
  -webkit-transition: left 3.2s linear; transition: left 3.2s linear;
}
.egg-runner.run { left: 100%; }
.topbar .wrap { position: relative; }
.topbar { overflow: hidden; }   /* the runner waits off-screen, not over the emblem */

/* ---------- phone: bottom tab bar ---------- */
@media (max-width: 600px) {
  :root { --tabbar: calc(64px + env(safe-area-inset-bottom)); }
  body { padding-bottom: 76px; padding-bottom: var(--tabbar); }   /* plain fallback first: an iPad without custom properties still clears the bar */
  .brand-desc { display: none; }
  .brand-name .wordmark { height: 20px; }
  .j-mark { width: 34px; height: 34px; margin-right: 8px; }
  .header-actions .label { display: none; }
  .header-actions .button { width: 44px; padding: 0; }
  .header-actions #addButton, .header-actions #updateButton { display: none; }   /* Add is in the tab bar; Refresh is in More */
  .masthead { min-height: 52px; padding: 2px 0; }
  .statline { padding-bottom: 4px; }
  .board { padding-top: 2px; }
  .tabs {
    position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
    height: 64px; height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: #041c38; background: var(--navy);
    border-top: 1px solid rgba(255,255,255,.12);
  }
  .tab { border-bottom: 0; -webkit-box-orient: vertical; -webkit-flex-direction: column; flex-direction: column; font-size: 12px; min-height: 64px; }
  .tab .tab-icon { margin: 0 0 3px; font-size: 22px; }
  .tab.active { color: #fdbb30; color: var(--gold); }
  .tab-count { position: absolute; margin: 0; top: 8px; left: 50%; margin-left: 10px; }
  .tab { position: relative; }
  .tab-add { display: -webkit-box; display: -webkit-flex; display: flex; }
  .view-group { display: none; }
  .chip .chip-count { display: none; }
  .chip-team .team-chip-label { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }   /* the counts are what pushed the rail past the screen; labels alone fit */
  .chips { padding-right: 4px; }
  .modal-sheet { border-radius: 0; }
}

@media (max-width: 359px) {
  .brand-name .wordmark { height: 18px; }   /* 320px: 34px mark + 120px wordmark + two 44px controls fits with room */
  .header-actions #helpButton { display: none; }   /* a third control would crowd the name; More carries Help */
}

/* ---------- tablet ---------- */
@media (min-width: 601px) {
  :root { --gutter: 20px; }
  .masthead { min-height: 60px; }
  .board { padding-top: 8px; }
  .card-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-gap: 14px; gap: 14px; }
  .modal-sheet {
    top: 20px; bottom: 20px; left: 50%; right: auto;
    width: calc(100% - 40px); max-width: 640px; max-height: calc(100% - 40px);
    -webkit-transform: translateX(-50%); transform: translateX(-50%);
    border-radius: 18px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.35);
  }
}
@media (min-width: 800px) {
  .card-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }
}

/* ---------- desktop ---------- */
@media (min-width: 1025px) {
  :root { --gutter: 24px; }
  .brand-name .wordmark { height: 24px; }
  .j-mark { width: 40px; height: 40px; }
  .toolbar-row.merge { -webkit-flex-wrap: nowrap; flex-wrap: nowrap; }
  .toolbar-row.merge .search-box { -webkit-flex: 1 1 320px; flex: 1 1 320px; max-width: 460px; margin-right: 14px; }
  .toolbar-row.merge .chips-wrap { -webkit-flex: 0 1 auto; flex: 0 1 auto; }
  .toolbar-row.merge .chips-wrap, .toolbar-row.merge .view-group { margin-top: 0; }
  .toolbar-row.merge .view-group { margin-left: auto; }
  .card-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); grid-gap: 16px; gap: 16px; }
  .pcard { min-height: 92px; }
  .portrait { width: 64px; height: 64px; }
  .portrait .portrait-mono { line-height: 60px; }
  .modal-sheet { max-width: 720px; }
}
