
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: #171310; color: #d8cdb4; font-family: "Trebuchet MS", "Segoe UI", sans-serif; font-size: 14px; }
body { padding: 10px; user-select: none; }
.hidden { display: none !important; }
button { font-family: inherit; line-height: 16px; background: #3a2f1f; color: #d8cdb4; border: 1px solid #57492e; border-radius: 3px; padding: 4px 10px; cursor: pointer; }
button:hover { background: #4a3c27; color: #e7c86a; }


#topbar { display: flex; justify-content: space-between; align-items: center; height: 26px; max-width: 1108px; margin: 0 auto 8px; }
#game-title { font-family: Georgia, serif; font-size: 20px; line-height: 24px; letter-spacing: 3px; color: #e7c86a; }
#game-title small { font-size: 11px; letter-spacing: 1px; color: #9c8f70; margin-left: 8px; }
#topbar-buttons button { margin-left: 6px; }


#layout { display: flex; flex-wrap: wrap; gap: 10px; max-width: 1108px; margin: 0 auto; align-items: flex-start; }
#play-column { display: flex; flex-direction: column; gap: 8px; flex: 1 1 420px; min-width: 0; max-width: 832px; }
#canvas-wrap { position: relative; width: 100%; aspect-ratio: 832 / 544; }

canvas#game { display: block; width: 100%; height: 100%; background: #000; border: 0; border-radius: 4px; box-shadow: inset 0 0 0 2px #57492e; cursor: pointer; }


#tooltip { position: absolute; top: 8px; left: 8px; background: rgba(10, 8, 5, 0.75); color: #f5edd6; border: 1px solid rgba(231, 200, 106, 0.35); padding: 3px 9px; border-radius: 3px; font-size: 13px; pointer-events: none; }
#tooltip:empty { display: none; }


#log { width: 100%; height: 116px; overflow-y: auto; background: #221b12; border: 2px solid #57492e; border-radius: 4px; padding: 6px 10px; font-size: 13px; line-height: 19px; }
.log-line { margin: 0; }
.log-sys { color: #b9ad93; }
.log-skill { color: #9be47a; }
.log-level { color: #e7c86a; }
.log-combat { color: #e0a05a; }
.log-death { color: #e06c5a; }
.log-lore { color: #b9a9d6; font-style: italic; }


#side-panel { width: 256px; flex: 0 0 256px; background: #2b2118; border: 2px solid #57492e; border-radius: 4px; padding: 10px; }
#hud { margin-bottom: 10px; }
.hud-label { display: inline-block; width: 60px; font-size: 12px; color: #9c8f70; }
#hp-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
#hp-bar { position: relative; flex: 1; height: 16px; background: #5a1d1d; border: 1px solid #1c1610; border-radius: 3px; overflow: hidden; }
#hp-fill { height: 100%; background: linear-gradient(#4fbf5a, #368a40); width: 100%; transition: width 0.2s; }
#hp-text { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; color: #fff; text-shadow: 1px 1px 0 #000; }
#mana-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
#mana-bar { position: relative; flex: 1; height: 16px; background: #232046; border: 1px solid #1c1610; border-radius: 3px; overflow: hidden; }
#mana-fill { height: 100%; background: linear-gradient(#6f78e0, #464fae); width: 100%; transition: width 0.2s; }
#mana-text { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; color: #fff; text-shadow: 1px 1px 0 #000; }
#crown-row { display: flex; align-items: center; gap: 6px; }
#time-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
#time-of-day { color: #b9ad93; font-size: 12px; }
#crown-count { color: #e7c86a; font-weight: bold; }
#crown-count::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f2dc96, #c9a23c); border: 1px solid #8a6f2a; }


#tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.tab-btn {
  flex: 1 1 64px; min-width: 64px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 4px 0 3px; font-size: 11px; line-height: 1;
}
.tab-btn canvas { display: block; opacity: 0.72; }
.tab-btn.active { background: #57492e; color: #e7c86a; }
.tab-btn.active canvas { opacity: 1; }


#xp-row { margin-top: 6px; cursor: pointer; }
#xp-row:hover #xp-more { color: #e7c86a; }
#xp-label { display: flex; justify-content: space-between; font-size: 10px; color: #6d6350;
            text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 1px; }
#xp-more { text-transform: none; letter-spacing: 0; color: #9c8f70; }
#xp-head { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 2px; }
#xp-skill { color: #9be47a; }
#xp-next { color: #9c8f70; }
#xp-bar { height: 6px; background: #241d14; border: 1px solid #1c1610; border-radius: 3px; overflow: hidden; }
#xp-fill { height: 100%; width: 0%; background: linear-gradient(#9be47a, #5f9c46); transition: width 0.2s; }


#name-row { display: flex; gap: 5px; }
#name-input {
  flex: 1; font-family: inherit; font-size: 13px; padding: 5px 8px;
  background: #221b12; color: #e7c86a; border: 1px solid #453823; border-radius: 3px;
}
#name-input:focus { outline: none; border-color: #e7c86a; }
#look-preview { display: block; margin: 6px auto 2px; background: #221b12; border: 1px solid #453823; border-radius: 3px; }
.look-part { margin-top: 7px; }
.look-label { font-size: 11px; color: #9c8f70; margin-bottom: 3px; }
.look-swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.swatch { width: 20px; height: 20px; border-radius: 3px; border: 1px solid #1c1610; cursor: pointer; }
.swatch:hover { border-color: #e7c86a; }
.swatch.on { border-color: #e7c86a; box-shadow: 0 0 0 1px rgba(231, 200, 106, 0.5); }


#creation { position: fixed; inset: 0; z-index: 60; background: rgba(8, 6, 4, 0.86); display: flex; align-items: center; justify-content: center; }
#creation-panel { width: 420px; max-width: 92vw; background: #2b2118; border: 2px solid #57492e; border-radius: 5px; padding: 18px 22px; }
#creation-panel h2 { font-family: Georgia, serif; font-size: 19px; color: #e7c86a; font-weight: normal; margin-bottom: 3px; }
#creation-panel .sub { font-size: 12px; color: #9c8f70; margin-bottom: 14px; line-height: 1.5; }
#creation-cols { display: flex; gap: 18px; align-items: flex-start; }
#creation-left { flex: none; text-align: center; }
#creation-right { flex: 1; }
#creation-preview { background: #221b12; border: 1px solid #453823; border-radius: 3px; }
#creation-name { width: 100%; font-family: inherit; font-size: 14px; padding: 6px 9px; margin-bottom: 4px;
  background: #221b12; color: #e7c86a; border: 1px solid #453823; border-radius: 3px; }
#creation-name:focus { outline: none; border-color: #e7c86a; }
#creation-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#creation-actions button { padding: 6px 16px; }
#creation-begin { background: #57492e; color: #e7c86a; }


#inv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.slot { position: relative; width: 100%; aspect-ratio: 1; background: #221b12; border: 1px solid #453823; border-radius: 3px; display: flex; align-items: center; justify-content: center; }
.slot canvas, .slot .qty { pointer-events: none; }
.slot.filled { cursor: pointer; }
.slot.filled:hover { border-color: #e7c86a; }
.slot .qty { position: absolute; top: 1px; left: 3px; font-size: 10px; line-height: 12px; color: #f5edd6; text-shadow: 1px 1px 0 #000; }


#skill-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.skill-cell { background: #221b12; border: 1px solid #453823; border-radius: 3px; padding: 4px 6px 5px; font-size: 12px; cursor: default; }
.skill-cell .skill-top { display: flex; justify-content: space-between; }
.skill-cell .skill-lvl { color: #e7c86a; font-weight: bold; }
.skill-cell .skill-xp { font-size: 9.5px; color: #9c8f70; margin: 1px 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skill-cell .skill-track { height: 3px; background: #17120c; border-radius: 2px; overflow: hidden; }
.skill-cell .skill-prog { height: 100%; width: 0%; background: #5f9c46; }
.skill-cell.trained { border-color: #6b5a35; }
.skill-cell.trained .skill-prog { background: #9be47a; }
#total-level { margin-top: 8px; text-align: center; font-size: 12px; color: #9c8f70; }


.combat-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #9c8f70; margin: 8px 0 5px; }

#equip-rows {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-areas:
    ".      helm   .      bow  "
    "weapon body   shield staff"
    ".      legs   .      .    ";
  gap: 5px;
  justify-items: center;
}
.equip-cell { width: 100%; aspect-ratio: 1; position: relative; }
.equip-weapon { grid-area: weapon; } .equip-shield { grid-area: shield; }
.equip-bow    { grid-area: bow; }    .equip-staff  { grid-area: staff; }
.equip-helm   { grid-area: helm; }   .equip-body   { grid-area: body; }
.equip-legs   { grid-area: legs; }
.equip-cell::after {
  content: attr(data-slot);
  position: absolute; bottom: -1px; left: 0; right: 0;
  font-size: 8px; text-align: center; color: #6d6350; pointer-events: none;
}
.equip-cell.equipped::after { content: ""; }
.equip-cell.equipped { border-color: #6b5a35; }

.equip-cell.taken { border-style: dashed; border-color: #5a4a2c; background: #1b160f; }
.equip-cell.taken::after { color: #8d7f5f; font-style: italic; }
#equip-worn { margin-top: 8px; font-size: 11px; color: #9c8f70; line-height: 1.4; }
#equip-stats { margin-top: 8px; font-size: 12px; line-height: 1.6; color: #b9ad93; }
#equip-stats b { color: #d8cdb4; }
#equip-stats hr { border: none; border-top: 1px solid #453823; margin: 6px 0; }
#style-buttons { display: flex; flex-direction: column; gap: 4px; }
#style-buttons button { text-align: left; font-size: 12px; }
#style-buttons button.active { background: #57492e; color: #e7c86a; }
#style-buttons button small { color: #9c8f70; margin-left: 5px; }


#dialogue { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; width: 560px; max-width: 92%; background: rgba(38, 30, 19, 0.96); border: 2px solid #57492e; border-radius: 5px; padding: 10px 16px; cursor: pointer; }
#dialogue-name { font-family: Georgia, serif; color: #e7c86a; margin-bottom: 4px; }
#dialogue-text { min-height: 36px; line-height: 1.4; }
#dialogue-hint { font-size: 11px; color: #9c8f70; text-align: right; }
#dialogue-options { display: flex; gap: 8px; margin-top: 6px; }


#overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
#overlay-panel { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); width: 480px; max-width: 92%; max-height: calc(100% - 16px); overflow: hidden; background: #2b2118; border: 2px solid #57492e; border-radius: 5px; display: flex; flex-direction: column; }
#overlay-head { flex: none; display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid #57492e; }
#overlay-title { font-family: Georgia, serif; color: #e7c86a; font-size: 16px; }
#overlay-close { padding: 2px 8px; }
#overlay-body { min-height: 0; padding: 12px; overflow-y: auto; overscroll-behavior: contain; }
.overlay-hint { font-size: 11px; color: #9c8f70; margin: 8px 0; line-height: 1.5; }

#overlay.import-open { z-index: 61; }
.import-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.import-refusal { font-size: 12px; color: #e06c5a; margin: 8px 0; line-height: 1.5; }
.import-who { font-size: 13px; color: #e7c86a; margin: 4px 0; line-height: 1.5; overflow-wrap: anywhere; }
.import-warning { font-size: 12px; color: #d8cdb4; margin: 8px 0; line-height: 1.5; }
.import-kept { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px solid #3a2f1f; }
.import-kept-name { font-size: 12px; overflow-wrap: anywhere; }
button.danger { background: #6a2a20; color: #ffd9c9; border-color: #e06c5a; }
button.danger:hover { background: #82352a; color: #fff0e8; }
#btn-save.save-failing { background: #6a2a20; color: #ffd9c9; border-color: #e06c5a; }
#creation-import { margin-right: auto; }
#bank-grid, #shop-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }

#bank-filter { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
#bank-shelves { display: flex; flex-wrap: wrap; gap: 3px; flex: 1; }
.bank-shelf.on { color: #e7c86a; border-color: #8a744d; background: #3a2f1f; }
#bank-search { width: 96px; background: #221b12; color: #e8dcc0; border: 1px solid #57492e; border-radius: 3px; padding: 2px 6px; font-size: 11px; }
#bank-actions { display: flex; gap: 6px; margin-top: 8px; }
#bank-actions button:disabled { opacity: 0.45; cursor: default; }
#shop-grid { grid-template-columns: repeat(5, 1fr); }
.shop-entry { text-align: center; }
.shop-entry .price { font-size: 10px; color: #e7c86a; margin-top: 2px; }
#shop-crowns { margin-bottom: 8px; font-size: 12px; color: #e7c86a; }
#bank-actions { margin-top: 10px; }



#region-viewport {

  flex: 1 1 auto; min-height: min(300px, 46vh); padding: 6px;
  overflow: auto; overscroll-behavior: contain;
  background: #221b12; border: 1px solid #453823; border-radius: 3px;
  cursor: grab;
}
#region-viewport:focus-visible { outline: 1px solid #c8b48a; outline-offset: -2px; }

#region-viewport.panning { cursor: grabbing; user-select: none; }

#overlay-body.region-map-body { display: flex; flex-direction: column; flex: 1 1 auto; }
#overlay-body.region-map-body .overlay-hint { flex: none; }
#region-grid { --rc-cell: 80px; display: grid; gap: 3px; width: max-content; }

.region-cell { min-height: 48px; display: flex; align-items: center; justify-content: center; }
.region-node { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; padding: 6px 4px; border-radius: 3px;
  background: #2a2118; border: 1px solid #57492e; }
.region-node.safe { background: #2b2a18; border-color: #6b5a35; }
.region-node.here { border-color: #e7c86a; background: #3a2f1f; box-shadow: 0 0 0 1px rgba(231,200,106,0.35); }
.rn-name { font-size: 11px; color: #d8cdb4; text-align: center; line-height: 1.2; }
.rn-note { font-size: 9px; color: #9c8f70; }
.region-node.here .rn-name { color: #e7c86a; }

.region-node.pocket { width: 84%; height: auto; min-height: 30px; padding: 3px 3px; background: #26221a; border-color: #4b4330; }
.region-node.pocket .rn-name { font-size: 10px; color: #bdb39a; }
.region-node.pocket.here { border-color: #e7c86a; background: #3a2f1f; }
.region-node.pocket.here .rn-name { color: #e7c86a; }

#region-grid.layer-below .region-node { background: #1d1b1c; border-color: #4a4d49; }
#region-grid.layer-below .region-node.here { border-color: #8fd0a8; background: #1f2622; box-shadow: 0 0 0 1px rgba(143,208,168,0.30); }
#region-grid.layer-below .region-node.here .rn-name { color: #a9e0bd; }
.region-ghost { width: 100%; height: 100%; min-height: 48px; border: 1px dashed rgba(156,143,112,0.16); border-radius: 3px; }

.region-node .rn-way { position: absolute; right: 2px; top: 0; background: none; font-style: normal; font-size: 10px; color: #8fd0a8; line-height: 1; }

.region-between { flex: none; display: flex; align-items: center; gap: 6px; padding: 6px 2px 0; font-size: 11px; color: #9c8f70; }
.rb-label { text-transform: uppercase; letter-spacing: 0.06em; font-size: 9px; }
.rb-place { font: inherit; font-size: 11px; padding: 2px 7px; border-radius: 3px; background: #26221a; border: 1px solid #4b4330; color: #d8cdb4; }
.rb-place.walkable { cursor: pointer; }
.rb-place.walkable:hover { border-color: #c8b48a; background: #35291c; }
.rb-place.here { border-color: #e7c86a; color: #e7c86a; }
.rb-step { color: #6b5a35; }
.rn-layer { margin-left: 6px; }

.region-node.walkable { cursor: pointer; }
.region-node.walkable:hover { border-color: #c8b48a; background: #35291c; }
.region-node.unknown .rn-name { color: #9c8f70; }
.map-walk { margin-left: auto; }
.region-node i { position: absolute; background: #57492e; }

.region-node .rn-undrawn { position: static; background: none; color: #9c8f70; font-style: normal; margin-left: 2px; }
.rc-e { right: -5px; top: 50%; width: 5px; height: 2px; }
.rc-w { left: -5px; top: 50%; width: 5px; height: 2px; }
.rc-n { top: -5px; left: 50%; width: 2px; height: 5px; }
.rc-s { bottom: -5px; left: 50%; width: 2px; height: 5px; }


#spell-list { display: flex; flex-direction: column; gap: 5px; }
.spell-entry { padding: 6px 8px; background: #221b12; border: 1px solid #453823; border-radius: 3px; cursor: pointer; }
.spell-entry:hover { border-color: #e7c86a; }
.spell-entry.selected { border-color: #9f7fd4; background: #2a2338; }
.spell-entry.locked { opacity: 0.42; cursor: default; }
.spell-entry.locked:hover { border-color: #453823; }
.spell-name { display: flex; justify-content: space-between; font-size: 13px; color: #d8cdb4; }
.spell-req { color: #9f7fd4; font-size: 11px; }
.spell-sub { font-size: 11px; color: #9c8f70; line-height: 1.4; }
#spell-hint { margin-top: 8px; text-align: center; }
.spell-note { font-size: 11px; color: #9c8f70; }


#craft-list { display: flex; flex-direction: column; gap: 5px; }
.craft-entry { display: flex; align-items: center; gap: 10px; padding: 6px 8px; background: #221b12; border: 1px solid #453823; border-radius: 3px; cursor: pointer; }
.craft-entry:hover { border-color: #e7c86a; }
.craft-entry .slot { width: 40px; flex: none; border: none; background: none; }
.craft-entry.locked { opacity: 0.42; cursor: default; }
.craft-entry.locked:hover { border-color: #453823; }
.craft-text { flex: 1; }
.craft-name { display: flex; justify-content: space-between; font-size: 13px; color: #d8cdb4; }
.craft-req { color: #e7c86a; font-size: 11px; }
.craft-sub { font-size: 11px; color: #9c8f70; line-height: 1.4; }


#ctx-menu { position: fixed; z-index: 50; min-width: 170px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow-y: auto; overscroll-behavior: contain; background: #2b2118; border: 1px solid #8a744d; border-radius: 3px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6); padding: 3px 0; }
#ctx-menu .menu-title { padding: 4px 12px; font-size: 11px; color: #e7c86a; border-bottom: 1px solid #453823; margin-bottom: 2px; }
#ctx-menu .menu-item { padding: 4px 12px; font-size: 13px; cursor: pointer; }
#ctx-menu .menu-item:hover { background: #453823; color: #e7c86a; }


#overlay-body, #ctx-menu, #region-viewport { scrollbar-width: thin; scrollbar-color: #6b5a35 #221b12; }

#overlay-body::-webkit-scrollbar, #ctx-menu::-webkit-scrollbar, #region-viewport::-webkit-scrollbar { width: 8px; height: 8px; }
#overlay-body::-webkit-scrollbar-track, #ctx-menu::-webkit-scrollbar-track, #region-viewport::-webkit-scrollbar-track { background: #221b12; }
#overlay-body::-webkit-scrollbar-thumb, #ctx-menu::-webkit-scrollbar-thumb, #region-viewport::-webkit-scrollbar-thumb { background: #6b5a35; border: 2px solid #221b12; border-radius: 4px; }


#quest-list { display: flex; flex-direction: column; gap: 6px; }
.quest-entry { padding: 7px 8px; background: #221b12; border: 1px solid #453823; border-radius: 3px; }
.quest-entry.done { opacity: 0.55; }
.quest-entry.ready { border-color: #e7c86a; }
.quest-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.quest-name { font-size: 13px; color: #d8cdb4; }
.quest-count { font-size: 11px; color: #e7c86a; white-space: nowrap; }
.quest-entry.done .quest-count { color: #9be47a; }
.quest-note { font-size: 11px; color: #9c8f70; line-height: 16px; margin-top: 3px; }
.quest-track { height: 3px; background: #17120c; border-radius: 2px; overflow: hidden; margin-top: 5px; }
.quest-prog { height: 100%; width: 0%; background: #9be47a; }
.quest-reward { font-size: 11px; color: #c9a23c; margin-top: 3px; }
#quest-empty { font-size: 11px; color: #9c8f70; line-height: 1.5; }


#effect-row { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.effect-line { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.effect-name { font-size: 10px; color: #9ec27e; }
.effect-left { font-size: 10px; color: #9c8f70; }
.effect-bar { height: 3px; background: #22201a; border: 1px solid #3d3729; border-radius: 2px; overflow: hidden; }
.effect-fill { height: 100%; background: #6f9c4e; }


#total-level { display: flex; flex-direction: column; gap: 1px; }
.tl-combat { font-size: 12px; color: #e7c86a; }
.tl-style  { font-size: 10px; color: #9ec27e; }
.tl-total  { font-size: 10px; color: #9c8f70; }
.rn-ready { position: absolute; left: 4px; right: 4px; bottom: 2px; height: 2px; border-radius: 1px; }

.rn-recentre { padding: 2px 6px; font-size: 10px; margin-left: 6px; }
.rn-key { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin: 0 3px 0 6px; vertical-align: middle; }


#style-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
#style-row:hover #style-now { color: #e8dcc0; }
#style-now { font-weight: 600; color: #c8b48a; }
#style-now .style-trains { font-weight: 400; color: #9b8f76; font-size: 11px; }
.skill-via { font-size: 10px; color: #8d8267; font-style: italic; margin-top: 1px; }


.tl-standing { display: block; margin-top: 5px; color: #c9b45e; font-weight: 600; }
.tl-next { display: block; margin-top: 2px; color: #8d8267; font-size: 11px; font-style: italic; }
.tl-next b { color: #b3a279; font-style: normal; }


.rn-calls { display: block; margin-top: 2px; font-size: 9px; letter-spacing: .04em;
            text-transform: uppercase; color: #b3a279; }


#tab-map { max-height: 352px; overflow-y: auto; padding-right: 2px; }
#map-tab-head { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px; font-family: Georgia, serif; color: #e7c86a; font-size: 14px; }
#map-overview { padding: 3px 7px; font-family: Arial, sans-serif; font-size: 10px; }
#map-region-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px; max-height: 116px; overflow-y: auto; padding-right: 2px; margin-bottom: 7px; }
.map-region-btn { min-width: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 4px; padding: 4px 5px; text-align: left; background: #221b12; border-color: #453823;
  font-size: 10px; line-height: 1.2; }
.map-region-btn:hover { border-color: #8a744d; }
.map-region-btn.selected { border-color: #e7c86a; background: #34291b; color: #e7c86a; }
.map-region-btn.here { box-shadow: inset 2px 0 #e7c86a; }
.map-region-btn.unexplored { color: #716754; }
.map-region-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-region-mark { flex: none; color: #c9b45e; font-size: 8px; letter-spacing: .04em; text-transform: uppercase; }
#map-region-detail { background: #221b12; border: 1px solid #453823; border-radius: 3px; padding: 7px; }
.map-detail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.map-detail-name { color: #e7c86a; font-family: Georgia, serif; font-size: 14px; }
.map-you-here { color: #9be47a; font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
.map-detail-sub { margin: 2px 0 5px; color: #8d8267; font-size: 10px; font-style: italic; line-height: 1.3; }
.map-status { margin-bottom: 6px; padding: 4px 5px; border-left: 2px solid #c05a4a;
  background: #291b17; color: #c9a58c; font-size: 10px; line-height: 1.35; }
.map-status.safe { border-color: #7fa85e; background: #1d2618; color: #a9c695; }
.map-knowledge-row { margin-top: 5px; font-size: 10px; line-height: 1.35; }
.map-knowledge-label { display: block; margin-bottom: 1px; color: #b3a279;
  font-size: 8px; letter-spacing: .07em; text-transform: uppercase; }
.map-knowledge-value { color: #d0c3a8; }
.map-route-list { display: flex; flex-wrap: wrap; gap: 3px; }
.map-route { padding: 2px 5px; font-size: 9px; color: #c8b48a; background: #2b2118; border-color: #57492e; }
.map-unexplored { padding: 9px 2px 4px; color: #9c8f70; font-size: 12px; }
.map-unexplored small { display: block; margin-top: 5px; color: #716754; font-size: 10px; line-height: 1.4; }


#stamina-row { display: flex; align-items: center; gap: 8px; }
#stamina-bar { position: relative; flex: 1; height: 14px; background: #241f1a;
               border: 1px solid #3d342b; border-radius: 3px; overflow: hidden; }
#stamina-fill { height: 100%; background: #6f8f5e; transition: width .12s linear; }
#stamina-row.running #stamina-fill { background: #8fbf68; }
#stamina-row.held    #stamina-fill { background: #8a7a4a; }
#stamina-row.laden   #stamina-fill { background: #7f8a4e; }
#stamina-text { position: absolute; inset: 0; text-align: center; font-size: 11px;
                line-height: 14px; color: #e8dcc0; text-shadow: 1px 1px 0 #000; }


#tab-journal { max-height: 352px; overflow-y: auto; padding-right: 2px; scrollbar-width: thin; scrollbar-color: #6b5a35 #221b12; }
#tab-journal::-webkit-scrollbar { width: 8px; }
#tab-journal::-webkit-scrollbar-track { background: #221b12; }
#tab-journal::-webkit-scrollbar-thumb { background: #6b5a35; border: 2px solid #221b12; border-radius: 4px; }
#journal-pages { display: flex; gap: 3px; margin-bottom: 6px; }
.journal-page { flex: 1; padding: 3px 4px; font-size: 11px; background: #221b12; border-color: #453823; }
.journal-page.on { color: #e7c86a; border-color: #8a744d; background: #3a2f1f; }
.journal-page-n { color: #9c8f70; font-size: 9px; }
.journal-page.on .journal-page-n { color: #c9b45e; }
#journal-body { display: flex; flex-direction: column; gap: 6px; }
.journal-section { margin: 4px 0 -1px; }
.quest-where { font-size: 10.5px; color: #b3a279; line-height: 1.4; margin-top: 3px; }
.quest-where-k { display: inline-block; min-width: 46px; color: #7f7458; font-size: 8px; letter-spacing: .07em; text-transform: uppercase; }
.quest-source { font-size: 10.5px; color: #9c8f70; font-style: italic; line-height: 15px; margin-top: 4px; }
.quest-entry.lead { border-style: dashed; }
.quest-entry.lead.open { border-color: #c9b45e; border-style: solid; }
.quest-entry.lead.open .quest-count { color: #e7c86a; }
.quest-entry.lead .quest-count { color: #9c8f70; }
.journal-done { display: flex; flex-wrap: wrap; gap: 3px 8px; font-size: 11px; color: #7f7458; line-height: 1.4; }
.journal-done span::before { content: "✓ "; color: #6f9c4e; }
.quest-entry.reading { cursor: pointer; }
.quest-entry.reading:hover { border-color: #8a744d; }
.quest-entry.reading.open { border-color: #6b5a35; }
.quest-entry.reading .quest-note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reading-line { font-size: 11px; color: #b9a9d6; font-style: italic; line-height: 16px; margin-top: 4px; }
.quest-entry.note { display: flex; align-items: flex-start; gap: 6px; }
.note-text { flex: 1; font-size: 12px; line-height: 17px; color: #d8cdb4; white-space: pre-wrap; word-break: break-word; }
.note-strike { flex: none; padding: 0 5px; font-size: 10px; color: #9c8f70; border-color: #453823; background: transparent; }
.note-strike:hover { color: #e06c5a; border-color: #8a5a4a; background: #2a1d18; }
#note-form { margin-top: 2px; }
#note-input { width: 100%; resize: vertical; min-height: 54px; font-family: inherit; font-size: 12px; line-height: 1.4; padding: 5px 7px;
  background: #221b12; color: #e8dcc0; border: 1px solid #453823; border-radius: 3px; user-select: text; }
#note-input:focus { outline: none; border-color: #e7c86a; }
#note-input:disabled { opacity: 0.5; }
#note-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.note-count { font-size: 10px; color: #7f7458; }
#note-write:disabled { opacity: 0.45; cursor: default; }


#shop-says { margin: 2px 0 6px; color: #b9c6ab; font-style: italic; line-height: 1.5; }

/* Browser demo shell: original game palette, responsive controls. */
html { color-scheme: dark; }
a { color: #e7c86a; text-underline-offset: 3px; }
#demo-return { max-width:1108px; margin:0 auto 12px; display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; font-size:12px; color:#b9ad93; }
#demo-return a { display:inline-flex; align-items:center; min-height:44px; }
#topbar { height:auto; min-height:44px; flex-wrap:wrap; gap:10px; }
#topbar-buttons { display:flex; gap:6px; flex-wrap:wrap; }
#topbar-buttons button { margin:0; min-height:44px; }
#game-title small { display:inline-block; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, canvas:focus-visible, [tabindex]:focus-visible { outline:3px solid #e7c86a; outline-offset:3px; }
canvas#game { touch-action:none; }
#player-controls { padding:8px 10px; border:1px solid #57492e; background:#221b12; border-radius:4px; }
#nearby-actions { display:flex; flex-wrap:wrap; gap:6px; max-height:176px; overflow:auto; }
.nearby-action, button.menu-item { min-height:44px; text-align:left; }
#game-status { min-height:20px; color:#e7c86a; line-height:1.5; }
#demo-help summary { cursor:pointer; min-height:44px; display:list-item; align-content:center; }
#demo-help p { margin:0 0 10px; line-height:1.6; color:#cabea5; user-select:text; }
#creation { overflow:auto; padding:16px 0; }
#creation-panel { max-height:calc(100dvh - 32px); overflow:auto; }
#creation-actions { flex-wrap:wrap; }
#creation-actions button, #creation-name, #name-input, .dialogue-option { min-height:44px; }
#creation-right { min-width:0; }
#creation-right label { display:block; margin-bottom:5px; }
#ctx-menu { max-width:calc(100vw - 20px); max-height:70dvh; overflow:auto; }
#overlay-panel { max-width:96%; }
@media(max-width:760px) {
  body { padding:8px; }
  #layout { flex-direction:column; }
  #play-column { flex:none; width:100%; }
  #side-panel { flex:none; width:100%; }
  #topbar { margin-bottom:12px; }
  #game-title small { display:block; margin:4px 0; }
  #dialogue { max-height:100%; overflow:auto; }
  #overlay-panel { max-height:100%; overflow:auto; }
  #tabs .tab-btn { min-height:44px; }
  #inv-grid { grid-template-columns:repeat(6,minmax(0,1fr)); }
  .swatch { width:32px; height:32px; }
  #creation-cols { gap:10px; }
  #creation-panel { padding:14px; }
}
@media(max-width:380px) {
  #inv-grid { grid-template-columns:repeat(4,minmax(0,1fr)); }
  #creation-left { display:none; }
  #game-title { font-size:18px; }
}
@media(prefers-reduced-motion:reduce) { *, *::before, *::after { scroll-behavior:auto!important; transition:none!important; animation:none!important; } }

#game-title { font-weight:normal; }
.demo-region-list { display:grid; gap:8px; }
.demo-region-list button { min-height:44px; }

button.spell-entry, button.craft-entry, button.quest-entry.reading { width:100%; text-align:left; }
