:root {
  --bg: #14110d;
  --paper: #f3ecda;
  --ink: #1a1a1a;
  --blood: #c8443f;
  --gold: #d4af37;
  --bone: #e8dcc0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--bone);
  font-family: Georgia, "Times New Roman", serif;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

.frame {
  position: relative;
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 14px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.frame__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 0 4px;
}
/* Shift the kicker + title past the fixed-position brand badge at the
   top-left so they don't visually collide. The badge is ~120px wide; a
   140px left bump on the title block gives the chapter / boss name
   breathing room while keeping the controls list anchored to the right. */
.frame__head > div:first-child {
  padding-left: 140px;
}

.kicker {
  font-size: 11px;
  letter-spacing: 4px;
  opacity: 0.6;
  text-transform: uppercase;
  /* Faint gold so the chapter label reads as the engraved page header
     rather than a plain caption. Same hue as the modal corner glyphs and
     resume CTA — the whole UI shares one firelight palette. */
  color: rgba(212, 175, 55, 0.62);
}

.title {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: normal;
  font-size: 22px;
  margin-top: 2px;
  /* Subtle warm glow + crisp shadow stack — matches the intro-text engraving
     treatment so when a boss room loads, the title and intro line read as
     two lines from the same epitaph. */
  text-shadow:
    0 0 14px rgba(255, 200, 120, 0.16),
    0 1px 1px rgba(0, 0, 0, 0.85);
  letter-spacing: 1px;
}

.controls {
  text-align: right;
  font-family: Georgia, serif;
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: 0.5px;
  /* Slight cream tint instead of full opacity:0.7 so the controls list
     reads as inscribed marginalia (kbd keys carry the firelight tint
     already; the body copy is a quieter cream). */
  color: rgba(232, 220, 192, 0.62);
  opacity: 1;
}

kbd {
  font-family: inherit;
  font-style: italic;
  letter-spacing: 1px;
  /* Faint gold dotted underline — same firelight tint as kicker / intro
     rules, distinguishes the input keys from regular flavor copy without
     adding a heavy boxed kbd look. */
  border-bottom: 1px dotted rgba(212, 175, 55, 0.5);
  color: rgba(232, 220, 192, 0.92);
  padding-bottom: 1px;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0 4px;
}

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar__label {
  width: 130px;
  font-family: Georgia, serif;
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  opacity: 0.7;
  /* Faint warm halo on the stat name (VITAE / INK / REMAINING) so it
     reads as an engraved heading on the ledger row rather than a plain
     uppercase label. Same firelight palette as the dev-panel chapter
     dividers and quickjump titles. */
  color: rgba(212, 175, 55, 0.55);
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.10);
}

.bar--reverse .bar__label {
  text-align: right;
  /* Boss bar — distinguish from VITAE/INK by making the boss name read as
     an engraved title rather than a stat label. Italic Georgia, gold tint,
     subtle warm halo. Same firelight palette as the kicker, intro, and
     menu corner glyphs. */
  font-family: Georgia, serif;
  font-style: italic;
  text-transform: none;
  font-size: 12px;
  letter-spacing: 2px;
  color: rgba(212, 175, 55, 0.78);
  text-shadow: 0 0 10px rgba(255, 200, 120, 0.18);
  opacity: 0.85;
}

.bar__track {
  flex: 1;
  position: relative;
  height: 12px;
  background: rgba(232, 220, 192, 0.07);
  border: 1px solid rgba(232, 220, 192, 0.18);
  /* Subtle inner shadow at the top so the empty channel reads as recessed
     paper rather than a flat line — matches how a wax-stamped ledger has a
     dark underside catching the lit page above. */
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.bar__track--thin {
  height: 6px;
}

.bar__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  transition: width 0.18s linear;
  /* Subtle vertical gradient + 1px inset highlight at the top so the fill
     reads as a stained pour with depth, not flat poster paint. The highlight
     uses a faint warm white so all three colours (blood / gold / ink) pick
     up the same firelight glaze. */
  background-image: linear-gradient(
    to bottom,
    rgba(255, 240, 200, 0.18) 0,
    rgba(255, 240, 200, 0.04) 20%,
    rgba(0, 0, 0, 0.18) 100%
  );
  background-blend-mode: screen, normal;
  box-shadow: inset 0 1px 0 rgba(255, 240, 200, 0.22);
}

.bar--reverse .bar__fill {
  left: auto;
  right: 0;
}

.bar__fill--blood { background-color: var(--blood); }
.bar__fill--gold  { background-color: var(--gold); }
.bar__fill--ink   { background-color: var(--ink); }

/* Stamina-out flash — JS toggles .stamina-out for ~280 ms when an action
   fails because of stamina. The pulse turns the stamina bar red and shakes
   the bar wrapper a few px so the player notices the cause of the no-op. */
@keyframes stamina-out-flash {
  0%   { filter: brightness(1) saturate(1) drop-shadow(0 0 0 transparent); transform: translateX(0); }
  18%  { filter: brightness(1.2) saturate(1.4) drop-shadow(0 0 8px rgba(232,68,40,0.95)); transform: translateX(-3px); }
  42%  { filter: brightness(1.1) saturate(1.2) drop-shadow(0 0 6px rgba(232,68,40,0.7)); transform: translateX(2px); }
  100% { filter: brightness(1) saturate(1) drop-shadow(0 0 0 transparent); transform: translateX(0); }
}
.stamina-out .bar__fill--gold { background: #c8443f !important; }
.stamina-out { animation: stamina-out-flash 0.32s ease-out; }

.bar__segs {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bar__segs span {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(20, 17, 13, 0.7);
}

.bar__num {
  width: 40px;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 11px;
  letter-spacing: 1px;
  opacity: 0.7;
  text-align: right;
  /* Same inked-margin treatment as the settings value readouts — bar
     counts (5/5, 100, 8/8) read as ledger entries in the firelight
     palette rather than plain numeric tags. */
  color: rgba(212, 175, 55, 0.65);
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.12);
}

.stage {
  /* Width + height are set imperatively from JS (sizeStageToAspect) so the
     "canvas aspect" slider actually drives both dimensions. We keep
     width: 100vw / margin: -18px as fallbacks for the very first frame
     before applySettings runs, but JS overrides via inline style after. */
  position: relative;
  flex: 0 0 auto;
  width: 100vw;
  margin-left: -18px;
  margin-right: -18px;
  min-height: 0;
  background: #14110d;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  align-self: center;
}
/* Soft vignette around the stage. Pulls the eye toward the center of the
   action and gives the page a heavier, dark-souls atmosphere — the periphery
   recedes into shadow even when the level paper is bright. Sits above the
   canvas via z-index but below modals/dev panel; pointer-events:none so it
   never intercepts clicks on the canvas underneath. */
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background:
    radial-gradient(
      ellipse 78% 70% at 50% 52%,
      rgba(0, 0, 0, 0) 55%,
      rgba(0, 0, 0, 0.32) 82%,
      rgba(0, 0, 0, 0.62) 100%
    );
  mix-blend-mode: multiply;
}
/* Subtle paper-grain overlay drawn from an inline SVG fractalNoise filter.
   `mix-blend-mode: overlay` at very low opacity tints highlights warmer and
   shadows slightly darker without flattening contrast — gives the rendered
   3D scene a film-grain / paper-fiber feel without GPU post-processing.
   Sits above the canvas + vignette but pointer-events:none. */
/* Custom scrollbar styling — applies to dev-panel, modals with overflowing
   content, and any other scrollable surface. WebKit-based browsers honor
   ::-webkit-scrollbar; Firefox falls back to scrollbar-width / color but
   renders thinner natively. The thin gold thumb on a dark track matches
   the firelight palette without drawing as much attention as the default
   chrome. */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 55, 0.45) rgba(8, 6, 4, 0.6);
}
*::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
*::-webkit-scrollbar-track {
  background: rgba(8, 6, 4, 0.6);
  border-radius: 3px;
}
*::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom,
    rgba(212, 175, 55, 0.55),
    rgba(212, 175, 55, 0.30));
  border-radius: 3px;
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(to bottom,
    rgba(212, 175, 55, 0.85),
    rgba(212, 175, 55, 0.50));
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0.10;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1   0 0 0 0 0.94   0 0 0 0 0.78   0 0 0 0.55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.dev-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 10px 12px;
  background: rgba(20, 17, 13, 0.78);
  border: 1px solid rgba(232, 220, 192, 0.18);
  font-size: 11px;
  letter-spacing: 1px;
  width: 140px;
  z-index: 5;
  pointer-events: auto;
  overflow-y: auto;
}

.dev-panel__title {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  /* Faint gold so the dev-panel section headers (campaign / margins / trials
     / vegetation / crease shapes / character / paper / debug) read as
     chapter dividers in a paper folio rather than plain category labels.
     Same hue family as the kicker, brand badge, and modal corner glyphs. */
  color: rgba(212, 175, 55, 0.58);
  margin-top: 8px;
  margin-bottom: 3px;
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.10);
}
.dev-panel__title:first-child { margin-top: 0; }

.dev-panel button {
  background: rgba(232, 220, 192, 0.05);
  border: 1px solid rgba(232, 220, 192, 0.18);
  color: var(--bone);
  font-family: Georgia, serif;
  font-size: 11px;
  padding: 4px 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}

.dev-panel button:hover {
  background: rgba(232, 220, 192, 0.12);
  border-color: rgba(232, 220, 192, 0.32);
}

.dev-panel button.active {
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.6);
  color: var(--gold);
}

.dev-panel button.locked {
  color: rgba(232, 220, 192, 0.32);
  font-style: italic;
}

.dev-panel button.locked::before {
  content: "🔒 ";
  font-size: 9px;
  margin-right: 2px;
  font-style: normal;
}

.intro-text {
  position: absolute;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  color: rgba(232, 220, 192, 0.92);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 18px;
  letter-spacing: 1.5px;
  pointer-events: none;
  /* Warm amber inner glow + cool deep shadow — pushes the line forward like
     candlelight is hitting the engraved letters from below while the page
     behind stays in shadow. The two-layer text-shadow stacks an outer halo
     (broad, soft) on top of a tight cooler shadow (crisper edge). */
  text-shadow:
    0 0 18px rgba(255, 200, 120, 0.18),
    0 1px 1px rgba(0, 0, 0, 0.85),
    0 0 24px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transform-origin: 50% 50%;
  transition: opacity 0.6s ease, transform 0.6s ease;
  z-index: 4;
  text-align: center;
  /* Thin gold rule above + below the line — like the engraved frame around
     a Souls-game opening epitaph. Done with linear-gradient borders so
     they fade at the ends rather than terminating in hard caps. */
  padding: 14px 28px;
  border-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(212, 175, 55, 0) 8%,
    rgba(212, 175, 55, 0.55) 50%,
    rgba(212, 175, 55, 0) 92%,
    transparent 100%
  ) 1;
  border-style: solid;
  border-width: 1px 0;
  max-width: 680px;
}

.intro-text.show {
  opacity: 1;
  /* Gentle scale-up so the line settles in instead of just fading. */
  transform: translateX(-50%) scale(1);
}

.intro-text:not(.show) {
  transform: translateX(-50%) scale(0.985);
}

/* ----- ad space (left margin button) ----- */
.ad-space {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 96px;
  background: linear-gradient(160deg,
    rgba(212, 175, 55, 0.18) 0%,
    rgba(120, 90, 30, 0.12) 60%,
    rgba(40, 28, 12, 0.0) 100%);
  border: 1px dashed rgba(212, 175, 55, 0.55);
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  cursor: pointer;
  font-family: Georgia, serif;
  color: var(--bone);
  z-index: 6;
  transition: transform 0.18s, border-color 0.18s, background 0.18s;
}
.ad-space:hover {
  transform: translateY(-50%) scale(1.04);
  border-color: rgba(212, 175, 55, 0.95);
  background: linear-gradient(160deg,
    rgba(212, 175, 55, 0.30) 0%,
    rgba(120, 90, 30, 0.18) 60%,
    rgba(40, 28, 12, 0.0) 100%);
}
.ad-space__kicker {
  font-size: 8.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(232, 220, 192, 0.55);
}
.ad-space__title {
  font-style: italic;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 1.5px;
  text-align: center;
  line-height: 1.15;
}
.ad-space__price {
  font-size: 10px;
  color: rgba(232, 220, 192, 0.7);
  letter-spacing: 1px;
}
.ad-space__cta {
  font-size: 8.5px;
  font-style: italic;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(212, 175, 55, 0.85);
  margin-top: 4px;
}

/* ----- ad modal ----- */
.ad-modal {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 4, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  font-family: Georgia, serif;
  pointer-events: auto;
  padding: 14px;
}
.ad-modal.open {
  display: flex;
}
.ad-modal__panel {
  /* Same wax-stamp atmosphere as the menu/map modals — warm radial glow at
     the title area, chiseled inset border, drop shadow lifting the panel
     off the dimmed backdrop. The ad-purchase modal now reads as a
     contracted page rather than a generic dialog. */
  background:
    radial-gradient(ellipse 60% 35% at 50% 0%, rgba(212, 175, 55, 0.10), transparent 70%),
    linear-gradient(to bottom, rgba(20, 16, 10, 0.97), rgba(8, 6, 4, 0.97)),
    #14110d;
  border: 1px solid rgba(212, 175, 55, 0.45);
  padding: 22px 26px 18px;
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  color: var(--bone);
  position: relative;
  box-shadow:
    inset 0 0 0 1px rgba(8, 6, 4, 0.85),
    inset 0 0 24px rgba(0, 0, 0, 0.45),
    0 24px 60px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(212, 175, 55, 0.08);
}
/* Mirror the corner glyphs from the menu/map modals for visual consistency. */
.ad-modal__panel::before,
.ad-modal__panel::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
  background:
    linear-gradient(to right,  rgba(212, 175, 55, 0.85), rgba(212, 175, 55, 0)) top    / 100% 1px no-repeat,
    linear-gradient(to bottom, rgba(212, 175, 55, 0.85), rgba(212, 175, 55, 0)) left   / 1px 100% no-repeat;
}
.ad-modal__panel::before { top: -1px; left: -1px; }
.ad-modal__panel::after  { top: -1px; right: -1px; transform: scaleX(-1); }
.ad-modal__kicker {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 10px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: rgba(212, 175, 55, 0.55);
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.10);
}
.ad-modal h2 {
  margin: 4px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: normal;
  font-size: 22px;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 200, 120, 0.25);
}
.ad-modal p {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 12px;
  color: rgba(232, 220, 192, 0.78);
  line-height: 1.6;
  letter-spacing: 0.3px;
  margin: 0 0 14px;
  /* Subtle warm halo so the contract pitch reads as the same inscribed
     body-copy as the menu blurb and item lore. */
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.08);
}
.ad-modal label {
  display: block;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 10px;
  letter-spacing: 4px;
  text-transform: uppercase;
  /* Faint gold so the section labels (YOUR AD COPY / TIER / PAYMENT)
     read as folio chapter dividers — same treatment as the dev-panel
     section headers and quickjump titles. */
  color: rgba(212, 175, 55, 0.55);
  margin: 14px 0 6px;
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.10);
}
.ad-modal label span {
  text-transform: none;
  letter-spacing: 0;
  color: rgba(232, 220, 192, 0.55);
  font-style: italic;
  font-size: 10px;
}
.ad-modal input[type="text"] {
  width: 100%;
  background: rgba(232, 220, 192, 0.05);
  border: 1px solid rgba(232, 220, 192, 0.2);
  /* Inset shadow on the input track + subtle italic placeholder so the
     field reads as a recessed paper line waiting for ink. */
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.4);
  color: var(--bone);
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 13px;
  letter-spacing: 0.5px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ad-modal input[type="text"]:focus {
  border-color: rgba(212, 175, 55, 0.7);
  /* Faint warm halo on focus — same firelight cue as the menu CTA hover. */
  box-shadow:
    inset 0 1px 1px rgba(0, 0, 0, 0.4),
    0 0 14px rgba(212, 175, 55, 0.22);
}
.ad-modal input[type="text"]::placeholder {
  color: rgba(232, 220, 192, 0.32);
  font-style: italic;
}
.ad-modal input[type="text"]:disabled {
  /* Disabled = "demo mode" payment fields. Render as a faded paper line
     so it reads as deliberately-inert marginalia rather than browser-
     greyed disabled input. Lower opacity placeholder + slightly darker
     track. */
  background: rgba(232, 220, 192, 0.025);
  border-color: rgba(232, 220, 192, 0.12);
  color: rgba(232, 220, 192, 0.4);
  cursor: not-allowed;
}
.ad-tiers {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ad-tier {
  text-align: left;
  background: rgba(232, 220, 192, 0.05);
  border: 1px solid rgba(232, 220, 192, 0.18);
  color: var(--bone);
  font-family: Georgia, serif;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  transition: background 0.12s, border-color 0.12s;
}
.ad-tier strong {
  color: var(--gold);
  font-style: italic;
  font-weight: normal;
  letter-spacing: 1px;
  /* Subtle warm halo on the price so it reads as struck gold leaf rather
     than bold text. */
  text-shadow: 0 0 10px rgba(255, 200, 120, 0.20);
}
.ad-tier span {
  font-family: Georgia, serif;
  font-style: italic;
  color: rgba(232, 220, 192, 0.65);
  font-size: 11px;
  letter-spacing: 0.5px;
}
.ad-tier:hover {
  background: rgba(232, 220, 192, 0.10);
  border-color: rgba(232, 220, 192, 0.28);
}
.ad-tier.active {
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.7);
  /* Same wax-stamp affordance as items-list.active and modal panels —
     warm halo + 1px chiseled inset on the selected tier. */
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 200, 0.18),
    0 0 14px rgba(212, 175, 55, 0.22);
}
.ad-payment {
  display: grid;
  grid-template-columns: 1fr 60px 60px;
  gap: 4px;
}
.ad-modal__pay {
  margin-top: 14px;
  width: 100%;
  /* Vertical gold gradient + inset highlight so the "Pay & publish" CTA
     reads as a stamped-foil button on warm paper, matching the wax-seal
     palette. Outer drop shadow lifts it from the form below. */
  background: linear-gradient(to bottom, #e6c45c 0%, var(--gold) 50%, #b89236 100%);
  border: 0;
  color: #1c1814;
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: 14px;
  padding: 11px 14px;
  cursor: pointer;
  letter-spacing: 2px;
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 200, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.45);
  transition: filter 0.12s, box-shadow 0.12s;
}
.ad-modal__pay:hover {
  filter: brightness(1.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 200, 0.7),
    0 6px 18px rgba(212, 175, 55, 0.45);
}
.ad-modal__close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: 0;
  color: rgba(232, 220, 192, 0.7);
  font-size: 22px;
  cursor: pointer;
  font-family: Georgia, serif;
  transition: color 0.12s, text-shadow 0.12s;
}
.ad-modal__close:hover {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(212, 175, 55, 0.55);
}
.ad-modal__fineprint {
  margin: 14px 0 0;
  font-family: Georgia, serif;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: rgba(232, 220, 192, 0.45);
  font-style: italic;
  text-align: center;
  /* Subtle warm halo so the disclaimer reads as a marginal note inscribed
     under the contracted-page CTA — same firelight family as the footer
     epigraph and modal foot lines. */
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.10);
}

.ad-toast {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  /* Same warm-radial glow + chiseled border treatment as the discovery
     toast, modal panels, and brand badge — every transient page-mark
     shares the wax-seal aesthetic. */
  background:
    radial-gradient(ellipse 70% 60% at 50% 0%, rgba(212, 175, 55, 0.10), transparent 70%),
    rgba(20, 17, 13, 0.88);
  border: 1px solid rgba(212, 175, 55, 0.6);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.5),
    0 6px 18px rgba(0, 0, 0, 0.55);
  color: var(--gold);
  padding: 10px 22px;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 13px;
  letter-spacing: 1.5px;
  text-shadow: 0 0 12px rgba(255, 200, 120, 0.18);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 8;
}
.ad-toast.show { opacity: 1; }

/* ----- Sekiro-style items modal ----- */
.items-modal {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 4, 0.86);
  display: none;
  z-index: 22;
  font-family: Georgia, serif;
  pointer-events: auto;
  padding: 28px 36px;
}
.items-modal.open { display: flex; }
.items-modal__panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(212, 175, 55, 0.35);
  border-right: 1px solid rgba(212, 175, 55, 0.35);
  /* Sekiro-style open top + bottom — no top/bottom border. But add a faint
     warm spotlight near the top so the title area picks up firelight, and
     a barely-perceptible vertical gradient pulls the bottom into shadow.
     Preserves the open feel while joining the firelight palette. */
  background:
    radial-gradient(ellipse 50% 25% at 50% 0%, rgba(212, 175, 55, 0.06), transparent 75%),
    linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.18) 100%);
  padding: 0 28px;
  color: var(--bone);
  position: relative;
}
/* Tiny gold tick marks at the top of each side rail — visual cue that the
   rails extend upward into the page rather than terminating. Same gold
   corner-glyph idea as the menu/map modals, sized down so it doesn't
   clutter the open top design. */
.items-modal__panel::before,
.items-modal__panel::after {
  content: "";
  position: absolute;
  top: 0;
  width: 1px;
  height: 28px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(212, 175, 55, 0.85), rgba(212, 175, 55, 0));
}
.items-modal__panel::before { left: -1px; }
.items-modal__panel::after  { right: -1px; }
.items-modal__head {
  /* Engraved fade-rule under the header — same gold gradient pattern as
     the cube-debug face mapping divider. Replaces the flat 1px border
     so the title block + body share the same manuscript-margin language
     as every other modal section divider. */
  border-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(212, 175, 55, 0) 8%,
    rgba(212, 175, 55, 0.32) 50%,
    rgba(212, 175, 55, 0) 92%,
    transparent 100%
  ) 1;
  border-style: solid;
  border-width: 0 0 1px;
  padding: 0 0 14px;
  margin-bottom: 18px;
  position: relative;
}
.items-modal__kicker {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 10px;
  letter-spacing: 4px;
  text-transform: uppercase;
  /* Same gold-tint engraved-kicker treatment as the .kicker chapter
     header, ad-modal kicker, and dev-panel chapter dividers. */
  color: rgba(212, 175, 55, 0.55);
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.10);
}
.items-modal__head h2 {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: normal;
  font-size: 28px;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 200, 120, 0.25);
  letter-spacing: 2px;
}
.items-modal__close {
  position: absolute;
  top: -4px;
  right: 0;
  background: none;
  border: 0;
  color: rgba(232, 220, 192, 0.7);
  font-size: 22px;
  cursor: pointer;
  font-family: Georgia, serif;
  /* Subtle warm glow on hover so the close affordance reads as catching
     firelight when the cursor finds it — same hover tint family as the
     menu CTA halo. */
  transition: color 0.12s, text-shadow 0.12s;
}
.items-modal__close:hover {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(212, 175, 55, 0.55);
}
.items-modal__body {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  min-height: 0;
}
.items-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  border-right: 1px solid rgba(232, 220, 192, 0.10);
  padding-right: 16px;
}
.items-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 1px;
  transition: background 0.12s, border-color 0.12s;
}
.items-list li:hover { background: rgba(232, 220, 192, 0.06); }
.items-list li.active {
  background: rgba(212, 175, 55, 0.16);
  border-color: rgba(212, 175, 55, 0.45);
  color: var(--gold);
  /* Warm halo + 1px chiseled inset shadow on the active item — same
     wax-stamp affordance as the modal panels. The selected entry feels
     pressed-into-the-page rather than hovered-on-top. */
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 200, 0.18),
    0 0 14px rgba(212, 175, 55, 0.22);
}
.items-list li:hover:not(.active):not(.empty) {
  border-color: rgba(232, 220, 192, 0.22);
}
.items-list li.empty {
  opacity: 0.4;
  font-style: italic;
  cursor: default;
}
.items-list__icon {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-style: italic;
  font-size: 16px;
  background: rgba(232, 220, 192, 0.06);
  border: 1px solid rgba(232, 220, 192, 0.16);
  color: var(--bone);
}
.items-list li.active .items-list__icon {
  background: rgba(212, 175, 55, 0.25);
  border-color: rgba(212, 175, 55, 0.7);
  color: var(--gold);
}
.items-list__name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.items-list__count {
  font-style: italic;
  font-size: 11px;
  letter-spacing: 1px;
  color: rgba(232, 220, 192, 0.55);
}
.items-list li.active .items-list__count { color: var(--gold); }
.items-detail {
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  min-height: 0;
}
.items-detail__icon {
  width: 84px; height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 38px;
  color: var(--gold);
  border: 1px solid rgba(212, 175, 55, 0.5);
  /* Layered radial warm spot + chiseled inset shadow so the icon plate
     reads as a pressed-foil seal on paper rather than a flat tile. */
  background:
    radial-gradient(ellipse 70% 60% at 50% 30%, rgba(212, 175, 55, 0.18), transparent 75%),
    rgba(212, 175, 55, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 200, 0.25),
    inset 0 0 14px rgba(0, 0, 0, 0.35),
    0 4px 12px rgba(0, 0, 0, 0.4);
  text-shadow: 0 0 14px rgba(255, 200, 120, 0.30);
  margin-bottom: 18px;
}
.items-detail__name {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 22px;
  color: var(--gold);
  letter-spacing: 1px;
  text-shadow: 0 0 14px rgba(255, 200, 120, 0.25);
}
.items-detail__kind {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 10px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: rgba(212, 175, 55, 0.50);
  margin: 4px 0 14px;
}
.items-detail__desc {
  font-family: Georgia, serif;
  font-size: 13px;
  line-height: 1.7;
  letter-spacing: 0.3px;
  color: rgba(232, 220, 192, 0.80);
  font-style: italic;
  max-width: 460px;
  white-space: pre-line;
  /* Subtle warm halo on item lore so each entry reads as an inscribed
     codex line — same engraving family as the intro stanza and footer. */
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.08);
}
.items-modal__foot {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 10px;
  letter-spacing: 3px;
  color: rgba(232, 220, 192, 0.50);
  text-transform: uppercase;
  /* Engraved fade-rule above the foot — matches the intro/end-state/legend
     pattern so all modal margins share one inscribed-page aesthetic. */
  border-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(232, 220, 192, 0) 8%,
    rgba(232, 220, 192, 0.18) 50%,
    rgba(232, 220, 192, 0) 92%,
    transparent 100%
  ) 1;
  border-style: solid;
  border-width: 1px 0 0;
  padding: 12px 0 0;
  margin-top: 14px;
  text-align: right;
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.10);
}

/* ----- Dev map modal ----- */
.map-modal {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 4, 0.92);
  display: none;
  z-index: 23;
  font-family: Georgia, serif;
  padding: 22px 28px;
}
.map-modal.open { display: flex; }
.map-modal__panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  color: var(--bone);
  border: 1px solid rgba(212, 175, 55, 0.35);
  /* Same warm-radial-spot + chiseled-border treatment as the menu modal so
     all modal panels feel like leaves of the same paper-bound tome. */
  background:
    radial-gradient(ellipse 60% 30% at 50% 0%, rgba(212, 175, 55, 0.08), transparent 70%),
    rgba(20, 16, 10, 0.50);
  padding: 14px 18px 12px;
  position: relative;
  box-shadow:
    inset 0 0 0 1px rgba(8, 6, 4, 0.7),
    inset 0 0 24px rgba(0, 0, 0, 0.35);
}
/* Mirror the gold-corner glyphs from .menu-modal__panel so the atlas reads
   as a sealed page just like the menu. */
.map-modal__panel::before,
.map-modal__panel::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
  background:
    linear-gradient(to right,  rgba(212, 175, 55, 0.85), rgba(212, 175, 55, 0)) top    / 100% 1px no-repeat,
    linear-gradient(to bottom, rgba(212, 175, 55, 0.85), rgba(212, 175, 55, 0)) left   / 1px 100% no-repeat;
}
.map-modal__panel::before { top: -1px; left: -1px; }
.map-modal__panel::after  { top: -1px; right: -1px; transform: scaleX(-1); }
.map-modal__head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  /* Engraved fade-rule under the title — matches all other modal heads. */
  border-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(212, 175, 55, 0) 8%,
    rgba(212, 175, 55, 0.32) 50%,
    rgba(212, 175, 55, 0) 92%,
    transparent 100%
  ) 1;
  border-style: solid;
  border-width: 0 0 1px;
  padding: 0 0 10px;
  margin-bottom: 10px;
  position: relative;
}
.map-modal__head h2 {
  margin: 0;
  font-style: italic;
  font-weight: normal;
  font-size: 22px;
  color: var(--gold);
  letter-spacing: 2px;
}
.map-modal__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.map-svg {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.map-svg .map-edge {
  stroke: rgba(232, 220, 192, 0.30);
  stroke-width: 1.5;
  fill: none;
}
.map-svg .map-edge--current {
  stroke: rgba(212, 175, 55, 0.85);
  stroke-width: 2;
}
.map-svg .map-node {
  cursor: pointer;
  transition: transform 0.12s;
}
.map-svg .map-node:hover .map-node__bg {
  stroke: rgba(212, 175, 55, 0.95);
  stroke-width: 2;
}
.map-svg .map-node__bg {
  stroke: rgba(232, 220, 192, 0.45);
  stroke-width: 1;
  fill: rgba(232, 220, 192, 0.06);
}
.map-svg .map-node--current .map-node__bg {
  stroke: var(--gold);
  stroke-width: 2.5;
  fill: rgba(212, 175, 55, 0.22);
}
.map-svg .map-node--cleared .map-node__bg {
  fill: rgba(64, 110, 60, 0.22);
  stroke: rgba(120, 180, 110, 0.6);
}
.map-svg .map-node--locked .map-node__bg {
  fill: rgba(20, 17, 13, 0.5);
  stroke: rgba(100, 90, 70, 0.4);
  stroke-dasharray: 4 3;
}
.map-svg .map-node--boss .map-node__bg {
  stroke: rgba(200, 68, 63, 0.85);
}
.map-svg .map-node--margin .map-node__bg {
  fill: rgba(200, 170, 80, 0.10);
  stroke: rgba(200, 170, 80, 0.5);
  stroke-dasharray: 2 2;
}
.map-svg .map-node--trial .map-node__bg {
  stroke: rgba(120, 160, 220, 0.65);
}
.map-svg .map-node--showcase .map-node__bg {
  stroke: rgba(180, 140, 220, 0.6);
}
.map-svg .map-node__label {
  fill: var(--bone);
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 11px;
  text-anchor: middle;
  pointer-events: none;
}
.map-svg .map-node--locked .map-node__label { opacity: 0.45; }
.map-svg .map-node__lock {
  fill: rgba(232, 220, 192, 0.5);
  font-size: 9px;
  text-anchor: middle;
  pointer-events: none;
}
.map-svg .map-node--current .map-node__label { fill: var(--gold); }
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 0 0;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(232, 220, 192, 0.65);
  /* Border-image gradient so the rule above the legend fades at the ends —
     same engraved-rule treatment as the intro/death prompt. */
  border-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(232, 220, 192, 0) 8%,
    rgba(232, 220, 192, 0.18) 50%,
    rgba(232, 220, 192, 0) 92%,
    transparent 100%
  ) 1;
  border-style: solid;
  border-width: 1px 0 0;
  margin-top: 8px;
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.10);
}
.map-legend__dot {
  display: inline-block;
  width: 10px; height: 10px;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid rgba(232, 220, 192, 0.45);
  background: rgba(232, 220, 192, 0.1);
}
.map-legend__dot--current  { background: var(--gold); border-color: var(--gold); }
.map-legend__dot--cleared  { background: rgba(120, 180, 110, 0.5); border-color: rgba(120, 180, 110, 0.7); }
.map-legend__dot--unlocked { background: rgba(232, 220, 192, 0.12); }
.map-legend__dot--locked   { background: rgba(20, 17, 13, 0.5); border-style: dashed; }
.map-legend__dot--boss     { border-color: rgba(200, 68, 63, 0.85); }
.map-legend__dot--margin   { border-color: rgba(200, 170, 80, 0.6); border-style: dashed; }
.map-legend__dot--trial    { border-color: rgba(120, 160, 220, 0.7); }
.map-legend__dot--showcase { border-color: rgba(180, 140, 220, 0.65); }
.map-modal__foot {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(232, 220, 192, 0.45);
  text-align: right;
  margin-top: 6px;
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.10);
}

.frame__foot {
  font-size: 11px;
  opacity: 0.55;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  letter-spacing: 1.5px;
  text-align: center;
  margin-top: 8px;
  /* Subtle warm halo on the flavor footer so it reads as a marginal
     manuscript line — matches the firelight palette of the kicker, intro,
     and combat pop-ups. */
  color: rgba(232, 220, 192, 0.62);
  text-shadow:
    0 1px 1px rgba(0, 0, 0, 0.7),
    0 0 12px rgba(255, 200, 120, 0.10);
}

/* FPS counter — fixed top-left, monospace, low-opacity so it doesn't fight
   for attention. Updates ~5x per second from game.js. */
.fps {
  position: fixed;
  top: 8px;
  left: 10px;
  z-index: 9999;
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 1px;
  color: rgba(232, 220, 192, 0.62);
  background: rgba(8, 6, 4, 0.55);
  padding: 4px 8px;
  border: 1px solid rgba(200, 170, 80, 0.18);
  border-radius: 3px;
  pointer-events: none;
  user-select: none;
}
.fps.hidden { display: none; }

/* Project brand — sits just below the FPS counter, top-left.
   Styled as a wax-seal page mark: dark paper backing with a faint warm
   radial glow at the top so the badge reads as if a candle is just out
   of frame. The gold border + inset shadow mimics a chiseled stamp. */
.brand {
  position: fixed;
  top: 30px;
  left: 10px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-family: Georgia, serif;
  color: rgba(232, 220, 192, 0.82);
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(212, 175, 55, 0.10), transparent 70%),
    rgba(8, 6, 4, 0.66);
  padding: 5px 11px 7px;
  border: 1px solid rgba(212, 175, 55, 0.36);
  border-radius: 3px;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  user-select: none;
}
.brand__name {
  font-style: italic;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--gold);
}
.brand__ver {
  font: 600 9.5px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 1.5px;
  text-transform: lowercase;
  /* Faint warm tint so the version stamp picks up the same firelight as
     the wax-seal badge container around it. Pulls the build label into
     the palette without sacrificing the monospaced "build number" read. */
  color: rgba(212, 175, 55, 0.55);
  text-shadow: 0 0 6px rgba(255, 200, 120, 0.10);
}

/* ===== Cube debug panel ===== */
/* Pinned to the lower-left so it's reachable while playing without
   covering the gameplay area. The directional pad mimics the cube's
   four roll axes: clicking N rolls the cube north (back face → top). */
.cube-debug {
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  /* Same wax-seal stamp treatment as the brand badge — radial warm glow at
     the top + chiseled inset shadow + outer drop shadow. The cube debug
     panel is a constant on-screen sibling of the brand badge so it should
     share its stamp aesthetic instead of looking like a vanilla overlay. */
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(212, 175, 55, 0.10), transparent 70%),
    rgba(8, 6, 4, 0.85);
  border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: 4px;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.55);
  font: 11px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--bone);
  user-select: none;
}
.cube-debug__row {
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.cube-debug__label {
  color: rgba(232, 220, 192, 0.55);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 9px;
  min-width: 28px;
}
.cube-debug__top { color: var(--gold); font-weight: 600; }
.cube-debug__last { color: rgba(232, 220, 192, 0.85); font-style: italic; }
.cube-debug__pad {
  display: grid;
  grid-template-columns: 28px 28px 28px;
  grid-template-rows: 28px 28px 28px;
  grid-template-areas:
    ".  n  ."
    "w  .  e"
    ".  s  .";
  gap: 2px;
  margin-top: 4px;
}
.cube-debug__btn {
  background: rgba(20, 17, 13, 0.9);
  color: var(--bone);
  border: 1px solid rgba(212, 175, 55, 0.4);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.cube-debug__btn:hover {
  background: rgba(212, 175, 55, 0.22);
  color: var(--gold);
  border-color: rgba(212, 175, 55, 0.85);
}
.cube-debug__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.cube-debug__btn.flash {
  background: rgba(212, 175, 55, 0.5);
  color: #14110d;
  border-color: var(--gold);
}
.cube-debug__btn--n { grid-area: n; }
.cube-debug__btn--w { grid-area: w; }
.cube-debug__btn--e { grid-area: e; }
.cube-debug__btn--s { grid-area: s; }
.cube-debug__faces {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 1px 8px;
  margin-top: 8px;
  padding-top: 8px;
  /* Engraved fade-rule above the per-face mapping table — same gold rule
     pattern as the intro / modal foot / map legend. */
  border-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(212, 175, 55, 0) 8%,
    rgba(212, 175, 55, 0.32) 50%,
    rgba(212, 175, 55, 0) 92%,
    transparent 100%
  ) 1;
  border-style: solid;
  border-width: 1px 0 0;
  font-size: 10px;
}
.cube-debug__faces > .k {
  color: rgba(212, 175, 55, 0.55);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.cube-debug__faces > .v {
  color: var(--bone);
  font-style: italic;
}

/* ===== Top-right menu button + main-menu modal ===== */
.menu-btn {
  position: fixed;
  top: 8px;
  right: 10px;
  z-index: 9999;
  font-family: Georgia, serif;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--bone);
  background: rgba(8, 6, 4, 0.78);
  border: 1px solid rgba(212, 175, 55, 0.45);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.menu-btn:hover {
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.85);
  color: var(--gold);
}

.menu-modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 4, 0.92);
  display: none;
  z-index: 9998;
  font-family: Georgia, serif;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.menu-modal.open { display: flex; }
.menu-modal__panel {
  width: min(640px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  color: var(--bone);
  border: 1px solid rgba(212, 175, 55, 0.45);
  /* Layered background — subtle radial warm spot at the top-center mimics
     candlelight falling on the page above the title, then a vertical
     gradient pulls the bottom into shadow. The base paper colour stays at
     rgba(20,16,10,0.92) so legibility is unchanged; the gradients only add
     atmospheric falloff. */
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(212, 175, 55, 0.10), transparent 70%),
    linear-gradient(to bottom, rgba(20, 16, 10, 0.95), rgba(8, 6, 4, 0.96)),
    rgba(20, 16, 10, 0.92);
  padding: 20px 26px;
  position: relative;
  /* Etched dual-border feel — outer 1px gold (the .border above) with an
     inset 1px dark line giving the panel a chiseled paper edge, plus a
     soft outer drop shadow so it floats over the dimmed backdrop instead
     of sitting flush against it. */
  box-shadow:
    inset 0 0 0 1px rgba(8, 6, 4, 0.85),
    inset 0 0 24px rgba(0, 0, 0, 0.45),
    0 24px 60px rgba(0, 0, 0, 0.7);
}
/* Tiny gold corner glyphs on the four panel corners — a Souls-style "this
   page is sealed" mark. Pure CSS via two layered radial-gradients in a
   ::before/::after, positioned absolutely so they don't disturb layout. */
.menu-modal__panel::before,
.menu-modal__panel::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
  background:
    linear-gradient(to right,  rgba(212, 175, 55, 0.85), rgba(212, 175, 55, 0)) top    / 100% 1px no-repeat,
    linear-gradient(to bottom, rgba(212, 175, 55, 0.85), rgba(212, 175, 55, 0)) left   / 1px 100% no-repeat;
}
.menu-modal__panel::before { top: -1px; left: -1px; }
.menu-modal__panel::after  {
  top: -1px; right: -1px;
  transform: scaleX(-1);
}
.menu-modal__head {
  /* Engraved fade-rule under the title — matches all other modal heads. */
  border-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(212, 175, 55, 0) 8%,
    rgba(212, 175, 55, 0.32) 50%,
    rgba(212, 175, 55, 0) 92%,
    transparent 100%
  ) 1;
  border-style: solid;
  border-width: 0 0 1px;
  padding: 0 0 14px;
  margin-bottom: 10px;
  position: relative;
}
.menu-modal__head h2 {
  margin: 4px 0 0;
  font-style: italic;
  font-weight: normal;
  font-size: 26px;
  color: var(--gold);
  letter-spacing: 2px;
}
.menu-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(232, 220, 192, 0.10);
  margin: 4px 0 16px;
}
.menu-tab {
  flex: 1;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 8px;
  color: rgba(232, 220, 192, 0.55);
  font-family: Georgia, serif;
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, text-shadow 0.12s;
}
.menu-tab:hover {
  color: var(--bone);
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.18);
}
.menu-tab.active {
  color: var(--gold);
  border-bottom-color: rgba(212, 175, 55, 0.7);
  /* Faint warm halo under the active tab — same firelight cue as the
     resume CTA breathing glow. The 14px halo sits below the underline so
     the active state reads as catching candlelight. */
  text-shadow: 0 0 14px rgba(255, 200, 120, 0.30);
}
.menu-modal__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.menu-section { display: none; }
.menu-section.active { display: block; }
.menu-blurb {
  font-family: Georgia, serif;
  font-size: 13px;
  line-height: 1.6;
  letter-spacing: 0.5px;
  color: rgba(232, 220, 192, 0.78);
  font-style: italic;
  margin: 0 0 16px;
  /* Subtle warm halo so the section blurb reads as an inscribed
     introduction — same firelight palette as the level-intro stanza
     and item lore body. */
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.10);
}
.menu-action {
  background: rgba(212, 175, 55, 0.16);
  border: 1px solid rgba(212, 175, 55, 0.6);
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 14px;
  letter-spacing: 3px;
  text-transform: lowercase;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.18s;
  /* Subtle warm halo + breathing animation. The breathing matches the
     cadence of the bonfire flicker so the resume button reads as the
     active "rest point" the player is invited to return to — same visual
     beat as kindling at a bonfire. */
  animation: menu-action-breathe 3.6s ease-in-out infinite;
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.18);
}
.menu-action:hover {
  background: rgba(212, 175, 55, 0.30);
  border-color: rgba(212, 175, 55, 0.95);
  box-shadow: 0 0 22px rgba(212, 175, 55, 0.42);
}
@keyframes menu-action-breathe {
  0%, 100% { box-shadow: 0 0 14px rgba(212, 175, 55, 0.18); }
  50%      { box-shadow: 0 0 22px rgba(212, 175, 55, 0.32); }
}
.menu-secondary {
  background: none;
  border: 1px solid rgba(232, 220, 192, 0.32);
  color: rgba(232, 220, 192, 0.78);
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 12px;
  letter-spacing: 2px;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, box-shadow 0.12s, text-shadow 0.12s;
}
.menu-secondary:hover {
  border-color: var(--blood);
  color: var(--blood);
  /* Red halo on hover — distinct cue that this action is destructive
     (resets campaign progress). Same red palette as the boss-room
     quickjump hover and stamina-out flash. */
  box-shadow: 0 0 14px rgba(200, 68, 63, 0.30);
  text-shadow: 0 0 10px rgba(200, 68, 63, 0.40);
}
.menu-quickjump {
  margin-top: 22px;
}
.menu-quickjump__title {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 10px;
  letter-spacing: 4px;
  text-transform: uppercase;
  /* Faint gold so the "JUMP TO" header sits in the firelight palette
     alongside the dev-panel chapter dividers and modal kickers. */
  color: rgba(212, 175, 55, 0.55);
  margin-bottom: 10px;
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.10);
}
.menu-quickjump__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.menu-quickjump__grid button {
  background: none;
  border: 1px solid rgba(232, 220, 192, 0.16);
  color: rgba(232, 220, 192, 0.78);
  font-family: Georgia, serif;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 6px 8px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.menu-quickjump__grid button:hover {
  border-color: rgba(212, 175, 55, 0.7);
  background: rgba(212, 175, 55, 0.10);
  color: var(--gold);
  /* Subtle warm halo on hover so the level button feels touched by
     candlelight when the cursor finds it. */
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.25);
}
.menu-quickjump__grid button.boss-room {
  border-color: rgba(200, 68, 63, 0.45);
  color: rgba(232, 200, 200, 0.95);
}
.menu-quickjump__grid button.boss-room:hover {
  border-color: var(--blood);
  background: rgba(200, 68, 63, 0.18);
  color: #ffd6d4;
  /* Boss rooms get a red halo on hover instead of gold — distinct cue
     that this jump leads to a fight, not a margin / showcase room. */
  box-shadow: 0 0 12px rgba(200, 68, 63, 0.30);
}

.menu-setting {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(232, 220, 192, 0.08);
}
.menu-setting label {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-style: italic;
  letter-spacing: 1.5px;
  color: rgba(232, 220, 192, 0.85);
  /* Faint warm halo on the setting names so each row reads as an engraved
     line item — same firelight palette as the kicker, intro, footer, and
     boss bar label. */
  text-shadow: 0 0 10px rgba(255, 200, 120, 0.10);
}
.menu-setting input[type="range"] {
  width: 180px;
  accent-color: var(--gold);
}
.menu-setting input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}
.menu-setting__val {
  min-width: 44px;
  text-align: right;
  font-family: Georgia, serif;
  font-size: 11px;
  letter-spacing: 1px;
  color: rgba(212, 175, 55, 0.62);
  font-style: italic;
  /* Faint warm halo so the slider value reads as inked digits in the
     margin of the settings ledger. */
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.12);
}
.menu-setting--actions {
  grid-template-columns: 1fr;
  justify-items: end;
}

.menu-share {
  display: flex;
  gap: 8px;
}
.menu-share input {
  flex: 1;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(232, 220, 192, 0.28);
  /* Same recessed-paper inset as the ad-modal input + warm focus halo so
     the share URL field shares the firelight palette. */
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.4);
  color: var(--bone);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 8px 12px;
  letter-spacing: 0.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.menu-share input:focus {
  border-color: rgba(212, 175, 55, 0.7);
  box-shadow:
    inset 0 1px 1px rgba(0, 0, 0, 0.4),
    0 0 14px rgba(212, 175, 55, 0.22);
}
.menu-share__status {
  margin-top: 12px;
  font-family: Georgia, serif;
  font-size: 11px;
  letter-spacing: 2px;
  color: rgba(212, 175, 55, 0.85);
  font-style: italic;
  min-height: 16px;
  /* Faint warm halo on the "copied" status line — matches the firelight
     palette of every other engraved label in the menu. */
  text-shadow: 0 0 10px rgba(255, 200, 120, 0.18);
}
.menu-modal__foot {
  margin-top: 12px;
  padding-top: 12px;
  /* Same engraved fade-rule as the intro / end-state / map legend so all
     three modal feet share the manuscript-margin pattern. */
  border-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(232, 220, 192, 0) 8%,
    rgba(232, 220, 192, 0.18) 50%,
    rgba(232, 220, 192, 0) 92%,
    transparent 100%
  ) 1;
  border-style: solid;
  border-width: 1px 0 0;
  text-align: right;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 10px;
  letter-spacing: 3px;
  color: rgba(232, 220, 192, 0.50);
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(255, 200, 120, 0.10);
}

/* Hide dev panel when "show dev panel" setting is off */
.dev-panel.hidden { display: none; }

/* ===== Hitbox debug overlay ===== */
/* The actual visualisation lives in the 3D scene (Three.js wireframes drawn
   from game.js). This class is just a tiny on-screen badge that surfaces
   when the toggle is on, so the player sees the option is active. */
.hitbox-badge {
  position: fixed;
  bottom: 8px;
  right: 10px;
  z-index: 9999;
  font: 600 10px/1 ui-monospace, monospace;
  letter-spacing: 1.5px;
  color: #ff6080;
  /* Wax-stamp atmosphere matching the brand badge + cube debug — radial
     red-toned glow at the top, chiseled inset border, drop shadow. The
     debug indicator becomes a deliberate page-mark instead of a flat tag. */
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 96, 128, 0.18), transparent 70%),
    rgba(8, 6, 4, 0.75);
  padding: 4px 9px 5px;
  border: 1px solid rgba(255, 96, 128, 0.45);
  border-radius: 3px;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.55);
  text-shadow: 0 0 10px rgba(255, 96, 128, 0.30);
  pointer-events: none;
  display: none;
}
.hitbox-badge.on { display: block; }
