/* V1.4.2 · screen-safe HUD placement.
 * The Three.js board is intentionally overscanned to fill the screen.
 * Do NOT anchor interactive overlays to that crop. These are children of
 * .battle (the actual visible viewport), not of the oversized .board-wrap.
 * Debug/2D presentation is deliberately untouched. */

/* The old renderer overlay is a real full-screen pseudo-element. A smaller
 * inset shadow still draws a visible dark rectangle on some monitors.
 * Remove it ENTIRELY for the normal formal scene: the actual 3D world is the
 * only battlefield backdrop. Observer indication is kept separately. */
.legion-game.mode-formal .board-wrap:not([data-observation])::after {
  content:none!important;
  display:none!important;
  border:0!important;
  box-shadow:none!important;
  background:none!important;
  filter:none!important;
}
/* Spectator mode keeps only an identifying edge, without darkening the map. */
.legion-game.mode-formal .board-wrap[data-observation]::after {
  border:0!important;
  background:none!important;
  filter:none!important;
  box-shadow:inset 0 0 0 3px #77bdf4a0!important;
  pointer-events:none!important;
}
.legion-game.mode-formal .board-wrap[data-observation="red"]::after {
  box-shadow:inset 0 0 0 3px #f47c8daa!important;
}

/* Only the inspector's actual CONTENT needs a dark backdrop. Previously its
 * gradient stretched from stage top to bottom and darkened the wave bar and
 * the entire left third of the screen. Bound it independently from the map. */
.legion-game.mode-formal .battle > #unit-inspector:not([hidden]) {
  position:absolute!important;
  top:clamp(115px,14vh,144px)!important;
  left:clamp(8px,1vw,17px)!important;
  right:auto!important;
  bottom:auto!important;
  height:min(570px,calc(100% - 198px))!important;
  min-height:0!important;
  max-height:calc(100% - 165px)!important;
  width:min(355px,calc(100vw - 30px))!important;
  max-width:calc(100% - 22px)!important;
  margin:0!important;
  box-sizing:border-box!important;
  padding:8px 20px 12px 8px!important;
  overflow:hidden!important;
  z-index:27!important;
  zoom:1!important;
  background:linear-gradient(90deg,#09171ee8 0%,#10242cce 63%,#10242b74 83%,transparent 100%);
  box-shadow:none!important;
  pointer-events:auto;
}

/* Fixed identity and tabs, independent text scrolling. Suppress long-number
 * clipping on monitors using Windows text scaling. */
.legion-game.mode-formal #unit-inspector .unit-detail-top,
.legion-game.mode-formal #unit-inspector .unit-detail-stats,
.legion-game.mode-formal #unit-inspector .unit-detail-tabs { flex-shrink:0; }
.legion-game.mode-formal #unit-inspector .unit-detail-scroll {
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overscroll-behavior:contain;
}
.legion-game.mode-formal #unit-inspector .unit-stat b {
  white-space:normal;
  overflow-wrap:anywhere;
  font-variant-numeric:tabular-nums;
}

/* Align start/ready/restart actions to real screen-safe coordinates. Zoom on
 * the positioned wrapper previously made its bottom offset misleading. */
.legion-game.mode-formal .battle > .formal-board-actions {
  position:absolute!important;
  right:max(24px,calc(env(safe-area-inset-right) + 18px))!important;
  bottom:max(77px,calc(env(safe-area-inset-bottom) + 72px))!important;
  left:auto!important;
  top:auto!important;
  transform:none!important;
  zoom:1!important;
  z-index:30!important;
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:8px;
  max-width:calc(100% - 48px);
  pointer-events:none;
}
.legion-game.mode-formal .battle > .formal-board-actions button:not([hidden]) {
  zoom:var(--terra-hud-scale,.95);
  pointer-events:auto;
  position:relative;
  min-width:138px;
  max-width:min(255px,calc(100vw - 48px));
  margin:0;
  border-radius:3px;
  box-shadow:0 4px 19px #000b,0 0 0 1px #d5f9db22 inset;
}

/* A narrower or shorter display must keep both the inspector and action
 * buttons visible without scaling the 3D board or modifying its hit tests. */
@media(max-height:760px) {
  .legion-game.mode-formal .battle > #unit-inspector:not([hidden]) {
    top:92px!important;
    height:calc(100% - 155px)!important;
    max-height:calc(100% - 155px)!important;
    padding:3px 16px 8px 7px!important;
  }
  .legion-game.mode-formal .battle > .formal-board-actions {
    bottom:max(44px,calc(env(safe-area-inset-bottom) + 42px))!important;
  }
}
@media(max-width:650px) {
  .legion-game.mode-formal .battle > #unit-inspector:not([hidden]) {
    left:6px!important;
    width:min(310px,calc(100vw - 12px))!important;
    max-width:calc(100% - 12px)!important;
  }
  .legion-game.mode-formal .battle > .formal-board-actions {
    right:max(10px,env(safe-area-inset-right))!important;
  }
}
