:root {
  --bg: #0c0d10;
  --panel: #14161c;
  --line: #2a2e38;
  --text: #e8e0d4;
  --muted: #9a9084;
  --gold: #c9b095;
  --accent: #d4b483;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.4 Tahoma, "Segoe UI", sans-serif; }
body { display: flex; overflow: hidden; }

#sidebar {
  width: 280px;
  flex: 0 0 280px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
#sidebar header { padding: 14px 14px 8px; border-bottom: 1px solid var(--line); }
.brand { font-size: 16px; letter-spacing: 0.04em; color: var(--gold); }
.sub { color: var(--muted); font-size: 11px; margin: 4px 0 10px; }
#search {
  width: 100%;
  background: #0c0d10;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 8px;
  border-radius: 4px;
}
#scenes { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
#scenes button, #toolbar button, #toolbar label {
  background: #1c2028;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 8px;
  cursor: pointer;
}
#scenes button.active, #groups button.active { background: #3a3228; border-color: var(--gold); color: var(--gold); }
#groups { overflow: auto; flex: 1; padding: 8px 0 24px; }
.group-title { color: var(--muted); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; padding: 10px 14px 4px; }
#groups button {
  display: block;
  width: calc(100% - 16px);
  margin: 2px 8px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
}
#groups button:hover { background: #1c2028; }
#groups button.fail { color: #c97a7a; }

main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
#title { font-size: 14px; color: var(--gold); margin-right: auto; }
#inspectLabel { color: var(--muted); font-size: 11px; }
#toolbar label { display: flex; align-items: center; gap: 6px; user-select: none; }

#stageWrap { flex: 1; overflow: auto; background: #07080a; }
#stage { min-width: 0; min-height: 0; display: block; padding: 12px; }
#screen {
  position: relative;
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
  overflow: hidden;
  background-color: #10140f;
  background-image: url("ingame-bg.jpg");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  box-shadow: 0 20px 80px rgba(0,0,0,0.55);
}

#screen.bg-login,
#screen.bg-intro,
#screen.bg-ingame {
  background-color: #10140f;
  background-image: url("ingame-bg.jpg");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.widget { position: absolute; }
.widget.hidden { display: none !important; }
.widget.inspect:hover { outline: 1px solid rgba(212, 180, 131, 0.85); }
#screen.outlines .widget { outline: 1px dashed rgba(255,255,255,0.12); }

.image, .expanded-image, .slice, .text { pointer-events: none; }
.image img, .expanded-image img, .button img { display: block; max-width: none; image-rendering: pixelated; }
.image.has-size img, .expanded-image.has-size img, .button.has-size img {
  width: 100%;
  height: 100%;
}
.button, .titlebar { pointer-events: auto; z-index: 4; cursor: pointer; }
.titlebar, .horizontalbar, .gauge { overflow: hidden; }
.scrollbar { overflow: hidden; }
.game-hidden { display: none !important; }
.window-root.hud { z-index: 5; }
.window-root.float-win { z-index: 6; }
.window-root.modal-win { z-index: 9; }
.chat-bar {
  position: absolute;
  left: 645px;
  top: 818px;
  width: 630px;
  height: 225px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: auto;
}
.chat-log {
  background: rgba(0, 0, 0, 0.28);
  color: #e8dcc8;
  font: 12px Tahoma, sans-serif;
  padding: 8px 10px;
  max-height: 190px;
  overflow: hidden;
  text-shadow: 1px 1px 0 #000;
}
.chat-input {
  height: 25px;
  border: 1px solid rgba(201, 176, 149, 0.35);
  background: rgba(0, 0, 0, 0.45);
  color: #e8dcc8;
  padding: 0 8px;
  font: 12px Tahoma, sans-serif;
}
.hint { color: var(--muted); font-size: 11px; margin-left: 8px; }
.button img.up { position: relative; }
.button img.over, .button img.down { position: absolute; left: 0; top: 0; opacity: 0; }
.button:hover img.over { opacity: 1; }
.button:hover img.up { opacity: 0; }
.button:active img.down { opacity: 1; }
.button:active img.up, .button:active img.over { opacity: 0; }
.board > .widget, .thinboard > .widget, .titlebar > .widget, .window-root > .widget { z-index: 1; }
.slice { z-index: 0; }
.button .label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}

.text, .editline {
  white-space: nowrap;
  color: #dadada;
  pointer-events: none;
}
.text.outline, .editline.outline, .button .label.outline {
  text-shadow: 0 0 2px #000, 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}
.editline {
  border: 0;
  background: transparent;
  outline: none;
  pointer-events: auto;
}

.slice { position: absolute; background-repeat: no-repeat; pointer-events: none; }
.board, .thinboard { background: transparent; }
.window-root { overflow: visible; }
.board, .thinboard, .titlebar, .horizontalbar, .gauge, .slot, .grid, .bar, .box, .scrollbar { pointer-events: auto; }
.titlebar > .text { z-index: 2; }
.bar { background: rgba(0,0,0,0.45); }
.box { border: 1px solid rgba(201,176,149,0.35); }
.slot-cell, .grid-cell {
  position: absolute;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
.missing {
  background: repeating-linear-gradient(45deg, #3a2030, #3a2030 6px, #24141c 6px, #24141c 12px);
}

#tooltip {
  position: fixed;
  z-index: 20;
  background: rgba(12,13,16,0.94);
  border: 1px solid var(--gold);
  color: var(--text);
  padding: 6px 8px;
  pointer-events: none;
  max-width: 280px;
  font-size: 11px;
}
