/* ==========================================================================
   1. TOKENS - colour, type, spacing, motion
   Dark theme is the default. theme-init.js sets html[data-theme] before first
   paint from the saved choice or the system preference.
   ========================================================================== */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/assets/fonts/bricolage-grotesque-var.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Sans 3";
  src: url("/assets/fonts/source-sans-3-var.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  /* Raw palette */
  --ink: #0F1115;
  --panel: #171A21;
  --panel-2: #1D212A;
  --line: #2A2F3A;
  --bone: #F3EFE6;
  --mute: #9AA1AF;
  --volt: #C8F23B;
  --coral: #FF5C4D;
  --sky: #5BC0FF;
  --amber: #FFB547;
  --mint: #4BE0A8;
  --rose: #FF8FB6;

  /* Semantic roles (these are what components use) */
  --bg: var(--ink);
  --surface: var(--panel);
  --surface-2: var(--panel-2);
  --rule: var(--line);
  --rule-strong: #3A404D;
  --text: var(--bone);
  --text-mute: var(--mute);
  --accent: var(--volt);          /* fills: CTAs, rank chips */
  --accent-fg: var(--volt);       /* accent used as text on --bg */
  --on-accent: #0F1115;           /* text placed on an accent fill */
  --link: var(--sky);
  --hot: var(--coral);
  --focus: var(--volt);
  --scrim: rgb(15 17 21 / 0.78);

  /* Type */
  --font-display: "Bricolage Grotesque", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  --fs-2xl: clamp(2rem, 1.4rem + 2.6vw, 3.25rem);
  --fs-hero: clamp(2.75rem, 1.6rem + 5.5vw, 6rem);

  /* Space (4px base) */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4.5rem;

  --gutter: clamp(1rem, 0.6rem + 2vw, 2.5rem);
  --max: 1320px;
  --rule-w: 2px;
  --notch: 14px;
  --header-h: 4rem;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --t-fast: 140ms;
  --t-med: 220ms;
}

/* Light theme: same structure, re-mapped roles. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F4F1EA;
  --surface: #FFFFFF;
  --surface-2: #ECE8DE;
  --rule: #D6D1C4;
  --rule-strong: #B9B3A4;
  --text: #14161B;
  --text-mute: #535A66;
  --accent: var(--volt);
  --accent-fg: #4A6B00;
  --on-accent: #0F1115;
  --link: #0A62A0;
  --hot: #C4301E;
  --focus: #14161B;
  --scrim: rgb(244 241 234 / 0.86);
}

/* Category tints: a small accent for tags, underlines and card notches only. */
[data-tint="volt"]  { --tint: var(--volt); }
[data-tint="coral"] { --tint: var(--coral); }
[data-tint="amber"] { --tint: var(--amber); }
[data-tint="sky"]   { --tint: var(--sky); }
[data-tint="mint"]  { --tint: var(--mint); }
[data-tint="rose"]  { --tint: var(--rose); }

/* ==========================================================================
   2. BASE - reset, element defaults, focus, utilities
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

p { margin: 0 0 var(--s-4); }
p:last-child { margin-bottom: 0; }

a { color: var(--link); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

img, svg { display: block; max-width: 100%; }
img { height: auto; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

ul, ol { margin: 0; padding: 0; }

kbd { font-family: var(--font-display); }

::selection { background: var(--accent); color: var(--on-accent); }

/* Visible focus: volt ring with an ink halo so it reads on any surface. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--bg);
}

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: -100px;
  z-index: 100;
  padding: var(--s-3) var(--s-4);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: var(--s-3); }

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

[hidden] { display: none !important; }

.num { font-family: var(--font-display); font-variant-numeric: tabular-nums lining-nums; }
.mute { color: var(--text-mute); }

/* ==========================================================================
   3. LAYOUT - page wrapper, header, sections, footer
   ========================================================================== */

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main { display: block; padding-bottom: var(--s-8); }
main:focus { outline: none; }

.section { margin-top: var(--s-8); }
.section--tight { margin-top: var(--s-7); }

/* Section heading: label + title on a thick rule, optional link on the right. */
.sec-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  padding-bottom: var(--s-3);
  margin-bottom: var(--s-5);
  border-bottom: var(--rule-w) solid var(--text);
}
.sec-head__label {
  display: block;
  margin-bottom: var(--s-2);
  color: var(--text-mute);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.sec-head h2 { font-size: var(--fs-xl); }
.sec-head[data-tint] { border-bottom-color: var(--tint); }

.see-all {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  flex-shrink: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 600;
  text-decoration: none;
}
.see-all .icon { transition: transform var(--t-fast) var(--ease); }
.see-all:hover .icon { transform: translateX(3px); }
.see-all:hover { color: var(--accent-fg); }

/* ---------- Header ------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: var(--rule-w) solid var(--rule);
}
.site-header.is-compact { border-bottom-color: var(--text); }

.header-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "brand . theme"
    "search search search"
    "nav nav nav";
  align-items: center;
  column-gap: var(--s-4);
  row-gap: var(--s-2);
  padding-top: var(--s-3);
  transition: padding var(--t-med) var(--ease);
}
.is-compact .header-bar { padding-block: var(--s-2); }

.brand {
  grid-area: brand;
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
}
.brand__mark { width: 34px; height: 34px; flex-shrink: 0; }
.brand__mark .mark-block { fill: var(--accent); }
.brand__mark .mark-bars { fill: var(--on-accent); }
.brand__word {
  display: flex;
  align-items: baseline;
  font-family: var(--font-display);
  line-height: 1;
  white-space: nowrap;
}
.brand__main { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.04em; }
.brand__sub { font-size: 1rem; font-weight: 500; color: var(--text-mute); letter-spacing: -0.01em; }

.theme-toggle { grid-area: theme; }
.search { grid-area: search; }
.cat-nav { grid-area: nav; min-width: 0; }
/* On small screens the category strip folds away once the page scrolls. */
.is-compact .cat-nav { display: none; }

.cat-nav ul {
  display: flex;
  gap: var(--s-1);
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  margin-inline: calc(var(--s-3) * -1);
}
.cat-nav ul::-webkit-scrollbar { display: none; }
.cat-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: var(--s-3);
  color: var(--text-mute);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: var(--rule-w) solid transparent;
}
.cat-nav a:hover { color: var(--text); }
.cat-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--tint, var(--accent)); }

@media (min-width: 640px) {
  .header-bar {
    grid-template-areas:
      "brand search theme"
      "nav nav nav";
  }
  .search { max-width: 420px; justify-self: end; width: 100%; }
}

@media (min-width: 1080px) {
  .header-bar {
    grid-template-columns: auto 1fr minmax(240px, 340px) auto;
    grid-template-areas: "brand nav search theme";
    padding-block: var(--s-3);
  }
  .cat-nav ul { margin-inline: 0; justify-content: center; }
  .is-compact .cat-nav { display: block; }
}

/* ---------- Footer ------------------------------------------------------ */

.site-footer {
  border-top: var(--rule-w) solid var(--text);
  padding-block: var(--s-7) var(--s-6);
  font-size: var(--fs-sm);
}
.footer-grid {
  display: grid;
  gap: var(--s-6);
  grid-template-columns: 1fr;
}
.footer-grid h2 {
  margin-bottom: var(--s-3);
  color: var(--text-mute);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.footer-grid ul { list-style: none; }
.footer-grid li a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
}
.footer-grid li a:hover { color: var(--accent-fg); text-decoration: underline; }
.footer-about p { max-width: 34ch; color: var(--text-mute); }
.footer-base {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: var(--s-6);
  padding-top: var(--s-4);
  border-top: 1px solid var(--rule);
  color: var(--text-mute);
}

@media (min-width: 720px) {
  .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; }
}

/* Scroll sentinel: when it leaves the viewport the header turns compact. */
.top-sentinel {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 48px;
  pointer-events: none;
}

/* ==========================================================================
   4. COMPONENTS - reusable pieces
   ========================================================================== */

/* ---------- Buttons ------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 48px;
  padding: 0 var(--s-5);
  border: var(--rule-w) solid var(--text);
  background: transparent;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  /* Stepped corner, the site's signature shape */
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:hover { background: var(--text); color: var(--bg); }
.btn:focus-visible { clip-path: none; }

.btn--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
.btn--primary:hover { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn--lg { min-height: 56px; padding: 0 var(--s-6); font-size: var(--fs-lg); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--s-3);
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.icon-btn:hover { border-color: var(--text); }
.icon-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-fg); }

/* Theme toggle shows the icon of the theme you would switch to. */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun,
:root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon,
:root:not([data-theme]) .theme-toggle .icon-moon { display: none; }

/* ---------- Search ------------------------------------------------------- */

.search { position: relative; }
.search__field {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  padding-inline: var(--s-3);
  border: 1px solid var(--rule);
  background: var(--surface);
}
.search__field:focus-within { border-color: var(--text); }
.search__field .icon { color: var(--text-mute); flex-shrink: 0; }
.search__input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  border: 0;
  background: transparent;
  outline: none;
}
.search__input::placeholder { color: var(--text-mute); opacity: 1; }
.search__input::-webkit-search-cancel-button { display: none; }
.search__field:has(.search__input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.search__hint { flex-shrink: 0; }
.search__field:focus-within .search__hint { display: none; }

.search__results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  max-height: min(70vh, 460px);
  overflow-y: auto;
  list-style: none;
  border: var(--rule-w) solid var(--text);
  background: var(--surface);
}
.search__option {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}
.search__option:last-child { border-bottom: 0; }
.search__option img { width: 72px; height: 40.5px; object-fit: cover; background: var(--surface-2); }
.search__option[aria-selected="true"] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.search__option strong { display: block; font-family: var(--font-display); }
.search__option span { color: var(--text-mute); font-size: var(--fs-sm); }
.search__empty { padding: var(--s-4); color: var(--text-mute); }

/* ---------- Keycaps ----------------------------------------------------- */

.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  margin: 0.125rem 0.25rem 0.125rem 0;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 3px;
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.key--glyph { font-family: var(--font-body); font-size: 1rem; }
.search__hint.key { min-width: 1.5rem; height: 1.5rem; font-size: var(--fs-xs); border-bottom-width: 2px; color: var(--text-mute); margin: 0; }
.key-or { margin: 0 0.5rem 0 0.125rem; color: var(--text-mute); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- Tags --------------------------------------------------------- */

.tag {
  display: inline-flex;
  align-items: center;
  height: 1.375rem;
  padding: 0 0.4rem;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}
.tag--new, .tag--hot { background: var(--coral); color: #0F1115; }
.tag--demo { border: 1px dashed var(--text-mute); color: var(--text-mute); }

.cat-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 600;
  text-decoration: none;
}
.cat-tag::before { content: ""; width: 10px; height: 10px; background: var(--tint, var(--accent)); }
.cat-tag:hover { text-decoration: underline; }

.chip-list { display: flex; flex-wrap: wrap; gap: var(--s-2); list-style: none; }
.chip {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--rule-strong);
  color: var(--text-mute);
  font-size: var(--fs-sm);
}

/* ---------- Game card ---------------------------------------------------- */

.gcard { position: relative; min-width: 0; }

/* The tinted triangle that fills the notched corner. */
.gcard::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: var(--notch);
  height: var(--notch);
  background: var(--tint, var(--accent));
  clip-path: polygon(0 0, 100% 0, 100% 100%);
  pointer-events: none;
  transition: transform var(--t-fast) var(--ease);
}

.gcard__link {
  display: block;
  color: var(--text);
  text-decoration: none;
  transition: transform var(--t-fast) var(--ease);
}
.gcard__frame {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-2);
  clip-path: polygon(0 0, calc(100% - var(--notch) - 4px) 0, 100% calc(var(--notch) + 4px), 100% 100%, 0 100%);
}
.gcard__img { width: 100%; height: 100%; object-fit: cover; }

.gcard__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  height: 40px;
  padding-inline: var(--s-3);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-display);
  font-weight: 700;
  transform: translateY(100%);
  transition: transform var(--t-med) var(--ease);
}
.gcard__body { display: block; padding-top: var(--s-3); }
.gcard__title {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.015em;
}
.gcard__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-1);
  color: var(--text-mute);
  font-size: var(--fs-sm);
}
.gcard__cat { box-shadow: inset 0 -2px 0 var(--tint, var(--accent)); }

.gcard:hover .gcard__link,
.gcard:focus-within .gcard__link { transform: translateY(-2px); }
.gcard:hover::after,
.gcard:focus-within::after { transform: translateY(-2px); }
.gcard:hover .gcard__bar,
.gcard:focus-within .gcard__bar { transform: translateY(0); }

/* Row of cards: swipeable on phones, grid from tablet up. */
.card-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 78%);
  gap: var(--s-5);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: var(--s-3);
  scrollbar-width: thin;
}
.card-row > * { scroll-snap-align: start; }
@media (min-width: 720px) {
  .card-row {
    grid-auto-flow: row;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    overflow: visible;
  }
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: var(--s-6) var(--s-5);
}

/* ---------- Scoreboard (ranked list) ------------------------------------ */

.board { list-style: none; border-top: var(--rule-w) solid var(--rule); }
.board__row {
  display: grid;
  grid-template-columns: 3.25rem 96px 1fr auto;
  align-items: center;
  gap: var(--s-4);
  min-height: 76px;
  padding-block: var(--s-3);
  border-bottom: 1px solid var(--rule);
}
.board__rank {
  color: var(--accent-fg);
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}
.board__thumb {
  width: 96px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-2);
}
.board__name {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  text-decoration: none;
}
.board__name::after { content: ""; position: absolute; inset: 0; }
.board__row { position: relative; }
.board__row:hover .board__name { text-decoration: underline; text-decoration-thickness: 2px; }
.board__sub { display: block; color: var(--text-mute); font-size: var(--fs-sm); }
.board__score { text-align: right; font-size: var(--fs-lg); font-weight: 700; }
.board__score small { display: block; color: var(--text-mute); font-family: var(--font-body); font-size: var(--fs-xs); font-weight: 400; }

/* Empty slots keep the board looking like a board while the catalogue grows. */
.board__row--empty { color: var(--text-mute); }
.board__row--empty .board__score { font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-mute); }
.board__row--empty .board__rank { color: var(--text-mute); font-weight: 500; }
.board__row--empty .board__thumb { border: 1px dashed var(--rule-strong); background: transparent; }
.board__dash { display: block; width: min(60%, 220px); border-top: 2px dashed var(--rule-strong); }

@media (max-width: 479.98px) {
  .board__row { grid-template-columns: 2.5rem 72px 1fr; gap: var(--s-3); }
  .board__thumb { width: 72px; }
  .board__rank { font-size: 1.875rem; }
  .board__score { grid-column: 3; text-align: left; margin-top: calc(var(--s-2) * -1); }
  .board__score small { display: inline; margin-left: var(--s-1); }
  .board__row--empty { min-height: 56px; }
  .board__row--empty .board__score { display: none; }
}

/* ---------- Category directory ------------------------------------------ */

.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  list-style: none;
  border-top: var(--rule-w) solid var(--rule);
  border-left: var(--rule-w) solid var(--rule);
}
.cat-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 160px;
  padding: var(--s-4) var(--s-5) var(--s-5);
  border-right: var(--rule-w) solid var(--rule);
  border-bottom: var(--rule-w) solid var(--rule);
  color: var(--text);
  text-decoration: none;
}
.cat-tile__num { color: var(--text-mute); font-size: var(--fs-sm); font-weight: 600; }
.cat-tile__name {
  margin-top: auto;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.cat-tile__count { margin-top: var(--s-2); color: var(--text-mute); font-size: var(--fs-sm); }
.cat-tile::before {
  content: "";
  position: absolute;
  left: var(--s-5);
  right: var(--s-5);
  bottom: 0;
  height: 4px;
  background: var(--tint);
  transform: scaleX(0.18);
  transform-origin: left;
  transition: transform var(--t-med) var(--ease);
}
a.cat-tile:hover::before, a.cat-tile:focus-visible::before { transform: scaleX(1); }
a.cat-tile:hover .cat-tile__count { color: var(--text); }
.cat-tile--soon { color: var(--text-mute); }
.cat-tile--soon .cat-tile__name { color: var(--text-mute); font-weight: 600; }
.cat-tile--soon::before { opacity: 0.35; }
.cat-tile--soon .cat-tile__count {
  align-self: flex-start;
  padding: 0.1rem 0.45rem;
  border: 1px dashed var(--rule-strong);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (min-width: 900px) { .cat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 479.98px) {
  .cat-tile { min-height: 128px; padding: var(--s-3) var(--s-4) var(--s-4); }
  .cat-tile::before { left: var(--s-4); right: var(--s-4); }
  .cat-tile__name { font-size: var(--fs-lg); }
}

/* ---------- Breadcrumb -------------------------------------------------- */

.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; list-style: none; font-size: var(--fs-sm); }
.crumbs li { display: inline-flex; align-items: center; }
.crumbs li + li::before { content: "/"; margin-inline: var(--s-2); color: var(--rule-strong); }
.crumbs a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text-mute); }
.crumbs a:hover { color: var(--text); }
.crumbs [aria-current] { color: var(--text); }

/* ---------- Notice / empty state ---------------------------------------- */

.notice {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  padding: var(--s-4) var(--s-5);
  border-left: 4px solid var(--accent);
  background: var(--surface);
}
.notice .icon { flex-shrink: 0; margin-top: 2px; }

.empty-line {
  padding: var(--s-5);
  border: 1px dashed var(--rule-strong);
  color: var(--text-mute);
}

/* ---------- Load-in stagger (kept under 300 ms in total) ---------------- */

@media (prefers-reduced-motion: no-preference) {
  .stagger > * { animation: rise 260ms var(--ease) both; }
  .stagger > *:nth-child(2) { animation-delay: 40ms; }
  .stagger > *:nth-child(3) { animation-delay: 80ms; }
  .stagger > *:nth-child(4) { animation-delay: 120ms; }
  .stagger > *:nth-child(n + 5) { animation-delay: 160ms; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Reduced motion: switch every transition and animation off. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .gcard:hover .gcard__link, .gcard:focus-within .gcard__link,
  .gcard:hover::after, .gcard:focus-within::after { transform: none; }
}

/* ==========================================================================
   5. PAGES - layouts specific to one page type
   ========================================================================== */

/* ---------- Page heading (home, category, legal, search) ----------------- */

.page-head {
  display: grid;
  gap: var(--s-5);
  align-items: end;
  padding-block: var(--s-6) var(--s-5);
  border-bottom: var(--rule-w) solid var(--text);
}
.page-head__eyebrow {
  margin-bottom: var(--s-2);
  color: var(--text-mute);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.page-head h1 { font-size: var(--fs-2xl); max-width: 22ch; }
.page-head__lede { max-width: 60ch; margin-top: var(--s-3); color: var(--text-mute); font-size: var(--fs-lg); }
.page-head[data-tint] { border-bottom-color: var(--tint); }

/* Scoreboard counters next to the home heading. */
.counters { display: flex; gap: 0; list-style: none; }
.counters li {
  min-width: 6.5rem;
  padding: 0 var(--s-4);
  border-left: var(--rule-w) solid var(--rule);
}
.counters li:first-child { border-left: 0; padding-left: 0; }
.counters b { display: block; font-size: var(--fs-2xl); font-weight: 800; line-height: 1; letter-spacing: -0.04em; }
.counters span { color: var(--text-mute); font-size: var(--fs-xs); letter-spacing: 0.1em; text-transform: uppercase; }

@media (min-width: 900px) {
  .page-head--split { grid-template-columns: 1fr auto; }
}

/* ---------- Featured "now playing" title card ---------------------------- */

.feature {
  display: grid;
  margin-top: var(--s-6);
  border: var(--rule-w) solid var(--text);
  background: var(--surface);
}
.feature__media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-2);
}
.feature__media img { width: 100%; height: 100%; object-fit: cover; }
/* The site's single intentional gradient: a short scrim so the label stays legible on any screenshot. */
.feature__media::after {
  content: "";
  position: absolute;
  inset: 55% 0 0 0;
  background: linear-gradient(to top, rgb(15 17 21 / 0.72), rgb(15 17 21 / 0));
  pointer-events: none;
}
.feature__live {
  position: absolute;
  left: var(--s-4);
  bottom: var(--s-4);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0.3rem 0.6rem;
  background: var(--volt);
  color: #0F1115;
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.feature__live::before { content: ""; width: 8px; height: 8px; background: #0F1115; }

.feature__panel {
  display: flex;
  flex-direction: column;
  padding: var(--s-5);
  border-top: var(--rule-w) solid var(--text);
}
.feature__eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-2);
  color: var(--text-mute);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.feature__eyebrow .cat-tag { min-height: 0; font-size: inherit; letter-spacing: inherit; }
.feature__title {
  font-size: var(--fs-hero);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.05em;
}
.feature__tagline { margin: var(--s-3) 0 var(--s-5); font-size: var(--fs-lg); color: var(--text-mute); }

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 0 0 var(--s-5);
  border-top: var(--rule-w) solid var(--rule);
}
.stats > div {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  padding: var(--s-3) var(--s-3) var(--s-3) 0;
  border-bottom: 1px solid var(--rule);
}
.stats > div:nth-child(even) { padding-left: var(--s-3); border-left: 1px solid var(--rule); }
.stats dt { color: var(--text-mute); font-size: var(--fs-sm); line-height: 1.25; }
.stats dd { margin: 0; font-family: var(--font-display); font-size: 2.25rem; font-weight: 800; line-height: 1; letter-spacing: -0.04em; color: var(--accent-fg); }
.stats dd.is-text { font-size: var(--fs-lg); line-height: 1.15; letter-spacing: -0.01em; color: var(--text); padding-top: 0.35rem; }
.feature__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4); margin-top: auto; }

@media (min-width: 960px) {
  .feature { grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); }
  .feature__media { aspect-ratio: auto; min-height: 100%; }
  .feature__panel { border-top: 0; border-left: var(--rule-w) solid var(--text); padding: var(--s-6); }
}

/* ---------- Home: two-column board + new list ----------------------------- */

.home-split { display: grid; gap: var(--s-8) var(--s-7); }
@media (min-width: 1000px) {
  .home-split { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
}
.new-list { display: grid; gap: var(--s-6) var(--s-5); }
@media (min-width: 560px) {
  .new-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .new-list > :only-child { grid-column: 1 / -1; }
}

/* ---------- Game page: stage ------------------------------------------- */

.play-top { padding-top: var(--s-5); }

.stage-shell { margin-inline: auto; width: min(100%, calc((100vh - var(--header-h) - 9rem) * 16 / 9)); min-width: min(100%, 560px); }

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border: var(--rule-w) solid var(--text);
  overflow: hidden;
}
.stage__frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #000; }

.stage__cover, .stage__error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--s-4);
}
.stage__cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage__cover::before { content: ""; position: absolute; inset: 0; z-index: 1; background: rgb(15 17 21 / 0.55); }
.stage__error { background: var(--bg); }
/* Touch-only devices: the stage grows to fit the notice instead of clipping it. */
.stage.is-touch { aspect-ratio: auto; min-height: 56.25vw; }
.stage.is-touch .stage__cover { position: relative; min-height: inherit; padding-block: var(--s-5); }

.title-card {
  position: relative;
  z-index: 2;
  width: min(100%, 460px);
  padding: var(--s-5);
  background: var(--surface);
  border: var(--rule-w) solid var(--text);
  color: var(--text);
  text-align: left;
  clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 22px 100%, 0 calc(100% - 22px));
}
.title-card__eyebrow { color: var(--text-mute); font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
.title-card__name { margin: var(--s-1) 0 var(--s-4); font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -0.045em; line-height: 0.95; }
.title-card p:not([class]) { color: var(--text-mute); font-size: var(--fs-sm); }
.title-card .btn { width: 100%; }
.title-card__alt { display: inline-flex; align-items: center; min-height: 44px; margin-top: var(--s-2); font-size: var(--fs-sm); background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; }
.title-card--error { border-color: var(--hot); }
.title-card--error h2 { display: flex; gap: var(--s-2); align-items: center; font-size: var(--fs-xl); margin-bottom: var(--s-3); }
.title-card--error ul { padding-left: 1.2rem; margin-bottom: var(--s-4); color: var(--text-mute); font-size: var(--fs-sm); }

/* Compact title card on small stages (phones). */
@media (max-width: 560px) {
  .title-card { padding: var(--s-3) var(--s-4); }
  .title-card__name { font-size: var(--fs-xl); margin-bottom: var(--s-2); }
  .title-card p:not([class]) { display: none; }
  .title-card .btn { min-height: 44px; font-size: var(--fs-md); }
  .title-card--touch p:not([class]) { display: block; margin-bottom: var(--s-2); }
}

.stage__hint {
  position: absolute;
  top: var(--s-3);
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  padding: 0.4rem 0.8rem;
  background: var(--volt);
  color: #0F1115;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}

.stage-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding-block: var(--s-3);
  border-bottom: var(--rule-w) solid var(--rule);
}
.stage-bar__meta { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; color: var(--text-mute); font-size: var(--fs-sm); }
.stage-bar__meta strong { color: var(--text); font-family: var(--font-display); font-size: var(--fs-md); }
.stage-bar__tools { display: flex; flex-wrap: wrap; gap: var(--s-2); }
/* On phones the button labels are visually hidden but still read by screen readers. */
@media (max-width: 719.98px) {
  .stage-bar__tools .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Theater mode: the stage takes the full viewport width and nearly all its height. */
.is-theater .play-top > .wrap { max-width: none; }
.is-theater .stage-shell { width: min(100%, calc((100vh - var(--header-h) - 5.5rem) * 16 / 9)); }
.is-theater .site-header:not(:focus-within) .cat-nav { display: none; }

/* ---------- Before you play -------------------------------------------- */

.prep {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: var(--s-4) var(--s-5);
  list-style: none;
  padding-block: var(--s-4);
  border-bottom: var(--rule-w) solid var(--rule);
  font-size: var(--fs-sm);
}
.prep li { display: flex; gap: var(--s-3); align-items: flex-start; }
.prep .icon { flex-shrink: 0; color: var(--accent-fg); margin-top: 2px; }
.prep b { display: block; font-family: var(--font-display); }
.prep span { color: var(--text-mute); }

/* ---------- Game page: details ------------------------------------------ */

.game-info { display: grid; gap: var(--s-7); margin-top: var(--s-6); }
@media (min-width: 1000px) { .game-info { grid-template-columns: minmax(0, 1fr) 320px; } }

.game-info h1 { font-size: var(--fs-hero); font-weight: 800; letter-spacing: -0.05em; line-height: 0.92; margin: var(--s-2) 0 var(--s-4); }
.game-info .lede { font-size: var(--fs-lg); max-width: 62ch; }
.game-info h2 { font-size: var(--fs-xl); margin: var(--s-7) 0 var(--s-4); padding-bottom: var(--s-3); border-bottom: var(--rule-w) solid var(--text); }
.game-info .tags-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); margin-bottom: var(--s-5); }

.controls { width: 100%; border-collapse: collapse; }
.controls th, .controls td { padding: var(--s-3) var(--s-3) var(--s-3) 0; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: middle; }
.controls thead th { color: var(--text-mute); font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; border-bottom: var(--rule-w) solid var(--rule); }
.controls thead .icon { display: inline-block; vertical-align: -5px; margin-right: var(--s-2); }
.controls tbody th { font-weight: 600; }
@media (max-width: 599.98px) {
  .controls thead { display: none; }
  .controls tr { display: grid; grid-template-columns: 1fr; padding-block: var(--s-3); border-bottom: 1px solid var(--rule); }
  .controls th, .controls td { border: 0; padding: var(--s-1) 0; }
  .controls td::before { content: attr(data-label); display: inline-block; width: 5.5rem; color: var(--text-mute); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.1em; }
}

.spec { border-top: var(--rule-w) solid var(--text); }
.spec > div { display: grid; grid-template-columns: 7rem 1fr; gap: var(--s-3); padding-block: var(--s-3); border-bottom: 1px solid var(--rule); }
.spec dt { color: var(--text-mute); font-size: var(--fs-sm); }
.spec dd { margin: 0; }
.fav-btn { width: 100%; margin-top: var(--s-5); }

/* ---------- Prose (legal and about pages) ------------------------------ */

.prose { max-width: 70ch; padding-top: var(--s-6); }
.prose h2 { font-size: var(--fs-xl); margin: var(--s-7) 0 var(--s-3); }
.prose h2:first-child { margin-top: 0; }
.prose ul { padding-left: 1.25rem; margin-bottom: var(--s-4); }
.prose li { margin-bottom: var(--s-2); }
.prose .updated { color: var(--text-mute); font-size: var(--fs-sm); }

/* ---------- 404 ---------------------------------------------------------- */

.lost { padding-block: var(--s-8); }
.lost__code { font-family: var(--font-display); font-size: clamp(6rem, 3rem + 14vw, 14rem); font-weight: 800; line-height: 0.85; letter-spacing: -0.06em; color: var(--accent-fg); }
.lost h1 { font-size: var(--fs-2xl); margin: var(--s-4) 0; }
.lost .feature__actions { margin-top: var(--s-5); }
