/* AGGROPIN design system
   1 tokens · 2 base · 3 top bar · 4 footer · 5 controls · 6 tool and text pages · 7 print
   Colors are themed on screen only. Print always uses the light values. */

/* 1 ─ Tokens ───────────────────────────────────────────── */
:root {
  /* Brand constants: identical in both themes. */
  --c-ink: #14160f;
  --c-lime: #c6f432;
  --c-cream: #fff5d9;
  --c-coral: #ff774f;
  --c-violet: #b9a2f5;
  --c-sky: #8fd0f0;
  --c-sun: #ffd76a;
  --c-mint: #7fdcb6;
  --c-pink: #f6a6c4;

  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
  --r-s: 4px;
  --r: 8px;
  --r-l: 12px;
  --gutter: clamp(16px, 4vw, 40px);
  --measure: 1180px;

  /* Light theme: warm paper, ink outlines, lime used as a sticker color. */
  color-scheme: light;
  --page: #f5f3ea;
  --surface: #fffdf6;
  --sunken: #e9e6d9;
  --fg: #14160f;
  --fg-muted: #55584a;
  --rule: #d3cfbf;
  --rule-strong: #8d8a79;
  --edge: #14160f;          /* outline of stickers, thumbnails and the wheel */
  --lip: #14160f;           /* pressed-key edge under the primary button */
  --brand: #c6f432;
  --on-brand: #14160f;
  --accent-fg: #3c5a00;     /* lime family, dark enough to read as text */
  --focus: #5a3fd4;
  --danger: #a3271b;
  --danger-bg: #fde8e1;
  --note-bg: #f3e6c4;
  --pop: 0 14px 34px #14160f29, 0 2px 6px #14160f1f;
  --tool: var(--c-lime);    /* each tool sets its own secondary color */
  --tool-wash: #e4f3b0;
}
@media screen {
  /* Dark theme: near-black board, lime carries the light. */
  :root[data-theme=dark] {
    color-scheme: dark;
    --page: #10110d;
    --surface: #1a1c16;
    --sunken: #25281f;
    --fg: #f3f1e6;
    --fg-muted: #a8aa98;
    --rule: #2f3229;
    --rule-strong: #686c5d;
    --edge: #686c5d;
    --lip: #7f9d14;
    --accent-fg: #c6f432;
    --focus: #c2aeff;
    --danger: #ffb4a3;
    --danger-bg: #43201b;
    --note-bg: #3a3320;
    --pop: 0 16px 40px #000c, 0 0 0 1px #ffffff0f;
    --tool-wash: #272e14;
  }
}

/* 2 ─ Base ─────────────────────────────────────────────── */
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: 8px; z-index: 50; transform: translateY(-200%); padding: 10px 16px; border-radius: var(--r); background: var(--c-ink); color: #fff; font: 600 .9375rem var(--font); }
.skip-link:focus { transform: none; }

@media screen {
  body.ds { margin: 0; background: var(--page); color: var(--fg); font: 400 1rem/1.5 var(--font); -webkit-text-size-adjust: 100%; }
  .ds *, .ds *::before, .ds *::after { box-sizing: border-box; }
  :where(.ds) main { width: min(100% - 2 * var(--gutter), var(--measure)); margin: 0 auto; padding: 0; }
  :where(.ds) :is(h1, h2, h3) { margin: 0; font-family: var(--font); font-weight: 800; letter-spacing: -.025em; line-height: 1.08; }
  :where(.ds) p { margin: 0; }
  :where(.ds) a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
  :where(.ds) :is(button, input, select, textarea) { font: inherit; color: inherit; }
  :focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
  .ds :focus:not(:focus-visible) { outline: none; }

  /* Small uppercase label. The marker carries the tool color: a dot for games, a square for tools. */
  .label { display: inline-flex; align-items: center; gap: .6em; margin: 0; font: 700 .6875rem/1.2 var(--font); letter-spacing: .09em; text-transform: uppercase; color: var(--fg-muted); }
  .label::before { content: ""; width: .7em; height: .7em; flex: none; border-radius: 50%; background: var(--tool); box-shadow: 0 0 0 1.5px var(--edge); }
  .label.is-tool::before { border-radius: 1.5px; background: transparent; }

  /* The pinboard: the dotted field every board, stage and hero sits on. */
  .pinfield { background-color: var(--board, var(--c-ink)); background-image: radial-gradient(var(--board-dot, #3b4030) 1.2px, transparent 1.4px); background-size: 16px 16px; }
}

/* 3 ─ Top bar ──────────────────────────────────────────── */
@media screen {
  header.top { position: relative; z-index: 20; margin: 0; padding: 0; border: 0; border-bottom: 1px solid var(--rule); background: var(--page); }
  .top .tool-nav { position: relative; display: flex; flex-wrap: nowrap; align-items: center; justify-content: flex-start; gap: 4px; width: min(100% - 2 * var(--gutter), var(--measure)); max-width: none; height: 56px; margin: 0 auto; padding: 0; font: 600 .9375rem/1.2 var(--font); letter-spacing: 0; }
  .top .brand { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin: 0 auto 0 0; padding: 0; color: var(--fg); font-size: 0; text-decoration: none; }
  .top .brand::before { content: none; }
  .brand svg { display: block; width: auto; }
  .brand .mark { height: 27px; }
  .brand .word { height: 33px; fill: none; stroke: currentColor; stroke-width: 6; }
  .brand .word .tittle { fill: var(--c-lime); stroke: var(--edge); stroke-width: 2; }
  [data-theme=dark] .brand .word .tittle { stroke: var(--c-lime); }
  [data-theme=dark] .brand .mark .pin { stroke: var(--c-lime); }

  .top details { position: static; margin: 0; padding: 0; border: 0; font: inherit; }
  .top summary { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; margin: 0; padding: 0 10px; border-radius: var(--r); color: var(--fg); font: inherit; cursor: pointer; list-style: none; user-select: none; -webkit-tap-highlight-color: transparent; }
  .top summary::-webkit-details-marker { display: none; }
  .top summary:hover, .top details[open] > summary { background: var(--sunken); }
  .top summary svg { width: 20px; height: 20px; flex: none; }
  .top .menu-panel { position: absolute; top: calc(100% + 8px); right: 0; margin: 0; padding: 8px; border: 1px solid var(--edge); border-radius: var(--r-l); background: var(--surface); color: var(--fg); box-shadow: var(--pop); }
  .directory .menu-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; width: min(476px, 100%); max-height: min(72vh, 560px); overflow-y: auto; }
  .menu-group b { display: block; padding: 12px 10px 6px; font: 700 .6875rem/1 var(--font); letter-spacing: .09em; text-transform: uppercase; color: var(--fg-muted); }
  .top .menu-group a { display: flex; align-items: center; min-height: 40px; padding: 4px 10px; border-radius: var(--r-s); color: var(--fg); font: 600 .9375rem/1.25 var(--font); text-decoration: none; }
  .top .menu-group a:hover { background: var(--sunken); }
  .top .menu-group a[aria-current] { background: var(--brand); color: var(--on-brand) !important; }

  .theme-menu summary { width: 40px; padding: 0; justify-content: center; }
  .theme-menu summary .icon-moon, [data-theme=dark] .theme-menu summary .icon-sun { display: none; }
  [data-theme=dark] .theme-menu summary .icon-moon { display: block; }
  .theme-menu .menu-panel { display: grid; gap: 2px; width: 176px; }
  .top .theme-menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; margin: 0; padding: 0 10px; border: 0; border-radius: var(--r-s); background: transparent; color: var(--fg); font: 600 .9375rem/1 var(--font); text-align: left; cursor: pointer; box-shadow: none; }
  .top .theme-menu button:hover { background: var(--sunken); }
  .top .theme-menu button svg { width: 18px; height: 18px; flex: none; }
  .top .theme-menu button[aria-pressed=true]::after { content: ""; width: 7px; height: 12px; margin: -3px 4px 0 auto; border: solid var(--accent-fg); border-width: 0 2px 2px 0; transform: rotate(45deg); }

  @media (max-width: 400px) {
    .top .tool-nav { gap: 0; }
    .brand .mark { height: 24px; }
    .brand .word { height: 29px; }
    .directory summary span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .directory summary { width: 40px; padding: 0; justify-content: center; }
    .directory .menu-panel { grid-template-columns: 1fr; }
  }
}

/* 4 ─ Footer ───────────────────────────────────────────── */
@media screen {
  footer.foot { max-width: none; margin: 72px 0 0; padding: 0; border: 0; border-top: 1px solid var(--rule); background: transparent; color: var(--fg-muted); font: 400 .875rem/1.5 var(--font); text-align: left; }
  .foot-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 32px; width: min(100% - 2 * var(--gutter), var(--measure)); margin: 0 auto; padding: 22px 0 30px; }
  .foot-in p { display: flex; align-items: center; gap: 10px; margin: 0; max-width: none; color: var(--fg-muted); }
  .foot-in p svg { width: 16px; height: 20px; flex: none; }
  .foot-in b { color: var(--fg); font-weight: 700; letter-spacing: .02em; }
  .footlinks { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 0; }
  .foot .footlinks a { display: inline-flex; align-items: center; min-height: 40px; padding: 0; color: var(--fg-muted); text-decoration: none; }
  .foot .footlinks a:hover { color: var(--fg); text-decoration: underline; }
}

/* 5 ─ Controls ─────────────────────────────────────────── */
@media screen {
  .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; margin: 0; padding: 0 16px; border: 1px solid var(--rule-strong); border-radius: var(--r); background: var(--surface); color: var(--fg); font: 600 .9375rem/1.1 var(--font); text-decoration: none; white-space: nowrap; cursor: pointer; touch-action: manipulation; transition: border-color .12s, background-color .12s, transform .08s; -webkit-tap-highlight-color: transparent; }
  .btn:hover { border-color: var(--fg); }
  .btn:active { transform: translateY(1px); }
  .btn:disabled { opacity: .42; cursor: default; transform: none; border-color: var(--rule-strong); }
  .btn svg { width: 18px; height: 18px; flex: none; }
  /* One primary action per screen. It looks like a key you can press. */
  .btn-primary { min-height: 48px; padding: 0 22px; border: 1.5px solid var(--lip); background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: 1rem; box-shadow: 0 3px 0 var(--lip); }
  .btn-primary:hover { border-color: var(--lip); background: #d4fb52; }
  .btn-primary:active { transform: translateY(3px); box-shadow: 0 0 0 var(--lip); }
  .btn-quiet { padding: 0 10px; border-color: transparent; background: transparent; color: var(--fg-muted); font-weight: 600; }
  .btn-quiet:hover { border-color: transparent; background: var(--sunken); color: var(--fg); }
  .btn-quiet:disabled { border-color: transparent; }

  .field { display: block; width: 100%; min-height: 44px; margin: 0; padding: 10px 12px; border: 1px solid var(--rule-strong); border-radius: var(--r); background: var(--surface); color: var(--fg); font: 400 1rem/1.45 var(--font); }
  .field::placeholder { color: var(--fg-muted); opacity: 1; }
  .field:focus-visible { outline-offset: 0; border-color: var(--focus); }
  .field:disabled { opacity: .6; }
  select.field { padding-right: 34px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--fg) 50%), linear-gradient(135deg, var(--fg) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
  .field-label { display: block; margin: 0 0 6px; font: 600 .875rem/1.3 var(--font); color: var(--fg); }
  .hint { display: block; margin: 6px 0 0; color: var(--fg-muted); font-size: .8125rem; line-height: 1.45; }

  /* A checkbox drawn as a switch. The input keeps its role and keyboard behavior. */
  .switch { display: flex; align-items: center; gap: 12px; min-height: 44px; margin: 0; font-weight: 600; font-size: .9375rem; cursor: pointer; }
  .switch input { appearance: none; position: relative; flex: none; width: 42px; height: 24px; margin: 0; border: 1.5px solid var(--rule-strong); border-radius: 12px; background: var(--sunken); cursor: pointer; transition: background-color .15s, border-color .15s; }
  .switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: var(--fg-muted); transition: transform .15s, background-color .15s; }
  .switch input:checked { border-color: var(--lip); background: var(--brand); }
  .switch input:checked::after { transform: translateX(18px); background: var(--c-ink); }
  .switch input:disabled { opacity: .5; }

  /* Things you only need sometimes fold away behind a plain row. */
  .fold { margin: 0; border-top: 1px solid var(--rule); }
  .fold:last-of-type { border-bottom: 1px solid var(--rule); }
  .fold > summary { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 2px; font: 650 .9375rem/1.2 var(--font); cursor: pointer; list-style: none; -webkit-tap-highlight-color: transparent; }
  .fold > summary::-webkit-details-marker { display: none; }
  .fold > summary::after { content: ""; flex: none; width: 8px; height: 8px; margin: -4px 6px 0 auto; border: solid var(--fg-muted); border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .15s; }
  .fold[open] > summary::after { margin-top: 4px; transform: rotate(-135deg); }
  .fold > summary:hover { color: var(--accent-fg); }
  .fold > summary small { font: 600 .8125rem/1 var(--font); color: var(--fg-muted); font-variant-numeric: tabular-nums; }
  .fold-body { padding: 2px 2px 20px; }
}
/* Off, not "very short": a near-zero duration still turns every style change into a transition. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

/* 6 ─ Tool and text pages ────────────────────────────────
   The heading row above every tool, and the reading text below it. */
@media screen {
  .tool-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 32px; flex-wrap: wrap; padding: 22px 0 16px; }
  .tool-head h1 { margin-top: 10px; font-size: clamp(2rem, 3.6vw, 2.75rem); letter-spacing: -.035em; }
  .tool-head > p { max-width: 34ch; color: var(--fg-muted); }
  .guide { max-width: 70ch; margin: 60px 0 0; }
  .guide h2 { margin: 28px 0 8px; font-size: 1.25rem; letter-spacing: -.015em; }
  .guide p { color: var(--fg-muted); line-height: 1.6; }
  .guide p + p { margin-top: 10px; }
  .guide a, .related a { font-weight: 600; color: var(--fg); }
  .related { margin: 17px 0 0; color: var(--fg-muted); }
  .related a { display: inline-block; padding: 11px 0; }
  .prose { padding-top: 34px; }
  .prose > * { max-width: 68ch; }
  .prose h1 { margin-bottom: 16px; font-size: clamp(2rem, 3.6vw, 2.75rem); letter-spacing: -.035em; }
  .prose h2 { margin: 28px 0 8px; font-size: 1.25rem; letter-spacing: -.015em; }
  .prose p { margin-bottom: 12px; color: var(--fg-muted); line-height: 1.6; }
  .prose a { font-weight: 600; color: var(--fg); }
  @media (max-width: 860px) {
    .tool-head { padding: 16px 0 14px; }
    .tool-head h1 { margin-top: 8px; font-size: 1.875rem; }
    .tool-head > p { max-width: none; font-size: .9375rem; }
    .guide { margin-top: 44px; }
  }
}

/* Fingers need more room than a mouse pointer: the small controls grow to 44px on touch screens. */
@media screen and (pointer: coarse) {
  .skip-link { padding: 12px 16px; }
  .top summary { min-height: 44px; }
  .theme-menu summary, .directory summary:has(span:only-of-type) { min-width: 44px; }
  .foot .footlinks a { min-width: 44px; min-height: 44px; justify-content: center; }
  .footlinks { gap: 0 10px; }
}

/* 7 ─ Print ────────────────────────────────────────────── */
@media print {
  :root { color-scheme: light; }
  body { background: #fff !important; color: #000; }
  header.top, footer.foot, .skip-link { display: none !important; }
}
