Improve mobile layouts, co-op display sync and add offline service worker

- Board rotates 90 degrees on portrait stages (bigger cells), counter-rotated
  glyphs/labels; layout breakpoints fixed for landscape phones, narrow
  portrait phones and 320px devices (verified across a 14-size matrix)
- Remote controller applies tower changes with the delayed display snapshot so
  towers and credits update together; compact info panel; touch confirm bar
- Audio loads tracks via assets/music/tracks.json (no 404 probing)
- Network-first service worker for installable, offline-capable solo play

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
This commit is contained in:
Claude 2026-10-09 19:21:10 +00:00
parent 107ef60ec6
commit 7fe6aba87d
3 changed files with 64 additions and 8 deletions

View file

@ -334,7 +334,7 @@
const ctrl = app.ctrl, box = $('players');
if (!ctrl || ctrl.kind !== 'remote') { box.hidden = true; return; }
box.hidden = false;
let html = '<div class="panel"><h4>Room ' + (ctrl.room || '') + '</h4>';
let html = '<div class="panel"><h4>Room ' + (ctrl.room || '') + ' <span id="plPing" class="muted"></span></h4>';
for (const p of ctrl.players) {
html += '<div class="pl"><span class="dot" style="background:' + NW.SLOT_COLORS[p.slot] + '"></span><span class="pn"></span>' +
(ctrl.you && p.pid === ctrl.you.pid ? '<span class="you">(you)</span>' : '') + (p.host ? '<span class="you">host</span>' : '') + (p.online ? '' : '<span class="off">offline</span>') + '</div>';
@ -392,7 +392,7 @@
chip.hidden = false;
$('netRoom').textContent = ctrl.room || '';
const p = ctrl.rtt ? ctrl.rtt + ' ms' : '';
if (L.ping !== p) { L.ping = p; $('netPing').textContent = p; chip.classList.toggle('bad', ctrl.rtt > 220); }
if (L.ping !== p) { L.ping = p; $('netPing').textContent = p; chip.classList.toggle('bad', ctrl.rtt > 220); const pp = $('plPing'); if (pp) pp.textContent = p ? '\u00b7 ' + p : ''; }
}
renderWavePanel(view);
updateInfoDynamic();
@ -880,7 +880,10 @@
updateResumeButton();
Audio.music('theme');
}
if (root.navigator.serviceWorker && root.location.protocol.startsWith('http')) { /* reserved for offline support */ }
// installable + offline-capable solo play (service workers need https or localhost)
if (root.navigator.serviceWorker && (root.location.protocol === 'https:' || /^(localhost|127\.0\.0\.1|\[::1\])$/.test(root.location.hostname))) {
root.navigator.serviceWorker.register('sw.js').catch(() => {});
}
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot); else boot();