CREATORJD commited on
Commit
3d60b29
·
verified ·
1 Parent(s): 812f855

Deploy v1.33.63 hotfix browser build (legacy-boot Apply repair) (part 3)

Browse files
src/engine/gl.js CHANGED
@@ -273,7 +273,10 @@ function resize(){
273
  VW = cssW; VH = cssH;
274
  cv.width = Math.round(VW*DPR); cv.height = Math.round(VH*DPR);
275
  gl.viewport(0,0,cv.width,cv.height);
276
- if(typeof camUpdateMatrices==='function') camUpdateMatrices();
 
 
 
277
  }
278
  /* Sun-depth CSM atlas binds on TEXTURE4 during csmApply only. Terrain
279
  already owns 0/1/2/3/7–15; ads stay on 7; post 4/5/6 never move to 0.
 
273
  VW = cssW; VH = cssH;
274
  cv.width = Math.round(VW*DPR); cv.height = Math.round(VH*DPR);
275
  gl.viewport(0,0,cv.width,cv.height);
276
+ /* mesh.js loads before terrain.js. A startup resize can land in that narrow
277
+ window, where the camera helper exists but its terrainH dependency does
278
+ not. Defer the matrix refresh; main performs one after all sources load. */
279
+ if(typeof camUpdateMatrices==='function'&&typeof terrainH==='function') camUpdateMatrices();
280
  }
281
  /* Sun-depth CSM atlas binds on TEXTURE4 during csmApply only. Terrain
282
  already owns 0/1/2/3/7–15; ads stay on 7; post 4/5/6 never move to 0.
src/main.js CHANGED
@@ -74,10 +74,17 @@ function startFirstContactGuide(){
74
  function setHudDeck(deck,quiet){
75
  const valid=['orders','platoons','buildings','abilities','view'];
76
  hudDeck=valid.includes(deck)?deck:'orders';
 
77
  document.body.classList.toggle('hudViewDeck',hudDeck==='view');
 
78
  document.querySelectorAll('.hudDeckBtn').forEach(b=>{
79
  const on=b.dataset.deck===hudDeck;b.classList.toggle('on',on);b.setAttribute('aria-selected',on?'true':'false');
 
80
  });
 
 
 
 
81
  for(const id of ['camRow','tacRow','grpRow','hotSlots']){
82
  const row=$(id); if(row) row.style.display='none';
83
  }
@@ -98,6 +105,7 @@ function showHudDock(on,deck){
98
  const primary=$('primaryRow'); if(primary) primary.style.display=on?'flex':'none';
99
  if(on) setHudDeck(deck||hudDeck,true);
100
  else {
 
101
  if(typeof closeBaseFinder==='function')closeBaseFinder(false);
102
  for(const id of ['tacRow','grpRow','hotSlots']){const row=$(id);if(row)row.style.display='none';}
103
  }
@@ -2829,6 +2837,7 @@ function wire(){
2829
  mfBindNativePress($('spdBtn'),()=>{
2830
  gameSpeed=gameSpeed===1?1.5:gameSpeed===1.5?2:1;
2831
  $('spdBtn').textContent=gameSpeed+'×';
 
2832
  toast('⏩ Game speed '+gameSpeed+'×'); sfx('ui');
2833
  });
2834
  /* The header is a tap target for Profile, but it now CONTAINS buttons — the
 
74
  function setHudDeck(deck,quiet){
75
  const valid=['orders','platoons','buildings','abilities','view'];
76
  hudDeck=valid.includes(deck)?deck:'orders';
77
+ if(hudDeck!=='abilities'&&typeof hotUtilityClose==='function')hotUtilityClose(true);
78
  document.body.classList.toggle('hudViewDeck',hudDeck==='view');
79
+ let activeTab=null;
80
  document.querySelectorAll('.hudDeckBtn').forEach(b=>{
81
  const on=b.dataset.deck===hudDeck;b.classList.toggle('on',on);b.setAttribute('aria-selected',on?'true':'false');
82
+ if(on)activeTab=b;
83
  });
84
+ /* Scaled labels can make the tab row horizontally scrollable. Keep the
85
+ newly selected tab inside that scroller instead of leaving its hit target
86
+ painted under the battlefield canvas at the clipped edge. */
87
+ if(activeTab)requestAnimationFrame(()=>activeTab.scrollIntoView({block:'nearest',inline:'nearest'}));
88
  for(const id of ['camRow','tacRow','grpRow','hotSlots']){
89
  const row=$(id); if(row) row.style.display='none';
90
  }
 
105
  const primary=$('primaryRow'); if(primary) primary.style.display=on?'flex':'none';
106
  if(on) setHudDeck(deck||hudDeck,true);
107
  else {
108
+ if(typeof hotUtilityClose==='function')hotUtilityClose(true);
109
  if(typeof closeBaseFinder==='function')closeBaseFinder(false);
110
  for(const id of ['tacRow','grpRow','hotSlots']){const row=$(id);if(row)row.style.display='none';}
111
  }
 
2837
  mfBindNativePress($('spdBtn'),()=>{
2838
  gameSpeed=gameSpeed===1?1.5:gameSpeed===1.5?2:1;
2839
  $('spdBtn').textContent=gameSpeed+'×';
2840
+ $('spdBtn').setAttribute('aria-label','Game speed '+gameSpeed+' times. Activate to change speed');
2841
  toast('⏩ Game speed '+gameSpeed+'×'); sfx('ui');
2842
  });
2843
  /* The header is a tap target for Profile, but it now CONTAINS buttons — the
src/styles/ui.css CHANGED
@@ -388,6 +388,10 @@ body.mfMenuOpen #hotUtilityPanel,body.menuMode #hotUtilityPanel{display:none!imp
388
  white-space:nowrap;overflow:hidden;
389
  background:rgba(4,10,18,.4) padding-box,var(--steelB) border-box;
390
  box-shadow:inset 0 1px 0 rgba(255,255,255,.06)}
 
 
 
 
391
  #goalBar .hudIntelChip{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:7px;
392
  border:1px solid rgba(120,170,205,.22);background:rgba(6,14,24,.42);letter-spacing:.05em}
393
  #goalBar .hudIntelChip.contact{color:#8fffc0;border-color:rgba(80,255,180,.28);
@@ -500,7 +504,8 @@ body.mfMenuOpen #hotUtilityPanel,body.menuMode #hotUtilityPanel{display:none!imp
500
  .baseFindTabs{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:5px;margin-top:8px}
501
  .baseFindTabs button{min-width:0;min-height:44px;padding:5px 3px;display:flex;align-items:center;justify-content:center;gap:4px;color:#afc9da;
502
  border:1px solid rgba(110,161,190,.28);border-radius:7px;background:rgba(4,13,22,.72);font:800 8px/1 var(--fT);letter-spacing:.035em;overflow:hidden}
503
- .baseFindTabs button span{font-size:12px;line-height:1}.baseFindTabs button.on{color:#fff1a5;border-color:#ffe17c;background:rgba(91,67,12,.72);box-shadow:0 0 10px rgba(255,214,80,.2)}
 
504
  .baseFindGrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin-top:8px;max-height:min(46dvh,344px);overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin}
505
  .baseFindCard{min-width:0;min-height:62px;padding:6px 7px;display:grid;grid-template-columns:40px minmax(0,1fr) auto;align-items:center;gap:7px;text-align:left;
506
  color:#dceeff;border:1px solid rgba(111,166,201,.28);border-radius:9px;background:linear-gradient(145deg,rgba(20,39,57,.96),rgba(7,18,29,.98));box-shadow:0 2px 8px rgba(0,0,0,.3)}
@@ -535,7 +540,19 @@ body.mfMenuOpen #hotUtilityPanel,body.menuMode #hotUtilityPanel{display:none!imp
535
  filter:drop-shadow(0 1px 2px rgba(0,0,0,.55))}
536
  .em[data-icon]{display:inline-block;width:24px;height:24px;background-repeat:no-repeat}
537
  .camBtn .em[data-icon]{width:20px;height:20px}
538
- html.cmdIcons .em[data-icon]{
 
 
 
 
 
 
 
 
 
 
 
 
539
  color:transparent;font-size:0;
540
  background-image:var(--cmdSheet);background-size:800% 800%;
541
  }
@@ -571,6 +588,12 @@ html.cmdIcons .em[data-icon="victory"] {background-position:57.1428% 42.8571%}
571
  html.cmdIcons .em[data-icon="defeat"] {background-position:71.4285% 42.8571%}
572
  html.cmdIcons .em[data-icon="pause"] {background-position:85.7142% 42.8571%}
573
  html.cmdIcons .em[data-icon="options"] {background-position:100% 42.8571%}
 
 
 
 
 
 
574
  .cbtn.on{background:linear-gradient(180deg,rgba(46,110,152,.96),rgba(20,52,80,.97)) padding-box,var(--goldB) border-box;
575
  box-shadow:0 0 12px rgba(255,210,87,.45),inset 0 1px 0 rgba(255,255,255,.2)}
576
  .cbtn:active{transform:scale(.94)}
@@ -611,6 +634,39 @@ html.cmdIcons .em[data-icon="options"] {background-position:100% 42.8571%}
611
  background:linear-gradient(180deg,rgba(15,30,46,.94),rgba(7,16,27,.97));
612
  clip-path:polygon(6px 0,100% 0,100% calc(100% - 6px),calc(100% - 6px) 100%,0 100%,0 6px);
613
  pointer-events:none;user-select:none}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
614
 
615
  /* ---------- SELECTION INFO ---------- */
616
  #selInfo{position:absolute;left:50%;transform:translateX(-50%);bottom:calc(var(--sab) + 6px);z-index:9;
@@ -765,7 +821,7 @@ html.cmdIcons .em[data-icon="options"] {background-position:100% 42.8571%}
765
  #placeUI{position:absolute;left:50%;transform:translateX(-50%);bottom:calc(var(--sab) + 68px);z-index:12;display:none;gap:12px}
766
  #placeUI .cbtn{width:62px;height:62px;font-size:26px;position:relative}
767
  #placeRotL,#placeRotR{width:52px;height:52px;font-size:22px;align-self:center;color:#8be8ff}
768
- #placeRotDeg{position:absolute;left:0;right:0;bottom:3px;font-size:9px;font-family:var(--fU);letter-spacing:.04em;opacity:.75}
769
  #placeOk{background:linear-gradient(180deg,rgba(20,64,40,.96),rgba(8,30,18,.97)) padding-box,linear-gradient(160deg,#b6ffd4,#2bd672 40%,#0d5a2e 70%,#6dffa8) border-box!important;color:var(--green)}
770
  #placeNo{background:linear-gradient(180deg,rgba(66,22,14,.96),rgba(32,10,6,.97)) padding-box,var(--redB) border-box!important;color:var(--red)}
771
 
@@ -2365,7 +2421,11 @@ body.godMode #godBadge{display:flex}
2365
  .baseFinder{left:calc(var(--sal) + 7px);right:calc(var(--sar) + 7px);transform:none;bottom:max(calc(var(--sab) + 202px),208px);
2366
  width:auto;max-height:calc(100dvh - var(--sat) - var(--sab) - 224px)}
2367
  .baseFindGrid{grid-template-columns:1fr;max-height:min(32dvh,276px)}
2368
- .baseFindTabs button{font-size:7px;letter-spacing:0}.baseFindTabs button span{font-size:10px}
 
 
 
 
2369
  /* One compact status chip replaces the old full-width icon strip. */
2370
  #wcBanner{top:calc(var(--sat) + var(--hudTopStack));font-size:9px;padding:2px 7px;gap:4px}
2371
  #wcBanner .wcBIcon{display:none}
@@ -2562,7 +2622,6 @@ button:focus-visible,[role="button"]:focus-visible,input:focus-visible,textarea:
2562
  wider is its longer label, so the type is sized to stay inside that
2563
  min-width rather than push past it. The two must report identical
2564
  offsetWidth at 412 px and at 360 px; that is measured, not assumed. */
2565
- }
2566
 
2567
 
2568
  /* ── Career ladder (Profile ▸ CAREER) ──────────────────────────────────────
@@ -2980,6 +3039,12 @@ body.menuMode #inboxHudBtn{display:none}
2980
  .mfLauncherFoot #updBack{width:50px;padding:0;font-size:0}.mfLauncherFoot #updBack::before{content:'◀';font-size:14px}
2981
  body.mfLauncherGate .mfLauncherFoot #updBack{display:none}
2982
  body.mfLauncherGate .mfLauncherFoot{grid-template-columns:minmax(0,.78fr) minmax(0,1.45fr)}
 
 
 
 
 
 
2983
 
2984
  @keyframes mfLaunchSweep{0%,18%{transform:translateX(-125%) skewX(-18deg);opacity:0}40%{opacity:.58}72%,100%{transform:translateX(420%) skewX(-18deg);opacity:0}}
2985
  @keyframes mfLaunchProgress{to{background-position:22px 0}}
@@ -3334,8 +3399,9 @@ body.mfLauncherGate .mfLauncherFoot{grid-template-columns:minmax(0,.78fr) minmax
3334
  #cmdrTx::before{content:'';position:absolute;inset:0;z-index:2;pointer-events:none;opacity:.34;
3335
  background:repeating-linear-gradient(180deg,transparent 0 3px,rgba(105,226,255,.16) 4px,transparent 5px),linear-gradient(90deg,rgba(0,208,255,.13),transparent 36%,rgba(255,191,70,.08));
3336
  mix-blend-mode:screen;animation:mfReceiverScan .8s steps(6,end) infinite}
3337
- #cmdrTx::after{content:'UGA COMMS';position:absolute;right:5px;top:4px;z-index:4;color:#8eeaff;
3338
  font:900 6px/1 var(--fT);letter-spacing:.14em;text-shadow:0 0 6px #16bce8}
 
3339
  #cmdrTx[data-state="enter"],#cmdrTx[data-state="hold"]{opacity:1}
3340
  #cmdrTx[data-state="exit"]{opacity:0;transition-duration:.22s}
3341
  #cmdrTx[data-state="idle"]{display:none}
@@ -3552,7 +3618,7 @@ body:has(#bldMenu2[style*="display: block"]) #mfNoticeDock{display:none!importan
3552
  #mfNoticeHistory nav{flex:0 0 auto;display:flex;gap:4px;padding:5px 6px;overflow-x:auto;scrollbar-width:none;touch-action:pan-x}
3553
  #mfNoticeHistory nav::-webkit-scrollbar{display:none}
3554
  #mfNoticeHistory nav button{flex:1 0 auto;min-width:54px;min-height:44px;padding:5px 8px;border-radius:8px;font-size:7px;letter-spacing:.05em;touch-action:manipulation}
3555
- #mfNoticeHistory .mfNoticeList{min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:0 6px 7px;scrollbar-width:thin}
3556
  #mfNoticeHistory .mfNoticeItem{display:grid;grid-template-columns:38px 48px minmax(0,1fr) auto;align-items:start;gap:5px;
3557
  min-height:34px;box-sizing:border-box;padding:6px 5px;border-bottom:1px solid rgba(110,175,210,.13);font-size:10px;line-height:1.25}
3558
  #mfNoticeHistory .mfNoticeItem time{color:#5f8499;font:800 8px/1.25 var(--fT);letter-spacing:.03em}
@@ -3574,3 +3640,881 @@ body:has(#bldMenu2[style*="display: block"]) #mfNoticeDock{display:none!importan
3574
  #mfNoticeHistory nav button{min-height:44px}
3575
  }
3576
  html[data-mf-text-scale="200"] .menuStrip{grid-template-columns:repeat(2,1fr)}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  white-space:nowrap;overflow:hidden;
389
  background:rgba(4,10,18,.4) padding-box,var(--steelB) border-box;
390
  box-shadow:inset 0 1px 0 rgba(255,255,255,.06)}
391
+ #goalDetailBtn{appearance:none;-webkit-appearance:none;display:flex;align-items:center;justify-content:center;gap:6px;
392
+ width:100%;min-width:0;min-height:24px;margin:0;padding:0;border:0;background:none;color:inherit;
393
+ font:inherit;letter-spacing:inherit;white-space:inherit;overflow:hidden;cursor:pointer}
394
+ #goalDetailBtn:focus-visible{outline:2px solid #77ddff;outline-offset:1px;border-radius:6px}
395
  #goalBar .hudIntelChip{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:7px;
396
  border:1px solid rgba(120,170,205,.22);background:rgba(6,14,24,.42);letter-spacing:.05em}
397
  #goalBar .hudIntelChip.contact{color:#8fffc0;border-color:rgba(80,255,180,.28);
 
504
  .baseFindTabs{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:5px;margin-top:8px}
505
  .baseFindTabs button{min-width:0;min-height:44px;padding:5px 3px;display:flex;align-items:center;justify-content:center;gap:4px;color:#afc9da;
506
  border:1px solid rgba(110,161,190,.28);border-radius:7px;background:rgba(4,13,22,.72);font:800 8px/1 var(--fT);letter-spacing:.035em;overflow:hidden}
507
+ .baseFindTabs button .baseFindTabIcon{font-size:12px;line-height:1}.baseFindTabs button .baseFindTabLabel{min-width:0;font:inherit;line-height:1;white-space:nowrap}
508
+ .baseFindTabs button.on{color:#fff1a5;border-color:#ffe17c;background:rgba(91,67,12,.72);box-shadow:0 0 10px rgba(255,214,80,.2)}
509
  .baseFindGrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin-top:8px;max-height:min(46dvh,344px);overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin}
510
  .baseFindCard{min-width:0;min-height:62px;padding:6px 7px;display:grid;grid-template-columns:40px minmax(0,1fr) auto;align-items:center;gap:7px;text-align:left;
511
  color:#dceeff;border:1px solid rgba(111,166,201,.28);border-radius:9px;background:linear-gradient(145deg,rgba(20,39,57,.96),rgba(7,18,29,.98));box-shadow:0 2px 8px rgba(0,0,0,.3)}
 
540
  filter:drop-shadow(0 1px 2px rgba(0,0,0,.55))}
541
  .em[data-icon]{display:inline-block;width:24px;height:24px;background-repeat:no-repeat}
542
  .camBtn .em[data-icon]{width:20px;height:20px}
543
+ /* Cinematic-only glyphs that have no honest shipped atlas cell use inline
544
+ monochrome vectors. Explicit SVG sizing prevents the browser's 300×150
545
+ replaced-element default from escaping a 44px touch target. */
546
+ .mfCinematicVectorIcon{display:inline-grid!important;place-items:center;width:24px;height:24px;flex:0 0 24px;line-height:0;background:none!important}
547
+ .mfCinematicVectorIcon svg{display:block;width:100%;height:100%;overflow:visible;pointer-events:none}
548
+ .tabBtn .tEm.mfCinematicVectorIcon{width:18px;height:18px;flex-basis:18px}
549
+ body.mf-cinematic-hud #inboxHudBtn>.mfCinematicVectorIcon,
550
+ body.mf-cinematic-hud #menuBtn>.mfCinematicVectorIcon{width:22px;height:22px;flex-basis:22px}
551
+ body.mf-cinematic-hud #heroRankEm.mfCinematicVectorIcon{width:16px;height:16px;min-width:16px;flex-basis:16px;padding:0;color:var(--gold)}
552
+ body.mf-cinematic-hud #upBtn,body.mf-cinematic-hud #repeatBtn,body.mf-cinematic-hud #rallyBtn{
553
+ display:flex;align-items:center;justify-content:center;gap:6px
554
+ }
555
+ html.cmdIcons .em[data-icon][data-icon-ready="true"]{
556
  color:transparent;font-size:0;
557
  background-image:var(--cmdSheet);background-size:800% 800%;
558
  }
 
588
  html.cmdIcons .em[data-icon="defeat"] {background-position:71.4285% 42.8571%}
589
  html.cmdIcons .em[data-icon="pause"] {background-position:85.7142% 42.8571%}
590
  html.cmdIcons .em[data-icon="options"] {background-position:100% 42.8571%}
591
+ html.cmdIcons body.mf-cinematic-hud [data-mf-hud-role="service-controls"] button[data-icon][data-icon-ready="true"]::before{
592
+ content:'';display:inline-block;position:static;width:24px;height:24px;flex:0 0 24px;
593
+ background-image:var(--cmdSheet);background-size:800% 800%;background-repeat:no-repeat
594
+ }
595
+ html.cmdIcons body.mf-cinematic-hud [data-mf-hud-role="service-controls"] button[data-icon="repair"]::before{background-position:57.1428% 14.2857%}
596
+ html.cmdIcons body.mf-cinematic-hud [data-mf-hud-role="service-controls"] button[data-icon="delete"]::before{background-position:100% 14.2857%}
597
  .cbtn.on{background:linear-gradient(180deg,rgba(46,110,152,.96),rgba(20,52,80,.97)) padding-box,var(--goldB) border-box;
598
  box-shadow:0 0 12px rgba(255,210,87,.45),inset 0 1px 0 rgba(255,255,255,.2)}
599
  .cbtn:active{transform:scale(.94)}
 
634
  background:linear-gradient(180deg,rgba(15,30,46,.94),rgba(7,16,27,.97));
635
  clip-path:polygon(6px 0,100% 0,100% calc(100% - 6px),calc(100% - 6px) 100%,0 100%,0 6px);
636
  pointer-events:none;user-select:none}
637
+ /* Unit stacks are a takeover inside the existing PLATOONS row, not another
638
+ battlefield drawer. P1-P4 keep their match-memory authority while the
639
+ remaining width becomes a finger-stable, horizontally panning type rail. */
640
+ #grpRow.mfUnitStackReady>.grpBtn{flex:0 0 44px}
641
+ #grpRow.mfUnitStackReady>#modeBtn{flex:0 0 54px}
642
+ #mfUnitStackRail{display:none;flex:1 1 112px;min-width:96px;height:48px;align-items:stretch;gap:4px;
643
+ overflow-x:auto;overflow-y:hidden;scroll-snap-type:x proximity;scroll-padding-inline:1px;
644
+ scrollbar-width:none;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch;touch-action:pan-x}
645
+ #mfUnitStackRail::-webkit-scrollbar{display:none}
646
+ .mfUnitStackCard{position:relative;flex:0 0 82px;width:82px;min-width:82px;height:48px;min-height:44px;
647
+ display:grid;grid-template-columns:34px minmax(0,1fr);align-items:center;gap:3px;padding:3px;
648
+ overflow:hidden;scroll-snap-align:start;touch-action:pan-x;pointer-events:auto;color:#dff7ff;
649
+ border:1px solid rgba(91,174,218,.34);border-radius:8px;
650
+ background:linear-gradient(180deg,rgba(17,38,56,.94),rgba(5,17,28,.98));
651
+ box-shadow:inset 0 1px rgba(255,255,255,.07);font-family:var(--fT);text-align:left}
652
+ .mfUnitStackCard:focus-visible{outline:2px solid #8be8ff;outline-offset:-2px}
653
+ .mfUnitStackCard.selected{border-color:#4ed5ff;background:linear-gradient(180deg,rgba(20,86,124,.98),rgba(5,33,54,.99));
654
+ box-shadow:0 0 9px rgba(61,201,248,.24),inset 0 1px rgba(255,255,255,.12)}
655
+ .mfUnitStackCard.partial{border-color:rgba(255,210,87,.72)}
656
+ .mfUnitStackIcon{width:34px;height:34px;display:grid;place-items:center;overflow:hidden;pointer-events:none}
657
+ .mfUnitStackIcon>*{max-width:34px;max-height:34px}
658
+ .mfUnitStackFallback{font-size:19px;line-height:1;color:#83dfff}
659
+ .mfUnitStackCopy{min-width:0;height:100%;display:flex;flex-direction:column;justify-content:center;gap:2px;pointer-events:none}
660
+ .mfUnitStackName{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
661
+ color:#e5f8ff;font:900 8px/1.05 var(--fT);letter-spacing:.025em;text-transform:uppercase}
662
+ .mfUnitStackMeta{display:flex;justify-content:space-between;align-items:center;gap:2px;color:#88bad0;
663
+ font:800 7px/1 var(--fT);font-variant-numeric:tabular-nums}
664
+ .mfUnitStackCount{color:#8be8ff;font:900 9px/1 var(--fT)}
665
+ .mfUnitStackReady{font:800 7px/1 var(--fT);color:#8bb0c2}
666
+ .mfUnitStackCard.ready .mfUnitStackReady{color:#72e0a1}
667
+ .mfUnitStackHealth{display:block;width:100%;height:3px;overflow:hidden;border-radius:2px;background:rgba(0,0,0,.66)}
668
+ .mfUnitStackHealthFill{display:block;height:100%;min-width:1px;background:linear-gradient(90deg,#40d77c,#b9ef70);
669
+ box-shadow:0 0 4px rgba(88,226,134,.35)}
670
 
671
  /* ---------- SELECTION INFO ---------- */
672
  #selInfo{position:absolute;left:50%;transform:translateX(-50%);bottom:calc(var(--sab) + 6px);z-index:9;
 
821
  #placeUI{position:absolute;left:50%;transform:translateX(-50%);bottom:calc(var(--sab) + 68px);z-index:12;display:none;gap:12px}
822
  #placeUI .cbtn{width:62px;height:62px;font-size:26px;position:relative}
823
  #placeRotL,#placeRotR{width:52px;height:52px;font-size:22px;align-self:center;color:#8be8ff}
824
+ #placeRotDeg{position:absolute;left:0;right:0;bottom:3px;font-size:max(9px,var(--mfHudTextMeta,8px));font-family:var(--fU);letter-spacing:.04em;opacity:.75}
825
  #placeOk{background:linear-gradient(180deg,rgba(20,64,40,.96),rgba(8,30,18,.97)) padding-box,linear-gradient(160deg,#b6ffd4,#2bd672 40%,#0d5a2e 70%,#6dffa8) border-box!important;color:var(--green)}
826
  #placeNo{background:linear-gradient(180deg,rgba(66,22,14,.96),rgba(32,10,6,.97)) padding-box,var(--redB) border-box!important;color:var(--red)}
827
 
 
2421
  .baseFinder{left:calc(var(--sal) + 7px);right:calc(var(--sar) + 7px);transform:none;bottom:max(calc(var(--sab) + 202px),208px);
2422
  width:auto;max-height:calc(100dvh - var(--sat) - var(--sab) - 224px)}
2423
  .baseFindGrid{grid-template-columns:1fr;max-height:min(32dvh,276px)}
2424
+ /* Five filters remain simultaneously discoverable on 344px phones. Stack a
2425
+ compact visual label under its icon; the button keeps the full category
2426
+ in aria-label/title for assistive technology and long-press inspection. */
2427
+ .baseFindTabs button{padding:3px 1px;flex-direction:column;gap:2px;font-size:7px;letter-spacing:0}
2428
+ .baseFindTabs button .baseFindTabIcon{font-size:10px}.baseFindTabs button .baseFindTabLabel{font-size:7px}
2429
  /* One compact status chip replaces the old full-width icon strip. */
2430
  #wcBanner{top:calc(var(--sat) + var(--hudTopStack));font-size:9px;padding:2px 7px;gap:4px}
2431
  #wcBanner .wcBIcon{display:none}
 
2622
  wider is its longer label, so the type is sized to stay inside that
2623
  min-width rather than push past it. The two must report identical
2624
  offsetWidth at 412 px and at 360 px; that is measured, not assumed. */
 
2625
 
2626
 
2627
  /* ── Career ladder (Profile ▸ CAREER) ──────────────────────────────────────
 
3039
  .mfLauncherFoot #updBack{width:50px;padding:0;font-size:0}.mfLauncherFoot #updBack::before{content:'◀';font-size:14px}
3040
  body.mfLauncherGate .mfLauncherFoot #updBack{display:none}
3041
  body.mfLauncherGate .mfLauncherFoot{grid-template-columns:minmax(0,.78fr) minmax(0,1.45fr)}
3042
+ /* updatePrimary() reveals the secondary route with an inline display value.
3043
+ Explicitly constrain both grid items so the legacy .mbtn minimum cannot
3044
+ overflow its column and let the disabled online action steal Offline taps. */
3045
+ .mfLauncherFoot .mfLauncherOfflineAction,.mfLauncherFoot .mfLauncherPlay{
3046
+ min-width:0;width:100%;max-width:100%;justify-self:stretch;overflow:hidden
3047
+ }
3048
 
3049
  @keyframes mfLaunchSweep{0%,18%{transform:translateX(-125%) skewX(-18deg);opacity:0}40%{opacity:.58}72%,100%{transform:translateX(420%) skewX(-18deg);opacity:0}}
3050
  @keyframes mfLaunchProgress{to{background-position:22px 0}}
 
3399
  #cmdrTx::before{content:'';position:absolute;inset:0;z-index:2;pointer-events:none;opacity:.34;
3400
  background:repeating-linear-gradient(180deg,transparent 0 3px,rgba(105,226,255,.16) 4px,transparent 5px),linear-gradient(90deg,rgba(0,208,255,.13),transparent 36%,rgba(255,191,70,.08));
3401
  mix-blend-mode:screen;animation:mfReceiverScan .8s steps(6,end) infinite}
3402
+ #cmdrTx::after{content:'COMMAND LINK';position:absolute;right:5px;top:4px;z-index:4;color:#8eeaff;
3403
  font:900 6px/1 var(--fT);letter-spacing:.14em;text-shadow:0 0 6px #16bce8}
3404
+ #cmdrTx[data-mf-link="uga-keel"]::after{content:'UGA // KEEL'}
3405
  #cmdrTx[data-state="enter"],#cmdrTx[data-state="hold"]{opacity:1}
3406
  #cmdrTx[data-state="exit"]{opacity:0;transition-duration:.22s}
3407
  #cmdrTx[data-state="idle"]{display:none}
 
3618
  #mfNoticeHistory nav{flex:0 0 auto;display:flex;gap:4px;padding:5px 6px;overflow-x:auto;scrollbar-width:none;touch-action:pan-x}
3619
  #mfNoticeHistory nav::-webkit-scrollbar{display:none}
3620
  #mfNoticeHistory nav button{flex:1 0 auto;min-width:54px;min-height:44px;padding:5px 8px;border-radius:8px;font-size:7px;letter-spacing:.05em;touch-action:manipulation}
3621
+ #mfNoticeHistory .mfNoticeList{min-height:0;flex:1 1 auto;overflow-y:auto;overscroll-behavior:contain;padding:0 6px 7px;scrollbar-width:thin}
3622
  #mfNoticeHistory .mfNoticeItem{display:grid;grid-template-columns:38px 48px minmax(0,1fr) auto;align-items:start;gap:5px;
3623
  min-height:34px;box-sizing:border-box;padding:6px 5px;border-bottom:1px solid rgba(110,175,210,.13);font-size:10px;line-height:1.25}
3624
  #mfNoticeHistory .mfNoticeItem time{color:#5f8499;font:800 8px/1.25 var(--fT);letter-spacing:.03em}
 
3640
  #mfNoticeHistory nav button{min-height:44px}
3641
  }
3642
  html[data-mf-text-scale="200"] .menuStrip{grid-template-columns:repeat(2,1fr)}
3643
+
3644
+ /* ===========================================================================
3645
+ CINEMATIC BATTLE HUD — late, opt-in takeover
3646
+ cinematic-hud.js adds body.mf-cinematic-hud and semantic role hooks, then
3647
+ reparents the authoritative controls without cloning their ids. Everything
3648
+ here is scoped to that class so an older OTA shell keeps the proven dock.
3649
+
3650
+ The material bitmap is deliberately only one translucent layer. If it is
3651
+ absent while an optional asset pack is repairing, the gradients underneath
3652
+ remain a complete high-contrast interface rather than a blank panel.
3653
+ ========================================================================== */
3654
+ body.mf-cinematic-hud{
3655
+ --mfHudGap:clamp(3px,.75vmin,7px);
3656
+ --mfHudEdge:clamp(6px,1.2vmin,12px);
3657
+ --mfHudTouch:clamp(44px,5.8vmin,54px);
3658
+ --mfHudTopProfile:clamp(50px,13.4vw,76px);
3659
+ --mfHudTopRow:var(--mfHudTouch);
3660
+ --mfHudIntel:clamp(28px,6.2vmin,34px);
3661
+ --mfHudTopClear:calc(var(--sat) + var(--mfHudTopRow) + var(--mfHudIntel) + var(--mfHudGap) * 3);
3662
+ --mfHudDockRows:calc(var(--mfHudTouch) * 2 + var(--mfHudGap) * 3);
3663
+ --mfHudDockClear:calc(var(--sab) + var(--mfHudDockRows) + var(--mfHudEdge));
3664
+ --mfHudMap:clamp(74px,23vw,112px);
3665
+ --mfHudContextW:min(66vw,390px);
3666
+ --mfHudTextGoal:max(9px,.5625rem);
3667
+ --mfHudTextCard:max(8px,.5rem);
3668
+ --mfHudTextFeed:max(10px,.625rem);
3669
+ --mfHudTextAction:clamp(10px,.625rem,18px);
3670
+ --mfHudTextDock:clamp(7px,.4375rem,11px);
3671
+ --mfHudTextMeta:clamp(8px,.5rem,14px);
3672
+ --mfHudPanelFallback:linear-gradient(155deg,rgba(14,31,46,.985),rgba(3,10,18,.99));
3673
+ --mfHudPanelMaterial:
3674
+ linear-gradient(155deg,rgba(11,27,41,.92),rgba(3,10,18,.965)),
3675
+ url('../../assets/textures/ui/mf-hud-panel-material-v1.webp') center/360px 360px repeat,
3676
+ var(--mfHudPanelFallback);
3677
+ /* Large chassis deliberately omit the opaque bitmap layer. Their bounded
3678
+ alpha lets the battle remain legible underneath without the GPU cost or
3679
+ fixed-descendant side effects of backdrop-filter. Cards and controls keep
3680
+ their denser fills below, so copy never depends on the map for contrast. */
3681
+ --mfHudSurfaceTranslucent:linear-gradient(155deg,rgba(10,27,42,.78),rgba(3,10,18,.89));
3682
+ --mfHudRailTranslucent:linear-gradient(180deg,rgba(7,20,31,.61),rgba(2,8,15,.84));
3683
+ --mfHudLine:rgba(112,204,241,.48);
3684
+ --mfHudLineSoft:rgba(112,204,241,.2);
3685
+ --mfHudShadow:0 10px 28px rgba(0,0,0,.66),inset 0 1px 0 rgba(255,255,255,.08);
3686
+ }
3687
+
3688
+ /* The wrapper is semantic, not a new containing block: fixed children retain
3689
+ viewport/safe-area geometry in source, PWA and Capacitor shells. */
3690
+ body.mf-cinematic-hud #mfCinematicTopRail[data-mf-hud-role="top-rail"],
3691
+ body.mf-cinematic-hud #mfCinematicContext[data-mf-hud-role="context"],
3692
+ body.mf-cinematic-hud #mfCinematicGroupPalette[data-mf-hud-role="group-palette"]{display:contents}
3693
+
3694
+ /* Commander identity + resources form one compact rail. The portrait is a
3695
+ distinct navigation target; resource cells and pause controls never sit on
3696
+ top of it, even at 344 CSS px with safe-area pressure. */
3697
+ body.mf-cinematic-hud #heroBar{
3698
+ position:fixed;z-index:21;top:calc(var(--sat) + var(--mfHudEdge));left:calc(var(--sal) + var(--mfHudEdge));
3699
+ width:var(--mfHudTopProfile);height:calc(var(--mfHudTopRow) + var(--mfHudIntel) + var(--mfHudGap));min-height:0;
3700
+ padding:3px;display:flex;align-items:flex-start;justify-content:center;overflow:hidden;border-radius:9px 0 0 9px;
3701
+ border:1px solid transparent;border-right:0;background:var(--mfHudPanelMaterial) padding-box,var(--steelB) border-box;
3702
+ box-shadow:var(--mfHudShadow);clip-path:polygon(7px 0,100% 0,100% 100%,0 100%,0 7px)
3703
+ }
3704
+ body.mf-cinematic-hud #heroPortrait{
3705
+ width:calc(var(--mfHudTopProfile) - 8px);height:calc(var(--mfHudTopRow) + 4px);flex-basis:auto;border-radius:7px
3706
+ }
3707
+ body.mf-cinematic-hud #heroRankEm{right:2px;bottom:2px}
3708
+ body.mf-cinematic-hud #heroBar .heroProfileBody{
3709
+ position:absolute;left:3px;right:3px;bottom:3px;height:calc(var(--mfHudIntel) - 2px);display:flex;
3710
+ align-items:center;justify-content:center;padding:0 2px;border-top:1px solid var(--mfHudLineSoft);
3711
+ background:linear-gradient(180deg,rgba(4,12,20,.62),rgba(3,9,16,.96))
3712
+ }
3713
+ body.mf-cinematic-hud #heroBar .heroProfileHead{justify-content:center}
3714
+ body.mf-cinematic-hud #heroNameTxt,body.mf-cinematic-hud #heroCallsignTxt,
3715
+ body.mf-cinematic-hud #heroBar .heroVital{display:none}
3716
+ body.mf-cinematic-hud #heroLvlTxt{color:#dff7ff;font:900 9px/1 var(--fT);letter-spacing:.08em}
3717
+
3718
+ body.mf-cinematic-hud #topbar{
3719
+ position:fixed;z-index:20;top:calc(var(--sat) + var(--mfHudEdge));
3720
+ left:calc(var(--sal) + var(--mfHudTopProfile) + var(--mfHudEdge) - 1px);right:calc(var(--sar) + var(--mfHudEdge));
3721
+ display:grid;grid-template-columns:repeat(3,minmax(0,1fr)) repeat(3,var(--mfHudTouch));
3722
+ grid-auto-flow:row;align-items:center;gap:var(--mfHudGap);padding:0;pointer-events:none;
3723
+ background:none;border:0;box-shadow:none;backdrop-filter:none;overflow:visible;isolation:isolate
3724
+ }
3725
+ /* One low-cost bracket chassis joins the resource/status rail. The pseudo
3726
+ frame paints first and never intercepts a tap; individual controls retain
3727
+ their complete 44px hit boxes and opaque-enough state fills. */
3728
+ body.mf-cinematic-hud #topbar::before,
3729
+ body.mf-cinematic-hud #cmdbar::before{
3730
+ content:'';position:absolute;inset:-1px;pointer-events:none;border:1px solid var(--mfHudLineSoft);
3731
+ background:var(--mfHudRailTranslucent);box-shadow:inset 0 1px rgba(255,255,255,.055);
3732
+ clip-path:polygon(9px 0,calc(100% - 9px) 0,100% 9px,100% calc(100% - 9px),calc(100% - 9px) 100%,9px 100%,0 calc(100% - 9px),0 9px)
3733
+ }
3734
+ body.mf-cinematic-hud #topbar>.res{
3735
+ min-width:0;width:auto;height:var(--mfHudTopRow);min-height:44px;padding:2px 4px;gap:3px;overflow:hidden;
3736
+ border-radius:8px;border-color:rgba(112,204,241,.16);background:linear-gradient(180deg,rgba(16,42,60,.48),rgba(4,15,25,.64));
3737
+ box-shadow:inset 0 1px rgba(255,255,255,.065);clip-path:none
3738
+ }
3739
+ body.mf-cinematic-hud #topbar>.res .ic{width:clamp(15px,4.5vmin,20px);height:clamp(15px,4.5vmin,20px)}
3740
+ body.mf-cinematic-hud #topbar>.res b{min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;
3741
+ font-size:max(clamp(9px,2.85vw,13px),var(--mfHudTextMeta));font-variant-numeric:tabular-nums;white-space:nowrap}
3742
+ body.mf-cinematic-hud #unitV{letter-spacing:-.03em}
3743
+ body.mf-cinematic-hud #topbar>.res .rate{min-width:0;font-size:clamp(7px,2.1vw,10px);white-space:nowrap}
3744
+ body.mf-cinematic-hud #inboxHudBtn,body.mf-cinematic-hud #spdBtn,body.mf-cinematic-hud #menuBtn{
3745
+ width:var(--mfHudTouch);height:var(--mfHudTouch);min-width:44px;min-height:44px;margin:0;border-radius:9px;
3746
+ pointer-events:auto;background:var(--mfHudPanelMaterial) padding-box,var(--steelB) border-box;
3747
+ box-shadow:0 4px 13px rgba(0,0,0,.55),inset 0 1px rgba(255,255,255,.1)
3748
+ }
3749
+ body.mf-cinematic-hud #inboxHudBtn{position:relative;top:auto;right:auto;font-size:18px}
3750
+ body.mf-cinematic-hud #spdBtn{font-size:12px}
3751
+ body.mf-cinematic-hud #menuBtn{font-size:18px}
3752
+ body.mf-cinematic-hud #godBadge,body.mf-cinematic-hud #fps{display:none!important}
3753
+ body.mf-cinematic-hud #topbar #goalBar{
3754
+ grid-column:1/-1;width:100%;min-width:0;min-height:var(--mfHudIntel);height:var(--mfHudIntel);max-height:var(--mfHudIntel);
3755
+ margin:0;padding:1px 8px;border-radius:8px;gap:5px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;
3756
+ background:linear-gradient(90deg,rgba(5,20,29,.94),rgba(8,25,37,.88),rgba(5,16,26,.94)) padding-box,var(--steelB) border-box;
3757
+ box-shadow:0 4px 13px rgba(0,0,0,.52),inset 0 1px rgba(255,255,255,.07)
3758
+ }
3759
+ body.mf-cinematic-hud #goalBar .hudIntelChip{min-width:0;padding:2px 5px;overflow:hidden;text-overflow:ellipsis}
3760
+ body.mf-cinematic-hud #goalBar .mfCinematicGoalIcon{width:16px;height:16px;flex:0 0 16px}
3761
+
3762
+ /* Alerts occupy the short strip below the rail and never become a second
3763
+ full-width header. Urgent attack controls retain the authored 44px target. */
3764
+ body.mf-cinematic-hud #wcRow{top:var(--mfHudTopClear);left:calc(var(--sal) + var(--mfHudEdge));right:auto;max-width:44vw}
3765
+ body.mf-cinematic-hud #infMeter,body.mf-cinematic-hud #hazChip{
3766
+ top:var(--mfHudTopClear);right:calc(var(--sar) + var(--mfHudEdge));left:auto;max-width:42vw
3767
+ }
3768
+ body.mf-cinematic-hud #atkAlert,body.mf-cinematic-hud #waveAlert{
3769
+ top:calc(var(--mfHudTopClear) + 36px);max-width:min(70vw,430px);min-height:44px
3770
+ }
3771
+
3772
+ /* The lower command dock is a shallow two-row control palette. Active rows are
3773
+ ordered above navigation tabs, while the permanent five high-frequency
3774
+ actions remain the final row. No opaque full-screen-width plate is painted. */
3775
+ body.mf-cinematic-hud #cmdbar{
3776
+ position:fixed;z-index:20;left:calc(var(--sal) + var(--mfHudEdge));right:calc(var(--sar) + var(--mfHudEdge));
3777
+ bottom:calc(var(--sab) + var(--mfHudEdge));width:auto;max-width:calc(100vw - var(--sal) - var(--sar) - var(--mfHudEdge) * 2);
3778
+ min-height:0;box-sizing:border-box;display:flex;align-items:stretch;gap:var(--mfHudGap);
3779
+ padding:2px;border:0;border-radius:0;background:transparent;isolation:isolate;
3780
+ /* A backdrop filter establishes a containing block for fixed descendants.
3781
+ #minimapWrap lives inside this authoritative dock, so blur made its
3782
+ viewport coordinates relative to the right-hand landscape dock. */
3783
+ box-shadow:none;
3784
+ backdrop-filter:none;-webkit-backdrop-filter:none
3785
+ }
3786
+ body.mf-cinematic-hud #cmdbar::before{
3787
+ inset:0;border:0;background:
3788
+ linear-gradient(90deg,var(--mfHudLine),transparent 18%,transparent 82%,var(--mfHudLine)) 0 0/100% 1px no-repeat,
3789
+ linear-gradient(90deg,var(--mfHudLineSoft),transparent 24%,transparent 76%,var(--mfHudLineSoft)) 0 100%/100% 1px no-repeat;
3790
+ box-shadow:none;clip-path:none
3791
+ }
3792
+ body.mf-cinematic-hud #cmdbar>*{width:100%;max-width:100%;min-width:0;box-sizing:border-box;grid-column:auto}
3793
+ body.mf-cinematic-hud #cmdbar #hudDeckTabs{order:80;display:flex;justify-content:flex-start;gap:0;padding:2px 4px;
3794
+ overflow-x:auto;scroll-padding-inline:2px;scrollbar-width:none}
3795
+ body.mf-cinematic-hud #cmdbar #primaryRow{order:90;display:flex;gap:0;padding:2px 4px}
3796
+ body.mf-cinematic-hud #cmdbar #camRow,body.mf-cinematic-hud #cmdbar #tacRow,
3797
+ body.mf-cinematic-hud #cmdbar #grpRow,body.mf-cinematic-hud #cmdbar #hotSlots{order:70}
3798
+ body.mf-cinematic-hud #cmdbar .btnrow,
3799
+ body.mf-cinematic-hud #cmdbar #hudDeckTabs{
3800
+ width:100%;max-width:100%;min-width:0;box-sizing:border-box;justify-content:center;
3801
+ border-top:1px solid rgba(112,204,241,.22);border-bottom:1px solid rgba(112,204,241,.13);
3802
+ background:linear-gradient(90deg,rgba(4,13,22,.18),rgba(5,17,28,.72) 8%,rgba(5,17,28,.72) 92%,rgba(4,13,22,.18));
3803
+ clip-path:polygon(7px 0,calc(100% - 7px) 0,100% 7px,100% calc(100% - 7px),calc(100% - 7px) 100%,7px 100%,0 calc(100% - 7px),0 7px)
3804
+ }
3805
+ body.mf-cinematic-hud #cmdbar .btnrow{gap:0;padding:2px 4px;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}
3806
+ body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn,
3807
+ body.mf-cinematic-hud #cmdbar .cbtn{
3808
+ flex:1 1 0;width:auto;min-width:44px;height:var(--mfHudTouch);min-height:44px;padding:2px 3px;border-radius:0;
3809
+ border:0;border-left:1px solid rgba(113,169,202,.18);background:transparent;
3810
+ box-shadow:none;clip-path:none;font-size:8px;letter-spacing:.035em;overflow:hidden
3811
+ }
3812
+ body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn:first-child,
3813
+ body.mf-cinematic-hud #cmdbar .btnrow>.cbtn:first-child{border-left:0}
3814
+ body.mf-cinematic-hud #cmdbar .cbtn .em{font-size:17px}
3815
+ body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn{gap:3px;white-space:nowrap;color:#7795a9}
3816
+ body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn span{font-size:13px}
3817
+ body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn.mfCinematicDeckActive,
3818
+ body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn[data-mf-active="true"],
3819
+ body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn.on{
3820
+ color:#eafdff;border-color:#32c9ff;background:linear-gradient(180deg,rgba(20,88,128,.98),rgba(5,35,58,.99));
3821
+ box-shadow:0 0 11px rgba(37,191,247,.28),inset 0 1px rgba(255,255,255,.13)
3822
+ }
3823
+ body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn:disabled{opacity:.35;filter:grayscale(1);box-shadow:none}
3824
+ body.mf-cinematic-hud #cmdbar #deployBtn{order:75;min-height:48px;margin:0}
3825
+ body.mf-cinematic-hud #heroRow[data-mf-hud-role="ability-authority"]{position:absolute!important;left:-9999px!important;top:-9999px!important}
3826
+
3827
+ /* Match-memory control groups read as saved command cards. They intentionally
3828
+ say PLATOONS, not account presets: these slots expire with the match. */
3829
+ body.mf-cinematic-hud #grpRow[data-mf-hud-role="match-command-palette"]{
3830
+ align-items:stretch;gap:var(--mfHudGap);overflow-x:auto;scrollbar-width:none;overscroll-behavior-x:contain
3831
+ }
3832
+ body.mf-cinematic-hud #grpRow .pltLabel{flex:0 0 auto;align-self:center;max-width:58px;padding:0 4px;
3833
+ color:#69bad8;font:900 7px/1.15 var(--fT);letter-spacing:.08em;white-space:normal}
3834
+ body.mf-cinematic-hud #grpRow .grpBtn{flex:1 0 44px;min-width:44px;height:var(--mfHudTouch);min-height:44px}
3835
+ body.mf-cinematic-hud #grpRow .grpBtn .pId{font-size:16px}
3836
+ body.mf-cinematic-hud #grpRow .grpBtn.saved{border-color:#4ed5ff;background:linear-gradient(180deg,rgba(22,76,105,.97),rgba(6,28,43,.99));
3837
+ box-shadow:0 0 9px rgba(61,201,248,.22)}
3838
+ body.mf-cinematic-hud #grpRow .grpBtn.active{border-color:#fff0a2;box-shadow:0 0 12px rgba(255,212,85,.32)}
3839
+ body.mf-cinematic-hud #grpRow.mfUnitStackReady{overflow:hidden}
3840
+ body.mf-cinematic-hud #grpRow.mfUnitStackReady .grpBtn{flex:0 0 44px}
3841
+ body.mf-cinematic-hud #grpRow.mfUnitStackReady #modeBtn{flex:0 0 44px}
3842
+ body.mf-cinematic-hud #mfUnitStackRail{flex:1 1 112px;min-width:96px;height:var(--mfHudTouch);gap:var(--mfHudGap)}
3843
+ body.mf-cinematic-hud .mfUnitStackCard{flex-basis:104px;width:104px;min-width:104px;height:var(--mfHudTouch);min-height:44px;border-radius:7px;
3844
+ display:block;padding:2px}
3845
+ /* The model occupies the lower-left while the authored name spans the whole
3846
+ card. A two-column grid made long real names clip beside their thumbnail. */
3847
+ body.mf-cinematic-hud .mfUnitStackCopy{display:contents}
3848
+ body.mf-cinematic-hud .mfUnitStackName{
3849
+ position:absolute;left:3px;right:3px;top:3px;overflow:hidden;text-align:left
3850
+ }
3851
+ body.mf-cinematic-hud .mfUnitStackIcon{
3852
+ position:absolute;left:3px;bottom:4px;width:27px;height:27px
3853
+ }
3854
+ body.mf-cinematic-hud .mfUnitStackIcon>*{max-width:27px;max-height:27px}
3855
+ body.mf-cinematic-hud .mfUnitStackMeta{
3856
+ position:absolute;left:33px;right:3px;top:17px
3857
+ }
3858
+ body.mf-cinematic-hud .mfUnitStackHealth{
3859
+ position:absolute;left:33px;right:3px;bottom:5px;width:auto
3860
+ }
3861
+
3862
+ /* The minimap stays a separate lower-left tactical instrument when a context
3863
+ surface opens. Commander/KEEL transmissions still replace its canvas using
3864
+ the established data-transmission state machine. */
3865
+ body.mf-cinematic-hud #minimapWrap[data-mf-hud-role="minimap-receiver"]{
3866
+ position:fixed;z-index:19;left:calc(var(--sal) + var(--mfHudEdge));right:auto;
3867
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudGap));width:calc(var(--mfHudMap) + 10px);height:calc(var(--mfHudMap) + 10px);
3868
+ margin:0;padding:4px;border-radius:10px;overflow:hidden;background:var(--mfHudPanelMaterial) padding-box,var(--steelB) border-box;
3869
+ box-shadow:var(--mfHudShadow);clip-path:polygon(7px 0,100% 0,100% calc(100% - 7px),calc(100% - 7px) 100%,0 100%,0 7px)
3870
+ }
3871
+ body.mf-cinematic-hud #minimapWrap[data-mf-hud-role="minimap-receiver"]::after{
3872
+ content:'';inset:3px;border-radius:7px;opacity:.65;background:
3873
+ linear-gradient(var(--cy),var(--cy)) 0 0/16px 2px,
3874
+ linear-gradient(var(--cy),var(--cy)) 0 0/2px 16px,
3875
+ linear-gradient(var(--cy),var(--cy)) 100% 100%/16px 2px,
3876
+ linear-gradient(var(--cy),var(--cy)) 100% 100%/2px 16px;background-repeat:no-repeat
3877
+ }
3878
+ body.mf-cinematic-hud #minimapWrap #minimap{width:var(--mfHudMap);height:var(--mfHudMap);border-radius:7px}
3879
+ body.mf-cinematic-hud.uiPrimaryOpen #minimapWrap[data-mf-hud-role="minimap-receiver"],
3880
+ body.mf-cinematic-hud.uiPrimaryOpen #heroBar{display:flex!important}
3881
+ body.mf-cinematic-hud.uiPrimaryOpen #minimapWrap[data-mf-hud-role="minimap-receiver"]{display:block!important}
3882
+ /* Reparenting #grpRow through a display:contents semantic wrapper changes its
3883
+ DOM ancestry even though it does not change layout. Preserve primary-panel
3884
+ focus explicitly; otherwise a previously open Platoons row remains live
3885
+ behind production/service controls. */
3886
+ body.mf-cinematic-hud.uiPrimaryOpen #mfCinematicGroupPalette #grpRow{display:none!important}
3887
+ /* Context, placement, feed and transmissions are higher-priority surfaces.
3888
+ A first-seen unit card must never survive behind them as a second panel. */
3889
+ body.mf-cinematic-hud:is(.mfCinematicContextOpen,.uiPanelOpen,.uiPlacing,.mfNoticeFeedOpen) #unitCard,
3890
+ body.mf-cinematic-hud:has(#minimapWrap[data-transmission="enter"],#minimapWrap[data-transmission="hold"],#minimapWrap[data-transmission="exit"]) #unitCard{display:none!important}
3891
+ body.mf-cinematic-hud:is(.mfCinematicContextOpen,.uiPrimaryOpen,.uiPlacing) #selInfo{display:none!important}
3892
+ /* PLATOONS already names the selected force and exposes its saved groups.
3893
+ Keeping the legacy selection card beside that third phone row repeated the
3894
+ same information and consumed the centre of 344–412px screens at 200% text. */
3895
+ body.mf-cinematic-hud:has(#cmdbar #grpRow[style*="display: flex"]) #selInfo{display:none!important}
3896
+
3897
+ /* Context lives opposite the map. Its cards scroll inside one surface instead
3898
+ of opening stacked overlays; the battlefield remains visible between the
3899
+ top rail and lower instruments. */
3900
+ body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface]{
3901
+ position:fixed;z-index:22;left:auto;right:calc(var(--sar) + var(--mfHudEdge));transform:none;
3902
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudGap));width:var(--mfHudContextW);max-width:calc(100vw - var(--sal) - var(--sar) - var(--mfHudMap) - 10px - var(--mfHudGap) - var(--mfHudEdge) * 3);
3903
+ max-height:min(36dvh,390px);padding:8px;border-radius:11px;overflow-x:hidden;overflow-y:auto;
3904
+ border:1px solid transparent;background:var(--mfHudPanelMaterial) padding-box,var(--steelB) border-box;
3905
+ box-shadow:var(--mfHudShadow);clip-path:polygon(9px 0,100% 0,100% calc(100% - 9px),calc(100% - 9px) 100%,0 100%,0 9px)
3906
+ }
3907
+ body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface],
3908
+ body.mf-cinematic-hud #mfNoticeHistory{scrollbar-width:thin;scrollbar-color:rgba(100,174,205,.72) rgba(3,12,20,.72)}
3909
+ body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface]::-webkit-scrollbar,
3910
+ body.mf-cinematic-hud #mfNoticeHistory::-webkit-scrollbar{width:5px;height:5px}
3911
+ body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface]::-webkit-scrollbar-track,
3912
+ body.mf-cinematic-hud #mfNoticeHistory::-webkit-scrollbar-track{background:rgba(3,12,20,.72)}
3913
+ body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface]::-webkit-scrollbar-thumb,
3914
+ body.mf-cinematic-hud #mfNoticeHistory::-webkit-scrollbar-thumb{border-radius:5px;background:rgba(100,174,205,.72)}
3915
+ body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface].mfCinematicSurfaceActive,
3916
+ body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface][data-mf-active="true"]{isolation:isolate}
3917
+ body.mf-cinematic-hud #mfCinematicContext .mfPanelChrome{top:-8px;height:44px;margin:-8px -8px 6px;padding-left:10px;
3918
+ background:linear-gradient(180deg,rgba(13,31,46,.99),rgba(4,13,22,.99))}
3919
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleBrief{grid-template-columns:76px minmax(0,1fr);min-height:76px;margin:5px 0 7px}
3920
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleVisual,
3921
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleVisual .mfIntelPreview{min-height:76px}
3922
+ /* The live model is the visual label here; repeating TACTICAL PREVIEW over its
3923
+ 62px phone bay obscures the model and adds no decision value. */
3924
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleVisual .mfIntelPreviewTag{display:none}
3925
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleCopy{padding:5px 7px}
3926
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleCopy>strong{margin-top:3px;font-size:10px}
3927
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleCopy>p,
3928
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleCopy>small{display:none}
3929
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleDoctrine{margin-top:3px;font-size:8px}
3930
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleInspect{min-height:44px;margin-top:auto;padding:3px 6px}
3931
+ body.mf-cinematic-hud #mfCinematicContext #buildGrid,
3932
+ body.mf-cinematic-hud #mfCinematicContext #prodGrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px;align-items:stretch}
3933
+ body.mf-cinematic-hud #mfCinematicContext .bcard{width:auto;min-width:0;min-height:88px;padding:5px;align-items:center;gap:2px}
3934
+ /* The legacy intel target sat four pixels outside an overflow-clipped card.
3935
+ Keep its full 44px hit box inside the contextual production surface. */
3936
+ body.mf-cinematic-hud #mfCinematicContext .bcard .cardIntel{top:0;right:0}
3937
+ body.mf-cinematic-hud #mfCinematicContext .bcard .icw,
3938
+ body.mf-cinematic-hud #mfCinematicContext .bcard .em{height:38px}
3939
+ body.mf-cinematic-hud #mfCinematicContext .bcard .nm{min-height:22px;padding:0;text-align:center;font-size:9px;-webkit-line-clamp:2}
3940
+ body.mf-cinematic-hud #mfCinematicContext .bcard .cost{font-size:9px;text-align:center}
3941
+ body.mf-cinematic-hud #mfCinematicContext .bcard .cardPurpose,
3942
+ body.mf-cinematic-hud #mfCinematicContext .bcard .cardDesc,
3943
+ body.mf-cinematic-hud #mfCinematicContext .bcard .cardMeta,
3944
+ body.mf-cinematic-hud #mfCinematicContext .bcard .cardDependency,
3945
+ body.mf-cinematic-hud #mfCinematicContext .bcard .cardEffect,
3946
+ body.mf-cinematic-hud #mfCinematicContext .bcard .cardLocks{display:none}
3947
+ body.mf-cinematic-hud #mfCinematicContext .tabRow{top:35px;gap:4px;margin-bottom:5px}
3948
+ body.mf-cinematic-hud #mfCinematicContext .tabRow{scroll-snap-type:x proximity;transition:box-shadow .15s ease}
3949
+ body.mf-cinematic-hud #mfCinematicContext .tabRow button{min-height:44px;scroll-snap-align:start}
3950
+ /* A soft edge signal appears only while more categories exist off-screen.
3951
+ It consumes no touch area and disappears at the terminal scroll edge. */
3952
+ body.mf-cinematic-hud #mfCinematicContext .tabRow[data-mf-overflow="start"],
3953
+ body.mf-cinematic-hud #mfCinematicContext .tabRow[data-mf-overflow="middle"]{
3954
+ box-shadow:inset -14px 0 10px -8px rgba(95,215,255,.85)
3955
+ }
3956
+ body.mf-cinematic-hud #mfCinematicContext .tabRow[data-mf-overflow="middle"],
3957
+ body.mf-cinematic-hud #mfCinematicContext .tabRow[data-mf-overflow="end"]{
3958
+ border-left:1px solid rgba(95,215,255,.38)
3959
+ }
3960
+ body.mf-cinematic-hud #mfCinematicContext #prodNav{gap:4px;margin-bottom:4px}
3961
+ body.mf-cinematic-hud #mfCinematicContext #prodQueue{margin-top:4px}
3962
+ body.mf-cinematic-hud #mfCinematicContext #bldMenu2{text-align:left}
3963
+ body.mf-cinematic-hud #mfCinematicContext #bp_head{justify-content:flex-start}
3964
+ body.mf-cinematic-hud #mfCinematicContext #bp_title{font-size:12px}
3965
+ body.mf-cinematic-hud #mfCinematicContext #bp_desc{font-size:10px}
3966
+ body.mf-cinematic-hud #mfCinematicContext #bp_stats{font-size:9px}
3967
+
3968
+ /* Repair and recycle are opposing primary actions. State is communicated by
3969
+ colour, border and text, and not by motion alone. */
3970
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"]{grid-template-columns:minmax(0,1.08fr) minmax(0,.92fr);gap:7px}
3971
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] .bldServiceBtn{
3972
+ min-width:0;min-height:52px;padding:7px 6px;border-width:1px;border-radius:8px;font-size:10px;
3973
+ overflow-wrap:normal;word-break:normal;hyphens:none;white-space:normal;display:flex;align-items:center;justify-content:center;gap:5px
3974
+ }
3975
+ /* Production keeps the sole Repair/Recycle authority in normal document flow.
3976
+ The former sticky footer covered the first visible unit cards on phones. */
3977
+ body.mf-cinematic-hud #prodMenu>#mfBldServiceActions{
3978
+ position:static;bottom:auto;z-index:auto;margin:8px 0 0;padding:0;background:none
3979
+ }
3980
+ body.mf-cinematic-hud #rotL .em[data-icon="patrol"]{transform:scaleX(-1)}
3981
+ /* The legacy recycle rule is ID-scoped at 44px. Restate both authoritative
3982
+ actions with the HUD scope so the paired targets remain equally tappable. */
3983
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] #bp_repair,
3984
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] #bp_sell{height:auto;min-height:52px}
3985
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] .bldServiceRepair{
3986
+ color:#74eaff!important;background:linear-gradient(180deg,rgba(8,69,94,.99),rgba(3,29,45,.99)) padding-box,
3987
+ linear-gradient(145deg,#c4fbff,#27ccf5 54%,#08729d) border-box!important
3988
+ }
3989
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"][data-mf-service-state="repairing"] .bldServiceRepair,
3990
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] .bldServiceRepair[data-state="repairing"]{
3991
+ color:#e8fdff!important;box-shadow:inset 0 0 13px rgba(44,216,255,.22),0 0 12px rgba(25,190,240,.24)
3992
+ }
3993
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"][data-mf-service-state="stalled"] .bldServiceRepair,
3994
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] .bldServiceRepair[data-state="stalled"]{color:#ffe39b!important}
3995
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"][data-mf-service-state="under-fire"] .bldServiceRepair,
3996
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] .bldServiceRepair[data-state="under-fire"]{color:#ffc18f!important}
3997
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] .bldServiceRecycle{
3998
+ color:#ff8f8f!important;background:linear-gradient(180deg,rgba(73,18,24,.99),rgba(31,7,12,.99)) padding-box,
3999
+ linear-gradient(145deg,#ffaaa8,#f34853 54%,#80101b) border-box!important
4000
+ }
4001
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"][data-mf-recycle-armed="true"] .bldServiceRecycle,
4002
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] .bldServiceRecycle[data-armed="true"]{
4003
+ color:#fff!important;border-color:#ff5b64;box-shadow:inset 0 0 13px rgba(255,53,67,.2),0 0 13px rgba(255,52,65,.26)
4004
+ }
4005
+
4006
+ /* The building directory uses canonical faction thumbnails injected by the
4007
+ takeover. Art remains the primary identifier; copy may wrap beside it. It
4008
+ shares the right context lane instead of spanning the phone: bottom-aligning
4009
+ it with the map leaves the centre camera open and its maximum width reserves
4010
+ the complete map receiver plus the authored instrument gap. */
4011
+ body.mf-cinematic-hud .baseFinder{
4012
+ left:auto;right:calc(var(--sar) + var(--mfHudEdge));transform:none;
4013
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudGap));width:var(--mfHudContextW);
4014
+ max-width:calc(100vw - var(--sal) - var(--sar) - var(--mfHudMap) - 10px - var(--mfHudGap) - var(--mfHudEdge) * 3);
4015
+ max-height:min(36dvh,390px)
4016
+ }
4017
+ body.mf-cinematic-hud .baseFinder.mfCinematicDecorated{background:var(--mfHudPanelMaterial);border-color:var(--mfHudLine)}
4018
+ /* Five category filters must remain simultaneously readable, including shallow
4019
+ landscape with enlarged text. Their full names remain in aria-label/title;
4020
+ the compact visible contract is always icon above short label. */
4021
+ body.mf-cinematic-hud .baseFindTabs button{padding:3px 1px;flex-direction:column;gap:2px;letter-spacing:0}
4022
+ body.mf-cinematic-hud .baseFindTabs button .baseFindTabIcon{font-size:10px}
4023
+ body.mf-cinematic-hud .baseFindTabs button .baseFindTabLabel{font-size:7px;line-height:1;white-space:nowrap}
4024
+ body.mf-cinematic-hud .baseFinder .mfBaseFinderArt{width:38px;height:38px;display:grid;place-items:center;overflow:hidden;border-radius:7px}
4025
+ body.mf-cinematic-hud .baseFinder .mfBaseFinderArt .facIcon,
4026
+ body.mf-cinematic-hud .baseFinder .mfBaseFinderArt img{max-width:100%;max-height:100%;object-fit:contain}
4027
+ body.mf-cinematic-hud .baseFinder .mfBaseFinderCopy{min-width:0}
4028
+
4029
+ /* Routine events live behind one corner feed target. Opening the drawer does
4030
+ not modal-block the map, and an active production/service surface wins the
4031
+ lower-right lane via the existing :has rule. */
4032
+ body.mf-cinematic-hud #mfNoticeDock{right:calc(var(--sar) + var(--mfHudEdge));bottom:calc(var(--mfHudDockClear) + var(--mfHudGap));width:44px;height:44px}
4033
+ body.mf-cinematic-hud #mfNoticeDock #noticeLogBtn{background:var(--mfHudPanelMaterial) padding-box,var(--steelB) border-box}
4034
+ body.mf-cinematic-hud #mfNoticeHistory{
4035
+ right:calc(var(--sar) + var(--mfHudEdge));bottom:calc(var(--mfHudDockClear) + 52px);width:min(88vw,390px);
4036
+ max-height:min(42dvh,390px);background:var(--mfHudPanelMaterial);border-color:var(--mfHudLine);box-shadow:var(--mfHudShadow)
4037
+ }
4038
+ /* Selectively translucent chassis expose more of the battlefield. Inner cards,
4039
+ tabs and destructive actions keep their own denser backgrounds, and no blur
4040
+ pass is used on these frequently moving gameplay surfaces. */
4041
+ body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface],
4042
+ body.mf-cinematic-hud .baseFinder.mfCinematicDecorated,
4043
+ body.mf-cinematic-hud #unitCard,
4044
+ body.mf-cinematic-hud #hotUtilityPanel,
4045
+ body.mf-cinematic-hud #mfNoticeHistory{
4046
+ background:var(--mfHudSurfaceTranslucent);backdrop-filter:none;-webkit-backdrop-filter:none
4047
+ }
4048
+ /* The open drawer already owns a full 44px close target. Retiring its launch
4049
+ button removes duplicate chrome and keeps placement rotation unobstructed. */
4050
+ body.mf-cinematic-hud.mfNoticeFeedOpen #mfNoticeDock,
4051
+ body.mf-cinematic-hud.uiPlacing #mfNoticeDock{display:none!important}
4052
+ /* The open feed is itself the optional command surface. Retire the prior
4053
+ camera/tactics/group row until it closes so the playfield does not inherit a
4054
+ third dock row from the button used immediately beforehand. */
4055
+ body.mf-cinematic-hud.mfNoticeFeedOpen #cmdbar #camRow,
4056
+ body.mf-cinematic-hud.mfNoticeFeedOpen #cmdbar #tacRow,
4057
+ body.mf-cinematic-hud.mfNoticeFeedOpen #cmdbar #grpRow,
4058
+ body.mf-cinematic-hud.mfNoticeFeedOpen #cmdbar #hotSlots{display:none!important}
4059
+
4060
+ /* Compact portrait phones. Values survive; expendable rate copy yields first.
4061
+ Context width is computed from the actual map bay, preventing a 344px overlap. */
4062
+ @media (max-width:430px) and (orientation:portrait){
4063
+ body.mf-cinematic-hud{--mfHudTopProfile:clamp(50px,15vw,62px);--mfHudContextW:calc(100vw - var(--sal) - var(--sar) - var(--mfHudMap) - var(--mfHudEdge) * 3)}
4064
+ body.mf-cinematic-hud #topbar{grid-template-columns:repeat(3,minmax(0,1fr)) repeat(3,44px)}
4065
+ body.mf-cinematic-hud #topbar>.res{min-height:44px;padding:1px 2px;gap:2px}
4066
+ body.mf-cinematic-hud #topbar>.res .rate{display:none}
4067
+ body.mf-cinematic-hud #topbar>.res b{font-size:max(clamp(10px,3.2vw,13px),var(--mfHudTextMeta))}
4068
+ body.mf-cinematic-hud #topbar>.res .ic{width:16px;height:16px}
4069
+ body.mf-cinematic-hud #topbar #goalBar{font-size:9px;letter-spacing:.025em;padding-left:4px;padding-right:4px}
4070
+ body.mf-cinematic-hud #goalBar .hudIntelChip{padding-left:3px;padding-right:3px}
4071
+ body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn{font-size:7px;letter-spacing:0;padding-left:1px;padding-right:1px}
4072
+ body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn span{font-size:11px}
4073
+ body.mf-cinematic-hud #cmdbar .cbtn{font-size:7px;padding-left:1px;padding-right:1px}
4074
+ body.mf-cinematic-hud #cmdbar .cbtn .em{font-size:15px}
4075
+ body.mf-cinematic-hud #minimapWrap[data-mf-hud-role="minimap-receiver"]{bottom:calc(var(--mfHudDockClear) + var(--mfHudGap) + 7px)}
4076
+ /* Platoons, view and ability decks add a real third row to the phone dock.
4077
+ Follow the authoritative inline visibility instead of the selected tab:
4078
+ Orders can be selected while its optional row is still closed. */
4079
+ body.mf-cinematic-hud:has(#cmdbar #grpRow[style*="display: flex"]) #minimapWrap[data-mf-hud-role="minimap-receiver"],
4080
+ body.mf-cinematic-hud:has(#cmdbar #camRow[style*="display: flex"]) #minimapWrap[data-mf-hud-role="minimap-receiver"],
4081
+ body.mf-cinematic-hud:has(#cmdbar #tacRow[style*="display: flex"]) #minimapWrap[data-mf-hud-role="minimap-receiver"],
4082
+ body.mf-cinematic-hud:has(#cmdbar #hotSlots[style*="display: flex"]) #minimapWrap[data-mf-hud-role="minimap-receiver"],
4083
+ body.mf-cinematic-hud:has(#placeUI[style*="display: flex"]) #minimapWrap[data-mf-hud-role="minimap-receiver"]{
4084
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudTouch) + var(--mfHudGap) * 2 + 7px)
4085
+ }
4086
+ /* Selection and placement controls share the lower instrument band with the
4087
+ map receiver; offset them into the remaining width instead of layering. */
4088
+ body.mf-cinematic-hud #selInfo,
4089
+ body.mf-cinematic-hud #placeUI{
4090
+ left:calc(var(--sal) + var(--mfHudMap) + var(--mfHudEdge) * 2 + 12px);
4091
+ right:calc(var(--sar) + var(--mfHudEdge));width:auto;transform:none
4092
+ }
4093
+ /* UTILITY is a transient continuation of the Abilities row. Keep it in the
4094
+ same right-hand instrument lane as selection intel so the higher-z minimap
4095
+ never steals the first action's touch target; selection copy yields only
4096
+ for the lifetime of this drawer. The landscape ribbon remains centred. */
4097
+ body.mf-cinematic-hud.mfHotUtilityOpen #hotUtilityPanel{
4098
+ left:calc(var(--sal) + var(--mfHudMap) + var(--mfHudEdge) * 2 + 12px);
4099
+ right:calc(var(--sar) + var(--mfHudEdge));width:auto;transform:none
4100
+ }
4101
+ body.mf-cinematic-hud.mfHotUtilityOpen #selInfo{display:none!important}
4102
+ body.mf-cinematic-hud #placeUI{justify-content:flex-end}
4103
+ body.mf-cinematic-hud.uiPlacing #selInfo{display:none!important}
4104
+ /* The measured dock director applies an inline bottom to transient controls.
4105
+ On portrait phones the left instrument rail has a safer destination: both
4106
+ the feed target and consumables clear the whole minimap receiver, while a
4107
+ visible consumable strip lifts FEED one 44px target higher. `!important`
4108
+ intentionally outranks that generic inline dock value only in this lane. */
4109
+ body.mf-cinematic-hud #consHud{
4110
+ position:fixed;left:calc(var(--sal) + var(--mfHudEdge));right:auto;
4111
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudMap) + 10px + var(--mfHudGap) * 2 + 7px)!important;
4112
+ max-width:calc(100vw - var(--sal) - var(--sar) - var(--mfHudEdge) * 2)
4113
+ }
4114
+ body.mf-cinematic-hud #mfNoticeDock{
4115
+ left:calc(var(--sal) + var(--mfHudEdge));right:auto;
4116
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudMap) + 10px + var(--mfHudGap) * 2 + 7px)!important
4117
+ }
4118
+ /* A visible third command row lifts the map exactly one 44px target + gap.
4119
+ FEED must follow that lift; otherwise its whole target lands on the map's
4120
+ upper-left corner. A consumable strip uses the same first tier. When both
4121
+ coexist, stack the strip and FEED on two tiers instead of double-owning the
4122
+ receiver. These formulas include the map's 10px frame and authored 7px
4123
+ dock clearance, so they continue to follow --mfHudMap at <=365px. */
4124
+ body.mf-cinematic-hud:has(#cmdbar :is(#grpRow,#camRow,#tacRow,#hotSlots)[style*="display: flex"]) #mfNoticeDock,
4125
+ body.mf-cinematic-hud:has(#consHud[style*="display: flex"]) #mfNoticeDock{
4126
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudMap) + var(--mfHudTouch) + var(--mfHudGap) * 3 + 17px)!important
4127
+ }
4128
+ body.mf-cinematic-hud:has(#cmdbar :is(#grpRow,#camRow,#tacRow,#hotSlots)[style*="display: flex"]):has(#consHud[style*="display: flex"]) #consHud{
4129
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudMap) + var(--mfHudTouch) + var(--mfHudGap) * 3 + 17px)!important
4130
+ }
4131
+ body.mf-cinematic-hud:has(#cmdbar :is(#grpRow,#camRow,#tacRow,#hotSlots)[style*="display: flex"]):has(#consHud[style*="display: flex"]) #mfNoticeDock{
4132
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudMap) + var(--mfHudTouch) * 2 + var(--mfHudGap) * 4 + 17px)!important
4133
+ }
4134
+ /* The selected PLATOONS tab already names this row on phones. Removing the
4135
+ duplicate label gives all five saved-group targets equal readable width. */
4136
+ body.mf-cinematic-hud #grpRow .pltLabel{display:none}
4137
+ body.mf-cinematic-hud .mfUnitStackCard{flex-basis:104px;width:104px;min-width:104px}
4138
+ /* The history drawer is a glanceable MMO feed, not a modal log covering the
4139
+ centre of the battlefield. The full history remains internally scrollable. */
4140
+ body.mf-cinematic-hud #mfNoticeHistory{width:min(60vw,280px);max-height:min(20dvh,190px)}
4141
+ body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface]{bottom:calc(var(--mfHudDockClear) + var(--mfHudGap));max-height:min(34dvh,320px)}
4142
+ /* Explicit About intel is a compact contextual instrument, not a centre
4143
+ modal. hudflow writes top/max-height inline for the legacy banner lane, so
4144
+ only this pinned phone state deliberately outranks those two coordinates.
4145
+ The width equation preserves the complete minimap receiver and its gap. */
4146
+ body.mf-cinematic-hud #unitCard.pinned{
4147
+ position:fixed;left:auto;right:calc(var(--sar) + var(--mfHudEdge));top:auto!important;transform:none;
4148
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudGap));width:var(--mfHudContextW);
4149
+ max-width:calc(100vw - var(--sal) - var(--sar) - var(--mfHudMap) - 10px - var(--mfHudGap) - var(--mfHudEdge) * 3);
4150
+ height:auto;max-height:min(30dvh,270px)!important;overflow-x:hidden;overflow-y:auto;
4151
+ overscroll-behavior:contain;-webkit-overflow-scrolling:touch
4152
+ }
4153
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleBrief{grid-template-columns:62px minmax(0,1fr)}
4154
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleEyebrow{font-size:7px}
4155
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleCopy>strong{font-size:8px}
4156
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleDoctrine{font-size:7px}
4157
+ body.mf-cinematic-hud #mfCinematicContext .bcard{min-height:82px;padding:4px 3px}
4158
+ body.mf-cinematic-hud #mfCinematicContext .bcard .nm{font-size:8px}
4159
+ body.mf-cinematic-hud #mfCinematicContext .bcard .cost{font-size:8px}
4160
+ body.mf-cinematic-hud #bp_ic{min-width:44px;min-height:44px}
4161
+ body.mf-cinematic-hud #bp_title{overflow-wrap:anywhere}
4162
+ }
4163
+
4164
+ @media (max-width:365px) and (orientation:portrait){
4165
+ body.mf-cinematic-hud{--mfHudGap:2px;--mfHudEdge:2px;--mfHudTopProfile:44px;--mfHudMap:70px}
4166
+ body.mf-cinematic-hud #topbar{grid-template-columns:repeat(3,minmax(0,1fr)) repeat(3,44px)}
4167
+ body.mf-cinematic-hud #topbar>.res{min-width:44px}
4168
+ body.mf-cinematic-hud #topbar>.res .ic{display:none}
4169
+ body.mf-cinematic-hud #topbar>.res b{font-size:max(10px,var(--mfHudTextMeta));letter-spacing:-.02em}
4170
+ body.mf-cinematic-hud #goalBar .hudIntelChip.goal{display:none}
4171
+ body.mf-cinematic-hud #cmdbar{padding-left:3px;padding-right:3px}
4172
+ body.mf-cinematic-hud #grpRow.mfUnitStackReady{gap:0;padding-left:1px;padding-right:1px}
4173
+ body.mf-cinematic-hud #grpRow.mfUnitStackReady>.grpBtn{flex-basis:44px}
4174
+ body.mf-cinematic-hud #mfUnitStackRail{min-width:84px}
4175
+ body.mf-cinematic-hud .mfUnitStackCard{flex-basis:84px;width:84px;min-width:84px}
4176
+ body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn{min-width:44px}
4177
+ body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface]{padding:6px;max-height:31dvh}
4178
+ body.mf-cinematic-hud #mfCinematicContext .mfPanelChrome{top:-6px;margin:-6px -6px 5px}
4179
+ /* The 76px role preview cannot coexist with the 44px close target in this
4180
+ width band. Cards remain the complete visual chooser, so retire the
4181
+ duplicate preview instead of leaving its INSPECT action live under chrome. */
4182
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleBrief{display:none}
4183
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"]{gap:4px}
4184
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] .bldServiceBtn{font-size:8px;padding:5px 3px}
4185
+ }
4186
+
4187
+ /* Short landscape keeps the permanent deck and primary orders in one shallow
4188
+ ribbon. Optional controls borrow one second row only while selected, leaving
4189
+ the left rail and centre camera unobstructed. */
4190
+ @media (orientation:landscape) and (max-height:600px){
4191
+ body.mf-cinematic-hud{
4192
+ --mfHudTopProfile:54px;--mfHudTopRow:44px;--mfHudIntel:28px;
4193
+ --mfHudMap:clamp(76px,23vh,96px);--mfHudDockW:min(65vw,560px);
4194
+ --mfHudDockRows:54px;--mfHudContextW:min(32vw,320px);
4195
+ --mfHudLeftRailW:calc(100vw - var(--sal) - var(--sar) - var(--mfHudEdge) * 2 - var(--mfHudDockW) - var(--mfHudGap))
4196
+ }
4197
+ body.mf-cinematic-hud #heroBar{width:54px;height:44px}
4198
+ body.mf-cinematic-hud #heroPortrait{width:46px;height:36px}
4199
+ body.mf-cinematic-hud #heroBar .heroProfileBody{left:auto;right:2px;bottom:2px;height:auto;padding:2px 3px;border:0;border-radius:4px}
4200
+ body.mf-cinematic-hud #topbar{
4201
+ right:auto;width:min(46vw,360px,calc(100vw - var(--sal) - var(--sar) - 54px - var(--mfHudEdge) * 3));
4202
+ grid-template-columns:repeat(3,minmax(58px,1fr)) repeat(3,44px)
4203
+ }
4204
+ body.mf-cinematic-hud #topbar>.res .rate{display:none}
4205
+ body.mf-cinematic-hud #topbar #goalBar{
4206
+ position:absolute;left:0;top:calc(44px + var(--mfHudGap));width:100%;height:28px;min-height:28px;max-height:28px;
4207
+ justify-self:auto;white-space:nowrap
4208
+ }
4209
+ body.mf-cinematic-hud #cmdbar{
4210
+ left:auto;right:calc(var(--sar) + var(--mfHudEdge));width:var(--mfHudDockW);display:grid;
4211
+ grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:44px;gap:var(--mfHudGap);padding:4px
4212
+ }
4213
+ body.mf-cinematic-hud #cmdbar #hudDeckTabs{grid-column:1;grid-row:1;justify-content:flex-start}
4214
+ /* The atlas is the label in the shallow landscape ribbon. Literal names are
4215
+ retained as the no-art fallback, but once the validated sheet is ready a
4216
+ 44px PLATOONS target must not clip eight characters around its glyph. */
4217
+ html.cmdIcons body.mf-cinematic-hud #cmdbar #hudDeckTabs .hudDeckBtn{font-size:0;letter-spacing:0}
4218
+ body.mf-cinematic-hud #cmdbar #primaryRow{grid-column:2;grid-row:1}
4219
+ body.mf-cinematic-hud #cmdbar #camRow,
4220
+ body.mf-cinematic-hud #cmdbar #tacRow,
4221
+ body.mf-cinematic-hud #cmdbar #grpRow,
4222
+ body.mf-cinematic-hud #cmdbar #hotSlots{grid-column:1/-1;grid-row:1}
4223
+ body.mf-cinematic-hud:has(#cmdbar #camRow[style*="display: flex"]),
4224
+ body.mf-cinematic-hud:has(#cmdbar #tacRow[style*="display: flex"]),
4225
+ body.mf-cinematic-hud:has(#cmdbar #grpRow[style*="display: flex"]),
4226
+ body.mf-cinematic-hud:has(#cmdbar #hotSlots[style*="display: flex"]){--mfHudDockRows:101px}
4227
+ body.mf-cinematic-hud:has(#cmdbar #camRow[style*="display: flex"]) #hudDeckTabs,
4228
+ body.mf-cinematic-hud:has(#cmdbar #tacRow[style*="display: flex"]) #hudDeckTabs,
4229
+ body.mf-cinematic-hud:has(#cmdbar #grpRow[style*="display: flex"]) #hudDeckTabs,
4230
+ body.mf-cinematic-hud:has(#cmdbar #hotSlots[style*="display: flex"]) #hudDeckTabs,
4231
+ body.mf-cinematic-hud:has(#cmdbar #camRow[style*="display: flex"]) #primaryRow,
4232
+ body.mf-cinematic-hud:has(#cmdbar #tacRow[style*="display: flex"]) #primaryRow,
4233
+ body.mf-cinematic-hud:has(#cmdbar #grpRow[style*="display: flex"]) #primaryRow,
4234
+ body.mf-cinematic-hud:has(#cmdbar #hotSlots[style*="display: flex"]) #primaryRow{grid-row:2}
4235
+ body.mf-cinematic-hud:is(.uiPrimaryOpen,.uiPlacing){--mfHudDockRows:54px}
4236
+ body.mf-cinematic-hud:is(.uiPrimaryOpen,.uiPlacing) #hudDeckTabs,
4237
+ body.mf-cinematic-hud:is(.uiPrimaryOpen,.uiPlacing) #cmdbar #camRow,
4238
+ body.mf-cinematic-hud:is(.uiPrimaryOpen,.uiPlacing) #cmdbar #tacRow,
4239
+ body.mf-cinematic-hud:is(.uiPrimaryOpen,.uiPlacing) #cmdbar #mfCinematicGroupPalette,
4240
+ body.mf-cinematic-hud:is(.uiPrimaryOpen,.uiPlacing) #cmdbar #hotSlots{display:none!important}
4241
+ body.mf-cinematic-hud:is(.uiPrimaryOpen,.uiPlacing) #cmdbar{grid-template-columns:1fr;grid-template-rows:44px}
4242
+ body.mf-cinematic-hud:is(.uiPrimaryOpen,.uiPlacing) #cmdbar #primaryRow{grid-column:1;grid-row:1}
4243
+ body.mf-cinematic-hud #minimapWrap[data-mf-hud-role="minimap-receiver"]{bottom:calc(var(--sab) + var(--mfHudEdge))}
4244
+ body.mf-cinematic-hud #selInfo{
4245
+ left:auto;right:calc(var(--sar) + var(--mfHudEdge) + var(--mfHudDockW) + var(--mfHudGap));
4246
+ bottom:calc(var(--sab) + var(--mfHudEdge));width:46px;max-width:46px;min-height:44px;padding:0;transform:none;overflow:hidden
4247
+ }
4248
+ body.mf-cinematic-hud #selInfo .selIntelCopy{display:none}
4249
+ body.mf-cinematic-hud #selInfo .selIntelBtn{border:0;border-radius:9px}
4250
+ body.mf-cinematic-hud:is(.uiPrimaryOpen,.uiPlacing) #selInfo{display:none!important}
4251
+ body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface]{
4252
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudGap));width:var(--mfHudContextW);max-width:var(--mfHudContextW);
4253
+ max-height:min(45dvh,186px,calc(100dvh - var(--mfHudTopClear) - var(--mfHudDockClear) - var(--mfHudGap) * 2));
4254
+ scroll-padding-top:52px
4255
+ }
4256
+ body.mf-cinematic-hud #mfCinematicContext .tabRow{position:static;top:auto}
4257
+ body.mf-cinematic-hud #mfCinematicContext .bcard{scroll-margin-top:52px}
4258
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleBrief{display:none}
4259
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"]{position:sticky;z-index:3;bottom:0;background:var(--mfHudPanelFallback)}
4260
+ body.mf-cinematic-hud #placeUI{
4261
+ left:auto;right:calc(var(--sar) + var(--mfHudEdge));bottom:calc(var(--mfHudDockClear) + var(--mfHudGap));transform:none
4262
+ }
4263
+ body.mf-cinematic-hud #mfNoticeDock{
4264
+ left:calc(var(--sal) + var(--mfHudEdge));right:auto;
4265
+ bottom:calc(var(--sab) + var(--mfHudEdge) + var(--mfHudMap) + 10px + var(--mfHudGap))
4266
+ }
4267
+ body.mf-cinematic-hud #mfNoticeDock:has(#noticeLogBtn[aria-expanded="true"]){display:none}
4268
+ body.mf-cinematic-hud #mfNoticeHistory{
4269
+ left:calc(var(--sal) + var(--mfHudEdge));right:auto;width:min(var(--mfHudLeftRailW),300px);
4270
+ bottom:calc(var(--sab) + var(--mfHudEdge) + var(--mfHudMap) + 10px + var(--mfHudGap));
4271
+ height:min(46dvh,176px,calc(100dvh - var(--mfHudTopClear) - var(--mfHudDockClear) - var(--mfHudGap) * 2));
4272
+ max-height:min(46dvh,176px,calc(100dvh - var(--mfHudTopClear) - var(--mfHudDockClear) - var(--mfHudGap) * 2))
4273
+ }
4274
+ body.mf-cinematic-hud #mfNoticeHistory header{height:44px;min-height:44px;padding:0 4px}
4275
+ body.mf-cinematic-hud #mfNoticeHistory nav{height:48px;padding:2px 4px}
4276
+ body.mf-cinematic-hud #mfNoticeHistory .mfNoticeItem{grid-template-columns:38px minmax(0,1fr) auto}
4277
+ body.mf-cinematic-hud #mfNoticeHistory .mfNoticeItem i,
4278
+ body.mf-cinematic-hud #mfNoticeHistory .mfNoticeItem>span{grid-column:2}
4279
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] .bldServiceBtn,
4280
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] #bp_repair,
4281
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] #bp_sell{min-height:48px}
4282
+ /* Enlarged text previously consumed the horizontal icon allowance and forced
4283
+ REPAIRING / CONFIRM through arbitrary mid-word breaks. Stack the icon only
4284
+ in this shallow band and permit wrapping at semantic spaces, never letters. */
4285
+ html[data-mf-text-scale]:not([data-mf-text-scale="100"]) body.mf-cinematic-hud [data-mf-hud-role="service-controls"] .bldServiceBtn,
4286
+ html[data-mf-text-scale]:not([data-mf-text-scale="100"]) body.mf-cinematic-hud [data-mf-hud-role="service-controls"] #bp_repair,
4287
+ html[data-mf-text-scale]:not([data-mf-text-scale="100"]) body.mf-cinematic-hud [data-mf-hud-role="service-controls"] #bp_sell{
4288
+ flex-direction:column;gap:2px;padding:4px 3px;font-size:8px;line-height:1.12;letter-spacing:0;
4289
+ overflow-wrap:normal;word-break:normal;hyphens:none
4290
+ }
4291
+ }
4292
+
4293
+ /* Tablets/desktops expose the full commander condition without making it a
4294
+ central overlay. Context and commands remain right-aligned; the map stays in
4295
+ its own lower-left well. */
4296
+ @media (min-width:700px) and (min-height:601px){
4297
+ body.mf-cinematic-hud{
4298
+ --mfHudTopProfile:clamp(210px,22vw,246px);--mfHudMap:clamp(104px,13vw,150px);
4299
+ --mfHudContextW:min(34vw,380px);--mfHudDockRows:calc(var(--mfHudTouch) * 2 + var(--mfHudGap) * 3)
4300
+ }
4301
+ body.mf-cinematic-hud #heroBar{height:var(--mfHudTopRow);padding:4px 7px;justify-content:flex-start;gap:7px}
4302
+ body.mf-cinematic-hud #heroPortrait{width:calc(var(--mfHudTopRow) - 8px);height:calc(var(--mfHudTopRow) - 8px);flex:0 0 calc(var(--mfHudTopRow) - 8px)}
4303
+ body.mf-cinematic-hud #heroBar .heroProfileBody{position:static;height:auto;display:flex;align-items:stretch;justify-content:center;padding:0;border:0;background:none}
4304
+ body.mf-cinematic-hud #heroNameTxt,body.mf-cinematic-hud #heroCallsignTxt,
4305
+ body.mf-cinematic-hud #heroBar .heroVital{display:grid}
4306
+ body.mf-cinematic-hud #heroNameTxt,body.mf-cinematic-hud #heroCallsignTxt{display:block}
4307
+ body.mf-cinematic-hud #heroBar .heroProfileHead{justify-content:space-between}
4308
+ body.mf-cinematic-hud #topbar{grid-template-columns:repeat(3,minmax(84px,1fr)) repeat(3,var(--mfHudTouch));max-width:760px}
4309
+ body.mf-cinematic-hud #cmdbar{left:auto;width:min(58vw,590px)}
4310
+ body.mf-cinematic-hud #minimapWrap[data-mf-hud-role="minimap-receiver"]{bottom:calc(var(--sab) + var(--mfHudEdge))}
4311
+ body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface]{max-width:var(--mfHudContextW);bottom:calc(var(--mfHudDockClear) + var(--mfHudGap));max-height:min(48dvh,470px)}
4312
+ body.mf-cinematic-hud #mfNoticeDock{right:calc(var(--sar) + min(58vw,590px) + var(--mfHudEdge) * 2);bottom:calc(var(--sab) + var(--mfHudEdge))}
4313
+ body.mf-cinematic-hud #mfNoticeHistory{left:calc(var(--sal) + var(--mfHudEdge));right:auto;bottom:calc(var(--sab) + 54px);width:min(34vw,360px)}
4314
+ }
4315
+
4316
+ /* Text scale is applied to visible tactical copy, not merely to a settings
4317
+ label. Touch geometry stays stable while scrollable decks absorb long copy. */
4318
+ body.mf-cinematic-hud #topbar #goalBar{font-size:var(--mfHudTextGoal)}
4319
+ /* A minimap transmission has only a 99px receiver on phones. Use the authored
4320
+ feed token and three compact lines rather than inheriting the larger legacy
4321
+ rem value, so Commander and KEEL copy remains complete at the base scale. */
4322
+ body.mf-cinematic-hud #cmdrTxBody{padding:17px 5px 4px}
4323
+ body.mf-cinematic-hud #cmdrTxWho{font-size:var(--mfHudTextAction);line-height:1.15}
4324
+ body.mf-cinematic-hud #cmdrTxLine{font-size:var(--mfHudTextFeed);line-height:1.15;-webkit-line-clamp:3}
4325
+ body.mf-cinematic-hud #mfCinematicContext .bcard .nm,
4326
+ body.mf-cinematic-hud #mfCinematicContext .bcard .cost{font-size:var(--mfHudTextCard)}
4327
+ body.mf-cinematic-hud #mfCinematicContext #bp_desc,
4328
+ body.mf-cinematic-hud .mfNoticeItem>span,
4329
+ body.mf-cinematic-hud .mfNoticeEmpty,
4330
+ body.mf-cinematic-hud #selInfo .selIntelCopy span{font-size:var(--mfHudTextFeed)}
4331
+ body.mf-cinematic-hud #mfCinematicContext #bp_title,
4332
+ body.mf-cinematic-hud #bp_repair,
4333
+ body.mf-cinematic-hud #bp_sell,
4334
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleInspect,
4335
+ body.mf-cinematic-hud #mfNoticeHistory header b{font-size:var(--mfHudTextAction)}
4336
+ body.mf-cinematic-hud #cmdbar .cbtn,
4337
+ body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn,
4338
+ body.mf-cinematic-hud #mfCinematicContext .tabRow button{font-size:var(--mfHudTextDock)}
4339
+ body.mf-cinematic-hud #mfCinematicContext #bp_stats,
4340
+ body.mf-cinematic-hud #mfCinematicContext #bp_delta,
4341
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleEyebrow,
4342
+ body.mf-cinematic-hud #mfCinematicContext .menuRoleDoctrine,
4343
+ body.mf-cinematic-hud #mfNoticeHistory .mfNoticeItem time,
4344
+ body.mf-cinematic-hud #mfNoticeHistory .mfNoticeItem i,
4345
+ body.mf-cinematic-hud #mfNoticeHistory .mfNoticeRepeat{font-size:var(--mfHudTextMeta)}
4346
+ body.mf-cinematic-hud.uiPlacing #selInfo{display:none!important}
4347
+ html[data-mf-text-scale="125"] body.mf-cinematic-hud{--mfHudIntel:30px}
4348
+ html[data-mf-text-scale="150"] body.mf-cinematic-hud{--mfHudIntel:34px}
4349
+ html[data-mf-text-scale="200"] body.mf-cinematic-hud{--mfHudIntel:42px}
4350
+ html[data-mf-text-scale]:not([data-mf-text-scale="100"]) body.mf-cinematic-hud #topbar{overflow:visible;touch-action:none}
4351
+ html[data-mf-text-scale]:not([data-mf-text-scale="100"]) body.mf-cinematic-hud #topbar>.res{flex:initial}
4352
+ html[data-mf-text-scale]:not([data-mf-text-scale="100"]) body.mf-cinematic-hud #topbar #goalBar{
4353
+ min-height:var(--mfHudIntel);height:var(--mfHudIntel);max-height:var(--mfHudIntel);white-space:normal;line-height:1.12
4354
+ }
4355
+ html[data-mf-text-scale]:not([data-mf-text-scale="100"]) body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn{
4356
+ flex:0 0 auto;min-width:max(44px,6.4em)
4357
+ }
4358
+ html:is([data-mf-text-scale="150"],[data-mf-text-scale="200"]) body.mf-cinematic-hud #topbar>.res .rate{display:none}
4359
+ html:is([data-mf-text-scale="150"],[data-mf-text-scale="200"]) body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface]{overflow-y:auto}
4360
+ html[data-mf-text-scale="200"] body.mf-cinematic-hud #mfCinematicContext #buildGrid,
4361
+ html[data-mf-text-scale="200"] body.mf-cinematic-hud #mfCinematicContext #prodGrid{grid-template-columns:1fr}
4362
+ html[data-mf-text-scale="200"] body.mf-cinematic-hud #mfCinematicContext .bcard{min-height:96px}
4363
+ html[data-mf-text-scale="200"] body.mf-cinematic-hud #mfNoticeHistory .mfNoticeItem{grid-template-columns:38px minmax(0,1fr)}
4364
+ html[data-mf-text-scale="200"] body.mf-cinematic-hud #mfNoticeHistory .mfNoticeItem i,
4365
+ html[data-mf-text-scale="200"] body.mf-cinematic-hud #mfNoticeHistory .mfNoticeItem>span{grid-column:2}
4366
+
4367
+ /* Measured collision/scale remediation. The status chip is an action, so the
4368
+ enlarged-copy rule above may wrap it but may never shrink its hit target. */
4369
+ body.mf-cinematic-hud #hazChip{box-sizing:border-box;min-height:44px;max-height:none}
4370
+ body.mf-cinematic-hud .baseFinder header b{
4371
+ min-width:0;font-size:min(var(--mfHudTextFeed),12px);line-height:1.1;overflow-wrap:anywhere
4372
+ }
4373
+ body.mf-cinematic-hud .baseFinder .baseFindCopy b{font-size:min(var(--mfHudTextGoal),11px)}
4374
+
4375
+ /* The receiver is intentionally the minimap rather than a second dialogue
4376
+ panel. Cap only its local type scale so a speaker plus three useful lines
4377
+ remain legible inside the 70--112px tactical instrument. */
4378
+ body.mf-cinematic-hud #cmdrTxWho{font-size:min(var(--mfHudTextAction),10px);line-height:1.1}
4379
+ body.mf-cinematic-hud #cmdrTxLine{font-size:min(var(--mfHudTextFeed),10px);line-height:1.1;-webkit-line-clamp:3}
4380
+
4381
+ /* Structure service is the one context whose last row is destructive. Keep
4382
+ that row inside its own scroller at every height; production retains normal
4383
+ flow so this never covers unit cards. */
4384
+ body.mf-cinematic-hud #bldMenu2 [data-mf-hud-role="service-controls"]{
4385
+ position:sticky;z-index:4;bottom:0;margin-bottom:0;padding-top:4px;
4386
+ background:linear-gradient(180deg,rgba(3,10,18,0),rgba(3,10,18,.98) 28%)
4387
+ }
4388
+
4389
+ /* Unit-stack cards scale their useful copy while the fixed 44px target and
4390
+ ellipsis keep the same-row PLATOONS rail bounded. */
4391
+ body.mf-cinematic-hud .mfUnitStackName{
4392
+ font-size:var(--mfHudTextCard);overflow:visible;text-overflow:clip;white-space:nowrap
4393
+ }
4394
+ body.mf-cinematic-hud .mfUnitStackMeta,
4395
+ body.mf-cinematic-hud .mfUnitStackCount,
4396
+ body.mf-cinematic-hud .mfUnitStackReady{font-size:var(--mfHudTextMeta)}
4397
+ body.mf-cinematic-hud .mfUnitStackReady{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
4398
+
4399
+ /* Compact tactical labels keep their authored phone floors, then participate
4400
+ in text scaling without outgrowing the 44px hot-slot and consumable rows. */
4401
+ body.mf-cinematic-hud #cmdbar #hotSlots>.hotSlot .hNm{
4402
+ font-size:max(9px,min(11px,var(--mfHudTextDock)))
4403
+ }
4404
+ body.mf-cinematic-hud #consHud .conHudNm{
4405
+ font-size:clamp(11px,var(--mfHudTextFeed),14px)
4406
+ }
4407
+
4408
+ /* Mid-width portrait devices were outside the phone collision lane but still
4409
+ used the full-width three-row dock. Follow the measured third row and keep
4410
+ selection/utility to the right of the map; transient strips stack above it. */
4411
+ @media (min-width:431px) and (max-width:699px) and (orientation:portrait){
4412
+ body.mf-cinematic-hud:has(#cmdbar :is(#grpRow,#camRow,#tacRow,#hotSlots)[style*="display: flex"]) #minimapWrap[data-mf-hud-role="minimap-receiver"],
4413
+ body.mf-cinematic-hud:has(#placeUI[style*="display: flex"]) #minimapWrap[data-mf-hud-role="minimap-receiver"]{
4414
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudTouch) + var(--mfHudGap) * 2)
4415
+ }
4416
+ body.mf-cinematic-hud #selInfo,
4417
+ body.mf-cinematic-hud #placeUI,
4418
+ body.mf-cinematic-hud.mfHotUtilityOpen #hotUtilityPanel{
4419
+ left:calc(var(--sal) + var(--mfHudEdge) + var(--mfHudMap) + 10px + var(--mfHudGap));
4420
+ right:calc(var(--sar) + var(--mfHudEdge));width:auto;transform:none
4421
+ }
4422
+ body.mf-cinematic-hud #consHud,
4423
+ body.mf-cinematic-hud #mfNoticeDock{
4424
+ left:calc(var(--sal) + var(--mfHudEdge));right:auto;
4425
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudMap) + 10px + var(--mfHudGap) * 2)!important
4426
+ }
4427
+ body.mf-cinematic-hud:has(#cmdbar :is(#grpRow,#camRow,#tacRow,#hotSlots)[style*="display: flex"]) #consHud,
4428
+ body.mf-cinematic-hud:has(#cmdbar :is(#grpRow,#camRow,#tacRow,#hotSlots)[style*="display: flex"]) #mfNoticeDock{
4429
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudTouch) + var(--mfHudMap) + 10px + var(--mfHudGap) * 3)!important
4430
+ }
4431
+ body.mf-cinematic-hud:has(#consHud[style*="display: flex"]) #mfNoticeDock{
4432
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudMap) + var(--mfHudTouch) + 10px + var(--mfHudGap) * 3)!important
4433
+ }
4434
+ body.mf-cinematic-hud:has(#cmdbar :is(#grpRow,#camRow,#tacRow,#hotSlots)[style*="display: flex"]):has(#consHud[style*="display: flex"]) #mfNoticeDock{
4435
+ bottom:calc(var(--mfHudDockClear) + var(--mfHudMap) + var(--mfHudTouch) * 2 + 10px + var(--mfHudGap) * 4)!important
4436
+ }
4437
+ }
4438
+
4439
+ @media (max-width:430px) and (orientation:portrait){
4440
+ /* One glanceable card is enough for FIND; removing the repeated hint and
4441
+ trimming its internal gaps pulls the opaque chassis out of the camera ROI. */
4442
+ body.mf-cinematic-hud .baseFinder{max-height:min(21dvh,170px)}
4443
+ body.mf-cinematic-hud .baseFinder header small,
4444
+ body.mf-cinematic-hud .baseFinder .baseFindHint{display:none}
4445
+ body.mf-cinematic-hud .baseFindTabs{margin-top:4px}
4446
+ body.mf-cinematic-hud .baseFindGrid{margin-top:4px;max-height:52px}
4447
+ body.mf-cinematic-hud .baseFindCard{min-height:52px;padding-top:3px;padding-bottom:3px}
4448
+ /* Keep one complete stack card visible beside the fixed 44px controls. The
4449
+ rail itself scrolls; shrinking its viewport to a single touch target made
4450
+ the first card look cut off even though the dock remained in bounds. */
4451
+ body.mf-cinematic-hud:has(#modeBtn[style*="display: flex"]) #mfUnitStackRail{
4452
+ flex-basis:84px;min-width:84px
4453
+ }
4454
+ }
4455
+
4456
+ @media (max-width:365px) and (orientation:portrait){
4457
+ /* 236px outer width - borders - 5px padding = 224px: five 44px targets plus
4458
+ four 1px gaps fit exactly even with the stressed safe-area profile. */
4459
+ body.mf-cinematic-hud .baseFinder{padding:5px}
4460
+ body.mf-cinematic-hud .baseFindTabs{grid-template-columns:repeat(5,minmax(44px,1fr));gap:1px}
4461
+ body.mf-cinematic-hud .baseFindTabs button{min-width:44px}
4462
+ body.mf-cinematic-hud #cmdrTxBody{gap:1px;padding:14px 4px 3px}
4463
+ body.mf-cinematic-hud #cmdrTxWho{font-size:9px;line-height:1.05}
4464
+ body.mf-cinematic-hud #cmdrTxLine{font-size:8px;line-height:1.05}
4465
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] #bp_repair,
4466
+ body.mf-cinematic-hud [data-mf-hud-role="service-controls"] #bp_sell{
4467
+ flex-direction:column;gap:2px;padding:4px 3px;font-size:10px;line-height:1.1;letter-spacing:0
4468
+ }
4469
+ }
4470
+
4471
+ @media (orientation:landscape) and (max-height:600px){
4472
+ /* The shallow ribbon has two unequal jobs: four atlas-labelled deck targets
4473
+ and five permanent order targets. One-pixel gaps fit both without pushing
4474
+ scrollWidth through the dock root at 640x360 / 200% text. */
4475
+ body.mf-cinematic-hud #topbar{grid-template-columns:repeat(3,minmax(0,1fr)) repeat(3,44px)}
4476
+ body.mf-cinematic-hud #cmdbar{grid-template-columns:minmax(0,44fr) minmax(0,56fr);gap:1px;padding:2px}
4477
+ body.mf-cinematic-hud #cmdbar #hudDeckTabs,
4478
+ body.mf-cinematic-hud #cmdbar #primaryRow{gap:1px}
4479
+ /* Three columns keep every 44px category visible without widening the
4480
+ contextual lane into the centre playfield. Cards remain below in scroll. */
4481
+ body.mf-cinematic-hud .baseFinder{width:min(28vw,280px);max-height:min(45dvh,186px)}
4482
+ body.mf-cinematic-hud .baseFinder header{gap:4px}
4483
+ body.mf-cinematic-hud .baseFinder header small,
4484
+ body.mf-cinematic-hud .baseFinder .baseFindHint{display:none}
4485
+ body.mf-cinematic-hud .baseFinder header>span{overflow:hidden;flex-wrap:wrap;gap:2px}
4486
+ body.mf-cinematic-hud .baseFinder header b{min-width:0;overflow-wrap:anywhere}
4487
+ body.mf-cinematic-hud .baseFindBack{width:44px;min-width:44px;padding:2px;font-size:0}
4488
+ body.mf-cinematic-hud .baseFindTabs{grid-template-columns:repeat(3,minmax(44px,1fr));gap:3px;margin-top:4px}
4489
+ body.mf-cinematic-hud .baseFindTabs button{min-width:44px}
4490
+ body.mf-cinematic-hud .baseFindGrid{margin-top:4px;max-height:52px}
4491
+ /* FEED and consumables occupy measured tiers above the map. When Utility is
4492
+ also open, consumables move to the free top-left tier and FEED stays beside
4493
+ (not under) Utility. */
4494
+ body.mf-cinematic-hud #consHud{
4495
+ left:calc(var(--sal) + var(--mfHudEdge));right:auto;
4496
+ bottom:calc(var(--sab) + var(--mfHudEdge) + var(--mfHudMap) + 10px + var(--mfHudGap))!important
4497
+ }
4498
+ body.mf-cinematic-hud:not(.mfHotUtilityOpen):has(#consHud[style*="display: flex"]) #mfNoticeDock{
4499
+ bottom:calc(var(--sab) + var(--mfHudEdge) + var(--mfHudMap) + var(--mfHudTouch) + 10px + var(--mfHudGap) * 2)!important
4500
+ }
4501
+ body.mf-cinematic-hud.mfHotUtilityOpen:has(#consHud[style*="display: flex"]) #consHud{
4502
+ top:var(--mfHudTopClear);bottom:auto!important
4503
+ }
4504
+ body.mf-cinematic-hud #mfNoticeHistory{width:min(42vw,260px)}
4505
+ body.mf-cinematic-hud #mfNoticeHistory nav{overflow-x:auto;overflow-y:hidden;scrollbar-width:none}
4506
+ }
4507
+
4508
+ @media (prefers-reduced-motion:reduce){
4509
+ body.mf-cinematic-hud #heroBar,body.mf-cinematic-hud #heroHpFill,body.mf-cinematic-hud #xpFill,
4510
+ body.mf-cinematic-hud #minimapWrap,body.mf-cinematic-hud #minimap,
4511
+ body.mf-cinematic-hud #mfCinematicContext>[data-mf-surface],
4512
+ body.mf-cinematic-hud #cmdbar button{transition:none!important;animation:none!important}
4513
+ body.mf-cinematic-hud #goalBar .clk.low,body.mf-cinematic-hud #infMeter.t4,
4514
+ body.mf-cinematic-hud #atkAlert,body.mf-cinematic-hud #waveAlert{animation:none!important}
4515
+ }
4516
+
4517
+ @media (hover:none) and (pointer:coarse){
4518
+ body.mf-cinematic-hud #hudDeckTabs .hudDeckBtn,body.mf-cinematic-hud #cmdbar .cbtn{touch-action:manipulation}
4519
+ body.mf-cinematic-hud #mfCinematicContext .bcard{touch-action:manipulation}
4520
+ }
src/ui/cinematic-hud.js ADDED
@@ -0,0 +1,648 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ;(function(){
2
+ /* OTA shells can re-evaluate the takeover without reloading the document.
3
+ Retire the previous observer first so one HUD owns one synchronization
4
+ loop for the lifetime of the page. */
5
+ if(window.MFCinematicHud&&typeof window.MFCinematicHud.destroy==='function'){
6
+ try{window.MFCinematicHud.destroy();}catch(e){}
7
+ }
8
+ /* The cinematic HUD is presentation-only. Moving the existing nodes keeps
9
+ their listeners, IDs and simulation authority intact; copying markup here
10
+ would create a second recycle button and bypass its confirmation guard. */
11
+ function mfCinematicSetRole(el,role){
12
+ if(el)el.setAttribute('data-mf-hud-role',role);
13
+ return el;
14
+ }
15
+ function mfCinematicWrap(id,before,nodes,role,label){
16
+ var wrap=document.getElementById(id),anchor=document.getElementById(before);
17
+ if(!wrap){
18
+ wrap=document.createElement('div');wrap.id=id;
19
+ if(anchor&&anchor.parentNode)anchor.parentNode.insertBefore(wrap,anchor);
20
+ else document.body.appendChild(wrap);
21
+ }
22
+ mfCinematicSetRole(wrap,role);
23
+ if(label&&!wrap.getAttribute('aria-label'))wrap.setAttribute('aria-label',label);
24
+ for(var i=0;i<nodes.length;i++){
25
+ var node=document.getElementById(nodes[i]);
26
+ if(node&&node.parentNode!==wrap)wrap.appendChild(node);
27
+ }
28
+ return wrap;
29
+ }
30
+ function mfCinematicLabelPanel(panel,label,surface){
31
+ if(!panel)return;
32
+ panel.classList.add('mfCinematicSurface');
33
+ panel.setAttribute('data-mf-hud-role','context-surface');
34
+ panel.setAttribute('data-mf-surface',surface);
35
+ if(!panel.getAttribute('role'))panel.setAttribute('role','region');
36
+ var title=panel.querySelector('.mfPanelChrome > span');
37
+ if(title){
38
+ if(!title.id)title.id='mfCinematic'+surface.charAt(0).toUpperCase()+surface.slice(1)+'Title';
39
+ panel.setAttribute('aria-labelledby',title.id);
40
+ }else if(!panel.getAttribute('aria-label'))panel.setAttribute('aria-label',label);
41
+ }
42
+ function mfCinematicMarkIcon(el,icon){
43
+ if(!el)return;
44
+ var direct=el.matches&&el.matches('[data-mf-hud-role="service-repair"],[data-mf-hud-role="service-recycle"]');
45
+ var mark=el.classList.contains('em')?el:el.querySelector&&el.querySelector('.em');
46
+ if(!mark&&!direct){
47
+ if(el.tagName==='SPAN')mark=el;
48
+ else{
49
+ mark=document.createElement('span');mark.className='em mfCinematicInjectedIcon';mark.setAttribute('aria-hidden','true');
50
+ el.insertBefore(mark,el.firstChild);
51
+ for(var n=mark.nextSibling;n;n=n.nextSibling){
52
+ if(n.nodeType===3)n.nodeValue=n.nodeValue.replace(/^\s*[⟲⟳✓✗⚑⇩▸]\s*/,'');
53
+ }
54
+ }
55
+ }
56
+ if(mark){
57
+ if(mark.hasAttribute('data-mf-vector-icon')){
58
+ var fallback=mark.getAttribute('data-mf-icon-fallback')||'';
59
+ mark.removeAttribute('data-mf-vector-icon');mark.classList.remove('mfCinematicVectorIcon');
60
+ mark.textContent=fallback;
61
+ }
62
+ mark.classList.add('em');mark.setAttribute('data-icon',icon);
63
+ }
64
+ else el.setAttribute('data-icon',icon);
65
+ if(typeof cmdIconsRefresh==='function')cmdIconsRefresh(mark||el);
66
+ }
67
+ /* The shipped command atlas intentionally stops at its authored cells. These
68
+ small monochrome vectors complete the cinematic shell without pretending a
69
+ blank atlas reservation is finished art. They inherit button colour, stay
70
+ sharp at every DPR/text scale, and never replace a button's listener. */
71
+ var MF_CINEMATIC_VECTOR={
72
+ mail:'<rect x="3" y="5" width="18" height="14" rx="2"/><path d="m4 7 8 6 8-6"/>',
73
+ pause:'<rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/>',
74
+ tilt:'<path d="M3 18 8 9l4 5 4-7 5 11"/><path d="M4 21h16M7 4h10"/>',
75
+ feed:'<circle cx="5" cy="7" r="1"/><circle cx="5" cy="12" r="1"/><circle cx="5" cy="17" r="1"/><path d="M9 7h11M9 12h11M9 17h8"/>',
76
+ confirm:'<path d="m5 12 4 4L19 6"/><path d="M12 2 4 6v6c0 5 3 8 8 10 5-2 8-5 8-10V6z"/>',
77
+ build:'<path d="M4 20V9h9v11M13 12h7v8M7 12h3M7 15h3M7 18h3M16 15h2M16 18h2"/>',
78
+ buildings:'<path d="M3 20V10h6v10M9 20V5h7v15M16 20v-8h5v8M5 13h2M11 8h2M11 12h2M11 16h2M18 15h1"/>',
79
+ upgrade:'<path d="M12 3 6 9h4v7h4V9h4zM5 20h14"/>',
80
+ repeat:'<path d="M18 8a7 7 0 0 0-12-2L3 9M6 16a7 7 0 0 0 12 2l3-3"/><path d="M3 4v5h5M21 20v-5h-5"/>',
81
+ prev:'<path d="m15 5-7 7 7 7"/>',next:'<path d="m9 5 7 7-7 7"/>',
82
+ close:'<path d="m6 6 12 12M18 6 6 18"/>',
83
+ info:'<circle cx="12" cy="12" r="9"/><path d="M12 11v6M12 7h.01"/>',
84
+ warning:'<path d="M12 3 2.8 20h18.4zM12 9v5M12 17h.01"/>',
85
+ lock:'<rect x="5" y="10" width="14" height="11" rx="2"/><path d="M8 10V7a4 4 0 0 1 8 0v3"/>',
86
+ target:'<circle cx="12" cy="12" r="7"/><circle cx="12" cy="12" r="2"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3"/>',
87
+ fire:'<path d="M13 2c1 5-3 6-1 10 1-2 3-3 4-5 3 3 4 6 3 9a7 7 0 0 1-14 0c0-4 2-7 5-10 0 3 1 4 3 5"/>',
88
+ recharge:'<path d="M13 2 6 13h6l-1 9 7-12h-6z"/><circle cx="12" cy="12" r="10"/>',
89
+ flight:'<path d="m2 13 8-3 3-7 2 1-1 7 7 3v2l-8-1-4 5-2-1 2-5-7 1z"/>',
90
+ birth:'<path d="M12 21V10M12 14c-5 0-7-3-7-7 5 0 7 2 7 7ZM12 11c4 0 6-2 6-6-4 0-6 2-6 6Z"/>',
91
+ economy:'<path d="m12 3 7 5-3 10H8L5 8zM8 8h8M9 12h6"/>',
92
+ factory:'<path d="M3 21V10l6 3v-3l6 3V6h4v15zM6 17h2M11 17h2M16 17h2"/>',
93
+ naval:'<path d="m4 14 3-5h10l3 5-8 4zM3 20c2 1 4 1 6 0 2 1 4 1 6 0 2 1 4 1 6 0"/>',
94
+ shield:'<path d="M12 2 4 6v6c0 5 3 8 8 10 5-2 8-5 8-10V6zM8 12h8"/>',
95
+ wall:'<path d="M3 7h5v4h4V7h5v4h4v10H3zM8 21v-5h8v5"/>',
96
+ tech:'<circle cx="12" cy="12" r="2"/><ellipse cx="12" cy="12" rx="9" ry="4"/><ellipse cx="12" cy="12" rx="4" ry="9" transform="rotate(45 12 12)"/>',
97
+ support:'<circle cx="12" cy="12" r="9"/><path d="M12 7v10M7 12h10"/>',
98
+ infantry:'<path d="M8 9a4 4 0 1 1 8 0M7 21v-5a5 5 0 0 1 10 0v5M5 21h14"/>',
99
+ vehicle:'<path d="M3 15h18v4H3zM6 15l2-6h8l3 6M8 19v2M16 19v2"/>',
100
+ antitank:'<path d="m4 17 11-11 3 3L7 20H4zM14 5l2-2 5 5-2 2"/>',
101
+ explosion:'<path d="m12 2 2 6 5-3-2 6 5 1-6 3 3 5-6-2-1 4-2-5-6 2 3-5-5-2 6-2-3-5 5 2z"/>',
102
+ artillery:'<path d="M4 17h10l5-5-2-2-6 4H4zM6 17v3M12 17v3M4 20h10"/>',
103
+ antiair:'<path d="M12 3v18M3 12h18M6 6l12 12M18 6 6 18"/><circle cx="12" cy="12" r="7"/>',
104
+ air:'<path d="m2 13 8-3 2-7 2 1v7l8 3v2l-8-1-3 5-2-1 1-5-8 1z"/>',
105
+ experimental:'<path d="m12 2 3 6 7 1-5 5 1 7-6-3-6 3 1-7-5-5 7-1z"/>',
106
+ ability:'<circle cx="12" cy="12" r="3"/><path d="M12 2v5M12 17v5M2 12h5M17 12h5M5 5l3 3M16 16l3 3M19 5l-3 3M8 16l-3 3"/>',
107
+ more:'<circle cx="5" cy="12" r="1.5" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.5" fill="currentColor" stroke="none"/><circle cx="19" cy="12" r="1.5" fill="currentColor" stroke="none"/>',
108
+ salvage:'<path d="m8 4 4-2 4 2M5 8l-3 4 3 4M19 8l3 4-3 4M8 20l4 2 4-2"/><path d="M8 4h8l3 4M5 8l3 12h8l3-4"/>',
109
+ stealth:'<path d="M3 12s3-5 9-5 9 5 9 5-3 5-9 5-9-5-9-5Z"/><path d="m4 4 16 16M10 10a3 3 0 0 0 4 4"/>',
110
+ deploy:'<path d="M12 3v11M8 10l4 4 4-4M4 18h16v3H4z"/>',
111
+ invalid:'<circle cx="12" cy="12" r="9"/><path d="m6 6 12 12"/>',
112
+ clock:'<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>',
113
+ rank:'<path d="m5 15 7-9 7 9-7 5zM8 15l4-5 4 5"/>',
114
+ domination:'<path d="M5 21V4M6 5h11l-2 4 2 4H6"/>',
115
+ annihilation:'<path d="M8 18v3M16 18v3M7 14a5 5 0 1 1 10 0v4H7zM9 13h.01M15 13h.01M11 17h2"/>',
116
+ purge:'<path d="M12 5v14M6 8l6 4 6-4M6 16l6-4 6 4M5 5l3 3M19 5l-3 3M5 19l3-3M19 19l-3-3"/>',
117
+ dust:'<path d="M3 8h12c3 0 3-4 0-4M3 12h17c3 0 3 4 0 4M3 16h8"/>',
118
+ storm:'<path d="M4 15a5 5 0 0 1 5-5 6 6 0 0 1 11 2 4 4 0 0 1-1 7H6a4 4 0 0 1-2-4Z"/><path d="m12 14-2 5h3l-2 4"/>',
119
+ calm:'<circle cx="12" cy="12" r="4"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3M5 5l2 2M17 17l2 2M19 5l-2 2M7 17l-2 2"/>',
120
+ spores:'<circle cx="8" cy="9" r="3"/><circle cx="15" cy="7" r="2"/><circle cx="16" cy="15" r="4"/><circle cx="7" cy="17" r="1.5"/>',
121
+ heat:'<path d="M8 19c-3-3 1-5 0-8 3 1 3 3 4 4 1-4-1-7 3-11 0 5 4 6 3 11-1 4-4 6-7 6"/>',
122
+ collapse:'<path d="M3 19 8 5h8l5 14M8 5l4 6 4-6M3 19h18M9 19l3-5 3 5"/>',
123
+ eruption:'<path d="m5 20 4-9h6l4 9M8 14h8M12 9V3M8 8 6 5M16 8l2-3"/>',
124
+ meteor:'<path d="m4 4 8 8M8 2l7 7M2 8l7 7"/><circle cx="16" cy="16" r="5"/>',
125
+ squall:'<path d="M3 7h13c4 0 4-5 0-5M3 12h17M3 17h11c4 0 4 5 0 5"/>',
126
+ whiteout:'<path d="M12 2v20M3 7l18 10M3 17 21 7M7 3l10 18M17 3 7 21"/>',
127
+ flood:'<path d="M3 8c3 2 6 2 9 0 3 2 6 2 9 0M3 13c3 2 6 2 9 0 3 2 6 2 9 0M3 18c3 2 6 2 9 0 3 2 6 2 9 0"/>',
128
+ solar:'<circle cx="12" cy="12" r="4"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3M5 5l2 2M17 17l2 2M19 5l-2 2M7 17l-2 2"/><path d="m9 13 3-5v4h3l-4 5v-4z"/>',
129
+ relic:'<path d="m12 2 7 5-2 12H7L5 7zM9 8h6M10 12h4M11 16h2"/>'
130
+ };
131
+ /* Unit Intel owns authoritative text labels while hud.js intentionally keeps
132
+ portable glyph fallbacks. Resolve art from those stable labels, never from
133
+ a platform-dependent emoji rendering, so Android, Safari and desktop show
134
+ the same semantic vector without weakening the no-art fallback. */
135
+ var MF_CINEMATIC_INTEL_CHIP_VECTOR={
136
+ 'RESOURCE FORECAST':'economy',ECONOMY:'economy',PRODUCTION:'factory',NAVAL:'naval',DEFENCE:'shield',
137
+ FORTIFICATION:'wall',TECH:'tech',SUPPORT:'support',SUPERWEAPON:'target',INFANTRY:'infantry',ARMOUR:'vehicle',
138
+ 'ANTI-TANK':'antitank','CROWD CONTROL':'explosion',ARTILLERY:'artillery','ANTI-AIR':'antiair',AIRCRAFT:'air',
139
+ EXPERIMENTAL:'experimental','AIR + GROUND':'target',GROUND:'target',AIR:'air',KINETIC:'target',BEAM:'recharge',
140
+ CLAWS:'warning',EXPLOSIVE:'explosion',GAUSS:'antitank',INCENDIARY:'fire',SONIC:'ability',ION:'recharge','—':'invalid',
141
+ EXTREME:'target',LONG:'target',MEDIUM:'target',CLOSE:'target','LIGHT ARMOR':'shield','MEDIUM ARMOR':'shield',
142
+ 'HEAVY ARMOR':'shield',RECON:'target',GHOST:'stealth',RADAR:'target',DETECT:'target'
143
+ };
144
+ var MF_CINEMATIC_INTEL_MATCH_VECTOR={
145
+ LIGHT:'infantry',MEDIUM:'vehicle',HEAVY:'experimental',KINETIC:'target',BEAM:'recharge',CLAWS:'warning',
146
+ EXPLOSIVE:'explosion',GAUSS:'antitank',INCENDIARY:'fire',SONIC:'ability',ION:'recharge'
147
+ };
148
+ function mfCinematicMarkVector(el,icon){
149
+ if(!el||!MF_CINEMATIC_VECTOR[icon])return;
150
+ /* The rank badge is rewritten by hudTxt when account rank changes. Own the
151
+ existing badge directly so that write destroys only this vector and the
152
+ observer can restore it; injecting a child left the new medal beside it. */
153
+ var direct=el.id==='heroRankEm';
154
+ var mark=direct?el:(el.classList&&el.classList.contains('em')?el:el.querySelector&&el.querySelector('.em'));
155
+ if(!mark){
156
+ if(el.tagName==='SPAN')mark=el;
157
+ else{
158
+ mark=document.createElement('span');mark.className='em mfCinematicInjectedIcon';mark.setAttribute('aria-hidden','true');
159
+ el.insertBefore(mark,el.firstChild);
160
+ for(var n=mark.nextSibling;n;n=n.nextSibling){
161
+ if(n.nodeType===3)n.nodeValue=n.nodeValue.replace(/^\s*(?:✉|⏸|⛰|☷|✓|⬆|‹|›|×|⚠|ⓘ|🔒|🐛|◈|☠|☄|⚡|♒)\s*/u,'');
162
+ }
163
+ }
164
+ }
165
+ if(mark.getAttribute('data-mf-vector-icon')===icon&&mark.firstElementChild){
166
+ mark.removeAttribute('data-icon');mark.removeAttribute('data-icon-ready');return;
167
+ }
168
+ if(!mark.hasAttribute('data-mf-icon-fallback'))mark.setAttribute('data-mf-icon-fallback',(mark.textContent||'').trim());
169
+ mark.classList.add('em','mfCinematicVectorIcon');mark.setAttribute('data-mf-vector-icon',icon);
170
+ mark.removeAttribute('data-icon');mark.removeAttribute('data-icon-ready');mark.setAttribute('aria-hidden','true');
171
+ mark.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true">'+MF_CINEMATIC_VECTOR[icon]+'</svg>';
172
+ }
173
+ function mfCinematicStripLeadingGlyph(el,re){
174
+ if(!el)return;
175
+ for(var i=0;i<el.childNodes.length;i++){
176
+ var node=el.childNodes[i];
177
+ if(node.nodeType===3)node.nodeValue=node.nodeValue.replace(re,'');
178
+ }
179
+ }
180
+ function mfCinematicIntelOwnText(el){
181
+ var text='';if(!el)return text;
182
+ for(var i=0;i<el.childNodes.length;i++)if(el.childNodes[i].nodeType===3)text+=el.childNodes[i].nodeValue;
183
+ return text.trim().toUpperCase();
184
+ }
185
+ function mfCinematicIntelLead(el){
186
+ if(!el)return null;
187
+ var mark=el.querySelector('.mfCinematicIntelLead');if(mark)return mark;
188
+ var fallback='';
189
+ for(var i=0;i<el.childNodes.length;i++){
190
+ var node=el.childNodes[i];if(node.nodeType!==3)continue;
191
+ var found=node.nodeValue.match(/^\s*([✦⛭⌾◆⚔▰◇ϟ⟲☄⚠🔒✓⌁])\s*/u);
192
+ if(found){fallback=found[1];node.nodeValue=node.nodeValue.slice(found[0].length);break;}
193
+ }
194
+ mark=document.createElement('span');mark.className='em mfCinematicIntelLead';mark.setAttribute('aria-hidden','true');
195
+ mark.textContent=fallback;el.insertBefore(mark,el.firstChild);return mark;
196
+ }
197
+ function mfCinematicDecorateUnitIntel(){
198
+ var card=document.getElementById('unitCard');if(!card)return;
199
+ var firstChip=card.querySelector('.ucChips .ucChip'),role=card.querySelector('.ucRoleIcon');
200
+ if(role){
201
+ var roleLabel=mfCinematicIntelOwnText(firstChip)||((card.querySelector('.ucHead b')||{}).textContent||'').trim().toUpperCase();
202
+ var roleVector=MF_CINEMATIC_INTEL_CHIP_VECTOR[roleLabel]||'info';
203
+ mfCinematicMarkVector(role,roleVector);
204
+ }
205
+ card.querySelectorAll('.ucChips .ucChip').forEach(function(chip){
206
+ var mark=chip.querySelector('i'),label=mfCinematicIntelOwnText(chip);if(!mark||!label)return;
207
+ var chipVector=MF_CINEMATIC_INTEL_CHIP_VECTOR[label]||(/\bHP$/.test(label)?'shield':'info');
208
+ mark.classList.add('em');mfCinematicMarkVector(mark,chipVector);
209
+ });
210
+ card.querySelectorAll('.ucMatchChip').forEach(function(chip){
211
+ var mark=chip.querySelector('i'),label=((chip.querySelector('b')||{}).textContent||'').trim().toUpperCase();
212
+ if(!mark||!label)return;
213
+ var matchVector=MF_CINEMATIC_INTEL_MATCH_VECTOR[label]||'target';
214
+ mark.classList.add('em');mfCinematicMarkVector(mark,matchVector);
215
+ });
216
+ card.querySelectorAll('.ucCounter.caution,.ucCounter .caution').forEach(function(line){
217
+ var label=(line.textContent||'').trim().toUpperCase();
218
+ var cautionVector=/LOCK|RESEARCH/.test(label)?'lock':/BARRAGE/.test(label)?'artillery':
219
+ /DEPENDENC/.test(label)?'tech':/ACTIVE/.test(label)?'ability':'warning';
220
+ mfCinematicMarkVector(mfCinematicIntelLead(line),cautionVector);
221
+ });
222
+ card.querySelectorAll('.ucCounter>span:not(.caution)').forEach(function(line){
223
+ if(/PURPOSE/.test(line.textContent||''))mfCinematicMarkVector(mfCinematicIntelLead(line),'confirm');
224
+ });
225
+ }
226
+ function mfCinematicRestoreLegacyGoalCopy(){
227
+ var goal=document.getElementById('goalBar');if(!goal)return;
228
+ var legacy=goal.querySelectorAll('.hudIntelChip[data-mf-vector-icon]');
229
+ if(!legacy.length)return;
230
+ legacy.forEach(function(chip){
231
+ var fallback=chip.getAttribute('data-mf-icon-fallback')||'';
232
+ chip.removeAttribute('data-mf-vector-icon');chip.removeAttribute('data-mf-icon-fallback');
233
+ chip.removeAttribute('data-icon');chip.removeAttribute('data-icon-ready');chip.removeAttribute('aria-hidden');
234
+ chip.classList.remove('em','mfCinematicVectorIcon');
235
+ if(fallback)chip.textContent=fallback;
236
+ });
237
+ /* An OTA takeover may replace this script without reloading the match.
238
+ The former whole-chip vector destroyed rich FIRST CONTACT/clock markup;
239
+ invalidate hud.js' HTML cache so its next normal HUD pass restores the
240
+ authoritative copy before this decorator adds child-only icons. */
241
+ goal._mfH=null;
242
+ }
243
+ function mfCinematicGoalIcon(chip){
244
+ if(!chip)return null;
245
+ var mark=chip.querySelector('.mfCinematicGoalIcon');
246
+ if(!mark){
247
+ /* hud.js still provides glyph fallbacks. Remove only that leading text
248
+ node; mission, enemy and clock copy must remain in the status chip. */
249
+ mfCinematicStripLeadingGlyph(chip,/^\s*[◈☠🐛]\s*/u);
250
+ mark=document.createElement('span');mark.className='em mfCinematicGoalIcon';
251
+ mark.setAttribute('aria-hidden','true');chip.insertBefore(mark,chip.firstChild);
252
+ }
253
+ return mark;
254
+ }
255
+ function mfCinematicDecorateVectorIcons(){
256
+ var controls={inboxHudBtn:'mail',menuBtn:'pause',tiltBtn:'tilt',noticeLogBtn:'feed',placeOk:'confirm',
257
+ buildBtn:'build',upBtn:'upgrade',repeatBtn:'repeat',prodPrev:'prev',prodNext:'next',heroRankEm:'rank'};
258
+ for(var id in controls)mfCinematicMarkVector(document.getElementById(id),controls[id]);
259
+ mfCinematicMarkVector(document.querySelector('#hudDeckTabs [data-deck="buildings"] span'),'buildings');
260
+ mfCinematicMarkVector(document.querySelector('#hudDeckTabs [data-deck="abilities"] span'),'ability');
261
+ document.querySelectorAll('#mfCinematicContext .mfPanelChrome button,#mfNoticeHistory header button').forEach(function(el){mfCinematicMarkVector(el,'close');});
262
+ var category={ECONOMY:'economy',PRODUCTION:'factory',NAVAL:'naval',DEFENCE:'shield',FORTIFICATION:'wall',TECH:'tech',SUPPORT:'support',SUPERWEAPON:'target',
263
+ INFANTRY:'infantry',ARMOUR:'vehicle','ANTI-TANK':'antitank','CROWD CONTROL':'explosion',ARTILLERY:'artillery','ANTI-AIR':'antiair',AIRCRAFT:'air',
264
+ EXPERIMENTAL:'experimental',HERO:'experimental',AIRLIFT:'flight',MASSFLESH:'birth'};
265
+ document.querySelectorAll('#buildTabs button,#prodTabs button').forEach(function(btn){
266
+ var label='';for(var i=0;i<btn.childNodes.length;i++)if(btn.childNodes[i].nodeType===3)label+=btn.childNodes[i].nodeValue;
267
+ label=label.trim().toUpperCase();var icon=category[label];
268
+ if(icon)mfCinematicMarkVector(btn.querySelector('.tEm')||btn,icon);
269
+ });
270
+ }
271
+ function mfCinematicSyncModeIcon(){
272
+ var mark=document.getElementById('modeEm'),label=document.getElementById('modeNm');if(!mark)return;
273
+ var modes={MOBILE:'move',MOVE:'move',GUARD:'guard',SURVEY:'ping',MINE:'resource',HOLD:'hold',PATROL:'patrol'};
274
+ var icon=modes[((label&&label.textContent)||'').trim().toUpperCase()];
275
+ if(icon)mfCinematicMarkIcon(mark,icon);
276
+ else{
277
+ mark.removeAttribute('data-icon');mark.removeAttribute('data-icon-ready');
278
+ if(typeof cmdIconsRefresh==='function')cmdIconsRefresh(mark);
279
+ }
280
+ }
281
+ function mfCinematicDecorateHotSlots(){
282
+ document.querySelectorAll('#hotSlots .hotSlot,#hotUtilityPanel .hotUtility').forEach(function(btn){
283
+ var label=((btn.querySelector('.hNm')||{}).textContent||'').trim().toUpperCase();
284
+ var mark=btn.querySelector('.hEm');if(!mark||!label)return;
285
+ var atlas=label.indexOf('REPAIR')>=0||label.indexOf('MEND')>=0?'repair':
286
+ label.indexOf('UNLOAD')>=0?'unload':label==='GUARD'?'guard':
287
+ (label==='MOBILE'||label==='MOVE')?'move':label==='HOLD'?'hold':label==='PATROL'?'patrol':
288
+ label==='MINE'?'resource':label==='SURVEY'?'ping':'';
289
+ if(atlas){mfCinematicMarkIcon(mark,atlas);return;}
290
+ var vector=label==='BUILD'?'build':label.indexOf('SALVAGE')>=0?'salvage':label.indexOf('TAKE FLIGHT')>=0?'flight':
291
+ label.indexOf('BIRTH')>=0?'birth':label==='UTILITY'?'more':label.indexOf('BLAST')>=0?'explosion':
292
+ (label.indexOf('SURGE')>=0||label==='EMP')?'recharge':label.indexOf('LANCE')>=0?'target':
293
+ label.indexOf('BARRAGE')>=0||label==='SIEGE'?'artillery':label==='ASSIST'?'support':
294
+ label==='GHOST'?'stealth':label.indexOf('SUPPRESS')>=0?'target':label==='PRIMARY'?'target':
295
+ label==='SECONDARY'?'fire':label.indexOf('SIGNATURE')>=0?'ability':label==='JUMP'?'flight':
296
+ label.indexOf('DOCTRINE')>=0?'tech':'';
297
+ if(vector)mfCinematicMarkVector(mark,vector);
298
+ });
299
+ }
300
+ function mfCinematicDecorateStateIcons(){
301
+ ['atkAlert','waveAlert','mfMassAlert'].forEach(function(id){mfCinematicMarkVector(document.getElementById(id),'warning');});
302
+ document.querySelectorAll('.selIntelBtn,.cardIntel').forEach(function(el){mfCinematicMarkVector(el,'info');});
303
+ document.querySelectorAll('#unitCard .ucClose').forEach(function(el){mfCinematicMarkVector(el,'close');});
304
+ mfCinematicDecorateUnitIntel();
305
+ var priority=document.getElementById('bp_prio');if(priority)mfCinematicMarkVector(priority,'target');
306
+ ['upBtn','bp_up'].forEach(function(id){
307
+ var el=document.getElementById(id);if(!el)return;
308
+ mfCinematicMarkVector(el,/LOCK|TECH|🔒/.test(el.textContent||'')?'lock':'upgrade');
309
+ });
310
+ var fire=document.getElementById('bp_fire');if(fire)mfCinematicMarkVector(fire,/CHARG|NEEDS|ENERGY/.test(fire.textContent||'')?'recharge':'fire');
311
+ var mass=document.getElementById('mfMassActionBtn');if(mass)mfCinematicMarkVector(mass,/BIRTH/.test(mass.textContent||'')?'birth':'flight');
312
+ var deploy=document.getElementById('deployBtn');if(deploy){
313
+ /* Old HTML and state writers prefix this authoritative button with an
314
+ anchor. Strip that fallback on every pass before choosing the vector;
315
+ otherwise a later label write can render ⚓ beside the valid icon. */
316
+ mfCinematicStripLeadingGlyph(deploy,/^\s*[⚓⛔]\s*(?:\u00a0\s*)*/u);
317
+ mfCinematicMarkVector(deploy,/INVALID|BLOCK|NO |⛔/.test(deploy.textContent||'')?'invalid':'deploy');
318
+ }
319
+ var meter=document.getElementById('infMeter');if(meter)mfCinematicMarkVector(meter,'purge');
320
+ var goal=document.getElementById('goalBar');if(goal){
321
+ goal.querySelectorAll('.hudIntelChip').forEach(function(chip){
322
+ if(chip.classList.contains('contact'))mfCinematicMarkVector(mfCinematicGoalIcon(chip),'target');
323
+ else if(chip.classList.contains('time'))mfCinematicMarkVector(mfCinematicGoalIcon(chip),'clock');
324
+ else{
325
+ var t=(chip.textContent||'').toUpperCase(),key=/HIVE|BUG|PURGE/.test(t)?'purge':/HOLD|NODE|TERRITORY/.test(t)?'domination':/SURVIV/.test(t)?'shield':'annihilation';
326
+ mfCinematicMarkVector(mfCinematicGoalIcon(chip),key);
327
+ }
328
+ });
329
+ }
330
+ var haz=document.getElementById('hazChip'),hazName=haz&&haz.querySelector('.hazNm'),hazMark=haz&&haz.querySelector('.hazEm');
331
+ if(hazName&&hazMark){
332
+ var h=(hazName.textContent||'').toUpperCase(),hazards=/DUST|SAND/.test(h)?'dust':/THUNDER|STORM/.test(h)?'storm':/CALM|CLEAR/.test(h)?'calm':
333
+ /SPORE/.test(h)?'spores':/HEAT|FIRE/.test(h)?'heat':/COLLAPSE|QUAKE/.test(h)?'collapse':/ERUPT|VOLCAN/.test(h)?'eruption':
334
+ /METEOR/.test(h)?'meteor':/SQUALL|WIND/.test(h)?'squall':/WHITE|BLIZZARD|SNOW/.test(h)?'whiteout':/FLOOD|RAIN/.test(h)?'flood':
335
+ /SOLAR|SUN/.test(h)?'solar':/RELIC/.test(h)?'relic':'warning';
336
+ mfCinematicMarkVector(hazMark,hazards);
337
+ }
338
+ mfCinematicDecorateHotSlots();
339
+ }
340
+ function mfCinematicDecorateCommandIcons(){
341
+ var deck={orders:'attack',platoons:'group',view:'minimap'};
342
+ for(var key in deck)mfCinematicMarkIcon(document.querySelector('#hudDeckTabs [data-deck="'+key+'"] span'),deck[key]);
343
+ var controls={armyBtn:'group',idleBuilderBtn:'repair',boxBtn:'selectall',stopBtn:'stop',
344
+ rotL:'patrol',rotR:'patrol',zoomIn:'zoomin',zoomOut:'zoomout',queueBtn:'waypoint',mfUnloadBtn:'unload',
345
+ rallyBtn:'rally',placeRotL:'patrol',placeRotR:'patrol',placeNo:'stop',
346
+ bp_repair:'repair',bp_sell:'delete'};
347
+ for(var id in controls)mfCinematicMarkIcon(document.getElementById(id),controls[id]);
348
+ }
349
+ function mfCinematicEnsureStructure(){
350
+ var body=document.body;
351
+ body.classList.add('mf-cinematic-hud');
352
+ body.setAttribute('data-mf-hud','cinematic-v1');
353
+ var top=mfCinematicWrap('mfCinematicTopRail','topbar',['heroBar','topbar'],'top-rail','Commander and battle resources');
354
+ var hero=mfCinematicSetRole(document.getElementById('heroBar'),'commander-profile');
355
+ var resources=mfCinematicSetRole(document.getElementById('topbar'),'resource-rail');
356
+ if(top)top.classList.add('mfCinematicRail');
357
+ if(resources){
358
+ if(!resources.getAttribute('role'))resources.setAttribute('role','region');
359
+ if(!resources.getAttribute('aria-label'))resources.setAttribute('aria-label','Battle resources and controls');
360
+ var tiles=[
361
+ {el:document.getElementById('massV'),label:'MASS'},
362
+ {el:document.getElementById('enV'),label:'ENERGY'},
363
+ {el:document.getElementById('unitRes'),label:'COMMAND'}
364
+ ];
365
+ for(var i=0;i<tiles.length;i++){
366
+ var tile=tiles[i].el;
367
+ if(tile&&tile.id!=='unitRes')tile=tile.parentElement;
368
+ if(!tile)continue;
369
+ tile.classList.add('mfCinematicResource');tile.setAttribute('data-label',tiles[i].label);
370
+ tile.setAttribute('data-mf-resource',tiles[i].label.toLowerCase());
371
+ if(!tile.getAttribute('role'))tile.setAttribute('role','group');
372
+ if(!tile.getAttribute('aria-label'))tile.setAttribute('aria-label',tiles[i].label+' resource');
373
+ }
374
+ }
375
+ if(hero)hero.classList.add('mfCinematicCommander');
376
+
377
+ var context=mfCinematicWrap('mfCinematicContext','buildMenu',['buildMenu','prodMenu','bldMenu2'],'context','Context controls');
378
+ if(context)context.classList.add('mfCinematicContext');
379
+ mfCinematicLabelPanel(document.getElementById('buildMenu'),'Structures','build');
380
+ mfCinematicLabelPanel(document.getElementById('prodMenu'),'Production','production');
381
+ mfCinematicLabelPanel(document.getElementById('bldMenu2'),'Structure control','structure');
382
+
383
+ var cmd=mfCinematicSetRole(document.getElementById('cmdbar'),'command-dock');
384
+ if(cmd){
385
+ cmd.classList.add('mfCinematicCommandDock');
386
+ if(!cmd.getAttribute('role'))cmd.setAttribute('role','region');
387
+ if(!cmd.getAttribute('aria-label'))cmd.setAttribute('aria-label','Tactical command dock');
388
+ }
389
+ var minimapWrap=mfCinematicSetRole(document.getElementById('minimapWrap'),'minimap-receiver');
390
+ if(minimapWrap){
391
+ if(!minimapWrap.getAttribute('role'))minimapWrap.setAttribute('role','region');
392
+ if(!minimapWrap.getAttribute('aria-label'))minimapWrap.setAttribute('aria-label','Tactical minimap and command transmissions');
393
+ }
394
+ var minimap=mfCinematicSetRole(document.getElementById('minimap'),'minimap-command');
395
+ if(minimap&&!minimap.getAttribute('aria-label'))minimap.setAttribute('aria-label','Tactical minimap');
396
+ mfCinematicSetRole(document.getElementById('cmdrTx'),'command-transmission');
397
+ mfCinematicSetRole(document.getElementById('hudDeckTabs'),'deck-tabs');
398
+ mfCinematicSetRole(document.getElementById('goalBar'),'mission-status');
399
+ mfCinematicSetRole(document.getElementById('goalDetailBtn'),'mission-command');
400
+ mfCinematicSetRole(document.getElementById('camRow'),'view-deck');
401
+ mfCinematicSetRole(document.getElementById('tacRow'),'orders-deck');
402
+ mfCinematicSetRole(document.getElementById('hotSlots'),'abilities-deck');
403
+ mfCinematicSetRole(document.getElementById('primaryRow'),'primary-orders');
404
+ document.querySelectorAll('#hudDeckTabs .hudDeckBtn').forEach(function(tab){mfCinematicSetRole(tab,'deck-command');});
405
+ var authorityRoles={
406
+ inboxHudBtn:'inbox-command',spdBtn:'speed-command',menuBtn:'pause-command',
407
+ armyBtn:'select-army-command',idleBuilderBtn:'select-idle-builders-command',boxBtn:'box-select-command',
408
+ stopBtn:'stop-command',buildBtn:'build-command',patrolBtn:'patrol-command',holdBtn:'hold-command',
409
+ formBtn:'formation-command',moveBtn:'attack-move-command',clearBtn:'clear-selection-command',
410
+ rotL:'rotate-left-command',zoomIn:'zoom-in-command',tiltBtn:'tilt-command',zoomOut:'zoom-out-command',rotR:'rotate-right-command',
411
+ queueBtn:'waypoint-command',rallyBtn:'rally-command',repeatBtn:'repeat-command',
412
+ upBtn:'production-upgrade',bp_up:'structure-upgrade',noticeLogBtn:'event-feed-control',
413
+ mfNoticeDock:'event-feed-dock',mfNoticeHistory:'event-feed',hotUtilityPanel:'utility-drawer'};
414
+ for(var authorityId in authorityRoles)mfCinematicSetRole(document.getElementById(authorityId),authorityRoles[authorityId]);
415
+ var heroRow=mfCinematicSetRole(document.getElementById('heroRow'),'ability-authority');
416
+ if(heroRow)heroRow.classList.add('mfCinematicAuthoritySource');
417
+
418
+ var groups=mfCinematicWrap('mfCinematicGroupPalette','grpRow',['grpRow'],'group-palette','Match command groups');
419
+ var grpRow=mfCinematicSetRole(document.getElementById('grpRow'),'match-command-palette');
420
+ if(groups)groups.classList.add('mfCinematicGroupPalette');
421
+ if(grpRow){
422
+ grpRow.setAttribute('data-mf-persistence','match-memory');
423
+ for(var g=1;g<=4;g++){
424
+ var btn=document.getElementById('grpBtn'+g);
425
+ if(btn){btn.classList.add('mfCinematicGroupSlot');btn.setAttribute('data-mf-group-slot',String(g));}
426
+ }
427
+ }
428
+ }
429
+ function mfCinematicSyncContext(){
430
+ var context=document.getElementById('mfCinematicContext'),body=document.body;
431
+ var surfaces=[['buildMenu','build'],['prodMenu','production'],['bldMenu2','structure']],active='none';
432
+ for(var i=0;i<surfaces.length;i++){
433
+ var panel=document.getElementById(surfaces[i][0]);
434
+ var on=!!(panel&&!panel.hidden&&panel.style.display==='block');
435
+ if(on&&active==='none')active=surfaces[i][1];
436
+ if(panel){
437
+ panel.classList.toggle('mfCinematicSurfaceActive',on);
438
+ panel.setAttribute('data-mf-active',on?'true':'false');
439
+ }
440
+ }
441
+ if(context)context.setAttribute('data-active-surface',active);
442
+ body.setAttribute('data-mf-hud-surface',active);
443
+ body.classList.toggle('mfCinematicContextOpen',active!=='none');
444
+ }
445
+ function mfCinematicSyncDeck(){
446
+ var tabs=document.getElementById('hudDeckTabs');if(!tabs)return;
447
+ var buttons=tabs.querySelectorAll('[data-deck]'),active='orders';
448
+ for(var i=0;i<buttons.length;i++){
449
+ var on=buttons[i].getAttribute('aria-selected')==='true'||buttons[i].classList.contains('on');
450
+ buttons[i].classList.toggle('mfCinematicDeckActive',on);
451
+ buttons[i].setAttribute('data-mf-active',on?'true':'false');
452
+ if(on)active=buttons[i].getAttribute('data-deck')||active;
453
+ }
454
+ tabs.setAttribute('data-active-deck',active);
455
+ document.body.setAttribute('data-mf-hud-deck',active);
456
+ }
457
+ function mfCinematicSyncService(){
458
+ var row=document.getElementById('mfBldServiceActions'),repair=document.getElementById('bp_repair');
459
+ var recycle=document.getElementById('bp_sell'),panels=[document.getElementById('prodMenu'),document.getElementById('bldMenu2')];
460
+ if(row){
461
+ row.classList.add('mfCinematicServiceStrip');
462
+ row.setAttribute('data-mf-hud-role','service-controls');
463
+ row.setAttribute('data-mf-service-state',repair&&repair.getAttribute('data-state')||'unavailable');
464
+ row.setAttribute('data-mf-recycle-armed',recycle&&recycle.getAttribute('data-armed')||'false');
465
+ }
466
+ if(repair){repair.classList.add('mfCinematicServiceRepair');repair.setAttribute('data-mf-hud-role','service-repair');}
467
+ if(recycle){recycle.classList.add('mfCinematicServiceRecycle');recycle.setAttribute('data-mf-hud-role','service-recycle');}
468
+ for(var i=0;i<panels.length;i++){
469
+ if(!panels[i])continue;
470
+ panels[i].removeAttribute('data-mf-service-state');
471
+ if(row&&row.parentElement===panels[i])panels[i].setAttribute('data-mf-service-state',row.getAttribute('data-mf-service-state'));
472
+ }
473
+ }
474
+ function mfCinematicSyncTransmission(){
475
+ var tx=document.getElementById('cmdrTx'),who=document.getElementById('cmdrTxWho');if(!tx)return;
476
+ /* Commander portraits belong to their own faction. Only the neutral UGA
477
+ guide may put UGA in the shared receiver chrome. */
478
+ var link=who&&String(who.textContent||'').trim().toUpperCase()==='KEEL'?'uga-keel':'command';
479
+ if(tx.getAttribute('data-mf-link')!==link)tx.setAttribute('data-mf-link',link);
480
+ }
481
+ function mfCinematicDecorateBaseFinder(){
482
+ var panel=document.getElementById('baseFinder');if(!panel)return;
483
+ panel.classList.add('mfCinematicDecorated');panel.setAttribute('data-mf-hud-role','base-finder');
484
+ var tabs=panel.querySelector('.baseFindTabs');if(tabs)tabs.setAttribute('data-mf-hud-role','base-finder-tabs');
485
+ mfCinematicMarkVector(panel.querySelector('.baseFindBack'),'prev');
486
+ var finderIcons={all:'buildings',economy:'economy',production:'factory',defence:'shield',support:'support'};
487
+ panel.querySelectorAll('.baseFindTabs [data-f]').forEach(function(btn){
488
+ mfCinematicMarkVector(btn.querySelector('span')||btn,finderIcons[btn.getAttribute('data-f')]||'buildings');
489
+ });
490
+ var cards=panel.querySelectorAll('.baseFindCard:not(.mfCinematicDecorated)');
491
+ for(var i=0;i<cards.length;i++){
492
+ var card=cards[i],type=card.getAttribute('data-btype'),art=card.querySelector('.baseFindIcon'),copy=card.querySelector('.baseFindCopy');
493
+ card.classList.add('mfCinematicDecorated');card.setAttribute('data-mf-hud-role','base-building-card');
494
+ if(copy)copy.classList.add('mfBaseFinderCopy');
495
+ if(!art)continue;
496
+ art.classList.add('mfBaseFinderArt');art.setAttribute('aria-hidden','true');
497
+ if(typeof bldIconEl!=='function'||!type)continue;
498
+ try{
499
+ var icon=bldIconEl(type,52,typeof playerKitKey==='function'?playerKitKey():undefined);
500
+ if(icon){icon.classList.add('mfBaseFinderModel');art.replaceChildren(icon);}
501
+ }catch(e){/* Keep the authored emoji when runtime art is unavailable. */}
502
+ }
503
+ }
504
+ var mfCinematicSyncFrame=0,mfCinematicWatch=null,mfCinematicFinderSeen=new WeakSet(),mfCinematicIconSeen=new WeakSet(),
505
+ mfCinematicCategoryRows=[];
506
+ function mfCinematicUpdateCategoryOverflow(row){
507
+ if(!row)return;
508
+ var overflow=row.clientWidth>0&&row.scrollWidth>row.clientWidth+2,state='none';
509
+ if(overflow){
510
+ var atStart=row.scrollLeft<=2,atEnd=row.scrollLeft+row.clientWidth>=row.scrollWidth-2;
511
+ state=atStart?'start':atEnd?'end':'middle';
512
+ }
513
+ row.setAttribute('data-mf-overflow',state);
514
+ if(!row.getAttribute('aria-label'))row.setAttribute('aria-label',row.id==='prodTabs'?'Production categories':'Structure categories');
515
+ }
516
+ function mfCinematicSyncCategoryOverflow(){
517
+ ['buildTabs','prodTabs'].forEach(function(id){
518
+ var row=document.getElementById(id);if(!row)return;
519
+ if(!row._mfCinematicOverflowHandler){
520
+ row._mfCinematicOverflowHandler=function(){mfCinematicUpdateCategoryOverflow(row);};
521
+ row.addEventListener('scroll',row._mfCinematicOverflowHandler,{passive:true});
522
+ mfCinematicCategoryRows.push(row);
523
+ }
524
+ mfCinematicUpdateCategoryOverflow(row);
525
+ });
526
+ }
527
+ function mfCinematicObserveDynamic(){
528
+ var finder=document.getElementById('baseFinder');
529
+ if(!mfCinematicWatch||!finder||mfCinematicFinderSeen.has(finder))return;
530
+ mfCinematicFinderSeen.add(finder);
531
+ mfCinematicWatch.observe(finder,{subtree:true,childList:true});
532
+ }
533
+ function mfCinematicObserveIconHosts(){
534
+ if(!mfCinematicWatch)return;
535
+ ['cmdbar','unitCard','selInfo','infMeter','goalBar','hazChip','atkAlert','waveAlert','mfMassAlert','deployBtn','consHud','heroRankEm','cmdrTx'].forEach(function(id){
536
+ var el=document.getElementById(id);if(!el||mfCinematicIconSeen.has(el))return;
537
+ mfCinematicIconSeen.add(el);mfCinematicWatch.observe(el,{subtree:true,childList:true,characterData:true});
538
+ });
539
+ }
540
+ function mfCinematicSync(){
541
+ mfCinematicSyncFrame=0;
542
+ mfCinematicEnsureStructure();mfCinematicSyncContext();mfCinematicSyncDeck();
543
+ mfCinematicSyncService();mfCinematicSyncTransmission();mfCinematicDecorateCommandIcons();mfCinematicDecorateVectorIcons();
544
+ mfCinematicSyncModeIcon();mfCinematicDecorateBaseFinder();mfCinematicDecorateStateIcons();mfCinematicSyncCategoryOverflow();
545
+ mfCinematicObserveDynamic();mfCinematicObserveIconHosts();
546
+ }
547
+ function mfCinematicQueueSync(){
548
+ if(!mfCinematicSyncFrame)mfCinematicSyncFrame=requestAnimationFrame(mfCinematicSync);
549
+ }
550
+ mfCinematicRestoreLegacyGoalCopy();mfCinematicEnsureStructure();mfCinematicSync();
551
+ mfCinematicWatch=new MutationObserver(mfCinematicQueueSync);
552
+ /* Body-wide subtree observation turns changing resource numerals into a
553
+ synthetic 60 Hz layout loop. Direct children catch the lazily appended
554
+ Base Finder; only the two small authority surfaces need deep observation. */
555
+ mfCinematicWatch.observe(document.body,{childList:true});
556
+ var mfCinematicContext=document.getElementById('mfCinematicContext');
557
+ if(mfCinematicContext)mfCinematicWatch.observe(mfCinematicContext,{subtree:true,childList:true,attributes:true,
558
+ attributeFilter:['style','class','hidden','data-state','data-armed']});
559
+ var mfCinematicDeckTabs=document.getElementById('hudDeckTabs');
560
+ if(mfCinematicDeckTabs)mfCinematicWatch.observe(mfCinematicDeckTabs,{subtree:true,attributes:true,
561
+ attributeFilter:['class','aria-selected','disabled']});
562
+ var mfCinematicModeBtn=document.getElementById('modeBtn');
563
+ if(mfCinematicModeBtn)mfCinematicWatch.observe(mfCinematicModeBtn,{subtree:true,childList:true,characterData:true});
564
+ mfCinematicObserveDynamic();
565
+ mfCinematicObserveIconHosts();
566
+ function mfCinematicAuthoritySnapshot(selector,role,optional){
567
+ var nodes=document.querySelectorAll(selector),node=nodes.length===1?nodes[0]:null;
568
+ var actual=node&&node.getAttribute('data-mf-hud-role')||'';
569
+ var one=nodes.length===1,roleOk=one&&actual===role;
570
+ return {selector:selector,count:nodes.length,duplicateCount:Math.max(0,nodes.length-1),one:one,
571
+ ownerId:node&&node.id||'',tag:node&&node.tagName||'',role:actual,roleOk:roleOk,optional:!!optional,
572
+ ok:optional&&nodes.length===0||one&&roleOk};
573
+ }
574
+ window.MFCinematicHud=Object.freeze({
575
+ sync:mfCinematicSync,
576
+ destroy:function(){
577
+ if(mfCinematicSyncFrame)cancelAnimationFrame(mfCinematicSyncFrame);
578
+ mfCinematicSyncFrame=0;
579
+ if(mfCinematicWatch)mfCinematicWatch.disconnect();
580
+ mfCinematicWatch=null;
581
+ for(var i=0;i<mfCinematicCategoryRows.length;i++){
582
+ var row=mfCinematicCategoryRows[i],handler=row&&row._mfCinematicOverflowHandler;
583
+ if(row&&handler){row.removeEventListener('scroll',handler);delete row._mfCinematicOverflowHandler;}
584
+ }
585
+ mfCinematicCategoryRows=[];
586
+ },
587
+ snapshot:function(){
588
+ var context=document.getElementById('mfCinematicContext'),tabs=document.getElementById('hudDeckTabs');
589
+ var authority={
590
+ inbox:mfCinematicAuthoritySnapshot('#inboxHudBtn','inbox-command',false),
591
+ speed:mfCinematicAuthoritySnapshot('#spdBtn','speed-command',false),
592
+ pause:mfCinematicAuthoritySnapshot('#menuBtn','pause-command',false),
593
+ minimap:mfCinematicAuthoritySnapshot('#minimap','minimap-command',false),
594
+ missionStatus:mfCinematicAuthoritySnapshot('#goalBar','mission-status',false),
595
+ missionAction:mfCinematicAuthoritySnapshot('#goalDetailBtn','mission-command',false),
596
+ deckTabs:mfCinematicAuthoritySnapshot('#hudDeckTabs','deck-tabs',false),
597
+ ordersTab:mfCinematicAuthoritySnapshot('#hudDeckTabs .hudDeckBtn[data-deck="orders"]','deck-command',false),
598
+ platoonsTab:mfCinematicAuthoritySnapshot('#hudDeckTabs .hudDeckBtn[data-deck="platoons"]','deck-command',false),
599
+ buildingsTab:mfCinematicAuthoritySnapshot('#hudDeckTabs .hudDeckBtn[data-deck="buildings"]','deck-command',false),
600
+ abilitiesTab:mfCinematicAuthoritySnapshot('#hudDeckTabs .hudDeckBtn[data-deck="abilities"]','deck-command',false),
601
+ viewTab:mfCinematicAuthoritySnapshot('#hudDeckTabs .hudDeckBtn[data-deck="view"]','deck-command',false),
602
+ army:mfCinematicAuthoritySnapshot('#armyBtn','select-army-command',false),
603
+ idleBuilders:mfCinematicAuthoritySnapshot('#idleBuilderBtn','select-idle-builders-command',false),
604
+ boxSelect:mfCinematicAuthoritySnapshot('#boxBtn','box-select-command',false),
605
+ stop:mfCinematicAuthoritySnapshot('#stopBtn','stop-command',false),
606
+ repair:mfCinematicAuthoritySnapshot('#bp_repair','service-repair',true),
607
+ recycle:mfCinematicAuthoritySnapshot('#bp_sell','service-recycle',false),
608
+ build:mfCinematicAuthoritySnapshot('#buildBtn','build-command',false),
609
+ patrol:mfCinematicAuthoritySnapshot('#patrolBtn','patrol-command',false),
610
+ hold:mfCinematicAuthoritySnapshot('#holdBtn','hold-command',false),
611
+ formation:mfCinematicAuthoritySnapshot('#formBtn','formation-command',false),
612
+ attackMove:mfCinematicAuthoritySnapshot('#moveBtn','attack-move-command',false),
613
+ clearSelection:mfCinematicAuthoritySnapshot('#clearBtn','clear-selection-command',false),
614
+ rotateLeft:mfCinematicAuthoritySnapshot('#rotL','rotate-left-command',false),
615
+ zoomIn:mfCinematicAuthoritySnapshot('#zoomIn','zoom-in-command',false),
616
+ tilt:mfCinematicAuthoritySnapshot('#tiltBtn','tilt-command',false),
617
+ zoomOut:mfCinematicAuthoritySnapshot('#zoomOut','zoom-out-command',false),
618
+ rotateRight:mfCinematicAuthoritySnapshot('#rotR','rotate-right-command',false),
619
+ waypoint:mfCinematicAuthoritySnapshot('#queueBtn','waypoint-command',true),
620
+ rally:mfCinematicAuthoritySnapshot('#rallyBtn','rally-command',false),
621
+ repeat:mfCinematicAuthoritySnapshot('#repeatBtn','repeat-command',false),
622
+ upgrade:mfCinematicAuthoritySnapshot('#upBtn','production-upgrade',false),
623
+ hero:mfCinematicAuthoritySnapshot('#heroBar','commander-profile',false),
624
+ groups:mfCinematicAuthoritySnapshot('#mfCinematicGroupPalette','group-palette',false),
625
+ feed:mfCinematicAuthoritySnapshot('#noticeLogBtn','event-feed-control',false),
626
+ transmission:mfCinematicAuthoritySnapshot('#cmdrTx','command-transmission',false),
627
+ hotslots:mfCinematicAuthoritySnapshot('#hotSlots','abilities-deck',false),
628
+ utility:mfCinematicAuthoritySnapshot('#hotUtilityPanel','utility-drawer',true),
629
+ baseFinder:mfCinematicAuthoritySnapshot('#baseFinder','base-finder',true)
630
+ };
631
+ var authorityOk=true,authorityDuplicateCount=0,authorityFailures=[];
632
+ for(var key in authority){
633
+ authorityDuplicateCount+=authority[key].duplicateCount;
634
+ if(!authority[key].ok){authorityOk=false;authorityFailures.push(key);}
635
+ }
636
+ return {ready:document.body.classList.contains('mf-cinematic-hud'),
637
+ surface:context&&context.getAttribute('data-active-surface')||'none',
638
+ deck:tabs&&tabs.getAttribute('data-active-deck')||'orders',
639
+ repairCount:authority.repair.count,recycleCount:authority.recycle.count,
640
+ buildCount:authority.build.count,rallyCount:authority.rally.count,repeatCount:authority.repeat.count,
641
+ upgradeCount:authority.upgrade.count,heroCount:authority.hero.count,groupsCount:authority.groups.count,
642
+ feedCount:authority.feed.count,hotslotsCount:authority.hotslots.count,baseFinderCount:authority.baseFinder.count,
643
+ authorityOk:authorityOk,authorityDuplicateCount:authorityDuplicateCount,authorityFailures:authorityFailures,authority:authority,
644
+ heroAuthorityHidden:!!(document.getElementById('heroRow')&&document.getElementById('heroRow').style.visibility==='hidden')};
645
+ }
646
+ });
647
+ window.dispatchEvent(new CustomEvent('massfront-cinematic-hud-ready'));
648
+ })();
src/ui/hotslots.js CHANGED
@@ -43,7 +43,25 @@ const HOT_UTILITIES=[
43
  {src:'abLance', em:'🛰', nm:'LANCE', ab:3},
44
  {src:'abEmp', em:'⚡', nm:'EMP', ab:4},
45
  ];
46
- let hotSig='', hotSlots=[], hotRow=null,hotUtilityPanel=null,hotUtilityItems=[];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  function hotSlotRow(){
49
  if(hotRow&&hotRow.isConnected) return hotRow;
@@ -74,33 +92,46 @@ function hotActivateSource(b){
74
  function hotUtilityShell(){
75
  if(hotUtilityPanel&&hotUtilityPanel.isConnected)return hotUtilityPanel;
76
  hotUtilityPanel=document.getElementById('hotUtilityPanel');
77
- if(!hotUtilityPanel){
78
- hotUtilityPanel=document.createElement('div');hotUtilityPanel.id='hotUtilityPanel';
79
- hotUtilityPanel.setAttribute('role','group');hotUtilityPanel.setAttribute('aria-label','Additional selected unit actions');
80
- document.body.appendChild(hotUtilityPanel);
81
- }
82
- return hotUtilityPanel;
83
- }
84
- function hotUtilityClose(){
85
- if(hotUtilityPanel)hotUtilityPanel.style.display='none';
86
- const more=hotSlots.find(s=>s.def.kind==='utility');if(more)more.el.classList.remove('on');
87
- }
88
- function hotUtilityToggle(items){
89
- const p=hotUtilityShell();if(p.style.display==='grid'){hotUtilityClose();return;}
90
- hotUtilityItems=items.slice();p.innerHTML='';
91
- for(const s of hotUtilityItems){
92
- const b=document.createElement('button');b.type='button';b.className='hotUtility';b.dataset.hotSrc=s.src||'';
93
- b.innerHTML='<span class="hEm"></span><span class="hNm"></span><span class="hCd"></span>';
94
- b.querySelector('.hEm').textContent=s.em||'✦';b.querySelector('.hNm').textContent=s.nm||'ACTION';
95
- b.setAttribute('aria-label',(s.nm||'Action')+(s.ds?' — '+s.ds:''));
96
- b.addEventListener('pointerdown',ev=>{ev.preventDefault();ev.stopPropagation();hotUtilityClose();
97
- if(s.kind==='mode')hotSetMode(s.mode);
98
- else if(s.kind==='local'&&s.fn)s.fn();
99
- else hotActivateSource(hotSrc(s.src));});
100
- p.appendChild(b);
101
- }
102
- p.style.display='grid';const more=hotSlots.find(s=>s.def.kind==='utility');if(more)more.el.classList.add('on');hotSlotPlace();
103
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
  /* What is selected, reduced to the shape the bar depends on. Rebuilding the
106
  DOM every HUD tick would kill the press state under the player's thumb, so
@@ -223,12 +254,12 @@ function hotBuilderSalvage(){
223
  }else{toast('No salvage fields detected');sfx('reject');}
224
  }
225
 
226
- function hotBuild(){
227
- const row=hotSlotRow();
228
- hotUtilityClose();
229
- hotSlots=[];
230
- const sel=hotSelectionSig();
231
- if(!sel){ row.style.display='none'; row.innerHTML=''; hotTabState(false); hotSlotPlace(); return; }
232
 
233
  const want=[],utility=[];
234
  /* The Commander's powers belong to the Commander. Selecting it is what puts
@@ -255,10 +286,10 @@ function hotBuild(){
255
  /* The starting Constructor's jobs used to exist only in simulation code.
256
  Surface them where a player expects unit actions: construction, routing to
257
  field repair, and routing to its faster salvage pass. */
258
- if(hotSelectedBuilders().length){
259
- want.push({kind:'ab',src:'buildBtn',em:'🏗',nm:'BUILD',ds:'Open the structure catalogue'});
260
- want.push({kind:'local',fn:hotBuilderRepair,em:'🔧',nm:'REPAIR',ds:'Move to the nearest damaged or unfinished friendly structure'});
261
- want.push({kind:'local',fn:hotBuilderSalvage,em:'♻',nm:'SALVAGE',ds:'Move to the nearest wreck and reclaim it at 2× rate'});
262
  }
263
  /* Repair-bay MEND is owned by src/repairbay.js. A one-line hook keeps this
264
  file from duplicating apron rules, and the function is absent until that
@@ -268,7 +299,7 @@ function hotBuild(){
268
  const sky=mfAirliftSelected();
269
  if(sky>=0){
270
  const H=typeof mfAirliftHold==='function'?mfAirliftHold(sky,false):null;
271
- want.push({kind:'local',fn:()=>{if(typeof mfAirliftArmUnload==='function')mfAirliftArmUnload(sky);},
272
  em:'⇩',nm:H&&H.cargo.length?'UNLOAD '+H.cargo.length:'UNLOAD',
273
  ds:'Set a formation drop zone for Skycrane cargo'});
274
  }
@@ -277,7 +308,7 @@ function hotBuild(){
277
  const mass=mfMassSelected();
278
  if(mass>=0){
279
  const air=utype[mass]===MF_UT_MASSFLESH_AIR;
280
- want.push({kind:'local',fn:()=>{if(typeof mfMassArmSelected==='function')mfMassArmSelected();},
281
  em:'♒',nm:air?'BIRTH':'TAKE FLIGHT',
282
  ds:air?'Mark a birth site behind the defensive line':'Ascend for a timed breakthrough flight'});
283
  }
@@ -300,27 +331,42 @@ function hotBuild(){
300
  /* Five stable thumb targets replace the clipped horizontal rail. Commander
301
  fire stays direct; legacy powers, artillery and stances live one tap deep
302
  in a measured popover rather than leaking off both phone edges. */
303
- const use=want.slice(0,4);
304
- if(want.length>4)utility.unshift(...want.slice(4));
305
- if(utility.length)use.push({kind:'utility',em:'⋯',nm:'UTILITY',items:utility});
306
- row.innerHTML='';
307
- for(const s of use){
308
- const b=document.createElement('button');
309
- b.type='button'; b.className='hotSlot';
310
- b.innerHTML='<span class="hEm"></span><span class="hNm"></span><span class="hCd"></span>';
311
- b.querySelector('.hEm').textContent=s.em;
312
- b.querySelector('.hNm').textContent=s.nm;
313
- b.setAttribute('aria-label',s.nm+(s.ds?' — '+s.ds:''));
314
- b.addEventListener('pointerdown',ev=>{
315
- ev.preventDefault(); ev.stopPropagation();
316
- if(s.kind==='mode') hotSetMode(s.mode);
317
- else if(s.kind==='local'&&s.fn)s.fn();
318
- else if(s.kind==='utility')hotUtilityToggle(s.items||[]);
319
- else hotActivateSource(hotSrc(s.src));
320
- });
321
- row.appendChild(b);
322
- hotSlots.push({def:s,el:b});
323
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  hotTabState(!!use.length);
325
  row.style.display=use.length&&typeof hudDeck==='string'&&hudDeck==='abilities'?'flex':'none';
326
  hotSlotPlace();
@@ -346,15 +392,15 @@ function hotSlotSync(force){
346
  cd.textContent=busy&&ring?(ring.textContent||''):'';
347
  if(S.def.src==='abCommander'){
348
  const em=document.getElementById('cmdAbEm'),nm=document.getElementById('cmdAbNm');
349
- if(em)el.querySelector('.hEm').textContent=em.textContent||'✦';
350
  if(nm)el.querySelector('.hNm').textContent=nm.textContent||'SIGNATURE';
351
  el.setAttribute('aria-label',src.getAttribute('aria-label')||'Commander signature ability');
352
  }else if(S.def.src==='abPrimary'||S.def.src==='abSecondary'){
353
  const W=typeof commanderWeaponDef==='function'?commanderWeaponDef(S.def.src==='abSecondary'?1:0):null;
354
- if(W){el.querySelector('.hEm').textContent=W.em||'•';el.querySelector('.hNm').textContent=W.nm.toUpperCase();}
355
  }else if(S.def.src==='abClass'){
356
  const em=document.getElementById('classAbEm'), nm=document.getElementById('classAbNm');
357
- if(em) el.querySelector('.hEm').textContent=em.textContent||'✦';
358
  if(nm) el.querySelector('.hNm').textContent=nm.textContent||'DOCTRINE';
359
  }
360
  }else if(S.def.kind==='local'){
@@ -373,12 +419,12 @@ function hotSlotSync(force){
373
  cd.textContent=able&&standing&&standing<able?standing+'/'+able:'';
374
  }
375
  }
376
- if(hotUtilityPanel&&hotUtilityPanel.style.display==='grid'){
377
- hotUtilityPanel.querySelectorAll('[data-hot-src]').forEach(el=>{
378
- const src=hotSrc(el.dataset.hotSrc),ring=src&&src.querySelector('.cdring'),cd=el.querySelector('.hCd');
379
- const busy=!!(src&&src.classList.contains('cd'));el.classList.toggle('cd',busy);
380
- if(cd)cd.textContent=busy&&ring?(ring.textContent||''):'';
381
- });
382
  }
383
  hotSlotPlace();
384
  }
@@ -440,6 +486,29 @@ if(typeof updateHUD==='function'){
440
  if(paints&&!hotHudSynced) hotSlotSync(false);
441
  };
442
  }
443
- addEventListener('resize',()=>hotSlotPlace());
444
- hotSlotRow();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
 
 
43
  {src:'abLance', em:'🛰', nm:'LANCE', ab:3},
44
  {src:'abEmp', em:'⚡', nm:'EMP', ab:4},
45
  ];
46
+ let hotSig='', hotSlots=[], hotRow=null,hotUtilityPanel=null,hotUtilityItems=[];
47
+ /* Presentation takeovers may replace the fallback glyph with validated art.
48
+ Remember the owner's semantic value separately so the HUD frame mirror does
49
+ not erase and recreate that art when the weapon/ability has not changed. */
50
+ function hotIconText(el,value){
51
+ const text=value||'•';if(el&&el._mfHotIconText!==text){el._mfHotIconText=text;el.textContent=text;}
52
+ }
53
+ /* A slot's DOM identity follows its authoritative action, never its visible
54
+ copy. UNLOAD gains a cargo count and Commander weapons can rename in place;
55
+ neither is allowed to manufacture a new button (and discard its injected
56
+ vector art) just because the label changed. */
57
+ function hotDataSource(def){
58
+ if(!def)return 'action:unknown';
59
+ if(def.src)return def.src;
60
+ if(def.hotSrc)return def.hotSrc;
61
+ if(def.kind==='mode')return 'mode:'+String(def.mode);
62
+ if(def.kind==='utility')return 'utility:more';
63
+ return (def.kind||'action')+':'+String(def.nm||'action').toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'');
64
+ }
65
 
66
  function hotSlotRow(){
67
  if(hotRow&&hotRow.isConnected) return hotRow;
 
92
  function hotUtilityShell(){
93
  if(hotUtilityPanel&&hotUtilityPanel.isConnected)return hotUtilityPanel;
94
  hotUtilityPanel=document.getElementById('hotUtilityPanel');
95
+ if(!hotUtilityPanel){
96
+ hotUtilityPanel=document.createElement('div');hotUtilityPanel.id='hotUtilityPanel';
97
+ hotUtilityPanel.setAttribute('role','group');hotUtilityPanel.setAttribute('aria-label','Additional selected unit actions');
98
+ document.body.appendChild(hotUtilityPanel);
99
+ }
100
+ hotUtilityPanel.setAttribute('data-mf-hud-role','utility-drawer');
101
+ return hotUtilityPanel;
102
+ }
103
+ function hotUtilityClose(clear){
104
+ if(!hotUtilityPanel)hotUtilityPanel=document.getElementById('hotUtilityPanel');
105
+ document.body.classList.remove('mfHotUtilityOpen');
106
+ if(hotUtilityPanel){
107
+ hotUtilityPanel.style.display='none';hotUtilityPanel.setAttribute('aria-hidden','true');
108
+ /* A closed drawer must not keep focusable, selection-specific commands in
109
+ document.body. Clearing also prevents a later Commander selection from
110
+ briefly exposing the previous unit's actions while its row rebuilds. */
111
+ if(clear!==false)hotUtilityPanel.replaceChildren();
112
+ }
113
+ if(clear!==false)hotUtilityItems.length=0;
114
+ const more=hotSlots.find(s=>s.def.kind==='utility');if(more)more.el.classList.remove('on');
115
+ }
116
+ function hotUtilityToggle(items){
117
+ const p=hotUtilityShell();if(p.style.display==='grid'){hotUtilityClose(true);return;}
118
+ hotUtilityItems=items.slice();p.innerHTML='';
119
+ for(const s of hotUtilityItems){
120
+ const b=document.createElement('button');b.type='button';b.className='hotUtility';b.dataset.hotSrc=hotDataSource(s);b._mfHotDef=s;
121
+ b.innerHTML='<span class="hEm"></span><span class="hNm"></span><span class="hCd"></span>';
122
+ hotIconText(b.querySelector('.hEm'),s.em||'✦');b.querySelector('.hNm').textContent=s.nm||'ACTION';
123
+ b.setAttribute('aria-label',(s.nm||'Action')+(s.ds?' — '+s.ds:''));
124
+ const activate=ev=>{ev.preventDefault();ev.stopPropagation();const def=b._mfHotDef;hotUtilityClose(true);
125
+ if(def.kind==='mode')hotSetMode(def.mode);
126
+ else if(def.kind==='local'&&def.fn)def.fn();
127
+ else hotActivateSource(hotSrc(def.src));};
128
+ if(typeof mfBindNativePress==='function')mfBindNativePress(b,activate);
129
+ else b.addEventListener('pointerdown',activate);
130
+ p.appendChild(b);
131
+ }
132
+ p.style.display='grid';p.setAttribute('aria-hidden','false');document.body.classList.add('mfHotUtilityOpen');
133
+ const more=hotSlots.find(s=>s.def.kind==='utility');if(more)more.el.classList.add('on');hotSlotPlace();
134
+ }
135
 
136
  /* What is selected, reduced to the shape the bar depends on. Rebuilding the
137
  DOM every HUD tick would kill the press state under the player's thumb, so
 
254
  }else{toast('No salvage fields detected');sfx('reject');}
255
  }
256
 
257
+ function hotBuild(){
258
+ const row=hotSlotRow();
259
+ hotUtilityClose(true);
260
+ hotSlots=[];
261
+ const sel=hotSelectionSig();
262
+ if(!sel){ row.style.display='none'; row.innerHTML=''; hotTabState(false); hotSlotPlace(); return; }
263
 
264
  const want=[],utility=[];
265
  /* The Commander's powers belong to the Commander. Selecting it is what puts
 
286
  /* The starting Constructor's jobs used to exist only in simulation code.
287
  Surface them where a player expects unit actions: construction, routing to
288
  field repair, and routing to its faster salvage pass. */
289
+ if(hotSelectedBuilders().length){
290
+ want.push({kind:'ab',src:'buildBtn',em:'🏗',nm:'BUILD',ds:'Open the structure catalogue'});
291
+ want.push({kind:'local',hotSrc:'local:builder-repair',fn:hotBuilderRepair,em:'🔧',nm:'REPAIR',ds:'Move to the nearest damaged or unfinished friendly structure'});
292
+ want.push({kind:'local',hotSrc:'local:builder-salvage',fn:hotBuilderSalvage,em:'♻',nm:'SALVAGE',ds:'Move to the nearest wreck and reclaim it at 2× rate'});
293
  }
294
  /* Repair-bay MEND is owned by src/repairbay.js. A one-line hook keeps this
295
  file from duplicating apron rules, and the function is absent until that
 
299
  const sky=mfAirliftSelected();
300
  if(sky>=0){
301
  const H=typeof mfAirliftHold==='function'?mfAirliftHold(sky,false):null;
302
+ want.push({kind:'local',hotSrc:'local:airlift-unload',fn:()=>{if(typeof mfAirliftArmUnload==='function')mfAirliftArmUnload(sky);},
303
  em:'⇩',nm:H&&H.cargo.length?'UNLOAD '+H.cargo.length:'UNLOAD',
304
  ds:'Set a formation drop zone for Skycrane cargo'});
305
  }
 
308
  const mass=mfMassSelected();
309
  if(mass>=0){
310
  const air=utype[mass]===MF_UT_MASSFLESH_AIR;
311
+ want.push({kind:'local',hotSrc:air?'local:mass-birth':'local:mass-flight',fn:()=>{if(typeof mfMassArmSelected==='function')mfMassArmSelected();},
312
  em:'♒',nm:air?'BIRTH':'TAKE FLIGHT',
313
  ds:air?'Mark a birth site behind the defensive line':'Ascend for a timed breakthrough flight'});
314
  }
 
331
  /* Five stable thumb targets replace the clipped horizontal rail. Commander
332
  fire stays direct; legacy powers, artillery and stances live one tap deep
333
  in a measured popover rather than leaking off both phone edges. */
334
+ const use=want.slice(0,4);
335
+ if(want.length>4)utility.unshift(...want.slice(4));
336
+ if(utility.length)use.push({kind:'utility',em:'⋯',nm:'UTILITY',items:utility});
337
+ /* Reconcile by data-hot-src. Reusing an unchanged button preserves the SVG
338
+ or atlas node a presentation layer injected into .hEm, while the one
339
+ bound handler reads the current definition and keeps behaviour owned by
340
+ the original source control. */
341
+ const old=new Map();
342
+ for(const b of row.querySelectorAll(':scope > .hotSlot[data-hot-src]'))old.set(b.dataset.hotSrc,b);
343
+ const next=document.createDocumentFragment();
344
+ for(const s of use){
345
+ const key=hotDataSource(s);let b=old.get(key);old.delete(key);
346
+ if(!b){
347
+ b=document.createElement('button');b.type='button';b.className='hotSlot';b.dataset.hotSrc=key;
348
+ b.innerHTML='<span class="hEm"></span><span class="hNm"></span><span class="hCd"></span>';
349
+ const activate=ev=>{
350
+ ev.preventDefault();ev.stopPropagation();const def=b._mfHotDef;if(!def)return;
351
+ if(def.kind==='utility')hotUtilityToggle(def.items||[]);
352
+ else{
353
+ hotUtilityClose(true);
354
+ if(def.kind==='mode')hotSetMode(def.mode);
355
+ else if(def.kind==='local'&&def.fn)def.fn();
356
+ else hotActivateSource(hotSrc(def.src));
357
+ }
358
+ };
359
+ if(typeof mfBindNativePress==='function')mfBindNativePress(b,activate);
360
+ else b.addEventListener('pointerdown',activate);
361
+ }
362
+ b._mfHotDef=s;b.dataset.hotSrc=key;
363
+ hotIconText(b.querySelector('.hEm'),s.em);
364
+ b.querySelector('.hNm').textContent=s.nm;
365
+ b.setAttribute('aria-label',s.nm+(s.ds?' — '+s.ds:''));
366
+ next.appendChild(b);
367
+ hotSlots.push({def:s,el:b});
368
+ }
369
+ row.replaceChildren(next);
370
  hotTabState(!!use.length);
371
  row.style.display=use.length&&typeof hudDeck==='string'&&hudDeck==='abilities'?'flex':'none';
372
  hotSlotPlace();
 
392
  cd.textContent=busy&&ring?(ring.textContent||''):'';
393
  if(S.def.src==='abCommander'){
394
  const em=document.getElementById('cmdAbEm'),nm=document.getElementById('cmdAbNm');
395
+ if(em)hotIconText(el.querySelector('.hEm'),em.textContent||'✦');
396
  if(nm)el.querySelector('.hNm').textContent=nm.textContent||'SIGNATURE';
397
  el.setAttribute('aria-label',src.getAttribute('aria-label')||'Commander signature ability');
398
  }else if(S.def.src==='abPrimary'||S.def.src==='abSecondary'){
399
  const W=typeof commanderWeaponDef==='function'?commanderWeaponDef(S.def.src==='abSecondary'?1:0):null;
400
+ if(W){hotIconText(el.querySelector('.hEm'),W.em||'•');el.querySelector('.hNm').textContent=W.nm.toUpperCase();}
401
  }else if(S.def.src==='abClass'){
402
  const em=document.getElementById('classAbEm'), nm=document.getElementById('classAbNm');
403
+ if(em) hotIconText(el.querySelector('.hEm'),em.textContent||'✦');
404
  if(nm) el.querySelector('.hNm').textContent=nm.textContent||'DOCTRINE';
405
  }
406
  }else if(S.def.kind==='local'){
 
419
  cd.textContent=able&&standing&&standing<able?standing+'/'+able:'';
420
  }
421
  }
422
+ if(hotUtilityPanel&&hotUtilityPanel.style.display==='grid'){
423
+ hotUtilityPanel.querySelectorAll('[data-hot-src]').forEach(el=>{
424
+ const def=el._mfHotDef,src=def&&def.src?hotSrc(def.src):null,ring=src&&src.querySelector('.cdring'),cd=el.querySelector('.hCd');
425
+ const busy=!!(src&&src.classList.contains('cd'));el.classList.toggle('cd',busy);
426
+ if(cd)cd.textContent=busy&&ring?(ring.textContent||''):'';
427
+ });
428
  }
429
  hotSlotPlace();
430
  }
 
486
  if(paints&&!hotHudSynced) hotSlotSync(false);
487
  };
488
  }
489
+ addEventListener('resize',()=>hotSlotPlace());
490
+ hotSlotRow();
491
+ /* Deck changes call hotUtilityClose synchronously from main.js. Attribute
492
+ observation is the safety net for contexts owned elsewhere (a selected
493
+ Factory opening production, a pause/level overlay, or a front-screen
494
+ transition). It only does work while the drawer is actually open. */
495
+ function hotUtilityGuard(){
496
+ if(!hotUtilityPanel||hotUtilityPanel.style.display!=='grid')return;
497
+ const body=document.body,front=body.classList.contains('mfMenuOpen')||body.classList.contains('menuMode');
498
+ const context=['buildMenu','prodMenu','bldMenu2','baseFinder'].some(id=>{
499
+ const el=document.getElementById(id);return !!(el&&!el.hidden&&el.style.display!=='none'&&getComputedStyle(el).display!=='none');
500
+ });
501
+ const modal=['pauseOverlay','levelUp','gameOver','loadScr'].some(id=>{
502
+ const el=document.getElementById(id);return !!(el&&el.style.display!=='none'&&getComputedStyle(el).display!=='none');
503
+ });
504
+ const dockHidden=typeof running==='boolean'&&running&&!body.classList.contains('hudTacticalDock');
505
+ if(typeof hudDeck==='string'&&hudDeck!=='abilities'||typeof paused==='boolean'&&paused||front||context||modal||dockHidden)hotUtilityClose(true);
506
+ }
507
+ if(typeof MutationObserver!=='undefined'){
508
+ const hotUtilityWatch=new MutationObserver(hotUtilityGuard);
509
+ hotUtilityWatch.observe(document.body,{attributes:true,attributeFilter:['class']});
510
+ for(const id of ['cmdbar','hudDeckTabs','buildMenu','prodMenu','bldMenu2','baseFinder','pauseOverlay','levelUp','gameOver','loadScr']){
511
+ const el=document.getElementById(id);if(el)hotUtilityWatch.observe(el,{attributes:true,attributeFilter:['class','style','hidden']});
512
+ }
513
+ }
514
 
src/ui/hud.js CHANGED
@@ -778,8 +778,11 @@ function updateHUD(fps){
778
  updateWaveWarning();
779
  const massV=$('massV'), enV=$('enV'), massR=$('massR'), enR=$('enR');
780
  const localBank=typeof mfLocalBank==='function'?mfLocalBank():{mass:resM[0],energy:resE[0],massCap:RES_MCAP[0],energyCap:RES_ECAP[0]};
781
- hudTxt(massV, String(Math.floor(localBank.mass)));
782
- hudTxt(enV, String(Math.floor(localBank.energy)));
 
 
 
783
  hudCol(massV, stallM>0?'#ff8d7a':(localBank.mass>=localBank.massCap-1?'#ffd257':''));
784
  hudCol(enV, stallE>0?'#ff8d7a':'');
785
  // net rate = income − measured spending, so the economy reads honestly
@@ -800,7 +803,7 @@ function updateHUD(fps){
800
  /* Chip is the whole player faction's 500, including allied commanders. */
801
  const popNowTxt=hudPopK(popL.used);
802
  const popCapTxt=popL.cap===1000?'1K':hudPopK(popL.cap);
803
- hudTxt(popEl, popNowTxt+' / '+popCapTxt);
804
  popBox.classList.toggle('popWarn',popL.used>=popL.cap*.9);
805
  popBox.classList.toggle('popFull',popL.used>=popL.cap);
806
  const popTitle='Faction population: '+popL.used+' of '+popL.cap+' — allied commanders share this cap';
@@ -872,6 +875,24 @@ function updateHUD(fps){
872
  if(gb){
873
  if(running&&!demoMode&&matchLive){
874
  gb.style.display='flex';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
875
  let h=goalStatus();
876
  /* Annihilate keys off livingEnemyCommanders(). Those units spawn in
877
  newSkirmish, but a first HUD paint (or a failed slot) can still read
@@ -909,8 +930,10 @@ function updateHUD(fps){
909
  (the clock) — so five of every six assignments reparsed identical HTML
910
  and invalidated layout for nothing, inside the frame loop. The handler
911
  was also a fresh closure every pass. */
912
- if(gb._mfH!==h){ gb._mfH=h; gb.innerHTML=h; }
913
- if(!gb.onclick) gb.onclick=()=>toast(goalDef().em+' '+goalDef().nm+' — '+goalDef().ds);
 
 
914
  } else hudDisp(gb,'none');
915
  }
916
  // hive threat meter
@@ -1083,7 +1106,11 @@ function showConsHud(){
1083
  let h='';
1084
  for(const c of _mfMatchCons){
1085
  const stock=b.consumables[c.id]||0;
1086
- h+='<div class="conHudSlot" title="ONE MATCH · '+c.nm+': '+c.ds+'"><span class="conHudEm">'+c.em+'</span>'
 
 
 
 
1087
  +'<span class="conHudNm">'+c.nm+'</span><span class="conHudScope">ONE MATCH</span><span class="conHudCt">'+stock+'</span></div>';
1088
  }
1089
  if(_mfConsHudEl._h!==h){ _mfConsHudEl._h=h; _mfConsHudEl.innerHTML=h; }
@@ -1701,27 +1728,53 @@ function mfIntel3DPump(ts){
1701
  using the legacy unit sheet gives every faction a Nova silhouette. The PNG
1702
  cache is keyed by the exact runtime faction kit and model ID, so a tab can
1703
  rebuild freely without rebuilding geometry or lying about the subject. */
1704
- const mfIntelThumbCache=new Map(),mfIntelThumbWait=new Map(),mfIntelThumbQueue=[];
1705
  let mfIntelThumbBusy=false,mfIntelThumbCanvas=null,mfIntelThumbView=null;
 
1706
  function mfIntelThumbKey(kind,id,kit){return kind+':'+mfIntelKit(kit)+':'+id;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1707
  function mfIntelThumbRequest(img,holder,kind,id,kit){
1708
  kit=mfIntelKit(kit);const key=mfIntelThumbKey(kind,id,kit),cached=mfIntelThumbCache.get(key);
 
1709
  const done=url=>{
1710
- if(!holder.isConnected)return;
1711
- if(url){img.src=url;img.style.opacity='1';holder.classList.remove('missingFactionModel');}
1712
- else if(kit!=='nova'){
1713
- holder.replaceChildren();holder.classList.add('missingFactionModel');holder.dataset.faction=kit;
1714
- const mark=document.createElement('span');mark.textContent='!';mark.setAttribute('aria-label',kit+' model unavailable');holder.appendChild(mark);
1715
- }
 
 
 
 
 
1716
  };
1717
- if(cached!==undefined){done(cached);return;}
1718
  const waits=mfIntelThumbWait.get(key);if(waits){waits.push(done);return;}
 
1719
  mfIntelThumbWait.set(key,[done]);mfIntelThumbQueue.push({key,kind,id,kit});mfIntelThumbPump();
1720
  }
1721
  function mfIntelThumbPump(){
1722
  if(mfIntelThumbBusy||!mfIntelThumbQueue.length)return;mfIntelThumbBusy=true;
1723
  requestAnimationFrame(ts=>{
1724
  const job=mfIntelThumbQueue.shift();let url='',subjectReady=false;
 
1725
  try{
1726
  if(!mfIntelThumbCanvas){
1727
  mfIntelThumbCanvas=document.createElement('canvas');
@@ -1735,10 +1788,25 @@ function mfIntelThumbPump(){
1735
  faction and recreate the exact silent-fallback bug this path fixes. */
1736
  if(subjectReady){mfIntelThumbView.dirty=true;mfIntelThumbView.draw(2100);url=mfIntelThumbCanvas.toDataURL('image/png');}
1737
  }catch(e){url='';}
 
 
1738
  mfIntelThumbCache.set(job.key,url);const waits=mfIntelThumbWait.get(job.key)||[];mfIntelThumbWait.delete(job.key);for(const fn of waits)fn(url);
1739
  mfIntelThumbBusy=false;if(mfIntelThumbQueue.length)mfIntelThumbPump();
1740
  });
1741
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
1742
  function mfIntelPreviewWindow(kind,id,tag,kit){
1743
  kit=mfIntelKit(kit);
1744
  const w=document.createElement('div');w.className='mfIntelPreview';w.setAttribute('role','img');
@@ -2077,6 +2145,7 @@ function mfEnsureBuildingServiceControls(panelId){
2077
  let row=$('mfBldServiceActions');
2078
  if(!row){
2079
  row=document.createElement('div');row.id='mfBldServiceActions';row.className='bldServiceActions';
 
2080
  row.setAttribute('aria-label','Structure maintenance');
2081
  }
2082
  let repair=$('bp_repair');
@@ -2111,7 +2180,7 @@ function mfRenderBuildingServiceControls(B,panelId){
2111
  C.repair.title=detail+(Q.rate?(' · '+Math.round(Q.rate)+' HP/s'):'')+(cost.length?(' · '+cost.join(' / ')):'' );
2112
  const refund=typeof bldRecycleMass==='function'?bldRecycleMass(B):0,armed=B.recycleConfirmAt>Date.now();
2113
  C.recycle.disabled=!B.alive;C.recycle.dataset.armed=armed?'true':'false';
2114
- C.recycle.textContent=armed?'CONFIRM +'+refund+'M':'RECYCLE +'+refund+'M';
2115
  C.recycle.setAttribute('aria-label',armed?'Confirm recycle '+BT[B.type].name+' for '+refund+' mass':'Arm recycle '+BT[B.type].name+' for '+refund+' mass');
2116
  }
2117
  function renderBldPanel(){ if(openBldGone()) return;
@@ -2123,7 +2192,14 @@ function renderBldPanel(){ if(openBldGone()) return;
2123
  bi.classList.add('intelTap');
2124
  bi.setAttribute('role','button'); bi.setAttribute('tabindex','0');
2125
  bi.setAttribute('aria-label','Explain '+T.name);
2126
- bi.onpointerdown=ev=>{ ev.stopPropagation(); showBuildingTypeCard(B.type,openBld,true); sfx('ui'); };
 
 
 
 
 
 
 
2127
  const bLv=typeof bldDisplayLevel==='function'?bldDisplayLevel(B):(B.type==='fac'?(B.tier===2?2:1):(B.lvl||1));
2128
  $('bp_title').textContent=intelBldName(B.type,(typeof factionTextKit==='function')?factionTextKit(B.team):undefined)
2129
  +' · LV'+bLv+(bLv>1?' '+'★'.repeat(Math.min(3,bLv)):'');
@@ -2196,12 +2272,16 @@ function renderResearchMenu(){ if(openBldGone()) return;
2196
  const carry=researchResumeTime(R.id),recover=carry>0?Math.min(99,Math.floor(carry/R.t*100)):0;
2197
  const d=document.createElement('div');
2198
  d.className='bcard'+(lockLvl?' locked':'');
 
 
 
2199
  d.innerHTML='<div class="em">'+(lockLvl?'🔒':R.em)+'</div><div class="nm">'+R.nm+'</div>'
2200
  +(lockLvl?'<div class="cost" style="color:#ffd257">CDR LV '+R.clvl+'</div>'
2201
  :'<div class="cost">'+R.cm+'m <span>'+R.ce+'e</span></div>')
2202
  +'<div style="opacity:.7">'+R.ds+'</div>'
2203
  +(recover?'<div class="researchRecover">◆ RECOVER '+recover+'%</div>':'');
2204
- d.addEventListener('pointerdown',ev=>{
 
2205
  ev.stopPropagation();
2206
  if(lockLvl){ toast('🔒 Field Study '+R.nm+' unlocks at Commander level '+R.clvl); return; }
2207
  /* Same corpse hazard as the production sheet, plus a hard throw: a lab
@@ -2217,7 +2297,9 @@ function renderResearchMenu(){ if(openBldGone()) return;
2217
  }
2218
  Bb.res=idx; Bb.resT=Math.min(R.t-.01,researchResumeTime(R.id)); sfx('ui'); renderQueue();
2219
  if(Bb.resT>0) toast('◆ '+R.nm+' recovered at '+Math.floor(Bb.resT/R.t*100)+'%');
2220
- });
 
 
2221
  g.appendChild(d);
2222
  shown++;
2223
  });
@@ -2258,88 +2340,33 @@ function makeIcon(spr,size,frame){
2258
  }
2259
  function unitIconEl(tIdx,size,kit){
2260
  kit=mfIntelKit(kit);
2261
- const T=TYPES[tIdx], F=4; // 3/4-view yaw frame
2262
  const w=document.createElement('div');
2263
  w.className='mfRuntimeThumb';
2264
  w.style.cssText='position:relative;width:'+size+'px;height:'+size+'px;display:grid;place-items:center;overflow:hidden';
2265
- /* Do not paint a base-roster thumbnail while waiting for the live preview.
2266
- That mixed registry contains Brood slots, so its optimistic fallback was
2267
- enough to put Ravagers in Blue catalogues even when strict 3D rejected it. */
2268
- if(typeof factionUnitModelAllowed==='function'&&!factionUnitModelAllowed(tIdx,kit)){
2269
- const unavailable=document.createElement('span');unavailable.textContent='—';unavailable.style.opacity='.38';
2270
- w.appendChild(unavailable);return w;
2271
- }
2272
  const live=document.createElement('img');live.alt='';live.setAttribute('aria-hidden','true');
2273
  live.style.cssText='position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;transition:opacity .16s';
2274
- const special={
2275
- 13:'unit_alpha',18:'unit_scorcher',19:'unit_constructor',
2276
- 20:'unit_reaper',21:'unit_cinder',22:'unit_lancer',23:'unit_resonator',
2277
- 24:'unit_warden',25:'unit_kestrel',26:'unit_basilisk',27:'unit_harbinger',
2278
- 28:'unit_praetor',29:'unit_archon',30:'unit_brood',31:'unit_brood'
2279
- }[tIdx];
2280
- /* The faction sheet leads: it is the only static art that exists for three of
2281
- the four kits, and it is drawn in that kit's livery rather than Nova's. It
2282
- returns null before the sheet decodes or when a role has no glyph, so the
2283
- older paths below stay live as written. */
2284
- const facIc=(typeof mfFacUnitIcon==='function')?mfFacUnitIcon(tIdx,size,kit):null;
2285
- if(facIc){
2286
- w.appendChild(facIc);
2287
- }else if(kit==='nova'&&special&&typeof itemArt==='function'){
2288
- w.innerHTML=itemArt(special,T.name,size);
2289
- const img=w.firstElementChild; if(img) img.classList.add('rosterArt');
2290
- }else{
2291
- /* Sheet sprites for every kit. Codex PNGs are not in the tree, so the
2292
- old nova-only branch left Brood/Legion/Syndicate on a ◇ diamond. */
2293
- const h=makeIcon(T.spr,size,F); if(h) w.appendChild(h);
2294
- if(T.tur){ const t=makeIcon(T.tur,size,F);
2295
- if(t){ t.style.position='absolute'; t.style.left='0'; t.style.top='0'; w.appendChild(t); } }
2296
- if(!h){
2297
- const wait=document.createElement('span');wait.textContent='◇';wait.style.opacity='.45';w.appendChild(wait);
2298
- }
2299
- }
2300
- /* A baked icon IS a render of this model, so asking the live thumbnail path
2301
- for one would spend a GPU pass reproducing the image already on screen and
2302
- then crossfade it onto itself. Skip it; the request still runs for anything
2303
- falling back to a role glyph, where the live render is a real upgrade. */
2304
- const baked=facIc&&facIc.classList.contains('bmIcon');
2305
  w.appendChild(live);
2306
- if(!baked) mfIntelThumbRequest(live,w,'unit',tIdx,kit);
2307
  return w;
2308
  }
2309
  function bldIconEl(key,size,kit){
2310
  kit=mfIntelKit(kit);
2311
  const d=document.createElement('div');d.className='mfRuntimeThumb';
2312
  d.style.cssText='position:relative;width:'+size+'px;height:'+size+'px;display:grid;place-items:center;overflow:hidden';
 
 
 
2313
  const live=document.createElement('img');live.alt='';live.setAttribute('aria-hidden','true');
2314
  live.style.cssText='position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;transition:opacity .16s';
2315
- const special={geo:'bld_geo',gate:'bld_gate'}[key];
2316
- /* Same order as unitIconEl, and it matters more here: 29 structures share
2317
- only ~15 sprite rows, so the sheet also ends a lot of duplicate art. */
2318
- const facIc=(typeof mfFacBldIcon==='function')?mfFacBldIcon(key,size,kit):null;
2319
- if(facIc){
2320
- d.appendChild(facIc);
2321
- }else if(kit==='nova'&&special&&typeof itemArt==='function'){
2322
- d.innerHTML=itemArt(special,BT[key].em,size);
2323
- const img=d.firstElementChild; if(img) img.classList.add('rosterArt');
2324
- }else{
2325
- const el=makeIcon(BT[key]&&BT[key].spr,size,0);
2326
- if(el){d.appendChild(el);
2327
- if(key==='geo') el.style.filter='hue-rotate(150deg) saturate(1.6) drop-shadow(0 3px 3px rgba(0,0,0,.55))';}
2328
- if(!el){
2329
- const uv=sprites[BT[key]&&BT[key].spr];
2330
- if(uv&&typeof atlasCanvas!=='undefined'&&atlasCanvas){
2331
- const cv3=document.createElement('canvas'); cv3.width=cv3.height=64;
2332
- cv3.getContext('2d').drawImage(atlasCanvas,
2333
- uv[0]*ATLAS,uv[1]*ATLAS,(uv[2]-uv[0])*ATLAS,(uv[3]-uv[1])*ATLAS, 0,0,64,64);
2334
- d.style.background='url('+cv3.toDataURL()+') center/contain no-repeat';
2335
- }else{
2336
- const wait=document.createElement('span');wait.textContent='◇';wait.style.opacity='.45';d.appendChild(wait);
2337
- }
2338
- }
2339
- }
2340
  d.appendChild(live);
2341
- if(!(facIc&&facIc.classList.contains('bmIcon'))) // see unitIconEl
2342
- mfIntelThumbRequest(live,d,'building',key,kit);
2343
  return d;
2344
  }
2345
  /* The open tab persists across openings — a player who is in the middle of
@@ -2360,9 +2387,9 @@ function mfSyncProductionQueueCards(B){
2360
  }
2361
  }
2362
  const BASE_FINDER_GROUPS=[
2363
- {id:'all',nm:'ALL',em:'⌂'},{id:'economy',nm:'ECON',em:'⛏'},
2364
- {id:'production',nm:'FACTORIES',em:'🏭'},{id:'defence',nm:'DEFENCE',em:'🛡'},
2365
- {id:'support',nm:'SUPPORT',em:'📡'}
2366
  ];
2367
  const BASE_FINDER_ECON=new Set(['mex','pgen','geo','silo','fab']);
2368
  const BASE_FINDER_PROD=new Set(['fac','tgate','harbor','airfield']);
@@ -2410,9 +2437,17 @@ function renderBaseFinder(){
2410
  +'<i><span style="width:'+S.health+'%"></span></i></span><strong>×'+owned.length+'<small>'+S.health+'% HP</small></strong></button>';
2411
  }).join('');
2412
  p.innerHTML='<header><button type="button" class="baseFindBack" aria-label="Close Buildings and return to Orders">‹ ORDERS</button><span><b>OWNED BUILDINGS</b><small>'+all.length+' TOTAL</small></span></header>'
2413
- +'<div class="baseFindTabs" role="tablist" aria-label="Building categories">'+BASE_FINDER_GROUPS.map(g=>'<button type="button" role="tab" aria-selected="'+(g.id===baseFinderFilter?'true':'false')+'" data-f="'+g.id+'" class="'+(g.id===baseFinderFilter?'on':'')+'"><span>'+g.em+'</span>'+g.nm+'</button>').join('')+'</div>'
2414
  +'<div class="baseFindGrid" role="list">'+(cards||'<p class="baseFindEmpty">NO '+baseFinderFilter.toUpperCase()+' BUILDINGS YET</p>')+'</div>'
2415
  +'<p class="baseFindHint">Tap a building card to select and center it. Tap again to cycle another of that type.</p>';
 
 
 
 
 
 
 
 
2416
  mfBindNativePress(p.querySelector('.baseFindBack'),()=>{closeBaseFinder(true);sfx('ui');});
2417
  p.querySelectorAll('[data-f]').forEach(btn=>mfBindNativePress(btn,ev=>{
2418
  ev.stopPropagation();baseFinderFilter=btn.dataset.f;renderBaseFinder();sfx('ui');
@@ -3404,7 +3439,10 @@ function cmdrTxBind(){
3404
  const cue={speakerId:'keel',profileId:'uga-keel-expedition-guide',key:d.hintId||d.context||'keel-hint',seq:d.issuedAt||Date.now(),
3405
  category:'UGA GUIDANCE',durationMs:d.durationMs,animationSrc:ugaMedia?(d.animationSrc||''):'',
3406
  subtitle:{speaker:'KEEL',shortName:'KEEL',rank:'UGA SHIP LIAISON',text:d.text||''},
3407
- portrait:{src:ugaMedia?(d.portraitSrc||''):'',fallback:ugaMedia?(d.fallbackPortraitSrc||''):''}};
 
 
 
3408
  if(!cmdrTxShow(cue)) return;
3409
  CMDRTX.state='enter'; CMDRTX.until=cmdrTxNow()+CMDRTX_ENTER_MS;
3410
  d.handled=true; d.presenter='battle-minimap';
 
778
  updateWaveWarning();
779
  const massV=$('massV'), enV=$('enV'), massR=$('massR'), enR=$('enR');
780
  const localBank=typeof mfLocalBank==='function'?mfLocalBank():{mass:resM[0],energy:resE[0],massCap:RES_MCAP[0],energyCap:RES_ECAP[0]};
781
+ /* The upper rail is a tactical glance surface, so four- and five-digit banks
782
+ use the same compact K notation as population. Full precision remains in
783
+ the inspector title reached by tapping the chip. */
784
+ hudTxt(massV, hudPopK(Math.floor(localBank.mass)));
785
+ hudTxt(enV, hudPopK(Math.floor(localBank.energy)));
786
  hudCol(massV, stallM>0?'#ff8d7a':(localBank.mass>=localBank.massCap-1?'#ffd257':''));
787
  hudCol(enV, stallE>0?'#ff8d7a':'');
788
  // net rate = income − measured spending, so the economy reads honestly
 
803
  /* Chip is the whole player faction's 500, including allied commanders. */
804
  const popNowTxt=hudPopK(popL.used);
805
  const popCapTxt=popL.cap===1000?'1K':hudPopK(popL.cap);
806
+ hudTxt(popEl, popNowTxt+'/'+popCapTxt);
807
  popBox.classList.toggle('popWarn',popL.used>=popL.cap*.9);
808
  popBox.classList.toggle('popFull',popL.used>=popL.cap);
809
  const popTitle='Faction population: '+popL.used+' of '+popL.cap+' — allied commanders share this cap';
 
875
  if(gb){
876
  if(running&&!demoMode&&matchLive){
877
  gb.style.display='flex';
878
+ /* #goalBar remains the polite live status region, while its one native
879
+ button owns the briefing action. A role=status element with only an
880
+ onclick was reachable by touch but was neither keyboard-actionable nor
881
+ exposed as a control to assistive technology. Keep an OTA-safe fallback
882
+ because an updated script may run once against an older HTML shell. */
883
+ let goalAction=$('goalDetailBtn');
884
+ if(!goalAction){
885
+ goalAction=document.createElement('button');goalAction.type='button';goalAction.id='goalDetailBtn';
886
+ goalAction.setAttribute('aria-label','Open mission objective details');gb.replaceChildren(goalAction);gb._mfH=null;
887
+ }
888
+ if(gb.onclick)gb.onclick=null;
889
+ if(goalAction.dataset.mfMissionBound!=='1'){
890
+ goalAction.dataset.mfMissionBound='1';
891
+ mfBindTap(goalAction,()=>{
892
+ const def=typeof goalDef==='function'?goalDef():null;
893
+ if(def)toast((def.em?def.em+' ':'')+def.nm+' — '+def.ds);
894
+ });
895
+ }
896
  let h=goalStatus();
897
  /* Annihilate keys off livingEnemyCommanders(). Those units spawn in
898
  newSkirmish, but a first HUD paint (or a failed slot) can still read
 
930
  (the clock) — so five of every six assignments reparsed identical HTML
931
  and invalidated layout for nothing, inside the frame loop. The handler
932
  was also a fresh closure every pass. */
933
+ if(gb._mfH!==h){ gb._mfH=h; goalAction.innerHTML=h; }
934
+ const def=typeof goalDef==='function'?goalDef():null;
935
+ const actionLabel='Open mission objective details'+(def&&def.nm?': '+def.nm:'');
936
+ if(goalAction.getAttribute('aria-label')!==actionLabel)goalAction.setAttribute('aria-label',actionLabel);
937
  } else hudDisp(gb,'none');
938
  }
939
  // hive threat meter
 
1106
  let h='';
1107
  for(const c of _mfMatchCons){
1108
  const stock=b.consumables[c.id]||0;
1109
+ /* Keep the live match chip on the same canonical art mapping as Account
1110
+ Armory. The data emoji remains the fallback when the inventory renderer
1111
+ is unavailable or the mapped image cannot load. */
1112
+ const art=typeof armInvIcon==='function'?armInvIcon(c,32):'<span>'+c.em+'</span>';
1113
+ h+='<div class="conHudSlot" title="ONE MATCH · '+c.nm+': '+c.ds+'"><span class="conHudEm">'+art+'</span>'
1114
  +'<span class="conHudNm">'+c.nm+'</span><span class="conHudScope">ONE MATCH</span><span class="conHudCt">'+stock+'</span></div>';
1115
  }
1116
  if(_mfConsHudEl._h!==h){ _mfConsHudEl._h=h; _mfConsHudEl.innerHTML=h; }
 
1728
  using the legacy unit sheet gives every faction a Nova silhouette. The PNG
1729
  cache is keyed by the exact runtime faction kit and model ID, so a tab can
1730
  rebuild freely without rebuilding geometry or lying about the subject. */
1731
+ const mfIntelThumbCache=new Map(),mfIntelThumbWait=new Map(),mfIntelThumbQueue=[],mfIntelThumbState=new Map();
1732
  let mfIntelThumbBusy=false,mfIntelThumbCanvas=null,mfIntelThumbView=null;
1733
+ let mfIntelThumbRequests=0,mfIntelThumbCacheHits=0,mfIntelThumbRenders=0,mfIntelThumbFailures=0;
1734
  function mfIntelThumbKey(kind,id,kit){return kind+':'+mfIntelKit(kit)+':'+id;}
1735
+ function mfIntelThumbRecord(key,kind,id,kit,status,bytes,reason){
1736
+ const old=mfIntelThumbState.get(key)||{};
1737
+ mfIntelThumbState.set(key,{key,kind,id:String(id),kit,status,bytes:bytes||old.bytes||0,reason:reason||''});
1738
+ }
1739
+ function mfIntelThumbHolder(holder,key,kind,id,kit,status,source){
1740
+ if(!holder)return;
1741
+ holder.dataset.mfModelKey=key;holder.dataset.mfModelKind=kind;holder.dataset.mfModelId=String(id);
1742
+ holder.dataset.mfModelKit=kit;holder.dataset.mfThumbStatus=status;holder.dataset.mfThumbSource=source||'pending';
1743
+ }
1744
+ function mfIntelThumbUnavailable(holder,key,kind,id,kit,reason){
1745
+ if(!holder||holder.dataset.mfModelKey!==key)return;
1746
+ holder.replaceChildren();holder.classList.add('missingFactionModel');
1747
+ mfIntelThumbHolder(holder,key,kind,id,kit,'unavailable','unavailable');
1748
+ const mark=document.createElement('span');mark.className='mfRuntimeThumbUnavailable';mark.textContent='!';
1749
+ mark.setAttribute('aria-label',kit+' '+kind+' model unavailable');holder.appendChild(mark);
1750
+ if(reason)holder.dataset.mfThumbReason=reason;
1751
+ }
1752
  function mfIntelThumbRequest(img,holder,kind,id,kit){
1753
  kit=mfIntelKit(kit);const key=mfIntelThumbKey(kind,id,kit),cached=mfIntelThumbCache.get(key);
1754
+ mfIntelThumbRequests++;mfIntelThumbHolder(holder,key,kind,id,kit,'queued','pending');
1755
  const done=url=>{
1756
+ if(!holder||holder.dataset.mfModelKey!==key)return;
1757
+ if(!url){mfIntelThumbUnavailable(holder,key,kind,id,kit,'geometry');return;}
1758
+ const ready=()=>{
1759
+ if(holder.dataset.mfModelKey!==key)return;
1760
+ const fallback=holder.querySelector('.mfRuntimeThumbFallback');if(fallback)fallback.remove();
1761
+ img.style.opacity='1';holder.classList.remove('missingFactionModel');delete holder.dataset.mfThumbReason;
1762
+ mfIntelThumbHolder(holder,key,kind,id,kit,'ready','runtime-geometry');
1763
+ };
1764
+ img.onload=ready;img.onerror=()=>mfIntelThumbUnavailable(holder,key,kind,id,kit,'decode');img.src=url;
1765
+ mfIntelThumbHolder(holder,key,kind,id,kit,'rendered','runtime-geometry');
1766
+ if(img.complete&&img.naturalWidth)ready();
1767
  };
1768
+ if(cached!==undefined){mfIntelThumbCacheHits++;done(cached);return;}
1769
  const waits=mfIntelThumbWait.get(key);if(waits){waits.push(done);return;}
1770
+ mfIntelThumbRecord(key,kind,id,kit,'queued',0,'');
1771
  mfIntelThumbWait.set(key,[done]);mfIntelThumbQueue.push({key,kind,id,kit});mfIntelThumbPump();
1772
  }
1773
  function mfIntelThumbPump(){
1774
  if(mfIntelThumbBusy||!mfIntelThumbQueue.length)return;mfIntelThumbBusy=true;
1775
  requestAnimationFrame(ts=>{
1776
  const job=mfIntelThumbQueue.shift();let url='',subjectReady=false;
1777
+ mfIntelThumbRecord(job.key,job.kind,job.id,job.kit,'rendering',0,'');
1778
  try{
1779
  if(!mfIntelThumbCanvas){
1780
  mfIntelThumbCanvas=document.createElement('canvas');
 
1788
  faction and recreate the exact silent-fallback bug this path fixes. */
1789
  if(subjectReady){mfIntelThumbView.dirty=true;mfIntelThumbView.draw(2100);url=mfIntelThumbCanvas.toDataURL('image/png');}
1790
  }catch(e){url='';}
1791
+ if(url){mfIntelThumbRenders++;mfIntelThumbRecord(job.key,job.kind,job.id,job.kit,'ready',url.length,'');}
1792
+ else{mfIntelThumbFailures++;mfIntelThumbRecord(job.key,job.kind,job.id,job.kit,'unavailable',0,subjectReady?'snapshot':'geometry');}
1793
  mfIntelThumbCache.set(job.key,url);const waits=mfIntelThumbWait.get(job.key)||[];mfIntelThumbWait.delete(job.key);for(const fn of waits)fn(url);
1794
  mfIntelThumbBusy=false;if(mfIntelThumbQueue.length)mfIntelThumbPump();
1795
  });
1796
  }
1797
+ function mfIntelThumbSnapshot(){
1798
+ const entries=[...mfIntelThumbState.values()].map(row=>({...row})),holders=[...document.querySelectorAll('.mfRuntimeThumb[data-mf-model-key]')].map(el=>({
1799
+ key:el.dataset.mfModelKey,kind:el.dataset.mfModelKind,id:el.dataset.mfModelId,kit:el.dataset.mfModelKit,
1800
+ status:el.dataset.mfThumbStatus,source:el.dataset.mfThumbSource,connected:el.isConnected
1801
+ }));
1802
+ return {sharedContextCount:mfIntel3DGL?1:0,sharedSurfaceCount:mfIntel3DSurf?1:0,
1803
+ contextReady:!!(mfIntel3DGL&&mfIntel3DProg&&!mfIntel3DGL.isContextLost()),busy:mfIntelThumbBusy,
1804
+ queueDepth:mfIntelThumbQueue.length,waitingKeys:mfIntelThumbWait.size,requests:mfIntelThumbRequests,
1805
+ cacheHits:mfIntelThumbCacheHits,renders:mfIntelThumbRenders,failures:mfIntelThumbFailures,
1806
+ readyEntries:entries.filter(row=>row.status==='ready').length,unavailableEntries:entries.filter(row=>row.status==='unavailable').length,
1807
+ readyHolders:holders.filter(row=>row.status==='ready'&&row.source==='runtime-geometry').length,entries,holders};
1808
+ }
1809
+ window.MFIntelRuntimeThumbnails=Object.freeze({snapshot:mfIntelThumbSnapshot});
1810
  function mfIntelPreviewWindow(kind,id,tag,kit){
1811
  kit=mfIntelKit(kit);
1812
  const w=document.createElement('div');w.className='mfIntelPreview';w.setAttribute('role','img');
 
2145
  let row=$('mfBldServiceActions');
2146
  if(!row){
2147
  row=document.createElement('div');row.id='mfBldServiceActions';row.className='bldServiceActions';
2148
+ row.setAttribute('role','group');
2149
  row.setAttribute('aria-label','Structure maintenance');
2150
  }
2151
  let repair=$('bp_repair');
 
2180
  C.repair.title=detail+(Q.rate?(' · '+Math.round(Q.rate)+' HP/s'):'')+(cost.length?(' · '+cost.join(' / ')):'' );
2181
  const refund=typeof bldRecycleMass==='function'?bldRecycleMass(B):0,armed=B.recycleConfirmAt>Date.now();
2182
  C.recycle.disabled=!B.alive;C.recycle.dataset.armed=armed?'true':'false';
2183
+ C.recycle.textContent=armed?'CONFIRM RECYCLE +'+refund+'M':'RECYCLE +'+refund+'M';
2184
  C.recycle.setAttribute('aria-label',armed?'Confirm recycle '+BT[B.type].name+' for '+refund+' mass':'Arm recycle '+BT[B.type].name+' for '+refund+' mass');
2185
  }
2186
  function renderBldPanel(){ if(openBldGone()) return;
 
2192
  bi.classList.add('intelTap');
2193
  bi.setAttribute('role','button'); bi.setAttribute('tabindex','0');
2194
  bi.setAttribute('aria-label','Explain '+T.name);
2195
+ const explainBuilding=ev=>{
2196
+ if(ev)ev.stopPropagation();
2197
+ const live=openBld>=0&&blds[openBld];if(!live||!live.alive)return;
2198
+ showBuildingTypeCard(live.type,openBld,true);sfx('ui');
2199
+ };
2200
+ bi.onpointerdown=explainBuilding;
2201
+ bi.onkeydown=ev=>{if(!ev.repeat&&(ev.key==='Enter'||ev.key===' ')){ev.preventDefault();explainBuilding(ev);}};
2202
+ bi.onclick=ev=>{if(ev.detail===0)explainBuilding(ev);};
2203
  const bLv=typeof bldDisplayLevel==='function'?bldDisplayLevel(B):(B.type==='fac'?(B.tier===2?2:1):(B.lvl||1));
2204
  $('bp_title').textContent=intelBldName(B.type,(typeof factionTextKit==='function')?factionTextKit(B.team):undefined)
2205
  +' · LV'+bLv+(bLv>1?' '+'★'.repeat(Math.min(3,bLv)):'');
 
2272
  const carry=researchResumeTime(R.id),recover=carry>0?Math.min(99,Math.floor(carry/R.t*100)):0;
2273
  const d=document.createElement('div');
2274
  d.className='bcard'+(lockLvl?' locked':'');
2275
+ d.setAttribute('role','button');d.tabIndex=0;d.setAttribute('aria-disabled',lockLvl?'true':'false');
2276
+ d.setAttribute('aria-label',R.nm+'. '+(lockLvl?'Unlocks at Commander level '+R.clvl:
2277
+ 'Costs '+R.cm+' mass and '+R.ce+' energy. '+R.ds));
2278
  d.innerHTML='<div class="em">'+(lockLvl?'🔒':R.em)+'</div><div class="nm">'+R.nm+'</div>'
2279
  +(lockLvl?'<div class="cost" style="color:#ffd257">CDR LV '+R.clvl+'</div>'
2280
  :'<div class="cost">'+R.cm+'m <span>'+R.ce+'e</span></div>')
2281
  +'<div style="opacity:.7">'+R.ds+'</div>'
2282
  +(recover?'<div class="researchRecover">◆ RECOVER '+recover+'%</div>':'');
2283
+ const activate=ev=>{
2284
+ if(ev)ev.preventDefault();
2285
  ev.stopPropagation();
2286
  if(lockLvl){ toast('🔒 Field Study '+R.nm+' unlocks at Commander level '+R.clvl); return; }
2287
  /* Same corpse hazard as the production sheet, plus a hard throw: a lab
 
2297
  }
2298
  Bb.res=idx; Bb.resT=Math.min(R.t-.01,researchResumeTime(R.id)); sfx('ui'); renderQueue();
2299
  if(Bb.resT>0) toast('◆ '+R.nm+' recovered at '+Math.floor(Bb.resT/R.t*100)+'%');
2300
+ };
2301
+ if(typeof mfBindNativePress==='function')mfBindNativePress(d,activate);
2302
+ else d.addEventListener('pointerdown',activate);
2303
  g.appendChild(d);
2304
  shown++;
2305
  });
 
2340
  }
2341
  function unitIconEl(tIdx,size,kit){
2342
  kit=mfIntelKit(kit);
2343
+ const T=TYPES[tIdx];
2344
  const w=document.createElement('div');
2345
  w.className='mfRuntimeThumb';
2346
  w.style.cssText='position:relative;width:'+size+'px;height:'+size+'px;display:grid;place-items:center;overflow:hidden';
2347
+ w.setAttribute('role','img');w.setAttribute('aria-label',(T&&T.name||'Unit')+' runtime model');
2348
+ /* A neutral loading reticle is deliberately the only pre-render fallback.
2349
+ The faction icon sheets classify a role; they do not depict the exact live
2350
+ chassis, and were the source of the commander/build-card mismatch. */
2351
+ const fallback=document.createElement('span');fallback.className='mfRuntimeThumbFallback';fallback.textContent='◌';
2352
+ fallback.setAttribute('aria-hidden','true');fallback.style.opacity='.42';w.appendChild(fallback);
 
2353
  const live=document.createElement('img');live.alt='';live.setAttribute('aria-hidden','true');
2354
  live.style.cssText='position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;transition:opacity .16s';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2355
  w.appendChild(live);
2356
+ mfIntelThumbRequest(live,w,'unit',tIdx,kit);
2357
  return w;
2358
  }
2359
  function bldIconEl(key,size,kit){
2360
  kit=mfIntelKit(kit);
2361
  const d=document.createElement('div');d.className='mfRuntimeThumb';
2362
  d.style.cssText='position:relative;width:'+size+'px;height:'+size+'px;display:grid;place-items:center;overflow:hidden';
2363
+ const T=BT[key];d.setAttribute('role','img');d.setAttribute('aria-label',(T&&T.name||'Building')+' runtime model');
2364
+ const fallback=document.createElement('span');fallback.className='mfRuntimeThumbFallback';fallback.textContent='◌';
2365
+ fallback.setAttribute('aria-hidden','true');fallback.style.opacity='.42';d.appendChild(fallback);
2366
  const live=document.createElement('img');live.alt='';live.setAttribute('aria-hidden','true');
2367
  live.style.cssText='position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;transition:opacity .16s';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2368
  d.appendChild(live);
2369
+ mfIntelThumbRequest(live,d,'building',key,kit);
 
2370
  return d;
2371
  }
2372
  /* The open tab persists across openings — a player who is in the middle of
 
2387
  }
2388
  }
2389
  const BASE_FINDER_GROUPS=[
2390
+ {id:'all',nm:'All buildings',short:'ALL',em:'⌂'},{id:'economy',nm:'Economy buildings',short:'ECON',em:'⛏'},
2391
+ {id:'production',nm:'Factories',short:'FACT',em:'🏭'},{id:'defence',nm:'Defence buildings',short:'DEF',em:'🛡'},
2392
+ {id:'support',nm:'Support buildings',short:'SUP',em:'📡'}
2393
  ];
2394
  const BASE_FINDER_ECON=new Set(['mex','pgen','geo','silo','fab']);
2395
  const BASE_FINDER_PROD=new Set(['fac','tgate','harbor','airfield']);
 
2437
  +'<i><span style="width:'+S.health+'%"></span></i></span><strong>×'+owned.length+'<small>'+S.health+'% HP</small></strong></button>';
2438
  }).join('');
2439
  p.innerHTML='<header><button type="button" class="baseFindBack" aria-label="Close Buildings and return to Orders">‹ ORDERS</button><span><b>OWNED BUILDINGS</b><small>'+all.length+' TOTAL</small></span></header>'
2440
+ +'<div class="baseFindTabs" role="tablist" aria-label="Building categories">'+BASE_FINDER_GROUPS.map(g=>'<button type="button" role="tab" aria-selected="'+(g.id===baseFinderFilter?'true':'false')+'" aria-label="'+g.nm+'" title="'+g.nm+'" data-f="'+g.id+'" class="'+(g.id===baseFinderFilter?'on':'')+'"><span class="baseFindTabIcon" aria-hidden="true">'+g.em+'</span><span class="baseFindTabLabel">'+g.short+'</span></button>').join('')+'</div>'
2441
  +'<div class="baseFindGrid" role="list">'+(cards||'<p class="baseFindEmpty">NO '+baseFinderFilter.toUpperCase()+' BUILDINGS YET</p>')+'</div>'
2442
  +'<p class="baseFindHint">Tap a building card to select and center it. Tap again to cycle another of that type.</p>';
2443
+ /* Cards are first assembled as light markup, then receive the same exact
2444
+ runtime-geometry thumbnails as production and Unit Intel. T.em remains
2445
+ only in the category vocabulary; it must not masquerade as a building. */
2446
+ const finderKit=typeof playerKitKey==='function'?playerKitKey():'nova';
2447
+ p.querySelectorAll('[data-btype]').forEach(btn=>{
2448
+ const icon=btn.querySelector('.baseFindIcon'),type=btn.dataset.btype;if(!icon||!BT[type])return;
2449
+ icon.replaceChildren(bldIconEl(type,36,finderKit));
2450
+ });
2451
  mfBindNativePress(p.querySelector('.baseFindBack'),()=>{closeBaseFinder(true);sfx('ui');});
2452
  p.querySelectorAll('[data-f]').forEach(btn=>mfBindNativePress(btn,ev=>{
2453
  ev.stopPropagation();baseFinderFilter=btn.dataset.f;renderBaseFinder();sfx('ui');
 
3439
  const cue={speakerId:'keel',profileId:'uga-keel-expedition-guide',key:d.hintId||d.context||'keel-hint',seq:d.issuedAt||Date.now(),
3440
  category:'UGA GUIDANCE',durationMs:d.durationMs,animationSrc:ugaMedia?(d.animationSrc||''):'',
3441
  subtitle:{speaker:'KEEL',shortName:'KEEL',rank:'UGA SHIP LIAISON',text:d.text||''},
3442
+ /* KEEL owns an original neutral-UGA portrait even when an older hint
3443
+ caller supplies no media. Callers may still replace it with an
3444
+ authored animation/portrait while the UGA identity gate remains. */
3445
+ portrait:{src:ugaMedia?(d.portraitSrc||'assets/textures/ui/mf-keel-uga-portrait-v1.webp'):'',fallback:ugaMedia?(d.fallbackPortraitSrc||''):''}};
3446
  if(!cmdrTxShow(cue)) return;
3447
  CMDRTX.state='enter'; CMDRTX.until=cmdrTxNow()+CMDRTX_ENTER_MS;
3448
  d.handled=true; d.presenter='battle-minimap';
src/ui/hudflow.js CHANGED
@@ -184,7 +184,14 @@ function mfFlowLayoutGo(){
184
  if(gb&&mfFlowVis(gb)) head=Math.max(head,gb.getBoundingClientRect().bottom);
185
 
186
  /* Corner columns first — the centre lane must clear whichever is taller. */
187
- const lb=mfFlowLaneSide(MF_LANE_L,head+6,5);
 
 
 
 
 
 
 
188
  const rb=mfFlowLaneSide(MF_LANE_R,head+6,5);
189
 
190
  let y=Math.max(head,lb,rb)+8;
@@ -258,10 +265,26 @@ function mfFlowDockSelInfo(release){
258
  const el=mfFlowEl(id);
259
  if(!el) continue;
260
  if(!can||!mfFlowVis(el)){ mfFlowDockRelease(el); continue; }
261
- /* The closed feed costs one 44px corner control. Its drawer opens above
262
- that control instead of covering it, so FEED remains the obvious close
263
- route and the bottom command dock stays fully usable. */
264
- const dockWant=want+(id==='mfNoticeHistory'?52:0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  if(el._mfDockBottom!==dockWant){
266
  el._mfDockBottom=dockWant;
267
  el.style.top='auto';
@@ -379,10 +402,12 @@ function mfNoticeHistoryRender(){
379
  const rows=mfNHistory.filter(n=>mfNHistoryFilter==='all'||n.channel===mfNHistoryFilter);
380
  const state=el.querySelector('#mfNoticeFeedState');if(state)state.textContent=rows.length+' RECENT';
381
  if(!rows.length){const e=document.createElement('p');e.className='mfNoticeEmpty';e.textContent='No messages in this channel yet.';list.appendChild(e);return;}
 
382
  for(const N of rows){
383
  const row=document.createElement('div');row.className='mfNoticeItem p'+N.pri+' ch-'+N.channel;row.setAttribute('role','listitem');
384
  const tm=document.createElement('time');tm.dateTime=new Date(N.at||Date.now()).toISOString();tm.textContent=mfNoticeClock(N.at);
385
- const tag=document.createElement('i');tag.textContent=N.channel.toUpperCase();
 
386
  const msg=document.createElement('span');msg.textContent=N.label;msg.title=N.label;
387
  row.append(tm,tag,msg);
388
  if(N.n>1){const repeat=document.createElement('b');repeat.className='mfNoticeRepeat';repeat.textContent='×'+N.n;row.appendChild(repeat);}
@@ -708,9 +733,23 @@ if(typeof updateHUD==='function'){
708
  transparency, cell order per docs/CMD_ICON_ART_SPEC.md.
709
  ============================================================================ */
710
  const CMD_ICON_SHEET='assets/textures/ui/cmdicons.png';
 
 
 
 
 
 
 
 
 
 
 
 
 
711
  function cmdIconsBind(){
712
  try{
713
  const rel=(typeof mf2AssetURL==='function')?mf2AssetURL(CMD_ICON_SHEET):('./'+CMD_ICON_SHEET);
 
714
  /* MUST be absolute. A relative url() inside a custom property is resolved
715
  against the stylesheet that uses it, not the document — so the plain
716
  relative form loaded fine for this Image() probe (document-based) and
@@ -718,13 +757,32 @@ function cmdIconsBind(){
718
  every tagged button blank: .cmdIcons had already hidden the emoji. */
719
  const url=new URL(rel,document.baseURI).href;
720
  const img=new Image();
721
- img.onload=()=>{
 
 
 
 
 
 
 
 
 
 
722
  /* Hand the resolved URL to CSS rather than repeating it there, so the OTA
723
  asset resolver stays the single source of truth for asset paths. */
724
  document.documentElement.style.setProperty('--cmdSheet','url("'+url+'")');
725
  document.documentElement.classList.add('cmdIcons');
726
- };
727
- img.onerror=()=>{}; // emoji stand; nothing to report
 
 
 
 
 
 
 
 
 
728
  img.src=url;
729
  }catch(e){}
730
  }
 
184
  if(gb&&mfFlowVis(gb)) head=Math.max(head,gb.getBoundingClientRect().bottom);
185
 
186
  /* Corner columns first — the centre lane must clear whichever is taller. */
187
+ /* The cinematic HUD physically joins #heroBar to #topbar. The legacy traffic
188
+ lane used to write an inline top below the header, which won over the late
189
+ CSS and recreated the large empty corner the joined rail was designed to
190
+ remove. Hand the portrait back to its rail owner; only transient world
191
+ condition badges continue down the left lane. */
192
+ const cinematic=body.classList.contains('mf-cinematic-hud');
193
+ if(cinematic)mfFlowRelease(mfFlowEl('heroBar'));
194
+ const lb=mfFlowLaneSide(cinematic?MF_LANE_L.filter(id=>id!=='heroBar'):MF_LANE_L,head+6,5);
195
  const rb=mfFlowLaneSide(MF_LANE_R,head+6,5);
196
 
197
  let y=Math.max(head,lb,rb)+8;
 
265
  const el=mfFlowEl(id);
266
  if(!el) continue;
267
  if(!can||!mfFlowVis(el)){ mfFlowDockRelease(el); continue; }
268
+ /* The legacy skin keeps its 44px FEED launcher below the drawer. The
269
+ cinematic skin hides that duplicate launcher while open and puts a full
270
+ close target in the drawer header, so reserving another 52px needlessly
271
+ pushed the feed into the centre of the battlefield. */
272
+ const feedGap=id==='mfNoticeHistory'&&!document.body.classList.contains('mf-cinematic-hud')?52:0;
273
+ let dockWant=want+feedGap;
274
+ /* Tablet/desktop cinematic layouts deliberately move the feed to the
275
+ minimap side so the right command dock stays live. Dock height alone is
276
+ not enough there: the map can be taller than the dock by a few pixels.
277
+ Measure horizontal ownership and clear the map only when the two lanes
278
+ actually intersect; portrait feeds on the opposite side keep their
279
+ shallower, glanceable position. */
280
+ if(id==='mfNoticeHistory'&&document.body.classList.contains('mf-cinematic-hud')){
281
+ const map=mfFlowEl('minimapWrap');
282
+ if(map&&mfFlowVis(map)){
283
+ const er=el.getBoundingClientRect(),mr=map.getBoundingClientRect();
284
+ const overlapX=Math.min(er.right,mr.right)-Math.max(er.left,mr.left);
285
+ if(overlapX>1)dockWant=Math.max(dockWant,Math.round(vh-mr.top+6));
286
+ }
287
+ }
288
  if(el._mfDockBottom!==dockWant){
289
  el._mfDockBottom=dockWant;
290
  el.style.top='auto';
 
402
  const rows=mfNHistory.filter(n=>mfNHistoryFilter==='all'||n.channel===mfNHistoryFilter);
403
  const state=el.querySelector('#mfNoticeFeedState');if(state)state.textContent=rows.length+' RECENT';
404
  if(!rows.length){const e=document.createElement('p');e.className='mfNoticeEmpty';e.textContent='No messages in this channel yet.';list.appendChild(e);return;}
405
+ const channelLabel={command:'ORDER',alert:'ALERT',radio:'COMMS',pickup:'LOOT'};
406
  for(const N of rows){
407
  const row=document.createElement('div');row.className='mfNoticeItem p'+N.pri+' ch-'+N.channel;row.setAttribute('role','listitem');
408
  const tm=document.createElement('time');tm.dateTime=new Date(N.at||Date.now()).toISOString();tm.textContent=mfNoticeClock(N.at);
409
+ const tag=document.createElement('i');tag.textContent=channelLabel[N.channel]||N.channel.toUpperCase();
410
+ tag.setAttribute('aria-label',N.channel==='command'?'Order':tag.textContent);
411
  const msg=document.createElement('span');msg.textContent=N.label;msg.title=N.label;
412
  row.append(tm,tag,msg);
413
  if(N.n>1){const repeat=document.createElement('b');repeat.className='mfNoticeRepeat';repeat.textContent='×'+N.n;row.appendChild(repeat);}
 
733
  transparency, cell order per docs/CMD_ICON_ART_SPEC.md.
734
  ============================================================================ */
735
  const CMD_ICON_SHEET='assets/textures/ui/cmdicons.png';
736
+ const CMD_ICON_INDEX='assets/textures/ui/icon-index.json';
737
+ let mfCmdIconNames=null,mfCmdIconObserver=null;
738
+ function cmdIconsRefresh(root){
739
+ if(!mfCmdIconNames)return;
740
+ const scope=root&&root.querySelectorAll?root:document;
741
+ const list=[];
742
+ if(scope.nodeType===1&&scope.matches('[data-icon]'))list.push(scope);
743
+ scope.querySelectorAll('[data-icon]').forEach(el=>list.push(el));
744
+ for(const el of list){
745
+ const ready=mfCmdIconNames.has(el.getAttribute('data-icon')||'');
746
+ el.setAttribute('data-icon-ready',ready?'true':'false');
747
+ }
748
+ }
749
  function cmdIconsBind(){
750
  try{
751
  const rel=(typeof mf2AssetURL==='function')?mf2AssetURL(CMD_ICON_SHEET):('./'+CMD_ICON_SHEET);
752
+ const indexRel=(typeof mf2AssetURL==='function')?mf2AssetURL(CMD_ICON_INDEX):('./'+CMD_ICON_INDEX);
753
  /* MUST be absolute. A relative url() inside a custom property is resolved
754
  against the stylesheet that uses it, not the document — so the plain
755
  relative form loaded fine for this Image() probe (document-based) and
 
757
  every tagged button blank: .cmdIcons had already hidden the emoji. */
758
  const url=new URL(rel,document.baseURI).href;
759
  const img=new Image();
760
+ const imageReady=new Promise(resolve=>{
761
+ img.onload=()=>resolve(img.naturalWidth===1024&&img.naturalHeight===1024);
762
+ img.onerror=()=>resolve(false);
763
+ });
764
+ const indexReady=fetch(new URL(indexRel,document.baseURI).href,{cache:'force-cache'}).then(r=>r.ok?r.json():null).catch(()=>null);
765
+ Promise.all([imageReady,indexReady]).then(([imageOk,index])=>{
766
+ const common=index&&index.common_neutral;
767
+ if(!imageOk||!common||common.sheet!=='cmdicons.png'||!common.cells)return;
768
+ const entries=Object.entries(common.cells);
769
+ if(!entries.length||entries.some(([,cell])=>!Number.isInteger(cell)||cell<0||cell>=64))return;
770
+ mfCmdIconNames=new Set(entries.map(([name])=>name));
771
  /* Hand the resolved URL to CSS rather than repeating it there, so the OTA
772
  asset resolver stays the single source of truth for asset paths. */
773
  document.documentElement.style.setProperty('--cmdSheet','url("'+url+'")');
774
  document.documentElement.classList.add('cmdIcons');
775
+ cmdIconsRefresh(document);
776
+ if(!mfCmdIconObserver){
777
+ mfCmdIconObserver=new MutationObserver(records=>{
778
+ for(const record of records){
779
+ if(record.type==='attributes')cmdIconsRefresh(record.target);
780
+ else record.addedNodes.forEach(node=>{if(node.nodeType===1)cmdIconsRefresh(node);});
781
+ }
782
+ });
783
+ mfCmdIconObserver.observe(document.body,{subtree:true,childList:true,attributes:true,attributeFilter:['data-icon']});
784
+ }
785
+ });
786
  img.src=url;
787
  }catch(e){}
788
  }
src/ui/input.js CHANGED
@@ -97,7 +97,11 @@ mfUiEventRoot.addEventListener('pointerdown',ev=>{
97
  /* Destructive two-step actions still need two COMPLETED taps. A second
98
  pointerdown inside the hardware-bounce window is never confirmation, even
99
  on the same control; the normal 2.6-3s confirmation window remains intact. */
100
- if(mfUiLastTarget&&now-mfUiLastAt<180&&(el!==mfUiLastTarget||risk==='destructive')){
 
 
 
 
101
  mfUiBlockedPointers.add(pid);mfUiSafetyAudit.bounceBlocks++;ev.preventDefault();ev.stopImmediatePropagation();return;
102
  }
103
  /* Production/build cards own a release/drag contract in hud.js (build cards
@@ -1696,13 +1700,28 @@ addEventListener('keyup',e=>{
1696
  ensureQueueBtn(); queueButtonState();
1697
 
1698
  // ---------- minimap ----------
1699
- const mmc=document.getElementById('minimap');
1700
- function mmNav(e){
 
 
 
1701
  const r=mmc.getBoundingClientRect();
1702
  cam.x=(e.clientX-r.left)/r.width*MAP;
1703
  cam.y=(e.clientY-r.top)/r.height*MAP;
1704
  camFollow=-1; camUser(); clampCam(); camUpdateMatrices();
1705
  }
1706
- mmc.addEventListener('pointerdown',e=>{ e.stopPropagation(); mmNav(e); mmc.setPointerCapture(e.pointerId); });
1707
- mmc.addEventListener('pointermove',e=>{ if(e.buttons) mmNav(e); });
 
 
 
 
 
 
 
 
 
 
 
 
1708
 
 
97
  /* Destructive two-step actions still need two COMPLETED taps. A second
98
  pointerdown inside the hardware-bounce window is never confirmation, even
99
  on the same control; the normal 2.6-3s confirmation window remains intact. */
100
+ /* Never spend a benign menu/navigation tap on the debounce window left by
101
+ another control. That made a fast FEED-close → BUILD tap appear dead even
102
+ though neither action could damage state. Risky actions still require a
103
+ clean contact, and destructive confirmation can never be hardware bounce. */
104
+ if(mfUiLastTarget&&now-mfUiLastAt<180&&risk!=='benign'){
105
  mfUiBlockedPointers.add(pid);mfUiSafetyAudit.bounceBlocks++;ev.preventDefault();ev.stopImmediatePropagation();return;
106
  }
107
  /* Production/build cards own a release/drag contract in hud.js (build cards
 
1700
  ensureQueueBtn(); queueButtonState();
1701
 
1702
  // ---------- minimap ----------
1703
+ const mmc=document.getElementById('minimap');
1704
+ mmc.setAttribute('role','application');mmc.tabIndex=0;
1705
+ mmc.setAttribute('aria-label','Tactical minimap. Use arrow keys to pan the camera and Home to center the map');
1706
+ mmc.setAttribute('aria-keyshortcuts','ArrowUp ArrowDown ArrowLeft ArrowRight Home');
1707
+ function mmNav(e){
1708
  const r=mmc.getBoundingClientRect();
1709
  cam.x=(e.clientX-r.left)/r.width*MAP;
1710
  cam.y=(e.clientY-r.top)/r.height*MAP;
1711
  camFollow=-1; camUser(); clampCam(); camUpdateMatrices();
1712
  }
1713
+ mmc.addEventListener('pointerdown',e=>{ e.stopPropagation(); mmNav(e); mmc.setPointerCapture(e.pointerId); });
1714
+ mmc.addEventListener('pointermove',e=>{ if(e.buttons) mmNav(e); });
1715
+ mmc.addEventListener('keydown',e=>{
1716
+ const arrows=['ArrowLeft','ArrowRight','ArrowUp','ArrowDown'];
1717
+ if(!arrows.includes(e.key)&&e.key!=='Home')return;
1718
+ e.preventDefault();e.stopPropagation();
1719
+ if(e.key==='Home'){cam.x=MAP*.5;cam.y=MAP*.5;}
1720
+ else {
1721
+ const step=Math.max(18,(typeof orthoSpan==='number'?orthoSpan:80)*.28)*(e.shiftKey?3:1);
1722
+ if(e.key==='ArrowLeft')cam.x-=step;if(e.key==='ArrowRight')cam.x+=step;
1723
+ if(e.key==='ArrowUp')cam.y-=step;if(e.key==='ArrowDown')cam.y+=step;
1724
+ }
1725
+ camFollow=-1;camUser();clampCam();camUpdateMatrices();
1726
+ });
1727
 
src/ui/unit-stack-hotbar.js ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ============================================================
2
+ UNIT-STACK HOTBAR — a compact type selector inside PLATOONS
3
+ ============================================================ */
4
+ const MF_UNIT_STACK_SYNC_MS=220;
5
+ const mfUnitStackCardMap=new Map(),mfUnitStackPointers=new Set();
6
+ let mfUnitStackRail=null,mfUnitStackNextSync=0,mfUnitStackLastType=-1,mfUnitStackLastAt=-1e9;
7
+ let mfUnitStackFocusCount=0,mfUnitStackLastFocusType=-1,mfUnitStackLastAction=null;
8
+
9
+ function mfUnitStackNow(){return typeof performance!=='undefined'&&performance.now?performance.now():Date.now();}
10
+ function mfUnitStackName(value){return String(value||'UNIT').replace(/\s+/g,' ').trim();}
11
+ function mfUnitStackOwns(i){
12
+ return typeof mfLocalOwnsUnit==='function'?mfLocalOwnsUnit(i):uteam[i]===0;
13
+ }
14
+ function mfUnitStackKit(){
15
+ const raw=typeof playerKitKey==='function'?playerKitKey():'nova';
16
+ return typeof mfIntelKit==='function'?mfIntelKit(raw):raw;
17
+ }
18
+ function mfUnitStackRows(){
19
+ if(typeof running!=='boolean'||!running||typeof matchLive!=='boolean'||!matchLive)return [];
20
+ const byType=new Map();
21
+ for(let i=0;i<unitHigh;i++){
22
+ if(!ualive[i]||!mfUnitStackOwns(i))continue;
23
+ const type=utype[i],T=TYPES[type];if(!T)continue;
24
+ let row=byType.get(type);
25
+ if(!row){row={type,name:mfUnitStackName(T.name||('UNIT '+type)),count:0,selected:0,ready:0,hp:0,x:0,y:0};byType.set(type,row);}
26
+ row.count++;row.selected+=usel[i]?1:0;
27
+ row.ready+=(typeof ustun==='undefined'||ustun[i]<=0)&&(ustate[i]===0||uhold[i])?1:0;
28
+ row.hp+=Math.max(0,Math.min(1,uhp[i]/Math.max(1,uhpm[i])));row.x+=ux[i];row.y+=uy[i];
29
+ }
30
+ return [...byType.values()].map(row=>{row.health=Math.round(row.hp/row.count*100);return row;}).sort((a,b)=>{
31
+ const A=TYPES[a.type],B=TYPES[b.type],ar=A&&A.cat==='hero'?-2:A&&A.builder?-1:(A&&A.tier||0),
32
+ br=B&&B.cat==='hero'?-2:B&&B.builder?-1:(B&&B.tier||0);
33
+ return ar-br||a.type-b.type;
34
+ });
35
+ }
36
+ function mfUnitStackReleasePointer(ev){
37
+ if(!mfUnitStackPointers.delete(ev.pointerId)||mfUnitStackPointers.size)return;
38
+ mfUnitStackSync(true);
39
+ }
40
+ function mfUnitStackShell(){
41
+ if(mfUnitStackRail&&mfUnitStackRail.isConnected)return mfUnitStackRail;
42
+ const row=document.getElementById('grpRow');if(!row)return null;
43
+ mfUnitStackRail=document.getElementById('mfUnitStackRail');
44
+ if(!mfUnitStackRail){
45
+ mfUnitStackRail=document.createElement('div');mfUnitStackRail.id='mfUnitStackRail';
46
+ mfUnitStackRail.setAttribute('role','group');mfUnitStackRail.setAttribute('aria-label','Unit stacks by type');
47
+ mfUnitStackRail.setAttribute('data-mf-hud-role','unit-stack-hotbar');mfUnitStackRail.dataset.mfScrollRail='horizontal';
48
+ row.appendChild(mfUnitStackRail);
49
+ }
50
+ if(mfUnitStackRail.dataset.mfStackBound!=='1'){
51
+ mfUnitStackRail.dataset.mfStackBound='1';
52
+ mfUnitStackRail.addEventListener('pointerdown',ev=>{if(ev.isPrimary!==false)mfUnitStackPointers.add(ev.pointerId);},{passive:true});
53
+ /* A card activation stops propagation so its command cannot leak into the
54
+ battlefield. Capture owns pointer release before that intentional stop,
55
+ otherwise the topology guard can remain latched after a normal tap. */
56
+ addEventListener('pointerup',mfUnitStackReleasePointer,{passive:true,capture:true});
57
+ addEventListener('pointercancel',mfUnitStackReleasePointer,{passive:true,capture:true});
58
+ mfUnitStackRail.addEventListener('wheel',ev=>{
59
+ if(Math.abs(ev.deltaY)<=Math.abs(ev.deltaX))return;
60
+ mfUnitStackRail.scrollLeft+=ev.deltaY;ev.preventDefault();
61
+ },{passive:false});
62
+ }
63
+ return mfUnitStackRail;
64
+ }
65
+ function mfUnitStackMountIcon(host,type,kit){
66
+ host.replaceChildren();let art=null;
67
+ try{if(typeof unitIconEl==='function')art=unitIconEl(type,34,kit);}catch(e){art=null;}
68
+ if(art){art.classList.add('mfUnitStackArt');host.appendChild(art);return;}
69
+ const fallback=document.createElement('span');fallback.className='mfUnitStackFallback';
70
+ fallback.textContent=typeof UNIT_EM==='object'&&UNIT_EM[type]||'◇';host.appendChild(fallback);
71
+ }
72
+ function mfUnitStackRefreshSelection(type){
73
+ /* updateSelInfo's first-seen lesson opens Unit Intel for a lone chassis. A
74
+ stack tap must keep PLATOONS present for its documented second activation.
75
+ The authored icon, name and status card is already that chassis' lesson;
76
+ its persistent info action remains the route to full Unit Intel. */
77
+ if(typeof intelSeenTypes==='object'&&intelSeenTypes)intelSeenTypes[type]=1;
78
+ if(typeof updateSelInfo==='function')updateSelInfo();
79
+ }
80
+ function mfUnitStackSelect(type,focus){
81
+ const members=[];let cx=0,cy=0;
82
+ for(let i=0;i<unitHigh;i++)if(ualive[i]&&utype[i]===type&&mfUnitStackOwns(i)){members.push(i);cx+=ux[i];cy+=uy[i];}
83
+ if(!members.length){mfUnitStackSync(true);return false;}
84
+ clearSel();for(const i of members)usel[i]=1;
85
+ cx/=members.length;cy/=members.length;
86
+ if(focus){
87
+ if(typeof camFollow!=='undefined')camFollow=-1;
88
+ cam.x=cx;cam.y=cy;if(typeof camUser==='function')camUser();clampCam();camUpdateMatrices();
89
+ mfUnitStackFocusCount++;mfUnitStackLastFocusType=type;
90
+ }
91
+ mfUnitStackRefreshSelection(type);
92
+ const name=TYPES[type]&&TYPES[type].name||('UNIT '+type);
93
+ toast(members.length+'× '+name+' selected'+(focus?' · camera focused':''));
94
+ if(typeof uiCommandAck==='function')uiCommandAck('select',members.length,cx,cy);else sfx('ui');
95
+ mfUnitStackLastAction={type,count:members.length,focus:!!focus,x:cx,y:cy,at:mfUnitStackNow()};
96
+ mfUnitStackSync(true);return true;
97
+ }
98
+ function mfUnitStackActivate(type){
99
+ const now=mfUnitStackNow(),focus=mfUnitStackLastType===type&&now-mfUnitStackLastAt<=700;
100
+ mfUnitStackLastType=type;mfUnitStackLastAt=now;mfUnitStackSelect(type,focus);
101
+ }
102
+ function mfUnitStackCard(type,kit){
103
+ const card=document.createElement('button');card.type='button';card.className='mfUnitStackCard';
104
+ card.dataset.unitStackKey=String(type);card.dataset.unitType=String(type);card.setAttribute('data-mf-hud-role','unit-stack-command');
105
+ const icon=document.createElement('span');icon.className='mfUnitStackIcon';icon.setAttribute('aria-hidden','true');
106
+ const copy=document.createElement('span');copy.className='mfUnitStackCopy';
107
+ const name=document.createElement('b');name.className='mfUnitStackName';
108
+ const meta=document.createElement('span');meta.className='mfUnitStackMeta';
109
+ const count=document.createElement('strong');count.className='mfUnitStackCount';
110
+ const ready=document.createElement('small');ready.className='mfUnitStackReady';
111
+ const health=document.createElement('i');health.className='mfUnitStackHealth';health.setAttribute('aria-hidden','true');
112
+ const fill=document.createElement('i');fill.className='mfUnitStackHealthFill';health.appendChild(fill);
113
+ meta.append(count,ready);copy.append(name,meta,health);card.append(icon,copy);
114
+ card._mfUnitStack={icon,name,count,ready,fill,kit};mfUnitStackMountIcon(icon,type,kit);
115
+ mfBindTap(card,ev=>{ev.preventDefault();ev.stopPropagation();mfUnitStackActivate(type);});
116
+ mfUnitStackCardMap.set(type,card);return card;
117
+ }
118
+ function mfUnitStackPaint(card,row,kit,order){
119
+ const view=card._mfUnitStack;if(!view)return;
120
+ if(view.kit!==kit&&!mfUnitStackPointers.size){view.kit=kit;mfUnitStackMountIcon(view.icon,row.type,kit);}
121
+ if(view.name.textContent!==row.name)view.name.textContent=row.name;
122
+ if(view.name.title!==row.name)view.name.title=row.name;
123
+ const count='×'+row.count,ready=row.ready===row.count?'':row.ready+' RDY';
124
+ if(view.count.textContent!==count)view.count.textContent=count;
125
+ if(view.ready.textContent!==ready)view.ready.textContent=ready;
126
+ view.ready.hidden=!ready;
127
+ view.fill.style.width=row.health+'%';card.style.order=String(order);
128
+ card.dataset.count=String(row.count);card.dataset.selected=String(row.selected);card.dataset.ready=String(row.ready);
129
+ card.dataset.health=String(row.health);card.classList.toggle('selected',row.selected===row.count);
130
+ card.classList.toggle('partial',row.selected>0&&row.selected<row.count);
131
+ card.classList.toggle('ready',row.ready===row.count);card.setAttribute('aria-pressed',
132
+ row.selected===row.count?'true':row.selected>0?'mixed':'false');
133
+ const label='Select all '+row.count+' '+row.name+(row.count===1?'':' units')+'. '+row.ready+' ready. Average health '+row.health+
134
+ ' percent. Activate twice to focus camera.';
135
+ if(card.getAttribute('aria-label')!==label)card.setAttribute('aria-label',label);
136
+ const title=row.name+' · '+row.count+' unit'+(row.count===1?'':'s')+' · '+row.health+'% health';
137
+ if(card.title!==title)card.title=title;
138
+ }
139
+ function mfUnitStackSync(force){
140
+ const rail=mfUnitStackShell();if(!rail)return;
141
+ const now=mfUnitStackNow();if(!force&&now<mfUnitStackNextSync)return;mfUnitStackNextSync=now+MF_UNIT_STACK_SYNC_MS;
142
+ const rows=mfUnitStackRows(),active=mfUnitStackPointers.size>0,kit=mfUnitStackKit(),seen=new Set();
143
+ for(let order=0;order<rows.length;order++){
144
+ const data=rows[order];seen.add(data.type);let card=mfUnitStackCardMap.get(data.type);
145
+ if(!card&&!active){card=mfUnitStackCard(data.type,kit);rail.appendChild(card);}
146
+ if(card)mfUnitStackPaint(card,data,kit,order);
147
+ }
148
+ if(!active)for(const [type,card] of mfUnitStackCardMap)if(!seen.has(type)){card.remove();mfUnitStackCardMap.delete(type);}
149
+ if(!active){rail.style.display=rows.length?'flex':'none';rail.setAttribute('aria-hidden',rows.length?'false':'true');}
150
+ const group=document.getElementById('grpRow');if(group)group.classList.toggle('mfUnitStackReady',rows.length>0);
151
+ }
152
+
153
+ const mfUnitStackBaseUpdateGroupBadges=typeof updateGroupBadges==='function'?updateGroupBadges:null;
154
+ if(mfUnitStackBaseUpdateGroupBadges)updateGroupBadges=function(){mfUnitStackBaseUpdateGroupBadges();mfUnitStackSync(false);};
155
+ addEventListener('resize',()=>mfUnitStackSync(true));
156
+ mfUnitStackShell();mfUnitStackSync(true);
157
+ window.MFUnitStackHotbar=Object.freeze({sync:()=>mfUnitStackSync(true),snapshot:()=>({
158
+ railCount:document.querySelectorAll('#mfUnitStackRail').length,cardCount:mfUnitStackCardMap.size,
159
+ cards:[...mfUnitStackCardMap.values()].map(card=>{const name=card.querySelector('.mfUnitStackName'),thumb=card.querySelector('.mfRuntimeThumb');return{
160
+ type:+card.dataset.unitType,count:+card.dataset.count,selected:+card.dataset.selected,ready:+card.dataset.ready,
161
+ health:+card.dataset.health,pressed:card.getAttribute('aria-pressed'),name:name&&name.textContent||'',
162
+ labelClipped:!!(name&&name.clientWidth&&name.scrollWidth>name.clientWidth+1),modelKey:thumb&&thumb.dataset.mfModelKey||'',
163
+ thumbnailStatus:thumb&&thumb.dataset.mfThumbStatus||'',thumbnailSource:thumb&&thumb.dataset.mfThumbSource||''};}),
164
+ pointerCount:mfUnitStackPointers.size,focusCount:mfUnitStackFocusCount,lastFocusType:mfUnitStackLastFocusType,
165
+ lastAction:mfUnitStackLastAction,platoonButtons:document.querySelectorAll('#grpRow>.grpBtn').length
166
+ })});
src/uistack.js CHANGED
@@ -26,9 +26,12 @@ function mfUiIntelOpen(){ return mfUiInlineOpen('unitCard'); }
26
  function mfUiCriticalOpen(){ return mfUiInlineOpen('atkAlert')||mfUiInlineOpen('waveAlert'); }
27
  function mfUiBusy(){ return mfUiPanelOpen()||mfUiIntelOpen()||mfUiCriticalOpen(); }
28
 
29
- function mfUiClosePrimary(){
30
  const intel=document.getElementById('unitCard');
31
  if(intel){ clearTimeout(intel._t); intel.style.display='none'; }
 
 
 
32
  if(typeof closeMenus==='function') closeMenus();
33
  mfUiQueueSync();
34
  }
@@ -38,9 +41,11 @@ function mfUiEnsurePanelChrome(id,label){
38
  if(!bar){
39
  bar=document.createElement('header');bar.className='mfPanelChrome';
40
  bar.innerHTML='<span></span><button type="button" aria-label="Close '+label+'">\u00d7</button>';
41
- bar.querySelector('button').addEventListener('pointerdown',ev=>{
42
  ev.preventDefault();ev.stopPropagation();mfUiClosePrimary();if(typeof sfx==='function')sfx('ui');
43
- });
 
 
44
  el.insertAdjacentElement('afterbegin',bar);
45
  }
46
  bar.querySelector('span').textContent=label;
@@ -106,17 +111,16 @@ showIntelMarkup=function(markup,pinned){
106
  const mfUiBaseCloseMenus=closeMenus;
107
  closeMenus=function(){mfUiBaseCloseMenus();mfUiQueueSync();};
108
  const mfUiBaseOpenBldMenu=openBldMenu;
109
- openBldMenu=function(b){mfUiBaseOpenBldMenu(b);mfUiQueueSync();};
110
  const mfUiBaseRenderBuildMenu=renderBuildMenu;
111
- renderBuildMenu=function(){mfUiBaseRenderBuildMenu();mfUiEnsurePanelChrome('buildMenu','STRUCTURES');mfUiQueueSync();};
112
  const mfUiBaseRenderProdMenu=renderProdMenu;
113
- renderProdMenu=function(){mfUiBaseRenderProdMenu();mfUiEnsurePanelChrome('prodMenu','PRODUCTION');mfUiQueueSync();};
114
  const mfUiBaseRenderBldPanel=renderBldPanel;
115
- renderBldPanel=function(){mfUiBaseRenderBldPanel();mfUiEnsurePanelChrome('bldMenu2','STRUCTURE CONTROL');mfUiQueueSync();};
116
 
117
  const mfUiWatch=new MutationObserver(mfUiQueueSync);
118
  for(const id of ['buildMenu','prodMenu','bldMenu2','unitCard','atkAlert','waveAlert']){
119
  const el=document.getElementById(id);if(el)mfUiWatch.observe(el,{attributes:true,attributeFilter:['style','class']});
120
  }
121
  mfUiInstallChrome();mfUiSync();
122
-
 
26
  function mfUiCriticalOpen(){ return mfUiInlineOpen('atkAlert')||mfUiInlineOpen('waveAlert'); }
27
  function mfUiBusy(){ return mfUiPanelOpen()||mfUiIntelOpen()||mfUiCriticalOpen(); }
28
 
29
+ function mfUiDismissIntel(){
30
  const intel=document.getElementById('unitCard');
31
  if(intel){ clearTimeout(intel._t); intel.style.display='none'; }
32
+ }
33
+ function mfUiClosePrimary(){
34
+ mfUiDismissIntel();
35
  if(typeof closeMenus==='function') closeMenus();
36
  mfUiQueueSync();
37
  }
 
41
  if(!bar){
42
  bar=document.createElement('header');bar.className='mfPanelChrome';
43
  bar.innerHTML='<span></span><button type="button" aria-label="Close '+label+'">\u00d7</button>';
44
+ const close=bar.querySelector('button'),activate=ev=>{
45
  ev.preventDefault();ev.stopPropagation();mfUiClosePrimary();if(typeof sfx==='function')sfx('ui');
46
+ };
47
+ if(typeof mfBindNativePress==='function')mfBindNativePress(close,activate);
48
+ else close.addEventListener('pointerdown',activate);
49
  el.insertAdjacentElement('afterbegin',bar);
50
  }
51
  bar.querySelector('span').textContent=label;
 
111
  const mfUiBaseCloseMenus=closeMenus;
112
  closeMenus=function(){mfUiBaseCloseMenus();mfUiQueueSync();};
113
  const mfUiBaseOpenBldMenu=openBldMenu;
114
+ openBldMenu=function(b){mfUiDismissIntel();mfUiBaseOpenBldMenu(b);mfUiQueueSync();};
115
  const mfUiBaseRenderBuildMenu=renderBuildMenu;
116
+ renderBuildMenu=function(){mfUiDismissIntel();mfUiBaseRenderBuildMenu();mfUiEnsurePanelChrome('buildMenu','STRUCTURES');mfUiQueueSync();};
117
  const mfUiBaseRenderProdMenu=renderProdMenu;
118
+ renderProdMenu=function(){mfUiDismissIntel();mfUiBaseRenderProdMenu();mfUiEnsurePanelChrome('prodMenu','PRODUCTION');mfUiQueueSync();};
119
  const mfUiBaseRenderBldPanel=renderBldPanel;
120
+ renderBldPanel=function(){mfUiDismissIntel();mfUiBaseRenderBldPanel();mfUiEnsurePanelChrome('bldMenu2','STRUCTURE CONTROL');mfUiQueueSync();};
121
 
122
  const mfUiWatch=new MutationObserver(mfUiQueueSync);
123
  for(const id of ['buildMenu','prodMenu','bldMenu2','unitCard','atkAlert','waveAlert']){
124
  const el=document.getElementById(id);if(el)mfUiWatch.observe(el,{attributes:true,attributeFilter:['style','class']});
125
  }
126
  mfUiInstallChrome();mfUiSync();
 
src/updater.js CHANGED
@@ -42,14 +42,14 @@
42
  ============================================================================ */
43
 
44
  /* Bumped by the release script. Compared against the manifest's `version`. */
45
- const APP_VERSION = '1.33.61';
46
 
47
  /* Release notes for the PACKAGED build, bumped by the release script beside
48
  APP_VERSION and PACKAGED_REV. A device that has never taken an OTA has no
49
  download history to read notes from, and an offline device can never fetch
50
  them, so the build carries its own copy — otherwise a fresh install shows a
51
  permanently empty first entry in the mailbox. */
52
- const APP_NOTES = "Overhaul — Features: visual launch gateway; persistent Social identity, player cards, online count and World Chat actions; commander quick-locate profile and Buildings tab; live Graphics diagnostics; dedicated battle event feed. Bug fixes: removed the connected-play state-hash hitch; restored username hydration; corrected building filters, navigation and multiplayer-seat commander identity; permanently removed e-mail verification as a Social or multiplayer blocker. Upcoming: streamlined War Table and an imagery-first mobile interface overhaul.";
53
 
54
  /* The channel URL in update-config.json remains publisher-configurable, but a
55
  production checker also needs one known-good recovery path. More importantly,
@@ -584,7 +584,7 @@ async function updPreparePrevious(expected,lease){
584
  const db=await updIdb();
585
  return new Promise((res,rej)=>{
586
  const tx=db.transaction(UPD_STORE,'readwrite'),store=tx.objectStore(UPD_STORE);
587
- let conflict=null,result=null,ready=0;
588
  const operation=store.get(UPD_OPERATION_KEY);
589
  const meta=store.get('activeMeta');
590
  const previousRef=store.get('previousRef');
@@ -605,12 +605,13 @@ async function updPreparePrevious(expected,lease){
605
  lease-owned transaction while preserving the validated bytes. */
606
  const active=store.get('active');
607
  active.onsuccess=()=>{
608
- if(!updSamePending(active.result,expected)){
609
  conflict=new Error('The installed update changed before rollback preservation');
610
  conflict.code='MF_UPDATE_ACTIVE_CHANGED';
611
  try{ tx.abort(); }catch(e){ rej(conflict); }
612
  return;
613
  }
 
614
  /* The currently referenced rollback remains untouched until promotion
615
  succeeds. A failed/quota-aborted Apply can therefore discard only
616
  its inactive preparation slot, never the last validated recovery. */
@@ -630,8 +631,17 @@ async function updPreparePrevious(expected,lease){
630
  meta.onerror=()=>rej(meta.error||new Error('could not inspect installed update metadata'));
631
  previousRef.onerror=()=>rej(previousRef.error||new Error('could not inspect rollback pointer'));
632
  tx.oncomplete=()=>res(result);
633
- tx.onerror=()=>rej(conflict||tx.error||new Error('could not save rollback copy'));
634
- tx.onabort=()=>rej(conflict||tx.error||new Error('rollback-copy write aborted'));
 
 
 
 
 
 
 
 
 
635
  });
636
  }
637
  async function updClearPreviousOwned(prepared,lease){
@@ -761,6 +771,24 @@ function updSamePending(a,b){
761
  updIdentityRootsMatch(a,b)&&
762
  String(a.at==null?'':a.at)===String(b.at==null?'':b.at));
763
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
764
  function updIdentityRootsMatch(a,b){
765
  if(!a||!b) return false;
766
  const ah=!!(a.manifestRoot||a.targetRoot),bh=!!(b.manifestRoot||b.targetRoot);
@@ -940,7 +968,7 @@ async function updCommitRollback(lease,expected){
940
  stale-metadata deadlock as Apply without weakening the lease check. */
941
  const current=activeLegacy?updBundleMeta(activeLegacy.result):records.activeMeta;
942
  const pending=records.pendingMeta||(pendingLegacy&&pendingLegacy.result)||null;
943
- if(expected&&!updSamePending(current,expected)){
944
  abort('The installed update changed before rollback','MF_UPDATE_ACTIVE_CHANGED');
945
  return;
946
  }
@@ -1285,6 +1313,11 @@ const UPD_TRANSFER_PREFIX='transfer-v1:', UPD_STORAGE_MARGIN=32*1024*1024;
1285
  protected explicitly, regardless of age. */
1286
  const UPD_TRANSFER_STALE_MS=7*24*60*60*1000;
1287
  const UPD_RANGE_IGNORE_MAX_BYTES=32*1024*1024;
 
 
 
 
 
1288
  function updTransferJournalKey(identity){ return UPD_TRANSFER_PREFIX+identity+':journal'; }
1289
  function updTransferFileKey(identity,path){ return UPD_TRANSFER_PREFIX+identity+':file:'+path; }
1290
  function updTransferChunkKey(identity,path,index){
@@ -1574,7 +1607,13 @@ async function updReadResponseBytes(response,limit,path,run,ac,onRead){
1574
  if(response.body&&response.body.getReader){
1575
  const reader=response.body.getReader();
1576
  for(;;){
1577
- const result=await reader.read(); updAssertDownload(run,ac);
 
 
 
 
 
 
1578
  if(result.done) break;
1579
  n+=result.value.byteLength;
1580
  if(n>limit) throw new Error(path+': download exceeded its declared size ('+
@@ -1583,7 +1622,13 @@ async function updReadResponseBytes(response,limit,path,run,ac,onRead){
1583
  if(onRead) onRead(result.value.byteLength);
1584
  }
1585
  }else{
1586
- const bytes=new Uint8Array(await response.arrayBuffer()); updAssertDownload(run,ac);
 
 
 
 
 
 
1587
  if(bytes.byteLength>limit) throw new Error(path+': download exceeded its declared size ('+
1588
  fmtBytes(bytes.byteLength)+' of '+fmtBytes(limit)+')');
1589
  parts.push(bytes); n=bytes.byteLength;
@@ -1593,13 +1638,90 @@ async function updReadResponseBytes(response,limit,path,run,ac,onRead){
1593
  for(const part of parts){ out.set(part,at); at+=part.byteLength; }
1594
  return out;
1595
  }
1596
- async function updFetchArtifactPart(src,m,file,chunk,index,count,run,ac,onRead){
1597
- const url=src+(src.includes('?')?'&':'?')+'v='+encodeURIComponent(m.version);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1598
  const headers={};
1599
  if(count>1) headers.Range='bytes='+chunk.offset+'-'+(chunk.offset+chunk.size-1);
1600
- const response=await fetch(url,{cache:'no-store',signal:ac.signal,headers});
 
 
 
 
 
1601
  updAssertDownload(run,ac);
1602
- if(!response.ok) throw new Error(file.path+': HTTP '+response.status);
 
1603
  const type=String(response.headers&&response.headers.get?response.headers.get('content-type')||'':'').toLowerCase();
1604
  if(count>1&&response.status===206){
1605
  const range=String(response.headers.get('content-range')||'');
@@ -1607,10 +1729,11 @@ async function updFetchArtifactPart(src,m,file,chunk,index,count,run,ac,onRead){
1607
  if(range.toLowerCase()!==expected.toLowerCase())
1608
  throw new Error(file.path+': server returned the wrong byte range');
1609
  const bytes=await updReadResponseBytes(response,chunk.size,file.path,run,ac,onRead);
1610
- if(bytes.byteLength!==chunk.size) throw new Error(file.path+': range download was incomplete ('+
1611
- fmtBytes(bytes.byteLength)+' of '+fmtBytes(chunk.size)+')');
 
1612
  await updVerifyHash(bytes,chunk.sha256,file.path+' range '+index,run,ac);
1613
- return {bytes,whole:false};
1614
  }
1615
  if(count>1&&file.size>UPD_RANGE_IGNORE_MAX_BYTES)
1616
  throw new Error(file.path+': download server must support byte ranges for artifacts over '+
@@ -1624,11 +1747,47 @@ async function updFetchArtifactPart(src,m,file,chunk,index,count,run,ac,onRead){
1624
  const hostPage=type.includes('text/html')||type.includes('application/xhtml');
1625
  const reason=bytes.byteLength===0?'download host returned no data':
1626
  hostPage?'download host returned a web page instead of update data':'download was incomplete';
1627
- throw new Error(file.path+': '+reason+' ('+fmtBytes(bytes.byteLength)+' of '+fmtBytes(limit)+')');
 
 
 
 
 
1628
  }
1629
- if(count>1){ await updVerifyHash(bytes,file.sha256,file.path,run,ac); return {bytes,whole:true}; }
1630
  await updVerifyHash(bytes,chunk.sha256,file.path,run,ac);
1631
- return {bytes,whole:false};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1632
  }
1633
  async function updDownloadArtifact(m,file,transfer,journal,src,run,ac,onBytes){
1634
  const saved=await updTransferGetFile(transfer,file,run,ac);
@@ -1666,7 +1825,7 @@ const UPD={ state:'idle', manifest:null, pct:0, got:0, total:0, rate:0, err:null
1666
  abort:null, lastCheck:0, checkedVersion:null, source:null, channel:'stable',
1667
  downloadSeq:0,downloadRun:0,retryDownload:false,
1668
  offerBytes:null,offerKind:null,offerFallback:false,transferKind:null,storage:null,
1669
- readyIdentity:null,
1670
  /* Per-file feed. The download loop has always walked m.files, but only
1671
  aggregate bytes were ever surfaced, so a multi-file patch looked
1672
  identical to one big blob and a stall gave no clue which object was
@@ -1697,6 +1856,14 @@ function mfUpdaterHistory(){
1697
  {features:release.features.slice(),fixes:release.fixes.slice(),
1698
  upcoming:release.upcoming.slice()}))};
1699
  }
 
 
 
 
 
 
 
 
1700
  function updStatusLabel(state){
1701
  const labels={idle:'Ready',unset:'Update service unavailable',offline:'Offline',
1702
  channeling:'Switching channel',checking:'Checking for updates',
@@ -1783,7 +1950,11 @@ function updPublishSnapshot(force){
1783
  function mfUpdaterAction(action){
1784
  const id=String(action||'').toLowerCase();
1785
  if(id==='check'){ updCheck(true); return true; }
1786
- if(id==='download'){ updDownload(); return true; }
 
 
 
 
1787
  if(id==='cancel'){ updCancel(); return true; }
1788
  if(id==='apply'){ updApply(); return true; }
1789
  if(id==='rollback'){ updRollback(); return true; }
@@ -1969,7 +2140,7 @@ async function updDownload(){
1969
  UPD.feed=files.map(f=>({path:f.path,size:f.size||0,state:'pending',got:0}));
1970
  UPD.fileIdx=-1;
1971
  updSet('downloading',{pct:0,got:0,total:initialTotal,rate:0,err:null,abort:ac,
1972
- retryDownload:false,readyIdentity:null});
1973
  const base=m.base||'';
1974
  const t0=performance.now();
1975
  const out={};
@@ -2014,14 +2185,27 @@ async function updDownload(){
2014
  const src=f.url||base+f.path;
2015
  let fileGot=0;
2016
  const text=await updDownloadArtifact(m,f,transfer,journal,src,run,ac,(n,resumed)=>{
2017
- const add=Math.max(0,Math.min(n,f.size-fileGot));
2018
- fileGot+=add; got+=add; if(!resumed) networkGot+=n;
 
 
 
 
 
 
 
 
 
 
 
 
2019
  if(UPD.feed[fi]) UPD.feed[fi].got=Math.min(f.size,fileGot);
2020
  const elapsed=(performance.now()-t0)/1000;
2021
  UPD.got=Math.min(total,got); UPD.pct=Math.min(99,UPD.got/total*100);
2022
  UPD.rate=elapsed>0.25?networkGot/elapsed:0;
2023
  if(typeof renderUpdatePanel==='function') renderUpdatePanel();
2024
  updPublishSnapshot(false);
 
2025
  });
2026
  out[f.path]=directArtifacts
2027
  ?{key:updTransferFileKey(transfer.identity,f.path),size:f.size,
@@ -2126,12 +2310,27 @@ async function updDownload(){
2126
  }
2127
  }
2128
  function updCancel(){ if(UPD.state==='downloading'&&UPD.abort) UPD.abort.abort(); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2129
 
2130
  /* ---- APPLY / ROLLBACK ------------------------------------------------------ */
2131
  async function updApply(){
2132
  if(updOperationBusy()) return;
2133
  const expected=UPD.readyIdentity;
2134
- const running=updRunningIdentity();
2135
  /* Applying owns storage from its first read onward. Acquiring this state
2136
  after `updGet('pending')` allowed a channel tap to clear the manifest while
2137
  the old channel's payload was already on its way to `active`. */
@@ -2149,7 +2348,13 @@ async function updApply(){
2149
  The copy is best-effort and lease-owned: quota failure cannot block the
2150
  install, while lost ownership cannot delete a newer window's copy. */
2151
  if(running&&!updSamePending(running,expected)){
2152
- try{ preparedPrevious=await updPreparePrevious(running,lease); }
 
 
 
 
 
 
2153
  catch(e){
2154
  if(e&&['MF_UPDATE_OPERATION_CHANGED','MF_UPDATE_ACTIVE_CHANGED'].includes(e.code))
2155
  throw e;
@@ -2713,7 +2918,7 @@ function updButton(){
2713
  should never be in, and updDownload() silently returns on one, so route it
2714
  to a fresh check instead of giving the player a button that does nothing. */
2715
  if(UPD.state==='available'&&UPD.manifest) updDownload();
2716
- else if(UPD.state==='error'&&UPD.retryDownload&&UPD.manifest) updDownload();
2717
  else if(UPD.state==='ready'||UPD.state==='applyError') updApply();
2718
  else updCheck(true);
2719
  }
 
42
  ============================================================================ */
43
 
44
  /* Bumped by the release script. Compared against the manifest's `version`. */
45
+ const APP_VERSION = '1.33.63';
46
 
47
  /* Release notes for the PACKAGED build, bumped by the release script beside
48
  APP_VERSION and PACKAGED_REV. A device that has never taken an OTA has no
49
  download history to read notes from, and an offline device can never fetch
50
  them, so the build carries its own copy — otherwise a fresh install shows a
51
  permanently empty first entry in the mailbox. */
52
+ const APP_NOTES = "Hotfix — Bug fixes: updates now finish installing on devices still running the v1.33.56 or earlier app shell. The final install step previously stopped with an 'installed update changed' error, which left those devices unable to move off the build they were already on. Upcoming: streamlined War Table and an imagery-first mobile interface overhaul.";
53
 
54
  /* The channel URL in update-config.json remains publisher-configurable, but a
55
  production checker also needs one known-good recovery path. More importantly,
 
584
  const db=await updIdb();
585
  return new Promise((res,rej)=>{
586
  const tx=db.transaction(UPD_STORE,'readwrite'),store=tx.objectStore(UPD_STORE);
587
+ let conflict=null,result=null,runningIdentity=null,ready=0;
588
  const operation=store.get(UPD_OPERATION_KEY);
589
  const meta=store.get('activeMeta');
590
  const previousRef=store.get('previousRef');
 
605
  lease-owned transaction while preserving the validated bytes. */
606
  const active=store.get('active');
607
  active.onsuccess=()=>{
608
+ if(!updStoredMatchesLegacyBoot(active.result,expected)){
609
  conflict=new Error('The installed update changed before rollback preservation');
610
  conflict.code='MF_UPDATE_ACTIVE_CHANGED';
611
  try{ tx.abort(); }catch(e){ rej(conflict); }
612
  return;
613
  }
614
+ runningIdentity=updPendingIdentity(active.result);
615
  /* The currently referenced rollback remains untouched until promotion
616
  succeeds. A failed/quota-aborted Apply can therefore discard only
617
  its inactive preparation slot, never the last validated recovery. */
 
631
  meta.onerror=()=>rej(meta.error||new Error('could not inspect installed update metadata'));
632
  previousRef.onerror=()=>rej(previousRef.error||new Error('could not inspect rollback pointer'));
633
  tx.oncomplete=()=>res(result);
634
+ const fail=message=>{
635
+ const original=conflict||tx.error||new Error(message);
636
+ if(!conflict&&runningIdentity){
637
+ const wrapped=new Error(original&&original.message||message);
638
+ wrapped.name=original&&original.name||'Error';
639
+ wrapped.mfRunningIdentity=runningIdentity;
640
+ rej(wrapped);
641
+ }else rej(original);
642
+ };
643
+ tx.onerror=()=>fail('could not save rollback copy');
644
+ tx.onabort=()=>fail('rollback-copy write aborted');
645
  });
646
  }
647
  async function updClearPreviousOwned(prepared,lease){
 
771
  updIdentityRootsMatch(a,b)&&
772
  String(a.at==null?'':a.at)===String(b.at==null?'':b.at));
773
  }
774
+ function updStoredMatchesLegacyBoot(stored,running){
775
+ if(updSamePending(stored,running)) return true;
776
+ if(!stored||!running) return false;
777
+ /* APK boot loaders through v1.33.56 predate schema-3 roots. They can execute
778
+ a fully rooted OTA record, but expose only version/channel/attempt to its
779
+ updater. Accept that one immutable-shell compatibility shape only while
780
+ reading the authoritative active payload; a descriptor-capable boot, a
781
+ partially populated running identity, or an unrooted stored record still
782
+ fails closed. The exact attempt token prevents a same-version rebuild from
783
+ borrowing consent from different staged bytes. */
784
+ if(typeof window!=='undefined'&&window.__MF_ARTIFACT_BOOT_V1) return false;
785
+ if(running.manifestRoot||running.targetRoot||running.runtimeRoot) return false;
786
+ const rooted=['manifestRoot','targetRoot','runtimeRoot'].every(key=>
787
+ /^[0-9a-f]{64}$/i.test(String(stored[key]||'')));
788
+ return !!(rooted&&String(stored.version)===String(running.version)&&
789
+ updChannelName(stored.channel||'stable')===updChannelName(running.channel||'stable')&&
790
+ String(stored.at==null?'':stored.at)===String(running.at==null?'':running.at));
791
+ }
792
  function updIdentityRootsMatch(a,b){
793
  if(!a||!b) return false;
794
  const ah=!!(a.manifestRoot||a.targetRoot),bh=!!(b.manifestRoot||b.targetRoot);
 
968
  stale-metadata deadlock as Apply without weakening the lease check. */
969
  const current=activeLegacy?updBundleMeta(activeLegacy.result):records.activeMeta;
970
  const pending=records.pendingMeta||(pendingLegacy&&pendingLegacy.result)||null;
971
+ if(expected&&!updStoredMatchesLegacyBoot(current,expected)){
972
  abort('The installed update changed before rollback','MF_UPDATE_ACTIVE_CHANGED');
973
  return;
974
  }
 
1313
  protected explicitly, regardless of age. */
1314
  const UPD_TRANSFER_STALE_MS=7*24*60*60*1000;
1315
  const UPD_RANGE_IGNORE_MAX_BYTES=32*1024*1024;
1316
+ /* Mobile radios and Android WebView redirect hand-offs occasionally drop one
1317
+ range even though the immutable object is healthy. Three bounded attempts
1318
+ repair that transient transport failure without turning a bad status,
1319
+ incorrect range, or failed hash into an infinite download loop. */
1320
+ const UPD_FETCH_ATTEMPTS=3, UPD_FETCH_BACKOFF_MS=220, UPD_FETCH_BACKOFF_CAP_MS=1100;
1321
  function updTransferJournalKey(identity){ return UPD_TRANSFER_PREFIX+identity+':journal'; }
1322
  function updTransferFileKey(identity,path){ return UPD_TRANSFER_PREFIX+identity+':file:'+path; }
1323
  function updTransferChunkKey(identity,path,index){
 
1607
  if(response.body&&response.body.getReader){
1608
  const reader=response.body.getReader();
1609
  for(;;){
1610
+ let result;
1611
+ try{ result=await reader.read(); }
1612
+ catch(error){
1613
+ updAssertDownload(run,ac);
1614
+ throw updTransportFailure(path+': network read failed','MF_UPDATE_NETWORK_READ',true);
1615
+ }
1616
+ updAssertDownload(run,ac);
1617
  if(result.done) break;
1618
  n+=result.value.byteLength;
1619
  if(n>limit) throw new Error(path+': download exceeded its declared size ('+
 
1622
  if(onRead) onRead(result.value.byteLength);
1623
  }
1624
  }else{
1625
+ let buffer;
1626
+ try{ buffer=await response.arrayBuffer(); }
1627
+ catch(error){
1628
+ updAssertDownload(run,ac);
1629
+ throw updTransportFailure(path+': network read failed','MF_UPDATE_NETWORK_READ',true);
1630
+ }
1631
+ const bytes=new Uint8Array(buffer); updAssertDownload(run,ac);
1632
  if(bytes.byteLength>limit) throw new Error(path+': download exceeded its declared size ('+
1633
  fmtBytes(bytes.byteLength)+' of '+fmtBytes(limit)+')');
1634
  parts.push(bytes); n=bytes.byteLength;
 
1638
  for(const part of parts){ out.set(part,at); at+=part.byteLength; }
1639
  return out;
1640
  }
1641
+ function updTransportFailure(message,code,retryable,status){
1642
+ const error=new Error(message); error.code=code;
1643
+ error.retryable=retryable===true;
1644
+ if(Number.isFinite(status)) error.status=status;
1645
+ return error;
1646
+ }
1647
+ function updRetryableHttp(status){
1648
+ return status===408||status===425||status===429||(status>=500&&status<=599);
1649
+ }
1650
+ function updArtifactHost(src){
1651
+ try{
1652
+ const base=typeof location!=='undefined'&&location.href?location.href:'https://local.invalid/';
1653
+ return (new URL(String(src),base).host||'local').slice(0,160);
1654
+ }catch(error){ return 'invalid-host'; }
1655
+ }
1656
+ function updSignedArtifactUrl(url){
1657
+ return /[?&](?:x-amz-[^=]*|x-goog-[^=]*|signature|sig|token|expires|policy|key-pair-id|awsaccesskeyid|googleaccessid|credential)=/i.test(url);
1658
+ }
1659
+ function updArtifactAttemptUrl(src,m,attempt){
1660
+ const signed=updSignedArtifactUrl(src);
1661
+ let url=signed?src:src+(src.includes('?')?'&':'?')+'v='+encodeURIComponent(m.version);
1662
+ /* A fresh query makes an immutable HF/Cloudflare URL resolve through the CDN
1663
+ again after a dropped redirect. Never append to an already signed URL:
1664
+ changing its query would invalidate the signature rather than retry it. */
1665
+ if(attempt>1&&!signed)
1666
+ url+=(url.includes('?')?'&':'?')+'mf_retry='+attempt+'-'+Date.now().toString(36);
1667
+ return url;
1668
+ }
1669
+ function updArtifactDiagnostic(src,chunk,index,count,attempt,error,outcome){
1670
+ const status=Number(error&&error.status);
1671
+ return Object.freeze({schema:1,outcome,attempt,maxAttempts:UPD_FETCH_ATTEMPTS,
1672
+ host:updArtifactHost(src),range:Object.freeze({index:index+1,count,
1673
+ start:chunk.offset,end:chunk.offset+chunk.size-1}),
1674
+ status:Number.isFinite(status)?status:null,
1675
+ online:typeof navigator==='undefined'||navigator.onLine!==false,
1676
+ code:String(error&&error.code||'MF_UPDATE_RESPONSE').slice(0,64)});
1677
+ }
1678
+ function updRememberTransferDiagnostic(diagnostic,warn){
1679
+ if(typeof UPD!=='undefined') UPD.transferDiagnostic=diagnostic;
1680
+ if(warn&&typeof console!=='undefined'&&typeof console.warn==='function')
1681
+ console.warn('MASSFRONT updater transport',diagnostic);
1682
+ }
1683
+ function updAttachTransferDiagnostic(error,diagnostic){
1684
+ try{ Object.defineProperty(error,'updateDiagnostic',{value:diagnostic,enumerable:true}); }
1685
+ catch(defineError){ try{ error.updateDiagnostic=diagnostic; }catch(assignError){} }
1686
+ return error;
1687
+ }
1688
+ function updRetryDelayMs(attempt){
1689
+ const base=Math.min(UPD_FETCH_BACKOFF_CAP_MS,UPD_FETCH_BACKOFF_MS*Math.pow(2,attempt-1));
1690
+ const room=Math.max(0,UPD_FETCH_BACKOFF_CAP_MS-base);
1691
+ return Math.round(base+Math.random()*Math.min(UPD_FETCH_BACKOFF_MS,room));
1692
+ }
1693
+ function updRetryDelay(ms,run,ac){
1694
+ updAssertDownload(run,ac);
1695
+ return new Promise((resolve,reject)=>{
1696
+ let settled=false,timer;
1697
+ const finish=(fn,value)=>{
1698
+ if(settled) return; settled=true;
1699
+ if(timer) clearTimeout(timer);
1700
+ if(ac&&ac.signal&&typeof ac.signal.removeEventListener==='function')
1701
+ ac.signal.removeEventListener('abort',cancel);
1702
+ fn(value);
1703
+ };
1704
+ const cancel=()=>finish(reject,updDownloadAbort());
1705
+ if(ac&&ac.signal&&typeof ac.signal.addEventListener==='function')
1706
+ ac.signal.addEventListener('abort',cancel,{once:true});
1707
+ timer=setTimeout(()=>{
1708
+ try{ updAssertDownload(run,ac); finish(resolve); }
1709
+ catch(error){ finish(reject,error); }
1710
+ },Math.max(0,ms));
1711
+ });
1712
+ }
1713
+ async function updFetchArtifactPartOnce(url,file,chunk,index,count,run,ac,onRead){
1714
  const headers={};
1715
  if(count>1) headers.Range='bytes='+chunk.offset+'-'+(chunk.offset+chunk.size-1);
1716
+ let response;
1717
+ try{ response=await fetch(url,{cache:'no-store',signal:ac.signal,headers}); }
1718
+ catch(error){
1719
+ updAssertDownload(run,ac);
1720
+ throw updTransportFailure(file.path+': network request failed','MF_UPDATE_NETWORK_FETCH',true);
1721
+ }
1722
  updAssertDownload(run,ac);
1723
+ if(!response.ok) throw updTransportFailure(file.path+': HTTP '+response.status,
1724
+ 'MF_UPDATE_HTTP',updRetryableHttp(response.status),response.status);
1725
  const type=String(response.headers&&response.headers.get?response.headers.get('content-type')||'':'').toLowerCase();
1726
  if(count>1&&response.status===206){
1727
  const range=String(response.headers.get('content-range')||'');
 
1729
  if(range.toLowerCase()!==expected.toLowerCase())
1730
  throw new Error(file.path+': server returned the wrong byte range');
1731
  const bytes=await updReadResponseBytes(response,chunk.size,file.path,run,ac,onRead);
1732
+ if(bytes.byteLength!==chunk.size) throw updTransportFailure(
1733
+ file.path+': range download was incomplete ('+fmtBytes(bytes.byteLength)+' of '+
1734
+ fmtBytes(chunk.size)+')','MF_UPDATE_INCOMPLETE',true);
1735
  await updVerifyHash(bytes,chunk.sha256,file.path+' range '+index,run,ac);
1736
+ return {bytes,whole:false,status:response.status};
1737
  }
1738
  if(count>1&&file.size>UPD_RANGE_IGNORE_MAX_BYTES)
1739
  throw new Error(file.path+': download server must support byte ranges for artifacts over '+
 
1747
  const hostPage=type.includes('text/html')||type.includes('application/xhtml');
1748
  const reason=bytes.byteLength===0?'download host returned no data':
1749
  hostPage?'download host returned a web page instead of update data':'download was incomplete';
1750
+ throw updTransportFailure(file.path+': '+reason+' ('+fmtBytes(bytes.byteLength)+' of '+
1751
+ fmtBytes(limit)+')',hostPage?'MF_UPDATE_HOST_PAGE':'MF_UPDATE_INCOMPLETE',!hostPage);
1752
+ }
1753
+ if(count>1){
1754
+ await updVerifyHash(bytes,file.sha256,file.path,run,ac);
1755
+ return {bytes,whole:true,status:response.status};
1756
  }
 
1757
  await updVerifyHash(bytes,chunk.sha256,file.path,run,ac);
1758
+ return {bytes,whole:false,status:response.status};
1759
+ }
1760
+ async function updFetchArtifactPart(src,m,file,chunk,index,count,run,ac,onRead){
1761
+ for(let attempt=1;attempt<=UPD_FETCH_ATTEMPTS;attempt++){
1762
+ let attemptRead=0;
1763
+ try{
1764
+ const result=await updFetchArtifactPartOnce(updArtifactAttemptUrl(src,m,attempt),file,
1765
+ chunk,index,count,run,ac,n=>{
1766
+ const credited=onRead?onRead(n):n;
1767
+ /* A whole-file legacy response can arrive after earlier ranges were
1768
+ resumed, so the UI may legitimately credit fewer bytes than the
1769
+ socket delivered. Roll back exactly that retained-progress delta,
1770
+ never the already durable ranges from a prior attempt. */
1771
+ attemptRead+=Number.isFinite(credited)?Math.max(0,credited):n;
1772
+ });
1773
+ if(attempt>1) updRememberTransferDiagnostic(
1774
+ updArtifactDiagnostic(src,chunk,index,count,attempt,
1775
+ {status:result.status,code:'MF_UPDATE_RECOVERED'},'recovered'),false);
1776
+ return result;
1777
+ }catch(error){
1778
+ /* A player cancellation is never converted into a retry. It also skips
1779
+ the backoff immediately through the shared AbortSignal. */
1780
+ updAssertDownload(run,ac);
1781
+ if(attemptRead&&onRead) onRead(-attemptRead);
1782
+ const retry=error&&error.retryable===true&&attempt<UPD_FETCH_ATTEMPTS;
1783
+ const diagnostic=updArtifactDiagnostic(src,chunk,index,count,attempt,error,
1784
+ retry?'retrying':'failed');
1785
+ updRememberTransferDiagnostic(diagnostic,true);
1786
+ if(!retry) throw updAttachTransferDiagnostic(error,diagnostic);
1787
+ await updRetryDelay(updRetryDelayMs(attempt),run,ac);
1788
+ }
1789
+ }
1790
+ throw new Error(file.path+': update transfer failed');
1791
  }
1792
  async function updDownloadArtifact(m,file,transfer,journal,src,run,ac,onBytes){
1793
  const saved=await updTransferGetFile(transfer,file,run,ac);
 
1825
  abort:null, lastCheck:0, checkedVersion:null, source:null, channel:'stable',
1826
  downloadSeq:0,downloadRun:0,retryDownload:false,
1827
  offerBytes:null,offerKind:null,offerFallback:false,transferKind:null,storage:null,
1828
+ readyIdentity:null,transferDiagnostic:null,
1829
  /* Per-file feed. The download loop has always walked m.files, but only
1830
  aggregate bytes were ever surfaced, so a multi-file patch looked
1831
  identical to one big blob and a stall gave no clue which object was
 
1856
  {features:release.features.slice(),fixes:release.fixes.slice(),
1857
  upcoming:release.upcoming.slice()}))};
1858
  }
1859
+ /* Safe support/debug surface. It deliberately returns only transport shape,
1860
+ never the signed URL, query, hash, manifest, or executable file name. */
1861
+ function mfUpdaterTransferDiagnostic(){
1862
+ const value=UPD.transferDiagnostic;
1863
+ if(!value) return null;
1864
+ return Object.assign({},value,{range:value.range?Object.assign({},value.range):null});
1865
+ }
1866
+ if(typeof window!=='undefined') window.mfUpdaterTransferDiagnostic=mfUpdaterTransferDiagnostic;
1867
  function updStatusLabel(state){
1868
  const labels={idle:'Ready',unset:'Update service unavailable',offline:'Offline',
1869
  channeling:'Switching channel',checking:'Checking for updates',
 
1950
  function mfUpdaterAction(action){
1951
  const id=String(action||'').toLowerCase();
1952
  if(id==='check'){ updCheck(true); return true; }
1953
+ if(id==='download'){
1954
+ if(UPD.state==='error'&&UPD.retryDownload&&UPD.manifest) updRetryDownload();
1955
+ else updDownload();
1956
+ return true;
1957
+ }
1958
  if(id==='cancel'){ updCancel(); return true; }
1959
  if(id==='apply'){ updApply(); return true; }
1960
  if(id==='rollback'){ updRollback(); return true; }
 
2140
  UPD.feed=files.map(f=>({path:f.path,size:f.size||0,state:'pending',got:0}));
2141
  UPD.fileIdx=-1;
2142
  updSet('downloading',{pct:0,got:0,total:initialTotal,rate:0,err:null,abort:ac,
2143
+ retryDownload:false,readyIdentity:null,transferDiagnostic:null});
2144
  const base=m.base||'';
2145
  const t0=performance.now();
2146
  const out={};
 
2185
  const src=f.url||base+f.path;
2186
  let fileGot=0;
2187
  const text=await updDownloadArtifact(m,f,transfer,journal,src,run,ac,(n,resumed)=>{
2188
+ /* A failed network attempt streamed bytes that were never retained.
2189
+ The range wrapper reports their negative delta before retrying so
2190
+ the progress bar cannot reach 100% on duplicate transient reads. */
2191
+ let credited=0;
2192
+ if(n<0){
2193
+ const remove=Math.min(fileGot,-n);
2194
+ fileGot-=remove; got=Math.max(0,got-remove);
2195
+ credited=-remove;
2196
+ }else{
2197
+ const add=Math.max(0,Math.min(n,f.size-fileGot));
2198
+ fileGot+=add; got+=add;
2199
+ credited=add;
2200
+ if(!resumed) networkGot+=n;
2201
+ }
2202
  if(UPD.feed[fi]) UPD.feed[fi].got=Math.min(f.size,fileGot);
2203
  const elapsed=(performance.now()-t0)/1000;
2204
  UPD.got=Math.min(total,got); UPD.pct=Math.min(99,UPD.got/total*100);
2205
  UPD.rate=elapsed>0.25?networkGot/elapsed:0;
2206
  if(typeof renderUpdatePanel==='function') renderUpdatePanel();
2207
  updPublishSnapshot(false);
2208
+ return credited;
2209
  });
2210
  out[f.path]=directArtifacts
2211
  ?{key:updTransferFileKey(transfer.identity,f.path),size:f.size,
 
2310
  }
2311
  }
2312
  function updCancel(){ if(UPD.state==='downloading'&&UPD.abort) UPD.abort.abort(); }
2313
+ /* RETRY is fresh consent to continue the same immutable release, not consent to
2314
+ trust yesterday's CDN URLs forever. Re-check the channel first so a delivery
2315
+ repair can repoint those URLs. Identity roots and ordered byte fingerprints
2316
+ exclude URL location but bind executable content: only that exact release
2317
+ may resume automatically. A newly published release remains AVAILABLE and
2318
+ waits for its own explicit DOWNLOAD action. */
2319
+ async function updRetryDownload(){
2320
+ if(UPD.state!=='error'||!UPD.retryDownload||!UPD.manifest||updOperationBusy()) return false;
2321
+ const failedManifest=UPD.manifest;
2322
+ await updCheck(true);
2323
+ if(UPD.state!=='available'||!UPD.manifest||
2324
+ !updManifestSameRelease(failedManifest,UPD.manifest)) return false;
2325
+ await updDownload();
2326
+ return true;
2327
+ }
2328
 
2329
  /* ---- APPLY / ROLLBACK ------------------------------------------------------ */
2330
  async function updApply(){
2331
  if(updOperationBusy()) return;
2332
  const expected=UPD.readyIdentity;
2333
+ let running=updRunningIdentity();
2334
  /* Applying owns storage from its first read onward. Acquiring this state
2335
  after `updGet('pending')` allowed a channel tap to clear the manifest while
2336
  the old channel's payload was already on its way to `active`. */
 
2348
  The copy is best-effort and lease-owned: quota failure cannot block the
2349
  install, while lost ownership cannot delete a newer window's copy. */
2350
  if(running&&!updSamePending(running,expected)){
2351
+ try{
2352
+ preparedPrevious=await updPreparePrevious(running,lease);
2353
+ /* Preparation read the authoritative active payload. Replace the
2354
+ root-less legacy boot report with that exact stored identity so the
2355
+ later promotion transaction remains root-strict. */
2356
+ if(preparedPrevious) running=updPendingIdentity(preparedPrevious);
2357
+ }
2358
  catch(e){
2359
  if(e&&['MF_UPDATE_OPERATION_CHANGED','MF_UPDATE_ACTIVE_CHANGED'].includes(e.code))
2360
  throw e;
 
2918
  should never be in, and updDownload() silently returns on one, so route it
2919
  to a fresh check instead of giving the player a button that does nothing. */
2920
  if(UPD.state==='available'&&UPD.manifest) updDownload();
2921
+ else if(UPD.state==='error'&&UPD.retryDownload&&UPD.manifest) updRetryDownload();
2922
  else if(UPD.state==='ready'||UPD.state==='applyError') updApply();
2923
  else updCheck(true);
2924
  }
sw.js CHANGED
@@ -3,7 +3,7 @@
3
  only after the player has successfully fetched them. */
4
  'use strict';
5
 
6
- const MF_SW_VERSION = '1.33.61-shell3';
7
  const MF_SW_PREFIX = 'massfront-pwa-';
8
  const MF_SW_CACHE = MF_SW_PREFIX + MF_SW_VERSION;
9
  const MF_SW_UPDATE_DB = 'massfront-updates';
 
3
  only after the player has successfully fetched them. */
4
  'use strict';
5
 
6
+ const MF_SW_VERSION = '1.33.63-shell3';
7
  const MF_SW_PREFIX = 'massfront-pwa-';
8
  const MF_SW_CACHE = MF_SW_PREFIX + MF_SW_VERSION;
9
  const MF_SW_UPDATE_DB = 'massfront-updates';