@font-face {
  font-family: "Noto Serif";
  src: url("assets/noto-serif-latin-400-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Noto Serif";
  src: url("assets/noto-serif-latin-700-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Noto Serif";
  src: url("assets/noto-serif-latin-900-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 900;
  font-display: swap;
}
@font-face {
  font-family: "Inconsolata";
  src: url("assets/inconsolata-latin-400-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Inconsolata";
  src: url("assets/inconsolata-latin-700-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  color: #171717;
  background: #e9e5dc;
  font-family: "Inconsolata", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body { margin: 0; min-height: 100vh; display: grid; grid-template-columns: 340px minmax(0, 1fr); }

.generator-panel {
  position: sticky; top: 0; height: 100vh; overflow: auto; padding: 28px 24px;
  background: #171817; color: #f7f3ea; border-right: 1px solid #000;
}
.back-link { display: inline-block; margin-bottom: 22px; color: #d3ad5c; font-size: 12px; font-weight: 800; text-decoration: none; }
.back-link:hover { color: #f0d79f; }
.eyebrow { margin: 0 0 8px; color: #c8aa69; font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.generator-heading h1 { margin: 0; font: 700 30px/1.05 "Noto Serif", serif; }
.generator-heading p:last-child { color: #b9bbb7; font-size: 14px; line-height: 1.5; }
.generator-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 22px 0; }
.mode-toggle { display: flex !important; align-items: center; gap: 8px; width: max-content; margin: -8px 0 18px; cursor: pointer; }
.mode-toggle input { width: 16px; height: 16px; margin: 0; accent-color: #d3ad5c; }
.generator-actions .primary { grid-column: 1 / -1; background: #d3ad5c; color: #181713; border-color: #e8ca88; }
button { appearance: none; border: 1px solid #5b5e59; border-radius: 7px; background: #30322f; color: white; padding: 10px 12px; font-weight: 750; cursor: pointer; }
button:hover { filter: brightness(1.12); }
button.quiet { color: #c8cbc5; }
.tool-link { grid-column: 1 / -1; display: block; border: 1px solid #5b5e59; border-radius: 7px; padding: 10px 12px; color: #f7f3ea; font-weight: 750; text-align: center; text-decoration: none; }
.tool-link:hover { background: #30322f; }
.generator-panel label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 800; }
#level-data, #map-data { width: 100%; height: 28vh; resize: vertical; border: 1px solid #575a55; border-radius: 8px; padding: 13px; background: #0f100f; color: #e9e6df; font: 11px/1.5 "Inconsolata", ui-monospace, monospace; tab-size: 2; }
.status { min-height: 20px; margin: 8px 0; color: #aeb2aa; font-size: 12px; }
.status.success { color: #a9d59d; }.status.error { color: #ff9d95; }
details { margin-top: 20px; border-top: 1px solid #3f413e; padding-top: 16px; color: #c8cbc5; font-size: 13px; line-height: 1.5; }
summary { cursor: pointer; font-weight: 800; }

.preview-area { min-width: 0; overflow: auto; }
.preview-toolbar { height: 48px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; color: #5f5b52; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.sheet-stage { padding: 0 22px 40px; min-width: 980px; }
.tracker-sheet {
  width: 11in; height: 8.5in; margin: 0 auto; padding: .08in; overflow: hidden;
  background: #fff; color: #090909; box-shadow: 0 8px 35px rgba(41, 35, 24, .23);
  font-family: "Inconsolata", ui-monospace, monospace;
}

.sheet-header { height: .64in; display: grid; grid-template-columns: .7in 3.1in 5.35in 1.3in; gap: .1in; align-items: center; }
.game-logo { display: block; width: .62in; height: .62in; object-fit: contain; }
.game-title { background: #111; color: white; padding: .08in .15in; font-size: 21px; line-height: 1; font-weight: 900; text-align: center; white-space: nowrap; clip-path: polygon(3% 0, 97% 0, 100% 20%, 98% 50%, 100% 80%, 97% 100%, 3% 100%, 0 80%, 2% 50%, 0 20%); }
.level-title { position: relative; border: 2px solid #111; padding: .08in .14in; text-align: center; font-size: 20px; font-weight: 900; line-height: 1.1; clip-path: polygon(3% 0, 97% 0, 100% 50%, 97% 100%, 3% 100%, 0 50%); }
.level-title span { font-size: 18px; }
.difficulty-badge { height: .5in; display: grid; align-content: center; justify-items: center; gap: .025in; border: 1.5px solid #111; border-radius: 7px; text-transform: uppercase; }
.difficulty-badge strong { font-size: 11px; line-height: 1; letter-spacing: .08em; }
.difficulty-dots { display: flex; gap: .055in; }
.difficulty-dots i { width: .09in; height: .09in; border: 1.3px solid #111; border-radius: 50%; }
.difficulty-dots i.filled { background: #111; }
.check-box { width: .15in; height: .13in; border: 1.3px solid #111; display: inline-block; }

.main-grid { height: 5.1in; display: grid; grid-template-columns: 3.05in 3.02in 4.48in; gap: .1in; }
.sheet-panel { border: 1.3px solid #111; border-radius: 8px; overflow: hidden; min-width: 0; }
.game-title, .level-title, .panel-title, .encounter-card h3, .difficulty-badge strong { font-family: "Noto Serif", serif; }
.panel-title { height: .28in; margin: 0; padding: 0 .055in; display: flex; align-items: center; gap: .045in; background: #111; color: white; font-size: 16px; line-height: 1; }
.sheet-icon { flex: 0 0 .27in; width: .27in; height: .27in; background-image: url("assets/deck-n-dice-dungeons-icons.png"); background-repeat: no-repeat; background-size: 900% 100%; }
.icon-party { background-position: 0% 50%; }
.icon-objectives { background-position: 12.5% 50%; }
.icon-enemies { background-position: 25% 50%; }
.icon-loot { background-position: 37.5% 50%; }
.icon-star { background-position: 50% 50%; }
.icon-notes { background-position: 62.5% 50%; }
.icon-dice { background-position: 75% 50%; }
.icon-people { background-position: 87.5% 50%; }
.icon-rewards { background-position: 100% 50%; }
.panel-body { height: calc(100% - .28in); padding: .07in; }

.party-panel .panel-body { display: grid; grid-template-rows: repeat(3, 1fr); gap: .06in; }
.hero-card { position: relative; min-height: 0; display: grid; grid-template-columns: .9in 1fr; gap: .09in; padding: .055in .05in .035in .065in; border: 1px solid #111; border-radius: 7px; }
.hero-number { position: absolute; top: 0; left: .055in; width: .29in; height: .4in; padding-top: .02in; background: #111; color: white; font: 900 18px/1 "Noto Serif", serif; text-align: center; clip-path: polygon(0 0,100% 0,100% 100%,50% 82%,0 100%); }
.card-write-field { display: grid; grid-template-rows: auto .19in auto auto auto auto; align-content: center; justify-items: stretch; padding-top: .11in; text-align: center; font-size: 10px; }
.card-write-field span { display: block; width: calc(100% - .06in); justify-self: start; border-bottom: 1.5px solid #111; }
.card-write-field small { margin-top: 2px; color: #333; font-size: 8px; }
.card-write-field .pool-instruction { margin-top: .04in; font-size: 8px; font-weight: 700; line-height: 1.05; white-space: nowrap; }
.card-write-field .pool-options { margin-top: 1px; font-size: 9px; font-weight: 700; line-height: 1.05; }
.card-write-field .minimum-hp { margin-top: 2px; font-size: 7.5px; font-weight: 700; line-height: 1; }
.hero-fields { display: grid; align-content: space-between; font-size: 10px; font-weight: 700; }
.write-line { display: flex; gap: .06in; align-items: end; }.write-line span { flex: 1; height: .12in; border-bottom: 1px solid #111; }
.stat-pair, .stat-trio { display: flex; align-items: center; justify-content: space-between; }
.stat-pair label, .stat-trio label { display: flex; gap: 3px; align-items: center; white-space: nowrap; }
.hero-fields i { display: inline-block; width: .22in; height: .21in; border: 1px solid #111; font-style: normal; }
.hero-fields .stat-wide i { width: .28in; }
.hp-row { display: flex; align-items: center; gap: .025in; }.hp-row strong { margin-right: .04in; }.hp-box { width: .14in; height: .14in; border: 1px solid #111; }

.middle-stack { display: grid; grid-template-rows: 1.02in 1.72in .83in 1.35in; gap: .06in; }
.check-list, .reward-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: flex; align-items: center; gap: .08in; margin-bottom: .035in; font-size: 12px; font-weight: 700; }
.check-list i, .reward-list i { flex: 0 0 auto; width: .14in; height: .14in; border: 1.2px solid #111; }
.upgrades-panel .panel-body { padding: .045in; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.upgrade-table { height: 100%; font-size: 9px; }.upgrade-table th,.upgrade-table td { border: 1px solid #222; padding: 1px 3px; }.upgrade-table th:nth-child(1){width:17%}.upgrade-table th:nth-child(2){width:41%}.upgrade-table th:nth-child(4){width:8%}.tiny-check{display:block;width:.11in;height:.11in;border:1px solid #111}
.carryover-panel .panel-title { font-size: 14px; }.carryover-list { padding-left: .12in; }
.note-lines { display: grid; gap: .09in; }.note-lines i { height: .11in; border-bottom: 1px solid #111; }

.encounters-panel .panel-body { display: grid; grid-template-rows: repeat(4, 1fr); gap: .1in; }
.encounter-card { min-height: 0; border: 1px solid #111; border-radius: 7px; overflow: hidden; }
.encounter-card header { height: .38in; display: grid; grid-template-columns: .4in 1fr; align-items: stretch; background: #eee; }
.encounter-card header b { align-self: stretch; display: grid; place-items: center; background: #111; color: white; font-size: 17px; clip-path: polygon(0 0, 85% 0, 100% 50%, 85% 100%, 0 100%); }
.encounter-heading { min-width: 0; display: grid; align-content: center; gap: 1px; padding: 1px .08in; }
.encounter-card h3 { margin: 0; font-size: 12px; line-height: 1; }
.encounter-heading span { min-width: 0; overflow: hidden; text-overflow: clip; white-space: nowrap; font-size: 9px; line-height: 1; }
.encounter-card table { height: calc(100% - .38in); font-size: 8px; }.encounter-card th,.encounter-card td { border: 1px solid #333; height: .17in; padding: 0 1px; text-align:center; }.encounter-card th:nth-child(1){width:10%}.encounter-card th:nth-child(2){width:18%}.encounter-card th:nth-child(3){width:7%}.encounter-card th:nth-child(4){width:8%}.encounter-card th:nth-child(5){width:6%}.encounter-card th:nth-child(6){width:6%}.encounter-card th:nth-child(7){width:7%}.encounter-card th:nth-child(8){width:7%}

.footer-grid { height: 2.52in; margin-top: .08in; display: grid; grid-template-columns: 2.3in 3.1in 2.4in 2.65in; gap: .1in; }
.footer-grid .panel-title { font-size: 14px; }
.footer-grid .panel-body { padding: .03in .06in; }
.quick-list { list-style: none; margin: 0; padding: 0; font-size: 9px; line-height: 1.15; }
.quick-list li { position: relative; padding-left: .1in; margin: .035in 0; }
.quick-list li::before { content: "•"; position: absolute; left: 0; }
.reference-table { height: 100%; font-size: 8px; }.reference-table th,.reference-table td { border: 1px solid #333; padding: 1px 2px; text-align:center; line-height: 1.05; }.reference-table td:last-child { text-align:left; }.reference-table .suit { font-size: 13px; }.hero-table th:last-child { width: 39%; }.hero-table th:nth-child(1) { width: 8%; }.hero-table th:nth-child(2) { width: 17%; }
.reward-list { display: grid; gap: .04in; font-size: 9px; line-height: 1.1; }.reward-list li { display: flex; gap: .06in; align-items: start; }.reward-list i { width: .13in; height: .13in; }

/* Ink-saving tracker palette. */
.tracker-sheet.light-mode .game-title,
.tracker-sheet.light-mode .panel-title,
.tracker-sheet.light-mode .hero-number,
.tracker-sheet.light-mode .encounter-card header b {
  background: #fff;
  color: #111;
  border: 1.5px solid #111;
}
.tracker-sheet.light-mode .game-title { border-width: 2px; }
.tracker-sheet.light-mode .panel-title { border-width: 0 0 1.3px; }
.tracker-sheet.light-mode .hero-number { border-width: 0 1.3px 1.3px 0; }
.tracker-sheet.light-mode .encounter-card header b { border-width: 0 1.3px 1.3px 0; }
.tracker-sheet.light-mode .sheet-icon { filter: invert(1); opacity: .58; }

@page { size: letter landscape; margin: 0; }
@media print {
  body { display: block; background: white; }
  .generator-panel, .preview-toolbar { display: none !important; }
  .preview-area, .sheet-stage { margin: 0; padding: 0; min-width: 0; overflow: visible; }
  .tracker-sheet { margin: 0; box-shadow: none; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .tracker-sheet, .map-sheet { break-after: page; page-break-after: always; }
  .map-sheet { break-after: auto; page-break-after: auto; }
}

@media (max-width: 900px) {
  body { display: block; }
  .generator-panel { position: static; width: 100%; height: auto; }
  #level-data, #map-data { height: 320px; }
}

*{box-sizing:border-box;-webkit-print-color-adjust:exact;print-color-adjust:exact}
body{margin:0;background:#2d382e;color:#1d1a15;font-family:Georgia,serif}
.screen-nav{position:sticky;top:0;z-index:3;display:flex;justify-content:space-between;padding:12px 4vw;background:#1f2922}.screen-nav a,.screen-nav button{color:#fff;font:700 14px system-ui}
.rules-sheet{width:min(1060px,96vw);margin:20px auto;background:#fff;padding:.4in .42in;box-shadow:0 18px 60px #0008}

/* header */
.hero{display:flex;justify-content:space-between;align-items:flex-end;gap:16px;border-bottom:3px double #111;padding-bottom:8px;margin-bottom:10px}
.hero p{margin:0 0 2px;font:800 10px system-ui;text-transform:uppercase;letter-spacing:.2em}
.hero h1{margin:0;font:900 44px/1 Georgia,serif;text-transform:uppercase;letter-spacing:.02em}
.hero h2{margin:3px 0 0;font:italic 700 15px Georgia,serif}
.hero-badges{display:flex;gap:6px}.hero-badges b{padding:5px 10px;border:2px solid #111;border-radius:14px;font:800 11px system-ui;white-space:nowrap}

/* columns */
.cols{column-count:3;column-gap:.22in;column-rule:1px solid #bbb}
.cols>section{break-inside:avoid;margin:0 0 11px;padding:0}
.cols h2{margin:0 0 4px;padding:3px 8px;background:#111;color:#fff;font:800 12px system-ui;text-transform:uppercase;letter-spacing:.08em;clip-path:polygon(0 0,100% 0,97% 100%,0 100%)}
.cols p,.cols li{font-size:12.5px;line-height:1.38;margin:0 0 5px}
.cols ul,.cols ol{margin:0 0 5px;padding-left:17px}.cols li{margin-bottom:2px}
.note{font-style:italic;font-size:11.5px!important}
.cols .intro{padding:7px 9px;border:2px solid #111;border-radius:12px}
.cols .intro h2{margin:-7px -9px 5px;border-radius:10px 10px 0 0;clip-path:none}
.cols .remember{padding:7px 9px;border:2px solid #111;border-radius:12px;background:#f2f2f2}
.cols .remember h2{margin:-7px -9px 5px;border-radius:10px 10px 0 0;clip-path:none}

/* icons */
.ic{display:inline-block;width:1.45em;height:1.45em;vertical-align:-.45em;background:url("assets/stake-or-die-icons.png") no-repeat;background-size:600% 200%;background-position:calc(var(--ix)*20%) calc(var(--iy)*100%)}
.ic.timber{--ix:0;--iy:0}.ic.stone{--ix:1;--iy:0}.ic.food{--ix:2;--iy:0}.ic.sawmill{--ix:3;--iy:0}.ic.quarry{--ix:4;--iy:0}.ic.farmstead{--ix:5;--iy:0}.ic.landmark{--ix:0;--iy:1}.ic.home{--ix:1;--iy:1}
.sico{display:inline-block;width:1.7em;height:1.7em;vertical-align:-.55em;background:url("assets/seasons-icons.png") no-repeat;background-size:400% 100%;background-position:calc(var(--s)*33.3333%) 0}
.s0{--s:0}.s1{--s:1}.s2{--s:2}.s3{--s:3}
.die{display:inline-block;width:1.7em;height:1.7em;margin-right:3px;vertical-align:-.55em;background:url("assets/dice-icons.png") no-repeat;background-size:600% 100%;background-position:calc(var(--d)*20%) 0}
.d0{--d:0}.d1{--d:1}.d2{--d:2}.d3{--d:3}.d4{--d:4}.d5{--d:5}
.vp{display:inline-grid;place-items:center;width:2em;height:2em;border:2px solid #111;border-radius:50%;font:900 15px/1 Georgia,serif;font-style:normal;vertical-align:-.65em;background:#fff}
.vp small{display:block;font:900 8px/1 Georgia,serif;margin-top:-1px}

.legend{display:grid;gap:3px;margin:0 0 5px}.legend span{font-size:12px;line-height:1.5}.legend.slim{margin-bottom:3px}

/* diagrams */
.fig{display:block;width:100%;height:auto;margin:3px 0 5px;border:1px solid #bbb;border-radius:6px;background:#fff}
.fig .gridlines path{stroke:#bbb;stroke-width:1;stroke-dasharray:2 3;fill:none}
.fig .solid,.fig .solid-r{stroke:#111;stroke-width:3.5;stroke-linecap:round;fill:none}
.fig .solid.hi{stroke:#111;stroke-width:6}
.fig .dotted{stroke:#111;stroke-width:3;stroke-dasharray:1 6;stroke-linecap:round;fill:none}
.fig .shade{fill:#e8e8e8}
.fig .xmark path{stroke:#111;stroke-width:3;stroke-linecap:round;fill:none}
.fig .mark{stroke:#111;stroke-width:3;fill:none;stroke-linecap:round}
.fig .box{fill:#fff;stroke:#111;stroke-width:2.5}
.fig .pt{fill:#fff;stroke:#111;stroke-width:1.5}
.fig .cap{font:700 9px system-ui;fill:#111}

/* tables */
table{width:100%;border-collapse:collapse;font:11.5px/1.3 system-ui;margin:0 0 5px}
th,td{border:1px solid #888;padding:3px 5px;text-align:left;vertical-align:middle}
th{background:#e6e6e6;font-weight:800}
td small{font-size:10.5px;color:#333}
.inv td:nth-child(2){text-align:center;font:900 16px Georgia,serif}.inv td:nth-child(2) small{font:700 11px system-ui}
.seasons td:nth-child(1){width:34px;text-align:center;padding:1px}.seasons td:nth-child(n+3){text-align:center}.seasons th:nth-child(n+3){text-align:center}
.mkt td:nth-child(2){width:46px;text-align:center}
.tiers{display:grid;grid-template-columns:auto 1fr;gap:2px 8px;font:12px system-ui}.tiers b{font-weight:900}

footer{text-align:center;margin-top:10px;padding-top:6px;border-top:3px double #111;font:800 11px system-ui;text-transform:uppercase;letter-spacing:.14em}

@media(max-width:900px){.cols{column-count:2}}
@media(max-width:600px){.cols{column-count:1}.hero{flex-direction:column;align-items:flex-start}.hero h1{font-size:34px}}

/* print: letter, as few pages as practical */
@media print{
 @page{size:letter portrait;margin:.3in}
 body{background:#fff}.screen-nav{display:none}
 .rules-sheet{width:auto;margin:0;padding:0;box-shadow:none}
 .hero h1{font-size:34px}.hero h2{font-size:13px}
 .cols{column-count:3;column-gap:.18in}
 .cols p,.cols li{font-size:9.6pt;line-height:1.3}
 .note{font-size:9pt!important}
 .legend span{font-size:9.4pt}
 table{font-size:8.8pt}td small{font-size:8.2pt}
 .cols>section{margin-bottom:8px}
 .cols h2{font-size:9.6pt}
 .fig .cap{font-size:8px}
}
.legend span{display:flex;align-items:center;gap:3px;line-height:1.25}
.legend .vp{flex:none;vertical-align:baseline;margin-right:3px}
.legend .ic{vertical-align:baseline;flex:none}

/* app shell with sidebar */
body.rules-app{background:#d8e0df}
.rules-preview{min-width:0;overflow:auto;padding:20px 0}
.rules-preview .rules-sheet{margin:0 auto}
@media print{.generator-panel{display:none!important}.rules-preview{padding:0;overflow:visible}body.rules-app{display:block!important;background:#fff}}
@media print{html,body.rules-app,.rules-preview{background:#fff!important;height:auto!important;min-height:0!important;overflow:visible!important}body.rules-app{display:block!important}.rules-preview{display:block!important}}

body.rules-app { display: block !important; }
@media screen and (max-width: 600px) { .rules-preview { padding: 0 !important; } .rules-preview .rules-sheet { width: 100% !important; padding: 16px !important; box-shadow: none; } .cols p, .cols li { font-size: 15px; line-height: 1.45; } table { font-size: 13px; } }
