:root{
  --bg:#0d1117; --panel:#161b22; --panel2:#1c232c;
  --line:#242c37; --line-strong:#33404f;
  --text:#e6edf3; --dim:#8b949e; --accent:#4a9eff; --now:#f7776d;
  --warn:#e3a008;

  --nfl:#3b7dd8; --ncaaf:#c9a227; --mlb:#3fa34d; --nba:#d1741f;
  --ncaab:#b8562f; --nhl:#7c5cbf; --ufc:#c0392b;

  /* grid metrics — app.js reads these back, so the media query below is the
     only place that decides them */
  --hour:155px; --labelw:150px; --lane:54px;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;background:var(--bg);color:var(--text);
  font:14px/1.4 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  display:flex;flex-direction:column;
}

/* ---------- header ---------- */
.top{padding:14px 20px 12px;border-bottom:1px solid var(--line);background:var(--bg);flex:0 0 auto}
.brand{display:flex;align-items:center;gap:18px;flex-wrap:wrap}
h1{
  margin:0;font-size:17px;font-weight:650;letter-spacing:-.2px;
  display:flex;align-items:center;gap:8px;
}
/* inline, so currentColor in the mark picks up the heading colour */
.logo{flex:0 0 auto;width:25px;height:25px;display:block}

.datenav{display:flex;align-items:center;gap:6px}
input[type=date]{
  background:var(--panel);border:1px solid var(--line-strong);color:var(--text);
  border-radius:6px;padding:5px 8px;font:inherit;font-size:13px;
}
button.ghost{
  background:var(--panel);border:1px solid var(--line-strong);color:var(--text);
  border-radius:6px;padding:5px 11px;font:inherit;font-size:13px;cursor:pointer;
}
button.ghost:hover{background:var(--panel2);border-color:var(--line-strong)}
button.ghost.danger{color:#f7776d}

.controls{display:flex;gap:22px;align-items:center;flex-wrap:wrap;margin-top:12px}
/* without these the pills stretch to fill the wrapped line height and the
   999px radius turns them into tall ovals */
.leagues{display:flex;gap:7px;flex-wrap:wrap;align-items:center;align-content:flex-start}
.lg{
  border:1px solid var(--line-strong);background:var(--panel);color:var(--dim);
  border-radius:999px;padding:4px 12px;font-size:12px;font-weight:600;cursor:pointer;
  display:flex;align-items:center;gap:6px;transition:.12s;
}
.lg i{width:8px;height:8px;border-radius:50%;background:var(--c);opacity:.45}
.lg.on{color:var(--text);border-color:var(--c);background:color-mix(in srgb,var(--c) 15%,var(--panel))}
.lg.on i{opacity:1}
.lg.empty{opacity:.4;cursor:default}

.opts{display:flex;gap:16px;align-items:center;flex-wrap:wrap}
.chk{display:flex;align-items:center;gap:6px;font-size:12.5px;color:var(--dim);cursor:pointer;user-select:none}
.chk input{accent-color:var(--accent);cursor:pointer}
#favCount{color:var(--accent);margin-left:5px;font-weight:600}

.conflicts{
  margin-top:11px;padding:8px 12px;border-radius:6px;font-size:12.5px;
  background:color-mix(in srgb,var(--warn) 14%,var(--panel));
  border:1px solid color-mix(in srgb,var(--warn) 45%,transparent);
}
.conflicts b{color:var(--warn)}

.status{padding:11px 20px;color:var(--dim);font-size:12.5px;flex:0 0 auto}
.status.err{color:#f7776d}
.status[hidden]{display:none}

/* ---------- grid ---------- */
.scroller{overflow:auto;flex:1 1 auto}
.grid{position:relative;width:max-content;min-width:100%}

.timebar{
  position:sticky;top:0;z-index:5;display:flex;height:32px;
  background:var(--panel);border-bottom:1px solid var(--line-strong);
}
.corner{
  position:sticky;left:0;z-index:6;width:var(--labelw);flex:0 0 var(--labelw);
  background:var(--panel);border-right:1px solid var(--line-strong);
}
.ticks{position:relative;flex:1}
.tick{
  position:absolute;top:0;bottom:0;padding-left:8px;font-size:11.5px;color:var(--dim);
  border-left:1px solid var(--line-strong);display:flex;align-items:center;
  white-space:nowrap;letter-spacing:.3px;
}

.row{display:flex;border-bottom:1px solid var(--line)}
.row:nth-child(even) .track{background:var(--stripe)}
.chan{
  position:sticky;left:0;z-index:4;width:var(--labelw);flex:0 0 var(--labelw);
  background:var(--panel);border-right:1px solid var(--line-strong);
  display:flex;flex-direction:column;justify-content:center;align-items:center;
  padding:0 12px;font-weight:600;font-size:12.5px;text-align:center;
}
.chan small{font-weight:400;color:var(--dim);font-size:10.5px;margin-top:3px}
.chname{
  font-weight:600;font-size:12.5px;white-space:nowrap;max-width:100%;
  overflow:hidden;text-overflow:ellipsis;
}
/* Network wordmarks are mostly black ink on transparency — FOX, CBS, ION, TNT
   and Apple TV all disappear against a dark row — so every mark sits on the
   same near-white tile. Marks are wide and vary in aspect, so the tile
   shrink-wraps rather than forcing them into a square. */
.netmark{
  display:inline-flex;align-items:center;justify-content:center;
  background:#f2f4f8;border-radius:4px;padding:3px 6px;max-width:100%;
  font-size:11.5px;font-weight:700;color:#11161d;   /* styles the alt fallback */
}
.netmark img{max-height:19px;max-width:98px;width:auto;height:auto;display:block}
.chan .more{
  margin-top:6px;cursor:pointer;   /* no align-self — inherit the column's centring */
  background:var(--panel2);border:1px solid var(--line-strong);color:var(--accent);
  border-radius:4px;padding:2px 7px;font:inherit;font-size:10.5px;font-weight:600;
}
.chan .more:hover{background:var(--line);border-color:var(--accent)}
.track{position:relative;flex:1}

.gl{position:absolute;top:0;bottom:0;width:1px;background:var(--line)}
.gl.half{background:var(--tint)}

.ev{
  position:absolute;height:calc(var(--lane) - 8px);border-radius:5px;
  padding:5px 8px;overflow:hidden;cursor:default;
  border-left:3px solid var(--c);
  background:color-mix(in srgb,var(--c) 17%,var(--panel));
  transition:filter .12s;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:1px;text-align:center;
}
.ev:hover{filter:brightness(1.35)}
/* full strength, not a softened mix — if you picked the colour you should see
   the colour you picked */
.ev.fav{box-shadow:inset 0 0 0 1.5px var(--fav)}
.ev.clash{box-shadow:inset 0 0 0 1.5px var(--warn)}
/* Both at once is the common case — your teams are exactly the games that
   clash. Stack them rather than letting source order silently drop one. */
.ev.fav.clash{box-shadow:inset 0 0 0 1.5px var(--fav), inset 0 0 0 3.5px var(--warn)}
.ev.live{border-left-color:var(--now)}
.ev.done{opacity:.5}
/* matchup line: crest, name, "@", crest, name */
.mu{
  display:flex;align-items:center;justify-content:center;gap:5px;
  max-width:100%;min-width:0;
}
.mu img{
  width:17px;height:17px;object-fit:contain;flex:0 0 auto;
  /* some crests are near-black and would vanish on this background */
  background:var(--crest-bg);border-radius:3px;padding:1px;
}
.mu b{
  font-size:12.5px;font-weight:650;white-space:nowrap;
  overflow:hidden;text-overflow:ellipsis;min-width:0;
}
.mu i{font-style:normal;color:var(--dim);font-size:10.5px;flex:0 0 auto}

.ev span{
  display:block;font-size:11px;color:var(--dim);white-space:nowrap;
  overflow:hidden;text-overflow:ellipsis;max-width:100%;
}

/* dismiss control — stays out of the way until you're over the bar */
.ev .hide{
  position:absolute;top:3px;right:4px;z-index:2;
  width:15px;height:15px;padding:0;
  display:flex;align-items:center;justify-content:center;
  border:0;border-radius:3px;cursor:pointer;
  /* the scrim is always dark, so the cross is always white — var(--text) would
     go dark-on-dark under a light theme */
  background:rgba(0,0,0,.45);color:#fff;
  opacity:0;transition:opacity .1s;
}
/* square viewBox with a symmetric path, so the cross is centred by geometry
   rather than by whatever metrics the platform font gives "×" */
.ev .hide svg{
  width:11px;height:11px;display:block;
  fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;
}
.ev:hover .hide{opacity:.7}
.ev .hide:hover{opacity:1;background:var(--now);color:#1a0e0d}
.ev .hide:focus-visible{opacity:1;outline:2px solid var(--accent)}
.ev .dot{
  display:inline-block;width:6px;height:6px;border-radius:50%;
  background:var(--now);margin-right:5px;vertical-align:1px;
  animation:pulse 1.8s ease-in-out infinite;
}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.3}}
@media (prefers-reduced-motion:reduce){.ev .dot{animation:none}}

/* a game in progress leads with its score, so give it more contrast */
.ev.live span{color:var(--text);font-weight:600}

.nowline{
  position:absolute;top:0;bottom:0;width:2px;background:var(--now);z-index:3;
  pointer-events:none;box-shadow:0 0 9px rgba(247,119,109,.55);
}

/* Not `.empty`: league pills carry an `empty` modifier for leagues with no
   games today, and a bare `.empty` rule hits them too. */
.grid-msg{padding:60px 20px;text-align:center;color:var(--dim);font-size:13px}

/* ---------- team picker ---------- */
.modal{
  position:fixed;inset:0;z-index:50;background:rgba(0,0,0,.6);
  display:flex;align-items:center;justify-content:center;padding:20px;
}
/* the class sets display:flex, which would otherwise win over [hidden] */
.modal[hidden],.conflicts[hidden]{display:none}
.sheet{
  background:var(--panel);border:1px solid var(--line-strong);border-radius:10px;
  width:min(520px,100%);max-height:80vh;display:flex;flex-direction:column;padding:16px;
}
.sheethead{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}
#teamSearch{
  background:var(--bg);border:1px solid var(--line-strong);color:var(--text);
  border-radius:6px;padding:8px 11px;font:inherit;font-size:13px;width:100%;
}
.hint{color:var(--dim);font-size:11.5px;margin:8px 2px 10px}
.teamlist{overflow-y:auto;flex:1;display:flex;flex-direction:column;gap:2px}
.trow{
  display:flex;align-items:center;gap:9px;padding:7px 9px;border-radius:6px;
  cursor:pointer;font-size:13px;
}
.trow:hover{background:var(--panel2)}
.trow img{width:19px;height:19px;object-fit:contain}
.trow .lgtag{
  margin-left:auto;font-size:10px;color:var(--dim);
  border:1px solid var(--line-strong);border-radius:3px;padding:1px 5px;
}
.trow input{accent-color:var(--accent);cursor:pointer}
.sheetfoot{margin-top:12px;display:flex;justify-content:flex-end}

/* ---------- theme picker ---------- */
.swatch{display:flex;align-items:center;gap:11px;margin-bottom:10px}
.swatch b{display:block;font-size:13px}
.swatch small{color:var(--dim);font-size:11.5px}
.swatch input[type=color]{
  width:44px;height:34px;flex:0 0 auto;padding:2px;cursor:pointer;
  background:var(--bg);border:1px solid var(--line-strong);border-radius:6px;
}
.swatch.sm{
  gap:7px;margin:0;padding:6px 8px;border-radius:6px;
  border:1px solid var(--line);cursor:pointer;
}
.swatch.sm:hover{border-color:var(--line-strong)}
.swatch.sm input[type=color]{width:30px;height:26px}
.swatch.sm b{font-size:12px}

.swatches{display:grid;grid-template-columns:repeat(auto-fill,minmax(104px,1fr));gap:7px}

.presets{display:flex;gap:7px;flex-wrap:wrap;margin:0 0 14px}
.preset{
  flex:1 1 84px;height:38px;border-radius:6px;cursor:pointer;
  border:1px solid var(--line-strong);position:relative;overflow:hidden;
}
.preset.on{outline:2px solid var(--accent);outline-offset:1px}
.preset span{
  position:absolute;left:0;right:0;bottom:0;font-size:10px;padding:2px 0;
  background:rgba(0,0,0,.45);color:#fff;text-align:center;
}

/* ---------- small screens ---------- */
/* The header was eating 624px of an 812px phone, leaving 149px of guide. The
   grid itself is fine sideways — a TV guide is meant to scroll in time — so
   this reclaims vertical space and narrows everything that was sized for a
   desktop column. */
@media (max-width:700px){
  :root{--hour:104px; --labelw:66px; --lane:50px}

  .top{padding:9px 12px}
  h1{font-size:15px}
  .brand{gap:10px}
  .controls{gap:9px;margin-top:9px}
  .status{padding:7px 12px;font-size:11.5px}

  /* one swipeable row instead of three wrapped ones */
  .leagues{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;padding-bottom:2px}
  .leagues::-webkit-scrollbar{display:none}
  .lg{flex:0 0 auto;padding:4px 10px;font-size:11.5px}

  .opts{gap:12px;row-gap:8px}
  .chk{font-size:12px}
  button.ghost{padding:5px 9px;font-size:12px}
  input[type=date]{padding:4px 6px;font-size:12px}

  .chan{padding:0 4px}
  .netmark{padding:2px 3px;border-radius:3px}
  .netmark img{max-height:15px;max-width:54px}
  .chname{font-size:10px}
  .chan small{font-size:9.5px}

  .timebar{height:28px}
  .tick{font-size:10.5px;padding-left:6px}
  .ev{padding:4px 6px;border-left-width:2px}
  .mu{gap:4px}
  .mu img{width:14px;height:14px}
  .mu b{font-size:11px}
  .ev span{font-size:9.5px}
  .conflicts{font-size:11.5px;padding:7px 9px}
}

/* No hover on touch, so a hover-revealed control is simply unreachable. */
@media (hover:none){
  .ev .hide{opacity:.45}
  .ev .hide svg{stroke-width:2}
}
