// Static markup: elements with data-i18n="label" get their text, and data-i18n-aria-label / data-i18n-title // their attribute, from the dictionary once at boot. The English stays in the markup for search engines. function i18nDom(){if(LANG==='en')return;for(const el of document.querySelectorAll('[data-i18n]'))el.textContent=tr(el.dataset.i18n); for(const a of ['aria-label','title'])for(const el of document.querySelectorAll(`[data-i18n-${a}]`))el.setAttribute(a,tr(el.getAttribute('data-i18n-'+a)));} // One button per [value,label] option; the current one is highlighted. // One dropdown instead of a button per language: the list keeps growing, and on phones the system picker opens. // Each language is named in itself (lang= lets screen readers say it right). const langPick=id=>``; function segBtns(act,cur,opts){return opts.map(([v,l])=>btn(l,act,{v},cur===v?'pink sm':'ghost sm')).join('');} /* Animation setting: auto follows the system's reduced-motion preference, or force it on or off. */ /* Settings are per device (localStorage), not part of the save: they are about how you like to play. */ const PREF_DEF={pauseFurious:true,warnUnhappy:true,pauseIncident:false,quiet:false}; let PREFS=(()=>{try{const j=JSON.parse(localStorage.getItem('sot-prefs')||'{}');return j&&typeof j==='object'?j:{};}catch(e){return {};}})(); const pref=k=>typeof PREFS[k]==='boolean'?PREFS[k]:PREF_DEF[k]; // Quiet notifications: the player's choice once made, until then on in Best Effort only. const quietOn=()=>typeof PREFS.quiet==='boolean'?PREFS.quiet:rulePreset()==='soft'; function setPref(k,v){if(!own(PREF_DEF,k))return;PREFS[k]=!!v;try{localStorage.setItem('sot-prefs',JSON.stringify(PREFS));}catch(e){}} // Stop the clock for something the player must see. Nothing happens if the game is already paused. function autoPause(){if(!S||!UI.speed)return false;UI.resumeSpeed=UI.speed;UI.speed=0;renderHUD();return true;} const resumeAct=()=>({l:tr('common.resume'),act:'speed',args:{v:UI.resumeSpeed||1}}); function settingsHtml(){const seg=(lab,act,cur,opts,note)=>`
${lab}
${segBtns(act,cur,opts)}
${note?`

${note}

`:''}`; const onoff=k=>[[k+':1',tr('common.on')],[k+':0',tr('common.off')]],cur=k=>k+':'+((k==='quiet'?quietOn():pref(k))?1:0); return `

⚙️ ${tr('common.settings')}

${tr('settings.saved_on_this_device')}

${tr('settings.customers_and_alerts')}

${seg(tr('settings.pause_when_a_customer_is_furious'),'prefSet',cur('pauseFurious'),onoff('pauseFurious'),tr('settings.the_game_stops_so_you_can'))} ${seg(tr('settings.warn_when_a_customer_gets_unhappy'),'prefSet',cur('warnUnhappy'),onoff('warnUnhappy'),tr('settings.an_early_heads_up_below_60'))} ${seg(tr('settings.pause_on_outages_that_hurt'),'prefSet',cur('pauseIncident'),onoff('pauseIncident'),tr('settings.stops_the_game_when_a_failure'))} ${seg(tr('settings.quiet_notifications'),'prefSet',cur('quiet'),onoff('quiet'),tr('settings.only_trouble_and_milestones_pop_up'))}

${tr('settings.display_and_sound')}

${seg(tr('common.animations'),'animSet',UI.anim||'auto',[['auto',tr('common.auto')],['on',tr('common.on')],['off',tr('common.off')]],tr('settings.auto_follows_your_device_s_reduce'))} ${seg(tr('common.sound'),'soundSet',UI.muted?'off':'on',[['on',tr('common.on')],['off',tr('common.off')]])}
${langPick('langSel')}
${seg(tr('common.viewport_info'),'vpSet',VP_T?'on':'off',[['on',tr('common.on')],['off',tr('common.off')]],tr('settings.for_reporting_layout_bugs_shows_what'))} ${installRow()}
${btn(tr('common.done_8dd3'),'settingsClose',{},'pink')}
`;} const refreshSettings=()=>{if(UI.setOpen)openModal(settingsHtml());}; function animOn(){const m=UI.anim||'auto';if(m==='on')return true;if(m==='off')return false;try{return !matchMedia('(prefers-reduced-motion: reduce)').matches;}catch(e){return true;}} function applyAnim(){const r=document.documentElement;r.classList.toggle('no-anim',UI.anim==='off');r.classList.toggle('anim-force',UI.anim==='on');if(!animOn())FLOATS.length=0;} const toS=(wx,wy,k=0)=>[(wx+k*W-cam.x)*cam.z+CW/2,(wy-cam.y)*cam.z+CH/2]; const iconScale=()=>clamp(Math.sqrt(cam.z),0.7,1.35);