/*
  Fractalax sites theme (3 Nov, sites theme pass): the game's field journal on the web. One file for the palette,
  type and the shared pieces (header, footer, buttons, cards, focus), put at the top of the wiki's wiki.css and the
  news site's news.css by tools/site-theme.ts, so both sites read as the same family as the game
  (app/src/journal.css, app/src/kit.css): a dark leather desk with a stitched edge for the header and footer,
  parchment pages instead of white, ink and pencil, specimen-label cards and rubber-stamp buttons.

  Fonts: the game's own, self-hosted from the site (/fonts/, copied from @fontsource by the build; SIL Open Font
  Licence 1.1, licences beside them). IM Fell English for headings, Alegreya Sans for reading. Latin subset only:
  other scripts use the system font, so Japanese, Korean and Chinese pages never wait on them.

  Contrast (WCAG 2.1, checked 3 Nov): ink on paper 12.1:1, ink-soft on paper-shade 5.7:1, pencil (links) on
  paper 5.6:1 and on paper-shade 4.8:1, oxblood on paper 6.7:1; dark theme: ink 12.7:1, ink-soft 8.4:1 and gold
  links 9.3:1 on the dark page; header text 11.1:1 on the desk; ink on the gold button 9.1:1.
*/
@font-face { font-family: "IM Fell English"; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/im-fell-english-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Alegreya Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/alegreya-sans-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Alegreya Sans"; font-style: italic; font-weight: 400; font-display: swap; src: url(/fonts/alegreya-sans-latin-400-italic.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Alegreya Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/alegreya-sans-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

:root {
  color-scheme: light;
  /* The game's journal palette (app/src/journal.css). */
  --desk: #3a2a1e; --desk-deep: #271b13; --desk-ink: #f1e7cc; --desk-muted: #d9c6a0; --stitch: rgba(239, 228, 200, 0.32);
  --gold: #e7c46a; --chip: #efe4c8; --chip-ink: #2c241b;
  --paper: #efe4c8; --paper-light: #f6eedb; --paper-shade: #e2d3ae;
  --ink: #2c241b; --ink-soft: #5c4a33; --pencil: #2f5d7c; --oxblood: #8a2d22; --moss: #46621f;
  --rule: rgba(47, 93, 124, 0.13); --margin-line: rgba(138, 45, 34, 0.28); --wash: #f7e3a0;
  --serif: "IM Fell English", Georgia, "Times New Roman", serif;
  --sans: "Alegreya Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Roles (the names every page style uses). */
  --bg: var(--paper-shade); --sheet: var(--paper); --card: var(--paper-light);
  --muted: var(--ink-soft); --line: rgba(44, 36, 27, 0.26); --edge: var(--ink);
  --head: var(--paper-shade); --link: var(--pencil); --accent: var(--oxblood); --ib: var(--paper-light); --hl: var(--wash);
  --focus: var(--pencil); --lift: 2px 3px 0 rgba(44, 36, 27, 0.16);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .17 0 0 0 0 .14 0 0 0 0 .1 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* Dark: the journal at night, read on the desk itself (the game's frame colours). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --desk: #271b13; --desk-deep: #1c130d;
  --paper: #2e2118; --paper-light: #3a2a1e; --paper-shade: #241911;
  --ink: #f1e7cc; --ink-soft: #d0bc94; --pencil: #e7c46a; --oxblood: #f0a08f; --moss: #a9cf7e;
  --rule: rgba(241, 231, 204, 0.05); --margin-line: rgba(240, 160, 143, 0.22); --wash: #4a3a1c;
  --line: rgba(241, 231, 204, 0.2); --edge: rgba(241, 231, 204, 0.55); --accent: var(--gold); --lift: 2px 3px 0 rgba(0, 0, 0, 0.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --desk: #271b13; --desk-deep: #1c130d;
    --paper: #2e2118; --paper-light: #3a2a1e; --paper-shade: #241911;
    --ink: #f1e7cc; --ink-soft: #d0bc94; --pencil: #e7c46a; --oxblood: #f0a08f; --moss: #a9cf7e;
    --rule: rgba(241, 231, 204, 0.05); --margin-line: rgba(240, 160, 143, 0.22); --wash: #4a3a1c;
    --line: rgba(241, 231, 204, 0.2); --edge: rgba(241, 231, 204, 0.55); --accent: var(--gold); --lift: 2px 3px 0 rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg) var(--grain); color: var(--ink); font: 17px/1.6 var(--sans); }
a { color: var(--link); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; }
.px { image-rendering: pixelated; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: 8px; top: -80px; z-index: 10; background: var(--gold); color: var(--chip-ink); padding: 8px 14px; border-radius: 3px; font-weight: 700; }
.skip:focus { top: 8px; }

/* ---------- Header: a ledger strip on the desk, stitched along its edge ---------- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center; padding: 8px 16px 9px;
  background: var(--desk); color: var(--desk-ink); border-bottom: 2px dashed var(--stitch);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}
.top :focus-visible { outline-color: var(--gold); }
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--desk-ink); font: 400 1.3rem/1 var(--serif); white-space: nowrap; }
.brand:hover { color: #fff; }
.brand img { image-rendering: pixelated; }
/* Chips: paper tabs on the desk, like the game's resource chips and gear button. */
.chipbtn, .top .theme, .top .menu, .top .lang summary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 6px 10px;
  background: var(--chip); color: var(--chip-ink); border: 0; border-radius: 2px; font: 700 0.95rem/1 var(--sans); cursor: pointer;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35), inset 0 -2px 0 var(--chip-ink);
}
.top .theme:hover, .top .menu:hover, .top .lang summary:hover { background: #f6eedb; }
/* Rubber stamps: the game's buttons. On the desk the call to action is gold. */
.stamp, .play {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 14px;
  background: var(--ink); color: var(--paper-light); border: 1.5px solid var(--ink); border-radius: 3px;
  font: 700 0.98rem/1.1 var(--sans); letter-spacing: 0.01em; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.top .play { background: var(--gold); color: var(--chip-ink); border-color: var(--chip-ink); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35), inset 0 -2px 0 rgba(44, 36, 27, 0.55); }
.top .play:hover { background: #f0d27f; text-decoration: none; }
.stamp.ghost { background: transparent; color: var(--ink); border-color: currentColor; }
.stamp:active, .play:active { transform: translateY(1px); }

/* ---------- Footer: the desk again ---------- */
.foot {
  margin-top: 0; padding: 22px 16px 26px; background: var(--desk); color: var(--desk-ink); border-top: 2px dashed var(--stitch);
  text-align: center; font-size: 0.92rem; line-height: 1.7;
}
.foot a { color: var(--gold); }
.foot :focus-visible { outline-color: var(--gold); }
.foot .foot-mark { display: block; margin: 0 auto 8px; width: 32px; height: 32px; image-rendering: pixelated; color: var(--desk-ink); }
.foot p { margin: 4px auto; max-width: 70ch; }
.foot .studio { color: var(--desk-muted); font-family: var(--serif); font-style: italic; font-size: 1rem; }

/* ---------- Paper ---------- */
/* A journal sheet: parchment with the red margin line of the game's pages. */
.sheet { background: var(--sheet); position: relative; }
/* Specimen labels: the game's building cards and journal blocks. */
.label-card { background: var(--card); border: 0; border-radius: 0; box-shadow: inset 0 0 0 1px var(--edge), var(--lift); }
.dashed { border: 0; border-top: 1.5px dashed var(--line); }
.icon { width: 32px; height: 32px; image-rendering: pixelated; flex: none; }

/* Reading comfort: language-specific line breaking stays with each site; motion stays still when asked. */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
@media (prefers-contrast: more) { body { background-image: none; } :root { --line: var(--ink); } }
@media (forced-colors: active) { .top, .foot { border-color: CanvasText; } .chipbtn, .top .theme, .top .menu, .top .lang summary, .play, .stamp { border: 1px solid ButtonText; } }
/* The wiki's own pieces, on top of sites/shared/theme.css (3 Nov, sites theme pass). */

/* ---------- Header ---------- */
.search { position: relative; flex: 1; max-width: 620px; display: flex; gap: 6px; }
.search input, .search select {
  min-height: 44px; padding: 8px 12px; border: 0; border-radius: 2px; background: var(--chip); color: var(--chip-ink); font: inherit;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35), inset 0 -2px 0 var(--chip-ink);
}
.search input { flex: 1; min-width: 0; width: 100%; }
.search input::placeholder { color: #5c4a33; opacity: 1; }
.search select { max-width: 42%; padding: 6px 8px; font-size: 0.9rem; }
.hits {
  position: absolute; left: 0; right: 0; top: 100%; margin-top: 6px; max-height: 60vh; overflow: auto; z-index: 6;
  background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--edge), 0 10px 24px rgba(0, 0, 0, 0.3);
}
.hits a { display: block; padding: 9px 12px; text-decoration: none; color: var(--ink); border-bottom: 1px dotted var(--line); }
.hits a:hover, .hits a.on { background: var(--hl); }
.hits small { display: block; color: var(--muted); }
.hitlang { display: inline-block; font-size: 0.75rem; line-height: 1.4; padding: 0 6px; margin-left: 6px; border: 1px solid var(--edge); border-radius: 999px; color: var(--muted); vertical-align: middle; }
.top .menu { display: none; font-size: 1.15rem; }
.lang { position: relative; font-size: 0.9rem; }
.top .lang summary { list-style: none; white-space: nowrap; font-weight: 700; }
.lang summary::-webkit-details-marker { display: none; }
.lang ul {
  position: absolute; right: 0; top: 100%; margin: 6px 0 0; padding: 4px 0; list-style: none; z-index: 6; min-width: 11em;
  background: var(--card); box-shadow: inset 0 0 0 1px var(--edge), 0 10px 24px rgba(0, 0, 0, 0.3);
}
.lang li a { display: block; padding: 8px 14px; text-decoration: none; color: var(--ink); }
.lang li a:hover, .lang li a[aria-current] { background: var(--hl); }
.lang li a[aria-current] { font-weight: 700; }

/* ---------- Shell: the index (sidebar) and the journal page ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 20px; max-width: 1320px; margin: 0 auto; padding: 20px 20px 36px; }
.side { font-size: 0.97rem; padding: 4px 0; }
.navgroup + .navgroup { margin-top: 14px; padding-top: 12px; border-top: 1.5px dashed var(--line); }
.side h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font: italic 400 1.12rem/1.2 var(--serif); color: var(--ink); }
.side ul { list-style: none; margin: 0; padding: 0 0 0 40px; }
.side li { margin: 1px 0; }
.side a { display: block; padding: 3px 6px; margin-left: -6px; color: var(--ink); text-decoration: none; border-left: 3px solid transparent; }
.side a:hover { text-decoration: underline; color: var(--link); }
.side a[aria-current="page"] { font-weight: 700; border-left-color: var(--ink); background: var(--card); }
.page {
  padding: 22px 30px 40px 52px; min-height: 80vh; background-color: var(--sheet);
  background-image: linear-gradient(90deg, transparent 30px, var(--margin-line) 30px, var(--margin-line) 31px, transparent 31px);
  box-shadow: inset 0 0 0 1px var(--line), 0 3px 0 rgba(44, 36, 27, 0.18), 0 10px 26px rgba(44, 36, 27, 0.12);
}
.page h1 { font: 400 2.5rem/1.1 var(--serif); margin: 4px 0 14px; padding-bottom: 10px; border-bottom: 2px solid var(--ink); overflow-wrap: break-word; }
.page h2 { font: 400 1.65rem/1.2 var(--serif); margin: 32px 0 10px; padding-bottom: 4px; border-bottom: 1.5px dashed var(--line); clear: none; }
.page h3 { font: italic 400 1.25rem/1.25 var(--serif); margin: 22px 0 6px; }
.crumbs { font-size: 0.9rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.content > p, .content > ul, .content > ol, .content > div > p, .content > div > ul, .lead { max-width: 72ch; }
.content li { margin: 3px 0; }
.lead { font-size: 1.12rem; line-height: 1.6; }
.note { color: var(--muted); font-size: 0.93rem; }
.cols { columns: 3 180px; }

/* Home: the game's ant farm at night, at a whole-number pixel scale (×2 on phones, ×3 wider), cropped to the page. */
.hero { display: flex; justify-content: center; overflow: hidden; margin: -22px -30px 20px -52px; background: #1d1626; border-bottom: 3px solid var(--ink); }
.hero img { flex: none; display: block; width: 512px; height: 250px; max-width: none; image-rendering: pixelated; }
@media (min-width: 1100px) { .hero img { width: 768px; height: 375px; } }

/* ---------- Infobox: a pinned specimen label ---------- */
.infobox {
  float: right; clear: right; width: 300px; margin: 4px 0 18px 22px; position: relative; font-size: 0.95rem;
  background: var(--card); outline: 1px solid var(--edge); outline-offset: -5px; box-shadow: inset 0 0 0 1px var(--edge), var(--lift); padding: 10px;
}
.infobox::before { content: ""; position: absolute; top: -5px; left: 50%; width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #d9d4c8, #5a5148 70%); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); }
.ib-title { font: 400 1.3rem/1.2 var(--serif); text-align: center; padding: 6px 8px 8px; border-bottom: 1.5px solid var(--edge); }
.ib-img { text-align: center; padding: 10px; margin: 8px 0; background-color: var(--paper-shade); background-image: repeating-linear-gradient(to bottom, transparent 0 15px, var(--rule) 15px 16px); }
.ib-img img { image-rendering: pixelated; max-width: 100%; }
.ib-art { width: 128px; height: auto; }
.ib-wide { width: 100%; height: auto; }
.infobox table { width: 100%; border-collapse: collapse; }
.infobox th { text-align: left; width: 40%; padding: 5px 6px; vertical-align: top; color: var(--muted); font-weight: 700; }
.infobox td { padding: 5px 6px; }
.infobox tr + tr { border-top: 1px dotted var(--line); }

/* ---------- Tables: ledger pages ---------- */
.tablewrap { overflow-x: auto; margin: 12px 0; max-width: 100%; }
.wikitable { border-collapse: collapse; min-width: 60%; font-size: 0.95rem; background: var(--card); box-shadow: inset 0 0 0 1px var(--edge); }
.wikitable th { background: var(--paper-shade); text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--edge); white-space: nowrap; font-weight: 700; }
.wikitable td { padding: 7px 10px; border-bottom: 1px dotted var(--line); vertical-align: top; }
.wikitable tbody tr:nth-child(even) { background: color-mix(in srgb, var(--paper-shade) 35%, transparent); }
.wikitable tbody tr:hover { background: var(--hl); }
.sortable th { cursor: pointer; user-select: none; }
.sortable th::after { content: " ⇅"; color: var(--muted); font-size: 0.75em; }
.thumb img { width: 32px; height: 32px; vertical-align: middle; image-rendering: pixelated; object-fit: contain; }
.stars { color: var(--accent); letter-spacing: 1px; white-space: nowrap; }
.gallery { display: flex; flex-wrap: wrap; gap: 12px; }
.gallery figure { margin: 0; text-align: center; font-size: 0.85rem; color: var(--muted); }
.gallery img { width: 96px; height: 120px; object-fit: contain; image-rendering: pixelated; background: var(--card); box-shadow: inset 0 0 0 1px var(--edge); }

/* Contents: a pencilled margin note, like the game's "Coming next". */
.toc { display: inline-block; max-width: 100%; background: var(--card); border-left: 3px solid var(--pencil); padding: 8px 18px 10px 14px; margin: 4px 0 14px; font-size: 0.95rem; box-shadow: var(--lift); }
.toc b { font: italic 400 1.15rem var(--serif); color: var(--ink); }
.toc ol { margin: 4px 0 0; padding-left: 22px; }
.navbox { width: 100%; border-collapse: collapse; margin: 32px 0 10px; font-size: 0.92rem; clear: both; background: var(--card); box-shadow: inset 0 0 0 1px var(--edge); }
.navbox th, .navbox td { border-bottom: 1px dotted var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.navbox th { background: var(--paper-shade); white-space: nowrap; }
.navbox tr:first-child th { text-align: center; background: var(--desk); color: var(--desk-ink); font: 400 1.15rem var(--serif); border-bottom: 2px dashed var(--stitch); }
.cats { clear: both; margin-top: 24px; padding: 10px 14px; border: 1.5px dashed var(--line); font-size: 0.93rem; }
.codexfoot { font-size: 0.93rem; color: var(--muted); border-top: 1.5px dashed var(--line); padding-top: 8px; margin-top: 24px; max-width: none; }
.codexlines li { margin: 5px 0; }

/* ---------- Main page portals: specimen labels with the game's pixel icons ---------- */
.portals { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 14px; margin: 14px 0; }
.portal {
  display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 2px 12px; align-items: start; position: relative; padding: 12px 14px;
  background: var(--card); box-shadow: inset 0 0 0 1px var(--edge), var(--lift); text-decoration: none; color: var(--ink);
}
.portal .icon { grid-row: span 2; margin-top: 2px; }
.portal b { font: 400 1.2rem/1.2 var(--serif); color: var(--link); }
.portal span { font-size: 0.9rem; color: var(--muted); line-height: 1.4; }
.portal:hover b { text-decoration: underline; }
.portal:hover { box-shadow: inset 0 0 0 2px var(--edge), var(--lift); }
#results .portal { grid-template-columns: minmax(0, 1fr); }

/* ---------- Codex: entry cards by category, with tabs ---------- */
.content .cx-tabs { max-width: none; }
.cx-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 6px; padding: 0 0 10px; list-style: none; border-bottom: 1.5px solid var(--edge); }
.cx-tabs a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 12px; text-decoration: none;
  background: var(--card); color: var(--ink); border: 1.5px solid var(--edge); border-radius: 3px; font-weight: 700;
}
.cx-tabs a:hover { background: var(--hl); }
.cx-tabs a[aria-selected="true"] { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.cx-tabs .n { font-weight: 400; font-variant-numeric: tabular-nums; }
.cx-panel:focus-visible { outline-offset: 6px; }
.page .cx-panel > h2 { margin-top: 22px; }
.cx-grid { list-style: none; margin: 10px 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cx-card {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; gap: 4px; padding: 12px 10px;
  background: var(--card); box-shadow: inset 0 0 0 1px var(--edge), var(--lift);
}
.cx-card:hover { background: var(--hl); }
.cx-card:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.cx-art { width: 64px; height: 64px; image-rendering: pixelated; background: var(--paper-shade); box-shadow: inset 0 0 0 1px var(--line); }
.cx-text { min-width: 0; }
.cx-name { font: 400 1.15rem/1.2 var(--serif); color: var(--link); text-decoration: none; overflow-wrap: anywhere; }
.cx-name::after { content: ""; position: absolute; inset: 0; }
.cx-name:focus-visible { outline: none; }
.cx-card:hover .cx-name { text-decoration: underline; }
.cx-sci { display: block; font-size: 0.85rem; font-style: italic; color: var(--muted); overflow-wrap: anywhere; }
.cx-stars { display: block; font-size: 0.85rem; }
.cx-fact { margin: 2px 0 0; font-size: 0.88rem; line-height: 1.4; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (min-width: 700px) {
  .cx-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
  .cx-card { grid-template-columns: 64px minmax(0, 1fr); justify-items: start; text-align: left; align-items: center; column-gap: 12px; }
  .cx-fact { grid-column: 1 / -1; }
}
/* Without the script the tabs are links to each category; opening one shows that category alone. */
.cx:not(.js):has(.cx-panel:target) .cx-panel:not(:target) { display: none; }
.cx-panel[hidden] { display: none; }

/* ---------- Footer ---------- */
.foot .foot-mark { border-radius: 4px; }

/* ---------- Phones and narrow windows ---------- */
@media (max-width: 860px) {
  .top { flex-wrap: wrap; padding: 8px 12px 9px; gap: 8px; }
  .top .menu { display: inline-flex; }
  /* Two rows: the name, Play and the menu; then search, language and theme. */
  .top { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; grid-template-areas: "brand play play menu" "search search lang theme"; }
  .brand { grid-area: brand; min-width: 0; font-size: 1.15rem; }
  .brand span { overflow: hidden; text-overflow: ellipsis; }
  .top .play { grid-area: play; }
  .top .menu { grid-area: menu; }
  .search { grid-area: search; min-width: 0; max-width: none; }
  .top .lang { grid-area: lang; }
  .top .theme { grid-area: theme; }
  .top .lang-name { display: none; }
  .search select { max-width: 38%; }
  .shell { grid-template-columns: minmax(0, 1fr); padding: 0; gap: 0; }
  .side { display: none; padding: 12px 16px 16px; columns: 2 150px; column-gap: 20px; background: var(--paper-shade); border-bottom: 2px solid var(--edge); }
  .menu-open .side { display: block; }
  .side .navgroup { break-inside: avoid; }
  .navgroup + .navgroup { margin-top: 0; padding-top: 10px; border-top: 0; }
  .side ul { padding-left: 0; }
  .side a { margin-left: 0; }
  .page { padding: 16px 16px 32px; background-image: none; box-shadow: none; }
  .hero { margin: -16px -16px 16px; }
  .page h1 { font-size: 2rem; }
  .page h2 { font-size: 1.45rem; }
  .infobox { float: none; width: 100%; margin: 6px 0 18px; }
}
@media (max-width: 520px) { .top .play { padding: 8px 10px; font-size: 0.92rem; } }
/* The news site's own pieces, on top of the shared theme and the wiki's styles (3 Nov, sites theme pass). */
.grow { flex: 1; }
.brand .mark { width: 32px; height: 32px; flex: none; color: var(--desk-ink); }

/* Section tabs hang from the desk like the game's index tabs; the open page's tab is the paper it opens onto. */
.newsnav { background: var(--desk); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18); }
.newsnav ul { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0 auto; padding: 0 16px; max-width: 1012px; }
.newsnav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 6px 14px; margin-bottom: 8px;
  background: var(--chip); color: var(--chip-ink); text-decoration: none; font-weight: 700;
  border-radius: 0 0 6px 6px; box-shadow: inset 0 -2px 0 var(--chip-ink), 0 1px 0 rgba(0, 0, 0, 0.35);
}
.newsnav a:hover { background: #f6eedb; text-decoration: underline; }
.newsnav a[aria-current="page"] { background: var(--gold); margin-bottom: 0; padding-bottom: 14px; box-shadow: inset 0 -3px 0 var(--chip-ink); }
.newsnav :focus-visible { outline-color: var(--gold); outline-offset: 3px; }

.page.news {
  max-width: 980px; margin: 22px auto 36px; min-height: 70vh; padding: 22px 30px 36px 52px;
  background-color: var(--sheet);
  background-image: linear-gradient(90deg, transparent 30px, var(--margin-line) 30px, var(--margin-line) 31px, transparent 31px);
  box-shadow: inset 0 0 0 1px var(--line), 0 3px 0 rgba(44, 36, 27, 0.18), 0 10px 26px rgba(44, 36, 27, 0.12);
}
.page.news:focus { outline: none; }

/* Home: a masthead with the studio's ant pinned on a specimen card (fixed sand colours: the mascot is drawn for light). */
.masthead { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 22px; align-items: center; margin-bottom: 8px; }
.page.news .masthead h1 { margin-top: 0; }
.masthead .lead { margin: 0; }
.mascot {
  position: relative; width: 148px; height: 148px; padding: 10px; background: #f6eedb; transform: rotate(2deg);
  box-shadow: inset 0 0 0 1px #2c241b, 2px 3px 0 rgba(44, 36, 27, 0.25);
}
.mascot::before { content: ""; position: absolute; top: -5px; left: 50%; width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #d9d4c8, #5a5148 70%); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); }
.mascot img { display: block; width: 128px; height: 128px; image-rendering: pixelated; }

/* Cards: specimen labels. */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 14px; margin: 14px 0; }
.card { background: var(--card); box-shadow: inset 0 0 0 1px var(--edge), var(--lift); padding: 12px 16px; }
.page .card h2, .page .card h3 { font: 400 1.3rem/1.25 var(--serif); margin: 0 0 4px; border: 0; padding: 0; }
.card p { margin: 6px 0; }
.latest { margin: 10px 0 24px; }
.latest-card { position: relative; background: var(--card); outline: 1px solid var(--edge); outline-offset: -5px; box-shadow: inset 0 0 0 1px var(--edge), var(--lift); padding: 14px 18px; }
.latest-card::before { content: ""; position: absolute; top: -5px; left: 50%; width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #d9d4c8, #5a5148 70%); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); z-index: 1; }
.page .latest-card h3 { font: 400 1.6rem/1.2 var(--serif); margin: 0 0 4px; border: 0; padding: 0; font-style: normal; }
.latest-card .splash { margin: 0 0 12px; }
.latest-card ul { margin: 8px 0; padding-left: 1.2em; max-width: 72ch; }
.latest-card li { margin: 4px 0; }
.latest-links { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; font-weight: 700; }
.latest-links .stamp { color: var(--paper-light); }
.latest-links .stamp.ghost { color: var(--ink); }
.patch { margin-bottom: 28px; }
.page .patch h3 { font: italic 400 1.2rem/1.25 var(--serif); margin: 16px 0 4px; }
.patch ul { max-width: 72ch; }
.poll { background: var(--card); box-shadow: inset 0 0 0 1px var(--edge), var(--lift); padding: 12px 16px; margin: 14px 0; }
.page .poll h2 { margin-top: 4px; border-bottom: 0; }
.poll-next { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.poll-next li { background: transparent; border: 1.5px dashed var(--edge); padding: 8px 14px; }
.poll-next b, .poll-next span { display: block; }
.poll ol { list-style: none; margin: 8px 0; padding: 0; }
.poll li { margin: 10px 0; }
.poll .bar { height: 8px; border-radius: 0; background: color-mix(in srgb, var(--ink) 14%, transparent); overflow: hidden; margin-top: 4px; }
.poll .bar i { display: block; height: 100%; background: var(--pencil); }
.tag { display: inline-block; border: 1px solid var(--edge); border-radius: 999px; padding: 0 9px; font-size: 0.82rem; margin-left: 6px; vertical-align: middle; color: var(--ink); background: var(--sheet); font-weight: 700; }
.note .tag { color: var(--ink); }
.page.news .toc { display: block; }
.page.news .toc ol { columns: 2 220px; }

/* Splash banners and card thumbnails: crisp pixel art, space reserved by width/height, no sideways scroll. */
.splash { display: block; width: 100%; max-width: 100%; height: auto; aspect-ratio: 3/1; image-rendering: pixelated; box-shadow: inset 0 0 0 1px var(--edge); border: 1.5px solid var(--edge); background: var(--paper-shade); padding: 0; margin: 4px 0 14px; }
.patch .splash { margin: 32px 0 10px; }
.patch:first-of-type .splash { margin-top: 16px; }
.card .thumb { display: block; width: calc(100% + 32px); max-width: none; height: auto; aspect-ratio: 3/1; min-height: 128px; object-fit: cover; image-rendering: pixelated; margin: -12px -16px 10px; padding: 0; border: 0; border-bottom: 1.5px solid var(--edge); background: var(--paper-shade); }

@media (max-width: 760px) {
  .page.news { margin: 0; padding: 16px 16px 32px; background-image: none; box-shadow: none; }
  .newsnav ul { padding: 0 10px; gap: 4px; }
  .newsnav a { padding: 6px 10px; }
  .masthead { gap: 8px 14px; }
}
/* Phones: the ant would squeeze the title; it's decoration, so it steps aside (never shrunk off its pixel grid). */
@media (max-width: 480px) { .masthead { grid-template-columns: minmax(0, 1fr); } .mascot { display: none; } }
.foot .foot-mark svg { display: block; width: 32px; height: 32px; }
/* The beta testers' thank-you on the home page (12 Nov, L-34): Discord names as plain text that wraps, long names break anywhere. */
.testers-names { list-style: none; padding: 0; margin: 0.5em 0 0; display: flex; flex-wrap: wrap; gap: 0.25em 1.25em; }
.testers-names li { overflow-wrap: anywhere; min-width: 0; }
/* The company home page's own pieces (tools/company/build.ts), on top of the shared theme, the wiki's styles and the news site's page, masthead and card styles. */
.page.company ul.promises { padding-left: 1.2em; margin: 10px 0 14px; }
.page.company ul.promises li { margin: 6px 0; }
.page.company .links { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 6px; padding: 0; list-style: none; }
.page.company .game { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 16px; align-items: start; }
.page.company .game img { width: 72px; height: 72px; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--edge), var(--lift); }
.page.company .game h3 { margin-top: 0; }
.page.company .game p { margin: 6px 0; }
.page.company .game .links { grid-column: 1 / -1; }
.page.company .policies { display: flex; flex-wrap: wrap; gap: 4px 20px; list-style: none; padding: 0; margin: 8px 0; }
.page.company .policies a, .page.company address a { display: inline-flex; align-items: center; min-height: 44px; }
.page.company address { font-style: normal; }
.top { display: flex; flex-wrap: nowrap; }
.top .theme, .top .play { flex: none; }
.top .brand { display: inline-flex; align-items: center; min-height: 44px; }
@media (max-width: 520px) {
  .page.news.company { padding: 18px 16px 28px 28px; background-image: linear-gradient(90deg, transparent 14px, var(--margin-line) 14px, var(--margin-line) 15px, transparent 15px); margin: 12px 8px 24px; }
  .top { gap: 8px; padding: 8px 12px; }
  .play { padding: 7px 10px; }
}
@media (max-width: 380px) {
  .brand span { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .page.company .game { grid-template-columns: minmax(0, 1fr); }
}
