/* Knights of the White Coat — illuminated-manuscript theme */
:root {
  --royal: #1e3a8a;
  --parch: #f5ecd7;
  --parch-2: #ead9b0;
  --parch-3: #dcc58f;
  --ink: #2b1d0e;
  --ink-soft: #5b4630;
  --crimson: #9f1239;
  --forest: #166534;
  --gold: #ca8a04;
  --gold-soft: #fde68a;
  --stone: #57534e;
  --cp: #6d28d9;
  --bb: #15803d;
  --ps: #0f766e;
  --cars: #881337;
  --cross: #ca8a04;
  --scale: 1;
  --f-title: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --f-body: 'EB Garamond', Garamond, Georgia, serif;
  --f-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 10px;
  --shadow: 0 2px 0 rgba(43, 29, 14, .15), 0 8px 24px rgba(43, 29, 14, .18);
}
* { box-sizing: border-box; }
html { font-size: calc(16px * var(--scale)); }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font-family: var(--f-body); font-size: 1.1rem; line-height: 1.5;
  background: radial-gradient(ellipse at 30% 20%, #fbf5e6 0%, var(--parch) 45%, var(--parch-2) 100%) fixed;
}
body.dyslexia { --f-body: 'Atkinson Hyperlegible', Verdana, Tahoma, sans-serif; --f-title: Verdana, Tahoma, sans-serif; letter-spacing: .03em; word-spacing: .12em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--royal); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--royal); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; }
h1, h2, h3, .title { font-family: var(--f-title); letter-spacing: .02em; margin: 0 0 .5rem; }
h2 { font-size: 1.5rem; } h3 { font-size: 1.15rem; }
a { color: var(--royal); }
.muted { color: var(--ink-soft); }
.small { font-size: .9rem; }
.ui { font-family: var(--f-ui); }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--f-ui); font-weight: 600; font-size: .95rem; border: 2px solid var(--ink); background: #fffaf0; color: var(--ink);
  padding: .55rem 1rem; border-radius: 8px; box-shadow: 0 2px 0 var(--ink); transition: transform .06s, box-shadow .06s, background .15s;
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
}
.btn:hover { background: #fff; }
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 0 2px 0 var(--ink); }
.btn.primary { background: var(--royal); color: #fff; border-color: #0f1d4a; box-shadow: 0 2px 0 #0f1d4a; }
.btn.primary:hover { background: #2747a8; }
.btn.gold { background: var(--gold); color: #1c1203; border-color: #6b4a03; box-shadow: 0 2px 0 #6b4a03; }
.btn.danger { background: var(--crimson); color: #fff; border-color: #5b0a21; box-shadow: 0 2px 0 #5b0a21; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 2px 0 #6b4a03, 0 0 0 0 rgba(202, 138, 4, .55); } 50% { box-shadow: 0 2px 0 #6b4a03, 0 0 0 8px rgba(202, 138, 4, 0); } }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }
.badge { font-family: var(--f-ui); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: .15rem .5rem; border-radius: 999px; background: var(--parch-2); border: 1px solid var(--parch-3); white-space: nowrap; }
.badge.rank { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); }
.badge.aamc { background: #e0e7ff; border-color: #a5b4fc; color: #1e1b4b; }
.pip-badge { background: var(--crimson); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .4rem; min-width: 1.2rem; text-align: center; }

/* ---------- HUD ---------- */
.hud {
  position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; align-items: center;
  padding: .5rem 1rem; background: linear-gradient(#2b1d0e, #3d2a14); color: var(--parch); border-bottom: 3px solid var(--gold);
}
.hud-knight { display: flex; align-items: center; gap: .6rem; background: none; border: 0; color: inherit; text-align: left; padding: .2rem; }
.hud-avatar { width: 46px; height: 58px; display: block; background: var(--parch); border-radius: 8px; border: 2px solid var(--gold); overflow: hidden; }
.hud-avatar svg { width: 100%; height: 100%; }
.hud-id { display: flex; flex-direction: column; gap: .15rem; }
.hud-name { font-family: var(--f-title); font-weight: 700; font-size: 1.05rem; }
.hud-buttons { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.hud-btn { font-family: var(--f-ui); font-size: .85rem; font-weight: 600; background: rgba(245, 236, 215, .1); color: var(--parch); border: 1px solid rgba(245, 236, 215, .35); border-radius: 8px; padding: .4rem .7rem; display: inline-flex; gap: .35rem; align-items: center; }
.hud-btn:hover { background: rgba(245, 236, 215, .2); }
.quickjump { grid-column: 1 / -1; display: flex; gap: .35rem; flex-wrap: wrap; }
.quickjump button { font-family: var(--f-ui); font-size: .78rem; border: 0; border-radius: 999px; padding: .25rem .7rem; color: #fff; font-weight: 600; }

/* ---------- realm map ---------- */
.realm { position: relative; }
.map-scroll { overflow: auto; height: calc(100vh - 120px); min-height: 480px; cursor: grab; }
.map-scroll.dragging { cursor: grabbing; }
.map-scroll svg { display: block; }
.map-controls { position: absolute; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .4rem; z-index: 5; }
.map-controls button { width: 2.4rem; height: 2.4rem; font-size: 1.2rem; border-radius: 50%; border: 2px solid var(--ink); background: var(--parch); font-weight: 700; }
.castle-node { cursor: pointer; }
.castle-node:hover .castle-art, .castle-node:focus .castle-art { filter: drop-shadow(0 0 6px rgba(202, 138, 4, .9)); }
.castle-node:focus { outline: none; }
.castle-label { font-family: var(--f-title); font-weight: 700; font-size: 17px; fill: var(--ink); paint-order: stroke; stroke: var(--parch); stroke-width: 5px; }
.castle-sub { font-family: var(--f-ui); font-size: 11.5px; fill: var(--ink-soft); paint-order: stroke; stroke: var(--parch); stroke-width: 4px; }
.region-label { font-family: var(--f-title); font-size: 26px; font-weight: 900; opacity: .55; letter-spacing: .06em; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(28, 18, 6, .55); display: grid; place-items: center; z-index: 50; padding: 1rem; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--parch); border: 3px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow), inset 0 0 0 6px var(--parch-2);
  width: min(760px, 100%); max-height: calc(100vh - 2rem); overflow: auto; position: relative; animation: rise .18s ease-out;
}
.modal.wide { width: min(1200px, 100%); }
.modal.mid { width: min(960px, 100%); }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem .75rem; background: var(--parch); border-bottom: 2px dashed var(--parch-3); }
.modal-head h2 { margin: 0; flex: 1; font-size: 1.3rem; }
.modal-close { border: 2px solid var(--ink); background: #fffaf0; border-radius: 50%; width: 2.2rem; height: 2.2rem; font-weight: 700; font-size: 1.1rem; line-height: 1; }
.modal-body { padding: 1rem 1.25rem 1.25rem; }
.toast-root { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--parch); font-family: var(--f-ui); padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); animation: rise .2s ease-out; }

/* ---------- title / creation ---------- */
.title-screen { max-width: 1080px; margin: 0 auto; padding: 2rem 1rem 4rem; }
.title-banner { text-align: center; margin-bottom: 1.5rem; }
.title-banner h1 { font-size: clamp(2rem, 5vw, 3.4rem); color: var(--royal); margin: 0; text-shadow: 0 2px 0 var(--parch-3); }
.title-banner .sub { font-family: var(--f-title); font-size: 1.15rem; color: var(--crimson); }
.card { background: #fbf5e6; border: 2px solid var(--parch-3); border-radius: var(--radius); padding: 1rem; box-shadow: 0 2px 0 var(--parch-3); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.profile-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; }
.profile-card { display: flex; gap: .75rem; align-items: center; text-align: left; padding: .75rem; background: #fffaf0; border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: 0 2px 0 var(--ink); }
.profile-card .pc-av { width: 60px; height: 76px; flex: none; }
.creator { display: grid; grid-template-columns: 240px 1fr; gap: 1.25rem; align-items: start; }
.creator-preview { position: sticky; top: 1rem; background: #fffaf0; border: 2px solid var(--parch-3); border-radius: var(--radius); padding: .5rem; }
.field { display: flex; flex-direction: column; gap: .25rem; }
.field label, .field .lbl { font-family: var(--f-ui); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.field input, .field select { padding: .5rem .6rem; border: 2px solid var(--parch-3); background: #fffdf7; border-radius: 8px; }
.swatches { display: flex; gap: .35rem; flex-wrap: wrap; }
.swatch { width: 2rem; height: 2rem; border-radius: 50%; border: 2px solid var(--parch-3); }
.swatch[aria-pressed="true"], .chip[aria-pressed="true"] { border-color: var(--royal); box-shadow: 0 0 0 3px rgba(30, 58, 138, .35); }
.chip { font-family: var(--f-ui); font-size: .82rem; border: 2px solid var(--parch-3); background: #fffdf7; border-radius: 999px; padding: .3rem .7rem; }
.preset { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .4rem; width: 108px; background: #fffdf7; border: 2px solid var(--parch-3); border-radius: var(--radius); font-family: var(--f-ui); font-size: .72rem; text-align: center; line-height: 1.2; }
.preset svg { width: 56px; height: 70px; }

/* ---------- castle modal ---------- */
.castle-head { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.castle-crest { width: 56px; height: 56px; border-radius: 12px; display: grid; place-items: center; font-size: 1.8rem; color: #fff; flex: none; border: 3px solid var(--ink); }
.progress { height: .6rem; border-radius: 999px; background: var(--parch-2); overflow: hidden; border: 1px solid var(--parch-3); }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #eab308); }
.ring-title { font-family: var(--f-title); font-weight: 700; margin: 1rem 0 .4rem; display: flex; align-items: center; gap: .5rem; }
.battle-list { display: flex; flex-direction: column; gap: .4rem; }
.battle-row { display: grid; grid-template-columns: 2rem 1fr auto; gap: .6rem; align-items: center; padding: .5rem .6rem; background: #fffaf0; border: 2px solid var(--parch-3); border-radius: 8px; }
.battle-row.won { border-color: var(--gold); background: #fffbeb; }
.battle-row.locked { opacity: .6; }
.battle-row .num { font-family: var(--f-title); font-weight: 700; text-align: center; }
.battle-row .bname { font-weight: 600; }
.battle-row .covers { font-size: .85rem; color: var(--ink-soft); }
.siege-row { display: flex; gap: .75rem; align-items: center; justify-content: space-between; padding: .6rem .8rem; border: 2px dashed var(--ink); border-radius: 8px; background: repeating-linear-gradient(45deg, #fdf6e3, #fdf6e3 10px, #f8ecd0 10px, #f8ecd0 20px); }
.siege-row.fallen { border-style: solid; border-color: var(--gold); }

/* ---------- battle ---------- */
.streak { display: flex; align-items: center; gap: .4rem; font-size: 1.6rem; }
.streak .shield { filter: grayscale(1) opacity(.35); transition: filter .25s, transform .25s; }
.streak .shield.lit { filter: none; transform: scale(1.15); }
.streak .dash { color: var(--parch-3); font-weight: 700; }
.qcard { background: #fffdf7; border: 2px solid var(--parch-3); border-radius: var(--radius); padding: 1rem 1.1rem; font-size: 1.15rem; }
.qcard table.t2x2, .qcard table.data, .passage table.data { margin: .6rem 0; }
table.t2x2, table.data { border-collapse: collapse; font-family: var(--f-ui); font-size: .92rem; background: #fff; }
table.t2x2 th, table.t2x2 td, table.data th, table.data td { border: 1px solid var(--parch-3); padding: .3rem .7rem; text-align: center; }
table.t2x2 th, table.data th { background: var(--parch-2); }
table.data caption { caption-side: top; text-align: left; font-weight: 600; padding-bottom: .3rem; }
.options { display: flex; flex-direction: column; gap: .5rem; margin-top: .9rem; }
.opt {
  display: grid; grid-template-columns: 2rem 1fr auto; gap: .6rem; align-items: center; text-align: left; padding: .6rem .8rem;
  background: #fffaf0; border: 2px solid var(--parch-3); border-radius: 8px; font-size: 1.05rem; transition: border-color .12s, background .12s;
}
.opt:hover:not(:disabled) { border-color: var(--royal); }
.opt .key { font-family: var(--f-ui); font-weight: 700; width: 1.8rem; height: 1.8rem; display: grid; place-items: center; border-radius: 50%; background: var(--parch-2); font-size: .85rem; }
.opt.struck .otext { text-decoration: line-through; opacity: .45; }
.opt.selected { border-color: var(--royal); background: #eef2ff; }
.opt.correct { border-color: var(--forest); background: #ecfdf5; }
.opt.wrong { border-color: var(--crimson); background: #fff1f2; }
.opt .mark { font-weight: 700; font-family: var(--f-ui); }
.opt.correct .mark { color: var(--forest); }
.opt.wrong .mark { color: var(--crimson); }
.opt:disabled { cursor: default; }
.num-answer { display: flex; gap: .5rem; margin-top: .9rem; align-items: center; }
.num-answer input { width: 10rem; padding: .5rem; border: 2px solid var(--parch-3); border-radius: 8px; font-family: var(--f-ui); }
.verdict { margin-top: 1rem; padding: .8rem 1rem; border-radius: var(--radius); border: 2px solid; }
.verdict.good { border-color: var(--forest); background: #ecfdf5; }
.verdict.bad { border-color: var(--crimson); background: #fff1f2; }
.verdict h3 { display: flex; gap: .4rem; align-items: center; }
.verdict ol { margin: .4rem 0 0; padding-left: 1.3rem; }
.trap-note { margin-top: .5rem; padding: .5rem .7rem; border-left: 4px solid var(--crimson); background: #fff; font-size: .98rem; }
.hint-box { margin-top: .6rem; padding: .5rem .7rem; border-left: 4px solid var(--gold); background: #fffbeb; }
.tip { font-family: var(--f-ui); font-size: .78rem; color: var(--ink-soft); }

/* ---------- training yard ---------- */
.tabs { display: flex; gap: .3rem; border-bottom: 2px solid var(--parch-3); margin-bottom: 1rem; flex-wrap: wrap; }
.tab { font-family: var(--f-ui); font-weight: 600; font-size: .9rem; border: 2px solid transparent; border-bottom: 0; background: none; padding: .5rem .8rem; border-radius: 8px 8px 0 0; }
.tab[aria-selected="true"] { background: #fffaf0; border-color: var(--parch-3); margin-bottom: -2px; border-bottom: 2px solid #fffaf0; }
.scroll { background: #fffdf7; border: 3px double var(--ink); border-radius: 6px; padding: 1rem; }
.scroll-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; border-bottom: 2px solid var(--ink); padding-bottom: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.scroll .cry { font-size: 1.15rem; font-style: italic; padding: .5rem .75rem; background: var(--gold-soft); border-radius: 6px; margin-bottom: .75rem; }
.scroll-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.scroll-cell { border: 1px solid var(--parch-3); border-radius: 6px; padding: .6rem .75rem; background: #fff; }
.scroll-cell h4 { font-family: var(--f-title); margin: 0 0 .35rem; font-size: .95rem; }
.scroll-cell ul, .scroll-cell ol { margin: 0; padding-left: 1.2rem; }
.scroll-cell li + li { margin-top: .2rem; }
.quick-check { margin-top: .75rem; border: 1px dashed var(--ink); padding: .6rem .75rem; border-radius: 6px; }
.quick-check .upside { transform: rotate(180deg); display: inline-block; color: var(--ink-soft); font-size: .9rem; }
.links { display: flex; flex-direction: column; gap: .5rem; }
.links a { display: flex; flex-direction: column; padding: .6rem .8rem; background: #fffaf0; border: 2px solid var(--parch-3); border-radius: 8px; text-decoration: none; color: var(--ink); }
.links a:hover { border-color: var(--royal); }
.links a b { color: var(--royal); }

/* ---------- archery range ---------- */
.range-top { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; justify-content: space-between; margin-bottom: .75rem; }
.quiver { font-family: var(--f-ui); font-weight: 700; }
.valor { font-family: var(--f-title); font-weight: 900; font-size: 1.4rem; color: var(--gold); }
.candle { position: relative; height: .7rem; border-radius: 999px; background: var(--parch-2); overflow: hidden; border: 1px solid var(--parch-3); margin-bottom: .75rem; }
.candle > span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #f59e0b, #fde047); transition: width .25s linear; }
.candle > span::after { content: '🔥'; position: absolute; right: -.5rem; top: -.55rem; font-size: 1rem; }
.target-zone { display: grid; grid-template-columns: 90px 1fr; gap: 1rem; align-items: center; }
.target { width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(circle, #dc2626 0 16%, #fff 16% 32%, #dc2626 32% 48%, #fff 48% 64%, #1e3a8a 64% 100%); border: 3px solid var(--ink); position: relative; }
.target.hit::after { content: '➶'; position: absolute; left: 40%; top: 18%; font-size: 2.2rem; color: var(--ink); animation: thwack .25s ease-out; }
.target.miss { animation: shake .3s; }
@keyframes thwack { from { transform: translate(-40px, -30px); opacity: 0; } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.reason { margin-top: .6rem; font-family: var(--f-ui); font-size: .9rem; }
.ground-taken { margin-top: .6rem; padding: .5rem .7rem; background: #ecfdf5; border-left: 4px solid var(--forest); }
.charge-stem { padding: .6rem .8rem; background: #eef2ff; border-left: 4px solid var(--royal); border-radius: 4px; margin-bottom: .6rem; }
.results-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; text-align: center; }
.stat { background: #fffaf0; border: 2px solid var(--parch-3); border-radius: 8px; padding: .5rem; }
.stat b { display: block; font-family: var(--f-title); font-size: 1.5rem; }

/* ---------- siege ---------- */
.siege { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1rem; align-items: start; }
.passage { background: #fffdf7; border: 2px solid var(--parch-3); border-radius: var(--radius); padding: 1rem 1.2rem; max-height: calc(100vh - 12rem); overflow: auto; position: sticky; top: 4.5rem; line-height: 1.65; }
.passage p { margin: 0 0 .9rem; }
.passage mark { background: #fde047; padding: 0 .1em; }
.siege-qs { display: flex; flex-direction: column; gap: 1rem; }
.siege-q { background: #fffaf0; border: 2px solid var(--parch-3); border-radius: var(--radius); padding: .8rem; }
.siege-q .qnum { font-family: var(--f-ui); font-weight: 700; font-size: .8rem; color: var(--ink-soft); }
.siege-tools { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.show-passage { display: none; }

/* ---------- armory ---------- */
.armory { display: grid; grid-template-columns: 260px 1fr; gap: 1.25rem; }
.armory-figure { background: #fffaf0; border: 2px solid var(--parch-3); border-radius: var(--radius); padding: .5rem; text-align: center; }
.slot h4 { font-family: var(--f-title); margin: .6rem 0 .3rem; }
.items { display: flex; flex-wrap: wrap; gap: .35rem; }
.item { font-family: var(--f-ui); font-size: .8rem; border: 2px solid var(--parch-3); background: #fffdf7; border-radius: 8px; padding: .35rem .6rem; position: relative; }
.item[aria-pressed="true"] { border-color: var(--gold); background: #fffbeb; font-weight: 700; }
.item:disabled { opacity: .45; cursor: not-allowed; }
.item .new { position: absolute; top: -.5rem; right: -.4rem; background: var(--crimson); color: #fff; border-radius: 999px; font-size: .6rem; padding: 0 .3rem; }

/* ---------- spoils ---------- */
.spoils { text-align: center; }
.chest { font-size: 4.5rem; animation: bounce .6s ease-out; }
@keyframes bounce { 0% { transform: scale(.4) rotate(-10deg); } 60% { transform: scale(1.15) rotate(4deg); } }
.loot-card { display: inline-flex; gap: 1rem; align-items: center; background: #fffbeb; border: 2px solid var(--gold); border-radius: var(--radius); padding: .75rem 1rem; margin: .5rem; text-align: left; }
.banner-raised { font-family: var(--f-title); font-size: 1.4rem; color: var(--crimson); }

/* ---------- ledger ---------- */
.bars { display: flex; flex-direction: column; gap: .35rem; }
.bar-row { display: grid; grid-template-columns: 9rem 1fr 4.5rem; gap: .5rem; align-items: center; font-family: var(--f-ui); font-size: .85rem; }
.bar { height: .8rem; background: var(--parch-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--royal); }
.readiness { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.ready-card { border: 2px solid var(--parch-3); border-radius: var(--radius); background: #fffaf0; padding: .6rem; text-align: center; }
.ready-card b { display: block; font-family: var(--f-title); font-size: 1.6rem; }

/* ---------- reference ---------- */
.ptable { display: grid; grid-template-columns: repeat(18, minmax(0, 1fr)); gap: 2px; font-family: var(--f-ui); }
.el { background: #fffaf0; border: 1px solid var(--parch-3); border-radius: 3px; padding: 2px; text-align: center; line-height: 1.1; min-width: 0; }
.el .z { font-size: .55rem; color: var(--ink-soft); display: block; text-align: left; }
.el .s { font-weight: 700; font-size: .85rem; }
.el .m { font-size: .5rem; display: block; color: var(--ink-soft); }
.el.f { background: #f3e8ff; }
.ref-table { border-collapse: collapse; font-size: .95rem; }
.ref-table td { border-bottom: 1px solid var(--parch-3); padding: .3rem .6rem; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .siege { grid-template-columns: 1fr; }
  .passage { position: relative; top: 0; max-height: none; }
  .passage.collapsed { display: none; }
  .show-passage { display: inline-flex; position: sticky; top: 4rem; z-index: 3; }
  .creator, .armory { grid-template-columns: 1fr; }
  .creator-preview { position: relative; display: flex; justify-content: center; }
  .grid-2, .scroll-grid, .readiness, .results-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .grid-2, .scroll-grid, .readiness, .results-grid, .grid-3 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 6rem 1fr 3.5rem; }
  .hud { grid-template-columns: 1fr; }
  .hud-buttons { justify-content: flex-start; }
}

/* ---------- print (War Scroll) ---------- */
@media print {
  body { background: #fff; }
  body.printing-scroll > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  .scroll { border: 2px solid #000; page-break-inside: avoid; }
  .scroll .cry { background: #eee; }
  .no-print { display: none !important; }
}
#print-root { display: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
