(()=>{'use strict';
const body=document.body;
const phase=document.getElementById('phase');
if(!body||!phase)return;

function sync(){
  const t=(phase.textContent||'').trim().toUpperCase();
  const open=t==='BETTING';
  body.classList.toggle('lz-betting-open',open);

  // Defensive DOM cleanup for bot chips that were created just as betting locked.
  if(!open){
    document.querySelectorAll('.lz-flying-chip,.lz-landed-chip').forEach(el=>el.remove());
  }
}
sync();
new MutationObserver(sync).observe(phase,{childList:true,subtree:true,characterData:true});
})();