:root {
  --ink: #f1e6cf; --dim: #a89c86; --panel: #17131a; --edge: #4a3b33; --gold: #ffd76a;
  --bad: #ff7a5c; --good: #9ee28a; --blue: #8cc8ff;
  --font: "Lucida Console", Consolas, "Courier New", monospace;
  --shopw: 268px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #07060a; color: var(--ink); font-family: var(--font); font-size: 13px; user-select: none; }
canvas { position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; image-rendering: pixelated; display: block; }
#ov { cursor: crosshair; }
.hidden { display: none !important; }
img { image-rendering: pixelated; }

/* chunky pixel frame shared by every panel */
#top, #objective, #shop, .logline, #hint, #dialog, #cutText, #modalBox, #titleBox, #tip, button {
  background: var(--panel); border: 2px solid var(--edge);
  box-shadow: 0 0 0 2px #000, 4px 4px 0 2px rgba(0, 0, 0, 0.55);
}
button { color: var(--ink); font: inherit; padding: 5px 9px; cursor: pointer; }
button:hover { border-color: var(--gold); }
button:disabled { opacity: 0.5; cursor: default; }

/* ---- HUD: four corners that cannot run into each other ---------------------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button, #shop, #top { pointer-events: auto; }

/* top left: figures and the current aim */
#topLeft { position: absolute; left: 10px; top: 10px; right: calc(var(--shopw) + 30px); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
#top { padding: 6px 10px; display: flex; flex-wrap: wrap; gap: 4px 18px; max-width: 100%; }
#top span { white-space: nowrap; }
#coins { color: var(--gold); font-weight: bold; min-width: 70px; }
.warn { color: var(--bad); } .mid { color: var(--gold); }
/* what Ansel is carrying: a gauge of its own, so that it cannot be missed */
#carry { background: var(--panel); border: 2px solid var(--edge); box-shadow: 0 0 0 2px #000, 4px 4px 0 2px rgba(0, 0, 0, 0.55); padding: 5px 10px; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
#carryName { color: var(--ink); }
#carryBar { display: inline-block; width: 132px; height: 12px; background: #0b090d; border: 2px solid var(--edge); }
#carryBar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.15s; }
#carryNum { min-width: 42px; }
#carryNote { color: var(--dim); }
#carry.full { border-color: var(--bad); animation: carryFull 0.9s steps(2) infinite; }
#carry.full #carryBar i { background: var(--bad); }
#carry.full #carryNote { color: var(--bad); font-weight: bold; }
@keyframes carryFull { 50% { border-color: var(--gold); } }
#objective { padding: 5px 10px; color: var(--blue); max-width: min(640px, 100%); line-height: 1.35; }
#objective:empty { display: none; }
/* a man under the pointer: his face, his name, and everything about him */
#mancard { position: fixed; display: none; width: 318px; z-index: 6; pointer-events: none; background: var(--panel); border: 2px solid var(--edge); box-shadow: 0 0 0 2px #000, 4px 4px 0 2px rgba(0, 0, 0, 0.55); padding: 8px 10px 9px; font-size: 12px; line-height: 1.35; color: var(--ink); }
#mancard .mc-pin { color: var(--gold); font-size: 11px; margin: -2px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--edge); }
#mancard .mc-top { display: flex; gap: 10px; align-items: flex-start; }
#mancard img.mc-face { width: 64px; height: 72px; image-rendering: pixelated; border: 2px solid var(--edge); background: #0b090d; flex: none; }
#mancard .mc-name { color: var(--gold); font-weight: bold; font-size: 15px; }
#mancard .mc-role { color: var(--blue); }
#mancard .mc-dim { color: var(--dim); }
#mancard .mc-doing { margin-top: 3px; }
#mancard .mc-doing.block { color: #ffb0a0; }
#mancard .mc-rows { margin-top: 7px; display: grid; grid-template-columns: 78px 1fr 34px; gap: 3px 8px; align-items: center; }
#mancard .mc-bar { height: 8px; background: #0b090d; border: 1px solid var(--edge); }
#mancard .mc-bar i { display: block; height: 100%; background: var(--gold); }
#mancard .mc-bar.bad i { background: var(--bad); } #mancard .mc-bar.good i { background: #6fb06a; } #mancard .mc-bar.mid i { background: #7aa7d8; }
#mancard .mc-num { text-align: right; color: var(--dim); }
#mancard .mc-sec { margin-top: 7px; padding-top: 5px; border-top: 1px solid var(--edge); color: var(--dim); }
#mancard .mc-sec b { color: var(--ink); font-weight: normal; }
#mancard .mc-log { margin-top: 5px; color: var(--dim); font-size: 11px; }
/* the panel of a zone: what it is for, how much it matters, how many men */
#zone { background: var(--panel); border: 2px solid var(--edge); box-shadow: 0 0 0 2px #000, 4px 4px 0 2px rgba(0, 0, 0, 0.55); padding: 6px 8px; pointer-events: auto; font-size: 12px; max-width: min(640px, 100%); }
#zone:empty { display: none; }
#zone .zhead { color: var(--blue); margin-bottom: 4px; }
#zone div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 3px; }
#zone span { color: var(--dim); min-width: 52px; }
#zone b { min-width: 30px; text-align: center; }
#zone button { box-shadow: none; padding: 2px 7px; }
#zone button.on { border-color: var(--gold); color: var(--gold); }
/* what the men ask for: a line each, the ones that stop work first, with the line of the ledger that answers it */
#asks { display: flex; flex-direction: column; gap: 5px; max-width: min(640px, 100%); pointer-events: auto; }
#asks:empty { display: none; }
.ask { background: var(--panel); border: 2px solid var(--edge); box-shadow: 0 0 0 2px #000, 4px 4px 0 2px rgba(0, 0, 0, 0.55); padding: 4px 8px; display: flex; align-items: center; gap: 10px; line-height: 1.3; font-size: 12px; color: var(--dim); }
.ask span { flex: 1; }
.ask.stop { border-color: var(--bad); color: #ffd0c4; }
.ask button { box-shadow: none; padding: 2px 8px; white-space: nowrap; color: var(--gold); }
.ask button.poor { opacity: 0.55; color: var(--bad); }
.asked { margin: 4px 0 8px 18px; padding: 0; line-height: 1.4; } .asked .stop { color: #ffd0c4; } .asked i { color: var(--dim); }
#finale { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); padding: 6px 12px; background: #3a1010; border: 2px solid var(--bad); color: #ffd9cf; display: none; }

/* top right: the ledger */
#shop { position: absolute; right: 10px; top: 10px; width: var(--shopw); max-height: calc(100vh - 86px); display: none; flex-direction: column; padding: 0; }
#shopTitle { color: var(--ink); padding: 6px 8px; display: flex; align-items: center; gap: 8px; cursor: pointer; border-bottom: 2px solid var(--edge); }
#shopTitle .ico { width: 24px; height: 24px; }
#shopTitle b { flex: 1; font-weight: normal; }
#shopTitle i { color: var(--dim); font-style: normal; }
#shopBody { overflow-y: auto; padding: 6px; }
#shop.folded #shopBody { display: none; }
#shop.folded #shopTitle { border-bottom: 0; }
.cat { color: var(--gold); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; padding: 6px 4px 3px; border-top: 1px solid var(--edge); margin-top: 4px; }
.cat:first-child { border-top: 0; margin-top: 0; }
.buy { display: grid; grid-template-columns: 1fr auto; width: 100%; text-align: left; margin-bottom: 5px; box-shadow: none; gap: 2px 6px; }
.buy .bn { font-weight: bold; } .buy .bc { color: var(--gold); } .buy .bc::before { content: "◉ "; }
.buy .bd { grid-column: 1 / 3; color: var(--dim); font-size: 11px; line-height: 1.3; }
.buy.poor { opacity: 0.55; } .buy.poor .bc { color: var(--bad); }
.buy.d1 { margin-left: 10px; width: calc(100% - 10px); border-left: 3px solid var(--edge); }
.buy.d2 { margin-left: 22px; width: calc(100% - 22px); border-left: 3px solid var(--edge); }
.buy.locked { opacity: 0.5; cursor: default; }
.buy .bl { color: var(--dim); font-size: 11px; }
.buy .pips { grid-column: 1 / 3; color: var(--gold); font-size: 9px; letter-spacing: 1px; line-height: 1; }
#toggles select { background: #17131a; color: inherit; border: 1px solid var(--edge); font: inherit; max-width: 100%; }
#toggles label { display: block; padding: 3px 4px; color: var(--dim); font-size: 12px; cursor: pointer; }

/* bottom left: messages stacked on the tool bar; the bar wraps upward and pushes them up */
#bottomLeft { position: absolute; left: 10px; bottom: 10px; right: calc(var(--shopw) + 30px); display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
#log { width: min(520px, 100%); display: flex; flex-direction: column; gap: 5px; }
.logline { padding: 4px 8px; line-height: 1.35; transition: opacity 3s; }
.logline.old { opacity: 0.35; }
.logline.bad { border-color: var(--bad); color: #ffd0c4; }
.logline.good { border-color: #4c7a44; color: var(--good); }
.logline.lie { border-color: #3fd6b0; color: #9ffbe0; font-style: italic; }
#tools { display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; }
#hands { display: flex; gap: 5px; margin-bottom: 6px; }
#hands:empty { display: none; }
.tool.hand { width: 38px; height: 38px; } .tool.hand .ico { width: 28px; height: 28px; }

/* icon buttons */
.ico { display: block; width: 36px; height: 36px; pointer-events: none; }
.tool, .sys { position: relative; padding: 0; width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; flex: none; }
.tool u, .sys u { position: absolute; left: 3px; top: 1px; font-size: 10px; line-height: 1; color: var(--dim); text-decoration: none; text-transform: uppercase; }
.tool i { position: absolute; right: 2px; bottom: 1px; font-size: 10px; line-height: 1; color: var(--gold); font-style: normal; background: rgba(23, 19, 26, 0.85); padding: 0 1px; }
.tool i.free { color: var(--good); }
.tool.on { border-color: var(--gold); background: #33291f; box-shadow: 0 0 0 2px #000, 0 0 0 4px rgba(255, 215, 106, 0.35), 4px 4px 0 2px rgba(0, 0, 0, 0.55); }
.tool.fire { margin-left: 10px; }
.tool.fire.armed { border-color: var(--bad); background: #3a1614; }
.tool.fire.armed i { color: #ffd9cf; }
.sys { width: 38px; height: 38px; }
.sys .ico { width: 24px; height: 24px; }
.sys.off .ico { opacity: 0.3; }
.sys b { position: absolute; right: 2px; bottom: 1px; font-size: 9px; line-height: 1; color: var(--gold); font-weight: normal; background: rgba(23, 19, 26, 0.85); }

/* bottom right: the things that are not tools */
#corner { position: absolute; right: 10px; bottom: 10px; width: var(--shopw); display: flex; gap: 6px; justify-content: flex-end; align-items: flex-end; }
#fps { position: absolute; right: 2px; bottom: 46px; color: var(--dim); font-size: 10px; white-space: nowrap; opacity: 0.7; }

/* floating bits */
#hint { position: absolute; left: 50%; top: 96px; transform: translateX(-50%); padding: 5px 12px; opacity: 0; transition: opacity 0.4s; max-width: min(70vw, 720px); text-align: center; z-index: 4; }
#tip { position: fixed; display: none; padding: 6px 9px; max-width: 280px; line-height: 1.35; z-index: 6; pointer-events: none; }
#tip b { color: var(--gold); } #tip em { color: var(--dim); font-style: normal; float: right; margin-left: 12px; }
#tip span { display: block; color: var(--dim); font-size: 12px; margin-top: 3px; }
#inspect { position: fixed; display: none; pointer-events: none; padding: 2px 7px; font-size: 12px; white-space: nowrap; z-index: 5;
  background: rgba(16, 13, 18, 0.9); border: 1px solid var(--edge); color: var(--dim); }
#inspect.block { color: #ffb4a4; border-color: #a04a3c; }
#inspect.pass { color: var(--good); border-color: #4c7a44; }
#inspect.water { color: var(--blue); }

/* ---- dialogue, cutscenes, modal, title -------------------------------------- */
#dialog { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); width: min(760px, 92vw); padding: 12px; display: flex; gap: 14px; z-index: 20; cursor: pointer; }
#dlgPic { width: 128px; height: 128px; border: 2px solid var(--edge); flex: none; background: #0d2a33; }
#dlgBody { flex: 1; display: flex; flex-direction: column; min-height: 128px; }
#dlgName { color: var(--gold); font-weight: bold; margin-bottom: 6px; min-height: 16px; }
#dlgText { flex: 1; font-size: 15px; line-height: 1.5; }
#dlgNext, #cutNext { color: var(--dim); text-align: right; font-size: 11px; }

#cutscene { position: fixed; inset: 0; background: #050408; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; cursor: pointer; }
#cutImg { width: min(1152px, 94vw, 135vh); aspect-ratio: 3 / 2; border: 2px solid var(--edge); box-shadow: 0 0 0 2px #000; }
#cutText { width: min(900px, 90vw); padding: 12px 16px; font-size: 16px; line-height: 1.5; min-height: 76px; }
#cutNext { width: min(900px, 90vw); }

#modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 60; display: flex; align-items: center; justify-content: center; }
#modalBox { width: min(720px, 92vw); max-height: 84vh; overflow-y: auto; padding: 16px 20px; position: relative; line-height: 1.5; }
#modalBox h2 { margin: 0 0 8px; color: var(--gold); } #modalBox h3 { margin: 14px 0 2px; color: var(--blue); font-size: 14px; }
#modalBox p { margin: 6px 0; font-size: 14px; }
#modalBox .legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; margin: 8px 0; }
#modalBox .legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; }
#modalBox .legend .ico { width: 24px; height: 24px; }
#modalBox .legend u { color: var(--dim); text-decoration: none; text-transform: uppercase; min-width: 12px; }
#modalBox .curioHead { margin-top: 22px; border-top: 1px solid rgba(255,255,255,0.15); padding-top: 14px; }
#modalBox .curio { display: flex; gap: 14px; align-items: flex-start; margin: 12px 0; }
#modalBox .curio img { width: 192px; height: 128px; image-rendering: pixelated; border: 1px solid rgba(255,255,255,0.2); flex: none; }
#modalBox .curio h3 { margin: 0 0 4px; }
#modalBox .curio p { margin: 0; }
#modalBox .curio.unknown { opacity: 0.75; }
#modalBox .curio .q { width: 192px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 26px; border: 1px dashed rgba(255,255,255,0.25); color: var(--dim); }
#modalBox table.book { width: 100%; border-collapse: collapse; margin: 4px 0 10px; font-size: 13px; }
#modalBox table.book th { text-align: left; color: var(--dim); font-weight: normal; padding: 2px 10px 2px 0; }
#modalBox table.book td { padding: 2px 10px 2px 0; vertical-align: top; }
#modalBox h3.rel { display: flex; align-items: baseline; gap: 8px; }
#modalBox h3.rel b { color: var(--gold); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
#modalBox h3.rel i { margin-left: auto; color: var(--dim); font-style: normal; font-weight: normal; font-size: 12px; }
#modalBox ul.rel { margin: 4px 0 0; padding-left: 20px; font-size: 14px; }
#modalBox ul.rel li { margin: 3px 0; }
#xp { color: var(--blue); } #xp.pts { color: var(--good); font-weight: bold; }
.stabs { display: flex; gap: 8px; margin: 0 0 10px; }
.stabs button { box-shadow: none; padding: 6px 14px; opacity: 0.6; }
.stabs button.on { opacity: 1; border-color: var(--gold); color: var(--gold); }
#storeInfo .sbar { height: 8px; border: 1px solid var(--edge); background: #0b090d; margin: 4px 0 2px; } #storeInfo .sbar i { display: block; height: 100%; background: var(--blue); }
#storeInfo .slevel { color: var(--blue); font-size: 15px; } #storeInfo .sxp { color: var(--dim); font-size: 12px; margin-bottom: 14px; }
#modalBox.wide { width: min(1120px, 96vw); max-height: 92vh; }
#modalBox { scrollbar-width: thin; scrollbar-color: var(--edge) transparent; }
.store { display: flex; gap: 14px; height: min(60vh, 640px); }
#storeTree { flex: 1; min-width: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--edge) #0e0b10; border: 1px solid var(--edge); background: #0e0b10; padding: 12px; }
#storeIn { position: relative; }
#storeIn svg { position: absolute; left: 0; top: 0; pointer-events: none; }
#storeIn path { fill: none; stroke: #3a2f2a; stroke-width: 2; }
#storeIn path.on { stroke: #9a7c4c; }
.tcat { position: absolute; left: 0; color: var(--blue); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
.tnode { position: absolute; width: 172px; height: 46px; padding: 4px 7px; text-align: left; box-shadow: none; display: grid; grid-template-columns: 1fr auto; gap: 0 6px; align-content: center; font-size: 12px; line-height: 1.3; overflow: hidden; }
.tnode b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tnode span { color: var(--gold); white-space: nowrap; }
.tnode i { grid-column: 1 / 3; color: var(--gold); font-style: normal; font-size: 8px; letter-spacing: 1px; line-height: 1.2; min-height: 10px; }
.tnode.s-done { border-color: var(--gold); background: #2a2212; }
.tnode.s-can { border-color: var(--good); }
.tnode.s-poor span { color: var(--bad); }
.tnode.s-locked { opacity: 0.6; } .tnode.s-locked span { color: var(--dim); font-size: 10px; }
.tnode.s-unknown { opacity: 0.4; border-style: dashed; }
.tnode.sel { outline: 2px solid var(--ink); outline-offset: 1px; opacity: 1; }
#storeInfo { width: 300px; flex: none; overflow-y: auto; }
#storeInfo h3 { margin: 2px 0 6px; color: var(--gold); font-size: 17px; }
#storeInfo .scat { color: var(--blue); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
#storeInfo .spips { color: var(--gold); font-size: 11px; letter-spacing: 2px; } #storeInfo .spips span { color: var(--dim); letter-spacing: 0; margin-left: 6px; }
#storeInfo .scost { margin: 12px 0 8px; color: var(--gold); font-size: 16px; } #storeInfo .scost span { display: block; color: var(--dim); font-size: 12px; }
#storeInfo #storeBuy { width: 100%; padding: 9px; font-size: 15px; }
#storeInfo .good { color: var(--good); } #storeInfo .bad { color: var(--bad); } #storeInfo .dimmed, #storeInfo .spurse { color: var(--dim); }
#storeInfo .spurse { margin-top: 16px; font-size: 12px; }
#modalClose { position: absolute; right: 10px; top: 10px; box-shadow: none; }

#title { position: fixed; inset: 0; z-index: 50; background: #050408; display: flex; align-items: flex-start; justify-content: flex-start; padding: 7vh 6vw; }
#titleImg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#titleBox { position: relative; padding: 22px 34px; text-align: center; background: rgba(15, 12, 18, 0.88); }
#titleBox h1 { margin: 0; font-size: 44px; letter-spacing: 6px; color: var(--gold); text-shadow: 3px 3px 0 #5a2a14; }
#titleBox .sub { margin: 4px 0 18px; color: var(--ink); }
#titleBox .small { color: var(--dim); font-size: 11px; margin: 14px 0 0; }
#titleBox button { display: block; width: 100%; margin: 8px 0; font-size: 15px; padding: 8px; }
/* the version, and the way to what is new: a line of small print that can be clicked, not a third big button */
#titleBox #btnVersion { background: none; border: 0; box-shadow: none; margin: 8px 0 0; padding: 2px; font-size: 11px; color: var(--dim); }
#titleBox #btnVersion:hover { color: var(--ink); text-decoration: underline; }
#titleBox #btnVersion.fresh { color: var(--gold); }
/* a shared mine: a name, a code, and the three ways in */
#me { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
#me input#mpName { flex: 1; min-width: 0; padding: 7px 8px; font: inherit; font-size: 14px; color: var(--ink); background: #0b090d; border: 2px solid var(--edge); user-select: text; }
#me input#mpName:focus { outline: none; border-color: var(--gold); }
#me label { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--dim); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; cursor: pointer; }
#me input[type=color] { width: 30px; height: 24px; padding: 0; border: 2px solid var(--edge); background: #0b090d; cursor: pointer; }
#lobby { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--edge); }
#lobby .lobbyHead { color: var(--dim); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 6px; }
#lobby input { display: block; width: 100%; margin: 6px 0; padding: 7px 8px; font: inherit; font-size: 14px; color: var(--ink); background: #0b090d; border: 2px solid var(--edge); user-select: text; }
#lobby input:focus { outline: none; border-color: var(--gold); }
#lobby .lobbyRow { display: flex; gap: 8px; align-items: stretch; }
#lobby .lobbyRow input { flex: 1; margin: 6px 0; text-transform: uppercase; letter-spacing: 3px; text-align: center; }
#lobby .lobbyRow button { width: auto; margin: 6px 0; padding: 6px 16px; }
#titleBox #lobby button { font-size: 14px; padding: 7px; margin: 6px 0; }
#loading { min-height: 18px; color: var(--blue); margin-top: 6px; }

#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 15; }

/* narrow windows: a slimmer ledger and smaller buttons */
@media (max-width: 1000px) {
  :root { --shopw: 236px; }
  .tool { width: 40px; height: 40px; } .tool .ico { width: 30px; height: 30px; }
  .sys { width: 34px; height: 34px; } #corner { gap: 4px; }
}

/* dev mode */
#dev { position: fixed; left: 10px; top: 96px; width: min(760px, calc(100vw - var(--shopw) - 40px)); z-index: 45; padding: 10px 12px;
  background: #101a24; border: 2px solid #3f6f9a; box-shadow: 0 0 0 2px #000, 4px 4px 0 2px rgba(0, 0, 0, 0.55); }
.devhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.devhead b { color: var(--blue); letter-spacing: 1px; } .devhead i { color: var(--dim); font-style: normal; font-size: 11px; }
.devrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 0; border-top: 1px solid #24405a; }
.devrow span { width: 74px; color: var(--dim); font-size: 12px; flex: none; }
.devrow button { box-shadow: none; padding: 3px 8px; font-size: 12px; background: #17232f; border-color: #2f5273; }
.devrow button:hover { border-color: var(--blue); }
.devrow button.on { border-color: var(--gold); color: var(--gold); background: #2a2616; }
