/* World-class UI/UX Phase 3 — battlefield composition and lane/board integration */
:root {
  --tactical-field-width: 520px;
  --lane-active: rgba(102, 231, 255, 0.2);
  --lane-line: rgba(133, 231, 255, 0.2);
}

.battlefield {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  justify-items: center;
  align-content: start;
  gap: 12px;
  min-height: 0;
  padding: 18px clamp(14px, 3.4vw, 38px) 22px;
}

.battlefield::before {
  opacity: 0.72;
  background-size: 42px 42px;
}

.battlefield::after {
  width: min(78vw, 760px);
  right: 50%;
  top: 3%;
  transform: translateX(50%);
  opacity: 0.68;
}

.lane-preview {
  display: none;
}

.combat-panel {
  width: min(100%, var(--tactical-field-width));
  max-width: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-self: center;
  text-align: left;
}

.combat-panel > .eyebrow,
.combat-panel > h2,
.combat-panel > p {
  display: none;
}

.combat-panel .wave-progress {
  order: 1;
  margin-top: 0;
  margin-bottom: 8px;
}

.combat-panel .boss-hud {
  order: 2;
  margin-bottom: 8px;
}

.combat-panel .combat-stage {
  order: 3;
}

.combat-panel .unit-roster {
  order: 4;
  margin: 9px 0 0;
}

.combat-panel .perk-summary {
  order: 5;
  margin: 7px 0 0;
}

.combat-panel .context-hint {
  order: 6;
  margin: 7px 0 0;
}

.combat-stage {
  position: relative;
  width: 100%;
  height: clamp(270px, 40vh, 350px);
  margin-top: 0;
  overflow: hidden;
  border-color: rgba(117, 226, 255, 0.28);
  border-radius: 20px 20px 14px 14px;
  background:
    linear-gradient(180deg, rgba(11, 31, 43, 0.96), rgba(3, 11, 17, 0.99)),
    #061018;
  box-shadow:
    inset 0 0 60px rgba(71, 203, 240, 0.05),
    0 10px 28px rgba(0, 0, 0, 0.2);
}

.combat-stage::before {
  content: "THREAT ENTRY  ↓";
  top: 7px;
  left: 10px;
  color: rgba(255, 171, 112, 0.58);
}

.combat-stage::after {
  content: "▼  CORE DEFENSE LINE";
  right: 10px;
  bottom: 7px;
  color: rgba(134, 236, 255, 0.54);
}

.combat-stage__grid {
  z-index: 0;
}

.combat-stage__grid span {
  position: relative;
  border-left-color: var(--lane-line);
  background:
    linear-gradient(180deg, rgba(102, 231, 255, 0.025), transparent 24%, rgba(102, 231, 255, 0.028) 78%, transparent),
    repeating-linear-gradient(180deg, transparent 0 34px, rgba(129, 225, 249, 0.025) 35px, transparent 36px);
  transition: background 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.combat-stage__grid span::before {
  position: absolute;
  left: 8px;
  top: 24px;
  color: rgba(165, 222, 236, 0.34);
  font-size: 0.5rem;
  font-weight: 950;
  letter-spacing: 0.12em;
}

.combat-stage__grid span:nth-child(1)::before { content: "L1"; }
.combat-stage__grid span:nth-child(2)::before { content: "L2"; }
.combat-stage__grid span:nth-child(3)::before { content: "L3"; }

.combat-stage__grid span::after {
  content: "↓";
  position: absolute;
  left: 50%;
  top: 43%;
  transform: translate(-50%, -50%);
  color: rgba(137, 221, 242, 0.13);
  font-size: 1.1rem;
  font-weight: 900;
}

.combat-stage__entities {
  z-index: 2;
}

.combat-stage .core-node.core-visual {
  top: auto;
  bottom: 4px;
  z-index: 3;
  width: 82px;
  height: 82px;
}

.combat-stage .core-visual__frame--outer { width: 72px; height: 72px; }
.combat-stage .core-visual__ring--outer { width: 64px; height: 64px; }
.combat-stage .core-visual__ring--inner { width: 45px; height: 45px; }
.combat-stage .core-visual__strut { width: 65px; height: 8px; }
.combat-stage .core-visual__shield { width: 39px; height: 39px; }
.combat-stage .core-visual__reactor { width: 25px; height: 25px; }
.combat-stage .core-visual__reactor-glow { width: 10px; height: 10px; }
.combat-stage .core-visual__integrity { width: 77px; height: 77px; }
.combat-stage .core-visual__label { top: calc(50% + 36px) !important; }

.board-preview {
  width: min(100%, var(--tactical-field-width));
  justify-self: center;
  padding: 10px;
  gap: 7px;
  border-radius: 14px 14px 20px 20px;
  border-color: rgba(111, 224, 255, 0.25);
  background:
    linear-gradient(90deg,
      rgba(102, 231, 255, 0.035) 0 33.333%,
      rgba(157, 123, 255, 0.025) 33.333% 66.666%,
      rgba(102, 231, 255, 0.035) 66.666% 100%),
    rgba(4, 13, 20, 0.76);
  box-shadow:
    inset 0 0 46px rgba(71, 203, 240, 0.035),
    0 12px 28px rgba(0, 0, 0, 0.18);
}

.board-preview::before {
  content: "DEFENDER GRID  ·  COLUMNS = LANES";
  position: absolute;
  left: 50%;
  top: -10px;
  z-index: 6;
  transform: translateX(-50%);
  padding: 2px 8px;
  border: 1px solid rgba(111, 224, 255, 0.18);
  border-radius: 999px;
  background: rgba(3, 12, 18, 0.94);
  color: rgba(179, 229, 241, 0.48);
  font-size: 0.46rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  white-space: nowrap;
  pointer-events: none;
}

.board-preview__slot {
  aspect-ratio: 1.45;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 44%, rgba(101, 225, 255, 0.07), transparent 54%),
    rgba(10, 26, 36, 0.8);
}

.board-preview__slot:nth-child(-n + 3)::before {
  position: absolute;
  left: 7px;
  top: 6px;
  color: rgba(174, 224, 236, 0.34);
  font-size: 0.44rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.board-preview__slot:nth-child(1)::before { content: "L1"; }
.board-preview__slot:nth-child(2)::before { content: "L2"; }
.board-preview__slot:nth-child(3)::before { content: "L3"; }

/* Dragging a defender lights the combat lane and every slot mapped to that lane. */
.combat-stage[data-focus-lane="1"] .combat-stage__grid span:nth-child(1),
.combat-stage[data-focus-lane="2"] .combat-stage__grid span:nth-child(2),
.combat-stage[data-focus-lane="3"] .combat-stage__grid span:nth-child(3) {
  border-color: rgba(137, 236, 255, 0.72);
  background:
    linear-gradient(180deg, rgba(102, 231, 255, 0.16), rgba(102, 231, 255, 0.045) 62%, rgba(102, 231, 255, 0.13)),
    repeating-linear-gradient(180deg, transparent 0 34px, rgba(167, 239, 255, 0.09) 35px, transparent 36px);
  box-shadow: inset 0 0 28px rgba(102, 231, 255, 0.1);
}

.board-preview[data-focus-lane="1"] .board-preview__slot[data-lane="1"],
.board-preview[data-focus-lane="2"] .board-preview__slot[data-lane="2"],
.board-preview[data-focus-lane="3"] .board-preview__slot[data-lane="3"] {
  border-color: rgba(124, 232, 255, 0.68);
  background:
    radial-gradient(circle at 50% 44%, rgba(102, 231, 255, 0.17), transparent 58%),
    rgba(11, 33, 43, 0.93);
  box-shadow: inset 0 0 22px rgba(102, 231, 255, 0.09);
}

.battlefield[data-lane-dragging="true"] .board-preview {
  border-color: rgba(111, 224, 255, 0.36);
}

@media (max-width: 720px) {
  :root { --tactical-field-width: 100%; }

  .battlefield {
    grid-template-rows: auto auto;
    gap: 10px;
    padding: 10px 9px 13px;
  }

  .combat-panel {
    width: 100%;
    max-width: none;
    text-align: left;
  }

  .combat-panel .unit-roster {
    margin-top: 7px;
  }

  .combat-stage {
    height: clamp(210px, 31vh, 286px);
    border-radius: 17px 17px 12px 12px;
  }

  .combat-stage .core-node.core-visual {
    bottom: 2px;
    width: 68px;
    height: 68px;
  }

  .combat-stage .core-visual__frame--outer { width: 60px; height: 60px; }
  .combat-stage .core-visual__ring--outer { width: 53px; height: 53px; }
  .combat-stage .core-visual__ring--inner { width: 37px; height: 37px; }
  .combat-stage .core-visual__strut { width: 54px; height: 7px; }
  .combat-stage .core-visual__shield { width: 33px; height: 33px; }
  .combat-stage .core-visual__reactor { width: 21px; height: 21px; }
  .combat-stage .core-visual__reactor-glow { width: 8px; height: 8px; }
  .combat-stage .core-visual__integrity { width: 64px; height: 64px; }
  .combat-stage .core-visual__label { top: calc(50% + 30px) !important; font-size: 0.38rem; }

  .board-preview {
    width: 100%;
    padding: 8px;
    gap: 6px;
    border-radius: 12px 12px 17px 17px;
  }

  .board-preview__slot {
    aspect-ratio: 1.28;
    min-height: 62px;
    border-radius: 10px;
  }

  .board-preview::before {
    top: -8px;
    font-size: 0.4rem;
  }
}

@media (max-width: 390px) {
  .battlefield {
    padding-left: 7px;
    padding-right: 7px;
  }

  .combat-stage {
    height: clamp(190px, 29vh, 244px);
  }

  .board-preview {
    padding: 7px;
    gap: 5px;
  }

  .board-preview__slot {
    min-height: 58px;
  }
}

@media (max-height: 680px) and (max-width: 720px) {
  .battlefield {
    gap: 8px;
    padding-top: 8px;
  }

  .combat-panel .unit-roster,
  .combat-panel .perk-summary:not([data-empty="false"]) {
    display: none;
  }

  .combat-stage {
    height: clamp(172px, 27vh, 218px);
  }

  .board-preview__slot {
    aspect-ratio: 1.42;
    min-height: 52px;
  }

  .board-preview::before {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .combat-stage__grid span,
  .board-preview__slot {
    transition: none;
  }
}