/* Adventure: a cheerful storybook table. Chunky outlines, sticker shadows, per-world title fonts.
   Light = sunny day, dark = night under the stars. */

:root {
  --sky: #a5dfd6;
  --sand: #fbe7c0;
  --dots: rgba(46, 33, 24, 0.09);
  --page: #fffaf0;
  --page-2: #fdf0d6;
  --card: #ffffff;
  --line: #2e2118;
  --drop: #2e2118;
  --soft: #ecd9b4;
  --ink: #2e2118;
  --ink-soft: #6a5642;
  --ink-faint: #9b8568;

  --accent: #e0673a;
  --accent-2: #137a86;
  --accent-ink: color-mix(in oklab, var(--accent) 88%, black);
  --on-accent: #fff;

  --good: #2f9e44;
  --bad: #e03131;
  --gold: #f2b705;
  --xp: #7950f2;
  --luck: #37b24d;
  --heart: #f03e3e;

  --f-display: "Baloo 2", system-ui, sans-serif;
  --f-ui: "Baloo 2", "Segoe UI", system-ui, sans-serif;
  --f-body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --f-hand: "Caveat", "Comic Sans MS", cursive;

  --r: 18px;
  --pop: 4px 5px 0 var(--drop);
  --pop-sm: 2px 3px 0 var(--drop);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky: #1d2748;
    --sand: #0e1326;
    --dots: rgba(255, 244, 214, 0.14);
    --page: #232a40;
    --page-2: #2b3450;
    --card: #2f3957;
    --line: #0a0d18;
    --drop: rgba(0, 0, 0, 0.75);
    --soft: #3e4a6d;
    --ink: #f6eedd;
    --ink-soft: #cbc1ad;
    --ink-faint: #9690a0;
    --accent-ink: color-mix(in oklab, var(--accent) 65%, white);
    --good: #69db7c;
    --bad: #ff8787;
    --xp: #b197fc;
    --luck: #8ce99a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --sky: #1d2748;
  --sand: #0e1326;
  --dots: rgba(255, 244, 214, 0.14);
  --page: #232a40;
  --page-2: #2b3450;
  --card: #2f3957;
  --line: #0a0d18;
  --drop: rgba(0, 0, 0, 0.75);
  --soft: #3e4a6d;
  --ink: #f6eedd;
  --ink-soft: #cbc1ad;
  --ink-faint: #9690a0;
  --accent-ink: color-mix(in oklab, var(--accent) 65%, white);
  --good: #69db7c;
  --bad: #ff8787;
  --xp: #b197fc;
  --luck: #8ce99a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(var(--dots) 1.6px, transparent 1.8px) 0 0 / 24px 24px,
    linear-gradient(180deg, var(--sky), var(--sand) 75%);
  background-color: var(--sand);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
svg { display: block; }

/* -- buttons ------------------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45em;
  border: 2.5px solid var(--line); border-radius: 14px;
  padding: 0.5em 1.1em; cursor: pointer; background: var(--card); color: var(--ink);
  font-family: var(--f-ui); font-weight: 600; font-size: 1rem; letter-spacing: 0.01em;
  box-shadow: var(--pop-sm);
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.btn svg { width: 1.2em; height: 1.2em; }
.btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 3px 4px 0 var(--drop); }
.btn:active:not(:disabled) { transform: translate(2px, 3px); box-shadow: 0 0 0 var(--drop); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { padding: 0.3em 0.8em; font-size: 0.9rem; border-radius: 11px; }
.btn.big { padding: 0.65em 1.4em; font-size: 1.12rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  border: 0; background: transparent; cursor: pointer; color: inherit;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: color-mix(in oklab, currentColor 12%, transparent); }

/* -- app frame ------------------------------------------------------------------------------- */
.app { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; }
/* a phone: the page is as tall as what's visible, so the on-screen keyboard pushes the input up instead of covering it
   (--vvh is window.visualViewport's height, set by app.js; 100dvh where it isn't set) */
@media (pointer: coarse) { .app { height: var(--vvh, 100dvh); } }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 18px 8px;
  min-height: 64px;
}
.brand { min-width: 0; }
.brand-title { font-family: var(--f-display); font-size: 1.55rem; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.brand-sub { font-family: var(--f-ui); font-weight: 500; font-size: 0.85rem; color: var(--ink-soft); }
.scene-line { flex: 1; min-width: 0; display: flex; justify-content: center; gap: 8px; align-items: center; white-space: nowrap; overflow: hidden; }
.scene-line > span { padding: 4px 12px; border-radius: 999px; border: 2px solid var(--line); background: var(--card); font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; }
.scene-line .sl-chapter { background: var(--accent-2); color: #fff; }
.scene-line .sl-when { color: var(--ink-soft); font-weight: 500; }
.top-actions { display: flex; gap: 6px; margin-left: auto; }
.top-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; position: relative;
  padding: 7px 12px; border-radius: 13px; border: 2.5px solid var(--line); background: var(--card); color: var(--ink);
  font-family: var(--f-ui); font-weight: 600; font-size: 0.95rem; box-shadow: var(--pop-sm);
  transition: transform 0.08s, box-shadow 0.08s;
}
.top-btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 4px 0 var(--drop); }
.top-btn:active { transform: translate(2px, 3px); box-shadow: none; }
.top-btn.on { background: var(--accent); color: var(--on-accent); }
.top-btn .ico svg { width: 20px; height: 20px; }
.top-btn.drawing .ico { animation: hop 1.2s ease-in-out infinite; }
/* the Map tab: the newest map big, its placeholder while it's made, the older ones below */
.map-tab { display: grid; gap: 14px; }
.map-main { margin: 0; display: grid; gap: 6px; padding: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.map-main figcaption { text-align: center; font-family: var(--f-display); color: var(--ink); }
.map-art { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--card); cursor: zoom-in; overflow: hidden; }
.map-art img, .map-art svg { display: block; width: 100%; height: auto; }
.map-wait { cursor: default; aspect-ratio: 3 / 2; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--ink-soft); }
.map-wait .brush { display: flex; gap: 8px; }
.map-wait .brush i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: hop 1s ease-in-out infinite; }
.map-wait .brush i:nth-child(2) { animation-delay: .15s; background: var(--accent-2); }
.map-wait .brush i:nth-child(3) { animation-delay: .3s; }
.map-older { margin: 4px 0 0; font-size: 1rem; }
.top-btn.ping::after { content: ""; position: absolute; top: -5px; right: -5px; width: 13px; height: 13px; border-radius: 50%; background: var(--gold); border: 2px solid var(--line); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.35); } }
@media (max-width: 1000px) { .top-btn .lbl { display: none; } .scene-line { display: none; } }
/* a phone: one button opens the side panel (its tabs lead to the rest), so the adventure's title has room */
@media (max-width: 560px) { .top-btn[data-open]:not([data-open="hero"]) { display: none !important; } }
/* no fullscreen on this browser (iPhone Safari): no button for it */
:root.no-fs .fs-btn { display: none !important; }

.main { display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 0; }
.stage { overflow-y: auto; min-height: 0; padding: 14px 16px 0; }
.book { width: min(100%, 760px); margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

/* -- the story page ------------------------------------------------------------------------ */
.page {
  position: relative; flex: 1 0 auto;
  background: var(--page); color: var(--ink);
  border: 3px solid var(--line); border-radius: var(--r) var(--r) 0 0; border-bottom: 0;
  padding: 40px clamp(18px, 6vw, 64px) 32px;
  box-shadow: 6px 0 0 var(--drop);
}
.title-page { text-align: center; margin-bottom: 1.8rem; }
.tp-title { font-family: var(--f-display); font-weight: 400; font-size: clamp(2.1rem, 5.5vw, 3.2rem); line-height: 1.05; margin: 0 0 0.15em; color: var(--accent-ink); text-wrap: balance; text-shadow: 2px 2px 0 color-mix(in oklab, var(--accent) 22%, transparent); }
.tp-sub { font-weight: 600; font-size: 1rem; color: var(--ink-soft); }
.tp-orn { display: flex; gap: 8px; justify-content: center; margin-top: 0.8rem; color: var(--gold); }
.tp-orn span svg { width: 18px; height: 18px; }
.tp-orn span:nth-child(2) svg { width: 24px; height: 24px; margin-top: -3px; }

.prose p { font-family: var(--f-body); font-size: 1.14rem; line-height: 1.7; margin: 0 0 0.9em; text-wrap: pretty; }
.prose em { font-style: italic; }
.prose strong { font-weight: 800; }
.prose blockquote { margin: 1em 0; padding: 0.5em 1em; border-left: 4px solid var(--accent-2); background: var(--page-2); border-radius: 0 12px 12px 0; font-family: var(--f-hand); font-size: 1.45rem; line-height: 1.3; }
.orn { text-align: center; color: var(--ink-faint); margin: 1em 0; letter-spacing: 0.4em; }
.caret { display: inline-block; width: 0.5em; height: 0.5em; margin-left: 4px; border-radius: 50%; background: var(--accent); animation: bob 0.9s ease-in-out infinite; vertical-align: 0.1em; }
@keyframes bob { 50% { transform: translateY(-4px); opacity: 0.5; } }

/* options the GM offers: click to use */
.choices { list-style: none; margin: 0.4em 0 1em; padding: 0; display: grid; gap: 8px; }
.choices li {
  position: relative; padding: 9px 14px 9px 40px; border-radius: 14px; cursor: pointer;
  border: 2.5px solid var(--line); background: var(--card); box-shadow: var(--pop-sm);
  font-family: var(--f-body); font-weight: 700; font-size: 1.04rem; line-height: 1.35;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}
.choices li::before { content: "➜"; position: absolute; left: 13px; top: 8px; color: var(--accent); font-weight: 800; }
.choices li:hover { transform: translate(-1px, -2px) rotate(-0.4deg); box-shadow: 3px 5px 0 var(--drop); background: color-mix(in oklab, var(--accent) 10%, var(--card)); }
.choices li:active { transform: translate(2px, 3px); box-shadow: none; }
.choices li em { font-style: normal; }
.choices.stale li { cursor: default; box-shadow: none; border-color: var(--soft); color: var(--ink-soft); background: transparent; transform: none; font-weight: 600; }
.choices.stale li::before { color: var(--ink-faint); }

/* scene banner */
.scene-break { text-align: center; margin: 2em 0 1.4em; }
.entries > .entry:first-child .scene-break:first-child { margin-top: 0.3em; }
.scene-break .chapter { font-family: var(--f-display); font-size: 1.7rem; color: var(--accent-2); margin-bottom: 0.4em; text-wrap: balance; }
.ribbon { position: relative; display: inline-block; padding: 0 30px; }
.ribbon span {
  position: relative; z-index: 1; display: inline-block; padding: 7px 22px;
  background: var(--accent); color: var(--on-accent); border: 2.5px solid var(--line); border-radius: 6px;
  font-family: var(--f-display); font-size: 1.25rem; line-height: 1.2; box-shadow: var(--pop-sm);
}
.ribbon::before, .ribbon::after {
  content: ""; position: absolute; top: 10px; bottom: -6px; width: 40px; z-index: 0;
  background: color-mix(in oklab, var(--accent) 70%, black); border: 2.5px solid var(--line);
}
.ribbon::before { left: 0; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 12px 50%); }
.ribbon::after { right: 0; clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 50%, 100% 100%, 0 100%); }
.scene-when { margin-top: 6px; font-family: var(--f-hand); font-size: 1.35rem; color: var(--ink-soft); }

/* feedback on GM messages: three faint dots in the corner, a small menu (like / report) */
.entry.gm { position: relative; }
.fb-dots {
  /* in the page's right margin, level with the message's first line (above it on narrow screens) */
  position: absolute; top: 2px; right: calc(6px - clamp(18px, 6vw, 64px)); z-index: 2; padding: 3px 7px; border: 0; border-radius: 8px;
  background: none; color: var(--ink-soft); opacity: .3; font: 700 11px/1 system-ui, sans-serif; letter-spacing: 1px;
  cursor: pointer; transition: opacity .15s, background .15s;
}
.entry.gm:hover > .fb-dots, .fb-dots:focus-visible, .fb-dots.liked { opacity: .7; }
.fb-dots:hover { opacity: 1; background: color-mix(in oklab, var(--ink-soft) 14%, transparent); }
.fb-heart { color: var(--accent); margin-right: 4px; font-size: 12px; }
@media (max-width: 700px) { .fb-dots { top: -18px; right: -6px; } }
/* reading aloud (voice.js): a speaker under the dots, in the same margin */
.speak-btn {
  position: absolute; top: 24px; right: calc(8px - clamp(18px, 6vw, 64px)); z-index: 2; width: 26px; height: 26px; padding: 4px;
  border: 0; border-radius: 8px; background: none; color: var(--ink-soft); opacity: .35; cursor: pointer;
  transition: opacity .15s, background .15s;
}
.speak-btn svg { width: 100%; height: 100%; }
.entry.gm:hover > .speak-btn, .speak-btn:focus-visible { opacity: .75; }
.speak-btn:hover { opacity: 1; background: color-mix(in oklab, var(--ink-soft) 14%, transparent); }
.speak-btn.playing { opacity: 1; color: var(--accent); }
.speak-btn.loading { opacity: .9; animation: speak-pulse 1s ease-in-out infinite; }
@keyframes speak-pulse { 50% { opacity: .3; } }
@media (max-width: 700px) { .speak-btn { top: -22px; right: 34px; } }
.fb-menu {
  position: absolute; top: 18px; right: -8px; z-index: 30; display: flex; flex-direction: column; min-width: 220px;
  padding: 4px; background: var(--card); border: 2px solid var(--line); border-radius: 10px; box-shadow: var(--pop-sm);
}
.fb-item {
  text-align: left; padding: 8px 12px; border: 0; border-radius: 6px; background: none; color: var(--ink);
  font: inherit; font-size: .95rem; cursor: pointer;
}
.fb-item:hover, .fb-item:focus-visible { background: color-mix(in oklab, var(--accent) 16%, transparent); }
.fb-text {
  display: block; width: 100%; box-sizing: border-box; margin-top: 8px; padding: 8px 10px; resize: vertical;
  font: inherit; color: var(--ink); background: var(--card); border: 2px solid var(--line); border-radius: 8px;
}

/* player speech bubbles */
.entry.player { display: flex; justify-content: flex-end; align-items: flex-end; gap: 10px; margin: 1.4em 0 1.6em; }
.bubble {
  position: relative; max-width: 82%; padding: 10px 16px 12px; border-radius: 18px 18px 4px 18px;
  background: color-mix(in oklab, var(--accent-2) 16%, var(--card)); border: 2.5px solid var(--line); box-shadow: var(--pop-sm);
}
.bubble .who { font-family: var(--f-ui); font-weight: 700; font-size: 0.82rem; color: var(--accent-2); margin-bottom: 2px; }
:root[data-theme="dark"] .bubble .who { color: color-mix(in oklab, var(--accent-2) 55%, white); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bubble .who { color: color-mix(in oklab, var(--accent-2) 55%, white); } }
.bubble .said p { font-family: var(--f-body); font-size: 1.06rem; line-height: 1.5; margin: 0 0 0.4em; }
.bubble .said p:last-child { margin-bottom: 0; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-2); color: #fff; border: 2.5px solid var(--line); font-family: var(--f-display); font-size: 1.2rem; box-shadow: var(--pop-sm); }
.entry.system { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 1.4em 0; font-weight: 700; color: var(--xp); font-size: 1.05rem; }
.entry.system svg { width: 18px; height: 18px; color: var(--gold); }

/* sheet changes as little stickers */
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0.5em 0 0.9em; }
.pill { padding: 3px 10px; border-radius: 999px; border: 2px solid var(--line); font-weight: 600; font-size: 0.85rem; background: var(--card); }
.pill.hurt { background: #ffc9c9; color: #7a1010; }
.pill.heal { background: #c3fae8; color: #0b5a45; }
.pill.gold { background: #ffec99; color: #6b4b00; }
.pill.xp { background: #e5dbff; color: #3b1f94; }
.pill.luck { background: #d3f9d8; color: #1c5d2a; }
.pill.item { background: #d0ebff; color: #10406d; }
.pill.lost { background: #e9ecef; color: #495057; text-decoration: line-through; }
.pill-reason { font-family: var(--f-hand); font-size: 1.2rem; color: var(--ink-soft); }

/* quest banners */
.quest-banner {
  display: flex; align-items: center; gap: 10px; margin: 0.8em 0; padding: 9px 14px;
  border: 2.5px solid var(--line); border-radius: 14px; box-shadow: var(--pop-sm);
  background: #fff3bf; color: #4d3800; animation: pop-in 0.45s cubic-bezier(.3,1.6,.5,1) both;
}
.qb-ico svg { width: 22px; height: 22px; }
.qb-label { font-family: var(--f-ui); font-weight: 700; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.06em; padding: 2px 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.08); }
.qb-name { font-family: var(--f-display); font-size: 1.15rem; }
.quest-banner.quest-active { background: #d0ebff; color: #10406d; }
.quest-banner.quest-done { background: #d3f9d8; color: #1c5d2a; }
.quest-banner.quest-done .qb-ico { color: var(--gold); animation: spin 1s ease-out; }
.quest-banner.quest-failed { background: #e9ecef; color: #495057; }
@keyframes pop-in { from { transform: scale(0.6); opacity: 0; } }
@keyframes spin { from { transform: rotate(-360deg) scale(0.3); } }

/* roll results in the story */
.entry.roll {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center;
  margin: 1.2em 0; padding: 10px 16px 10px 10px; background: var(--page-2); border: 2.5px solid var(--line); border-radius: 16px; box-shadow: var(--pop-sm);
}
.roll-die .d20 { width: 58px; height: 58px; }
.roll-action { font-weight: 700; font-size: 1.05rem; line-height: 1.3; }
.roll-math { font-size: 0.85rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.stamp {
  font-family: var(--f-display); font-size: 1.2rem; padding: 3px 12px; border-radius: 10px;
  border: 3px solid currentColor; transform: rotate(-6deg); white-space: nowrap; background: var(--card);
}
.res-crit .stamp { color: #d9480f; background: #fff3bf; animation: wobble 0.6s ease-in-out; }
.res-success .stamp { color: var(--good); }
.res-fail .stamp { color: var(--bad); }
.res-fumble .stamp { color: #862e9c; background: #f3d9fa; }
@keyframes wobble { 25% { transform: rotate(4deg) scale(1.15); } 60% { transform: rotate(-10deg); } }

/* d20 drawing (shared) */
.d20 { overflow: visible; }
.d20-body { fill: var(--accent); }
.d20-face { fill: color-mix(in oklab, var(--accent) 55%, white); }
.d20-edge { stroke: color-mix(in oklab, var(--accent) 60%, black); stroke-width: 2; fill: none; stroke-linejoin: round; }
.d20-outline { fill: none; stroke: var(--line); stroke-width: 5; stroke-linejoin: round; }
.d20-num { font-family: "Baloo 2", sans-serif; font-weight: 700; font-size: 25px; fill: #2e2118; dominant-baseline: middle; }
.res-crit .d20-body { fill: #fab005; }
.res-crit .d20-face { fill: #fff3bf; }
.res-fumble .d20-body { fill: #9c36b5; }
.res-fumble .d20-face { fill: #eebefa; }

/* handouts inline */
.handout { margin: 1.6em 0; }
.handout-art {
  display: block; width: 100%; padding: 8px; cursor: zoom-in;
  background: var(--card); border: 3px solid var(--line); border-radius: 16px; box-shadow: var(--pop);
  transform: rotate(-0.6deg); transition: transform 0.2s;
}
.handout-art:hover { transform: rotate(0.3deg) scale(1.01); }
.handout-art svg, .lightbox-art svg, .thumb-art svg { width: 100%; height: auto; border-radius: 9px; }
.handout.kind-letter .handout-art, .handout.kind-poster .handout-art, .handout.kind-object .handout-art, .handout.kind-portrait .handout-art { max-width: 420px; margin: 0 auto; transform: rotate(1.2deg); }
.handout figcaption { text-align: center; margin-top: 0.7em; }
.ho-title { font-family: var(--f-hand); font-size: 1.5rem; font-weight: 700; }
.ho-cap { display: block; font-size: 0.92rem; color: var(--ink-soft); }

/* waiting for the first scene */
.waiting { text-align: center; padding: 1.5rem 0 2rem; }
.waiting-die { width: 96px; margin: 0 auto 0.6rem; animation: roll-about 2.4s ease-in-out infinite; }
.waiting h2 { font-family: var(--f-display); font-weight: 400; font-size: 1.7rem; margin: 0.4rem 0; }
.waiting p { font-family: var(--f-body); font-size: 1.08rem; color: var(--ink-soft); max-width: 32em; margin: 0 auto; line-height: 1.5; }
.waiting.failed .waiting-die { animation: none; filter: grayscale(1); }
@keyframes roll-about { 0% { transform: rotate(0) translateY(0); } 25% { transform: rotate(90deg) translateY(-14px); } 50% { transform: rotate(180deg) translateY(0); } 75% { transform: rotate(270deg) translateY(-14px); } 100% { transform: rotate(360deg); } }

/* -- dock: roll card, status, composer ------------------------------------------------------ */
.dock {
  position: sticky; bottom: 0; z-index: 5;
  background: var(--page); color: var(--ink);
  border: 3px solid var(--line); border-top: 2.5px dashed var(--soft); border-radius: 0 0 var(--r) var(--r);
  box-shadow: 6px 6px 0 var(--drop);
  padding: 12px clamp(14px, 4vw, 40px) 14px;
  margin-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: grid; gap: 10px;
}
.roll-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px 14px; align-items: center;
  padding: 10px 12px; border-radius: 16px; border: 2.5px solid var(--line); box-shadow: var(--pop-sm);
  background: color-mix(in oklab, var(--accent) 14%, var(--card));
  animation: pop-in 0.4s cubic-bezier(.3,1.6,.5,1) both;
}
.rc-die svg { width: 48px; height: 48px; animation: jiggle 1.6s ease-in-out infinite; }
@keyframes jiggle { 0%, 70%, 100% { transform: rotate(0); } 80% { transform: rotate(-12deg); } 90% { transform: rotate(10deg); } }
.rc-kicker { font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-ink); }
.rc-action { font-family: var(--f-body); font-weight: 800; font-size: 1.12rem; line-height: 1.25; }
.rc-chips, .tray-mods { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.rc-chip, .tray-chip { font-weight: 600; font-size: 0.85rem; padding: 2px 10px; border-radius: 999px; border: 2px solid var(--line); background: var(--card); }
.rc-chip.need, .tray-chip.need { background: #fff3bf; color: #4d3800; }
.rc-chip.adv, .tray-chip.adv { background: #d3f9d8; color: #1c5d2a; }
.rc-chip.dis, .tray-chip.dis { background: #ffc9c9; color: #7a1010; }
@media (max-width: 560px) {
  .roll-card { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .rc-die { display: none; }
  .rc-chip { font-size: 0.8rem; padding: 1px 8px; }
}

/* The hero is dead: the ending card takes the input's place. */
.end-card {
  text-align: center; padding: 18px 16px 16px; border-radius: 16px; border: 2.5px solid var(--line);
  box-shadow: var(--pop-sm); background: var(--card); color: var(--ink); animation: pop-in 0.6s ease both;
}
.ec-kicker { font-family: var(--f-display); font-size: 1.9rem; line-height: 1.1; color: var(--accent-ink); }
.ec-title { font-family: var(--f-body); font-style: italic; font-size: 1.08rem; margin: 6px 0 14px; }
.ec-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* a refused move: the Game Master's note above the input box */
.move-note {
  position: relative; padding: 10px 40px 10px 14px; border-radius: 16px; border: 2.5px solid var(--line);
  box-shadow: var(--pop-sm); background: color-mix(in oklab, var(--accent-2, var(--accent)) 12%, var(--card)); color: var(--ink);
  animation: pop-in 0.4s cubic-bezier(.3,1.6,.5,1) both;
}
.mn-kicker { font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-ink); }
.mn-title { font-family: var(--f-body); font-weight: 800; font-size: 1.1rem; line-height: 1.25; margin-top: 2px; }
.mn-text { margin: 4px 0 0; font-family: var(--f-body); line-height: 1.45; }
.mn-after { margin: 6px 0 0; font-weight: 700; font-size: 0.92rem; color: var(--ink-soft); }
.mn-after.locked { color: var(--bad); }
.mn-close {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink-soft); cursor: pointer;
}
.mn-close svg { width: 14px; height: 14px; }
.mn-close:hover { background: color-mix(in oklab, var(--ink) 10%, transparent); color: var(--ink); }
.composer.locked textarea { cursor: default; background: color-mix(in oklab, var(--ink) 5%, var(--card)); }

.status-line { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--ink-soft); }
.status-line .btn { margin-left: auto; }
.status-text.error { color: var(--bad); }
.wait-clock { font-variant-numeric: tabular-nums; opacity: 0.7; font-size: 0.9em; }
.writing { display: inline-flex; gap: 5px; }
.writing i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 1.5px solid var(--line); animation: hop 1s ease-in-out infinite; }
.writing i:nth-child(2) { animation-delay: 0.15s; background: var(--accent-2); }
.writing i:nth-child(3) { animation-delay: 0.3s; background: var(--gold); }
@keyframes hop { 30% { transform: translateY(-7px); } 60% { transform: translateY(0); } }

.composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: end; }
.composer textarea {
  width: 100%; resize: none; min-height: 52px; max-height: 40vh;
  padding: 12px 14px; border-radius: 14px; border: 2.5px solid var(--line);
  background: var(--card); color: var(--ink);
  font-family: var(--f-body); font-size: 1.08rem; line-height: 1.45;
}
.composer textarea:focus { outline: none; box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 30%, transparent); }
.composer .send { height: 52px; }
.composer-hint { grid-column: 1 / -1; font-size: 0.78rem; color: var(--ink-faint); }
@media (max-width: 560px) { .composer-hint { display: none; } .composer .send span:last-child { display: none; } }

/* -- side panel -------------------------------------------------------------------------------- */
.panel {
  width: 380px; min-height: 0; overflow-y: auto; margin: 14px 14px 14px 0;
  background: var(--page-2); color: var(--ink);
  border: 3px solid var(--line); border-radius: var(--r); box-shadow: var(--pop);
}
@media (max-width: 1180px) {
  .panel { position: fixed; z-index: 30; right: 0; top: 0; bottom: 0; width: min(94vw, 400px); margin: 10px; }
}
.panel-tabs { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 4px; padding: 10px 8px 8px; background: var(--page-2); border-bottom: 2.5px dashed var(--soft); overflow-x: auto; }
.panel-tab { border: 2px solid transparent; background: none; cursor: pointer; padding: 4px 8px; border-radius: 11px; color: var(--ink-soft); font-weight: 600; font-size: 0.92rem; white-space: nowrap; }
.panel-tab:hover { background: color-mix(in oklab, var(--ink) 7%, transparent); }
.panel-tab[aria-selected="true"] { color: var(--on-accent); background: var(--accent-2); border-color: var(--line); }
.panel-close { margin-left: auto; }
.panel-body { padding: 16px 14px 30px; }
.panel h3 { font-family: var(--f-ui); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); margin: 0 0 8px; }
.empty { color: var(--ink-faint); font-style: italic; }
.card-sec { background: var(--card); border: 2.5px solid var(--line); border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; box-shadow: var(--pop-sm); }
.card-sec p { margin: 0 0 8px; line-height: 1.45; font-family: var(--f-body); }
.card-sec p:last-child { margin-bottom: 0; }

/* hero sheet */
.hero-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.level-badge { flex: none; width: 60px; height: 60px; border-radius: 50%; display: grid; place-content: center; text-align: center; background: var(--gold); color: #3b2a00; border: 3px solid var(--line); box-shadow: var(--pop-sm); line-height: 1; }
.lv-n { font-family: var(--f-ui); font-weight: 700; font-size: 1.6rem; }
.lv-l { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.1em; }
.hero-name { font-family: var(--f-display); font-size: 1.6rem; line-height: 1.1; }
.hero-class { font-weight: 600; color: var(--accent-ink); }
.hero-look { font-family: var(--f-hand); font-size: 1.2rem; color: var(--ink-soft); line-height: 1.1; margin-top: 2px; }
.meters { display: grid; gap: 10px; margin-bottom: 14px; }
.meter { display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: center; }
.m-ico svg { width: 26px; height: 26px; }
.meter.hp .m-ico { color: var(--heart); }
.meter.hp.out .m-ico { animation: pulse 1s infinite; }
.meter.xp .m-ico { color: var(--xp); }
.bar { position: relative; height: 26px; border-radius: 999px; border: 2.5px solid var(--line); background: var(--card); overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; transition: width 0.6s cubic-bezier(.3,1.3,.5,1); }
.hp .bar-fill { background: linear-gradient(180deg, #ff8787, #f03e3e); }
.xp .bar-fill { background: linear-gradient(180deg, #b197fc, #7950f2); }
.bar-text { position: relative; display: block; text-align: center; font-weight: 700; font-size: 0.85rem; line-height: 21px; color: var(--ink); text-shadow: 0 0 3px var(--card), 0 0 3px var(--card); }
/* its own gentle pulse: the shared one grows things by 35%, which pushed this full-width button out of the panel (a sideways scrollbar) */
.levelup { animation: levelup-pulse 1.4s ease-in-out infinite; background: var(--xp) !important; }
@keyframes levelup-pulse { 50% { transform: scale(1.04); filter: brightness(1.15); } }
.meter-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.purse, .luck { display: flex; align-items: center; gap: 6px; }
.purse .m-ico svg { width: 26px; height: 26px; }
.purse-n { font-family: var(--f-ui); font-weight: 700; font-size: 1.5rem; }
.purse-l { font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); }
.clover svg { width: 24px; height: 24px; color: #9a9a96; opacity: 0.8; }
.clover.on svg { color: #3fae4f; opacity: 1; filter: drop-shadow(1px 1.5px 0 var(--drop)); }
.abilities { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.ability { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border: 2.5px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: var(--pop-sm); }
.ab-ico svg { width: 22px; height: 22px; }
.ab-might .ab-ico { color: #e8590c; }
.ab-agility .ab-ico { color: #1c7ed6; }
.ab-wits .ab-ico { color: #f59f00; }
.ab-charm .ab-ico { color: #d6336c; }
.ab-v { font-family: var(--f-ui); font-weight: 700; font-size: 1.45rem; line-height: 1; }
.ab-n { font-size: 0.75rem; font-weight: 600; color: var(--ink-soft); }
.knacks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-family: var(--f-body); line-height: 1.35; }
.knacks li { display: grid; grid-template-columns: 18px 1fr; gap: 6px; }
.kn-ico svg { width: 16px; height: 16px; color: var(--gold); margin-top: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 11px; border-radius: 999px; border: 2px solid var(--line); background: var(--page-2); font-weight: 600; font-size: 0.88rem; }
.chip.item { background: #d0ebff; color: #10406d; }
.chip.warn { background: #ffe8cc; color: #7a3a00; }

/* quests */
.quest-list { display: grid; gap: 10px; }
.quest-card { padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: #fff9db; color: #3b2a00; }
.quest-card.q-active { background: #e7f5ff; color: #10304d; }
.quest-card.q-done { background: #ebfbee; color: #1c4d2a; }
.quest-card.q-failed { background: #f1f3f5; color: #495057; }
.qc-top { display: flex; gap: 8px; align-items: center; }
.qc-ico svg { width: 18px; height: 18px; }
.q-done .qc-ico { color: #f08c00; }
.qc-name { font-family: var(--f-display); font-size: 1.1rem; line-height: 1.2; }
.qc-note { font-family: var(--f-body); font-size: 0.95rem; line-height: 1.4; margin: 4px 0 0 !important; }
.qc-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; font-size: 0.85rem; font-weight: 600; }
.qc-reward { display: inline-flex; align-items: center; gap: 4px; }
.qc-reward svg { width: 16px; height: 16px; }
.qc-giver { opacity: 0.75; }

/* people & places */
.world-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.wl-name { font-family: var(--f-display); font-size: 1.08rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wl-note { font-family: var(--f-body); font-size: 0.93rem; line-height: 1.4; color: var(--ink-soft); }
.wl-search { width: 100%; box-sizing: border-box; margin: 0 0 12px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); font: inherit; font-size: 0.95rem; }
.wl-card { padding: 8px 10px; margin: 0 -10px; border-radius: 10px; cursor: pointer; transition: background 0.15s; }
.wl-card:hover, .wl-card.open { background: color-mix(in oklab, var(--ink) 6%, transparent); }
.wl-card:focus-visible { outline: 2px solid var(--accent); }
.wl-card.focus { box-shadow: inset 3px 0 0 var(--accent); }
.wl-card.flash { animation: wl-flash 1.6s ease-out; }
@keyframes wl-flash { 0%, 30% { background: color-mix(in oklab, var(--accent) 22%, transparent); } }
.wl-more { margin-left: auto; font-size: 0.75rem; color: var(--ink-faint); }
.wl-details { margin-top: 8px; display: grid; gap: 10px; font-family: var(--f-body); font-size: 0.92rem; line-height: 1.4; cursor: default; }
.wl-label { font-family: var(--f-ui); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin-right: 6px; }
.wl-block .wl-label { display: block; margin-bottom: 4px; }
.wl-facts, .wl-moments { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.wl-moments { list-style: none; padding: 0; gap: 6px; }
.wl-moments li { display: flex; gap: 8px; align-items: baseline; }
.wl-quote { flex: 1; font-style: italic; color: var(--ink-soft); }
.wl-jump { flex: none; border: 0; background: none; padding: 0; font: inherit; font-family: var(--f-ui); font-size: 0.75rem; font-weight: 700;
  color: var(--accent); cursor: pointer; }
.wl-jump:hover { text-decoration: underline; }
.wl-quest { cursor: pointer; font: inherit; font-family: var(--f-ui); font-size: 0.8rem; }

/* names in the story: plain text until hovered, then a quiet link to their World entry */
.ent { cursor: pointer; border-radius: 2px; }
/* a touch screen has no hover: the ••• and the speaker stay faintly visible, and names show they can be tapped */
@media (hover: none) {
  .entry.gm > .fb-dots, .entry.gm > .speak-btn { opacity: .5; }
  .ent { text-decoration: underline dotted; text-decoration-color: color-mix(in oklab, currentColor 35%, transparent); text-underline-offset: 3px; }
}
.ent:hover { color: var(--accent); text-decoration: underline dotted; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.entry.flash { animation: entry-flash 1.8s ease-out; }
@keyframes entry-flash { 0%, 35% { background: color-mix(in oklab, var(--accent) 14%, transparent); box-shadow: 0 0 0 8px color-mix(in oklab, var(--accent) 14%, transparent); } }
.tag { font-family: var(--f-ui); font-weight: 600; font-size: 0.72rem; padding: 1px 8px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--page-2); color: var(--ink-soft); }
.tag-friend, .tag-ally { background: #d3f9d8; color: #1c5d2a; }
.tag-enemy, .tag-villain { background: #ffc9c9; color: #7a1010; }

.handout-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.handout-thumb { border: 2.5px solid var(--line); background: var(--card); border-radius: 14px; padding: 7px; cursor: zoom-in; text-align: left; box-shadow: var(--pop-sm); transition: transform 0.12s; }
.handout-thumb:nth-child(odd) { transform: rotate(-1deg); }
.handout-thumb:nth-child(even) { transform: rotate(1deg); }
.handout-thumb:hover { transform: rotate(0) scale(1.03); }
.thumb-art { border-radius: 8px; overflow: hidden; aspect-ratio: 4 / 3; display: grid; place-items: center; background: var(--page-2); }
.thumb-art svg { max-height: 100%; }
.thumb-title { font-family: var(--f-hand); font-size: 1.2rem; font-weight: 700; margin-top: 4px; line-height: 1.1; }

.rules dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 8px 0 0; font-family: var(--f-body); }
.rules dt { font-family: var(--f-display); color: var(--accent-ink); }
.rules dd { margin: 0; line-height: 1.4; }

/* -- dice tray ------------------------------------------------------------------------------- */
.tray-backdrop, .modal-backdrop, .lightbox-backdrop {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: rgba(20, 14, 30, 0.6); backdrop-filter: blur(4px); overflow-y: auto;
  grid-template-columns: minmax(0, 1fr); /* a wide row (the voice list) can't stretch a dialog past the screen */
}
.tray {
  width: min(100%, 620px); border-radius: 26px; padding: 12px 14px 18px; color: #fff8e8;
  background: linear-gradient(170deg, #9c5f35, #6b3e22 70%);
  border: 3px solid #2e2118; box-shadow: 8px 10px 0 rgba(0, 0, 0, 0.5);
  animation: pop-in 0.35s cubic-bezier(.3,1.5,.5,1) both;
}
.tray-top { display: flex; align-items: center; gap: 4px; padding: 0 2px 10px; }
.tray-kicker { font-family: var(--f-display); font-size: 1.35rem; margin-right: auto; padding-left: 6px; text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35); }
.felt {
  position: relative; height: 250px; border-radius: 18px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #2f9e6b, #1b6b48 80%);
  border: 3px solid #2e2118; box-shadow: inset 0 8px 20px rgba(0, 0, 0, 0.45);
}
.felt::after { content: ""; position: absolute; inset: 9px; border: 2px dashed rgba(255, 255, 255, 0.28); border-radius: 12px; pointer-events: none; }
.die20 { position: absolute; left: 0; top: 0; width: 96px; height: 96px; filter: drop-shadow(5px 7px 0 rgba(0, 0, 0, 0.35)); transition: opacity 0.3s, filter 0.3s; }
.die20 .d20 { width: 100%; height: 100%; }
.die20 .d20-num { font-size: 27px; }
.die20.idle { opacity: 0.85; animation: idle-bob 1.6s ease-in-out infinite; }
@keyframes idle-bob { 50% { translate: 0 -8px; } }
.die20.dropped { opacity: 0.4; filter: grayscale(0.8); }
.die20.crit .d20-body { fill: #fab005; }
.die20.crit .d20-face { fill: #fff3bf; }
.die20.crit { filter: drop-shadow(0 0 16px #ffe066) drop-shadow(5px 7px 0 rgba(0, 0, 0, 0.35)); }
.die20.fumble .d20-body { fill: #9c36b5; }
.die20.fumble .d20-face { fill: #eebefa; }
.die20.fumble .d20 { animation: shake 0.5s ease-in-out 2; }
@keyframes shake { 25% { transform: translateX(-6px) rotate(-6deg); } 75% { transform: translateX(6px) rotate(6deg); } }
.spark { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; color: var(--c); pointer-events: none; animation: burst 1s ease-out forwards; }
.spark svg { width: 100%; height: 100%; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(200deg) scale(0.3); opacity: 0; } }

.tray-info { padding: 14px 6px 0; display: grid; gap: 12px; text-align: center; }
.tray-what { font-family: var(--f-body); font-weight: 800; font-size: 1.3rem; line-height: 1.25; }
.tray-stakes { font-size: 0.95rem; color: #ffe8c2; margin-top: 3px; }
.tray-mods { justify-content: center; margin-top: 0; }
.tray .tray-chip { color: #2e2118; }
.tray-label { font-weight: 600; font-size: 0.88rem; color: #ffe8c2; margin-bottom: 6px; }
.tray-knack-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.tray-knack { border: 2px solid #2e2118; background: rgba(0, 0, 0, 0.22); color: #fff8e8; border-radius: 999px; padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 0.92rem; }
.tray-knack.on { background: #ffd43b; color: #2e2118; }
.tray-knack:disabled { opacity: 0.45; cursor: default; }
.tray-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.tray .btn { --drop: #2e2118; border-color: #2e2118; }
.tray .btn.ghost { color: #fff8e8; }
.tray .btn.primary { background: #ffd43b; color: #2e2118; }
.luck-ico svg { width: 18px; height: 18px; color: #4cc15c; }
.tray-result { display: grid; justify-items: center; gap: 4px; opacity: 0.4; }
.tray-result.shown { opacity: 1; }
.tray-total { font-family: var(--f-ui); font-weight: 700; font-size: 3.4rem; line-height: 1; text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.35); }
.stamp.big { font-size: 1.6rem; padding: 4px 18px; animation: stamp-in 0.4s cubic-bezier(.3,1.8,.5,1) both; }
@keyframes stamp-in { from { transform: rotate(-20deg) scale(2.2); opacity: 0; } }
.tray-math { font-size: 0.9rem; color: #ffe8c2; }

/* -- modal, lightbox, toasts ------------------------------------------------------------------- */
.modal-card { width: min(100%, 460px); background: var(--page); color: var(--ink); border-radius: 22px; padding: 22px; border: 3px solid var(--line); box-shadow: 8px 10px 0 var(--drop); animation: pop-in 0.3s cubic-bezier(.3,1.5,.5,1) both; }
.modal-card h2 { font-family: var(--f-display); font-weight: 400; font-size: 1.7rem; margin: 0 0 12px; }
.modal-card p { line-height: 1.5; font-family: var(--f-body); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.menu-list { display: grid; gap: 4px; }
/* the book dialog */
.book-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.book-links .btn { text-decoration: none; }
.modal-card .muted { color: var(--ink-soft); font-size: 0.92rem; }
.menu-item { display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: none; padding: 10px 8px; border-radius: 12px; cursor: pointer; font-size: 1rem; font-weight: 500; }
.menu-item:hover { background: var(--page-2); }
.menu-item svg { width: 22px; height: 22px; }
.menu-item.danger { color: var(--bad); }
.menu-slider { cursor: default; }
.menu-slider input { flex: 1; min-width: 80px; accent-color: var(--accent); }
.menu-select, .menu-check { cursor: default; }
.menu-select select { flex: 1; min-width: 0; max-width: 100%; font: inherit; font-size: .9em; padding: 4px 6px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }
.menu-check, .menu-sub { padding-left: 46px; font-size: .92em; }
.menu-rate { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.menu-check input { accent-color: var(--accent); width: 16px; height: 16px; }
.menu-item[hidden] { display: none; }
.adv { display: grid; gap: 10px; }
.adv-opt { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; padding: 10px; border: 2.5px solid var(--line); border-radius: 14px; background: var(--card); font-weight: 600; }
.adv-opt select, .adv-opt input[type="text"] { grid-column: 2; }
.adv select, .adv input[type="text"] { width: 100%; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--line); background: var(--page); color: var(--ink); font: inherit; font-weight: 500; }
.lightbox-figure { margin: 0; width: min(100%, 980px); display: grid; gap: 10px; }
.lightbox-art { background: var(--card); padding: 10px; border-radius: 18px; border: 3px solid var(--line); max-height: 82vh; overflow: auto; }
.lightbox-figure.kind-letter, .lightbox-figure.kind-poster, .lightbox-figure.kind-portrait { width: min(100%, 600px); }
.lightbox-figure figcaption { text-align: center; color: #fff8e8; font-family: var(--f-hand); font-size: 1.6rem; }
.lightbox-close { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 12px); right: 12px; color: #fff8e8; }
.toasts { position: fixed; z-index: 80; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 520px); pointer-events: none; }
.toast { background: var(--card); color: var(--ink); border: 2.5px solid var(--line); border-radius: 14px; padding: 10px 14px; box-shadow: var(--pop-sm); font-weight: 500; transition: opacity 0.5s, transform 0.5s; animation: pop-in 0.3s cubic-bezier(.3,1.5,.5,1) both; }
.toast.error { background: #ffe3e3; color: #7a1010; }
.toast.out { opacity: 0; transform: translateY(8px); }


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* paintings (rendered by the local image model) */
.handout.kind-painting .handout-art { padding: 6px; transform: rotate(-0.8deg); }
.painting-art img, .thumb-art img, .lightbox-art img { display: block; width: 100%; height: auto; border-radius: 10px; }
.handout.gone { display: none; }
.painting-wait {
  display: grid; place-content: center; justify-items: center; gap: 12px; aspect-ratio: 3 / 2; cursor: default;
  background: linear-gradient(110deg, var(--page-2) 30%, color-mix(in oklab, var(--accent) 18%, var(--page-2)) 50%, var(--page-2) 70%);
  background-size: 250% 100%; animation: shimmer 2.2s linear infinite;
}
.painting-wait:hover { transform: rotate(-0.8deg); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
.brush { display: flex; gap: 8px; }
.brush i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); animation: hop 1.1s ease-in-out infinite; }
.brush i:nth-child(1) { background: var(--accent); }
.brush i:nth-child(2) { background: var(--gold); animation-delay: 0.15s; }
.brush i:nth-child(3) { background: var(--accent-2); animation-delay: 0.3s; }
.pw-text { font-family: var(--f-hand); font-size: 1.6rem; font-weight: 700; color: var(--ink-soft); }
.thumb-wait { font-family: var(--f-hand); font-size: 1.2rem; color: var(--ink-faint); }
.handout-thumb.painting .thumb-art img { height: 100%; object-fit: cover; }
/* drawings re-rendered as the real object: switch back to the sketch, and a badge while it's being made */
.handout-frame { position: relative; }
.handout-art.real { padding: 6px; }
.handout-art.real img { display: block; width: 100%; height: auto; border-radius: 10px; }
.sketch-toggle {
  position: absolute; top: 14px; right: 14px; z-index: 2; padding: 3px 10px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--line); background: var(--card); color: var(--ink); font: 600 0.8rem var(--f-ui);
  box-shadow: var(--pop-sm); opacity: 0.85;
}
.sketch-toggle:hover { opacity: 1; }
.sketch-toggle.inline { position: static; margin-left: 8px; vertical-align: middle; }
.restyle-badge {
  position: absolute; bottom: 14px; right: 14px; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; border: 2px solid var(--line); background: var(--card); font: 600 0.8rem var(--f-ui); color: var(--ink-soft);
}
.restyle-badge i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
/* a paid picture waiting for the player's OK */
.painting-wait.asking { animation: none; background: var(--page-2); aspect-ratio: 3 / 1; }
.restyle-badge.ask { cursor: pointer; color: var(--ink); }
.ask-scene { font-size: 0.92rem; color: var(--ink-soft); font-style: italic; max-height: 9em; overflow: auto; }

/* saved games */
.modal-card.wide { width: min(100%, 640px); }
.saves-note { margin: 0 0 12px; color: var(--ink-soft); font-size: 0.95rem; }
.save-list { display: grid; gap: 10px; max-height: 60vh; overflow-y: auto; padding: 2px 4px 4px 2px; }
.save-card {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 10px 8px 8px;
  background: var(--card); border: 2.5px solid var(--line); border-radius: 14px; box-shadow: var(--pop-sm);
}
.save-card.current { outline: 3px solid var(--accent); outline-offset: 1px; }
.save-card.old { opacity: 0.6; }
.save-thumb { width: 92px; height: 64px; border-radius: 9px; overflow: hidden; display: grid; place-items: center; background: var(--page-2); color: var(--ink-faint); border: 2px solid var(--line); }
.save-thumb img { width: 100%; height: 100%; object-fit: cover; }
.save-thumb svg { width: 26px; height: 26px; }
.save-title { font-family: var(--f-display); font-size: 1.25rem; line-height: 1.1; }
.save-hero { font-weight: 600; font-size: 0.92rem; }
.save-meta { font-size: 0.82rem; color: var(--ink-soft); }
.save-actions { display: flex; align-items: center; gap: 4px; }
.save-now { font-weight: 700; font-size: 0.82rem; color: var(--accent-ink); white-space: nowrap; }
.save-del { width: 32px; height: 32px; color: var(--ink-faint); }
.save-del:hover { color: var(--bad); }

.save-lang { margin-left: 8px; font-size: 0.7rem; vertical-align: middle; }

.qc-side { margin-left: auto; }
.quest-banner.side { transform: scale(0.95); }

/* -- home page ---------------------------------------------------------------------------------
   An old fantasy RPG website (2007) crossed with a Game Master's handbook: the skins' own textures
   (dark leather, parchment, ship's wood), a wood-framed banner of world paintings, a glossy nav bar with
   gold bevel buttons, a parchment book column (chapters, drop cap, read-aloud boxes, a sidebar box) and
   portal-style side boxes. The same in light and dark theme. Fonts with the Polish letters: Amarante
   (titles), Vollkorn and Vollkorn SC. */
.home-open .app { display: none; } /* the game page behind would widen a phone's layout */
.home, .wizard {
  --hm-ink: #3b2414; --hm-ink-2: #6b4a2a; --hm-red: #7d2418; --hm-gold: #c9962f; --hm-edge: #1a0f08;
  --hm-parchment: #f3e2bb url("/static/skins/wildwest/img/parchment.jpg") center / 700px;
  position: fixed; inset: 0; z-index: 50; overflow-y: auto; overflow-x: hidden;
  background: #2a1c12 url("/static/skins/wildwest/img/leather-dark.jpg") center top / 512px;
  color: var(--hm-ink); font-family: "Vollkorn", Georgia, serif;
}
.hm {
  min-height: 100%; box-sizing: border-box; padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px 28px;
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 190, 110, 0.14), transparent 55%), radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.55));
}
.hm-wrap { max-width: 1000px; margin: 0 auto; }
/* the home page uses a wide screen: a wider column, the worlds two side by side (the wizard and login stay narrow) */
.home:not(.login) .hm-wrap { max-width: 1520px; }
.hm-worlds { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(470px, 100%), 1fr)); column-gap: 36px; }
@media (min-width: 1600px) and (min-height: 860px) { .home:not(.login) .hm-banner { height: 340px; } }
/* from here the worlds sit two side by side: a lone last one goes in the middle */
@media (min-width: 1440px) { .hm-world:last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; width: calc(50% - 18px); } }
@media (min-width: 1280px) {
  .home:not(.login) .hm-cols { grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; }
  .hm-side { position: sticky; top: 18px; } /* the saved games and the tip stay in view beside the long book */
  .hm-rules { columns: 3 260px; }
}

/* banner: paintings in a wooden frame with brass studs, a parchment title plaque */
.hm-banner {
  position: relative; height: 280px; border: 2px solid var(--hm-edge); border-radius: 8px 8px 0 0;
  background: #5a3a22 url("/static/skins/pirates/img/wood.jpg") center / 420px;
  box-shadow: inset 0 0 0 2px rgba(255, 220, 160, 0.22), inset 0 0 24px rgba(0, 0, 0, 0.5), 0 10px 30px rgba(0, 0, 0, 0.6);
}
.hm-banner::after {
  content: ""; position: absolute; inset: 4px; pointer-events: none;
  background:
    radial-gradient(circle at 5px 5px, #ffe7a8 0 1.5px, #b98a2e 2.5px, #5a3c10 4.5px, transparent 5px) top left / 10px 10px no-repeat,
    radial-gradient(circle at 5px 5px, #ffe7a8 0 1.5px, #b98a2e 2.5px, #5a3c10 4.5px, transparent 5px) top right / 10px 10px no-repeat,
    radial-gradient(circle at 5px 5px, #ffe7a8 0 1.5px, #b98a2e 2.5px, #5a3c10 4.5px, transparent 5px) bottom left / 10px 10px no-repeat,
    radial-gradient(circle at 5px 5px, #ffe7a8 0 1.5px, #b98a2e 2.5px, #5a3c10 4.5px, transparent 5px) bottom right / 10px 10px no-repeat;
}
.hm-slides { position: absolute; inset: 14px; overflow: hidden; border: 2px solid var(--hm-edge); background: #1a0f08; box-shadow: 0 0 0 1px rgba(255, 220, 160, 0.3); }
.hm-slides::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.55); pointer-events: none; }
.hm-slide { position: absolute; inset: 0; background: center 45% / cover no-repeat; opacity: 0; transition: opacity 2.2s ease; }
.hm-slide.on { opacity: 1; animation: hm-drift 18s ease-out both; }
@keyframes hm-drift { from { transform: scale(1.1) translateX(1.5%); } to { transform: scale(1.02); } }
.hm-plaque {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -54%); width: max-content; max-width: calc(100% - 60px); box-sizing: border-box;
  text-align: center; padding: 12px 40px 14px; background: var(--hm-parchment); border: 3px double #5a3a1e; border-radius: 4px;
  box-shadow: 0 0 0 1px #f7e6c0, 0 8px 22px rgba(0, 0, 0, 0.6), inset 0 0 30px rgba(140, 90, 30, 0.35);
}
.hm-title {
  margin: 0; font: 400 clamp(2.6rem, 7vw, 4.2rem) / 1 "Amarante", "Vollkorn", serif; color: var(--hm-red);
  text-shadow: 1px 1px 0 #fbeccb, 2px 3px 0 rgba(60, 30, 10, 0.3);
}
.hm-tagline { font-style: italic; font-size: 1.05rem; margin-top: 4px; color: var(--hm-ink); }
.hm-slidebar { position: absolute; right: 26px; bottom: 24px; display: flex; align-items: center; gap: 10px; }
.hm-caption { font: 600 0.85rem "Vollkorn", serif; color: #f7e6c0; padding: 2px 10px; border-radius: 3px; background: rgba(26, 15, 8, 0.7); text-shadow: 0 1px 0 #000; }
.hm-dots { display: flex; gap: 6px; }
.hm-dot { width: 12px; height: 12px; padding: 0; border-radius: 50%; cursor: pointer; border: 1px solid #1a0f08; background: radial-gradient(circle at 35% 35%, #fff4cf, #9c7a3c); opacity: 0.55; }
.hm-dot[aria-current="true"] { opacity: 1; background: radial-gradient(circle at 35% 35%, #fff4cf, #e0a93a 60%, #7a4e0e); box-shadow: 0 0 6px rgba(255, 200, 90, 0.8); }

/* the glossy 2007 nav bar */
.hm-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 14px; border: 2px solid var(--hm-edge); border-top: 0; border-radius: 0 0 8px 8px;
  background: linear-gradient(#7a2616, #561509 49%, #410d05 51%, #5a1a0e);
  box-shadow: inset 0 1px 0 rgba(255, 210, 170, 0.35), inset 0 -1px 0 rgba(0, 0, 0, 0.4), 0 8px 20px rgba(0, 0, 0, 0.5);
}
.hm-bar-gap { flex: 1; }
.hm-btn {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 7px 16px; cursor: pointer;
  font: 700 1rem "Vollkorn", Georgia, serif; color: #2b1604; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  border: 1px solid #3b2006; border-radius: 6px;
  background: linear-gradient(#fbf1dc, #ead7b0 48%, #d8bf91 52%, #e9d6ae);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 2px 3px rgba(0, 0, 0, 0.45);
}
.hm-btn.gold { background: linear-gradient(#fff3c8, #f2cb66 46%, #d9a53a 54%, #ecc05a); }
.hm-btn:hover:not(:disabled) { filter: brightness(1.08); }
.hm-btn:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35); }
.hm-btn:disabled { opacity: 0.6; cursor: default; }
.hm-btn svg { width: 18px; height: 18px; flex: none; }
.hm-btn-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-btn.small { padding: 4px 13px; font-size: 0.95rem; }
.hm-langs { display: flex; gap: 4px; }
.hm-tab {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; cursor: pointer; border-radius: 4px;
  font: 600 0.92rem "Vollkorn", serif; color: #f3d9a0; background: rgba(0, 0, 0, 0.28); border: 1px solid rgba(255, 220, 160, 0.3);
}
.hm-tab svg { width: 15px; height: 15px; }
.hm-tab:hover { color: #fff3d0; border-color: rgba(255, 220, 160, 0.6); }
.hm-tab.on { color: #2b1604; background: linear-gradient(#f6d77e, #c9962f); border-color: #3b2006; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4); }

/* two columns: the book and the side boxes */
.hm-cols { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; margin-top: 18px; align-items: start; }
.hm-book {
  position: relative; padding: 30px 38px 36px; background: var(--hm-parchment); border: 2px solid var(--hm-edge); border-radius: 3px;
  box-shadow: inset 0 0 70px rgba(130, 80, 25, 0.4), 0 10px 26px rgba(0, 0, 0, 0.55);
}
.hm-book::before { content: ""; position: absolute; inset: 9px; border: 3px double rgba(90, 58, 30, 0.5); pointer-events: none; }
.hm-foreword { margin: 0; font-size: 1.06rem; line-height: 1.55; }
.hm-foreword::first-letter { float: left; font: 400 3.1em / 0.8 "Amarante", serif; margin: 5px 6px 0 0; color: var(--hm-red); text-shadow: 1px 1px 0 rgba(60, 30, 10, 0.25); }
.hm-chapter { margin: 22px 0 4px; padding-bottom: 6px; border-bottom: 2px solid rgba(125, 36, 24, 0.55); box-shadow: 0 3px 0 -1px rgba(125, 36, 24, 0.25); }
.hm-chapter h2 { margin: 0; font: 400 clamp(1.7rem, 4vw, 2.1rem) / 1.1 "Amarante", serif; color: var(--hm-red); }

.hm-world { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 20px; padding: 14px 0; border-bottom: 1px dashed rgba(90, 58, 30, 0.45); }
.hm-world:last-child { border-bottom: 0; }
.hm-world-pic {
  align-self: start; aspect-ratio: 4 / 3; width: 100%; padding: 0; cursor: pointer; background: #1a0f08 center / cover no-repeat;
  border: 6px solid #fbf3e0; outline: 1px solid #5a3a1e; box-shadow: 2px 4px 9px rgba(0, 0, 0, 0.45);
  transform: rotate(-1.4deg); transition: transform 0.25s;
}
.hm-world:nth-child(even) .hm-world-pic { transform: rotate(1.2deg); }
.hm-world .hm-world-pic:hover { transform: rotate(0) scale(1.03); }
.hm-world-pic.plain { background: radial-gradient(90% 110% at 30% 25%, color-mix(in oklab, var(--w-accent) 60%, #fff 25%), color-mix(in oklab, var(--w-accent) 40%, #0d0a07)); }
.hm-world-title { margin: 0; font: 400 1.9rem / 1.1 var(--w-font), serif; color: color-mix(in oklab, var(--w-accent) 80%, #2b1604); }
.hm-world-place { font-family: "Vollkorn SC", "Vollkorn", serif; font-size: 0.95rem; color: var(--hm-ink-2); }
.hm-readaloud {
  margin: 9px 0 12px; padding: 10px 14px; font-style: italic; line-height: 1.5;
  background: rgba(125, 80, 30, 0.13); border-left: 4px solid var(--hm-red); box-shadow: inset 0 0 0 1px rgba(90, 58, 30, 0.22);
}

.hm-rules { counter-reset: hm-rule; list-style: none; margin: 0; padding: 0; columns: 2 260px; column-gap: 30px; }
.hm-rules li { counter-increment: hm-rule; break-inside: avoid; position: relative; margin: 0 0 12px; padding-left: 34px; line-height: 1.55; }
.hm-rules li::before {
  content: counter(hm-rule); position: absolute; left: 0; top: 1px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%;
  font: 400 0.95rem "Amarante", serif; color: #f7e2b0; background: radial-gradient(circle at 35% 30%, #a8412c, #6a1a0f); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.hm-rules b { color: var(--hm-red); }
.hm-sidebar-box { margin-top: 10px; padding: 10px 16px 12px; border: 2px solid #5a3a1e; background: rgba(90, 58, 30, 0.1); box-shadow: 3px 3px 0 rgba(90, 58, 30, 0.35); }
.hm-sidebar-title { font-family: "Vollkorn SC", "Vollkorn", serif; font-weight: 600; font-size: 1.08rem; letter-spacing: 0.06em; color: var(--hm-red); padding-bottom: 4px; margin-bottom: 6px; border-bottom: 1px solid rgba(90, 58, 30, 0.4); }
.hm-sidebar-box p { margin: 0; line-height: 1.55; }

/* side boxes, portal style */
.hm-side { display: grid; gap: 18px; }
.hm-box { background: var(--hm-parchment); border: 2px solid var(--hm-edge); border-radius: 5px; overflow: hidden; box-shadow: inset 0 0 40px rgba(130, 80, 25, 0.3), 0 8px 20px rgba(0, 0, 0, 0.5); }
.hm-box-title {
  margin: 0; padding: 7px 12px 8px; font: 400 1.3rem / 1.2 "Amarante", serif; color: #f7e2b0; text-shadow: 0 1px 0 #000;
  background: linear-gradient(#7a2616, #4a1009); border-bottom: 2px solid var(--hm-gold); box-shadow: inset 0 1px 0 rgba(255, 210, 170, 0.3);
}
.hm-saves { list-style: none; margin: 0; padding: 4px 12px; max-height: 620px; overflow-y: auto; }
.hm-save { display: grid; grid-template-columns: 64px minmax(0, 1fr) 22px; gap: 10px; align-items: start; padding: 9px 0; border-bottom: 1px dotted rgba(90, 58, 30, 0.55); }
.hm-save:last-child { border-bottom: 0; }
.hm-save.old { opacity: 0.55; }
.hm-save-pic { width: 64px; height: 48px; overflow: hidden; background: #cdb68a; border: 2px solid #fbf3e0; outline: 1px solid #5a3a1e; box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.4); }
.hm-save-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hm-save-title {
  display: block; max-width: 100%; padding: 0; border: 0; background: none; cursor: pointer; text-align: left;
  font: 700 1rem / 1.2 "Vollkorn", serif; color: var(--hm-red); text-decoration: underline dotted; text-underline-offset: 3px;
}
.hm-save-title:hover:not(:disabled) { color: #b0301c; text-decoration-style: solid; }
.hm-save-title:disabled { cursor: default; color: var(--hm-ink); text-decoration: none; }
.hm-save-hero { font-size: 0.9rem; margin-top: 2px; }
.hm-save-meta { font-size: 0.8rem; font-style: italic; color: var(--hm-ink-2); }
.hm-save-lang { margin-left: 6px; padding: 0 5px; font: 600 0.68rem "Vollkorn", serif; font-style: normal; color: #f7e2b0; background: var(--hm-red); border-radius: 3px; vertical-align: 1px; }
.hm-save-del {
  width: 22px; height: 22px; display: grid; place-items: center; padding: 0; cursor: pointer; border-radius: 3px;
  border: 1px solid rgba(90, 58, 30, 0.5); background: rgba(255, 255, 255, 0.3); color: var(--hm-ink-2);
}
.hm-save-del svg { width: 12px; height: 12px; }
.hm-save-del:hover { background: var(--hm-red); color: #fff; }
.hm-box-empty, .hm-tip { margin: 0; padding: 10px 14px; line-height: 1.5; }
.hm-link { margin: 0 14px 12px; padding: 0; border: 0; background: none; cursor: pointer; font: 600 0.92rem "Vollkorn", serif; color: var(--hm-red); text-decoration: underline; }
.hm-foot { margin-top: 20px; text-align: center; font-size: 0.85rem; color: #d9bf8f; text-shadow: 0 1px 0 #000; }
.hm-who { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font: italic 0.92rem "Vollkorn", serif; color: #f3d9a0; }
.hm-credit { opacity: 0.85; font-size: 0.85rem; }
.menu-credit { cursor: default; font-weight: 600; border-bottom: 1px dashed color-mix(in oklab, currentColor 25%, transparent); border-radius: 0; margin-bottom: 4px; }
.menu-credit:hover { background: none; }

/* the welcome and login page (online play, closed alpha): the home page's banner, what the game is on a parchment
   page, a big login box beside it and "Request access" under it; /request swaps the columns for one form */
.lg-wrap { max-width: 1040px; }
.lg-banner { height: 230px; }
.lg-alpha {
  padding: 3px 11px; border-radius: 4px; font: 600 0.88rem "Vollkorn SC", "Vollkorn", serif; letter-spacing: 0.05em;
  color: #2b1604; background: linear-gradient(#f6d77e, #c9962f); border: 1px solid #3b2006;
}
.lg-cols { display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "intro side"; gap: 18px; margin-top: 18px; align-items: start; }
.lg-cols[hidden], .lg-req[hidden] { display: none; }
.lg-side { grid-area: side; display: grid; gap: 18px; }
.lg-intro { grid-area: intro; }
.lg-intro .hm-chapter { margin-top: 0; }
.lg-lead { margin-top: 12px; }
.lg-points { columns: 1; margin-top: 18px; }
.lg-worlds { list-style: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 6px 0 18px; padding: 0; }
.lg-worlds li { display: grid; gap: 5px; text-align: center; font: 600 0.88rem "Vollkorn SC", "Vollkorn", serif; color: var(--hm-ink-2); }
.lg-world-pic {
  aspect-ratio: 4 / 3; background: #1a0f08 center 45% / cover no-repeat;
  border: 4px solid #fbf3e0; outline: 1px solid #5a3a1e; box-shadow: 1px 3px 6px rgba(0, 0, 0, 0.4); transform: rotate(-1.5deg);
}
.lg-worlds li:nth-child(even) .lg-world-pic { transform: rotate(1.3deg); }
.lg-alpha-box { margin-top: 0; }
.lg-form { display: grid; gap: 14px; padding: 18px 22px 20px; }
.lg-box { border-color: #3b2006; box-shadow: 0 0 0 3px rgba(201, 150, 47, 0.55), inset 0 0 40px rgba(130, 80, 25, 0.3), 0 10px 26px rgba(0, 0, 0, 0.6); }
.lg-box .hm-box-title { font-size: 1.55rem; padding: 10px 16px 11px; }
.lg-field { display: grid; gap: 4px; font: 600 1rem "Vollkorn SC", "Vollkorn", serif; color: var(--hm-ink-2); }
.lg-field input, .lg-field textarea {
  font: 1.1rem "Vollkorn", Georgia, serif; color: var(--hm-ink); padding: 9px 11px; border-radius: 4px; min-width: 0;
  border: 2px solid #5a3a1e; background: rgba(255, 250, 235, 0.85); box-shadow: inset 0 2px 4px rgba(90, 58, 30, 0.25);
}
.lg-field textarea { resize: vertical; min-height: 4.5em; }
.lg-field ::placeholder { color: #9a7c5a; font-style: italic; }
.lg-field input:focus, .lg-field textarea:focus { outline: 2px solid var(--hm-gold); outline-offset: 1px; }
.lg-go { justify-content: center; width: 100%; padding: 11px 16px; font-size: 1.2rem; }
.lg-ask .hm-tip { padding-bottom: 4px; }
.lg-ask-go { margin: 6px 14px 14px; text-decoration: none; }
.lg-error { margin: 0; padding: 8px 12px; color: #fff3e6; background: var(--hm-red); border-radius: 4px; line-height: 1.4; }
.lg-note { margin: 0; font-style: italic; font-size: 0.92rem; color: var(--hm-ink-2); }
.lg-req { max-width: 620px; margin: 18px auto 0; }
.lg-lead-small { margin: 0; line-height: 1.55; }
.lg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.lg-back { justify-self: start; margin: 0; }
.lg-done-title { margin: 0; font: 400 1.8rem / 1.1 "Amarante", serif; color: var(--hm-red); }
#req-done p { margin: 0; line-height: 1.55; }
.lg-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

@media (max-width: 760px) {
  .hm { padding-inline: 10px; }
  .hm-cols { grid-template-columns: 1fr; }
  .hm-banner { height: 250px; }
  .hm-plaque { padding: 10px 18px 12px; max-width: calc(100% - 40px); }
  .hm-tagline { font-size: 0.95rem; }
  .hm-slidebar { right: 22px; bottom: 20px; }
  .hm-caption { display: none; }
  .hm-bar-gap { flex-basis: 100%; height: 0; }
  .hm-book { padding: 22px 20px 26px; }
  .hm-world { grid-template-columns: 1fr; gap: 12px; }
  .hm-world-pic { aspect-ratio: 16 / 7; }
  /* the login box first: most visitors already have an account */
  .lg-cols { grid-template-columns: minmax(0, 1fr); grid-template-areas: "side" "intro"; }
  .lg-banner { height: 190px; }
  .lg-worlds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .login .hm-bar-gap { flex-basis: auto; height: auto; }
}

/* -- the new-adventure wizard, dressed like the home page (the same for every world; the skin comes with the game) --
   A shorter banner with the chosen world's painting (all of them side by side until one is picked), the glossy bar with
   the steps and languages, and one parchment page: world cards as pinned photos with read-aloud blurbs, class cards
   with a red ribbon title, the story deal and the hero's sheet as sidebar boxes. */
.wz-banner { height: 220px; }
.wz-strip { display: flex; }
.wz-strip-pic { flex: 1; background: center 45% / cover no-repeat; animation: hm-drift 18s ease-out both; }
.wz-strip-pic + .wz-strip-pic { border-left: 2px solid var(--hm-edge); }
.wz-kicker { font: 600 0.95rem "Vollkorn SC", "Vollkorn", serif; letter-spacing: 0.12em; color: var(--hm-ink-2); }
.wz-title { font-size: clamp(2.2rem, 6vw, 3.4rem); }
.wz-world { margin-top: 4px; font: 400 1.35rem / 1.1 var(--w-font), serif; color: color-mix(in oklab, var(--w-accent) 80%, #2b1604); }
.wz-steps { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
.wz-steps .hm-tab { cursor: default; }
.wz-steps .hm-tab:not(.on):hover { color: #f3d9a0; border-color: rgba(255, 220, 160, 0.3); }
.wz-steps .n { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; font: 400 0.78rem "Amarante", serif; color: #f3d9a0; background: rgba(0, 0, 0, 0.4); }
.wz-steps .on .n { color: #f7e2b0; background: radial-gradient(circle at 35% 30%, #a8412c, #6a1a0f); text-shadow: none; }
.wz-steps .done .n { color: #f7e2b0; background: radial-gradient(circle at 35% 30%, #6f8f3a, #33501a); }
.hm-btn.big { padding: 9px 22px; font-size: 1.12rem; }

.wz-book { margin-top: 18px; }
.wz-body { display: grid; gap: 22px; }
.wz-foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 26px; padding-top: 16px; border-top: 2px solid rgba(125, 36, 24, 0.55); }
.wz-error { min-height: 1.2em; font-weight: 700; font-style: italic; color: var(--hm-red); }
.wz-nav { display: flex; gap: 10px; margin-left: auto; }

.world-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px 20px; }
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px 20px; }
.world-card, .class-card {
  position: relative; display: flex; flex-direction: column; padding: 0; text-align: left; cursor: pointer;
  font: inherit; color: var(--hm-ink); background: rgba(255, 248, 230, 0.45); border: 2px solid #5a3a1e; border-radius: 3px;
  box-shadow: 3px 3px 0 rgba(90, 58, 30, 0.35); transition: transform 0.2s, box-shadow 0.2s;
}
.world-card:hover, .class-card:hover { transform: translateY(-2px); box-shadow: 4px 6px 0 rgba(90, 58, 30, 0.4); }
.world-card.selected, .class-card.selected { border-color: var(--hm-red); background: rgba(255, 244, 214, 0.85); box-shadow: 0 0 0 3px var(--hm-gold), 0 0 16px rgba(201, 150, 47, 0.8); }
/* the pick: a red wax seal with a tick */
.world-card.selected::after, .class-card.selected::after {
  content: "✓"; position: absolute; z-index: 2; top: -13px; right: -11px; width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 50%; font: 700 1.15rem "Vollkorn", serif; color: #f7e2b0; transform: rotate(-8deg);
  background: radial-gradient(circle at 35% 30%, #b8452e, #6a1a0f 72%); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45), inset 0 0 0 3px rgba(0, 0, 0, 0.15);
}
.wc-art {
  margin: 12px 12px 0; aspect-ratio: 16 / 9; overflow: hidden; background: #1a0f08 center / cover no-repeat;
  border: 5px solid #fbf3e0; outline: 1px solid #5a3a1e; box-shadow: 2px 3px 7px rgba(0, 0, 0, 0.4); transform: rotate(-1deg);
}
.world-card:nth-child(even) .wc-art { transform: rotate(1deg); }
.wc-art svg { display: block; width: 100%; height: 100%; }
.wc-text { display: grid; gap: 3px; padding: 12px 14px 14px; }
.wc-title { font: 400 1.7rem / 1.1 var(--card-font, "Amarante"), serif; color: color-mix(in oklab, var(--card-accent) 80%, #2b1604); }
.wc-place { font-family: "Vollkorn SC", "Vollkorn", serif; font-size: 0.95rem; color: var(--hm-ink-2); }
.wc-blurb { margin: 6px 0 8px; padding: 8px 11px; font-style: italic; line-height: 1.45; background: rgba(125, 80, 30, 0.13); border-left: 4px solid var(--hm-red); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.wizard .tag { padding: 1px 7px; font: 600 0.76rem "Vollkorn SC", "Vollkorn", serif; color: #f7e2b0; background: #6b4a2a; border: 0; border-radius: 2px; }

/* the story deal: a fresh deal or a classic, as boxes with a red radio */
.deal-box { display: grid; gap: 12px; }
.deal-opt {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 16px 12px; cursor: pointer;
  border: 2px solid #5a3a1e; background: rgba(90, 58, 30, 0.1); box-shadow: 3px 3px 0 rgba(90, 58, 30, 0.35);
}
.deal-opt.on { border-color: var(--hm-red); background: rgba(255, 244, 214, 0.85); box-shadow: 0 0 0 3px var(--hm-gold), 0 0 12px rgba(201, 150, 47, 0.7); }
.deal-radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #5a3a1e; background: #fbf3e0; }
.deal-opt.on .deal-radio { background: radial-gradient(circle, var(--hm-red) 0 5px, #fbf3e0 6px); }
.deal-kicker { font: 600 1.08rem "Vollkorn SC", "Vollkorn", serif; letter-spacing: 0.04em; color: var(--hm-red); }
.deal-teaser { margin: 2px 0 0; font-style: italic; line-height: 1.5; }

/* class cards */
.cc-name { padding: 6px 12px 7px; font: 400 1.45rem / 1.15 "Amarante", serif; color: #f7e2b0; text-shadow: 0 1px 0 #000; background: linear-gradient(#7a2616, #4a1009); border-bottom: 2px solid var(--hm-gold); }
.class-card > :not(.cc-name) { margin-inline: 14px; }
.cc-blurb { margin-block: 10px 0; font-style: italic; line-height: 1.45; }
.cc-abil { display: grid; gap: 4px; margin-top: 10px; }
.cc-row { display: grid; grid-template-columns: 80px 1fr 26px; gap: 8px; align-items: center; font-size: 0.92rem; }
.cc-n { font-family: "Vollkorn SC", "Vollkorn", serif; color: var(--hm-ink-2); }
.cc-bar { display: flex; gap: 3px; }
.cc-bar i { flex: 1; height: 9px; border-radius: 2px; background: rgba(90, 58, 30, 0.2); box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.2); }
.cc-bar i.on { background: linear-gradient(#b8452e, #6a1a0f); }
.cc-v { text-align: right; font-weight: 700; }
.cc-hp { display: flex; align-items: center; gap: 5px; margin-top: 10px; font-weight: 700; }
.cc-hp svg { width: 17px; height: 17px; color: #b0301c; }
.cc-hp .cc-gold { margin-left: 10px; }
.cc-hp .cc-gold svg { color: #b98a2e; }
.cc-knack { display: grid; grid-template-columns: 16px 1fr; gap: 6px; margin-top: 10px; padding: 8px 10px; line-height: 1.4; background: rgba(125, 80, 30, 0.13); border-left: 4px solid var(--hm-gold); }
.cc-knack svg { width: 14px; height: 14px; margin-top: 3px; color: #b98a2e; }
/* skills (the skills branch): chips on class and profession cards, the requirement, the draft's longer story */
.cc-skills { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.sk-chip { padding: 2px 9px; font: 600 0.88rem "Vollkorn", serif; color: #3b2612; background: rgba(125, 80, 30, 0.13); border-left: 3px solid var(--hm-gold); }
.sk-chip.pick { font-style: italic; }
.cc-req { margin-top: 6px; font-size: 0.85rem; font-style: italic; color: var(--hm-ink-2); }
.cc-req.unmet { color: var(--hm-red); font-weight: 600; }
.cc-story { margin: 4px 0 0; padding: 12px 16px; line-height: 1.5; font-style: italic; color: var(--hm-ink); background: rgba(255, 248, 230, 0.55); border-left: 4px solid var(--hm-gold); }
/* the hero panel's skills: name, tier as three pips */
.knacks.skills li { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sk-pips { display: inline-flex; gap: 3px; }
.sk-pips i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid currentColor; opacity: 0.55; }
.sk-pips i.on { background: currentColor; opacity: 1; }
.tray-chip.untrained { opacity: 0.7; font-style: italic; }
/* the level up with skills: ability chips, three skill cards */
.sk-pick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.sk-pick-grid .lvl-skill { background: rgba(255, 251, 240, 0.75); border-color: #5a3a1e; color: var(--hm-ink); }
.sk-pick-grid .lvl-skill.on { border-color: var(--hm-red); box-shadow: 0 0 0 2px var(--hm-red) inset; }
.lvl-label { margin-top: 6px; font-weight: 700; color: inherit; }
.lvl-picks { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.lvl-skills { display: grid; gap: 6px; margin-top: 4px; }
.lvl-skill { display: grid; gap: 2px; text-align: left; padding: 8px 12px; cursor: pointer; font: inherit; color: inherit; background: var(--card, #fbf3e0); border: 2px solid var(--line, #5a3a1e); border-radius: 4px; }
.lvl-skill.on { border-color: var(--accent, #a8412c); box-shadow: 0 0 0 2px var(--accent, #a8412c) inset; }
.lvl-skill span { font-size: 0.9rem; opacity: 0.85; }
.lvl-tier { font-weight: 400; font-size: 0.85rem; opacity: 0.75; }
.cc-gear { margin-top: auto; padding: 10px 0 12px; font-size: 0.88rem; font-style: italic; color: var(--hm-ink-2); }

/* the full hero: quick or full, origins, professions, bought abilities, traits */
.wz-mode { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.wz-mode .deal-opt { grid-template-columns: auto minmax(0, 1fr); }

/* classic or cinematic: a box each, with a screenshot of that layout (web/img/layouts) */
.lp-box { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.lp-box .lp-opt { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 10px 10px 12px; }
.lp-label { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; padding: 0 6px; }
.lp-shot { display: block; width: 100%; aspect-ratio: 1920 / 945; object-fit: cover; background: #3b2716; border: 2px solid #2a1a0d; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.pick {
  display: grid; gap: 2px; padding: 8px 12px 10px; text-align: left; cursor: pointer; font: inherit; color: var(--hm-ink);
  background: rgba(255, 248, 230, 0.45); border: 2px solid #5a3a1e; border-radius: 3px; box-shadow: 2px 2px 0 rgba(90, 58, 30, 0.3);
}
.pick b { font: 600 1.08rem "Vollkorn SC", "Vollkorn", serif; color: var(--hm-red); }
.pick span { font-size: 0.86rem; font-style: italic; line-height: 1.35; color: var(--hm-ink-2); }
.pick.on { border-color: var(--hm-red); background: rgba(255, 244, 214, 0.85); box-shadow: 0 0 0 3px var(--hm-gold); }
.job-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.job-grid .cc-name { font-size: 1.25rem; }
.ab-presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ab-presets .hm-btn.on { outline: 2px solid var(--accent, #8a3b1e); outline-offset: 1px; font-weight: 700; }
.ab-buy { display: grid; gap: 6px; max-width: 420px; }
.ab-row { grid-template-columns: 90px auto 1fr 28px auto; }
.ab-row .hm-btn { min-width: 32px; padding-inline: 8px; }
.ab-left { color: var(--hm-red); font-weight: 700; }
.trait-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.trait {
  padding: 3px 11px; cursor: pointer; font: 600 0.95rem "Vollkorn", serif; color: var(--hm-ink);
  background: #fbf3e0; border: 1px solid #5a3a1e; border-radius: 2px;
}
.trait.on { color: #f7e2b0; background: linear-gradient(#a8412c, #6a1a0f); border-color: #4a1009; }

/* the hero */
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field { display: grid; gap: 5px; }
.field-label { font: 600 1.05rem "Vollkorn SC", "Vollkorn", serif; color: var(--hm-red); }
.field-hint { font-size: 0.88rem; font-style: italic; color: var(--hm-ink-2); }
.field input, .field select, .field textarea, .with-btn input {
  width: 100%; box-sizing: border-box; padding: 9px 12px; font: 1.08rem "Vollkorn", Georgia, serif; color: var(--hm-ink);
  background: rgba(255, 251, 240, 0.75); border: 1px solid #5a3a1e; border-radius: 2px; box-shadow: inset 0 1px 3px rgba(90, 58, 30, 0.35);
}
.field textarea { resize: vertical; line-height: 1.4; }
.field input::placeholder, .field textarea::placeholder, .with-btn input::placeholder { color: #9a7d5c; font-style: italic; }
.field input:focus, .field select:focus, .with-btn input:focus { outline: 2px solid var(--hm-gold); outline-offset: 1px; }
.with-btn { display: flex; gap: 8px; align-items: center; }
/* reading aloud in the wizard: the voice, then speed and auto-read once a voice is picked */
.wz-voice { display: grid; gap: 8px; }
.wz-voice .wv-extras { display: grid; gap: 6px; padding-left: 4px; }
.wz-voice .wv-extras[hidden] { display: none; }
.wz-voice .wv-line { display: flex; align-items: center; gap: 10px; font: 1rem "Vollkorn", Georgia, serif; color: var(--hm-ink); }
.field .wz-voice .wv-line input { width: auto; padding: 0; box-shadow: none; background: none; border: 0; accent-color: var(--hm-red); }
.field .wz-voice .wv-line input[type="range"] { flex: 1; max-width: 260px; }
.field .wz-voice .wv-line input[type="checkbox"] { width: 16px; height: 16px; }
.wz-voice .wv-rate { min-width: 3.2em; font-variant-numeric: tabular-nums; }
.with-btn .hm-btn { flex: none; }
/* man or woman, joined into one switch before the name */
.wz-sex { display: flex; flex: none; align-self: stretch; }
.wz-sex .trait { padding: 0 12px; }
.wz-sex .trait + .trait { border-left: 0; }
@media (max-width: 520px) { .with-btn:has(.wz-sex) { flex-wrap: wrap; } .wz-sex { order: -1; } }
.summary { padding: 16px 18px 18px; text-align: center; border: 3px double #5a3a1e; background: rgba(255, 248, 230, 0.5); box-shadow: 3px 3px 0 rgba(90, 58, 30, 0.35); }
.sum-name { font: 400 2.3rem / 1.1 "Amarante", serif; color: var(--hm-red); }
.sum-line { margin: 2px 0 10px; font-family: "Vollkorn SC", "Vollkorn", serif; color: var(--hm-ink-2); }
.sum-stats { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.sum-chip { padding: 2px 10px; font-weight: 600; font-size: 0.92rem; border: 1px solid #5a3a1e; border-radius: 2px; background: #fbf3e0; }
.sum-chip.hp { background: #f3c9bd; color: #6a1a0f; }
.sum-chip.gold { background: #f3dc9a; color: #5a3c10; }

@media (max-width: 760px) {
  .wz-banner { height: 190px; }
  .wz-banner .hm-plaque { padding: 8px 16px 10px; }
  .wz-kicker { display: none; }
  .wz-title { font-size: 2rem; }
  .wz-world { font-size: 1rem; }
  .wz-nav { width: 100%; justify-content: flex-end; }
}
/* -- the host watching a player's game, read-only (/?watch=NAME): a strip at the bottom, nothing to play ------- */
#watch-bar {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px);
  padding: 8px 10px 8px 14px; border-radius: 999px;
  background: rgba(20, 16, 12, .88); color: #f4ead8; font: 600 14px/1.3 system-ui, sans-serif;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
}
#watch-bar svg { width: 18px; height: 18px; flex: none; }
#watch-bar .btn { color: inherit; border-color: rgba(255, 255, 255, .35); }
body.watching .choices { pointer-events: none; }
body.watching .fb-dots, body.watching .speak-btn, body.watching .rc-go, body.watching .levelup,
body.watching #composer, body.watching #move-note { display: none !important; }
body.watching #stage { padding-bottom: 60px; }
.watch-list { display: grid; gap: 14px; max-height: 65vh; overflow: auto; }
.watch-player h3 { margin: 0 0 6px; display: flex; gap: 8px; align-items: center; }
.watch-games { display: grid; gap: 4px; }
.watch-game { display: flex; flex-direction: column; padding: 6px 10px; border-radius: 6px; text-decoration: none; color: inherit;
  border: 1px solid rgba(0, 0, 0, .12); }
.watch-game:hover { background: rgba(0, 0, 0, .05); }
.watch-game.current { outline: 2px solid var(--accent); }
.watch-meta { font-size: .85em; opacity: .75; }
