/* ============================================================
   Fitba Briefing
   1. Tokens   2. Base   3. Chrome   4. Briefing   5. Panels
   6. Footer   7. States 8. Ceefax theme
   ============================================================ */

/* ---------- 1. Tokens ---------- */

:root {
  --ink: #16202a;
  --ink-soft: #5a6672;
  --ink-faint: #8d97a1;
  --paper: #f8f8f6;
  --paper-raised: #ffffff;
  --hair: #e2e2de;
  --hair-strong: #cbcbc4;
  --green: #10243a;
  --green-soft: #0f5da8;
  --accent: #c9a227;
  --accent-soft: #d9c295;
  --accent-wash: #f5efe1;
  --link: #0f5da8;
  --urgent: #9c3a2a;
  --win: #2f7d55;
  --draw: #9a9384;
  --loss: #b4574a;
  --btn-ink: #10243a;
  --btn-on-ink: #f8f8f6;
  color-scheme: light dark;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;

  --saltire: #0065bd;

  /* Club accent. app.js sets --club-colour, --club-accent, --club-on and the
     two --club-text-* values on :root when the reader filters to a club, and
     removes them for "All clubs". Everything below is expressed through these,
     so the default state is byte-for-byte the site palette and a selection
     re-tints the page without a second set of rules. */
  --club-primary:   var(--club-colour, var(--green));
  --tartan-ground:  var(--club-colour, var(--green));
  --club-secondary: var(--club-accent, var(--accent));
  --club-ink:       var(--club-on,     var(--btn-on-ink));
  /* The sett's constant Scottish thread. It is deliberately not the club's ink:
     a white thread reads as a gap against the paper, which turns the woven rule
     into a dashed line and looks like a rendering fault. */
  --club-thread:    var(--saltire);
  /* Safe as text on the page ground, which the raw strip colour is not: an
     amber or tangerine club would vanish. app.js tones it per scheme. */
  --club-text:      var(--club-text-light, var(--accent));

  /* A continuous sett — no gaps. With gaps it reads as a dashed line, which
     looks like a rendering fault rather than a woven rule. */
  --tartan: repeating-linear-gradient(90deg,
    var(--tartan-ground)    0px, var(--tartan-ground)   10px,
    var(--club-thread)     10px, var(--club-thread)     13px,
    var(--tartan-ground)   13px, var(--tartan-ground)   20px,
    var(--club-secondary)  20px, var(--club-secondary)  22px,
    var(--tartan-ground)   22px, var(--tartan-ground)   32px);

  --scale: 1;
  --measure: 620px;
}

:root[data-textsize="large"]  { --scale: 1.12; }
:root[data-textsize="xlarge"] { --scale: 1.26; }

/* Dark palette, tuned rather than inverted: a warmer ground, brighter gold so
   it doesn't go muddy, and hairlines lifted enough to still read as rules.
   Applied two ways — by system preference unless the reader has explicitly
   chosen light, and by explicit choice regardless of the system. The two blocks
   must be kept identical; a media-conditional selector can't be merged with a
   plain one. */
@media (prefers-color-scheme: dark) {
  :root:not([data-colour="light"]) {
    --ink: #e9eef4;
    --ink-soft: #a3b3c4;
    --ink-faint: #718396;
    --paper: #0a1018;
    --paper-raised: #111b26;
    --hair: #1f2d3b;
    --hair-strong: #32485e;
    --green: #132a3d;
    --green-soft: #4d92cf;
    --accent: #e0bd7a;
    --accent-soft: #8a7444;
    --accent-wash: #14202c;
    --link: #86bce8;
    --urgent: #e0866f;
    --win: #5cc48b;
    --draw: #8b8878;
    --loss: #d9796a;
    --btn-ink: #e0bd7a;
    --btn-on-ink: #e9eef4;
    --club-text: var(--club-text-dark, var(--accent));
    --tartan-ground: var(--club-colour, #24455f);
  }
}

:root[data-colour="dark"] {
  --ink: #e9eef4;
  --ink-soft: #a3b3c4;
  --ink-faint: #718396;
  --paper: #0a1018;
  --paper-raised: #111b26;
  --hair: #1f2d3b;
  --hair-strong: #32485e;
  --green: #132a3d;
  --green-soft: #4d92cf;
  --accent: #e0bd7a;
  --accent-soft: #8a7444;
  --accent-wash: #14202c;
  --link: #86bce8;
  --urgent: #e0866f;
  --win: #5cc48b;
  --draw: #8b8878;
  --loss: #d9796a;
  --btn-ink: #e0bd7a;
  --btn-on-ink: #e9eef4;
  --club-text: var(--club-text-dark, var(--accent));
  --tartan-ground: var(--club-colour, #24455f);
}

/* ---------- 2. Base ---------- */

* { box-sizing: border-box; }

/* Author `display` rules beat the UA stylesheet's [hidden] rule, so state it
   explicitly — otherwise anything flex/grid ignores its hidden attribute. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 3. Chrome ---------- */

.topbar::after {
  content: "";
  display: block;
  height: 3px;
  background: var(--tartan);
  background-size: 32px 3px;
}

.topbar {
  background: var(--paper);
  border-bottom: 0;
  box-shadow: inset 0 -3px 0 0 transparent;
  padding-top: env(safe-area-inset-top);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-text { min-width: 0; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; display: block; flex: none; overflow: hidden; }

.brand-text h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.16rem;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.15;
}

.tagline {
  margin: 2px 0 0;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 999px;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 6px 11px;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 1px;
  font-family: var(--font-display);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.icon-btn .aa-small { font-size: 0.72rem; font-weight: 600; }
.icon-btn .aa-large { font-size: 1rem; font-weight: 600; }
.icon-btn:hover { border-color: var(--hair-strong); }
.icon-btn:active { background: var(--hair); }

.notify-btn {
  flex: none;
  background: transparent;
  color: var(--btn-ink);
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}


.notify-btn:hover { border-color: var(--hair-strong); }
.notify-btn:active { background: var(--hair); }

.notify-btn[data-state="on"] {
  background: var(--green);
  color: var(--btn-on-ink);
  border-color: var(--green);
}


/* Display settings popover */

.display-panel {
  position: absolute;
  right: max(20px, calc(50% - var(--measure) / 2 + 20px));
  top: calc(100% - 6px);
  z-index: 14;
  min-width: 268px;
  background: var(--paper-raised);
  border: 1px solid var(--hair-strong);
  border-radius: 8px;
  padding: 6px 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
  animation: rise 0.16s ease both;
}

.display-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--hair);
}

.display-row:last-child { border-bottom: none; }

.display-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--hair);
  border-radius: 999px;
  overflow: hidden;
  flex: none;
}

.segmented button {
  background: transparent;
  border: 0;
  padding: 8px 13px;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  line-height: 1.4;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.segmented button + button { border-left: 1px solid var(--hair); }
.segmented button:hover { color: var(--ink); }

.segmented button.is-active {
  background: var(--green);
  color: var(--btn-on-ink);
}

.segmented--sizes button { font-family: var(--font-display); padding: 4px 13px; }
.segmented--sizes .size-sm { font-size: 0.68rem; }
.segmented--sizes .size-md { font-size: 0.84rem; }
.segmented--sizes .size-lg { font-size: 1rem; }

.switch {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  flex: none;
}

.switch-track {
  display: block;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--hair-strong);
  background: var(--paper);
  position: relative;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink-faint);
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.switch.is-on .switch-track { background: var(--green); border-color: var(--green); }
.switch.is-on .switch-thumb { transform: translateX(18px); background: var(--btn-on-ink); }

/* ---------- 4. Briefing ---------- */

.content {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 8px 20px;
}

.error { text-align: center; color: var(--ink-soft); padding: 60px 10px; font-size: calc(0.9rem * var(--scale)); }

.top-story {
  padding: 30px 0 24px;
  border-bottom: 1px solid var(--hair);
  animation: rise 0.4s ease both;
}

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.top-story-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--club-text);
  margin: 0 0 12px;
}

.top-story-text {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 480;
  font-size: calc(1.5rem * var(--scale));
  line-height: 1.32;
  letter-spacing: -0.01em;
}

.top-story-actions { display: flex; gap: 8px; margin-top: 18px; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 6px 15px;
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ghost-btn:hover { border-color: var(--hair-strong); }
.ghost-btn:active { background: var(--hair); }

.date-line {
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.76rem;
  margin: 16px 0 24px;
}

.countdown {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--hair);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 12px 16px;
  margin-bottom: 28px;
  background: var(--paper-raised);
}

.countdown--urgent { border-left-color: var(--urgent); }
.countdown-label { font-size: calc(0.8rem * var(--scale)); font-weight: 600; }

.countdown-value {
  font-size: calc(0.78rem * var(--scale));
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.countdown--urgent .countdown-value { color: var(--urgent); }

/* Sections */

.section { margin-bottom: 34px; }

.section-title, .panel-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 0;
  color: var(--ink);
  position: relative;
}

/* A tartan sett rather than a plain rule — Scottish without the shortbread tin.
   Two threads high, so it reads as texture at arm's length, not decoration. */
.section-title::after, .panel-title::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--tartan);
  background-size: 32px 2px;
  opacity: 0.5;
}

.section-title::before, .panel-title::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: var(--club-text);
  transform: rotate(45deg);
  flex: none;
}

.section-note {
  margin: -8px 0 14px;
  font-size: calc(0.75rem * var(--scale));
  color: var(--ink-soft);
  font-style: italic;
}

.item-list { list-style: none; margin: 0; padding: 0; }

.item { padding: 16px 0; border-bottom: 1px solid var(--hair); }
.item:last-child { border-bottom: none; }

.item-heading {
  margin: 0 0 5px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: calc(1.02rem * var(--scale));
  line-height: 1.35;
  letter-spacing: -0.005em;
}

.item-text {
  margin: 0;
  font-size: calc(0.945rem * var(--scale));
  line-height: 1.55;
  color: var(--ink-soft);
}

/* A lead story is given room and a display face; a brief is compressed;
   a quiet item is a note, not a story. */
.item--lead { padding: 22px 0; }

.item--lead .item-heading {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: calc(1.32rem * var(--scale));
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin-bottom: 7px;
}

.item--lead .item-text { font-size: calc(1rem * var(--scale)); color: var(--ink); }

.item--brief { padding: 11px 0; }
.item--brief .item-heading { font-size: calc(0.92rem * var(--scale)); margin-bottom: 3px; }
.item--brief .item-text { font-size: calc(0.875rem * var(--scale)); }

.item--quiet { padding: 10px 0; }

.item--quiet .item-text {
  font-size: calc(0.83rem * var(--scale));
  color: var(--ink-faint);
  font-style: italic;
}

.item--quiet .item-foot { display: none; }

.item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
}

.item-source { margin: 0; font-size: 0.71rem; text-transform: uppercase; letter-spacing: 0.06em; }

.item-source a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid var(--hair);
  padding-bottom: 1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.item-source a:hover, .item-source a:active { color: var(--link); border-color: var(--link); }

.react-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  flex: none;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.react-btn svg { width: 11px; height: 11px; fill: currentColor; display: block; }
.react-btn:hover { border-color: var(--hair-strong); }
.react-btn:active { background: var(--hair); }
.react-btn.is-reacted { color: var(--accent); border-color: var(--accent-soft); }

/* ---------- 5. Panels ---------- */

/* Same rules-and-whitespace language as the briefing, no boxes. */
.extras { padding-bottom: 8px; }
.panel { margin-bottom: 30px; }
.panel-foot { margin: 12px 0 0; font-size: 0.68rem; color: var(--ink-faint); }

.fixture-list, .injury-list, .archive-list { list-style: none; margin: 0; padding: 0; }

.fixture { padding: 10px 0; border-bottom: 1px solid var(--hair); }
.fixture:last-child { border-bottom: none; }
.fixture:first-child { padding-top: 0; }

.fixture-main { display: flex; align-items: baseline; gap: 8px; }
.fixture-opponent { font-size: calc(0.92rem * var(--scale)); font-weight: 700; }

.fixture-venue, .injury-status {
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  border: 1px solid var(--hair);
  border-radius: 3px;
  padding: 1px 5px;
}

.fixture-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 3px;
  font-size: calc(0.75rem * var(--scale));
  color: var(--ink-soft);
}

.injury { padding: 10px 0; border-bottom: 1px solid var(--hair); }
.injury:last-child { border-bottom: none; }
.injury:first-child { padding-top: 0; }
.injury-head { display: flex; align-items: baseline; gap: 8px; }
.injury-player { font-size: calc(0.92rem * var(--scale)); font-weight: 700; }
.injury-status.status--out { color: var(--urgent); border-color: var(--urgent); }
.injury-status.status--doubt { color: var(--accent); border-color: var(--accent-soft); }

.injury-detail {
  margin: 3px 0 0;
  font-size: calc(0.78rem * var(--scale));
  color: var(--ink-soft);
  line-height: 1.5;
}

/* League table */

.table-wrap { overflow-x: auto; }

.league-table {
  width: 100%;
  border-collapse: collapse;
  font-size: calc(0.82rem * var(--scale));
}

.league-table th {
  text-align: right;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--hair);
  white-space: nowrap;
}

.league-table th.col-pos, .league-table th.col-team, .league-table th.col-form { text-align: left; }
.league-table th + th, .league-table td + td { padding-left: 12px; }

.league-table td {
  padding: 7px 0;
  text-align: right;
  border-bottom: 1px solid var(--hair);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.league-table td:first-child {
  text-align: left;
  width: 28px;
  position: relative;
  padding-left: 8px;
}
.league-table td.col-team { text-align: left; width: 100%; padding-left: 8px; color: var(--ink); }
.league-table td.col-form { text-align: left; padding-left: 10px; }
.league-table td.col-pts { font-weight: 700; color: var(--ink); }
.league-table tr:last-child td { border-bottom: none; }
/* The row for whichever club the reader has filtered to, tinted in its own
   colours. Celtic and Rangers are in the table because a table missing two
   clubs is wrong, but they are never the subject here. */
.league-table tr.is-club td {
  color: var(--ink);
  font-weight: 700;
  background: var(--accent-wash);
  background: color-mix(in srgb, var(--club-primary) 10%, transparent);
}

/* Zone markers sit in the position column as a thin coloured rule. */
.league-table tr.zone-europe td:first-child::before,
.league-table tr.zone-playoff td:first-child::before,
.league-table tr.zone-drop td:first-child::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  bottom: 3px;
  width: 2px;
  border-radius: 1px;
}

.league-table tr.zone-europe td:first-child::before { background: var(--win); }
.league-table tr.zone-playoff td:first-child::before { background: var(--draw); }
.league-table tr.zone-drop td:first-child::before { background: var(--loss); }

.pip {
  display: inline-block;
  width: 13px;
  height: 13px;
  line-height: 13px;
  margin-right: 2px;
  border-radius: 2px;
  font-size: 0.55rem;
  font-weight: 700;
  text-align: center;
  color: var(--paper);
  vertical-align: middle;
}

.pip--w { background: var(--win); }
.pip--d { background: var(--draw); }
.pip--l { background: var(--loss); }

/* Archive */

.archive-list { display: flex; flex-wrap: wrap; gap: 8px; }

.archive-link {
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 8px 13px;
  font-family: var(--font-body);
  font-size: 0.73rem;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.archive-link:hover { border-color: var(--hair-strong); }
.archive-link:active { background: var(--hair); }

/* ---------- 6. Footer ---------- */

.footer {
  max-width: var(--measure);
  margin: 8px auto 40px;
  padding: 22px 20px 0;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.7rem;
  line-height: 1.7;
  border-top: 1px solid var(--hair);
}

.stats-line { font-weight: 600; color: var(--ink-soft); margin: 0 0 6px; }
.footer p { margin: 0 0 4px; }
.footer-actions { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--ink-faint);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.link-btn:hover { color: var(--ink-soft); }
.footer a { color: var(--ink-faint); text-underline-offset: 2px; }
.dot { opacity: 0.5; }

/* ---------- 7. States ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.8rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
  z-index: 20;
  max-width: calc(100vw - 40px);
  text-align: center;
  animation: rise 0.2s ease both;
}

.skeleton { padding: 30px 0; }

.sk {
  background: var(--hair);
  border-radius: 3px;
  animation: shimmer 1.4s ease-in-out infinite;
}

.sk-eyebrow  { width: 34%; height: 9px;  margin-bottom: 18px; }
.sk-headline { width: 100%; height: 24px; margin-bottom: 10px; }
.sk-headline--short { width: 62%; margin-bottom: 26px; }
.sk-rule     { width: 100%; height: 1px; margin-bottom: 26px; animation: none; }
.sk-line     { width: 100%; height: 12px; margin-bottom: 10px; }
.sk-line--short { width: 45%; }

@keyframes shimmer { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ---------- 8. Ceefax theme ---------- */

:root[data-theme="ceefax"] {
  --ink: #ffffff;
  --ink-soft: #ffffff;
  --ink-faint: #00ff00;
  --paper: #000000;
  --paper-raised: #000000;
  --hair: #0000cc;
  --hair-strong: #0000ff;
  --green: #0000aa;
  --green-soft: #00ffff;
  --accent: #ffff00;
  --accent-soft: #00ffff;
  --accent-wash: #000000;
  --link: #00ffff;
  --urgent: #ff0000;
  --win: #00ff00;
  --draw: #ffff00;
  --loss: #ff0000;
  --btn-ink: #00ffff;
  --btn-on-ink: #000000;
  --club-primary: #0000aa;
  --club-secondary: #ffff00;
  --club-ink: #ffffff;
  --club-thread: #00ffff;
  --club-text: #00ffff;
  --font-display: var(--font-mono);
  --font-body: var(--font-mono);
  --measure: 46rem;
  background: #000;
}

:root[data-theme="ceefax"] body {
  background: #000;
  letter-spacing: 0.02em;
}

/* Teletext header row */

.teletext-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 10px 16px 6px;
  font-family: var(--font-mono);
  font-size: clamp(0.7rem, 3.1vw, 0.95rem);
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.tt-page { color: #fff; }
.tt-service { color: #000; background: #00ff00; padding: 1px 8px; }
.tt-clock { color: #00ffff; }

/* Everything square, blocky and high-contrast */

:root[data-theme="ceefax"] .topbar {
  background: #000;
  border-bottom: 0;
  position: static;
}

:root[data-theme="ceefax"] .brand-mark { display: none; }

:root[data-theme="ceefax"] .brand-text h1 {
  font-family: var(--font-mono);
  font-weight: 700;
  text-transform: uppercase;
  color: #ffff00;
  font-size: clamp(1.1rem, 5.6vw, 1.9rem);
  letter-spacing: 0.04em;
}

:root[data-theme="ceefax"] .tagline { color: #00ffff; text-transform: uppercase; }

:root[data-theme="ceefax"] .icon-btn,
:root[data-theme="ceefax"] .notify-btn,
:root[data-theme="ceefax"] .ghost-btn,
:root[data-theme="ceefax"] .archive-link,
:root[data-theme="ceefax"] .react-btn {
  border-radius: 0;
  border-color: #00ffff;
  color: #00ffff;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

:root[data-theme="ceefax"] .notify-btn[data-state="on"] {
  background: #00ff00;
  color: #000;
  border-color: #00ff00;
}

:root[data-theme="ceefax"] .react-btn.is-reacted { color: #ffff00; border-color: #ffff00; }

:root[data-theme="ceefax"] .top-story { border-bottom: 0; padding-bottom: 8px; }
:root[data-theme="ceefax"] .top-story-label { color: #00ffff; }

:root[data-theme="ceefax"] .top-story-text {
  color: #ffff00;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: calc(1.15rem * var(--scale));
  line-height: 1.45;
  letter-spacing: 0;
}

:root[data-theme="ceefax"] .date-line { color: #00ffff; text-transform: uppercase; }

/* Section headings become full-width teletext bars */

:root[data-theme="ceefax"] .section-title,
:root[data-theme="ceefax"] .panel-title {
  background: #0000aa;
  color: #ffff00;
  border-bottom: 0;
  padding: 5px 10px;
  margin-bottom: 12px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
}

:root[data-theme="ceefax"] .section-title::before,
:root[data-theme="ceefax"] .panel-title::before { display: none; }

:root[data-theme="ceefax"] .item { border-bottom: 0; padding: 8px 0; }
:root[data-theme="ceefax"] .item-heading { color: #00ffff; font-family: var(--font-mono); letter-spacing: 0; }
:root[data-theme="ceefax"] .item--lead .item-heading { font-size: calc(1.05rem * var(--scale)); }
:root[data-theme="ceefax"] .item-text { color: #fff; }
:root[data-theme="ceefax"] .item--quiet .item-text { color: #00ff00; font-style: normal; }
:root[data-theme="ceefax"] .item-source a { color: #00ff00; border-bottom: 0; }
:root[data-theme="ceefax"] .section-note { color: #00ff00; font-style: normal; }

:root[data-theme="ceefax"] .countdown {
  border: 0;
  border-radius: 0;
  background: #aa0000;
  color: #fff;
  padding: 6px 10px;
}

:root[data-theme="ceefax"] .countdown-label { color: #fff; }
:root[data-theme="ceefax"] .countdown-value { color: #ffff00; }

:root[data-theme="ceefax"] .fixture-venue,
:root[data-theme="ceefax"] .injury-status {
  border-radius: 0;
  border-color: #00ffff;
  color: #00ffff;
}

:root[data-theme="ceefax"] .fixture,
:root[data-theme="ceefax"] .injury { border-bottom: 0; padding: 5px 0; }

:root[data-theme="ceefax"] .fixture-opponent,
:root[data-theme="ceefax"] .injury-player { color: #ffff00; }

:root[data-theme="ceefax"] .fixture-meta,
:root[data-theme="ceefax"] .injury-detail { color: #fff; }

:root[data-theme="ceefax"] .league-table td,
:root[data-theme="ceefax"] .league-table th {
  border-bottom: 0;
  color: #fff;
  font-family: var(--font-mono);
}

:root[data-theme="ceefax"] .league-table th { color: #00ffff; }
:root[data-theme="ceefax"] .league-table tr.is-club td { color: #ffff00; background: none; }
:root[data-theme="ceefax"] .league-table td.col-pts { color: #00ff00; }

:root[data-theme="ceefax"] .pip { border-radius: 0; color: #000; }

:root[data-theme="ceefax"] .footer,
:root[data-theme="ceefax"] .panel-foot,
:root[data-theme="ceefax"] .stats-line { border-top-color: #0000cc; color: #00ff00; }

:root[data-theme="ceefax"] .link-btn,
:root[data-theme="ceefax"] .footer a { color: #00ffff; }

:root[data-theme="ceefax"] .toast {
  border-radius: 0;
  background: #ffff00;
  color: #000;
  font-family: var(--font-mono);
  font-weight: 700;
}

/* Fastext shortcut bar */

/* Pinned to the bottom of the viewport, the way the real thing was. */
.fastext {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 12;
}

:root[data-theme="ceefax"] body { padding-bottom: 54px; }

.ft {
  border: 0;
  padding: 10px 4px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #000;
  cursor: pointer;
}

.ft-red { background: #ff0000; color: #fff; }
.ft-green { background: #00ff00; }
.ft-yellow { background: #ffff00; }
.ft-cyan { background: #00ffff; }

/* Shown when the newest edition is more than about a day and a half old — a
   failed run should say so rather than quietly passing yesterday off as today. */
.stale-note {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 10px 20px;
  font-size: calc(0.78rem * var(--scale));
  color: var(--ink-soft, #6b6b6b);
  border-left: 3px solid var(--accent);
  background: rgba(0,0,0,0.03);
}
:root[data-theme="ceefax"] .stale-note {
  border-left: 0; background: #0000cc; color: #fff; border-radius: 0;
}

.copyright {
  font-size: calc(0.72rem * var(--scale));
  color: var(--ink-soft, #7a7a7a);
  max-width: 46ch;
}
:root[data-theme="ceefax"] .copyright { color: #00ffff; }

/* Club filter — one briefing, ten audiences. Horizontally scrollable on a
   phone rather than wrapping to three rows. */
.club-filter {
  display: flex; gap: 7px;
  max-width: var(--measure);
  margin: 0 auto; padding: 12px 20px 4px;
  overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.club-filter::-webkit-scrollbar { display: none; }
.club-chip {
  flex: none;
  font: inherit;
  font-size: calc(0.78rem * var(--scale));
  padding: 8px 13px;
  border: 1px solid var(--hair-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.club-chip:hover { border-color: var(--ink-faint); color: var(--ink); }
.club-chip[aria-pressed="true"] {
  background: var(--club-primary); border-color: var(--club-primary); color: var(--club-ink);
}
:root[data-theme="ceefax"] .club-filter { display: none; }

/* Weekly poll. Before voting the options are buttons; afterwards they become
   rows with a share bar, so the layout does not jump between the two states. */
.poll-question {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: calc(1rem * var(--scale));
  line-height: 1.35;
  color: var(--ink);
}

.poll-options { display: flex; flex-direction: column; gap: 6px; }

.poll-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  font: inherit;
  font-size: calc(0.82rem * var(--scale));
  text-align: left;
  padding: 8px 11px;
  border: 1px solid var(--hair);
  border-radius: 4px;
  background: var(--paper-raised);
  color: var(--ink);
  overflow: hidden;
}

button.poll-option { cursor: pointer; }
button.poll-option:hover { border-color: var(--club-primary); }
.poll-option.is-chosen { border-color: var(--club-primary); font-weight: 600; }

.poll-option-label, .poll-option-share { position: relative; z-index: 1; }
.poll-option-share { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.poll-option.is-chosen .poll-option-share { color: var(--club-text); }

/* The bar sits behind the text, so a long option label is never truncated by
   the share of the vote it happens to have. */
.poll-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  z-index: 0;
  background: var(--accent-wash);
  background: color-mix(in srgb, var(--club-primary) 14%, transparent);
  transition: width 0.35s ease;
}

@media (prefers-reduced-motion: reduce) { .poll-bar { transition: none; } }

:root[data-theme="ceefax"] .poll-option {
  border: 1px solid #0000ff;
  border-radius: 0;
  background: #000;
}
:root[data-theme="ceefax"] .poll-option.is-chosen { border-color: #ffff00; color: #ffff00; }
:root[data-theme="ceefax"] .poll-bar { background: #0000aa; }

/* Which division's table is on show. Follows the selected club by default; the
   reader can look at the other one without dropping their filter. */
.table-tabs {
  display: flex;
  gap: 6px;
  margin: -6px 0 12px;
}
.table-tab {
  font: inherit;
  font-size: calc(0.72rem * var(--scale));
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border: 1px solid var(--hair-strong);
  border-radius: 3px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.table-tab:hover { color: var(--ink); border-color: var(--ink-faint); }
.table-tab[aria-selected="true"] {
  background: var(--club-primary);
  border-color: var(--club-primary);
  color: var(--club-ink);
}

/* Divider label between Premiership and Championship chips. */
.club-group {
  flex: none;
  align-self: center;
  font-size: calc(0.64rem * var(--scale));
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  padding: 0 4px 0 8px;
  white-space: nowrap;
}

/* Shown when a club filter matches nothing in today's edition. */
.empty-filter {
  margin: 28px 0 14px;
  font-family: var(--font-display);
  font-size: calc(1.05rem * var(--scale));
  color: var(--ink-soft);
}

/* Stands in for the notify button on iOS, where Web Push exists only once the
   site has been added to the Home Screen. */
.install-hint {
  max-width: var(--measure);
  margin: 0 auto;
  /* Matches .topbar-inner's horizontal padding so it lines up with the brand. */
  padding: 0 20px 12px;
  font-size: calc(0.75rem * var(--scale));
  line-height: 1.45;
  color: var(--ink-soft);
}
.install-hint strong { color: var(--ink); font-weight: 600; }

/* Footer "last updated". The relative form carries the meaning, so the exact
   timestamp beside it recedes. */
#status-line {
  margin-top: 14px;
  font-size: calc(0.72rem * var(--scale));
  color: var(--ink-faint);
}
#status-line time { font-weight: 600; color: var(--ink-soft); }
.status-exact { opacity: 0.75; }
