/* === assets/styles.css === */
/* Taipei GTA — design tokens then layout then components.
   Rule enforced by tests/style.test.mjs: every colour is a token declared in one of the
   two theme blocks below; no hex or rgb() value appears anywhere else in this file.
   Contrast is also asserted there (body text AAA on the page colour, accent and focus
   ring AA), which is what keeps the dark default and the light option readable for
   low-vision readers rather than merely looking tasteful. */

:root {
  color-scheme: dark;

  /* Palette taken from the game's own stylesheet, so the guide and the game read as one
     product: --panel #0a0c12, --text #f6f3ec, --brand #e0262f, --cyan #35e0ff,
     --gold #ffcf4d, --amber #ffb13d, --green #3ddc84, --paper #f4f1ea, --ink #0b0b10.
     Values are shared, assets are not: nothing here is copied from the game but numbers. */

  /* Surfaces and text */
  --page: #07080c;
  --surface: #0f1219;
  --surface-2: #171b25;
  --surface-3: #212633;
  --ink: #f6f3ec;
  --ink-muted: #a9a59d;
  --ink-inverse: #0b0b10;
  --line: #262b38;
  --line-strong: #39404f;

  /* Brand: red is the identity colour, cyan carries links, gold carries the primary action */
  --brand: #e0262f;
  --accent: #ffcf4d;
  --accent-strong: #ffdd7a;
  --accent-soft: #2a2418;
  --accent-text: #35e0ff;
  --focus: #35e0ff;

  /* Status */
  --tip: #3ddc84;
  --warn: #ffb13d;
  --info: #35e0ff;

  /* Type — the game ships no webfont and neither do we, so this is a system stack. Latin faces
     come FIRST on purpose: the game's own stack leads with PingFang TC, which exists only on
     Apple platforms, so a Windows or Android visitor would get CJK-font Latin glyphs. Leading
     with the platform UI face keeps Latin locales native everywhere, and CJK text still falls
     through to the CJK faces listed after it. */
  --font-display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "PingFang TC", "Noto Sans TC", "Hiragino Sans", sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "PingFang TC", "Noto Sans TC", "Hiragino Sans", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, monospace;
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-base: 1.0625rem;
  --text-lg: 1.1875rem;
  --text-xl: 1.4375rem;
  --text-2xl: clamp(1.6rem, 1.2rem + 1.4vw, 2.1rem);
  --text-3xl: clamp(2.1rem, 1.4rem + 3.2vw, 3.4rem);
  --leading-tight: 1.15;
  --leading-snug: 1.35;
  --leading-body: 1.7;

  /* Spacing: one 8px scale, no ad-hoc numbers */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 56px;
  --space-7: 80px;
  --space-8: 112px;

  /* Shape */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
  --page-width: 1440px;
  --content-width: 1200px;
  --prose-width: 46rem;
  --header-height: 64px;
  --transition: 160ms ease;
}

[data-theme="light"] {
  color-scheme: light;
  /* Same identity on the game's --paper #f4f1ea: gold still carries the primary action, and
     the link colour becomes the brand red darkened until it clears AA on paper. */
  --page: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #e9e4da;
  --surface-3: #ded7c9;
  --ink: #0b0b10;
  --ink-muted: #55524b;
  --ink-inverse: #0b0b10;
  --line: #d9d2c4;
  --line-strong: #bfb6a4;
  --brand: #a8121b;
  --accent: #ffcf4d;
  --accent-strong: #f2bd2f;
  --accent-soft: #fdf1d3;
  --accent-text: #b3171f;
  --focus: #b3171f;
  --tip: #10673c;
  --warn: #8a5600;
  --info: #0f5f80;
  --shadow-sm: 0 1px 2px rgba(11, 11, 16, 0.08);
  --shadow: 0 14px 30px rgba(11, 11, 16, 0.12);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-2);
  text-wrap: balance;
}

p {
  margin: 0 0 var(--space-2);
  text-wrap: pretty;
}

a {
  color: var(--accent-text);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-strong);
}

img,
svg,
iframe {
  max-width: 100%;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
}

kbd {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  white-space: nowrap;
  color: var(--ink);
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-2);
  top: -100px;
  z-index: 60;
  background: var(--accent);
  color: var(--ink-inverse);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius);
  font-weight: 600;
  transition: top var(--transition);
}

.skip-link:focus {
  top: var(--space-2);
}

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

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--page) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: var(--space-1) var(--space-3);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--ink-inverse);
  font-size: var(--text-xs);
  font-weight: 800;
}

.site-nav ul {
  display: flex;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.site-nav a {
  display: inline-block;
  padding: var(--space-1) 10px;
  border-radius: var(--radius);
  color: var(--ink-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color var(--transition), background var(--transition);
}

.site-nav a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.site-nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--surface-2);
  font-weight: 600;
}

.header-tools {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Language is navigation: a list of real links behind a disclosure, so it works without
   JavaScript and a crawler sees every translation of the current page. */
.language-menu {
  position: relative;
}

.language-menu summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--ink);
  font-size: var(--text-sm);
  cursor: pointer;
  list-style: none;
}

.language-menu summary::-webkit-details-marker {
  display: none;
}

.language-menu[open] summary,
.language-menu summary:hover {
  border-color: var(--accent-text);
}

.language-menu ul {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  z-index: 50;
  min-width: min(13rem, calc(100vw - 2 * var(--space-2)));
  /* Anchored to the inline end, but a long locale label must not push the panel off the
     other side of a phone: measured 6px outside the viewport before this cap. */
  max-width: calc(100vw - 2 * var(--space-2));
  max-height: 60vh;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.language-menu ul a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  font-size: var(--text-sm);
}

.language-menu ul a:hover {
  background: var(--surface-2);
}

.language-menu ul a[aria-current="true"] {
  color: var(--accent-text);
  font-weight: 600;
}

/* Arabic and any future RTL locale need no overrides: the layout above uses logical
   properties (inset-inline-*, margin-inline-*, padding-inline-*, border-inline-*) rather than
   left/right, so setting dir="rtl" on <html> is enough. */

.theme-switcher {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}

.theme-option {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: var(--text-xs);
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 30px;
}

.theme-option[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--ink);
  font-weight: 600;
}

/* Below the desktop breakpoint the three header groups cannot share one row: without this
   the nav wraps into a vertical list and the language control is pushed off the right edge,
   which the page-level overflow check cannot see because the document still fits the
   viewport. Brand and controls share the first row, navigation takes the second. */
@media (max-width: 1023px) {
  /* The header stacks into two bands on a phone, and a 149px sticky band would pin a fifth
     of the screen for the whole session. It scrolls away instead. */
  .site-header {
    position: static;
  }

  .header-inner {
    flex-wrap: wrap;
    row-gap: var(--space-1);
    padding-bottom: var(--space-1);
  }

  .brand {
    order: 1;
  }

  .header-tools {
    order: 2;
    gap: var(--space-1);
  }

  .site-nav {
    order: 3;
    flex-basis: 100%;
    /* A flex item will not shrink below its content unless told to, and the nav band is
       deliberately wider than the screen: without this the whole page scrolls sideways. */
    min-width: 0;
  }

  /* One band of links that scrolls sideways, rather than three wrapped lines: the header
     stays short on a phone and every destination is still one tap away. */
  .site-nav ul {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    gap: 4px;
  }

  .site-nav ul::-webkit-scrollbar {
    display: none;
  }

  .site-nav li {
    flex: 0 0 auto;
  }

  .site-nav a {
    padding: 7px 11px;
    border: 1px solid var(--line);
    white-space: nowrap;
  }

  .site-nav a[aria-current="page"] {
    border-color: transparent;
  }
}

@media (max-width: 460px) {
  .theme-option {
    padding: 6px 7px;
  }

  .language-form select {
    padding: 6px 8px;
  }
}

.header-extra {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0 var(--space-3);
}

.breadcrumb ol {
  list-style: none;
  display: flex;
  gap: var(--space-1);
  margin: 0 0 var(--space-1);
  padding: 0;
  font-size: var(--text-xs);
  color: var(--ink-muted);
  flex-wrap: wrap;
}

.breadcrumb li + li::before {
  content: "/";
  margin-inline-end: var(--space-1);
  color: var(--line-strong);
}

.breadcrumb a {
  color: var(--ink-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* ---------- Layout ---------- */

.page {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) var(--space-6);
}

.page-hero {
  max-width: var(--prose-width);
  margin: 0 0 var(--space-4);
}

.page-hero h1 {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-2);
}

.home-hero h1 {
  font-size: var(--text-3xl);
}

.page-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

@media (min-width: 1024px) {
  .page-body {
    grid-template-columns: 15rem minmax(0, var(--prose-width));
    align-items: start;
  }
}

.page-toc {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  background: var(--surface);
  font-size: var(--text-sm);
}

@media (min-width: 1024px) {
  .page-toc {
    position: sticky;
    top: calc(var(--header-height) + var(--space-2));
  }
}

.page-toc-title {
  margin: 0 0 var(--space-1);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.page-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
}

.page-toc a {
  display: flex;
  gap: var(--space-1);
  align-items: baseline;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  text-decoration: none;
}

.page-toc a:hover,
.page-toc a:focus-visible {
  color: var(--ink);
  text-decoration: underline;
}

/* The current section, set from the browser by assets/app.js as the reader scrolls. */
.page-toc a[aria-current="true"] {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
}

.page-toc-num {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.page-toc a[aria-current="true"] .page-toc-num {
  color: var(--accent);
}

.page-toc-back {
  display: block;
  margin-top: var(--space-1);
  padding-top: var(--space-1);
  border-top: 1px solid var(--line);
  font-size: var(--text-sm);
}

.label {
  display: inline-block;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--accent-text);
  margin: 0 0 var(--space-1);
}

.lead {
  font-size: var(--text-lg);
  color: var(--ink);
  max-width: 60ch;
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  color: var(--ink-muted);
  font-size: var(--text-sm);
  margin: var(--space-2) 0 0;
}

/* The first-screen pair on guides, hubs and articles: launch the game, or jump straight to
   the practice tool that page already carries. */
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0 var(--space-4);
}

.hero-secondary {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
}

@media (max-width: 460px) {
  .page-actions {
    display: grid;
  }

  .page-actions .button {
    width: 100%;
  }
}

.prose > h2 {
  margin-top: var(--space-5);
  font-size: var(--text-2xl);
}

.prose > h3 {
  margin-top: var(--space-4);
  font-size: var(--text-xl);
}

.prose > * {
  max-width: var(--prose-width);
}

.prose > ul,
.prose > ol {
  padding-inline-start: 1.15rem;
  display: grid;
  gap: 6px;
  margin: 0 0 var(--space-3);
}

.prose blockquote {
  margin: var(--space-3) 0;
  padding: var(--space-2) var(--space-3);
  border-inline-start: 3px solid var(--brand);
  background: var(--surface);
  border-radius: var(--radius);
}

/* ---------- Hero ---------- */

.home-hero {
  display: grid;
  gap: var(--space-4);
  align-items: start;
  margin-bottom: var(--space-4);
}

@media (min-width: 1024px) {
  /* The reference's hero: the playable card takes the room, two narrow cards sit beside it. */
  .home-hero {
    grid-template-columns: minmax(0, 1fr) 20rem;
  }
}

.home-side {
  display: grid;
  gap: var(--space-2);
  align-content: start;
}

.hero-facts {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: 0;
  margin: var(--space-3) 0 0;
}

.hero-facts li {
  font-size: var(--text-xs);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-pill);
  padding: 5px 11px;
  color: var(--ink-muted);
}

/* ---------- Game embed ---------- */

.game-embed {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.game-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
}

/* A phone gets the game's own portrait poster, so the card keeps the shape the game itself
   uses there instead of cropping a 16:9 skyline into a column. */
@media (max-width: 720px) {
  .game-stage {
    aspect-ratio: 414 / 896;
    max-height: 78vh;
  }
}

.game-stage iframe {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.game-art {
  position: absolute;
  inset: 0;
  display: block;
}

.game-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-launch {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: var(--space-4);
  border: 0;
  width: 100%;
  text-align: start;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

/* Keeps the overlaid copy readable over the bright half of the artwork. */
.game-launch::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    color-mix(in srgb, var(--page) 92%, transparent),
    color-mix(in srgb, var(--page) 40%, transparent) 45%,
    transparent 78%
  );
}

.game-launch-text {
  position: relative;
  display: grid;
  gap: 6px;
  max-width: 32ch;
}

.game-launch-text strong {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  line-height: var(--leading-tight);
}

.game-launch-text small {
  color: var(--ink);
}

/* The honesty label: this picture is the game's own title art, not a frame of gameplay. */
.game-art-note {
  position: absolute;
  inset-inline-end: var(--space-3);
  bottom: var(--space-3);

  max-width: 60%;
  margin: 0;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--page) 88%, transparent);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  pointer-events: none;
}

@media (max-width: 560px) {
  /* No room for the label and the copy side by side: the label moves above the copy. */
  .game-art-note {
    top: var(--space-2);
    bottom: auto;
    inset-inline-end: var(--space-2);
  }
}

.game-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-1);
  text-align: center;
  padding: var(--space-3);
  background: var(--surface);
  color: var(--ink);
}

.game-loading small {
  color: var(--ink-muted);
}

.loader {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* The card's footer strip: the four controls the reference puts under the poster. The three
   that need a running game ship disabled, so the strip is never a row of dead buttons. */
.game-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: var(--space-1) var(--space-2);
  border-top: 1px solid var(--line);
}

.game-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.game-action:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.game-action:disabled {
  color: var(--ink-muted);
  cursor: not-allowed;
}

.game-action .icon {
  flex: 0 0 auto;
}

.game-fallback {
  margin-inline-start: auto;
  padding: 6px 4px;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.game-status {
  margin: 0;
  padding: 0 var(--space-2) var(--space-2);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.game-status:empty {
  display: none;
}

/* Theatre mode: the card takes the viewport, so the game gets the whole screen without going
   fullscreen. Esc, or the same button, brings the page back. */
.game-embed[data-theater="on"] {
  position: fixed;
  inset: 0;
  z-index: 70;
  grid-template-rows: minmax(0, 1fr) auto auto;
  border: 0;
  border-radius: 0;
  background: var(--page);
}

.game-embed[data-theater="on"] .game-stage {
  aspect-ratio: auto;
  max-height: none;
  min-height: 0;
}

body:has(.game-embed[data-theater="on"]) {
  overflow: hidden;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.button.primary,
.button.secondary {
  /* The game's controls are pills; panels stay tight. Same split here. */
  border-radius: var(--radius-pill);
}

.button.primary {
  background: var(--accent);
  color: var(--ink-inverse);
}

.button.primary:hover {
  background: var(--accent-strong);
  color: var(--ink-inverse);
}

.button.secondary {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink);
}

.button.secondary:hover {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--surface-2);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.chip {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-muted);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  min-height: 38px;
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink-inverse);
  font-weight: 600;
}

/* ---------- Cards ---------- */

.card-grid {
  list-style: none;
  padding: 0;
  margin: var(--space-3) 0;
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.card {
  display: flex;
}

.card-link {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--transition), transform var(--transition);
}

.card-link:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent-text);
  font-weight: 700;
}

.card-link strong {
  font-family: var(--font-display);
  font-size: var(--text-lg);
}

.card-link span:last-child {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

/* ---------- Notes, QA, steps ---------- */

.note {
  border: 1px solid var(--line);
  border-inline-start-width: 4px;
  border-radius: var(--radius);
  padding: var(--space-2);
  background: var(--surface);
  margin: var(--space-3) 0;
}

.note-tip {
  border-inline-start-color: var(--tip);
}

.note-warning {
  border-inline-start-color: var(--warn);
}

.note-info {
  border-inline-start-color: var(--info);
}

.note p:last-child {
  margin-bottom: 0;
}

.qa-list {
  display: grid;
  gap: var(--space-1);
  margin: var(--space-3) 0;
}

.qa-item {
  border: 1px solid var(--line);
  border-inline-start-width: 3px;
  border-radius: var(--radius);
  background: var(--surface);
}

/* The reference's accordion: a bare + on the inline end, and a vertical accent rule down
   the inline start while the answer is open. Both are drawn in CSS, so the marker cannot
   disagree with the open state the way a hand-written one can. */
.qa-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2);
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-lg);
  list-style: none;
}

.qa-item summary::-webkit-details-marker {
  display: none;
}

.qa-item summary::after {
  content: "+";
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  line-height: 1;
  color: var(--ink-muted);
}

.qa-item[open] summary::after {
  content: "-";
}

.qa-item[open] {
  border-inline-start-color: var(--accent);
}

.qa-item summary:hover {
  color: var(--accent-text);
}

.qa-answer {
  padding: 0 var(--space-2) var(--space-2);
}

.qa-answer p:last-child {
  margin-bottom: 0;
}

.step-list {
  display: grid;
  gap: var(--space-2);
  padding-inline-start: 1.15rem;
  margin: var(--space-3) 0;
}

.step-list li::marker {
  color: var(--accent-text);
  font-weight: 700;
}

.step-list p {
  margin: 4px 0 0;
  color: var(--ink-muted);
}

.link-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-1);
}

.link-list li {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: var(--space-2);
}

.link-list li span {
  display: block;
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.block-cta {
  display: grid;
  gap: var(--space-1);
  justify-items: start;
  margin: var(--space-3) 0;
}

/* ---------- Tables ---------- */

.table-scroll {
  overflow-x: auto;
  margin: var(--space-3) 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 34rem;
  font-size: var(--text-sm);
}

caption {
  text-align: start;
  padding: var(--space-2) var(--space-2) 0;
  color: var(--ink-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

th,
td {
  text-align: start;
  padding: 10px var(--space-2);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

thead th {
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  position: sticky;
  top: 0;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
}

.control-table th[scope="row"] {
  font-weight: 600;
  white-space: nowrap;
}

.keys-cell {
  white-space: nowrap;
}

.keys-cell kbd + kbd {
  margin-left: 4px;
}

.key-plus {
  color: var(--ink-muted);
  margin-inline: 2px;
}

.when-cell {
  color: var(--ink-muted);
  min-width: 14rem;
}

.context-cell {
  color: var(--ink-muted);
  white-space: nowrap;
}

/* ---------- Tools ---------- */

.tool {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--space-3);
  margin: var(--space-4) 0;
}

.tool > h2 {
  margin-top: 0;
}

.tool-controls {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-2) 0;
}

.field {
  display: grid;
  gap: 6px;
  max-width: 26rem;
}

.field label {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.field input {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--page);
  color: var(--ink);
  font: inherit;
}

.tool-status,
.tool-empty {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.tool-status:empty {
  display: none;
}

.drill-card {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--page);
  border: 1px solid var(--line);
}

.drill-progress,
.drill-score {
  margin: 0;
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.drill-question {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
}

.drill-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.drill-options .chip {
  min-width: 56px;
  font-family: var(--font-mono);
  font-size: var(--text-base);
}

.drill-options .chip.correct {
  background: var(--tip);
  border-color: var(--tip);
  color: var(--ink-inverse);
}

.drill-options .chip.wrong {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink-inverse);
}

.drill-feedback {
  margin: 0;
  min-height: 1.5rem;
}

.drill-actions {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.checklist-items {
  list-style: none;
  padding: 0;
  margin: var(--space-2) 0;
  display: grid;
  gap: 6px;
}

.checklist-items label {
  display: flex;
  gap: var(--space-1);
  align-items: flex-start;
  padding: 10px var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--page);
  cursor: pointer;
}

.checklist-items input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.checklist-items input:checked + span {
  color: var(--ink-muted);
  text-decoration: line-through;
}

/* ---------- Consent ---------- */

.consent-banner {
  position: fixed;
  left: var(--space-2);
  right: var(--space-2);
  bottom: var(--space-2);
  z-index: 50;
  max-width: 40rem;
  margin: 0 auto;
  padding: var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  font-size: var(--text-sm);
}

.consent-banner p {
  margin: 0 0 var(--space-2);
}

.consent-actions {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

/* A phone has to keep the hero CTA usable while the consent bar is up. The default type scale
   made the bar 225px tall and it clipped the 375px hero CTA; this keeps the same words in a
   bar under 150px without hiding the choice. */
@media (max-width: 720px) {
  .consent-banner {
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.35;
  }

  .consent-banner p {
    margin-bottom: 6px;
  }

  .consent-banner .button {
    min-height: 44px;
    padding: 6px 14px;
    font-size: 13px;
  }
}

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

.site-footer {
  border-top: 1px solid var(--line);
  /* The game's own UI is a textured dark surface rather than a flat panel; this is the
     tileable grid drawn in assets/art/pattern-grid.svg, kept faint enough to stay behind
     body text. The colour underneath is applied first so contrast does not depend on it. */
  background-color: var(--surface);
  background-image: url("/_a/pattern-grid.bed2fe9054.svg");
  background-repeat: repeat;
  margin-top: var(--space-7);
}

.footer-inner {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: var(--space-5) var(--space-3) var(--space-3);
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}

.footer-about p {
  color: var(--ink-muted);
  font-size: var(--text-sm);
  max-width: 34rem;
}

.footer-column h2 {
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-muted);
  margin-bottom: var(--space-1);
}

.footer-column ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.footer-column a {
  color: var(--ink);
  text-decoration: none;
  font-size: var(--text-sm);
}

.footer-column a:hover {
  text-decoration: underline;
}

.footer-base {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: var(--space-2) var(--space-3) var(--space-4);
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  color: var(--ink-muted);
  font-size: var(--text-xs);
}

.back-to-top {
  color: var(--ink-muted);
}

.content-figure {
  margin: var(--space-3) 0;
}

.content-figure figcaption {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Hero sidebar cards ---------- */

.side-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--space-2);
}

.side-card h2 {
  margin-bottom: var(--space-1);
  font-size: var(--text-base);
}

.quick-keys {
  margin: 0 0 var(--space-2);
  padding: 0;
}

.quick-key {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1);
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}

.quick-key:last-child {
  border-bottom: 0;
}

.quick-key dt {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.quick-key dd {
  margin: 0;
  text-align: end;
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.side-card-cta {
  font-size: var(--text-sm);
  font-weight: 600;
}

/* ---------- Information strip ---------- */

.info-row {
  margin: 0 0 var(--space-4);
}

.info-row dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.info-cell {
  padding: var(--space-2);
  border-inline-start: 1px solid var(--line);
}

.info-cell:first-child {
  border-inline-start: 0;
}

.info-cell dt {
  color: var(--ink-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.info-cell dd {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
}

@media (max-width: 720px) {
  .info-row dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .info-cell {
    border-inline-start: 0;
    border-top: 1px solid var(--line);
  }

  .info-cell:nth-child(-n + 2) {
    border-top: 0;
  }

  .info-cell:nth-child(even) {
    border-inline-start: 1px solid var(--line);
  }
}

/* ---------- Call-to-action band ---------- */

.cta-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin: var(--space-5) 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: linear-gradient(120deg, var(--surface-2), var(--surface));
}

.cta-band h2 {
  margin-bottom: 4px;
  font-size: var(--text-2xl);
}

.cta-band p {
  margin: 0;
  color: var(--ink-muted);
  max-width: 46ch;
}

.cta-band-action {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.share-status {
  margin: 0;
  min-height: 1.2em;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

/* ---------- Next stop ---------- */

.next-steps {
  margin-bottom: var(--space-4);
}

.next-steps h2 {
  font-size: var(--text-2xl);
}

.next-steps-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
}

.next-step a {
  position: relative;
  display: grid;
  gap: 6px;
  height: 100%;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--transition);
}

.next-step a:hover {
  border-color: var(--accent);
}

.next-step strong {
  font-family: var(--font-display);
  font-size: var(--text-xl);
}

.next-step span {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.next-step-arrow {
  position: absolute;
  inset-inline-end: var(--space-3);
  top: var(--space-3);
  color: var(--accent-text);
  font-size: var(--text-lg);
}

/* ---------- Footer badge row ---------- */

.footer-badges {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0 var(--space-3) var(--space-3);
}

.footer-badges ul {
  display: flex;
  flex-wrap: wrap;

  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-badges a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  text-decoration: none;
}

.footer-badges a:hover,
.footer-badges a:focus-visible {
  border-color: var(--accent-text);
  color: var(--ink);
}

/* ---------- The developer's own posts ---------- */

.post-list {
  list-style: none;
  margin: var(--space-3) 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.post {
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-inline-start-width: 3px;
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.post p:last-child {
  margin-bottom: 0;
}

.post-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.post-meta time,
.post-meta span {
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.post-source {
  font-weight: 600;
}

/* The user agent's `[hidden] { display: none }` loses to any author rule that sets
   `display`, so a component that ships hidden (the loading overlay, the iframe itself, the
   consent banner) would render anyway. This rule is last on purpose: equal specificity
   means source order decides. */
[hidden],
.game-embed iframe[hidden] {
  display: none;
}


/* Keep review note inside flow below artwork instead of overlapping mobile nav */
.game-embed > .game-art-note[data-game-review] { position: static; margin-top: 8px; }
