/* ==========================================================================================
   Landlords of Amsterdam — design system
   Semi-serious, warm, 20th-century Dutch fantasy: cream paper, Delft-blue ink, brick red,
   tulip orange, canal green and gold. Serif display (Fraunces) + Inter for the interface.

   Cascade layers (later wins): reset < tokens < base < layout < components < charts < screens
   < areas < utilities. The per-area files below are imported into the `areas` layer, so their
   rules override the kit without needing extra specificity; utilities always win.
   Reference: docs/UI-KIT.md · live style guide: #/kit
   ========================================================================================== */

@layer reset, tokens, base, layout, components, charts, screens, areas, utilities;

@import url('./styles/game.css') layer(areas);
@import url('./styles/results.css') layer(areas);
@import url('./styles/lobby.css') layer(areas);
@import url('./styles/config.css') layer(areas);
@import url('./styles/batch.css') layer(areas);

/* ------------------------------------------------------------------------------------------
   Reset
   ------------------------------------------------------------------------------------------ */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
  ul[role='list'], ol[role='list'] { list-style: none; padding: 0; }
  img, svg, video, canvas { display: block; max-width: 100%; }
  svg { overflow: visible; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; }
  [hidden] { display: none !important; }
  table { border-collapse: collapse; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.001ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.001ms !important;
      scroll-behavior: auto !important;
    }
  }
}

/* ------------------------------------------------------------------------------------------
   Tokens (light is the default; dark via prefers-color-scheme unless [data-theme="light"],
   or forced with [data-theme="dark"] on <html>)
   ------------------------------------------------------------------------------------------ */
@layer tokens {
  :root {
    color-scheme: light;
    /* surfaces */
    --paper: #f4ecda;
    --paper-2: #eadfc4;
    --surface: #fffaf0;
    --surface-2: #f8f0df;
    --surface-3: #efe4cb;
    --overlay: rgba(18, 22, 34, 0.46);
    /* ink */
    --ink: #1d2940;
    --ink-2: #4a5469;
    --ink-3: #737a8c;
    --line: rgba(29, 41, 64, 0.13);
    --line-2: rgba(29, 41, 64, 0.24);
    /* palette */
    --delft: #1f4f9e;
    --delft-strong: #163c7c;
    --delft-soft: #e1e8f5;
    --brick: #b3412a;
    --brick-soft: #f7e0d8;
    --tulip: #cf5f1c;
    --tulip-soft: #fbe6d4;
    --canal: #1f7a5f;
    --canal-soft: #d9eee6;
    --gold: #9c7112;
    --gold-bright: #e2ad35;
    --gold-soft: #f6ebc8;
    --star: #d99a1c;
    /* semantic */
    --primary-bg: #1f4f9e;
    --primary-bg-hover: #1a4488;
    --primary-fg: #ffffff;
    --danger-bg: #b3412a;
    --danger-bg-hover: #9c3521;
    --success-bg: #1f7a5f;
    --success-bg-hover: #186650;
    --on-tone: #ffffff;
    --focus: #2f6fe0;
    --social: #1f7a5f;
    --social-soft: #d9eee6;
    --private: #9c7112;
    --private-soft: #f6ebc8;
    /* players (validated for colour-vision deficiency separation) */
    --player-0: #2560c4;
    --player-1: #e36a2c;
    --player-2: #22a67b;
    --player-3: #9c3c8c;
    --player-4: #d9a21b;
    --player-5: #4b4fa8;
    /* charts */
    --chart-surface: var(--surface);
    --chart-grid: rgba(29, 41, 64, 0.09);
    --chart-axis: rgba(29, 41, 64, 0.35);
    --chart-ref: #4a5469;
    /* shape */
    --radius-xs: 4px;
    --radius-sm: 7px;
    --radius: 11px;
    --radius-lg: 16px;
    --radius-pill: 999px;
    --shadow-1: 0 1px 2px rgba(60, 40, 10, 0.08), 0 1px 1px rgba(60, 40, 10, 0.04);
    --shadow-2: 0 6px 18px -6px rgba(60, 40, 10, 0.18), 0 2px 4px rgba(60, 40, 10, 0.07);
    --shadow-3: 0 24px 60px -12px rgba(20, 15, 5, 0.32), 0 6px 16px rgba(20, 15, 5, 0.12);
    /* type */
    --font-display: 'Fraunces', 'DM Serif Display', Georgia, 'Times New Roman', serif;
    --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: ui-monospace, 'Cascadia Code', 'SFMono-Regular', Menlo, Consolas, monospace;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --text-3xl: 2.25rem;
    /* spacing scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;
    /* layout */
    --header-h: 60px;
    --tabbar-h: 62px;
    --page-max: 1200px;
    --gutter: 16px;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    /* paper texture (subtle fibres + warm vignette) */
    --paper-texture:
      radial-gradient(ellipse 120% 80% at 10% -10%, rgba(255, 255, 255, 0.55), transparent 55%),
      radial-gradient(ellipse 90% 70% at 110% 110%, rgba(176, 124, 36, 0.10), transparent 60%),
      repeating-linear-gradient(97deg, rgba(90, 60, 20, 0.018) 0 1px, transparent 1px 7px),
      repeating-linear-gradient(3deg, rgba(90, 60, 20, 0.022) 0 1px, transparent 1px 5px);
    --tile-pattern:
      radial-gradient(circle at 50% 50%, var(--delft) 0 1.6px, transparent 2.2px),
      linear-gradient(45deg, transparent 46%, color-mix(in srgb, var(--delft) 22%, transparent) 47% 53%, transparent 54%),
      linear-gradient(-45deg, transparent 46%, color-mix(in srgb, var(--delft) 22%, transparent) 47% 53%, transparent 54%);
  }

  @media (max-width: 599.98px) {
    :root { --header-h: 54px; --gutter: 14px; }
  }

  /* dark tokens: once for the system preference, once for the explicit override */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
      color-scheme: dark;
      --paper: #111726;
      --paper-2: #0c111c;
      --surface: #1a2133;
      --surface-2: #20293d;
      --surface-3: #29344b;
      --overlay: rgba(4, 6, 12, 0.62);
      --ink: #efe6d3;
      --ink-2: #bdb5a4;
      --ink-3: #8f8b83;
      --line: rgba(239, 230, 211, 0.11);
      --line-2: rgba(239, 230, 211, 0.21);
      --delft: #86aaef;
      --delft-strong: #a9c3f6;
      --delft-soft: rgba(134, 170, 239, 0.15);
      --brick: #ee8b72;
      --brick-soft: rgba(238, 139, 114, 0.15);
      --tulip: #f3a263;
      --tulip-soft: rgba(243, 162, 99, 0.15);
      --canal: #62c7a6;
      --canal-soft: rgba(98, 199, 166, 0.14);
      --gold: #e7c068;
      --gold-bright: #f0c55a;
      --gold-soft: rgba(231, 192, 104, 0.14);
      --star: #f0c04e;
      --primary-bg: #5d8ee6;
      --primary-bg-hover: #7aa3ee;
      --primary-fg: #0b1426;
      --danger-bg: #d9664d;
      --danger-bg-hover: #e57b63;
      --success-bg: #3fae8a;
      --success-bg-hover: #52bd99;
      --on-tone: #0e1424;
      --focus: #8fb4ff;
      --social: #62c7a6;
      --social-soft: rgba(98, 199, 166, 0.14);
      --private: #e7c068;
      --private-soft: rgba(231, 192, 104, 0.14);
      --player-0: #4f86e6;
      --player-1: #e2692f;
      --player-2: #1f9d72;
      --player-3: #bf5bb0;
      --player-4: #b9840a;
      --player-5: #7f7be0;
      --chart-grid: rgba(239, 230, 211, 0.08);
      --chart-axis: rgba(239, 230, 211, 0.3);
      --chart-ref: #bdb5a4;
      --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35);
      --shadow-2: 0 8px 22px -8px rgba(0, 0, 0, 0.6), 0 2px 4px rgba(0, 0, 0, 0.3);
      --shadow-3: 0 28px 70px -12px rgba(0, 0, 0, 0.75), 0 6px 16px rgba(0, 0, 0, 0.4);
      --paper-texture:
        radial-gradient(ellipse 120% 80% at 10% -10%, rgba(134, 170, 239, 0.07), transparent 55%),
        radial-gradient(ellipse 90% 70% at 110% 110%, rgba(231, 192, 104, 0.05), transparent 60%),
        repeating-linear-gradient(97deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 7px),
        repeating-linear-gradient(3deg, rgba(255, 255, 255, 0.014) 0 1px, transparent 1px 5px);
    }
  }
  :root[data-theme='dark'] {
    color-scheme: dark;
    --paper: #111726;
    --paper-2: #0c111c;
    --surface: #1a2133;
    --surface-2: #20293d;
    --surface-3: #29344b;
    --overlay: rgba(4, 6, 12, 0.62);
    --ink: #efe6d3;
    --ink-2: #bdb5a4;
    --ink-3: #8f8b83;
    --line: rgba(239, 230, 211, 0.11);
    --line-2: rgba(239, 230, 211, 0.21);
    --delft: #86aaef;
    --delft-strong: #a9c3f6;
    --delft-soft: rgba(134, 170, 239, 0.15);
    --brick: #ee8b72;
    --brick-soft: rgba(238, 139, 114, 0.15);
    --tulip: #f3a263;
    --tulip-soft: rgba(243, 162, 99, 0.15);
    --canal: #62c7a6;
    --canal-soft: rgba(98, 199, 166, 0.14);
    --gold: #e7c068;
    --gold-bright: #f0c55a;
    --gold-soft: rgba(231, 192, 104, 0.14);
    --star: #f0c04e;
    --primary-bg: #5d8ee6;
    --primary-bg-hover: #7aa3ee;
    --primary-fg: #0b1426;
    --danger-bg: #d9664d;
    --danger-bg-hover: #e57b63;
    --success-bg: #3fae8a;
    --success-bg-hover: #52bd99;
    --on-tone: #0e1424;
    --focus: #8fb4ff;
    --social: #62c7a6;
    --social-soft: rgba(98, 199, 166, 0.14);
    --private: #e7c068;
    --private-soft: rgba(231, 192, 104, 0.14);
    --player-0: #4f86e6;
    --player-1: #e2692f;
    --player-2: #1f9d72;
    --player-3: #bf5bb0;
    --player-4: #b9840a;
    --player-5: #7f7be0;
    --chart-grid: rgba(239, 230, 211, 0.08);
    --chart-axis: rgba(239, 230, 211, 0.3);
    --chart-ref: #bdb5a4;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-2: 0 8px 22px -8px rgba(0, 0, 0, 0.6), 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-3: 0 28px 70px -12px rgba(0, 0, 0, 0.75), 0 6px 16px rgba(0, 0, 0, 0.4);
    --paper-texture:
      radial-gradient(ellipse 120% 80% at 10% -10%, rgba(134, 170, 239, 0.07), transparent 55%),
      radial-gradient(ellipse 90% 70% at 110% 110%, rgba(231, 192, 104, 0.05), transparent 60%),
      repeating-linear-gradient(97deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 7px),
      repeating-linear-gradient(3deg, rgba(255, 255, 255, 0.014) 0 1px, transparent 1px 5px);
  }

  /* soft player tints derive from the (theme-dependent) player colours */
  :root, :root[data-theme='dark'], :root[data-theme='light'] {
    --player-0-soft: color-mix(in srgb, var(--player-0) 16%, transparent);
    --player-1-soft: color-mix(in srgb, var(--player-1) 16%, transparent);
    --player-2-soft: color-mix(in srgb, var(--player-2) 16%, transparent);
    --player-3-soft: color-mix(in srgb, var(--player-3) 16%, transparent);
    --player-4-soft: color-mix(in srgb, var(--player-4) 18%, transparent);
    --player-5-soft: color-mix(in srgb, var(--player-5) 16%, transparent);
  }
}

/* ------------------------------------------------------------------------------------------
   Base
   ------------------------------------------------------------------------------------------ */
@layer base {
  html {
    background: var(--paper);
    scrollbar-color: var(--line-2) transparent;
    -webkit-tap-highlight-color: transparent;
  }
  html.modal-open { overflow: hidden; }
  body {
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--paper);
    background-image: var(--paper-texture);
    background-attachment: fixed;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: var(--text-md);
    line-height: 1.5;
    font-feature-settings: 'cv11', 'ss01';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
  }
  h1, h2, h3, .display {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.15;
    color: var(--ink);
  }
  h1 { font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.4rem); }
  h2 { font-size: clamp(1.3rem, 1.15rem + 0.6vw, 1.6rem); }
  h3 { font-size: 1.15rem; }
  h4, h5, h6 { font-family: var(--font-ui); font-weight: 650; font-size: 1rem; line-height: 1.3; }
  p { text-wrap: pretty; }
  a { color: var(--delft); text-decoration-thickness: 1px; text-underline-offset: 3px; }
  a:hover { color: var(--delft-strong); }
  strong, b { font-weight: 650; }
  small { font-size: var(--text-sm); }
  hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-4) 0; }
  code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.86em; font-variant-ligatures: none; }
  code { background: var(--surface-3); border-radius: var(--radius-xs); padding: 0.1em 0.35em; }
  pre {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    overflow-x: auto;
    line-height: 1.55;
    font-size: 0.8rem;
    tab-size: 2;
  }
  pre code { background: none; padding: 0; font-size: inherit; }
  kbd {
    display: inline-block;
    padding: 0.05em 0.45em;
    border: 1px solid var(--line-2);
    border-bottom-width: 2px;
    border-radius: var(--radius-xs);
    background: var(--surface);
    font-size: 0.8em;
  }
  ::selection { background: color-mix(in srgb, var(--delft) 28%, transparent); }
  :focus { outline: none; }
  :focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; }
  ul, ol { padding-left: 1.3em; }
  li + li { margin-top: 0.25em; }
  .sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
  }
  .icon { display: inline-block; flex-shrink: 0; vertical-align: -0.18em; } /* icons sit inline in text */
  .ico { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .ico svg, .btn svg, .chip svg, .badge svg { flex-shrink: 0; }
}

/* ------------------------------------------------------------------------------------------
   Layout primitives + app shell
   ------------------------------------------------------------------------------------------ */
@layer layout {
  /* ---- app shell ---- */
  .app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
  .app-view { flex: 1; display: flex; flex-direction: column; min-width: 0; }
  .app-view > .screen { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .app-view > .screen > * { min-width: 0; }

  .app-header {
    position: sticky;
    top: 0;
    z-index: 60;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 max(var(--gutter), env(safe-area-inset-left)) 0 max(var(--gutter), env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.3) blur(10px);
    -webkit-backdrop-filter: saturate(1.3) blur(10px);
    border-bottom: 1px solid var(--line-2);
    box-shadow: 0 1px 0 var(--surface), 0 3px 0 -1px var(--line);
  }
  .app-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
    min-height: 44px;
    flex-shrink: 0;
  }
  .app-brand:hover { color: var(--ink); }
  .app-brand__mark { width: 34px; height: 34px; flex-shrink: 0; }
  .app-brand__name {
    font-family: var(--font-display);
    font-weight: 650;
    font-size: 1.12rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
  }
  .app-brand__name em { font-style: italic; font-weight: 400; color: var(--brick); }
  .app-nav { display: flex; align-items: center; gap: 2px; margin-left: var(--space-4); min-width: 0; overflow: hidden; }
  /* Medium widths: icon-only links so the nav never runs under the connection pill / theme / menu buttons. */
  @media (min-width: 900px) and (max-width: 1199.98px) {
    .app-nav { margin-left: var(--space-2); }
    .app-nav__link { padding: 0 11px; min-width: 44px; min-height: 44px; justify-content: center; }
    .app-nav__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  }
  .app-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    text-decoration: none;
    font-weight: 550;
    font-size: var(--text-sm);
    white-space: nowrap;
  }
  .app-nav__link:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
  .app-nav__link[aria-current='page'] { color: var(--delft); background: var(--delft-soft); }
  .app-shell.is-header-hidden { --header-h: 0px; }
  .app-shell.is-header-hidden > .app-header { display: none; }
  .app-header__right { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
  .app-header__menu { display: none; }
  @media (max-width: 899.98px) {
    .app-nav { display: none; }
    .app-header__menu { display: inline-flex; }
  }
  .app-header__right { flex-shrink: 0; }
  .app-brand { min-width: 0; }
  @media (max-width: 479.98px) {
    .app-header { gap: var(--space-2); }
    .app-brand__name { display: flex; flex-direction: column; line-height: 1.02; font-size: 1.02rem; }
    .app-brand__l2 { font-size: 0.8em; color: var(--ink-2); }
    .app-header__right { gap: 2px; }
  }

  .conn-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 0 11px 0 9px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line-2);
    background: var(--surface);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--ink-2);
    white-space: nowrap;
  }
  .conn-pill__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex-shrink: 0; }
  .conn-pill[data-status='open'] .conn-pill__dot { background: var(--canal); box-shadow: 0 0 0 3px var(--canal-soft); }
  .conn-pill[data-status='connecting'] .conn-pill__dot { background: var(--tulip); animation: pulse 1.1s ease-in-out infinite; }
  .conn-pill[data-status='closed'] .conn-pill__dot { background: var(--brick); }
  @media (max-width: 479.98px) { .conn-pill__label { display: none; } .conn-pill { padding: 0; width: 32px; justify-content: center; } }

  .conn-banner {
    position: sticky;
    top: var(--header-h);
    z-index: 55;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px var(--gutter);
    background: var(--tulip-soft);
    color: var(--ink);
    border-bottom: 1px solid color-mix(in srgb, var(--tulip) 40%, transparent);
    font-size: var(--text-sm);
    font-weight: 550;
    text-align: center;
  }
  .conn-banner--closed { background: var(--brick-soft); border-bottom-color: color-mix(in srgb, var(--brick) 40%, transparent); }

  /* ---- page containers ---- */
  .page {
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: var(--space-5) max(var(--gutter), env(safe-area-inset-left)) var(--space-7);
  }
  .page--narrow { max-width: 780px; }
  .page--wide { max-width: 1440px; }
  .page--flush { padding-top: 0; }
  @media (min-width: 900px) { .page { padding-top: var(--space-6); } }

  /* ---- stack: vertical rhythm ---- */
  /* Gap variables are reset on every primitive so nested layouts don't inherit a parent's modifier. */
  .stack { --stack-gap: var(--space-4); display: flex; flex-direction: column; gap: var(--stack-gap); }
  .stack > .btn:not(.btn--block) { align-self: flex-start; } /* buttons keep their width inside stacks */
  .stack--xs { --stack-gap: var(--space-1); }
  .stack--sm { --stack-gap: var(--space-2); }
  .stack--md { --stack-gap: var(--space-3); }
  .stack--lg { --stack-gap: var(--space-5); }
  .stack--xl { --stack-gap: var(--space-6); }

  /* ---- cluster: wrapping row ---- */
  .cluster { --cluster-gap: var(--space-2); display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap); }
  .cluster--sm { --cluster-gap: var(--space-1); }
  .cluster--lg { --cluster-gap: var(--space-4); }
  .cluster--end { justify-content: flex-end; }
  .cluster--center { justify-content: center; }
  .cluster--between { justify-content: space-between; }
  .cluster--nowrap { flex-wrap: nowrap; }
  .cluster--top { align-items: flex-start; }

  /* ---- split: title left, actions right ---- */
  .split { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
  .split > :first-child { min-width: 0; }

  /* ---- grids ---- */
  .grid { --grid-gap: var(--space-4); display: grid; gap: var(--grid-gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--grid-min, 240px)), 1fr)); }
  .grid--sm { --grid-min: 160px; }
  .grid--lg { --grid-min: 320px; }
  .grid--tight { --grid-gap: var(--space-2); }
  .cols-2, .cols-3, .cols-4 { display: grid; gap: var(--grid-gap, var(--space-4)); grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 600px) {
    .cols-2, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (min-width: 900px) {
    .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }

  /* ---- sidebar layout: main + aside (aside drops below main under 900px) ---- */
  .with-sidebar { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 1fr); align-items: start; }
  @media (min-width: 900px) {
    .with-sidebar { grid-template-columns: minmax(0, 1fr) var(--sidebar-w, 320px); }
    .with-sidebar--left { grid-template-columns: var(--sidebar-w, 260px) minmax(0, 1fr); }
    .with-sidebar > .sticky-side { position: sticky; top: calc(var(--header-h) + var(--space-4)); max-height: calc(100dvh - var(--header-h) - var(--space-6)); overflow: auto; }
  }

  .center { display: grid; place-items: center; }
  .spacer { flex: 1; }
  .full-bleed { margin-inline: calc(-1 * var(--gutter)); }
  .scroll-x { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
  .scroll-y { overflow-y: auto; overscroll-behavior-y: contain; }
}

/* ------------------------------------------------------------------------------------------
   Components
   ------------------------------------------------------------------------------------------ */
@layer components {
  @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
  @keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
  @keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
  @keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
  @keyframes shimmer { from { background-position: 0 0; } to { background-position: 40px 0; } }

  /* ---- buttons ---- */
  .btn {
    --btn-bg: var(--surface);
    --btn-bg-hover: var(--surface-2);
    --btn-fg: var(--ink);
    --btn-border: var(--line-2);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--btn-border);
    border-radius: var(--radius);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font: 600 0.95rem/1.15 var(--font-ui);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: background-color 0.15s, box-shadow 0.15s, transform 0.08s, border-color 0.15s, color 0.15s;
    box-shadow: var(--shadow-1);
  }
  .btn:hover { background: var(--btn-bg-hover); color: var(--btn-fg); }
  .btn:active:not([disabled]):not(.is-disabled) { transform: translateY(1px); box-shadow: none; }
  .btn__label { overflow: hidden; text-overflow: ellipsis; }
  .btn--primary {
    --btn-bg: var(--primary-bg); --btn-bg-hover: var(--primary-bg-hover); --btn-fg: var(--primary-fg); --btn-border: transparent;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16), var(--shadow-1);
  }
  .btn--danger {
    --btn-bg: var(--danger-bg); --btn-bg-hover: var(--danger-bg-hover); --btn-fg: var(--primary-fg); --btn-border: transparent;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16), var(--shadow-1);
  }
  .btn--success {
    --btn-bg: var(--success-bg); --btn-bg-hover: var(--success-bg-hover); --btn-fg: var(--primary-fg); --btn-border: transparent;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16), var(--shadow-1);
  }
  .btn--ghost { --btn-bg: transparent; --btn-bg-hover: color-mix(in srgb, var(--ink) 7%, transparent); --btn-border: transparent; box-shadow: none; }
  .btn--link {
    --btn-bg: transparent; --btn-bg-hover: transparent; --btn-fg: var(--delft); --btn-border: transparent;
    min-height: 0; padding: 0; box-shadow: none; text-decoration: underline; text-underline-offset: 3px; font-weight: 550;
  }
  .btn--sm { min-height: 36px; padding: 0 12px; font-size: var(--text-sm); border-radius: var(--radius-sm); gap: 6px; }
  .btn--lg { min-height: 52px; padding: 0 22px; font-size: 1.05rem; border-radius: 13px; }
  .btn--xl { min-height: 60px; padding: 0 26px; font-size: 1.12rem; border-radius: 14px; }
  .btn--block { display: flex; width: 100%; }
  .btn--icon { padding: 0; width: 44px; flex-shrink: 0; }
  .btn--icon.btn--sm { width: 36px; }
  .btn--icon.btn--lg { width: 52px; }
  .btn[disabled], .btn.is-disabled { opacity: 0.48; cursor: not-allowed; box-shadow: none; }
  .btn[disabled]:hover, .btn.is-disabled:hover { background: var(--btn-bg); }
  .btn.is-busy { color: transparent !important; pointer-events: none; }
  .btn.is-busy::after {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 2.5px solid var(--btn-fg);
    border-right-color: transparent;
    animation: spin 0.7s linear infinite;
  }
  .btn[aria-pressed='true'] { --btn-bg: var(--delft-soft); --btn-border: color-mix(in srgb, var(--delft) 45%, transparent); --btn-fg: var(--delft); }
  .btn__badge {
    position: absolute;
    top: -6px; right: -6px;
    min-width: 20px; height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--brick);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--surface);
  }
  .btn-group { display: inline-flex; }
  .btn-group > .btn { border-radius: 0; }
  .btn-group > .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
  .btn-group > .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
  .btn-group > .btn + .btn { margin-left: -1px; }

  .info-tip {
    display: inline-grid;
    place-items: center;
    width: 20px; height: 20px;
    margin: -2px 0 -2px 6px;
    border-radius: 50%;
    border: 1px solid var(--line-2);
    background: var(--surface);
    color: var(--ink-2);
    font: italic 700 12px/1 var(--font-display);
    vertical-align: middle;
    position: relative;
  }
  .info-tip::before { content: ''; position: absolute; inset: -12px; } /* 44px touch target */
  .info-tip:hover { color: var(--delft); border-color: var(--delft); }

  /* ---- badge ---- */
  .badge {
    --b-bg: var(--surface-3); --b-fg: var(--ink-2); --b-border: transparent;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 24px;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--b-border);
    background: var(--b-bg);
    color: var(--b-fg);
    font-size: var(--text-xs);
    font-weight: 650;
    line-height: 1.2;
    white-space: nowrap;
    vertical-align: middle;
  }
  .badge--sm { min-height: 20px; padding: 1px 7px; font-size: 0.7rem; gap: 4px; }
  .badge--delft { --b-bg: var(--delft-soft); --b-fg: var(--delft); }
  .badge--brick { --b-bg: var(--brick-soft); --b-fg: var(--brick); }
  .badge--tulip { --b-bg: var(--tulip-soft); --b-fg: var(--tulip); }
  .badge--canal { --b-bg: var(--canal-soft); --b-fg: var(--canal); }
  .badge--gold { --b-bg: var(--gold-soft); --b-fg: var(--gold); }
  .badge--social { --b-bg: var(--social-soft); --b-fg: var(--social); }
  .badge--private { --b-bg: var(--private-soft); --b-fg: var(--private); }
  .badge--solid { --b-bg: var(--ink); --b-fg: var(--paper); }
  .badge--outline { --b-bg: transparent; --b-border: var(--line-2); }
  .badge--player { --b-bg: var(--pc-soft); --b-fg: var(--ink); }
  .badge--player::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--pc); }
  .badge__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
  .count {
    display: inline-grid; place-items: center;
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px; background: var(--brick); color: #fff;
    font-size: 0.7rem; font-weight: 700;
  }

  /* ---- chip ---- */
  .chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 0 13px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line-2);
    background: var(--surface);
    color: var(--ink);
    font-size: var(--text-sm);
    font-weight: 550;
    white-space: nowrap;
    max-width: 100%;
  }
  .chip__label { overflow: hidden; text-overflow: ellipsis; }
  button.chip { cursor: pointer; min-height: 44px; }
  button.chip:hover { background: var(--surface-2); }
  .chip.is-selected { background: var(--delft-soft); border-color: color-mix(in srgb, var(--delft) 50%, transparent); color: var(--delft); }
  .chip--sm { min-height: 28px; padding: 0 10px; font-size: var(--text-xs); }
  button.chip--sm { min-height: 36px; }
  .chip--delft { background: var(--delft-soft); border-color: transparent; color: var(--delft); }
  .chip--gold { background: var(--gold-soft); border-color: transparent; color: var(--gold); }
  .chip--canal { background: var(--canal-soft); border-color: transparent; color: var(--canal); }
  .chip--brick { background: var(--brick-soft); border-color: transparent; color: var(--brick); }
  .chip--player { background: var(--pc-soft); border-color: color-mix(in srgb, var(--pc) 35%, transparent); }
  .chip__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); flex-shrink: 0; }
  .chip__remove {
    display: inline-grid; place-items: center;
    width: 22px; height: 22px; margin-right: -6px;
    border: 0; border-radius: 50%;
    background: color-mix(in srgb, var(--ink) 8%, transparent);
    color: var(--ink-2);
    position: relative;
  }
  .chip__remove::before { content: ''; position: absolute; inset: -11px; }
  .chip-wrap { display: inline-flex; align-items: center; gap: 2px; }

  /* ---- card ---- */
  .card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    min-width: 0;
  }
  .card__head {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-4) 0;
  }
  .card__icon {
    display: grid; place-items: center;
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--delft-soft);
    color: var(--delft);
    flex-shrink: 0;
  }
  .card__titles { flex: 1; min-width: 0; }
  .card__title { font-size: 1.12rem; margin: 0; }
  h3.card__title, h4.card__title { font-size: 1.02rem; }
  .card__subtitle { color: var(--ink-2); font-size: var(--text-sm); margin-top: 2px; }
  .card__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; margin-left: auto; }
  .card__body { padding: var(--space-4); }
  .card__foot {
    display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center;
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-2) 60%, transparent);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }
  .card--flush > .card__body { padding: 0; }
  .card--delft { border-top: 4px solid var(--delft); }
  .card--brick { border-top: 4px solid var(--brick); }
  .card--canal { border-top: 4px solid var(--canal); }
  .card--tulip { border-top: 4px solid var(--tulip); }
  .card--gold { border-top: 4px solid var(--gold-bright); }
  .card--inset { background: var(--surface-2); box-shadow: none; }
  .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3) var(--space-4); }
  .panel--sunken { background: var(--surface-2); }

  /* ---- board-game card ---- */
  .game-card {
    --tone: var(--delft);
    --tone-ink: #fff;
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 5px;
    border-radius: 15px;
    background:
      linear-gradient(135deg, color-mix(in srgb, var(--surface) 92%, var(--gold-bright)) 0%, var(--surface) 40%, color-mix(in srgb, var(--surface) 90%, var(--paper-2)) 100%);
    box-shadow: var(--shadow-2), inset 0 0 0 1px var(--line-2);
    color: var(--ink);
    transition: transform 0.15s var(--ease), box-shadow 0.15s;
  }
  .game-card__frame {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-radius: 11px;
    border: 1.5px solid color-mix(in srgb, var(--tone) 50%, transparent);
    background: var(--surface);
    overflow: hidden;
  }
  .game-card__head {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: 8px 10px 7px;
    background: var(--tone);
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 70%);
    color: var(--tone-ink);
  }
  .game-card__titles { flex: 1; min-width: 0; }
  .game-card__kicker { font-size: 0.64rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; opacity: 0.85; }
  .game-card__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.04rem;
    font-weight: 650;
    line-height: 1.15;
    color: inherit;
    overflow-wrap: anywhere;
  }
  .game-card__subtitle { font-size: 0.74rem; opacity: 0.9; margin-top: 1px; }
  .game-card__ribbon {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--ink);
    font-size: 0.74rem;
    font-weight: 750;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  }
  .game-card__art {
    position: relative;
    aspect-ratio: 4 / 3;
    background: linear-gradient(180deg, color-mix(in srgb, var(--delft) 12%, var(--surface)) 0%, var(--surface-2) 100%);
    border-bottom: 1px solid var(--line);
    overflow: hidden;
  }
  .game-card__art > svg, .game-card__art > img { width: 100%; height: 100%; object-fit: cover; }
  .game-card__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 12px;
    padding: 8px 10px;
    border-bottom: 1px dashed var(--line-2);
    font-size: 0.8rem;
  }
  .game-card__stat { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); white-space: nowrap; }
  .game-card__stat b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
  .game-card__stat small { font-size: 0.72rem; }
  .game-card__stat.tone-gold, .game-card__stat .icon { color: var(--gold); }
  .game-card__stats:last-child { border-bottom: 0; }
  .game-card__body { padding: 8px 10px; font-size: 0.83rem; color: var(--ink-2); }
  .game-card__body p + p { margin-top: 4px; }
  .game-card__foot { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px 10px; margin-top: auto; }
  .game-card--brick { --tone: var(--brick); }
  .game-card--canal { --tone: var(--canal); }
  .game-card--tulip { --tone: var(--tulip); }
  .game-card--gold { --tone: var(--gold-bright); --tone-ink: #2b2006; }
  .game-card--plain { --tone: var(--surface-3); --tone-ink: var(--ink); }
  .game-card--ink { --tone: #1d2940; --tone-ink: #f4ecda; }
  :root[data-theme='dark'] .game-card, :root[data-theme='dark'] .game-card--ink { --tone-ink: #0e1424; }
  :root[data-theme='dark'] .game-card--plain { --tone-ink: var(--ink); }
  :root[data-theme='dark'] .game-card--ink { --tone: #cfc5ae; }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) .game-card, :root:not([data-theme='light']) .game-card--ink { --tone-ink: #0e1424; }
    :root:not([data-theme='light']) .game-card--plain { --tone-ink: var(--ink); }
    :root:not([data-theme='light']) .game-card--ink { --tone: #cfc5ae; }
  }
  .game-card--sm .game-card__title { font-size: 0.92rem; }
  .game-card--sm .game-card__art { aspect-ratio: 16 / 10; }
  .game-card--sm .game-card__stats { font-size: 0.74rem; padding: 6px 8px; gap: 3px 9px; }
  .game-card--lg .game-card__title { font-size: 1.25rem; }
  .game-card--owned { box-shadow: var(--shadow-2), 0 0 0 2.5px var(--pc); }
  .game-card.is-clickable { cursor: pointer; }
  .game-card.is-clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-3), inset 0 0 0 1px var(--line-2); }
  .game-card.is-selected { box-shadow: var(--shadow-2), 0 0 0 3px var(--focus); }
  .game-card.is-disabled { opacity: 0.6; filter: saturate(0.6); }
  .game-card.is-disabled:hover { transform: none; }

  /* ---- stat ---- */
  .stat { display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap; }
  .stat__icon { align-self: center; display: inline-flex; color: var(--ink-3); }
  .stat__value { font-weight: 700; font-variant-numeric: tabular-nums; }
  .stat__label { font-size: var(--text-xs); color: var(--ink-2); }
  .stat--lg .stat__value { font-size: 1.35rem; font-family: var(--font-display); }
  .stat--sm { font-size: var(--text-sm); }
  .stat.tone-gold .stat__icon, .stars { color: var(--star); }

  /* ---- player tag ---- */
  .ptag { display: inline-flex; align-items: center; gap: 7px; min-width: 0; max-width: 100%; font-weight: 600; }
  .ptag__dot {
    display: inline-grid; place-items: center;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--pc);
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px color-mix(in srgb, var(--pc) 50%, transparent);
  }
  .ptag__dot:not(:empty) { width: 20px; height: 20px; }
  .ptag__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ptag__you {
    font-size: 0.66rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.06em;
    padding: 1px 6px; border-radius: var(--radius-pill); background: var(--pc-soft); color: var(--ink-2);
  }
  .ptag__ready { color: var(--canal); display: inline-flex; }
  .ptag.is-offline { opacity: 0.55; }
  .ptag.is-offline .ptag__dot { background: var(--ink-3); }
  .ptag.is-active .ptag__name { text-decoration: underline; text-decoration-color: var(--pc); text-decoration-thickness: 2px; text-underline-offset: 4px; }
  .ptag--sm { font-size: var(--text-sm); gap: 6px; }
  .ptag--sm .ptag__dot { width: 11px; height: 11px; }
  .ptag--lg { font-size: 1.1rem; }
  .ptag--lg .ptag__dot { width: 18px; height: 18px; }

  /* ---- callout ---- */
  .callout {
    --c-tone: var(--delft); --c-soft: var(--delft-soft);
    display: flex; gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    background: var(--c-soft);
    border: 1px solid color-mix(in srgb, var(--c-tone) 28%, transparent);
    border-left: 4px solid var(--c-tone);
    font-size: var(--text-sm);
  }
  .callout__icon { color: var(--c-tone); padding-top: 1px; display: inline-flex; }
  .callout__body { min-width: 0; flex: 1; }
  .callout__title { display: block; margin-bottom: 2px; }
  .callout ul { margin: 4px 0 0; padding-left: 1.1em; }
  .callout--success { --c-tone: var(--canal); --c-soft: var(--canal-soft); }
  .callout--warn { --c-tone: var(--tulip); --c-soft: var(--tulip-soft); }
  .callout--error { --c-tone: var(--brick); --c-soft: var(--brick-soft); }

  /* ---- forms ---- */
  .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
  .field__label { font-weight: 600; font-size: var(--text-sm); color: var(--ink); display: inline-flex; align-items: center; }
  .field__hint { font-size: var(--text-xs); color: var(--ink-2); }
  .field__error { font-size: var(--text-xs); color: var(--brick); font-weight: 600; }
  .field--inline { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
  .field--inline .field__hint, .field--inline .field__error { flex-basis: 100%; margin-top: -4px; }
  .input {
    width: 100%;
    min-height: 44px;
    padding: 0 13px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: 1rem; /* ≥ 16px prevents iOS zoom */
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .input::placeholder { color: var(--ink-3); }
  .input:focus { border-color: var(--delft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--delft) 22%, transparent); outline: none; }
  .input--sm { min-height: 36px; font-size: var(--text-sm); }
  textarea.input { padding: 10px 13px; min-height: 90px; resize: vertical; line-height: 1.45; }

  .select { position: relative; display: inline-flex; min-width: 0; max-width: 100%; }
  .select--block { display: flex; width: 100%; }
  .select__input {
    appearance: none; -webkit-appearance: none;
    width: 100%;
    min-height: 44px;
    padding: 0 40px 0 13px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: 0.95rem;
    font-weight: 550;
    text-overflow: ellipsis;
    cursor: pointer;
  }
  .select__input:hover { border-color: color-mix(in srgb, var(--ink) 40%, transparent); }
  .select__input:focus-visible { border-color: var(--delft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--delft) 22%, transparent); outline: none; }
  .select__input:disabled { opacity: 0.55; cursor: not-allowed; }
  .select__chevron { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--ink-2); display: inline-flex; }
  .select--sm .select__input { min-height: 36px; font-size: var(--text-sm); }
  .select__input option, .select__input optgroup { background: var(--surface); color: var(--ink); }

  /* switch */
  .switch { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; position: relative; max-width: 100%; }
  .switch__input { position: absolute; opacity: 0; width: 44px; height: 26px; margin: 0; cursor: pointer; }
  .switch__track {
    position: relative;
    flex-shrink: 0;
    width: 46px; height: 28px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--ink) 22%, transparent);
    transition: background-color 0.18s;
  }
  .switch__thumb {
    position: absolute; top: 3px; left: 3px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.18s var(--ease);
  }
  .switch__input:checked + .switch__track { background: var(--canal); }
  .switch__input:checked + .switch__track .switch__thumb { transform: translateX(18px); }
  .switch__input:focus-visible + .switch__track { outline: 2.5px solid var(--focus); outline-offset: 2px; }
  .switch__input:disabled + .switch__track, .switch.is-disabled .switch__track { opacity: 0.45; }
  .switch.is-disabled { cursor: not-allowed; }
  .switch__text { display: flex; flex-direction: column; min-width: 0; }
  .switch__label { font-weight: 600; font-size: 0.95rem; }
  .switch__desc { font-size: var(--text-xs); color: var(--ink-2); }
  .switch--sm .switch__track { width: 38px; height: 22px; }
  .switch--sm .switch__thumb { width: 16px; height: 16px; }
  .switch--sm .switch__input:checked + .switch__track .switch__thumb { transform: translateX(16px); }

  /* segmented */
  .segmented {
    display: inline-flex;
    gap: 3px;
    padding: 3px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--ink) 7%, var(--surface-2));
    border: 1px solid var(--line);
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .segmented--block { display: flex; width: 100%; }
  .segmented--block .segmented__opt { flex: 1; }
  .segmented__opt {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 38px;
    padding: 0 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--ink-2);
    font-weight: 600;
    font-size: var(--text-sm);
    white-space: nowrap;
    touch-action: manipulation;
    transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
  }
  .segmented__opt:hover { color: var(--ink); }
  .segmented__opt.is-selected { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
  .segmented__opt.is-disabled, .segmented__opt[disabled] { opacity: 0.42; cursor: not-allowed; }
  .segmented--sm .segmented__opt { min-height: 30px; padding: 0 10px; font-size: var(--text-xs); }

  /* stepper */
  .stepper {
    display: inline-flex;
    align-items: stretch;
    height: 44px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-pill);
    background: var(--surface);
    box-shadow: var(--shadow-1);
    user-select: none;
    -webkit-user-select: none;
    max-width: 100%;
  }
  .stepper__btn {
    display: grid; place-items: center;
    width: 44px;
    flex-shrink: 0;
    border: 0;
    background: transparent;
    color: var(--delft);
    border-radius: var(--radius-pill);
    touch-action: manipulation;
    -webkit-touch-callout: none;
    transition: background-color 0.12s;
  }
  .stepper__btn:hover:not(:disabled) { background: var(--delft-soft); }
  .stepper__btn:active:not(:disabled) { background: color-mix(in srgb, var(--delft) 22%, transparent); }
  .stepper__btn:disabled { color: var(--ink-3); opacity: 0.45; cursor: not-allowed; }
  .stepper__value {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    min-width: var(--stepper-value-w, 64px);
    padding: 0 4px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    border-radius: 6px;
    cursor: default;
  }
  .stepper.is-holding .stepper__value { color: var(--delft); }
  .stepper.is-disabled { opacity: 0.55; }
  .stepper--sm { height: 36px; }
  .stepper--sm .stepper__btn { width: 36px; }
  .stepper--sm .stepper__value { min-width: var(--stepper-value-w, 52px); font-size: var(--text-sm); }
  .stepper--lg { height: 52px; }
  .stepper--lg .stepper__btn { width: 52px; }
  .stepper--lg .stepper__value { min-width: var(--stepper-value-w, 96px); font-size: 1.1rem; }

  /* choice list */
  .choices { display: grid; gap: var(--space-2); grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 600px) {
    .choices--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .choices--cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (min-width: 900px) { .choices--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
  .choice {
    display: flex; align-items: center; gap: var(--space-3);
    width: 100%;
    min-height: 60px;
    padding: 12px 14px;
    border: 1.5px solid var(--line-2);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    text-align: left;
    touch-action: manipulation;
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
  }
  .choice:hover { border-color: color-mix(in srgb, var(--delft) 45%, var(--line-2)); }
  .choice.is-selected { border-color: var(--delft); background: var(--delft-soft); box-shadow: 0 0 0 1px var(--delft); }
  .choice.is-disabled { opacity: 0.5; cursor: not-allowed; }
  .choice__icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--surface-3); color: var(--delft); flex-shrink: 0; }
  .choice__art { width: 64px; flex-shrink: 0; border-radius: 8px; overflow: hidden; }
  .choice__art > svg, .choice__art > img { width: 100%; height: auto; }
  .choice__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
  .choice__title { font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .choice__desc { font-size: var(--text-sm); color: var(--ink-2); line-height: 1.35; }
  .choice__check {
    display: grid; place-items: center;
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 1.5px solid var(--line-2);
    color: transparent;
    flex-shrink: 0;
  }
  .choice[role='checkbox'] .choice__check { border-radius: 6px; }
  .choice.is-selected .choice__check { background: var(--delft); border-color: var(--delft); color: var(--primary-fg); }
  .choices--compact .choice { min-height: 48px; padding: 8px 12px; }

  /* ---- tabs ---- */
  .tabs { display: flex; flex-direction: column; min-width: 0; }
  .tabs__list { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
  .tabs__list::-webkit-scrollbar { display: none; }
  .tabs__tab {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 44px;
    padding: 0 14px;
    border: 0;
    background: transparent;
    color: var(--ink-2);
    font-weight: 600;
    font-size: var(--text-sm);
    white-space: nowrap;
    touch-action: manipulation;
  }
  .tabs__tab:hover { color: var(--ink); }
  .tabs__tab.is-disabled { opacity: 0.45; cursor: not-allowed; }
  .tabs__badge {
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--brick); color: #fff;
    font-size: 0.68rem; font-weight: 700; line-height: 18px; text-align: center;
  }
  .tabs__badge--dot { min-width: 8px; width: 8px; height: 8px; padding: 0; }
  .tabs--line .tabs__list { border-bottom: 1px solid var(--line-2); }
  .tabs--line .tabs__tab.is-active { color: var(--delft); }
  .tabs--line .tabs__tab.is-active::after {
    content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px;
    border-radius: 3px 3px 0 0; background: var(--delft);
  }
  .tabs--pill .tabs__list { padding: 3px; gap: 3px; border-radius: 12px; background: color-mix(in srgb, var(--ink) 7%, var(--surface-2)); align-self: flex-start; max-width: 100%; }
  .tabs--pill .tabs__tab { min-height: 38px; border-radius: 9px; }
  .tabs--pill .tabs__tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
  .tabs--stretch .tabs__list { align-self: stretch; }
  .tabs--stretch .tabs__tab { flex: 1; }
  .tabs__panels { min-width: 0; }
  .tabs__panel { padding-top: var(--space-4); outline: none; min-width: 0; }

  /* ---- mobile bottom tab bar (game view on narrow screens) ---- */
  .tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    display: flex;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line-2);
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-shadow: 0 -6px 20px -10px rgba(0, 0, 0, 0.25);
  }
  .tabbar__item {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: var(--tabbar-h);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0;
    background: transparent;
    color: var(--ink-3);
    font-size: 0.7rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    text-decoration: none;
    touch-action: manipulation;
  }
  .tabbar__item > span:not(.tabbar__badge) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
  .tabbar__item:hover { color: var(--ink); }
  .tabbar__item.is-active, .tabbar__item[aria-selected='true'], .tabbar__item[aria-current='page'] { color: var(--delft); }
  .tabbar__item.is-active::before, .tabbar__item[aria-selected='true']::before, .tabbar__item[aria-current='page']::before {
    content: ''; position: absolute; top: 0; left: 26%; right: 26%; height: 3px; border-radius: 0 0 3px 3px; background: var(--delft);
  }
  .tabbar__badge {
    position: absolute;
    top: 7px; left: calc(50% + 5px);
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--brick); color: #fff;
    font-size: 0.66rem; font-weight: 750; line-height: 18px; text-align: center;
    box-shadow: 0 0 0 2px var(--surface);
  }
  .tabbar__badge--dot { min-width: 10px; width: 10px; height: 10px; padding: 0; top: 10px; }
  .has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--space-3)); }
  @media (min-width: 900px) {
    .tabbar--narrow-only { display: none; }
    .has-tabbar--narrow-only { padding-bottom: 0; }
  }

  /* ---- table ---- */
  .table-wrap {
    width: 100%;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    scrollbar-width: thin;
  }
  .table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
  .table th {
    padding: 9px 12px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--line-2);
  }
  .table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
  .table tbody tr:last-child td { border-bottom: 0; }
  .table .align-right { text-align: right; font-variant-numeric: tabular-nums; }
  .table .align-center { text-align: center; }
  .table--compact th, .table--compact td { padding: 6px 10px; }
  .table--striped tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
  .table--sticky thead th { position: sticky; top: 0; z-index: 1; }
  .table tr.is-clickable { cursor: pointer; }
  .table tr.is-clickable:hover td { background: var(--delft-soft); }
  .table__sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; display: inline-flex; gap: 4px; align-items: center; min-height: 28px; }
  .table__sort-ind { font-size: 0.6rem; color: var(--delft); }
  .table__empty { text-align: center; color: var(--ink-3); padding: var(--space-5) !important; }
  th.align-right .table__sort { flex-direction: row-reverse; }

  /* ---- page head ---- */
  .page-head { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }
  .page-head__back {
    align-self: flex-start;
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 32px;
    color: var(--ink-2);
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
  }
  .page-head__back:hover { color: var(--delft); }
  .page-head__row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3) var(--space-4); flex-wrap: wrap; }
  .page-head__titles { min-width: 0; flex: 1 1 320px; }
  .page-head__kicker { font-size: var(--text-xs); font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brick); margin-bottom: 4px; }
  .page-head__title { display: flex; align-items: center; gap: 12px; margin: 0; }
  .page-head__icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--delft-soft); color: var(--delft); flex-shrink: 0; }
  .page-head__subtitle { color: var(--ink-2); margin-top: 6px; max-width: 70ch; }
  .page-head__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

  /* ---- empty state ---- */
  .empty {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2);
    padding: var(--space-6) var(--space-4);
    color: var(--ink-2);
  }
  .empty__icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--surface-3); color: var(--delft); margin-bottom: var(--space-2); }
  .empty__title { color: var(--ink); font-size: 1.2rem; }
  .empty__text { max-width: 46ch; font-size: var(--text-sm); }
  .empty__action { margin-top: var(--space-3); display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; }

  /* ---- spinner ---- */
  .spinner-wrap { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-2); }
  .spinner {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2.5px solid color-mix(in srgb, var(--delft) 22%, transparent);
    border-top-color: var(--delft);
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
  }
  .spinner--sm { width: 16px; height: 16px; border-width: 2px; }
  .spinner--lg { width: 40px; height: 40px; border-width: 3.5px; }
  .spinner__label { font-size: var(--text-sm); font-weight: 550; }

  /* ---- progress ---- */
  .progress { --p-tone: var(--delft); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
  .progress__meta { display: flex; justify-content: space-between; gap: var(--space-2); font-size: var(--text-xs); color: var(--ink-2); font-weight: 600; }
  .progress__value { font-variant-numeric: tabular-nums; color: var(--ink); }
  .progress__track { position: relative; height: 10px; border-radius: 5px; background: color-mix(in srgb, var(--p-tone) 15%, var(--surface-3)); overflow: hidden; }
  .progress__bar { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 5px; background: var(--p-tone); transition: width 0.3s var(--ease); }
  .progress__marker { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--ink); opacity: 0.6; }
  .progress--sm .progress__track { height: 6px; }
  .progress--canal { --p-tone: var(--canal); }
  .progress--brick { --p-tone: var(--brick); }
  .progress--tulip { --p-tone: var(--tulip); }
  .progress--gold { --p-tone: var(--gold-bright); }
  .progress--player { --p-tone: var(--pc); }
  .progress.is-complete { --p-tone: var(--canal); }
  .progress--player.is-complete { --p-tone: var(--pc); }
  .progress.is-indeterminate .progress__bar {
    width: 100% !important;
    background: repeating-linear-gradient(-45deg, var(--p-tone) 0 10px, color-mix(in srgb, var(--p-tone) 60%, transparent) 10px 20px);
    background-size: 40px 100%;
    animation: shimmer 0.8s linear infinite;
  }

  /* ---- collapsible ---- */
  .collapsible { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  .collapsible__summary {
    display: flex; align-items: center; gap: 10px;
    min-height: 48px;
    padding: 0 var(--space-4);
    font-weight: 650;
    list-style: none;
    cursor: pointer;
    user-select: none;
    border-radius: var(--radius);
  }
  .collapsible__summary::-webkit-details-marker { display: none; }
  .collapsible__summary:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
  .collapsible__title { flex: 1; min-width: 0; }
  .collapsible__meta { color: var(--ink-2); font-size: var(--text-sm); font-weight: 550; }
  .collapsible__chevron { display: inline-flex; color: var(--ink-2); transition: transform 0.2s var(--ease); }
  .collapsible[open] > .collapsible__summary .collapsible__chevron { transform: rotate(180deg); }
  .collapsible[open] > .collapsible__summary { border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
  .collapsible__body { padding: var(--space-4); }

  /* ---- tooltip ---- */
  .tooltip {
    position: fixed;
    top: 0; left: 0;
    z-index: 3000;
    max-width: min(280px, calc(100vw - 16px));
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: var(--paper);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.35;
    box-shadow: var(--shadow-2);
    pointer-events: none;
    animation: fade-in 0.12s ease-out;
  }
  .tooltip::after {
    content: '';
    position: absolute;
    left: var(--arrow-x, 50%);
    bottom: -5px;
    width: 10px; height: 10px;
    margin-left: -5px;
    background: inherit;
    transform: rotate(45deg);
    border-radius: 2px;
  }
  .tooltip--below::after { bottom: auto; top: -5px; }

  /* ---- toasts ---- */
  .toast-region {
    position: fixed;
    z-index: 2500;
    top: calc(var(--header-h) + 10px);
    right: max(12px, env(safe-area-inset-right));
    width: min(380px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
  }
  @media (max-width: 599.98px) {
    .toast-region { top: calc(env(safe-area-inset-top) + 8px); left: 8px; right: 8px; width: auto; }
  }
  .toast {
    --t-tone: var(--delft);
    pointer-events: auto;
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 10px 11px 13px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-left: 4px solid var(--t-tone);
    box-shadow: var(--shadow-3);
    font-size: var(--text-sm);
    animation: toast-in 0.2s var(--ease);
  }
  .toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity 0.18s, transform 0.18s; }
  .toast--success { --t-tone: var(--canal); }
  .toast--warn { --t-tone: var(--tulip); }
  .toast--error { --t-tone: var(--brick); }
  .toast__icon { color: var(--t-tone); display: inline-flex; padding-top: 1px; }
  .toast__text { flex: 1; min-width: 0; padding-top: 1px; font-weight: 550; overflow-wrap: anywhere; }
  .toast__count { margin-left: 6px; color: var(--ink-3); font-weight: 700; }
  .toast__action { margin: -6px 0; }
  .toast__close {
    display: grid; place-items: center;
    width: 28px; height: 28px; margin: -4px 0;
    border: 0; border-radius: 50%;
    background: transparent; color: var(--ink-3);
  }
  .toast__close:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }

  /* ---- modal / sheet ---- */
  .overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    /* Pin the track to the viewport: an auto track would grow with wide content (charts render
       600px wide before they measure, wide tables) and push the dialog off-screen on phones. */
    grid-template-columns: minmax(0, 1fr);
    place-items: center;
    padding: var(--space-4);
    background: var(--overlay);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: fade-in 0.16s ease-out;
    overscroll-behavior: contain;
  }
  .overlay.is-closing { opacity: 0; transition: opacity 0.16s; }
  .modal {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(560px, 100%);
    min-width: 0;
    max-height: calc(100dvh - 32px);
    background: var(--surface);
    background-image: var(--paper-texture);
    border: 1px solid var(--line-2);
    border-radius: 18px;
    box-shadow: var(--shadow-3);
    animation: pop-in 0.2s var(--ease);
    outline: none;
    color: var(--ink);
  }
  .modal--sm { width: min(430px, 100%); }
  .modal--lg { width: min(840px, 100%); }
  .modal--xl { width: min(1120px, 100%); }
  .modal__grip { display: none; }
  .modal__head { display: flex; align-items: flex-start; gap: var(--space-3); padding: 18px 16px 6px 22px; }
  .modal__icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--delft-soft); color: var(--delft); flex-shrink: 0; }
  .modal__titles { flex: 1; min-width: 0; padding-top: 4px; }
  .modal__title { font-size: 1.3rem; margin: 0; }
  .modal__subtitle { color: var(--ink-2); font-size: var(--text-sm); margin-top: 3px; }
  .modal__subtitle:empty { display: none; }
  .modal__close { margin: -4px -2px 0 0; }
  .modal__body { padding: 8px 22px 18px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; min-width: 0; }
  .modal__text { color: var(--ink-2); }
  .modal__foot {
    display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap;
    padding: 12px 22px 18px;
    border-top: 1px solid var(--line);
  }
  .modal--menu .modal__body { padding: 4px 8px 12px; }
  @media (max-width: 599.98px) {
    .overlay--sheet { place-items: end stretch; padding: 0; }
    .overlay--sheet .modal {
      width: 100%;
      max-height: 92dvh;
      border-radius: 20px 20px 0 0;
      border-bottom: 0;
      padding-bottom: env(safe-area-inset-bottom);
      animation: sheet-in 0.24s var(--ease);
    }
    .overlay--sheet .modal__grip {
      display: block;
      width: 40px; height: 5px;
      margin: 8px auto -4px;
      border-radius: 3px;
      background: var(--line-2);
    }
    .overlay--sheet .modal__head { padding: 12px 12px 4px 18px; }
    .overlay--sheet .modal__body { padding: 8px 18px 16px; }
    .overlay--sheet .modal__foot { padding: 10px 18px 14px; }
    .overlay--sheet .modal__foot .btn { flex: 1 1 0; }
    .overlay--sheet.is-closing .modal { transform: translateY(40%); transition: transform 0.16s; }
  }

  /* ---- popover menu ---- */
  .popover {
    position: fixed;
    z-index: 2000;
    min-width: 200px;
    max-width: min(320px, calc(100vw - 16px));
    padding: 6px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow-3);
    animation: pop-in 0.14s var(--ease);
  }
  .menu__title { padding: 6px 10px 4px; font-size: var(--text-xs); font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
  .menu__item {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    min-height: 42px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink);
    text-align: left;
    font-weight: 550;
    font-size: var(--text-sm);
  }
  .menu__item:hover, .menu__item:focus-visible { background: var(--delft-soft); outline: none; }
  .menu__item--danger { color: var(--brick); }
  .menu__item--danger:hover { background: var(--brick-soft); }
  .menu__item.is-disabled { opacity: 0.45; }
  .menu__spacer { width: 18px; flex-shrink: 0; }
  .menu__label { flex: 1; display: flex; flex-direction: column; min-width: 0; }
  .menu__hint { color: var(--ink-3); font-size: var(--text-xs); font-weight: 500; }
  .menu__divider { height: 1px; margin: 5px 4px; background: var(--line); }
  .menu--sheet .menu__item { min-height: 52px; font-size: 1rem; }

  /* ---- misc game typography helpers ---- */
  .money { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
  .money.is-neg, .neg { color: var(--brick); }
  .pos { color: var(--canal); }
  .num { font-variant-numeric: tabular-nums; }
  .eyebrow { font-size: var(--text-xs); font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brick); }
  .rule {
    height: 12px;
    border: 0;
    margin: var(--space-5) auto;
    width: min(420px, 80%);
    background:
      radial-gradient(circle, var(--gold-bright) 0 3px, transparent 3.5px) center / 12px 12px no-repeat,
      linear-gradient(var(--line-2), var(--line-2)) left center / calc(50% - 14px) 1px no-repeat,
      linear-gradient(var(--line-2), var(--line-2)) right center / calc(50% - 14px) 1px no-repeat;
  }
  .kbd-hint { font-size: var(--text-xs); color: var(--ink-3); }
  .prose { max-width: 72ch; }
  .prose p + p, .prose p + ul, .prose ul + p { margin-top: 0.7em; }
  .prose li + li { margin-top: 0.3em; }
  .dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: var(--text-sm); }
  .dl dt { color: var(--ink-2); }
  .dl dd { font-weight: 600; margin: 0; }
}

/* ------------------------------------------------------------------------------------------
   Charts
   ------------------------------------------------------------------------------------------ */
@layer charts {
  .chart { margin: 0; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
  .chart__title { font-weight: 650; font-size: var(--text-sm); color: var(--ink); }
  .chart__plot { position: relative; width: 100%; min-width: 0; touch-action: pan-y; border-radius: var(--radius-sm); }
  .chart__plot:focus-visible { outline-offset: 4px; }
  .chart__svg { display: block; width: 100%; font-family: var(--font-ui); overflow: visible; }
  .chart__grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
  .chart__grid--zero { stroke: var(--chart-axis); }
  .chart__tick { fill: var(--ink-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
  .chart__axis-title { fill: var(--ink-2); font-size: 11.5px; font-weight: 600; }
  .chart__line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
  .chart__line--dashed { stroke-dasharray: 6 5; }
  .chart__area { opacity: 0.1; }
  .chart__band { opacity: 0.14; }
  .chart__dot { stroke: var(--chart-surface); stroke-width: 2; }
  .chart__dot--hover { stroke-width: 2.5; }
  .chart__bar { transition: opacity 0.12s; }
  .chart__value { fill: var(--ink-2); font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; }
  .chart__ref { stroke: var(--chart-ref); stroke-width: 1.5; stroke-dasharray: 5 4; }
  .chart__ref-bg { fill: var(--chart-surface); opacity: 0.85; }
  .chart__ref-label { fill: var(--ink-2); font-size: 11px; font-weight: 650; }
  .chart__cross { stroke: var(--chart-axis); stroke-width: 1; }
  .chart__band-hl { fill: color-mix(in srgb, var(--ink) 6%, transparent); }
  .chart__empty { fill: var(--ink-3); font-size: 13px; }
  .chart__legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--text-xs); color: var(--ink-2); font-weight: 550; }
  .chart__key { display: inline-flex; align-items: center; gap: 6px; }
  .chart__swatch { width: 11px; height: 11px; border-radius: 3px; background: var(--sc); flex-shrink: 0; }
  .chart__swatch--line { width: 16px; height: 3px; border-radius: 2px; }
  .chart__swatch--dashed { background: repeating-linear-gradient(90deg, var(--sc) 0 5px, transparent 5px 8px); }
  .chart__tip {
    position: absolute;
    top: 0; left: 0;
    z-index: 5;
    min-width: 120px;
    max-width: 260px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow-2);
    font-size: var(--text-xs);
    pointer-events: none;
  }
  .chart__tip-title { font-weight: 700; color: var(--ink); margin-bottom: 4px; }
  .chart__tip-row { display: flex; align-items: center; gap: 7px; line-height: 1.6; }
  .chart__tip-key { width: 12px; height: 3px; border-radius: 2px; background: var(--sc); flex-shrink: 0; }
  .chart__tip-key--box { height: 10px; width: 10px; border-radius: 2px; }
  .chart__tip-key--none { background: none; }
  .chart__tip-value { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
  .chart__tip-name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sparkline { display: inline-block; vertical-align: middle; overflow: visible; }
  .sparkline__line { fill: none; stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
  .sparkline__fill { opacity: 0.12; }
  .sparkline__ref { stroke: var(--chart-axis); stroke-width: 1; stroke-dasharray: 3 3; }
  .sparkline__dot { stroke: var(--chart-surface); stroke-width: 1.5; }
}

/* ------------------------------------------------------------------------------------------
   Screens owned by the shell: boot/error, home, rules, kit
   ------------------------------------------------------------------------------------------ */
@layer screens {
  /* ---- boot + route states ---- */
  .route-loading { flex: 1; display: grid; place-items: center; padding: var(--space-7) var(--space-4); }
  .route-error { max-width: 640px; margin: var(--space-7) auto; padding: 0 var(--gutter); }
  .route-error pre { margin-top: var(--space-3); max-height: 240px; white-space: pre-wrap; }

  /* ---- home ---- */
  .home { padding-top: var(--space-4); }
  .home-hero {
    position: relative;
    text-align: center;
    padding: var(--space-5) var(--space-4) var(--space-5);
    margin-bottom: var(--space-5);
  }
  .home-hero__logo { width: min(620px, 100%); margin: 0 auto; color: var(--ink); }
  .home-hero__logo > svg, .home-hero__logo > img { width: 100%; height: auto; }
  .home-hero__tagline {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.3rem);
    color: var(--ink-2);
    margin-top: var(--space-3);
  }
  .home-hero__credits { margin-top: var(--space-2); font-size: var(--text-sm); color: var(--ink-3); letter-spacing: 0.02em; }
  .home-hero__credits strong { color: var(--ink-2); font-weight: 650; }
  .home-name {
    display: flex; align-items: center; justify-content: center; gap: var(--space-2); flex-wrap: wrap;
    margin-top: var(--space-5);
  }
  .home-name__label { color: var(--ink-2); font-size: var(--text-sm); font-weight: 550; }
  .name-chip {
    display: inline-flex; align-items: center; gap: 10px;
    min-height: 48px;
    padding: 0 8px 0 8px;
    border-radius: var(--radius-pill);
    background: var(--surface);
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow-1);
    max-width: 100%;
  }
  .name-chip__avatar {
    display: grid; place-items: center;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--delft);
    color: var(--primary-fg);
    font-weight: 750;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    flex-shrink: 0;
  }
  .name-chip__name { font-family: var(--font-display); font-weight: 650; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .name-chip .btn { width: 40px; min-height: 40px; border-radius: 50%; }
  @media (max-width: 479.98px) {
    .home-name { flex-direction: column; gap: var(--space-2); }
    .name-chip { border-radius: 26px; padding-block: 4px; }
    .name-chip__name { white-space: normal; line-height: 1.15; overflow-wrap: anywhere; font-size: 1.05rem; }
  }

  .home-resume { margin: 0 auto var(--space-5); max-width: 880px; }

  .home-actions { display: grid; gap: var(--space-3); max-width: 880px; margin: 0 auto; grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 640px) {
    .home-actions { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-4); }
    .home-tile--primary { grid-column: span 3; }
    .home-tile--secondary { grid-column: span 2; }
  }
  .home-tile {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 76px;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    border: 1px solid var(--line-2);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    box-shadow: var(--shadow-1);
    transition: transform 0.15s var(--ease), box-shadow 0.15s, border-color 0.15s;
    overflow: hidden;
  }
  .home-tile:hover { color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: color-mix(in srgb, var(--delft) 40%, var(--line-2)); }
  .home-tile:active { transform: translateY(0); }
  .home-tile__icon {
    display: grid; place-items: center;
    width: 48px; height: 48px;
    border-radius: 14px;
    background: var(--delft-soft);
    color: var(--delft);
    flex-shrink: 0;
  }
  .home-tile__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
  .home-tile__title { font-family: var(--font-display); font-weight: 650; font-size: 1.15rem; line-height: 1.2; }
  .home-tile__desc { font-size: var(--text-sm); color: var(--ink-2); line-height: 1.35; }
  .home-tile__arrow { color: var(--ink-3); transform: rotate(180deg); flex-shrink: 0; display: inline-flex; }
  .home-tile--primary { min-height: 108px; padding: var(--space-4) var(--space-5); }
  .home-tile--primary .home-tile__icon { width: 56px; height: 56px; }
  .home-tile--primary .home-tile__title { font-size: 1.35rem; }
  .home-tile--online { background: linear-gradient(135deg, var(--primary-bg) 0%, color-mix(in srgb, var(--primary-bg) 70%, #0b1a3a) 100%); border-color: transparent; color: var(--primary-fg); }
  .home-tile--online:hover { color: var(--primary-fg); }
  .home-tile--online .home-tile__icon { background: rgba(255, 255, 255, 0.16); color: var(--primary-fg); }
  .home-tile--online .home-tile__desc, .home-tile--online .home-tile__arrow { color: color-mix(in srgb, var(--primary-fg) 78%, transparent); }
  .home-tile--online::after {
    content: '';
    position: absolute; right: -30px; bottom: -40px;
    width: 160px; height: 160px;
    background: var(--tile-pattern);
    background-size: 22px 22px;
    opacity: 0.18;
    transform: rotate(8deg);
    pointer-events: none;
    -webkit-mask-image: radial-gradient(circle, #000 30%, transparent 70%);
    mask-image: radial-gradient(circle, #000 30%, transparent 70%);
  }
  .home-tile--local .home-tile__icon { background: var(--tulip-soft); color: var(--tulip); }
  .home-tile--batch .home-tile__icon { background: var(--canal-soft); color: var(--canal); }
  .home-tile--config .home-tile__icon { background: var(--gold-soft); color: var(--gold); }
  .home-tile--rules .home-tile__icon { background: var(--brick-soft); color: var(--brick); }

  .home-how { max-width: 880px; margin: var(--space-7) auto 0; }
  .home-how__title { text-align: center; margin-bottom: var(--space-4); }
  .home-how__grid { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 760px) { .home-how__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
  .home-how__item h3 { font-size: 1.05rem; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
  .home-how__item p { font-size: var(--text-sm); color: var(--ink-2); }
  .home-how__num {
    display: inline-grid; place-items: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--ink); color: var(--paper);
    font: 700 0.8rem/1 var(--font-ui);
    flex-shrink: 0;
  }
  .phase-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-3); }
  .phase-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px 3px 7px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    font-size: 0.72rem; font-weight: 650; color: var(--ink-2);
  }
  .phase-chip--auto { background: transparent; border: 1px dashed var(--line-2); }
  .home-foot { text-align: center; margin-top: var(--space-7); color: var(--ink-3); font-size: var(--text-sm); }
  .home-foot a { color: inherit; }

  /* ---- rules ---- */
  .rules-layout { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 1fr); align-items: start; }
  @media (min-width: 1024px) { .rules-layout { grid-template-columns: 220px minmax(0, 1fr); gap: var(--space-6); } }
  .rules-toc { display: none; }
  @media (min-width: 1024px) {
    .rules-toc {
      display: block;
      position: sticky;
      top: calc(var(--header-h) + var(--space-4));
      max-height: calc(100dvh - var(--header-h) - var(--space-6));
      overflow: auto;
    }
  }
  .rules-toc__title { font-size: var(--text-xs); font-weight: 750; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: var(--space-2); }
  .rules-toc a {
    display: block;
    padding: 6px 10px;
    border-left: 2px solid var(--line);
    color: var(--ink-2);
    font-size: var(--text-sm);
    font-weight: 550;
    text-decoration: none;
  }
  .rules-toc a:hover { color: var(--delft); border-left-color: var(--delft); }
  .rules-toc a.is-current { color: var(--delft); border-left-color: var(--delft); background: var(--delft-soft); }
  .rules-chips {
    position: sticky;
    top: var(--header-h);
    z-index: 5;
    display: flex; gap: 6px;
    overflow-x: auto;
    padding: 8px var(--gutter);
    margin: 0 calc(-1 * var(--gutter)) var(--space-2);
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }
  .rules-chips::-webkit-scrollbar { display: none; }
  @media (min-width: 1024px) { .rules-chips { display: none; } }
  .rules-chips .chip { flex-shrink: 0; }
  .rules-main { display: flex; flex-direction: column; gap: var(--space-6); min-width: 0; }
  .rules-section { scroll-margin-top: calc(var(--header-h) + 64px); }
  @media (min-width: 1024px) { .rules-section { scroll-margin-top: calc(var(--header-h) + 16px); } }
  .rules-section > h2 { display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-3); }
  .rules-section > h2 .ico { width: 36px; height: 36px; border-radius: 10px; background: var(--delft-soft); color: var(--delft); }
  .rules-section > .lead { color: var(--ink-2); margin-bottom: var(--space-4); max-width: 72ch; }
  .rules-roles { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 700px) { .rules-roles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  .role-card { border-radius: var(--radius-lg); padding: var(--space-4); border: 1px solid var(--line); background: var(--surface); position: relative; overflow: hidden; }
  .role-card::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: var(--rc, var(--delft)); }
  .role-card--social { --rc: var(--social); }
  .role-card--private { --rc: var(--private); }
  .role-card h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
  .role-card h3 .ico { color: var(--rc); }
  .phase-list { display: flex; flex-direction: column; gap: var(--space-3); counter-reset: phase; }
  .phase-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
  }
  .phase-row.is-disabled { opacity: 0.55; }
  .phase-row__icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-3); color: var(--delft); }
  .phase-row__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
  .phase-row__name { font-family: var(--font-display); font-weight: 650; font-size: 1.1rem; }
  .phase-row__num { font-size: var(--text-xs); font-weight: 750; color: var(--ink-3); }
  .phase-row p, .phase-row li { font-size: var(--text-sm); color: var(--ink-2); }
  .phase-row p + p { margin-top: 4px; }
  .phase-row ul { margin-top: 4px; }
  .prop-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
  @media (min-width: 600px) { .prop-grid { gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); } }
  @media (max-width: 599.98px) {
    .prop-grid .game-card__art { aspect-ratio: 16 / 11; }
    .prop-grid .game-card__stats { gap: 3px 8px; padding: 6px 8px; }
    .prop-grid .game-card__stat small { display: none; }
    .prop-grid .game-card__body { padding: 6px 8px; font-size: 0.78rem; }
  }
  .track { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
  .track__step { display: flex; justify-content: space-between; gap: 8px; font-size: 0.78rem; }
  .track__step span:first-child { color: var(--ink-2); }
  .track__label { font-size: 0.68rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin-top: 6px; }
  .rent-grid { display: flex; flex-wrap: wrap; gap: 6px; }
  .rent-cell {
    display: flex; flex-direction: column; align-items: center;
    min-width: 58px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--line);
    font-variant-numeric: tabular-nums;
  }
  .rent-cell b { font-size: 0.92rem; }
  .rent-cell span { font-size: 0.78rem; color: var(--star); font-weight: 700; }
  .policy-cat { display: flex; flex-direction: column; gap: var(--space-2); }
  .policy-levels { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
  .policy-level { padding: var(--space-3); border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); position: relative; }
  .policy-level.is-start { border-color: var(--delft); box-shadow: 0 0 0 1px var(--delft); }
  .policy-level__head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
  .policy-level__num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); font-size: 0.75rem; font-weight: 750; }
  .policy-level.is-start .policy-level__num { background: var(--delft); color: var(--primary-fg); }
  .policy-level__name { font-weight: 650; }
  .policy-level p { font-size: var(--text-sm); color: var(--ink-2); }
  .effects { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 3px; }
  .effects li { font-size: 0.78rem; color: var(--ink-2); padding-left: 14px; position: relative; margin: 0; }
  .effects li::before { content: ''; position: absolute; left: 3px; top: 0.55em; width: 5px; height: 5px; border-radius: 1px; background: var(--gold-bright); transform: rotate(45deg); }
  /* Final round rules (config.policies.finalRoundEffects): a level-like box with a gold edge. */
  .policy-level--final { border-left: 4px solid var(--gold-bright); max-width: 72ch; }
  .policy-level--final .effects li { font-size: var(--text-sm); }
  /* "Rounds 1–3 only" on a round-restricted random policy card. */
  .rules-card-rounds { margin-bottom: 6px; }
  /* Tenant cards per round per player count (Tenants → Arrivals). */
  .rules-draws { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: var(--text-sm); color: var(--ink-2); }
  .rules-draws b { color: var(--ink); }
  .card-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
  .tenant-bars { display: flex; flex-direction: column; gap: 4px; }
  .interp-list { counter-reset: interp; list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
  .interp-list li {
    counter-increment: interp;
    position: relative;
    padding: var(--space-3) var(--space-4) var(--space-3) 52px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
    font-size: var(--text-sm);
    margin: 0;
  }
  .interp-list li::before {
    content: counter(interp);
    position: absolute; left: 14px; top: 12px;
    display: grid; place-items: center;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--delft-soft); color: var(--delft);
    font-weight: 750; font-size: 0.75rem;
  }
  .credits-card { text-align: center; padding: var(--space-5); }
  .credits-card h2 { justify-content: center; }
  .portrait-row { display: flex; flex-wrap: wrap; gap: 6px; }
  .portrait { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: var(--surface-3); flex-shrink: 0; }
  .portrait > svg, .portrait > img { width: 100%; height: 100%; object-fit: cover; }
  .tenant-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; min-width: 0; }
  .tenant-row__name { flex: 1; min-width: 0; font-size: var(--text-sm); font-weight: 550; }
  .tenant-row__rent { font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--text-sm); }

  /* ---- kit ---- */
  .kit-layout { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 1100px) { .kit-layout { grid-template-columns: 200px minmax(0, 1fr); } }
  .kit-nav { display: none; }
  @media (min-width: 1100px) {
    .kit-nav { display: flex; flex-direction: column; position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100dvh - var(--header-h) - 32px); overflow: auto; }
    .kit-nav a { padding: 5px 10px; font-size: var(--text-sm); color: var(--ink-2); text-decoration: none; border-radius: 6px; }
    .kit-nav a:hover { background: var(--delft-soft); color: var(--delft); }
  }
  .kit-section { scroll-margin-top: calc(var(--header-h) + 16px); }
  .kit-section > h2 { margin-bottom: var(--space-2); }
  .kit-section > p { color: var(--ink-2); margin-bottom: var(--space-3); max-width: 75ch; font-size: var(--text-sm); }
  .kit-demo { display: grid; gap: var(--space-3); grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 900px) { .kit-demo { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
  .kit-demo__stage { padding: var(--space-4); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
  .kit-demo__code { margin: 0; max-height: 460px; white-space: pre-wrap; overflow-wrap: anywhere; }
  .swatches { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .swatch { border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); background: var(--surface); font-size: 0.72rem; }
  .swatch__color { height: 46px; }
  .swatch__name { padding: 5px 8px; font-family: var(--font-mono); color: var(--ink-2); }
  .icon-grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
  .icon-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 8px; background: var(--surface-2); font-size: 0.68rem; color: var(--ink-2); font-family: var(--font-mono); }
  .kit-tabbar-demo { position: relative; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; height: 150px; background: var(--paper); }
  .kit-tabbar-demo .tabbar { position: absolute; }
}

/* ------------------------------------------------------------------------------------------
   Utilities (always win)
   ------------------------------------------------------------------------------------------ */
@layer utilities {
  .muted { color: var(--ink-2); }
  .faint { color: var(--ink-3); }
  .text-xs { font-size: var(--text-xs); }
  .text-sm { font-size: var(--text-sm); }
  .text-lg { font-size: var(--text-lg); }
  .text-xl { font-size: var(--text-xl); }
  .text-center { text-align: center; }
  .text-right { text-align: right; }
  .font-display { font-family: var(--font-display); }
  .fw-600 { font-weight: 600; }
  .fw-700 { font-weight: 700; }
  .nowrap { white-space: nowrap; }
  .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .tone-delft { color: var(--delft); }
  .tone-brick { color: var(--brick); }
  .tone-canal { color: var(--canal); }
  .tone-tulip { color: var(--tulip); }
  .tone-gold { color: var(--gold); }
  .tone-star { color: var(--star); }
  .w-full { width: 100%; }
  .grow { flex: 1 1 auto; min-width: 0; }
  .shrink-0 { flex-shrink: 0; }
  .m-0 { margin: 0; }
  .mt-1 { margin-top: var(--space-1); } .mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); }
  .mt-4 { margin-top: var(--space-4); } .mt-5 { margin-top: var(--space-5); } .mt-6 { margin-top: var(--space-6); }
  .mb-1 { margin-bottom: var(--space-1); } .mb-2 { margin-bottom: var(--space-2); } .mb-3 { margin-bottom: var(--space-3); }
  .mb-4 { margin-bottom: var(--space-4); } .mb-5 { margin-bottom: var(--space-5); } .mb-6 { margin-bottom: var(--space-6); }
  .gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }
  .p-0 { padding: 0; }
  @media (max-width: 599.98px) { .hide-phone { display: none !important; } }
  @media (min-width: 600px) { .show-phone { display: none !important; } }
  @media (max-width: 899.98px) { .hide-narrow { display: none !important; } }
  @media (min-width: 900px) { .show-narrow { display: none !important; } }
}
