/* ---------- Tokens ---------- */
:root {
  /* colour */
  --bg: #0E1318;
  --surface: #151C23;
  --surface-hi: #1B242D;
  --line: #26323D;
  --line-hi: #3A4856;
  --text: #E9EEF2;
  --muted: #93A1AD;
  --focus: #8FD3FF;
  --g: #8FD3FF; /* genre colour, set per section/card */

  /* type */
  --display: "Chakra Petch", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* space and shape */
  --wrap: 1120px;
  --gutter: clamp(16px, 4vw, 32px);
  --radius: 6px;
  --radius-s: 3px;

  /* motion (transitions.dev scale) */
  --duration-stagger: 40ms;
  --duration-quick: 150ms;
  --duration-fast: 250ms;
  --duration-very-slow: 500ms;
  --ease-smooth-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.36, 0.64, 1);
  --distance-base: 8px;
  --blur-small: 2px;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; scroll-behavior: smooth; scroll-padding-top: 120px; }
body { transition: opacity var(--duration-fast) var(--ease-smooth-out); margin: 0; font: 400 1rem/1.55 var(--body); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ol, dl, dd, dt { margin: 0; }
ol { padding: 0; list-style: none; }
a { color: var(--text); text-decoration-color: var(--line-hi); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
code { font: 500 0.9em ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--surface); padding: 1px 6px; border-radius: var(--radius-s); }
[hidden] { display: none !important; }

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

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: var(--gutter); top: -60px; z-index: 20; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: var(--radius); font-weight: 600; }
.skip:focus { top: 10px; }

/* ---------- Hero ---------- */
.hero { padding-block: clamp(40px, 9vw, 96px) clamp(32px, 6vw, 64px); border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: clamp(32px, 6vw, 72px); align-items: center; }
.hero h1 { font: 700 clamp(2.25rem, 5.6vw, 4.25rem)/1.02 var(--display); letter-spacing: -0.015em; text-wrap: balance; max-width: 14ch; }
.lead { margin-top: 20px; max-width: 46ch; font-size: 1.125rem; color: var(--muted); }
.stats { display: flex; flex-wrap: wrap; gap: 12px 40px; margin-top: 32px; }
.stat { display: flex; flex-direction: column-reverse; }
.stat-n { font: 700 2.25rem/1 var(--display); font-variant-numeric: tabular-nums; }
.stat-l { color: var(--muted); font-size: 0.9375rem; margin-top: 4px; }

/* LAN party simulator (lanrpg.js) */
.rpg { width: 100%; min-width: 0; }
.rpg-screen { position: relative; border: 4px solid #4a3020; border-radius: var(--radius); box-shadow: 0 0 0 2px #d9a441; background: #000; overflow: hidden; }
.rpg-canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; cursor: pointer; }
.rpg-canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.rpg-dialog { position: absolute; left: 8px; right: 8px; bottom: 8px; max-height: calc(100% - 16px); overflow: auto; padding: 12px 14px; background: #fbf3df; color: #2b1d12; border: 3px solid #2b1d12; box-shadow: 0 0 0 3px #d9a441; border-radius: 4px; }
.rpg-title { font: 400 0.625rem/1.5 "Press Start 2P", monospace; margin-bottom: 6px; }
.rpg-body { font-size: 0.875rem; line-height: 1.4; margin-bottom: 8px; }
.rpg-opts { display: grid; gap: 4px; }
.rpg-opt { display: flex; gap: 10px; align-items: center; text-align: left; font: 500 0.875rem/1.2 var(--body); color: #2b1d12; background: #efe2c2; border: 2px solid transparent; border-radius: 3px; min-height: 36px; padding: 4px 10px; cursor: pointer; }
.rpg-opt:hover:not(:disabled), .rpg-opt:focus-visible { background: #ffc531; border-color: #2b1d12; outline: none; }
.rpg-opt:disabled { opacity: 0.5; cursor: default; }
.rpg-opts.row { display: flex; flex-wrap: wrap; }
.rpg-opts.row .rpg-opt { flex: 1 1 auto; justify-content: center; min-height: 30px; }
.rpg-opts.row .rpg-key { display: none; }
.rpg-mine { display: grid; grid-template-columns: repeat(8, 22px); gap: 1px; justify-content: center; margin-bottom: 8px; }
.rpg-cell { width: 22px; height: 22px; padding: 0; font: 400 0.625rem/1 "Press Start 2P", monospace; background: #c9b98f; border: 2px outset #efe2c2; cursor: pointer; }
.rpg-cell:hover:not(.open) { background: #d9c99f; }
.rpg-cell.open { background: #efe2c2; border: 1px solid #c9b98f; cursor: default; }
.rpg-cell.bomb { background: #e8a79d; color: #2b1d12 !important; }
.rpg-key {font: 400 0.625rem/1 "Press Start 2P", monospace; opacity: 0.6; flex: none; }
.rpg button, .rpg-canvas { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
.rpg-pb:focus, .rpg-pb:focus-visible { outline: none; }
.rpg-pad { display: none; justify-content: space-between; align-items: center; margin-top: 12px; user-select: none; -webkit-user-select: none; }
.rpg-dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px); gap: 6px; grid-template-areas: ". up ." "left down right"; }
.rpg-pb { font: 400 1rem/1 "Press Start 2P", monospace; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); touch-action: none; -webkit-touch-callout: none; cursor: pointer; }
.rpg-pb:active { background: var(--surface-hi); }
.rpg-pb[data-k="ArrowUp"] { grid-area: up; } .rpg-pb[data-k="ArrowLeft"] { grid-area: left; } .rpg-pb[data-k="ArrowRight"] { grid-area: right; } .rpg-pb[data-k="ArrowDown"] { grid-area: down; }
.rpg-pact { width: 84px; height: 84px; border-radius: 50%; background: #ffc531; color: #2b1d12; border-color: #2b1d12; }
@media (pointer: coarse), (hover: none), (any-pointer: coarse) { .rpg-pad { display: flex; } }
.rpg-lock { overflow: hidden; }
.rpg.expanded { position: fixed; inset: 0; z-index: 100; background: var(--bg); padding: 12px; overflow: auto; display: flex; flex-direction: column; align-items: center; }
.rpg.expanded > * { width: 100%; max-width: 960px; }
.rpg.expanded .rpg-screen { width: auto; max-width: 100%; }
.rpg.expanded .rpg-canvas { max-width: none; }
.rpg-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 12px; font: 600 0.9375rem/1.2 var(--display); }
.rpg-clock { font-variant-numeric: tabular-nums; }
.rpg-temp { color: var(--muted); }
.rpg-speeds { margin-left: auto; display: flex; gap: 4px; }
.rpg-sp { font: 500 0.8125rem/1 var(--body); color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); min-height: 32px; padding: 0 10px; cursor: pointer; }
.rpg-sp:hover { background: var(--surface-hi); }
.rpg-sp[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.rpg-pcline { margin-top: 6px; color: var(--muted); font-size: 0.8125rem; min-height: 1.3em; }
.rpg-meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px 12px; margin-top: 8px; }
.rpg-m { display: grid; gap: 3px; }
.rpg-ml { font-size: 0.75rem; color: var(--muted); }
.rpg-mb { display: block; height: 8px; background: var(--line); border-radius: 1px; overflow: hidden; position: relative; }
.rpg-mb i { display: block; height: 100%; }
.rpg-mb::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 7px, rgba(14,19,24,.55) 7px 8px); }
.rpg-m.low .rpg-ml { color: #FF8A7A; }
.rpg-m.low i { background: #FF5A47 !important; }
.rpg-hint { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } /* screen readers only; the on-canvas HUD is the visual hint */
.rpg-log { margin-top: 6px; display: grid; gap: 2px; font-size: 0.8125rem; color: var(--muted); min-height: 5.6em; }
.rpg-log li:first-child { color: var(--text); }

/* ---------- Filter bar ---------- */
.bar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.bar-inner { display: flex; flex-wrap: wrap; gap: 12px 32px; padding-block: 12px; }
.group { display: flex; align-items: center; gap: 12px; min-width: 0; }
.group-label { color: var(--muted); font-size: 0.875rem; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: 500 0.9375rem/1 var(--body); color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 44px; padding: 0 14px; cursor: pointer;
  transition: background-color var(--duration-quick) var(--ease-smooth-out), border-color var(--duration-quick) var(--ease-smooth-out), color var(--duration-quick) var(--ease-smooth-out), transform var(--duration-quick) var(--ease-smooth-out); }
.chip:hover { background: var(--surface-hi); border-color: var(--line-hi); }
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"] { background: var(--g); border-color: var(--g); color: #0E1318; font-weight: 600; }
.bar .chip[aria-pressed="true"]:not([style]) { --g: var(--text); }

/* ---------- Library ---------- */
#library { padding-block: 28px 80px; }
.result { color: var(--muted); font-size: 0.9375rem; min-height: 1.5em; }
.genre { margin-top: 48px; }
.genre-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 20px; padding-left: 16px; border-left: 4px solid var(--g); }
.genre-name { font: 700 1.75rem/1.1 var(--display); }
.genre-blurb { color: var(--muted); flex: 1 1 24ch; }
.genre-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; margin-top: 20px; }

.card { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px 18px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--g); border-radius: var(--radius);
  transition: transform var(--duration-fast) var(--ease-smooth-out), border-color var(--duration-fast) var(--ease-smooth-out), background-color var(--duration-fast) var(--ease-smooth-out); }
.card:hover { transform: translateY(-2px); background: var(--surface-hi); border-color: var(--line-hi); border-top-color: var(--g); }
.card.enter { animation: card-in var(--duration-fast) var(--ease-smooth-out) both; }
@keyframes card-in { from { opacity: 0; filter: blur(var(--blur-small)); } to { opacity: 1; filter: blur(0); } }

.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card-name { font: 600 1.1875rem/1.2 var(--display); }
.note { color: var(--muted); font-size: 0.9375rem; min-height: 2.9em; }

.modes { display: grid; gap: 6px; margin-top: auto; }
.mode { display: grid; grid-template-columns: 56px minmax(0, 1fr) 40px auto; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg); border-radius: var(--radius-s);
  transition: opacity var(--duration-fast) var(--ease-smooth-out); }
.mode-name { font-size: 0.875rem; font-weight: 600; }
.mode.none { opacity: 0.55; grid-template-columns: 56px 1fr; }
.mode-none { color: var(--muted); font-size: 0.875rem; }
.count { font: 700 1.375rem/1 var(--display); text-align: right; font-variant-numeric: tabular-nums; }

/* With a mode selected, the other row steps back. */
#sections[data-mode="coop"] .mode[data-mode="versus"],
#sections[data-mode="versus"] .mode[data-mode="coop"] { opacity: 0.35; }

.pips { display: flex; gap: 2px; align-items: center; min-width: 0; }
.pips i { flex: 1 1 0; max-width: 8px; height: 14px; background: var(--line); border-radius: 1px; }
.pips i.on { background: var(--g); }
.pips .over { margin-left: 3px; color: var(--g); font: 700 0.875rem/1 var(--display); }

/* ---------- Source tags ---------- */
.tag { font-size: 0.75rem; font-weight: 600; padding: 3px 7px; border-radius: var(--radius-s); border: 1px solid; white-space: nowrap; }
.tag-co  { color: #8FE3A6; border-color: #2F6B43; background: #12281B; }
.tag-chk { color: #8FD3FF; border-color: #2D5A78; background: #11222E; }
.tag-pcgw { color: #FFFFFF; border-color: #5E7A92; background: #17222C; }
.tag-rep { color: #FFB3D1; border-color: #7A3A55; background: #2A1420; }
.tag-unv { color: var(--muted); border-color: var(--line-hi); background: transparent; }

.mod { align-self: flex-start; margin-top: -2px; padding: 2px 8px; font-size: 0.8125rem; font-weight: 600; color: var(--g); border: 1px solid color-mix(in srgb, var(--g) 45%, transparent); border-radius: var(--radius-s); }
.ext-link { align-self: flex-start; font-size: 0.875rem; color: var(--muted); text-decoration: underline; text-decoration-color: var(--line-hi); text-underline-offset: 3px; padding-block: 12px; margin-block: -6px -12px;
  transition: color var(--duration-quick) var(--ease-smooth-out), text-decoration-color var(--duration-quick) var(--ease-smooth-out); }
.ext-link:hover { color: var(--text); text-decoration-color: var(--text); }

/* ---------- Empty + notes ---------- */
.empty { margin-top: 48px; padding: 32px; border: 1px dashed var(--line-hi); border-radius: var(--radius); }
.empty h2 { font: 700 1.5rem/1.2 var(--display); }
.empty p { color: var(--muted); margin: 8px 0 20px; max-width: 50ch; }
.btn { font: 600 1rem/1 var(--body); min-height: 44px; padding: 0 20px; border: 0; border-radius: var(--radius); background: var(--text); color: var(--bg); cursor: pointer; transition: transform var(--duration-quick) var(--ease-smooth-out), background-color var(--duration-quick) var(--ease-smooth-out); }
.btn:hover { background: #fff; }
.btn:active { transform: scale(0.97); }


.foot { border-top: 1px solid var(--line); padding-block: 24px; color: var(--muted); font-size: 0.9375rem; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .hero-grid { grid-template-columns: 1fr; }
  .bar-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  .group { flex-direction: column; align-items: flex-start; gap: 6px; max-width: 100%; }
  .bar { position: static; }
}
@media (max-width: 480px) {
  .mode { grid-template-columns: 48px minmax(0, 1fr) 36px; }
  .mode .tag { grid-column: 2 / -1; justify-self: start; }
  .mode.none { grid-template-columns: 48px 1fr; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
  .card:hover { transform: none; }
}

.links { display: flex; flex-wrap: wrap; gap: 0 18px; margin-block: -6px -12px; }
.links .ext-link { margin-block: 0; }
.caveat { margin: -2px 0 0; font-size: 0.8125rem; color: var(--muted); }

.search { font: 500 0.9375rem/1 var(--body); color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 44px; width: 220px; max-width: 100%; padding: 0 14px;
  transition: border-color var(--duration-quick) var(--ease-smooth-out), background-color var(--duration-quick) var(--ease-smooth-out); }
.search::placeholder { color: var(--muted); }
.search:hover { border-color: var(--line-hi); }
.search:focus-visible { background: var(--surface-hi); }
a.mod { text-decoration: none; transition: background-color var(--duration-quick) var(--ease-smooth-out); }
a.mod:hover { background: color-mix(in srgb, var(--g) 14%, transparent); }

.net { margin: 0; padding: 8px 10px; font-size: 0.875rem; border-radius: var(--radius-s); border-left: 3px solid; background: var(--bg); color: var(--muted); }
.net strong { color: var(--text); font-weight: 600; }
.net-required { border-color: #FF8A7A; }
.net-partial { border-color: #E3C99A; }

/* The page is built by script, then revealed once, so nothing visibly moves after first paint. */
html.loading body { opacity: 0; }
.buy { border-color: #FFC531; }
