.battle-map-panel {
  width: 100%;
  margin-top: 18px;
  padding: 18px 10px 28px;
  border-top: 1px solid rgba(199, 173, 114, 0.24);
}

.battle-map-head {
  max-width: 1180px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.battle-map-head h3 {
  margin: 0;
  color: var(--gold);
  font-size: 17px;
}

.battle-map-head-actions,
.battle-map-toolbar,
.battle-map-add {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.battle-map-head-actions label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.battle-map-head-actions input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--gold);
}

.battle-map-setup-control[hidden] { display: none; }

.battle-map-setup-control select {
  min-height: 36px;
  max-width: 220px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #11110f;
  color: var(--text);
}

.battle-map-workspace {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 14px;
  align-items: start;
}

.battle-map-main {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.battle-map-board {
  position: relative;
  width: 100%;
  aspect-ratio: 10 / 7;
  overflow: hidden;
  border: 1px solid rgba(199, 173, 114, 0.34);
  background: #080b0a;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  cursor: crosshair;
}

.battle-map-board-image,
.battle-map-terrain-layer,
.battle-map-start-layer,
.battle-map-grid,
.battle-map-coordinate-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.battle-map-board-image {
  display: block;
  object-fit: contain;
}

.battle-map-grid {
  z-index: 3;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 5% 100%, 100% calc(100% / 14);
}

.battle-map-board.coordinates-visible .battle-map-grid {
  background-image:
    linear-gradient(to right, rgba(239, 68, 58, 0.78) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(239, 68, 58, 0.78) 1px, transparent 1px);
}

.battle-map-terrain-layer { z-index: 2; }
.battle-map-start-layer { z-index: 4; pointer-events: none; }

.battle-map-los-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}
.battle-map-los-layer > div { position: absolute; }
.battle-map-los-visible {
  background: rgba(74, 222, 128, 0.30);
  box-shadow: inset 0 0 0 1px rgba(74, 222, 128, 0.55);
}
.battle-map-los-blocked { background: transparent; }
.battle-map-los-layer.dim-blocked .battle-map-los-blocked {
  background: rgba(4, 6, 6, 0.62);
}
.battle-map-los-source {
  z-index: 5;
  border-radius: 999px;
  background: rgba(56, 132, 255, 0.95);
  box-shadow: 0 0 0 2px rgba(190, 220, 255, 0.95), 0 0 12px rgba(56, 132, 255, 0.72);
  transform: translate(-50%, -50%) scale(0.48);
}
/* 朝向标注：画在来源脚印正面边的中点，箭头指向朝向；盲区在其反向。 */
.battle-map-los-facing {
  position: absolute;
  color: #ffd166;
  font-size: 1.15em;
  line-height: 1;
  text-shadow: 0 0 3px #000, 0 1px 3px #000;
  transform-origin: center;
  pointer-events: none;
  z-index: 3;
}
.battle-map-los-obscuring {
  box-shadow: inset 0 0 0 2px rgba(250, 204, 21, 0.85);
  background: rgba(250, 204, 21, 0.12);
}
/* Cloud 云层: still blocks an Elevated source, so mark it apart from the rest. */
.battle-map-los-cloud {
  box-shadow: inset 0 0 0 2px rgba(96, 180, 240, 0.95);
  background: rgba(96, 180, 240, 0.18);
}
/* 射程层：移速 + 攻击距离内的格子，叠在视线结果之上。 */
.battle-map-los-in-range {
  box-shadow: inset 0 0 0 2px rgba(180, 132, 255, 0.75);
}
.battle-map-los-in-range.has-los {
  box-shadow: inset 0 0 0 2px rgba(200, 160, 255, 0.98);
  background: rgba(180, 132, 255, 0.16);
}
.battle-map-los-move-target {
  box-sizing: border-box;
  z-index: 6;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 0 2px rgba(20, 20, 20, 0.88), 0 0 12px rgba(255, 255, 255, 0.58);
  transform: translate(-50%, -50%) scale(0.48);
}
.battle-map-los-move-step {
  box-sizing: border-box;
  z-index: 4;
  pointer-events: none;
}
.battle-map-los-move-a {
  background: rgba(239, 68, 58, 0.28);
  box-shadow: inset 0 0 0 2px rgba(239, 68, 58, 0.88);
}
.battle-map-los-move-b {
  background: rgba(250, 204, 21, 0.30);
  box-shadow: inset 0 0 0 2px rgba(250, 204, 21, 0.94);
}
.battle-map-los-move-overlap {
  background: rgba(251, 146, 60, 0.34);
  box-shadow: inset 0 0 0 2px rgba(251, 146, 60, 0.96);
}
.battle-map-los-move-final {
  box-sizing: border-box;
  z-index: 6;
  border-radius: 999px;
  transform: translate(-50%, -50%) scale(0.48);
}
.battle-map-los-move-final.battle-map-los-move-a {
  background: rgba(239, 68, 58, 0.96);
  box-shadow: 0 0 0 2px rgba(255, 235, 235, 0.92), 0 0 12px rgba(239, 68, 58, 0.76);
}
.battle-map-los-move-final.battle-map-los-move-b {
  background: rgba(250, 204, 21, 0.96);
  box-shadow: 0 0 0 2px rgba(255, 250, 205, 0.92), 0 0 12px rgba(250, 204, 21, 0.76);
}
.battle-map-los-move-final.battle-map-los-move-overlap {
  background: rgba(251, 146, 60, 0.96);
  box-shadow: 0 0 0 2px rgba(255, 238, 214, 0.92), 0 0 12px rgba(251, 146, 60, 0.76);
}
.battle-map-los-move-facing {
  position: absolute;
  z-index: 6;
  font-size: 1.12em;
  line-height: 1;
  text-shadow: 0 0 3px #000, 0 1px 3px #000;
  transform-origin: center;
  pointer-events: none;
}
.battle-map-los-move-facing-a { color: #ef4444; }
.battle-map-los-move-facing-b { color: #facc15; }
.battle-map-los-move-facing-overlap { color: #fb923c; }
/* 每格到来源的正交距离。贴右下角，避开居中的坐标标签。 */
.battle-map-los-distance {
  /* 显式 border-box：padding 必须留在格子内，否则第 20 列会被顶出版图 1px。
     ss/styles.css 有全局 * { box-sizing: border-box }，这里不依赖它。 */
  box-sizing: border-box;
  display: grid;
  place-items: end;
  padding: 0 2px 1px 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(6px, 0.6vw, 11px);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 2px #000, 0 -1px 2px #000, 1px 0 2px #000, -1px 0 2px #000;
  white-space: nowrap;
  pointer-events: none;
}
.battle-map-los-distance.in-range { color: rgba(224, 205, 255, 0.98); }
.battle-map-los-distance.is-source { color: rgba(190, 220, 255, 0.95); }
/* 盲区：P39 永远不视作在视线内。 */
.battle-map-los-blindspot {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
  background: repeating-linear-gradient(
    45deg,
    rgba(12, 14, 18, 0.78) 0 5px,
    rgba(190, 190, 200, 0.5) 5px 10px
  );
}
.battle-map-los-wall {
  background: rgba(239, 68, 58, 0.95);
  box-shadow: 0 0 4px rgba(239, 68, 58, 0.9);
}
.battle-map-los-wall.horizontal { height: 3px; transform: translateY(-1.5px); }
.battle-map-los-wall.vertical { width: 3px; transform: translateX(-1.5px); }
/* 迷宫感应生效时红线不再遮挡，画成虚线以示"看得见但不挡"。 */
.battle-map-los-wall-ignored {
  background: none;
  box-shadow: none;
  opacity: 0.75;
}
.battle-map-los-wall-ignored.horizontal {
  background-image: linear-gradient(
    to right, rgba(239, 68, 58, 0.9) 0 6px, transparent 6px 12px);
  background-size: 12px 3px;
}
.battle-map-los-wall-ignored.vertical {
  background-image: linear-gradient(
    to bottom, rgba(239, 68, 58, 0.9) 0 6px, transparent 6px 12px);
  background-size: 3px 12px;
}

.battle-map-los {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(199, 173, 114, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}
.battle-map-los-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  gap: 8px;
}
.battle-map-los-head button {
  padding: 3px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.battle-map-los-head button[aria-pressed="true"] {
  background: rgba(74, 222, 128, 0.22);
  border-color: rgba(74, 222, 128, 0.6);
}
.battle-map-los-body { margin-top: 8px; display: grid; gap: 8px; }
.battle-map-los-field { display: grid; gap: 4px; font-size: 0.9em; }
.battle-map-los-field select,
.battle-map-los-field input { width: 100%; }
.battle-map-los-hint { margin: 0; font-size: 0.8em; opacity: 0.8; }
.battle-map-los-path-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.battle-map-los-path-tools[hidden] { display: none; }
.battle-map-los-path-tools button {
  min-height: 30px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.battle-map-los-path-tools button[aria-pressed="true"] {
  background: rgba(45, 212, 191, 0.18);
  border-color: rgba(45, 212, 191, 0.58);
}
.battle-map-los-path-summary {
  margin: 0;
  padding: 6px 7px;
  border-radius: 6px;
  border: 1px solid rgba(45, 212, 191, 0.35);
  background: rgba(45, 212, 191, 0.10);
  font-size: 0.78em;
  line-height: 1.45;
}
.battle-map-los-path-summary[hidden] { display: none; }
/* 当前使徒的面板数据一行：尺寸 / 移速 / 攻击距离 / 射程 / 盲区。 */
.battle-map-los-stats {
  margin: 0;
  padding: 5px 7px;
  border-radius: 6px;
  border: 1px solid rgba(180, 132, 255, 0.35);
  background: rgba(180, 132, 255, 0.10);
  font-size: 0.8em;
  line-height: 1.45;
}
.battle-map-los-opt { display: flex; align-items: center; gap: 6px; font-size: 0.85em; }
.battle-map-los-opt[hidden] { display: none; }

.battle-map-coordinate-layer {
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(20, minmax(0, 1fr));
  grid-template-rows: repeat(14, minmax(0, 1fr));
  pointer-events: none;
}

.battle-map-coordinate {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(7px, 0.72vw, 12px);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 2px #000, 0 -1px 2px #000;
  white-space: nowrap;
}

.battle-map-terrain {
  position: absolute;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 3px;
  background: transparent;
  transform-origin: center;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.48));
}

.battle-map-terrain:hover {
  border-color: rgba(255, 255, 255, 0.62);
}

.battle-map-terrain.selected {
  z-index: 2;
  border-color: #f0c15d;
  box-shadow: 0 0 0 2px rgba(10, 10, 8, 0.8), 0 0 0 4px rgba(240, 193, 93, 0.85);
}

.battle-map-terrain img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.battle-map-light-range {
  position: absolute;
  box-sizing: border-box;
  pointer-events: none;
  background: rgba(255, 231, 131, 0.24);
  box-shadow: inset 0 0 0 1px rgba(255, 244, 190, 0.86), 0 0 10px rgba(255, 210, 86, 0.68);
  mix-blend-mode: screen;
}

.battle-map-terrain.special-terrain {
  display: grid;
  place-items: center;
  border-color: color-mix(in srgb, var(--battle-special-color, #f0c15d) 72%, #fff 28%);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.34), transparent 30%),
    linear-gradient(180deg, color-mix(in srgb, var(--battle-special-color, #f0c15d) 82%, #fff 18%), var(--battle-special-color, #f0c15d));
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.44),
    0 0 0 1px rgba(255, 255, 255, 0.28),
    0 0 14px var(--battle-special-glow, rgba(240, 193, 93, 0.5));
}

.battle-map-special-label {
  display: grid;
  place-items: center;
  width: 70%;
  height: 70%;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  color: #fff;
  font-size: clamp(10px, 1.2vw, 18px);
  font-weight: 950;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.86);
  background: rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.battle-map-start {
  position: absolute;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.9);
  color: #fff;
  font-weight: 950;
  line-height: 1;
  text-shadow: 0 1px 3px #000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.58);
}

.battle-map-start.apostle {
  z-index: 2;
  border-color: #f36f62;
  background: rgba(146, 31, 25, 0.78);
  font-size: clamp(12px, 1.7vw, 25px);
}

.battle-map-facing {
  position: absolute;
  left: 50%;
  top: 50%;
  color: #ffd166;
  font-size: 0.72em;
  line-height: 1;
  text-shadow: 0 1px 3px #000;
  transform-origin: center;
}

.battle-map-start.titan {
  border-radius: 999px;
  border-color: #73d2c1;
  background: rgba(18, 94, 82, 0.82);
  font-size: clamp(8px, 0.9vw, 13px);
}

.battle-map-side {
  position: static;
  top: auto;
  min-width: 0;
  height: auto;
  display: grid;
  gap: 12px;
  padding: 12px;
  overflow: visible;
  border-right: 0;
  border-left: 1px solid rgba(199, 173, 114, 0.2);
  background: transparent;
  box-shadow: none;
}

.battle-map-toolbar button,
.battle-map-add button,
.battle-map-head-actions button {
  min-width: 38px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 6px;
}

.battle-map-toolbar button {
  flex: 1 1 calc(50% - 7px);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.battle-map-toolbar button.danger {
  color: #ff8d82;
}

.battle-map-add select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #11110f;
  color: var(--text);
}

.battle-map-add button {
  width: 100%;
  color: var(--gold);
  font-weight: 800;
}

.battle-map-selection {
  min-height: 42px;
  padding-top: 10px;
  border-top: 1px solid rgba(199, 173, 114, 0.15);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.battle-map-selection strong {
  display: block;
  color: var(--text);
}

.battle-map-cards {
  min-width: 0;
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(199, 173, 114, 0.2);
}

.battle-map-cards-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.battle-map-cards-head h4 {
  margin: 0;
  color: var(--gold);
  font-size: 14px;
}

.battle-map-cards-head span,
.battle-map-card-empty {
  color: var(--muted);
  font-size: 12px;
}

.battle-map-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.battle-map-card {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(199, 173, 114, 0.28);
  border-radius: 4px;
  background: #0c0d0c;
  color: var(--text);
  cursor: zoom-in;
  text-align: left;
}

.battle-map-card:hover,
.battle-map-card:focus-visible {
  border-color: var(--gold);
}

.battle-map-card img {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 7;
  object-fit: cover;
}

.battle-map-card span {
  display: block;
  min-height: 36px;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.battle-map-card-empty {
  margin: 0;
  padding: 14px 0;
  text-align: center;
}

@media (max-width: 900px) {
  .battle-map-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .battle-map-side {
    grid-template-columns: auto minmax(180px, 1fr) minmax(150px, 1fr);
    align-items: start;
    border-left: 0;
    border-top: 1px solid rgba(199, 173, 114, 0.2);
  }

  .battle-map-add button { width: auto; }
}

@media (max-width: 620px) {
  .battle-map-panel { padding-inline: 4px; }
  .battle-map-side { grid-template-columns: 1fr; }
  .battle-map-toolbar { justify-content: center; }
  .battle-map-card-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
