:root {
  --bg: #0b0b0d; --panel: #16140f; --edge: #5b4a2c; --gold: #d8b36a; --text: #e8e2d4; --muted: #9a927f;
  --font: "MingLiU", "PMingLiU", "新細明體", "Microsoft JhengHei", "PingFang TC", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.45 var(--font); overflow: hidden; }
#app { display: flex; height: 100%; padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); }
#stage-wrap { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; min-width: 0; }

/* the client screen: 640x480, scaled as a whole (main.js) */
#stage { position: relative; width: 640px; height: 480px; flex: none; transform-origin: center center; background: #000;
  font: 12px/13px var(--font); color: #fff; user-select: none; -webkit-user-select: none; overflow: hidden; touch-action: none; -webkit-touch-callout: none; }
#stage img { image-rendering: pixelated; }
#game { position: absolute; left: 0; top: 0; display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #000; color: var(--gold); font-size: 14px; z-index: 1000; }

/* HUD 406 / 431 */
#hud { position: absolute; left: 0; top: 355px; width: 640px; height: 125px; z-index: 5; }
#hud > * { position: absolute; }
#hud .bg { left: 0; top: 0; pointer-events: none; }
.hud-txt { color: #e8e8e8; text-shadow: 1px 1px 0 #000; white-space: nowrap; overflow: hidden; pointer-events: none; }
.hud-txt.name { padding-left: 4px; color: #fff; }
.c { text-align: center; }
.small { font-size: 11px; letter-spacing: -.2px; }
.gauge { background-repeat: no-repeat; pointer-events: none; }
.chat { overflow-y: auto; overflow-x: hidden; font-size: 12px; line-height: 16px; padding: 0 2px; scrollbar-width: none; }
.chat::-webkit-scrollbar { display: none; }
.chat .line { white-space: pre-wrap; word-break: break-all; text-shadow: 1px 1px 0 #000; }
.menu { cursor: pointer; } .menu img { position: absolute; left: 0; top: 0; }
.btn { cursor: pointer; }

/* windows: one client bitmap each */
.win { position: absolute; z-index: 10; }
.win > * { position: absolute; }
.win > .bg { left: 0; top: 0; }
.win .close { cursor: pointer; }
.win .close .close-tag { position: absolute; left: 1px; top: -1px; }
.win-txt { color: #e8e8e8; text-shadow: 1px 1px 0 #000; white-space: nowrap; overflow: hidden; pointer-events: none; }
.hit { cursor: pointer; }
.thumb { background: rgba(255, 240, 200, .18); border-radius: 3px; pointer-events: none; }

.inv-grid { overflow: hidden; }
.slot, .eqbox { position: absolute; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.slot img, .eqbox img { width: 32px; height: 32px; pointer-events: none; }
.slot:hover, .eqbox:hover { outline: 1px solid rgba(255, 220, 140, .7); }
.slot.sel { outline: 1px solid #8cf; }
body.targeting #stage, body.targeting .slot, body.targeting .eqbox { cursor: crosshair; }
.flash-success { animation: fl-s .9s; } .flash-curse { animation: fl-c .9s; } .flash-nothing { animation: fl-n .9s; } .flash-rejected { animation: fl-n .5s; }
@keyframes fl-s { 0%, 60% { box-shadow: 0 0 8px 3px rgba(80, 170, 255, .9) inset; } }
@keyframes fl-c { 0%, 60% { box-shadow: 0 0 8px 3px rgba(0, 0, 0, .95) inset; } }
@keyframes fl-n { 0%, 60% { box-shadow: 0 0 8px 3px rgba(220, 230, 255, .8) inset; } }
.layer { left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.layer > * { position: absolute; pointer-events: auto; }
.layer > .win-txt { pointer-events: none; }

.tip { position: absolute; z-index: 900; padding: 1px 4px; background: rgba(0, 0, 0, .85); border: 1px solid #6b5a38; color: #fff; white-space: nowrap; pointer-events: none; font-size: 12px; line-height: 14px; }

.dlg-body { overflow-y: auto; overflow-x: hidden; color: #fff; font-size: 12px; line-height: 16px; scrollbar-width: none; user-select: text; }
.dlg-body::-webkit-scrollbar { display: none; }
.dlg-body p { margin: 0; }
.dlg-body pre { white-space: pre-wrap; font: inherit; margin: 0; }
.dlg-body a { color: #f4dc7a; cursor: pointer; text-decoration: none; }
.dlg-body a:hover { color: #fff3b0; }
.html-btn { cursor: pointer; vertical-align: middle; }

.shop-rows { overflow: hidden; }
.shop-row { position: absolute; cursor: pointer; }
.shop-row > * { position: absolute; }
.shop-row .nm { color: #fff; white-space: nowrap; overflow: hidden; }
.shop-row .pr { color: #f4dc7a; white-space: nowrap; }
.shop-row:hover .nm { color: #fff3b0; }
.shop-row.picked .nm { color: #8fe; }
#qty { position: absolute; width: 134px; height: 93px; z-index: 50; }
#qty > * { position: absolute; }
.qty-in { background: #000; color: #fff; border: 0; font: 12px var(--font); text-align: center; padding: 0; outline: none; }
.qty-in::-webkit-inner-spin-button { display: none; }

/* side panel (outside the client screen) */
#side { width: 300px; flex: none; overflow-y: auto; padding: 12px 14px; background: var(--panel); border-left: 1px solid #2a2418; }
#side h1 { font-size: 16px; margin: 0 0 4px; color: var(--gold); }
#side h2 { font-size: 13px; margin: 12px 0 4px; color: var(--gold); border-bottom: 1px solid #2a2418; }
#side p { margin: 4px 0; }
#side table { border-collapse: collapse; width: 100%; } #side td { padding: 1px 4px; } #side td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#side .warn { color: #f99; }
#hist { padding-left: 18px; margin: 0; font-size: 12px; max-height: 300px; overflow-y: auto; }
#hist li { margin-bottom: 3px; }
#hist li span { color: var(--muted); }
#hist .k-success { color: #9ee6ff; } #hist .k-destroy { color: #ff8b8b; } #hist .k-nothing { color: #ddd; } #hist .k-curse { color: #c9a; } #hist .k-rejected { color: #888; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
#side button { font: inherit; color: var(--text); background: linear-gradient(#3b3222, #231d13); border: 1px solid var(--edge); padding: 3px 9px; cursor: pointer; }
#side button:hover { border-color: var(--gold); }
#side button.on { border-color: #6c6; color: #bfb; }
.muted { color: var(--muted); }
#side .small { font-size: 11px; }
code { color: #cdb; }
#side a { color: var(--gold); }

@media (max-width: 900px) {
  #app { flex-direction: column; }
  #stage-wrap { flex: none; height: 75vw; min-height: 240px; }
  #side { width: auto; border-left: 0; border-top: 1px solid #2a2418; flex: 1; }
}
.dlg-body, .chat { touch-action: pan-y; }
