diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6571cb5..65c8f06 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ All notable changes to this project are documented here. The project follows
- "Meet halfway" on a renewal now offers the price halfway between what the customer pays and what they ask, and the button shows it before you press (#293).
- Fujairah sits on the UAE's east coast again, where its cables land, instead of on top of Muscat (#295).
+- Puzzles on phones no longer scroll. A bar at the top shows the stars, the money and the one thing to do next, with a chip for every flow that turns green once it all arrives; tap a chip to jump to its city. A city or a link opens a short card at the bottom, split into tabs (links, router, traffic; size, traffic, routing), so every button is on screen at once. Architect runs get the same bar, and Reset is in the β° menu on phones.
## [2.10.0] β 2026-11-05
diff --git a/src/agent/20-commands.js b/src/agent/20-commands.js
index d1dc62c..c243ed2 100644
--- a/src/agent/20-commands.js
+++ b/src/agent/20-commands.js
@@ -439,6 +439,8 @@ const API_VIEW={
bankClose:{args:[],doc:'Close the bank.'},
closePanel:{args:[],doc:'Close the selection panel.'},
tab:{args:[['t','string']],doc:'Switch the city panel\'s tab.'},
+ pzCity:{args:[['c','cityId']],doc:'Puzzles on a phone: open a city\'s card from its flow chip.'},
+ pzTab:{args:[['k','string'],['t','string']],doc:'Puzzles on a phone: switch the city (k:"city") or link (k:"link") card\'s tab.'},
leftTab:{args:[['t','leftTab']],doc:'Switch the left drawer and open it.'},
toggleLeft:{args:[],doc:'Open or close the left drawer.'},
netFocus:{args:[['id','netId']],doc:'Focus one network in the left drawer.'},
diff --git a/src/game/90-actions/95-puzzles.js b/src/game/90-actions/95-puzzles.js
index 3af3af5..881800c 100644
--- a/src/game/90-actions/95-puzzles.js
+++ b/src/game/90-actions/95-puzzles.js
@@ -14,6 +14,10 @@ Object.assign(ACT,{
pzRetry:()=>{if(!pzOn())return;if(S.ar){arBegin(arRun());return;}pzBegin(S.pz.id==='weekly'?pzWkDef():pzDef(S.pz.id));},
pzLeave:()=>{if(pzOn())pzLeave();},
// The sheet's next-fix line: bring the city, or the link a cut hurts most, into view (the zoom stays).
+ // Phones split a puzzle's city and link cards into tabs (97-puzzles-phone.js); the tab shown is kept per kind of card.
+ pzTab:({k,t})=>{if(!pzOn()||!['city','link'].includes(k)||typeof t!=='string')return;UI.pzTab={...(UI.pzTab||{}),[k]:t};renderPanel();},
+ // A flow chip on a phone: that city's card, with the city on screen.
+ pzCity:({c})=>{if(!pzOn()||!isCity(c)||!pzKind(c))return;ACT.pzLook({c});selectCity(c);renderTabbar();},
pzLook:({c,u})=>{if(!pzOn())return;let x,y;if(c&&isCity(c)){x=CITY[c].x;y=CITY[c].y;}else{const l=u&&S.links.find(q=>pzUnit(q)===u);if(!l)return;const A=CITY[l.a],B=CITY[l.b];x=A.x+wrapDx(A.x,B.x)/2;y=(A.y+B.y)/2;}
const sh=isPhone()&&CW<=CH?($('pzBox').offsetHeight||0):0;cam.x=x;cam.y=y+sh/2/cam.z;wrapCam();haptic(8);},
pzPop:({city})=>{if(!pzOn()||S.pops[city]||!['goal','via','off'].includes(pzKind(city)))return;pzSnap();S.pops[city]=pzNewPop(city);sfx('build');haptic(10);floater(CITY[city].x,CITY[city].y-30,tr('common.new_pop'),'#FF4F9A');pzAfter();},
@@ -49,7 +53,7 @@ Object.assign(ACT,{
// A circuit follows the metrics (the IGP's shortest path) or takes the lowest-latency path, as customers can in the main game.
pzRoute:({i,m})=>{const b=pzOn()&&S.biz.find(x=>x.id===pzFlowId(+i));if(!b||!['normal','fast'].includes(m)||b.route===m)return;pzSnap();b.route=m;sfx('click');pzAfter();},
pzUndo:()=>{const h=UI.pzHist;if(!pzOn()||!h||!h.length)return;if(S.ar)arStop(true);const o=JSON.parse(h.pop());S.pops=o.p;S.links=o.l;S.pairMet=o.m||{};if(S.ar){S.ar.sunk=o.k||0;arDemand();}(o.r||[]).forEach((m,i)=>{if(S.biz[i])S.biz[i].route=m;});sfx('click');pzAfter();},
- pzReset:()=>{if(!pzOn())return;pzSnap();if(S.ar){arReset();sfx('click');pzAfter();return;}S.pops={};S.links=[];S.pairMet={};for(const b of S.biz)b.route='normal';UI.sel=null;sfx('click');pzAfter();},
+ pzReset:()=>{if(!pzOn())return;if(!$('modal').hidden)closeModal();pzSnap();if(S.ar){arReset();sfx('click');pzAfter();return;}S.pops={};S.links=[];S.pairMet={};for(const b of S.biz)b.route='normal';UI.sel=null;sfx('click');pzAfter();},
pzShare:()=>{if(!pzOn())return;const t=S.ar?arShareText(arStars(arSpend()),arSpend()):pzShareText(pzEval());
const copied=()=>toast(tr('puzzles.copied_paste_it_anywhere',{t:esc(t)}),'good'),copy=()=>{try{navigator.clipboard.writeText(t).then(copied,()=>toast(esc(t),''));}catch(e){toast(esc(t),'');}};
if(navigator.share&&isPhone()){navigator.share({text:t}).catch(()=>{});return;}copy();track('puzzle_share');},
diff --git a/src/game/93-ui/20-phone.js b/src/game/93-ui/20-phone.js
index d428192..0daaa54 100644
--- a/src/game/93-ui/20-phone.js
+++ b/src/game/93-ui/20-phone.js
@@ -13,11 +13,10 @@ function renderTabbar(){const tb=$('tabbar');if(!tb||(pressing&&UI.ticking))retu
function haptic(ms){if(UI.muted)return;try{navigator.vibrate&&navigator.vibrate(ms||12);}catch(e){}}
// Bottom sheets: drag the handle up to expand, down to shrink or close; tap it to toggle.
(function(){let g=null;
- document.addEventListener('pointerdown',e=>{const h=e.target.closest('[data-grab]');if(!h||!isPhone()||e.target.closest('button,select,input'))return;const el=h.dataset.grab==='pz'?$('pzBox'):h.parentElement;g={el,y:e.clientY,dy:0,id:e.pointerId,full:el.classList.contains('full')};try{h.setPointerCapture(e.pointerId);}catch(_){}el.style.transition='none';});
+ document.addEventListener('pointerdown',e=>{const h=e.target.closest('[data-grab]');if(!h||!isPhone()||e.target.closest('button,select,input'))return;const el=h.parentElement;g={el,y:e.clientY,dy:0,id:e.pointerId,full:el.classList.contains('full')};try{h.setPointerCapture(e.pointerId);}catch(_){}el.style.transition='none';});
document.addEventListener('pointermove',e=>{if(!g||e.pointerId!==g.id)return;g.dy=e.clientY-g.y;if(g.dy>0)g.el.style.transform=`translateY(${g.dy}px)`;});
const end=e=>{if(!g||e.pointerId!==g.id)return;const {el,dy,full}=g;g=null;el.style.transition='';el.style.transform='';
- if(Math.abs(dy)<6){el.classList.toggle(el.id==='pzBox'?'mini':'full');return;}
- if(el.id==='pzBox'){el.classList.toggle('mini',dy>0);return;}
+ if(Math.abs(dy)<6){el.classList.toggle('full');return;}
if(dy<-40){el.classList.add('full');return;}
if(dy>40){if(full){el.classList.remove('full');return;}if(el.id==='panel')ACT.closePanel();else{UI.leftOpen=false;renderLeft();}}};
document.addEventListener('pointerup',end);document.addEventListener('pointercancel',end);})();
diff --git a/src/game/95-modals/95-puzzles.js b/src/game/95-modals/95-puzzles.js
index b7e1ada..529e81a 100644
--- a/src/game/95-modals/95-puzzles.js
+++ b/src/game/95-modals/95-puzzles.js
@@ -35,12 +35,12 @@ function pzGoalRow(g,i){const ic=g.done?'β':g.cur?'π':`${i+1}`;
+(g.cur&&g.hint?`
`:'')+``;}
// A delivered eyeball flow is a chip; anything still short, a circuit or a latency cap keeps its full row.
const pzChip=x=>`π ${esc(CITY[x.f.a].name)} ${fmtG(x.f.g)} β`;
-function pzRender(){const el=$('pzBox');if(!pzOn()){el.hidden=true;return;}el.hidden=false;el.classList.toggle('ar',!!S.ar);if(S.ar){arRender(el);return;}
+function pzRender(){const el=$('pzBox');if(!pzOn()){el.hidden=true;return;}el.hidden=false;el.classList.toggle('ar',!!S.ar);UI._pzPhone=isPhone();if(S.ar){el.classList.toggle('dock',UI._pzPhone);(UI._pzPhone?arDock:arRender)(el);return;}
const e=pzEval(),P=S.pz,d=pzDef(P.id),pk=d&&PZ_PACKS.find(x=>x.id===d.pack);
- // A phone held upright starts each puzzle with the sheet down to its status bar, so the map has the room (swipe it up for the rest).
- const pk2=P.id+'|'+(P.key||'');if(UI._pzPeek!==pk2){UI._pzPeek=pk2;el.classList.toggle('mini',isPhone()&&CW<=CH);}
+ // A phone gets fixed overlays that never scroll (97-puzzles-phone.js).
+ el.classList.toggle('dock',UI._pzPhone);if(UI._pzPhone){pzDock(el,e);return;}
const sp=fmt$(e.spend);
- // The status bar stays at the top of the sheet, whatever scrolls: the puzzle, its stars, the money, undo and the menu.
+ // The status bar stays at the top of the card, whatever scrolls: the puzzle, its stars, the money, undo and the menu.
let h=`
`;
h+=arMenuRows();
h+=pzWkRow();
// The packs' own total, right above them: it is what unlocks the next pack (#231). Runs and weeklies count their own.
diff --git a/src/game/95-modals/97-puzzles-phone.js b/src/game/95-modals/97-puzzles-phone.js
new file mode 100644
index 0000000..53a59f8
--- /dev/null
+++ b/src/game/95-modals/97-puzzles-phone.js
@@ -0,0 +1,95 @@
+/* ---------- puzzles on a phone: fixed overlays that never scroll ----------
+ A bar pinned at the top says how the puzzle stands (its name, the three stars, the money, undo and the menu), the one
+ thing to do next and what each flow gets, as chips. A city or a link opens a card at the bottom whose content is
+ split into tabs, so each tab fits on the screen. Desktop keeps the side card (pzRender, pzPanel). */
+// A rate in a few characters, for the chips: 30G, 2.5G, 1.2T.
+const pzG=g=>g>=1000?(g/1000).toFixed(g>=10000?0:1)+'T':g>=10||g===0?Math.round(g)+'G':g.toFixed(1)+'G';
+// One flow as a chip: what it is, how much of it arrives, a circuit's latency against its cap. Tapping it shows the city.
+function pzFlowChip(x){const f=x.f,ok=x.full&&x.fast,part=x.g>0&&!ok;
+ const lat=f.ms?` Β· ${x.ms==null?'β':x.ms.toFixed(1)}/${f.ms} ms`:'';
+ return ``;}
+// The rules of this puzzle as chips: the content's home, the cities to avoid, no subsea cables, the ring.
+function pzRuleChips(e){const P=S.pz;let h='';
+ if(P.src.length)h+=`ποΈ ${P.src.map(c=>esc(CITY[c].name)).join(', ')}`;
+ for(const t of e.tw)h+=t.k==='avoid'?`π« ${P.avoid.map(c=>esc(CITY[c].name)).join(', ')}`:`${t.ok?'β':'β'} ${pzTwistTxt(t)}`;
+ return h;}
+function pzDock(el,e){const P=S.pz,d=pzDef(P.id),gs=pzGoals(e),cur=gs.find(g=>g.cur);UI.pzMark=!UI.pzMk&&cur&&cur.mark||null;
+ const stars=gs.map((g,i)=>`${g.done?'β':i+1}`).join('');
+ const bud=P.budget?`${fmt$(e.spend)} / ${fmt$(P.budget)}`:`${tr('puzzles.free')}`;
+ let h=`
`;
+ if(h!==UI._pzh){UI._pzh=h;morph(el,h);}}
+// The bar's height, for what must sit under it (toasts) or stop short of it (the card): it changes with its content and
+// when a card opens, so it is watched rather than measured after each render.
+try{new ResizeObserver(()=>{const H=$('pzBox').offsetHeight||0;document.documentElement.style.setProperty('--pzdock',H+'px');}).observe($('pzBox'));}catch(e){}
+// An architect run on a phone: the same bar. The brief, its sites and rules as chips, and the review with its one button.
+function arDock(el){const A=S.ar,run=arRun(),b=arBrief(),e=arEval(),sh=UI.arShow,f=UI.arFail,n=run.briefs.length,nm=c=>esc(CITY[c].name),T=e.tubes;
+ let h=`
`;
+ if(h!==UI._pzh){UI._pzh=h;morph(el,h);}}
+// The tabs of a card; the one shown is kept per kind of card (city or link) while the puzzle runs.
+const pzTabs=(kind,tabs,cur)=>``;
+const pzTabOf=(kind,tabs,def)=>{const t=(UI.pzTab||{})[kind];return tabs.some(([k])=>k===t)?t:def;};
+// The card's head in two short lines: what it is (and whether it is yours) above the name, the facts beside the name.
+const pzHead=(eb,name,facts)=>`
`;
+ for(const x of nb){const ls=pairLinks(c,x),ld=ls.reduce((a,l)=>a+(R.load[l.id]||0),0),cp=ls.filter(l=>!linkDown(l)).reduce((a,l)=>a+capOf(l),0);
+ h+=`
';}
+// A phone turned or a window resized can switch between the two layouts: draw the puzzle again in the one that fits.
+addEventListener('resize',()=>{if(!S||!pzOn())return;const ph=isPhone();if(ph===UI._pzPhone)return;UI._pzh=null;UI._ph=null;pzRender();renderPanel();});
diff --git a/src/styles/70-puzzles.css b/src/styles/70-puzzles.css
index 39275c0..ace2ce8 100644
--- a/src/styles/70-puzzles.css
+++ b/src/styles/70-puzzles.css
@@ -47,27 +47,64 @@ body.pz #hud .chip:not(.brand):not(.speed),body.pz #hud .speed button:not(#muteB
.pzconf i{position:absolute;top:-12px;left:var(--x);width:8px;height:12px;background:var(--c);border:1.5px solid var(--ink);border-radius:2px;animation:pzfall var(--t) ease-in var(--dl) both}
@keyframes pzfall{0%{transform:translateY(0) rotate(0);opacity:1}100%{transform:translateY(420px) rotate(var(--r));opacity:0}}
@media (max-width:760px),(max-height:500px) and (pointer:coarse){
- #pzBox{top:auto;left:0;right:0;width:auto;bottom:0;max-height:min(46%,330px);border-radius:20px 20px 0 0;border-bottom:0;box-shadow:0 -3px 0 var(--ink);padding:0 12px calc(10px + env(safe-area-inset-bottom,0px))}
- #pzBox .grab{display:block}
- #pzBox .btns .b,#pzBox .pzh .b{min-height:40px;min-width:40px;padding:4px 12px}
- /* Long languages make the sheet scroll: Undo, Reset and Back stay pinned at its foot. */
- #pzBox>.btns{position:sticky;bottom:0;background:var(--paper);margin:6px -12px 0;padding:6px 12px 0;box-shadow:0 -6px 6px -6px rgba(30,38,64,.25)}
- #pzBox .pztop{top:0;margin:0 -12px;padding:0 12px 2px}
- /* Peek: only the status bar, so the map keeps the screen while you build; tap or swipe it up for the rest. */
- #pzBox.mini{max-height:none}#pzBox.mini>:not(.pztop){display:none}
- #pzBox .pzh .eyebrow{display:none}#pzBox h3{font-size:17px}
- #pzBox .pzgl{font-size:14.5px}#pzBox .pzgh{font-size:13.5px}#pzBox .pzgh .pzshow{min-height:32px}
- body.pz:has(#pzBox.mini) #hint{bottom:calc(150px + env(safe-area-inset-bottom,0px)) !important}
- body.pz.sheet-open #pzBox{display:none}
body.pz #panel{bottom:0 !important}
- body.pz #hint{bottom:calc(min(46%,330px) + 8px) !important}
.pzbig{font-size:40px}
}
+/* Phones (97-puzzles-phone.js): nothing scrolls. A bar pinned at the top holds the puzzle's state and the next thing to
+ do; a city or a link opens a card at the bottom, split into tabs that each fit. --pzdock is the bar's height. */
+@media (max-width:760px),(max-height:500px) and (pointer:coarse){
+ body.pz #hud{display:none}
+ #pzBox.dock{top:calc(env(safe-area-inset-top,0px) + 6px);bottom:auto;left:max(6px,env(safe-area-inset-left,0px));right:max(6px,env(safe-area-inset-right,0px));width:auto;max-height:none;overflow:visible;border-radius:16px;border:3px solid var(--ink);box-shadow:3px 3px 0 var(--ink);padding:6px 8px 7px}
+ body.pz.sheet-open #pzBox.dock{display:block}
+ body.pz.sheet-open #pzBox.dock .pzd-goal,body.pz.sheet-open #pzBox.dock .pzd-chips{display:none}
+ .pzd-bar{display:flex;align-items:center;gap:6px;min-width:0}
+ .pzd-nm{flex:1 1 auto;min-width:0;font:800 15px/1.2 var(--display);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
+ .pzd-stars{display:flex;gap:2px;flex:none}
+ .pzd-st{display:inline-grid;place-items:center;width:22px;height:22px;border:2px solid var(--line);border-radius:50%;font:900 11px var(--body);color:var(--ink2);box-sizing:border-box}
+ .pzd-st.on{border:0;font-size:17px}.pzd-st.cur{border-color:var(--warn);background:#FFF4D6;color:var(--ink)}
+ .pzd-bud{flex:none;font-weight:900;font-size:12.5px;font-variant-numeric:tabular-nums;white-space:nowrap}.pzd-bud.bad{color:var(--bad)}
+ #pzBox.dock .pzd-bar .b.sm{min-width:36px;min-height:36px;padding:2px 8px;font-size:16px}
+ .pzd-goal{display:flex;align-items:center;gap:8px;margin-top:6px;padding:5px 8px;background:#FFF4D6;border:2px solid var(--warn);border-radius:12px}
+ .pzd-goal.done{background:#DFFBEA;border-color:var(--ok)}.pzd-goal.bad{background:#FFE6E9;border-color:var(--bad)}
+ #pzBox.dock .arsteps{margin:6px 0 4px}#pzBox.dock .arsteps i{height:6px}#pzBox.dock .arbrief{font-size:13px;margin:0 0 2px}
+ #pzBox.dock .arsites{display:contents}#pzBox.dock .arsite{font-size:12px;padding:2px 8px}
+ body.pz.sheet-open #pzBox.dock .arbrief,body.pz.sheet-open #pzBox.dock .arsteps{display:none}
+ .pzd-goal{flex-wrap:wrap}.pzd-gi{flex:none;font-size:16px}.pzd-gt{flex:1 1 170px;min-width:0;font-size:13px;line-height:1.3}.pzd-gt b{font-weight:800}
+ .pzd-ga{flex:none;display:flex;flex-direction:column;gap:4px}#pzBox.dock .pzd-ga{margin-left:auto}#pzBox.dock .pzd-ga .b{min-height:32px;padding:2px 10px;font-size:13px;white-space:nowrap}
+ .pzd-chips{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}
+ .pzd-chip{font:800 12px/1.2 var(--body);color:var(--ink);background:#fff;border:2px solid var(--line);border-radius:999px;padding:3px 8px;white-space:nowrap;max-width:100%;overflow:hidden;text-overflow:ellipsis;cursor:pointer}
+ .pzd-chip b{font-weight:900;font-variant-numeric:tabular-nums}.pzd-chip .bad{color:var(--bad)}
+ .pzd-chip.ok{border-color:var(--ok);background:#DFFBEA}.pzd-chip.part{border-color:var(--warn);background:#FFF4D6}.pzd-chip.none{border-color:var(--bad);background:#FFE6E9}
+ .pzd-chip.rule{cursor:default;color:var(--ink2)}
+ /* The card: as tall as its tab, under the bar at most; tabs keep each part short enough to need no scrolling. */
+ body.pz #panel{max-height:calc(100% - var(--pzdock,60px) - 18px - env(safe-area-inset-top,0px)) !important}
+ body.pz #panel>.grab{display:none}
+ body.pz #panel .pzd-ph{padding:10px 12px 6px;align-items:center}body.pz #panel .pzd-ph .grow{min-width:0}
+ body.pz #panel .pzd-ph h2{font-size:20px;line-height:1.15}body.pz #panel .pzd-ph h2 small{font:700 12px var(--body);color:var(--ink2);white-space:normal}
+ body.pz #panel .pzd-ph .eyebrow .mine{color:var(--me)}
+ .pzd-body{padding:0 14px calc(10px + env(safe-area-inset-bottom,0px))}
+ .pzd-tabs{display:flex;gap:4px;margin:6px 0 8px;border-bottom:2px solid var(--line)}
+ .pzd-tabs button{flex:1;font:800 13px var(--body);color:var(--ink2);background:none;border:0;border-bottom:3px solid transparent;margin-bottom:-2px;padding:6px 2px;min-height:36px}
+ .pzd-tabs button.on{color:var(--ink);border-bottom-color:var(--me)}
+ .pzd-row{display:flex;align-items:center;gap:8px;padding:4px 0;border-bottom:1.5px dashed var(--line);font-size:13px}.pzd-row .grow{min-width:0}.pzd-row.on{background:#FFE3F0;border-radius:8px}
+ .pzd-to{flex-wrap:wrap}.pzd-foot{justify-content:flex-end}
+ .pzd-models{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:5px;margin-top:6px}
+ .pzd-model{display:flex;flex-direction:column;align-items:flex-start;gap:0;text-align:left;font:inherit;color:var(--ink);background:#fff;border:2px solid var(--ink);border-radius:10px;padding:3px 7px;min-width:0;cursor:pointer}
+ .pzd-mh{display:flex;gap:6px;width:100%;align-items:baseline}.pzd-mh b{flex:1 1 auto;min-width:0;font-size:12.5px;font-weight:900;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.pzd-mh span{flex:none;font-weight:900;font-size:12.5px}
+ .pzd-model small{font-size:11px;color:var(--ink2);line-height:1.25;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
+ .pzd-model.on{background:#FFE3F0;border-color:var(--me)}.pzd-model:disabled:not(.on){opacity:.45;border-color:var(--line)}
+ .pzd-rt{margin:6px 0 0}.pzd-rt .b{min-height:34px}
+ .pzd-tiers{display:grid;grid-template-columns:1fr 1fr;gap:6px}.pzd-tiers .b{margin:0;display:flex;flex-direction:column;align-items:center;gap:0;white-space:normal;line-height:1.15;padding:4px 6px}.pzd-tiers .b small{font-size:11px}
+ /* What a routing metric does, and the redundancy check's question, are on the desktop card; here the buttons speak. */
+ .pzd-routing section{margin:0}.pzd-routing h3{font-size:15px;margin:4px 0}.pzd-routing .note,.pzd-routing .lead{display:none}.pzd-routing .btns{margin:4px 0 8px}
+ body.pz #hint{bottom:calc(env(safe-area-inset-bottom,0px) + 12px) !important}
+ body.pz #toasts{top:calc(env(safe-area-inset-top,0px) + var(--pzdock,60px) + 14px) !important;bottom:auto !important}
+}
@media (orientation:landscape) and (max-height:500px) and (pointer:coarse),(orientation:landscape) and (max-width:760px) and (max-height:500px){
- #pzBox{left:auto;right:0;width:min(360px,52%);top:calc(env(safe-area-inset-top,0px) + 50px);max-height:calc(100% - 50px - env(safe-area-inset-top,0px));overscroll-behavior:contain;border-radius:20px 0 0 0;border-right:0}
- #pzBox .pzj{display:none}#pzBox .pzs span{font-size:16px;padding:1px 0}
- body.pz #hint{bottom:12px !important;left:30% !important}
- body.pz #toasts{left:8px !important;transform:none !important;width:calc(48% - 16px) !important}
+ #pzBox.dock{right:auto;width:min(380px,46%)}
+ body.pz #toasts{top:auto !important;bottom:12px !important;left:8px !important;transform:none !important;width:calc(46% - 16px) !important}
+ /* The bar sits on the left here, so the card on the right can have the whole height. */
+ body.pz #panel{top:calc(env(safe-area-inset-top,0px) + 6px) !important;max-height:calc(100% - 6px - env(safe-area-inset-top,0px)) !important}
}
/* The weekly puzzle: a badge on the Puzzles door and in the list while this week's puzzle is unplayed. */
.pznew{display:inline-block;font:900 10.5px/1.2 var(--body);font-style:normal;text-transform:uppercase;letter-spacing:.04em;background:var(--me);color:#fff;border:2px solid var(--ink);border-radius:999px;padding:1px 7px;white-space:nowrap;vertical-align:1px}
diff --git a/tests/puzzle-sheet.test.js b/tests/puzzle-sheet.test.js
index c47577a..2dc7e8d 100644
--- a/tests/puzzle-sheet.test.js
+++ b/tests/puzzle-sheet.test.js
@@ -54,17 +54,18 @@ test('delivered eyeballs are chips; Back to my network lives in the menu, not in
assert.deepEqual(errors, []);
});
-test('on a phone held upright the sheet starts as its status bar, and the bar opens it', () => {
+test('a phone gets the fixed bar (tests/puzzles-phone.test.js), a desktop the whole card', () => {
const { ev, dom, errors } = load();
ev("window.innerWidth=360;window.innerHeight=740;dispatchEvent(new Event('resize'))");
begin(ev);
- assert.equal(box(dom).classList.contains('mini'), true, 'peek');
+ assert.equal(box(dom).classList.contains('dock'), true, 'the bar');
ev('ACT.pzRetry()');
- assert.equal(box(dom).classList.contains('mini'), true, 'a fresh try of the same puzzle keeps the sheet as the player left it');
+ assert.equal(box(dom).classList.contains('dock'), true, 'a fresh try keeps it');
const { ev: ev2, dom: dom2 } = load();
ev2("window.innerWidth=1280;window.innerHeight=800;dispatchEvent(new Event('resize'))");
begin(ev2);
- assert.equal(box(dom2).classList.contains('mini'), false, 'a desktop shows the whole card');
+ assert.equal(box(dom2).classList.contains('dock'), false, 'a desktop shows the whole card');
+ assert.ok(box(dom2).querySelector('.pztop .pzgoals'), 'with its three goals');
assert.deepEqual(errors, []);
});
diff --git a/tests/puzzles-phone.test.js b/tests/puzzles-phone.test.js
new file mode 100644
index 0000000..f693271
--- /dev/null
+++ b/tests/puzzles-phone.test.js
@@ -0,0 +1,112 @@
+// Puzzles on a phone are fixed overlays that never scroll: a bar pinned at the top with the puzzle's state, the one
+// thing to do and a chip per flow; a city or a link opens a card at the bottom split into tabs. Architect runs get the
+// same bar. A desktop keeps the side card.
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const { load } = require('./harness');
+
+const phone = (ev, w = 360, h = 740) => ev(`innerWidth=${w};innerHeight=${h};dispatchEvent(new Event('resize'))`);
+const q = (dom, s) => dom.window.document.querySelector(s);
+const qa = (dom, s) => [...dom.window.document.querySelectorAll(s)];
+
+test('the bar: name, three stars, the money, undo and the menu; the goal to work on; a chip per flow', () => {
+ const { ev, dom, errors } = load();
+ phone(ev);
+ ev("pzBegin(pzDef('baltic'))");
+ const box = q(dom, '#pzBox');
+ assert.ok(box.classList.contains('dock'));
+ assert.equal(qa(dom, '#pzBox .pzd-bar .pzd-st').length, 3, 'three stars');
+ assert.ok(q(dom, '#pzBox .pzd-bar [data-act="pzUndo"]') && q(dom, '#pzBox .pzd-bar [data-act="puzzleMenu"]'));
+ assert.match(q(dom, '#pzBox .pzd-bar .pzd-bud').textContent, /\$/, 'the money');
+ assert.equal(qa(dom, '#pzBox .pzd-st.cur').length, 1, 'the goal being worked on is marked');
+ assert.ok(q(dom, '#pzBox .pzd-goal [data-act="pzLook"]'), 'Show me');
+ const flows = ev('S.pz.dem.length');
+ assert.equal(qa(dom, '#pzBox .pzd-chips [data-act="pzCity"]').length, flows, 'one chip per flow');
+ assert.ok(qa(dom, '#pzBox .pzd-chip.none').length > 0, 'nothing built: the chips say nothing arrives');
+ assert.equal(q(dom, '#pzBox .pztop'), null, 'not the desktop card');
+ assert.deepEqual(errors, []);
+});
+
+test('a chip opens its cityβs card; the cardβs tabs switch, and the choice is kept for the next city', () => {
+ const { ev, dom, errors } = load();
+ phone(ev);
+ ev("pzBegin(pzDef('baltic'));ACT.pzPop({city:'fra'})");
+ const c = ev("S.pz.dem[0].a");
+ ev(`document.querySelector('#pzBox [data-act="pzCity"]').click()`);
+ assert.equal(ev("UI.sel&&UI.sel.id"), c, 'the chip picked its city');
+ ev("selectCity('fra')");
+ const tabs = qa(dom, '#panelBody .pzd-tabs button').map((b) => b.dataset.args);
+ assert.ok(tabs.length >= 2, 'tabs');
+ assert.ok(q(dom, '#panelBody [data-act="pzLinkTo"]'), 'Links first: where to lease a wave');
+ assert.equal(q(dom, '#panelBody .pzd-models'), null, 'the models wait in their own tab');
+ ev(`document.querySelector('#panelBody .pzd-tabs button:nth-child(2)').click()`);
+ assert.equal(qa(dom, '#panelBody .pzd-model').length, ev('PZ_RG.length'), 'every router model, in a grid');
+ assert.equal(q(dom, '#panelBody [data-act="pzLinkTo"]'), null);
+ ev("ACT.pzPop({city:'tll'});selectCity('tll')");
+ assert.ok(q(dom, '#panelBody .pzd-models'), 'the next city opens on the same tab');
+ ev("ACT.pzTab({k:'city',t:'nonsense'})");
+ assert.ok(q(dom, '#panelBody [data-act="pzLinkTo"]'), 'an unknown tab falls back to Links');
+ assert.deepEqual(errors, []);
+});
+
+test('a linkβs card: sizes first, then what it carries, then its routing', () => {
+ const { ev, dom, errors } = load();
+ phone(ev);
+ ev("pzBegin(pzDef('baltic'));ACT.pzPop({city:'fra'});ACT.pzLinkTo({a:'fra',b:'tll'});ACT.pzLink({tier:1});closeModal();selectLink(S.links[0].id)");
+ assert.equal(qa(dom, '#panelBody .pzd-tiers [data-act="pzTier"]').length, ev('PZ_TIERS.length'));
+ assert.ok(q(dom, '#panelBody [data-act="pzRmLink"]'));
+ ev("ACT.pzTab({k:'link',t:'routing'})");
+ assert.ok(q(dom, '#panelBody .pzd-routing [data-act="setMetric"]'), 'the metric buttons');
+ assert.equal(q(dom, '#panelBody .pzd-tiers'), null);
+ ev("ACT.pzTab({k:'link',t:'traffic'})");
+ assert.match(q(dom, '#panelBody').textContent, /Gbps/);
+ assert.deepEqual(errors, []);
+});
+
+test('nothing on a phone scrolls by design: the bar and the cardβs body have no scroll of their own', () => {
+ const { ev, errors } = load();
+ const rules = JSON.parse(ev(`JSON.stringify([...document.styleSheets].flatMap(s=>[...s.cssRules]).filter(r=>r.media&&/max-width: ?760px/.test(r.media.mediaText))
+ .flatMap(m=>[...m.cssRules]).map(r=>({sel:r.selectorText||'',ov:r.style.getPropertyValue('overflow')+r.style.getPropertyValue('overflow-y'),mh:r.style.getPropertyValue('max-height')})))`));
+ const dock = rules.find((r) => r.sel === '#pzBox.dock');
+ assert.ok(dock && dock.ov === 'visible' && dock.mh === 'none', 'the bar is as tall as it needs, never a scroll box');
+ assert.ok(!rules.some((r) => /pzd-/.test(r.sel) && /auto|scroll/.test(r.ov)), 'no part of the bar or the cards scrolls');
+ assert.deepEqual(errors, []);
+});
+
+test('Reset moves to the menu on a phone; the desktop keeps its own', () => {
+ const { ev, dom, errors } = load();
+ phone(ev);
+ ev("pzBegin(pzDef('baltic'));ACT.pzPop({city:'fra'});ACT.puzzleMenu()");
+ assert.ok(q(dom, '#modalCard [data-act="pzReset"]'), 'in the menu');
+ ev(`document.querySelector('#modalCard [data-act="pzReset"]').click()`);
+ assert.equal(ev('Object.keys(S.pops).length'), 0, 'it resets');
+ assert.equal(q(dom, '#modal').hidden, true, 'and closes the menu');
+ const d = load();
+ d.ev("innerWidth=1280;innerHeight=800;dispatchEvent(new Event('resize'));pzBegin(pzDef('baltic'));ACT.puzzleMenu()");
+ assert.equal(d.dom.window.document.querySelector('#modalCard [data-act="pzReset"]'), null, 'not in the desktop menu');
+ assert.ok(d.dom.window.document.querySelector('#pzBox .pzfoot [data-act="pzReset"]'), 'it is on the card');
+ assert.deepEqual(errors, []);
+});
+
+test('an architect run gets the same bar: its brief, the sites as chips and the review with its button', () => {
+ const { ev, dom, errors } = load();
+ phone(ev);
+ ev('ACT.pzArStart({id:AR_RUNS[0].id});closeModal()');
+ assert.ok(q(dom, '#pzBox').classList.contains('dock'));
+ assert.ok(q(dom, '#pzBox .pzd-bar [data-act="puzzleMenu"]'));
+ assert.ok(q(dom, '#pzBox .arbrief').textContent.length > 10, 'the brief');
+ assert.ok(qa(dom, '#pzBox .arsite').length >= 2, 'the sites');
+ assert.ok(q(dom, '#pzBox .pzd-goal [data-act="pzArGo"]'), 'the review and its button');
+ assert.deepEqual(errors, []);
+});
+
+test('turning a tablet-sized window into a phone redraws the puzzle in the bar, and back', () => {
+ const { ev, dom, errors } = load();
+ ev("innerWidth=1280;innerHeight=800;dispatchEvent(new Event('resize'));pzBegin(pzDef('baltic'))");
+ assert.equal(q(dom, '#pzBox').classList.contains('dock'), false);
+ phone(ev);
+ assert.equal(q(dom, '#pzBox').classList.contains('dock'), true);
+ ev("innerWidth=1280;innerHeight=800;dispatchEvent(new Event('resize'))");
+ assert.equal(q(dom, '#pzBox').classList.contains('dock'), false);
+ assert.deepEqual(errors, []);
+});
diff --git a/tests/puzzles.test.js b/tests/puzzles.test.js
index b815b3d..4d9ea67 100644
--- a/tests/puzzles.test.js
+++ b/tests/puzzles.test.js
@@ -392,24 +392,26 @@ test('puzzle HUD and panels fit a 360 px phone, portrait and landscape', () => {
ev("pzBegin(pzDef('baltic'))");
assert.equal(ev("document.getElementById('tabbar').hidden"), true);
assert.equal(ev("document.getElementById('pzBox').hidden"), false);
+ // The bar: each flow as a chip, the content's home as a rule.
const box = ev("document.getElementById('pzBox').textContent");
- assert.match(box, /Eyeballs in Tallinn/);
+ assert.match(box, /π Tallinn/);
assert.match(box, /Frankfurt β Tallinn circuit/);
- assert.match(box, /Content lives in Frankfurt/);
+ assert.match(box, /ποΈ Frankfurt/);
ev("selectCity('fra')");
assert.match(ev("document.getElementById('panelBody').textContent"), /Open a POP/);
ev("document.querySelector('#panelBody [data-act=pzPop]').click()");
- assert.match(ev("document.getElementById('panelBody').textContent"), /Your POP[\s\S]*Router load[\s\S]*Ports[\s\S]*Router model/);
+ assert.match(ev("document.getElementById('panelBody').textContent"), /Your POP[\s\S]*Links[\s\S]*Router model/);
+ ev("ACT.pzTab({k:'city',t:'router'})");
+ assert.match(ev("document.getElementById('panelBody').textContent"), /1 of 8 used|of \d+ used/);
ev("pzLinkModal('fra','tll')");
assert.equal(ev("document.querySelectorAll('#modalCard .tierbtn').length"), 4, 'four sizes');
ev("closeModal();innerWidth=740;innerHeight=360;dispatchEvent(new Event('resize'));renderAll()");
assert.equal(ev("document.getElementById('pzBox').hidden"), false, 'landscape too');
- // jsdom has no layout: the phone rules keep 40 px targets and pin the action row.
+ // jsdom has no layout: the phone rules keep the bar from scrolling and its buttons big enough to tap.
const rules = JSON.parse(ev(`JSON.stringify([...document.styleSheets].flatMap(s=>[...s.cssRules]).filter(r=>r.media&&/max-width: ?760px/.test(r.media.mediaText))
- .flatMap(m=>[...m.cssRules]).filter(r=>/#pzBox/.test(r.selectorText||'')).map(r=>({sel:r.selectorText,mh:r.style.getPropertyValue('min-height'),pos:r.style.getPropertyValue('position')})))`));
- assert.ok(rules.some((r) => /#pzBox \.btns \.b/.test(r.sel) && parseFloat(r.mh) >= 40), 'touch targets');
- assert.ok(rules.some((r) => /^#pzBox ?> ?\.btns$/.test(r.sel) && r.pos === 'sticky'), 'pinned actions');
- assert.ok(ev("[...document.querySelectorAll('#pzBox button')].every(b=>b.classList.contains('b'))"), 'every sheet button is a .b the rule sizes');
+ .flatMap(m=>[...m.cssRules]).filter(r=>/#pzBox/.test(r.selectorText||'')).map(r=>({sel:r.selectorText,mh:r.style.getPropertyValue('min-height'),ov:r.style.getPropertyValue('overflow')})))`));
+ assert.ok(rules.some((r) => /^#pzBox\.dock$/.test(r.sel) && r.ov === 'visible'), 'the bar never scrolls');
+ assert.ok(rules.some((r) => /#pzBox\.dock \.pzd-bar \.b\.sm/.test(r.sel) && parseFloat(r.mh) >= 36), 'touch targets');
assert.deepEqual(errors, []);
});