* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #111812; }
body { display: grid; grid-template-rows: minmax(0, 1fr) auto; color: #f4f1df; font: 15px system-ui, sans-serif; }
#map-viewport { position: relative; min-width: 0; min-height: 0; overflow: hidden; display: grid; place-items: start; }
#map-stage { position: relative; flex: none; overflow: hidden; background: #284526; box-shadow: 0 0 30px #000a; }
#map-canvas { display: block; }
#map-place { position: absolute; top: .65rem; left: .65rem; z-index: 3; display: grid; gap: .15rem; pointer-events: none; padding: .35rem .55rem; border: 1px solid #f4f1df66; border-radius: .3rem; background: #111d; color: #fff; }
#entry-log:empty { display: none; }
#portal-label { position: absolute; z-index: 5; transform: translate(.6rem, calc(-100% - .6rem)); pointer-events: none; padding: .25rem .45rem; border: 1px solid #e9ddb0; border-radius: .25rem; background: #151a12ee; color: #fff7d6; white-space: nowrap; }
#world-clock { position: absolute; top: .65rem; right: .65rem; z-index: 3; pointer-events: none; padding: .3rem .55rem; border: 1px solid #f4f1df66; border-radius: .3rem; background: #111d; color: #fff; font-variant-numeric: tabular-nums; line-height: 1.25; }
#map-command-bar { z-index: 4; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; min-width: 0; min-height: 2.75rem; padding: .35rem .75rem; background: #111d; border-top: 1px solid #ffffff24; }
#map-inspection-controls { display: flex; align-items: center; gap: .35rem; }
#camera-state { min-width: 8.25rem; color: #d7ddc6; }
#map-inspection-controls button { min-width: 2.2rem; min-height: 2rem; border: 1px solid #b4c8a1; border-radius: .25rem; background: #263c28; color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
#map-inspection-controls button:hover:not(:disabled), #map-inspection-controls button:focus-visible { background: #38543b; }
#map-inspection-controls button:disabled { opacity: .55; cursor: default; }
#center-rowan { min-width: 7.5rem !important; }
#status { min-height: 2rem; margin: 0; padding: .4rem 0; }
/* Use the existing 2rem footer row; the canvas and inspection controls keep their geometry. */
#map-inspection-controls, #status { flex-shrink: 0; }
#status { white-space: nowrap; }
#player-profile { flex: 1 1 auto; min-width: 0; height: 2rem; overflow: auto; scrollbar-width: none; font-size: .75rem; }
#player-profile::-webkit-scrollbar { display: none; }
#profile-state { line-height: 2rem; white-space: nowrap; color: #d7ddc6; }
.profile-stats { display: grid; grid-template-columns: repeat(4, max-content); grid-template-rows: repeat(2, 1rem); gap: 0 .65rem; }
.profile-stat { display: flex; align-items: center; gap: .25rem; white-space: nowrap; }
.profile-stat > span:nth-child(2) { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.profile-stat meter { width: 1.5rem; height: .55rem; }
.profile-description { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#refreshment-controls { flex: 0 1 auto; max-width: 13rem; height: 2rem; min-width: 0; display: grid; align-content: center; font-size: .75rem; }
#refreshment-result { display: block; max-width: 13rem; height: .9rem; line-height: .9rem; overflow: auto; scrollbar-width: none; white-space: nowrap; }
#refreshment-result:empty { display: none; }
.profile-stats[hidden], #profile-state[hidden] { display: none; }
#player-inventory { flex: 1 1 30rem; max-width: 100%; min-width: 0; height: 2rem; display: flex; align-items: center; gap: .5rem; overflow: auto; scrollbar-width: none; font-size: .7rem; }
#player-inventory::-webkit-scrollbar, #inventory-stacks::-webkit-scrollbar { display: none; }
#inventory-state { line-height: 2rem; white-space: nowrap; color: #d7ddc6; }
/* The stacks scroll inside their own box, which also contains their visually hidden descriptions. */
#inventory-stacks { position: relative; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: .5rem; height: 2rem; overflow-x: auto; scrollbar-width: none; }
.inventory-stack { display: flex; align-items: center; gap: .2rem; white-space: nowrap; flex: none; }
.inventory-stack img { width: 1.3rem; height: 1.3rem; object-fit: contain; flex: none; }
.inventory-stack > span:nth-child(3) { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.inventory-worn { color: #e9ddb0; font-weight: 700; }
.inventory-worn[hidden] { display: none; }
.inventory-description { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.inventory-stack button { height: 1.1rem; padding: 0 .3rem; border: 1px solid #b4c8a1; border-radius: .2rem; background: #263c28; color: #fff; font: inherit; white-space: nowrap; cursor: pointer; }
.inventory-stack button:disabled { opacity: .55; cursor: default; }
.inventory-stack button:focus-visible { outline: 2px solid #f4f1df; outline-offset: 1px; }
#inventory-result { display: block; flex: none; max-width: 16rem; height: .9rem; line-height: .9rem; overflow: auto; scrollbar-width: none; white-space: nowrap; }
#inventory-result:empty { display: none; }
#inventory-stacks[hidden], #inventory-state[hidden] { display: none; }
#player-quests { flex: 1 1 30rem; max-width: 100%; min-width: 0; height: 2rem; display: flex; align-items: center; gap: .5rem; overflow: visible; font-size: .7rem; }
#quest-state { line-height: 2rem; white-space: nowrap; color: #d7ddc6; }
/* The entries keep their 2rem of text. When they overflow, a thin scrollbar under them shows that
   more exist; the strip grows past its 2rem box into the bar's spacing, so the bar keeps its geometry. */
#quest-entries { position: relative; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: .75rem; padding: .05rem 0; overflow-x: auto; overflow-y: hidden; }
#quest-entries::-webkit-scrollbar { height: 4px; }
#quest-entries::-webkit-scrollbar-track { border-radius: 2px; background: #ffffff24; }
#quest-entries::-webkit-scrollbar-thumb { border-radius: 2px; background: #b4c8a1; }
@supports not selector(::-webkit-scrollbar) { #quest-entries { scrollbar-width: thin; scrollbar-color: #b4c8a1 #ffffff24; } }
.quest-entry { display: grid; grid-template-rows: 1rem .9rem; align-content: center; white-space: nowrap; flex: none; }
.quest-head, .quest-detail { display: flex; align-items: center; gap: .3rem; }
.quest-title, .quest-progress { color: #fff; font-weight: 700; }
.quest-progress { font-variant-numeric: tabular-nums; }
.quest-status { color: #e9ddb0; }
.quest-detail { color: #d7ddc6; }
.quest-head button { height: .95rem; padding: 0 .3rem; border: 1px solid #b4c8a1; border-radius: .2rem; background: #263c28; color: #fff; font: inherit; white-space: nowrap; cursor: pointer; }
.quest-head button:disabled { opacity: .55; cursor: default; }
.quest-head button:focus-visible { outline: 2px solid #f4f1df; outline-offset: 1px; }
#quest-result { display: block; flex: none; max-width: 16rem; height: .9rem; line-height: .9rem; overflow: auto; scrollbar-width: none; white-space: nowrap; }
#quest-result:empty { display: none; }
#quest-entries[hidden], #quest-state[hidden] { display: none; }
#talk-notice { flex-shrink: 0; min-height: 2rem; padding: 0 .7rem; border: 1px solid #e8c45e; border-radius: .25rem; background: #e8c45e; color: #18372c; font: inherit; font-weight: 700; cursor: pointer; }
#talk-notice:hover, #talk-notice:focus-visible { background: #f2d16f; }
/* The action list beside one figure or marker on the map, in the talk panel's colours. */
.figure-actions { position: absolute; z-index: 6; width: max-content; max-width: min(14rem, calc(100% - 8px)); display: grid; gap: 4px; padding: 6px 8px; background: #123227; border: 1px solid #e8c45e; border-radius: 8px; color: #f3efe2; font-size: 12px; line-height: 1.35; box-shadow: 0 6px 18px rgba(3, 14, 10, .45); }
.figure-actions[hidden], .figure-actions-note[hidden], .figure-actions-reason[hidden] { display: none; }
.figure-actions-kind { color: #f2d16f; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.figure-actions-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.figure-actions-item { display: grid; gap: 2px; }
.figure-actions-button { justify-self: start; min-height: 32px; padding: 0 14px; background: #e8c45e; color: #18372c; border: 1px solid #e8c45e; border-radius: 6px; font: inherit; font-weight: 750; cursor: pointer; }
.figure-actions-button:disabled { opacity: .55; cursor: default; }
.figure-actions-button:focus-visible { outline: 2px solid #f4f1df; outline-offset: 1px; }
.figure-actions-note { color: #f3efe2; font-size: 11px; font-style: italic; overflow-wrap: anywhere; }
.figure-actions-reason { color: #c9d9d0; font-size: 11px; overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* The conversation overlay, copied from HTBS2's NpcDialogueOverlay styles. */
.npc-talk-overlay { position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(6, 22, 16, .72); }
.npc-talk-overlay[hidden], .npc-talk-error[hidden], .npc-talk-portrait[hidden] { display: none; }
.npc-talk-panel { width: min(520px, 100%); max-height: 100%; box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; padding: 14px; background: #123227; border: 2px solid #e8c45e; border-radius: 14px; color: #f3efe2; box-shadow: 0 20px 48px rgba(3, 14, 10, .5); }
.npc-talk-header { display: flex; align-items: center; gap: 11px; }
.npc-talk-portrait { width: 56px; height: 84px; flex: 0 0 56px; object-fit: contain; image-rendering: pixelated; background: #0d251d; border: 1px solid #5d7d6f; border-radius: 9px; }
.npc-talk-identity { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.npc-talk-name { color: #f2d16f; font-size: 15px; font-weight: 800; line-height: 1.2; }
.npc-talk-role { color: #d2e2d9; font-size: 11px; line-height: 1.35; }
.npc-talk-situation { color: #9eb6aa; font-size: 9px; line-height: 1.35; }
.npc-talk-close { min-height: 34px; background: transparent; color: #e8f1eb; border: 1px solid #6e8c7f; border-radius: 8px; font: inherit; font-size: 10px; font-weight: 650; line-height: 1.35; cursor: pointer; padding: 5px 8px; }
.npc-talk-transcript { display: flex; flex-direction: column; gap: 7px; min-height: 130px; max-height: 210px; overflow-y: auto; padding: 10px; background: #0d251d; border: 1px solid #5d7d6f; border-radius: 9px; user-select: text; }
.npc-talk-empty { margin: 0; color: #9eb6aa; font-size: 10px; line-height: 1.5; }
.npc-talk-line { display: flex; flex-direction: column; gap: 2px; font-size: 11px; line-height: 1.5; }
.npc-talk-speaker { color: #8fb0a1; font-size: 8px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.npc-talk-player-text { color: #eaf3ed; white-space: pre-wrap; overflow-wrap: anywhere; }
.npc-talk-npc-text { color: #f4d879; white-space: pre-wrap; overflow-wrap: anywhere; }
.npc-talk-error { display: flex; flex-direction: column; gap: 4px; padding: 9px; background: #3d2a24; border: 1px solid #b98978; border-radius: 9px; color: #ffdfd5; font-size: 10px; line-height: 1.5; }
.npc-talk-form { display: flex; align-items: flex-end; gap: 7px; }
.npc-talk-input { flex: 1 1 auto; min-width: 0; min-height: 38px; box-sizing: border-box; background: #0d251d; color: #fff; border: 1px solid #739385; border-radius: 8px; padding: 8px 9px; font: inherit; font-size: 12px; line-height: 1.45; resize: none; }
.npc-talk-send { min-height: 38px; background: #e8c45e; color: #18372c; border: 1px solid #e8c45e; border-radius: 8px; font: inherit; font-size: 12px; font-weight: 750; cursor: pointer; padding: 0 14px; }
.npc-talk-send:disabled { opacity: .55; cursor: default; }
.npc-talk-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.npc-talk-status { color: #c9d9d0; font-size: 10px; line-height: 1.45; min-height: 15px; }
@media (max-width: 1100px) {
  #map-command-bar { min-width: 0; flex-wrap: wrap; justify-content: flex-start; gap: .35rem .75rem; }
  #map-inspection-controls { flex-wrap: wrap; max-width: 100%; }
  #player-profile { flex: 1 1 24rem; }
  #refreshment-controls { flex-shrink: 0; }
  #player-inventory { flex: 1 1 18rem; }
  #player-quests { flex: 1 1 18rem; }
  #status { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
}
@media (max-width: 600px) {
  #player-profile { flex-basis: 100%; height: 4rem; }
  .profile-stats { grid-template-columns: repeat(2, max-content); grid-template-rows: repeat(4, 1rem); }
  #player-inventory { flex-basis: 100%; height: 2.5rem; max-width: 100%; }
  #player-quests { flex-basis: 100%; height: 2.5rem; max-width: 100%; }
}
#game-map-choices { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
/* Private exposure screens retain safety controls and a fixed stimulus. */
#exposure-dialog[hidden] { display: none; }
#exposure-dialog { position: fixed; inset: 0; z-index: 1000; background: #111d26ed; display: grid; place-items: center; padding: 1rem; color: #eff5f3; }
#exposure-card { box-sizing: border-box; width: min(54rem, 100%); max-height: 96dvh; overflow: auto; border: 1px solid #72968d; border-radius: .8rem; background: #172c31; padding: 1.25rem; }
#exposure-card h1 { margin: 0 0 .5rem; font-size: 1.5rem; }
#exposure-timer { font-size: 1.5rem; font-variant-numeric: tabular-nums; margin: .4rem 0; }
#exposure-status { min-height: 1.4em; white-space: pre-wrap; }
#exposure-body label { display: block; margin: .7rem 0; }
#exposure-body textarea { display: block; width: min(95%, 35rem); min-height: 3rem; margin-top: .3rem; }
#exposure-body fieldset label { display: inline-flex; align-items: center; gap: .3rem; margin: .5rem 1rem .5rem 0; font-size: 1.2rem; }
#exposure-stimulus { display: block; width: 100%; max-height: 48dvh; object-fit: contain; background: #fff; }
#exposure-safety { position: sticky; bottom: -1.25rem; background: #172c31; border-top: 1px solid #72968d; padding: .7rem 0; margin-top: 1rem; display: flex; flex-wrap: wrap; gap: .5rem; }
#exposure-card button, #player-exposure button { min-height: 2.75rem; padding: .5rem .8rem; cursor: pointer; }
#exposure-card button:disabled, #player-exposure button:disabled { cursor: default; opacity: .5; }
#exposure-skills button { margin: .25rem; }
#exposure-early-confirmation { border: 1px solid #e8c08b; padding: .8rem; }
#exposure-card :focus-visible, #player-exposure :focus-visible { outline: 3px solid #ffd48a; outline-offset: 3px; }
#player-exposure { flex: 1 1 100%; padding: .25rem; display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
#player-exposure h2 { font-size: 1rem; margin: 0; }
#player-exposure p { max-width: 60rem; margin: 0; font-size: .75rem; }
#exposure-card[data-mode="active"] { height: min(56rem, 96dvh); display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; overflow: hidden; }
#exposure-card[data-mode="active"] #exposure-body { min-height: 0; display: grid; grid-template-rows: minmax(6rem, 1fr) minmax(0, 1fr); gap: .3rem; }
#exposure-card[data-mode="active"] #exposure-body > h2 { display: none; }
#exposure-card[data-mode="active"] #exposure-stimulus { height: 100%; min-height: 0; max-height: none; }
#exposure-card[data-mode="active"] #exposure-tools { position: relative; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; scroll-padding-block: .35rem; }
#exposure-tools button, #exposure-tools textarea { scroll-margin-block: .35rem; }
#exposure-card[data-mode="active"] #exposure-skills h3 { margin: .2rem 0; font-size: .9rem; }
#exposure-card[data-mode="active"] #exposure-safety { position: static; margin: .4rem 0 0; padding-bottom: 0; }
