Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat: walk and game module updates
nirholasd79f3cdfa075
diff --git a/src/game/agent-commerce.js b/src/game/agent-commerce.jsindex 96ecaaf6e..500621d46 100644--- a/src/game/agent-commerce.js+++ b/src/game/agent-commerce.js@@ -23,6 +23,7 @@ import {import { AnimationManager } from '../animation-manager.js';import { resolveAvatarUrl, buildAvatar, loadManifest, MANIFEST_URL, CLIP_IDLE } from './avatar-rig.js';import { createX402Jumbotron } from './x402-jumbotron.js';+import { log } from '../shared/log.js';// Where the two agents stand — off to the right of the totem so a player// entering the town sees them but doesn't spawn on top of them.@@ -386,7 +387,7 @@ export class AgentCommerce {this.ui?.toast?.('Give the agents a moment — settling the last payment.', 'info');return;}- this._runRound().catch((err) => console.warn('[agent-commerce] round failed:', err?.message));+ this._runRound().catch((err) => log.warn('[agent-commerce] round failed:', err?.message));}// Load a one-shot gesture clip from the full manifest and play it, returning todiff --git a/src/game/avatar-rig.js b/src/game/avatar-rig.jsindex 786748bf9..3adfac80c 100644--- a/src/game/avatar-rig.js+++ b/src/game/avatar-rig.js@@ -15,6 +15,7 @@ import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';import { AnimationManager } from '../animation-manager.js';import { GUEST_SENTINEL, resolveGuestAvatar } from './play-handoff.js';+import { log } from '../shared/log.js';export const AVATAR_DEFAULT = '/avatars/default.glb';export const MANIFEST_URL = '/animations/manifest.json';@@ -115,7 +116,7 @@ export async function buildAvatar(rig, url, anim) {if (_animDefs?.length) { anim.setAnimationDefs(_animDefs); await anim.loadAll(); await anim.crossfadeTo(CLIP_IDLE, 0); }return { height: headAnchorHeight(box), fallback: false };} catch (err) {- console.warn('[avatar-rig] avatar load failed, using stand-in:', url, err?.message);+ log.warn('[avatar-rig] avatar load failed, using stand-in:', url, err?.message);const body = new Mesh(new CapsuleGeometry(0.32, 0.7, 4, 10), new MeshStandardMaterial({ color: 0x8aa6d8 }));body.position.y = 0.85; body.castShadow = true;const head = new Mesh(new SphereGeometry(0.28, 14, 10), new MeshStandardMaterial({ color: 0xf1c9a5 }));diff --git a/src/game/avatar-thumb.js b/src/game/avatar-thumb.jsindex 4eef06f05..2c9bc2dc6 100644--- a/src/game/avatar-thumb.js+++ b/src/game/avatar-thumb.js@@ -13,6 +13,7 @@ import {import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';import { AnimationManager } from '../animation-manager.js';import { loadManifest, getLocomotionDefs, CLIP_IDLE, dracoLoader } from './avatar-rig.js';+import { log } from '../shared/log.js';const SIZE = 160; // square render target, downscaled by the chip's CSS box@@ -41,7 +42,7 @@ function ensureRenderer() {_camera = new PerspectiveCamera(30, 1, 0.01, 100);return true;} catch (err) {- console.warn('[avatar-thumb] WebGL unavailable, skipping previews:', err?.message);+ log.warn('[avatar-thumb] WebGL unavailable, skipping previews:', err?.message);_failed = true;_renderer = null;return false;@@ -54,7 +55,7 @@ export function renderAvatarThumb(url) {if (!url) return Promise.resolve(null);if (_cache.has(url)) return _cache.get(url);const p = _snapshot(url).catch((err) => {- console.warn('[avatar-thumb] preview failed:', url, err?.message);+ log.warn('[avatar-thumb] preview failed:', url, err?.message);return null;});_cache.set(url, p);diff --git a/src/game/boot-avatar.js b/src/game/boot-avatar.jsindex 807d4b8f6..0e08d1d3f 100644--- a/src/game/boot-avatar.js+++ b/src/game/boot-avatar.js@@ -26,6 +26,7 @@ import {resolveAvatarUrl, dracoLoader,} from './avatar-rig.js';import { getPlayAvatar } from './play-handoff.js';+import { log } from '../shared/log.js';const REDUCED_MOTION = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;const TURN_SPEED = 0.5; // radians/sec — a slow, premium turntable@@ -56,7 +57,7 @@ function boot() {camera = new PerspectiveCamera(28, 1, 0.05, 100);} catch (err) {// No WebGL — reveal the static fallback mark and let the loader proceed.- console.warn('[boot-avatar] WebGL unavailable:', err?.message);+ log.warn('[boot-avatar] WebGL unavailable:', err?.message);canvas.parentElement?.classList.add('kx-boot-noavatar');done();return { ready, dispose() {} };@@ -115,7 +116,7 @@ function boot() {loop(last, target);done();}).catch((err) => {- console.warn('[boot-avatar] avatar load failed:', err?.message);+ log.warn('[boot-avatar] avatar load failed:', err?.message);canvas.parentElement?.classList.add('kx-boot-noavatar');done();});diff --git a/src/game/coincommunities-ui.js b/src/game/coincommunities-ui.jsindex e123a891f..4ff1ec2b5 100644--- a/src/game/coincommunities-ui.js+++ b/src/game/coincommunities-ui.js@@ -13,6 +13,7 @@ import { renderAvatarThumb } from './avatar-thumb.js';import { resolveAvatarUrl } from './avatar-rig.js';import { validateGlb, uploadGlb } from './avatar-upload.js';import { GUEST_SENTINEL, playAs } from './play-handoff.js';+import { log } from '../shared/log.js';function el(tag, props = {}, kids = []) {const n = document.createElement(tag);@@ -503,7 +504,7 @@ export class CommunityUI {});await this._creator.openDefaultEditor();} catch (err) {- console.warn('[coincommunities] avatar creator failed to open:', err?.message);+ log.warn('[coincommunities] avatar creator failed to open:', err?.message);this.toast('Couldn’t open the avatar creator. Try uploading a .glb instead.', 'warn');} finally {this.createBtn.classList.remove('cc-busy');@@ -526,7 +527,7 @@ export class CommunityUI {this._setUploadState('done', 'Your avatar is ready — pick a community to drop in.');this.toast('Your avatar is ready — pick a community below to drop in.', 'info');} catch (err) {- console.warn('[coincommunities] could not adopt created avatar:', err?.message);+ log.warn('[coincommunities] could not adopt created avatar:', err?.message);this._setUploadState('error', 'Couldn’t save your new avatar. Please try again.');}}@@ -565,7 +566,7 @@ export class CommunityUI {});if (selected) this._adoptGalleryAvatar(selected);} catch (err) {- console.warn('[coincommunities] gallery picker failed:', err?.message);+ log.warn('[coincommunities] gallery picker failed:', err?.message);} finally {this.galleryBtn.classList.remove('cc-busy');}@@ -707,7 +708,7 @@ export class CommunityUI {try {results = (await this.h.onSearch(query)) || [];} catch (err) {- console.warn('[coincommunities] search failed:', err?.message);+ log.warn('[coincommunities] search failed:', err?.message);}if (seq !== this._searchSeq) return; // a newer query superseded this onethis.searchResults = results;@@ -1099,7 +1100,7 @@ export class CommunityUI {}setStatus(state) {- const labels = { connecting: 'connecting…', online: 'connected', offline: 'reconnecting…', failed: 'offline — retry', idle: 'idle' };+ const labels = { connecting: 'connecting…', online: 'connected', offline: 'reconnecting…', unavailable: 'multiplayer unavailable', failed: 'offline — retry', idle: 'idle' };this.statusPill.setAttribute('data-state', state);this.statusText.textContent = labels[state] || state;// The latency readout is only meaningful while the link is live.diff --git a/src/game/coincommunities.css b/src/game/coincommunities.cssindex 6a10a7b0d..84228ab33 100644--- a/src/game/coincommunities.css+++ b/src/game/coincommunities.css@@ -725,6 +725,9 @@ html, body {#cc-status[data-state="connecting"] .cc-dot { background: var(--cc-warn); animation: cc-pulse 1s infinite; }#cc-status[data-state="offline"] .cc-dot, #cc-status[data-state="failed"] .cc-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--cc-dim); }#cc-status[data-state="offline"], #cc-status[data-state="failed"] { cursor: pointer; }+/* No server configured for this env — passive solo readout, not retryable. */+#cc-status[data-state="unavailable"] .cc-dot { background: var(--cc-faint); }+#cc-status[data-state="unavailable"] { cursor: default; }@keyframes cc-pulse { 50% { opacity: 0.3; } }/* spatial voice toggle — top-right, tucked under the status pill */diff --git a/src/game/coincommunities.js b/src/game/coincommunities.jsindex dfc62204f..8694c351d 100644--- a/src/game/coincommunities.js+++ b/src/game/coincommunities.js@@ -40,6 +40,8 @@ import { requestHolderPass, signInWithX, ensureSolanaWallet, relinkSolanaWallet,import { ensurePlayAccess } from './play-gate.js';import { clearStoredPass, fetchPlayConfig, signInToPlay, loadStoredPass, storePass } from './play-auth.js';import { PlaySystems } from './play-systems.js';+import { PlayOnboard } from './play-onboard.js';+import { log } from '../shared/log.js';const WORLD_RADIUS = 58; // a touch inside the server's 60m clampconst MOVE_SPEED = 4.2;@@ -279,7 +281,7 @@ export class CoinCommunities {const raw = await r.json();this.ui.setCoins(mapCoins(raw));} catch (err) {- console.warn('[coincommunities] coin load failed:', err?.message);+ log.warn('[coincommunities] coin load failed:', err?.message);this.ui.setCoinsError(() => this._loadCoins());}}@@ -297,7 +299,7 @@ export class CoinCommunities {if (coin?.mint) this.ui.setFeatured({ ...HOME_TOWN, ...coin, official: true });} catch (err) {// Non-fatal: the static pin from above stands in until next load.- console.warn('[coincommunities] home town refresh failed:', err?.message);+ log.warn('[coincommunities] home town refresh failed:', err?.message);}}@@ -700,7 +702,7 @@ export class CoinCommunities {// other players, chat and shared building are off, and how to recover.if (status === 'failed' && !this._failedNotified) {this._failedNotified = true;- this.ui.toast('Lost the connection — you’re in single-player. Builds here won’t be saved or seen by others. Tap the status pill to reconnect.', 'warn');+ this.ui.toast('Lost the connection to the world — chat and shared builds are paused. Tap the status pill to reconnect.', 'warn');}if (status === 'online') this._failedNotified = false;// Every (re)connect re-streams the server's authoritative build, so wipe@@ -715,7 +717,7 @@ export class CoinCommunities {// Durability badge: online reflects the server's persistent flag; solo// single-player isn't saved at all, so hide it (null) to avoid a false// promise. Re-sync the budget meter against whatever layer is now live.- this.buildHud.setPersistent(status === 'online' ? this.net?.persistent : (status === 'offline' ? false : null));+ this.buildHud.setPersistent(status === 'online' ? this.net?.persistent : (status === 'offline' || status === 'unavailable' ? false : null));this._syncBudget();// A reconnect reissues every sessionId, stranding the voice mesh — refresh// our id, drop the stale peers, and re-announce so it re-forms.@@ -798,6 +800,12 @@ export class CoinCommunities {// re-reads the chain (via /api/play/verify) so a wallet that offloaded its// tokens is refused rather than silently let through on a stale pass.this._schedulePassRefresh();++ // First-join onboarding: overlay + economy clarity strip + controls help.+ // Created per-world so the economy copy is always specific to this coin.+ // Torn down in leave() along with all other per-world objects.+ if (this._onboard) { this._onboard.dispose(); }+ this._onboard = new PlayOnboard({ coin });}// First-run nudge so players discover building exists — the HUD's ⛏ toggle is@@ -870,7 +878,7 @@ export class CoinCommunities {}return access;} catch (err) {- console.warn('[coincommunities] play gate error:', err?.message);+ log.warn('[coincommunities] play gate error:', err?.message);return { required: false };}}@@ -979,7 +987,7 @@ export class CoinCommunities {try {await this.voice.join();} catch (err) {- console.warn('[coincommunities] voice join failed:', err?.name, err?.message);+ log.warn('[coincommunities] voice join failed:', err?.name, err?.message);this.ui.setVoiceState(err?.name === 'NotAllowedError' ? 'denied' : 'error');}} else {@@ -999,6 +1007,7 @@ export class CoinCommunities {if (this.net) { this.net.destroy(); this.net = null; }if (this.playSystems) { this.playSystems.dispose(); this.playSystems = null; }if (this.agentCommerce) { this.agentCommerce.dispose(); this.agentCommerce = null; }+ if (this._onboard) { this._onboard.dispose(); this._onboard = null; }for (const [, r] of this.remotes) r.dispose();this.remotes.clear();if (this._totem) { this.world.remove(this._totem); this._totem = null; this._coinSpin = null; }@@ -1091,7 +1100,7 @@ export class CoinCommunities {const { openBuyModal } = await import('./coin-buy.js');openBuyModal(coin);} catch (err) {- console.warn('[coincommunities] buy modal failed to load:', err?.message);+ log.warn('[coincommunities] buy modal failed to load:', err?.message);this.ui.toast('Couldn’t open the buy panel. Trade on pump.fun instead.', 'warn');}}@@ -1243,7 +1252,9 @@ export class CoinCommunities {// the connecting window (nothing to build into yet) is the only time off._buildableConnection() {const s = this.net?.status;- return s === 'online' || s === 'offline';+ // 'unavailable' (no server configured for this env) is a solo session just+ // like 'offline' — let the player build their own local copy.+ return s === 'online' || s === 'offline' || s === 'unavailable';}// Place or break a block under the pointer. Online is server-authoritative: we@@ -1385,7 +1396,7 @@ export class CoinCommunities {const how = touch? 'tap to place, hold to break, pick a block, ⌘/Ctrl+Z to undo': 'click to place, right-click to break, 1–0 pick a block, ⌘/Ctrl+Z to undo';- this.ui.toast(`Build mode${solo ? ' (single-player)' : ''} — ${how}`, 'info');+ this.ui.toast(`Build mode${solo ? ' (offline — reconnect to share)' : ''} — ${how}`, 'info');this._syncBudget();if (this._lastHover) this._updateGhost(this._lastHover.x, this._lastHover.y);}diff --git a/src/game/community-net.js b/src/game/community-net.jsindex e13c9dbfe..00c463526 100644--- a/src/game/community-net.js+++ b/src/game/community-net.js@@ -11,6 +11,7 @@import { Client, getStateCallbacks } from 'colyseus.js';import { WalkState } from '../../multiplayer/src/schemas.js';+import { log } from '../shared/log.js';const ROOM_NAME = 'walk_world';const RECONNECT_BASE_MS = 3000;@@ -48,11 +49,24 @@ function defaultServerUrl() {if (v) return v;}}+ try {+ const envUrl = import.meta?.env?.VITE_GAME_SERVER_URL || import.meta?.env?.VITE_WALK_SERVER_URL;+ if (envUrl) return String(envUrl).trim().replace(/\/$/, '');+ } catch (_) {}if (typeof location !== 'undefined') {const proto = location.protocol === 'https:' ? 'wss:' : 'ws:';- return `${proto}//${location.hostname}:2567`;+ // Codespaces / Gitpod forward each port as its own subdomain (-3000 → -2567).+ const fwd = host.match(/^(.*)-(\d+)\.(app\.github\.dev|githubpreview\.dev|gitpod\.io)$/);+ if (fwd) return `${proto}//${fwd[1]}-2567.${fwd[3]}`;+ // Same-host:2567 is a dev convenience; the public domain doesn't expose+ // :2567. In production with no meta/env configured, return '' so the+ // caller stays single-player instead of looping on a dead socket.+ let isProd = false;+ try { isProd = import.meta?.env?.PROD === true; } catch (_) {}+ if (!isProd) return `${proto}//${host}:2567`;+ return '';}- return 'ws://localhost:2567';+ return '';}export class CommunityNet {@@ -134,7 +148,7 @@ export class CommunityNet {}_emit(event, ...args) {for (const fn of this._handlers[event]) {- try { fn(...args); } catch (e) { console.error(`[community-net] ${event} handler threw:`, e); }+ try { fn(...args); } catch (e) { log.error(`[community-net] ${event} handler threw:`, e); }}}_setStatus(status, error = null) {@@ -161,6 +175,16 @@ export class CommunityNet {async connect() {if (this._destroyed) return;this._closeRoom();+ // No multiplayer server resolved for this environment (production with no+ // game-server meta/env). Surface a distinct, honest 'unavailable' state —+ // solo play still works — rather than throwing in `new Client('')`,+ // looping on reconnects, or showing a "reconnecting…" pill that can never+ // reconnect. (The exhausted-reconnect path below stays 'offline' because+ // there a real server exists and a manual retry can still succeed.)+ if (!this.url) {+ this._setStatus('unavailable', 'multiplayer unavailable — single-player only');+ return;+ }// Bump a generation token so a slower in-flight connect (e.g. a manual// retry racing the auto-reconnect timer) can detect it's been superseded// after its await resolves and discard the room it joined, rather than@@ -275,7 +299,7 @@ export class CommunityNet {if (code === 4002) { this._setStatus('denied', 'play_pass_required'); this._emit('denied', 'play_pass_required'); return; }if (!this._destroyed && code !== 1000) this._scheduleReconnect();});- this.room.onError((code, message) => console.warn('[community-net] room.onError', code, message));+ this.room.onError((code, message) => log.warn('[community-net] room.onError', code, message));this._reconnectAttempts = 0;this._setStatus('online');@@ -291,12 +315,12 @@ export class CommunityNet {// retrying with the same expired/invalid pass just loops. Surface it so// the scene can route the player back to the gate, and stop here.if (/holder_pass|play_pass/i.test(msg)) {- console.warn('[community-net] gate denied join:', msg);+ log.warn('[community-net] gate denied join:', msg);this._setStatus('denied', msg);this._emit('denied', msg);return;}- console.warn('[community-net] connect failed:', msg);+ log.warn('[community-net] connect failed:', msg);this._setStatus('failed', msg);this._scheduleReconnect();}diff --git a/src/game/cosmetics-visual.js b/src/game/cosmetics-visual.jsindex 562402f5c..0ae3d8a37 100644--- a/src/game/cosmetics-visual.js+++ b/src/game/cosmetics-visual.js@@ -20,6 +20,7 @@ import {} from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';import { dracoLoader } from './avatar-rig.js';+import { log } from '../shared/log.js';// Share the Draco-enabled decoder module + cache with the avatar loader so prop// GLBs (which may be Draco-compressed) decode without a second decoder instance.@@ -33,7 +34,7 @@ function loadProp(url) {if (!_propCache.has(url)) {_propCache.set(url, _loader.loadAsync(url).then((g) => g.scene)- .catch((err) => { console.warn('[cosmetics] prop load failed:', url, err?.message); return null; }));+ .catch((err) => { log.warn('[cosmetics] prop load failed:', url, err?.message); return null; }));}return _propCache.get(url);}diff --git a/src/game/play-handoff.js b/src/game/play-handoff.jsindex e01e1b258..a25e35dbc 100644--- a/src/game/play-handoff.js+++ b/src/game/play-handoff.js@@ -17,6 +17,7 @@// URL so peers see it too — no upload round-trip before the world appears.import { stage, load, peek } from '../guest-avatar.js';+import { log } from '../shared/log.js';export const CC_AVATAR_KEY = 'cc-avatar';export const CC_NAME_KEY = 'cc-name';@@ -129,7 +130,7 @@ export async function uploadPendingGuestAvatar(onPublished) {onPublished?.(publicUrl);return publicUrl;} catch (err) {- console.warn('[play-handoff] guest avatar upload failed; staying local-only:', err?.message);+ log.warn('[play-handoff] guest avatar upload failed; staying local-only:', err?.message);return null;}}diff --git a/src/game/play-intro.js b/src/game/play-intro.jsnew file mode 100644index 000000000..ee0971338--- /dev/null+++ b/src/game/play-intro.js@@ -0,0 +1,277 @@+// Lobby cold-open for /play — the first thing a newcomer sees.+//+// The audit found /play opens straight onto a grid of pump.fun coins with no+// context: a visitor expecting a game lands in what reads like a token-economy+// sim and bounces. This module fixes the *first ten seconds* — before any coin,+// wallet, or avatar decision is asked for — with one plain-language card:+//+// • What this is, in human words: a live 3D world you explore with other+// people. The on-chain economy is named as a hook, never as a gate.+// • A concrete first objective so the player knows what to *do*.+// • A primary "Drop in now" action that enters the $THREE home town with the+// default character — zero friction, no wallet, no coin to understand. The+// economy stays fully discoverable in-world (see play-onboard.js), just not+// mandatory up front.+//+// Shown once per browser (localStorage), skippable (×/Esc), focus-trapped,+// prefers-reduced-motion respected. Re-openable any time via mountIntroReopener.+//+// Framing rules honored: never single-player ("with other people", "others are+// here too"); the only coin named anywhere is $THREE.++const INTRO_KEY = 'cc-lobby-intro-v1';++function lsGet(k) { try { return localStorage.getItem(k); } catch { return null; } }+function lsSet(k, v) { try { localStorage.setItem(k, v); } catch { /* private mode — just re-show */ } }++function mk(tag, attrs = {}, ...children) {+ const n = document.createElement(tag);+ for (const [k, v] of Object.entries(attrs)) {+ if (k === 'className') n.className = v;+ else if (k === 'html') n.innerHTML = v;+ else if (k === 'text') n.textContent = v;+ else if (k.startsWith('on') && typeof v === 'function') n.addEventListener(k.slice(2).toLowerCase(), v);+ else if (v !== false && v !== null && v !== undefined) n.setAttribute(k, v === true ? '' : String(v));+ }+ children.flat().forEach((c) => c != null && n.appendChild(typeof c === 'string' ? document.createTextNode(c) : c));+ return n;+}++let stylesInjected = false;+function injectStyles() {+ if (stylesInjected || document.getElementById('pi-styles')) { stylesInjected = true; return; }+ stylesInjected = true;+ const s = document.createElement('style');+ s.id = 'pi-styles';+ // Tokens mirror coincommunities.css --cc-* with safe fallbacks, so the card+ // stands alone even if the lobby sheet hasn't painted yet.+ s.textContent = `+#pi-overlay {+ position: fixed; inset: 0; z-index: 60;+ display: flex; align-items: center; justify-content: center; padding: 20px;+ background: rgba(4,4,5,0.78); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);+ opacity: 0; transition: opacity 0.24s ease;+}+#pi-overlay.pi-show { opacity: 1; }++.pi-card {+ position: relative; box-sizing: border-box;+ width: min(480px, calc(100vw - 32px));+ background: var(--cc-panel-solid, #0c0c0e);+ border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));+ border-radius: var(--cc-radius, 4px);+ box-shadow: var(--cc-shadow, 0 18px 56px rgba(0,0,0,0.72));+ padding: 26px 26px 22px;+ transform: translateY(12px) scale(0.985);+ transition: transform 0.24s cubic-bezier(0.2,0.7,0.2,1);+}+#pi-overlay.pi-show .pi-card { transform: none; }++.pi-close {+ position: absolute; top: 13px; right: 13px;+ width: 30px; height: 30px;+ border-radius: var(--cc-radius-sm, 2px);+ background: var(--cc-bg2, #101012);+ border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));+ color: var(--cc-dim, #8c8c92); font-size: 21px; line-height: 1; cursor: pointer;+ display: flex; align-items: center; justify-content: center;+ transition: color 0.12s ease, border-color 0.12s ease;+}+.pi-close:hover { color: var(--cc-text, #f5f5f6); border-color: var(--cc-edge-hi, rgba(255,255,255,0.55)); }+.pi-close:focus-visible { outline: none; border-color: #fff; box-shadow: 0 0 0 1px #fff; }++.pi-tag {+ font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;+ color: var(--cc-faint, #5a5a60); margin: 0 0 8px;+}+.pi-title {+ font-size: 23px; font-weight: 800; line-height: 1.2; letter-spacing: 0.005em;+ color: var(--cc-text, #f5f5f6); margin: 0 0 12px; max-width: 22ch;+}+.pi-body {+ font-size: 14px; line-height: 1.6; color: var(--cc-dim, #8c8c92);+ margin: 0 0 18px; max-width: 46ch;+}++/* First-objective callout */+.pi-goal {+ display: flex; align-items: flex-start; gap: 11px;+ background: var(--cc-bg2, #101012);+ border: 1px solid var(--cc-edge-soft, rgba(255,255,255,0.07));+ border-radius: var(--cc-radius, 4px);+ padding: 12px 14px; margin: 0 0 22px;+}+.pi-goal-ico {+ flex: none; width: 26px; height: 26px; border-radius: 50%;+ display: flex; align-items: center; justify-content: center;+ background: rgba(255,255,255,0.06);+ border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));+ color: var(--cc-text, #f5f5f6); font-size: 13px;+}+.pi-goal-txt { font-size: 12.5px; line-height: 1.5; color: var(--cc-dim, #8c8c92); }+.pi-goal-txt strong { color: var(--cc-text, #f5f5f6); font-weight: 700; }++.pi-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }+.pi-btn {+ appearance: none; font: inherit; cursor: pointer;+ padding: 11px 22px; border-radius: var(--cc-radius-sm, 2px);+ font-weight: 700; font-size: 13.5px; letter-spacing: 0.02em;+ display: inline-flex; align-items: center; gap: 8px;+ transition: filter 0.12s ease, transform 0.1s ease, border-color 0.12s ease, color 0.12s ease, background 0.12s ease;+}+.pi-btn:active { transform: translateY(1px); }+.pi-btn-primary {+ background: #fff; color: var(--cc-ink, #060607); border: 1px solid #fff;+ box-shadow: var(--cc-glow, 0 0 16px rgba(255,255,255,0.32));+}+.pi-btn-primary:hover { filter: brightness(0.92); }+.pi-btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--cc-bg, #060607), 0 0 0 4px #fff; }+.pi-btn-ghost {+ background: none; border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));+ color: var(--cc-dim, #8c8c92);+}+.pi-btn-ghost:hover { border-color: var(--cc-edge-hi, rgba(255,255,255,0.55)); color: var(--cc-text, #f5f5f6); }+.pi-btn-ghost:focus-visible { outline: none; border-color: #fff; box-shadow: 0 0 0 1px #fff; }+.pi-btn-arrow { transition: transform 0.14s ease; }+.pi-btn-primary:hover .pi-btn-arrow { transform: translateX(2px); }++.pi-fine {+ margin: 16px 0 0; font-size: 11px; line-height: 1.5;+ color: var(--cc-faint, #5a5a60);+}++/* "New here?" lobby re-opener */+.pi-reopen {+ appearance: none; cursor: pointer; font: inherit;+ display: inline-flex; align-items: center; gap: 6px;+ background: var(--cc-panel, rgba(12,12,14,0.78));+ border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));+ border-radius: var(--cc-radius, 4px); padding: 6px 12px;+ color: var(--cc-dim, #8c8c92);+ font-size: 11px; font-weight: 600; letter-spacing: 0.04em;+ transition: border-color 0.12s ease, color 0.12s ease;+}+.pi-reopen:hover { border-color: var(--cc-edge-hi, rgba(255,255,255,0.55)); color: var(--cc-text, #f5f5f6); }+.pi-reopen:focus-visible { outline: none; border-color: #fff; box-shadow: 0 0 0 1px #fff; }+.pi-reopen .pi-reopen-dot {+ width: 6px; height: 6px; border-radius: 50%;+ background: var(--cc-live, #fff); box-shadow: var(--cc-glow, 0 0 12px rgba(255,255,255,0.35));+}++@media (max-width: 520px) {+ .pi-card { padding: 22px 20px 20px; }+ .pi-title { font-size: 20px; }+ .pi-actions { flex-direction: column; align-items: stretch; }+ .pi-btn { justify-content: center; }+}++@media (prefers-reduced-motion: reduce) {+ #pi-overlay, .pi-card { transition: none; }+ .pi-btn-arrow { transition: none; }+ .pi-reopen .pi-reopen-dot { box-shadow: none; }+}+`;+ document.head.appendChild(s);+}++/**+ * Mount the cold-open card. Self-contained; returns nothing.+ * @param {object} opts+ * @param {() => void} opts.onDropIn Enter the $THREE home town with the default+ * character — the zero-friction path. Called after the card closes.+ * @param {boolean} [opts.force] Show even if already dismissed (re-open).+ */+export function showPlayIntro({ onDropIn, force = false } = {}) {+ if (!force && lsGet(INTRO_KEY)) return null;+ if (document.getElementById('pi-overlay')) return null;+ injectStyles();++ const overlay = mk('div', {+ id: 'pi-overlay', role: 'dialog', 'aria-modal': 'true',+ 'aria-label': 'Welcome to three.ws Play',+ });++ let prevFocus = document.activeElement;+ let keyFn = null;+ let trapFn = null;++ const close = () => {+ lsSet(INTRO_KEY, '1');+ overlay.classList.remove('pi-show');+ if (keyFn) document.removeEventListener('keydown', keyFn);+ if (trapFn) document.removeEventListener('keydown', trapFn);+ setTimeout(() => overlay.remove(), 260);+ try { prevFocus?.focus?.(); } catch { /* element gone */ }+ };++ const dropIn = () => { close(); try { onDropIn?.(); } catch { /* caller logs */ } };++ const closeBtn = mk('button', {+ className: 'pi-close', type: 'button', 'aria-label': 'Skip intro', text: '×',+ onclick: close,+ });++ const goal = mk('div', { className: 'pi-goal' },+ mk('span', { className: 'pi-goal-ico', 'aria-hidden': 'true', text: '◎' }),+ mk('span', { className: 'pi-goal-txt', html:+ '<strong>Your first move:</strong> drop into the $THREE home town, then walk up to the two AI traders in the plaza and watch them strike a live on-chain deal.' }),+ );++ const actions = mk('div', { className: 'pi-actions' },+ mk('button', {+ className: 'pi-btn pi-btn-primary', type: 'button', onclick: dropIn,+ }, 'Drop in now', mk('span', { className: 'pi-btn-arrow', 'aria-hidden': 'true', text: '→' })),+ mk('button', {+ className: 'pi-btn pi-btn-ghost', type: 'button', onclick: close,+ }, 'Pick a character first'),+ );++ const card = mk('div', { className: 'pi-card' },+ closeBtn,+ mk('p', { className: 'pi-tag', text: 'Welcome' }),+ mk('h2', { className: 'pi-title', text: 'A 3D world you explore together' }),+ mk('p', { className: 'pi-body', text:+ 'three.ws is a live 3D world you walk around with other people — chat, build, and explore side by side. AI agents even trade on-chain in the town square. You can look around with no wallet and no crypto; the economy is there when you want it, never in the way.' }),+ goal,+ actions,+ mk('p', { className: 'pi-fine', text: 'Move with WASD or the on-screen joystick · drag to look around · Enter to chat. You can change your character any time.' }),+ );++ overlay.appendChild(card);+ document.body.appendChild(overlay);++ // Focus trap so Tab can't escape to the lobby behind the modal.+ const FOCUSABLE = 'button:not([disabled]), a[href], input:not([disabled]), [tabindex]:not([tabindex="-1"])';+ trapFn = (e) => {+ if (e.key !== 'Tab') return;+ const els = Array.from(overlay.querySelectorAll(FOCUSABLE));+ if (!els.length) return;+ const first = els[0], last = els[els.length - 1];+ if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }+ else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }+ };+ keyFn = (e) => { if (e.key === 'Escape') { e.preventDefault(); close(); } };+ document.addEventListener('keydown', keyFn);+ document.addEventListener('keydown', trapFn);++ requestAnimationFrame(() => {+ overlay.classList.add('pi-show');+ card.querySelector('.pi-btn-primary')?.focus();+ });++ return { close };+}++/**+ * Build a small, always-available "New here?" button that re-opens the intro.+ * Returns the element for the caller to place in the lobby chrome.+ * @param {() => void} onDropIn same drop-in handler as showPlayIntro.+ */+export function makeIntroReopener(onDropIn) {+ injectStyles();+ return mk('button', {+ className: 'pi-reopen', type: 'button', 'aria-label': 'New here? Replay the intro',+ title: 'New here? Replay the intro',+ onclick: () => showPlayIntro({ onDropIn, force: true }),+ }, mk('span', { className: 'pi-reopen-dot', 'aria-hidden': 'true' }), 'New here?');+}diff --git a/src/game/play-onboard.js b/src/game/play-onboard.jsnew file mode 100644index 000000000..dc84fddf5--- /dev/null+++ b/src/game/play-onboard.js@@ -0,0 +1,545 @@+// First-join onboarding + economy clarity for /play.+//+// Three deliverables in one self-contained module:+//+// 1. First-join overlay — a 3-step modal shown once per browser:+// Step 1: Welcome — names the world and its coin; shared-world framing.+// Step 2: Controls — the real input bindings from the input handler.+// Step 3: Economy — grounded in agent-commerce.js and the market reactor.+// Persists dismissal in localStorage so it never nags returning players.+// ESC / ← → keyboard navigation; focus-trapped; prefers-reduced-motion respected.+//+// 2. Economy clarity strip — always-visible info panel below the coin banner.+// For the $THREE home town: describes the live Agent Exchange (ORACLE/NOVA).+// For other coins: describes how real trades drive the world environment.+//+// 3. Controls help button — "Controls" button that opens a full reference panel+// sourced from the real _bindInput() / _stepLocal() bindings.+//+// Never frames /play as single-player. Connecting/offline states use correct copy.++import { isHomeTown } from './home-town.js';++const ONBOARD_KEY = 'cc-onboarded-v1';++// ── Real controls sourced from coincommunities.js _bindInput() / _stepLocal() ─++const DESK_CONTROLS = [+ { key: 'W A S D', desc: 'Move' },+ { key: '↑ ↓ ← →', desc: 'Move (arrows)' },+ { key: 'Shift', desc: 'Sprint' },+ { key: 'Space', desc: 'Jump' },+ { key: 'Drag', desc: 'Look around' },+ { key: 'Scroll', desc: 'Zoom camera' },+ { key: 'Enter', desc: 'Chat' },+ { key: 'B', desc: 'Build mode' },+ { key: 'E', desc: 'Watch agent trade' },+ { key: 'F', desc: 'Fish (near ponds)' },+ { key: '1–6', desc: 'Hotbar slot' },+ { key: 'Ctrl/⌘+Z', desc: 'Undo build' },+];++const TOUCH_CONTROLS = [+ { key: 'Joystick', desc: 'Move (bottom-left)' },+ { key: 'Drag', desc: 'Look around' },+ { key: 'Scroll / pinch', desc: 'Zoom camera' },+ { key: '⛏ button', desc: 'Build mode' },+ { key: 'Tap agents', desc: 'Watch agent trade' },+ { key: 'Chat bar', desc: 'Chat' },+];++// ── Helpers ───────────────────────────────────────────────────────────────────++function isTouch() {+ return typeof matchMedia === 'function' &&+ matchMedia('(hover: none), (pointer: coarse)').matches;+}++function lsGet(k) { try { return localStorage.getItem(k); } catch { return null; } }+function lsSet(k, v) { try { localStorage.setItem(k, v); } catch {} }++function mk(tag, attrs = {}, ...children) {+ const n = document.createElement(tag);+ for (const [k, v] of Object.entries(attrs)) {+ if (k === 'className') n.className = v;+ else if (k === 'innerHTML') n.innerHTML = v;+ else if (k === 'textContent') n.textContent = v;+ else if (k.startsWith('on') && typeof v === 'function') n.addEventListener(k.slice(2).toLowerCase(), v);+ else if (v !== false && v !== null && v !== undefined) n.setAttribute(k, v === true ? '' : String(v));+ }+ children.flat().forEach((c) => c != null && n.appendChild(typeof c === 'string' ? document.createTextNode(c) : c));+ return n;+}++// ── Main class ────────────────────────────────────────────────────────────────++export class PlayOnboard {+ /**+ * @param {object} opts+ * @param {object} opts.coin The coin this world is keyed to { mint, name, symbol, image }.+ */+ constructor({ coin }) {+ this.coin = coin;+ this._disposed = false;+ this._step = 0;+ this._overlay = null;+ this._helpPanel = null;+ this._strip = null;+ this._keyFn = null;+ this._showTimer = null;++ this._injectStyles();+ this._buildStrip();++ if (!lsGet(ONBOARD_KEY)) {+ // Delay slightly so the world geometry is visible behind the overlay.+ this._showTimer = setTimeout(() => {+ if (!this._disposed) this._showOverlay();+ }, 650);+ }+ }++ // ── Slide content ──────────────────────────────────────────────────────────++ _slides() {+ const { coin } = this;+ const sym = coin.symbol ? '$' + coin.symbol.toUpperCase() : '';+ const name = coin.name || 'Community';+ const home = isHomeTown(coin.mint);++ return [+ {+ tag: 'Welcome',+ title: name + (sym ? ' · ' + sym : ''),+ body:+ 'A shared 3D world — everyone in ' ++ (sym || `the ${name} community`) ++ ' meets here. Walk around, chat, build, and trade together. ' ++ 'Others are in this world with you right now.',+ },+ {+ tag: 'Controls',+ title: 'How to move',+ isControls: true,+ },+ {+ tag: 'Economy',+ title: 'The economy',+ body: home+ ? 'Two AI agents — ORACLE and NOVA — trade on-chain here. NOVA pays ORACLE in USDC via x402 for access to ORACLE\'s service catalog. Every settlement is a real Solana transaction with a Solscan link. Walk up to the agents by the plaza and press E (or tap them) to watch a live payment round.'+ : 'Real ' + (sym || name) + ' trades drive this world: buys light the boundary ring green, sells ripple red. Volume spins the totem, price momentum shifts the weather. The jumbotron above shows live on-chain market data.',+ },+ ];+ }++ // ── Overlay ────────────────────────────────────────────────────────────────++ _showOverlay() {+ if (this._overlay) return;+ this._step = 0;++ const overlay = mk('div', {+ id: 'po-overlay',+ role: 'dialog',+ 'aria-modal': 'true',+ 'aria-label': 'Welcome to this world',+ });+ document.body.appendChild(overlay);+ this._overlay = overlay;+ this._renderSlide();++ this._keyFn = (e) => {+ if (!this._overlay) return;+ if (e.key === 'Escape') { e.preventDefault(); this._dismiss(); }+ if (e.key === 'ArrowRight') { e.preventDefault(); this._stepTo(this._step + 1); }+ if (e.key === 'ArrowLeft') { e.preventDefault(); this._stepTo(this._step - 1); }+ };+ document.addEventListener('keydown', this._keyFn);++ requestAnimationFrame(() => {+ overlay.classList.add('po-show');+ overlay.querySelector('.po-btn-primary')?.focus();+ });+ }++ _renderSlide() {+ const overlay = this._overlay;+ if (!overlay) return;+ overlay.textContent = '';++ const slides = this._slides();+ const slide = slides[this._step];+ const total = slides.length;+ const isLast = this._step === total - 1;+ const isFirst = this._step === 0;++ // ── Dots ──+ const dots = mk('div', { className: 'po-dots', 'aria-hidden': 'true' });+ for (let i = 0; i < total; i++) {+ dots.appendChild(mk('span', { className: 'po-dot' + (i === this._step ? ' po-dot-on' : '') }));+ }++ // ── Header ──+ const tag = mk('p', { className: 'po-tag', textContent: slide.tag.toUpperCase() });+ const title = mk('h2', { className: 'po-title', textContent: slide.title });++ // ── Body ──+ let body;+ if (slide.isControls) {+ body = this._buildControlsGrid(isTouch());+ } else {+ body = mk('p', { className: 'po-body', textContent: slide.body });+ }++ // ── Actions ──+ const actions = mk('div', { className: 'po-actions' });++ if (!isFirst) {+ const back = mk('button', {+ className: 'po-btn po-btn-ghost', type: 'button', textContent: 'Back',+ onclick: () => this._stepTo(this._step - 1),+ });+ actions.appendChild(back);+ }++ const cta = mk('button', {+ className: 'po-btn po-btn-primary', type: 'button',+ textContent: isLast ? 'Enter the world' : 'Continue',+ onclick: () => isLast ? this._dismiss() : this._stepTo(this._step + 1),+ });+ actions.appendChild(cta);++ // ── Close (skip) ──+ const closeBtn = mk('button', {+ className: 'po-close', type: 'button',+ 'aria-label': 'Skip intro',+ textContent: '×',+ onclick: () => this._dismiss(),+ });++ const card = mk('div', { className: 'po-card' });+ card.appendChild(closeBtn);+ card.appendChild(dots);+ card.appendChild(tag);+ card.appendChild(title);+ card.appendChild(body);+ card.appendChild(actions);+ overlay.appendChild(card);+ }++ _stepTo(idx) {+ const slides = this._slides();+ const next = Math.max(0, Math.min(slides.length - 1, idx));+ if (next === this._step) return;+ this._step = next;+ this._renderSlide();+ this._overlay?.querySelector('.po-btn-primary')?.focus();+ }++ _dismiss() {+ lsSet(ONBOARD_KEY, '1');+ const overlay = this._overlay;+ if (!overlay) return;+ overlay.classList.remove('po-show');+ setTimeout(() => overlay.remove(), 250);+ this._overlay = null;+ if (this._keyFn) { document.removeEventListener('keydown', this._keyFn); this._keyFn = null; }+ }++ // ── Controls grid (used in overlay slide + help panel) ─────────────────────++ _buildControlsGrid(touch) {+ const list = touch ? TOUCH_CONTROLS : DESK_CONTROLS;+ const grid = mk('div', { className: 'po-ctrl-grid' });+ for (const { key, desc } of list) {+ const row = mk('div', { className: 'po-ctrl-row' });+ row.appendChild(mk('kbd', { className: 'po-kbd', textContent: key }));+ row.appendChild(mk('span', { className: 'po-ctrl-desc', textContent: desc }));+ grid.appendChild(row);+ }+ return grid;+ }++ // ── Economy + controls strip (always-visible in-world) ─────────────────────++ _buildStrip() {+ const { coin } = this;+ const home = isHomeTown(coin.mint);+ const sym = coin.symbol ? '$' + coin.symbol.toUpperCase() : '';++ const econText = home+ ? 'AI agents trading on-chain · press E near them'+ : (sym+ ? sym + ' community · live trades drive this world'+ : 'Coin community · live trades drive this world');++ // Economy row: live dot + label+ const dot = mk('span', { className: 'po-live-dot', 'aria-hidden': 'true' });+ const label = mk('span', { className: 'po-econ-label', textContent: econText });+ const econRow = mk('div', { className: 'po-econ-row' }, dot, label);++ // Controls toggle button+ const ctrlBtn = mk('button', {+ className: 'po-ctrl-btn', type: 'button',+ 'aria-label': 'Show controls reference',+ textContent: 'Controls',+ onclick: () => this._toggleHelp(),+ });++ const strip = mk('div', { id: 'po-strip' }, econRow, ctrlBtn);+ document.body.appendChild(strip);+ this._strip = strip;+ }++ // ── Controls help panel ────────────────────────────────────────────────────++ _toggleHelp() {+ if (this._helpPanel) {+ this._helpPanel.classList.remove('po-show');+ const p = this._helpPanel;+ this._helpPanel = null;+ setTimeout(() => p.remove(), 200);+ return;+ }++ const closeBtn = mk('button', {+ className: 'po-help-close', type: 'button',+ 'aria-label': 'Close controls',+ textContent: '×',+ onclick: () => this._toggleHelp(),+ });+ const head = mk('div', { className: 'po-help-head' },+ mk('span', { className: 'po-help-title', textContent: 'CONTROLS' }),+ closeBtn,+ );++ const panel = mk('div', {+ id: 'po-help',+ role: 'dialog',+ 'aria-label': 'Controls reference',+ }, head, this._buildControlsGrid(isTouch()));++ document.body.appendChild(panel);+ this._helpPanel = panel;++ requestAnimationFrame(() => {+ panel.classList.add('po-show');+ closeBtn.focus();+ });+ }++ // ── Styles ─────────────────────────────────────────────────────────────────++ _injectStyles() {+ if (document.getElementById('po-styles')) return;+ const s = document.createElement('style');+ s.id = 'po-styles';+ /* Tokens mirror coincommunities.css --cc-* so this stands alone if /play+ ever loads without the main sheet. Values match the monochrome design lang. */+ s.textContent = `+/* ── PlayOnboard ─────────────────────────────────────────────────────────── */++/* First-join overlay */+#po-overlay {+ position: fixed; inset: 0; z-index: 45;+ display: flex; align-items: center; justify-content: center; padding: 20px;+ background: rgba(4,4,5,0.74); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);+ opacity: 0; transition: opacity 0.22s ease;+}+#po-overlay.po-show { opacity: 1; }++.po-card {+ position: relative;+ width: min(440px, calc(100vw - 32px));+ background: var(--cc-panel-solid, #0c0c0e);+ border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));+ border-radius: var(--cc-radius, 4px);+ box-shadow: var(--cc-shadow, 0 16px 50px rgba(0,0,0,0.7));+ padding: 22px 22px 20px;+ transform: translateY(10px) scale(0.99);+ transition: transform 0.22s cubic-bezier(0.2,0.7,0.2,1);+}+#po-overlay.po-show .po-card { transform: none; }++.po-close {+ position: absolute; top: 12px; right: 12px;+ width: 28px; height: 28px;+ border-radius: var(--cc-radius-sm, 2px);+ background: var(--cc-bg2, #101012);+ border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));+ color: var(--cc-dim, #8c8c92); font-size: 20px; line-height: 1; cursor: pointer;+ display: flex; align-items: center; justify-content: center;+ transition: color 0.12s ease, border-color 0.12s ease;+}+.po-close:hover { color: var(--cc-text, #f5f5f6); border-color: var(--cc-edge-hi, rgba(255,255,255,0.55)); }+.po-close:focus-visible { outline: none; border-color: #fff; box-shadow: 0 0 0 1px #fff; }++/* Progress dots */+.po-dots { display: flex; gap: 6px; margin-bottom: 16px; }+.po-dot {+ height: 3px; width: 18px; border-radius: 2px;+ background: var(--cc-edge-soft, rgba(255,255,255,0.07));+ transition: background 0.18s ease, width 0.18s ease;+}+.po-dot.po-dot-on { background: #fff; width: 26px; }++/* Slide text */+.po-tag {+ font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;+ color: var(--cc-faint, #5a5a60); margin: 0 0 6px;+}+.po-title {+ font-size: 19px; font-weight: 800; letter-spacing: 0.01em;+ color: var(--cc-text, #f5f5f6); margin: 0 0 14px;+}+.po-body {+ font-size: 13.5px; line-height: 1.65; color: var(--cc-dim, #8c8c92);+ margin: 0 0 20px; max-width: 44ch;+}++/* Controls grid (used in overlay + help panel) */+.po-ctrl-grid {+ display: grid; grid-template-columns: auto 1fr; gap: 6px 14px;+ margin-bottom: 20px;+ max-height: 230px; overflow-y: auto; padding-right: 2px;+}+.po-ctrl-grid::-webkit-scrollbar { width: 4px; }+.po-ctrl-grid::-webkit-scrollbar-thumb { background: var(--cc-edge, rgba(255,255,255,0.12)); }+.po-ctrl-row { display: contents; }+.po-kbd {+ display: inline-flex; align-items: center; justify-content: center;+ background: rgba(255,255,255,0.06);+ border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));+ border-radius: var(--cc-radius-sm, 2px); padding: 2px 7px;+ font-size: 11px; font-family: ui-monospace, "SF Mono", Menlo, monospace;+ color: var(--cc-text, #f5f5f6); white-space: nowrap; align-self: center;+}+.po-ctrl-desc {+ font-size: 12px; color: var(--cc-dim, #8c8c92); align-self: center;+}++/* Slide actions */+.po-actions {+ display: flex; align-items: center; justify-content: flex-end; gap: 9px;+ padding-top: 18px; border-top: 1px solid var(--cc-edge-soft, rgba(255,255,255,0.07));+}+.po-btn {+ padding: 9px 20px; border-radius: var(--cc-radius-sm, 2px);+ font: inherit; font-weight: 700; font-size: 13px; letter-spacing: 0.03em; cursor: pointer;+ transition: filter 0.12s ease, transform 0.1s ease, border-color 0.12s ease, color 0.12s ease;+}+.po-btn:active { transform: translateY(1px); }+.po-btn-primary {+ background: #fff; color: var(--cc-ink, #060607); border: 1px solid #fff;+ box-shadow: var(--cc-glow, 0 0 14px rgba(255,255,255,0.35));+}+.po-btn-primary:hover { filter: brightness(0.92); }+.po-btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--cc-bg, #060607), 0 0 0 4px #fff; }+.po-btn-ghost {+ background: none; border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));+ color: var(--cc-dim, #8c8c92);+}+.po-btn-ghost:hover { border-color: var(--cc-edge-hi, rgba(255,255,255,0.55)); color: var(--cc-text, #f5f5f6); }+.po-btn-ghost:focus-visible { outline: none; border-color: #fff; box-shadow: 0 0 0 1px #fff; }++/* ── In-world info strip (economy + controls toggle) ── */+#po-strip {+ position: fixed; left: 14px; top: 128px; z-index: 19;+ display: flex; flex-direction: column; gap: 6px;+ pointer-events: auto;+}+/* Hide on narrow screens — the onboarding overlay covers economy info there */+@media (max-width: 640px) { #po-strip { display: none; } }++.po-econ-row {+ display: inline-flex; align-items: center; gap: 7px;+ background: var(--cc-panel, rgba(12,12,14,0.78));+ border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));+ border-radius: var(--cc-radius, 4px); padding: 6px 11px;+ backdrop-filter: blur(10px);+ max-width: min(310px, 52vw);+}+.po-live-dot {+ width: 6px; height: 6px; border-radius: 50%; flex: none;+ background: var(--cc-live, #fff);+ box-shadow: var(--cc-glow, 0 0 14px rgba(255,255,255,0.35));+ animation: po-blink 1.8s ease-in-out infinite;+}+@keyframes po-blink { 50% { opacity: 0.3; } }+.po-econ-label {+ font-size: 11px; color: var(--cc-dim, #8c8c92); letter-spacing: 0.01em;+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis;+}++.po-ctrl-btn {+ display: inline-flex; align-items: center;+ background: var(--cc-panel, rgba(12,12,14,0.78));+ border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));+ border-radius: var(--cc-radius, 4px); padding: 5px 11px;+ backdrop-filter: blur(10px);+ color: var(--cc-dim, #8c8c92); font: inherit;+ font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;+ cursor: pointer;+ transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;+}+.po-ctrl-btn:hover { border-color: var(--cc-edge-hi, rgba(255,255,255,0.55)); color: var(--cc-text, #f5f5f6); }+.po-ctrl-btn:focus-visible { outline: none; border-color: #fff; box-shadow: 0 0 0 1px #fff; }++/* ── Controls reference panel ── */+#po-help {+ position: fixed; left: 14px; top: 202px; z-index: 46;+ width: min(268px, calc(100vw - 28px));+ background: var(--cc-panel-solid, #0c0c0e);+ border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));+ border-radius: var(--cc-radius, 4px);+ box-shadow: var(--cc-shadow, 0 16px 50px rgba(0,0,0,0.7));+ padding: 12px 14px;+ opacity: 0; transform: translateY(-4px); pointer-events: none;+ transition: opacity 0.18s ease, transform 0.18s ease;+}+#po-help.po-show { opacity: 1; transform: none; pointer-events: auto; }+/* On small screens anchor to bottom-left above the joystick */+@media (max-width: 640px) {+ #po-help { left: 14px; top: auto; bottom: 160px; }+}++.po-help-head {+ display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;+}+.po-help-title {+ font-size: 10px; font-weight: 700; letter-spacing: 0.14em; color: var(--cc-faint, #5a5a60);+}+.po-help-close {+ width: 22px; height: 22px; border-radius: var(--cc-radius-sm, 2px);+ background: var(--cc-bg2, #101012);+ border: 1px solid var(--cc-edge, rgba(255,255,255,0.12));+ color: var(--cc-dim, #8c8c92); font-size: 16px; line-height: 1; cursor: pointer;+ display: flex; align-items: center; justify-content: center;+ transition: color 0.12s ease, border-color 0.12s ease;+}+.po-help-close:hover { color: var(--cc-text, #f5f5f6); border-color: var(--cc-edge-hi, rgba(255,255,255,0.55)); }+.po-help-close:focus-visible { outline: none; border-color: #fff; box-shadow: 0 0 0 1px #fff; }++#po-help .po-ctrl-grid { margin-bottom: 0; max-height: 280px; }++/* Reduced-motion overrides */+@media (prefers-reduced-motion: reduce) {+ #po-overlay, .po-card, #po-help { transition: none; }+ .po-dot { transition: none; }+ .po-live-dot { animation: none; }+}+`;+ document.head.appendChild(s);+ }++ // ── Teardown ───────────────────────────────────────────────────────────────++ dispose() {+ this._disposed = true;+ clearTimeout(this._showTimer);+ if (this._keyFn) { document.removeEventListener('keydown', this._keyFn); this._keyFn = null; }+ if (this._overlay) { this._overlay.remove(); this._overlay = null; }+ if (this._helpPanel) { this._helpPanel.remove(); this._helpPanel = null; }+ if (this._strip) { this._strip.remove(); this._strip = null; }+ }+}diff --git a/src/game/voice-chat.js b/src/game/voice-chat.jsindex 3b9a5666f..ca8f71896 100644--- a/src/game/voice-chat.js+++ b/src/game/voice-chat.js@@ -26,6 +26,7 @@// Proximity thresholds, in metres. CONNECT a little outside the audible edge so// the handshake completes before someone is fully in earshot; DISCONNECT with// hysteresis so a peer pacing the boundary doesn't thrash connections.+import { log } from '../shared/log.js';const CONNECT_RANGE = 27;const DISCONNECT_RANGE = 33;@@ -183,7 +184,7 @@ export class VoiceChat {try { await peer.pc.addIceCandidate(data.ice); } catch { /* premature candidate */ }}} catch (err) {- console.warn('[voice] signal handling failed:', err?.message);+ log.warn('[voice] signal handling failed:', err?.message);}}@@ -265,7 +266,7 @@ export class VoiceChat {await pc.setLocalDescription(offer);this.sendSignal(id, { sdp: pc.localDescription });} catch (err) {- console.warn('[voice] offer failed:', err?.message);+ log.warn('[voice] offer failed:', err?.message);}};}