/* ============================================================================
 * SpinDecide — styles.css
 *
 * DESIGN DIRECTION: "Fairground prize wheel".
 *   Scene: someone on a phone deciding dinner from the sofa, or a teacher
 *   throwing the wheel onto a classroom projector in daylight. So: light by
 *   default, true dark mode on request, and a dark marquee "stage" band that
 *   makes the wheel pop on any screen or projector.
 *   The wheel IS the hero image. Chrome is quiet; colour is committed:
 *   vermilion + mustard carry the brand, neutrals are tinted toward vermilion.
 *   No gradient text, no decorative glass, no indigo.
 *
 * TYPE: Bricolage Grotesque (variable opsz + wght), one family on purpose —
 *   heavy optical sizes for display, text sizes for UI and prose.
 *
 * Layers: reset → tokens → base → layout → components → pages → utilities.
 * ========================================================================= */
@layer reset, tokens, base, layout, components, pages, utilities;

/* Metric-matched fallback so the web font swap does not shift layout. */
@font-face {
  font-family: 'Bricolage Fallback';
  src: local('Arial'), local('Helvetica Neue'), local('Helvetica');
  size-adjust: 101%;
  ascent-override: 93%;
  descent-override: 26%;
  line-gap-override: 0%;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  img, svg, video, canvas { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; }
  p, li, h1, h2, h3, h4 { overflow-wrap: break-word; }
  [hidden] { display: none !important; }
}

@layer tokens {
  :root {
    color-scheme: light;
    --font: 'Bricolage Grotesque', 'Bricolage Fallback', 'Segoe UI', system-ui, sans-serif;

    /* Light */
    --bg: oklch(98.4% 0.006 33);
    --surface: oklch(99.6% 0.003 33);
    --surface-2: oklch(95.6% 0.012 33);
    --surface-3: oklch(92% 0.018 33);
    --ink: oklch(22% 0.03 33);
    --ink-2: oklch(40% 0.03 33);
    --ink-3: oklch(50% 0.03 33);
    --line: oklch(88% 0.016 33);
    --line-strong: oklch(78% 0.02 33);

    --accent: oklch(55% 0.2 33);          /* vermilion: buttons, links */
    --accent-hover: oklch(49% 0.19 33);
    --accent-ink: oklch(99% 0.005 33);    /* text on accent */
    --accent-soft: oklch(94% 0.04 33);
    --link: oklch(48% 0.18 33);
    --mustard: oklch(83% 0.16 85);
    --mustard-ink: oklch(25% 0.05 70);
    --teal: oklch(58% 0.1 185);
    --focus: oklch(55% 0.2 250);

    /* Marquee stage: stays dark in both themes, so the wheel always pops. */
    --stage: oklch(24% 0.06 28);
    --stage-2: oklch(29% 0.07 28);
    --stage-ink: oklch(96% 0.012 60);
    --stage-ink-2: oklch(84% 0.03 50);
    --stage-line: oklch(38% 0.06 28);

    --rim: oklch(22% 0.04 28);
    --hub: oklch(98% 0.01 60);

    --radius-s: 8px;
    --radius: 14px;
    --radius-l: 22px;

    /* Elevation: warm, low, layered. */
    --shadow-1: 0 1px 0 oklch(22% 0.03 33 / 0.05), 0 1px 3px oklch(22% 0.03 33 / 0.08);
    --shadow-2: 0 1px 0 oklch(22% 0.03 33 / 0.04), 0 6px 16px -6px oklch(22% 0.05 33 / 0.18), 0 18px 40px -20px oklch(22% 0.05 33 / 0.25);
    --shadow-wheel: 0 22px 50px -18px oklch(10% 0.05 28 / 0.7), 0 0 0 1px oklch(10% 0.03 28 / 0.4);

    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --gutter: clamp(16px, 4vw, 40px);
    --max: 1180px;
    --prose: 70ch;

    /* z-index scale */
    --z-sticky: 20;
    --z-nav: 30;
    --z-dialog: 50;
  }

  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: oklch(17% 0.014 33);
    --surface: oklch(20.5% 0.016 33);
    --surface-2: oklch(24% 0.018 33);
    --surface-3: oklch(28% 0.02 33);
    --ink: oklch(95% 0.01 60);
    --ink-2: oklch(80% 0.02 50);
    --ink-3: oklch(70% 0.02 45);
    --line: oklch(31% 0.02 33);
    --line-strong: oklch(40% 0.025 33);
    --accent: oklch(68% 0.18 36);
    --accent-hover: oklch(74% 0.16 40);
    --accent-ink: oklch(17% 0.03 33);
    --accent-soft: oklch(28% 0.06 33);
    --link: oklch(76% 0.14 45);
    --focus: oklch(78% 0.13 250);
    --stage: oklch(13.5% 0.03 28);
    --stage-2: oklch(19% 0.045 28);
    --stage-line: oklch(30% 0.05 28);
    --shadow-1: 0 1px 2px oklch(0% 0 0 / 0.4);
    --shadow-2: 0 10px 30px -12px oklch(0% 0 0 / 0.6);
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --bg: oklch(17% 0.014 33);
      --surface: oklch(20.5% 0.016 33);
      --surface-2: oklch(24% 0.018 33);
      --surface-3: oklch(28% 0.02 33);
      --ink: oklch(95% 0.01 60);
      --ink-2: oklch(80% 0.02 50);
      --ink-3: oklch(70% 0.02 45);
      --line: oklch(31% 0.02 33);
      --line-strong: oklch(40% 0.025 33);
      --accent: oklch(68% 0.18 36);
      --accent-hover: oklch(74% 0.16 40);
      --accent-ink: oklch(17% 0.03 33);
      --accent-soft: oklch(28% 0.06 33);
      --link: oklch(76% 0.14 45);
      --focus: oklch(78% 0.13 250);
      --stage: oklch(13.5% 0.03 28);
      --stage-2: oklch(19% 0.045 28);
      --stage-line: oklch(30% 0.05 28);
      --shadow-1: 0 1px 2px oklch(0% 0 0 / 0.4);
      --shadow-2: 0 10px 30px -12px oklch(0% 0 0 / 0.6);
    }
  }
}

@layer base {
  html { scroll-padding-top: 84px; }
  @media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
  body {
    font-family: var(--font);
    font-size: 1.0625rem;
    line-height: 1.62;
    background: var(--bg);
    color: var(--ink);
    font-optical-sizing: auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    text-rendering: optimizeLegibility;
  }
  main { flex: 1; }
  h1, h2, h3, h4 { line-height: 1.12; text-wrap: balance; font-weight: 750; letter-spacing: -0.015em; }
  h1 { font-size: clamp(2rem, 1.35rem + 2.6vw, 3.35rem); font-weight: 800; letter-spacing: -0.028em; font-variation-settings: 'opsz' 96; }
  h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.15rem); font-variation-settings: 'opsz' 72; }
  h3 { font-size: 1.25rem; font-variation-settings: 'opsz' 36; }
  h4 { font-size: 1.05rem; }
  p { text-wrap: pretty; }
  a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
  a:hover { text-decoration-thickness: 2px; }
  strong { font-weight: 700; }
  code, kbd { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 0.9em; }
  kbd { padding: 0.05em 0.4em; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); }
  ::selection { background: var(--mustard); color: var(--mustard-ink); }

  :focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
    border-radius: 4px;
  }
  @media (forced-colors: active) {
    :focus-visible { outline: 3px solid ButtonText; }
    .btn, .wheel-spin { border: 2px solid ButtonText; }
  }

  .skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 100;
    background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-s);
    font-weight: 700; text-decoration: none;
  }
  .skip-link:focus { top: 12px; }

  .visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
}

@layer layout {
  .container { width: min(100% - 2 * var(--gutter), var(--max)); margin-inline: auto; }
  .prose-wrap { width: min(100% - 2 * var(--gutter), 760px); margin-inline: auto; }

  /* ---------------- Header ---------------- */
  .site-header {
    position: sticky; top: 0; z-index: var(--z-nav);
    background: color-mix(in oklch, var(--stage) 96%, transparent);
    color: var(--stage-ink);
    border-bottom: 1px solid var(--stage-line);
  }
  .header-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; }
  .brand {
    display: inline-flex; align-items: center; gap: 10px;
    color: var(--stage-ink); text-decoration: none; font-weight: 800; font-size: 1.28rem; letter-spacing: -0.02em;
    font-variation-settings: 'opsz' 48; margin-right: auto; min-height: 44px;
  }
  .brand svg { width: 30px; height: 30px; flex: none; }
  .brand:hover .brand-mark { transform: rotate(40deg); }
  .brand-mark { transition: transform 0.5s var(--ease-out); transform-origin: 50% 50%; }
  .primary-nav ul { list-style: none; padding: 0; display: flex; gap: 4px; }
  .primary-nav a {
    display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 999px;
    color: var(--stage-ink-2); text-decoration: none; font-weight: 600; font-size: 0.98rem;
  }
  .primary-nav a:hover { color: var(--stage-ink); background: var(--stage-2); }
  .primary-nav a[aria-current="page"] { color: var(--stage-ink); background: var(--stage-2); box-shadow: inset 0 -2px 0 var(--mustard); }
  .header-actions { display: flex; align-items: center; gap: 4px; }
  .icon-btn {
    display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 999px;
    background: transparent; border: 0; color: var(--stage-ink-2);
  }
  .icon-btn:hover { background: var(--stage-2); color: var(--stage-ink); }
  .icon-btn svg { width: 22px; height: 22px; }
  .nav-toggle { display: none; }
  .theme-toggle .moon { display: none; }
  :root[data-theme="dark"] .theme-toggle .sun { display: none; }
  :root[data-theme="dark"] .theme-toggle .moon { display: block; }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
    :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
  }

  @media (max-width: 860px) {
    .js .nav-toggle { display: inline-grid; }
    .js .primary-nav {
      position: absolute; inset: 100% 0 auto 0; background: var(--stage); border-bottom: 1px solid var(--stage-line);
      padding: 8px var(--gutter) 16px; display: none;
    }
    .js .primary-nav.is-open { display: block; }
    .primary-nav ul { flex-direction: column; }
    .no-js .primary-nav ul, html:not(.js) .primary-nav ul { flex-direction: row; flex-wrap: wrap; }
    .primary-nav a { width: 100%; font-size: 1.08rem; }
    html:not(.js) .header-inner { flex-wrap: wrap; }
  }

  /* ---------------- Stage (hero band that holds the tool) ---------------- */
  .stage {
    background:
      radial-gradient(1200px 500px at 20% -10%, oklch(40% 0.12 30 / 0.55), transparent 60%),
      radial-gradient(900px 480px at 100% 110%, oklch(45% 0.12 70 / 0.28), transparent 60%),
      var(--stage);
    color: var(--stage-ink);
    padding-block: clamp(20px, 3.5vw, 40px) clamp(28px, 5vw, 56px);
    position: relative;
    overflow: hidden;
  }
  /* A faint marquee-dot texture, the only decoration on the page. */
  .stage::before {
    content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.35;
    background-image: radial-gradient(circle at 1px 1px, oklch(80% 0.05 60 / 0.16) 1px, transparent 1.4px);
    background-size: 22px 22px;
    mask-image: linear-gradient(to bottom, black, transparent 75%);
  }
  .stage > * { position: relative; }
  .stage a { color: var(--mustard); }
  .stage-head { margin-bottom: clamp(16px, 2.5vw, 28px); max-width: 860px; }
  .stage-head h1 { color: var(--stage-ink); }
  .lede { margin-top: 12px; font-size: clamp(1.05rem, 1rem + 0.3vw, 1.2rem); color: var(--stage-ink-2); max-width: 64ch; line-height: 1.55; }
  .stage-head--center { text-align: center; margin-inline: auto; }
  /* On tool pages the H1 shares the first screen with the wheel, so it is smaller. */
  .type-home .stage-head h1, .type-wheel .stage-head h1, .type-tool .stage-head h1 { font-size: clamp(1.85rem, 1.3rem + 1.9vw, 2.75rem); }
  .type-home .lede, .type-wheel .lede, .type-tool .lede { font-size: clamp(1rem, 0.96rem + 0.25vw, 1.12rem); max-width: 72ch; }
  .stage-head--center .lede { margin-inline: auto; }

  .breadcrumbs { font-size: 0.9rem; margin-bottom: 10px; color: var(--stage-ink-2); }
  .breadcrumbs ol { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 0; }
  .breadcrumbs li { display: inline-flex; align-items: center; }
  .breadcrumbs li + li::before { content: '/'; margin: 0 8px; opacity: 0.6; }
  .breadcrumbs a { color: var(--stage-ink-2); text-decoration: none; }
  .breadcrumbs a:hover { color: var(--stage-ink); text-decoration: underline; }
  .breadcrumbs [aria-current] { color: var(--stage-ink); }

  /* ---------------- Content sections ---------------- */
  .content { padding-block: clamp(36px, 6vw, 72px); }
  .content > * + * { margin-top: clamp(36px, 5.5vw, 64px); }
  .content > .page-meta + * { margin-top: 0; }
  .prose { max-width: var(--prose); }
  .prose > * + * { margin-top: 1em; }
  .prose h2 { margin-top: 1.9em; }
  .prose h3 { margin-top: 1.6em; }
  .prose h2 + *, .prose h3 + * { margin-top: 0.6em; }
  .prose ul, .prose ol { padding-left: 1.3em; }
  .prose li + li { margin-top: 0.35em; }
  .prose li::marker { color: var(--accent); font-weight: 700; }
  .prose blockquote {
    border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius);
    padding: 16px 20px; color: var(--ink-2);
  }
  .prose table { width: 100%; border-collapse: collapse; font-size: 0.97rem; }
  .prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
  .prose th { background: var(--surface-2); font-weight: 700; }
  .table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
  .table-scroll table th:first-child, .table-scroll table td:first-child { padding-left: 16px; }

  .page-meta { font-size: 0.92rem; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 20px; }
  .page-meta a { color: inherit; }

  .two-col { display: grid; gap: clamp(24px, 4vw, 56px); grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 960px) { .two-col { grid-template-columns: minmax(0, 1fr) 320px; } }
  .aside-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--surface); align-self: start; }
  .aside-box h2, .aside-box h3 { font-size: 1.1rem; margin-bottom: 10px; }
  .aside-box ul { list-style: none; padding: 0; }
  .aside-box li + li { margin-top: 8px; }
  @media (min-width: 960px) { .aside-box.sticky { position: sticky; top: 88px; } }

  /* ---------------- Footer ---------------- */
  .site-footer { background: var(--stage); color: var(--stage-ink-2); padding-block: 48px 28px; margin-top: auto; font-size: 0.96rem; }
  .footer-grid { display: grid; gap: 28px 32px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .footer-grid h2 { font-size: 1rem; color: var(--stage-ink); margin-bottom: 10px; letter-spacing: 0; }
  .footer-grid ul { list-style: none; padding: 0; }
  .footer-grid li + li { margin-top: 2px; }
  .footer-grid a { color: var(--stage-ink-2); text-decoration: none; display: inline-flex; min-height: 32px; align-items: center; }
  .footer-grid a:hover { color: var(--stage-ink); text-decoration: underline; }
  .footer-brand p { margin-top: 10px; max-width: 34ch; }
  .footer-bottom { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--stage-line); display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
  .footer-bottom a { color: var(--stage-ink-2); }
  .lang-list { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; padding: 0; }
}

@layer components {
  /* ---------------- Buttons ---------------- */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
    font-weight: 700; font-size: 0.98rem; text-decoration: none; white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.15s var(--ease-out);
  }
  .btn:active { transform: translateY(1px); }
  .btn svg { width: 18px; height: 18px; flex: none; }
  .btn-primary { background: var(--accent); color: var(--accent-ink); }
  .btn-primary:hover { background: var(--accent-hover); }
  .btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
  .btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-3); }
  .btn-ghost { background: transparent; color: var(--ink-2); }
  .btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
  .btn-mustard { background: var(--mustard); color: var(--mustard-ink); }
  .btn-mustard:hover { background: oklch(78% 0.16 82); }
  .btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }
  .btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
  .btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); }
  .stage .btn-ghost { color: var(--stage-ink-2); }
  .stage .btn-ghost:hover { background: var(--stage-2); color: var(--stage-ink); }
  .stage .btn-ghost[aria-pressed="true"] { background: var(--stage-2); color: var(--mustard); border-color: transparent; }
  /* Light cards inside the dark stage keep the normal ghost-button colours. */
  .stage .panel .btn-ghost, .stage .tool-card .btn-ghost { color: var(--ink-2); }
  .stage .panel .btn-ghost:hover, .stage .tool-card .btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

  /* ---------------- Form controls ---------------- */
  .field { display: grid; gap: 6px; }
  .field label, .label { font-weight: 650; font-size: 0.93rem; color: var(--ink-2); }
  .input, .select, .textarea {
    width: 100%; min-height: 44px; padding: 8px 12px; border-radius: var(--radius-s);
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .input::placeholder, .textarea::placeholder { color: var(--ink-3); }
  .input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
  .input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in oklch, var(--focus) 35%, transparent); }
  .textarea { min-height: 180px; resize: vertical; line-height: 1.5; }
  .check { display: flex; gap: 10px; align-items: flex-start; min-height: 32px; padding-block: 4px; font-size: 0.96rem; color: var(--ink-2); cursor: pointer; }
  .check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
  .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

  /* ---------------- The wheel app ---------------- */
  .wheel-app {
    display: grid; gap: clamp(20px, 3vw, 40px);
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }
  @media (min-width: 900px) {
    .wheel-app { grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr); }
  }
  .wheel-col { display: grid; justify-items: center; gap: 14px; min-width: 0; }
  .wheel-wrap { width: 100%; display: grid; justify-items: center; gap: 14px; }
  .wheel-stage {
    position: relative; width: min(100%, 540px, max(300px, calc(100svh - 280px))); aspect-ratio: 1; margin-top: 18px;
  }
  .wheel-svg {
    width: 100%; height: 100%; border-radius: 50%; box-shadow: var(--shadow-wheel);
    transform-origin: 50% 50%; will-change: transform; cursor: pointer; touch-action: manipulation;
  }
  .wheel-svg text { font-family: var(--font); font-weight: 700; pointer-events: none; font-variation-settings: 'opsz' 24; }
  .wh-rim { fill: var(--rim); }
  .wh-empty { fill: var(--stage-2); }
  .wh-sep { stroke: oklch(15% 0.03 28 / 0.28); stroke-width: 1; }
  .wh-hub { fill: var(--hub); stroke: var(--rim); stroke-width: 4; }
  .wh-bulb { fill: oklch(90% 0.12 85); }
  .wh-bulb--b { fill: oklch(96% 0.05 85); }
  @media (prefers-reduced-motion: no-preference) {
    .is-spinning .wh-bulb { animation: bulb 0.36s steps(1) infinite; }
    .is-spinning .wh-bulb--b { animation-delay: 0.18s; }
  }
  @keyframes bulb { 50% { fill: oklch(70% 0.19 40); } }

  .wheel-pointer {
    position: absolute; left: 50%; top: -18px; width: 44px; height: 56px; margin-left: -22px; z-index: 2;
    filter: drop-shadow(0 4px 4px oklch(10% 0.04 28 / 0.55)); transform-origin: 50% 12px; pointer-events: none;
  }
  .wheel-stage.flick .wheel-pointer { animation: flick 0.12s ease-out; }
  @keyframes flick { 40% { transform: rotate(-14deg); } }
  @media (prefers-reduced-motion: reduce) { .wheel-stage.flick .wheel-pointer { animation: none; } }

  .wheel-spin {
    position: absolute; left: 50%; top: 50%; translate: -50% -50%;
    width: 19%; aspect-ratio: 1; min-width: 64px; border-radius: 50%;
    border: 4px solid var(--rim); background: var(--accent); color: var(--accent-ink);
    font-weight: 800; font-size: clamp(0.9rem, 0.7rem + 0.8vw, 1.25rem); letter-spacing: 0.02em; text-transform: uppercase;
    box-shadow: 0 6px 16px -4px oklch(10% 0.05 28 / 0.6), inset 0 -3px 0 oklch(0% 0 0 / 0.15);
    transition: transform 0.15s var(--ease-out), background-color 0.15s;
    z-index: 2;
  }
  :root[data-theme="dark"] .wheel-spin { color: oklch(17% 0.03 33); }
  .wheel-spin:hover:not(:disabled) { transform: scale(1.06); background: var(--accent-hover); }
  .wheel-spin:active:not(:disabled) { transform: scale(0.97); }
  .wheel-spin:disabled { cursor: progress; font-size: 0.72rem; }
  .is-spinning .wheel-spin:disabled { opacity: 1; }
  .wheel-app:not(.is-spinning) .wheel-spin:disabled { cursor: not-allowed; opacity: 0.7; }

  .wheel-status {
    min-height: 1.6em; text-align: center; color: var(--stage-ink-2); font-size: 1.02rem; max-width: 40ch;
  }
  .wheel-status strong { color: var(--stage-ink); font-size: 1.25rem; font-weight: 800; }
  .wheel-toolbar { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }

  /* Full-screen for projectors */
  .wheel-wrap:fullscreen { background: var(--stage); padding: 4vh 4vw; align-content: center; }
  .wheel-wrap:fullscreen .wheel-stage { width: min(88vh, 92vw); }
  .wheel-wrap:fullscreen .wheel-status { font-size: 1.4rem; }
  .wheel-wrap:fullscreen .wheel-status strong { font-size: 2rem; }

  /* Editor panel */
  .panel {
    background: var(--surface); color: var(--ink); border-radius: var(--radius-l);
    box-shadow: var(--shadow-2); padding: clamp(16px, 2.2vw, 22px); min-width: 0;
    border: 1px solid var(--line);
  }
  .panel fieldset { border: 0; padding: 0; min-width: 0; display: grid; gap: 14px; }
  .panel fieldset:disabled { opacity: 0.75; }
  .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
  .panel-head h2 { font-size: 1.2rem; letter-spacing: -0.01em; }
  .count-badge:empty { display: none; }
  .count-badge {
    display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 7px; margin-left: 6px;
    border-radius: 999px; background: var(--surface-3); color: var(--ink-2); font-size: 0.82rem; font-weight: 700; vertical-align: 2px;
  }
  .add-row { display: flex; gap: 8px; }
  .add-row .input { flex: 1; min-width: 0; }
  .opt-list { list-style: none; padding: 0; display: grid; gap: 6px; max-height: 340px; overflow-y: auto; padding-right: 2px; overscroll-behavior: contain; }
  .opt { display: flex; gap: 6px; align-items: center; }
  .opt-color {
    width: 36px; height: 36px; flex: none; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; background: none; cursor: pointer;
  }
  .opt-color::-webkit-color-swatch-wrapper { padding: 3px; }
  .opt-color::-webkit-color-swatch { border: 0; border-radius: 5px; }
  .opt-color::-moz-color-swatch { border: 0; border-radius: 5px; }
  .opt-name { flex: 1; min-width: 0; min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--bg); }
  .opt-name:hover { border-color: var(--line-strong); }
  .opt-name:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in oklch, var(--focus) 35%, transparent); }
  .opt-weight { width: 70px; min-height: 40px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--bg); }
  .opt-remove {
    display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 10px;
    border: 0; background: transparent; color: var(--ink-3);
  }
  .opt-remove:hover { background: oklch(93% 0.05 30); color: oklch(45% 0.18 30); }
  :root[data-theme="dark"] .opt-remove:hover { background: oklch(30% 0.07 30); color: oklch(85% 0.1 35); }
  .panel-actions { display: flex; flex-wrap: wrap; gap: 6px; }
  .note { font-size: 0.9rem; color: var(--ink-3); }
  .note--warn { color: oklch(45% 0.15 50); }

  .disclosure { border-top: 1px solid var(--line); padding-top: 4px; }
  .disclosure > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
    min-height: 44px; font-weight: 700; font-size: 1rem;
  }
  .disclosure > summary::-webkit-details-marker { display: none; }
  .disclosure > summary::after {
    content: ''; width: 10px; height: 10px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3);
    transform: rotate(45deg) translateY(-3px); transition: transform 0.2s var(--ease-out);
  }
  .disclosure[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
  .disclosure-body { display: grid; gap: 10px; padding-bottom: 12px; }

  .history-list { list-style: none; padding: 0; display: grid; gap: 4px; max-height: 240px; overflow-y: auto; }
  .history-list li { display: flex; align-items: center; gap: 10px; font-size: 0.97rem; padding: 4px 0; }
  .history-num { color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 2.6em; font-size: 0.88rem; }
  .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px oklch(0% 0 0 / 0.15); }
  .history-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .history-empty { color: var(--ink-3); }

  .mode-box { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; }
  .mode-box h3 { font-size: 1rem; }
  .num-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .teams-out { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .team { background: var(--surface-2); border-radius: var(--radius-s); padding: 10px 12px; }
  .team h3 { font-size: 0.95rem; margin-bottom: 4px; }
  .team ul { padding-left: 1.1em; font-size: 0.95rem; }

  /* ---------------- Dialogs ---------------- */
  dialog.modal {
    margin: auto; /* the reset zeroes margins; modal dialogs centre with auto */
    overflow: visible;
    border: 0; padding: 0; border-radius: var(--radius-l); background: var(--surface); color: var(--ink);
    width: min(92vw, 460px); box-shadow: 0 30px 80px -20px oklch(0% 0 0 / 0.6);
  }
  dialog.modal--wide { width: min(94vw, 620px); max-height: calc(100dvh - 32px); overflow-y: auto; }
  dialog.modal::backdrop { background: oklch(12% 0.03 28 / 0.72); }
  @media (prefers-reduced-motion: no-preference) {
    dialog.modal[open] { animation: pop 0.32s var(--ease-out); }
    dialog.modal[open]::backdrop { animation: fade 0.25s ease-out; }
  }
  @keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
  @keyframes fade { from { opacity: 0; } }
  .modal-body { padding: clamp(22px, 4vw, 32px); display: grid; gap: 14px; position: relative; }
  .result-body { text-align: center; justify-items: center; }
  .result-kicker { color: var(--ink-2); font-weight: 600; font-size: 1rem; }
  .result-name {
    font-size: clamp(1.9rem, 1.3rem + 3vw, 3rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05;
    font-variation-settings: 'opsz' 96; max-width: 100%; overflow-wrap: anywhere;
  }
  .result-swatch { width: 56px; height: 8px; border-radius: 99px; }
  .modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
  .modal-close {
    position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border: 0; border-radius: 50%;
    background: transparent; color: var(--ink-3); display: grid; place-items: center;
  }
  .modal-close:hover { background: var(--surface-2); color: var(--ink); }
  .share-field { display: grid; gap: 6px; }
  .share-field .row { flex-wrap: nowrap; }
  .share-field .input { font-size: 0.9rem; }
  .share-field textarea { min-height: 110px; font-family: ui-monospace, Consolas, monospace; font-size: 0.82rem; }

  .confetti { position: absolute; inset: -40px 0 auto 0; height: 0; pointer-events: none; overflow: visible; }
  .confetti i {
    position: absolute; top: 0; left: var(--x); width: 9px; height: 14px; background: var(--c); border-radius: 2px;
    animation: confetti 1.9s var(--d) cubic-bezier(0.2, 0.6, 0.35, 1) forwards; opacity: 0;
  }
  .confetti i:nth-child(3n) { width: 8px; height: 8px; border-radius: 50%; }
  @keyframes confetti {
    0% { opacity: 1; transform: translate(0, 0) rotate(0); }
    100% { opacity: 0; transform: translate(var(--dx), 420px) rotate(var(--r)); }
  }

  /* ---------------- Ads: reserved space, never inside the tool ---------------- */
  .ad-slot { display: grid; place-items: center; margin-inline: auto; overflow: hidden; max-width: 100%; }
  .ad-slot--leaderboard { min-height: 90px; width: min(100%, 728px); margin-block: 24px; }
  .ad-slot--rect { min-height: 250px; width: 300px; margin-block: 24px; }
  .ad-slot--native { width: 100%; min-height: 120px; margin-block: 32px; }
  .ad-label { font-size: 0.72rem; color: var(--ink-3); text-align: center; margin-bottom: 4px; letter-spacing: 0.04em; }

  /* ---------------- FAQ ---------------- */
  .faq { max-width: var(--prose); }
  .faq h2 { margin-bottom: 16px; }
  .faq-item { border-bottom: 1px solid var(--line); }
  .faq-item:first-of-type { border-top: 1px solid var(--line); }
  .faq-item summary {
    list-style: none; cursor: pointer; padding: 16px 40px 16px 0; font-weight: 700; font-size: 1.08rem;
    position: relative; min-height: 44px;
  }
  .faq-item summary::-webkit-details-marker { display: none; }
  .faq-item summary::after {
    content: '+'; position: absolute; right: 6px; top: 50%; translate: 0 -50%; font-size: 1.5rem; font-weight: 500; color: var(--accent);
    transition: transform 0.2s var(--ease-out);
  }
  .faq-item[open] summary::after { transform: rotate(45deg); }
  .faq-item .faq-a { padding-bottom: 18px; color: var(--ink-2); max-width: 66ch; }
  .faq-item .faq-a > * + * { margin-top: 0.7em; }

  /* ---------------- Link lists (hubs, related) ---------------- */
  .chip-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
  .chip {
    display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px 0 12px; border-radius: 999px;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 650;
  }
  .chip:hover { border-color: var(--accent); background: var(--accent-soft); }
  .chip .dot { width: 14px; height: 14px; }

  .link-rows { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); column-gap: 32px; }
  .link-rows li { border-top: 1px solid var(--line); }
  .link-rows a {
    display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: baseline; padding: 14px 4px; text-decoration: none; color: var(--ink);
  }
  .link-rows a:hover .lr-title { color: var(--link); text-decoration: underline; }
  .lr-mark { width: 12px; height: 12px; border-radius: 50%; translate: 0 -1px; }
  .lr-title { font-weight: 700; font-size: 1.05rem; }
  .lr-blurb { grid-column: 2; color: var(--ink-2); font-size: 0.95rem; margin-top: 2px; }

  .cat-block + .cat-block { margin-top: clamp(32px, 5vw, 56px); }
  .cat-block > h2 { margin-bottom: 6px; }
  .cat-block > p { color: var(--ink-2); margin-bottom: 14px; max-width: 60ch; }

  /* ---------------- Steps (real sequences only) ---------------- */
  .steps { list-style: none; padding: 0; counter-reset: step; display: grid; gap: 18px; max-width: var(--prose); }
  .steps li { counter-increment: step; display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; }
  .steps li::before {
    content: counter(step); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
    background: var(--mustard); color: var(--mustard-ink); font-weight: 800; font-size: 1.1rem;
  }
  .steps h3 { font-size: 1.08rem; margin-bottom: 2px; }
  .steps p { color: var(--ink-2); }

  /* Callout for the one direct answer near the top of content pages */
  .answer {
    background: var(--surface-2); border-radius: var(--radius); padding: 18px 22px; max-width: var(--prose);
    font-size: 1.08rem; border: 1px solid var(--line);
  }
  .answer strong { color: var(--ink); }

  /* Spin-this-list band on list pages */
  .spin-cta {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
    background: var(--stage); color: var(--stage-ink); border-radius: var(--radius-l); padding: 20px 24px; margin-block: 24px;
  }
  .spin-cta p { color: var(--stage-ink-2); max-width: 52ch; }
  .spin-cta strong { color: var(--stage-ink); }

  /* Idea lists: long, scannable, two-column on wide screens */
  .idea-list { columns: 2 280px; column-gap: 40px; padding-left: 1.4em; }
  .idea-list li { break-inside: avoid; padding-block: 3px; }
}

@layer pages {
  /* Home: category index directly under the tool */
  .home-cats { display: grid; gap: 28px 40px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
  .home-cat h3 { font-size: 1.15rem; margin-bottom: 4px; }
  .home-cat p { color: var(--ink-2); font-size: 0.96rem; margin-bottom: 8px; }
  .home-cat ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
  .home-cat a { font-weight: 600; display: inline-flex; min-height: 32px; align-items: center; }

  /* Mini randomizer tools */
  .tool-card {
    background: var(--surface); color: var(--ink); border-radius: var(--radius-l); box-shadow: var(--shadow-2);
    border: 1px solid var(--line); padding: clamp(18px, 3vw, 32px); display: grid; gap: 18px; max-width: 860px; margin-inline: auto;
  }
  .tool-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
  .tool-controls .field { min-width: 120px; flex: 1 1 120px; }
  .tool-output { min-height: 150px; display: grid; place-items: center; text-align: center; gap: 10px; }
  .big-result { font-size: clamp(2.6rem, 2rem + 4vw, 5rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variation-settings: 'opsz' 96; }
  .big-result--sm { font-size: clamp(1.6rem, 1.2rem + 2vw, 2.6rem); }
  .tool-stats { text-align: center; color: var(--ink-2); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
  .tool-stats strong { color: var(--ink); margin-inline: 0.2em 0.6em; }
  .tool-history { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; list-style: none; padding: 0; }
  .tool-history li { padding: 2px 10px; border-radius: 999px; background: var(--surface-2); font-size: 0.9rem; font-variant-numeric: tabular-nums; }

  .coin { width: 150px; height: 150px; position: relative; transform-style: preserve-3d; }
  .coin-face {
    position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; backface-visibility: hidden;
    font-weight: 800; font-size: 1.1rem; letter-spacing: 0.06em; text-transform: uppercase;
    background: radial-gradient(circle at 35% 30%, oklch(92% 0.1 85), oklch(76% 0.15 80) 60%, oklch(62% 0.13 70));
    color: oklch(30% 0.07 65); box-shadow: inset 0 0 0 6px oklch(70% 0.13 75), inset 0 0 0 9px oklch(85% 0.12 85), 0 10px 24px -8px oklch(20% 0.05 60 / 0.5);
  }
  .coin-face--tails { transform: rotateY(180deg); background: radial-gradient(circle at 35% 30%, oklch(92% 0.02 250), oklch(78% 0.03 250) 60%, oklch(62% 0.03 250)); color: oklch(30% 0.03 250); box-shadow: inset 0 0 0 6px oklch(70% 0.03 250), inset 0 0 0 9px oklch(86% 0.02 250), 0 10px 24px -8px oklch(20% 0.02 250 / 0.5); }
  .coin.is-flipping { animation: coinflip 1.1s var(--ease-out); }
  @keyframes coinflip { from { transform: rotateY(var(--from, 0deg)) translateY(0); } 40% { transform: rotateY(calc(var(--to) * 0.5)) translateY(-40px); } to { transform: rotateY(var(--to)); } }
  @media (prefers-reduced-motion: reduce) { .coin.is-flipping { animation: none; } }

  .dice-row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
  .die {
    width: 76px; height: 76px; border-radius: 16px; background: var(--surface); border: 2px solid var(--ink);
    display: grid; place-items: center; font-weight: 800; font-size: 1.8rem; box-shadow: 0 4px 0 var(--ink);
  }
  .die svg { width: 62px; height: 62px; }
  .die.is-rolling { animation: roll 0.5s var(--ease-out); }
  @keyframes roll { 30% { transform: rotate(-18deg) scale(0.92); } 70% { transform: rotate(10deg) scale(1.04); } }
  @media (prefers-reduced-motion: reduce) { .die.is-rolling { animation: none; } }

  .rps-choices { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
  .rps-choices .btn { min-width: 120px; min-height: 56px; font-size: 1.05rem; }
  .ball {
    width: 190px; height: 190px; border-radius: 50%; display: grid; place-items: center;
    background: radial-gradient(circle at 35% 30%, oklch(40% 0.02 30), oklch(12% 0.01 30) 70%);
    box-shadow: 0 16px 34px -12px oklch(0% 0 0 / 0.6);
  }
  .ball-window {
    width: 104px; height: 104px; border-radius: 50%; background: radial-gradient(circle, oklch(35% 0.12 260), oklch(18% 0.08 260));
    display: grid; place-items: center; padding: 12px; text-align: center; color: oklch(92% 0.05 250);
    font-size: 0.8rem; font-weight: 700; line-height: 1.15; text-transform: uppercase;
  }
  .ball.is-shaking { animation: shake 0.6s ease-in-out; }
  @keyframes shake { 20%, 60% { transform: translateX(-10px) rotate(-6deg); } 40%, 80% { transform: translateX(10px) rotate(6deg); } }
  @media (prefers-reduced-motion: reduce) { .ball.is-shaking { animation: none; } }

  .result-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 100%; }
  .result-grid span { min-width: 56px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-weight: 800; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
  .ordered-out { text-align: left; width: 100%; max-width: 520px; padding-left: 2em; }
  .ordered-out li { padding: 4px 0; border-bottom: 1px solid var(--line); }

  /* Embed page */
  .embed-body { background: var(--stage); min-height: 100vh; padding: 16px; }
  .embed-body .wheel-app { grid-template-columns: 1fr; }
  .embed-credit { text-align: center; margin-top: 8px; font-size: 0.85rem; }
  .embed-credit a { color: var(--stage-ink-2); }

  /* Guides */
  .article-head .page-meta { color: var(--stage-ink-2); margin: 14px 0 0; }
  .article-head .page-meta a { color: var(--stage-ink-2); }
  .toc { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; background: var(--surface); }
  .toc h2 { font-size: 1rem; margin-bottom: 6px; }
  .toc ol { padding-left: 1.2em; }
  .toc li + li { margin-top: 4px; }
  .author-box { display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: start; border-top: 1px solid var(--line); padding-top: 20px; max-width: var(--prose); }
  .author-avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--mustard); color: var(--mustard-ink); display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; }
  .author-box p { color: var(--ink-2); font-size: 0.96rem; }

  .error-page { text-align: center; padding-block: 60px; }
}

@layer utilities {
  .mt-0 { margin-top: 0 !important; }
  .center { text-align: center; }
  .muted { color: var(--ink-2); }
  .stack > * + * { margin-top: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .site-header, .site-footer, .ad-slot, .wheel-toolbar, .panel { display: none !important; }
  .stage { background: none; color: #000; }
}
