@font-face {
  font-family: "Cinzel";
  src: url("../fonts/cinzel-400.woff2?v=20261201-d30c25") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cinzel";
  src: url("../fonts/cinzel-700.woff2?v=20261201-d30c25") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url("../fonts/ebgaramond-400.woff2?v=20261201-d30c25") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url("../fonts/ebgaramond-400i.woff2?v=20261201-d30c25") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url("../fonts/ebgaramond-600.woff2?v=20261201-d30c25") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url("../fonts/ebgaramond-700.woff2?v=20261201-d30c25") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #2a2118; --ink-soft: #5c4f40;
  --parchment: #fbf6ec; --parchment-deep: #f3e8d4; --desk: #e7d8c0;
  --rule: #d7c4a4; --rule-strong: #8d7048;
  --oxblood: #6e2b33; --oxblood-deep: #521f26; --forest: #234237; --gold: #84632e; --gold-soft: #e4d2ae; --focus: #8d3b3b;
  --serif: "EB Garamond", "Palatino Linotype", Palatino, Georgia, serif;
  --display: "Cinzel", "Palatino Linotype", Palatino, serif;
  --shadow: 0 22px 50px rgba(62, 42, 24, 0.16);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: var(--serif); font-size: 1.125rem; line-height: 1.45;
  background: linear-gradient(180deg, #f6ead6 0%, #e7d3b4 46%, #dcc6a4 100%); }
.skip { position: absolute; left: 1rem; top: -3rem; background: var(--oxblood); color: #f8f1e6; padding: .4rem .7rem; z-index: 5; }
.skip:focus { top: .6rem; }
.site-head, main, .site-foot { width: min(1080px, calc(100% - 2rem)); margin: 0 auto; }
.site-head { padding: 2.2rem 0 1.2rem; }
.brand { display: flex; gap: .9rem; align-items: center; }
.mark { width: 52px; height: 52px; flex: none; }
h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: clamp(2rem, 4vw, 3.1rem); line-height: .95; letter-spacing: .04em; color: var(--oxblood-deep); }
.subtitle { margin: .2rem 0 0; font-family: var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.section-title, .cite { font-family: var(--display); letter-spacing: .08em; }
.section-title { color: var(--oxblood); font-size: 1.05rem; text-transform: uppercase; margin: 1.2rem 0 .6rem; }
.panel, .sheet { background: var(--parchment); border: 1px solid var(--rule); border-radius: 6px; box-shadow: var(--shadow); padding: 1.1rem 1.3rem; margin-bottom: 1.2rem; }
.panel-head h2 { margin: 0 0 .5rem; font-family: var(--display); color: var(--oxblood-deep); }
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin: .8rem 0; }
.filters button { font: inherit; padding: .35rem .8rem; border: 1px solid var(--rule-strong); background: var(--parchment-deep); border-radius: 999px; cursor: pointer; }
.filters button[aria-pressed="true"] { background: var(--oxblood); color: #fbf3e6; border-color: var(--oxblood-deep); }
.btn { font: inherit; padding: .45rem 1rem; border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--parchment-deep); color: var(--ink); cursor: pointer; }
.btn-primary { background: var(--oxblood); border-color: var(--oxblood-deep); color: #fbf3e6; }
.btn-ghost { background: transparent; }
.btn-small { font-size: .85rem; padding: .2rem .6rem; }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--oxblood); text-decoration: underline; cursor: pointer; text-align: left; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input[type="search"] { font: inherit; width: 100%; padding: .4rem .6rem; border: 1px solid var(--rule-strong); border-radius: 4px; background: #fffaf3; }
.table-list { list-style: none; padding: 0; margin: .6rem 0 0; max-height: 22rem; overflow: auto; columns: 2 22rem; }
.table-list li { break-inside: avoid; margin: .15rem 0; }
.cite { font-size: .7rem; color: var(--ink-soft); white-space: nowrap; }
.roll { border-top: 1px solid var(--rule); padding: .6rem 0; }
.roll header { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.roll h3 { margin: 0; font-size: 1.05rem; color: var(--forest); }
.roll dl { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: .15rem .9rem; margin: .4rem 0; }
.roll dt { font-weight: 600; color: var(--ink-soft); }
.roll dd { margin: 0; }
.die { display: inline-block; min-width: 1.7rem; text-align: center; font-family: var(--display); font-size: .75rem; border: 1px solid var(--gold); border-radius: 3px; color: var(--gold); margin-left: .3rem; }
.seed { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 1.2rem; }
.flesh { padding-left: 1.1rem; }
.flesh strong { text-transform: capitalize; }
.status { min-height: 1.3em; color: var(--ink-soft); font-size: .9rem; }
.site-foot { font-size: .85rem; color: var(--ink-soft); padding-bottom: 2rem; }
.noscript { text-align: center; }

/* ---- Generator forms ---- */
.mode-choice { gap: .35rem; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: .55rem .9rem; margin: .7rem 0; }
.fields label, .impair label { display: flex; flex-direction: column; gap: .15rem; font-size: .92rem; color: var(--ink-soft); }
.fields label.check, .impair label.check { flex-direction: row; align-items: center; gap: .4rem; color: var(--ink); }
select, input[type="number"], .library-controls input[type="text"] { font: inherit; font-size: 1rem; padding: .3rem .45rem; border: 1px solid var(--rule-strong); border-radius: 4px; background: #fffaf3; color: var(--ink); min-width: 0; width: 100%; }
input[type="checkbox"] { accent-color: var(--oxblood); width: 1.05rem; height: 1.05rem; margin: 0; flex: none; }
select:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.impair { border: 1px solid var(--rule); border-radius: 4px; margin: .2rem 0 .8rem; padding: .4rem .8rem .6rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .25rem .9rem; }
.impair legend { font-family: var(--display); font-size: .8rem; letter-spacing: .08em; color: var(--oxblood); padding: 0 .3rem; }
.run-row { display: flex; flex-wrap: wrap; gap: .45rem; margin: .4rem 0 .2rem; }
.field-note { font-family: var(--serif); font-size: 1em; letter-spacing: normal; text-transform: none; color: var(--ink-soft); margin: .4rem 0; }
.field-hint { display: block; font-family: var(--serif); font-size: .78rem; line-height: 1.3; font-weight: 400; color: var(--ink-soft); max-width: 16rem; }
.packet-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---- Generator sections ---- */
.sec { border-top: 2px solid var(--rule); padding: .8rem 0 .6rem; }
.sheet > .sec:first-child, .sheet > .roll:first-child { border-top: 0; padding-top: .2rem; }
.sec header { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .8rem; }
.sec h3 { margin: 0; font-family: var(--display); font-size: 1.2rem; color: var(--oxblood-deep); letter-spacing: .03em; }
.sec h4, .sec h5, .sec h6 { margin: 0; font-size: 1.02rem; color: var(--forest); }
.sec .sub { margin: 0; font-style: italic; color: var(--ink-soft); }
.sec-sub { border-top: 1px dotted var(--rule); margin-left: .9rem; padding: .5rem 0 .3rem; }
.sec-sub .sec-sub { margin-left: .7rem; }
.hook { background: var(--parchment-deep); border-left: 3px solid var(--gold); padding: .5rem .8rem; margin: .5rem 0; }
.lines { display: grid; grid-template-columns: minmax(9rem, max-content) minmax(0, 1fr); gap: .2rem .9rem; margin: .45rem 0; }
.lines dt { font-weight: 600; color: var(--ink-soft); max-width: 24rem; }
.lines dd { margin: 0; overflow-wrap: anywhere; }
.die { white-space: nowrap; padding: 0 .25rem; vertical-align: .08em; max-width: 100%; }
.die.long, .lines dt .die { white-space: normal; overflow-wrap: anywhere; }
.notes { margin: .3rem 0; padding-left: 1.2rem; font-size: .95rem; color: var(--ink-soft); }
.flesh { margin: .4rem 0; padding-left: 0; font-size: .98rem; }
.flesh-label { font-family: var(--display); font-size: .75rem; letter-spacing: .08em; color: var(--gold); text-transform: uppercase; margin-right: .3rem; }
.roll-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 0; }
.art { display: flex; gap: 1.1rem; align-items: flex-start; }
.art > svg { flex: none; max-width: 100%; height: auto; }
.art-body { flex: 1; min-width: 0; }
svg.hexmap { width: 300px; background: #fffaf1; border: 1px solid var(--rule); border-radius: 4px; }
svg.shield { width: 150px; }
.hx, .hx-start, .hx-actual, .hx-plan { stroke: var(--rule-strong); stroke-width: 1; fill: #fbf3e3; }
.hx-start { fill: var(--gold-soft); }
.hx-plan { fill: #e6ecdf; stroke-dasharray: 3 2; }
.hx-actual { fill: #efd3cf; stroke: var(--oxblood); stroke-width: 2; }
.ray-plan { stroke: var(--forest); stroke-width: 2; stroke-dasharray: 6 4; }
.ray-actual { stroke: var(--oxblood); stroke-width: 2.5; stroke-linecap: round; }
.rose { fill: #fffaf1; stroke: var(--rule-strong); }
.rose-l { font-family: var(--display); font-size: 11px; fill: var(--ink-soft); }

@media (max-width: 640px) {
  body { font-size: 1.05rem; }
  .site-head, main, .site-foot { width: calc(100% - 1rem); }
  .panel, .sheet { padding: .9rem .8rem; }
  .fields { grid-template-columns: 1fr 1fr; }
  .roll dl, .lines { grid-template-columns: 1fr; gap: 0; }
  .lines dd, .roll dd { margin-bottom: .35rem; }
  .table-list { columns: 1; }
  .art { flex-direction: column; }
  svg.hexmap { width: 100%; max-width: 340px; }
  .sec-sub { margin-left: .4rem; }
  .sec-sub .sec-sub { margin-left: .3rem; }
}

/* ---- Geomorph dungeon map (js/tiles.js) ---- */
.dmap { margin: .7rem 0 .8rem; }
.dmap svg.wilderness-map { display: block; width: 100%; max-width: 760px; height: auto; margin: 0 auto; border: 1px solid var(--rule); border-radius: 4px; }
.dmap svg.tilemap { display: block; width: 100%; max-width: 760px; height: auto; margin: 0 auto; border: 1px solid var(--rule); border-radius: 4px; background: #fffaf1; }
.dmap figcaption { font-size: .85rem; color: var(--ink-soft); text-align: center; margin-top: .3rem; }
.tm-bg { fill: #f5f9fc; }
.tm-hatch { stroke: #7a96b0; stroke-width: .55; fill: none; stroke-linecap: round; }
.tm-hatch-b { stroke-width: .4; opacity: .75; }
.tm-floor { fill: #fcfdff; }
.tm-grid { stroke: #b9cde3; stroke-width: .5; fill: none; }
.tm-wall { stroke: #1f4e79; stroke-width: 2.6; stroke-linecap: square; stroke-linejoin: miter; fill: none; }
.tm-door { fill: #fcfdff; stroke: #1f4e79; stroke-width: 1.3; }
.tm-jamb { stroke: #1f4e79; stroke-width: 2.2; fill: none; }
.tm-port { stroke: #1f4e79; stroke-width: 2; stroke-dasharray: 1 3; stroke-linecap: round; fill: none; }
.tm-secret { font: 700 10px var(--display); fill: #1f4e79; paint-order: stroke; stroke: #f5f9fc; stroke-width: 2.5px; }
.tm-pillar { fill: #1f4e79; }
.tm-rubble { fill: #91aac0; stroke: #1f4e79; stroke-width: .5; }
.tm-stairs path { stroke: #1f4e79; stroke-width: 1.1; fill: none; }
.tm-stair-box { fill: #fcfdff; stroke: #1f4e79; stroke-width: .8; }
.tm-water ellipse { fill: #d4e6f2; stroke: #426f93; stroke-width: 1.1; }
.tm-water path { stroke: #426f93; stroke-width: .9; fill: none; }
.tm-water ellipse.tm-rim { fill: none; stroke-width: .7; }
.tm-glyph rect, .tm-glyph circle, .tm-glyph path { fill: #e5eef5; stroke: #1f4e79; stroke-width: 1.1; }
.tm-num { font: 700 12px var(--display); fill: #a3242c; paint-order: stroke; stroke: #fffdf8; stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.tm-hit { fill: transparent; stroke: none; }
.tm-room { cursor: pointer; }
.tm-room:hover .tm-hit, .tm-room:focus .tm-hit { fill: rgba(163, 36, 44, .08); }
.tm-room.on .tm-hit { fill: rgba(163, 36, 44, .17); stroke: #a3242c; stroke-width: 2; }
.tm-room:focus { outline: none; }
.tm-scale, .tm-north { stroke: #1f4e79; stroke-width: 1.2; fill: none; }
.tm-north { fill: #1f4e79; }
.tm-label { font: 10px var(--display); fill: #5c4f40; letter-spacing: .04em; }
.boxed { margin: .45rem 0 .5rem; padding: .5rem .8rem; border: 1px solid var(--rule-strong); border-left: 4px solid var(--oxblood); background: #fffaf1; font-style: italic; border-radius: 2px; }
.sec[data-room].on { background: rgba(163, 36, 44, .06); box-shadow: inset 3px 0 0 #a3242c; }
.maplink { font-size: .8rem; font-family: var(--display); letter-spacing: .05em; }
.briefing p { margin: .35rem 0; }

/* Phase 3: a compact handout switch; SVG symbols stay identical in the legend. */
.map-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .4rem .8rem; margin-top: .4rem; font-size: .85rem; }
.map-controls label { display: inline-flex; align-items: center; gap: .3rem; }
.map-player[hidden], .is-player > .map-dm-caption, .hide-numbers .tm-num, .player-print { display: none; }
.tm-boundary { fill: none; stroke: #6c89a4; stroke-width: 1.2; stroke-dasharray: 2 3; }
.tm-legend-label { font: 10px Georgia, serif; fill: #1f4e79; }
.tm-door-bar { fill: none; stroke: #1f4e79; stroke-width: 2; }
.tm-lock { fill: #1f4e79; }
.tm-stairs .tm-arrow-down { fill: #1f4e79; }
.tm-stairs .tm-arrow-up { fill: none; stroke-width: 1.5; }
.tm-glyph path { fill: none; }
/* Fixed local metrics keep number placement independent of downloaded fonts. */
.tm-num { font-family: Arial, sans-serif; letter-spacing: 0; }
/* Small local actions keep the existing section flow. */
.section-tools, .result-tools { display: flex; gap: .35rem; flex-wrap: wrap; margin: .4rem 0; }
.optional-section { margin: .5rem 0; }
.result-print { display: none; }
.solo-dialog { width: min(100% - 2rem, 900px); max-height: 92vh; padding: 1rem; border: 1px solid #b9a27f; background: #fffaf1; color: #2a2118; overflow: auto; }
.solo-dialog::backdrop { background: rgb(25 20 15 / .65); }
.solo-map { position: relative; max-width: 760px; margin: auto; }
.solo-map svg { width: 100%; height: auto; display: block; }
.solo-door { position: absolute; transform: translate(-50%, -50%); min-width: 26px; min-height: 26px; padding: 0; border: 2px solid #2a2118; background: #fffaf1; color: #a3242c; border-radius: 50%; cursor: pointer; font-weight: bold; }
.solo-door:focus-visible { outline: 3px solid #a3242c; outline-offset: 3px; }
.solo-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.solo-key .maplink { display: none; }

.solo-resume { margin: 0; }
.solo-resume:has(button:not([hidden])) { margin: .5rem 0; }

/* GM progress lives only on the page; the generated SVG stays pristine. */
.tracker-panel { text-align: left; padding: .8rem; margin-top: .6rem; border: 1px solid var(--rule-strong); background: #fffaf1; font-size: .9rem; }
.tracker-panel h4, .tracker-time { margin: .2rem 0 .6rem; }
.tracker-rooms { list-style: none; padding: 0; max-height: 22rem; overflow: auto; }
.tracker-rooms li { padding: .4rem 0; border-bottom: 1px solid var(--rule-strong); }
.tracker-rooms label { display: inline-block; margin: .2rem .5rem .2rem 0; }
.tracker-panel input[type="number"] { width: 7rem; }
.tracker-custom { margin-top: .5rem; }
.tracker-level select { width: auto; display: inline-block; margin: 0 .3rem; }
.tracker-encounter { padding: .5rem; border-left: 3px solid var(--oxblood); }
.tracker-mark { display: none; fill: #315b39; font: bold 10px Arial, sans-serif; paint-order: stroke; stroke: #fffdf8; stroke-width: 2px; pointer-events: none; }
.tm-room.is-cleared .tracker-mark { display: inline; }
.tm-room.is-cleared .tm-hit { fill: rgba(49, 91, 57, .14); }
.tm-room.is-cleared.on .tm-hit { stroke: #a3242c; stroke-width: 2; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Small adventure-library controls share the result and packet action rows. */
.library-save, .library-edit { display: flex; align-items: end; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; flex-basis: 100%; }
.library-controls .field { display: flex; flex-direction: column; gap: .15rem; font-size: .92rem; }
.library-list { list-style: none; margin: 0; padding: 0; }
.library-list > li { border-top: 1px solid var(--rule); padding: .6rem 0; }
.library-list h3 { margin: .2rem 0; }

/* Temporary booklet documents are visible only to the print stylesheet. */
.booklet-print { display: none; }
.result-print { display: none; }

.booklet-choice { display: inline-block; vertical-align: top; margin: .35rem; max-width: 34rem; }
.booklet-choice fieldset { margin: 0 0 .35rem; padding: .4rem; }
.booklet-choice label { display: block; }
/* The inline booklet choice is taller than a button; keep neighbouring buttons at their natural height. */
.packet-actions, .section-tools, .result-tools { align-items: flex-start; }
.booklet-choice { margin: 0 .35rem; }

/* The same accents identify map fixtures in colour and retain dark outlines on paper. */
.tm-hazard rect, .tm-hazard path { stroke: #9b3434; fill: #f8e4df; }
.tm-gold rect, .tm-gold circle, .tm-gold path { fill: #ead294; stroke: #715426; }
.tm-gold path { fill: none; }
.print-preference { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; margin: .3rem 0; }

/* A mobile map opens at its natural SVG size; only this viewport scrolls. */
.map-enlarge { display: none; }
.map-viewing { overflow: hidden; }
.map-viewer { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--parchment); color: var(--ink); }
.map-viewer[open] { display: flex; flex-direction: column; }
.map-viewer-tools { display: flex; align-items: center; gap: .5rem; padding: .6rem; flex-shrink: 0; border-bottom: 1px solid var(--rule); }
.map-viewer-scroll { flex: 1; min-height: 0; overflow: auto; touch-action: pan-x pan-y pinch-zoom; overscroll-behavior: contain; }
.map-viewer-scroll svg { display: block; max-width: none; max-height: none; }
.map-viewer-scroll svg .tm-room { pointer-events: none; }
@media (max-width: 600px) {
  .map-enlarge { display: inline-block; margin-top: .4rem; }
  .dmap > svg, .dmap .map-player > svg { cursor: zoom-in; }
  .panel, .sheet, .sec, .fields > *, .map-controls { min-width: 0; }
  .map-controls { flex-wrap: wrap; }
}
