.shell {
  width: min(100% - (var(--gutter) * 2), 46rem);
  margin-inline: auto;
}

/* ---- masthead ---- */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--space-5);
  border-bottom: 2px solid var(--rule-strong);
}

.masthead__brand { display: flex; align-items: center; gap: var(--space-3); }
.masthead__crest { width: 48px; height: 48px; flex: none; }
.masthead__name { font-size: var(--step-2); letter-spacing: 0.04em; }
.masthead__est {
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: 0.18em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ---- theme switch ----
   Where the knob sits and which icon is lit are worked out here from --is-dark,
   the same theme resolution tokens.css does, not set by script. So the switch
   is already right on the first paint -- the React original renders nothing
   until it has mounted, to dodge exactly that jump -- and it follows the OS on
   its own when no choice is stored. theme.js only flips the attribute.

   A pill and a round knob, although the crest is otherwise the only circle in
   the system: a switch is recognised by that shape. */
.theme-switch {
  --track-w: 5rem;
  --track-h: 2.25rem;
  --inset: 0.25rem;
  --knob: calc(var(--track-h) - 2px - var(--inset) * 2);
  --travel: calc(var(--track-w) - 2px - var(--knob) - var(--inset) * 2);

  display: inline-grid;
  place-items: center;
  /* The drawn track is 36px tall; the button around it is the 44px target. */
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
}

.theme-switch__track {
  position: relative;
  display: block;
  width: var(--track-w);
  height: var(--track-h);
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  transition: border-color var(--dur-1) ease;
}
.theme-switch:hover .theme-switch__track { border-color: var(--rule-strong); }

/* Surface-filled with a ring in the text colour, so it stands off the track in
   both themes without a drop shadow doing the work. */
.theme-switch__thumb {
  position: absolute;
  top: var(--inset);
  left: var(--inset);
  width: var(--knob);
  height: var(--knob);
  border: 1.5px solid var(--text);
  border-radius: 50%;
  background: var(--surface);
  translate: calc(var(--travel) * var(--is-dark)) 0;
  transition: translate var(--dur-2) var(--ease-out);
}

/* Drawn above the knob, so the lit icon rides on it. The original put the knob
   on top and hid the very icon it had just highlighted. */
.theme-switch__icon {
  position: absolute;
  z-index: 1;
  top: 50%;
  width: 1rem;
  height: 1rem;
  margin-top: -0.5rem;
  color: var(--text);
  transition: opacity var(--dur-2) ease, scale var(--dur-2) var(--ease-out);
}
/* Each centred on where the knob rests at its end of the track. Lit: full
   strength and a touch larger. Unlit: just over half strength. */
.theme-switch__icon--sun {
  left: calc(var(--inset) + var(--knob) / 2 - 0.5rem);
  opacity: calc(1 - var(--is-dark) * 0.45);
  scale: calc(1.1 - var(--is-dark) * 0.1);
}
.theme-switch__icon--moon {
  right: calc(var(--inset) + var(--knob) / 2 - 0.5rem);
  opacity: calc(0.55 + var(--is-dark) * 0.45);
  scale: calc(1 + var(--is-dark) * 0.1);
}

@media (prefers-reduced-motion: reduce) {
  .theme-switch__thumb,
  .theme-switch__icon { transition: none; }
}

/* ---- next match: the one focal point ---- */
.next {
  background: var(--text);
  color: var(--surface);
  padding: var(--space-6) var(--space-5) var(--space-7);
  margin-block: var(--space-6);
}
.next__label {
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.75;
}
.next__opponent {
  font-family: var(--font-display);
  font-size: var(--step-4);
  line-height: 0.95;
  text-transform: uppercase;
  margin-block: var(--space-3) var(--space-4);
}
.next__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  font-family: var(--font-display);
  font-size: var(--step-1);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.next .message { color: inherit; opacity: 0.8; }
.next .retry {
  display: block;
  margin-top: var(--space-3);
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
}

/* ---- sections ---- */
.panel { padding-block: var(--space-6); border-top: 1px solid var(--rule); }
.panel__title {
  font-size: var(--step--1);
  letter-spacing: 0.2em;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

/* ---- results ---- */
.results { list-style: none; padding: 0; }
.result {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  align-items: baseline;
  gap: var(--space-3);
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--rule);
}
.result__mark {
  font-family: var(--font-display);
  font-size: var(--step--1);
  line-height: 1.7;
  text-align: center;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  align-self: center;
}
/* Outcome reads from weight and fill, never colour alone. */
.result--won .result__mark { background: var(--text); color: var(--mark-on); }
.result--lost .result__mark { border-color: var(--rule); color: var(--text-muted); }
.result__opponent { font-size: var(--step-1); }
.result__score {
  font-family: var(--font-display);
  font-size: var(--step-2);
  letter-spacing: 0.02em;
}
.result__date { display: none; }

/* ---- record ---- */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.summary > div { background: var(--surface); padding: var(--space-4) var(--space-3); }
.summary dt {
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.summary dd {
  font-family: var(--font-display);
  font-size: var(--step-3);
  margin: 0;
}

/* ---- footer ---- */
.footer {
  border-top: 2px solid var(--rule-strong);
  padding-block: var(--space-6) var(--space-8);
  text-align: center;
}
.footer__motto {
  font-family: var(--font-display);
  font-size: var(--step-2);
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
/* The four-pointed star is lifted straight off the badge and the shirt front. */
.footer__note { color: var(--text-muted); font-size: var(--step--1); margin-top: var(--space-3); }

@media (min-width: 40rem) {
  :root { --gutter: 2rem; }
  .result { grid-template-columns: 7rem 2rem 1fr auto; }
  .result__date {
    display: block;
    font-family: var(--font-display);
    font-size: var(--step--1);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
  }
  .next { padding: var(--space-7) var(--space-7) var(--space-8); }
}

.footer__crest { width: 140px; height: 140px; margin: 0 auto var(--space-4); }

.next__ground {
  font-family: var(--font-display);
  font-size: var(--step-0);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-top: var(--space-2);
}

/* Undated early games show a game number in the same column as a date would. */
.result__date--game { color: var(--text-muted); }

.results__year {
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: 0.22em;
  color: var(--text-muted);
  padding-block: var(--space-5) var(--space-2);
  border-bottom: 1px solid var(--rule);
}
.results__year:first-child { padding-top: 0; }
