/* ===== iOS-style design tokens ===== */
:root {
  --bg: #f2f2f7;            /* systemGroupedBackground */
  --card: #ffffff;          /* secondarySystemGroupedBackground */
  --fill: #e5e5ea;          /* systemGray5 */
  --fill2: #f2f2f7;
  --ink: #000000;
  --ink2: #3c3c43;
  --dim: #8a8a8e;           /* secondaryLabel */
  --line: #e5e5ea;          /* separator */
  --blue: #007aff; --green: #34c759; --red: #ff3b30; --orange: #ff9500;
  --yellow: #ffcc00; --purple: #af52de; --pink: #ff2d55; --teal: #30b0c7;
  --indigo: #5856d6; --mint: #00c7be;
  --accent: var(--blue); --pos: #248a3d; --neg: #d70015;
  --mine: rgba(0, 122, 255, 0.08);
  --heat: 0, 122, 255;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1c1c1e; --fill: #2c2c2e; --fill2: #2c2c2e;
    --ink: #ffffff; --ink2: #ebebf5; --dim: #8d8d93; --line: #38383a;
    --blue: #0a84ff; --green: #30d158; --red: #ff453a; --orange: #ff9f0a;
    --yellow: #ffd60a; --purple: #bf5af2; --pink: #ff375f; --teal: #40c8e0;
    --indigo: #5e5ce6; --mint: #63e6e2;
    --pos: #30d158; --neg: #ff453a;
    --mine: rgba(10, 132, 255, 0.16);
    --heat: 10, 132, 255;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
b, strong { font-weight: 600; }

/* ===== Top bar (frosted, sticky) ===== */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--line);
}
h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
input, select, button {
  font: inherit; font-size: 15px; color: var(--ink); background: var(--card);
  border: none; border-radius: 10px; padding: 8px 12px; box-shadow: var(--shadow);
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 0; }
button[type=submit] { background: var(--blue); color: #fff; font-weight: 600; cursor: pointer; }

/* ===== Tabs = segmented control ===== */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 20px 6px; align-items: center; }
.tabs .seg-wrap { display: contents; }
.tab {
  background: var(--fill); color: var(--ink); border-radius: 999px; padding: 7px 14px;
  font-size: 14px; font-weight: 500; cursor: pointer; box-shadow: none; transition: background .15s, color .15s;
}
.tab:hover { background: color-mix(in srgb, var(--fill) 70%, var(--blue) 12%); }
.tab[aria-selected=true] { background: var(--blue); color: #fff; font-weight: 600; }
#week { margin-left: auto; font-weight: 500; }
.share { background: var(--card); color: var(--blue); font-weight: 600; cursor: pointer; margin-left: 8px; }
#week[hidden] + .share { margin-left: auto; }

#status { padding: 0 20px; color: var(--dim); min-height: 1em; font-size: 13px; }
#status.error { color: var(--red); }
main { padding: 4px 20px 48px; max-width: 1200px; margin: 0 auto; }

/* ===== Large title ===== */
.league-head h2 { margin: 8px 0 2px; font-size: 32px; font-weight: 700; letter-spacing: -0.6px; }
.league-head p { margin: 0 0 16px; color: var(--dim); }

/* ===== Cards & tables (inset grouped lists) ===== */
.card { background: var(--card); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th { font-size: 12px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; border-bottom: 0.5px solid var(--line); }
td { border-bottom: 0.5px solid var(--line); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: color-mix(in srgb, var(--fill) 40%, transparent); }
.l { text-align: left; }
.rank { color: var(--dim); width: 36px; font-weight: 600; }
tr.cutline td { border-bottom: 2px dashed color-mix(in srgb, var(--blue) 60%, transparent); }
.team { display: flex; gap: 10px; align-items: center; }
.team img, .team .ph { width: 32px; height: 32px; border-radius: 50%; background: var(--fill); flex: none; }
.team.mine img { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--blue); }
.tname { font-weight: 600; }
.owner, .dim { color: var(--dim); font-size: 12px; font-weight: 400; }
tr:has(.team.mine) td { background: var(--mine); }
.pos { color: var(--pos); font-weight: 600; }
.neg { color: var(--neg); font-weight: 600; }
.note { color: var(--dim); font-size: 13px; margin: 10px 4px; }
.empty { color: var(--dim); }

/* Power bars */
.bar-col { width: 35%; }
.bar { position: relative; height: 22px; background: var(--fill); border-radius: 999px; overflow: hidden; }
.bar span { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: linear-gradient(90deg, var(--indigo), var(--blue)); }
.bar em { position: relative; font-style: normal; font-weight: 700; padding-left: 10px; line-height: 22px; color: #fff; font-size: 12px; text-shadow: 0 0 4px rgba(0,0,0,.25); }

/* Heatmap */
.grid td.heat { background: rgba(var(--heat), calc(var(--h) * 0.5)); }
.callouts { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.callout { padding: 14px 18px; display: flex; flex-direction: column; min-width: 190px; }
.callout b { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.callout:first-child b { color: var(--green); }
.callout:nth-child(2) b { color: var(--red); }

/* ===== Matchups ===== */
.match { display: grid; grid-template-columns: 1fr auto 1fr; margin-bottom: 16px; }
.side { padding: 14px; min-width: 0; }
.side.mine-side { background: var(--mine); }
.side .score { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; margin: 8px 0 4px; color: var(--dim); }
.side.won .score { color: var(--green); }
.proj-total { font-size: 12px; font-weight: 500; margin-left: 8px; }
.col-head { display: grid; grid-template-columns: 48px 1fr auto; font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .3px; padding-bottom: 4px; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side li { display: grid; grid-template-columns: 48px 1fr auto; gap: 6px; padding: 7px 0; border-top: 0.5px solid var(--line); font-size: 14px; align-items: center; }
.side li.player { cursor: pointer; border-radius: 8px; }
.side li.player:hover { background: color-mix(in srgb, var(--fill) 50%, transparent); }
.slot {
  justify-self: start; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px;
  background: var(--fill); color: var(--ink2);
}
.pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp { display: flex; gap: 8px; align-items: baseline; font-variant-numeric: tabular-nums; }
.proj { color: var(--dim); font-size: 12px; min-width: 32px; text-align: right; }
.proj.pos { color: var(--pos); font-weight: 600; }
.proj.neg { color: var(--neg); font-weight: 600; }
.inj { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); vertical-align: 1px; }
.inj-bad { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.news { grid-column: 1 / -1; padding: 6px 4px 6px 54px; cursor: auto; }
.news-item { margin-bottom: 10px; padding-left: 10px; border-left: 3px solid var(--blue); }
.news-when { font-size: 11px; color: var(--dim); }
.news-head { font-weight: 600; font-size: 14px; }
.news-story { font-size: 13px; color: var(--dim); white-space: normal; }
.vs { align-self: center; text-align: center; line-height: 1.3; color: var(--dim); font-size: 12px; font-weight: 600; padding: 0 6px; }

/* ===== Newsletter ===== */
.newsletter { max-width: 780px; margin: 0 auto; }
.masthead {
  text-align: center; padding: 28px 20px 24px; border-radius: 20px; color: #fff;
  background: linear-gradient(135deg, var(--indigo), var(--blue) 55%, var(--teal));
  box-shadow: var(--shadow);
}
.masthead h2 { font-size: 34px; font-weight: 800; letter-spacing: -0.8px; margin: 6px 0 4px; }
.masthead .dim { color: rgba(255,255,255,.85); font-size: 14px; }
.masthead .kicker { color: rgba(255,255,255,.9); }
.kicker { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--blue); }
.headline {
  font-size: 26px; font-weight: 800; line-height: 1.2; letter-spacing: -0.5px;
  margin: 18px 0 0; padding: 18px 20px; background: var(--card); border-radius: var(--r);
  box-shadow: var(--shadow); border-left: 5px solid var(--orange);
}
.nl-section { margin-top: 28px; }
.nl-section h3 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.4px; margin: 0 4px 10px;
}
.nl-section h4 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--dim); margin: 22px 4px 8px; }
.newsletter p { font-size: 16px; line-height: 1.55; margin: 6px 0 0; color: var(--ink2); }
.newsletter p b { color: var(--ink); }

/* TL;DR */
.tldr { margin-top: 16px; background: var(--card); border-radius: var(--r); padding: 14px 18px; box-shadow: var(--shadow); }
.tldr-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--blue); margin-bottom: 6px; }
.tldr ul { list-style: none; margin: 0; padding: 0; }
.tldr li { padding: 6px 0; border-top: 0.5px solid var(--line); font-size: 15px; color: var(--ink2); }
.tldr li:first-child { border-top: none; }
.tldr b { color: var(--ink); }

/* Shared bits */
.av { width: 36px; height: 36px; border-radius: 50%; background: var(--fill); flex: none; object-fit: cover; }
.av.sm { width: 22px; height: 22px; }
.who { display: inline-flex; align-items: center; gap: 8px; }
.quip { font-size: 14px !important; color: var(--dim) !important; font-style: italic; margin: 8px 0 0 !important; line-height: 1.4 !important; }
.quip b { color: var(--ink2) !important; font-style: normal; }
.chip { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--fill); color: var(--ink2); }
.chip.streak.w { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--pos); }
.chip.streak.l { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--neg); }

/* Scoreboards */
.sb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 12px; }
.sb { background: var(--card); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); }
.sb-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; min-height: 22px; }
.sb-margin { font-size: 12px; color: var(--dim); font-weight: 600; }
.sb-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.sb-row + .sb-row { border-top: 0.5px solid var(--line); }
.sb-name { flex: 1; min-width: 0; }
.sb-team { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-rec { font-size: 12px; color: var(--dim); font-weight: 500; }
.sb-star { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-star b { color: var(--ink2); }
.sb-score { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
.sb-row.win .sb-score { color: var(--green); }
.sb-row.lose { opacity: .75; }
.sb-row.lose .sb-score { color: var(--dim); }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .3px; padding: 3px 9px; border-radius: 999px; background: var(--fill); color: var(--dim); }
.tag-blowout { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.tag-close   { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); }
.tag-robbed  { background: color-mix(in srgb, var(--purple) 16%, transparent); color: var(--purple); }
.tag-stole   { background: color-mix(in srgb, var(--yellow) 25%, transparent); color: color-mix(in srgb, var(--yellow) 55%, var(--ink)); }

/* Awards: stat-first cards */
.awards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.award { background: var(--card); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); border-top: 4px solid var(--c, var(--blue)); }
.award-title { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--c); }
.icon-tile { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; font-size: 17px; background: color-mix(in srgb, var(--c, var(--blue)) 18%, transparent); }
.award-stat { margin: 10px 0 4px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.award-stat b { font-size: 34px; font-weight: 800; letter-spacing: -1px; color: var(--ink); line-height: 1; }
.award-stat span { font-size: 13px; color: var(--dim); font-weight: 500; }
.award-who { font-size: 15px; }

/* Standings list */
.standings-list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.st-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 0.5px solid var(--line); }
.st-row:first-child { border-top: none; }
.st-main { flex: 1; min-width: 0; }
.st-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 15px; }
.roast { font-size: 13px; line-height: 1.4; color: var(--dim); margin-top: 2px; font-style: italic; }
.st-power { display: flex; flex-direction: column; align-items: center; min-width: 40px; font-size: 15px; line-height: 1.2; }
.st-power .dim { font-size: 10px; font-weight: 700; letter-spacing: .5px; }
.st-power .pos, .st-power .neg { font-size: 11px; }
.rank-badge { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex: none; font-size: 13px; font-weight: 700; background: var(--fill); color: var(--ink2); }
.rank-badge.in { background: var(--blue); color: #fff; }
.rank-badge.last { background: var(--red); color: #fff; }
.cut-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--blue); padding: 4px 14px; background: color-mix(in srgb, var(--blue) 10%, transparent); border-top: 1.5px dashed var(--blue); }

/* Preview cards */
.pv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 12px; }
.pv { background: var(--card); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); }
.pv.is-gotw { box-shadow: 0 0 0 2px var(--orange), var(--shadow); grid-column: 1 / -1; }
.pv.is-lock { box-shadow: 0 0 0 2px var(--red), var(--shadow); }
.pv-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.pv-label.gotw { color: var(--orange); }
.pv-label.lock { color: var(--red); }
.pv-teams { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.pv-side > div { min-width: 0; }
.pv-side { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pv-side.right { flex-direction: row-reverse; text-align: right; }
.pv-team { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-proj { font-size: 13px; }
.tug { height: 8px; border-radius: 999px; background: var(--pink); margin: 10px 0 2px; overflow: hidden; }
.tug span { display: block; height: 100%; background: var(--blue); border-right: 2px solid var(--card); }
.pv-alerts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--ink2); }
.pv-alerts > div > div { padding: 2px 0; }
.pv-alerts .right { text-align: right; }

/* ===== Phone ===== */
@media (max-width: 700px) {
  .top { padding: 10px 16px; }
  .controls { width: 100%; }
  .controls input { flex: 1 1 140px; }
  .tabs { padding: 12px 16px 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; }
  #week, .share { flex: none; }
  main { padding: 4px 16px 40px; }
  .league-head h2 { font-size: 28px; }
  .match { grid-template-columns: 1fr; }
  .vs { padding: 4px; }
  .card:not(.match) { overflow-x: auto; }
  .masthead h2 { font-size: 28px; }
  .headline { font-size: 21px; }
  .sb-grid, .pv-grid, .awards { grid-template-columns: 1fr; }
  .award-stat b { font-size: 30px; }
}

/* ===== 🍻 Chugs ===== */
.tab[hidden] { display: none; }
.chug-hero {
  border-radius: 20px; padding: 20px 22px; color: #3b2300; margin-bottom: 16px; box-shadow: var(--shadow);
  background: linear-gradient(135deg, #ffd60a, #ff9f0a 70%, #ff9500);
}
.chug-hero-title { font-size: 30px; font-weight: 800; letter-spacing: -0.6px; }
.chug-hero p { margin: 4px 0 12px; font-size: 15px; font-weight: 500; }
.chug-stats { display: flex; gap: 12px; flex-wrap: wrap; }
.chug-stats > div { background: rgba(255,255,255,.55); border-radius: 12px; padding: 8px 14px; display: flex; flex-direction: column; }
.chug-stats b { font-size: 24px; font-weight: 800; line-height: 1.1; }
.chug-stats span { font-size: 12px; font-weight: 600; opacity: .8; }
.chug-stats .repeat { font-size: 14px; font-weight: 600; }
.chug-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.chug-card { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.chug-card.owed { box-shadow: 0 0 0 2px color-mix(in srgb, var(--orange) 70%, transparent), var(--shadow); }
.chug-card.future { opacity: .6; }
.chug-card.live { box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 50%, transparent), var(--shadow); }
.chug-card p { margin: 0; }
.chug-head { display: flex; justify-content: space-between; align-items: center; }
.chug-week { font-size: 17px; font-weight: 700; }
.chip.ok { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--pos); }
.chip.owe { background: color-mix(in srgb, var(--orange) 20%, transparent); color: var(--orange); }
.chug-who { display: flex; align-items: center; gap: 10px; }
.chug-video { width: 100%; max-height: 420px; border-radius: 12px; background: #000; }
.upload-btn {
  display: block; text-align: center; padding: 12px; border-radius: 12px; cursor: pointer;
  background: var(--blue); color: #fff; font-weight: 600; font-size: 15px;
}
.upload-btn:active { opacity: .8; }
.link { color: var(--blue); cursor: pointer; font-weight: 600; }
.uploading .upload-btn, .uploading .link { pointer-events: none; opacity: .5; }
.progress { height: 8px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s; }
.chug-err { color: var(--red); font-size: 13px; }
.chug-wait { text-align: center; }
.chip.aka { background: color-mix(in srgb, var(--pink) 16%, transparent); color: var(--pink); }

/* ===== 🔮 Preseason rankings ===== */
.pre-hero {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  border-radius: 20px; padding: 20px 22px; color: #fff; box-shadow: var(--shadow);
  background: linear-gradient(135deg, #5e5ce6, #bf5af2 60%, #ff375f);
}
.pre-title { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.pre-hero p { margin: 4px 0 0; font-size: 15px; opacity: .9; max-width: 560px; }
.grade { background: rgba(255,255,255,.2); border-radius: 16px; padding: 10px 18px; text-align: center; display: flex; flex-direction: column; }
.grade b { font-size: 44px; font-weight: 900; line-height: 1; }
.grade span { font-size: 12px; font-weight: 600; opacity: .9; }
.grade-line { font-size: 16px; font-style: italic; color: var(--ink2); margin: 12px 4px 14px; }
.pre-callouts .award-stat b { font-size: 26px; }
.slope-card { margin-top: 14px; padding: 12px 8px; }
.slope-chart { display: block; width: 100%; max-width: 560px; margin: 0 auto; height: auto; font: 600 14px -apple-system, BlinkMacSystemFont, system-ui, sans-serif; }
.slope-chart text { fill: var(--ink); }
.slope-chart .rk { fill: var(--dim); font-weight: 700; }
.slope-chart .col-title { fill: var(--dim); font-size: 10px; font-weight: 700; letter-spacing: .6px; }
.slope line { stroke-width: 2.5; stroke-linecap: round; opacity: .85; }
.slope circle { stroke: none; }
.slope.up line { stroke: var(--green); } .slope.up circle { fill: var(--green); }
.slope.down line { stroke: var(--red); } .slope.down circle { fill: var(--red); }
.slope.flat line { stroke: var(--dim); } .slope.flat circle { fill: var(--dim); }
.slope.self line { stroke-width: 5; opacity: 1; }
.slope.self text { fill: var(--pink); font-weight: 800; }
.pre-callouts { margin: 12px 0 14px; }
.zev-col { background: color-mix(in srgb, var(--purple) 7%, transparent); }
th.zev-col { color: var(--purple); }
.zev-pick { font-weight: 700; color: var(--purple); }
.section-h { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; margin: 26px 4px 10px; }
