/* ─────────────────────────────────────────────────────────────────────────
   Buildings Panel  (#hud-bldg)
   ───────────────────────────────────────────────────────────────────────── */

#hud-bldg {
  position: fixed;
  bottom: 28px;
  left: calc(28px + 640px + 16px);
  width: 540px;
  z-index: 202;
  pointer-events: none;
  font-family: 'Courier New', Courier, monospace;

  background: rgba(6, 16, 32, 0.72);
  backdrop-filter: blur(22px) saturate(2) brightness(0.88);
  -webkit-backdrop-filter: blur(22px) saturate(2) brightness(0.88);
  border: 1px solid rgba(0, 190, 255, 0.18);
  box-shadow:
    0 16px 56px rgba(0,0,0,0.65),
    0 0 36px rgba(0,180,255,0.10),
    inset 0 1px 0 rgba(255,255,255,0.04);

  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.20s ease, transform 0.20s ease;
}
#hud-bldg.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* scanline */
#hud-bldg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    transparent 0px, transparent 3px,
    rgba(0,180,255,0.013) 3px, rgba(0,180,255,0.013) 4px
  );
  pointer-events: none;
  z-index: 0;
}

/* corner brackets */
#hud-bldg .hc { position: absolute; width: 12px; height: 12px; }
#hud-bldg .hc-tl { top:-1px; left:-1px;
  border-top:2px solid rgba(0,220,255,0.75); border-left:2px solid rgba(0,220,255,0.75); }
#hud-bldg .hc-tr { top:-1px; right:-1px;
  border-top:2px solid rgba(0,220,255,0.75); border-right:2px solid rgba(0,220,255,0.75); }
#hud-bldg .hc-bl { bottom:-1px; left:-1px;
  border-bottom:2px solid rgba(0,220,255,0.75); border-left:2px solid rgba(0,220,255,0.75); }
#hud-bldg .hc-br { bottom:-1px; right:-1px;
  border-bottom:2px solid rgba(0,220,255,0.75); border-right:2px solid rgba(0,220,255,0.75); }

/* ── Header ── */
.hbldg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 18px;
  border-bottom: 1px solid rgba(0,180,255,0.13);
  position: relative;
  z-index: 1;
}
.hbldg-title {
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(0,180,255,0.45);
}
.hbldg-subtitle {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: rgba(0,180,255,0.30);
}
.hbldg-close {
  background: none;
  border: 1px solid rgba(0,180,255,0.20);
  color: rgba(0,180,255,0.55);
  font-size: 10px;
  width: 22px; height: 22px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.hbldg-close:hover {
  border-color: rgba(0,220,255,0.60);
  color: rgba(0,220,255,0.90);
}

/* ── Building card grid ── */
.hbldg-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 14px 18px 18px;
  position: relative;
  z-index: 1;
}

/* ── Single building card ── */
.hbldg-card {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid rgba(0,180,255,0.16);
  background: rgba(0,180,255,0.04);
}

.hbldg-icon {
  width: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  border-right: 1px solid rgba(0,180,255,0.12);
  background: rgba(0,180,255,0.05);
}

.hbldg-info {
  flex: 1;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hbldg-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 10px rgba(0,210,255,0.70);
}

.hbldg-desc {
  font-size: 10px;
  letter-spacing: 0.06em;
  color: rgba(0,180,255,0.55);
  line-height: 1.5;
}

.hbldg-stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.hbldg-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hbldg-stat-key {
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(0,180,255,0.38);
}
.hbldg-stat-val {
  font-size: 13px;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.88);
  text-shadow: 0 0 6px rgba(0,200,255,0.25);
}
.hbldg-stat-val.gold  { color: rgba(255,210,80,0.95); text-shadow: 0 0 8px rgba(255,200,60,0.55); }
.hbldg-stat-val.green { color: rgba(0,255,160,0.90);  text-shadow: 0 0 8px rgba(0,255,160,0.50); }

/* ── Right side: count + buy button ── */
.hbldg-actions {
  width: 110px;
  flex-shrink: 0;
  border-left: 1px solid rgba(0,180,255,0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 12px;
}

.hbldg-count-label {
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(0,180,255,0.38);
}
.hbldg-count-val {
  font-size: 28px;
  font-weight: 700;
  color: var(--h-blue, rgba(0,210,255,0.90));
  text-shadow: 0 0 14px rgba(0,210,255,0.70);
  line-height: 1;
}

.hbldg-buy-btn {
  width: 100%;
  padding: 8px 0;
  background: rgba(0,180,255,0.08);
  border: 1px solid rgba(0,200,255,0.30);
  color: rgba(0,210,255,0.90);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  text-shadow: 0 0 8px rgba(0,210,255,0.60);
}
.hbldg-buy-btn:hover:not(:disabled) {
  background: rgba(0,200,255,0.18);
  border-color: rgba(0,220,255,0.65);
  box-shadow: 0 0 18px rgba(0,200,255,0.28);
}
.hbldg-buy-btn:active:not(:disabled) {
  background: rgba(0,200,255,0.28);
}
.hbldg-buy-btn:disabled {
  opacity: 0.30;
  cursor: not-allowed;
  border-color: rgba(0,180,255,0.12);
}

/* ── Status message below button ── */
.hbldg-status {
  font-size: 8px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(255,100,100,0.70);
  min-height: 12px;
  white-space: nowrap;
}

/* ── New card style v2 ── */
.hbldg-card2 {
  display: flex;
  border: 1px solid rgba(0,180,255,0.08);
  border-left: 3px solid var(--accent, rgba(0,180,255,0.7));
  background: rgba(0,0,0,0.15);
  margin-bottom: 8px;
  transition: background 0.15s;
  cursor: pointer;
}
.hbldg-card2 * {
  pointer-events: none;
}
.hbldg-card2:last-child { margin-bottom: 0; }
.hbldg-card2:hover { background: rgba(0,0,0,0.25); }
.hbldg2-body {
  flex: 1;
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.hbldg2-top {
  display: flex;
  align-items: center;
  gap: 11px;
}
.hbldg2-icon {
  font-size: 26px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}
.hbldg2-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.hbldg2-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 10px var(--accent, rgba(0,210,255,0.6));
}
.hbldg2-desc {
  font-size: 9px;
  letter-spacing: 0.05em;
  color: rgba(0,180,255,0.42);
  line-height: 1.4;
}
.hbldg2-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 44px;
}
.hbldg2-count-num {
  font-size: 30px;
  font-weight: 700;
  color: var(--accent, rgba(0,210,255,0.9));
  text-shadow: 0 0 14px var(--accent, rgba(0,210,255,0.55));
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hbldg2-count-lbl {
  font-size: 7px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
}
.hbldg2-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.hbldg2-chip {
  font-size: 9px;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 2px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.45);
}
.hbldg2-chip.dim    { color: rgba(255,255,255,0.35); }
.hbldg2-chip.gold   { color: rgba(255,210,80,0.90);  border-color: rgba(255,200,60,0.22);  background: rgba(255,200,60,0.05); }
.hbldg2-chip.green  { color: rgba(0,255,150,0.88);   border-color: rgba(0,255,150,0.18);   background: rgba(0,255,140,0.05); }
.hbldg2-chip.blue   { color: rgba(120,200,255,0.88); border-color: rgba(120,200,255,0.18); background: rgba(100,180,255,0.05); }
.hbldg2-chip.orange { color: rgba(255,160,40,0.88);  border-color: rgba(255,160,40,0.22);  background: rgba(255,155,35,0.05); }
.hbldg2-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hbldg2-avail {
  font-size: 9px;
  letter-spacing: 0.07em;
  color: rgba(0,180,255,0.38);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hbldg2-avail span {
  color: rgba(0,210,255,0.72);
  font-variant-numeric: tabular-nums;
}
.hbldg2-build-btn {
  padding: 6px 16px;
  background: rgba(0,180,255,0.08);
  border: 1px solid var(--accent, rgba(0,200,255,0.32));
  color: var(--accent, rgba(0,220,255,0.90));
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  text-shadow: 0 0 7px var(--accent, rgba(0,210,255,0.50));
  white-space: nowrap;
  flex-shrink: 0;
}
.hbldg2-build-btn:hover:not(:disabled) {
  background: rgba(0,200,255,0.18);
  box-shadow: 0 0 14px rgba(0,200,255,0.25);
}
.hbldg2-build-btn:disabled {
  opacity: 0.26;
  cursor: not-allowed;
}

/* ─────────────────────────────────────────────────────────────────────────
   Building Detail Panel  (#hud-bldg-detail)
   ───────────────────────────────────────────────────────────────────────── */
#hud-bldg-detail {
  position: fixed;
  bottom: 28px;
  left: calc(28px + 640px + 16px);
  width: 380px;
  z-index: 203;
  pointer-events: none;
  font-family: 'Courier New', Courier, monospace;

  background: rgba(6, 16, 32, 0.80);
  backdrop-filter: blur(22px) saturate(2) brightness(0.88);
  -webkit-backdrop-filter: blur(22px) saturate(2) brightness(0.88);
  border: 1px solid rgba(0, 190, 255, 0.22);
  box-shadow:
    0 16px 56px rgba(0,0,0,0.65),
    0 0 36px rgba(0,180,255,0.12),
    inset 0 1px 0 rgba(255,255,255,0.04);

  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.20s ease, transform 0.20s ease;
}
#hud-bldg-detail.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* scanline */
#hud-bldg-detail::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    transparent 0px, transparent 3px,
    rgba(0,180,255,0.013) 3px, rgba(0,180,255,0.013) 4px
  );
  pointer-events: none;
  z-index: 0;
}

/* corner brackets */
#hud-bldg-detail .hc { position: absolute; width: 12px; height: 12px; }
#hud-bldg-detail .hc-tl { top:-1px; left:-1px;
  border-top:2px solid rgba(0,220,255,0.75); border-left:2px solid rgba(0,220,255,0.75); }
#hud-bldg-detail .hc-tr { top:-1px; right:-1px;
  border-top:2px solid rgba(0,220,255,0.75); border-right:2px solid rgba(0,220,255,0.75); }
#hud-bldg-detail .hc-bl { bottom:-1px; left:-1px;
  border-bottom:2px solid rgba(0,220,255,0.75); border-left:2px solid rgba(0,220,255,0.75); }
#hud-bldg-detail .hc-br { bottom:-1px; right:-1px;
  border-bottom:2px solid rgba(0,220,255,0.75); border-right:2px solid rgba(0,220,255,0.75); }

/* ── Header ── */
.hbd-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(0,180,255,0.13);
  position: relative;
  z-index: 1;
}
.hbd-icon {
  font-size: 22px;
  line-height: 1;
}
.hbd-title {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 10px rgba(0,210,255,0.70);
}
.hbd-close {
  background: none;
  border: 1px solid rgba(0,180,255,0.20);
  color: rgba(0,180,255,0.55);
  font-size: 10px;
  width: 22px; height: 22px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.hbd-close:hover {
  border-color: rgba(0,220,255,0.60);
  color: rgba(0,220,255,0.90);
}

/* ── Body ── */
.hbd-body {
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 1;
}

/* Info row: Built + Cost */
.hbd-info-row {
  display: flex;
  gap: 28px;
}
.hbd-info-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.hbd-info-key {
  font-size: 8px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: rgba(0,180,255,0.40);
}
.hbd-info-val {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(0,210,255,0.90);
  text-shadow: 0 0 12px rgba(0,210,255,0.60);
  line-height: 1;
}
.hbd-info-val.gold {
  font-size: 14px;
  color: rgba(255,210,80,0.95);
  text-shadow: 0 0 8px rgba(255,200,60,0.55);
}

/* Actions row */
.hbd-actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hbd-qty-group {
  display: flex;
  align-items: center;
  border: 1px solid rgba(0,180,255,0.25);
}
.hbd-qty-btn {
  background: rgba(0,180,255,0.06);
  border: none;
  color: rgba(0,210,255,0.80);
  font-family: inherit;
  font-size: 16px;
  width: 28px; height: 30px;
  cursor: pointer;
  transition: background 0.12s;
  line-height: 1;
}
.hbd-qty-btn:hover { background: rgba(0,180,255,0.18); }
.hbd-qty-hint {
  font-size: 9px;
  letter-spacing: 0.08em;
  color: rgba(0,200,255,0.45);
  white-space: nowrap;
  align-self: center;
}
.hbd-qty {
  min-width: 32px;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.90);
  padding: 0 6px;
  line-height: 30px;
  border-left: 1px solid rgba(0,180,255,0.18);
  border-right: 1px solid rgba(0,180,255,0.18);
}
.hbd-action-btn {
  flex: 1;
  padding: 8px 0;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.hbd-btn-build {
  background: rgba(0,180,255,0.08);
  border-color: rgba(0,200,255,0.35);
  color: rgba(0,210,255,0.90);
  text-shadow: 0 0 8px rgba(0,210,255,0.55);
}
.hbd-btn-build:hover:not(:disabled) {
  background: rgba(0,200,255,0.18);
  border-color: rgba(0,220,255,0.65);
  box-shadow: 0 0 16px rgba(0,200,255,0.25);
}
.hbd-btn-build:disabled { opacity: 0.28; cursor: not-allowed; }
.hbd-btn-destroy {
  background: rgba(255,60,60,0.07);
  border-color: rgba(255,80,80,0.30);
  color: rgba(255,100,100,0.85);
}
.hbd-btn-destroy:hover:not(:disabled) {
  background: rgba(255,60,60,0.18);
  border-color: rgba(255,80,80,0.65);
  box-shadow: 0 0 14px rgba(255,60,60,0.22);
}
.hbd-btn-destroy:disabled { opacity: 0.22; cursor: not-allowed; }

/* Status line */
.hbd-status {
  font-size: 9px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(255,100,100,0.75);
  min-height: 12px;
  margin-top: -6px;
}

/* Worker section */
.hbd-worker-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid rgba(0,180,255,0.10);
  padding-top: 14px;
}
.hbd-worker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hbd-worker-label {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(0,180,255,0.50);
}
.hbd-worker-vals {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(0,210,255,0.80);
}
.hbd-slider {
  width: 100%;
  accent-color: rgba(0,200,255,0.85);
  cursor: pointer;
}
.hbd-worker-hint {
  font-size: 8px;
  letter-spacing: 0.06em;
  color: rgba(0,180,255,0.30);
  line-height: 1.4;
}

/* Hotbar active state */
.h2-hotbar-cell--active {
  background: rgba(0,180,255,0.16) !important;
  border-color: rgba(0,220,255,0.65) !important;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.3), 0 0 12px rgba(0,200,255,0.35) !important;
}
