/* ===== BUILDING MODAL ===== */
.building-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 10px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.building-modal {
  width: 100%;
  max-width: 360px;
  background-image: url('../img/modal_bg.webp');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-color: #231f1a; /* Fix transparent middle */
  border-radius: 20px;
  padding: 30px 22px 25px 22px; /* Reduced top padding */
  position: relative;
  display: flex;
  flex-direction: column;
  color: #fff;
  font-family: var(--font-body);
  filter: drop-shadow(0px 10px 20px rgba(0,0,0,0.8));
}

.bm-header {
  display: flex;
  justify-content: center;
  position: absolute;
  top: 35px; /* Overlap the banner image */
  left: 0;
  right: 0;
  pointer-events: none; /* Let clicks pass through if needed */
  z-index: 10; /* Ensure it stays above the image */
}

.bm-title {
  font-family: var(--font-title);
  font-size: 16px; /* Slightly larger since it's on the image */
  color: #ffe8b5;
  text-shadow: 1px 1px 2px #000, 0 0 4px #000, 0 0 8px rgba(0,0,0,0.8); /* Stronger shadow for readability */
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.bm-close {
  position: absolute;
  right: 8px;
  top: 12px;
  background: rgba(40,30,20,0.9);
  border: 2px solid #a08050;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  color: #eeddcc;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  transition: transform 0.1s, background 0.1s;
  pointer-events: auto;
  z-index: 20;
}
.bm-close:active {
  transform: scale(0.9);
  background: #a08050;
  color: #fff;
}

.bm-help {
  background: rgba(0,0,0,0.6);
  border: 1px solid #d4a017;
  border-radius: 50%;
  color: #d4a017;
  width: 18px;
  height: 18px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  pointer-events: auto;
  vertical-align: middle;
  transition: all 0.2s;
  box-shadow: 0 0 5px #000;
}
.bm-help:hover {
  background: #d4a017;
  color: #000;
}

.bm-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bm-banner-container {
  position: relative;
  border: 2px solid #5a4b3c;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
  background: #000;
  display: flex;
  justify-content: center;
}

.bm-banner {
  width: 100%;
  height: auto;
  display: block;
}

.bm-upgrade-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.9), rgba(0,0,0,0));
  padding: 15px 10px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bm-upgrade-text {
  font-size: 12px;
  color: #fff;
  text-shadow: 1px 1px 2px #000;
  margin-bottom: 3px;
}

.bm-progress {
  width: 90%;
  height: 12px;
  background: #111;
  border: 1px solid #5577aa;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.bm-progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #1e3a5f, #3a7bd5);
}

.bm-progress span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: #fff;
  font-weight: bold;
  text-shadow: 1px 1px 1px #000;
}

.bm-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bm-section-title {
  text-align: center;
  font-family: var(--font-title);
  color: #ccaa77;
  font-size: 13px;
  margin: 5px 0 0 0;
  letter-spacing: 0.05em;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.bm-mejorar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 5px;
}

.bm-cost-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #eeddcc;
}

.bm-btn-red {
  background: linear-gradient(180deg, #b03a3a, #7a1a1a);
  border: 2px solid #501010;
  border-radius: 4px;
  color: #fff;
  font-family: var(--font-title);
  font-size: 14px;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  transition: transform 0.1s, filter 0.1s;
}

.bm-btn-red:active {
  transform: translateY(2px);
  filter: brightness(0.8);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.bm-btn-large {
  font-size: 16px;
  padding: 10px;
  width: 80%;
  align-self: center;
  margin-top: 5px;
}

.bm-recruit-card {
  background-image: url('../img/parchment_bg.webp');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #3d2a15;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.2);
}

.bm-unit-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.bm-unit-portrait {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid #8b6914;
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
  object-fit: cover;
}

.bm-unit-stats {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bm-unit-name {
  margin: 0 0 5px 0;
  font-family: var(--font-title);
  font-size: 14px;
  color: #2a1400;
  letter-spacing: 0.05em;
}

.bm-stat {
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 5px;
}

.bm-slider-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
}

.bm-slider-label {
  font-size: 13px;
  font-weight: bold;
}

.bm-slider-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.bm-slider-btn {
  background: #3d5a80;
  color: #fff;
  border: 2px solid #1d2a40;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.bm-slider-btn:active {
  transform: scale(0.9);
}

.bm-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 10px;
  background: linear-gradient(to right, #d4a017, #8b6914);
  border-radius: 5px;
  border: 1px solid #5a400a;
  outline: none;
}

.bm-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 20px;
  background: #2a5a8a;
  border: 2px solid #aaddff;
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.bm-total-cost {
  font-size: 13px;
  font-weight: bold;
  color: #2a1400;
}

/* ===== POPUP DE ASENTAMIENTO DEL MAPA (reutiliza el marco .building-modal) ===== */

/* Botón secundario azul, gemelo del .bm-btn-red para acciones de apoyo. */
.bm-btn-blue {
  background: linear-gradient(180deg, #3a6ea5, #1e3a5f);
  border: 2px solid #102540;
  border-radius: 4px;
  color: #fff;
  font-family: var(--font-title);
  font-size: 14px;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  transition: transform 0.1s, filter 0.1s;
}
.bm-btn-blue:active {
  transform: translateY(2px);
  filter: brightness(0.8);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Botones de acción apilados a lo ancho. */
.bm-btn-row {
  gap: 8px;
}
.bm-btn-row .bm-btn-large {
  width: 100%;
  margin-top: 0;
}

/* Rótulo del rango sobre el banner del castillo. */
.map-banner-tag {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-title);
  font-size: 12px;
  color: #ffe8b5;
  text-shadow: 1px 1px 2px #000, 0 0 6px #000;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Ficha del gobernante en pergamino (gemela de .bm-recruit-card). */
.map-info-card {
  background-image: url('../img/parchment_bg.webp');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #3d2a15;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.2);
}

.map-info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
}
.map-info-row span { color: #5a4326; }
.map-info-row b {
  color: #2a1400;
  font-family: var(--font-title);
  letter-spacing: 0.02em;
}

.map-info-shield {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid rgba(0,0,0,0.18);
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  color: #2e6a2e;
}

/* Desglose de tu guarnición desplegada (iconos de tropa) dentro de la ficha. */
.map-guarni-mini {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(0,0,0,0.18);
}
.map-guarni-mini-tit {
  display: block;
  text-align: center;
  font-size: 11px;
  font-weight: bold;
  color: #2e6a2e;
  margin-bottom: 5px;
}
.map-guarni-mini-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.map-guarni-mini-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #2a1400;
}
.map-guarni-mini-item img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.4));
}

/* Botón de retirada dentro de la ficha (discreto, sobre el pergamino). */
.map-guarni-retirar {
  display: block;
  margin: 8px auto 0;
  padding: 3px 12px;
  background: rgba(120, 30, 30, 0.12);
  border: 1px solid #7a1a1a;
  border-radius: 4px;
  color: #7a1a1a;
  font-family: var(--font-title);
  font-size: 11px;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
}
.map-guarni-retirar:hover { background: rgba(120, 30, 30, 0.22); }
.map-guarni-retirar:active { transform: scale(0.96); }
.map-guarni-retirar:disabled { opacity: 0.6; cursor: default; }

/* Aviso de tropas en tránsito (en camino o regresando), sobre el marco oscuro. */
.map-guarni-transito {
  margin-top: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-gold-light);
}

.map-info-text {
  margin: 0;
  padding: 2px 4px 6px;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: #eeddcc;
}
.map-info-text b { color: #ffe8b5; }

/* Asignador de ataque embebido (reutiliza ejc-*/eco-vp-* sobre el marco oscuro). */
.map-atk-preview { margin: 8px 0 4px; }
.building-modal .ejc-mision span { font-size: 12px; }
