/* EMBERGEIST — melancholy weird-fantasy, ember-lit. */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0d0a09;
  --panel: #171210;
  --panel2: #1e1815;
  --line: #2e2620;
  --text: #d8cfc2;
  --dim: #8a8378;
  --accent: #ff8c4a;
  --gold: #ffcf6b;
}
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Cascadia Mono", ui-monospace, Menlo, Consolas, monospace;
  overflow: hidden;
}
#app { display: flex; flex-direction: column; height: 100vh; max-width: 1500px; margin: 0 auto; padding: 8px; gap: 8px; }

#topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 6px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; color: var(--dim);
}
#brand { color: var(--accent); letter-spacing: 3px; font-weight: 700; }
#brand b { color: var(--gold); }
#floorinfo { color: var(--text); }
#topbtns { margin-left: auto; display: flex; gap: 6px; }
#topbtns button {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; width: 30px; height: 26px; cursor: pointer; font: inherit;
}
#topbtns button:hover { border-color: var(--accent); color: var(--accent); }

#mainrow { display: flex; gap: 8px; flex: 1; min-height: 0; }
#stage { position: relative; flex: 1; display: flex; align-items: flex-start; justify-content: center; min-width: 0; }
canvas#game {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  max-width: 100%; max-height: 100%; image-rendering: pixelated; cursor: crosshair;
}
#hint {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 8px;
  color: var(--gold); font-size: 12px; text-shadow: 0 1px 3px #000; pointer-events: none;
}

#side {
  width: 285px; flex-shrink: 0; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
#side section { margin-bottom: 12px; }
#side h3 {
  font-size: 10px; text-transform: uppercase; letter-spacing: 2px;
  color: var(--dim); border-bottom: 1px solid var(--line); margin-bottom: 5px; padding-bottom: 2px;
}
.hprow { display: flex; align-items: center; gap: 8px; }
#hpwrap { flex: 1; height: 14px; background: #241a16; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
#hpbar { height: 100%; width: 100%; background: #7fd97f; transition: width .15s; }
#hptext { font-size: 13px; color: var(--text); min-width: 52px; text-align: right; }
.vitals { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; }
.ember-ico { color: var(--gold); }
#embers { color: var(--gold); font-weight: 700; }
.noiselabel { margin-left: auto; color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; }
#noisewrap { width: 60px; height: 8px; background: #241a16; border-radius: 3px; overflow: hidden; border: 1px solid var(--line); }
#noisebar { height: 100%; width: 0; background: linear-gradient(90deg, #c9a832, #ff6b3a); transition: width .2s; }
#noisetext { font-size: 10px; color: var(--dim); min-width: 56px; }

.chip {
  display: inline-block; border: 1px solid var(--dim); border-radius: 10px;
  font-size: 11px; padding: 1px 8px; margin: 1px 3px 1px 0; color: var(--dim);
}
.chip.dim { opacity: .6; }
.eq { font-size: 12px; padding: 1px 0; }
.eq .k { color: var(--dim); font-size: 10px; margin-right: 5px; text-transform: uppercase; }
.aspect { font-size: 12px; color: var(--gold); padding: 1px 0; }
.slot { font-size: 12px; padding: 2px 4px; border-radius: 4px; cursor: pointer; }
.slot:hover { background: var(--panel2); }
.slot .key {
  display: inline-block; width: 15px; color: var(--bg); background: var(--dim);
  border-radius: 3px; text-align: center; font-size: 10px; margin-right: 5px;
}
.dim { color: var(--dim); }
.small { font-size: 11px; }
.keysref b { color: var(--text); }

#log {
  height: 132px; overflow-y: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 12.5px;
}
.msg { padding: 0.5px 0; color: var(--dim); }
.msg.hit { color: #ffb36b; }
.msg.pain { color: #ff6b6b; }
.msg.good { color: #9be89b; }
.msg.bad { color: #ff8f5c; }
.msg.note { color: #d9c9a8; }
.msg.kill { color: #ff9d9d; }
.msg.ember { color: var(--gold); }
.msg.title { color: var(--gold); font-weight: 700; }
.msg.lore { color: #b8a8d9; font-style: italic; }

#tooltip {
  display: none; position: fixed; z-index: 50; max-width: 300px;
  background: rgba(18, 14, 12, .96); border: 1px solid #4a3b33; border-radius: 8px;
  padding: 8px 10px; font-size: 12px; pointer-events: none; box-shadow: 0 4px 18px rgba(0,0,0,.6);
}
.tt-name { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.tt-intent { color: #ff8f5c; margin: 2px 0; }
.tt-preview { color: #9be89b; }
.tt-status { color: #b48ad6; }
.tt-desc { color: var(--dim); font-style: italic; margin-top: 3px; }
.tt-terrain { color: #d9c9a8; margin-top: 3px; border-top: 1px dashed var(--line); padding-top: 3px; }

/* modals */
.backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(8, 5, 4, .8);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.card {
  background: var(--panel); border: 1px solid #4a3b33; border-radius: 12px;
  max-width: 720px; width: 100%; max-height: 92vh; overflow-y: auto;
  padding: 22px 26px; box-shadow: 0 8px 40px rgba(0,0,0,.7);
}
.card h2 { color: var(--accent); letter-spacing: 2px; margin-bottom: 10px; font-size: 20px; }
.card .sub { color: var(--text); margin-bottom: 14px; font-size: 13px; }
.card .cause { color: var(--gold); font-size: 15px; font-style: italic; }
.opts { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; cursor: pointer; font: inherit;
}
.opt:hover:not(.disabled) { border-color: var(--accent); background: #251c17; }
.opt.disabled { opacity: .45; cursor: not-allowed; }
.optkey {
  background: var(--dim); color: var(--bg); border-radius: 4px;
  min-width: 20px; text-align: center; font-weight: 700; flex-shrink: 0; margin-top: 1px;
}
.optbody b { color: var(--gold); display: block; margin-bottom: 2px; }
.optbody small { color: var(--dim); font-size: 12px; line-height: 1.4; display: block; }
.deathstats { margin: 10px 0; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.titlefoot { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.linkbtn {
  background: none; border: 1px solid var(--line); color: var(--gold);
  border-radius: 8px; padding: 8px; cursor: pointer; font: inherit; font-size: 13px;
}
.linkbtn:hover { border-color: var(--gold); }
.seedrow { font-size: 12px; color: var(--dim); }
.seedrow input {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 4px 8px; font: inherit; width: 130px; margin-left: 6px;
}
.help { display: flex; gap: 18px; flex-wrap: wrap; }
.hcol { flex: 1; min-width: 200px; }
.hcol h3 { color: var(--accent); font-size: 12px; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 6px; }
.hcol p { font-size: 12px; margin-bottom: 6px; color: var(--text); }

/* small screens: stack; the game stays playable on a laptop, phones get best-effort */
@media (max-width: 980px) {
  #app { height: auto; }
  body { overflow: auto; }
  #mainrow { flex-direction: column; }
  #side { width: 100%; }
}
