
/* Layout: a surveyor's atlas. Map plate up top, a sticky contents rail on wide screens, ledger-style tables. */
:root {
  --paper: #eef1ec; --paper-2: #e3e8e2; --ink: #1d2420; --muted: #5a665f; --rule: #c6cfc8;
  --accent: #2c6a5c; --accent-ink: #ffffff; --gold: #8f6d16; --silver: #6f7d84; --bronze: #93532a; --danger: #8c2e29;
  --display: "IM Fell English SC", "Iowan Old Style", Georgia, serif;
  --body: "Alegreya", "Iowan Old Style", Georgia, serif;
  --label: "Alegreya Sans SC", "Gill Sans", "Trebuchet MS", sans-serif;
  --sans: "Alegreya Sans", "Gill Sans", "Trebuchet MS", sans-serif;
  --measure: 66ch;
  --viz-1: #008a6e; --viz-2: #b8581a;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #121815; --paper-2: #1a221e; --ink: #dce4df; --muted: #94a39b; --rule: #2d3833;
  --accent: #6db4a1; --accent-ink: #0d1411; --gold: #d8b456; --silver: #b5c1c6; --bronze: #d08b58; --danger: #e47b71; --viz-1: #239a80; --viz-2: #c8702f; color-scheme: dark } }
:root[data-theme="dark"] {
  --paper: #121815; --paper-2: #1a221e; --ink: #dce4df; --muted: #94a39b; --rule: #2d3833;
  --accent: #6db4a1; --accent-ink: #0d1411; --gold: #d8b456; --silver: #b5c1c6; --bronze: #d08b58; --danger: #e47b71; --viz-1: #239a80; --viz-2: #c8702f; color-scheme: dark }

* { box-sizing: border-box }
body { background: var(--paper); color: var(--ink); font: 18px/1.6 var(--body); padding-inline: 16px; padding-block: 0 64px }
a { color: var(--accent) }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 400; text-wrap: balance; line-height: 1.15; margin: 0 }
h2 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
h3 { font-size: 1.45rem; margin-top: 1.6em }
h4 { font-size: 1.15rem; margin-top: 1.2em }
p { margin: 0.7em 0; max-width: var(--measure) }
.label { font: 700 0.78rem/1.2 var(--label); letter-spacing: 0.08em; text-transform: lowercase; color: var(--muted) }
.lede { font-size: 1.2rem; color: var(--ink); max-width: 60ch }
.small { font-size: 0.92rem; color: var(--muted) }
.num { font-variant-numeric: tabular-nums lining-nums }

.wrap { max-width: 1240px; margin: 0 auto }
header.top { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 32px; padding-block: 36px 18px; border-bottom: 1px solid var(--rule) }
header.top h1 { font-size: clamp(2.8rem, 8vw, 5.2rem); letter-spacing: 0.01em }
header.top .meta { display: grid; grid-template-columns: auto auto; gap: 2px 18px; font: 0.95rem/1.5 var(--sans); color: var(--muted) }
header.top .meta b { font-weight: 500; color: var(--ink) }

/* Map plate */
.plate { margin-block: 22px 8px }
.plate-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 10px }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden }
.seg button { font: 500 0.95rem var(--sans); background: transparent; color: var(--ink); border: 0; padding: 7px 16px; cursor: pointer }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink) }
.plate figure { margin: 0; position: relative; border: 1px solid var(--rule); background: var(--paper-2) }
.plate figcaption { font: 0.9rem/1.4 var(--sans); color: var(--muted); padding: 8px 2px }
.btn { font: 500 0.95rem var(--sans); border: 1px solid var(--rule); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 7px 14px; cursor: pointer }
.btn:hover { border-color: var(--accent) }

.zoombar { display: flex; flex-wrap: wrap; gap: 6px }
.zoombar .btn { min-width: 40px }
.osd { position: relative; width: 100%; aspect-ratio: 8 / 5; background: var(--paper-2); touch-action: none }
.osd > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; cursor: default }
#mapfig:fullscreen { background: var(--paper); display: flex; flex-direction: column; padding: 8px }
#mapfig:fullscreen .osd { flex: 1; aspect-ratio: auto }
#mapfig.max { position: fixed; inset: 0; z-index: 50; background: var(--paper); display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top, 0px) + 8px) 8px calc(env(safe-area-inset-bottom, 0px) + 8px) }
#mapfig.max .osd { flex: 1; aspect-ratio: auto }

/* Body grid */
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 48px; margin-top: 36px }
nav.toc { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 16px); align-self: start; font: 0.98rem/1.35 var(--sans); max-height: calc(100vh - 32px); overflow: auto }
nav.toc ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; counter-reset: toc }
nav.toc a { display: block; padding: 5px 10px; border-left: 2px solid var(--rule); color: var(--muted); text-decoration: none }
nav.toc a:hover, nav.toc a.on { color: var(--ink); border-left-color: var(--accent) }
main { min-width: 0 }
section.chapter { padding-block: 28px 20px; border-top: 1px solid var(--rule) }
section.chapter:first-child { border-top: 0; padding-top: 0 }
.chapter > .label { display: block; margin-bottom: 6px }

/* Tables */
.tbl { overflow-x: auto; margin: 14px 0 6px; border-top: 2px solid var(--ink) }
table { border-collapse: collapse; width: 100%; font: 0.95rem/1.45 var(--sans); font-variant-numeric: tabular-nums }
th { font: 700 0.76rem/1.2 var(--label); letter-spacing: 0.07em; text-transform: lowercase; color: var(--muted); text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap }
td { padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top }
td.r, th.r { text-align: right }
td b { font-weight: 500 }

/* State entries */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px }
.states { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 0 32px }
.state { padding-block: 18px; border-bottom: 1px solid var(--rule); min-width: 0 }
.state h4 { margin: 0; font-size: 1.3rem }
.state .facts { display: grid; grid-template-columns: max-content 1fr; gap: 1px 12px; font: 0.9rem/1.45 var(--sans); margin: 8px 0; color: var(--muted) }
.state .facts span:nth-child(even) { color: var(--ink) }
.state p { font-size: 1rem; margin: 0.5em 0 }
.bloc { display: inline-block; font: 700 0.72rem/1 var(--label); letter-spacing: 0.08em; text-transform: lowercase; padding: 4px 8px; border-radius: 999px; border: 1px solid currentColor; margin-top: 4px }
.bloc.compact { color: var(--accent) } .bloc.league { color: var(--bronze) } .bloc.alone { color: var(--muted) }

/* Gods */
.gods { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 32px }
.god { padding-block: 16px; border-bottom: 1px solid var(--rule); min-width: 0 }
.god h4 { margin: 0 }
.god .epithet { font-style: italic; color: var(--muted) }
.god p { font-size: 1rem; margin: 0.45em 0 }
.axis { font: 0.85rem var(--sans); color: var(--muted) }

/* Coins */
.coins { display: flex; flex-wrap: wrap; gap: 22px; margin: 18px 0 }
.coin { display: flex; align-items: center; gap: 12px; min-width: 0 }
.coin i { width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; font: 700 0.8rem var(--label); font-style: normal; color: var(--paper); flex: none }
.coin .g { background: var(--gold) } .coin .s { background: var(--silver) } .coin .b { background: var(--bronze) }
.coin div { font: 0.95rem/1.35 var(--sans) }
.coin div b { display: block; font: 600 1.05rem var(--body) }

.tool { border: 1px solid var(--rule); background: var(--paper-2); padding: 16px; margin: 18px 0; max-width: 760px }
.tool h4 { margin: 0 0 10px }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end }
.row label { display: grid; gap: 4px; font: 0.85rem var(--sans); color: var(--muted) }
input, select { font: 1rem var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: 7px 9px; min-width: 0 }
input[type="number"] { width: 120px }
.out { font: 500 1.05rem/1.5 var(--sans); margin-top: 12px; min-height: 1.5em }
.out .neg { color: var(--danger) } .out .pos { color: var(--accent) }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 14px 0; border-left: 2px solid var(--rule) }
.timeline li { position: relative; padding: 0 0 12px 22px; max-width: var(--measure) }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 0.55em; width: 10px; height: 10px; border-radius: 50%; background: var(--paper); border: 2px solid var(--accent) }
.timeline li.now::before { background: var(--danger); border-color: var(--danger) }
.timeline .yr { font: 700 0.85rem var(--label); letter-spacing: 0.05em; color: var(--muted); display: block }

.callout { border-left: 3px solid var(--accent); padding: 4px 0 4px 16px; margin: 16px 0; max-width: var(--measure) }
.callout.warn { border-left-color: var(--danger) }
.gamebook { background: var(--paper-2); border: 1px solid var(--rule); padding: 18px 22px; margin: 16px 0; max-width: 760px }
.gamebook .sec { font: 400 1.6rem var(--display); color: var(--accent); display: block; margin-top: 10px }
.gamebook .sec:first-child { margin-top: 0 }
.gamebook p { font-size: 1.02rem }
.statline { font: 500 0.9rem var(--sans); letter-spacing: 0.04em; display: block; margin: 6px 0 }

.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 36px }
.two > div { min-width: 0 }
dl.gloss { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 1rem; max-width: var(--measure) }
dl.gloss dt { font-style: italic } dl.gloss dd { margin: 0 }
pre.mermaid { background: var(--paper-2); border: 1px solid var(--rule); padding: 16px; overflow-x: auto; font-size: 0.85rem }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 8px }
  nav.toc { position: static; max-height: none }
  nav.toc ol { display: flex; flex-wrap: wrap; gap: 6px }
  nav.toc a { border: 1px solid var(--rule); border-radius: 999px; padding: 4px 12px }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth } }

/* ---- v3: cities, wonders, factions ---- */
.cities, .factions { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 0 36px }
.wonders { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 32px }
.city, .faction, .wonder { padding-block: 18px; border-bottom: 1px solid var(--rule); min-width: 0; scroll-margin-top: 16px }
.city header h3, .faction h3 { margin: 0; font-size: 1.45rem }
.wonder h4 { margin: 0; font-size: 1.2rem }
.wonder h4::before { content: "◆ "; color: var(--gold) }
.wonder.nat h4::before { content: "▲ "; color: var(--accent) }
.wonder p { font-size: 1rem; margin: 0.45em 0 }
.cmeta, .wmeta, .fmeta { display: block; font: 0.88rem/1.4 var(--sans); color: var(--muted); margin: 4px 0 6px }
dl.ddl { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 6px 12px; font-size: 0.98rem; margin: 8px 0 0 }
dl.ddl dt { font: 700 0.74rem/1.7 var(--label); letter-spacing: 0.07em; text-transform: lowercase; color: var(--muted) }
dl.ddl dd { margin: 0 }
ul.inner { list-style: none; padding: 0 0 0 14px; margin: 8px 0 0; border-left: 2px solid var(--rule); display: grid; gap: 6px; font-size: 0.98rem; max-width: var(--measure) }
table.beliefs td { font-size: 0.88rem; min-width: 8.5em }
table.beliefs td:first-child { min-width: 10em }

/* ---- v3: power charts ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 18px 0 }
.tile { border: 1px solid var(--rule); padding: 12px 14px; display: grid; gap: 4px; align-content: start; min-width: 0 }
.tile b { font: 500 1.05rem/1.3 var(--sans) }
.tile .tv { font: 500 1.5rem/1.1 var(--sans) }
.viz { margin: 28px 0 }
.viz-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 10px }
.viz-head h3 { margin: 0 }
.viz-head .filters { margin: 0 }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font: 0.88rem var(--sans); color: var(--muted); margin: 10px 0 }
.legend span { display: inline-flex; align-items: center; gap: 6px }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none }
.sw.s1 { background: var(--viz-1) } .sw.s2 { background: var(--viz-2) }
.bars { display: grid }
.bar-row { display: grid; grid-template-columns: minmax(110px, 15em) minmax(0, 1fr); align-items: center; min-height: 26px; gap: 10px; border-radius: 4px }
.bar-row:hover, .bar-row:focus-visible { background: color-mix(in srgb, var(--ink) 6%, transparent) }
.bar-name { font: 0.9rem/1.2 var(--sans); text-align: right; overflow-wrap: anywhere }
.bar-track { position: relative; height: 26px; margin-right: 5.5em;
  background: repeating-linear-gradient(to right, var(--rule) 0 1px, transparent 1px calc(100% / 7)) }
.bar { position: absolute; left: 0; top: 8px; height: 10px; border-radius: 0 4px 4px 0 }
.bar.s1 { background: var(--viz-1) } .bar.s2 { background: var(--viz-2) }
.bar-val { position: absolute; top: 4px; margin-left: 6px; font: 500 0.85rem var(--sans); color: var(--ink); white-space: nowrap; opacity: 0; transition: opacity 0.15s }
.bar-row:hover .bar-val, .bar-row:focus .bar-val, .bar-val.on { opacity: 1 }
.bar-note { color: var(--muted); font-weight: 400 }
.axis-row { min-height: 20px }
.axis-row:hover { background: none }
.axis-track { position: relative; height: 18px; margin-right: 5.5em }
.axis-track span { position: absolute; transform: translateX(-50%); font: 0.75rem var(--sans); color: var(--muted); font-variant-numeric: tabular-nums }
.cmp { display: grid; gap: 4px; max-width: 760px }
.cmp-row { display: grid; grid-template-columns: 7em minmax(0, 1fr); gap: 10px; align-items: center; padding-block: 3px }
.cmp-row .bar-name { text-align: left }
.cmp-pair { display: grid; gap: 2px; margin-right: 3em }
.cmp-line { position: relative; height: 14px }
.cmp-line .bar { top: 2px }
.cmp-v { position: absolute; top: -2px; margin-left: 6px; font: 0.8rem var(--sans); color: var(--ink); font-variant-numeric: tabular-nums }
.viz-tip { position: fixed; z-index: 60; background: var(--paper); color: var(--ink); border: 1px solid var(--rule); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); padding: 10px 12px; font: 0.85rem/1.4 var(--sans); pointer-events: none; max-width: 260px }
.viz-tip b { display: block; font-weight: 600 }
.viz-tip dl { display: grid; grid-template-columns: auto auto; gap: 0 14px; margin: 6px 0 0 }
.viz-tip dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums }
table.heat td.hc { background: color-mix(in srgb, var(--viz-1) var(--h), transparent) }

/* ---- v3: grouped contents ---- */
nav.toc li.part { font: 700 0.72rem/1 var(--label); letter-spacing: 0.08em; text-transform: lowercase; color: var(--muted); padding: 14px 10px 4px }
nav.toc li.part:first-child { padding-top: 4px }

/* ---- v3: map layers ---- */
.layers { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px }
.chip { font: 500 0.88rem var(--sans); border: 1px solid var(--rule); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 5px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--paper-2) }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none }
.chip[disabled] { opacity: 0.5; cursor: default }
.chip i { box-shadow: 0 0 0 1px var(--muted) }
.ov-off { visibility: hidden !important; pointer-events: none !important }
.pin { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font: 700 11px/1 var(--sans); color: #fff; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45); cursor: pointer; padding: 0; position: relative }
.pin:focus-visible { outline: 3px solid #111; outline-offset: 2px }
.pin.k-wonder { background: #8f6d16 } .pin.k-natural { background: #2c6a5c } .pin.k-dragon { background: #8c2e29 }
.pin.k-hold { background: #5d6870 } .pin.k-city { background: #1d2420; width: 14px; height: 14px; font-size: 0 }
.pin .pl { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 3px; white-space: nowrap; font: 600 11px/1.2 var(--sans); color: #1d2420;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; pointer-events: none; display: none }
.osd.zoomed .pin .pl { display: block }
.mappanel { position: absolute; left: 10px; bottom: 10px; z-index: 5; max-width: min(360px, calc(100% - 20px)); background: var(--paper); color: var(--ink); border: 1px solid var(--rule); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); padding: 12px 14px; font: 0.92rem/1.45 var(--sans) }
.mappanel h4 { font-size: 1.15rem; margin: 2px 0 4px }
.mappanel .x { position: absolute; top: 6px; right: 8px; border: 0; background: none; color: var(--muted); font: 1.1rem var(--sans); cursor: pointer; padding: 2px 6px }
.mapwrap { position: relative }
#mapfig { position: relative }
.hl-label { font: 600 12px/1.2 var(--sans); color: #1d2420; background: rgba(255, 255, 255, 0.85); border: 1px solid var(--c); border-left-width: 4px; border-radius: 3px; padding: 2px 6px; cursor: pointer; white-space: nowrap }
.elder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 10px; margin: 14px 0 }
.glyph { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border: 1px solid var(--rule); font: 0.78rem/1.25 var(--sans); text-align: center; color: var(--muted); min-width: 0 }
.glyph svg { width: 42px; height: 42px; color: var(--ink) }
.glyph b { font: 600 0.95rem var(--sans); color: var(--ink) }
.glyph .conf { font-size: 0.7rem; letter-spacing: 0.04em }
.insc { margin: 10px 0; min-width: 0 }
.insc > div { color: var(--ink); overflow-x: auto }
.insc svg { max-width: 100%; height: auto }
.insc figcaption { font: 0.9rem/1.45 var(--sans); color: var(--muted); margin-top: 6px }
.tb textarea { width: 100%; font: 1.05rem/1.4 var(--body); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: 8px 10px; resize: vertical }
.tb-ex { margin: 10px 0 }
.tb-ex .chip { font-size: 0.8rem }
.tb-out { font: italic 1.45rem/1.35 var(--body); margin-top: 12px; min-height: 1.4em; overflow-wrap: anywhere }
.interlinear { font: 0.85rem/1.5 var(--sans); color: var(--muted); margin-top: 6px; overflow-x: auto; white-space: nowrap }
.il-seg { color: var(--ink) }
/* lore:begin */
details.lore { margin: 12px 0 4px; border-top: 1px dashed var(--rule); padding-top: 6px }
details.lore > summary { cursor: pointer; font: 700 0.8rem/1.8 var(--label); letter-spacing: 0.07em; text-transform: lowercase; color: var(--accent); list-style-position: outside }
details.lore > summary b { font: 400 1.05rem/1.4 var(--display); letter-spacing: 0; text-transform: none; color: var(--ink) }
details.lore[open] > summary { margin-bottom: 4px }
.lore-dl { grid-template-columns: 7.5em minmax(0, 1fr); font-size: 0.95rem }
.verse { font-style: italic; line-height: 1.55; margin: 6px 0 8px }
.lore-hook { font-size: 0.95rem; border-left: 3px solid var(--gold); padding-left: 12px; margin: 10px 0 4px }
@media (max-width: 560px) { .lore-dl { grid-template-columns: minmax(0, 1fr) } .lore-dl dd { margin-bottom: 6px } }
/* lore:end */
/* ================= Website chrome =================
   Layout: an atlas in ink. A quiet header with five grouped menus, section tabs over each page, a frontispiece plate
   in each hero, a sticky contents rail on long pages, and every ink plate shown in a paper mount (the mount stays
   paper-coloured in the dark theme, like a plate tipped into a book). Colours come from the guide's tokens above. */
:root {
  --head-h: 60px; --wide: 1280px;
  --plate-bg: #ffffff; --plate-rule: #c4cdc6; --plate-cap: #4a524d;
  --plate-shadow: 0 1px 2px rgba(29, 36, 32, 0.07), 0 10px 24px -16px rgba(29, 36, 32, 0.35);
  --panel-shadow: 0 22px 44px -18px rgba(16, 22, 19, 0.35), 0 2px 6px rgba(16, 22, 19, 0.08);
  --scrim: rgba(18, 24, 21, 0.42);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --plate-bg: #e3e7e1; --plate-rule: #39443e;
  --plate-shadow: 0 12px 28px -16px rgba(0, 0, 0, 0.8); --panel-shadow: 0 24px 48px -16px rgba(0, 0, 0, 0.7); --scrim: rgba(4, 7, 6, 0.66) } }
:root[data-theme="dark"] {
  --plate-bg: #e3e7e1; --plate-rule: #39443e;
  --plate-shadow: 0 12px 28px -16px rgba(0, 0, 0, 0.8); --panel-shadow: 0 24px 48px -16px rgba(0, 0, 0, 0.7); --scrim: rgba(4, 7, 6, 0.66) }

body { padding: 0 }
.skip { position: absolute; left: -999px; top: 0; z-index: 99; background: var(--paper); color: var(--ink); padding: 8px 12px }
.skip:focus { left: 8px; top: 8px }
[id] { scroll-margin-top: calc(var(--head-h) + 20px) }
section.chapter { scroll-margin-top: calc(var(--head-h) + 20px) }
kbd { font: 500 0.72rem/1 var(--sans); color: var(--muted); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; background: var(--paper) }

/* ---------- Ink plates in their mounts ---------- */
.mount, .city-plate, .plate-main, .plate-strip figure { background: var(--plate-bg); border: 1px solid var(--plate-rule); box-shadow: var(--plate-shadow) }
.mount { margin: 0; padding: 6px }
.mount img, .city-plate img, .plate-main img, .plate-strip img, .thumb img { mix-blend-mode: multiply; background: transparent }
.mount img { display: block; width: 100%; height: auto }
.mount figcaption { font: 0.84rem/1.35 var(--sans); color: var(--plate-cap); padding: 6px 4px 1px; text-align: center }
.mount figcaption a { color: inherit }

/* ---------- Header ---------- */
.site-head { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40; background: color-mix(in srgb, var(--paper) 94%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule) }
.head-bar { max-width: var(--wide); margin: 0 auto; padding: 0 16px; height: var(--head-h); display: flex; align-items: stretch; gap: 26px }
.brand { font: 400 1.6rem/1 var(--display); color: var(--ink); text-decoration: none; white-space: nowrap; align-self: center; letter-spacing: 0.01em }
.gnav { display: flex; align-items: stretch; gap: 2px }
.grp { position: relative; display: flex; align-items: center }
.g-btn { font: 500 1rem/1 var(--sans); color: var(--ink); background: none; border: 0; border-radius: 6px; padding: 9px 10px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px }
.g-btn:hover, .grp.open .g-btn { background: var(--paper-2) }
.chev { width: 11px; height: 11px; color: var(--muted); transition: transform 0.15s }
.grp.open .chev { transform: rotate(180deg) }
.grp.here::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--ink) }
.g-panel { display: none; position: absolute; top: calc(100% + 1px); left: -6px; width: 350px; z-index: 50; background: var(--paper);
  border: 1px solid var(--rule); border-top: 2px solid var(--ink); box-shadow: var(--panel-shadow); padding: 8px }
.grp.open .g-panel { display: grid; gap: 2px }
.g-panel a, .mnav a { display: grid; gap: 3px; padding: 10px 12px; border-radius: 6px; text-decoration: none; color: var(--ink) }
.g-panel b, .mnav b { font: 400 1.16rem/1.15 var(--display) }
.g-panel span, .mnav span { font: 0.88rem/1.35 var(--sans); color: var(--muted) }
.g-panel a:hover, .g-panel a:focus-visible, .mnav a:hover { background: var(--paper-2) }
.g-panel a[aria-current="page"] b, .mnav a[aria-current="page"] b { color: var(--accent) }
.g-panel a[aria-current="page"] b::after, .mnav a[aria-current="page"] b::after { content: " · you are here"; font: 500 0.78rem var(--sans); color: var(--muted) }

.head-tools { margin-left: auto; display: flex; align-items: center; gap: 8px }
.hbtn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--paper); color: var(--ink); font: 500 0.95rem var(--sans); cursor: pointer }
.hbtn:hover { border-color: var(--ink) }
.hbtn svg { width: 17px; height: 17px; flex: none }
.search-btn { color: var(--muted); padding-right: 6px; min-width: 150px }
.search-btn span { margin-right: auto }
.theme-btn { width: 36px; padding: 0; justify-content: center }
.atlas-btn { height: 36px; padding: 0 16px }
.menu-btn { display: none }
.mnav { display: none }

@media (max-width: 1180px) {
  .head-bar { gap: 16px }
  .search-btn { min-width: 0; width: 36px; padding: 0; justify-content: center }
  .search-btn span, .search-btn kbd { display: none }
}
@media (max-width: 1000px) {
  .gnav { display: none }
  .menu-btn { display: inline-flex }
  .mnav { position: absolute; left: 0; right: 0; top: 100%; z-index: 45; background: var(--paper); border-bottom: 1px solid var(--rule); box-shadow: var(--panel-shadow);
    max-height: calc(100dvh - var(--head-h) - env(safe-area-inset-top, 0px)); overflow: auto; padding: 12px 16px 20px;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 14px 28px }
  .mnav.open { display: grid }
  .m-group { display: grid; align-content: start; gap: 1px; min-width: 0 }
  .m-group .label { margin: 0 0 4px; padding: 0 12px; display: block; border-bottom: 1px solid var(--rule); padding-bottom: 6px }
  .m-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 22px; border-top: 1px solid var(--rule); padding-top: 12px }
  .m-foot a { display: inline; padding: 0; font: 500 0.95rem var(--sans); color: var(--accent) }
}
@media (max-width: 460px) {
  .brand { font-size: 1.35rem }
  .head-tools { gap: 6px }
  .menu-btn { width: 36px; padding: 0; justify-content: center }
  .menu-btn span { display: none }
  .atlas-btn { padding: 0 12px }
}

/* ---------- Section tabs and page heroes ---------- */
.tabs { max-width: var(--wide); margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 4px 22px; border-bottom: 1px solid var(--rule);
  overflow-x: auto; scrollbar-width: none }
.tabs::-webkit-scrollbar { display: none }
.tabs-g { font: 700 0.76rem/1 var(--label); letter-spacing: 0.08em; text-transform: lowercase; color: var(--muted); white-space: nowrap }
.tabs-row { display: flex; gap: 20px }
.tabs a { font: 500 0.98rem/1 var(--sans); color: var(--muted); text-decoration: none; padding: 15px 0 13px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap }
.tabs a:hover { color: var(--ink) }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink) }

.page-hero { max-width: var(--wide); margin: 0 auto; padding: 38px 16px 30px; display: grid; gap: 22px 56px; align-items: center }
.page-hero.has-plate { grid-template-columns: minmax(0, 1fr) minmax(0, 430px) }
.ph-text { min-width: 0 }
.page-hero .label { display: block; margin-bottom: 8px }
.page-hero h1 { font-size: clamp(2.5rem, 5.6vw, 4.3rem); line-height: 1 }
.page-hero .lede { margin: 16px 0 0; font-size: 1.22rem; line-height: 1.55 }
.ph-plate img { max-height: 290px; object-fit: contain }
.ph-plate.tall { justify-self: center; width: auto }
.ph-plate.tall img { width: auto; max-height: 330px }
@media (max-width: 860px) {
  .page-hero { padding-top: 26px }
  .page-hero.has-plate { grid-template-columns: minmax(0, 1fr) }
  .ph-plate { max-width: 460px; width: 100% }
  .ph-plate img { max-height: 230px }
  .ph-plate.tall { width: auto; justify-self: start }
  .ph-plate.tall img { max-height: 260px }
}

/* ---------- Page body and the contents rail ---------- */
.page-body { max-width: var(--wide); margin: 0 auto; padding: 0 16px 80px;
  background: linear-gradient(var(--rule), var(--rule)) 16px 0 / calc(100% - 32px) 1px no-repeat }
.page-body > section.chapter:first-child { padding-top: 30px }
.page-body.has-rail { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 52px; align-items: start }
.pb-main { min-width: 0 }
.pb-main > section.chapter:first-of-type { border-top: 0; padding-top: 30px }
.rail { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--head-h)); max-height: calc(100vh - var(--head-h) - env(safe-area-inset-top, 0px));
  overflow: auto; padding: 30px 6px 24px 0; font: 0.93rem/1.3 var(--sans); scrollbar-width: thin; overscroll-behavior: contain }
.rail .label { margin: 0 0 10px; padding-left: 13px }
.rail ol { list-style: none; margin: 0; padding: 0 }
.rail a { display: block; padding: 6px 0 6px 12px; border-left: 1px solid var(--rule); color: var(--muted); text-decoration: none }
.rail a:hover { color: var(--ink) }
.rail a.on { color: var(--ink); border-left: 2px solid var(--ink); padding-left: 11px; font-weight: 500 }
.rail li > ol { display: none; margin: 0 0 6px }
.rail li.open > ol { display: block }
.rail li li a { padding: 4px 0 4px 24px; font-size: 0.86rem }
.rail li li a.on { padding-left: 23px }
.toc-m { display: none }
@media (max-width: 1080px) {
  .page-body.has-rail { grid-template-columns: minmax(0, 1fr); gap: 0 }
  .rail { display: none }
  .toc-m { display: block; margin: 22px 0 0; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper-2) }
  .toc-m summary { padding: 11px 14px; font: 500 0.98rem var(--sans); cursor: pointer }
  .toc-m ol { list-style: none; margin: 0; padding: 2px 14px 14px; display: flex; flex-wrap: wrap; gap: 6px }
  .toc-m a { display: inline-block; font: 0.9rem/1.3 var(--sans); color: var(--ink); text-decoration: none; border: 1px solid var(--rule); border-radius: 999px; padding: 5px 11px; background: var(--paper) }
  .toc-m a:hover { border-color: var(--ink) }
}

/* ---------- Cards: cities, wonders, factions, bestiary, armoury ---------- */
.cities, .factions { grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 0 44px }
.wonders { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 0 36px }
.city, .faction, .wonder { padding-block: 22px 24px; border-bottom: 0; border-top: 1px solid var(--rule); scroll-margin-top: calc(var(--head-h) + 20px) }
.city header h3, .faction h3 { font-size: 1.5rem }
.city-plate { margin: 12px 0; padding: 5px }
.city .stats { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 4px }
.city .stats > span { font: 700 0.72rem/1 var(--label); letter-spacing: 0.06em; color: var(--ink); border: 1px solid var(--rule); border-radius: 4px; padding: 5px 7px; display: inline-flex; gap: 5px; align-items: baseline }
.city .stats b { font: 700 0.92rem/1 var(--sans); letter-spacing: 0 }
.city .stats .tier, .adv-foe .tier { background: var(--ink); color: var(--paper); border-color: var(--ink) }
.cmeta .where { display: block; margin-top: 4px }

/* adventures */
.adv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 18px; margin: 20px 0 36px }
.adv { display: flex; flex-direction: column; gap: 8px; min-width: 0; border: 1px solid var(--rule); background: var(--paper-2); padding: 16px 18px 18px }
.adv h3 { margin: 0; font-size: 1.45rem }
.adv p { margin: 0; font-size: 1rem }
.adv-where { font: 0.88rem/1.3 var(--sans) !important; color: var(--muted) }
.adv-where a { color: var(--ink) }
.adv-foe { margin-top: auto !important; padding-top: 10px; border-top: 1px solid var(--rule); font: 0.92rem/1.4 var(--sans) !important; display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: baseline }
.adv-foe .label { flex-basis: 100% }
.adv-foe .tier { font: 700 0.72rem/1 var(--label); letter-spacing: 0.06em; border-radius: 4px; padding: 4px 7px }
.adv .btn { align-self: start; font-size: 0.88rem; padding: 5px 13px }

/* ---------- Footer ---------- */
.site-foot { border-top: 1px solid var(--rule); background: var(--paper-2) }
.site-foot .cols { max-width: var(--wide); margin: 0 auto; padding: 36px 16px 48px; display: grid; grid-template-columns: minmax(0, 1.7fr) repeat(5, minmax(0, 1fr)); gap: 28px;
  font: 0.92rem/1.6 var(--sans); color: var(--muted) }
.foot-about p { margin: 6px 0 0; max-width: 34ch }
.foot-h { font: 700 0.76rem/1.2 var(--label); letter-spacing: 0.08em; text-transform: lowercase; color: var(--muted); margin: 4px 0 10px }
.site-foot a { color: var(--ink); text-decoration: none } .site-foot a:hover { text-decoration: underline }
.site-foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px }
.site-foot .brand { font-size: 1.45rem }
@media (max-width: 1000px) {
  .site-foot .cols { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) }
  .foot-about { grid-column: 1 / -1 }
}

/* ---------- Search ---------- */
.search { position: fixed; inset: 0; z-index: 90; background: var(--scrim); display: flex; justify-content: center; align-items: flex-start;
  padding: calc(env(safe-area-inset-top, 0px) + 9vh) 16px 16px }
.search[hidden] { display: none }
body.search-open { overflow: hidden }
.s-box { width: min(640px, 100%); max-height: 76vh; display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--rule); border-top: 2px solid var(--ink); box-shadow: var(--panel-shadow) }
.s-field { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--rule) }
.s-field svg { width: 20px; height: 20px; color: var(--muted); flex: none }
.s-field input { flex: 1; min-width: 0; border: 0; background: none; font: 1.15rem var(--sans); padding: 6px 0; outline: none; border-radius: 0 }
.s-field input::-webkit-search-cancel-button { display: none }
.s-x { font: 500 0.82rem var(--sans); border: 1px solid var(--rule); background: var(--paper-2); color: var(--muted); border-radius: 999px; padding: 5px 11px; cursor: pointer }
.s-list { overflow: auto; padding: 6px; overscroll-behavior: contain }
.s-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 14px; padding: 9px 10px; border-radius: 6px; text-decoration: none; color: var(--ink) }
.s-item b { font: 500 1.03rem/1.3 var(--sans) }
.s-page { font: 700 0.72rem/1.3 var(--label); letter-spacing: 0.07em; text-transform: lowercase; color: var(--muted); align-self: center; white-space: nowrap }
.s-snip { grid-column: 1 / -1; font: 0.87rem/1.4 var(--sans); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.s-item[aria-selected="true"], .s-item:hover { background: var(--paper-2) }
.s-item[aria-selected="true"] { box-shadow: inset 0 0 0 1px var(--rule) }
.s-empty { font: 0.95rem/1.7 var(--sans); color: var(--muted); padding: 12px 10px; margin: 0; max-width: none }
.s-empty .chip { font-size: 0.85rem; padding: 3px 10px; margin: 2px 0 }
.s-hint { font: 0.8rem var(--sans); color: var(--muted); margin: 0; max-width: none; padding: 8px 16px; border-top: 1px solid var(--rule) }
@media (max-width: 600px) { .search { padding-top: calc(env(safe-area-inset-top, 0px) + 8px) } .s-box { max-height: 88vh } .s-hint { display: none } }

/* ---------- Home ---------- */
.home-hero { max-width: var(--wide); margin: 0 auto; padding: 46px 16px 30px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: 30px 60px; align-items: center }
.home-hero h1 { font-size: clamp(3.4rem, 10vw, 7.4rem); line-height: 0.92; letter-spacing: 0.005em; margin-top: 8px }
.home-hero .tagline { font-size: 1.32rem; line-height: 1.45; max-width: 32ch; margin: 16px 0 0 }
.cta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
.btn.primary:hover { filter: brightness(1.08) }
a.btn { text-decoration: none; display: inline-flex; align-items: center }
.hh-plate { padding: 7px }
.ledger { max-width: var(--wide); margin: 0 auto; padding: 0 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) }
.ledger div { display: grid; gap: 2px; padding: 14px 18px 14px 0; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule) }
.ledger div + div { padding-left: 18px; border-left: 1px solid var(--rule) }
.ledger b { font: 500 1.45rem/1.15 var(--sans); font-variant-numeric: lining-nums }
.ledger span { font: 0.88rem var(--sans); color: var(--muted) }
@media (max-width: 860px) {
  .home-hero { grid-template-columns: minmax(0, 1fr); padding-top: 30px }
  .ledger { grid-template-columns: repeat(2, minmax(0, 1fr)) }
  .ledger div:nth-child(3) { border-left: 0; padding-left: 0 }
  .ledger div:nth-child(n+3) { border-top-width: 1px; border-top-color: var(--rule) }
}
.home-sec { max-width: var(--wide); margin: 0 auto; padding: 56px 16px 0 }
.home-sec:last-of-type { padding-bottom: 72px }
.sec-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px 24px; margin-bottom: 18px }
.sec-head h2 { margin: 0 }
.sec-head .small { margin: 6px 0 0 }
.more { font: 500 0.98rem var(--sans); color: var(--accent); text-decoration: none; white-space: nowrap }
.more::after { content: " →" }
.more:hover { text-decoration: underline }
.home-sec .map-widget .mapfig { box-shadow: var(--plate-shadow) }

.news { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 40px 36px }
.news article { display: flex; flex-direction: column; gap: 6px; min-width: 0 }
.nc-plate { display: block; margin-bottom: 8px }
.nc-plate img { aspect-ratio: 3 / 2; object-fit: contain }
.news h3 { font-size: 1.45rem; margin: 0 }
.news h3 a { color: var(--ink); text-decoration: none }
.news h3 a:hover { color: var(--accent) }
.news p { font-size: 1rem; margin: 0 }
.news .more { margin-top: 4px; font-size: 0.95rem }

.people { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 16px }
.person { display: grid; gap: 6px; align-content: start; text-decoration: none; color: var(--ink); min-width: 0 }
.person .mount { padding: 4px; margin-bottom: 4px }
.person img { aspect-ratio: 3 / 4; object-fit: contain }
.person b { font: 400 1.28rem/1.1 var(--display) }
.person span { font: 0.88rem/1.35 var(--sans); color: var(--muted) }
.person:hover b { color: var(--accent) }
@media (max-width: 1100px) {
  .people { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(150px, 23%); overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 10px }
  .person { scroll-snap-align: start }
}
@media (max-width: 560px) { .people { grid-auto-columns: 44% } }

.explore-g { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 30px }
.ex-col { display: grid; align-content: start; min-width: 0 }
.ex-col h3 { font-size: 1.4rem; margin: 0; padding-bottom: 8px; border-bottom: 2px solid var(--ink) }
.ex-col a { display: grid; gap: 2px; padding: 11px 0; border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--ink) }
.ex-col b { font: 600 1.04rem/1.25 var(--body) }
.ex-col span { font: 0.88rem/1.35 var(--sans); color: var(--muted) }
.ex-col a:hover b { color: var(--accent) }
@media (max-width: 1100px) { .explore-g { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)) } }

/* ---------- Map widget (home and atlas) ---------- */
.mapfig { position: relative; margin: 0; border: 1px solid var(--rule); background: var(--paper-2) }
.mapfig:fullscreen { background: var(--paper); display: flex; flex-direction: column; padding: 8px }
.mapfig:fullscreen .osd { flex: 1; aspect-ratio: auto }
.mapfig.max { position: fixed; inset: 0; z-index: 60; background: var(--paper); display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 8px calc(env(safe-area-inset-bottom, 0px) + 8px) }
.mapfig.max .osd { flex: 1; aspect-ratio: auto }
.mapcap { font: 0.9rem/1.4 var(--sans); color: var(--muted); padding: 8px 10px }

/* ---------- Atlas page ---------- */
.atlas-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; padding: 14px 16px 16px;
  height: calc(100dvh - var(--head-h) - 1px - env(safe-area-inset-top, 0px)); min-height: 520px }
.atlas-side { overflow: auto; min-width: 0; display: grid; align-content: start; gap: 16px; padding-right: 4px }
.atlas-side h1 { font-size: 2.2rem }
.atlas-side .layers { margin: 0 }
.atlas-main { min-width: 0; display: flex; flex-direction: column; gap: 10px }
.atlas-main .mapfig { flex: 1; display: flex; flex-direction: column }
.atlas-main .osd { flex: 1; aspect-ratio: auto; min-height: 320px }
.atlas-search input { width: 100% }
.results { display: grid; gap: 2px; margin-top: 8px }
.result { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 8px; align-items: center; text-align: left; background: none; border: 0; padding: 7px 8px;
  border-radius: 6px; color: var(--ink); font: 0.92rem var(--sans); cursor: pointer }
.result:hover, .result:focus-visible { background: var(--paper-2) }
.result i { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 1px var(--muted) }
.key { display: grid; gap: 6px; font: 0.88rem var(--sans); color: var(--muted) }
.key span { display: flex; align-items: center; gap: 8px }
.key .pin { position: static; pointer-events: none; transform: scale(0.85) }
@media (max-width: 900px) {
  .atlas-layout { grid-template-columns: minmax(0, 1fr); height: auto }
  .atlas-main { order: -1 }
  .atlas-main .osd { height: 70vh; flex: none }
}

/* ---------- Race portraits ---------- */
.race-block { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 12px 40px; align-items: start }
.race-text { min-width: 0 }
.race-text .two { grid-template-columns: minmax(0, 1fr) }
.race-plate { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--head-h) + 20px); display: grid; gap: 8px }
.plate-main { margin: 0; padding: 8px 8px 6px }
.plate-main img { display: block; width: 100%; height: auto; aspect-ratio: 832 / 1216; object-fit: contain }
.plate-main figcaption { font: 0.84rem/1.35 var(--sans); color: var(--plate-cap); margin-top: 6px; text-align: center }
.plate-thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px }
.thumb { display: grid; gap: 3px; padding: 4px; border: 1px solid var(--rule); background: var(--plate-bg); cursor: pointer; font: 0.74rem var(--label); color: var(--plate-cap);
  text-transform: lowercase; letter-spacing: 0.06em; opacity: 0.72 }
.thumb:hover { opacity: 1 }
.thumb img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; object-position: 50% 12% }
.thumb[aria-pressed="true"] { border-color: var(--ink); opacity: 1; box-shadow: 0 0 0 1px var(--ink) }
.plate-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 16px 0 20px }
.plate-strip figure { margin: 0; padding: 6px }
.plate-strip img { display: block; width: 100%; height: auto; aspect-ratio: 1152 / 896; object-fit: contain }
.plate-strip figcaption { font: 0.84rem/1.35 var(--sans); color: var(--plate-cap); margin-top: 5px; text-align: center }
.plate-strip.knights img { aspect-ratio: 832 / 1216 }
.plate-strip.wide img { aspect-ratio: 1216 / 832 }
.plate-strip.dragons { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) }
.city-plate img { display: block; width: 100%; height: auto }
.city-plate.tall { max-width: 300px; margin-inline: auto }
.mappanel.has-pic { width: min(320px, calc(100% - 20px)); max-height: calc(100% - 20px); overflow: auto }
.mappanel .mp-img { display: block; width: calc(100% + 28px); max-width: none; margin: -12px -14px 10px; height: auto; max-height: 210px; object-fit: contain;
  background: var(--plate-bg); border-bottom: 1px solid var(--rule) }
.mappanel.has-pic .x { z-index: 1; background: var(--paper); border-radius: 999px; line-height: 1 }
.power-plate { max-width: 760px }
@media (max-width: 860px) {
  .race-block { grid-template-columns: minmax(0, 1fr) }
  .race-plate { position: static; order: -1; max-width: 340px }
  .plate-strip { grid-template-columns: minmax(0, 1fr) }
  .plate-strip.knights { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px }
  .plate-strip.knights figcaption { font-size: 0.74rem }
}
@media (max-width: 520px) { .plate-strip.knights { grid-template-columns: minmax(0, 1fr); max-width: 320px } }

/* ---------- Brand: The Doomquill Tales (lockups built in chrome_build.py and home_page.py) ---------- */
.brand { display: inline-flex; align-items: center; gap: 9px }
.brand .dq-mark { height: 40px; width: auto; flex: none }
.dq-word { display: grid; justify-items: start }
.dq-w1 { font: 400 1.55rem/0.95 var(--display); letter-spacing: 0.01em }
.dq-w2 { justify-self: stretch; display: flex; align-items: center; gap: 6px; font: 700 0.6rem/1 var(--label); letter-spacing: 0.34em; text-transform: uppercase;
  color: var(--muted); margin-top: 3px; padding-left: 2px }
.dq-w2::before { content: ""; flex: 1; height: 1px; background: currentColor; opacity: 0.55 }
.site-foot .brand .dq-mark { height: 46px }
.dq-motto { font: italic 400 1.02rem/1.3 var(--body); color: var(--ink) }
@media (max-width: 460px) { .brand .dq-mark { height: 34px } .dq-w1 { font-size: 1.32rem } .dq-w2 { font-size: 0.54rem } }

.home-hero h1.dq-lockup { display: flex; align-items: center; gap: clamp(8px, 1.8vw, 20px); font-size: clamp(2.3rem, 5.6vw, 4.9rem); line-height: 1; margin-top: 10px; letter-spacing: 0 }
.dq-lockup .dq-mark { height: 1.8em; width: auto; flex: none }
.dq-stack { display: grid; min-width: 0 }
.dq-name { font: 400 1em/0.95 var(--display) }
.dq-the, .dq-tales { display: flex; align-items: center; gap: 0.6em; font: 700 max(0.19em, 0.72rem)/1 var(--label); letter-spacing: 0.34em; text-transform: uppercase; color: var(--muted) }
.dq-the { margin-bottom: 0.12em } .dq-tales { margin-top: 0.16em }
.dq-the::after, .dq-tales::before { content: ""; flex: 1; height: 1px; background: currentColor; opacity: 0.55 }
.home-hero .dq-hero-motto { font: italic 400 1.5rem/1.3 var(--body); margin: 18px 0 0 }

/* ---------- Hero Builder (.kx-hb) ---------- */
.kx-hb { display: grid; grid-template-columns: 1.1fr 1fr; gap: 36px; margin: 24px 0 }
.kx-hb-side { display: flex; flex-direction: column; gap: 16px }
.kx-peoples { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px }
.kx-person-card { text-align: left; background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 10px 12px; cursor: pointer; transition: all 0.15s ease }
.kx-person-card:hover { border-color: var(--ink); background: color-mix(in srgb, var(--ink) 4%, var(--paper)) }
.kx-person-card.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); background: color-mix(in srgb, var(--ink) 6%, var(--paper)) }
.kx-person-card b { display: block; font: 600 1.05rem/1.2 var(--display); color: var(--ink) }
.kx-person-card small { font: 500 0.8rem var(--label); color: var(--muted) }
.kx-person-card span { display: block; font: 0.85rem/1.3 var(--sans); color: var(--muted); margin-top: 4px }
.kx-name-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 }
.kx-sheet { background: var(--plate-bg); border: 1px solid var(--plate-rule); box-shadow: var(--plate-shadow); padding: 24px; border-radius: 4px; display: flex; flex-direction: column; gap: 18px }
.kx-scores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 6px 0 }
.kx-score-card { background: color-mix(in srgb, var(--ink) 3%, var(--plate-bg)); border: 1px solid var(--rule); border-radius: 4px; padding: 12px; text-align: center }
.kx-score-val { display: block; font: 700 2.2rem/1 var(--display); color: var(--ink); margin: 6px 0 }
.kx-sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; font-size: 0.95rem }
@media (max-width: 860px) {
  .kx-hb { grid-template-columns: minmax(0, 1fr) }
  .kx-scores { grid-template-columns: 1fr }
}

/* the sheet is paper in both themes, so it keeps the light-theme ink */
.kx-sheet { --ink: #1d2420; --muted: #5a665f; --rule: #c4cdc6; --paper: #ffffff; --accent: #2c6a5c; --accent-ink: #ffffff; color: var(--ink) }

/* ---------- Tavern Tables (.kx-tool) ---------- */
.kx-tool { background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 18px 20px; margin: 16px 0 24px }
.kx-roll-list { margin: 12px 0 0; padding-left: 20px; line-height: 1.6 }
.kx-enc { width: 100%; border-collapse: collapse; margin-top: 12px }
.kx-enc th, .kx-enc td { padding: 8px 12px; border-bottom: 1px solid var(--rule); text-align: left }
.kx-enc th.r, .kx-enc td.r { text-align: right }

/* ---------- Lore cards, term tips, map buttons, auto-links (site_extras.py, chrome.js) ---------- */
.kx-tip { position: fixed; z-index: 95; width: 280px; background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-top: 2px solid var(--ink);
  box-shadow: var(--panel-shadow); padding: 12px 14px; font: 0.9rem/1.4 var(--sans); pointer-events: none }
.kx-tip[hidden] { display: none }
.kx-tip.wide { width: 300px }
.kx-tip img { display: block; width: calc(100% + 28px); margin: -12px -14px 10px; max-width: none; height: 150px; object-fit: contain;
  background: var(--plate-bg); border-bottom: 1px solid var(--plate-rule); mix-blend-mode: normal }
.kx-tip .label { display: block; margin-bottom: 2px }
.kx-tip b { display: block; font: 400 1.2rem/1.2 var(--display) }
.kx-tip p { margin: 6px 0 0; color: var(--muted); max-width: none }
.kx-tip-map { display: inline-block; margin-top: 8px; font: 500 0.78rem var(--sans); color: var(--accent) }
a.kx-link { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  text-decoration-thickness: 1px; text-underline-offset: 3px }
a.kx-link:hover { color: var(--accent); text-decoration-color: currentColor }
.kx-term { border-bottom: 1px dotted var(--muted); cursor: help }
.kx-map { float: right; display: inline-flex; align-items: center; gap: 4px; margin: 4px 0 4px 10px; font: 500 0.8rem/1 var(--sans); color: var(--muted);
  text-decoration: none; border: 1px solid var(--rule); border-radius: 999px; padding: 5px 9px 5px 7px; background: var(--paper) }
.kx-map svg { width: 13px; height: 13px }
.kx-map:hover { color: var(--ink); border-color: var(--ink) }

/* previous / next */
.kx-pager { max-width: var(--wide); margin: 0 auto; padding: 0 16px 56px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px }
.kx-pager a { display: grid; gap: 2px; padding: 14px 16px; border: 1px solid var(--rule); text-decoration: none; color: var(--ink); min-width: 0 }
.kx-pager a[rel="next"] { text-align: right; grid-column: 2 }
.kx-pager a span { font: 700 0.74rem var(--label); letter-spacing: 0.08em; text-transform: lowercase; color: var(--muted) }
.kx-pager a b { font: 400 1.35rem/1.2 var(--display) }
.kx-pager a[rel="prev"] span::before { content: "← " } .kx-pager a[rel="next"] span::after { content: " →" }
.kx-pager a:hover { border-color: var(--ink) }
.page-body { padding-bottom: 48px }

/* gazetteer */
.kx-gaz-tools { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--head-h)); z-index: 5; background: var(--paper); padding: 14px 0 10px;
  border-bottom: 1px solid var(--rule); display: grid; gap: 8px }
.kx-gaz-tools input { width: 100%; max-width: 520px }
.kx-letters { display: flex; flex-wrap: wrap; gap: 2px 10px; font: 500 0.95rem var(--sans) }
.kx-letters a { text-decoration: none }
.kx-gaz { list-style: none; margin: 6px 0 18px; padding: 0; columns: 2 320px; column-gap: 40px }
.kx-gaz li { break-inside: avoid; padding: 7px 0; border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px }
.kx-gaz a { font-weight: 600; text-decoration: none; color: var(--ink) } .kx-gaz a:hover { color: var(--accent) }
.kx-gk { font: 700 0.72rem/1.6 var(--label); letter-spacing: 0.06em; text-transform: lowercase; color: var(--muted) }
.kx-gd { grid-column: 1 / -1; font: 0.86rem/1.4 var(--sans); color: var(--muted) }
.kx-gaz li[hidden], .kx-gaz[hidden], h2[hidden] { display: none }

/* timeline eras */
.kx-eras { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 }
.timeline li[hidden] { display: none }

/* ---------- Combat Arena (.kx-arena-setup, .kx-pit) ---------- */
.kx-arena-setup { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 20px 0; }
.kx-combatant-card { background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.kx-combatant-card .card-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--rule); padding-bottom: 8px; }
.kx-combatant-card .card-head h3 { margin: 0; font: 700 1.2rem/1.2 var(--serif); color: var(--ink); }
.row-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.row-stats label { display: flex; flex-direction: column; font: 500 0.8rem var(--label); color: var(--muted); gap: 4px; }
.row-stats input { width: 100%; }
.lore-box { font-style: italic; color: var(--muted); border-left: 2px solid var(--gold, #8f6d16); padding-left: 8px; margin-top: 4px; line-height: 1.4; }

.kx-pit { background: var(--plate-bg); border: 2px solid var(--ink); box-shadow: var(--plate-shadow); border-radius: 6px; padding: 24px; margin: 24px 0; }
.pit-hud { display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: center; margin-bottom: 20px; }
.hud-vs { font: 900 1.4rem var(--display); color: var(--muted); text-align: center; }
.fighter-hud { background: color-mix(in srgb, var(--ink) 4%, var(--plate-bg)); border: 1px solid var(--rule); border-radius: 4px; padding: 12px 16px; }
.hud-name { font: 700 1.15rem var(--serif); color: var(--ink); margin-bottom: 6px; }
.hp-bar-wrap { height: 14px; background: rgba(0,0,0,0.12); border-radius: 7px; overflow: hidden; margin-bottom: 6px; }
.hp-bar { height: 100%; background: #2c6a5c; transition: width 0.3s ease; }
.hp-bar.foe-bar { background: #8c2e29; }
.hp-nums { font: 500 0.85rem var(--label); color: var(--muted); }

.pit-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--rule); }
.pit-log-wrap h4 { margin: 0 0 8px; font: 700 1rem var(--serif); color: var(--ink); }
.pit-log { max-height: 220px; overflow-y: auto; background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 12px 16px; font: 0.92rem/1.55 var(--sans); }
.pit-log p { margin: 4px 0; }
.pit-log .log-entry.h-hit { color: #1c5244; font-weight: 500; }
.pit-log .log-entry.f-hit { color: #8c2e29; font-weight: 500; }
.pit-log .log-entry.luck { color: #8f6d16; font-style: italic; }
.pit-log .log-entry.sys { color: var(--muted); }
.pit-log .log-entry.crit { font-weight: 700; color: #4a1512; }
.pit-log .log-entry.victory { font-weight: 700; color: #1c5244; font-size: 1.05em; border-top: 1px solid var(--rule); padding-top: 6px; }
.pit-log .log-entry.defeat { font-weight: 700; color: #8c2e29; font-size: 1.05em; border-top: 1px solid var(--rule); padding-top: 6px; }

.sim-results { margin-top: 18px; border-top: 1px solid var(--rule); padding-top: 16px; }
.sim-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.sim-stat { background: color-mix(in srgb, var(--ink) 3%, var(--paper)); border: 1px solid var(--rule); border-radius: 4px; padding: 10px; text-align: center; }
.sim-stat .label { display: block; font: 500 0.75rem var(--label); color: var(--muted); text-transform: uppercase; margin-bottom: 4px; }
.sim-stat strong { font: 700 1.5rem var(--display); color: var(--ink); }
.sim-rating-box { display: flex; align-items: center; gap: 14px; background: color-mix(in srgb, var(--ink) 4%, var(--paper)); border-radius: 4px; padding: 12px 16px; }
.sim-badge { font: 700 0.95rem var(--label); text-transform: uppercase; padding: 4px 10px; border-radius: 4px; color: #fff; background: #2c6a5c; }
.sim-badge.deadly { background: #8c2e29; }
.sim-badge.challenging { background: #8f6d16; }
.sim-badge.trivial { background: #5d6870; }

@media (max-width: 860px) {
  .kx-arena-setup { grid-template-columns: 1fr; }
  .pit-hud { grid-template-columns: 1fr; }
  .sim-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Atlas Journey Planner (.atlas-journey) ---------- */
.atlas-journey { background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 12px 14px; display: grid; gap: 8px; }
.j-row select { width: 100%; font-size: 0.88rem; }
.j-summary { border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 6px; display: grid; gap: 8px; }
.j-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.j-metrics div { background: var(--paper-2); border: 1px solid var(--rule); border-radius: 4px; padding: 6px 4px; }
.j-metrics b { display: block; font: 700 1.05rem var(--display); color: var(--ink); }
.j-perils { font-style: italic; color: var(--muted); border-left: 2px solid var(--accent); padding-left: 8px; }
.j-enc-out { background: var(--paper-2); border: 1px solid var(--rule); border-radius: 4px; padding: 8px 10px; line-height: 1.45; }

/* ---------- Commercial Book Showcase & 3D Mockup (.books-grid) ---------- */
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(460px, 100%), 1fr)); gap: 32px; margin: 28px 0; }
.book-showcase-card { background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: 24px; display: grid; grid-template-columns: 140px 1fr; gap: 24px; box-shadow: var(--panel-shadow); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.book-showcase-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.book-3d-wrap { perspective: 800px; display: flex; justify-content: center; align-items: center; padding: 10px 0; }
.book-3d { width: 120px; height: 180px; position: relative; transform-style: preserve-3d; transform: rotateY(-22deg) rotateX(6deg); transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); box-shadow: -8px 10px 20px rgba(0,0,0,0.3); border-radius: 2px 4px 4px 2px; }
.book-showcase-card:hover .book-3d { transform: rotateY(-6deg) rotateX(2deg) translateY(-4px); box-shadow: -10px 16px 28px rgba(0,0,0,0.4); }
.book-cover-front { position: absolute; inset: 0; color: #fff; padding: 14px 10px; border-radius: 2px 4px 4px 2px; border: 1px solid rgba(255,255,255,0.25); display: flex; flex-direction: column; justify-content: space-between; text-align: center; box-shadow: inset 0 0 30px rgba(0,0,0,0.5); }
.book-cover-front h4 { font: 700 0.95rem/1.15 var(--serif); color: #fff; margin: 4px 0; text-transform: uppercase; letter-spacing: 0.05em; text-shadow: 0 1px 2px #000; }
.book-spine-3d { position: absolute; top: 0; bottom: 0; left: 0; width: 14px; background: #110e0c; transform: rotateY(-90deg) translateX(-14px); transform-origin: left; border-right: 1px solid #2b241e; }
.book-pages-3d { position: absolute; top: 3px; bottom: 3px; right: 0; width: 12px; background: #f2ede4; transform: rotateY(90deg) translateX(6px); transform-origin: right; border-left: 1px solid #c9bfa8; box-shadow: inset -2px 0 4px rgba(0,0,0,0.2); }

.book-info { display: flex; flex-direction: column; justify-content: space-between; }
.book-info h3 { margin: 2px 0 4px; font: 700 1.35rem/1.2 var(--serif); color: var(--ink); }
.author-byline { margin-bottom: 8px; color: var(--muted); }
.synopsis-p { font-size: 0.95rem; line-height: 1.5; color: var(--ink); margin-bottom: 12px; }
.book-spec-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 4px; padding: 8px 10px; margin-bottom: 14px; text-align: center; }
.book-spec-grid .label { display: block; font: 500 0.72rem var(--label); color: var(--muted); text-transform: uppercase; }
.book-spec-grid b { font: 700 1.05rem var(--display); color: var(--ink); }
.book-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 600px) {
  .book-showcase-card { grid-template-columns: 1fr; }
  .book-3d-wrap { justify-content: flex-start; }
}




/* realm arms and adventure covers (placed by site_extras.py once drawn) */
.state .kx-arms { float: right; width: 92px; margin: 0 0 8px 14px; padding: 4px }
.state .kx-arms img { aspect-ratio: 1 / 1; object-fit: contain }
.adv .kx-cover { margin: -16px -18px 4px; border-width: 0 0 1px; box-shadow: none; padding: 0 }
.adv .kx-cover img { aspect-ratio: 3 / 2; object-fit: cover }
.adv { position: relative }
.adv > .kx-map { position: absolute; top: 10px; right: 10px; float: none; margin: 0; z-index: 1 }

/* ---------- Quick Nav Buttons in Header ---------- */
.play-quick-btn {
  background: color-mix(in srgb, #c29d46 16%, var(--paper)) !important;
  border-color: #c29d46 !important;
  font-weight: 600;
  color: var(--ink) !important;
  box-shadow: 0 1px 3px rgba(194, 157, 70, 0.25);
  transition: transform 0.15s ease, background 0.15s ease;
}
.play-quick-btn:hover {
  background: color-mix(in srgb, #c29d46 28%, var(--paper)) !important;
  border-color: #9f7d2e !important;
  transform: translateY(-1px);
}
.books-quick-btn {
  background: color-mix(in srgb, #4a6b5d 10%, var(--paper)) !important;
  border-color: color-mix(in srgb, #4a6b5d 40%, var(--rule)) !important;
  transition: transform 0.15s ease;
}
.books-quick-btn:hover {
  border-color: #4a6b5d !important;
  transform: translateY(-1px);
}
/* Phones: the buttons are text-only now, so drop them; the menu's footer has Play and Books */
@media (max-width: 600px) {
  .play-quick-btn, .books-quick-btn { display: none !important; }
}

/* ---------- Hero CTA Enhancements ---------- */
.hero-play-btn {
  background: #8c2e29 !important;
  border-color: #5c1814 !important;
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 3px 12px rgba(140, 46, 41, 0.35);
}
.hero-play-btn:hover {
  background: #a83832 !important;
  box-shadow: 0 5px 16px rgba(140, 46, 41, 0.45);
  transform: translateY(-1px);
}
.hero-books-btn {
  background: color-mix(in srgb, #c29d46 16%, var(--paper));
  border-color: #c29d46;
  font-weight: 600;
}
.hero-books-btn:hover {
  background: color-mix(in srgb, #c29d46 25%, var(--paper));
}

/* ---------- Publishing & Game Suite Grid ---------- */
.pub-suite-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
  margin-top: 18px;
}
.suite-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--panel-shadow);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.suite-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(0,0,0,0.12);
}
.suite-icon {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 2px;
}
.suite-card h3 {
  font: 700 1.25rem/1.2 var(--serif);
  color: var(--ink);
  margin: 0;
}
.suite-card p {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted);
  margin: 0 0 12px;
  flex: 1;
}
.suite-card .more {
  font: 600 0.88rem var(--sans);
  color: var(--accent);
  text-decoration: none;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.suite-card .more:hover {
  text-decoration: underline;
}


/* Atlas fortifications layers (atlas.js: fort, castle, walled) */
.pin.k-fort { background: #4b3a22 }
.pin.k-castle { background: #6b5536; width: 16px; height: 16px }
.pin.k-walled { background: #8a7a5c; width: 10px; height: 10px; font-size: 0; border-width: 1.5px }
.pin.k-fort svg, .pin.k-castle svg { display: block }
.pin.k-castle svg { width: 9px; height: 9px }

/* ---------- Quill pointer ----------
   The mouse pointer is a pen-and-ink quill (nib is the hotspot, bottom-left); over anything clickable the vane takes the
   accent colour, as if freshly dipped. White halo keeps it visible on the dark theme. Text fields keep the I-beam, and
   touch devices never see it. !important because older per-element pointer rules, and player.css /
   editor.css loaded after this file, would otherwise put the hand back. */
@media (hover: hover) and (pointer: fine) {
  html, body { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg stroke-linejoin='round' stroke-linecap='round'%3E%3Cg fill='%23fff' stroke='%23fff' stroke-width='3.2'%3E%3Cpath d='M8.5 22.5C9.5 13.5 18 5.5 30 1.5C27 10 20 19 8.5 22.5Z'/%3E%3Cpath d='M1.5 30.5L4.5 25.5L6.5 27.5Z'/%3E%3Cpath d='M4 28L10 22'/%3E%3C/g%3E%3Cpath d='M3.5 28.5L10 22' stroke='%231d2420' stroke-width='1.8'/%3E%3Cpath d='M8.5 22.5C9.5 13.5 18 5.5 30 1.5C27 10 20 19 8.5 22.5Z' fill='%231d2420' stroke='%231d2420' stroke-width='1'/%3E%3Cpath d='M9.5 21.5L26 5.5' stroke='%23fff' stroke-width='0.9'/%3E%3Cpath d='M14 17.5L18 17M17.5 14L22 13M21 10.5L25.5 9M12.5 14L13.5 11.5M16 10.5L17.5 8M19.5 7L21.5 5' stroke='%23fff' stroke-width='0.8' fill='none'/%3E%3Cpath d='M1.5 30.5L4.5 25.5L6.5 27.5Z' fill='%231d2420' stroke='%231d2420' stroke-width='1'/%3E%3C/g%3E%3C/svg%3E") 2 30, auto }
  a, button, summary, label, select, [role="button"], [role="tab"], [role="menuitem"], .btn, .chip, .pin, .hl-label, .g-btn,
  .thumb, .kx-person-card, .s-x, .tile-btn, .mp-item, .vbadge, .choice, .tiny, .ar.ar-hover { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg stroke-linejoin='round' stroke-linecap='round'%3E%3Cg fill='%23fff' stroke='%23fff' stroke-width='3.2'%3E%3Cpath d='M8.5 22.5C9.5 13.5 18 5.5 30 1.5C27 10 20 19 8.5 22.5Z'/%3E%3Cpath d='M1.5 30.5L4.5 25.5L6.5 27.5Z'/%3E%3Cpath d='M4 28L10 22'/%3E%3C/g%3E%3Cpath d='M3.5 28.5L10 22' stroke='%231d2420' stroke-width='1.8'/%3E%3Cpath d='M8.5 22.5C9.5 13.5 18 5.5 30 1.5C27 10 20 19 8.5 22.5Z' fill='%238b2a1a' stroke='%238b2a1a' stroke-width='1'/%3E%3Cpath d='M9.5 21.5L26 5.5' stroke='%23fff' stroke-width='0.9'/%3E%3Cpath d='M14 17.5L18 17M17.5 14L22 13M21 10.5L25.5 9M12.5 14L13.5 11.5M16 10.5L17.5 8M19.5 7L21.5 5' stroke='%23fff' stroke-width='0.8' fill='none'/%3E%3Cpath d='M1.5 30.5L4.5 25.5L6.5 27.5Z' fill='%231d2420' stroke='%231d2420' stroke-width='1'/%3E%3C/g%3E%3C/svg%3E") 2 30, pointer !important }
  input:not([type="button"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]), textarea, [contenteditable="true"] { cursor: text }
  .chip[disabled], button[disabled], .choice[disabled], .osd > img { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg stroke-linejoin='round' stroke-linecap='round'%3E%3Cg fill='%23fff' stroke='%23fff' stroke-width='3.2'%3E%3Cpath d='M8.5 22.5C9.5 13.5 18 5.5 30 1.5C27 10 20 19 8.5 22.5Z'/%3E%3Cpath d='M1.5 30.5L4.5 25.5L6.5 27.5Z'/%3E%3Cpath d='M4 28L10 22'/%3E%3C/g%3E%3Cpath d='M3.5 28.5L10 22' stroke='%231d2420' stroke-width='1.8'/%3E%3Cpath d='M8.5 22.5C9.5 13.5 18 5.5 30 1.5C27 10 20 19 8.5 22.5Z' fill='%231d2420' stroke='%231d2420' stroke-width='1'/%3E%3Cpath d='M9.5 21.5L26 5.5' stroke='%23fff' stroke-width='0.9'/%3E%3Cpath d='M14 17.5L18 17M17.5 14L22 13M21 10.5L25.5 9M12.5 14L13.5 11.5M16 10.5L17.5 8M19.5 7L21.5 5' stroke='%23fff' stroke-width='0.8' fill='none'/%3E%3Cpath d='M1.5 30.5L4.5 25.5L6.5 27.5Z' fill='%231d2420' stroke='%231d2420' stroke-width='1'/%3E%3C/g%3E%3C/svg%3E") 2 30, default !important }
}

/* ---------- The site as a book ----------
   Every page is a leaf of paper with a faint grain. On wide screens the leaf sits in a cloth binding: a spine shadow
   down the left (the gutter), the cover's edge beyond it, and the stacked edges of the pages beneath on the right and
   bottom. Narrow screens just get the paper. */
:root { --binding: #5a3219; --binding-2: #2a150a; --edge: var(--rule) }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --binding: #43230f; --binding-2: #170a03; --edge: #5c4732 } }
:root[data-theme="dark"] { --binding: #43230f; --binding-2: #170a03; --edge: #5c4732 }
body {
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.11 0 0 0 0 0.14 0 0 0 0 0.12 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E") } }
:root[data-theme="dark"] body { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E") }
@media (min-width: 1180px) {
  html { background: radial-gradient(ellipse at 50% 30%, var(--binding), var(--binding-2)) fixed; min-height: 100% }
  body { position: relative; max-width: calc(var(--wide) + 72px); margin: 32px auto 56px; border-radius: 1px 5px 5px 1px;
    box-shadow: inset 34px 0 30px -28px rgba(0, 0, 0, 0.28), inset 2px 0 0 rgba(0, 0, 0, 0.12),
      3px 3px 0 -1px var(--paper), 3px 3px 0 0 var(--edge), 6px 6px 0 -1px var(--paper-2), 6px 6px 0 0 var(--edge),
      9px 9px 0 -1px var(--paper), 9px 9px 0 0 var(--edge), 12px 12px 0 -1px var(--paper-2), 12px 12px 0 0 var(--edge),
      0 40px 70px -24px rgba(0, 0, 0, 0.65) }
  /* the cover board showing past the leaf at the spine */
  body::before { content: ""; position: absolute; top: -10px; bottom: -22px; left: -16px; width: 16px; border-radius: 4px 0 0 4px;
    background: linear-gradient(to right, var(--binding-2), color-mix(in srgb, var(--binding) 70%, #fff 6%) 55%, var(--binding-2));
    box-shadow: -4px 10px 18px rgba(0, 0, 0, 0.4); pointer-events: none }
  .site-head { border-radius: 1px 5px 0 0 }
}

/* ---------- Page turns ----------
   Going to another page turns the leaf: the page you were on lifts from the spine and swings away to reveal the next
   one; going back (to a page earlier in the reading order, set by PAGE_TURN in chrome_build.py) the earlier leaf swings
   back over. The running header holds still. Browsers without cross-document view transitions just load the page. */
@view-transition { navigation: auto }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none } }
html.turning .site-head { view-transition-name: running-head }
::view-transition-group(root) { animation-duration: 0.85s }
::view-transition-image-pair(root) { isolation: auto }
::view-transition-old(root), ::view-transition-new(root) { mix-blend-mode: normal; transform-origin: 0 50%; backface-visibility: hidden }
::view-transition-old(root) { z-index: 2; animation: leaf-away 0.85s cubic-bezier(0.5, 0, 0.6, 1) both }
::view-transition-new(root) { z-index: 1; animation: leaf-under 0.85s ease-out both }
html:active-view-transition-type(turn-back)::view-transition-old(root) { z-index: 1; animation: leaf-under-back 0.85s ease-in both }
html:active-view-transition-type(turn-back)::view-transition-new(root) { z-index: 2; animation: leaf-return 0.85s cubic-bezier(0.4, 0, 0.5, 1) both }
@keyframes leaf-away {
  0% { transform: perspective(2200px) rotateY(0); filter: brightness(1) }
  100% { transform: perspective(2200px) rotateY(-92deg); filter: brightness(0.62) } }
@keyframes leaf-return {
  0% { transform: perspective(2200px) rotateY(-92deg); filter: brightness(0.62) }
  100% { transform: perspective(2200px) rotateY(0); filter: brightness(1) } }
@keyframes leaf-under { 0% { filter: brightness(0.82) } 100% { filter: brightness(1) } }
@keyframes leaf-under-back { 0% { filter: brightness(1) } 100% { filter: brightness(0.82) } }

/* ---------- Ye olde volume ----------
   An old book rather than a clean one: warm parchment, darker towards the edges, mottled with age and spotted with
   foxing; sepia-black ink with oxblood rubrics (links and accents), the way old printers picked out words in red; drop
   caps and a flourish on each chapter; squared-off buttons; and a grained leather binding with a gilt line at the spine.
   By candlelight (dark theme) the page darkens to a smoky brown and the ink lightens. The texture tiles are inline SVG
   noise, so they cost no files. */
:root {
  --paper: #f1e6c9; --paper-2: #e7d6ae; --ink: #2a1c10; --muted: #6e5838; --rule: #cdb78a; --accent: #8b2a1a; --accent-ink: #fbf3df; --gold: #9a7420; --danger: #9b2c1c;
  --plate-bg: #f8efd7; --plate-rule: #c9b384; --plate-cap: #5a4428;
  --tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.25 0 0 0 0 0.15 0 0 0 0 0.05 0 0 0 0.11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1100' height='1500'%3E%3Cfilter id='b'%3E%3CfeGaussianBlur stdDeviation='2.5'/%3E%3C/filter%3E%3Cg fill='rgb(122,78,30)' filter='url(%23b)'%3E%3Ccircle cx='140' cy='210' r='9' opacity='0.16'/%3E%3Ccircle cx='160' cy='232' r='4' opacity='0.2'/%3E%3Ccircle cx='820' cy='140' r='14' opacity='0.09'/%3E%3Ccircle cx='610' cy='520' r='6' opacity='0.14'/%3E%3Ccircle cx='1010' cy='760' r='11' opacity='0.1'/%3E%3Ccircle cx='90' cy='980' r='7' opacity='0.13'/%3E%3Ccircle cx='470' cy='1180' r='16' opacity='0.07'/%3E%3Ccircle cx='760' cy='1340' r='5' opacity='0.17'/%3E%3Ccircle cx='300' cy='700' r='3' opacity='0.2'/%3E%3Ccircle cx='950' cy='1250' r='8' opacity='0.11'/%3E%3C/g%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1800' height='1800'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.006' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.28 0 0 0 0 0.08 0.75 0 0 0 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); --browning: rgba(120, 72, 20, 0.26) }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #201810; --paper-2: #2b2016; --ink: #ecdfc2; --muted: #b5a07d; --rule: #4b3a27; --accent: #e08b6c; --accent-ink: #201810; --gold: #d9b45a; --danger: #e8836f;
  --plate-bg: #eadcbc; --plate-rule: #4b3a27; --plate-cap: #5a4428;
  --tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.9 0 0 0 0 0.7 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1100' height='1500'%3E%3Cfilter id='b'%3E%3CfeGaussianBlur stdDeviation='2.5'/%3E%3C/filter%3E%3Cg fill='rgb(0,0,0)' filter='url(%23b)'%3E%3Ccircle cx='140' cy='210' r='9' opacity='0.16'/%3E%3Ccircle cx='160' cy='232' r='4' opacity='0.2'/%3E%3Ccircle cx='820' cy='140' r='14' opacity='0.09'/%3E%3Ccircle cx='610' cy='520' r='6' opacity='0.14'/%3E%3Ccircle cx='1010' cy='760' r='11' opacity='0.1'/%3E%3Ccircle cx='90' cy='980' r='7' opacity='0.13'/%3E%3Ccircle cx='470' cy='1180' r='16' opacity='0.07'/%3E%3Ccircle cx='760' cy='1340' r='5' opacity='0.17'/%3E%3Ccircle cx='300' cy='700' r='3' opacity='0.2'/%3E%3Ccircle cx='950' cy='1250' r='8' opacity='0.11'/%3E%3C/g%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1800' height='1800'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.006' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.9 0 0 0 -0.32'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); --browning: rgba(0, 0, 0, 0.45) } }
:root[data-theme="dark"] {
  --paper: #201810; --paper-2: #2b2016; --ink: #ecdfc2; --muted: #b5a07d; --rule: #4b3a27; --accent: #e08b6c; --accent-ink: #201810; --gold: #d9b45a; --danger: #e8836f;
  --plate-bg: #eadcbc; --plate-rule: #4b3a27; --plate-cap: #5a4428;
  --tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.9 0 0 0 0 0.7 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1100' height='1500'%3E%3Cfilter id='b'%3E%3CfeGaussianBlur stdDeviation='2.5'/%3E%3C/filter%3E%3Cg fill='rgb(0,0,0)' filter='url(%23b)'%3E%3Ccircle cx='140' cy='210' r='9' opacity='0.16'/%3E%3Ccircle cx='160' cy='232' r='4' opacity='0.2'/%3E%3Ccircle cx='820' cy='140' r='14' opacity='0.09'/%3E%3Ccircle cx='610' cy='520' r='6' opacity='0.14'/%3E%3Ccircle cx='1010' cy='760' r='11' opacity='0.1'/%3E%3Ccircle cx='90' cy='980' r='7' opacity='0.13'/%3E%3Ccircle cx='470' cy='1180' r='16' opacity='0.07'/%3E%3Ccircle cx='760' cy='1340' r='5' opacity='0.17'/%3E%3Ccircle cx='300' cy='700' r='3' opacity='0.2'/%3E%3Ccircle cx='950' cy='1250' r='8' opacity='0.11'/%3E%3C/g%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1800' height='1800'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.006' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.9 0 0 0 -0.32'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); --browning: rgba(0, 0, 0, 0.45) }
body { background-color: var(--paper); background-image: var(--tex); box-shadow: inset 0 0 70px var(--browning) }
:root:not([data-theme="light"]) body, :root[data-theme="dark"] body { background-image: var(--tex) }
.site-head { background-color: color-mix(in srgb, var(--paper) 93%, transparent); background-image: var(--tex);
  border-bottom: 3px double var(--rule) }
.btn, .chip { border-radius: 3px }
section.chapter > h2 { color: var(--ink) }
section.chapter > h2::after { content: ""; display: block; width: 160px; height: 16px; margin-top: 6px; background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 16'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.3' stroke-linecap='round'%3E%3Cpath d='M2 8H62M98 8H158'/%3E%3Cpath d='M62 8c6-7 12-7 14-2s-4 6-6 3M98 8c-6 7-12 7-14 2s4-6 6-3'/%3E%3C/g%3E%3Cpath d='M80 2l5 6-5 6-5-6z'/%3E%3C/svg%3E") no-repeat left center / contain; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 16'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.3' stroke-linecap='round'%3E%3Cpath d='M2 8H62M98 8H158'/%3E%3Cpath d='M62 8c6-7 12-7 14-2s-4 6-6 3M98 8c-6 7-12 7-14 2s4-6 6-3'/%3E%3C/g%3E%3Cpath d='M80 2l5 6-5 6-5-6z'/%3E%3C/svg%3E") no-repeat left center / contain; opacity: 0.85 }
section.chapter > h2 + p::first-letter { float: left; font: 3.6em/0.82 var(--display); color: var(--accent); padding: 0.06em 0.1em 0 0 }
.page-hero h1 { text-shadow: 0 1px 0 color-mix(in srgb, var(--paper) 60%, transparent) }
@media (min-width: 1180px) {
  html { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.28 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"), radial-gradient(ellipse at 50% 30%, var(--binding), var(--binding-2)) fixed }
  body { box-shadow: inset 40px 0 34px -30px rgba(40, 20, 5, 0.45), inset 2px 0 0 rgba(40, 20, 5, 0.2), inset 0 0 90px var(--browning),
      3px 3px 0 -1px var(--paper), 3px 3px 0 0 var(--edge), 6px 6px 0 -1px var(--paper-2), 6px 6px 0 0 var(--edge),
      9px 9px 0 -1px var(--paper), 9px 9px 0 0 var(--edge), 12px 12px 0 -1px var(--paper-2), 12px 12px 0 0 var(--edge),
      0 40px 70px -24px rgba(0, 0, 0, 0.7) }
  /* gilt tooling down the cover board at the spine */
  body::before { background: linear-gradient(to right, transparent 5px, #b8913f 5px, #e2c26f 6px, #b8913f 7px, transparent 7px),
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.28 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"), linear-gradient(to right, var(--binding-2), var(--binding) 55%, var(--binding-2)) }
}

/* ---------- The open volume ----------
   book.js lays the page out as an open book on wide screens (html.bk-open): the header stays as a shelf above, and below it
   the volume lies open on a wooden desk. Thick leather boards with a blind-tooled frame reach past the page block; the
   page block shows its edges as stacks of leaves at the fore-edges, head and tail (the left stack grows and the right
   shrinks as you read, --prog); the gutter falls into shadow between headbands, with a ribbon marker hanging in it; the
   outer corners are dog-eared where a leaf can be turned. The content flows through CSS columns one leaf wide and tall
   (.bk-leaves), so each column is a leaf, and turning shifts the flow by two columns. Sizes come from book.js as custom
   properties on .bk. A turn builds a .bk-flip layer of throwaway clones: a ghost over the leaf that stays, and a .bk-leaf
   with the old page on its front and the new on its back that swings about the gutter. On the home page the book starts
   closed (.bk-closed), front cover up, and opens on a click (.bk-opening). */
html.bk-open, html.bk-open body { height: 100%; overflow: clip }
html.bk-open { background-color: #2a190d;
  background-image: radial-gradient(ellipse at 50% 30%, rgba(255, 214, 150, 0.14), rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.6) 100%), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='400'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.006 0.22' numOctaves='4' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0.42 0 0 0 0.09  0.26 0 0 0 0.045  0.12 0 0 0 0.015  0 0 0 0 1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)'/%3E%3C/svg%3E");
  background-size: auto, 1200px 400px; background-attachment: fixed }
html.bk-open body { max-width: none; margin: 0; padding: 0; box-shadow: none; border-radius: 0; background: none;
  display: flex; flex-direction: column; box-sizing: border-box }
html.bk-open body::before { display: none }
html.bk-open .site-head { position: static; flex: none; border-radius: 0; border-bottom: 1px solid #1a120a; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35) }
html.bk-open:not(.bk-ready) main, html.bk-open:not(.bk-ready) footer.site-foot { visibility: hidden }
.bk-view { display: none } @media (min-width: 1180px) { .bk-view { display: inline-flex } }

.bk { flex: 1; min-height: 0; display: grid; place-items: center; padding: 12px 0 22px; --leather: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='l'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.32 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23l)'/%3E%3C/svg%3E") }
.bk-vol { position: relative; width: calc(2 * var(--page-w) + var(--gutter) + 2 * var(--board)); height: calc(var(--page-h) + 2 * var(--board));
  perspective: 2800px; perspective-origin: 50% 50% }
.bk-body { position: absolute; inset: 0; border-radius: 12px 14px 14px 12px;
  background-color: var(--binding); background-image: var(--leather), linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0) 35%, rgba(0, 0, 0, 0.28));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 -2px 0 rgba(0, 0, 0, 0.45), 0 1px 0 #0a0603,
    0 46px 60px -26px rgba(0, 0, 0, 0.9), 0 18px 26px -12px rgba(0, 0, 0, 0.7), 0 4px 6px rgba(0, 0, 0, 0.45) }
/* a blind-tooled frame with a gilt fillet, run round each board */
.bk-body::before { content: ""; position: absolute; inset: 9px; border-radius: 7px; pointer-events: none;
  border: 1px solid rgba(222, 182, 100, 0.6); outline: 1px solid rgba(0, 0, 0, 0.45); outline-offset: 2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35) }
/* the spine, falling into shadow */
.bk-body::after { content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--board) + var(--page-w) - 14px); width: calc(var(--gutter) + 28px); pointer-events: none;
  background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.45) 30%, rgba(0, 0, 0, 0.8) 50%, rgba(0, 0, 0, 0.45) 70%, transparent) }

/* the page block's edges */
.bk-edge { position: absolute; pointer-events: none; z-index: 1 }
.bk-edge-l, .bk-edge-r { top: calc(var(--board) + 3px); height: calc(var(--page-h) - 2px); background: repeating-linear-gradient(to right, #f2e6c9 0 1px, #c8b287 1px 2px, #e4d5b2 2px 3px) }
.bk-edge-l { left: calc(var(--board) - var(--stack-l)); width: var(--stack-l); border-radius: 4px 0 0 4px;
  box-shadow: -1px 3px 4px rgba(0, 0, 0, 0.45), inset 1px 0 0 rgba(255, 255, 255, 0.4) }
.bk-edge-r { left: calc(var(--board) + 2 * var(--page-w) + var(--gutter)); width: var(--stack-r); border-radius: 0 4px 4px 0;
  box-shadow: 1px 3px 4px rgba(0, 0, 0, 0.45), inset -1px 0 0 rgba(255, 255, 255, 0.4) }
.bk-edge-l::after, .bk-edge-r::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(255, 255, 255, 0.25), transparent 30%, rgba(0, 0, 0, 0.18)) }
.bk-edge-t, .bk-edge-b { left: calc(var(--board) - var(--stack-l)); width: calc(2 * var(--page-w) + var(--gutter) + var(--stack-l) + var(--stack-r)); background: repeating-linear-gradient(to bottom, #f2e6c9 0 1px, #c8b287 1px 2px, #e4d5b2 2px 3px);
  -webkit-mask: linear-gradient(to right, #000 calc(50% - var(--gutter) / 2 + 2px), transparent 0 calc(50% + var(--gutter) / 2 - 2px), #000 0);
  mask: linear-gradient(to right, #000 calc(50% - var(--gutter) / 2 + 2px), transparent 0 calc(50% + var(--gutter) / 2 - 2px), #000 0) }
.bk-edge-t { top: calc(var(--board) - 4px); height: 4px }
.bk-edge-b { top: calc(var(--page-h) + var(--board)); height: 10px; box-shadow: 0 3px 4px rgba(0, 0, 0, 0.5) }
.bk { --stack-l: calc(5px + 16px * var(--prog, 0)); --stack-r: calc(5px + 16px * (1 - var(--prog, 0))) }
.bk-band { position: absolute; left: calc(var(--board) + var(--page-w) - 3px); width: calc(var(--gutter) + 6px); height: 7px; z-index: 2; border-radius: 3px;
  background: repeating-linear-gradient(90deg, #8b2a1a 0 3px, #efe1c2 3px 6px); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6) }
.bk-band-t { top: calc(var(--board) - 8px) } .bk-band-b { top: calc(var(--board) + var(--page-h) + 2px) }
.bk-ribbon { position: absolute; z-index: 3; top: -10px; left: calc(50% - 8px); width: 16px; height: 40%; pointer-events: none;
  background: linear-gradient(to right, #58160e, #a3362a 35%, #8e2c22 65%, #58160e);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 85%, 0 100%); filter: drop-shadow(2px 5px 4px rgba(0, 0, 0, 0.5)) }

.bk-sheet { position: absolute; top: var(--board); width: var(--page-w); height: var(--page-h); z-index: 1; background-color: var(--paper); background-image: var(--tex);
  box-shadow: inset 0 0 70px var(--browning) }
.bk-sheet-l { left: var(--board); border-radius: 4px 0 0 4px }
.bk-sheet-r { left: calc(var(--board) + var(--page-w) + var(--gutter)); border-radius: 0 4px 4px 0 }
.bk-sheet::after { content: ""; position: absolute; inset: 0; pointer-events: none }
.bk-sheet-l::after { background: linear-gradient(to left, rgba(35, 18, 4, 0.5), rgba(35, 18, 4, 0.22) 2.5%, rgba(35, 18, 4, 0.07) 9%, transparent 22%),
  linear-gradient(to right, rgba(255, 255, 255, 0.12), transparent 12%) }
.bk-sheet-r::after { background: linear-gradient(to right, rgba(35, 18, 4, 0.5), rgba(35, 18, 4, 0.22) 2.5%, rgba(35, 18, 4, 0.07) 9%, transparent 22%),
  linear-gradient(to left, rgba(255, 255, 255, 0.12), transparent 12%) }

.bk-rhead { position: absolute; top: 16px; left: var(--pad); right: var(--pad); height: 26px; display: flex; align-items: center; gap: 16px; z-index: 2;
  font: 700 0.72rem/1 var(--label); letter-spacing: 0.1em; text-transform: lowercase; color: var(--muted); border-bottom: 1px solid var(--rule); padding-bottom: 6px }
.bk-rhead-r { justify-content: flex-end }
.bk-title { font: 400 1rem/1 var(--display); letter-spacing: 0.02em; text-transform: none; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.bk-rhead .bk-tabs { max-width: none; margin: 0; padding: 0; border: 0; gap: 4px 14px; overflow: visible; min-width: 0 }
.bk-rhead .bk-tabs .tabs-g { font-size: 0.72rem }
.bk-rhead .bk-tabs .tabs-row { gap: 12px; overflow-x: auto; scrollbar-width: none }
.bk-rhead .bk-tabs .tabs-row::-webkit-scrollbar { display: none }
.bk-rhead .bk-tabs .tabs-row.bk-more { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent) }
.bk-rhead .bk-tabs a { padding: 0 0 2px; margin: 0; font: 500 0.82rem/1 var(--sans); border-bottom: 1px solid transparent; white-space: nowrap }
.bk-rhead .bk-tabs a[aria-current="page"] { border-bottom-color: var(--ink) }
.bk-contents-btn { margin-left: auto; font: 700 0.72rem/1 var(--label); letter-spacing: 0.1em; text-transform: lowercase; color: var(--accent); background: none; border: 0; padding: 0 0 2px; border-bottom: 1px dotted var(--accent) }
.bk-contents { position: absolute; top: 32px; right: 0; z-index: 6; width: min(320px, 100%); max-height: calc(var(--page-h) - 110px); overflow: auto;
  background-color: var(--paper); background-image: var(--tex); border: 1px solid var(--rule); box-shadow: var(--panel-shadow); padding: 12px 14px;
  font: 400 0.95rem/1.4 var(--sans); letter-spacing: 0; text-transform: none }
.bk-contents .rail { position: static; max-height: none; overflow: visible }
.bk-contents .rail li > ol { display: block }
.bk-folio { position: absolute; bottom: 15px; left: var(--pad); right: var(--pad); text-align: center; font: 500 0.82rem/1 var(--label); letter-spacing: 0.1em; color: var(--muted) }
.bk-folio::before, .bk-folio::after { content: "—"; margin: 0 8px; opacity: 0.6 }
.bk-folio:empty::before, .bk-folio:empty::after { content: none }

.bk-spread { position: absolute; left: var(--board); top: var(--board); width: calc(2 * var(--page-w) + var(--gutter)); height: var(--page-h); overflow: clip; z-index: 2 }
.bk-leaves { position: absolute; left: var(--pad); top: var(--pad-top); width: var(--col-w); height: var(--col-h);
  column-width: var(--col-w); column-gap: var(--col-gap); column-fill: auto; will-change: transform }
.bk-end { display: inline-block; width: 1px; height: 1px }
/* dog-eared corners: the next leaf is turned from the bottom outer corner */
.bk-turn { position: absolute; bottom: var(--board); width: 46px; height: 46px; border: 0; padding: 0; z-index: 4; cursor: pointer; transition: transform 0.25s;
  filter: drop-shadow(-1px -1px 2px rgba(0, 0, 0, 0.25)) }
.bk-turn-r { right: var(--board); transform-origin: 100% 100%; border-radius: 0 0 4px 0;
  background: linear-gradient(to bottom right, var(--paper-2) 0 48%, rgba(0, 0, 0, 0.28) 48% 51%, rgba(50, 30, 10, 0.42) 51%) }
.bk-turn-l { left: var(--board); transform-origin: 0 100%; border-radius: 0 0 0 4px;
  background: linear-gradient(to bottom left, var(--paper-2) 0 48%, rgba(0, 0, 0, 0.28) 48% 51%, rgba(50, 30, 10, 0.42) 51%) }
.bk-turn:not([disabled]):hover, .bk-turn:not([disabled]):focus-visible { transform: scale(1.4) }
.bk-turn[disabled] { visibility: hidden }

/* the turn itself */
.bk-flip { position: absolute; left: var(--board); top: var(--board); width: calc(2 * var(--page-w) + var(--gutter)); height: var(--page-h); z-index: 3;
  perspective: 2600px; perspective-origin: 50% 50%; pointer-events: none }
.bk-win { position: absolute; overflow: clip; background-color: var(--paper); background-image: var(--tex); width: var(--col-w); height: var(--col-h); top: var(--pad-top) }
.bk-flip > .bk-win-l { left: var(--pad) } .bk-flip > .bk-win-r { left: calc(var(--page-w) + var(--gutter) + var(--pad)) }
.bk-win > .bk-leaves { left: 0; top: 0; will-change: auto }
.bk-leaf { position: absolute; top: 0; width: var(--page-w); height: var(--page-h); transform-style: preserve-3d;
  transition: transform 0.95s cubic-bezier(0.42, 0.02, 0.5, 1) }
.bk-flip.bk-fwd .bk-leaf { left: calc(var(--page-w) + var(--gutter)); transform-origin: calc(var(--gutter) * -0.5) 50% }
.bk-flip.bk-back .bk-leaf { left: 0; transform-origin: calc(100% + var(--gutter) * 0.5) 50% }
.bk-flip.bk-fwd.bk-go .bk-leaf { transform: rotateY(-180deg) }
.bk-flip.bk-back.bk-go .bk-leaf { transform: rotateY(180deg) }
.bk-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: clip;
  background-color: var(--paper); background-image: var(--tex); box-shadow: inset 0 0 70px var(--browning) }
.bk-face.bk-back { transform: rotateY(180deg) }
.bk-face > .bk-win { left: var(--pad); background: none }
.bk-face::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.95s ease-in-out }
.bk-flip.bk-fwd .bk-face.bk-front::after { background: linear-gradient(to right, rgba(20, 10, 0, 0.5), rgba(20, 10, 0, 0.08) 60%) }
.bk-flip.bk-back .bk-face.bk-front::after { background: linear-gradient(to left, rgba(20, 10, 0, 0.5), rgba(20, 10, 0, 0.08) 60%) }
.bk-flip.bk-go .bk-face.bk-front::after { opacity: 1 }
.bk-leaf::before { content: ""; position: absolute; inset: 0; box-shadow: 0 0 40px rgba(0, 0, 0, 0.35); opacity: 0; transition: opacity 0.4s }
.bk-flip.bk-go .bk-leaf::before { opacity: 1 }

/* the closed book: the front cover lies over the page block, hinged at the spine; a click swings it open */
.bk-cover { position: absolute; top: 0; left: calc(var(--board) + var(--page-w) + var(--gutter) / 2); width: calc(var(--page-w) + var(--board) + var(--gutter) / 2); height: 100%;
  transform-origin: 0 50%; transform-style: preserve-3d; z-index: 10; cursor: pointer; border: 0; padding: 0; background: none; text-align: center }
.bk-cover-front, .bk-cover-back { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden }
.bk-cover-front { border-radius: 0 14px 14px 0; color: #dcb565; display: grid; place-content: center; gap: 12px; padding: 40px;
  background-color: var(--binding); background-image: var(--leather), linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 35%, rgba(0, 0, 0, 0.3));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset -2px 0 0 rgba(0, 0, 0, 0.4), 0 40px 50px -24px rgba(0, 0, 0, 0.9), 0 6px 8px rgba(0, 0, 0, 0.45) }
.bk-cover-front::before { content: ""; position: absolute; inset: 18px 18px 18px 14px; border-radius: 6px; pointer-events: none;
  border: 2px solid rgba(222, 182, 100, 0.6); outline: 1px solid rgba(222, 182, 100, 0.45); outline-offset: 5px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4) }
.bk-cover-front .dq-mark { height: 120px; width: auto; margin: 0 auto 10px; filter: drop-shadow(0 1px 0 rgba(255, 240, 200, 0.3)) drop-shadow(0 -1px 0 rgba(0, 0, 0, 0.7)) }
.bk-cover-title { font: 400 clamp(1.9rem, 3vw, 2.9rem)/1.05 var(--display); letter-spacing: 0.08em; text-transform: uppercase; margin: 0;
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.3), 0 -1px 0 rgba(0, 0, 0, 0.7) }
.bk-cover-rule { width: 120px; height: 1px; margin: 4px auto; background: linear-gradient(to right, transparent, #dcb565, transparent) }
.bk-cover-motto { font: italic 400 1.2rem/1.3 var(--body); color: #ead9ad; margin: 0; opacity: 0.9 }
.bk-cover-hint { font: 700 0.72rem/1 var(--label); letter-spacing: 0.16em; text-transform: lowercase; margin: 30px 0 0; opacity: 0.7; animation: bk-hint 2.6s ease-in-out infinite }
@keyframes bk-hint { 50% { opacity: 0.3 } }
.bk-cover-back { transform: rotateY(180deg); border-radius: 14px 0 0 14px; background-color: var(--paper-2); background-image: var(--tex);
  box-shadow: inset 0 0 70px var(--browning), inset -50px 0 60px -40px rgba(35, 18, 4, 0.55) }
.bk-closed .bk-vol { transform: translateX(calc((var(--page-w) + var(--board) + var(--gutter) / 2) / -2)) }
.bk-closed .bk-body { clip-path: inset(0 0 0 calc(var(--board) + var(--page-w) + var(--gutter) / 2) round 14px) }
.bk-closed .bk-ribbon { height: 46% }
.bk-opening .bk-vol { transform: none; transition: transform 1.3s cubic-bezier(0.45, 0.05, 0.55, 0.95) }
.bk-opening .bk-cover { transform: rotateY(-180deg); transition: transform 1.3s cubic-bezier(0.45, 0.05, 0.55, 0.95); pointer-events: none }
.bk-opening .bk-body { animation: bk-reveal 1.3s cubic-bezier(0.45, 0.05, 0.55, 0.95) forwards }
@keyframes bk-reveal {
  0%, 46% { clip-path: inset(0 0 0 calc(var(--board) + var(--page-w) + var(--gutter) / 2) round 14px) }
  100% { clip-path: inset(0 round 14px) } }

/* one fold-out plate across both leaves for the tools */
.bk-plate .bk-sheet-l { width: calc(2 * var(--page-w) + var(--gutter)); border-radius: 4px }
.bk-plate .bk-sheet-l::after, .bk-plate .bk-sheet-r { background: none; box-shadow: none }
.bk-plate .bk-body::after, .bk-plate .bk-turn, .bk-plate .bk-folio, .bk-plate .bk-ribbon, .bk-plate .bk-band { display: none }
.bk-plate .bk-leaves { width: calc(2 * var(--page-w) + var(--gutter) - 2 * var(--pad)); height: calc(var(--page-h) - var(--pad-top) - 24px);
  column-width: auto; column-gap: normal; overflow: auto; overscroll-behavior: contain }
.bk-plate .page-hero { display: none }

/* content, re-set for a leaf */
html.bk-open .bk-leaves main { display: block }
html.bk-open .bk-leaves p { max-width: none; orphans: 2; widows: 2; text-align: justify; hyphens: auto; -webkit-hyphens: auto; text-wrap: pretty }
html.bk-open .bk-leaves .page-hero, html.bk-open .bk-leaves .page-hero p { text-align: center }
html.bk-open .bk-leaves .page-hero .lede { margin-inline: auto }
html.bk-open .bk-leaves section.chapter > h2 { text-align: center }
html.bk-open .bk-leaves section.chapter > h2::after { margin: 8px auto 0 }
html.bk-open .bk-leaves h2, html.bk-open .bk-leaves h3, html.bk-open .bk-leaves h4 { break-after: avoid }
html.bk-open .bk-leaves img, html.bk-open .bk-leaves svg, html.bk-open .bk-leaves canvas, html.bk-open .bk-leaves video { max-width: 100%; max-height: calc(var(--col-h) - 40px) }
html.bk-open .bk-leaves .mount img, html.bk-open .bk-leaves .city-plate img, html.bk-open .bk-leaves .plate-main img { width: auto; height: auto; max-width: 100%; max-height: calc(var(--col-h) - 90px); margin: 0 auto }
html.bk-open .bk-leaves figure, html.bk-open .bk-leaves .mount, html.bk-open .bk-leaves .facts, html.bk-open .bk-leaves .tool, html.bk-open .bk-leaves .kx-tool, html.bk-open .bk-leaves .ledger,
html.bk-open .bk-leaves blockquote, html.bk-open .bk-leaves pre, html.bk-open .bk-leaves .kx-person-card, html.bk-open .bk-leaves .mapfig, html.bk-open .bk-leaves .plate-strip figure,
html.bk-open .bk-leaves .gamebook, html.bk-open .bk-leaves .coin, html.bk-open .bk-leaves .timeline li { break-inside: avoid }
html.bk-open .bk-leaves .page-hero { display: block; max-width: none; margin: 0; padding: 0 0 20px; break-after: column }
html.bk-open .bk-leaves .page-hero h1 { font-size: 3rem; line-height: 1.02 }
html.bk-open .bk-leaves .page-hero .lede { font-size: 1.15rem }
html.bk-open .bk-leaves .page-hero figure, html.bk-open .bk-leaves .page-hero .mount { margin: 22px 0 0; max-width: 100% }
html.bk-open .bk-leaves .page-hero img { max-height: calc(var(--col-h) * 0.5); width: auto; max-width: 100%; margin: 0 auto }
html.bk-open .bk-leaves .page-body { display: block; max-width: none; margin: 0; padding: 0 }
html.bk-open .bk-leaves .page-body.has-rail { display: block }
html.bk-open .bk-leaves section.chapter { break-before: column; border-top: 0; padding: 0 0 12px }
html.bk-open .bk-leaves .page-body > section.chapter:first-child, html.bk-open .bk-leaves .pb-main > section.chapter:first-of-type { padding-top: 0 }
html.bk-open .bk-leaves section.chapter > h2 { margin-top: 0 }
html.bk-open .bk-leaves .kx-gaz-tools, html.bk-open .bk-leaves .race-plate { position: static }
html.bk-open .bk-leaves .tbl { overflow: visible }
html.bk-open .bk-leaves pre { white-space: pre-wrap; overflow: visible; word-break: break-word }
html.bk-open .bk-leaves table.beliefs td { min-width: 0 }
html.bk-open .bk-leaves table { font-size: 0.88rem }
html.bk-open .bk-leaves th, html.bk-open .bk-leaves td { white-space: normal; min-width: 0 }
html.bk-open .bk-leaves .books-grid > * { break-inside: avoid }
html.bk-open .bk-leaves .kx-pager { break-before: column; max-width: none; margin: 0 0 28px; padding: 0; grid-template-columns: 1fr }
html.bk-open .bk-leaves .kx-pager a[rel="next"] { grid-column: auto }
html.bk-open .bk-leaves .site-foot { border: 0; background: none; margin-top: 10px }
html.bk-open .bk-leaves .site-foot .cols { grid-template-columns: 1fr 1fr; padding: 0; gap: 14px 24px; max-width: none }
html.bk-open .bk-leaves .site-foot .foot-about { grid-column: 1 / -1 }
html.bk-open .bk-leaves .home-hero { grid-template-columns: 1fr; max-width: none; padding: 0; gap: 18px; break-after: column }
html.bk-open .bk-leaves .home-hero h1.dq-lockup { font-size: 3.2rem }
html.bk-open .bk-leaves .home-hero img { max-height: calc(var(--col-h) * 0.36); width: auto; max-width: 100%; margin: 0 auto }
html.bk-open .bk-leaves .ledger { grid-template-columns: 1fr 1fr; max-width: none; padding: 0 }
html.bk-open .bk-leaves .home-sec { max-width: none; padding: 0; break-before: column }
html.bk-open .bk-leaves .home-sec:last-of-type { padding-bottom: 0 }
html.bk-open .bk-leaves .books-grid { grid-template-columns: 1fr; gap: 20px; margin: 16px 0 }
html.bk-open .bk-leaves .two { grid-template-columns: 1fr }
html.bk-open .bk-leaves .kx-hb { grid-template-columns: 1fr }

/* Moving to another page of the site while the volume is open turns the whole volume as one leaf (the desk and the
   shelf stay put), instead of the root flip the scrolling layout uses. */
html.bk-open.turning .bk-vol { view-transition-name: volume }
html.bk-open::view-transition-old(root), html.bk-open::view-transition-new(root) { animation: none; mix-blend-mode: normal }
::view-transition-group(volume) { animation-duration: 0.85s }
::view-transition-image-pair(volume) { isolation: auto }
::view-transition-old(volume), ::view-transition-new(volume) { mix-blend-mode: normal; transform-origin: 0 50%; backface-visibility: hidden }
::view-transition-old(volume) { z-index: 2; animation: leaf-away 0.85s cubic-bezier(0.5, 0, 0.6, 1) both }
::view-transition-new(volume) { z-index: 1; animation: leaf-under 0.85s ease-out both }
html:active-view-transition-type(turn-back)::view-transition-old(volume) { z-index: 1; animation: leaf-under-back 0.85s ease-in both }
html:active-view-transition-type(turn-back)::view-transition-new(volume) { z-index: 2; animation: leaf-return 0.85s cubic-bezier(0.4, 0, 0.5, 1) both }


/* ---------- The Archive ----------
   The home page as a WebGL library (archive.js). It fills the window under the header; the open book is hidden while
   the room shows (html.bk-archive). Labels name what the pointer rests on; .ar-leaving fades to black as a thing is
   taken down and its page opens. */
html.bk-archive .bk { display: none }
.ar { position: fixed; left: 0; right: 0; bottom: 0; top: var(--head-h); z-index: 5; background: #0d0905; overflow: hidden; outline: none }
.ar[hidden] { display: none }
.ar canvas { display: block; width: 100% !important; height: 100% !important }
.ar::after { content: ""; position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.45s ease-in }
.ar.ar-leaving::after { opacity: 1 }
.ar-label { position: absolute; z-index: 2; pointer-events: none; transform: translate(-50%, -100%); max-width: 280px; padding: 9px 13px 10px;
  background: #efe3c4; color: #2a1c10; border: 1px solid #c9b384; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55); font: 0.86rem/1.35 var(--sans) }
.ar-label b { display: block; font: 400 1.1rem/1.15 var(--display); margin-bottom: 3px }
.ar-label::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 10px; background: #efe3c4; border-right: 1px solid #c9b384; border-bottom: 1px solid #c9b384; transform: translateX(-50%) rotate(45deg) }
.ar-hint { position: absolute; left: 0; right: 0; bottom: 18px; margin: 0; text-align: center; color: #d9b25f; font: 700 0.72rem/1 var(--label); letter-spacing: 0.16em; text-transform: lowercase;
  opacity: 0.85; transition: opacity 1.2s; pointer-events: none; text-shadow: 0 1px 2px #000 }
.ar-hint.ar-hint-fade { opacity: 0 }
.bk-archive-link { font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--accent); text-decoration: none; background: none; border: 0; padding: 0 0 2px; margin-right: 4px; border-bottom: 1px dotted var(--accent) }

/* the music button: lit while the piece plays */
.music-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent) }
.music-btn span { font: 500 0.95rem var(--sans) }

/* ---------- The atlas as a fold-out chart ----------
   The map's own canvas, image and hatching overlay must never be resized by the leaf rules above (a capped canvas is
   drawn squashed while the pins keep their true places). In the plate the chart fills the full height, the finder
   scrolls beside it, and nothing scrolls the plate itself; the heights are made definite all the way down so the map
   can take exactly the room that is left. */
html.bk-open .bk-leaves .osd canvas, html.bk-open .bk-leaves .osd img, html.bk-open .bk-leaves .osd svg { max-width: none; max-height: none; width: 100%; height: 100% }
html.bk-open .bk-plate .bk-leaves:has(.atlas-layout) { overflow: hidden }
html.bk-open .bk-plate .bk-leaves > main:has(.atlas-layout) { height: 100% }
html.bk-open .bk-plate .bk-leaves:has(.atlas-layout) > footer { display: none }
html.bk-open .bk-plate .atlas-layout { height: 100%; max-width: none; padding: 0; gap: 14px; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); align-items: stretch }
html.bk-open .bk-plate .atlas-side { max-height: 100%; min-height: 0; overflow: auto; padding-right: 8px }
html.bk-open .bk-plate .atlas-main { display: flex; flex-direction: column; min-height: 0; height: 100% }
html.bk-open .bk-plate .atlas-main .mapfig { flex: 1; min-height: 0; display: flex; flex-direction: column }
html.bk-open .bk-plate .atlas-main .osd { flex: 1; min-height: 0; height: auto; aspect-ratio: auto }

/* ---------- Keeping things together on a leaf ----------
   A heading never ends a leaf while what it names starts the next: a realm's title, badge and arms stay with its fact
   table, a creature's or wonder's title with its plate, a "Life & lore" line with the entry it belongs to. */
html.bk-open .bk-leaves details.lore { break-before: avoid; break-inside: avoid }
html.bk-open .bk-leaves .state > h4, html.bk-open .bk-leaves .state > .bloc { break-after: avoid }
html.bk-open .bk-leaves .state .facts { break-before: avoid; break-inside: avoid }
html.bk-open .bk-leaves figure.mount, html.bk-open .bk-leaves .plate, html.bk-open .bk-leaves .plate-main, html.bk-open .bk-leaves .plate-strip { break-before: avoid }
html.bk-open .bk-leaves h2 + .small, html.bk-open .bk-leaves h3 + .small, html.bk-open .bk-leaves h4 + .small, html.bk-open .bk-leaves h3 + p.small { break-after: avoid }

/* the journey on the map */
.j-route { overflow: visible }
.j-label { font: 600 12px/1.2 var(--sans); color: #efe3c4; background: #8b2a1a; border: 1px solid #efe3c4; border-radius: 3px; padding: 3px 8px; white-space: nowrap; pointer-events: none; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4) }
.atlas-journey.j-flash { animation: j-flash 1.4s ease-out }
@keyframes j-flash { 0% { box-shadow: 0 0 0 3px var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent) } 100% { box-shadow: 0 0 0 0 transparent; background: transparent } }
.mappanel .j-note { margin: 8px 0 0; color: var(--accent) }

/* the peoples: plate above the text in a leaf, not beside it in a squeezed column; the seven-people strip in two rows */
html.bk-open .bk-leaves .race-block { grid-template-columns: minmax(0, 1fr); gap: 12px }
html.bk-open .bk-leaves .race-plate { order: -1; position: static; max-width: 100% }
html.bk-open .bk-leaves .plate-main img { max-height: calc(var(--col-h) * 0.55); width: auto; max-width: 100%; margin: 0 auto }
html.bk-open .bk-leaves .people { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px }

/* card grids stack in a leaf: a grid fragments badly across columns (it jumps whole to the next leaf, stranding its
   heading), so in the book the cards become a simple run that flows like text */
html.bk-open .bk-leaves .cities, html.bk-open .bk-leaves .states { display: block }
html.bk-open .bk-leaves .cities > *, html.bk-open .bk-leaves .states > .state { break-inside: auto; margin-bottom: 14px }  /* long cards run on to the next leaf; book.js keeps each card's title with its start */

/* a fold-out plate is one sheet: no fold shadow from either leaf, no gap in the page edges at the gutter */
.bk-plate .bk-sheet-r::after, .bk-plate .bk-sheet-l::after { display: none }
.bk-plate .bk-sheet-r { display: none }
.bk-plate .bk-edge-t, .bk-plate .bk-edge-b { -webkit-mask: none; mask: none }
.bk-plate .bk-sheet-l { box-shadow: inset 0 0 70px var(--browning) }
/* the atlas finder in the plate: layers sit up top where they can be seen and clicked; the list scrolls below them */
html.bk-open .bk-plate .atlas-side { display: flex; flex-direction: column; gap: 14px }
html.bk-open .bk-plate .atlas-side > * { flex: none }
html.bk-open .bk-plate .atlas-side > :has(> .layers) { order: 1 }
html.bk-open .bk-plate .atlas-side > .atlas-search { order: 2 }
html.bk-open .bk-plate .atlas-side > .atlas-journey { order: 3 }

/* ================= The other artefacts =================
   book.js renders each page as what it is (data-artefact on <body>, set by ARTEFACT in chrome_build.py): scrolls unroll
   between rollers, the atlas lies on a map table, the ledgers are ruled account books, and the tools sit on the desk as
   a working sheet, a card on baize or a drafting board. They share the bar over them (.af-bar) and fill the window
   under the header; only the parchment or the piece scrolls. */
.af-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: 8px 24px 18px; gap: 8px }
.af-bar { position: relative; width: min(1240px, 100%); display: flex; align-items: center; gap: 18px; min-height: 30px; padding: 4px 14px;
  font: 700 0.72rem/1 var(--label); letter-spacing: 0.1em; text-transform: lowercase; color: #e9d9b4;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.2)); border: 1px solid rgba(255, 220, 160, 0.12); border-radius: 4px }
.af-bar .bk-archive-link { color: #e9b77a; border-bottom-color: #e9b77a }
.af-bar .bk-tabs { max-width: none; margin: 0; padding: 0; border: 0; gap: 4px 14px; overflow: visible; min-width: 0 }
.af-bar .bk-tabs .tabs-g { color: #c9b48a; font-size: 0.72rem }
.af-bar .bk-tabs .tabs-row { gap: 14px; overflow-x: auto; scrollbar-width: none }
.af-bar .bk-tabs a { padding: 0 0 2px; margin: 0; font: 500 0.84rem/1 var(--sans); color: #d8c7a0; border-bottom: 1px solid transparent; white-space: nowrap }
.af-bar .bk-tabs a:hover { color: #fff3d6 } .af-bar .bk-tabs a[aria-current="page"] { color: #fff3d6; border-bottom-color: #e9b77a }
.af-bar .bk-contents-btn { color: #e9b77a; border-bottom-color: #e9b77a }
.af-bar .bk-contents { top: 34px; right: 8px; color: var(--ink) }
html.bk-open.turning .af-shell { view-transition-name: artefact }
.af-shell main { display: block }

/* ---------- The scroll ---------- */
.sc-body { position: relative; flex: 1; min-height: 0; width: min(900px, 76vw); display: flex; flex-direction: column; filter: drop-shadow(0 22px 26px rgba(0, 0, 0, 0.55)) }
.sc-roll { position: relative; z-index: 2; flex: none; height: 34px; margin: 0 -30px; border-radius: 17px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0) 32%, rgba(255, 230, 190, 0.28) 44%, rgba(0, 0, 0, 0) 56%, rgba(0, 0, 0, 0.6)),
    repeating-linear-gradient(to bottom, #6e4422 0 3px, #87572d 3px 5px, #5d381b 5px 8px, #7b4d27 8px 11px);
  background-position: 0 0, 0 var(--roll, 0px); box-shadow: 0 6px 10px rgba(0, 0, 0, 0.45) }
.sc-knob { position: absolute; top: -9px; left: -26px; width: 30px; height: 52px; border-radius: 45%;
  background: radial-gradient(ellipse at 35% 30%, #fff1b8, #d9b25f 25%, #8a6420 65%, #4a330c); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5) }
.sc-knob-r { left: auto; right: -26px }
.sc-sheet { position: relative; z-index: 1; flex: 1; min-height: 0; margin: -8px 0; overflow-y: auto; scrollbar-width: none; overscroll-behavior: contain;
  background-color: var(--paper); background-image: var(--tex);
  box-shadow: inset 0 18px 20px -12px rgba(40, 20, 5, 0.6), inset 0 -18px 20px -12px rgba(40, 20, 5, 0.6), inset 14px 0 18px -14px rgba(40, 20, 5, 0.45), inset -14px 0 18px -14px rgba(40, 20, 5, 0.45), inset 0 0 70px var(--browning) }
.sc-sheet::-webkit-scrollbar { display: none }
.sc-text { max-width: 72ch; margin: 0 auto; padding: 46px 52px 70px }
.sc-unroll .sc-sheet { animation: sc-open 1.3s cubic-bezier(0.3, 0, 0.3, 1) both }
.sc-unroll .sc-roll-b { animation: sc-roll-down 1.3s cubic-bezier(0.3, 0, 0.3, 1) both }
@keyframes sc-open { from { clip-path: inset(0 0 100% 0) } to { clip-path: inset(0 0 0 0) } }
@keyframes sc-roll-down { from { transform: translateY(calc(-1 * var(--sh, 600px))) } to { transform: none } }
.sc-text .page-hero { display: block; max-width: none; padding: 0 0 26px; text-align: center; border-bottom: 1px solid var(--rule); margin-bottom: 10px }
.sc-text .page-hero .lede { margin-inline: auto }
.sc-text .page-hero figure { max-width: 420px; margin: 20px auto 0 }
.sc-text .page-body, .sc-text .page-body.has-rail { display: block; max-width: none; padding: 0 }
.sc-text p { text-align: justify; hyphens: auto }
.sc-text section.chapter > h2 { text-align: center }
.sc-text section.chapter > h2::after { margin: 8px auto 0 }
.sc-text .kx-gaz-tools { top: -46px; background-color: var(--paper); background-image: var(--tex) }
.sc-text .kx-pager { max-width: none; padding: 30px 0 0 }
.sc-text .tbl { margin-inline: -8px }

/* ---------- The ledger: a cloth-bound account book with ruled leaves ---------- */
.bk-ledger { --binding: #2f3f35; --binding-2: #18221c }
.bk-ledger .bk-sheet { background-image:
    linear-gradient(to right, transparent 34px, rgba(150, 38, 28, 0.42) 34px 35px, transparent 35px 38px, rgba(150, 38, 28, 0.42) 38px 39px, transparent 39px),
    repeating-linear-gradient(to bottom, transparent 0 25px, rgba(60, 90, 130, 0.2) 25px 26px), var(--tex);
  background-position: 0 0, 0 54px, 0 0 }
.bk-ledger .bk-title { font-family: var(--label); letter-spacing: 0.08em; text-transform: lowercase }
.bk-ledger .bk-ribbon { background: linear-gradient(to right, #1d3326, #3c6a4c 35%, #2f5a3e 65%, #1d3326) }

/* ---------- Desk pieces: the chart, the working sheet, the baize card, the drafting board ---------- */
.dk-surface { position: relative; flex: 1; min-height: 0; width: min(1360px, 100%); display: flex; justify-content: center }
.dk-piece { position: relative; flex: 1; min-height: 0; max-width: 1300px; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin }
.dk main > .page-hero { max-width: none; padding: 20px 0 16px }
.dk main > .page-body, .dk main > .play, .dk main > .play-ref, .dk main > .ed-layout { max-width: none }
.dk main > .kx-pager { display: none }
/* the working sheet: parchment pinned to the desk */
.dk-sheet .dk-piece, .dk-baize .dk-piece { background-color: var(--paper); background-image: var(--tex); padding: 10px 36px 30px;
  box-shadow: inset 0 0 70px var(--browning), 0 1px 0 rgba(255, 255, 255, 0.3), 0 26px 40px -18px rgba(0, 0, 0, 0.8), 0 4px 10px rgba(0, 0, 0, 0.4) }
.dk-sheet .dk-surface::before, .dk-sheet .dk-surface::after, .dk-baize .dk-surface::before, .dk-baize .dk-surface::after { content: ""; position: absolute; z-index: 3; top: -6px; width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1b8, #d9b25f 30%, #7a5a1a 75%); box-shadow: 0 3px 4px rgba(0, 0, 0, 0.5); pointer-events: none }
.dk-surface::before { left: calc(50% - 600px) } .dk-surface::after { right: calc(50% - 600px) }
/* the tavern pieces lie on green baize */
html.af-baize { background-color: #1f3a2a;
  background-image: radial-gradient(ellipse at 50% 30%, rgba(255, 240, 200, 0.12), rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.55)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.25 0 0 0 0 0.15 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") }
.dk-baize .dk-piece { border-radius: 10px; max-width: 1180px }
/* the drafting board: grid paper clamped to a wooden board */
.dk-draft .dk-surface { padding: 14px; border-radius: 6px; max-width: 1760px; width: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.25)), #6a4524; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35), 0 24px 40px -16px rgba(0, 0, 0, 0.8) }
.dk-draft .dk-piece { max-width: none; background-color: #e9eef0;
  background-image: linear-gradient(rgba(60, 100, 150, 0.16) 1px, transparent 1px), linear-gradient(90deg, rgba(60, 100, 150, 0.16) 1px, transparent 1px),
    linear-gradient(rgba(60, 100, 150, 0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(60, 100, 150, 0.08) 1px, transparent 1px);
  background-size: 60px 60px, 60px 60px, 12px 12px, 12px 12px; color: #1d2420; padding: 6px 12px 16px }
/* the chart: the atlas on a leather map table, the finder in a notebook beside it */
html.af-chart { background-color: #20262a;
  background-image: radial-gradient(ellipse at 55% 40%, rgba(255, 220, 160, 0.12), rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.6)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.12 0 0 0 0 0.16 0 0 0 0 0.18 0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") }
.dk-chart .dk-surface { max-width: 1500px; width: 100%; border: 10px solid #4a3220; border-radius: 6px; padding: 16px;
  box-shadow: inset 0 0 0 1px rgba(217, 178, 95, 0.55), inset 0 0 40px rgba(0, 0, 0, 0.6), 0 26px 40px -18px rgba(0, 0, 0, 0.9) }
.dk-chart .dk-piece { overflow: hidden; max-width: none; display: flex }
.dk-chart main { flex: 1; min-height: 0; display: flex }
.dk-chart .atlas-layout { flex: 1; min-height: 0; height: auto; max-width: none; padding: 0; gap: 22px; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) }
.dk-chart .atlas-side { min-height: 0; overflow: auto; padding: 16px 16px 16px 30px; transform: rotate(-0.6deg);
  background-color: #efe3c4; background-image: var(--tex); color: #2a1c10;
  border-left: 16px solid #5a2a18; box-shadow: inset 4px 0 6px -2px rgba(0, 0, 0, 0.35), 0 18px 26px -14px rgba(0, 0, 0, 0.9), 0 3px 6px rgba(0, 0, 0, 0.4);
  outline: 1px dashed rgba(217, 178, 95, 0.6); outline-offset: -26px }
.dk-chart .atlas-main { position: relative; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 12px;
  background-color: #eadcb8; background-image: var(--tex); box-shadow: inset 0 0 60px rgba(120, 80, 30, 0.35), 0 22px 30px -16px rgba(0, 0, 0, 0.9), 0 3px 8px rgba(0, 0, 0, 0.45) }
.dk-chart .atlas-main::before, .dk-chart .atlas-main::after { content: ""; position: absolute; z-index: 5; top: 6px; width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1b8, #d9b25f 30%, #7a5a1a 75%); box-shadow: 0 3px 4px rgba(0, 0, 0, 0.5); pointer-events: none }
.dk-chart .atlas-main::before { left: 6px } .dk-chart .atlas-main::after { right: 6px }
.dk-chart .atlas-main .mapfig { flex: 1; min-height: 0; display: flex; flex-direction: column; border-color: #b49a6a; background: #d6c49a }
.dk-chart .atlas-main .osd { flex: 1; min-height: 0; aspect-ratio: auto; background: #cdb98d }
.dk-chart .osd canvas, .dk-chart .osd svg { max-width: none; max-height: none }
.dk-rose { position: absolute; z-index: 6; right: -34px; bottom: -34px; width: 120px; height: 120px; color: #d9b25f; opacity: 0.85; pointer-events: none; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.6)) }
.dk-rose svg { width: 100%; height: 100% }
/* the hero builder's <body class="page-hero"> must not pick up the .page-hero section rules (it was being centred and narrowed) */
body.page-hero { display: block; max-width: none; margin: 0; padding: 0; gap: 0; align-items: normal; grid-template-columns: none }
html.bk-open body.page-hero { display: flex; flex-direction: column }
/* on the desk, the contents rail lives in the bar: the page body's rail column goes */
.dk .page-body, .dk .page-body.has-rail { display: block; max-width: none; padding: 0 0 30px }
.dk-rose { right: -18px; bottom: -18px; width: 110px; height: 110px }

/* ---------- The window ----------
   sky.js: a round window in the header in place of the light/dark switch, showing the world outside by the reader's
   clock; clicking it opens a large leaded window with a look-ahead slider, the programme and the lamp setting. */
.theme-btn[hidden] { display: none }
.sky-btn { width: 40px; height: 40px; padding: 0; border-radius: 50%; border: 3px solid #6a4524; overflow: hidden; position: relative;
  box-shadow: inset 0 0 0 1px rgba(217, 178, 95, 0.7), 0 2px 5px rgba(0, 0, 0, 0.35) }
.sky-btn canvas { width: 100%; height: 100%; display: block }
.sky-btn::after { content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: linear-gradient(transparent calc(50% - 1px), #3a2614 calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)), linear-gradient(90deg, transparent calc(50% - 1px), #3a2614 calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) }
.sky-view { position: fixed; z-index: 95; top: calc(var(--head-h) + 10px); right: max(16px, calc(50% - 640px)); width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - var(--head-h) - 24px); overflow: auto;
  background-color: var(--paper); background-image: var(--tex); color: var(--ink); border: 1px solid var(--rule); box-shadow: var(--panel-shadow); padding: 18px; display: grid; gap: 14px }
.sky-view[hidden] { display: none }
.sky-frame { position: relative; border: 12px solid #5a3a1c; border-radius: 200px 200px 6px 6px; overflow: hidden; box-shadow: inset 0 0 0 2px rgba(217, 178, 95, 0.6), 0 8px 18px rgba(0, 0, 0, 0.4); background: #000 }
.sky-frame canvas { display: block; width: 100%; height: auto }
.sky-bar { position: absolute; background: #3a2614; box-shadow: 0 0 0 1px rgba(217, 178, 95, 0.35) }
.sky-bar-v { left: calc(50% - 4px); top: 0; bottom: 0; width: 8px } .sky-bar-h { top: 46%; left: 0; right: 0; height: 8px }
.sky-info { position: relative; display: grid; gap: 6px }
.sky-line { font: 400 1.4rem/1.2 var(--display); margin: 0 }
.sky-notes { margin: 0; color: var(--accent); font-style: italic }
.sky-ahead { display: flex; align-items: center; gap: 10px; margin-top: 6px } .sky-ahead input { flex: 1 } .sky-when { min-width: 5em; text-align: right; color: var(--ink) }
.sky-next { margin: 0; padding-left: 18px; display: grid; gap: 3px } .sky-next b { font-weight: 600 }
.sky-lamp button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink) }
.sky-x { position: absolute; top: -6px; right: -4px; border: 0; background: none; font: 1.4rem var(--sans); color: var(--muted) }

/* ================= Zone editor and Zones page ================= */
.ed-layout { display: grid; grid-template-columns: 252px minmax(0, 1fr) 330px; gap: 14px; padding: 10px 16px 28px; max-width: 1700px; margin: 0 auto }
.ed-left, .ed-right { display: grid; align-content: start; gap: 12px; min-width: 0 }
.ed-main { min-width: 0; display: grid; align-content: start; gap: 8px }
.ed-panel { border: 1px solid var(--rule); background: var(--paper-2); padding: 10px 12px 12px; border-radius: 6px; min-width: 0 }
.ed-panel h2 { font-size: 1.15rem; margin: 0 0 8px }
.ed-panel .label { display: block; margin: 8px 0 4px }
.ed-panel select { max-width: 100% } #ed-pick { width: 100% }
.tile-btn.undrawn { opacity: 0.7 } .tile-btn.undrawn img { filter: contrast(0.6) }
.ed-panel details { margin: 4px 0 } .ed-panel summary { cursor: pointer; font: 600 0.9rem var(--sans); padding: 4px 0 }
.ed-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0 }
.ed-bar input[type="text"] { flex: 1 1 200px; min-width: 120px; font: 1.1rem var(--display); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: 6px 10px }
.ed-bar .btn, .ed-panel .btn { padding: 5px 11px; font-size: 0.88rem }
.ed-bar .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
.ed-bar .sep { width: 1px; height: 24px; background: var(--rule); margin: 0 2px }
.ed-bar .small { white-space: nowrap }
.ed-canvas-wrap { overflow: auto; border: 1px solid var(--rule); background: #cfd4ce; padding: 14px; height: min(78vh, 900px); min-height: 360px; border-radius: 4px }
#ed-canvas { display: block; background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3); touch-action: none }
#ed-status { font: 0.88rem/1.4 var(--sans); color: var(--muted); min-height: 1.5em; padding: 0 2px }
.tool-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 4px }
.tool-row button, .kind-row button { font: 500 0.82rem/1.2 var(--sans); border: 1px solid var(--rule); background: var(--paper); color: var(--ink); border-radius: 6px; padding: 7px 4px; cursor: pointer; display: grid; justify-items: center; gap: 2px }
.tool-row button kbd { font: 0.68rem var(--sans); color: var(--muted) }
.tool-row button[aria-pressed="true"], .kind-row button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
.tool-row button[aria-pressed="true"] kbd { color: inherit; opacity: 0.8 }
.kind-row { display: flex; flex-wrap: wrap; gap: 4px } .kind-row button { padding: 5px 9px }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 4px; margin: 4px 0 6px }
.tile-btn { display: grid; gap: 2px; padding: 3px; border: 1px solid var(--rule); background: #fff; font: 0.64rem/1.1 var(--sans); cursor: pointer; color: #333; border-radius: 4px; text-align: center; overflow: hidden }
.tile-btn img { width: 100%; aspect-ratio: 1 / 1; display: block; background: #fff; object-fit: cover }
.tile-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.tile-btn[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) }
.f { display: grid; gap: 3px; margin: 7px 0; font: 0.84rem var(--sans) } .f > span { color: var(--muted) }
.f input, .f select, .f textarea { width: 100%; font-size: 0.95rem; padding: 6px 8px }
.f textarea { font: 0.98rem/1.4 var(--body) }
.row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center }
.btn.danger { color: var(--danger); border-color: var(--danger) }
.enc-row { display: grid; grid-template-columns: 1.4em minmax(0, 1fr); gap: 6px; align-items: center; margin: 3px 0; font: 0.9rem var(--sans) }
.enc-row input { width: 100%; font-size: 0.92rem; padding: 5px 8px }
.mon-list { display: grid; gap: 4px; margin: 6px 0 }
.mon-row { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 6px; align-items: center; font: 0.9rem var(--sans); background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 4px 6px }
.mon-row input { width: 100%; padding: 3px 6px } .mon-row small { display: block; color: var(--muted); font-size: 0.78rem }
.mon-row .x { border: 0; background: none; font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px }
.mon-pick select { font-size: 0.86rem; padding: 4px 6px } .mon-pick input[type="search"] { width: 100%; margin-top: 6px; font-size: 0.92rem; padding: 6px 8px }
.mp-list { max-height: 230px; overflow: auto; display: grid; gap: 2px; margin-top: 6px }
.mp-item { text-align: left; display: grid; padding: 5px 8px; border: 1px solid var(--rule); background: var(--paper); border-radius: 4px; cursor: pointer; font: 0.88rem var(--sans); color: var(--ink) }
.mp-item small { color: var(--muted); font-size: 0.78rem } .mp-item:hover { border-color: var(--accent) }
#ed-txt-box { width: 100%; min-height: 320px; font: 0.86rem/1.45 ui-monospace, Menlo, monospace; margin-top: 8px }
.ed-help { font: 0.86rem/1.5 var(--sans); color: var(--muted) } .ed-help kbd { font: 0.8rem var(--sans); border: 1px solid var(--rule); border-radius: 3px; padding: 0 4px; color: var(--ink) }
@media (max-width: 1180px) {
  .ed-layout { grid-template-columns: minmax(0, 1fr) }
  .ed-main { order: 0 } .ed-left { order: 1; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) } .ed-right { order: 2; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) }
  .ed-canvas-wrap { height: 60vh }
}

/* Zones page */
.zone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 24px 28px; margin: 18px 0 }
.zone-card { border-top: 2px solid var(--ink); padding-top: 10px; min-width: 0; display: grid; align-content: start; gap: 6px }
.zone-card h3 { margin: 0; font-size: 1.45rem }
.zone-card .zmeta { font: 0.88rem/1.4 var(--sans); color: var(--muted) }
.zone-card canvas, .zone-card .zthumb { display: block; width: 100%; height: auto; border: 1px solid var(--rule); background: #fff }
.zone-card p { font-size: 1rem; margin: 2px 0 }
.zone-card details { font: 0.95rem/1.5 var(--sans) } .zone-card summary { cursor: pointer; font-weight: 600; padding: 3px 0 }
.zone-card ol { padding-left: 1.4em; margin: 4px 0 } .zone-card li { margin: 2px 0 }
.zone-card .row { margin-top: 4px } .zone-card .row .btn { padding: 5px 11px; font-size: 0.86rem }
.zone-card table { font-size: 0.9rem } .zone-card td, .zone-card th { padding: 4px 6px }
@media (max-width: 480px) { .zone-grid { grid-template-columns: minmax(0, 1fr) } }

/* ================= Play page ================= */
.play { max-width: 1240px; margin: 0 auto; padding: 0 16px 60px }
.play [hidden] { display: none !important }
.play *, .play *::before, .play *::after { box-sizing: border-box }
.play-hero { padding-bottom: 12px }
.play-bar { position: relative; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 12px 0; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); margin-bottom: 18px }
.play-bar .pick { display: flex; align-items: center; gap: 10px; flex: 1 1 320px; min-width: 0 }
.play-bar .pick select { flex: 1; min-width: 0; max-width: 560px }
.play-bar .actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center }
.play-bar .play-msg { flex-basis: 100%; margin: 0; font: 0.95rem var(--sans); color: var(--danger) }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
.btn[disabled] { opacity: 0.45; cursor: default }
.vbadge { font: 700 0.76rem/1.2 var(--label); letter-spacing: 0.06em; text-transform: lowercase; border-radius: 999px; padding: 6px 12px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); cursor: pointer }
.vbadge.ok { border-color: var(--accent); color: var(--accent) }
.vbadge.warn { border-color: var(--gold); color: var(--gold) }
.vbadge.bad { border-color: var(--danger); color: var(--danger) }
.paste-box { flex-basis: 100%; display: grid; gap: 8px; padding: 10px 0 4px }
.paste-box textarea { width: 100%; font: 0.86rem/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--ink); background: var(--paper-2); border: 1px solid var(--rule); border-radius: 6px; padding: 8px; resize: vertical }
.paste-box .row, .combat .row, .dice .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center }
.vpanel { flex-basis: 100%; border: 1px solid var(--rule); background: var(--paper-2); padding: 12px 14px; display: grid; gap: 10px; max-height: 60vh; overflow: auto }
.vhead { font: 0.95rem var(--sans); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center }
.vhead .vact { margin-left: auto; display: flex; gap: 6px }
.vstats th { font-size: 0.7rem } .vstats td { font-size: 0.9rem }
.issues { margin: 0; padding-left: 18px; font: 0.92rem/1.5 var(--sans) }
.issues li { margin: 2px 0 }
.issues b { font-weight: 600; margin-right: 4px }
.issues.err li::marker { color: var(--danger) } .issues.err b { color: var(--danger) }
.issues.warn li::marker { color: var(--gold) } .issues.warn b { color: var(--gold) }
.issues.info { color: var(--muted) }

.play-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px 40px; align-items: start }
.play-main { min-width: 0 }
.entry { background: var(--paper-2); border: 1px solid var(--rule); padding: 22px 26px 24px; max-width: 800px }
.entry .sec { font: 400 2.1rem var(--display); color: var(--accent); display: block; line-height: 1 }
.entry .etitle { font-size: 1.25rem; margin: 2px 0 4px; color: var(--muted) }
.entry p { font-size: 1.06rem; max-width: 66ch }
.entry.title h2 { margin: 4px 0 6px }
.entry .meta { font: 0.92rem/1.5 var(--sans); color: var(--muted); margin: 0 0 10px }
.entry .start { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px }
.rolls { display: inline-flex; gap: 14px; font: 500 0.95rem var(--sans); color: var(--muted) }
.rolls b { color: var(--ink); font-size: 1.15rem }
.notes { border-left: 3px solid var(--accent); padding: 2px 0 2px 14px; margin: 12px 0 }
.notes p { margin: 4px 0; font: 500 0.98rem/1.5 var(--sans) }
.test, .combat { border-top: 1px solid var(--rule); margin-top: 16px; padding-top: 12px }
.test p, .combat p { font-size: 1rem; margin: 6px 0 10px }
.result { font: 500 0.98rem/1.5 var(--sans); margin: 10px 0 0 }
.result.pos { color: var(--accent) } .result.neg { color: var(--danger) }
.die { display: inline-block; width: 1.5em; height: 1.5em; line-height: 1.45em; text-align: center; font: 700 0.9rem var(--sans); border: 1px solid var(--ink); border-radius: 4px; background: var(--paper); color: var(--ink); vertical-align: -0.35em; margin-right: 3px }
.foes { margin: 4px 0 10px; max-width: 640px }
.foes tr.dead td { color: var(--muted); text-decoration: line-through }
.foes td small { display: block; text-decoration: none }
.foes th { font-size: 0.7rem }
.clog { font: 0.86rem/1.5 var(--sans); color: var(--muted); margin-top: 10px; max-height: 14em; overflow: auto; border-left: 2px solid var(--rule); padding-left: 10px }
.choices { display: grid; gap: 8px; margin-top: 18px; border-top: 1px solid var(--rule); padding-top: 14px }
.choice { display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: left; width: 100%; background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 6px; padding: 10px 14px; cursor: pointer; font: 1rem/1.45 var(--body) }
.choice:hover:not([disabled]) { border-color: var(--accent) }
.choice[disabled] { opacity: 0.55; cursor: default }
.choice small { color: var(--muted); font-family: var(--sans); font-size: 0.86rem }
.choice .turn { flex: none; font: 700 0.74rem/1.2 var(--label); letter-spacing: 0.06em; text-transform: lowercase; color: var(--accent); white-space: nowrap }
.ending { margin-top: 18px; border-top: 2px solid var(--ink); padding-top: 12px }
.ending.death .label { color: var(--danger) } .ending.win .label { color: var(--accent) }
.ending p { font-size: 1.15rem; margin: 4px 0 10px }
.trail { margin: 12px 0 0; word-break: break-word; max-width: 800px }
details.map { margin-top: 12px; max-width: 800px }
details.map summary { font: 500 0.92rem var(--sans); color: var(--muted); cursor: pointer }
details.map pre { font: 0.72rem/1.15 ui-monospace, Menlo, Consolas, monospace; overflow: auto; background: var(--paper-2); border: 1px solid var(--rule); padding: 10px; margin: 8px 0 }

.sheet { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 66px); max-height: calc(100vh - 80px); overflow: auto; min-width: 0 }
.sheet-in { border: 1px solid var(--rule); background: var(--paper); padding: 14px 16px 16px; display: grid; gap: 12px }
.sheet h3 { font-size: 1.2rem; margin: 0 }
.stats { display: grid; gap: 6px }
.stats.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px }
.stat { display: grid; gap: 2px; min-width: 0 }
.stat .val { display: flex; align-items: center; gap: 6px; font: 500 1.05rem var(--sans) }
.stat .val b { font-weight: 600; min-width: 1.2em; text-align: center }
.stat .of { font-size: 0.86rem; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; margin-left: 4px }
.tiny.up { width: 20px; height: 20px; font-size: 0.75rem; color: var(--muted) }
.tiny { font: 500 0.85rem/1 var(--sans); border: 1px solid var(--rule); background: var(--paper); color: var(--ink); border-radius: 999px; width: 24px; height: 24px; cursor: pointer; padding: 0; flex: none }
.tiny:hover { border-color: var(--accent) }
.purse, .gear { display: grid; gap: 8px }
.gear .small { font-size: 0.82rem }
.items ul { list-style: none; margin: 4px 0 6px; padding: 0; display: grid; gap: 3px }
.items li { display: flex; align-items: center; gap: 6px; font: 0.95rem var(--sans); border-bottom: 1px solid var(--rule); padding: 3px 0 }
.items li span { flex: 1; min-width: 0 }
.items .tiny[data-act="use"] { width: auto; padding: 0 8px }
.additem { display: flex; gap: 6px; align-items: center }
.additem input { flex: 1; min-width: 0; font-size: 0.9rem; padding: 5px 8px }
.flags { margin: 0 }
.dice .dout { font: 0.92rem/1.5 var(--sans); color: var(--ink); margin: 6px 0 0; min-height: 1.5em }
.log { font: 0.84rem/1.45 var(--sans); color: var(--muted) }
.log > div { max-height: 14em; overflow: auto; border-left: 2px solid var(--rule); padding-left: 10px; margin-top: 4px }
.log > div > div { padding: 1px 0 }
.play.dragging::after, #player.dragging::after { content: "Drop a JSON file to open it"; position: fixed; inset: 0; background: color-mix(in srgb, var(--accent) 18%, transparent); border: 3px dashed var(--accent); display: grid; place-items: center; font: 500 1.4rem var(--sans); color: var(--ink); z-index: 70; pointer-events: none }
.play-ref { max-width: 1240px; margin: 28px auto 0; padding: 0 16px 48px }
.play-ref > details { border-top: 1px solid var(--rule); padding: 12px 0 }
.play-ref summary { font: 400 1.4rem var(--display); cursor: pointer }
.play-ref .ref-body { max-width: 860px }
.play-ref .ref-body h1 { display: none }
.play-ref .ref-body h2 { font-size: 1.5rem; margin-top: 1.2em }
.play-ref .ref-body h3 { font-size: 1.2rem; margin-top: 1.1em }
.play-ref .ref-body pre { font: 0.82rem/1.4 ui-monospace, Menlo, Consolas, monospace; background: var(--paper-2); border: 1px solid var(--rule); padding: 12px; overflow: auto }
.play-ref .ref-body code { font: 0.88em ui-monospace, Menlo, Consolas, monospace; background: var(--paper-2); padding: 1px 4px; border-radius: 3px }
.play-ref .ref-body .tscroll { overflow-x: auto; margin: 8px 0 14px }
.play-ref .ref-body table { margin: 0; min-width: 520px }
.play-ref .ref-body ul { padding-left: 20px }
@media (max-width: 900px) {
  .play-layout { grid-template-columns: minmax(0, 1fr) }
  .sheet { position: static; max-height: none }
  .entry { padding: 16px 16px 18px }
}

.hero-handoff {
  background: color-mix(in srgb, var(--accent) 7%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--rule));
  border-radius: 6px;
  padding: 12px 16px;
  margin: 14px 0;
  display: grid;
  gap: 6px;
}
.hero-handoff .hh-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 1.05rem var(--sans);
}
.hero-handoff .hh-people {
  color: var(--muted);
  font-size: 0.9rem;
}
.hero-handoff .hh-stats {
  margin: 0;
  color: var(--muted);
}
.hero-handoff .hh-stats b {
  color: var(--ink);
}
.hero-handoff .hh-btn {
  justify-self: start;
  margin-top: 4px;
}
.ending-actions {
  margin-top: 14px;
}
.btn.muted {
  opacity: 0.7;
}

.story-map-modal {
  flex-basis: 100%;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  padding: 14px 16px;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  margin-top: 8px;
}
.smap-box {
  display: grid;
  gap: 10px;
}
.smap-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.smap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
  font-family: var(--sans);
  color: var(--muted);
}
.smap-legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 4px;
}
.smap-legend .dot.current { background: var(--accent); }
.smap-legend .dot.visited { background: var(--gold); }
.smap-legend .dot.available { border: 1.5px dashed var(--accent); background: transparent; }
.smap-legend .dot.fog { background: var(--rule); }

.smap-svg-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 4px;
  padding: 10px;
}
.smap-svg {
  min-width: 100%;
  height: auto;
  max-height: 480px;
  display: block;
}
.smap-svg .edge {
  fill: none;
  stroke-width: 2px;
  transition: stroke 0.2s;
}
.smap-svg .edge.traversed { stroke: var(--gold); stroke-width: 2.5px; }
.smap-svg .edge.choice { stroke: var(--accent); stroke-dasharray: 4,4; stroke-width: 2px; }
.smap-svg .edge.fog { stroke: var(--rule); stroke-width: 1px; opacity: 0.45; }

.smap-svg .snode {
  cursor: pointer;
  transition: transform 0.2s;
}
.smap-svg .snode text {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 11px;
  text-anchor: middle;
  pointer-events: none;
}
.smap-svg .snode.visited circle {
  fill: var(--gold);
  stroke: var(--ink);
  stroke-width: 1.5px;
}
.smap-svg .snode.visited text { fill: #fff; }
.smap-svg .snode.current circle {
  fill: var(--accent);
  stroke: var(--ink);
  stroke-width: 2.5px;
}
.smap-svg .snode.current text { fill: var(--accent-ink); }
.smap-svg .snode.available circle {
  fill: var(--paper);
  stroke: var(--accent);
  stroke-dasharray: 3,3;
  stroke-width: 2px;
}
.smap-svg .snode.available text { fill: var(--accent); }
.smap-svg .snode.fog circle {
  fill: var(--rule);
  stroke: none;
  opacity: 0.45;
}

/* Audiobook voice narration sentence highlight */
.narrating-sentence {
  background: color-mix(in srgb, var(--gold) 24%, transparent) !important;
  border-radius: 4px;
  outline: 2px solid color-mix(in srgb, var(--gold) 60%, transparent);
  box-shadow: 0 0 10px rgba(194, 157, 70, 0.25);
  transition: all 0.25s ease;
}


/* ---------- Play page additions: plates, endings, map, playtest, keys, phone bar ---------- */
.play-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap }
.vpanel .vsub { font: 700 0.76rem/1.2 var(--label); letter-spacing: 0.08em; text-transform: lowercase; color: var(--muted); margin: 6px 0 0; border-top: 1px solid var(--rule); padding-top: 10px }
.play-plate { margin: 10px 0 14px; background: #fff; border: 1px solid var(--rule); padding: 6px; max-width: 560px }
.play-plate img { display: block; width: 100%; height: auto; mix-blend-mode: multiply }
.play-plate figcaption { font: 0.84rem/1.35 var(--sans); color: #4a524d; margin-top: 5px; text-align: center }
.play-plate.cover { max-width: 420px; margin: 0 0 14px }
.play-endings { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 0; font: 0.92rem var(--sans) }
.play-endings .end-chip { font: 600 0.8rem var(--sans); border: 1px solid var(--rule); border-radius: 999px; padding: 2px 9px; color: var(--muted) }
.play-endings .end-chip.win { border-color: var(--accent); color: var(--accent) }
.play-endings .end-chip.death { border-color: var(--danger); color: var(--danger) }
.play-endings .end-chip.end { border-color: var(--ink); color: var(--ink) }
.play-dmap-box { margin: 14px 0 0; max-width: 800px }
.play-dmap { display: block; width: 100%; height: auto; max-height: 420px; background: var(--paper); border: 1px solid var(--rule); margin-top: 6px }
.play-dmap .pd-hatch-line { stroke: var(--rule); stroke-width: 1.2 }
.play-dmap .pd-room { fill: var(--paper); stroke: var(--ink); stroke-width: 1.6 }
.play-dmap .pd-room.pd-here { fill: color-mix(in srgb, var(--accent) 22%, var(--paper)); stroke: var(--accent); stroke-width: 2.4 }
.play-dmap .pd-corr { fill: none; stroke: var(--ink); stroke-width: 5; stroke-linecap: square; opacity: 0.55 }
.play-dmap .pd-corr.pd-unknown { stroke-dasharray: 3 5; opacity: 0.4 }
.play-dmap .pd-num { font: 700 9px var(--sans); fill: var(--ink); text-anchor: middle }
.play-keys { margin: 10px 0 0 }
.play-keys kbd { font: 600 0.78rem var(--sans); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--paper) }
.play-mini { display: none }
@media (max-width: 900px) {
  .play-mini:not([hidden]) { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); background: color-mix(in srgb, var(--paper) 95%, transparent); border-top: 1px solid var(--rule);
    font: 500 0.9rem var(--sans); color: var(--ink); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px) }
  .play-mini b { font-weight: 700 }
  .play-mini a { color: var(--accent) }
  .play { padding-bottom: 70px }
  .play-keys { display: none }
}
.choices { counter-reset: play-choice }
.choices .choice::before { counter-increment: play-choice; content: counter(play-choice); flex: none; font: 600 0.75rem/1 var(--sans); color: var(--muted); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; padding: 3px 6px; margin-right: 2px }
.choices .choice > span { flex: 1; min-width: 0 }
@media (max-width: 900px) { .choices .choice::before { display: none } }

/* ================= Retinue & Companions Mode ================= */
.sheet-hero-badge {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-family: var(--sans);
  background: color-mix(in srgb, var(--accent) 8%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 4px;
  padding: 4px 8px;
  margin: -4px 0 6px;
}
.sheet-hero-badge b { color: var(--accent); font-size: 0.95rem; }
.sheet-hero-badge .small { color: var(--muted); font-size: 0.8rem; }

.sheet-companions {
  border-top: 1px solid var(--rule);
  padding-top: 8px;
  display: grid;
  gap: 6px;
}
.sc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sc-list {
  display: grid;
  gap: 8px;
}
.sc-card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
  font-family: var(--sans);
}
.sc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.92rem;
}
.sc-row b { color: var(--ink); font-weight: 600; }
.chip-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--gold) 20%, transparent);
  color: var(--gold);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  border-radius: 999px;
  padding: 1px 7px;
}
.sc-role {
  color: var(--muted);
  font-size: 0.82rem;
}
.sc-hp {
  position: relative;
  background: color-mix(in srgb, var(--ink) 12%, transparent);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  margin: 2px 0;
}
.sc-bar {
  background: var(--accent);
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}
.sc-hp-txt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}
.sc-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
}
.tiny-chip {
  font: 600 0.78rem var(--sans);
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  padding: 2px 7px;
  cursor: pointer;
}
.tiny-chip:hover:not([disabled]) {
  border-color: var(--accent);
  color: var(--accent);
}
.tiny-chip[disabled] {
  opacity: 0.5;
  cursor: default;
}
.trait-status {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
}

/* Modal styling for Party & Passport */
.party-modal, .passport-modal {
  flex-basis: 100%;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  padding: 18px 20px;
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.08);
  margin-top: 10px;
}
.modal-box { display: grid; gap: 14px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 10px;
}
.modal-head h3 { margin: 2px 0 0; font-size: 1.35rem; }
.tiny-close {
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
}
.tiny-close:hover { border-color: var(--accent); color: var(--accent); }
.modal-lede { margin: 0; color: var(--muted); font-size: 0.95rem; }
.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid var(--rule);
  padding-top: 10px;
}

.party-status-bar {
  display: flex;
  gap: 20px;
  font-family: var(--sans);
  font-size: 0.92rem;
  padding: 8px 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
}

.recruit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.recruit-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.recruit-card:hover {
  border-color: var(--accent);
}
.recruit-card.hired {
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 6%, var(--paper));
}
.rc-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rc-icon { font-size: 1.5rem; flex: none; }
.rc-head b { font-size: 1.05rem; display: block; color: var(--ink); }
.rc-role { font-size: 0.8rem; color: var(--muted); display: block; font-family: var(--sans); }
.rc-badge {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px;
  padding: 2px 8px;
}
.rc-desc { margin: 0; color: #4a524d; font-size: 0.88rem; line-height: 1.4; }
.rc-stats {
  display: flex;
  gap: 14px;
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--muted);
  border-top: 1px dashed var(--rule);
  border-bottom: 1px dashed var(--rule);
  padding: 6px 0;
}
.rc-stats b { color: var(--ink); }
.rc-trait { font-size: 0.84rem; line-height: 1.35; color: var(--ink); }
.rc-trait .label { color: var(--gold); font-weight: 700; }
.rc-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.rc-cost { font-family: var(--sans); font-size: 0.88rem; color: var(--muted); }
.rc-cost b { color: var(--ink); }
.rc-hired-tag {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--gold);
}

/* ================= Campaign Passport & Continuity ================= */
.passport-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-family: var(--sans);
  font-size: 0.95rem;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--gold) 10%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
  border-radius: 4px;
}
.passport-summary span b { color: var(--ink); font-weight: 700; margin-left: 4px; }
.passport-empty {
  text-align: center;
  padding: 28px 16px;
  background: var(--paper);
  border: 1px dashed var(--rule);
  border-radius: 6px;
}
.empty-seal { font-size: 2.8rem; margin-bottom: 8px; }
.deeds-list {
  display: grid;
  gap: 12px;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 4px;
}
.deed-card {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  padding: 12px 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}
.wax-seal {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #d43b2c, #8c1a1a);
  color: #ffd875;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  box-shadow: 0 2px 6px rgba(140, 26, 26, 0.4), inset 0 1px 2px rgba(255,255,255,0.4);
}
.deed-body { flex: 1; min-width: 220px; }
.deed-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.deed-title {
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
}
.deed-date { font-family: var(--sans); font-size: 0.78rem; color: var(--muted); }
.deed-body h4 { margin: 2px 0 3px; font-size: 1.15rem; color: var(--ink); }
.deed-body h4 small { font-size: 0.82rem; color: var(--muted); font-weight: normal; }
.deed-book { margin: 0 0 6px; color: var(--muted); }
.deed-spoils {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-family: var(--sans);
  font-size: 0.84rem;
  color: var(--muted);
}
.deed-spoils b { color: var(--ink); }
.deed-action { flex: none; }

/* Victory Stamp Card on Endings */
.passport-stamp-card {
  display: flex;
  gap: 16px;
  align-items: center;
  background: color-mix(in srgb, var(--gold) 12%, var(--paper));
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 14px 0;
  box-shadow: 0 4px 12px rgba(194, 157, 70, 0.18);
}
.stamp-seal {
  font-size: 2.2rem;
  color: var(--gold);
  flex: none;
}
.stamp-body { flex: 1; }
.stamp-body .label { color: var(--gold); letter-spacing: 0.08em; }
.stamp-body h4 { margin: 2px 0 4px; font-size: 1.25rem; color: var(--ink); font-family: var(--display); }
.stamp-body p { margin: 0; font-size: 0.95rem; }

.veteran-handoff {
  background: color-mix(in srgb, var(--gold) 12%, var(--paper)) !important;
  border-color: var(--gold) !important;
}

