/* Fabled Lands — classic-fantasy, mobile-first styling. */

:root {
  --leather: #2b1a0f;
  --leather-2: #3a2415;
  --parchment: #f4e8ce;
  --parchment-2: #efe0c0;
  --parchment-edge: #e3d2ab;
  --ink: #2f2415;
  --ink-soft: #5a4a34;
  --gold: #a8791f;
  --gold-bright: #c8962a;
  --crimson: #7a2318;
  --crimson-bright: #9a3b2a;
  --green: #3f6b3a;
  --shadow: rgba(30, 18, 8, 0.35);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sheet-w: 340px;
  --radius: 10px;

  /* Semantic reading-surface tokens. The header and sheet are always dark
     (leather); these are the *light* surfaces (story card, modals, inputs,
     inline panels) that the dark theme below re-skins. Keep component rules
     referencing these vars — never hard-code the hexes again — so a single
     override block flips the whole reading area. */
  --reading-bg-1: #f7ecd4;   /* story-pane gradient (top) */
  --reading-bg-2: #ecdcb8;   /* story-pane gradient (bottom) */
  --card: var(--parchment);  /* story card, modals, create/saves cards */
  --field: #fbf5e6;          /* inputs, choices, prof & save cards */
  --field-hover: #fff8ea;
  --field-sel: #fdf3d8;      /* selected prof card / prof detail */
  --panel: #f6ead0;          /* rolls, market, caches */
  --panel-2: #f3e3c4;        /* fight box */
  --btn-soft-1: #fbf1d9;     /* plain / mini / secondary button, tabs (top) */
  --btn-soft-2: #ecdcb6;     /* plain button (bottom) */
  --btn-soft-hover-1: #fff6e2;
  --btn-soft-hover-2: #f1e2bd;
  --die: #fffaf0;            /* dice face */
  --item-name: #5a3410;      /* item names highlighted in the prose */
}

/* ---- Dark theme ----------------------------------------------------------
   Applied via <html data-theme="dark"> (set before paint by the inline script
   in index.html, toggled from the game header / menu). The header, sheet, and
   title screen are leather in both themes; this block re-skins the light
   reading surfaces to a warm "leather at night" palette and lifts text, links,
   and accents to legible tones. */
:root[data-theme="dark"] {
  --parchment-edge: #55412c;   /* only ever a border/edge — safe to darken */
  --ink: #e9dcc2;              /* only ever text — safe to lighten */
  --ink-soft: #b3a488;
  --crimson: #e3856a;          /* headings / danger, legible on dark */
  --crimson-bright: #ef9c7f;   /* links */
  --gold: #c79a35;
  --gold-bright: #e2b854;
  --shadow: rgba(0, 0, 0, 0.55);

  --reading-bg-1: #241a11;
  --reading-bg-2: #1a1209;
  --card: #2c2016;
  --field: #362819;
  --field-hover: #423220;
  --field-sel: #4a3720;
  --panel: #302416;
  --panel-2: #37271b;
  --btn-soft-1: #3d2e1d;
  --btn-soft-2: #2f2315;
  --btn-soft-hover-1: #4a3826;
  --btn-soft-hover-2: #3a2c1c;
  --die: #40301f;
  --item-name: #e6b866;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--serif);
  color: var(--ink);
  background: var(--leather);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
  overflow-x: hidden; /* the off-canvas sheet drawer is parked off-screen right */
}
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }

#app { min-height: 100%; }

.fatal { color: var(--parchment); text-align: center; padding: 3rem 1.5rem; font-size: 1.1rem; }
.fatal small { opacity: 0.7; }

.inherit-style {
  color: inherit;
  text-decoration: inherit;
}

/* ---- Buttons -------------------------------------------------------------- */
.btn {
  appearance: none;
  border: 1px solid var(--gold);
  background: linear-gradient(var(--btn-soft-1), var(--btn-soft-2));
  color: var(--ink);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 2px 4px var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s;
}
.btn:hover:not(:disabled) { background: linear-gradient(var(--btn-soft-hover-1), var(--btn-soft-hover-2)); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 2px var(--shadow); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(var(--gold-bright), var(--gold)); color: #2a1c07; border-color: #6f4e13; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(#dba63a, #b6851f); }
.btn-danger { border-color: var(--crimson); color: var(--crimson); }
.btn-lg { font-size: 1.15rem; padding: 0.8rem 1.4rem; }
.btn-block { display: block; width: 100%; margin: 0.35rem 0; text-align: left; }

/* ---- Title screen --------------------------------------------------------- */
.screen-title {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh; padding: 2rem 1.25rem; text-align: center;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(200,150,42,0.18), transparent 60%),
    var(--leather);
}
.title-hero { margin-bottom: 2.2rem; }
.game-title {
  font-family: var(--display); color: var(--gold-bright);
  font-size: clamp(2.8rem, 12vw, 5rem); margin: 0; letter-spacing: 0.04em;
  text-shadow: 0 2px 0 #1a0f06, 0 0 24px rgba(200,150,42,0.35);
}
.game-tagline { color: #d8c49a; font-style: italic; font-size: clamp(1rem, 3.5vw, 1.2rem); margin: 0.6rem auto 0; max-width: 32ch; }
.title-menu { display: flex; flex-direction: column; gap: 0.7rem; width: min(360px, 90vw); }
.title-credits { margin-top: 2.2rem; color: #b39c76; font-size: 0.8rem; line-height: 1.5; max-width: 46ch; }
.credits-licence { margin: 0.9rem 0 0; font-style: italic; }
.title-note { margin-top: 0.9rem; }

/* ---- Create & Saves ------------------------------------------------------- */
.screen-create, .screen-saves { min-height: 100vh; min-height: 100dvh; padding: 1.5rem 1rem 3rem; }
.create-wrap { max-width: 760px; margin: 0 auto; background: var(--card); border-radius: 14px; padding: 1.5rem 1.4rem 2rem; box-shadow: 0 10px 40px rgba(0,0,0,0.4); border: 1px solid var(--parchment-edge); }
.create-title { font-family: var(--display); color: var(--crimson); text-align: center; margin: 0.2rem 0 1.4rem; font-size: clamp(1.6rem, 6vw, 2.2rem); }
.field { margin-bottom: 1rem; }
.field label, .field-label { display: block; font-weight: 700; color: var(--ink-soft); margin-bottom: 0.35rem; font-size: 0.95rem; }
.field-label { margin-top: 0.6rem; }
.input, .select {
  width: 100%; padding: 0.6rem 0.7rem; font-size: 1rem; font-family: inherit;
  border: 1px solid var(--parchment-edge); border-radius: 8px; background: var(--field); color: var(--ink);
}
.prof-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.7rem; }
.prof-card { text-align: left; border: 2px solid var(--parchment-edge); background: var(--field); border-radius: 10px; padding: 0.7rem; transition: border-color 0.12s, background 0.12s; }
.prof-card:hover { background: var(--field-hover); }
.prof-card.selected { border-color: var(--gold-bright); background: var(--field-sel); box-shadow: 0 0 0 2px rgba(200,150,42,0.25); }
.prof-name { font-family: var(--display); font-size: 1.15rem; color: var(--crimson); margin-bottom: 0.4rem; }
.prof-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.2rem 0.6rem; }
.prof-stat { font-size: 0.8rem; color: var(--ink-soft); }
.prof-stat i { display: inline-block; width: 4.8em; font-style: normal; opacity: 0.7; }
.prof-info { grid-column: 1 / -1; text-align: center; color: var(--ink-soft); font-style: italic; margin-top: 0.4rem; }
.prof-detail { margin-top: 1rem; padding: 0.9rem 1.1rem; border: 1px solid var(--parchment-edge); border-left: 4px solid var(--gold-bright); border-radius: 8px; background: var(--field-sel); }
.prof-detail[hidden] { display: none; }
.prof-detail-name { font-family: var(--display); font-size: 1.25rem; color: var(--crimson); margin-bottom: 0.35rem; }
.prof-detail-bio { margin: 0 0 0.5rem; line-height: 1.5; }
.prof-detail-hint { margin: 0; font-size: 0.85rem; font-style: italic; color: var(--ink-soft); }
.create-actions { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.6rem; }

.save-list { display: flex; flex-direction: column; gap: 0.8rem; margin: 0.5rem 0 1.5rem; }
.save-card { display: flex; justify-content: space-between; align-items: center; gap: 1rem; background: var(--field); border: 1px solid var(--parchment-edge); border-radius: 10px; padding: 0.8rem 1rem; }
.save-name { font-family: var(--display); font-size: 1.2rem; color: var(--crimson); }
.save-sub { color: var(--ink-soft); font-size: 0.9rem; }
.save-date { color: #9c885f; font-size: 0.78rem; margin-top: 0.15rem; }
.save-btns { display: flex; gap: 0.5rem; flex-shrink: 0; }
.empty { color: var(--ink-soft); font-style: italic; text-align: center; padding: 1rem; }

/* ---- Game layout ---------------------------------------------------------- */
.screen-game { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.game-header {
  display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0;
  background: linear-gradient(var(--leather-2), var(--leather));
  color: var(--parchment); padding: calc(env(safe-area-inset-top) + 0.5rem) 0.75rem 0.5rem;
  border-bottom: 2px solid var(--gold); box-shadow: 0 2px 8px rgba(0,0,0,0.4); z-index: 20;
}
.header-title { flex: 1; text-align: center; font-family: var(--display); color: var(--gold-bright); font-size: 1.2rem; letter-spacing: 0.03em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 0.3rem; }
.icon-btn { flex: none; background: rgba(255,255,255,0.06); border: 1px solid rgba(200,150,42,0.4); color: var(--gold-bright); font-size: 1.25rem; width: 2.5rem; height: 2.5rem; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: rgba(200,150,42,0.18); }
.icon-btn.active { background: rgba(200,150,42,0.3); border-color: var(--gold-bright); }
.icon-btn.speed-btn { width: auto; min-width: 2.5rem; padding: 0 0.45rem; font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* narration (text-to-speech) */
.tts-s { border-radius: 4px; transition: background 0.2s; }
.tts-active { background: rgba(200,150,42,0.35); box-shadow: 0 0 0 2px rgba(200,150,42,0.35); }
.tts-settings { display: flex; flex-direction: column; gap: 0.9rem; }
.tts-row { display: flex; align-items: center; gap: 0.6rem; }
.tts-row > label:first-child { min-width: 4rem; font-weight: 700; color: var(--ink-soft); }
.tts-row .select { flex: 1; }
.tts-row input[type="range"] { flex: 1; accent-color: var(--gold); }
.tts-rate { min-width: 3rem; text-align: right; color: var(--ink-soft); }

.game-main { flex: 1; display: flex; min-height: 0; position: relative; }
.story-pane { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 1.2rem; background:
  radial-gradient(140% 120% at 50% 0%, var(--reading-bg-1), var(--reading-bg-2));
}
.story {
  max-width: 44rem; margin: 0 auto;
  background: var(--card); border-radius: 12px; padding: 1.4rem 1.5rem 2rem;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18); border: 1px solid var(--parchment-edge);
}

/* ---- Story content -------------------------------------------------------- */
.section-num { text-align: center; font-variant: small-caps; letter-spacing: 0.08em; color: var(--gold); font-size: 0.85rem; border-bottom: 1px solid var(--parchment-edge); padding-bottom: 0.6rem; margin-bottom: 1rem; }
.section-boxes { text-align: center; font-size: 1.25rem; letter-spacing: 0.25rem; color: var(--gold); margin: -0.4rem 0 0.8rem; }
.section-boxes .tick-box.ticked { color: var(--crimson); }
.take-item, .pay-action { font-style: normal; }
.flow { font-size: 1.12rem; line-height: 1.72; }
.flow p { margin: 0 0 1rem; }
.flow .item-name { font-weight: 700; color: var(--item-name); }
.flow .caps { font-variant: small-caps; letter-spacing: 0.03em; font-weight: 600; }
.flow .fx { }
.flow .fx.paid { color: var(--crimson); font-style: italic; opacity: 0.85; }
/* An untaken conditional branch: shown for context (like the printed book / JaFL)
   but greyed and non-interactive. Its buttons are also disabled in JS. */
.flow .cond-inactive, .flow .cond-inactive * { color: #9a9186 !important; }
.flow .cond-inactive button { pointer-events: none; background: transparent; border-color: #cfc7ba; box-shadow: none; cursor: default; text-decoration: underline; }
/* A navigation link gated behind an unresolved/lost fight (see applyFightGate). */
.flow .goto.gated, .flow .choice.gated { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.illus { margin: 0 0 1.2rem; text-align: center; }
.illus img { max-width: 100%; height: auto; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,0.25); }
.illus figcaption { margin-top: 0.4rem; font-size: 0.85em; font-style: italic; opacity: 0.75; }

/* inline <image>text</image> — a link that opens the illustration in a modal */
.image-link {
  display: inline; border: none; background: none; color: var(--crimson-bright); font: inherit;
  font-weight: 600; text-decoration: underline dotted; text-decoration-color: rgba(154,59,42,0.5);
  text-underline-offset: 2px; padding: 0; cursor: pointer;
}

/* goto links */
.goto {
  display: inline; border: none; background: none; color: var(--crimson-bright); font: inherit;
  font-weight: 700; text-decoration: underline; text-decoration-color: rgba(154,59,42,0.4);
  text-underline-offset: 2px; padding: 0 0.1em; cursor: pointer;
}
.goto:hover:not(:disabled) { color: var(--crimson); text-decoration-color: var(--crimson); }
.goto:disabled { color: #9c885f; text-decoration: none; cursor: not-allowed; }
.goto-primary {
  display: inline-block; margin-top: 0.5rem; text-decoration: none; color: #2a1c07;
  background: linear-gradient(var(--gold-bright), var(--gold)); border: 1px solid #6f4e13;
  padding: 0.5rem 1rem; border-radius: 8px; box-shadow: 0 2px 4px var(--shadow);
}
.goto-primary:hover:not(:disabled) { background: linear-gradient(#dba63a, #b6851f); }

/* <field>: a live codeword-counter readout (bribery/offering bonus, court status) */
.field { display: inline-block; margin: 0 0.2rem; padding: 0.05rem 0.45rem; border: 1px dashed var(--gold); border-radius: 6px; font-size: 0.85rem; font-weight: 700; font-style: normal; color: var(--gold); }

/* <extrachoice>: persistent "noted on your Adventure Sheet" options, surfaced at
   their target section as a small labelled block of navigation buttons (task 32) */
.extra-choices { margin-top: 1rem; padding-top: 0.6rem; border-top: 1px dashed rgba(154,59,42,0.35); }
.extra-choices-label { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold); margin-bottom: 0.3rem; }
.extra-choice { display: block; margin: 0.25rem 0; }

/* choices */
.choices { display: flex; flex-direction: column; gap: 0.55rem; margin: 1.1rem 0 0.4rem; }
.choice {
  display: flex; align-items: center; gap: 0.6rem; text-align: left; width: 100%;
  background: var(--field); border: 1px solid var(--parchment-edge); border-left: 4px solid var(--gold);
  border-radius: 8px; padding: 0.7rem 0.9rem; font-size: 1.02rem; color: var(--ink);
  box-shadow: 0 1px 3px var(--shadow); transition: background 0.12s, transform 0.06s;
}
.choice:hover:not(.disabled) { background: var(--field-hover); }
.choice:active:not(.disabled) { transform: translateY(1px); }
.choice.disabled { opacity: 0.55; cursor: not-allowed; border-left-color: #b3a17a; }
.choice-label { flex: 1; }
.choice-cost { font-size: 0.82rem; font-weight: 700; color: var(--gold); background: rgba(168,121,31,0.12); padding: 0.1rem 0.45rem; border-radius: 20px; white-space: nowrap; }
.choice-box { font-size: 1.1rem; color: var(--gold); }
.choice-box.ticked { color: var(--green); }

/* branches */
.branch { display: block; margin: 0.3rem 0; }

/* group: an optional click-to-apply action embedded in the prose */
.group-action {
  display: inline; border: none; background: none; font: inherit; cursor: pointer;
  color: var(--crimson-bright); font-weight: 700; text-decoration: underline;
  text-decoration-color: rgba(154, 59, 42, 0.4); text-underline-offset: 2px; padding: 0 0.1em;
}
.group-action:hover:not(:disabled) { color: var(--crimson); text-decoration-color: var(--crimson); }
.group-action.done { color: var(--green); text-decoration: none; cursor: default; font-weight: 600; }

/* rolls */
.roll { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 0.6rem 0 0.9rem; padding: 0.6rem 0.8rem; background: var(--panel); border: 1px dashed var(--gold); border-radius: 10px; }
.btn-roll {
  border: 1px solid #6f4e13; background: linear-gradient(var(--gold-bright), var(--gold));
  color: #2a1c07; font-weight: 700; padding: 0.5rem 1rem; border-radius: 8px; box-shadow: 0 2px 4px var(--shadow);
}
.btn-roll:hover:not(:disabled) { background: linear-gradient(#dba63a, #b6851f); }
.btn-roll:disabled { opacity: 0.6; }
.btn-secondary { border: 1px solid var(--gold); background: var(--btn-soft-1); color: var(--ink); padding: 0.45rem 0.9rem; border-radius: 8px; font-weight: 600; }
.dice-row, .dice-anim { display: inline-flex; gap: 0.4rem; }
.die {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; background: var(--die); border: 2px solid var(--ink-soft);
  border-radius: 6px; font-weight: 800; font-size: 1.1rem; color: var(--ink); box-shadow: inset 0 -2px 0 rgba(0,0,0,0.1);
}
.die.rolling { animation: shake 0.15s infinite; color: var(--crimson); }
.dice-anim.small .die { width: 1.6rem; height: 1.6rem; font-size: 0.9rem; }
@keyframes shake { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-3px) rotate(4deg); } }
.roll-detail { font-size: 0.92rem; color: var(--ink-soft); }
.roll-outcome { font-weight: 800; padding: 0.15rem 0.6rem; border-radius: 20px; font-size: 0.9rem; }
.roll-outcome.ok { background: rgba(63,107,58,0.16); color: var(--green); }
.roll-outcome.bad { background: rgba(154,59,42,0.16); color: var(--crimson-bright); }

/* fight */
.fight { margin: 0.9rem 0; padding: 0.9rem 1rem; background: var(--panel-2); border: 2px solid var(--crimson); border-radius: 12px; }
.fight-title { font-family: var(--display); font-size: 1.25rem; color: var(--crimson); margin-bottom: 0.4rem; }
.fight-stats { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 0.9rem; color: var(--ink-soft); margin-bottom: 0.2rem; }
.fight-stats.you { color: #4a5a3a; border-top: 1px dashed var(--parchment-edge); padding-top: 0.3rem; margin-top: 0.3rem; }
.fight-stats .en-stam { font-weight: 700; color: var(--crimson-bright); }
.fight-stats.defeated { opacity: 0.5; text-decoration: line-through; }
.fight-log { font-size: 0.86rem; color: var(--ink-soft); margin: 0.5rem 0; max-height: 8rem; overflow-y: auto; }
.fight-log div { padding: 0.1rem 0; border-bottom: 1px dotted rgba(90,74,52,0.2); }
.fight-controls { display: flex; gap: 0.6rem; margin-top: 0.5rem; align-items: center; }

/* market */
.market { margin: 0.9rem 0; background: var(--panel); border: 1px solid var(--gold); border-radius: 10px; overflow: hidden; }
.market-head { background: linear-gradient(var(--leather-2), var(--leather)); color: var(--gold-bright); font-family: var(--display); padding: 0.5rem 0.9rem; font-size: 1.05rem; }
.trade { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; padding: 0.5rem 0.9rem; border-bottom: 1px solid rgba(168,121,31,0.2); }
.trade:last-child { border-bottom: none; }
.trade-name { font-weight: 600; }
.trade-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.btn-mini { border: 1px solid var(--gold); background: var(--btn-soft-1); color: var(--ink); padding: 0.3rem 0.6rem; border-radius: 6px; font-size: 0.85rem; font-weight: 700; }
.btn-mini:disabled { opacity: 0.45; cursor: not-allowed; }
.reward-pick { margin: 0 0.15rem; padding: 0.15rem 0.5rem; font-size: 0.8rem; font-style: normal; vertical-align: baseline; }
.items-pick-status { display: inline-block; margin: 0 0.35rem 0 0; padding: 0.1rem 0.5rem; border: 1px dashed var(--gold); border-radius: 6px; font-size: 0.8rem; font-weight: 700; font-style: normal; color: var(--gold); }
.ability-choice { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.2rem 0; vertical-align: middle; }
.ability-pick { cursor: pointer; }
.trade-na { font-size: 0.8rem; color: #9c885f; font-style: italic; }

/* caches: banks / investment boxes / villa strongrooms */
.cache { margin: 0.9rem 0; padding: 0.7rem 0.9rem; background: var(--panel); border: 1px solid var(--gold); border-radius: 10px; }
.cache-label { font-family: var(--display); color: var(--crimson); font-size: 1.02rem; }
.cache-balance { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; margin-bottom: 0.5rem; }
.cache-sum { font-weight: 800; color: var(--ink); }
.cache-controls { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.cache-amount { width: 6rem; padding: 0.3rem 0.5rem; border: 1px solid var(--gold); border-radius: 6px; background: var(--btn-soft-1); color: var(--ink); font-size: 0.9rem; }
.cache-list { display: flex; flex-direction: column; gap: 0.3rem; margin: 0.4rem 0; }
.cache-item { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; }
.cache-empty { color: #9c885f; font-style: italic; font-size: 0.88rem; }
.cache-deposit { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; border-top: 1px dashed var(--parchment-edge); padding-top: 0.5rem; }

.book-table { border-collapse: collapse; margin: 0.6rem auto; width: auto; max-width: 100%; }
.book-table td, .book-table th { border: 1px solid var(--parchment-edge); padding: 0.35rem 0.7rem; text-align: left; }
.book-table th, .book-table h1, .book-table h2, .book-table h3 { font-family: var(--display); color: var(--crimson); }

/* ---- Adventure Sheet ------------------------------------------------------ */
.sheet-pane {
  width: var(--sheet-w); flex-shrink: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: linear-gradient(var(--leather-2), var(--leather)); color: var(--parchment);
  padding: 1rem 1rem 3rem; border-left: 2px solid var(--gold);
}
.sheet-head { text-align: center; border-bottom: 1px solid rgba(200,150,42,0.35); padding-bottom: 0.7rem; margin-bottom: 0.8rem; }
.sheet-name { font-family: var(--display); font-size: 1.4rem; color: var(--gold-bright); }
.sheet-sub { font-size: 0.85rem; color: #d8c49a; }
.stat-block { margin-bottom: 0.9rem; }
.stat-label { font-variant: small-caps; letter-spacing: 0.06em; color: #d8c49a; font-size: 0.82rem; margin-bottom: 0.25rem; }
.stamina-bar { position: relative; height: 1.5rem; background: rgba(0,0,0,0.35); border-radius: 20px; overflow: hidden; border: 1px solid rgba(200,150,42,0.4); }
.stamina-fill { height: 100%; background: linear-gradient(90deg, #6f9a4a, #4a7a3a); transition: width 0.4s ease; }
.stamina-fill.low { background: linear-gradient(90deg, #c85a3a, #9a3b2a); }
.stamina-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.7); }
.abilities { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.4rem; margin-bottom: 0.9rem; }
.ability { display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.05); border: 1px solid rgba(200,150,42,0.25); border-radius: 8px; padding: 0.35rem 0.6rem; }
.ability-name { font-size: 0.88rem; color: #e8d8b4; }
.ability-val { font-family: var(--display); font-size: 1.3rem; font-weight: 700; color: var(--gold-bright); }
.ability-val.boosted { color: #8fd07a; }
.sheet-line { display: flex; gap: 0.6rem; margin-bottom: 0.6rem; }
.kv { flex: 1; background: rgba(255,255,255,0.05); border: 1px solid rgba(200,150,42,0.25); border-radius: 8px; padding: 0.4rem 0.6rem; display: flex; justify-content: space-between; align-items: center; }
.kv-k { font-size: 0.85rem; color: #d8c49a; }
.kv-v { font-family: var(--display); font-size: 1.2rem; font-weight: 700; color: var(--gold-bright); }
.sheet-section-title { font-variant: small-caps; letter-spacing: 0.06em; color: var(--gold-bright); border-bottom: 1px solid rgba(200,150,42,0.3); margin: 0.9rem 0 0.4rem; padding-bottom: 0.2rem; font-size: 0.9rem; }
.item-list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.28rem 0; border-bottom: 1px dotted rgba(200,150,42,0.2); font-size: 0.92rem; }
.item-txt.wielded::after { content: ' ⚔'; color: var(--gold-bright); }
.item-txt.worn::after { content: ' 🛡'; }
.item-txt { flex: 1 1 auto; min-width: 0; }
.item-use { flex: none; background: rgba(200,150,42,0.16); border: 1px solid rgba(200,150,42,0.4); color: #ecdcb8; border-radius: 4px; font-size: 0.74rem; padding: 0.08rem 0.42rem; cursor: pointer; }
.item-use:hover { background: rgba(200,150,42,0.3); }
.item-drop { background: none; border: none; color: #c9704f; font-size: 0.9rem; opacity: 0.6; padding: 0 0.2rem; }
.item-drop:hover { opacity: 1; }
.item-controls { display: inline-flex; align-items: center; gap: 0.1rem; flex: none; }
.item-move { background: none; border: none; color: var(--gold-bright, #c8962a); font-size: 0.66rem; line-height: 1; opacity: 0.55; padding: 0 0.12rem; cursor: pointer; }
.item-move:hover:not(:disabled) { opacity: 1; }
.item-move:disabled { opacity: 0.12; cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip { background: rgba(200,150,42,0.14); border: 1px solid rgba(200,150,42,0.35); color: #ecdcb8; border-radius: 20px; padding: 0.15rem 0.6rem; font-size: 0.8rem; }

/* ---- Sheet drawer (mobile) ------------------------------------------------ */
.sheet-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 25; }
@media (max-width: 899px) {
  .sheet-pane {
    position: fixed; top: 0; right: 0; height: 100%; width: min(340px, 88vw);
    transform: translateX(100%); transition: transform 0.28s ease; z-index: 30;
    box-shadow: -6px 0 24px rgba(0,0,0,0.5); padding-top: calc(env(safe-area-inset-top) + 1rem);
  }
  body.sheet-open .sheet-pane { transform: translateX(0); }
  body.sheet-open .sheet-backdrop { display: block; }
}
@media (min-width: 900px) {
  .icon-btn.sheet-toggle { display: none; }
}
/* Narrow screens: make room for the action icons by dropping the decorative title. */
@media (max-width: 600px) {
  .game-header { gap: 0.25rem; padding-left: 0.4rem; padding-right: 0.4rem; }
  .header-title { display: none; }
  .header-actions { gap: 0.15rem; }
  .icon-btn { width: 2.2rem; height: 2.2rem; font-size: 1.1rem; }
  /* Stack the save card so its Play / Export / Delete buttons wrap below the
     info and share the row instead of overflowing a narrow screen. */
  .save-card { flex-direction: column; align-items: stretch; gap: 0.6rem; }
  .save-btns { width: 100%; }
  .save-btns .btn { flex: 1; min-width: 0; padding-left: 0.4rem; padding-right: 0.4rem; text-align: center; }
}

/* ---- Modal ---------------------------------------------------------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,12,4,0.62); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal { background: var(--card); border-radius: 14px; border: 1px solid var(--parchment-edge); max-width: 640px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 1.3rem 1.4rem; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.modal h2 { font-family: var(--display); color: var(--crimson); margin: 0 0 0.8rem; }
.modal-body { line-height: 1.6; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.2rem; flex-wrap: wrap; }
.menu-list { display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 0.7rem; text-align: left; }
.menu-icon { width: 1.6rem; text-align: center; font-size: 1.15rem; flex: none; }
.menu-credits { text-align: center; color: var(--ink-soft); font-size: 0.8rem; line-height: 1.5; margin-top: 1.3rem; padding-top: 1rem; border-top: 1px solid var(--parchment-edge); }
.menu-version { text-align: center; margin-top: 0.9rem; color: #9c885f; font-size: 0.8rem; font-variant: small-caps; letter-spacing: 0.05em; }
.title-version { margin-top: 0.6rem; color: #8a744f; font-size: 0.75rem; letter-spacing: 0.05em; }
.static-doc { font-size: 1rem; line-height: 1.65; }
.static-doc h1, .static-doc h2, .static-doc h3, .static-doc h4 { font-family: var(--display); color: var(--crimson); }
.map-box { text-align: center; }
.world-map { border-radius: 8px; }
.maps-box { display: flex; flex-direction: column; gap: 0.7rem; }
.map-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.map-tab { border: 1px solid var(--gold); background: var(--btn-soft-1); color: var(--ink); padding: 0.35rem 0.7rem; border-radius: 20px; font-size: 0.85rem; font-weight: 600; }
.map-tab.active { background: linear-gradient(var(--gold-bright), var(--gold)); color: #2a1c07; border-color: #6f4e13; }
.map-view { text-align: center; }
.map-img { border-radius: 8px; max-height: 62vh; box-shadow: 0 4px 14px rgba(0,0,0,0.25); }
.map-note { margin-top: 0.5rem; font-variant: small-caps; letter-spacing: 0.04em; color: var(--ink-soft); }
.map-note.missing { font-variant: normal; letter-spacing: 0; color: #9c885f; font-style: italic; white-space: pre-line; }

/* ---- Toasts --------------------------------------------------------------- */
.toast-host { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 0.5rem; align-items: center; pointer-events: none; }
.toast { background: var(--leather-2); color: var(--parchment); border: 1px solid var(--gold); border-radius: 20px; padding: 0.5rem 1rem; font-size: 0.92rem; box-shadow: 0 4px 16px rgba(0,0,0,0.4); opacity: 0; transform: translateY(10px); transition: opacity 0.25s, transform 0.25s; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.warn { border-color: var(--crimson-bright); color: #f5d3c7; }

@media (min-width: 900px) {
  .story-pane { padding: 2rem; }
  .story { max-width: none; padding: 2rem 2.6rem 2.6rem; } /* fill the available page width */
  .flow { font-size: 1.15rem; }
}
