/* The tactical terminal occupies its own viewport column. The Cocos stage
   and HUD use the remaining rectangle, so controls never cover the field. */
:root{--tactical-width:260px}
#tactical-sidebar{display:none}
body.squad-mode #stage,body.squad-mode #hud{left:var(--tactical-width);right:0;width:auto}
body.squad-mode #stage{contain:layout paint;isolation:isolate}
body.squad-mode #damage-flash{left:var(--tactical-width)}
body.squad-mode #tactical-sidebar{
  position:fixed;inset:0 auto 0 0;z-index:5;display:flex;flex-direction:column;gap:12px;
  width:var(--tactical-width);height:100vh;height:100dvh;box-sizing:border-box;
  padding:max(15px,env(safe-area-inset-top)) 13px max(12px,env(safe-area-inset-bottom)) max(13px,env(safe-area-inset-left));
  overflow:hidden;overscroll-behavior:contain;
  background:linear-gradient(160deg,#1a3137 0%,#10242b 40%,#09181f 100%);border-right:1px solid #729b8a6b;
  color:#c8ddcc;box-shadow:inset -1px 0 #09161a;pointer-events:auto;touch-action:pan-y
}
#tactical-sidebar>*{flex:0 0 auto;min-width:0;box-sizing:border-box}
#tactical-sidebar .tactical-sidebar-scroll{display:flex;flex:1 1 auto;flex-direction:column;gap:12px;min-height:0;min-width:0;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#517c70 #102126}
#tactical-sidebar .tactical-sidebar-scroll>*{flex:0 0 auto;min-width:0;box-sizing:border-box}
#tactical-sidebar .tactical-sidebar-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 1px 11px;border-bottom:1px solid #7a9b8240;color:#ebd09c;font-size:15px;font-weight:650;letter-spacing:3px;line-height:1.4}
#tactical-sidebar .tactical-sidebar-heading small{font-size:8px;letter-spacing:1px;font-weight:400;color:#85aa9b}
#tactical-sidebar h2{margin:0 0 8px;font-size:11px;line-height:1.4;font-weight:500;letter-spacing:1px;color:#b9d7c6}
#tactical-sidebar #sidebar-map{padding:10px;background:#0a1b22a8;border:1px solid #698e7952}
#tactical-sidebar #sidebar-map header{display:flex;align-items:center;justify-content:space-between;gap:5px;margin-bottom:7px}
#tactical-sidebar #sidebar-map header h2{margin:0}
#tactical-sidebar #sidebar-map header small{font-size:8px;letter-spacing:.5px;color:#759c8c}
#tactical-sidebar #tactical-map{display:block;width:100%;height:128px;box-sizing:border-box;border:1px solid #5078646b;background:#08161c;image-rendering:auto;pointer-events:none}

/* Reset all earlier floating-widget positions inside this column. */
body.squad-mode #tactical-sidebar #squad-roster,
body.squad-mode #tactical-sidebar #squad-command,
body.squad-mode #tactical-sidebar #squad-ammo,
body.squad-mode #tactical-sidebar .bottom-left{
  position:static;inset:auto;left:auto;right:auto;top:auto;bottom:auto;transform:none;
  width:100%;max-width:none;min-width:0;height:auto;margin:0;box-sizing:border-box
}
#tactical-sidebar #squad-roster{padding:10px;background:#0b1d25ad;border:1px solid #74968a47;pointer-events:auto}
#tactical-sidebar .squad-roster-title{margin:0 0 3px;gap:5px;font-size:9px;letter-spacing:.4px;line-height:1.4}
#tactical-sidebar .squad-roster-title strong{font-size:9px;white-space:nowrap}
#tactical-sidebar .squad-member{display:flex;gap:7px;align-items:center;margin:0;padding:9px 0 8px;border-bottom:1px solid #6b8c7430}
#tactical-sidebar .squad-member:last-child{border-bottom:0;padding-bottom:2px}
#tactical-sidebar .squad-member>b{flex:0 0 25px;box-sizing:border-box;padding:5px 2px;text-align:center;font-size:11px;line-height:1.2;border-radius:2px}
#tactical-sidebar .squad-member>div{min-width:0;flex:1}
#tactical-sidebar .squad-member-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10px;line-height:1.3}
#tactical-sidebar .squad-member-weapon{font-size:9px;line-height:1.3;margin:3px 0 5px}
#tactical-sidebar .squad-member-track{height:4px}
#tactical-sidebar .squad-member-health{flex:0 0 auto;max-width:52px;font-size:10px;font-variant-numeric:tabular-nums;white-space:nowrap}

#tactical-sidebar #squad-ammo{padding:10px;background:#0b1d25ad;border:1px solid #74968a47}
#tactical-sidebar #squad-ammo-list{display:grid;gap:8px;min-width:0}
#tactical-sidebar .squad-ammo-group{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 7px;padding-bottom:8px;border-bottom:1px solid #6b8c7430;min-width:0}
#tactical-sidebar .squad-ammo-group:last-child{padding-bottom:0;border-bottom:0}
#tactical-sidebar .squad-ammo-header{grid-column:1/-1;display:flex;align-items:center;justify-content:space-between;gap:7px;min-width:0}
#tactical-sidebar #squad-ammo>.squad-ammo-header{flex-wrap:wrap;margin-bottom:8px}
#tactical-sidebar #squad-ammo>.squad-ammo-header h2{margin:0}
#tactical-sidebar #squad-ammo>.squad-ammo-header #squad-ammo-total{margin:0;padding:0;border:0}
#tactical-sidebar .squad-ammo-group>.squad-ammo-header{flex-wrap:nowrap}
#tactical-sidebar .squad-ammo-gun{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10px;color:#c6ddcd;line-height:1.4}
#tactical-sidebar .squad-ammo-gun{flex:1 1 auto}
#tactical-sidebar .squad-ammo-reserve{flex:0 0 auto;font-size:10px;color:#e5c58a;font-variant-numeric:tabular-nums;white-space:nowrap;line-height:1.4}
#tactical-sidebar .squad-ammo-members{grid-column:1/-1;display:flex;flex-wrap:wrap;gap:4px}
#tactical-sidebar .squad-ammo-member{display:inline-flex;align-items:center;gap:4px;min-height:21px;padding:2px 5px;box-sizing:border-box;border:1px solid #709a8052;background:#20382f66;font-size:9px;line-height:1.2}
#tactical-sidebar .squad-ammo-label{color:#92b8a5;font-size:8px}
#tactical-sidebar .squad-ammo-magazine{color:#d6e4cc;font-size:9px;font-variant-numeric:tabular-nums;white-space:nowrap}
#tactical-sidebar #squad-ammo-total{margin:8px 0 0;padding-top:7px;border-top:1px solid #789c6f3d;color:#a2bf9e;font-size:9px;line-height:1.5;font-variant-numeric:tabular-nums}

#tactical-sidebar #squad-command{padding:10px;background:#0e232bd9;border:1px solid #7caa9c63;box-shadow:none;pointer-events:auto;touch-action:pan-y}
#tactical-sidebar .squad-command-title{display:flex;align-items:flex-start;justify-content:space-between;gap:5px;margin:0 0 9px;line-height:1.4}
#tactical-sidebar .squad-command-title small{display:block;font-size:9px;letter-spacing:.7px;color:#ddc18c;white-space:nowrap}
#tactical-sidebar #squad-order{font-size:9px;line-height:1.4;text-align:right;overflow-wrap:anywhere;max-width:130px;color:#9fc4ae}
#tactical-sidebar .squad-command-body{display:block}
#tactical-sidebar .squad-compass{display:grid;grid-template-columns:repeat(3,minmax(44px,1fr));gap:4px;width:100%;margin:0 auto;touch-action:manipulation}
#tactical-sidebar .squad-compass button{width:100%;height:44px;min-width:44px;min-height:44px;padding:0;box-sizing:border-box;font-size:22px;line-height:1;touch-action:manipulation}
#tactical-sidebar .squad-compass #squad-hold{font-size:11px;white-space:nowrap}
#tactical-sidebar .squad-command-actions{display:flex;gap:5px;margin-top:9px}
#tactical-sidebar .squad-bombard{width:auto;min-width:0;min-height:44px;margin:0;padding:7px 5px;box-sizing:border-box;font-size:10px;letter-spacing:0;line-height:1.4;touch-action:manipulation}
#tactical-sidebar .squad-command-actions #squad-supply{max-width:75px}
#tactical-sidebar button:focus-visible{outline:2px solid #edcf8c;outline-offset:2px}
body.squad-mode #tactical-sidebar .bottom-left{display:block!important;margin-top:auto;padding:10px;background:#172e2c9c;border:1px solid #82936b50}
#tactical-sidebar .bottom-left .status-caption,#tactical-sidebar .bottom-left .health-track,#tactical-sidebar .bottom-left #dash-status{display:none!important}
#tactical-sidebar .bottom-left .status-footer{display:flex!important;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:6px;margin:0;font-size:10px;line-height:1.4;letter-spacing:0}
#tactical-sidebar .bottom-left .status-footer b{font-size:13px;line-height:1.2;font-variant-numeric:tabular-nums}
body.squad-mode .weapon-panel{display:none!important}

/* These overlays are now relative to the actual battle viewport. */
body.squad-mode #hud .topbar{left:20px;right:20px;top:max(15px,env(safe-area-inset-top));gap:12px}
body.squad-mode #hud .mission-meta{right:20px;top:85px}
body.squad-mode #hud #assault-strip,
body.squad-mode.assault-mode #hud #assault-strip{left:50%;right:auto;top:85px;transform:translateX(-50%);width:min(680px,calc(100% - 40px));box-sizing:border-box}
body.squad-mode #hud #boss-bar{left:15%;right:15%;top:135px;width:auto;transform:none}
body.squad-mode.assault-mode #hud #boss-bar{left:15%;right:15%;top:168px;width:auto;transform:none}
body.squad-mode #hud .bottom-center{left:50%;right:auto;bottom:max(18px,env(safe-area-inset-bottom));width:calc(100% - 36px);max-width:650px;transform:translateX(-50%)}
body.squad-mode #hud #controls-hint{display:none}
@media(min-width:901px) and (min-height:561px){
  body.squad-mode.assault-mode #hud #assault-strip{left:20px;right:260px;width:auto;transform:none}
}
.commander-squad .squad-formations{grid-template-columns:1fr}
.commander-squad .squad-custom-formation{display:flex;align-items:center;gap:16px;min-height:100px;text-align:left;cursor:default}
.commander-squad .squad-custom-formation .squad-formation-diagram{flex:0 0 90px;margin:0}
.commander-squad .squad-custom-formation strong{margin:0;white-space:nowrap}
.commander-squad .squad-custom-formation small{font-size:10px;line-height:1.7}

@media(max-width:1100px) and (orientation:landscape){
  :root{--tactical-width:208px}
  body.squad-mode #tactical-sidebar{gap:8px;padding:10px 8px max(8px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))}
  #tactical-sidebar .tactical-sidebar-scroll{gap:8px}
  #tactical-sidebar .tactical-sidebar-heading{font-size:12px;letter-spacing:2px;padding-bottom:8px}
  #tactical-sidebar #sidebar-map,#tactical-sidebar #squad-roster,#tactical-sidebar #squad-ammo,#tactical-sidebar #squad-command{padding:8px}
  #tactical-sidebar #tactical-map{height:90px}
  #tactical-sidebar .squad-member{gap:5px;padding:7px 0 6px}
  #tactical-sidebar .squad-member>b{flex-basis:21px;font-size:10px}
  #tactical-sidebar .squad-member-health{font-size:9px}
  body.squad-mode #hud .topbar{left:12px;right:12px;top:max(10px,env(safe-area-inset-top));gap:8px}
  body.squad-mode #hud .brand strong{font-size:15px;letter-spacing:1px}
  body.squad-mode #hud .brand small{font-size:6px;letter-spacing:1.5px}
  body.squad-mode #hud .mission-strip{min-width:0;max-width:42%;padding:7px 9px}
  body.squad-mode #hud .mission-strip strong{display:block;font-size:10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  body.squad-mode #hud .toolbar{gap:3px}
  body.squad-mode #hud .utility{width:29px;height:29px}
  body.squad-mode #hud #assault-strip,
  body.squad-mode.assault-mode #hud #assault-strip{top:65px;width:calc(100% - 24px)}
  body.squad-mode #hud .mission-meta{right:12px;top:62px}
  body.squad-mode #hud #boss-bar{left:12px;right:12px;top:100px}
  body.squad-mode.assault-mode #hud #boss-bar{left:12px;right:12px;top:145px}
}

/* Pair the map with the roster on short landscape screens. With two initial
   recruits this preserves space for nine full-size direction controls. */
@media(max-height:560px) and (orientation:landscape){
  body.squad-mode #tactical-sidebar{display:flex;flex-direction:column;gap:6px}
  #tactical-sidebar .tactical-sidebar-scroll{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-content:start;align-items:start;gap:6px}
  #tactical-sidebar .tactical-sidebar-heading{grid-column:1/-1;padding-bottom:5px;font-size:11px}
  #tactical-sidebar #sidebar-map{grid-column:1;padding:5px}
  #tactical-sidebar #sidebar-map header{margin-bottom:4px}
  #tactical-sidebar h2{font-size:9px;letter-spacing:0;margin-bottom:5px}
  #tactical-sidebar #sidebar-map header small{display:none}
  #tactical-sidebar #tactical-map{height:64px}
  #tactical-sidebar #squad-roster{grid-column:2;padding:5px}
  #tactical-sidebar .squad-roster-title{flex-wrap:wrap;gap:1px;font-size:7px;margin:0 0 2px;line-height:1.1}
  #tactical-sidebar .squad-roster-title>span{display:none}
  #tactical-sidebar .squad-roster-title strong{font-size:8px}
  #tactical-sidebar .squad-member{position:relative;gap:3px;padding:4px 0 6px}
  #tactical-sidebar .squad-member>b{flex-basis:17px;font-size:8px;padding:3px 0}
  #tactical-sidebar .squad-member-name{font-size:7px;line-height:1.2}
  #tactical-sidebar .squad-member-weapon{font-size:7px;margin:1px 0 3px;line-height:1.2}
  #tactical-sidebar .squad-member-track{height:3px}
  #tactical-sidebar .squad-member-health{font-size:8px;max-width:none;position:absolute;right:0;bottom:0;line-height:1.1}
  #tactical-sidebar #squad-ammo{grid-column:1/-1;padding:6px}
  #tactical-sidebar #squad-ammo>.squad-ammo-header{display:none}
  #tactical-sidebar #squad-ammo-list{grid-template-columns:minmax(0,1fr);gap:4px}
  #tactical-sidebar .squad-ammo-group{gap:0;padding:0;border:0}
  #tactical-sidebar .squad-ammo-group>.squad-ammo-header{grid-column:1/-1;display:flex;justify-content:space-between;gap:5px}
  #tactical-sidebar .squad-ammo-gun,#tactical-sidebar .squad-ammo-reserve{font-size:8px;line-height:1.2}
  #tactical-sidebar .squad-ammo-members{display:none}
  #tactical-sidebar .squad-ammo-member{gap:3px;padding:1px 3px;min-height:16px}
  #tactical-sidebar .squad-ammo-label{font-size:7px}
  #tactical-sidebar .squad-ammo-magazine{font-size:8px}
  #tactical-sidebar #squad-ammo-total{margin-top:4px;padding-top:4px;font-size:8px;line-height:1.3}
  #tactical-sidebar #squad-command{flex:0 0 auto;padding:3px}
  #tactical-sidebar .squad-command-title{margin-bottom:3px;gap:3px;line-height:1.2}
  #tactical-sidebar .squad-command-title small{font-size:8px;letter-spacing:0;line-height:1.2}
  #tactical-sidebar #squad-order{font-size:8px;max-width:123px;line-height:1.2}
  #tactical-sidebar .squad-compass{gap:2px}
  #tactical-sidebar .squad-command-actions{margin-top:3px;gap:4px}
  #tactical-sidebar .squad-bombard{font-size:9px}
  body.squad-mode #tactical-sidebar .bottom-left{grid-column:1/-1;padding:6px}
  #tactical-sidebar .bottom-left .status-footer{font-size:8px}
  #tactical-sidebar .bottom-left .status-footer b{font-size:10px}
  body.squad-mode #hud .mission-meta{display:none}
  body.squad-mode #hud .mission-strip{max-width:40%;padding:5px 7px}
  body.squad-mode #hud .mission-strip small{font-size:6px;letter-spacing:1px}
  body.squad-mode #hud .mission-strip strong{font-size:9px}
  body.squad-mode #hud #assault-strip,
  body.squad-mode.assault-mode #hud #assault-strip{left:50%;right:auto;transform:translateX(-50%);width:calc(100% - 24px);top:57px;padding:4px 6px}
  body.squad-mode #hud .assault-sectors span{font-size:7px;padding:4px 2px;white-space:nowrap}
  body.squad-mode #hud #assault-objective{font-size:8px;margin:4px 2px 0;line-height:1.4}
  body.squad-mode #hud #boss-bar{left:12px;right:12px;top:62px;padding:6px 9px}
  body.squad-mode.assault-mode #hud #boss-bar{left:12px;right:12px;top:112px}
  body.squad-mode #hud .bottom-center{left:50%;right:auto;transform:translateX(-50%);bottom:12px;width:calc(100% - 24px);max-width:620px}
}

@media(orientation:portrait) and (max-width:760px){
  :root{--tactical-width:160px}
  body.squad-mode #tactical-sidebar{gap:8px;padding:max(10px,env(safe-area-inset-top)) 5px max(8px,env(safe-area-inset-bottom)) max(5px,env(safe-area-inset-left))}
  #tactical-sidebar .tactical-sidebar-scroll{gap:8px}
  #tactical-sidebar .tactical-sidebar-heading{font-size:12px;letter-spacing:2px;padding:2px 3px 7px}
  #tactical-sidebar .tactical-sidebar-heading small{display:none}
  #tactical-sidebar #sidebar-map,#tactical-sidebar #squad-roster,#tactical-sidebar #squad-ammo,#tactical-sidebar #squad-command{padding:5px}
  #tactical-sidebar h2{font-size:10px;margin-bottom:6px}
  #tactical-sidebar #sidebar-map header small{display:none}
  #tactical-sidebar #tactical-map{height:90px}
  #tactical-sidebar .squad-member{gap:4px;padding:8px 0 7px}
  #tactical-sidebar .squad-member>b{flex-basis:18px;padding:4px 0;font-size:9px}
  #tactical-sidebar .squad-member-name{font-size:8px}
  #tactical-sidebar .squad-member-weapon{font-size:8px;margin:2px 0 4px}
  #tactical-sidebar .squad-member-health{font-size:8px}
  #tactical-sidebar .squad-roster-title{font-size:7px;letter-spacing:0}
  #tactical-sidebar .squad-roster-title strong{font-size:8px}
  #tactical-sidebar .squad-compass{gap:2px}
  #tactical-sidebar .squad-command-title{flex-direction:column;gap:3px;margin-bottom:6px}
  #tactical-sidebar .squad-command-title small{font-size:9px}
  #tactical-sidebar #squad-order{max-width:none;text-align:left;font-size:8px}
  #tactical-sidebar .squad-command-actions{flex-direction:column;gap:4px;margin-top:6px}
  #tactical-sidebar .squad-command-actions #squad-supply{max-width:none}
  #tactical-sidebar .squad-ammo-group{gap:4px}
  #tactical-sidebar .squad-ammo-gun,#tactical-sidebar .squad-ammo-reserve{font-size:8px}
  #tactical-sidebar #squad-ammo-total{font-size:8px}
  body.squad-mode #tactical-sidebar .bottom-left{padding:6px}
  #tactical-sidebar .bottom-left .status-footer{font-size:8px;gap:5px}
  #tactical-sidebar .bottom-left .status-footer b{font-size:11px}
  body.squad-mode #hud .topbar{left:9px;right:9px;top:max(10px,env(safe-area-inset-top));gap:6px;align-items:center;flex-wrap:wrap}
  body.squad-mode #hud .brand{gap:0}
  body.squad-mode #hud .brand-emblem,body.squad-mode #hud .brand small{display:none}
  body.squad-mode #hud .brand strong{font-size:12px;letter-spacing:0}
  body.squad-mode #hud .mission-strip{display:none}
  body.squad-mode #hud .toolbar{gap:2px}
  body.squad-mode #hud .utility{width:28px;height:28px}
  body.squad-mode #hud .mission-meta{top:58px;left:9px;right:9px;justify-content:space-between}
  body.squad-mode #hud .meta-cell{padding:5px;min-width:0}
  body.squad-mode #hud .meta-cell small{font-size:5px;letter-spacing:0}
  body.squad-mode #hud .meta-cell strong{font-size:13px}
  body.squad-mode #hud .meta-cell .unit{font-size:7px}
  body.squad-mode #hud #assault-strip,
  body.squad-mode.assault-mode #hud #assault-strip{left:9px;right:9px;transform:none;top:108px;width:auto;padding:5px}
  body.squad-mode #hud .assault-sectors{flex-wrap:wrap;gap:2px}
  body.squad-mode #hud .assault-sectors span{flex:1 1 22%;font-size:7px;padding:4px 2px;line-height:1.3;white-space:nowrap}
  body.squad-mode #hud #assault-objective{font-size:8px;text-align:left;line-height:1.4;margin:5px 1px 0}
  body.squad-mode #hud #boss-bar{left:9px;right:9px;top:108px;padding:7px}
  body.squad-mode.assault-mode #hud #boss-bar{left:9px;right:9px;top:207px}
  body.squad-mode #hud .boss-label{font-size:9px;letter-spacing:0;gap:6px}
  body.squad-mode #hud .bottom-center{display:block;left:50%;right:auto;bottom:max(14px,env(safe-area-inset-bottom));width:calc(100% - 18px);max-width:none;transform:translateX(-50%)}
  body.squad-mode #hud #mission-hint{font-size:9px;line-height:1.7}
  .commander-squad .squad-custom-formation{flex-wrap:wrap;gap:10px}
  .commander-squad .squad-custom-formation .squad-formation-diagram{flex-basis:70px}
  .commander-squad .squad-custom-formation small{flex-basis:100%}
}
