:root {
  /* 像素简约统一色板 */
  --bg: #12151c;
  --panel: #1a1f2a;
  --panel-2: #222836;
  --text: #e6edf5;
  --muted: #7d8a9c;
  --accent: #e2554a;
  --accent-2: #3fae6c;
  --player: #4ec4f0;
  --player-dim: #1a6a88;
  --enemy: #e85a5a;
  --enemy-dim: #8a2020;
  --elite: #e0b43a;
  --corpse: #6a6e78;
  --slot: #151a24;
  --warn: #ffd866;
  --shield: #6ec8ff;
  --heart: #e2554a;
  --muscle: #d86a6a;
  --spine: #7eb0ff;
  --ribs: #a8b0bc;
  --pixel-border: #2c3444;
  --pixel-hi: rgba(255, 255, 255, 0.08);
  --font-ui: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-ui);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02) 0 1px, transparent 1px) 0 0 / 100% 8px,
    radial-gradient(800px 420px at 50% -8%, #1e2533, var(--bg));
  color: var(--text);
  image-rendering: pixelated;
}
body { display: flex; justify-content: center; }
#app {
  width: min(1100px, 100vw);
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  padding: 10px;
}
.hidden { display: none !important; }

/* Menu */
#menu {
  min-height: calc(100vh - 20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}
#menu h1 { margin: 0; letter-spacing: 0.1em; font-size: 2.2rem; }
#menu .sub { color: var(--muted); }
#menu button { width: min(260px, 80%); }
.account-badge {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  font-size: 0.85rem;
  color: var(--muted);
}
.tip { color: #667; font-size: 0.85rem; }
.boot-error { background: #5a1d1d; padding: 8px 12px; border-radius: 8px; }

/* Game landscape */
#game {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: calc(100vh - 20px);
  height: calc(100vh - 20px);
  height: calc(100dvh - 20px);
  max-height: calc(100dvh - 20px);
}
/* 战斗区内嵌顶栏：叠在战场上方，不再独占一行 */
.battle-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 22;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 10px;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(8, 10, 14, 0.92) 0%,
    rgba(8, 10, 14, 0.55) 55%,
    rgba(8, 10, 14, 0) 100%
  );
}
.hud-left, .hud-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  pointer-events: auto;
}
#floorLabel {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 0 #000;
}
#accountPlayInfo {
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 左上角方形背包钮 */
.bag-square-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  border: 2px solid var(--pixel-border);
  border-radius: 2px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 var(--pixel-hi);
}
.bag-square-btn:hover { background: #2a3344; }
.bag-square-btn:active { transform: translateY(1px); }
.bag-square-btn .bag-pix {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
  display: block;
  pointer-events: none;
}
#phase { color: var(--warn); font-weight: 700; }
#diffLabel { color: #9ec5ff; }
.icon-btn {
  border: 2px solid var(--pixel-border);
  border-radius: 2px;
  padding: 4px 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}
.icon-btn:active { transform: translateY(1px); }

/* 设置：全屏拦截交互；打开时战斗外一切点击/悬停失效 */
.settings-overlay {
  position: absolute;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: auto;
}
.settings-overlay.hidden { display: none !important; }

/* 角色属性：右侧滑出面板 */
.inspect-overlay {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}
.inspect-overlay.hidden { display: none !important; }
.inspect-scrim {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
  pointer-events: auto;
}
.inspect-panel {
  position: relative;
  z-index: 1;
  width: min(300px, 86vw);
  height: 100%;
  max-height: 100%;
  overflow: auto;
  background: linear-gradient(180deg, #1a222c 0%, #12171e 100%);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: -12px 0 36px rgba(0, 0, 0, 0.45);
  padding: 14px 14px 20px;
  pointer-events: auto;
  animation: inspect-slide-in 0.22s ease-out;
}
@keyframes inspect-slide-in {
  from { transform: translateX(18px); opacity: 0.65; }
  to { transform: translateX(0); opacity: 1; }
}
.inspect-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.inspect-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}
.inspect-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.inspect-close:hover { background: rgba(255, 255, 255, 0.14); }
.inspect-body { display: flex; flex-direction: column; gap: 10px; }
.inspect-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.inspect-tag {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}
.inspect-tag.player { color: #9fd0ef; background: rgba(74, 163, 217, 0.18); }
.inspect-tag.enemy { color: #f0a0a0; background: rgba(217, 90, 90, 0.18); }
.inspect-tag.elite { color: #f0d78a; background: rgba(201, 162, 39, 0.2); }
.inspect-tag.shock { color: #ffd866; background: rgba(255, 216, 102, 0.16); }
.inspect-tag.dead { color: #bbb; background: rgba(120, 120, 120, 0.25); }
.inspect-hp {
  display: grid;
  gap: 4px;
  font-size: 0.85rem;
}
.inspect-hp-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: #0c1016;
  overflow: hidden;
}
.inspect-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #3d8f5f, #6ecf8e);
}
.inspect-shield-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(110, 200, 255, 0.55);
  pointer-events: none;
}
.inspect-stat-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  font-size: 0.88rem;
}
.inspect-stat-grid .k { color: var(--muted); }
.inspect-stat-grid .v { font-weight: 700; text-align: right; }
.inspect-stat-grid .v.accent { color: var(--warn); }
.inspect-section-title {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.inspect-organ {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.inspect-organ-name {
  font-weight: 700;
  font-size: 0.86rem;
  margin-bottom: 2px;
}
.inspect-organ-stats {
  font-size: 0.78rem;
  color: var(--muted);
}
.inspect-organ-special {
  margin-top: 4px;
  font-size: 0.75rem;
  color: #ffd866;
  line-height: 1.35;
}
.inspect-tag.electro { color: #9ecbff; background: rgba(80, 140, 220, 0.2); }
.inspect-tag.flame { color: #ffb07a; background: rgba(220, 100, 40, 0.2); }

/* 血条下 buff 栏：色块 + 字形，兼容无 clip-path 环境 */
.buff-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 22px;
  margin-top: 5px;
  justify-content: center;
  width: 120px;
  max-width: 100%;
  padding: 2px 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
}
.enemy-formation .unit-col .buff-row { width: 96px; }
.buff-row.empty {
  min-height: 10px;
  opacity: 0.4;
  background: rgba(0, 0, 0, 0.1);
}
.buff-row.has-buffs {
  background: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.buff-ico {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  overflow: visible;
}
.buff-ico.large {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}
.buff-ico.bolt {
  background: linear-gradient(160deg, #cfeaff 0%, #3d8ef0 55%, #163f86 100%);
}
.buff-ico.flame {
  background: linear-gradient(180deg, #ffd978 0%, #ff7a2e 55%, #b83212 100%);
}
/* 简约闪电 / 火焰剪影，不用汉字 */
.buff-glyph {
  display: block;
  position: relative;
  z-index: 1;
  pointer-events: none;
}
.buff-ico.bolt .buff-glyph {
  width: 9px;
  height: 14px;
  background: #fff;
  clip-path: polygon(55% 0%, 18% 55%, 42% 55%, 30% 100%, 82% 42%, 56% 42%);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}
.buff-ico.flame .buff-glyph {
  width: 10px;
  height: 14px;
  background: #fff;
  clip-path: polygon(50% 0%, 68% 28%, 78% 22%, 86% 48%, 72% 78%, 50% 100%, 28% 78%, 14% 48%, 22% 22%, 32% 28%);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}
.buff-ico.large.bolt .buff-glyph { width: 12px; height: 18px; }
.buff-ico.large.flame .buff-glyph { width: 13px; height: 18px; }
.buff-mark { display: none; }
.buff-ico .buff-lv,
.buff-ico .buff-st {
  position: absolute;
  z-index: 2;
  font-size: 0.6rem;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 1px 1px #000, 1px 0 1px #000;
  pointer-events: none;
}
.buff-ico.large .buff-lv,
.buff-ico.large .buff-st { font-size: 0.7rem; }
.buff-ico .buff-lv { left: 1px; bottom: 0; }
.buff-ico .buff-st { right: 1px; bottom: 0; }
.buff-ico.bolt .buff-st { right: 1px; bottom: 0; left: auto; }

.float-buff {
  position: absolute;
  transform: translate(-50%, 0);
  pointer-events: none;
  z-index: 14;
  animation: float-buff-up 0.95s ease forwards;
}
@keyframes float-buff-up {
  0% { transform: translate(-50%, 0) scale(0.7); opacity: 0; }
  18% { opacity: 1; transform: translate(-50%, -6px) scale(1.1); }
  100% { transform: translate(-50%, -40px) scale(1); opacity: 0; }
}

/* 主世界 / 仓库 / 训练场 */
#hub {
  min-height: calc(100vh - 20px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 12px 28px;
}
.hub-head { text-align: center; }
.hub-head h1 { margin: 0 0 6px; letter-spacing: 0.08em; }
.hub-status { color: var(--muted); margin: 0; }
.hub-entries {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.hub-entry {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  text-align: left;
  padding: 18px 16px;
  border: 2px solid var(--pixel-border);
  border-radius: 2px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s, transform 0.12s;
  box-shadow: inset 0 1px 0 var(--pixel-hi);
}
.hub-entry:hover {
  border-color: var(--warn);
  transform: translateY(-1px);
}
.hub-entry-accent {
  border-color: rgba(226, 85, 74, 0.55);
  background: linear-gradient(180deg, #2e1c1c, #171414);
}
.hub-entry-train {
  border-color: rgba(78, 196, 240, 0.5);
  background: linear-gradient(180deg, #1a2836, #121820);
}
.hub-entry-title { font-size: 1.15rem; font-weight: 800; }
.hub-entry-sub { font-size: 0.8rem; color: var(--muted); }
.hub-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.warehouse-overlay,
.training-overlay,
.rest-overlay,
.defeat-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 12px;
}
.warehouse-overlay.hidden,
.training-overlay.hidden,
.rest-overlay.hidden,
.defeat-overlay.hidden { display: none !important; }
.warehouse-panel,
.training-panel,
.rest-panel,
.defeat-panel {
  width: min(920px, 100%);
  max-height: min(90vh, 820px);
  overflow: auto;
  background: #171b21;
  border-radius: 14px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.defeat-overlay { z-index: 55; background: rgba(0, 0, 0, 0.72); }
.defeat-panel {
  width: min(420px, 100%);
  text-align: center;
  border: 2px solid var(--pixel-border);
  border-radius: 2px;
  background: linear-gradient(180deg, #2a1818, #171b21);
  box-shadow: inset 0 1px 0 var(--pixel-hi);
}
.defeat-panel h2 {
  margin: 0 0 8px;
  color: #ff8a8a;
  letter-spacing: 0.08em;
}
.defeat-panel button {
  display: block;
  width: 100%;
  margin-top: 10px;
  border: 2px solid var(--pixel-border);
  border-radius: 2px;
  padding: 12px 10px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
}
.defeat-panel .btn-secondary { background: #3a424c !important; }
.warehouse-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.warehouse-head h2,
.training-panel h2,
.rest-panel h2 { margin: 0 0 4px; }
.warehouse-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 720px) {
  .warehouse-cols { grid-template-columns: 1fr; }
}
.warehouse-col h3 { margin: 0 0 8px; font-size: 0.95rem; }
.modal-actions.dual {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}
.modal-warn { color: #ffb4a8; font-size: 0.85rem; }
.training-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 720px) {
  .training-grid { grid-template-columns: 1fr; }
}
.training-field {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  align-items: center;
  font-size: 0.85rem;
}
.training-field label { color: var(--muted); }
.training-field input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #2a313a;
  background: #0f1318;
  color: var(--text);
}
.training-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.organ-tip .tip-stat-edit {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  margin-top: 8px;
  font-size: 0.78rem;
}
.organ-tip .tip-stat-edit input {
  width: 64px;
  padding: 2px 4px;
  border-radius: 4px;
  border: 1px solid #333;
  background: #111;
  color: var(--text);
}

.unit-block.inspectable,
.unit-name.inspectable,
.hp-row.inspectable {
  cursor: pointer;
}
.unit-block.inspectable:hover {
  outline: 2px solid rgba(255, 216, 102, 0.55);
  outline-offset: 2px;
}
.settings-panel {
  width: min(320px, 100%);
  background: #171b21;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.settings-panel h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  text-align: center;
}
.settings-panel button {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
#game.settings-open {
  pointer-events: none;
}
#game.settings-open #settingsOverlay {
  pointer-events: auto;
}
#game.settings-open .battle-hud {
  z-index: 85;
  pointer-events: none;
}
#game.settings-open #settingsBtn {
  position: relative;
  z-index: 86;
  pointer-events: auto;
}
#game.settings-open .build-bar,
#game.settings-open .battlefield,
#game.settings-open .hud-left,
#game.settings-open #accountPlayInfo {
  pointer-events: none !important;
}
#game.settings-open #settingsBtn {
  pointer-events: auto !important;
}

/* 整块战斗壳：顶栏 + 单位区 + 构筑栏同一面板 */
.battlefield {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  display: flex;
  flex-direction: column;
  padding: 0;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px) 0 0 / 16px 16px,
    #0f131a;
  border: 2px solid var(--pixel-border);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}
.battle-arena {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  padding: 0 8px 4px;
  overflow-x: hidden;
  overflow-y: auto;
}
/* 遮罩只罩单位区，不压暗下方器官/开战栏 */
.battle-dim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  transition: opacity 0.28s ease;
}
.battlefield.fx-dim .battle-dim { opacity: 1; }
.battle-stage {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: start;
  min-height: 100%;
  height: auto;
  isolation: isolate;
  /* 给内嵌顶栏留空，单位不被挡住 */
  padding-top: 38px;
}
.battle-float-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  overflow: visible;
}
/* 敌阵：2 列(前/后) × 4 行；顶对齐，避免多敌时上方槽被裁 */
.enemy-formation {
  position: relative;
  z-index: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 120px));
  grid-template-rows: repeat(4, auto);
  gap: 4px 12px;
  justify-content: end;
  align-content: start;
  justify-self: end;
  min-height: 0;
  width: max-content;
  max-width: 100%;
  padding-top: 2px;
}
.enemy-formation .unit-col {
  min-width: 96px;
  max-width: 120px;
  gap: 3px;
}
.enemy-formation .unit-col .hp-row { width: 96px; }
.enemy-formation .unit-slots {
  min-height: 28px;
  gap: 3px;
}
.enemy-formation .act-slot {
  width: 34px;
  height: 34px;
  font-size: 0.56rem;
}
.unit-col {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 120px;
  transition: transform 0.35s ease, filter 0.28s ease;
  will-change: transform;
  /* 行动槽在头顶，保证可点不被下层盖住 */
  overflow: visible;
}
/* 单位整体压在遮盖上方（敌阵网格无法让单列穿透父级）；未行动用压暗滤镜，行动双方保持高亮 */
.battlefield.fx-dim .unit-col {
  z-index: 8;
}
.battlefield.fx-dim .unit-col:not(.acting) {
  filter: brightness(0.42) saturate(0.75);
}
.battlefield.fx-dim .unit-col.acting {
  filter: drop-shadow(0 0 10px rgba(255, 230, 140, 0.55));
}
.unit-col.player-side {
  justify-self: start;
  align-self: start;
  margin-top: 28px; /* 与敌方头顶行动槽区大致齐平 */
  padding-top: 2px;
}
.unit-col.approached.player-side {
  transform: translate(var(--approach-x, 0px), var(--approach-y, 0px));
}
.unit-col.approached.enemy-side {
  transform: translate(calc(-1 * var(--approach-x, 0px)), var(--approach-y, 0px));
}
.unit-col.acting {
  z-index: 8;
  filter: drop-shadow(0 0 10px rgba(255, 230, 140, 0.55));
}
.unit-col.acting .unit-block {
  outline: 2px solid var(--warn);
  outline-offset: 2px;
}
.unit-col.hit-flash .unit-block {
  animation: unit-hit 0.35s ease;
}
.unit-col.dodge-flash .unit-block {
  animation: unit-dodge 0.45s ease;
}
.unit-col.elite .unit-block { outline: 2px solid var(--elite); }
@keyframes unit-hit {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}
@keyframes unit-dodge {
  0% { transform: translateX(0); opacity: 1; }
  35% { transform: translateX(14px); opacity: 0.55; }
  70% { transform: translateX(-4px); opacity: 0.9; }
  100% { transform: translateX(0); opacity: 1; }
}
.float-num {
  position: absolute;
  font-weight: 800;
  font-size: 1.05rem;
  color: #ffd0d0;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
  animation: float-up 0.85s ease forwards;
  z-index: 13;
}
.float-num.shield { color: #9ad8ff; }
.float-num.miss { color: #9dffc3; font-size: 0.9rem; }
.float-num.skill { color: #ffe08a; font-size: 0.85rem; }
@keyframes float-up {
  0% { transform: translate(-50%, 0); opacity: 1; }
  100% { transform: translate(-50%, -36px); opacity: 0; }
}

.unit-slots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 36px;
}
.act-slot {
  width: 42px;
  height: 42px;
  border-radius: 2px;
  border: 2px dashed rgba(255,255,255,0.18);
  background: var(--slot);
  color: inherit;
  font: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  cursor: pointer;
  padding: 2px;
  text-align: center;
  line-height: 1.1;
  box-shadow: inset 0 1px 0 var(--pixel-hi);
  display: grid;
  place-items: center;
  position: relative;
}
.act-slot .skill-pix {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
  display: block;
  pointer-events: none;
}
.act-slot-stat {
  position: absolute;
  right: 1px;
  bottom: 1px;
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0 2px;
  font-size: 0.55rem;
  font-weight: 800;
  line-height: 1;
  color: #e6edf5;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--pixel-border);
  border-radius: 1px;
  pointer-events: none;
}
.act-slot-stat .stat-glyph {
  width: 8px;
  height: 8px;
  image-rendering: pixelated;
}
.act-slot.need-target {
  box-shadow: inset 0 0 0 1px rgba(255, 216, 102, 0.55);
}
.act-slot.base { opacity: 0.55; border-style: dotted; }
.act-slot.filled { border-style: solid; }
.act-slot.intent-attack, .act-slot.skill-attack { border-color: #e65b5b; background: #3a1e1e; }
.act-slot.intent-block, .act-slot.skill-block { border-color: #5b8de6; background: #1e2a3a; }
.act-slot.intent-dodge, .act-slot.skill-dodge { border-color: #5be6a0; background: #1e3a2a; }
.act-slot.intent-dissect, .act-slot.skill-dissect { border-color: #b55be6; background: #2a1e3a; }
.act-slot.intent-static_discharge, .act-slot.skill-static_discharge {
  border-color: #6ec8ff; background: #1a2a3a;
}
.act-slot.intent-ember_seed, .act-slot.skill-ember_seed {
  border-color: #ff9a4a; background: #3a2218;
}
.act-slot.skill-ember_seed { border-color: #ff9a4a; background: #3a2214; }
.act-slot.targeting { outline: 2px solid var(--warn); outline-offset: 1px; }
.act-slot.shocked {
  opacity: 0.55;
  border-style: solid;
  border-color: rgba(255,255,255,0.15);
  background: #1a1f26;
  color: var(--muted);
  cursor: default;
}
.act-slot.corpse-slot {
  border-style: solid;
  border-color: var(--corpse);
  background: #2a2e36;
  color: #c8ccd4;
}

.unit-block {
  width: 64px;
  height: 64px;
  border-radius: 2px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #0b0d10;
  image-rendering: pixelated;
  border: 2px solid var(--pixel-border);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.2), 0 2px 0 rgba(0,0,0,0.35);
}
.unit-block.player {
  background: linear-gradient(180deg, #7ad8f8 0%, var(--player) 45%, var(--player-dim) 100%);
}
.unit-block.enemy {
  background: linear-gradient(180deg, #ff8a8a 0%, var(--enemy) 45%, var(--enemy-dim) 100%);
}
.unit-block.corpse,
.unit-col.corpse .unit-block {
  background: linear-gradient(180deg, #9aa0aa 0%, var(--corpse) 50%, #3a3e48 100%);
  filter: grayscale(0.35) brightness(0.85);
}
.unit-block canvas,
.unit-block .unit-pix {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
}
.unit-col.corpse { opacity: 0.92; }
.unit-col.corpse .unit-name { color: var(--corpse); }
.enemy-formation .unit-name { font-size: 0.68rem; max-width: 110px; }
.organ-pix,
.muscle-sprite.organ-pix,
canvas.pix {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.unit-vitals {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
}
.hp-row {
  width: 120px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}
.hp-track {
  position: relative;
  height: 10px;
  background: #2a313a;
  border-radius: 999px;
  overflow: hidden;
}
.hp-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: #3d8f5f;
  border-radius: 999px;
}
.shield-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(110, 200, 255, 0.75);
  border-radius: 999px;
  pointer-events: none;
}
.hp-text { font-size: 0.68rem; color: var(--muted); white-space: nowrap; }
.unit-name { font-size: 0.75rem; font-weight: 700; text-align: center; }

.combat-hint {
  margin: 4px 0 0;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.35;
}
.battle-log {
  flex: 1;
  min-height: 64px;
  max-height: 120px;
  overflow: auto;
  font-size: 0.68rem;
  white-space: pre-wrap;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--pixel-border);
  border-radius: 2px;
  padding: 4px 6px;
  color: #cfd8e3;
}

.build-bar {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) minmax(160px, 200px);
  gap: 8px;
  margin: 0;
  padding: 6px 8px 8px;
  background: linear-gradient(180deg, rgba(12, 16, 22, 0.2) 0%, rgba(12, 16, 22, 0.78) 28%, rgba(14, 18, 26, 0.92) 100%);
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
  align-items: end;
  justify-content: stretch;
  flex: 0 0 auto;
  position: relative;
  z-index: 18;
  box-shadow: none;
}
.dock-label { font-size: 0.68rem; color: var(--muted); margin-bottom: 2px; letter-spacing: 0.04em; }
.weapon-slot {
  width: 64px;
  height: 64px;
  border-radius: 2px;
  background: var(--slot);
  border: 2px dashed rgba(255,255,255,0.18);
  display: grid;
  place-items: center;
  cursor: pointer;
  text-align: center;
  font-size: 0.68rem;
}
.weapon-slot.filled { border-style: solid; border-color: var(--pixel-border); }
.center-build {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  min-height: 0;
  gap: 2px;
}
.center-build .panel-title {
  font-size: 0.78rem;
  font-weight: 700;
  margin: 4px 0;
  width: 100%;
  text-align: center;
}
.hint { color: var(--muted); font-weight: 500; font-size: 0.7rem; }
.player-plan-slots {
  margin-bottom: 6px;
  justify-content: center;
  width: 100%;
}
.organ-stage {
  position: relative;
  display: flex;
  justify-content: center;
  width: 100%;
}
.chain-fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 8;
}
.chain-fx .chain-converge {
  opacity: 0.95;
}
.chain-fx .chain-path {
  fill: none;
  stroke: rgba(255, 216, 102, 0.35);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chain-fx .chain-trail {
  fill: none;
  stroke: #ffe08a;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px rgba(255, 210, 80, 0.9));
}
.chain-fx .chain-head {
  fill: #fff6c8;
  stroke: #ffb84d;
  stroke-width: 1.5;
  filter: drop-shadow(0 0 6px #ffd866);
}
.organ-cell.chain-hot {
  box-shadow: inset 0 0 0 2px rgba(255, 216, 102, 0.85);
  z-index: 3;
}
.organ-cell.chain-muscle-fire {
  box-shadow: inset 0 0 0 2px #ff6b5b;
  background: rgba(255, 80, 60, 0.28);
  z-index: 4;
}
/* 选中行动槽：主干绿 / 支路黄，底层半透明遮盖 */
.organ-cell.slot-chain-main,
.organ-cell.slot-chain-branch {
  position: relative;
}
.organ-cell.slot-chain-main::before,
.organ-cell.slot-chain-branch::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.organ-cell.slot-chain-main::before {
  background: rgba(72, 210, 120, 0.38);
}
.organ-cell.slot-chain-branch::before {
  background: rgba(255, 210, 70, 0.38);
}
.organ-cell.slot-chain-main > *,
.organ-cell.slot-chain-branch > * {
  position: relative;
  z-index: 1;
}
.slot-row { display: flex; flex-wrap: wrap; gap: 6px; }
.round-dock {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 100%;
  justify-content: flex-end;
}
.round-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.round-dock button {
  border: 2px solid var(--pixel-border);
  border-radius: 2px;
  padding: 8px 10px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
}
.round-dock .btn-sm {
  padding: 6px 8px;
  font-size: 0.72rem;
}
.btn-secondary { background: #3a424c !important; }
/* 开始回合：与武器栏同尺寸 */
#startRoundBtn {
  width: 64px;
  height: 64px;
  padding: 4px;
  border-radius: 2px;
  border: 2px solid var(--pixel-border);
  background: #c43c35;
  font-size: 0.75rem;
  line-height: 1.25;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}
#nextFloorBtn { background: var(--accent-2); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Organ grid — 无间隔，多格器官连续；整栏居中；默认 7×7 */
.organ-grid {
  display: grid;
  gap: 0;
  width: 224px;
  height: 224px;
  background: #0a0d12;
  padding: 2px;
  border: 2px solid var(--pixel-border);
  border-radius: 2px;
  flex-shrink: 0;
  overflow: visible;
  margin: 0 auto;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}
.organ-cell {
  position: relative;
  background: #151a21;
  border: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.07);
  border-radius: 0;
  overflow: hidden;
  cursor: pointer;
  min-height: 0;
  aspect-ratio: auto;
}
.organ-cell.inactive {
  opacity: 0.32;
  background:
    linear-gradient(135deg, transparent 46%, rgba(255,255,255,0.04) 46% 54%, transparent 54%),
    #10141b;
}
.organ-cell .pix {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  display: block;
  position: relative;
  z-index: 1;
  object-fit: contain;
}
.organ-cell .pix.rot-180 {
  transform: rotate(180deg);
}
.organ-cell.muscle-anchor {
  overflow: visible;
  z-index: 2;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.organ-cell.muscle-cont {
  border-color: transparent;
  background: transparent;
  z-index: 1;
  box-shadow: none;
}
.muscle-sprite {
  position: absolute;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 1;
  display: block;
  object-fit: contain;
  background: transparent;
}
/* 肌肉：无缝拉长覆盖整块 2 格 */
.organ-cell.muscle-v .muscle-sprite {
  left: 0;
  top: 0;
  width: 100%;
  height: 200%;
  object-fit: fill;
  transform: none;
}
.organ-cell.muscle-h .muscle-sprite {
  left: 0;
  top: 0;
  width: 200%;
  height: 100%;
  object-fit: fill;
  transform: none;
}
.organ-cell.muscle-v.rot-180 .muscle-sprite { transform: scaleY(-1); }
.organ-cell.muscle-h.rot-90 .muscle-sprite { transform: scaleX(-1); }
.organ-cell.muscle-h.rot-270 .muscle-sprite { transform: none; }

.harvest-mask {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  overflow: hidden;
}
.harvest-mask .harvest-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: rgba(255, 255, 255, 0.55);
}
/* 采集中：整块器官红框；进度条在单格内裁剪 */
.organ-cell.harvesting {
  overflow: hidden !important;
  z-index: 4;
  box-shadow: inset 0 0 0 2px #e65b5b !important;
  background: #0a0c10 !important;
}
.organ-cell.harvesting .muscle-sprite {
  /* 采集时按格裁切，避免 200% 贴图把进度条视觉拉成两格 */
  width: 100% !important;
  height: 100% !important;
  object-fit: fill;
}
.organ-cell.organ-selected {
  box-shadow: inset 0 0 0 2px rgba(255, 214, 90, 0.95);
  z-index: 3;
}
.organ-cell.dissect-silhouette.muscle-anchor,
.organ-cell.dissect-silhouette.muscle-cont {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.85);
  background: #0a0c10;
}
.organ-cell.dissect-silhouette.muscle-anchor {
  overflow: visible; /* 非采集时贴图仍跨两格 */
}
.organ-cell.dissect-silhouette.muscle-cont {
  overflow: hidden;
}
.organ-cell.drag-over.muscle-anchor,
.organ-cell.drag-over.muscle-cont,
.organ-cell.drag-invalid.muscle-anchor,
.organ-cell.drag-invalid.muscle-cont {
  /* 拖放高亮盖过肌肉透明边框 */
  overflow: hidden;
}
.organ-cell.muscle-anchor.powered::after,
.organ-cell.muscle-cont.powered::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(125,255,176,0.35);
  pointer-events: none;
  z-index: 3;
}
.organ-cell .flow-arrow {
  position: absolute;
  width: 0; height: 0;
  z-index: 2;
  pointer-events: none;
}
.flow-arrow.up {
  top: 1px; left: 50%; transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 7px solid #7dffb0;
}
.flow-arrow.down {
  bottom: 1px; left: 50%; transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid #7dffb0;
}
.flow-arrow.left {
  left: 1px; top: 50%; transform: translateY(-50%);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 7px solid #7dffb0;
}
.flow-arrow.right {
  right: 1px; top: 50%; transform: translateY(-50%);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid #7dffb0;
}
.spine-link {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.14);
  pointer-events: none;
  z-index: 0;
}
.organ-cell.powered { box-shadow: inset 0 0 0 1px rgba(125,255,176,0.35); }

.weapon-dock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}
.expand-dock-btn {
  width: 72px;
  padding: 6px 4px !important;
  font-size: 0.68rem !important;
  line-height: 1.2;
}

/* Bags — 仅上半屏；点空白处关闭 */
.bag-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 46%;
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr minmax(40px, 1fr) 1fr;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.45) 70%, transparent 100%);
  align-items: stretch;
  cursor: default;
}
.bag-spacer { min-height: 100%; }
.bag-side {
  background: var(--panel);
  border-radius: 12px;
  padding: 8px 10px;
  overflow: auto;
  max-height: 100%;
}
.bag-side h3 { margin: 0 0 8px; font-size: 0.95rem; }
.organ-cell.drag-over {
  outline: none;
  box-shadow: inset 0 0 0 2px #ffd866;
  background: rgba(255, 216, 102, 0.22);
  z-index: 4;
}
.organ-cell.drag-invalid {
  box-shadow: inset 0 0 0 2px #e65b5b;
  background: rgba(230, 91, 91, 0.18);
  z-index: 4;
}
.organ-cell[draggable="true"] { cursor: grab; }
.bag-hint {
  margin: 0 0 6px;
  font-size: 0.72rem;
  color: var(--muted);
}
.bag-organ-grid {
  width: 108px !important;
  height: 108px !important;
  margin: 0;
}
/* 训练场超大背包：允许滚动，不被 3×3 尺寸锁死 */
.bag-organ-grid.train-bag-grid {
  width: auto !important;
  height: auto !important;
  max-width: 100%;
  max-height: min(52vh, 420px);
  overflow: auto;
  padding-bottom: 4px;
}
.bag-organ-grid .organ-cell {
  cursor: pointer;
}
.bag-organ-grid .organ-cell.bag-selected {
  box-shadow: inset 0 0 0 2px #ffd866 !important;
  z-index: 3;
}
.bag-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.bag-item {
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--slot);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  padding: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: inherit;
  font: inherit;
}
.bag-item canvas, .bag-item .pix {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  object-fit: contain;
}
.bag-item .name { font-size: 0.62rem; font-weight: 700; }
.bag-item.selected {
  outline: 2px solid #ffd866;
  background: #2a3340;
}
.player-plan-slots .act-slot {
  width: 48px;
  height: 48px;
  font-size: 0.7rem;
}
.player-plan-slots .act-slot .skill-pix {
  width: 20px;
  height: 20px;
}
.organ-cell.dissect-silhouette .pix {
  filter: brightness(0);
}
.organ-cell.dissect-silhouette {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.85);
  background: #0a0c10;
}
.organ-cell.dissect-silhouette .muscle-sprite {
  filter: brightness(0);
}

/* Dissect */
.dissect-overlay {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 10px;
  padding: 16px;
  background: rgba(0,0,0,0.72);
}
.dissect-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.dissect-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.dissect-grid {
  width: auto !important;
  height: auto !important;
  margin: 0 auto;
  /* 行高由 JS 按格子像素设置，避免空行被压扁 */
}
.dissect-grid .organ-cell {
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1 / 1;
}
.dissect-grid .organ-cell.implant-target {
  box-shadow: inset 0 0 0 2px rgba(110, 200, 255, 0.7);
  background: rgba(110, 200, 255, 0.14);
}
.dissect-bag .bag-organ-grid.train-bag-grid {
  max-height: min(58vh, 460px);
}
.fly-fx {
  position: fixed;
  width: 40px;
  height: 40px;
  pointer-events: none;
  z-index: 120;
  opacity: 0;
  left: 0;
  top: 0;
  margin: 0;
  padding: 0;
  overflow: visible;
  box-sizing: border-box;
}
.fly-fx.show { opacity: 1; }
.fly-fx .pix,
.fly-fx .muscle-sprite {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
}
.fly-fx.fly-muscle-v .muscle-sprite,
.fly-fx.fly-muscle-h .muscle-sprite {
  object-fit: fill;
}
.fly-fx .pix.rot-180 { transform: rotate(180deg); }

.skill-popup {
  position: fixed;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  background: var(--panel);
  border: 2px solid var(--pixel-border);
  border-radius: 2px;
  min-width: 0;
  max-width: none;
  box-shadow: inset 0 1px 0 var(--pixel-hi), 0 8px 20px rgba(0,0,0,0.45);
}
.skill-popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 148px;
}
.skill-popup .skill-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  border: 2px solid var(--pixel-border);
  border-radius: 2px;
  background: var(--panel-2);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 var(--pixel-hi);
}
.skill-popup .skill-icon-btn:hover { background: #2a3344; }
.skill-popup .skill-icon-btn:active { transform: translateY(1px); }
.skill-popup .skill-icon-btn[data-skill="attack"] { background: #3a1e1e; border-color: #e65b5b; }
.skill-popup .skill-icon-btn[data-skill="block"] { background: #1e2a3a; border-color: #5b8de6; }
.skill-popup .skill-icon-btn[data-skill="dodge"] { background: #1e3a2a; border-color: #5be6a0; }
.skill-popup .skill-icon-btn[data-skill="dissect"] { background: #2a1e3a; border-color: #b55be6; }
.skill-popup .skill-icon-btn[data-skill="static_discharge"] { background: #1a2a3a; border-color: #6ec8ff; }
.skill-popup .skill-icon-btn[data-skill="ember_seed"] { background: #3a2218; border-color: #ff9a4a; }
.skill-popup .skill-icon-btn.skill-clear { background: #2a2e36; border-color: #6a7280; }
.skill-popup .skill-icon-btn .skill-pix {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
  display: block;
  pointer-events: none;
}
.slot-chain-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 6px;
  align-items: center;
  font-size: 0.68rem;
  line-height: 1.2;
  color: rgba(255,255,255,0.82);
  font-variant-numeric: tabular-nums;
  max-width: 148px;
  padding: 0 1px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.slot-chain-stats .sc-chip {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 1px 3px;
  border: 1px solid var(--pixel-border);
  border-radius: 2px;
  background: rgba(0,0,0,0.28);
  white-space: nowrap;
}
.slot-chain-stats .sc-chip .stat-glyph {
  width: 10px;
  height: 10px;
  image-rendering: pixelated;
  display: block;
}
.slot-chain-stats .sc-chip .sc-val {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.slot-chain-stats .sc-chip.electro { color: #8ed0ff; border-color: #3a6a8a; }
.slot-chain-stats .sc-chip.flame { color: #ffb070; border-color: #8a4a28; }
.slot-chain-stats .sc-chip.mark { color: #ffd866; }
.slot-chain-stats .muted { color: rgba(255,255,255,0.45); }
.organ-cell.expand-plus {
  opacity: 1 !important;
  background: rgba(255, 216, 102, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 216, 102, 0.65);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffd866;
  font-size: 1.1rem;
  font-weight: 800;
}
.organ-cell.expand-plus:hover {
  background: rgba(255, 216, 102, 0.22);
}

.organ-tip {
  position: fixed;
  z-index: 120;
  max-width: 220px;
  padding: 10px;
  background: #171b21;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.4;
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.organ-tip .actions { display: flex; gap: 6px; margin-top: 8px; }
.organ-tip button {
  border: 0;
  border-radius: 6px;
  padding: 6px 8px;
  background: #3a424c;
  color: #fff;
  cursor: pointer;
  font-size: 0.72rem;
}

.arc-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 35;
}
/* 非战斗壳层时隐藏索敌黄线，避免退回主世界后残留 */
body:not(.shell-game) .arc-layer {
  display: none !important;
}
.arc-layer path {
  fill: none;
  stroke-width: 2.5;
  opacity: 0.92;
}
.arc-layer path.arc-player {
  stroke: #ffd65a;
}
.arc-layer path.arc-player-aoe {
  stroke: #ffd65a;
  stroke-width: 2.1;
  stroke-dasharray: 5 6;
  opacity: 0.75;
}
.arc-layer path.arc-enemy {
  stroke: #e65b5b;
  stroke-width: 2.6;
  opacity: 0.95;
}
.arc-layer .aim-line {
  fill: none;
  stroke: #ffe08a;
  stroke-width: 2.4;
  stroke-dasharray: 7 5;
  opacity: 0.95;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 16px;
}
.modal-card {
  width: min(420px, 100%);
  max-height: min(92vh, 720px);
  overflow-y: auto;
  background: #171b21;
  border-radius: 14px;
  padding: 16px;
}
.text-input, .text-area {
  width: 100%;
  margin: 8px 0;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #10151b;
  color: var(--text);
  font: inherit;
}
.modal-actions.dual { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.account-list, .slot-list { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow: auto; }
.account-item, .slot-item {
  text-align: left;
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #222831;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.account-item.active { border-color: #3d7cff; }
.modal-warn { color: #ffb4b4; font-size: 0.8rem; }
.modal-sub { color: var(--muted); font-size: 0.85rem; }
.mini-btn { width: 100%; margin-top: 6px; padding: 8px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.transfer-box { margin-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 10px; }
.cloud-sync-box .sync-title {
  margin: 0 0 6px;
  font-size: 0.92rem;
}
.cloud-sync-box .text-input {
  width: 100%;
  margin: 4px 0;
  box-sizing: border-box;
}
.cloud-sync-box .modal-actions.dual .text-input {
  width: calc(50% - 4px);
  flex: 1;
}
.cloud-sync-box .modal-actions.dual {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

@media (max-width: 820px) {
  .battle-stage { grid-template-columns: 1fr; }
  .build-bar { grid-template-columns: 1fr; justify-items: center; }
  .round-dock { width: min(320px, 100%); }
  .bag-overlay { grid-template-columns: 1fr; }
  .dissect-overlay { grid-template-columns: 1fr; }
}
