/* Retro styles: Ceefax/teletext screens, Sensible Soccer pitch, pixel-art buttons, arcade pop-ups.
   Body text stays in an easy-to-read font; pixel fonts are only for short labels and big moments. */

:root {
  /* Teletext's 8 colours (softened slightly so they're easier on the eyes) */
  --black: #000000;
  --red: #ff4b3e;
  --green: #3cff4f;
  --yellow: #ffe93d;
  --blue: #2f45ff;
  --magenta: #ff4bf0;
  --cyan: #3deeff;
  --white: #ffffff;
  --grey: #b8b8c8;      /* for less important text */
  --dim: #3a3a4a;       /* borders and empty things */
  /* Sensible Soccer pitch */
  --grass-a: #2f9e3a;
  --grass-b: #278a31;
  --body-font: "Atkinson Hyperlegible", Verdana, system-ui, sans-serif;
  --teletext-font: "VT323", "IBM Plex Mono", Menlo, monospace;
  --arcade-font: "Press Start 2P", var(--teletext-font);
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--black);
  color: var(--white);
  font-family: var(--body-font);
  font-size: 18px;
  line-height: 1.5;
}

/* Very faint TV scan lines over everything */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  z-index: 10;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}

/* ---------- Ceefax header ---------- */
.ceefax-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--teletext-font);
  font-size: 1.25rem;
  line-height: 1.2;
  color: var(--white);
}
.ceefax-top .page { color: var(--white); }
.ceefax-top .service { color: var(--yellow); }
#clock { color: var(--yellow); white-space: nowrap; }
#matchday { display: none; } /* only shown in the manager look */

/* Big title band, like a teletext double-height banner with mosaic blocks */
.titlebar {
  margin: 6px 0 12px;
  background: var(--blue);
  padding: 10px 12px;
  position: relative;
}
.titlebar h1 {
  margin: 0;
  font-family: var(--arcade-font);
  font-size: clamp(1.3rem, 6vw, 1.8rem);
  line-height: 1.5;
  color: var(--yellow);
  letter-spacing: 2px;
  text-shadow: 3px 3px 0 var(--black);
}
/* Mosaic stripe under the title */
.titlebar::after {
  content: "";
  display: block;
  height: 8px;
  margin: 8px -12px -10px;
  background: repeating-linear-gradient(90deg,
    var(--red) 0 16px, var(--yellow) 16px 32px, var(--green) 32px 48px,
    var(--cyan) 48px 64px, var(--magenta) 64px 80px);
}
.tag { font-family: var(--teletext-font); font-size: 1.1rem; color: var(--cyan); }

/* Puzzle menu (prototype) */
.puzzle-pick {
  display: flex; /* Today button on the left, past-puzzle menu on the right */
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  font-family: var(--teletext-font);
  font-size: 1.2rem;
  color: var(--cyan);
}
#today-puzzle { font-family: var(--teletext-font); font-size: 1.2rem; font-weight: 400; padding: 4px 12px; color: var(--cyan); background: var(--black); border: 3px solid var(--cyan); box-shadow: none; }
#today-puzzle.active { color: var(--black); background: var(--cyan); }
.puzzle-pick select {
  flex: 1;
  font: inherit;
  padding: 4px 8px;
  background: var(--black);
  color: var(--white);
  border: 3px solid var(--cyan);
}

/* ---------- Panels: black boxes with a coloured teletext title bar ---------- */
.panel {
  background: var(--black);
  border: 3px solid var(--dim);
  margin-bottom: 14px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 10px;
  font-family: var(--teletext-font);
  font-size: 1.35rem;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 1px;
}
/* One teletext colour per panel */
.head-blue { background: var(--blue); color: var(--yellow); }
.head-green { background: var(--green); color: var(--black); }
.head-magenta { background: var(--magenta); color: var(--black); }
.head-cyan { background: var(--cyan); color: var(--black); }
.head-yellow { background: var(--yellow); color: var(--black); }

/* ---------- How to play (fold-out panel) ---------- */
.rules summary { cursor: pointer; list-style: none; }
.rules summary::-webkit-details-marker { display: none; }
.rules .toggle::after { content: "+ SHOW"; }
.rules[open] .toggle::after { content: "– HIDE"; }
.rules-list { margin: 0; padding: 8px 12px 10px; list-style: none; counter-reset: rule; font-size: 0.85rem; line-height: 1.5; }
/* Numbers in a fixed-width column, right-aligned, so "10." lines up with "9." */
.rules-list li { position: relative; margin-bottom: 4px; padding-left: 2.2em; counter-increment: rule; }
.rules-list li::before {
  content: counter(rule) ".";
  position: absolute;
  left: 0;
  width: 1.8em;
  text-align: right;
  color: var(--cyan);
  font-family: var(--teletext-font);
}
.rules-list b { color: var(--yellow); }
.stats b { color: var(--white); }

/* Pixel-art hearts (lives) */
#lives { display: inline-flex; gap: 4px; vertical-align: middle; margin-left: 6px; }
.heart { width: 21px; height: 18px; }
.heart.full rect { fill: var(--red); }
.heart.full .shine { fill: var(--white); }
.heart.empty rect { fill: var(--dim); }

/* Start / End rows */
.fixture {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  padding: 10px 12px;
  align-items: baseline;
}
.fixture .k { font-family: var(--teletext-font); font-size: 1.3rem; color: var(--cyan); }
.fixture .v { font-weight: 700; font-size: 1.2rem; color: var(--white); }
.fixture .banned { color: var(--red); }
.fixture .v.banned { text-decoration: line-through; }

/* ---------- Sensible Soccer pitch ---------- */
.pitch-panel { padding: 6px; }
#pitch { display: block; width: 100%; height: auto; image-rendering: pixelated; }
#pitch .stripe-a { fill: var(--grass-a); }
#pitch .stripe-b { fill: var(--grass-b); }
#pitch .markings { fill: none; stroke: var(--white); stroke-width: 1; }
#pitch .net { fill: var(--white); }
#pitch .pass { stroke: var(--yellow); stroke-width: 1; stroke-dasharray: 2 2; }
#pitch .label {
  fill: var(--white);
  font-family: var(--teletext-font);
  font-size: 10px;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--black);
  stroke-width: 2.5px;
}
#pitch .label.faint { fill: var(--yellow); }
/* Pixel footballers (colours set per sprite part) */
#pitch .skin { fill: #f1c27d; }
#pitch .hair { fill: #3b2414; }
#pitch .shirt { fill: var(--red); }
#pitch .shorts { fill: var(--white); }
#pitch .boots { fill: var(--black); }
/* The end player waiting by goal: yellow kit, blinking until you reach them */
#pitch .target .shirt { fill: var(--yellow); }
#pitch .target { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { opacity: 0.35; } }
#ball {
  fill: var(--white);
  stroke: var(--black);
  stroke-width: 0.6;
  transition: transform 0.6s cubic-bezier(0.3, 0.7, 0.3, 1);
}

/* Commentary under the pitch, in teletext yellow */
#commentary {
  margin: 6px 4px 0;
  min-height: 1.3em;
  font-family: var(--teletext-font);
  font-size: 1.45rem;
  line-height: 1.2;
  color: var(--yellow);
}

/* ---------- Pixel-art buttons ---------- */
button {
  font: inherit;
  font-weight: 700;
  padding: 10px 14px;
  border: 3px solid var(--black);
  background: var(--dim);
  color: var(--white);
  cursor: pointer;
  /* stepped bevel: light top-left, dark bottom-right */
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.25), inset -3px -3px 0 rgba(0, 0, 0, 0.45);
}
button:hover { filter: brightness(1.15); }
button:active {
  transform: translate(2px, 2px);
  box-shadow: inset -3px -3px 0 rgba(255, 255, 255, 0.2), inset 3px 3px 0 rgba(0, 0, 0, 0.45);
}
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* ---------- Fastext bar: the coloured buttons from Ceefax remotes ---------- */
.fastext {
  display: flex; /* buttons share the width equally; hidden ones take no space */
  gap: 6px;
  margin-bottom: 14px;
}
.fastext button {
  flex: 1;
  font-family: var(--teletext-font);
  font-size: 1.35rem;
  font-weight: 400;
  padding: 6px 4px;
  background: var(--black);
  border: 3px solid currentColor;
  box-shadow: none;
}
.fastext:has(+ .milner-row) { margin-bottom: 6px; } /* keep the Milner switch close to the modes */
.fastext .red { color: var(--red); }
.fastext .green { color: var(--green); }
.fastext .yellow { color: var(--yellow); }
/* Chosen mode: filled block in its colour */
.fastext button.active { background: currentColor; }
.fastext button.active span { color: var(--black); }

/* ---------- Chain list ---------- */
#chain { list-style: none; padding: 0; margin: 0; counter-reset: step; }
#chain li {
  counter-increment: step;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  align-items: baseline;
  padding: 6px 12px;
  border-bottom: 2px dotted var(--dim);
  font-weight: 700;
  animation: slide-in 0.35s steps(4);
}
#chain li:last-child { border-bottom: 0; }
#chain li::before {
  content: counter(step);
  font-family: var(--teletext-font);
  font-size: 1.3rem;
  color: var(--cyan);
  min-width: 1.2em;
}
/* Clues: each revealed club on its own short line, then the button for the next one */
.clues { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.clue.shown { display: block; }
/* Clue: small cyan teletext button; once clicked it becomes plain cyan text */
.clue {
  font-family: var(--teletext-font);
  font-size: 1rem;
  font-weight: 400;
  color: var(--cyan);
}
button.clue {
  padding: 0 6px;
  background: var(--black);
  border: 2px solid var(--cyan);
  box-shadow: none;
  vertical-align: middle;
}
.kit-picture { display: none; } /* pixel shirts on the chain: only in the sticker album look */
#chain .via { margin-left: auto; font-weight: 400; font-size: 0.85rem; color: var(--green); }

/* Steps(4) makes it move in chunky jumps, like old games */
@keyframes slide-in {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: none; }
}

#message { margin: 0 0 14px; color: var(--red); font-weight: 700; }
#message:empty { display: none; } /* no gap when there's no message, so panels stay evenly spaced */

/* ---------- Next pick ---------- */
#controls { display: flex; flex-direction: column; }
.option {
  text-align: left;
  border: 0;
  border-bottom: 2px dotted var(--dim);
  background: transparent;
  box-shadow: none;
}
.option:hover { background: var(--blue); filter: none; }
.option:disabled { color: var(--dim); text-decoration: line-through; cursor: default; background: transparent; } /* wrong guess */
/* Manager-game style ">" pointer on the row you're on */
.option::before { content: "  "; white-space: pre; font-family: var(--teletext-font); color: var(--yellow); }
.option:hover::before, .option:focus-visible::before { content: "> "; }
.back { margin: 8px; color: var(--grey); background: var(--black); border: 3px dashed var(--dim); box-shadow: none; }
.note { margin: 12px; color: var(--grey); }

/* Typing modes: name box */
.guess-box { padding: 12px; }
.guess-box label { display: block; margin-bottom: 6px; }
.guess-box input {
  box-sizing: border-box;
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  background: var(--black);
  color: var(--white);
  border: 3px solid var(--cyan);
  caret-color: var(--yellow);
}
#suggestions { list-style: none; margin: 4px 0 0; padding: 0; }
#suggestions li { padding: 8px 12px; cursor: pointer; border-bottom: 2px dotted var(--dim); }
#suggestions li::before { content: "  "; white-space: pre; font-family: var(--teletext-font); color: var(--yellow); }
#suggestions li:hover, #suggestions li.active { background: var(--blue); }
#suggestions li:hover::before, #suggestions li.active::before { content: "> "; }
#suggestions li.none { color: var(--grey); cursor: default; }
#suggestions li.none::before { content: ""; }
/* Clubs under each suggested name */
#suggestions .hint { display: block; padding-left: 2ch; font-size: 0.8rem; color: var(--green); }

/* Ko-fi and report links (footer and end screen) */
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; }
.kofi { font-weight: 700; }
.result .kofi { display: block; margin-top: 12px; text-align: center; }
.stats-line { margin: 0 0 10px; font-size: 0.85rem; color: var(--grey); }

/* Wikipedia credit */
.credit { margin-top: 20px; font-size: 0.8rem; color: var(--grey); }
.credit a { color: var(--cyan); }

/* ---------- Result ---------- */
.result { padding: 12px; }
.final-score { margin: 0; font-family: var(--arcade-font); font-size: 1rem; color: var(--yellow); line-height: 1.8; }
.verdict { margin: 4px 0 12px; font-size: 1.3rem; font-weight: 700; color: var(--green); }
.share-preview {
  background: var(--black);
  border: 3px solid var(--dim);
  padding: 12px;
  font-family: inherit;
  white-space: pre-wrap;
}
#share { width: 100%; background: var(--yellow); color: var(--black); }
/* WhatsApp · Text · Copy under the Share button */
.share-links { display: flex; justify-content: center; gap: 18px; margin: 10px 0 0; }
.share-links a, .link-button { font: inherit; font-weight: 700; color: var(--cyan); text-decoration: underline; }
.link-button { padding: 0; background: none; border: 0; box-shadow: none; cursor: pointer; }

/* ---------- Arcade pop-up ---------- */
.popup {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  font-family: var(--arcade-font);
  font-size: clamp(1.6rem, 9vw, 3rem);
  padding: 20px 28px;
  border: 6px solid currentColor;
  background: var(--black);
  box-shadow: 8px 8px 0 var(--blue);
  pointer-events: none;
  white-space: nowrap;
  z-index: 20;
  animation: pop 1.6s steps(12) forwards;
}
.popup.good { color: var(--yellow); }
.popup.bad { color: var(--red); font-size: clamp(1.2rem, 6vw, 2rem); }

@keyframes pop {
  0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  15%  { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  25%  { transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* Hidden text for screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* Less motion if the device asks for it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .popup { opacity: 1; }
}

/* Seasons note in the footer: big, bold, on its own line, so people know the live season isn't in */
.seasons-note { display: block; margin: 10px 0; font-size: 1.05rem; font-weight: 700; color: var(--yellow); }

/* Buttons at the bottom (Ko-fi, report/suggest): pixel-art picture + words, chunky bevel like the other pixel buttons */
.footer-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin: 18px 0 8px; }
.kofi-button, .report-button {
  display: flex; align-items: center; gap: 12px; width: fit-content;
  padding: 10px 16px; text-decoration: none; color: var(--black); background: var(--yellow);
  border: 3px solid var(--black); box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.3), inset 3px 3px 0 rgba(255, 255, 255, 0.5);
}
.kofi-cup { width: 36px; height: 33px; image-rendering: pixelated; flex: none; }
.kofi-cup .cup { fill: var(--white); }
.kofi-cup .coffee { fill: #6b3d1f; }
.kofi-cup .saucer { fill: var(--black); }
.kofi-cup .steam { fill: var(--black); opacity: 0.6; }
.report-button[hidden] { display: none; } /* display: flex above would otherwise show it before it is set up */
.report-icon { width: 36px; height: 27px; image-rendering: pixelated; flex: none; }
.report-icon .paper { fill: var(--white); }
.report-icon .fold { fill: var(--black); }
.kofi-words { display: flex; flex-direction: column; line-height: 1.25; }
.kofi-words b { font-size: 1rem; }
.kofi-words small { font-size: 0.8rem; }

/* Ko-fi pop-up: dark background, a box with a title bar and Ko-fi's donation form inside */
#kofi-panel { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(0, 0, 0, 0.7); }
.kofi-box { width: 100%; max-width: 420px; max-height: 100%; display: flex; flex-direction: column;
  background: var(--black); border: 3px solid var(--yellow); }
.kofi-box-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px;
  background: var(--yellow); color: var(--black); font-weight: 700; }
#kofi-panel[hidden] { display: none; } /* the display: flex above would otherwise keep it on screen */
#kofi-close { border: 0; background: none; color: inherit; font-size: 1.3rem; cursor: pointer; padding: 2px 6px; }
#kofi-frame { width: 100%; height: 640px; max-height: calc(100vh - 100px); border: 0; background: #f9f9f9; }
