/* ---------- team focus view ---------------------------------------- */

.team-section { padding: 1.25rem; border-top: 1px solid var(--rule); }
.team-section:first-child { border-top: 0; padding-top: 0.75rem; }
.team-section > .label { margin-bottom: 0.6rem; }
.team-section__hint { font-size: 0.85rem; color: var(--ink-muted); margin: 0 0 0.5rem; }
.team-shape--loading { height: 280px; display: flex; align-items: center; justify-content: center; color: var(--ink-muted); }

.team-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.team-section__header > .label { margin-bottom: 0; }

/* Back: a quiet tinted circle with a chevron that leans the way it goes, at
   the head of the club's summary. No lift or shadow on hover -- a navigation
   control, not a call to action. Its words are the accessible name. */
.team-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  align-self: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: color-mix(in oklab, var(--ink) 6%, var(--panel));
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.team-back span { display: none; }
.team-back svg { flex: none; transition: transform 0.15s var(--ease); }
.team-back:hover { background: color-mix(in oklab, var(--ink) 11%, var(--panel)); }
.team-back:hover svg { transform: translateX(-3px); }
.team-back:active { background: color-mix(in oklab, var(--ink) 15%, var(--panel)); }
@media (prefers-reduced-motion: reduce) {
  .team-back svg { transition: none; }
  .team-back:hover svg { transform: none; }
}

#team-content { padding: 0.5rem 1.25rem; }

/* Overview / Forecast / History: the league switch's segmented pill,
   stretched so each group is a wide target; the open group follows it
   without a rule, since the pill already divides it from the header. */
.team-tabs { display: flex; max-width: 30rem; margin: 0 auto 0.25rem; }
.team-tabs button { flex: 1; }
.team-tabs + .team-section { border-top: 0; }
.team-now { display: grid; gap: 0.75rem; }

.team-summary {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.team-summary__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}



.team-logo--large {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  flex: none;
}

.team-summary__name-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1;
}

.team-summary__name {
  font-size: 1.5rem;
  /* The ellipsis needs overflow hidden, which would shave a descender off the
     g in Viking at a tight line height. */
  line-height: 1.3;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Your club and the share button, one row under the name. */
.team-summary__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  margin-top: var(--space-1);
}
/* Outranks the general .share-btn rule's auto margin, which would push it right. */
.team-summary .team-summary__actions > .share-btn { margin: 0; }

/* Your club: a quiet pill, lit in the accent once chosen. */
.team-summary__own {
  appearance: none;
  min-height: 2rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: none;
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.team-summary__own:hover { color: var(--ink); border-color: var(--ink-faint); }
.team-summary__own[aria-pressed="true"] { color: var(--accent-ink); border-color: var(--accent-ink); }
.team-summary__own-words { margin-left: 0.35rem; }
/* On a phone the star stands alone under the name, the share button beside
   it: beside the name, the two took its width and cut it short. */
@media (max-width: 760px) {
  .team-summary__name-block { gap: 0.25rem; }
  .team-summary__own-words { display: none; }
  .team-summary__actions { margin-top: 0; }
  .team-summary__own { padding: 0.25rem 0.6rem; font-size: 1rem; line-height: 1; }

  /* One row, as an app's navigation bar: back, the crest, the name (two lines
     at most rather than cut short), and the club's two actions at the right,
     in the room the name leaves; the rating and its rank on the row below. */
  .team-summary .team-summary__header {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "back crest name actions" "rating rating rating rating";
    align-items: center;
    gap: 0.75rem 0.6rem;
  }
  .team-summary__header > .team-back { grid-area: back; }
  .team-summary__header > .team-logo--large { grid-area: crest; width: 44px; height: 44px; }
  .team-summary__header .team-summary__name-block { display: contents; }
  .team-summary__header .team-summary__name {
    grid-area: name;
    font-size: 1.25rem;
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .team-summary__header .team-summary__actions { grid-area: actions; margin: 0; gap: 0.4rem; }
  .team-summary__header .team-summary__rating-block { grid-area: rating; }
  .team-summary__actions > :is(.team-summary__own, .share-btn) {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    min-height: 0;
    padding: 0;
    border-radius: 999px;
  }
}

.team-summary__rating-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex: none;
  margin-left: auto;
}

.team-summary__rating-line {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.team-summary__rating {
  font-family: var(--display);
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.team-summary__rating-pos {
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.team-summary__trend {
  font-size: 2.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
}

.team-summary__trend--strong-rise { color: var(--outcome-good); }
.team-summary__trend--rise { color: var(--outcome-good); }
.team-summary__trend--steady { color: var(--ink-faint); }
.team-summary__trend--fall { color: var(--outcome-bad); }
.team-summary__trend--strong-fall { color: var(--outcome-bad); }

/* The trend arrows are icons, not text (3:1 is their bar, WCAG 1.4.11), so
   they take the vivid fills: 3.4:1 or more on every surface.
   xG form under the rating: a labelled line, so it never reads as a second
   verdict on the rating. Only the icon takes the trend colour. */
.team-summary__form {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.3rem;
  font-size: 0.8125rem;
  color: var(--ink-muted);
  cursor: help;
}
.team-summary__form-key {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.team-summary__form-icon { display: inline-flex; font-size: 1rem; }

/* The club overview's glance, after the club app's: a card for the next match
   and one for the last five, each score a chip in its result's colour with
   the opponent's crest beneath. */
.team-glance { display: grid; gap: 0.75rem; }
@media (min-width: 761px) { .team-glance { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.team-card {
  padding: 0.75rem 0.9rem 0.6rem;
  border-radius: var(--radius);
  background: var(--panel-sunk);
  min-width: 0;
}
.team-card > .label { display: block; margin-bottom: 0.4rem; }
.team-card .team-match { padding-inline: 0; border-bottom: 0; }
/* In the next-match card the odds take a line of their own, the card's width. */
@media (max-width: 760px) {
  .team-card .team-match {
    grid-template-columns: 1.25rem 2.25rem minmax(0, 1fr);
    grid-template-areas: "venue crest opp" "venue crest date" "result result result";
    row-gap: 0.35rem;
  }
  .team-card .team-match__odds { width: 100%; grid-area: result; margin-top: 0.4rem; }
  .team-card .team-match__pcts { font-size: 0.875rem; }
  .team-card .team-match__odds .odds { height: 0.625rem; }
}
@media (min-width: 761px) { .team-card .team-match__odds { width: 11rem; } }
.team-last { display: flex; justify-content: space-between; gap: 0.4rem; }
.team-last__item {
  appearance: none;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.2rem 0 0.35rem;
  cursor: pointer;
}
.team-last__score {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.team-last__score.form__chip--d { color: #10171b; }
.team-last__item .team-logo { width: 1.75rem; height: 1.75rem; }

/* The club overview and forecast are wrappers: a plain column on a phone
   (the side's sections flow in the order they were drawn), two columns on a
   wide screen. Each section keeps its own rule above it. */
.team-side { display: contents; }
.team-overview > .team-section,
.team-side > .team-section,
.team-forecast > .team-section { border-top: 1px solid var(--rule); }
.team-overview > .team-now,
.team-overview > .team-glance,
.team-forecast > .team-section:first-child { border-top: 0; }
/* The tiles come first, the rest below a rule. */
.team-overview > .team-now { border-bottom: 1px solid var(--rule); }
/* Higher specificity than the row rules that come after, which set `display`. */
@media (max-width: 760px) {
  .team-matches .team-match--later { display: none; }
  .team-mini .team-mini__row .team-mini__extra, .team-mini .team-mini__row--far { display: none; }
}

/* The seasons' places as a line: circles on a scale of places, coloured by
   division, the line by whether the club rose or fell. */
.team-positions { display: block; width: 100%; height: auto; overflow: visible; }
.team-positions__seg { fill: none; stroke-width: 2.5; stroke-linecap: round; }
.team-positions__seg--up { stroke: var(--outcome-good); }
.team-positions__seg--down { stroke: var(--outcome-bad); }
.team-positions__seg--flat { stroke: var(--rule-strong); }
.team-positions__rule { stroke: var(--rule-strong); stroke-width: 1; stroke-dasharray: 3 4; }
.team-positions__tier { font-size: 8px; font-weight: 600; letter-spacing: 0.08em; fill: var(--ink-muted); }
.team-positions__dot { fill: var(--panel); stroke-width: 2; }
.team-positions__dot--tier1 { stroke: var(--tier-1); }
.team-positions__dot--tier2 { stroke: var(--tier-2); }
.team-positions__dot--champion { stroke: var(--band-champion); }
.team-positions__num { font-size: 10px; font-weight: 700; fill: var(--ink); text-anchor: middle; dominant-baseline: central; font-variant-numeric: tabular-nums; }
.team-positions__year { font-size: 9px; fill: var(--ink-muted); text-anchor: middle; font-variant-numeric: tabular-nums; }
.team-positions__item.is-now .team-positions__dot { fill: var(--accent); stroke: var(--accent); }
.team-positions__item.is-now .team-positions__num { fill: var(--on-accent); }
.team-split { display: none; }
.team-split__grid { display: grid; grid-template-columns: minmax(3.5rem, 1fr) repeat(7, 2.1rem); row-gap: 0.45rem; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.team-split__cell { text-align: right; }
.team-split__cell:nth-child(8n + 1) { text-align: left; font-weight: 600; }
.team-split__label { display: inline-flex; align-items: center; gap: 0.35rem; }
.team-split__cell.team-split__head { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }
.team-split__cell:nth-child(8n) { font-weight: 700; }

@media (min-width: 761px) {
  .team-split { display: block; }
}

/* A wide screen: the glance and the results on the left, the standing on
   the right. */
@media (min-width: 961px) {
  .team-overview {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
    grid-template-areas: "now now" "glance side" "results side";
    grid-template-rows: auto auto 1fr;
    gap: 0 1.75rem;
    align-items: start;
    padding-top: 0.5rem;
  }
  .team-overview > .team-now {
    grid-area: now;
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
    gap: 0 1.75rem;
    padding-inline: 0;
    margin-bottom: 0.75rem;
  }
  .team-overview > .team-glance { grid-area: glance; grid-template-columns: 1fr; padding-inline: 0; }
  .team-overview > .team-side { grid-area: side; display: grid; gap: 0; }
  .team-overview > .team-section:not(.team-glance):not(.team-now) { grid-area: results; padding-inline: 0; }
  .team-side > .team-section { padding-inline: 0; }
  .team-side > .team-section:first-child { border-top: 0; padding-top: 0.75rem; }
  .team-overview .team-card .team-match__odds { width: 14rem; }
  .team-overview .team-results .team-match { grid-template-columns: 5.5rem 1.5rem minmax(0, 1fr) auto; }

}

/* The club's place in the table, three rows. */
.team-mini { display: grid; gap: 0; }
.team-mini__row {
  appearance: none;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr) 2rem 1.75rem 1.75rem 1.75rem 2.5rem 2.75rem;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.5rem;
  border-top: 1px solid var(--rule);
  cursor: pointer;
}
button.team-mini__row:hover { background: var(--panel-sunk); }
.team-mini__row.is-own { font-weight: 700; background: var(--panel-sunk); cursor: default; opacity: 1; }
.team-mini__row:disabled { color: var(--ink); }
@media (max-width: 760px) {
  .team-mini__row { grid-template-columns: 1.5rem minmax(0, 1fr) 2rem 2.5rem 2.75rem; }
}
.team-mini__head {
  border-top: 0;
  padding-block: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  cursor: default;
}
.team-mini__club { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.team-mini__club span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-mini__num { text-align: right; font-variant-numeric: tabular-nums; }
.team-mini__row > .team-mini__num:first-child { text-align: left; }
/* A button that leads to another page: a real, bordered button in the same
   pill as the other secondary buttons, never a bare text link. */
.team-mini__full,
.whatif-reset,
.whatif-impact__meta {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.team-mini__full:hover,
.whatif-reset:hover,
.whatif-impact__meta:hover {
  background: var(--panel-sunk);
  border-color: var(--rule-strong);
  box-shadow: var(--glow-hover);
}
.team-mini__full:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.team-section__header:has(> .team-mini__full) { display: flex; align-items: baseline; justify-content: space-between; }

/* Team view fixtures and results: one compact row per match from the club's
   side -- date, H/A, opponent, then odds or result. */
.team-matches { display: flex; flex-direction: column; }
.team-match {
  display: grid;
  grid-template-columns: 6.25rem 1.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.25rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.9375rem;
}
.team-match:last-child { border-bottom: 0; }
/* The forecast tab's fixtures: the likeliest scores between the opponent and
   the odds. On a desktop the odds bar takes the larger share of the room the
   name leaves, never under its usual 13rem; the scores keep a fixed column
   (three pills of two-digit chances fit), so the bars line up row to row. */
.team-match--lines { grid-template-columns: 6.25rem 1.5rem minmax(0, 1fr) auto auto; }
.team-match__lines { display: flex; gap: 0.3rem; }
@media (min-width: 761px) {
  .team-match--lines { grid-template-columns: 6.25rem 1.5rem minmax(0, 1fr) 13rem minmax(13rem, 1.5fr); }
  .team-match--lines .team-match__lines { justify-content: flex-end; }
  .team-match--lines .team-match__odds { width: auto; }
}
/* A narrow desktop has no room for a scores column beside the name: the
   scores go under the name, and the bar keeps the right-hand side. */
@media (min-width: 761px) and (max-width: 1099px) {
  .team-match--lines {
    grid-template-columns: 6.25rem 1.5rem minmax(0, 1fr) minmax(13rem, 1.5fr);
    grid-template-areas: "date venue opp odds" "date venue lines odds";
    row-gap: 0.35rem;
  }
  .team-match--lines .team-match__date { grid-area: date; }
  .team-match--lines .team-match__venue { grid-area: venue; }
  .team-match--lines .team-match__opponent { grid-area: opp; }
  .team-match--lines .team-match__lines { grid-area: lines; justify-content: flex-start; }
  .team-match--lines .team-match__odds { grid-area: odds; }
}
.team-match__date { font-size: 0.8125rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.team-match__venue { justify-self: center; }
.team-match .team-match__opponent { display: flex; flex-direction: row; align-items: center; gap: 0.5rem; min-width: 0; }
.team-match .team-match__opponent .team-logo { width: 28px; height: 28px; flex: none; }
.team-match__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.team-match__name:hover { text-decoration: underline; }
.team-match__label { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.team-match__result { display: inline-flex; align-items: center; gap: 0.6rem; font-variant-numeric: tabular-nums; }
.team-match__score { font-family: var(--display); font-weight: 800; min-width: 2.2rem; }
.team-match__xg { font-size: 0.75rem; color: var(--ink-muted); min-width: 4.5rem; }
.team-match__delta { font-size: 0.8125rem; font-weight: 700; min-width: 2rem; text-align: right; color: var(--ink-faint); }
.team-match__delta.up { color: var(--outcome-good-ink); }
.team-match__delta.down { color: var(--outcome-bad-ink); }
.team-match__odds { width: 13rem; display: grid; gap: 0.25rem; }
.team-match__odds .odds { height: 0.5rem; padding: 0; margin: 0; overflow: visible; }
.team-match__pcts { display: grid; gap: 2px; font-size: 0.75rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.team-match__pct--draw { text-align: center; }
.team-match__pct--loss { text-align: right; }
.team-match__pct--win { color: var(--outcome-good-ink); }
.team-match__pct--draw { color: var(--ink-muted); }
.team-match__pct--loss { color: var(--outcome-bad-ink); }
.team-match__legend { padding: 0; border: 0; background: none; font-size: 0.75rem; }
/* Below desktop width the date moves under the opponent's name, so a row is
   one block instead of a floating date line over it, and the crest stands
   beside both lines, centred on the row and the larger for it. */
@media (max-width: 760px) {
  .team-match {
    grid-template-columns: 1.25rem 2.25rem minmax(0, 1fr) auto;
    grid-template-areas: "venue crest opp result" "venue crest date result";
    gap: 0.1rem 0.6rem;
  }
  .team-match__venue { grid-area: venue; justify-self: center; }
  .team-match .team-match__opponent { display: contents; }
  .team-match .team-match__opponent .team-logo { grid-area: crest; width: 2.25rem; height: 2.25rem; }
  .team-match__label { grid-area: opp; align-self: end; }
  .team-match__date { grid-area: date; align-self: start; font-size: 0.75rem; }
  .team-match__result, .team-match__odds { grid-area: result; }
  .team-match__odds { width: 8.5rem; }
  .team-match__xg { display: none; }
  .team-section__header:has(.team-match__legend) { flex-wrap: wrap; row-gap: 0.4rem; }
  .team-match__legend { flex-basis: 100%; }
  /* The scores take a line of their own under the name and date. */
  .team-match--lines {
    grid-template-columns: 1.25rem 2.25rem minmax(0, 1fr) auto;
    grid-template-areas: "venue crest opp result" "venue crest date result" ". . lines lines";
  }
  .team-match__lines { grid-area: lines; margin-top: 0.35rem; }
}

/* Matches: a part-played week puts a heading over its results and fixtures. */
.matches__group { display: block; padding: 0.9rem 1.25rem 0.25rem; }

/* Outlook: the model's forecast as tiles under the table tiles, with the
   pre-season call as one line beneath. */
.team-outlook { margin-top: 0.75rem; }
.team-outlook > .label { display: block; margin-bottom: 0.45rem; }
.team-outlook__note {
  margin: 0.45rem 0 0;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

/* Rating trend arrow in the standings table — same style as the team view */
.rating-trend {
  display: inline-flex;
  /* Level with the rating beside it: "middle" sat the arrow 3px high. */
  vertical-align: -0.2em;
  margin-left: 0.3rem;
  font-size: 1.15rem;
  line-height: 1;
}
.rating-trend--strong-rise { color: var(--outcome-good); }
.rating-trend--rise { color: var(--outcome-good); }
.rating-trend--steady { color: var(--ink-faint); }
.rating-trend--fall { color: var(--outcome-bad); }
.rating-trend--strong-fall { color: var(--outcome-bad); }
.rating-trend--top { color: var(--band-champion); }
/* Gold on white is 1.8:1; an icon needs 3:1 (WCAG 1.4.11). */
:root:not([data-resolved-theme="dark"]) .rating-trend--top { color: color-mix(in srgb, var(--band-champion) 60%, var(--ink)); }


/* Stat tiles: equal columns split by hairlines, value over label. Four
   across for the table strip, two for the xG strip, on any width. */
.team-stats {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  margin: 0;
  gap: 1px;
  border-radius: var(--radius);
  background: var(--rule);
  overflow: hidden;
}
.team-stats__tile {
  background: var(--panel-sunk);
  display: flex;
  flex-direction: column-reverse; /* dt first in the markup, value on top */
  justify-content: flex-end;
  align-items: center;
  gap: 0.2rem;
  padding: 0.75rem 0.5rem;
  text-align: center;
  min-width: 0;
}
.team-stats__label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.team-stats__value {
  margin: 0;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
/* xG tiles read value, label, bar, note: order puts the bar and note after
   the label while the value stays on top. */
.team-stats--xg .team-stats__tile { flex-direction: column; align-items: stretch; }
.team-stats--xg .team-stats__value { order: -1; text-align: center; }
.team-stats__bar {
  position: relative;
  height: 6px;
  margin: 0.35rem 0.5rem 0;
  border-radius: 999px;
  background: var(--rule);
}
.team-stats__bar::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 var(--from);
  width: var(--width);
  border-radius: inherit;
  background: var(--outcome-good);
}
.team-stats__bar--bad::before { background: var(--outcome-bad); }
/* The division average: the centre line the bar grows out from. */
.team-stats__bar::after {
  content: "";
  position: absolute;
  left: calc(50% - 1px);
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--ink);
}

/* High-stakes lines in the team summary: one row per entry, the band carried
   by a dot in its palette colour and the consequence in words. Restrained by
   design — the numbers live in the sentence, not in a dashboard. */
.team-stakes > .label { display: block; margin-bottom: 0.45rem; }
.team-stakes__more { margin: 0.5rem 0 0; font-size: 0.75rem; color: var(--ink-muted); }
.team-stakes__list + .label { margin-top: 0.85rem; }
.team-stakes__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
/* A decisive match as a small chart (see stakeRow). */
.team-stakes .legend { padding: 0 0 0.35rem; border: 0; background: none; font-size: 0.75rem; }
.stake__now-key { display: inline-block; width: 2px; height: 0.8rem; background: var(--ink); border-radius: 1px; }
/* In between, each match a compact unit, not a track the width of the page; on
   a wide screen they go two to a row and use the width. */
.team-stakes__list, .team-stakes .legend { max-width: 36rem; }
@media (min-width: 961px) {
  .team-stakes__list, .team-stakes .legend { max-width: none; }
  .team-stakes__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 2.5rem; }
  .team-stakes__list > .stake:nth-child(2) { border-top: 0; padding-top: 0.2rem; }
}
.stake { padding: 0.55rem 0 0.2rem; border-top: 1px solid var(--rule); }
.stake:first-child { border-top: 0; padding-top: 0.2rem; }
.stake__head { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.stake__race {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
  min-width: 4.6rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.stake__dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; flex: none; }
.stake__who {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}
.stake__who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* A rival match's name in a stake row: the club button's size, not clickable. */
.stake__match { min-width: 0; font-size: 0.875rem; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stake__who:hover span { text-decoration: underline; }
.stake__when { display: inline-flex; align-items: center; gap: 0.2rem; margin-left: auto; flex: none; font-size: 0.75rem; color: var(--ink-faint); white-space: nowrap; }
.stake__track {
  position: relative;
  height: 0.5rem;
  margin: 0.65rem 0.5rem 1.35rem;
  border-radius: 999px;
  background: var(--rule);
}
.stake__span { position: absolute; top: 0; bottom: 0; border-radius: inherit; opacity: 0.65; }
.stake__now { position: absolute; top: -0.25rem; bottom: -0.25rem; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; }
.stake__pin {
  position: absolute;
  top: 50%;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px var(--panel);
}
.stake__pin--win { background: var(--home); }
.stake__pin--draw { background: var(--draw); }
.stake__pin--loss { background: var(--away); }
.stake__figure {
  position: absolute;
  top: 0.85rem;
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stake__figure--win { color: var(--outcome-good-ink); }
.stake__figure--loss { color: var(--outcome-bad-ink); }

@media (max-width: 760px) {
  .stake-flag { font-size: 0.75rem; padding: 0.25rem 0.6rem; }
}

/* Rating chart stats (peak/worst) beneath the chart */
.team-chart-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.team-chart-stat {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.team-chart-stat b { color: var(--ink); font-weight: 700; }

/* Finish grid row: one team's 16-position probability bar */
.team-grid-row {
  display: flex;
  gap: 3px;
  width: 100%;
}

.team-grid-row__cell-wrap { justify-content: flex-end; }
.team-grid-row__cell-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.team-grid-row__pos {
  font-size: 0.625rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.team-grid-row__cell {
  width: 100%;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 3px;
  font-size: 0.6875rem;
  color: var(--cell-ink);
  font-variant-numeric: tabular-nums;
  cursor: default;
  transition: transform 0.12s var(--ease);
}

.team-grid-row__cell--empty { color: transparent; }
/* A phone's few cells stay cells, not slabs, with room for their figures. */
.team-grid-row--roomy .team-grid-row__cell-wrap { flex: 0 0 3.25rem; }
.team-grid-row--roomy .team-grid-row__cell { height: 2rem; font-size: 0.75rem; letter-spacing: 0; }
.team-grid-row--roomy .team-grid-row__pos { font-size: 0.6875rem; }

.team-grid-row__cell.cell--invert { color: var(--cell-ink-invert); }

.team-grid-row__cell:hover {
  transform: scale(1.12);
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px var(--ink);
  position: relative;
  z-index: 2;
}

/* ---------- season-by-season (team view) ---------------------------- */

/* Unified compact season list: one single column of rows under the chart,
   which is also the picker. */
.seasons-list-compact {
  display: grid;
  grid-template-columns: 1fr;
  padding-bottom: 0.5rem;
}

.season-row-compact {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0.85rem;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background 0.12s var(--ease);
  position: relative;
  width: 100%;
  min-width: 0;
  text-align: left;
}
.season-row-compact:last-child { border-bottom: 0; }
.season-row-compact:hover,
.season-row-compact:focus-visible { background: var(--panel-sunk); }
.season-row-compact:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: -2px;
}

/* Active state - currently displayed season shape */
.season-row-compact.is-active {
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  box-shadow: inset 3px 0 0 var(--accent);
}
.season-row-compact.is-active:hover {
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
}

.season-row-compact__season {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 7.5rem;
  flex-shrink: 0;
}
.season-row-compact__year {
  font-family: var(--display);
  font-size: 0.9375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
/* Division pill: full-round, type big enough to read at a glance. */
.season-row-compact__badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  height: 1.25rem;
  padding: 0 0.4rem;
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
}
.is-one-division .season-row-compact__badge { display: none; }
.season-row-compact__badge--tier1 { background: color-mix(in srgb, var(--tier-1) 18%, transparent); color: color-mix(in srgb, var(--tier-1) 75%, var(--ink)); }
.season-row-compact__badge--tier2 { background: color-mix(in srgb, var(--tier-2) 18%, transparent); color: color-mix(in srgb, var(--tier-2) 75%, var(--ink)); }

.season-row-compact__main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
  padding-left: 0.5rem;
}
.season-row-compact__pos {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  width: 3rem;
  text-align: right;
}

.season-row-compact__rating {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  min-width: 7rem;
}
.season-row-compact__rating-start {
  font-family: var(--display);
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  text-align: right;
  min-width: 3rem;
}
.season-row-compact__change {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 5.5rem;
}
.season-row-compact__change-val {
  font-family: var(--display);
  font-size: 0.875rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 2.2rem;
  text-align: right;
}
.season-row-compact__change-val.up { color: var(--outcome-good-ink); }
.season-row-compact__change-val.down { color: var(--outcome-bad-ink); }
.season-row-compact__change-bar {
  flex: 1;
  height: 4px;
  background: var(--rule);
  border-radius: 999px;
  overflow: hidden;
}
.season-row-compact__change-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s var(--ease);
}
.season-row-compact__change-fill--up { background: var(--outcome-good); }
.season-row-compact__change-fill--down { background: var(--outcome-bad); }

/* Column names above the season rows: the rows' cells and spacing, label
   type, no chrome. Its own class, so nothing that walks the rows meets it. */
.season-row-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 0.85rem 0.1rem;
}
.team-seasons .season-row-head * {
  font: 600 0.6875rem/1.2 var(--body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.season-row-head .season-row-compact__change { justify-content: center; }
.season-row-compact__live {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--outcome-good-ink);
}
/* On a phone, or in the seasons' narrow side column, the word does not fit
   beside the place; a dot carries it. */
@media (max-width: 760px), (min-width: 961px) {
  .team-seasons .season-row-compact__live,
  .season-row-compact__live {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: var(--outcome-good);
    font-size: 0;
    flex: none;
  }
}
.season-row-compact__rating-end {
  font-family: var(--display);
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 3rem;
  text-align: right;
}

/* Pagination in team section */
.team-section .played-nav { padding-inline: 1.25rem; }
@media (max-width: 760px) {
  .team-section .played-nav { padding-inline: 0; }
}
/* ...but under the picker it aligns with the rows and drops the trailing
   rule: the section already has an edge. */
.team-seasons .played-nav {
  padding-inline: 0;
  border-bottom: 0;
  margin-top: 0.35rem;
}

/* Rating chart used in team view */
.chart .career-line { fill: none; stroke: var(--seq-5); stroke-width: 2; }
.chart .career-area { fill: var(--seq-5); opacity: 0.12; }
.chart .season-split { stroke: var(--rule); stroke-width: 1; }
.chart .season-label { fill: var(--ink-muted); font-size: 9px; }
.chart .career-dot { fill: var(--seq-5); stroke: var(--panel); stroke-width: 2; }

/* The season list sits under the chart, clear of its axis caption. */
.team-seasons > .team-shape-container { margin-bottom: 1rem; }
/* On a phone the chart takes the card's width: out into the padding either side,
   its heading kept in line with the rest. */
@media (max-width: 480px) {
  .team-shape-container { margin-inline: -0.6rem; }
  .team-shape-container > .label { margin-left: 0.6rem; }
}
/* The numerals sit on the gradient: dark ink on the light steps, the page's
   ground on the dark ones. */
.chart .band-pos { font-size: 9.5px; font-weight: 700; fill: var(--ink); opacity: 0.8; dominant-baseline: middle; }
.chart .band-pos--invert { fill: var(--panel); opacity: 1; }

#standings tbody tr { cursor: pointer; }

.club-btn {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  text-align: left;
  /* WCAG 2.5.8's 24px minimum. 44px set every row's height; the whole row
     opens the club, so a finger already has the row's full width. */
  min-height: 24px;
}
.club-btn:hover { text-decoration: underline; }

.club-btn--crest .team-logo {
  width: 18px;
  height: 18px;
  margin-right: 0.45rem;
  vertical-align: -0.3em;
}

/* ---------- season rewind timeline -------------------------------- */

/* Inside the open view's card, under its heading (placeTimeline), and only
   once its button there has opened it. */
.timeline { padding: 0.85rem var(--space-5) 0.75rem; border-bottom: 1px solid var(--rule); }
.timeline:not(.is-open) { display: none; }

/* A card heading's buttons: the rewind's, the view's own. */
.panel__tools { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
/* The table's Rewind button comes before its Current/Prediction switch. */
#table .panel__tools .timeline-toggle { order: -1; }
/* The button's own display would beat [hidden] and leave it as a bare bar
   above the views that have no rewind (a club, Compare, Matches). */
.timeline-toggle[hidden] { display: none; }
.timeline-toggle[aria-expanded="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--glow-ring);
}
.timeline-toggle[aria-expanded="true"] .grid-anim-btn__icon { color: inherit; }

.timeline__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

/* The eyebrow and the state read as one line rather than a stacked block. */
.timeline__head > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.timeline__head p {
  margin: 0.25rem 0 0;
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timeline__now {
  appearance: none;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--panel-sunk);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 0.35rem 0.8rem;
  cursor: pointer;
  flex: none;
}

.timeline__now:hover { border-color: var(--ink-faint); }
/* Hidden, the back-to-live button keeps its room, so its appearing as you
   leave live never moves the slider. */
.timeline__now[hidden] { display: block; visibility: hidden; }
.timeline__now-short { display: none; }

/* On a phone, a fixed shape while you scrub: the eyebrow and the
   back-to-live button on one row, the state on two reserved lines below, so
   neither the button nor a longer date moves the slider under the thumb.
   The race in the hero above keeps the room it has taken too (renderHero
   never lets it shrink while you scrub). After the base rules
   above, which it must override. */
@media (max-width: 760px) {
  .timeline__head { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.25rem 0.75rem; }
  .timeline__head > div:first-child { display: contents; }
  .timeline__head .label { grid-column: 1; grid-row: 1; }
  .timeline__now { grid-column: 2; grid-row: 1; }
  .timeline__head p { grid-column: 1 / -1; grid-row: 2; min-height: 2lh; margin: 0; }
  /* "Live" rather than "Back to live", so the eyebrow beside it keeps to one line. */
  .timeline__now-long { display: none; }
  .timeline__now-short { display: inline; }
}

.timeline__control { position: relative; }

/* A slider scrubs sideways: the browser keeps vertical pans (the page
   scrolls) and leaves the horizontal to the slider, so a scrub never turns
   into a pull to refresh or an edge swipe. */
#timeline-range, #mountain-upto { touch-action: pan-y; }

.timeline input[type="range"] {
  appearance: none;
  width: 100%;
  height: 1.5rem;
  background: none;
  cursor: pointer;
  margin: 0;
}

/* The rail is the season; the thumb is where you are standing in it. */
.timeline input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: var(--rule);
}

.timeline input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--rule);
}

.timeline input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--panel);
  box-shadow: 0 0 0 1px var(--rule-strong), var(--glow-ring);
}

.timeline input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--panel);
  box-shadow: 0 0 0 1px var(--rule-strong), var(--glow-ring);
}

.timeline input[type="range"]:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 4px; }

.timeline__scale {
  display: flex;
  justify-content: space-between;
  margin-top: 0.1rem;
  font-size: 0.6875rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* Everything downstream dims while a rewound view is being fetched, so it is
   obvious the numbers on screen are about to change. */
#content.is-rewinding .panel > :not(.panel__head, .timeline) { opacity: 0.55; transition: opacity 0.15s var(--ease); }
#content.is-rewinding { cursor: progress; }

.timeline.is-past { border-bottom-color: var(--accent); }
.timeline.is-past .timeline__head p { color: var(--accent-ink); }

/* A wide screen holds the panel on one line: where the page stands, the
   slider, the way back to live. The first column has a fixed width and the
   state a single line, so a longer date never moves the slider under the
   thumb. */
@media (min-width: 1000px) {
  .timeline.is-open:not([hidden]) {
    display: grid;
    grid-template-columns: 24rem minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 1.5rem;
  }
  .timeline__head { display: contents; }
  .timeline__head > div:first-child { flex-direction: column; align-items: flex-start; gap: 0.15rem; flex-wrap: nowrap; min-width: 0; }
  .timeline__head p { margin: 0; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .timeline__control { grid-column: 2; grid-row: 1; }
  .timeline__now { grid-column: 3; grid-row: 1; }
}

/* Team focus: Season Shape responsiveness */
@media (max-width: 480px) {
  .team-section .chart .crosshair { stroke-width: 1.5; }

  /* Beside a 2.5rem rating the club name had ~30px left and read "Vi…". The
     rating drops to its own line so the name gets the width. */

}

/* The narrowest phones, 360px and below: tighter than 480px everywhere, never
   looser (the 480px rules come first in each section, these last). */
@media (max-width: 360px) {
  .grid-wrap { padding: 0.5rem 0.25rem; }
  .cell { font-size: 0.5rem; letter-spacing: -0.05em; }
  .ladder__track--list { --scale-w: 38%; }
  .panel__head { padding: 0.75rem 0.875rem; }
  .hero { padding-inline: 0.75rem; }


  /* Ladder row height bump for touch */
  .ladder__track--list .ladder__team { height: 2.75rem; }
  .ladder__track--list .ladder__rank { font-size: 0.6875rem; }
  .ladder__track--list .ladder__name { font-size: 0.8125rem; }
  .ladder__track--list .ladder__rating { font-size: 0.75rem; }
  .ladder__track--list .ladder__team img { width: 1.125rem; height: 1.125rem; }

}
