@font-face {
  font-family: "Noto Serif";
  src: url("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("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("noto-serif-latin-900-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 900;
  font-display: swap;
}
@font-face {
  font-family: "Inconsolata";
  src: url("inconsolata-latin-400-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Inconsolata";
  src: url("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: none; 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; }
}
