/* =========================
   夜之城队伍定位棋子
   ========================= */

.map-workspace {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 286px;
  align-items: stretch;
}

.map-workspace .map-scroll {
  min-width: 0;
}

.map-character-layer {
  position: absolute;
  z-index: 4;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.map-character-anchor-group {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

.map-character-anchor-point {
  position: absolute;
  z-index: 4;
  left: 0;
  top: 0;
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
  border: 2px solid #f5fbff;
  border-radius: 50%;
  background: #071015;
  box-shadow:
    0 0 0 2px rgba(7, 16, 21, 0.92),
    0 0 11px rgba(0, 217, 255, 0.95);
  pointer-events: none;
}

.map-character-anchor-point[data-count]::after {
  content: attr(data-count);
  position: absolute;
  left: 50%;
  top: 50%;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  transform: translate(7px, -22px);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  color: #071015;
  background: var(--yellow);
  box-shadow: 0 0 8px rgba(252, 238, 9, 0.6);
  font-family: monospace;
  font-size: 9px;
  font-weight: 1000;
  line-height: 1;
}

.map-character-connector {
  position: absolute;
  z-index: 1;
  left: 0;
  top: 0;
  height: 3px;
  transform-origin: 0 50%;
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      #f5fbff 0%,
      #f5fbff 26%,
      var(--character-color) 100%
    );
  box-shadow:
    0 0 0 1px rgba(7, 16, 21, 0.78),
    0 0 7px var(--character-color);
  pointer-events: none;
}

.map-character-ball {
  position: absolute;
  z-index: 3;
  width: 42px;
  height: 42px;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 3px solid #f5fbff;
  border-radius: 50%;
  color: #071015;
  background: var(--character-color);
  box-shadow:
    0 0 0 2px rgba(7, 16, 21, 0.92),
    0 5px 9px rgba(0, 0, 0, 0.7),
    0 0 15px var(--character-color);
  font-family: monospace;
  font-size: 16px;
  font-weight: 1000;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  transition:
    transform 0.16s ease,
    filter 0.16s ease;
}

.map-character-ball:hover,
.map-character-ball:focus-visible,
.map-character-ball.is-highlighted {
  z-index: 8;
  outline: none;
  transform: translate(-50%, -50%) scale(1.16);
  filter: brightness(1.08);
}

.map-character-anchor-group.is-merge-target {
  z-index: 20;
}

.map-character-anchor-group.is-merge-target
.map-character-anchor-point {
  border-color: var(--yellow);
  background: var(--yellow);
  box-shadow:
    0 0 0 6px rgba(252, 238, 9, 0.18),
    0 0 24px rgba(252, 238, 9, 0.95);
  animation: map-character-anchor-pulse 0.72s ease-in-out infinite alternate;
}

.map-character-anchor-group.is-merge-target
.map-character-connector {
  filter: brightness(1.3);
}

.map-character-anchor-group.is-merge-target
.map-character-ball {
  box-shadow:
    0 0 0 3px rgba(252, 238, 9, 0.78),
    0 5px 9px rgba(0, 0, 0, 0.7),
    0 0 22px var(--character-color);
}

@keyframes map-character-anchor-pulse {
  from {
    transform: translate(-50%, -50%) scale(1);
  }

  to {
    transform: translate(-50%, -50%) scale(1.38);
  }
}

.map-character-pin-shape,
.map-character-mini-pin {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
}

.map-character-pin-head {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 50%;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  transform: translateX(-50%);
  border: 3px solid #f5fbff;
  border-radius: 50%;
  color: #071015;
  background: var(--character-color);
  box-shadow:
    0 0 0 2px rgba(7, 16, 21, 0.9),
    0 0 16px var(--character-color);
  font-family: monospace;
  font-size: 16px;
  font-weight: 1000;
  line-height: 1;
}

.map-character-pin-tip {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 35px;
  width: 3px;
  height: 27px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #f5fbff;
  box-shadow:
    0 0 0 1px rgba(7, 16, 21, 0.85),
    0 0 7px var(--character-color);
}

.map-character-sidebar {
  position: relative;
  z-index: 6;
  min-width: 0;
  padding: 18px;
  border-left: 1px solid var(--border);
  background:
    linear-gradient(
      180deg,
      rgba(7, 11, 16, 0.99),
      rgba(11, 20, 27, 0.98)
    );
}

.map-character-sidebar-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.map-character-sidebar-kicker {
  margin: 0 0 4px;
  color: var(--green);
  font-family: monospace;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.map-character-sidebar h2 {
  margin: 0;
  color: var(--text);
  font-size: 24px;
}

.map-character-admin-badge {
  padding: 4px 7px;
  border: 1px solid var(--yellow);
  color: #071015;
  background: var(--yellow);
  font-family: monospace;
  font-size: 10px;
  font-weight: 1000;
}

.map-character-help {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.map-character-roster {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.map-character-roster-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid rgba(0, 217, 255, 0.22);
  background: rgba(0, 217, 255, 0.025);
  transition:
    border-color 0.18s ease,
    background 0.18s ease;
}

.map-character-roster-row:hover,
.map-character-roster-row.is-selected {
  border-color: var(--yellow);
  background: rgba(252, 238, 9, 0.055);
}

.map-character-roster-row.is-hidden {
  opacity: 0.55;
}

.map-character-roster-drag,
.map-character-roster-select,
.map-character-row-controls button,
.map-character-action {
  font: inherit;
}

.map-character-roster-drag {
  width: 42px;
  height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
}

.map-character-roster-drag:active {
  cursor: grabbing;
}

.map-character-roster-drag:disabled {
  cursor: default;
}

.map-character-mini-pin {
  width: 34px;
  height: 48px;
  margin: 0 auto;
}

.map-character-mini-pin .map-character-pin-head {
  width: 30px;
  height: 30px;
  border-width: 2px;
  font-size: 12px;
}

.map-character-mini-pin .map-character-pin-tip {
  top: 28px;
  width: 2px;
  height: 19px;
}

.map-character-roster-select {
  min-width: 0;
  padding: 4px 2px;
  border: 0;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.map-character-roster-select strong,
.map-character-roster-select span {
  display: block;
}

.map-character-roster-select strong {
  font-size: 14px;
  line-height: 1.3;
}

.map-character-roster-select span {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-family: monospace;
  font-size: 10px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-character-row-controls {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.map-character-row-controls button {
  min-height: 30px;
  border: 1px solid rgba(0, 217, 255, 0.3);
  color: var(--blue);
  background: rgba(0, 217, 255, 0.035);
  font-family: monospace;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.map-character-row-controls button:hover:not(:disabled) {
  color: #071015;
  border-color: var(--yellow);
  background: var(--yellow);
}

.map-character-row-controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.map-character-admin-actions {
  margin-top: 14px;
  display: grid;
  gap: 7px;
}

.map-character-action {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid rgba(0, 217, 255, 0.38);
  color: var(--blue);
  background: rgba(0, 217, 255, 0.04);
  font-family: monospace;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.map-character-action.is-save {
  color: #071015;
  border-color: var(--green);
  background: var(--green);
}

.map-character-action:hover:not(:disabled) {
  border-color: var(--yellow);
  box-shadow: 0 0 18px rgba(252, 238, 9, 0.16);
}

.map-character-action:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.map-character-status {
  min-height: 36px;
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 217, 255, 0.18);
  color: var(--muted);
  font-family: monospace;
  font-size: 10px;
  line-height: 1.45;
}

.map-character-status.is-success {
  color: var(--green);
}

.map-character-status.is-error {
  color: #ff5b6f;
}

.map-character-drag-ghost {
  position: fixed;
  z-index: 10000;
  width: 44px;
  height: 66px;
  transform: translate(-50%, -100%);
  pointer-events: none;
  filter:
    drop-shadow(0 6px 8px rgba(0, 0, 0, 0.8))
    drop-shadow(0 0 14px var(--character-color));
}

body.map-character-dragging,
body.map-character-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}

@media (max-width: 1040px) {
  .map-workspace {
    grid-template-columns: minmax(0, 1fr) 240px;
  }

  .map-character-sidebar {
    padding: 14px;
  }
}

@media (max-width: 760px) {
  .map-workspace {
    grid-template-columns: 1fr;
  }

  .map-character-sidebar {
    order: -1;
    border-left: 0;
    border-bottom: 1px solid var(--border);
  }

  .map-character-roster {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x proximity;
  }

  .map-character-roster-row {
    min-width: 210px;
    scroll-snap-align: start;
  }

  .map-character-admin-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-character-ball {
    width: 46px;
    height: 46px;
    font-size: 17px;
  }
}

@media (max-width: 480px) {
  .map-character-admin-actions {
    grid-template-columns: 1fr;
  }
}
