/* Kings By Dawn website, new design ("Sunlit Aegean").
   site.css is loaded by every page: tokens, fonts, base, toy buttons, the chrome (header, phone tab bar, footer,
   search, image viewer, toast) and the shared page parts (page hero on the dawn scene, white sheets on the
   sea, prose, tables, chips, callouts, badges, breadcrumbs). Page styles live in home.css, wiki-article.css,
   wiki-hub.css, play.css and pages.css.
   Rules: Ink outlines, an Ink lip only under pressable things, blue (never grey or black) shadows, radius by
   hierarchy, Vollkorn SC 900 for names, Sofia Sans for labels and text, Sofia Sans Condensed for numbers,
   11 px text floor, light only (no dark theme). Mobile first. */

/* ---------- fonts (Latin subsets, SIL Open Font License; notices in assets/fonts/OFL-*.txt) ---------- */
@font-face { font-family: "Vollkorn SC"; src: url("../fonts/vollkorn-sc-black.woff2") format("woff2"); font-weight: 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Sofia Sans"; src: url("../fonts/sofia-sans.woff2") format("woff2-variations"), url("../fonts/sofia-sans.woff2") format("woff2"); font-weight: 500 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Sofia Sans Condensed"; src: url("../fonts/sofia-sans-condensed.woff2") format("woff2-variations"), url("../fonts/sofia-sans-condensed.woff2") format("woff2"); font-weight: 600 800; font-style: normal; font-display: swap; }

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --font-display: "Vollkorn SC", Georgia, "Times New Roman", serif;
  --font-label: "Sofia Sans", "Segoe UI", system-ui, Arial, sans-serif;
  --font-body: "Sofia Sans", "Segoe UI", system-ui, Arial, sans-serif;
  --font-num: "Sofia Sans Condensed", "Arial Narrow", "Segoe UI", Arial, sans-serif;

  --whitewash:#FFFFFF; --whitewash-lit:#EEF3F9; --whitewash-shade:#C6DAEE;
  --aegean:#1E5BC6; --aegean-lit:#4B86EA; --aegean-shade:#143F8F;
  --lagoon:#2FC2D0; --lagoon-lit:#7FE0E6; --lagoon-shade:#1E97A8;
  --sand:#F4D9A2; --sand-lit:#FBE9C4; --sand-shade:#D9B273; --sand-wet:#E2C084;
  --olive:#74A132; --olive-lit:#A9C95A; --olive-shade:#52782A; --olive-ink:#3F6E1A;
  --marble:#ECE4D4; --marble-lit:#FBF7EF; --marble-shade:#C3CCD8;
  --ink:#1B2A4E; --ink-2:#3A4C74; --ink-3:#5A6A8C; --ink-deep:#0F1A36;
  --gold:#FFC22E; --gold-lit:#FFE07A; --gold-shade:#D9901A; --gold-deep:#FFB619;
  --bad:#E3343A; --bad-shade:#B01F2A;
  --amethyst:#7D5BD8; --amethyst-shade:#5A3DB0; --rhodon:#C9327F; --rhodon-shade:#9A1F60;
  --sea:#2A78DD; --sea-shelf:#379FDA; --sea-shallow:#43C6D8; --grass:#8CBB44; --grass-edge:#6E9A30;
  --dawn-1:#2B2F6B; --dawn-2:#6A4C93; --dawn-3:#E8938E; --dawn-4:#FFC88A; --dawn-sun:#FFE7A8; --dawn-sea:#1B3E7A; --dawn-pill:#2A2C62;
  --paper:#FFFFFF; --paper-2:#EEF3F9; --paper-line:#C6DAEE;
  --border:var(--paper-line); --accent:var(--aegean); /* old names still used by inline styles and wiki.js markup */ --thumb-bg:#DCEBFA; --track:#D6E4F2;
  --on-head:#FFFFFF; --on-head-2:#D9E7FF;
  --role-chip:#FFF1C6; --role-chip-line:#F2D58A;
  --disabled:#DCE3EC; --disabled-edge:#8C9AB4; --on-disabled:#4E5C7C;
  --link:#1A4FB0;
  --shadow:rgba(22,46,112,.24); --shadow-card:rgba(22,46,112,.14); --highlight:rgba(255,255,255,.85);
  --r-sheet:26px; --r-panel:22px; --r-btn:14px; --r-tabs:16px; --r-card:12px; --r-thumb:12px; --r-pill:999px;
  --sh-chip:0 3px 0 var(--shadow); --sh-card:0 3px 0 var(--shadow-card);
  --sh-float:0 5px 0 rgba(22,46,112,.3), 0 14px 30px rgba(22,46,112,.26);
  --ts-title:-2px -2px 0 var(--ink),2px -2px 0 var(--ink),-2px 2px 0 var(--ink),2px 2px 0 var(--ink),0 -2px 0 var(--ink),0 2px 0 var(--ink),-2px 0 0 var(--ink),2px 0 0 var(--ink),0 4px 0 var(--ink);
  --focus:#167D8C;
  --wrap:1180px;
  --topbar-h:64px;
  --tabbar-h:0px;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 16px; }
body {
  margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-weight: 500; font-size: 16px; line-height: 1.5;
  overflow-x: hidden; padding-bottom: var(--tabbar-h);
}
/* nothing may pan the page sideways on phones (iOS Safari ignores a body-only clip): clip on the root as well.
   clip, unlike hidden, makes no scroll container, so sticky headers keep working */
@supports (overflow: clip) { html, body { overflow-x: clip; } }
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4, h5, p, ul, ol, figure, dl, dd, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
table { border-collapse: collapse; border-spacing: 0; }
strong, b { font-weight: 800; }
kbd { font-family: var(--font-num); font-weight: 700; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; padding: 1px 5px; border-radius: 6px; background: var(--paper-2); }
hr { border: 0; border-top: 1.5px dashed var(--paper-line); margin: 24px 0; }
.num { font-family: var(--font-num); font-weight: 800; font-variant-numeric: tabular-nums lining-nums; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.g { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.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; }
.wrap, .container {
  width: min(var(--wrap), calc(100% - 2 * max(16px, env(safe-area-inset-left), env(safe-area-inset-right))));
  margin-inline: auto;
}
.container--prose { --wrap: 760px; }
html:not(.js) .js-only { display: none !important; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }
main:focus { outline: none; }
::selection { background: var(--gold-lit); color: var(--ink); }

.skip {
  position: absolute; left: 16px; top: -80px; z-index: 100;
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r-btn);
  padding: 10px 16px; font: 800 16px/1.2 var(--font-label); text-decoration: none; box-shadow: 0 4px 0 var(--ink);
}
.skip:focus { top: 12px; }

/* ---------- pressables: toy buttons ---------- */
.btn {
  --_top: #FFFFFF; --_bottom: #E3EEF9; --_shade: var(--paper-line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; min-width: 52px; padding: 0 20px; margin-bottom: 4px;
  border: 3px solid var(--ink); border-radius: var(--r-btn);
  background: linear-gradient(180deg, var(--_top), var(--_bottom));
  box-shadow: inset 0 3px 0 var(--highlight), inset 0 -4px 0 var(--_shade), 0 4px 0 var(--ink);
  font: 800 18px/1.1 var(--font-label); white-space: nowrap; text-decoration: none; text-align: center;
  color: var(--aegean-shade); cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active { transform: translateY(3px); box-shadow: inset 0 3px 0 var(--highlight), inset 0 -2px 0 var(--_shade), 0 1px 0 var(--ink); }
.btn--primary { --_top: #FFE48A; --_bottom: var(--gold-deep); --_shade: rgba(217,144,26,.55); color: var(--ink); }
.btn--secondary { color: var(--aegean-shade); }
.btn--ghost { --_top: transparent; --_bottom: transparent; --_shade: transparent; border-color: transparent; box-shadow: none; margin-bottom: 0; color: var(--aegean-shade); }
.btn--ghost:active { box-shadow: none; }
.btn--block { display: flex; width: 100%; }
.btn--sm { min-height: 44px; padding: 0 14px; font-size: 16px; gap: 6px; }
.btn--lg { min-height: 58px; padding: 0 26px; font-size: 20px; }
.btn .g, .btn svg { width: 20px; height: 20px; }
.btn--sm .g { stroke-width: 2.6; }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--disabled); border-color: var(--disabled-edge); color: var(--on-disabled); box-shadow: none; transform: translateY(4px); cursor: default; }
@media (hover: hover) {
  .btn--primary:hover { --_top: #FFEDA6; }
  .btn:not(.btn--primary):not(.btn--ghost):hover { --_bottom: #D9E7F6; }
  .btn--ghost:hover { background: var(--paper-2); }
}
.actions-row { display: flex; flex-wrap: wrap; gap: 10px 12px; margin-top: 18px; }

/* a store that is not open yet: the game's disabled state (grey-blue, no lip, a lock and a reason) */
.store-soon {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 4px 18px 4px 14px; margin: 4px 0 0;
  background: var(--disabled); color: var(--on-disabled);
  border: 3px solid var(--disabled-edge); border-radius: var(--r-btn);
}
.store-soon .g { width: 22px; height: 22px; stroke-width: 2.4; }
.store-soon__txt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; line-height: 1.05; }
.store-soon__name { font: 800 17px/1.05 var(--font-label); }
.store-soon__sub { font: 800 13px/1 var(--font-num); letter-spacing: .02em; }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; margin-bottom: 3px; flex: none;
  background: var(--paper); color: var(--ink); border: 2.5px solid var(--ink); border-radius: 50%;
  box-shadow: inset 0 -3px 0 var(--paper-line), 0 3px 0 var(--ink); cursor: pointer; text-decoration: none;
}
.icon-btn .g, .icon-btn > svg { width: 22px; height: 22px; stroke-width: 2.4; }
.icon-btn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 var(--paper-line), 0 1px 0 var(--ink); }
.icon-btn[aria-pressed="true"] { background: linear-gradient(180deg, var(--gold-lit), var(--gold)); box-shadow: inset 0 -3px 0 rgba(217,144,26,.6), 0 3px 0 var(--ink); }

.round-btn {
  display: inline-grid; place-items: center; width: 48px; height: 48px; padding: 0; margin-bottom: 3px;
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 50%;
  box-shadow: inset 0 -3px 0 var(--paper-line), 0 3px 0 var(--ink); cursor: pointer;
}
.round-btn .g { stroke-width: 2.6; }
.round-btn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 var(--paper-line), 0 1px 0 var(--ink); }
.round-btn:disabled { background: var(--disabled); border-color: var(--disabled-edge); color: var(--on-disabled); box-shadow: none; transform: translateY(3px); cursor: default; }

/* ---------- header: white chrome bar with a 3px Ink edge ---------- */
.topbar { position: relative; z-index: 30; padding-top: env(safe-area-inset-top); background: var(--paper); border-bottom: 3px solid var(--ink); --focus: #167D8C; }
.topbar__row { display: flex; align-items: center; gap: 8px; min-height: var(--topbar-h); }
.brand { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand__crest {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 50%;
  box-shadow: inset 0 -3px 0 var(--paper-line), 0 3px 0 var(--ink);
}
.emblem { width: 32px; height: 27px; margin-top: -2px; }
.brand__name { font: 900 19px/1 var(--font-display); letter-spacing: .01em; white-space: nowrap; }
.topnav { display: none; }
.topbar__tools { display: flex; align-items: center; gap: 8px; }
.topbar__cta { display: none; }
@media (min-width: 480px) { .topbar__cta { display: inline-flex; } .brand__name { font-size: 21px; } }

/* ---------- phone tab bar: the game's round buttons with label pills, on a solid white strip ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 7px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  background: var(--paper); border-top: 3px solid var(--ink);
  box-shadow: 0 -4px 0 rgba(22,46,112,.12);
  --focus: #167D8C;
}
.tabbar__list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); max-width: 460px; margin: 0 auto; }
.tabbar__list > li { display: flex; justify-content: center; }
.tab-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 0; margin: 0 auto;
  width: 66px; text-decoration: none; color: var(--ink); cursor: pointer; list-style: none;
}
.tab-btn::-webkit-details-marker { display: none; }
.tab-btn__disc {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--paper); border: 3px solid var(--ink);
  box-shadow: inset 0 -4px 0 var(--paper-line), 0 3px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease;
}
.tab-btn__disc img { width: 30px; height: 30px; }
.tab-btn__disc--glyph .g { width: 24px; height: 24px; stroke-width: 2.6; }
.tab-btn__label {
  display: inline-grid; place-items: center; height: 20px; padding: 1px 9px; margin-top: 1px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 10px;
  font: 800 12px/1 var(--font-label); white-space: nowrap;
}
.tab-btn[aria-current] .tab-btn__label, .tab-more[open] > .tab-btn .tab-btn__label { background: linear-gradient(180deg, var(--gold-lit), var(--gold)); }
.tab-btn[aria-current] .tab-btn__disc { background: var(--thumb-bg); }
.tab-btn:active .tab-btn__disc { transform: translateY(3px); box-shadow: inset 0 -2px 0 var(--paper-line), 0 0 0 var(--ink); }
.tab-btn:focus-visible { outline: none; }
.tab-btn:focus-visible .tab-btn__disc { outline: 3px solid #167D8C; outline-offset: 2px; }
.tab-more > summary { list-style: none; }
.more-sheet {
  position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabbar-h) + 8px);
  max-width: 440px; margin: 0 auto; overflow: hidden;
  background: var(--paper); border: 3px solid var(--ink); border-radius: var(--r-panel); box-shadow: var(--sh-float);
  color: var(--ink);
}
.more-sheet__title { padding: 10px 14px 12px; background: var(--aegean); border-bottom: 3px solid var(--ink); color: #fff; text-shadow: var(--ts-title); font: 900 22px/1.1 var(--font-display); letter-spacing: .01em; }
.more-sheet ul { padding: 6px 12px 10px; }
.more-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 4px 0; color: var(--ink); text-decoration: none; font: 800 16px/1.2 var(--font-label); }
.more-sheet li + li .more-row { border-top: 1.5px dashed var(--paper-line); }
.more-row__glyph { display: grid; place-items: center; width: 40px; height: 40px; flex: none; background: var(--thumb-bg); border: 2px solid var(--ink); border-radius: var(--r-thumb); color: var(--aegean-shade); }
.more-row > .g { margin-left: auto; color: var(--aegean-shade); width: 20px; height: 20px; stroke-width: 2.6; }

/* ---------- footer: whitewash chrome with an Ink top edge ---------- */
.footer { background: var(--paper); color: var(--ink); border-top: 3px solid var(--ink); padding: 30px 0 22px; --focus: #167D8C; }
.footer__top { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.footer__blurb { margin-top: 12px; max-width: 34rem; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.footer__cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; }
.footer__head { color: var(--ink); font: 900 17px/1.2 var(--font-display); letter-spacing: .01em; margin-bottom: 4px; }
.footer__cols a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink-2); font: 700 15px/1.25 var(--font-label); text-decoration: none; }
@media (max-width: 899px) { .footer__cols a { min-height: 48px; } }
.footer__cols a:hover { color: var(--aegean-shade); text-decoration: underline; text-underline-offset: 3px; }
.footer__bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; margin-top: 24px; padding-top: 16px; border-top: 1.5px dashed var(--paper-line); color: var(--ink-3); font: 600 14px/1.45 var(--font-label); }
.footer__legal a { color: var(--ink-2); text-underline-offset: 3px; }

/* ---------- search (Ctrl K): the shared script's palette, as a game sheet ---------- */
.palette { position: fixed; inset: 0; z-index: 90; display: flex; justify-content: center; align-items: flex-start; padding: 64px 12px 12px; --focus: #167D8C; }
.palette__scrim { position: absolute; inset: 0; background: rgba(20,63,143,.45); }
.palette__dialog {
  position: relative; display: flex; flex-direction: column; width: min(600px, 100%); max-height: calc(100vh - 96px);
  background: var(--paper); border: 3px solid var(--ink); border-radius: var(--r-panel); box-shadow: var(--sh-float); overflow: hidden;
}
.palette__field { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--aegean); border-bottom: 3px solid var(--ink); color: #fff; }
.palette__field > .g { width: 26px; height: 26px; stroke-width: 2.6; }
.palette__field input {
  flex: 1; min-width: 0; height: 46px; padding: 0 14px; border: 2.5px solid var(--ink); border-radius: var(--r-pill);
  background: #fff; color: var(--ink); font: 700 17px/1 var(--font-label);
}
.palette__field input:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.palette__close { display: grid; place-items: center; min-width: 52px; min-height: 44px; padding: 0 8px; border: 2.5px solid var(--ink); border-radius: var(--r-btn); background: var(--paper); color: var(--ink); box-shadow: 0 3px 0 var(--ink); cursor: pointer; margin-bottom: 3px; }
.palette__close kbd { font-size: 14px; }
@media (max-width: 767px) { .palette__close { min-height: 48px; } }
.palette__results { overflow-y: auto; padding: 6px 10px 10px; overscroll-behavior: contain; }
.palette__group { padding: 12px 6px 4px; color: var(--ink-3); font: 800 12px/1.2 var(--font-label); letter-spacing: .06em; text-transform: uppercase; }
.palette__item { border-radius: 10px; cursor: pointer; }
.palette__item[aria-selected="true"] { background: var(--thumb-bg); box-shadow: inset 0 0 0 2px var(--aegean); }
.palette__row { display: flex; align-items: center; gap: 12px; padding: 8px 8px; }
.palette__row .thumb, .palette__row .glyph { width: 40px; height: 40px; flex: none; border-radius: var(--r-thumb); background: var(--paper-2); object-fit: contain; display: grid; place-items: center; color: var(--aegean-shade); }
.palette__row .glyph svg { width: 22px; height: 22px; }
.palette__row > span:nth-child(2) { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.palette__row .t { font: 800 16px/1.25 var(--font-label); color: var(--ink); }
.palette__row .d { color: var(--ink-2); font: 600 13px/1.35 var(--font-label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette__row .k { flex: none; padding: 2px 9px; border-radius: var(--r-pill); background: var(--paper-2); border: 1.5px solid var(--paper-line); color: var(--aegean-shade); font: 800 12px/1.4 var(--font-label); }
.palette__row mark { background: var(--gold-lit); color: inherit; border-radius: 3px; padding: 0 1px; }
.palette__empty { padding: 18px; color: var(--ink-2); font: 600 15px/1.45 var(--font-label); }
.palette__foot { display: none; gap: 18px; padding: 10px 14px; border-top: 1.5px dashed var(--paper-line); color: var(--ink-3); font: 600 13px/1.3 var(--font-label); }
.palette__foot kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border: 1.5px solid var(--paper-line); border-radius: 6px; background: var(--paper-2); text-align: center; font-size: 12px; color: var(--ink-2); }
@media (min-width: 768px) and (hover: hover) { .palette__foot { display: flex; } .palette { padding-top: 96px; } }

/* ---------- image viewer ---------- */
.lightbox { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 64px 12px; background: rgba(15,26,54,.86); --focus: var(--lagoon-lit); }
.lightbox figure { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: min(1100px, 100%); }
.lightbox img { max-height: calc(100vh - 170px); width: auto; border: 3px solid var(--ink); border-radius: var(--r-card); background: var(--paper); }
.lightbox figcaption { padding: 6px 14px; border-radius: var(--r-pill); background: var(--paper); color: var(--ink); border: 2px solid var(--ink); font: 700 14px/1.35 var(--font-label); text-align: center; }
.lightbox__close { position: absolute; top: 12px; right: 12px; }
.lightbox__nav { position: absolute; top: 50%; transform: translateY(-50%); }
.lightbox__nav--prev { left: 12px; }
.lightbox__nav--next { right: 12px; }

/* ---------- toast: slides from the top, white with Ink border and lip ---------- */
.toast {
  position: fixed; left: 50%; top: 14px; z-index: 99; transform: translate(-50%, -140%);
  max-width: calc(100% - 32px); padding: 10px 18px; border: 3px solid var(--ink); border-radius: var(--r-btn);
  background: var(--paper); color: var(--ink); box-shadow: 0 4px 0 var(--ink);
  font: 800 15px/1.3 var(--font-label); transition: transform .22s cubic-bezier(.3,1.4,.6,1); pointer-events: none;
}
.toast.is-visible { transform: translate(-50%, 0); }
.toast:empty { display: none; }

/* ---------- the page: dawn hero, then the sea with white sheets on it ---------- */
.page { display: block; background: var(--sea) url("../img/scene/sea-tile.svg") 0 0 / 240px 240px; padding-bottom: 40px; --focus: #FFFFFF; }
.page > .container, .page > .wrap { position: relative; }

/* the page hero (Wiki hubs, press, updates, legal pages): a band of the dawn title scene */
.codex-hero {
  position: relative; isolation: isolate; overflow: hidden;
  padding: 26px 0 30px; margin-bottom: 22px; color: var(--on-head);
  background: var(--dawn-1);
  border-bottom: 3px solid var(--ink);
  --focus: var(--lagoon-lit);
}
.codex-hero::before {
  content: ""; position: absolute; inset: 0; z-index: -2;
  background: url("../img/scene/dawn-wide.svg") 50% 58% / auto 230% no-repeat, var(--dawn-1);
}
.codex-hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(43,47,107,.55), rgba(43,47,107,.15) 55%, rgba(27,62,122,.55));
}
.codex-hero__grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; align-items: end; }
.codex-hero .eyebrow { color: var(--dawn-sun); }
.codex-hero .eyebrow::before { background: var(--gold); }
.codex-hero .display, .display {
  font: 900 clamp(34px, 7.4vw, 56px)/1.02 var(--font-display); letter-spacing: .01em; color: var(--ink); text-wrap: balance;
}
.codex-hero .display { color: #fff; text-shadow: var(--ts-title); padding: 2px 4px 6px 2px; }
.display em { font-style: normal; color: var(--gold); }
.codex-hero .display em { color: var(--gold-lit); display: block; }
.codex-hero .lead { color: #EEF0FF; max-width: 44rem; margin-top: 10px; text-shadow: 0 1px 0 rgba(15,26,54,.45); }
.codex-hero .lead strong { color: #fff; }
.codex-hero .lead + .lead { margin-top: 6px; font-size: 15px; }
.codex-hero a:not(.btn):not(.chip) { color: var(--dawn-sun); }
.codex-hero__grid > div:first-child { min-width: 0; }

.codex-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.codex-stats > div {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 10px; min-height: 52px;
  background: var(--paper); color: var(--ink); border: 2.5px solid var(--ink); border-radius: var(--r-pill); box-shadow: var(--sh-chip);
}
.codex-stats strong { flex: none; min-width: 38px; height: 34px; padding: 0 8px; display: grid; place-items: center; border-radius: var(--r-pill); background: var(--gold); border: 2px solid var(--ink); box-shadow: inset 0 -3px 0 rgba(217,144,26,.6); font: 800 20px/1 var(--font-num); font-variant-numeric: tabular-nums lining-nums; }
.codex-stats span { color: var(--ink-2); font: 700 13px/1.2 var(--font-label); }

.codex-search {
  display: flex; align-items: center; gap: 10px; width: min(100%, 34rem); min-height: 52px; margin-top: 18px; padding: 4px 6px 4px 14px;
  background: var(--paper); color: var(--ink-3); border: 3px solid var(--ink); border-radius: var(--r-pill);
  box-shadow: inset 0 -4px 0 var(--paper-line), 0 4px 0 var(--ink); cursor: pointer; text-align: left;
  font: 700 16px/1.2 var(--font-label); margin-bottom: 4px;
}
.codex-search svg { width: 22px; height: 22px; color: var(--aegean-shade); flex: none; }
.codex-search span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.codex-search kbd { display: none; padding: 3px 8px; border: 2px solid var(--paper-line); border-radius: 8px; background: var(--paper-2); color: var(--ink-2); font-size: 13px; }
@media (hover: hover) and (min-width: 768px) { .codex-search kbd { display: inline-block; } }
.codex-search:active { transform: translateY(3px); box-shadow: inset 0 -2px 0 var(--paper-line), 0 1px 0 var(--ink); }
.snapshot { display: inline-flex; align-items: flex-start; gap: 8px; margin-top: 14px; padding: 6px 12px; border-radius: 14px; background: rgba(42,44,98,.72); color: var(--on-head-2); font: 600 13px/1.4 var(--font-label); }
.snapshot svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--gold); }

/* a white sheet on the sea: the default home for page content */
.codex-section, .sheet-box {
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); border-radius: var(--r-panel); box-shadow: var(--sh-float);
  padding: 18px 16px 22px; margin-bottom: 22px; --focus: #167D8C;
}
.codex-section > h2:first-child, .codex-section__head h2, .section-title {
  font: 900 26px/1.1 var(--font-display); letter-spacing: .01em; color: var(--ink);
}

/* the sheet's Aegean header band (use as the first child of a .codex-section or .sheet-box) */
.sheet-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-height: 64px;
  margin: -18px -16px 18px; padding: 12px 14px;
  background: var(--aegean); border-bottom: 3px solid var(--ink); border-radius: 19px 19px 0 0;
}
.sheet-head h2, .sheet-head .sheet-head__title { padding: 2px 2px 4px; color: #fff; text-shadow: var(--ts-title); font: 900 26px/1.05 var(--font-display); letter-spacing: .01em; }
.sheet-head p { color: var(--on-head-2); font: 700 14px/1.3 var(--font-label); }

/* ---------- text ---------- */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 8px;
  color: var(--ink-3); font: 800 13px/1.2 var(--font-label); letter-spacing: .06em; text-transform: uppercase;
}
.eyebrow::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px rgba(255,194,46,.3); flex: none; }
.eyebrow--center, .center .eyebrow { justify-content: center; }
.center { text-align: center; }
.center .lead { margin-inline: auto; }
.lead { color: var(--ink-2); font-size: 17px; line-height: 1.55; max-width: 64ch; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.h2 { font: 900 28px/1.1 var(--font-display); letter-spacing: .01em; }
.h3 { font: 900 21px/1.15 var(--font-display); letter-spacing: .01em; }
.h2 em, .h3 em { font-style: normal; color: var(--aegean); }
.section-head { max-width: 46rem; margin-bottom: 18px; }
.text-link { display: inline-flex; align-items: center; gap: 6px; color: var(--link); font: 800 15px/1.3 var(--font-label); text-decoration: none; }
.text-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.text-link .arrow { transition: transform .12s ease; }
.text-link:hover .arrow { transform: translateX(3px); }

.prose { color: var(--ink); font-size: 16px; line-height: 1.6; }
.prose > * + *, .prose section > * + * { margin-top: 14px; }
.prose h2 {
  display: flex; align-items: baseline; gap: 8px; margin: 34px 0 10px;
  font: 900 26px/1.12 var(--font-display); letter-spacing: .01em; color: var(--ink); scroll-margin-top: 16px;
}
.prose section:first-child > h2:first-child, .prose > h2:first-child { margin-top: 0; }
.prose h3 { margin: 24px 0 6px; font: 800 19px/1.25 var(--font-label); color: var(--ink); }
.prose h4 { margin: 18px 0 4px; font: 800 16px/1.3 var(--font-label); }
.prose p, .prose li { color: var(--ink); }
.prose a { color: var(--link); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.prose a:hover { color: var(--aegean-shade); }
.prose ul, .prose ol { padding-left: 0; }
.prose ul > li, .prose ol > li { position: relative; padding-left: 26px; }
.prose ul > li + li, .prose ol > li + li { margin-top: 6px; }
.prose ul > li::before { content: ""; position: absolute; left: 6px; top: .62em; width: 9px; height: 9px; border-radius: 50%; background: var(--aegean); border: 1.5px solid var(--ink); }
.prose ol { counter-reset: li; }
.prose ol > li { counter-increment: li; }
.prose ol > li::before { content: counter(li); position: absolute; left: 0; top: .1em; min-width: 20px; height: 20px; padding: 0 4px; display: grid; place-items: center; border-radius: var(--r-pill); background: var(--gold); border: 1.5px solid var(--ink); font: 800 12px/1 var(--font-num); }
.prose strong { color: var(--ink); }
.prose blockquote { padding: 10px 14px; border-left: 4px solid var(--aegean); background: var(--paper-2); border-radius: 0 var(--r-card) var(--r-card) 0; }
.prose a.anchor { opacity: 0; font: 800 .65em/1 var(--font-num); color: var(--ink-3); text-decoration: none; transition: opacity .12s ease; }
.prose h2:hover a.anchor, .prose a.anchor:focus { opacity: 1; }
.prose p.note, p.note, .note {
  padding: 10px 14px; border-radius: var(--r-card); background: var(--paper-2); border: 2px solid var(--paper-line);
  color: var(--ink-2); font: 600 15px/1.45 var(--font-label);
}

/* ---------- callouts, badges, chips, breadcrumbs ---------- */
.callout {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 12px 14px; border: 2.5px solid var(--ink); border-radius: var(--r-card);
  background: var(--role-chip); color: var(--ink); font: 600 15px/1.5 var(--font-label); box-shadow: var(--sh-card);
}
.callout > svg { width: 24px; height: 24px; margin-top: 1px; padding: 3px; border-radius: 50%; background: var(--gold); border: 2px solid var(--ink); color: var(--ink); box-sizing: content-box; stroke-width: 2.4; }
.callout p { margin: 0; }
.callout p + p { margin-top: 6px; }
.callout strong { color: var(--ink); }
.callout a { color: var(--link); }
.callout--sea { background: #E3F4F8; }
.callout--sea > svg { background: var(--lagoon); color: #fff; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: var(--r-pill);
  background: var(--aegean); color: #fff; border: 2px solid var(--ink); font: 800 12px/1 var(--font-label); letter-spacing: .03em; white-space: nowrap;
}
.badge--soon { background: var(--role-chip); color: var(--ink); border-color: var(--role-chip-line); }
.badge--live { background: var(--olive); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; margin-bottom: 3px;
  background: var(--paper); color: var(--aegean-shade); border: 2.5px solid var(--ink); border-radius: var(--r-pill);
  box-shadow: inset 0 -3px 0 var(--paper-line), 0 3px 0 var(--ink);
  font: 800 14px/1.1 var(--font-label); white-space: nowrap; text-decoration: none; cursor: pointer;
}
a.chip:active, button.chip:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 var(--paper-line), 0 1px 0 var(--ink); }
.chip[aria-pressed="true"], .chip[aria-selected="true"], .chip.is-active, .chip[aria-current] {
  background: linear-gradient(180deg, var(--gold-lit), var(--gold)); color: var(--ink); box-shadow: inset 0 -3px 0 rgba(217,144,26,.6), 0 3px 0 var(--ink);
}
.chip .count { font: 800 12px/1 var(--font-num); color: var(--ink-3); }
.chip .dot, .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--aegean)); border: 1.5px solid var(--ink); flex: none; }
@media (hover: hover) { a.chip:hover, button.chip:hover { background: #F2F7FD; } .chip[aria-pressed="true"]:hover { background: linear-gradient(180deg, var(--gold-lit), var(--gold)); } }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin: 0 0 18px; }

.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 14px; padding: 0; color: var(--ink-3); font: 700 14px/1.3 var(--font-label); }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 6px; }
.breadcrumbs li + li::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--ink-3); border-top: 2px solid var(--ink-3); transform: rotate(45deg); margin-right: 3px; }
.breadcrumbs a { color: var(--link); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* resource amounts: icon + number (the Wiki's cost cells) */
.res { display: inline-flex; align-items: center; vertical-align: middle; gap: 4px; white-space: nowrap; font-family: var(--font-num); font-weight: 800; font-variant-numeric: tabular-nums lining-nums; }
.res img { width: 20px; height: 20px; flex: none; }
.res + .res { margin-left: 10px; }
.res-list { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; }
.res-list .res + .res { margin-left: 0; }

/* ---------- tables: white with a blue header and a sticky first column ---------- */
.table-wrap {
  position: relative; margin: 16px 0 20px; overflow: auto; /* no height limit: every row shows on the page */
  background: var(--paper); border: 3px solid var(--ink); border-radius: var(--r-card);
  scrollbar-width: thin; scrollbar-color: var(--paper-line) transparent;
}
.table-wrap:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.data-table { width: 100%; font: 600 14px/1.4 var(--font-label); font-variant-numeric: tabular-nums lining-nums; color: var(--ink); }
.data-table caption { position: sticky; left: 0; padding: 10px 14px; text-align: left; font: 800 13px/1.3 var(--font-label); letter-spacing: .04em; color: var(--ink-2); background: var(--paper-2); border-bottom: 2px solid var(--paper-line); }
.data-table th, .data-table td { padding: 9px 12px; border-bottom: 1.5px solid var(--paper-line); text-align: left; vertical-align: top; }
.data-table thead th {
  position: sticky; top: 0; z-index: 2; background: var(--aegean); color: #fff; border-bottom: 3px solid var(--ink);
  font: 800 13px/1.25 var(--font-label); letter-spacing: .02em; white-space: nowrap; vertical-align: middle;
}
.data-table tbody th { font-weight: 800; color: var(--ink); white-space: nowrap; }
.data-table td { min-width: 5.5rem; }
.data-table td.wide, .data-table th.wide { min-width: 13rem; }
.data-table tbody th, .data-table thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--paper); box-shadow: 2px 0 0 var(--paper-line); }
.data-table thead th:first-child { z-index: 3; background: var(--aegean); box-shadow: none; }
.data-table tbody tr:nth-child(2n) { background: #F6F9FD; }
.data-table tbody tr:nth-child(2n) th { background: #F6F9FD; }
.data-table tbody tr:hover, .data-table tbody tr:hover th { background: #EAF2FC; }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table .num, .data-table td.num { text-align: right; font-family: var(--font-num); font-weight: 800; }
.data-table a { color: var(--link); }
.data-table tr.is-target, .data-table tr.is-target th { background: #FFF1C6 !important; box-shadow: inset 4px 0 0 var(--gold); }
.data-table tr.is-range, .data-table tr.is-range th { background: #E3EEFB !important; }
.data-table th[aria-sort] { padding: 0; }
.data-table th[aria-sort] button { display: inline-flex; align-items: center; gap: 6px; width: 100%; min-height: 44px; padding: 9px 12px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; white-space: nowrap; cursor: pointer; }
.data-table th[aria-sort] button::after { content: "\2195"; opacity: .55; font-size: .95em; }
.data-table th[aria-sort="ascending"] button::after { content: "\2191"; opacity: 1; color: var(--gold); }
.data-table th[aria-sort="descending"] button::after { content: "\2193"; opacity: 1; color: var(--gold); }
@media (max-width: 759px) {
  /* a long row name must not fill the whole frame on a phone */
  .data-table tbody th { white-space: normal; max-width: 40vw; overflow-wrap: break-word; }
  .data-table thead th:first-child { max-width: 40vw; }
}
.is-filtered-out { display: none !important; } /* wiki.js filters */

/* ---------- on-page contents (Wiki and legal pages) ---------- */
.toc p { margin: 0 0 8px; color: var(--ink-3); font: 800 12px/1.2 var(--font-label); letter-spacing: .06em; text-transform: uppercase; }
.toc ol { display: grid; gap: 2px; }
.toc a { display: block; padding: 7px 10px; border-radius: 10px; color: var(--ink-2); font: 700 14px/1.3 var(--font-label); text-decoration: none; border-left: 3px solid transparent; }
.toc a:hover { background: var(--paper-2); color: var(--ink); }
.toc a.is-active { background: var(--thumb-bg); color: var(--ink); border-left-color: var(--aegean); }

/* ---------- small phones ---------- */
@media (max-width: 359px) {
  .brand__name { font-size: 17px; }
  .topbar__tools [data-sound-toggle] { display: none; }
  .tab-btn { width: 58px; }
}

/* ---------- phones and small tablets: room for the tab bar ---------- */
@media (max-width: 767px) {
  :root { --tabbar-h: calc(84px + env(safe-area-inset-bottom)); }
}

/* ---------- tablet ---------- */
@media (min-width: 600px) {
  .footer__cols { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .codex-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .codex-section, .sheet-box { padding: 24px 24px 28px; }
  .sheet-head { margin: -24px -24px 22px; padding: 14px 18px; }
}

/* ---------- top nav from 768px (the tab bar stays on phones) ---------- */
@media (min-width: 768px) {
  .tabbar { display: none; }
  .topnav { display: block; margin-right: 4px; }
  .topnav ul { display: flex; gap: 2px; }
  .topnav a {
    display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: var(--r-btn);
    color: var(--ink); text-decoration: none; font: 800 16px/1 var(--font-label); border: 2.5px solid transparent;
  }
  .topnav a:hover { background: var(--paper-2); }
  .topnav a[aria-current] { background: linear-gradient(180deg, var(--gold-lit), var(--gold)); border-color: var(--ink); box-shadow: inset 0 -3px 0 rgba(217,144,26,.6); }
}
@media (min-width: 768px) and (max-width: 899px) { .topbar__cta { display: none; } }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  :root { --topbar-h: 72px; }
  html { scroll-padding-top: 92px; }
  .topbar { position: sticky; top: 0; }
  .topbar__row { gap: 12px; }
  .brand__name { font-size: 24px; }
  .topnav a { padding: 0 14px; }
  .footer__top { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 40px; }
  .prose h2 { scroll-margin-top: 92px; }

  .codex-hero { padding: 44px 0 46px; margin-bottom: 34px; }
  .codex-hero::before { background-size: auto 260%; background-position: 30% 60%; }
  .codex-hero__grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 40px; }
  .codex-hero .display { font-size: 58px; }
  .codex-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .codex-section, .sheet-box { padding: 28px 30px 32px; margin-bottom: 30px; }
  .sheet-head { margin: -28px -30px 24px; padding: 14px 20px; min-height: 80px; }
  .sheet-head h2, .sheet-head .sheet-head__title { font-size: 32px; }
  .codex-section > h2:first-child, .codex-section__head h2, .section-title { font-size: 30px; }
}

/* ---------- reduced motion: nothing moves ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- print: plain white pages ---------- */
@media print {
  .topbar, .tabbar, .footer, .palette, .lightbox, .toast, .skip { display: none !important; }
  .page { background: #fff; }
  .codex-hero { color: var(--ink); background: #fff; }
  .codex-hero::before, .codex-hero::after { display: none; }
  .codex-hero .display { color: var(--ink); text-shadow: none; }
  .codex-hero .lead, .codex-hero .lead strong { color: var(--ink); text-shadow: none; }
  .codex-section, .sheet-box { box-shadow: none; }
}
