:root {
  --paper: #efe3c2;
  --paper-light: #fff7df;
  --paper-dark: #d7bf84;
  --ink: #17130d;
  --muted: #4f4536;
  --accent: #80321d;
  --accent-dark: #4f1f14;
  --ochre: #9a7636;
  --line: #1d1811;
  --focus: #005fcc;
  --shadow: rgba(23,19,13,.24);
  font-family: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 16% 0%, rgba(255,247,223,.92), transparent 34%),
    linear-gradient(180deg, #e8d6aa, #c5a66a 70%, #a9854b);
  color: var(--ink);
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: var(--ink); }
button {
  border: 2px solid var(--line);
  background: var(--paper-light);
  color: var(--ink);
  padding: .65rem .95rem;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  min-height: 44px;
}
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--accent); color: #fff7e5; }
button:hover:not(:disabled) { transform: translateY(-1px); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.topbar {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 4px solid var(--line);
  background: rgba(239,227,194,.97);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { margin: 0; font-size: clamp(1.45rem, 2vw, 2.2rem); }
.version { font-size: .9rem; color: var(--accent-dark); vertical-align: middle; }
.topbar p { margin: .25rem 0 0; color: var(--muted); max-width: 72ch; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }

.layout {
  display: grid;
  grid-template-columns: minmax(270px, 340px) minmax(720px, 1fr);
  grid-template-areas:
    "controls sheet"
    "prompt prompt"
    "log log";
  gap: 1rem;
  padding: 1rem;
}
.controls { grid-area: controls; }
.sheet-wrap { grid-area: sheet; overflow: auto; padding-bottom: 1rem; }
.prompt-panel { grid-area: prompt; }
.log-panel { grid-area: log; }

.panel, .sheet {
  background: var(--paper);
  border: 3px solid var(--line);
  box-shadow: 6px 6px 0 var(--shadow);
}
.panel { padding: 1rem; border-radius: 14px; align-self: start; }
.panel h2 { margin-top: 0; }

.choiceBox.empty, .emptyState { color: var(--muted); font-style: italic; }
.choiceGroup { border-top: 2px solid var(--line); padding-top: .75rem; margin-top: .75rem; }
.choiceGroup h3 { margin: .2rem 0 .5rem; }
.field { display: grid; gap: .25rem; margin: .6rem 0; }
.field input, .field select, textarea {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--paper-light);
  padding: .5rem;
  min-height: 44px;
}
textarea { resize: vertical; min-height: 13rem; font-family: "Courier New", monospace; }
.hint { color: var(--muted); font-size: .95rem; margin: .35rem 0; }
.smallprint { font-size: .9rem; color: var(--muted); margin-top: 1rem; }

.sheet {
  width: min(100%, 1120px);
  min-height: 760px;
  margin: 0 auto;
  padding: 1.1rem;
  border-radius: 4px;
  background:
    linear-gradient(90deg, rgba(29,24,17,.055) 1px, transparent 1px),
    linear-gradient(rgba(29,24,17,.055) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
}
.sheet.placeholder { display: grid; place-items: center; }

.sheet-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: .75rem;
}
.sheet-title {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: .75rem;
  align-items: stretch;
  margin-bottom: .75rem;
}
.big-name {
  border: 3px solid var(--line);
  background: var(--paper-light);
  padding: .5rem;
  min-height: 74px;
}
.big-name label, .sheet-box label { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.big-name input { width: 100%; border: 0; background: transparent; font-size: 2rem; font-weight: bold; color: var(--ink); outline: none; }
.portrait {
  border: 3px solid var(--line);
  background: var(--paper-light);
  min-height: 124px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: .9rem;
  color: var(--muted);
}

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.stat {
  border: 3px solid var(--line);
  background: var(--paper-light);
  text-align: center;
  padding: .45rem;
}
.stat .label { font-size: .9rem; font-weight: bold; }
.stat .value { font-size: 2.3rem; line-height: 1; font-weight: bold; }
.stat .roll { color: var(--muted); font-size: .84rem; }

.sheet-box {
  border: 2px solid var(--line);
  background: rgba(255,247,223,.78);
  padding: .55rem;
  margin-bottom: .6rem;
}
.sheet-box h3 { margin: 0 0 .45rem; font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; }
.kv { display: grid; grid-template-columns: 145px 1fr; gap: .35rem .6rem; font-size: .97rem; }
.kv b { color: var(--muted); }
.tp-kerne { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.meter { border: 2px solid var(--line); background: var(--paper-light); padding: .4rem; text-align: center; }
.meter strong { display: block; font-size: 1.6rem; }

.inventory {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: .55rem;
}
.slot {
  aspect-ratio: 1 / 1;
  border: 2px solid var(--line);
  background: var(--paper-light);
  padding: .35rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.slot .slot-title { font-size: .72rem; color: var(--muted); text-transform: uppercase; }
.slot.filled { background: #f8e7b6; }
.item { font-weight: bold; font-size: clamp(.78rem, 1vw, .96rem); overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: .76rem; }
.fullspan { grid-column: 1 / -1; }

.roll-log { max-height: 46vh; overflow: auto; padding-left: 1.4rem; }
.roll-log li { margin: .45rem 0; line-height: 1.3; }
.roll-log .decision { color: var(--accent-dark); font-weight: bold; }
.roll-log .rule { color: var(--muted); }

@media (max-width: 1120px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "controls" "sheet" "prompt" "log"; }
  .topbar { position: static; flex-direction: column; align-items: flex-start; }
  .actions { justify-content: flex-start; }
  .sheet-grid, .sheet-title { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
@media print {
  body { background: white; }
  .topbar, .controls, .log-panel, .prompt-panel { display: none; }
  .layout { display: block; padding: 0; }
  .sheet { box-shadow: none; width: 100%; border: 2px solid #000; }
}


/* v1.2.0: A5 portrait character sheet layout based on measured PDF coordinates */
.sheet.a5-sheet {
  position: relative;
  width: min(100%, 760px);
  aspect-ratio: 419.528 / 595.276;
  min-height: auto;
  padding: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(29,24,17,.035) 1px, transparent 1px),
    linear-gradient(rgba(29,24,17,.035) 1px, transparent 1px),
    var(--paper);
  background-size: 18px 18px;
}
.a5-field, .a5-box {
  position: absolute;
  border: 2px solid var(--line);
  background: rgba(255,247,223,.74);
  padding: .55em;
  overflow: hidden;
}
.a5-line {
  position: absolute;
  border-bottom: 2px solid var(--line);
  padding: .2em .25em;
  overflow: hidden;
}
.a5-label {
  display: block;
  font-size: clamp(.48rem, 1.35vw, .72rem);
  line-height: 1;
  font-weight: 700;
  color: var(--line);
  text-transform: none;
}
.a5-value { font-size: clamp(.58rem, 1.55vw, .88rem); line-height: 1.12; overflow-wrap: anywhere; }
.a5-name .a5-value { font-size: clamp(1.05rem, 4.2vw, 2rem); font-weight: 700; line-height: 1; }
.a5-title { position:absolute; font-size: clamp(1rem, 3.8vw, 1.85rem); font-weight:700; line-height:1; }
.a5-micro { font-size: clamp(.45rem, 1.1vw, .64rem); color: var(--muted); }
.a5-stat-row { position:absolute; display:grid; grid-template-columns: 1fr 18% 18%; gap:.25em; align-items:center; }
.a5-stat-label { font-size: clamp(1.15rem, 4vw, 2rem); font-weight:700; }
.a5-stat-cell { border:2px solid var(--line); background:var(--paper-light); min-height:2.1em; display:grid; place-items:center; font-weight:700; }
.a5-inv-title { left:4.8%; top:50.1%; width:20%; height:4%; }
.a5-inventory-slot {
  position:absolute;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--line);
  background: rgba(255,247,223,.82);
  padding: .35em;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  overflow:hidden;
}
.a5-slot-label { font-size: clamp(.45rem, 1.1vw, .64rem); font-weight:700; color:var(--muted); }
.a5-slot-item { font-size: clamp(.48rem, 1.18vw, .7rem); line-height:1.05; font-weight:700; overflow-wrap:anywhere; }
.a5-slot-note { font-size: clamp(.4rem, .95vw, .57rem); color:var(--muted); line-height:1.05; }
.a5-help { position:absolute; left:4.8%; top:79.4%; width:90%; font-size: clamp(.45rem, 1.05vw, .63rem); line-height:1.15; }
.a5-bottom-label { position:absolute; font-size: clamp(.55rem, 1.4vw, .78rem); font-weight:700; }
.a5-smallbox { position:absolute; border:2px solid var(--line); background:rgba(255,247,223,.74); padding:.35em; }
.a5-textbox { position:absolute; border:2px solid var(--line); background:rgba(255,247,223,.74); padding:.35em; }
.a5-origin-note { position:absolute; right:2%; bottom:1%; font-size: clamp(.4rem, .9vw, .55rem); color:var(--muted); }

/* Absolute coordinates in percent, derived from A5 PDF 419.528 x 595.276 pt */
.a5-name { left:4.8%; top:4.3%; width:52.8%; height:7.4%; border-bottom-width:3px; }
.a5-background { left:4.8%; top:10.3%; width:52.8%; height:5.7%; }
.a5-portrait { left:4.8%; top:14.0%; width:53.6%; height:33.2%; display:flex; align-items:flex-start; justify-content:center; text-align:center; }
.a5-birth { left:61.5%; top:3.6%; width:33.8%; height:4.2%; }
.a5-fell { left:61.5%; top:6.9%; width:33.8%; height:4.2%; }
.a5-feature { left:61.5%; top:10.2%; width:33.8%; height:4.6%; }
.a5-stat-head-max { left:74.7%; top:20.4%; width:8%; height:2.1%; }
.a5-stat-head-cur { left:87.4%; top:20.4%; width:8%; height:2.1%; }
.a5-stat-sta { left:61.5%; top:23.4%; width:34%; height:5.6%; }
.a5-stat-ges { left:61.5%; top:28.8%; width:34%; height:5.6%; }
.a5-stat-wil { left:61.5%; top:34.3%; width:34%; height:5.6%; }
.a5-stat-tp  { left:61.5%; top:41.4%; width:34%; height:5.6%; }
.a5-kernels { left:64.0%; top:50.9%; width:31.5%; height:4.5%; }
.a5-slot-haupt { left:4.8%; top:55.3%; width:16.9%; }
.a5-slot-body1 { left:23.9%; top:55.3%; width:16.9%; }
.a5-slot-pack1 { left:43.0%; top:55.3%; width:16.9%; }
.a5-slot-pack2 { left:60.3%; top:55.3%; width:16.9%; }
.a5-slot-pack3 { left:77.6%; top:55.3%; width:16.9%; }
.a5-slot-neben { left:4.8%; top:67.5%; width:16.9%; }
.a5-slot-body2 { left:23.9%; top:67.5%; width:16.9%; }
.a5-slot-pack4 { left:43.0%; top:67.5%; width:16.9%; }
.a5-slot-pack5 { left:60.3%; top:67.5%; width:16.9%; }
.a5-slot-pack6 { left:77.6%; top:67.5%; width:16.9%; }
.a5-level { left:4.8%; top:84.1%; width:16.8%; height:7.8%; }
.a5-mumm { left:23.0%; top:84.1%; width:33.0%; height:7.8%; }
.a5-stored { left:61.5%; top:84.1%; width:33.8%; height:12.2%; }
.a5-ep { left:4.8%; top:93.6%; width:16.8%; height:3.4%; }
.a5-ignore { left:23.0%; top:93.6%; width:33.0%; height:3.4%; }
.a5-treasure { left:4.8%; top:96.9%; width:51.2%; height:2.5%; }

@media (max-width: 1120px) {
  .sheet.a5-sheet { width: min(100%, 640px); }
}

/* v1.3.0: decision status */
.statusBox {
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: .7rem;
  background: var(--paper-light);
}
.statusBox.open {
  border-color: #7a2e1d;
  background: #f8dfc6;
}
.statusBox.complete {
  border-color: #245c39;
  background: #dcebd9;
}
.statusBox ul {
  margin: .4rem 0 0 1.2rem;
  padding: 0;
}
.statusBox.complete ul:empty::after {
  content: "Keine offenen Entscheidungen.";
  color: var(--muted);
}
.choiceGroup button + button {
  margin-left: .5rem;
  margin-top: .5rem;
}


/* v1.3.1: layout bugfixes from visual review */
.sheet.a5-sheet { font-size: clamp(10px, 1.45vw, 15px); }
.a5-line {
  border-bottom: 0;
  background: transparent;
  padding: .15em .25em;
}
.a5-name, .a5-background, .a5-birth, .a5-fell, .a5-feature, .a5-kernels, .a5-treasure {
  box-shadow: inset 0 -2px 0 var(--line);
}
.a5-name { top: 5.0%; height: 7.8%; }
.a5-background { top: 13.2%; height: 5.8%; }
.a5-portrait { top: 19.8%; height: 31.9%; }
.a5-birth { top: 5.0%; height: 4.8%; }
.a5-fell { top: 10.0%; height: 4.8%; }
.a5-feature { top: 15.0%; height: 4.8%; }
.a5-label { margin-bottom: .12em; }
.a5-name .a5-value { font-size: clamp(1.3rem, 4.7vw, 2.4rem); }
.a5-stat-head-max, .a5-stat-head-cur { position: absolute; font-size: clamp(.55rem, 1.25vw, .78rem); }
.a5-stat-head-max { left: 77.8%; top: 30.0%; width: 8%; }
.a5-stat-head-cur { left: 88.8%; top: 30.0%; width: 8%; }
.a5-stat-row {
  grid-template-columns: 1fr 24% 24%;
  gap: .45em;
}
.a5-stat-label { font-size: clamp(1.55rem, 5vw, 2.75rem); }
.a5-stat-cell { min-height: 2.65em; font-size: clamp(1rem, 2.4vw, 1.5rem); }
.a5-stat-sta { top: 34.0%; }
.a5-stat-ges { top: 43.3%; }
.a5-stat-wil { top: 52.6%; }
.a5-stat-tp  { top: 66.0%; }
.a5-kernels { top: 79.0%; height: 5.0%; }
.a5-inv-title { top: 53.2%; }
.a5-slot-haupt, .a5-slot-body1, .a5-slot-pack1, .a5-slot-pack2, .a5-slot-pack3 { top: 61.0%; }
.a5-slot-neben, .a5-slot-body2, .a5-slot-pack4, .a5-slot-pack5, .a5-slot-pack6 { top: 73.3%; }
.a5-help {
  left: 4.8%;
  top: 85.7%;
  width: 90%;
  display: grid;
  grid-template-columns: 21% 21% 1fr;
  gap: .6em;
  font-size: clamp(.42rem, .95vw, .6rem);
}
.a5-progression {
  position: absolute;
  left: 4.8%;
  top: 89.0%;
  width: 52.9%;
  height: 8.8%;
  border: 2px solid var(--line);
  background: rgba(255,247,223,.74);
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  grid-template-rows: 1fr 1fr;
}
.a5-progress-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: .25em .35em;
  overflow: hidden;
}
.a5-progress-cell:nth-child(3), .a5-progress-cell:nth-child(6) { border-right: 0; }
.a5-progress-cell:nth-child(n+4) { border-bottom: 0; }
.a5-progress-mumm { grid-row: span 2; }
.a5-progress-value { font-weight: 700; font-size: clamp(.8rem, 2vw, 1.25rem); }
.a5-level, .a5-mumm, .a5-ep, .a5-ignore, .a5-treasure { display: none; }
.a5-stored { top: 89.0%; height: 8.8%; }

/* v1.3.2: corrected attribute area and original-like bottom row */
.a5-birth { height: 5.7%; }
.a5-feature { top: 16.2%; }
.a5-stat-head-max { left: 77.8%; top: 24.2%; width: 8%; }
.a5-stat-head-cur { left: 88.8%; top: 24.2%; width: 8%; }
.a5-stat-row { grid-template-columns: 1fr 24% 24%; gap: .45em; min-height: 7.2%; }
.a5-stat-label { font-size: clamp(1.55rem, 5.1vw, 2.8rem); }
.a5-stat-cell { min-height: 2.45em; font-size: clamp(1rem, 2.45vw, 1.55rem); }
.a5-stat-sta { top: 28.0%; }
.a5-stat-ges { top: 37.0%; }
.a5-stat-wil { top: 46.0%; }
.a5-stat-tp  { top: 55.0%; }
.a5-inv-title { top: 58.7%; }
.a5-kernels { top: 60.0%; height: 4.8%; }
.a5-slot-haupt, .a5-slot-body1, .a5-slot-pack1, .a5-slot-pack2, .a5-slot-pack3 { top: 67.2%; }
.a5-slot-neben, .a5-slot-body2, .a5-slot-pack4, .a5-slot-pack5, .a5-slot-pack6 { top: 79.7%; }
.a5-help { top: 91.8%; grid-template-columns: 18% 18% 1fr; }
.a5-progression { display: none; }
.a5-level-block, .a5-mumm-block, .a5-storage-block {
  top: 94.1%;
  height: 16.9%;
  border: 2px solid var(--line);
  background: rgba(255,247,223,.74);
  padding: 0;
  position: absolute;
  overflow: hidden;
}
.a5-level-block { left: 4.8%; width: 16.9%; }
.a5-mumm-block { left: 23.8%; width: 33.8%; }
.a5-storage-block { left: 61.5%; width: 33.8%; padding: .45em; }
.a5-level-head, .a5-mumm-head {
  height: 25%;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 32%;
  align-items: center;
  padding: .25em .35em;
}
.a5-mumm-head { grid-template-columns: 1fr 22%; }
.a5-level-value {
  border-left: 1px solid var(--line);
  height: 100%;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.a5-level-body { height: 75%; padding: .35em; }
.a5-mumm-block > .a5-micro { padding: .35em .45em 0; }
.a5-stored { display: none; }
.a5-origin-note { bottom: .35%; }
@media (max-width: 1120px) {
  .a5-help { font-size: clamp(.38rem, 1.1vw, .55rem); }
}

/* v1.3.2 override: fit inventory and bottom row within A5 */
.a5-stat-head-max { top: 23.0%; }
.a5-stat-head-cur { top: 23.0%; }
.a5-stat-sta { top: 26.5%; }
.a5-stat-ges { top: 34.5%; }
.a5-stat-wil { top: 42.5%; }
.a5-stat-tp  { top: 50.5%; }
.a5-inv-title { top: 57.4%; }
.a5-kernels { top: 58.4%; }
.a5-slot-haupt, .a5-slot-body1, .a5-slot-pack1, .a5-slot-pack2, .a5-slot-pack3 { top: 62.0%; }
.a5-slot-neben, .a5-slot-body2, .a5-slot-pack4, .a5-slot-pack5, .a5-slot-pack6 { top: 74.2%; }
.a5-help { top: 86.4%; }
.a5-level-block, .a5-mumm-block, .a5-storage-block { top: 88.0%; height: 11.9%; }

/* v1.3.3: cleaner lines, more breathing room, compact Kerne box */
.a5-name, .a5-background, .a5-birth, .a5-fell, .a5-feature {
  box-shadow: none;
  border-bottom: 2px solid var(--line);
  padding-bottom: .2em;
}
.a5-name { top: 4.9%; height: 9.6%; }
.a5-background { top: 15.2%; height: 8.0%; }
.a5-portrait { top: 24.2%; height: 31.0%; }
.a5-birth { top: 5.0%; height: 6.6%; }
.a5-fell { top: 13.2%; height: 5.8%; }
.a5-feature { top: 21.1%; height: 5.8%; }
.a5-birth .a5-value, .a5-fell .a5-value, .a5-feature .a5-value { line-height: 1.08; }
.a5-stat-head-max { top: 28.0%; }
.a5-stat-head-cur { top: 28.0%; }
.a5-stat-sta { top: 31.5%; }
.a5-stat-ges { top: 40.0%; }
.a5-stat-wil { top: 48.5%; }
.a5-stat-tp  { top: 57.0%; }
.a5-stat-cell { min-height: 2.25em; }
.a5-inv-title { top: 60.8%; }
.a5-kernels {
  left: 61.5%;
  top: 60.6%;
  width: 33.8%;
  height: 3.6%;
  border: 2px solid var(--line);
  box-shadow: none;
  background: rgba(255,247,223,.74);
  padding: .15em .4em;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .8em;
  align-items: center;
}
.a5-kernels .a5-label { margin: 0; }
.a5-kernels .a5-value { line-height: 1; }
.a5-slot-haupt, .a5-slot-body1, .a5-slot-pack1, .a5-slot-pack2, .a5-slot-pack3 { top: 66.0%; }
.a5-slot-neben, .a5-slot-body2, .a5-slot-pack4, .a5-slot-pack5, .a5-slot-pack6 { top: 77.8%; }
.a5-help {
  top: 89.8%;
  line-height: 1.05;
  gap: .35em;
  background: rgba(239,227,194,.88);
  padding: .08em .15em;
}
.a5-level-block, .a5-mumm-block, .a5-storage-block { top: 91.5%; height: 7.9%; }
.a5-level-head, .a5-mumm-head { height: 28%; }
.a5-level-body { height: 72%; }
.a5-mumm-block > .a5-micro { padding-top: .25em; line-height: 1.1; }
.a5-origin-note { display: none; }


/* v1.3.4: compact vertical layout, no TP/Kerne overlap, consistent bottom heights */
.a5-name { top: 3.8%; height: 8.0%; }
.a5-background { top: 12.6%; height: 6.0%; }
.a5-portrait { top: 19.2%; height: 34.0%; }
.a5-birth { top: 4.0%; height: 6.0%; }
.a5-fell { top: 11.0%; height: 5.8%; }
.a5-feature { top: 18.0%; height: 5.8%; }
.a5-name, .a5-background, .a5-birth, .a5-fell, .a5-feature {
  border-bottom: 2px solid var(--line);
  box-shadow: none;
  padding-top: .05em;
}
.a5-label { line-height: 1.05; }
.a5-value { line-height: 1.08; }
.a5-name .a5-value { font-size: clamp(1.12rem, 4.5vw, 2.25rem); }
.a5-stat-head-max { top: 25.2%; left: 78.0%; }
.a5-stat-head-cur { top: 25.2%; left: 89.0%; }
.a5-stat-row { min-height: 6.9%; grid-template-columns: 1fr 24% 24%; }
.a5-stat-label { font-size: clamp(1.35rem, 4.7vw, 2.55rem); }
.a5-stat-cell { min-height: 2.05em; font-size: clamp(.95rem, 2.2vw, 1.45rem); }
.a5-stat-sta { top: 28.8%; }
.a5-stat-ges { top: 36.0%; }
.a5-stat-wil { top: 43.2%; }
.a5-stat-tp  { top: 50.4%; }
.a5-inv-title { top: 56.8%; }
.a5-kernels {
  left: 61.5%;
  top: 57.4%;
  width: 33.8%;
  height: 3.35%;
  border: 2px solid var(--line);
  box-shadow: none;
  background: rgba(255,247,223,.84);
  padding: .1em .45em;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .75em;
  align-items: center;
}
.a5-kernels .a5-label, .a5-kernels .a5-value { margin: 0; line-height: 1; }
.a5-slot-haupt, .a5-slot-body1, .a5-slot-pack1, .a5-slot-pack2, .a5-slot-pack3 { top: 61.4%; }
.a5-slot-neben, .a5-slot-body2, .a5-slot-pack4, .a5-slot-pack5, .a5-slot-pack6 { top: 73.55%; }
.a5-help {
  top: 85.85%;
  width: 90.5%;
  line-height: 1.0;
  gap: .45em;
  background: rgba(239,227,194,.92);
  padding: .08em .12em;
  font-size: clamp(.38rem, .85vw, .55rem);
}
.a5-level-block, .a5-mumm-block, .a5-storage-block {
  top: 87.9%;
  height: 11.9%;
  border: 2px solid var(--line);
  background: rgba(255,247,223,.84);
}
.a5-level-block { left: 4.8%; width: 16.9%; }
.a5-mumm-block { left: 23.9%; width: 33.8%; }
.a5-storage-block { left: 61.5%; width: 33.8%; padding: .45em; }
.a5-level-head, .a5-mumm-head { height: 25%; padding: .2em .35em; }
.a5-level-body { height: 75%; padding: .3em .35em; }
.a5-mumm-block > .a5-micro { padding: .25em .45em 0; line-height: 1.05; }
.a5-progress-value { font-size: clamp(.8rem, 2vw, 1.2rem); }
.a5-origin-note { display: none; }

/* v1.3.5: align helper labels to slot columns, right-align 250 in Kerne, EP-only Stufe body */
.a5-help {
  display: block;
  left: 4.8%;
  width: 90.5%;
  top: 85.9%;
  height: 1.9%;
  background: rgba(239,227,194,.96);
  padding: 0;
  line-height: 1.0;
  font-size: clamp(.38rem, .82vw, .54rem);
}
.a5-help span { position: absolute; top: 0; display: block; }
.a5-help span:nth-child(1) { left: 0; width: 16.9%; }
.a5-help span:nth-child(2) { left: 19.1%; width: 16.9%; }
.a5-help span:nth-child(3) { left: 38.2%; width: 52%; }
.a5-kernels {
  grid-template-columns: auto 1fr;
  gap: .35em;
}
.a5-kernels .a5-value {
  text-align: right;
  justify-self: stretch;
}
.a5-level-body .a5-micro { font-weight: 700; color: var(--line); }
.a5-level-body .a5-progress-value { margin-top: .35em; }


/* v1.3.6: helper labels aligned to marked column edges, EP value removed */
.a5-help span:nth-child(2) { left: 21.4%; width: 16.9%; }
.a5-help span:nth-child(3) { left: 40.5%; width: 52%; }
.a5-level-body .a5-progress-value { display: none; }
.a5-level-body .a5-micro {
  display: block;
  margin-top: .55em;
  font-weight: 700;
  color: var(--line);
  font-size: clamp(.62rem, 1.3vw, .82rem);
}
.a5-kernels .a5-value { text-align: right; justify-self: stretch; }


/* v1.3.7: move Gepackt helper label further right under packed inventory columns */
.a5-help span:nth-child(3) {
  left: 42.2%;
  width: 50.5%;
}


/* v1.4.0-rc1: publication footer, legal pages, release polish */
.site-footer, .legal-page {
  background: rgba(239,227,194,.97);
  color: var(--ink);
  border-top: 3px solid var(--line);
}
.site-footer {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  font-size: .95rem;
}
.site-footer p { margin: .35rem 0; max-width: 98ch; }
.site-footer a, .legal-page a { color: var(--accent-dark); font-weight: 700; }
.legal-page {
  max-width: 980px;
  margin: 1rem auto;
  padding: 1.25rem;
  border: 3px solid var(--line);
  border-radius: 12px;
  box-shadow: 6px 6px 0 var(--shadow);
  line-height: 1.55;
}
.legal-page h1, .legal-page h2 { line-height: 1.15; }
.legal-page code { background: var(--paper-light); padding: .1rem .25rem; border: 1px solid var(--line); }
.release-note {
  border: 2px solid var(--line);
  background: var(--paper-light);
  padding: .75rem;
  border-radius: 10px;
  margin: 1rem 0;
}
@media print { .site-footer { display: none; } }

.button-link {
  border: 2px solid var(--line);
  background: var(--paper-light);
  color: var(--ink);
  padding: .65rem .95rem;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 2px 2px 0 var(--line);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}


/* v1.5.0-rc1: local persistence, mobile polish, print view */
#storageStatus {
  border: 2px solid var(--line);
  background: var(--paper-light);
  border-radius: 8px;
  padding: .55rem .65rem;
  margin-bottom: .75rem;
}
.actions button, .actions .button-link { margin: .18rem; }
.print-main {
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: 1rem;
}
.print-instructions {
  max-width: 760px;
  border: 2px solid var(--line);
  background: var(--paper-light);
  border-radius: 10px;
  padding: .75rem 1rem;
}
.print-sheet-target {
  width: min(92vw, 148mm);
  height: calc(min(92vw, 148mm) * 1.4142);
  max-height: 210mm;
}
.print-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 4px;
}
#printPortraitContent { width: 100%; height: 100%; }

@media (max-width: 980px) {
  .topbar { align-items: stretch; }
  .topbar .actions { justify-content: flex-start; }
  .layout { grid-template-columns: 1fr; }
  .sheet-wrap { overflow-x: auto; padding-bottom: 1rem; }
  .sheet.a5-sheet { min-width: 360px; }
  .panel { width: auto; }
  textarea { width: 100%; }
}

@media (max-width: 560px) {
  .topbar { padding: .75rem; }
  .topbar h1 { font-size: 1.35rem; }
  .actions button, .actions .button-link {
    width: 100%;
    justify-content: center;
  }
  .choiceGroup { padding: .75rem; }
  .field input, .field select, button, .button-link { font-size: 1rem; }
  .sheet.a5-sheet { min-width: 330px; }
}

@page {
  size: A5 portrait;
  margin: 0;
}
@media print {
  html, body {
    width: 148mm;
    min-height: 210mm;
    margin: 0;
    padding: 0;
    background: white;
  }
  .print-controls, .print-instructions, .site-footer { display: none !important; }
  .print-main { padding: 0; display: block; }
  .print-sheet-target {
    width: 148mm !important;
    height: 210mm !important;
    max-height: none !important;
    margin: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }
}


/* v1.5.0-rc2: correct A5 preview ratio and remove screen preview squashing */
.print-page .print-main {
  overflow-x: auto;
  align-items: start;
}
.print-page .print-sheet-target {
  width: 148mm !important;
  height: 210mm !important;
  aspect-ratio: auto !important;
  max-width: none !important;
  max-height: none !important;
  flex: 0 0 auto;
}
@media screen and (max-width: 720px) {
  .print-page .print-main {
    justify-items: start;
  }
  .print-page .print-sheet-target {
    margin-left: .5rem;
    margin-right: .5rem;
  }
}


/* v1.5.1 final: help page and accessible messages */
.message-area {
  min-height: 1.2rem;
  margin: .5rem 0 .75rem;
  font-weight: 700;
}
.message-area.info { color: var(--ink); }
.message-area.error {
  color: #5f1d14;
  background: #f3d8c9;
  border: 2px solid #5f1d14;
  border-radius: 8px;
  padding: .5rem .65rem;
}
.legal-page dl {
  display: grid;
  grid-template-columns: minmax(5rem, 10rem) 1fr;
  gap: .35rem .85rem;
}
.legal-page dt { font-weight: 800; }
.legal-page dd { margin: 0 0 .35rem; }
@media (max-width: 560px) {
  .legal-page dl { grid-template-columns: 1fr; }
}


/* v1.5.3: table-play character sheet adjustments */
.a5-current-cell {
  color: transparent;
}
.a5-slot-item,
.a5-slot-note {
  color: rgba(42, 32, 22, 0.22);
  font-weight: 600;
}
.a5-slot-note {
  color: rgba(42, 32, 22, 0.18);
}
@media print {
  .a5-slot-item {
    color: rgba(0, 0, 0, 0.24) !important;
  }
  .a5-slot-note {
    color: rgba(0, 0, 0, 0.18) !important;
  }
}


/* v1.6.0-rc1: action grouping and maintainability pass */
.grouped-actions {
  display: grid;
  gap: .45rem;
  align-content: start;
}
.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.primary-actions {
  padding-bottom: .25rem;
  border-bottom: 2px solid rgba(42, 32, 22, .22);
}
.secondary-actions button {
  font-size: .92rem;
}
@media (max-width: 560px) {
  .action-group { width: 100%; }
  .action-group button { width: 100%; }
}

.visual-style-selector {
  margin: 0.75rem 0;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(255,255,255,0.04);
}
.visual-style-selector legend {
  font-weight: 700;
  padding: 0 0.35rem;
}
.radio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.35rem 0.75rem;
  margin-top: 0.4rem;
}
.radio-grid label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.92rem;
  line-height: 1.25;
}
.radio-grid input[type="radio"] {
  accent-color: var(--accent);
}
