:root {
  --bg: #0a0d12;
  --panel: rgba(8, 10, 14, 0.96);
  --line: #4a5568;
  --text: #c9d4e2;
  --dim: #7d8798;
  --accent: #8cf2b8;
  --warn: #f0c060;
  --bad: #e06250;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
}

/* 画布跟着窗口走：分辨率由 JS 同步，UI 覆盖层用 px 相对定位 */
#game {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

#cv {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  cursor: crosshair;
}

#game:fullscreen { width: 100vw; height: 100vh; }

/* ---------------- HUD ---------------- */

#hud {
  position: absolute;
  left: 0; top: 0; right: 0;
  padding: 14px 18px 0;
  pointer-events: none;
}
#stats { font-size: 15px; color: #cfdaea; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hint { font-size: 12px; color: var(--dim); margin-top: 3px; white-space: nowrap; overflow: hidden; }
#fps {
  position: absolute;
  right: 18px; top: 14px;
  font-size: 12px; color: var(--dim);
}
#info {
  position: absolute;
  left: 18px; bottom: 104px;
  font-size: 13px; color: #dbe6f2;
  max-width: 1000px;
}

/* ---------------- 快捷栏 ---------------- */

#hotbar {
  position: absolute;
  left: 50%; bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
}

.slot {
  position: relative;
  width: 44px; height: 44px;
  background: rgba(12, 15, 20, 0.92);
  border: 2px solid #2b323d;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.slot img { width: 32px; height: 32px; image-rendering: pixelated; }
.slot .n {
  position: absolute; right: 2px; bottom: 1px;
  font-size: 11px; color: #dfe8f4;
  text-shadow: 0 1px 2px #000;
}
.slot .k {
  position: absolute; left: 3px; top: 1px;
  font-size: 10px; color: #7d8798;
}
.slot.sel { border-color: var(--accent); background: rgba(24, 44, 34, 0.95); }
.slot.locked img { opacity: 0.25; }
.slot.ghost img { opacity: 0.75; }

/* ---------------- 面板 ---------------- */

#panel, #techPanel, #menu {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 12px 14px;
}
#panel { width: 486px; }
#techPanel { width: 900px; }
#menu { width: 420px; }

.hidden { display: none !important; }

.section-title {
  font-size: 12px; color: var(--accent);
  margin: 8px 0 4px;
}
.section-title:first-child { margin-top: 0; }
#pickerTitle { color: var(--warn); }
#machineTitle { color: var(--warn); }

.grid { display: grid; grid-template-columns: repeat(10, 44px); gap: 2px; }
.grid .slot { width: 44px; height: 44px; }

.panel-head {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--accent);
  margin-bottom: 10px;
}
.dim { color: var(--dim); font-size: 12px; }

/* ---------------- 科技树 ---------------- */

#techBody { position: relative; height: 430px; }
.tech-node {
  position: absolute;
  width: 158px; height: 50px;
  background: rgba(12, 15, 20, 0.95);
  border: 2px solid #2b323d;
  padding: 4px 8px;
  cursor: pointer;
  overflow: hidden;
}
.tech-node .t { font-size: 13px; }
.tech-node .s { font-size: 11px; color: var(--dim); }
.tech-node .e { font-size: 9px; color: #5f6874; white-space: nowrap; }
.tech-node .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.tech-node .prog { position: absolute; left: 2px; right: 2px; bottom: 2px; height: 3px; background: #1b2027; }
.tech-node .prog i { display: block; height: 100%; background: var(--warn); }
.tech-node.done { border-color: #66d99a; }
.tech-node.done .t { color: #b8f0d0; }
.tech-node.current { border-color: var(--warn); background: rgba(38, 30, 10, 0.95); }
.tech-node.current .t { color: #f5dfa8; }
.tech-node.available { border-color: #8cc0f2; }
.tech-node.available .t { color: #dcecfd; }
.tech-node.locked .t { color: #6b7480; }
.tech-node.locked { cursor: default; }
#techLines { position: absolute; left: 0; top: 0; pointer-events: none; }

/* ---------------- 菜单 ---------------- */

.menu-item {
  padding: 9px 12px;
  border-left: 3px solid transparent;
  cursor: pointer;
  display: flex; justify-content: space-between;
}
.menu-item:hover, .menu-item.sel {
  background: rgba(30, 44, 38, 0.95);
  border-left-color: var(--accent);
}
.menu-item .val { color: #7fd8a4; font-size: 13px; }
.menu-item.info { cursor: default; color: var(--dim); }
.menu-item.info .val { color: #cfdaea; }

/* ---------------- 合成队列 / 提示 ---------------- */

#queue {
  position: absolute;
  left: 50%; bottom: 62px;
  transform: translateX(-50%);
  width: 300px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(8, 10, 14, 0.92);
  border: 1px solid var(--accent);
  padding: 4px 8px;
}
#queue img { width: 24px; height: 24px; image-rendering: pixelated; }
#queueText { font-size: 11px; flex: 1; }
#queueBar { width: 90px; height: 6px; background: #1b2027; }
#queueBar i { display: block; height: 100%; width: 0; background: var(--accent); }

#toast {
  position: absolute;
  left: 50%; bottom: 150px;
  transform: translateX(-50%);
  background: rgba(8, 10, 14, 0.95);
  border: 1px solid var(--line);
  padding: 6px 14px;
  font-size: 13px; color: var(--warn);
  pointer-events: none;
}

#held {
  position: absolute;
  width: 32px; height: 32px;
  pointer-events: none;
  z-index: 50;
}
#held img { width: 32px; height: 32px; image-rendering: pixelated; }
#held span {
  position: absolute; right: -2px; bottom: -4px;
  font-size: 11px; color: #fff; text-shadow: 0 1px 2px #000;
}

/* ---------------- 账号 / 登录 ---------------- */

#userbar {
  position: absolute;
  right: 18px; top: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--dim);
  pointer-events: auto;
}
#userbar .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 6px currentColor;
}
#userbar .dot.on { background: var(--accent); }
#userbar button {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: rgba(30, 38, 50, 0.9);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
}
#userbar button:hover { border-color: var(--accent); color: var(--accent); }

#login {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, #121a24 0%, #05070a 70%);
  z-index: 50;
}
.login-card {
  width: 340px;
  padding: 26px 26px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: 1px;
  color: #dfe9f5;
}
.login-card p { margin: 0 0 16px; font-size: 12px; }
.login-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.login-tabs button {
  flex: 1;
  font: inherit;
  font-size: 13px;
  padding: 7px 0;
  color: var(--dim);
  background: rgba(20, 26, 34, 0.9);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
}
.login-tabs button.active { color: #0b1016; background: var(--accent); border-color: var(--accent); font-weight: 600; }
#loginForm { display: flex; flex-direction: column; gap: 10px; }
#loginForm input {
  font: inherit;
  font-size: 13px;
  padding: 9px 10px;
  color: var(--text);
  background: rgba(12, 16, 22, 0.95);
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
}
#loginForm input:focus { border-color: var(--accent); }
#loginForm button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 0;
  margin-top: 4px;
  color: #0b1016;
  background: var(--accent);
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}
#loginForm button:disabled { opacity: 0.6; cursor: default; }
#login .err {
  min-height: 18px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--bad);
}
