/* Fraunces (SIL OFL, fonts/OFL.txt), self-hosted so no visitor request goes to a third party. Latin subset only. */
@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/fraunces-800-italic-latin.woff2") format("woff2");
}
/* Neutrals lean navy (hue 280) so the ink band, text and shadows read as one family. */
:root {
  --bg: oklch(0.965 0.004 280);
  --surface: oklch(1 0 0);
  --tile-hover: oklch(0.95 0.006 280);
  --text: oklch(0.23 0.025 280);
  --muted: oklch(0.47 0.02 280);
  --border: oklch(0.23 0.025 280 / 0.14);
  --shadow: 0 1px 2px oklch(0.23 0.025 280 / 0.06), 0 3px 10px oklch(0.23 0.025 280 / 0.1);
  --band: oklch(0.23 0.025 280);
  --on-band: oklch(0.93 0.07 90);
  --on-band-muted: oklch(0.8 0.02 280);
  --strong: oklch(0.23 0.025 280);
  --on-strong: oklch(0.98 0.003 280);
  --disabled-bg: oklch(0.92 0.006 280);
  --disabled-fg: oklch(0.55 0.012 280);
  --danger: oklch(0.5 0.17 25);
  --display: "Fraunces", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.2 0.022 280);
    --surface: oklch(0.27 0.025 280);
    --tile-hover: oklch(0.31 0.027 280);
    --text: oklch(0.95 0.008 280);
    --muted: oklch(0.78 0.015 280);
    --border: oklch(0.36 0.025 280);
    --shadow: inset 0 0 0 1px oklch(0.34 0.025 280);
    --band: oklch(0.14 0.02 280);
    --on-band-muted: oklch(0.78 0.015 280);
    --strong: oklch(0.93 0.07 90);
    --on-strong: oklch(0.2 0.022 280);
    --disabled-bg: oklch(0.25 0.022 280);
    --disabled-fg: oklch(0.6 0.015 280);
    --danger: oklch(0.8 0.114 25);
  }
}

/* Player colour: candy fills, one L per role, hue per board slot (gold, sky, lilac, coral). Chroma is a share
   of each hue's sRGB ceiling (fill 92%, edge 85%, ink 90%), capped at
   0.16/0.17/0.09, so every value stays in sRGB. Dark mode keeps the bright fills
   and dark ink (yellow at low lightness turns olive) and only lifts the edge,
   which sits on dark surfaces: 80% of the ceiling at L 0.8, capped at 0.14. */
.pc {
  --fill: oklch(0.82 var(--c-fill) var(--h));
  --edge: oklch(0.6 var(--c-edge) var(--h));
  --ink: oklch(0.28 var(--c-ink) var(--h));
}
.s-0 { --h: 85;  --c-fill: 0.154; --c-edge: 0.104; --c-ink: 0.051; }
.s-1 { --h: 225; --c-fill: 0.111; --c-edge: 0.096; --c-ink: 0.047; }
.s-2 { --h: 310; --c-fill: 0.111; --c-edge: 0.17;  --c-ink: 0.09; }
.s-3 { --h: 20;  --c-fill: 0.092; --c-edge: 0.17;  --c-ink: 0.09; }
@media (prefers-color-scheme: dark) {
  .pc { --edge: oklch(0.8 var(--c-edge) var(--h)); }
  .s-0 { --c-edge: 0.131; }
  .s-1 { --c-edge: 0.108; }
  .s-2 { --c-edge: 0.108; }
  .s-3 { --c-edge: 0.091; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
button, summary { touch-action: manipulation; }
button:focus-visible, summary:focus-visible, h2:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.head summary:focus-visible { outline-color: oklch(0.98 0.003 280); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header: an ink band that bleeds to the screen edges past the 520px column. */
.head {
  padding: calc(20px + env(safe-area-inset-top)) 0 14px;
  background: var(--band);
  box-shadow: 0 0 0 100vmax var(--band);
  clip-path: inset(0 -100vmax);
  color: var(--on-band);
}
.head h1 { margin: 0; font-family: var(--display); font-size: 36px; line-height: 1; font-weight: 800; font-style: italic; letter-spacing: -0.01em; text-wrap: balance; }
.head-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
.days { display: flex; align-items: center; margin-right: -12px; }
.day-step { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 999px; color: var(--on-band); font-size: 26px; line-height: 1; text-decoration: none; touch-action: manipulation; }
span.day-step { opacity: 0.3; }
a.day-step:focus-visible { outline: 2px solid oklch(0.98 0.003 280); outline-offset: -2px; }
@media (hover: hover) and (pointer: fine) {
  a.day-step:hover { background: oklch(1 0 0 / 0.08); }
}
.day-label { min-width: 7.5em; text-align: center; font-size: 15px; font-weight: 600; color: var(--on-band); font-variant-numeric: tabular-nums; }
.day-tag { display: inline-block; margin-left: 4px; padding: 2px 7px; border-radius: 999px; background: var(--on-band); color: var(--band); font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: 2px; }
.edition-badge { display: inline-block; margin-left: 8px; padding: 3px 8px; border-radius: 999px; background: var(--on-band); color: var(--band); font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-style: normal; vertical-align: 6px; }
.rules { margin-top: 4px; font-size: 14px; color: var(--on-band-muted); }
.rules summary { cursor: pointer; width: fit-content; padding: 12px 0; margin: -8px 0; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: oklch(0.8 0.02 280 / 0.4); }
.rules p { margin: 4px 0 0; max-width: 60ch; }
.edition-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: 2px; font-size: 14px; color: var(--on-band-muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: oklch(0.8 0.02 280 / 0.4); }
.edition-link:focus-visible { outline: 2px solid oklch(0.98 0.003 280); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .edition-link:hover { color: var(--on-band); }
}
.how { margin: 4px 0 0; font-size: 15px; font-weight: 600; }

/* Tiles */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tile {
  appearance: none;
  position: relative;
  min-height: 68px;
  padding: 8px 6px;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: clamp(12.5px, 3.6vw, 14px);
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 150ms ease-out, scale 150ms ease-out;
}
.tile:active { scale: 0.96; }
@media (hover: hover) and (pointer: fine) {
  .tile:not(.painted):hover { background: var(--tile-hover); }
}
.tile.painted { background: var(--fill); color: var(--ink); box-shadow: none; }
.tile.locked { cursor: default; }
.tile.locked:active { scale: 1; }
.badge {
  position: absolute;
  top: 5px;
  right: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
}

/* Status bar */
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.bar p { margin: 0; display: flex; align-items: center; gap: 8px; }
.count { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.msg { margin: 0; min-height: 2.9em; font-size: 15px; font-weight: 600; text-wrap: pretty; }
.msg.warn { color: var(--danger); }

/* Buttons */
.primary, .ghost {
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease-out, scale 150ms ease-out;
}
.primary { border: 0; background: var(--strong); color: var(--on-strong); }
.ghost { border: 1px solid var(--border); background: transparent; color: var(--text); }
.primary:active, .ghost:active { scale: 0.96; }
.primary:disabled, .ghost:disabled { background: var(--disabled-bg); color: var(--disabled-fg); border-color: transparent; cursor: not-allowed; scale: 1; }
@media (hover: hover) and (pointer: fine) {
  .ghost:not(:disabled):hover { background: var(--surface); }
  .primary:not(:disabled):hover { background: color-mix(in oklch, var(--strong) 88%, var(--bg)); }
}
.actions { display: flex; gap: 8px; }
.actions .primary { flex: 1; }
.swatch { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--edge); }

/* Player chips */
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  transition: scale 150ms ease-out;
}
.chip:active { scale: 0.96; }
.chip[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--edge), var(--shadow); }
.chip.locked { background: var(--fill); color: var(--ink); box-shadow: none; cursor: default; }
.chip.locked:active { scale: 1; }
.chip-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chip-name { font-size: 15px; font-weight: 600; line-height: 1.2; }
.chip-note { font-size: 13px; color: var(--muted); line-height: 1.3; }
.chip-note:empty { display: none; } /* an empty line would sit the name above the swatch and count */
.chip.locked .chip-note { color: inherit; }
.chip.locked .swatch { background: var(--ink); }
.chip .count { font-size: 14px; color: var(--muted); }
.chip.locked .count { color: inherit; }

/* Recap */
.recap { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.recap h2 { margin: 0; font-family: var(--display); font-size: 30px; line-height: 1.05; font-weight: 800; font-style: italic; letter-spacing: -0.01em; text-wrap: balance; }
.recap .insight { margin: 0; color: var(--muted); max-width: 60ch; text-wrap: pretty; }
.career { padding: 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.career h3 { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.career ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.career li { padding: 4px 10px; border-radius: 999px; background: var(--fill); color: var(--ink); font-size: 14px; font-weight: 600; }
.career .also { margin: 8px 0 0; font-size: 14px; }
.career .path { margin: 8px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

/* Motion runs on state changes only, never on load. Every tap rebuilds the board, so
   the tapped button is a new element: .release carries on its press from 0.96
   instead of snapping back to full size. */
@keyframes release { from { scale: 0.96; } }
@keyframes shake { 0%, 100% { translate: 0; } 20% { translate: -4px; } 40% { translate: 4px; } 60% { translate: -3px; } 80% { translate: 2px; } }
.release { animation: release 150ms ease-out; }
.shake { animation: shake 300ms ease-in-out; }
@media (prefers-reduced-motion: reduce) {
  .release, .shake { animation: none; }
  .tile, .primary, .ghost, .chip { transition: none; }
  .tile:active, .chip:active, .primary:active, .ghost:active { scale: 1; }
}

@media (max-width: 400px) {
  .tile { padding: 8px 3px; }
}
/* Forced colours (Windows High Contrast) drop shadows and remap fills, so surfaces get real borders
   and the selected player keeps a visible ring. Initials still mark painted tiles. */
@media (forced-colors: active) {
  .tile, .chip, .career, .primary { border: 1px solid CanvasText; }
  .chip[aria-pressed="true"] { outline: 3px solid Highlight; outline-offset: 1px; }
}

/* Under 360px a long name and the count don't fit on one line, so the count drops below
   the name, and the tiles tighten so Groningen and Barcelona don't break mid-word. */
@media (max-width: 359px) {
  .chip { display: grid; grid-template-columns: 12px minmax(0, 1fr); column-gap: 10px; align-items: start; }
  .chip .swatch { margin-top: 4px; }
  .chip .count { grid-column: 2; }
  .board { gap: 6px; }
  .tile { padding: 8px 2px; font-size: 12px; letter-spacing: -0.01em; }
}

/* Studio credit, outside the board so rebuilds never touch it. */
.credit { max-width: 520px; margin: 0 auto; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); font-size: 14px; color: var(--muted); }
.credit a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
}
.credit a:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .credit a:hover { color: var(--text); text-decoration-color: currentColor; }
}
