A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D
Fold the HUD away on phones; full-screen dialogs with pinned actions
Claude5232b731b4ca
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.mdindex 85f9ed4..37887a2 100644--- a/DEVELOPMENT.md+++ b/DEVELOPMENT.md@@ -15,6 +15,7 @@ pnpm typecheckpnpm test # model-based tests: random mayors, rules that must always hold; and savingpnpm check # every way a term can end, ends itpnpm check:browser # the actual 3D game: placement, picking, saves, populated towns and phone layout+pnpm check:phone # phone sizes: the picker's found button on screen, the folded HUD opens and closespnpm balance # a bot plays terms headless and reports the pressure```@@ -34,13 +35,19 @@ first holds the ghost or outline where it landed, a second on the same spotcommits it. This lives entirely in `src/render3d/input.ts`; the game stillsees one ordinary press and release.-Phones get their layout from `src/phone.css`, loaded after `factory.css`. It-only moves and resizes what `factory.css` draws, in three media queries:-compact (narrow or short screens: icon-only bars, a two-line ticker),-portrait (chrome stacked top and bottom, the panel as a bottom sheet) and-touch (bigger targets, no key hints, the hint line pinned above the bars).-New UI needs nothing there unless it has to move on a phone; check it at-390×844, 360×640 and 844×390.+Phones get their layout from `src/phone.css`, loaded after `factory.css`. On+a narrow or short screen the HUD folds away: one top line (clock, treasury,+people, and a chip of planks, stone and tools), one tool bar along the bottom+(town, the tools, pause, a speed button that cycles, and a ⋯ menu holding+share, guide, save, load, new town and recentre), and two buttons top right+for the guide and the map overlays. `host.ts` sets `body.fold-goods`,+`fold-guide`, `fold-views` or `fold-more` while one is open; a tap on the map+folds it. A new guide step peeks above the tool bar for a few seconds. Sheets+open from the side on a landscape phone (`max-height: 500px`) and from the+bottom in portrait. Dialogs take the whole screen with their actions pinned+to the bottom. The camera bar is hidden: pinch zooms and turns. New UI needs+nothing there unless it has to move on a phone; check it at 390×844, 360×640+and 762×330, and run `pnpm check:phone`.`src/render3d/scene.ts` owns the orthographic camera, ground projection andframe source. `views.ts` follows live construction, upgrades, resources,diff --git a/package.json b/package.jsonindex 256e6b9..bef0217 100644--- a/package.json+++ b/package.json@@ -13,6 +13,7 @@"balance:model:check": "node --test test/balance-model.test.ts","check": "node scripts/check.ts","check:browser": "node scripts/check-browser.ts",+ "check:phone": "node scripts/check-phone.ts","check:models": "node scripts/check-town-models.ts","check:effects": "node scripts/check-house-effects.ts","check:revisions": "node scripts/check-model-revisions.ts",diff --git a/scripts/check-browser.ts b/scripts/check-browser.tsindex 618a11a..71437d5 100644--- a/scripts/check-browser.ts+++ b/scripts/check-browser.ts@@ -158,9 +158,11 @@ try {facts.speedAndPause=truefacts.liveWalkerMovement=trueawait page.setViewportSize({width:390,height:844})- await page.getByRole("button",{name:"Reset camera",exact:true}).click()+ // A phone has no camera bar (pinch zooms and turns): recentre from the menu.+ await page.locator(".toolbar .more").click()+ await page.getByRole("button",{name:"recentre",exact:true}).click()await page.keyboard.press("q")- assert.equal(await page.evaluate(()=>[...document.querySelectorAll(".camera-controls,.toolbar,.system,.hud")].some(e=>{const r=e.getBoundingClientRect();return r.left<0||r.right>innerWidth+1})),false)+ assert.equal(await page.evaluate(()=>[...document.querySelectorAll(".toolbar,.hud,.fold-buttons")].some(e=>{const r=e.getBoundingClientRect();return r.left<0||r.right>innerWidth+1})),false)facts.phoneViewport=trueawait tool("homes")const touch=await page.context().newCDPSession(page),beforeTouch=await snapshot(),cameraBefore=await page.evaluate(()=>window.town.view.stats())@@ -177,8 +179,10 @@ try {assert.notEqual(cameraAfter.heading,cameraBefore.heading)facts.touchPinchRotateDoesNotBuild=trueawait tool("select")- await page.getByRole("button",{name:"Reset camera",exact:true}).click()+ await page.locator(".toolbar .more").click()+ await page.getByRole("button",{name:"recentre",exact:true}).click()await capture("phone")+ await page.setViewportSize({width:1440,height:1000})// A saved term that has ended still opens the existing reckoning UI.const ended=structuredClone(grown)ended.world.resources["Town/Fate"]={...ended.world.resources["Town/Fate"],state:"over",reason:"The term has ended.",at:ended.world.resources["Town/Time"].tick}diff --git a/scripts/check-phone.ts b/scripts/check-phone.tsnew file mode 100644index 0000000..f9c072e--- /dev/null+++ b/scripts/check-phone.ts@@ -0,0 +1,47 @@+/** Phone-sized checks against the real local game: the town picker's found+ * button is on screen, and the folded HUD opens and closes. Start pnpm dev+ * first. BROWSER_EXECUTABLE_PATH selects an installed browser, as in+ * check-browser.ts. Screenshots go to output/inkline-3d/phone-check.+ */+import assert from "node:assert/strict"+import { existsSync } from "node:fs"+import { mkdir } from "node:fs/promises"+import { chromium } from "playwright"++const executable=process.env.BROWSER_EXECUTABLE_PATH??["/Applications/Brave Browser.app/Contents/MacOS/Brave Browser","/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"].find(existsSync)+const browser=await chromium.launch({headless:true,...(executable?{executablePath:executable}:{})})+const output="output/inkline-3d/phone-check"+await mkdir(output,{recursive:true})+const errors:Array<string>=[]+try {+ for (const [name,width,height] of [["portrait",390,720],["landscape",762,330]] as const) {+ const page=await browser.newPage({viewport:{width,height},deviceScaleFactor:2,isMobile:true,hasTouch:true})+ page.on("pageerror",e=>errors.push(`${name}: ${e.message}`))+ await page.goto(process.env.GAME_BASE_URL??"http://127.0.0.1:5232")+ await page.waitForFunction(()=>"town" in window)+ // The found button sits inside the screen without scrolling: it is pinned to the bottom.+ const found=page.getByRole("button",{name:"Found the town",exact:true})+ const box=(await found.boundingBox())!+ assert.ok(box.y>=0&&box.y+box.height<=height,`${name}: the found button is off screen`)+ await page.screenshot({path:`${output}/${name}-picker.png`})+ await page.getByRole("button",{name:"small",exact:true}).click()+ await found.click()+ await page.waitForTimeout(1500)+ // Folded: no goods row, no system bar, no overlay list.+ for (const hidden of [".hud .stock",".system",".views"]) assert.equal(await page.locator(hidden).isVisible(),false,`${name}: ${hidden} is out`)+ await page.screenshot({path:`${output}/${name}-game.png`})+ for (const [button,shows] of [[".goods-chip",".hud .stock"],[".toolbar .more",".system"],[".fold-buttons button:last-child",".views"]] as const) {+ await page.locator(button).click()+ assert.ok(await page.locator(shows).isVisible(),`${name}: ${button} opens ${shows}`)+ await page.locator(button).click()+ assert.equal(await page.locator(shows).isVisible(),false,`${name}: ${button} folds ${shows}`)+ }+ // Everything fits the width: nothing scrolls sideways.+ assert.ok(await page.evaluate(()=>document.documentElement.scrollWidth<=window.innerWidth),`${name}: the page scrolls sideways`)+ await page.close()+ }+ assert.deepEqual(errors,[])+ console.log("phone checks passed")+} finally {+ await browser.close()+}diff --git a/src/factory.css b/src/factory.cssindex d721c36..31639c1 100644--- a/src/factory.css+++ b/src/factory.css@@ -27,6 +27,9 @@ body { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;}.card .cell { display: flex; align-items: center; gap: 10px; padding: 7px 14px; white-space: nowrap; }.card .cell + .cell { border-left: 1px solid #e0e3db; }+.hud .topline { display: flex; gap: 8px; align-items: stretch; }+/* What only a phone shows (phone.css): the goods chip, the guide and overlay buttons, the speed cycle, the menu. */+.goods-chip, .fold-buttons, .toolbar .more, .toolbar .speed .cycle, .system .phone-only { display: none; }.hud .stack { display: flex; flex-direction: column; line-height: 1.2; }.hud .stack b { font-size: 15px; font-weight: 700; }.hud .stack small { font-size: 11px; color: #77817a; }@@ -97,6 +100,7 @@ body { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;}.panel {+ overscroll-behavior: contain;position: fixed; top: 0; right: 0; bottom: 0; width: 360px; max-width: 46vw; box-sizing: border-box;background: #eef0ea; border-left: 1px solid #c3c8bf; padding: 18px 16px calc(24px + env(safe-area-inset-bottom));overflow-y: auto; transform: translateX(100%); transition: transform 240ms cubic-bezier(.2,.8,.2,1);@@ -226,6 +230,8 @@ body { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;.dialog .sheet {background: #f1f3ed; border: 1px solid #c3c8bf; border-radius: 6px; box-shadow: 0 3px 0 #d5d9d0; padding: 22px 26px;width: 640px; max-width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; box-sizing: border-box; font-size: 14px;+ /* The visible height, URL bar and all: 100vh alone is the height with the bar hidden, and cut the actions off. */+ max-height: calc(100dvh - 32px); overscroll-behavior: contain; touch-action: pan-y;}.dialog .sheet.wide { width: 720px; }.dialog .sheet.narrow { width: 460px; }diff --git a/src/host.ts b/src/host.tsindex 7beb942..908e6a6 100644--- a/src/host.ts+++ b/src/host.ts@@ -186,19 +186,25 @@ export const createHost = async (mount: HTMLElement, persistence: () => Persisteconst alarm = el("div", "card alarm")// The town ticker: what needs looking at now, and the latest news.const ticker = el("div", "card ticker")- hud.append(bar, stock, request, alarm, ticker)+ // The top line: the clock and treasury (on a phone, the people and a chip of the building goods beside them).+ const topline = el("div", "topline")+ const goodsChip = el("button", "card goods-chip")+ goodsChip.title = "The goods in storage"+ topline.append(bar, goodsChip)+ hud.append(topline, stock, request, alarm, ticker)const people = el("div", "hud right")- const folk = el("div", "card bar")+ const folk = el("div", "card bar folk")const approval = el("div", "cell")const settlerCell = el("div", "cell")const citizenCell = el("div", "cell")const jobs = el("div", "cell jobs")folk.append(approval, settlerCell, citizenCell, jobs)people.append(folk)- people.title = "Open the town's numbers, goals, and levers (T)"- people.onclick = () => toggleMenu("town")+ folk.title = "Open the town's numbers, goals, and levers (T)"+ folk.onclick = () => toggleMenu("town")/** Points the page at a place: the camera goes there, it is outlined for a moment, and (when it is a thing) it is selected. */const goTo = (at: { readonly x: number; readonly y: number }, size: number, id: number | null) => {+ setFold(null)stage.focus(at.x + size / 2, at.y + size / 2)ui.flash = { cell: { x: at.x, y: at.y }, size, until: Date.now() + 4000 }if (id !== null) {@@ -231,7 +237,58 @@ export const createHost = async (mount: HTMLElement, persistence: () => Persiste// Map views, and the legend of the one shown.const views = el("div", "views")const legend = el("div", "card legend")- document.body.append(hud, people, tooltip, toastBox, toolbar, system, panel, result, dialog, confirmBox, reckoning, shareBox, visitBar, views, legend)+ // A phone's buttons for what stays folded away: the guide and the map views.+ const foldButtons = el("div", "fold-buttons")+ const guideBulb = el("button", "card")+ guideBulb.title = "The guide, and what needs looking at now"+ const guideBadge = el("span", "badge")+ guideBulb.append(iconEl("hint", 16), guideBadge)+ const layersButton = el("button", "card")+ layersButton.title = "Map overlays"+ layersButton.append(iconEl("layers", 16))+ foldButtons.append(guideBulb, layersButton)+ document.body.append(hud, people, tooltip, toastBox, toolbar, system, panel, result, dialog, confirmBox, reckoning, shareBox, visitBar, views, legend, foldButtons)++ // ── Phones: the HUD folds away ──+ // On a small screen only the top line and the tool bar stay out; the goods,+ // the guide, the map views, and the system buttons each open on a tap, one+ // at a time, and a tap on the map folds them again.+ const phone = window.matchMedia("(max-width: 760px), (max-height: 500px)")+ type Fold = "goods" | "guide" | "views" | "more"+ let fold: Fold | null = null+ const setFold = (next: Fold | null) => {+ fold = next+ for (const f of ["goods", "guide", "views", "more"] as const) document.body.classList.toggle(`fold-${f}`, f === next)+ goodsChip.classList.toggle("on", next === "goods")+ guideBulb.classList.toggle("on", next === "guide")+ layersButton.classList.toggle("on", next === "views" || ui.view !== "none")+ moreButton.classList.toggle("on", next === "more")+ if (next !== null) {+ ticker.classList.remove("peek")+ // The panel and a fold would cover each other: the fold wins.+ if (ui.menu !== null || ui.selected !== null) {+ ui.menu = null+ ui.selected = null+ refreshTools()+ }+ }+ }+ const toggleFold = (f: Fold) => setFold(fold === f ? null : f)+ goodsChip.onclick = (event) => {+ event.stopPropagation()+ toggleFold("goods")+ }+ guideBulb.onclick = () => toggleFold("guide")+ layersButton.onclick = () => toggleFold("views")+ mount.addEventListener("pointerdown", () => {+ if (fold !== null) setFold(null)+ })+ // The people's card joins the top line on a phone, and goes back to the top right on a wider screen.+ const placeFolk = () => {+ if (phone.matches) topline.insertBefore(folk, goodsChip)+ else people.append(folk)+ if (!phone.matches) setFold(null)+ }let toastTimer = 0const ui: UiValue = {@@ -298,6 +355,11 @@ export const createHost = async (mount: HTMLElement, persistence: () => PersistetownButton.title = "The town's goals, numbers, taxes, and trade (T)"townButton.append(iconEl("town", 22), el("span", "", "town"), el("kbd", "", "T"))townButton.onclick = () => toggleMenu("town")+ // Everything the bottom-right buttons do, folded into one menu on a phone.+ const moreButton = el("button", "more")+ moreButton.title = "Share, the guide, save, load, new town"+ moreButton.append(iconEl("more"))+ moreButton.onclick = () => toggleFold("more")const toolGroup = el("div", "group")toolbar.append(townButton, toolGroup)const buttons = tools.map((tool) => {@@ -323,11 +385,19 @@ export const createHost = async (mount: HTMLElement, persistence: () => PersistespeedGroup.append(button)return { speed, button }})+ // A phone has room for one speed button: it runs a paused town, else goes on to the next speed.+ const cycle = el("button", "cycle")+ cycle.title = "Change speed: 1×, 2×, 4×"+ cycle.onclick = () => setSpeed(ui.speed === 0 ? lastSpeed : ui.speed === 4 ? 1 : ui.speed * 2)+ speedGroup.append(cycle)+ toolbar.append(moreButton)let lastSpeed = 1const setSpeed = (speed: number) => {if (speed > 0) lastSpeed = speedui.speed = speedfor (const s of speeds) s.button.classList.toggle("on", s.speed === speed)+ cycle.textContent = `${speed === 0 ? lastSpeed : speed}×`+ cycle.classList.toggle("paused", speed === 0)}setSpeed(1)@@ -354,6 +424,9 @@ export const createHost = async (mount: HTMLElement, persistence: () => Persisteconst setView = (view: View) => {ui.view = viewfor (const v of viewEls) v.button.classList.toggle("on", v.view === view)+ // On a phone the list folds away once one is chosen, so the map shows.+ if (fold === "views") setFold(null)+ layersButton.classList.toggle("on", view !== "none")}// Share, the guide, save, load, and new town: a row of icons in the bottom// right. Founding or loading replaces the town, so each asks first.@@ -384,6 +457,15 @@ export const createHost = async (mount: HTMLElement, persistence: () => PersisteopenCharter(true)))+ // A phone has no camera bar: this puts the camera back.+ action("view", "recentre", "Back to the original angle and centre", () => stage.resetCamera())+ system.lastElementChild!.classList.add("phone-only")+ // A choice from the menu folds it.+ system.addEventListener("click", () => {+ if (fold === "more") setFold(null)+ })+ placeFolk()+ phone.addEventListener("change", placeFolk)/** Asks before something that replaces the town: save first, go ahead, or stay. */const confirmLeave = (title: string, text: string, go: string, run: () => void) => {@@ -433,6 +515,7 @@ export const createHost = async (mount: HTMLElement, persistence: () => PersisterefreshTools()}const toggleMenu = (menu: "build" | "town") => {+ setFold(null)ui.menu = ui.menu === menu ? null : menuif (ui.menu) ui.selected = nullrefreshTools()@@ -1565,6 +1648,8 @@ export const createHost = async (mount: HTMLElement, persistence: () => Persistelet tickerLines: { guide: Stats["guide"]["step"]; alerts: Stats["alerts"]; news: Stats["chronicle"] } = { guide: null, alerts: [], news: [] }ticker.onclick = (event) => {event.stopPropagation()+ // On a phone the peeking line opens the guide in full.+ if (ticker.classList.contains("peek")) return setFold("guide")const target = event.target as HTMLElementconst off = target.closest<HTMLElement>("[data-dismiss]")if (off) {@@ -1608,6 +1693,9 @@ export const createHost = async (mount: HTMLElement, persistence: () => Persiste/** The last chronicle line announced. */let lastNews = ""+ /** The guide step last shown, and the timer that hides its peek. */+ let lastStep = ""+ let peekTimer = 0/** Copies the town's numbers and preview into the page, once a frame. */const syncPage = () => {syncPanel()@@ -1634,6 +1722,13 @@ export const createHost = async (mount: HTMLElement, persistence: () => Persistejobs.title = short > 0? `Workers at work over workers needed. ${short} workplace${short > 1 ? "s are" : " is"} short: ${s.shortStaffed.slice(0, 5).map((w) => `${w.title} ${w.assigned}/${w.needed}${w.nobodyNear ? " (no homes within 15 road cells)" : ""}`).join(", ")}. Click to visit them in turn.`: "Workers at work over workers needed: every workplace has its crew. Residents walk at most 15 road cells to work."+ const chipHtml = (["planks", "stone", "tools"] as const)+ .map((g) => `<span class="${s.stock[g] === 0 ? "short" : ""}">${goodIcon(g, 14)}${s.stock[g]}</span>`)+ .join("")+ if (goodsChip.dataset.html !== chipHtml) {+ goodsChip.dataset.html = chipHtml+ goodsChip.innerHTML = chipHtml+ }for (const [g, count] of goodCells) {count.textContent = String(s.stock[g])count.parentElement!.classList.toggle("empty", s.stock[g] === 0)@@ -1714,6 +1809,20 @@ export const createHost = async (mount: HTMLElement, persistence: () => PersisteguideButton.classList.toggle("on", !s.guide.off)guideButton.title = s.guide.off ? "Turn the guide back on: a next step to take, and why, at the top of the ticker" : "Turn the guide off"ticker.classList.toggle("show", tickerHtml !== "" && s.fate.state === "playing")+ // The phone's guide button: the step it is on, or how many things need looking at.+ const bad = alerts.some((a) => a.tone === "bad")+ const badge = g ? `${s.guide.done + 1}/${s.guide.total}` : alerts.length > 0 ? String(alerts.length) : ""+ if (guideBadge.textContent !== badge) guideBadge.textContent = badge+ guideBulb.classList.toggle("alert", bad)+ // A new step peeks out above the tool bar for a few seconds.+ const stepKey = g?.key ?? ""+ // Not behind the town picker: the step waits until the town is founded.+ if (stepKey !== lastStep && !ui.founding) {+ lastStep = stepKey+ window.clearTimeout(peekTimer)+ ticker.classList.toggle("peek", stepKey !== "" && phone.matches && fold === null)+ if (stepKey !== "") peekTimer = window.setTimeout(() => ticker.classList.remove("peek"), 7000)+ }// News as it happens: a toast for each new alarm line.const latest = s.chronicle.at(-1)const seen = `${s.charter.seed}|${latest?.tick ?? -1}|${s.chronicle.length}`diff --git a/src/icons.ts b/src/icons.tsindex 02a74b3..76928be 100644--- a/src/icons.ts+++ b/src/icons.ts@@ -59,6 +59,8 @@ const paths: Record<string, string> = {load: `<path d="M2 4.5h4.5l1.5 1.5h6v7.5H2z" fill="#f3dca6"/><path d="M8 7v5M5.8 10L8 12.2 10.2 10" fill="none"/>`,newTown: `<path d="M4 14.5V2" fill="none"/><path d="M4 2.5h8.5l-2 3 2 3H4z" fill="#a6c48a"/><path d="M9.5 11.5h4M11.5 9.5v4" fill="none"/>`,close: `<path d="M4 4l8 8M12 4l-8 8" fill="none"/>`,+ more: `<circle cx="3.5" cy="8" r="1.1" fill="${ink}"/><circle cx="8" cy="8" r="1.1" fill="${ink}"/><circle cx="12.5" cy="8" r="1.1" fill="${ink}"/>`,+ layers: `<path d="M8 2.5l6 3.5-6 3.5-6-3.5z" fill="#c9d6ee"/><path d="M2 9l6 3.5L14 9" fill="none"/>`,share: `<path d="M3 8.5v5.5h10V8.5" fill="#f7f8f4"/><path d="M8 10.5V2.5M5.3 5.2L8 2.5l2.7 2.7" fill="none"/>`,picture: `<path d="M2 3.5h12v9H2z" fill="#f7f8f4"/><path d="M2.5 12l4-4.5 3 3 1.5-1.5 2.5 3" fill="#cfe5b8"/><circle cx="11" cy="6" r="1.2" fill="#f0d98a"/>`,link: `<path d="M7 9a2.5 2.5 0 0 0 3.5 0l2.5-2.5a2.5 2.5 0 0 0-3.5-3.5L8.5 4M9 7a2.5 2.5 0 0 0-3.5 0L3 9.5A2.5 2.5 0 0 0 6.5 13l1-1" fill="none"/>`,diff --git a/src/phone.css b/src/phone.cssindex 9fac52f..af39cf6 100644--- a/src/phone.css+++ b/src/phone.css@@ -1,120 +1,210 @@/* ── Phones and other small or touch screens ──- * Layout only: every rule here rearranges or resizes the page that- * factory.css draws, so new UI works on a phone by default and only needs a- * line here when it has to move. Three layers, each a media query:- * compact (narrow or short screens): icon-only bars, a shorter ticker- * portrait (narrow screens): the chrome stacked top and bottom, the panel as a bottom sheet- * touch (coarse pointers): bigger targets, no key hints, the hint line pinned+ * On a small screen the HUD folds away: one top line (the clock, the+ * treasury, the people, and a chip of the building goods), one tool bar along+ * the bottom, and two buttons in the top right for the guide and the map+ * overlays. The goods, the guide, the overlays, and the system menu each open+ * on a tap (host.ts sets body.fold-*), one at a time; a tap on the map folds+ * them again. Desktop is untouched: every rule here sits in a media query.+ * phone (narrow or short screens): the folded HUD+ * landscape (short screens): sheets open from the side, so the map shows beside them+ * portrait (narrow and tall screens): sheets open from the bottom+ * touch (coarse pointers): no key hints, the build hint pinned*/-/* ── Compact: narrow (portrait phone) or short (landscape phone) ── */@media (max-width: 760px), (max-height: 500px) {- /* The bars keep their icons; the words are in each button's title. */- .toolbar button, .toolbar .town-button { font-size: 0; gap: 0; padding: 6px; min-width: 40px; min-height: 40px; justify-content: center; }- .toolbar .speed button { font-size: 12px; min-width: 36px; }- .toolbar button kbd { display: none; }- .system button, .system button.labelled { font-size: 0; gap: 0; padding: 6px; min-width: 38px; min-height: 38px; justify-content: center; }- .camera-controls [data-mode="pan"], .camera-controls output { display: none; }+ /* ── The top line ── */+ .hud { top: calc(8px + env(safe-area-inset-top)); gap: 6px; font-size: 11px; }+ .hud.left { left: calc(8px + env(safe-area-inset-left)); right: calc(92px + env(safe-area-inset-right)); max-width: none; }+ .hud.right { display: none; }+ .hud .topline { flex-wrap: wrap; gap: 6px; pointer-events: none; }+ .hud .topline > * { pointer-events: auto; }+ .hud .card { border-radius: 8px; }+ .hud .card .cell { padding: 0 8px; gap: 5px; min-height: 30px; }+ .hud .card .icon { width: 15px; height: 15px; }+ .hud .stack small { display: none; }+ .hud .stack b, .hud .coins b { font-size: 12px; }+ .hud .stack .of { font-size: 11px; }+ .hud .folk { cursor: pointer; }+ .goods-chip {+ display: flex; align-items: center; gap: 8px; padding: 0 9px; min-height: 30px; font: inherit; font-size: 12px; font-weight: 700;+ color: #3d4943; cursor: pointer;+ }+ .goods-chip span { display: inline-flex; align-items: center; gap: 4px; }+ .goods-chip .short { color: #b04a39; }+ .goods-chip.on { border-color: #3d4943; }- /* The goods on one line that scrolls, a little smaller. */- .hud .stock { max-width: 100%; overflow-x: auto; flex: none; padding: 4px; scrollbar-width: none; }- .hud .stock .group { flex: none; gap: 3px; padding: 0 3px; }+ /* The goods: folded into the chip; open, every good in a wrapped card under the top line. */+ .hud .stock { display: none; }+ .fold-goods .hud .stock { display: flex; flex-wrap: wrap; gap: 4px 0; padding: 5px; max-width: min(430px, 100%); }+ .hud .stock .group { flex-wrap: wrap; gap: 3px; padding: 0 3px; }.hud .good { gap: 4px; padding: 3px 7px 3px 4px; }.hud .good .count { font-size: 12px; }- /* The ticker: only what needs looking at now (the guide's step first, with its one-line heading), in at most two lines. */- .hud .ticker .head:not(.guide), .hud .ticker .cell ~ .cell, .hud .ticker .cell ~ .head { display: none; }- .hud .ticker .head.guide { padding: 6px 10px 0 12px; }- .hud .ticker .head.guide .progress { display: none; }- .hud .ticker .cell { padding: 6px 4px 6px 12px; font-size: 11px; line-height: 1.45; }- .hud .ticker .cell .text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }+ /* The crown's request and the alarms stay out: they need answering now. */+ .hud .request { width: auto; }+ .hud .request .ask { font-size: 12px; }+ .hud .alarm .cell { padding: 6px 9px; font-size: 11px; white-space: normal; }- /* The map overlays: a column of icons on the right, the legend beside it. */- .views { top: auto; right: 10px; bottom: calc(120px + env(safe-area-inset-bottom)); flex-direction: column; max-width: none; }- .views button { font-size: 0; gap: 0; padding: 7px; justify-content: center; }+ /* ── The guide and the overlay buttons, top right ── */+ .fold-buttons { display: flex; gap: 6px; position: fixed; top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); z-index: 2; }+ .fold-buttons button { overflow: visible; position: relative; width: 34px; height: 34px; padding: 0; justify-content: center; cursor: pointer; border-radius: 10px; }+ .fold-buttons button.on { border-color: #3d4943; background: #eceee8; }+ .fold-buttons button:first-child { background: #eef3fb; border-color: #c9d6ee; }+ .fold-buttons button:first-child.on { border-color: #2f5a9c; }+ .fold-buttons .badge {+ position: absolute; top: -6px; right: -7px; font-size: 9px; font-weight: 700; line-height: 1; padding: 3px 5px; border-radius: 999px;+ background: #2f5a9c; color: #f7f8f4;+ }+ .fold-buttons .badge:empty { display: none; }+ .fold-buttons .alert .badge { background: #b04a39; }++ /* ── The guide: folded to the bulb; a new step peeks above the tool bar; open, a sheet ── */+ .hud .ticker.show { display: none; width: auto; }+ .hud .ticker.show.peek {+ display: flex; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(58px + env(safe-area-inset-bottom));+ width: min(460px, calc(100vw - 16px)); cursor: pointer;+ }+ .hud .ticker.peek > :not(.cell.guide), .hud .ticker.peek .goal, .hud .ticker.peek .acts { display: none; }+ .hud .ticker.peek .cell.guide { padding: 7px 10px 7px 12px; font-size: 11px; line-height: 1.45; }+ .hud .ticker.peek .cell.guide .text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }+ .fold-guide .hud.left { z-index: 4; }+ .fold-guide .fold-buttons { z-index: 5; }+ .fold-guide .hud .ticker.show {+ display: flex; position: fixed; z-index: 4; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;+ box-shadow: 0 0 0 100vmax rgba(61, 73, 67, 0.12);+ }+ .hud .ticker .head { padding: 10px 14px 4px; }+ .hud .ticker .cell { font-size: 12px; padding: 9px 8px 9px 14px; }+ .hud .ticker .act { width: 30px; height: 30px; opacity: 0.6; }++ /* ── The map overlays: folded to the layers button; open, a list under it ── */+ .views { display: none; }+ .fold-views .views {+ display: flex; top: calc(50px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); bottom: auto;+ flex-direction: column; flex-wrap: nowrap; max-width: none; max-height: calc(100dvh - 120px); overflow-y: auto;+ }+ .fold-views .views button { font-size: 12px; gap: 8px; padding: 7px 9px; min-height: 34px; }.views button kbd, .views-title { display: none; }- .legend { top: auto; right: 64px; bottom: calc(120px + env(safe-area-inset-bottom)); max-width: min(220px, calc(100vw - 84px)); }-}+ .legend { top: calc(50px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); bottom: auto; max-width: min(220px, calc(100vw - 16px)); }+ .fold-views .legend { display: none; }-/* ── Portrait phone: stacked chrome, map in the middle, panel from the bottom ── */-@media (max-width: 760px) {- /* Top: the clock and treasury (with save and load beside them), the people, the goods, the ticker. */- .hud { top: calc(8px + env(safe-area-inset-top)); gap: 6px; }- .hud.left { left: 10px; right: 10px; max-width: none; }- .hud.right, .panel-open .hud.right { top: calc(58px + env(safe-area-inset-top)); left: 10px; right: auto; max-width: calc(100vw - 20px); align-items: flex-start; }- .hud .card .cell { padding: 6px 9px; gap: 7px; }- .hud .stack b { font-size: 14px; }- .hud .coins b { font-size: 15px; }- .hud.left .stock { margin-top: 48px; }- .hud .ticker { width: auto; }- .system, .panel-open .system { top: calc(8px + env(safe-area-inset-top)); bottom: auto; right: 10px; padding: 3px; }- .system button { min-height: 32px; }+ /* ── The tool bar: one card along the bottom ── */+ .toolbar, .panel-open .toolbar {+ left: 50%; right: auto; transform: translateX(-50%); bottom: calc(8px + env(safe-area-inset-bottom)); max-width: calc(100vw - 16px);+ gap: 0; padding: 2px; overflow-x: auto; scrollbar-width: none;+ background: #f7f8f4; border: 1px solid #c9cec4; border-radius: 10px; box-shadow: 0 2px 0 #dfe2db;+ }+ .toolbar .group, .toolbar .town-button { flex: none; background: none; border: 0; box-shadow: none; padding: 0; gap: 1px; border-radius: 6px; }+ .toolbar > * + * { margin-left: 3px; padding-left: 3px; border-left: 1px solid #e0e3db; border-radius: 0; }+ .toolbar > .town-button + * { border-left: 0; margin-left: 0; padding-left: 1px; }+ .toolbar button, .toolbar .town-button {+ font-size: 0; gap: 0; padding: 0; min-width: 34px; min-height: 34px; justify-content: center; border-radius: 6px;+ }+ .toolbar .town-button { padding: 0; }+ .toolbar button kbd { display: none; }+ .toolbar .speed { gap: 1px; }+ .toolbar .speed button:not(.pause):not(.cycle) { display: none; }+ .toolbar .speed button.cycle { display: flex; font-size: 12px; font-weight: 700; min-width: 38px; }+ .toolbar .speed button.cycle.paused { color: #9aa29b; }+ .toolbar button.more { display: flex; }+ .toolbar button.more.on { background: #3d4943; }+ .toolbar button.more.on .icon circle { fill: #f7f8f4; }- /* Bottom: the tools along the edge; the camera and the speed just above them. */- .toolbar { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); justify-content: center; overflow: visible; max-width: none; }- .toolbar .group, .toolbar .town-button { flex: none; }- .toolbar .speed { position: fixed; right: 10px; bottom: calc(66px + env(safe-area-inset-bottom)); padding: 3px; }- .toolbar .speed button { min-height: 38px; }- /* Pinch zooms, so the zoom buttons give their room to the speed. */- .camera-controls { left: 10px; bottom: calc(66px + env(safe-area-inset-bottom)); padding: 3px; }- .camera-controls [data-action="in"], .camera-controls [data-action="out"] { display: none; }- .camera-controls button { min-height: 38px; padding: 6px 9px; }- .toast { bottom: calc(120px + env(safe-area-inset-bottom)); max-width: calc(100vw - 28px); white-space: normal; text-align: center; }+ /* The camera: pinch zooms and turns it, and the menu has "recentre". */+ .camera-controls { display: none; }- /* The panel slides up as a sheet over the bottom half, so the town stays in view above it. */- .panel {- top: auto; left: 0; width: auto; max-width: none; height: 58dvh; border-left: 0; border-top: 1px solid #c3c8bf;- border-radius: 14px 14px 0 0; box-shadow: 0 -3px 0 #dfe2db; padding-top: 22px; transform: translateY(100%);+ /* ── The menu: share, the guide, save, load, new town, recentre ── */+ .system, .panel-open .system { display: none; }+ .fold-more .system, .fold-more.panel-open .system {+ display: flex; flex-direction: column; top: auto; right: calc(8px + env(safe-area-inset-right)); bottom: calc(58px + env(safe-area-inset-bottom));+ padding: 4px; gap: 1px; z-index: 4;+ }+ .fold-more .system .phone-only { display: flex; }+ .fold-more .system button, .fold-more .system button.labelled {+ font-size: 12px; gap: 10px; padding: 7px 12px 7px 9px; min-height: 34px; justify-content: flex-start; color: #3d4943;}- .panel::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: #c9cec4; }- .panel.open { transform: none; }- .panel-open .hud .stock, .panel-open .hud .ticker, .panel-open .hud .request, .panel-open .hud .alarm, .panel-open .views, .panel-open .legend { display: none; }-}-/* A very narrow phone: a little less padding so the tool row still fits. */-@media (max-width: 370px) {- .toolbar .group { gap: 2px; padding: 3px; }- .toolbar button, .toolbar .town-button { min-width: 38px; }- .camera-controls button { padding: 6px; min-width: 34px; }- .toolbar .speed button { min-width: 32px; padding: 6px 4px; }- .system button { min-width: 32px; padding: 4px; }+ .toast { bottom: calc(100px + env(safe-area-inset-bottom)); max-width: calc(100vw - 28px); white-space: normal; text-align: center; }++ /* ── Dialogs: the whole screen, the body scrolling, the actions pinned to the bottom ── */+ .dialog { padding: 0; }+ .dialog .sheet, .dialog .sheet.wide, .dialog.share .sheet {+ width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; box-shadow: none;+ padding: calc(18px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 0 calc(16px + env(safe-area-inset-left));+ display: flex; flex-direction: column; font-size: 13px;+ }+ .dialog .sheet > * { flex: none; }+ /* A question (load? new town?) stays a card in the middle. */+ .dialog .sheet.narrow {+ width: min(460px, calc(100% - 32px)); max-height: calc(100dvh - 32px); border: 1px solid #c3c8bf; border-radius: 6px; padding: 18px 16px 0;+ }+ .dialog .sheet > .actions {+ position: sticky; bottom: 0; margin: auto -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));+ background: #f1f3ed; border-top: 1px solid #dcdfd7; box-shadow: 0 -6px 12px rgba(61, 73, 67, 0.06);+ }+ .dialog .sheet > .actions .frame { flex: 1; justify-content: center; padding: 10px 12px; }+ .dialog .sheet > .actions .frame.primary { flex: 2; }+ .dialog h2 { font-size: 17px; }+ .dialog .sub { font-size: 12px; }+ .dialog section { margin-top: 12px; }+ .dialog .choices .frame { flex: 1; justify-content: center; padding: 8px 6px; }+ .dialog .preview canvas { width: 132px; height: 132px; }+ .dialog .chronicle { max-height: none; }}-/* ── Landscape phone: short, so the bars stay low and the panel keeps to the side ── */+/* ── Landscape phone: sheets from the side, so the map stays in view beside them ── */@media (max-height: 500px) {- .hud { top: calc(6px + env(safe-area-inset-top)); gap: 5px; }- .hud .card .cell { padding: 5px 10px; }- .toolbar { bottom: calc(6px + env(safe-area-inset-bottom)); }- .system { bottom: calc(6px + env(safe-area-inset-bottom)); }- .panel-open .system { display: none; }- .camera-controls { bottom: calc(60px + env(safe-area-inset-bottom)); padding: 3px; }- .views { bottom: calc(60px + env(safe-area-inset-bottom)); }- .legend { bottom: calc(60px + env(safe-area-inset-bottom)); }- .toast { bottom: calc(110px + env(safe-area-inset-bottom)); }+ .fold-guide .hud .ticker.show {+ top: calc(48px + env(safe-area-inset-top)); right: 0; bottom: 0; left: auto; width: min(380px, 55vw); border-radius: 12px 0 0 0;+ padding: 0 env(safe-area-inset-right) calc(10px + env(safe-area-inset-bottom)) 0; box-sizing: border-box;+ }+ .fold-guide .toolbar { left: calc(8px + env(safe-area-inset-left)); transform: none; }.panel { padding-top: 12px; }+ .panel-open .toolbar { left: calc(8px + env(safe-area-inset-left)); transform: none; max-width: calc(54vw - 16px); }+ .panel-open .hud .ticker.peek { display: none; }+ /* The picker: the options beside the map. */+ .dialog .charter { grid-template-columns: 1fr 150px; gap: 16px; }+}++/* ── Portrait phone: sheets from the bottom, so the town stays in view above them ── */+@media (max-width: 760px) and (min-height: 501px) {+ /* The clock and treasury on the first line beside the guide and overlay buttons; the people and goods on the second. */+ .hud.left { right: calc(8px + env(safe-area-inset-right)); }+ .hud .topline > .bar:first-child { flex: none; margin-right: 100%; }+ .fold-guide .hud .ticker.show {+ top: auto; left: 0; right: 0; bottom: 0; max-height: 62dvh; border-radius: 14px 14px 0 0;+ padding: 4px 0 calc(10px + env(safe-area-inset-bottom));+ }+ .panel {+ top: auto; left: 0; width: auto; max-width: none; height: 58dvh; border-left: 0; border-top: 1px solid #c3c8bf;+ border-radius: 14px 14px 0 0; box-shadow: 0 -3px 0 #dfe2db; padding-top: 22px; transform: translateY(100%);+ }+ .panel::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: #c9cec4; }+ .panel.open { transform: none; }+ .panel-open .hud .stock, .panel-open .hud .ticker, .panel-open .views, .panel-open .legend { display: none; }+ .dialog .charter { grid-template-columns: 1fr; gap: 0; }+ .dialog .preview { flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 10px; margin-top: 12px; }+ .dialog .preview .sub { flex: 1; min-width: 0; margin: 0; }+ .dialog .preview .row { flex-basis: 100%; }}-/* A small landscape window: the map views stand in a column on the right, so the ticker and the speed keep left of it. */-@media (max-width: 760px) and (max-height: 500px) {- .hud.left { right: 66px; }- /* Portrait puts the bar at the top; it must not also keep landscape's bottom. */- .system, .panel-open .system { bottom: auto; }- .toolbar .speed { right: 66px; }+/* A very narrow phone: the tool bar's buttons a little narrower so it still fits. */+@media (max-width: 380px) {+ .toolbar button, .toolbar .town-button { min-width: 31px; }+ .toolbar .speed button.cycle { min-width: 34px; }}/* ── Touch: fingers instead of a mouse ── */@media (pointer: coarse) {- /* No hover, so no key hints; targets big enough for a thumb. */+ /* No hover, so no key hints. */.toolbar button kbd, .views button kbd { display: none; }- .camera-controls button, .views button { min-width: 40px; min-height: 40px; }.panel .close { min-width: 40px; min-height: 40px; }- .hud .ticker .act { width: 32px; height: 32px; opacity: 0.6; }- /* The build hint follows no finger: it sits in one place above the bottom bars. */+ /* The build hint follows no finger: it sits in one place above the tool bar. */.tooltip {- left: 10px !important; right: 62px; top: auto !important; bottom: calc(120px + env(safe-area-inset-bottom));+ left: 10px !important; right: 10px; top: auto !important; bottom: calc(100px + env(safe-area-inset-bottom));transform: none; white-space: normal; text-align: center; font-size: 12px; line-height: 1.4;}}@media (pointer: coarse) and (max-height: 500px) {- .tooltip { bottom: calc(110px + env(safe-area-inset-bottom)); left: 25% !important; right: 25%; }+ .tooltip { left: 25% !important; right: 25%; }}