:root {
  --pitch: #0e3b2c;
  --stripe: #0c3628;
  --chalk: #eef3ea;
  --chalk-dim: #9fb8a8;
  --line: rgba(238, 243, 234, 0.16);
  --yellow: #f4c430;
  --red: #e0503f;
  --green: #3fbf63;
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--pitch); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--chalk);
  font: 400 16px/1.45 var(--body);
  font-variant-numeric: tabular-nums;
  /* Mown stripes, the only decoration on the page. */
  /* Mown stripes, the only decoration on the page: wide and faint, so they
     never read as row highlights. */
  background:
    repeating-linear-gradient(180deg, var(--pitch) 0 220px, var(--stripe) 220px 440px);
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px 48px;
}

/* ---- masthead ---------------------------------------------------------- */

.masthead { margin: 8px 0 18px; }

h1 {
  margin: 0;
  font: 700 clamp(30px, 8vw, 48px)/0.95 var(--cond);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.status {
  margin: 8px 0 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--chalk-dim);
  font-size: 15px;
}

.status { flex-wrap: wrap; }
.gw-nav { display: inline-flex; align-items: center; gap: 2px; }
#gw {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 1px dashed var(--chalk-dim);
  border-radius: 0;
  padding: 2px 2px 1px;
  color: var(--chalk);
  font: 600 15px/1.2 var(--body);
  cursor: pointer;
}
#gw option { color: #111; }
.gw-step {
  appearance: none; background: none; border: 0;
  width: 28px; height: 28px;
  color: var(--chalk); font: 600 22px/1 var(--body); cursor: pointer;
}
.gw-step:disabled { color: var(--line); cursor: default; }
.gw-step:hover:not(:disabled), #gw:hover { color: var(--yellow); }
.gw-step:focus-visible, #gw:focus-visible, .gw-latest:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.gw-latest {
  appearance: none; background: none; border: 0; padding: 0;
  color: var(--yellow); font: 500 15px/1.2 var(--body); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}

.pulse {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 0 rgba(244, 196, 48, 0.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 9px rgba(244, 196, 48, 0); }
  100% { box-shadow: 0 0 0 0 rgba(244, 196, 48, 0); }
}

.banner {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-left: 3px solid var(--yellow);
  background: rgba(0, 0, 0, 0.22);
  font-size: 15px;
}

/* ---- fixtures ---------------------------------------------------------- */

.fixtures {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -16px 20px;
  padding: 2px 16px 6px;
  scrollbar-width: none;
}
.fixtures::-webkit-scrollbar { display: none; }
@media (min-width: 600px) {
  .fixtures { flex-wrap: wrap; overflow: visible; margin: 0 0 22px; padding: 0; }
}

.fx {
  appearance: none;
  background: none;
  cursor: pointer;
  flex: none;
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: baseline;
  gap: 3px 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: 600 16px/1.2 var(--cond);
  color: var(--chalk-dim);
}
.fx .score { color: var(--chalk); min-width: 2.6em; text-align: center; }
.fx.live { border-color: var(--yellow); color: var(--chalk); }
.fx.live .score { color: var(--yellow); }
.fx.todo .score { font-weight: 500; font-size: 14px; }
.fx:hover { border-color: var(--chalk-dim); }
.fx.open { background: var(--chalk); border-color: var(--chalk); color: var(--pitch); }
.fx.open .score { color: var(--pitch); }
.fx .count { font: 700 12px/1 var(--body); text-align: center; }
.fx .count .plus { color: var(--chalk-dim); font-weight: 400; margin: 0 1px; }
/* League-bench players: same colours, quieter, in brackets after the starters. */
.fx .bench-count { font-weight: 500; opacity: 0.7; color: var(--chalk-dim); }
.c-todo { color: var(--yellow); }
.c-on { color: var(--green); }
.c-off { color: var(--chalk-dim); }
.c-missed { color: var(--red); }
.fx.open .c-off, .fx.open .plus { color: #5b6f63; }
.fx.open .c-todo { color: #9a7400; }
.fx.open .c-on { color: #1d7a3a; }
.fx:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

/* ---- one match ---------------------------------------------------------- */

.match {
  margin: -8px 0 22px;
  padding: 12px 12px 14px;
  border-top: 2px solid var(--chalk);
  background: rgba(0, 0, 0, 0.22);
}
.match-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.match h2 { margin: 0; font: 700 26px/1.1 var(--cond); }
.match .close {
  appearance: none; background: none; border: 0; padding: 4px 0;
  color: var(--chalk-dim); font: 500 14px/1 var(--body); cursor: pointer;
}
.match .close:hover { color: var(--chalk); }
.match .note { margin: 4px 0 0; color: var(--chalk-dim); font-size: 14px; }
.match-cols { display: grid; gap: 4px 24px; }
@media (min-width: 600px) { .match-cols { grid-template-columns: 1fr 1fr; } }
.match h3 { margin: 12px 0 4px; font: 600 15px/1 var(--cond); color: var(--chalk-dim); }
.match .empty { padding: 6px 0; font-size: 14px; }

.mp {
  display: grid;
  grid-template-columns: 34px 1fr 40px;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-top: 1px dashed var(--line);
}
.mp .pos { color: var(--chalk-dim); font: 500 14px/1 var(--cond); }
.mp-main { min-width: 0; }
.mp-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.mp .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp .owner {
  margin-left: auto;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  appearance: none; background: none; border: 0; padding: 0;
  color: var(--yellow); font: 500 13px/1.2 var(--body); cursor: pointer;
}
.mp .owner:hover { text-decoration: underline; }
.mp .owner.free { color: var(--chalk-dim); cursor: default; }
.mp .owner .on-bench { color: var(--chalk-dim); font-style: italic; }
.mp .facts { display: block; color: var(--chalk-dim); font-size: 13px; }
.mp .pts { justify-self: end; }
.mp:not(.owned) .name { color: var(--chalk-dim); }

/* ---- table ------------------------------------------------------------- */

.table-head, .row-main {
  display: grid;
  grid-template-columns: 34px 1fr 52px 64px;
  align-items: center;
  column-gap: 8px;
}
.c-wide { display: none; }
@media (min-width: 600px) {
  .table-head, .row-main { grid-template-columns: 40px 1fr 56px 52px 52px 64px 64px; }
  .table-head { align-items: end; }
  .c-wide { display: block; }
  .row-sub .wide-hide { display: none; }
}

.table-head {
  padding: 0 10px 6px;
  color: var(--chalk-dim);
  font: 500 14px/1 var(--body);
}
.c-num { text-align: right; }

.table { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--chalk); }

.row { border-bottom: 1px solid var(--line); position: relative; }
.row.open { background: rgba(0, 0, 0, 0.2); }

.row-button {
  all: unset;
  box-sizing: border-box;
  display: block;
  width: 100%;
  padding: 12px 10px;
  cursor: pointer;
}
.row-button:focus-visible { outline: 2px solid var(--yellow); outline-offset: -2px; }

.rank {
  font: 700 26px/1 var(--cond);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.move { font: 600 12px/1 var(--body); margin-top: 3px; }
.move.up { color: var(--yellow); }
.move.down { color: var(--red); }

.who { min-width: 0; }
.team {
  display: block;
  font: 600 21px/1.1 var(--cond);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-sub { display: block; color: var(--chalk-dim); font-size: 14px; margin-top: 2px; }
@media (max-width: 599px) { .row-sub .wide-hide { display: block; } }
.to-play { color: var(--yellow); }
.playing { color: var(--green); font-weight: 600; }

/* ---- sortable header ---------------------------------------------------- */

.table-head .sort {
  appearance: none; background: none; border: 0; padding: 0;
  color: inherit; font: inherit; text-align: right; cursor: pointer;
}
.table-head .sort.c-rank { text-align: left; }
.table-head .sort:hover, .table-head .sort.active { color: var(--chalk); }
.table-head .sort:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.table-head .sort[data-dir="down"]::after { content: " ▼"; font-size: 10px; }
.table-head .sort[data-dir="up"]::after { content: " ▲"; font-size: 10px; }

/* ---- the week's scores, relative to each other --------------------------- */

.num.gw { justify-self: end; padding: 3px 5px 2px; border-radius: 3px; }
.num.gw.gw-top { background: var(--yellow); color: var(--pitch); }
.num.gw.gw-good { color: var(--green); }
.num.gw.gw-low { color: var(--red); }

.num { text-align: right; font: 600 22px/1 var(--cond); }
.num.gw { font-size: 26px; }
.num.total { font-size: 26px; font-weight: 700; }
.num.dim { color: var(--chalk-dim); font-weight: 500; font-size: 20px; }

.flash { animation: flash 1.6s ease-out; }
@keyframes flash {
  0% { color: var(--pitch); background: var(--yellow); }
  100% { background: transparent; }
}

/* ---- squad ------------------------------------------------------------- */

.squad { padding: 0 10px 14px 52px; }
@media (max-width: 599px) { .squad { padding-left: 10px; } }

.squad h3 {
  margin: 10px 0 4px;
  font: 500 14px/1 var(--body);
  color: var(--chalk-dim);
}

.p {
  display: grid;
  grid-template-columns: 38px 1fr 42px;
  gap: 8px;
  align-items: center;
  padding: 5px 0;
  border-top: 1px dashed var(--line);
}
.p .pos { color: var(--chalk-dim); font: 500 14px/1 var(--cond); }
.p .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p .club { color: var(--chalk-dim); font-size: 13px; margin-left: 4px; }
/* Name and breakdown on one line; it wraps only when it has to. */
.p .line { min-width: 0; line-height: 1.3; }
.p .name { white-space: normal; overflow: visible; }
.p .facts { color: var(--chalk-dim); font-size: 13px; margin-left: 6px; }
/* Points pills. The colour is the reading: dim for nothing, green for a
   decent return, yellow for a big one, a solid yellow card for a haul. */
.pts {
  justify-self: end;
  min-width: 2em;
  padding: 3px 5px 2px;
  border-radius: 3px;
  text-align: center;
  font: 700 19px/1 var(--cond);
}
.t-neg { color: var(--red); }
.t-low { color: var(--chalk-dim); font-weight: 500; }
.t-ok { color: var(--chalk); }
.t-good { color: var(--green); }
.t-great { color: var(--yellow); box-shadow: inset 0 0 0 1.5px var(--yellow); }
.t-haul { color: var(--pitch); background: var(--yellow); }
.p.todo .pts, .p.blank .pts, .mp.todo .pts { color: var(--chalk-dim); background: none; box-shadow: none; }
/* Still to come: yellow, like "3 to play" in the table and the chip counts. */
.p.yet .facts, .mp.yet .facts { color: var(--yellow); }
.p.yet .pts, .mp.yet .pts { color: var(--yellow); opacity: 0.75; background: none; box-shadow: none; }
.p.playing .name::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px; margin-left: 6px; border-radius: 50%;
  background: var(--yellow);
  vertical-align: middle;
}
.p .sub-in { color: var(--yellow); }
.p .sub-out { color: var(--red); }
.p.out .name { text-decoration: line-through; text-decoration-color: var(--red); }
.prov { color: var(--yellow); }

.foot { margin-top: 28px; color: var(--chalk-dim); font-size: 14px; max-width: 62ch; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.legend .pts { font-size: 16px; }

.empty { padding: 24px 10px; color: var(--chalk-dim); }

@media (prefers-reduced-motion: reduce) {
  .pulse, .flash { animation: none; }
}
