@energy8platform/shell 0.6.6 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/html.cjs.js +677 -109
  2. package/dist/html.cjs.js.map +1 -1
  3. package/dist/html.d.ts +207 -27
  4. package/dist/html.esm.js +670 -110
  5. package/dist/html.esm.js.map +1 -1
  6. package/dist/index.cjs.js +378 -22
  7. package/dist/index.cjs.js.map +1 -1
  8. package/dist/index.d.ts +199 -26
  9. package/dist/index.esm.js +371 -23
  10. package/dist/index.esm.js.map +1 -1
  11. package/dist/pixi.cjs.js +952 -282
  12. package/dist/pixi.cjs.js.map +1 -1
  13. package/dist/pixi.d.ts +202 -28
  14. package/dist/pixi.esm.js +945 -283
  15. package/dist/pixi.esm.js.map +1 -1
  16. package/package.json +1 -1
  17. package/src/core/ShellController.ts +68 -16
  18. package/src/core/format.ts +8 -4
  19. package/src/core/icon-names.ts +30 -0
  20. package/src/core/index.ts +4 -0
  21. package/src/core/menu.ts +301 -0
  22. package/src/core/popover.ts +81 -0
  23. package/src/core/renderer.ts +13 -10
  24. package/src/core/state.ts +2 -1
  25. package/src/core/types.ts +15 -6
  26. package/src/core/version.ts +1 -1
  27. package/src/ui/html/HtmlRenderer.ts +31 -8
  28. package/src/ui/html/components/GameInfo.ts +1 -1
  29. package/src/ui/html/components/Menu.ts +153 -0
  30. package/src/ui/html/icons.ts +16 -15
  31. package/src/ui/html/primitives.ts +142 -0
  32. package/src/ui/html/shell.css.ts +21 -1
  33. package/src/ui/pixi/PixiRenderer.ts +32 -14
  34. package/src/ui/pixi/components/BottomBar.ts +80 -9
  35. package/src/ui/pixi/components/GameInfo.ts +1 -1
  36. package/src/ui/pixi/components/Menu.ts +167 -0
  37. package/src/ui/pixi/context.ts +3 -2
  38. package/src/ui/pixi/icons.ts +16 -15
  39. package/src/ui/pixi/pixi-icon.ts +15 -3
  40. package/src/ui/pixi/primitives/controls.ts +46 -0
  41. package/src/ui/pixi/primitives/popover.ts +163 -0
  42. package/src/ui/pixi/primitives/scroll.ts +9 -5
  43. package/src/ui/html/components/Settings.ts +0 -68
  44. package/src/ui/pixi/components/Settings.ts +0 -132
package/dist/html.esm.js CHANGED
@@ -50,6 +50,240 @@ class EventEmitter {
50
50
  }
51
51
  }
52
52
 
53
+ // AUTO-GENERATED from ../../icons.svg by scripts/gen-icons-from-svg.mjs — do not edit by hand.
54
+ // Sharp monochrome icon set: each glyph is a 24×24 viewBox fragment using currentColor
55
+ // (hollow shapes use fill-rule="evenodd"). Coordinates are baked into the 24×24 space (no
56
+ // <g transform>), so the same fragment renders identically in the DOM <svg> and in Pixi's
57
+ // GraphicsContext.svg. To change an icon: edit icons.svg, then run
58
+ // `node scripts/gen-icons-from-svg.mjs`.
59
+ // The single glyph-name union, shared by core (menu items) and both renderers.
60
+ const ICON_NAMES = [
61
+ 'spin',
62
+ 'turbo1',
63
+ 'autoplay',
64
+ 'stop',
65
+ 'menu',
66
+ 'minus',
67
+ 'plus',
68
+ 'gift',
69
+ 'info',
70
+ 'soundOn',
71
+ 'soundOff',
72
+ 'close',
73
+ 'back',
74
+ 'chevronRight',
75
+ 'ticket',
76
+ 'turbo2',
77
+ 'turboOff',
78
+ 'chevronUp',
79
+ 'chevronDown',
80
+ ];
81
+
82
+ const PRESET_IDS = ['sound', 'music', 'sfx', 'gameInfo'];
83
+ function isPresetId(id) {
84
+ return PRESET_IDS.includes(id);
85
+ }
86
+ /** The rows shown when `ShellConfig.menu` is omitted — today's Settings content, minus master. */
87
+ const DEFAULT_MENU = [
88
+ { id: 'sound' },
89
+ { id: 'music' },
90
+ { id: 'sfx' },
91
+ { type: 'separator' },
92
+ { id: 'gameInfo' },
93
+ ];
94
+ const isSeparator = (i) => i.type === 'separator';
95
+ /** Range bounds with defaults: 0..1 like a volume slider, step = a twentieth of the span. */
96
+ function rangeBounds(item) {
97
+ const min = item.min ?? 0;
98
+ const max = item.max ?? 1;
99
+ const derivedStep = (max - min) / 20;
100
+ // A declared `step` must be a genuinely positive number. `??` alone doesn't catch this: an
101
+ // explicit 0 (or a negative value) is not null/undefined, so it would sail through unchanged —
102
+ // and a renderer's position math divides by it (Pixi's fromUnit: `(raw-min)/step`), turning the
103
+ // slider's value into NaN, which then reaches `state.menu` and the `settingChange` payload.
104
+ const step = item.step != null && item.step > 0 ? item.step : derivedStep;
105
+ return { min, max, step };
106
+ }
107
+ /** Initial values for CUSTOM items (presets keep their own homes). Values already in `prev` win, so
108
+ * a later `setMenu()` with the same ids does not reset what the player has changed. */
109
+ function seedMenuValues(items, prev = {}) {
110
+ const out = {};
111
+ for (const item of items) {
112
+ if (isSeparator(item))
113
+ continue;
114
+ const type = item.type;
115
+ if (!type || isPresetId(item.id))
116
+ continue;
117
+ // A previous value only carries over when its runtime type still matches this item's kind.
118
+ // Without this guard, reconfiguring the same id from a toggle to a range (or back) would seed
119
+ // a boolean into a slider's position math (or a stale number into a checkbox) — a legitimate
120
+ // reconfiguration, not a config error, so it falls through to the item's own default instead
121
+ // of warning.
122
+ const prevValue = prev[item.id];
123
+ if (type === 'toggle') {
124
+ out[item.id] = typeof prevValue === 'boolean' ? prevValue : (item.value ?? false);
125
+ }
126
+ else if (type === 'range') {
127
+ const r = item;
128
+ out[item.id] = typeof prevValue === 'number' ? prevValue : (r.value ?? rangeBounds(r).min);
129
+ }
130
+ }
131
+ return out;
132
+ }
133
+ const percent = (v) => `${Math.round(v * 100)}%`;
134
+ function safeIcon(name) {
135
+ return name && ICON_NAMES.includes(name) ? name : undefined;
136
+ }
137
+ /** Every drop/collision warning goes through here so the message style stays uniform. */
138
+ function warn(message) {
139
+ console.warn(`[shell] ${message}`);
140
+ }
141
+ /** Expand the configured list into render-ready rows. A config mistake — an unknown preset id, an
142
+ * unrecognized custom `type`, or an invalid range span — is dropped with one warning rather than
143
+ * silently misbehaving: a typo must be visible, not silently invisible. A custom id that collides
144
+ * with a reserved preset id also warns, but keeps its row (see `custom()`). */
145
+ function resolveMenu(host) {
146
+ const rows = [];
147
+ for (const item of host.menu) {
148
+ if (isSeparator(item)) {
149
+ rows.push({ kind: 'separator' });
150
+ continue;
151
+ }
152
+ const type = item.type;
153
+ if (!type) {
154
+ const row = preset(host, item);
155
+ if (row)
156
+ rows.push(row);
157
+ else
158
+ warn(`unknown menu preset id "${item.id}" — item skipped`);
159
+ continue;
160
+ }
161
+ const row = custom(host, item, type);
162
+ if (row)
163
+ rows.push(row);
164
+ }
165
+ return rows;
166
+ }
167
+ function preset(host, item) {
168
+ const disabled = item.disabled ?? false;
169
+ const label = host.t(item.label ?? DEFAULT_LABELS[item.id] ?? item.id);
170
+ switch (item.id) {
171
+ case 'sound':
172
+ return {
173
+ kind: 'toggle',
174
+ id: 'sound',
175
+ label,
176
+ disabled,
177
+ icon: (v) => safeIcon(item.icon) ?? (v ? 'soundOn' : 'soundOff'),
178
+ get: () => host.getMenuValue('sound') !== false,
179
+ set: (v) => host.setMenuValue('sound', v),
180
+ };
181
+ case 'music':
182
+ case 'sfx': {
183
+ const id = item.id;
184
+ return {
185
+ kind: 'range',
186
+ id,
187
+ label,
188
+ icon: safeIcon(item.icon),
189
+ disabled,
190
+ min: 0,
191
+ max: 1,
192
+ step: 0.05,
193
+ get: () => Number(host.getMenuValue(id) ?? 1),
194
+ set: (v) => host.setMenuValue(id, v),
195
+ format: percent,
196
+ };
197
+ }
198
+ case 'gameInfo':
199
+ return {
200
+ kind: 'button',
201
+ id: 'gameInfo',
202
+ label,
203
+ icon: safeIcon(item.icon) ?? 'info',
204
+ disabled,
205
+ chevron: true,
206
+ select: () => host.actions.openInfo(),
207
+ };
208
+ default:
209
+ return null;
210
+ }
211
+ }
212
+ const DEFAULT_LABELS = {
213
+ sound: 'Sound',
214
+ music: 'Music',
215
+ sfx: 'SFX',
216
+ gameInfo: 'Game info',
217
+ };
218
+ function custom(host, item, type) {
219
+ // Same store, different semantics: the real preset's get() and a custom row's get() disagree
220
+ // (see the preset cases below vs. the toggle case here). Routing does not change — Task 4's
221
+ // ShellHost is what actually owns the value — this warning just makes the clash visible.
222
+ if (isPresetId(item.id)) {
223
+ warn(`menu item id "${item.id}" collides with a built-in preset id — preset ids are reserved`);
224
+ }
225
+ const disabled = item.disabled ?? false;
226
+ const label = host.t(item.label ?? item.id);
227
+ const icon = safeIcon(item.icon);
228
+ if (type === 'toggle') {
229
+ const it = item;
230
+ return {
231
+ kind: 'toggle',
232
+ id: it.id,
233
+ label,
234
+ disabled,
235
+ icon: () => icon,
236
+ get: () => host.getMenuValue(it.id) === true,
237
+ set: (v) => {
238
+ host.setMenuValue(it.id, v);
239
+ it.onChange?.(v);
240
+ },
241
+ };
242
+ }
243
+ if (type === 'range') {
244
+ const it = item;
245
+ const { min, max, step } = rangeBounds(it);
246
+ if (max <= min) {
247
+ // A renderer's position math ((value - min) / (max - min)) turns this into Infinity/NaN —
248
+ // drop the row instead, exactly like an unknown preset id.
249
+ warn(`menu item "${it.id}" has invalid range bounds (min ${min}, max ${max}) — item skipped`);
250
+ return null;
251
+ }
252
+ return {
253
+ kind: 'range',
254
+ id: it.id,
255
+ label,
256
+ icon,
257
+ disabled,
258
+ min,
259
+ max,
260
+ step,
261
+ get: () => Number(host.getMenuValue(it.id) ?? min),
262
+ set: (v) => {
263
+ host.setMenuValue(it.id, v);
264
+ it.onChange?.(v);
265
+ },
266
+ format: it.format ?? (min === 0 && max === 1 ? percent : (v) => String(v)),
267
+ };
268
+ }
269
+ if (type === 'button') {
270
+ const it = item;
271
+ return {
272
+ kind: 'button',
273
+ id: it.id,
274
+ label,
275
+ icon,
276
+ disabled,
277
+ chevron: it.chevron ?? false,
278
+ select: () => it.onSelect?.(),
279
+ };
280
+ }
281
+ // Neither toggle, range, nor button — a typo'd `type` used to fall through to an unconditional
282
+ // button row with no onSelect. Drop it visibly instead.
283
+ warn(`menu item "${item.id}" has unknown type "${type}" — item skipped`);
284
+ return null;
285
+ }
286
+
53
287
  function createInitialState(config) {
54
288
  return {
55
289
  mode: config.mode,
@@ -66,10 +300,10 @@ function createInitialState(config) {
66
300
  bonus: null,
67
301
  activeFeature: null,
68
302
  volumes: {
69
- master: clampVolume(config.volumes?.master),
70
303
  music: clampVolume(config.volumes?.music),
71
304
  sfx: clampVolume(config.volumes?.sfx),
72
305
  },
306
+ menu: seedMenuValues(config.menu ?? DEFAULT_MENU),
73
307
  };
74
308
  }
75
309
  /** Clamp a configured volume to 0..1, defaulting to full (1) when unset/invalid. */
@@ -167,15 +401,19 @@ function resolveTheme(theme = {}) {
167
401
  * trailing zeros are trimmed down to (but never past) `minDecimals`, so small wins keep their
168
402
  * significant digits. Balance / bet / prices stay fixed at `minDecimals`.
169
403
  *
404
+ * Separators default to the platform convention — `.` decimal, `,` thousands (`€1,234.50`).
405
+ * A comma decimal is NOT safe as a default: players read "2,50" as 250 and believe they were
406
+ * paid far more than they were. Games that need another convention pass `currency.separator`.
407
+ *
170
408
  * Example with `maxDecimals: 4, minDecimals: 2`:
171
- * fixed → 0.0673 → 0,07 0.3 → 0,30
172
- * variable → 0.0673 → 0,0673 0.067 → 0,067 0.3 → 0,30 0 → 0,00
409
+ * fixed → 0.0673 → 0.07 0.3 → 0.30
410
+ * variable → 0.0673 → 0.0673 0.067 → 0.067 0.3 → 0.30 0 → 0.00
173
411
  */
174
412
  function formatCurrency(value, currency, variableDecimals = false) {
175
413
  const maxDecimals = currency.maxDecimals ?? 2;
176
414
  const minDecimals = Math.max(0, Math.min(maxDecimals, currency.minDecimals ?? maxDecimals));
177
- const thousands = currency.separator?.thousands ?? '.';
178
- const decimal = currency.separator?.decimal ?? ',';
415
+ const thousands = currency.separator?.thousands ?? ',';
416
+ const decimal = currency.separator?.decimal ?? '.';
179
417
  const safe = Number.isFinite(value) ? value : 0;
180
418
  // fixed callers round at minDecimals; variable callers round at maxDecimals then trim back down.
181
419
  const places = variableDecimals ? maxDecimals : minDecimals;
@@ -1453,7 +1691,7 @@ class KeyboardController {
1453
1691
 
1454
1692
  // AUTO-GENERATED by scripts/gen-version.mjs — do not edit. Mirrors package.json "version".
1455
1693
  /** The @energy8platform/shell package version, stamped into the game-info footer. */
1456
- const PACKAGE_VERSION = '0.6.6';
1694
+ const PACKAGE_VERSION = '0.7.1';
1457
1695
 
1458
1696
  /** Apply defaults to the raw config (the mount target lives on the renderer, not here). */
1459
1697
  function resolveConfig(config) {
@@ -1471,6 +1709,7 @@ function resolveConfig(config) {
1471
1709
  theme: config.theme,
1472
1710
  onBonusBuy: config.onBonusBuy,
1473
1711
  volumes: config.volumes,
1712
+ menu: config.menu,
1474
1713
  version: config.version ?? '1.0.0',
1475
1714
  isSocial: config.isSocial ?? false,
1476
1715
  replay: config.replay ?? config.mode === 'replay',
@@ -1491,8 +1730,9 @@ class ShellController extends EventEmitter {
1491
1730
  i18n;
1492
1731
  kbd;
1493
1732
  overlay = null;
1494
- soundRefresh = null;
1495
- volumeRefresh = null;
1733
+ menuItems;
1734
+ menuRefresh = null;
1735
+ overlayKind = null;
1496
1736
  prevBalance;
1497
1737
  prevWin;
1498
1738
  destroyed = false;
@@ -1503,6 +1743,7 @@ class ShellController extends EventEmitter {
1503
1743
  this.config = resolveConfig(config);
1504
1744
  this.i18n = createI18n({ language: this.config.language, isSocial: this.config.isSocial });
1505
1745
  this.state = createInitialState(this.config);
1746
+ this.menuItems = this.config.menu ?? DEFAULT_MENU;
1506
1747
  this.tokens = resolveTheme(this.config.theme);
1507
1748
  this.prevBalance = this.state.balance;
1508
1749
  this.prevWin = this.state.win;
@@ -1636,14 +1877,21 @@ class ShellController extends EventEmitter {
1636
1877
  show(req) {
1637
1878
  this.closeModal();
1638
1879
  this.overlay = this.renderer.openOverlay(req) ?? null;
1880
+ this.overlayKind = this.overlay ? req.kind : null;
1639
1881
  }
1882
+ /** Open the bar menu. Called again while it is open, it closes it — the burger toggles. */
1640
1883
  openMenu() {
1884
+ if (this.overlayKind === 'menu') {
1885
+ this.closeModal();
1886
+ return;
1887
+ }
1641
1888
  this.emit('menuOpen');
1642
- this.openSettings();
1889
+ this.show({ kind: 'menu' });
1643
1890
  }
1891
+ /** @deprecated The Settings overlay is gone — this opens the bar menu. */
1644
1892
  openSettings() {
1645
1893
  this.emit('settingsOpen');
1646
- this.show({ kind: 'settings' });
1894
+ this.openMenu();
1647
1895
  }
1648
1896
  openInfo() {
1649
1897
  this.emit('infoOpen');
@@ -1675,35 +1923,72 @@ class ShellController extends EventEmitter {
1675
1923
  if (!this.overlay)
1676
1924
  return;
1677
1925
  this.overlay = null;
1678
- this.soundRefresh = null;
1679
- this.volumeRefresh = null;
1926
+ this.overlayKind = null;
1927
+ this.menuRefresh = null;
1680
1928
  this.renderer.closeOverlay();
1681
1929
  }
1682
1930
  // ── sound ──────────────────────────────────────────────────────────────────
1683
1931
  setSound(on) {
1684
1932
  this.soundOn = on;
1685
1933
  this.emit('settingChange', { key: 'sound', value: on });
1686
- this.soundRefresh?.(on);
1687
- this.renderer.refreshSoundIcon?.(on);
1688
- }
1689
- setSoundRefresh(fn) {
1690
- this.soundRefresh = fn;
1934
+ this.menuRefresh?.('sound', on);
1691
1935
  }
1692
1936
  // ── volume ─────────────────────────────────────────────────────────────────
1693
1937
  getVolume(key) {
1694
1938
  return this.state.volumes[key];
1695
1939
  }
1696
1940
  /** Set a volume slider (0..1). Shared by the slider control (drag) and game code (public API):
1697
- * clamps, stores so a reopened Settings overlay reflects it, emits `settingChange`, and
1698
- * live-updates the slider if the overlay is currently open. */
1941
+ * clamps, stores so a reopened menu popover reflects it, emits `settingChange`, and
1942
+ * live-updates the slider if the menu is currently open. */
1699
1943
  setVolume(key, value) {
1700
1944
  const v = Math.max(0, Math.min(1, value));
1701
1945
  this.state.volumes[key] = v;
1702
1946
  this.emit('settingChange', { key, value: v });
1703
- this.volumeRefresh?.(key, v);
1947
+ this.menuRefresh?.(key, v);
1948
+ }
1949
+ // ── menu ───────────────────────────────────────────────────────────────────
1950
+ get menu() {
1951
+ return this.menuItems;
1952
+ }
1953
+ /** Replace the item list. Values of ids already in state are kept; new ids are seeded. */
1954
+ setMenu(items) {
1955
+ this.menuItems = items;
1956
+ this.state.menu = seedMenuValues(items, this.state.menu);
1957
+ if (this.overlayKind === 'menu')
1958
+ this.show({ kind: 'menu' });
1704
1959
  }
1705
- setVolumeRefresh(fn) {
1706
- this.volumeRefresh = fn;
1960
+ getMenuValue(id) {
1961
+ if (id === 'sound')
1962
+ return this.soundOn;
1963
+ if (id === 'music' || id === 'sfx')
1964
+ return this.state.volumes[id];
1965
+ return this.state.menu[id];
1966
+ }
1967
+ /** Set a menu value. Presets route to their own homes so there is never a second copy. */
1968
+ setMenuValue(id, value) {
1969
+ if (id === 'sound') {
1970
+ this.setSound(value !== false);
1971
+ return;
1972
+ }
1973
+ if (id === 'music' || id === 'sfx') {
1974
+ this.setVolume(id, Number(value));
1975
+ return;
1976
+ }
1977
+ const next = typeof value === 'number' ? this.clampRange(id, value) : value;
1978
+ this.state.menu[id] = next;
1979
+ this.emit('settingChange', { key: id, value: next });
1980
+ this.menuRefresh?.(id, next);
1981
+ }
1982
+ setMenuRefresh(fn) {
1983
+ this.menuRefresh = fn;
1984
+ }
1985
+ /** Clamp to the declared bounds of a custom `range` item (a non-range id passes through). */
1986
+ clampRange(id, value) {
1987
+ const item = this.menuItems.find((i) => i.id === id);
1988
+ if (!item || item.type !== 'range')
1989
+ return value;
1990
+ const { min, max } = rangeBounds(item);
1991
+ return Math.max(min, Math.min(max, value));
1707
1992
  }
1708
1993
  // ── features ─────────────────────────────────────────────────────────────────
1709
1994
  activateFeature(bonus) {
@@ -1813,6 +2098,11 @@ class ShellController extends EventEmitter {
1813
2098
  if (this.destroyed)
1814
2099
  return Promise.resolve();
1815
2100
  this.destroyed = true;
2101
+ // With the menu (or any overlay) open at teardown, `menuRefresh` / `overlay` / `overlayKind`
2102
+ // would otherwise survive the renderer's destroy — so a later setVolume()/setSound() call
2103
+ // invokes a stale row updater against already-destroyed Pixi Graphics (or a detached DOM node)
2104
+ // and throws. Run BEFORE the renderer teardown below, while it can still close cleanly.
2105
+ this.closeModal();
1816
2106
  if (typeof document !== 'undefined') {
1817
2107
  this.kbd?.detach();
1818
2108
  document.removeEventListener('pointerdown', this.pullFocus, true);
@@ -1822,6 +2112,64 @@ class ShellController extends EventEmitter {
1822
2112
  }
1823
2113
  }
1824
2114
 
2115
+ /** Geometry for the bar-menu popover. Pure math over rectangles so the DOM and Pixi renderers
2116
+ * place it identically — the renderers only supply measured sizes and apply the result. */
2117
+ const POPOVER = {
2118
+ /** Keep-out from the surface edges. */
2119
+ margin: 8,
2120
+ /** Space between the anchor and the card. */
2121
+ gap: 8,
2122
+ /** Minimum distance from the arrow tip to either rounded corner. */
2123
+ arrowInset: 14,
2124
+ /** A card shorter than this does not fit — flip to the other side instead. */
2125
+ minH: 120,
2126
+ minW: 220,
2127
+ maxW: 320,
2128
+ };
2129
+ const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
2130
+ /** Card width: content width clamped to [minW, maxW] and never wider than the surface. */
2131
+ function popoverWidth(surfaceW, contentW) {
2132
+ const hi = Math.min(POPOVER.maxW, surfaceW - POPOVER.margin * 2);
2133
+ return Math.max(0, clamp(contentW, Math.min(POPOVER.minW, hi), hi));
2134
+ }
2135
+ /** Place the card above the `anchor` (below if it does not fit), left-aligned to it and clamped
2136
+ * inside the surface. `anchor === null` (no bar / hidden shell) centres it, arrow off.
2137
+ *
2138
+ * `anchor` drives PLACEMENT (x, y, maxH, below) — normally the bar's whole plaque ("plate"), so the
2139
+ * card sits flush with the bar as a whole rather than with whichever control opened it. `pointer` is
2140
+ * the (optional) rect the ARROW points at — normally the burger button, which can sit anywhere
2141
+ * inside the plate. Defaults to `anchor` when omitted, so every caller that only ever had one rect
2142
+ * (i.e. every caller before `pointer` existed) keeps behaving exactly as it did before. */
2143
+ function placePopover(anchor, surface, size, pointer = null) {
2144
+ const { margin, gap, arrowInset, minH } = POPOVER;
2145
+ if (!anchor) {
2146
+ const maxH = Math.max(0, surface.h - margin * 2);
2147
+ const h = Math.min(size.h, maxH);
2148
+ const rawY = (surface.h - h) / 2;
2149
+ const y = clamp(rawY, margin, Math.max(margin, surface.h - h - margin));
2150
+ return {
2151
+ x: Math.max(margin, (surface.w - size.w) / 2),
2152
+ y,
2153
+ maxH,
2154
+ arrowX: -1,
2155
+ below: false,
2156
+ };
2157
+ }
2158
+ const spaceAbove = anchor.y - gap - margin;
2159
+ const spaceBelow = surface.h - (anchor.y + anchor.h) - gap - margin;
2160
+ // Prefer above; flip only when the card would be squeezed below its usable minimum AND there is
2161
+ // genuinely more room on the other side.
2162
+ const below = spaceAbove < Math.min(size.h, minH) && spaceBelow > spaceAbove;
2163
+ const maxH = Math.max(0, below ? spaceBelow : spaceAbove);
2164
+ const h = Math.min(size.h, maxH);
2165
+ const x = clamp(anchor.x, margin, Math.max(margin, surface.w - size.w - margin));
2166
+ const rawY = below ? anchor.y + anchor.h + gap : anchor.y - gap - h;
2167
+ const y = clamp(rawY, margin, Math.max(margin, surface.h - h - margin));
2168
+ const arrowAnchor = pointer ?? anchor;
2169
+ const arrowX = clamp(arrowAnchor.x + arrowAnchor.w / 2 - x, arrowInset, Math.max(arrowInset, size.w - arrowInset));
2170
+ return { x, y, maxH, arrowX, below };
2171
+ }
2172
+
1825
2173
  const NO_INSET = { top: 0, right: 0, bottom: 0, left: 0 };
1826
2174
  /** Create a shell with an explicit renderer instance (custom or a built-in HtmlRenderer/PixiRenderer).
1827
2175
  * Built-in renderers also have the createGameShell/createPixiShell sugar in /html and /pixi.
@@ -2029,7 +2377,10 @@ const SHELL_CSS = SHELL_FONT_CSS + SHELL_DIGIT_FONT_CSS + `
2029
2377
  border-radius:16px; background:var(--shell-plaque-glass); color:#fff; font-size:14px; font-weight:600; }
2030
2378
  #${SHELL_ROOT_ID} .ge-ov-row .ge-grow { flex:1; text-align:left; }
2031
2379
  #${SHELL_ROOT_ID} button.ge-ov-row { cursor:pointer; font-family:inherit; transition:background .12s ease, color .12s ease; }
2032
- #${SHELL_ROOT_ID} button.ge-ov-row:hover { background:var(--shell-plaque-glass-hover); color:var(--shell-accent); }
2380
+ #${SHELL_ROOT_ID} button.ge-ov-row:hover:not([disabled]) { background:var(--shell-plaque-glass-hover); color:var(--shell-accent); }
2381
+ /* disabled rows — mirrors Pixi's box.alpha = 0.5 for all three row kinds. A <button> row carries
2382
+ the native attribute directly; a toggle/range row is a <div> wrapper, so it gets .ge-disabled. */
2383
+ #${SHELL_ROOT_ID} .ge-ov-row[disabled], #${SHELL_ROOT_ID} .ge-ov-row.ge-disabled { opacity:.5; cursor:default; }
2033
2384
  #${SHELL_ROOT_ID} .ge-ov-row.ge-col { flex-direction:column; align-items:stretch; gap:10px; }
2034
2385
  #${SHELL_ROOT_ID} .ge-ov-row .ge-row-head { display:flex; justify-content:space-between; align-items:center; }
2035
2386
  #${SHELL_ROOT_ID} .ge-ov-row .ge-row-head .ge-val { color:var(--shell-plaque-label); font-variant-numeric:tabular-nums; font-weight:700; }
@@ -2040,6 +2391,7 @@ const SHELL_CSS = SHELL_FONT_CSS + SHELL_DIGIT_FONT_CSS + `
2040
2391
  #${SHELL_ROOT_ID} .ge-toggle i { position:absolute; top:2px; left:2px; width:20px; height:20px; border-radius:50%;
2041
2392
  background:#fff; transition:left .12s ease; }
2042
2393
  #${SHELL_ROOT_ID} .ge-toggle.ge-on i { left:20px; }
2394
+ #${SHELL_ROOT_ID} .ge-toggle:disabled { cursor:default; }
2043
2395
  /* sound on/off — speaker icon button (replaces the toggle) */
2044
2396
  #${SHELL_ROOT_ID} .ge-snd { pointer-events:auto; cursor:pointer; border:none; background:none; padding:0;
2045
2397
  width:36px; height:36px; display:flex; align-items:center; justify-content:center; font-size:24px;
@@ -2048,6 +2400,22 @@ const SHELL_CSS = SHELL_FONT_CSS + SHELL_DIGIT_FONT_CSS + `
2048
2400
  #${SHELL_ROOT_ID} .ge-snd:hover { color:var(--shell-accent); }
2049
2401
  #${SHELL_ROOT_ID} .ge-snd:active { transform:scale(.92); }
2050
2402
 
2403
+ /* bar menu popover — light dismiss (no dim, no blur), card anchored to the burger */
2404
+ #${SHELL_ROOT_ID} .ge-pop-layer { position:absolute; inset:0; z-index:55; pointer-events:auto; }
2405
+ #${SHELL_ROOT_ID} .ge-pop { position:absolute; box-sizing:border-box; display:flex; flex-direction:column;
2406
+ padding:8px; border-radius:18px; background:var(--shell-plaque-dark);
2407
+ box-shadow:0 14px 38px rgba(0,0,0,.5); backdrop-filter:blur(12px) saturate(120%);
2408
+ -webkit-backdrop-filter:blur(12px) saturate(120%); animation:ge-ov-in .12s ease-out; }
2409
+ #${SHELL_ROOT_ID} .ge-pop-body { overflow-y:auto; overflow-x:hidden; min-height:0; }
2410
+ #${SHELL_ROOT_ID} .ge-pop .ge-ov-row { padding:10px 12px; margin-bottom:6px; font-size:13px; }
2411
+ #${SHELL_ROOT_ID} .ge-pop .ge-ov-row:last-child { margin-bottom:0; }
2412
+ #${SHELL_ROOT_ID} .ge-pop-sep { height:1px; margin:6px 4px; background:var(--shell-plaque-line); opacity:.5; }
2413
+ #${SHELL_ROOT_ID} .ge-pop-arrow { position:absolute; bottom:-7px; width:14px; height:14px; margin-left:-7px;
2414
+ background:var(--shell-plaque-dark); transform:rotate(45deg); border-radius:3px; }
2415
+ #${SHELL_ROOT_ID} .ge-pop.ge-pop-below .ge-pop-arrow { bottom:auto; top:-7px; }
2416
+ #${SHELL_ROOT_ID} .ge-pop .ge-mi-icon { flex:0 0 auto; width:20px; font-size:20px; display:flex; }
2417
+ #${SHELL_ROOT_ID} .ge-pop .ge-mi-chev { flex:0 0 auto; width:16px; font-size:16px; color:var(--shell-muted); display:flex; }
2418
+
2051
2419
  /* game info — each section is its own glass plaque; body text sized for comfortable reading */
2052
2420
  #${SHELL_ROOT_ID} .ge-gi-sec { margin-bottom:12px; background:var(--shell-plaque-glass);
2053
2421
  border-radius:16px; padding:16px 18px; }
@@ -2478,25 +2846,25 @@ function countUp(el, from, to, fmt, durationMs = 450) {
2478
2846
  // GraphicsContext.svg. To change an icon: edit icons.svg, then run
2479
2847
  // `node scripts/gen-icons-from-svg.mjs`.
2480
2848
  const SVGS = {
2481
- spin: `<g fill="currentColor" fill-rule="evenodd"><path d="M13.57 8.41C13.3 8.31 13.51 7.09 13.59 6.65C13.61 6.56 13.55 6.48 13.46 6.48C12.32 6.45 5.74 6.61 4.16 14.85C4.15 14.9 4 15.16 3.8 14.91C3.27 14.23 2.43 12.08 3.46 9.16C6.01 1.92 13 3.07 13.79 3.23C13.83 3.23 13.86 3.2 13.86 3.17C13.85 2.86 13.82 1.68 14.17 1.64C14.51 1.6 19.04 5.61 18.96 5.95C18.86 6.36 13.83 8.51 13.57 8.41Z"/><path d="M10.43 15.59C10.7 15.69 10.49 16.91 10.41 17.35C10.39 17.44 10.45 17.52 10.54 17.52C11.68 17.55 18.26 17.39 19.84 9.15C19.85 9.1 20 8.84 20.2 9.09C20.73 9.77 21.57 11.92 20.54 14.85C17.99 22.08 11 20.93 10.21 20.77C10.17 20.77 10.13 20.8 10.14 20.83C10.15 21.14 10.18 22.32 9.83 22.36C9.49 22.4 4.96 18.39 5.04 18.05C5.14 17.64 10.17 15.49 10.43 15.59Z"/></g>`,
2482
- turbo1: `<g fill="currentColor" fill-rule="evenodd"><path d="M17.81 2.62L14.41 8.21C14.15 8.64 14.46 9.2 14.97 9.2L18.84 9.21C19.42 9.21 19.72 9.9 19.32 10.31L8.02 22.19C7.89 22.33 7.72 22.4 7.53 22.4L7.53 22.4C7.08 22.39 6.77 21.93 6.93 21.5L9.91 13.91C10.08 13.48 9.76 13.01 9.29 13.01L5.11 13.06C4.61 13.06 4.28 12.53 4.53 12.09L10.07 1.94C10.19 1.73 10.41 1.6 10.65 1.6L17.26 1.62C17.77 1.62 18.08 2.18 17.81 2.62Z"/></g>`,
2483
- autoplay: `<g fill="currentColor" fill-rule="evenodd"><path d="M19.97 12.41C20.22 11.94 20.95 11.88 20.97 12.47C21.14 16.4 18.71 19.92 14.44 20.97C8.59 22.4 5.29 18.55 5.28 18.52C5.2 18.33 4.41 19.77 4.19 19.59C3.81 19.28 3.78 14.9 3.9 14.78C4.01 14.67 8.39 14.95 8.48 15.31C8.58 15.64 7.2 16.1 7.4 16.38C9.14 18.67 15.82 20.29 19.97 12.41Z"/><path d="M9.3 15.36L9.3 8.67C9.3 8.32 9.97 7.74 10.58 8.14C15.83 11.56 16 11.46 16.01 12.04C16.02 12.61 15.12 12.98 10.63 15.91C10.32 16.11 9.29 15.72 9.29 15.36Z"/><path d="M4.03 11.59C3.78 12.06 3.05 12.12 3.03 11.53C2.86 7.6 5.29 4.08 9.56 3.03C15.41 1.6 18.71 5.45 18.72 5.48C18.8 5.67 19.59 4.23 19.81 4.41C20.19 4.72 20.22 9.1 20.1 9.22C19.99 9.33 15.61 9.05 15.52 8.69C15.42 8.36 16.8 7.9 16.6 7.62C14.86 5.33 8.18 3.71 4.03 11.59Z"/></g>`,
2849
+ spin: `<g fill="currentColor" fill-rule="evenodd"><path d="M13.57 8.41C13.3 8.31 13.51 7.09 13.59 6.65C13.61 6.56 13.55 6.48 13.46 6.48C12.32 6.45 5.74 6.61 4.16 14.85C4.15 14.9 4 15.16 3.8 14.91C3.27 14.23 2.43 12.08 3.46 9.16C6.01 1.92 13 3.07 13.79 3.23C13.83 3.23 13.86 3.2 13.86 3.17C13.85 2.86 13.82 1.68 14.17 1.64C14.51 1.6 19.04 5.61 18.96 5.95C18.86 6.36 13.83 8.51 13.57 8.41L13.57 8.41Z"/><path d="M10.43 15.59C10.7 15.69 10.49 16.91 10.41 17.35C10.39 17.44 10.45 17.52 10.54 17.52C11.68 17.55 18.26 17.39 19.84 9.15C19.85 9.1 20 8.84 20.2 9.09C20.73 9.77 21.57 11.92 20.54 14.85C17.99 22.08 11 20.93 10.21 20.77C10.17 20.77 10.13 20.8 10.14 20.83C10.15 21.14 10.18 22.32 9.83 22.36C9.49 22.4 4.96 18.39 5.04 18.05C5.14 17.64 10.17 15.49 10.43 15.59L10.43 15.59L10.43 15.59Z"/></g>`,
2850
+ turbo1: `<g fill="currentColor" fill-rule="evenodd"><path d="M17.81 2.62L14.41 8.21C14.15 8.64 14.46 9.2 14.97 9.2L18.84 9.21C19.42 9.21 19.72 9.9 19.32 10.31L8.02 22.19C7.89 22.33 7.72 22.4 7.53 22.4L7.53 22.4C7.08 22.39 6.77 21.93 6.93 21.5L9.91 13.91C10.08 13.48 9.76 13.01 9.29 13.01L5.11 13.06C4.61 13.06 4.28 12.53 4.53 12.09L10.07 1.94C10.19 1.73 10.41 1.6 10.65 1.6L17.26 1.62C17.77 1.62 18.08 2.18 17.81 2.62L17.81 2.62Z"/></g>`,
2851
+ autoplay: `<g fill="currentColor" fill-rule="evenodd"><path d="M19.97 12.41C20.22 11.94 20.95 11.88 20.97 12.47C21.14 16.4 18.71 19.92 14.44 20.97C8.59 22.4 5.29 18.55 5.28 18.52C5.2 18.33 4.41 19.77 4.19 19.59C3.81 19.28 3.78 14.9 3.9 14.78C4.01 14.67 8.39 14.95 8.48 15.31C8.58 15.64 7.2 16.1 7.4 16.38C9.14 18.67 15.82 20.29 19.97 12.41L19.97 12.41Z"/><path d="M9.3 15.36L9.3 8.67C9.3 8.32 9.97 7.74 10.58 8.14C15.83 11.56 16 11.46 16.01 12.04C16.02 12.61 15.12 12.98 10.63 15.91C10.32 16.11 9.29 15.72 9.29 15.36L9.3 15.36Z"/><path d="M4.03 11.59C3.78 12.06 3.05 12.12 3.03 11.53C2.86 7.6 5.29 4.08 9.56 3.03C15.41 1.6 18.71 5.45 18.72 5.48C18.8 5.67 19.59 4.23 19.81 4.41C20.19 4.72 20.22 9.1 20.1 9.22C19.99 9.33 15.61 9.05 15.52 8.69C15.42 8.36 16.8 7.9 16.6 7.62C14.86 5.33 8.18 3.71 4.03 11.59L4.03 11.59Z"/></g>`,
2484
2852
  stop: `<g fill="currentColor" fill-rule="evenodd"><rect x="1.6" y="1.6" width="20.8" height="20.8" rx="2.9"/></g>`,
2485
2853
  menu: `<g fill="currentColor" fill-rule="evenodd"><rect x="1.61" y="3.81" width="20.79" height="4.47" rx="2.23"/><rect x="1.6" y="9.77" width="20.79" height="4.46" rx="2.23"/><rect x="1.6" y="15.72" width="20.79" height="4.47" rx="2.23"/></g>`,
2486
2854
  minus: `<g fill="currentColor" fill-rule="evenodd"><rect x="1.6" y="9.86" width="20.8" height="4.28" rx="2.11"/></g>`,
2487
- plus: `<g fill="currentColor" fill-rule="evenodd"><path d="M19.72 14.37L13.84 14.37L13.84 20.33C13.84 21.48 12.89 22.4 11.74 22.36C10.61 22.36 9.7 21.45 9.7 20.33L9.7 14.37L3.67 14.37C2.52 14.37 1.6 13.42 1.63 12.27C1.63 11.15 2.55 10.23 3.67 10.23L9.7 10.23L9.7 4.28C9.71 1.61 13.83 1.6 13.84 4.28L13.84 10.23L19.72 10.23C22.39 10.24 22.4 14.36 19.72 14.37Z"/></g>`,
2855
+ plus: `<g fill="currentColor" fill-rule="evenodd"><path d="M19.72 14.37L13.84 14.37L13.84 20.33C13.84 21.48 12.89 22.4 11.74 22.36C10.61 22.36 9.7 21.45 9.7 20.33L9.7 14.37L3.67 14.37C2.52 14.37 1.6 13.42 1.63 12.27C1.63 11.15 2.55 10.23 3.67 10.23L9.7 10.23L9.7 4.28C9.71 1.61 13.83 1.6 13.84 4.28L13.84 10.23L19.72 10.23C22.39 10.24 22.4 14.36 19.72 14.37L19.72 14.37Z"/></g>`,
2488
2856
  gift: `<rect x="4" y="9" width="16" height="11" rx="2" fill="currentColor"/><path d="M9 9c-1.35 -0.31 -2.18 -1.65 -1.87 -3s1.65 -2.18 3 -1.87c0.93 0.22 1.65 0.94 1.87 1.87c0.31 -1.35 1.65 -2.18 3 -1.87c1.35 0.31 2.18 1.65 1.87 3c-0.22 0.93 -0.94 1.65 -1.87 1.87h-6Z" fill="currentColor"/><rect x="11" y="9" width="2" height="11" fill="rgba(0,0,0,.35)"/>`,
2489
- info: `<g fill="currentColor" fill-rule="evenodd"><circle cx="11.98" cy="4.27" r="2.67"/><path d="M16.05 21.09L16.05 21.54C16.05 22.02 15.67 22.4 15.19 22.4L8.89 22.4C8.42 22.4 8.04 22.02 8.04 21.54L8.04 20.98C8.04 20.5 8.42 20.12 8.89 20.12L8.89 20.12C9.13 20.12 9.32 19.93 9.32 19.7L9.32 11.59C9.32 11.29 9.08 11.05 8.8 11.05C8.33 11.05 7.95 10.67 7.95 10.19L7.95 9.18C7.95 8.7 8.33 8.32 8.8 8.32L9.32 8.32C9.32 8.32 13.8 8.32 13.8 8.32C14.27 8.32 14.65 8.71 14.65 9.18L14.65 19.7C14.65 19.93 14.84 20.12 15.07 20.12L15.07 20.12C15.61 20.12 16.05 20.56 16.05 21.09Z"/></g>`,
2490
- soundOn: `<g fill="currentColor" fill-rule="evenodd"><path d="M1.6 15.04L1.6 9.18C1.6 8.75 1.95 8.4 2.38 8.4L5.03 8.4C5.21 8.4 5.39 8.36 5.56 8.28L11.6 5.26C12.12 5 12.73 5.38 12.73 5.96L12.73 18.27C12.73 18.85 12.12 19.22 11.6 18.96L5.56 15.94C5.39 15.86 5.22 15.82 5.03 15.82L2.38 15.82C1.95 15.82 1.6 15.47 1.6 15.04Z"/><path d="M16.01 12.11C16.04 12.36 15.67 14.7 14.7 15.23C13.92 15.42 13.54 14.77 13.86 14.1C14.89 12.56 14.88 11.66 13.86 10.13C13.54 9.46 13.92 8.8 14.7 8.99C15.67 9.53 16.06 11.81 16.01 12.11Z"/><path d="M19.15 12.12C19.2 12.51 18.6 16.4 17.3 17.05C16.32 17.54 15.99 16.87 16.42 15.81C17.8 13.4 17.59 9.93 16.42 8.41C15.73 7.5 16.34 6.58 17.26 7.18C18.74 8.15 19.21 11.64 19.15 12.12Z"/><path d="M22.4 12.16C22.16 15.18 21 17.95 19.71 18.82C18.73 19.48 18.22 18.42 18.93 17.32C20.96 14.17 21.92 9.95 18.9 6.29C18.13 5.35 19.35 4.52 20.11 5.48C21.43 7.14 22.33 9.14 22.4 12.16Z"/></g>`,
2857
+ info: `<g fill="currentColor" fill-rule="evenodd"><circle cx="11.98" cy="4.27" r="2.67"/><path d="M16.05 21.09L16.05 21.54C16.05 22.02 15.67 22.4 15.19 22.4L8.89 22.4C8.42 22.4 8.04 22.02 8.04 21.54L8.04 20.98C8.04 20.5 8.42 20.12 8.89 20.12L8.89 20.12C9.13 20.12 9.32 19.93 9.32 19.7L9.32 11.59C9.32 11.29 9.08 11.05 8.8 11.05C8.33 11.05 7.95 10.67 7.95 10.19L7.95 9.18C7.95 8.7 8.33 8.32 8.8 8.32L13.8 8.32C14.27 8.32 14.65 8.71 14.65 9.18L14.65 19.7C14.65 19.93 14.84 20.12 15.07 20.12L15.07 20.12C15.61 20.12 16.05 20.56 16.05 21.09L16.05 21.09Z"/></g>`,
2858
+ soundOn: `<g fill="currentColor" fill-rule="evenodd"><path d="M1.6 15.04L1.6 9.18C1.6 8.75 1.95 8.4 2.38 8.4L5.03 8.4C5.21 8.4 5.39 8.36 5.56 8.28L11.6 5.26C12.12 5 12.73 5.38 12.73 5.96L12.73 18.27C12.73 18.85 12.12 19.22 11.6 18.96L5.56 15.94C5.39 15.86 5.22 15.82 5.03 15.82L2.38 15.82C1.95 15.82 1.6 15.47 1.6 15.04L1.6 15.04Z"/><path d="M16.01 12.11C16.04 12.36 15.67 14.7 14.7 15.23C13.92 15.42 13.54 14.77 13.86 14.1C14.89 12.56 14.88 11.66 13.86 10.13C13.54 9.46 13.92 8.8 14.7 8.99C15.67 9.53 16.06 11.81 16.01 12.11Z"/><path d="M19.15 12.12C19.2 12.51 18.6 16.4 17.3 17.05C16.32 17.54 15.99 16.87 16.42 15.81C17.8 13.4 17.59 9.93 16.42 8.41C15.73 7.5 16.34 6.58 17.26 7.18C18.74 8.15 19.21 11.64 19.15 12.12L19.15 12.12Z"/><path d="M22.4 12.16C22.16 15.18 21 17.95 19.71 18.82C18.73 19.48 18.22 18.42 18.93 17.32C20.96 14.17 21.92 9.95 18.9 6.29C18.13 5.35 19.35 4.52 20.11 5.48C21.43 7.14 22.33 9.14 22.4 12.16L22.4 12.16Z"/></g>`,
2491
2859
  soundOff: `<g fill="currentColor" fill-rule="evenodd"><path d="M1.6 14.77L1.6 9.23C1.6 8.82 1.93 8.49 2.34 8.49L4.85 8.49C5.02 8.49 5.19 8.45 5.34 8.38L11.06 5.52C11.55 5.27 12.12 5.63 12.12 6.18L12.12 17.82C12.12 18.37 11.55 18.73 11.06 18.48L5.34 15.62C5.19 15.55 5.02 15.51 4.85 15.51L2.34 15.51C1.93 15.51 1.6 15.18 1.6 14.77Z"/><path d="M21.95 16.53C21.5 16.98 20.78 16.98 20.33 16.53L17.79 13.99L15.25 16.54C14.8 16.99 14.07 16.99 13.62 16.54C13.17 16.09 13.17 15.36 13.62 14.92L16.17 12.37L13.63 9.83C13.18 9.38 13.18 8.65 13.63 8.21C13.85 7.98 14.14 7.87 14.44 7.87C14.73 7.87 15.02 7.98 15.25 8.21L17.79 10.75L20.33 8.21C20.77 7.76 21.5 7.76 21.95 8.21C22.17 8.44 22.28 8.73 22.28 9.02C22.28 9.32 22.17 9.61 21.95 9.83L19.41 12.37L21.95 14.91C22.4 15.36 22.4 16.08 21.95 16.53Z"/></g>`,
2492
- close: `<g fill="currentColor" fill-rule="evenodd"><path d="M21.39 21.37C20.38 22.38 18.74 22.38 17.73 21.37L12.01 15.64L6.27 21.38C5.26 22.39 3.62 22.39 2.61 21.38C1.6 20.38 1.6 18.74 2.61 17.73L8.35 11.99L2.62 6.25C1.61 5.24 1.61 3.61 2.62 2.6C3.12 2.09 3.79 1.84 4.45 1.84C5.11 1.84 5.77 2.09 6.28 2.6L12.01 8.33L17.72 2.62C18.73 1.61 20.37 1.61 21.38 2.62C21.89 3.12 22.14 3.78 22.14 4.44C22.14 5.11 21.89 5.77 21.38 6.27L15.67 11.99L21.39 17.71C22.4 18.72 22.4 20.36 21.39 21.37Z"/></g>`,
2493
- back: `<g fill="currentColor" fill-rule="evenodd"><path d="M17.49 2.32L17.49 2.32C18.2 3.03 18.2 4.19 17.49 4.9L11.68 10.71C10.97 11.42 10.97 12.58 11.68 13.29L17.49 19.1C18.21 19.81 18.21 20.97 17.49 21.69L17.49 21.69C16.78 22.4 15.62 22.4 14.91 21.69L7.8 14.58L7.8 14.58C7.8 14.58 6.51 13.29 6.51 13.29C5.79 12.58 5.79 11.42 6.51 10.71L14.9 2.31C15.62 1.6 16.77 1.6 17.49 2.31Z"/></g>`,
2494
- chevronRight: `<g fill="currentColor" fill-rule="evenodd"><path d="M6.51 21.68L6.51 21.68C5.8 20.97 5.8 19.81 6.51 19.1L12.32 13.29C13.03 12.58 13.03 11.42 12.32 10.71L6.51 4.9C5.79 4.19 5.79 3.03 6.51 2.31L6.51 2.31C7.22 1.6 8.38 1.6 9.09 2.31L16.2 9.42L16.2 9.42C16.2 9.42 17.49 10.71 17.49 10.71C18.21 11.42 18.21 12.58 17.49 13.29L9.1 21.69C8.38 22.4 7.23 22.4 6.51 21.69Z"/></g>`,
2860
+ close: `<g fill="currentColor" fill-rule="evenodd"><path d="M21.39 21.37C20.38 22.38 18.74 22.38 17.73 21.37L12.01 15.64L6.27 21.38C5.26 22.39 3.62 22.39 2.61 21.38C1.6 20.38 1.6 18.74 2.61 17.73L8.35 11.99L2.62 6.25C1.61 5.24 1.61 3.61 2.62 2.6C3.12 2.09 3.79 1.84 4.45 1.84C5.11 1.84 5.77 2.09 6.28 2.6L12.01 8.33L17.72 2.62C18.73 1.61 20.37 1.61 21.38 2.62C21.89 3.12 22.14 3.78 22.14 4.44C22.14 5.11 21.89 5.77 21.38 6.27L15.67 11.99L21.39 17.71C22.4 18.72 22.4 20.36 21.39 21.37L21.39 21.37Z"/></g>`,
2861
+ back: `<g fill="currentColor" fill-rule="evenodd"><path d="M17.49 2.32L17.49 2.32C18.2 3.03 18.2 4.19 17.49 4.9L11.68 10.71C10.97 11.42 10.97 12.58 11.68 13.29L17.49 19.1C18.21 19.81 18.21 20.97 17.49 21.69L17.49 21.69C16.78 22.4 15.62 22.4 14.91 21.69L7.8 14.58L7.8 14.58L6.51 13.29C5.79 12.58 5.79 11.42 6.51 10.71L14.9 2.31C15.62 1.6 16.77 1.6 17.49 2.31L17.49 2.31Z"/></g>`,
2862
+ chevronRight: `<g fill="currentColor" fill-rule="evenodd"><path d="M6.51 21.68L6.51 21.68C5.8 20.97 5.8 19.81 6.51 19.1L12.32 13.29C13.03 12.58 13.03 11.42 12.32 10.71L6.51 4.9C5.79 4.19 5.79 3.03 6.51 2.31L6.51 2.31C7.22 1.6 8.38 1.6 9.09 2.31L16.2 9.42L16.2 9.42L17.49 10.71C18.21 11.42 18.21 12.58 17.49 13.29L9.1 21.69C8.38 22.4 7.23 22.4 6.51 21.69L6.51 21.69Z"/></g>`,
2495
2863
  ticket: `<g transform="translate(12 12) scale(0.0354) translate(-518.2 -535.2)"><g transform="rotate(-15 512 512)"><path d="M250 392H774L774 462C739 474 720 504 720 536C720 568 739 598 774 610V680H250V610C285 598 304 568 304 536C304 504 285 474 250 462V392Z" fill="none" stroke="currentColor" stroke-width="52" stroke-linejoin="miter" stroke-linecap="square"/><path d="M562.9 408.3L441.5 553.9L506.9 546.3L472.9 664.1L604 504L528.9 514.3Z" fill="currentColor"/></g></g>`,
2496
- turbo2: `<g fill="currentColor" fill-rule="evenodd"><path d="M8.24 8.81L3.92 7.68C3.88 7.67 3.88 7.61 3.92 7.61L9.66 6.45C9.8 6.43 9.89 6.56 9.83 6.68L8.86 8.35C8.67 8.73 8.33 8.83 8.24 8.81Z"/><path d="M20.58 3.04L17.34 8.38C17.09 8.8 17.39 9.33 17.87 9.33L21.57 9.33C22.12 9.33 22.4 9.99 22.02 10.39L11.24 21.73C11.12 21.86 10.95 21.93 10.77 21.92L10.77 21.92C10.34 21.92 10.04 21.47 10.2 21.07L13.04 13.82C13.21 13.41 12.9 12.96 12.45 12.97L8.46 13.01C7.98 13.01 7.67 12.5 7.9 12.08L13.2 2.4C13.31 2.2 13.52 2.07 13.75 2.07L20.05 2.09C20.54 2.1 20.84 2.63 20.58 3.04Z"/><path d="M5.96 12.68L1.64 11.54C1.6 11.54 1.6 11.47 1.64 11.47L7.38 10.31C7.52 10.3 7.61 10.42 7.55 10.55L6.58 12.22C6.39 12.59 6.05 12.69 5.96 12.68Z"/><path d="M9.67 16.66L5.35 15.53C5.31 15.52 5.31 15.46 5.35 15.46L11.09 14.3C11.22 14.28 11.32 14.41 11.26 14.53L10.29 16.2C10.1 16.58 9.76 16.68 9.67 16.66Z"/></g>`,
2497
- turboOff: `<g fill="currentColor" fill-rule="evenodd"><path d="M17.81 2.62L14.41 8.21C14.15 8.64 14.46 9.2 14.97 9.2L18.84 9.21C19.42 9.21 19.72 9.9 19.32 10.31L8.02 22.19C7.89 22.33 7.72 22.4 7.53 22.4L7.53 22.4C7.08 22.39 6.77 21.93 6.93 21.5L9.91 13.91C10.08 13.48 9.76 13.01 9.29 13.01L5.11 13.06C4.61 13.06 4.28 12.53 4.53 12.09L10.07 1.94C10.19 1.73 10.41 1.6 10.65 1.6L17.26 1.62C17.77 1.62 18.08 2.18 17.81 2.62Z"/></g>`,
2498
- chevronUp: `<g fill="currentColor" fill-rule="evenodd"><path d="M21.68 17.49L21.68 17.49C20.97 18.2 19.81 18.2 19.1 17.49L13.29 11.68C12.58 10.97 11.42 10.97 10.71 11.68L4.9 17.49C4.19 18.21 3.03 18.21 2.31 17.49L2.31 17.49C1.6 16.78 1.6 15.62 2.31 14.91L9.42 7.8L9.42 7.8C9.42 7.8 10.71 6.51 10.71 6.51C11.42 5.79 12.58 5.79 13.29 6.51L21.69 14.9C22.4 15.62 22.4 16.77 21.69 17.49Z"/></g>`,
2499
- chevronDown: `<g fill="currentColor" fill-rule="evenodd"><path d="M2.32 6.51L2.32 6.51C3.03 5.8 4.19 5.8 4.9 6.51L10.71 12.32C11.42 13.03 12.58 13.03 13.29 12.32L19.1 6.51C19.82 5.79 20.97 5.79 21.69 6.51L21.69 6.51C22.4 7.22 22.4 8.38 21.69 9.09L14.58 16.19L14.58 16.2C14.58 16.2 13.29 17.49 13.29 17.49C12.58 18.21 11.42 18.21 10.71 17.49L2.31 9.1C1.6 8.38 1.6 7.23 2.31 6.51Z"/></g>`,
2864
+ turbo2: `<g fill="currentColor" fill-rule="evenodd"><path d="M8.24 8.81L3.92 7.68C3.88 7.67 3.88 7.61 3.92 7.61L9.66 6.45C9.8 6.43 9.89 6.56 9.83 6.68L8.86 8.35C8.67 8.73 8.33 8.83 8.24 8.81L8.24 8.81Z"/><path d="M20.58 3.04L17.34 8.38C17.09 8.8 17.39 9.33 17.87 9.33L21.57 9.33C22.12 9.33 22.4 9.99 22.02 10.39L11.24 21.73C11.12 21.86 10.95 21.93 10.77 21.92L10.77 21.92C10.34 21.92 10.04 21.47 10.2 21.07L13.04 13.82C13.21 13.41 12.9 12.96 12.45 12.97L8.46 13.01C7.98 13.01 7.67 12.5 7.9 12.08L13.2 2.4C13.31 2.2 13.52 2.07 13.75 2.07L20.05 2.09C20.54 2.1 20.84 2.63 20.58 3.04L20.58 3.04Z"/><path d="M5.96 12.68L1.64 11.54C1.6 11.54 1.6 11.47 1.64 11.47L7.38 10.31C7.51 10.3 7.61 10.42 7.55 10.55L6.58 12.22C6.39 12.59 6.05 12.69 5.96 12.68L5.96 12.68Z"/><path d="M9.67 16.66L5.35 15.53C5.31 15.52 5.31 15.46 5.35 15.46L11.09 14.3C11.22 14.28 11.32 14.41 11.26 14.53L10.29 16.2C10.1 16.58 9.76 16.68 9.67 16.66L9.67 16.66Z"/></g>`,
2865
+ turboOff: `<g fill="currentColor" fill-rule="evenodd"><path d="M17.81 2.62L14.41 8.21C14.15 8.64 14.46 9.2 14.97 9.2L18.84 9.21C19.42 9.21 19.72 9.9 19.32 10.31L8.02 22.19C7.89 22.33 7.72 22.4 7.53 22.4L7.53 22.4C7.08 22.39 6.77 21.93 6.93 21.5L9.91 13.91C10.08 13.48 9.76 13.01 9.29 13.01L5.11 13.06C4.61 13.06 4.28 12.53 4.53 12.09L10.07 1.94C10.19 1.73 10.41 1.6 10.65 1.6L17.26 1.62C17.77 1.62 18.08 2.18 17.81 2.62L17.81 2.62Z"/></g>`,
2866
+ chevronUp: `<g fill="currentColor" fill-rule="evenodd"><path d="M21.68 17.49L21.68 17.49C20.97 18.2 19.81 18.2 19.1 17.49L13.29 11.68C12.58 10.97 11.42 10.97 10.71 11.68L4.9 17.49C4.19 18.21 3.03 18.21 2.31 17.49L2.31 17.49C1.6 16.78 1.6 15.62 2.31 14.91L9.42 7.8L9.42 7.8L10.71 6.51C11.42 5.79 12.58 5.79 13.29 6.51L21.69 14.9C22.4 15.62 22.4 16.77 21.69 17.49L21.69 17.49Z"/></g>`,
2867
+ chevronDown: `<g fill="currentColor" fill-rule="evenodd"><path d="M2.32 6.51L2.32 6.51C3.03 5.8 4.19 5.8 4.9 6.51L10.71 12.32C11.42 13.03 12.58 13.03 13.29 12.32L19.1 6.51C19.82 5.79 20.97 5.79 21.69 6.51L21.69 6.51C22.4 7.22 22.4 8.38 21.69 9.09L14.58 16.19L14.58 16.2L13.29 17.49C12.58 18.21 11.42 18.21 10.71 17.49L2.31 9.1C1.6 8.38 1.6 7.23 2.31 6.51L2.32 6.51L2.32 6.51Z"/></g>`,
2500
2868
  };
2501
2869
  /** Inline SVG string for an icon, sized to 1em (scale via font-size/width). */
2502
2870
  function icon(name) {
@@ -2855,77 +3223,246 @@ function createOverlay(opts) {
2855
3223
  root.append(head, scroll);
2856
3224
  return { root, body, scroll };
2857
3225
  }
3226
+ /** A light-dismiss popover: a transparent full-surface layer (closes on pointerdown) holding a
3227
+ * card with an arrow that points at `pointer`. Append rows to `body`; call `position()` after the
3228
+ * card is in the DOM and again on resize. */
3229
+ function createPopover(opts) {
3230
+ const root = document.createElement('div');
3231
+ root.className = 'ge-pop-layer';
3232
+ root.dataset.ge = opts.ge;
3233
+ const card = document.createElement('div');
3234
+ card.className = 'ge-pop';
3235
+ card.dataset.ge = 'menu-card';
3236
+ const body = document.createElement('div');
3237
+ body.className = 'ge-pop-body';
3238
+ const arrow = document.createElement('span');
3239
+ arrow.className = 'ge-pop-arrow';
3240
+ card.append(body, arrow);
3241
+ root.appendChild(card);
3242
+ // Clicks inside the card must not reach the dismiss layer.
3243
+ card.addEventListener('pointerdown', (e) => e.stopPropagation());
3244
+ root.addEventListener('pointerdown', opts.onClose);
3245
+ const resolveEl = (v) => typeof v === 'function' ? v() : (v ?? null);
3246
+ /** A rect in surface coordinates, or null when unresolved/fully zero-sized (a zero-HEIGHT rect —
3247
+ * e.g. a not-yet-laid-out anchor — is still considered valid, matching placePopover's own rule). */
3248
+ const rectOf = (el, surfaceRect) => {
3249
+ if (!el)
3250
+ return null;
3251
+ const r = el.getBoundingClientRect();
3252
+ if (r.width <= 0 && r.height <= 0)
3253
+ return null;
3254
+ return { x: r.left - surfaceRect.left, y: r.top - surfaceRect.top, w: r.width, h: r.height };
3255
+ };
3256
+ const position = () => {
3257
+ const surfaceRect = opts.surface.getBoundingClientRect();
3258
+ const surface = { w: surfaceRect.width || opts.surface.clientWidth, h: surfaceRect.height || opts.surface.clientHeight };
3259
+ if (surface.w <= 0 || surface.h <= 0)
3260
+ return;
3261
+ const s = opts.scale?.() ?? 1;
3262
+ // 1. Clear a prior run's constraints (transform + width + max-height + left) before measuring —
3263
+ // otherwise scrollWidth/offsetHeight report the already-scaled/clamped box (not the natural
3264
+ // content size) on every call after the first, and the card can shrink to fit a
3265
+ // narrower/shorter surface but never grow back when the surface widens/grows again. An uncleared
3266
+ // max-height is the worse of the two: placePopover positions a card sized for the STALE clamped
3267
+ // height, then the un-clamped natural height (restored below) springs back afterward — so the
3268
+ // rendered card can overlap the plate or run off the surface edge until reopened. The transform
3269
+ // doesn't affect layout either way, but clearing it keeps every pass measuring the same way.
3270
+ // `left` matters too: `.ge-pop` is absolutely positioned inside an `inset:0` layer, so with the
3271
+ // previous pass's `left` still applied, its shrink-to-fit width is bounded by (layerWidth − left)
3272
+ // instead of the card's true natural width. Invisible at scale 1; a scale below 1 lays the card
3273
+ // out at up to 1/s its on-screen width, so a stale left — only ever a few hundred px — can clip it.
3274
+ card.style.transform = '';
3275
+ card.style.width = '';
3276
+ card.style.maxHeight = '';
3277
+ card.style.left = '0px';
3278
+ const naturalW = card.scrollWidth || POPOVER.minW;
3279
+ // 2. Resolve the ON-SCREEN width from the natural (unscaled) width scaled up to screen units,
3280
+ // then set the LOCAL style.width so the card renders at that resolved width once scaled — and
3281
+ // re-measure the height at that width (wrapping may have changed it).
3282
+ const resolvedW = popoverWidth(surface.w, naturalW * s);
3283
+ card.style.width = `${resolvedW / s}px`;
3284
+ const naturalH = card.offsetHeight || POPOVER.minH;
3285
+ // 3. Resolve plate/pointer in surface coordinates and place using SCREEN-space size —
3286
+ // placePopover works in surface pixels throughout, so both the anchor rects and `size` here are
3287
+ // screen units even though the card's own layout (width/height above) is still LOCAL/unscaled.
3288
+ const plateEl = resolveEl(opts.plate);
3289
+ const pointerEl = resolveEl(opts.pointer);
3290
+ let plate = rectOf(plateEl, surfaceRect) ?? rectOf(pointerEl, surfaceRect);
3291
+ // Extend the plate's TOP edge upward to a popped-out hero's true top (e.g. the mobile SPIN/FS
3292
+ // control, taller than its row) — bottom edge untouched. Both rects are already in the SAME
3293
+ // surface-coordinate space (post any bar-scale transform), so this is a plain coordinate compare,
3294
+ // no separate unit conversion needed.
3295
+ const overflowEl = resolveEl(opts.plateOverflowTop);
3296
+ if (plate) {
3297
+ const overflowRect = rectOf(overflowEl, surfaceRect);
3298
+ if (overflowRect && overflowRect.y < plate.y) {
3299
+ plate = { ...plate, h: plate.h + (plate.y - overflowRect.y), y: overflowRect.y };
3300
+ }
3301
+ }
3302
+ const pointer = rectOf(pointerEl, surfaceRect);
3303
+ const p = placePopover(plate, surface, { w: resolvedW, h: naturalH * s }, pointer);
3304
+ // 4. Apply. maxHeight and the arrow's offset are LOCAL (unscaled) too, since both live inside the
3305
+ // scaled card; transform-origin:top left keeps left/top (screen units) as the card's visual
3306
+ // top-left regardless of `s`, and — since a transform doesn't affect layout — the next
3307
+ // measurement pass stays clean without needing any extra bookkeeping.
3308
+ card.style.left = `${p.x}px`;
3309
+ card.style.top = `${p.y}px`;
3310
+ card.style.maxHeight = `${p.maxH / s}px`;
3311
+ card.style.transformOrigin = 'top left';
3312
+ card.style.transform = Math.abs(s - 1) > 0.001 ? `scale(${s})` : '';
3313
+ card.classList.toggle('ge-pop-below', p.below);
3314
+ if (p.arrowX < 0)
3315
+ arrow.style.display = 'none';
3316
+ else {
3317
+ arrow.style.display = '';
3318
+ arrow.style.left = `${p.arrowX / s}px`;
3319
+ }
3320
+ };
3321
+ return { root, card, body, position };
3322
+ }
2858
3323
 
2859
- function openSettingsModal(host) {
2860
- const { root, body } = createOverlay({ title: host.t('Settings'), onClose: () => host.actions.closeOverlay() });
2861
- root.dataset.ge = 'settings-modal';
2862
- // Sound on/off — backed by the shell's shared `soundOn` state so this toggle and the Shift+M
2863
- // hotkey stay in sync; `setSound` emits `settingChange({ key: 'sound' })` and refreshes the icon.
2864
- const sound = (() => {
3324
+ /** The bar menu, as a light-dismiss popover anchored to the burger. Rows come from the core model,
3325
+ * so DOM and Pixi always show the same list in the same order. */
3326
+ function openMenuPopover(host, surface, getScale) {
3327
+ const pop = createPopover({
3328
+ ge: 'menu-popover',
3329
+ surface,
3330
+ // Resolved lazily on every position() call, not captured once: HtmlRenderer's renderBar() (run
3331
+ // on every resize, and on ~20 other state changes) rebuilds the bottom bar from scratch, so the
3332
+ // plate/burger are brand-new elements after it — a captured reference would already be detached
3333
+ // by the next position() call and the card would silently recentre with its arrow hidden.
3334
+ // The plate is the bar's own plaque — the continuous dark panel wide, the controls row mobile
3335
+ // (NOT the info pill below it) — so the card sits flush with the WHOLE bar, not just the burger.
3336
+ plate: () => surface.querySelector(host.layout === 'mobile' ? '.ge-m-controls' : '.ge-bar-panel'),
3337
+ pointer: () => surface.querySelector('[data-ge="menu"]'),
3338
+ // Mobile only: the SPIN disc / FS counter is taller than `.ge-m-controls` and centred inside it
3339
+ // (`align-items:center` over a shorter fixed-height row), so it pops above the row's own top edge
3340
+ // — see createPopover's `plateOverflowTop` doc comment. Exactly one of the two (or neither, e.g. a
3341
+ // replay with no free spins) is ever rendered, so a combined selector resolves to whichever is
3342
+ // current. Wide's plate already contains its content, so this deliberately resolves to null there.
3343
+ plateOverflowTop: () => host.layout === 'mobile'
3344
+ ? surface.querySelector('[data-ge="spin"], [data-ge="fs-counter"]')
3345
+ : null,
3346
+ scale: getScale,
3347
+ onClose: () => host.actions.closeOverlay(),
3348
+ });
3349
+ const updaters = {};
3350
+ for (const row of resolveMenu(host)) {
3351
+ pop.body.appendChild(buildRow(host, row, updaters, () => pop.position()));
3352
+ }
3353
+ // Live updates while open (host.setMenuValue / setSound / setVolume); cleared by the controller.
3354
+ host.setMenuRefresh((id, v) => updaters[id]?.(v));
3355
+ return { root: pop.root, position: pop.position };
3356
+ }
3357
+ function glyph(name, cls) {
3358
+ if (!name)
3359
+ return null;
3360
+ const el = document.createElement('span');
3361
+ el.className = cls;
3362
+ el.innerHTML = icon(name);
3363
+ return el;
3364
+ }
3365
+ function buildRow(host, row, updaters, reposition) {
3366
+ if (row.kind === 'separator') {
3367
+ const sep = document.createElement('div');
3368
+ sep.className = 'ge-pop-sep';
3369
+ sep.dataset.ge = 'menu-sep';
3370
+ return sep;
3371
+ }
3372
+ if (row.kind === 'button') {
3373
+ // The row hook goes on a wrapper so both `menu-row-<id>` (order assertions) and
3374
+ // `menu-item-<id>` (the clickable control) exist, as they do for toggle/range rows.
3375
+ const wrap = document.createElement('div');
3376
+ wrap.dataset.ge = `menu-row-${row.id}`;
3377
+ const btn = document.createElement('button');
3378
+ btn.className = 'ge-ov-row';
3379
+ btn.dataset.ge = `menu-item-${row.id}`;
3380
+ btn.disabled = row.disabled;
3381
+ const label = document.createElement('span');
3382
+ label.className = 'ge-grow';
3383
+ label.textContent = row.label;
3384
+ const ico = glyph(row.icon, 'ge-mi-icon');
3385
+ const chev = row.chevron ? glyph('chevronRight', 'ge-mi-chev') : null;
3386
+ for (const el of [ico, label, chev])
3387
+ if (el)
3388
+ btn.appendChild(el);
3389
+ btn.addEventListener('click', () => {
3390
+ if (btn.disabled)
3391
+ return;
3392
+ host.actions.closeOverlay();
3393
+ row.select();
3394
+ });
3395
+ wrap.appendChild(btn);
3396
+ return wrap;
3397
+ }
3398
+ if (row.kind === 'toggle') {
3399
+ const el = document.createElement('div');
3400
+ el.className = 'ge-ov-row';
3401
+ el.classList.toggle('ge-disabled', row.disabled); // a <div> can't carry [disabled] itself
3402
+ el.dataset.ge = `menu-row-${row.id}`;
3403
+ const ico = glyph(row.icon(row.get()), 'ge-mi-icon');
3404
+ const label = document.createElement('span');
3405
+ label.className = 'ge-grow';
3406
+ label.textContent = row.label;
2865
3407
  const btn = document.createElement('button');
2866
- btn.className = 'ge-snd';
2867
- btn.dataset.ge = 'setting-sound';
2868
- btn.setAttribute('aria-label', host.t('Sound'));
2869
- const paint = (on) => {
2870
- btn.innerHTML = icon(on ? 'soundOn' : 'soundOff');
2871
- btn.classList.toggle('ge-active', on);
2872
- btn.setAttribute('aria-pressed', String(on));
3408
+ btn.className = 'ge-toggle';
3409
+ btn.dataset.ge = `menu-item-${row.id}`;
3410
+ btn.disabled = row.disabled;
3411
+ btn.innerHTML = '<i></i>';
3412
+ const paint = (v) => {
3413
+ btn.classList.toggle('ge-on', v);
3414
+ btn.setAttribute('aria-pressed', String(v));
3415
+ const next = row.icon(v);
3416
+ if (ico && next)
3417
+ ico.innerHTML = icon(next);
2873
3418
  };
2874
- paint(host.soundOn);
2875
- btn.addEventListener('click', () => host.setSound(!host.soundOn));
2876
- // Live-update the icon when sound changes from here OR via Shift+M (shell clears on close).
2877
- host.setSoundRefresh(paint);
2878
- const row = document.createElement('div');
2879
- row.className = 'ge-ov-row';
2880
- row.innerHTML = `<span class="ge-grow">${host.t('Sound')}</span>`;
2881
- row.appendChild(btn);
2882
- return row;
2883
- })();
2884
- body.appendChild(sound);
2885
- // Volume sliders — full-width column rows with a live value readout. Positions are read from the
2886
- // shell's stored volumes (not hardcoded to 100%), so reopening the overlay reflects the last set
2887
- // value, and `host.setVolume()` from game code updates them live via the registered refreshers.
2888
- const updaters = {};
2889
- const slider = (key, label) => {
2890
- const row = document.createElement('div');
2891
- row.className = 'ge-ov-row ge-col';
2892
- const head = document.createElement('div');
2893
- head.className = 'ge-row-head';
2894
- const val = document.createElement('span');
2895
- val.className = 'ge-val';
2896
- head.innerHTML = `<span>${label}</span>`;
2897
- head.appendChild(val);
2898
- const input = document.createElement('input');
2899
- input.type = 'range';
2900
- input.min = '0';
2901
- input.max = '1';
2902
- input.step = '0.05';
2903
- input.className = 'ge-slider';
2904
- input.dataset.ge = `setting-${key}`;
2905
- const paint = (v) => { input.value = String(v); val.textContent = `${Math.round(v * 100)}%`; };
2906
- paint(host.getVolume(key));
2907
- input.addEventListener('input', () => {
2908
- val.textContent = `${Math.round(Number(input.value) * 100)}%`;
2909
- host.setVolume(key, Number(input.value));
3419
+ paint(row.get());
3420
+ btn.addEventListener('click', () => {
3421
+ if (!btn.disabled)
3422
+ row.set(!row.get());
2910
3423
  });
2911
- updaters[key] = paint;
2912
- row.append(head, input);
2913
- return row;
3424
+ updaters[row.id] = (v) => paint(v === true);
3425
+ if (ico)
3426
+ el.appendChild(ico);
3427
+ el.append(label, btn);
3428
+ return el;
3429
+ }
3430
+ // range
3431
+ const el = document.createElement('div');
3432
+ el.className = 'ge-ov-row ge-col';
3433
+ el.classList.toggle('ge-disabled', row.disabled); // a <div> can't carry [disabled] itself
3434
+ el.dataset.ge = `menu-row-${row.id}`;
3435
+ const head = document.createElement('div');
3436
+ head.className = 'ge-row-head';
3437
+ const name = document.createElement('span');
3438
+ name.textContent = row.label;
3439
+ const val = document.createElement('span');
3440
+ val.className = 'ge-val';
3441
+ head.append(name, val);
3442
+ const input = document.createElement('input');
3443
+ input.type = 'range';
3444
+ input.className = 'ge-slider';
3445
+ input.dataset.ge = `menu-item-${row.id}`;
3446
+ input.min = String(row.min);
3447
+ input.max = String(row.max);
3448
+ input.step = String(row.step);
3449
+ input.disabled = row.disabled;
3450
+ const paint = (v) => {
3451
+ input.value = String(v);
3452
+ val.textContent = row.format(v);
3453
+ };
3454
+ paint(row.get());
3455
+ input.addEventListener('input', () => {
3456
+ const v = Number(input.value);
3457
+ val.textContent = row.format(v);
3458
+ row.set(v);
3459
+ });
3460
+ updaters[row.id] = (v) => {
3461
+ paint(Number(v));
3462
+ reposition();
2914
3463
  };
2915
- body.appendChild(slider('master', host.t('Master volume')));
2916
- body.appendChild(slider('music', host.t('Music')));
2917
- body.appendChild(slider('sfx', host.t('SFX')));
2918
- // Live-update sliders when volume changes via host.setVolume (shell clears on close).
2919
- host.setVolumeRefresh((key, v) => updaters[key]?.(v));
2920
- // Game info — full-width row button that opens its own overlay
2921
- const gameInfo = document.createElement('button');
2922
- gameInfo.className = 'ge-ov-row';
2923
- gameInfo.dataset.ge = 'game-info-btn';
2924
- gameInfo.style.marginTop = '6px';
2925
- gameInfo.innerHTML = `<span style="width:22px;font-size:22px">${icon('info')}</span><span class="ge-grow">${host.t('Game info')}</span><span style="width:20px;font-size:20px;color:var(--shell-muted)">${icon('chevronRight')}</span>`;
2926
- gameInfo.addEventListener('click', () => { root.remove(); host.actions.openInfo(); });
2927
- body.appendChild(gameInfo);
2928
- return root;
3464
+ el.append(head, input);
3465
+ return el;
2929
3466
  }
2930
3467
 
2931
3468
  /** Default order key for the auto-injected hotkeys section: just after `controls` (-1). */
@@ -2935,7 +3472,7 @@ function openGameInfoModal(host) {
2935
3472
  const { root, body, scroll } = createOverlay({
2936
3473
  title: host.t('Game info'),
2937
3474
  onClose: () => host.actions.closeOverlay(),
2938
- onBack: () => { root.remove(); host.actions.openSettings(); },
3475
+ onBack: () => { root.remove(); host.actions.openMenu(); },
2939
3476
  });
2940
3477
  root.dataset.ge = 'info-modal';
2941
3478
  const rawSections = host.config.gameInfo.sections ?? [];
@@ -3908,7 +4445,11 @@ class HtmlRenderer {
3908
4445
  ro = null;
3909
4446
  moneyAnims = [];
3910
4447
  modalOnKey;
4448
+ popoverPosition = null;
3911
4449
  destroyed = false;
4450
+ /** The scale factor last applied to the bar by applyFitScale() — exposed so the menu popover can
4451
+ * match it exactly (see getBarScale) rather than re-derive its own, possibly-disagreeing, value. */
4452
+ barScale = 1;
3912
4453
  /** MutationObserver for buy-bonus confirm fit — fires fitModals() when nodes are added
3913
4454
  * inside the modalHost (e.g. the confirm dialog appended after the grid is open). */
3914
4455
  mutObs = null;
@@ -3951,6 +4492,14 @@ class HtmlRenderer {
3951
4492
  this.barHost.innerHTML = '';
3952
4493
  this.barHost.appendChild(renderBottomBar(this.host));
3953
4494
  this.applyFitScale();
4495
+ // renderBar() runs on every resize AND on ~20 other state changes (bet/win/turbo/mode/…), any of
4496
+ // which can change barScale and/or the plate rect (e.g. a WIN pill appearing mid-autoplay
4497
+ // retriggers the overflow-tightening branch). Only the resize hook used to reposition an open
4498
+ // popover, so a live bar-content change while the menu was open left the card at the stale
4499
+ // scale/position until the next resize. `popoverPosition` only reads plate/pointer/scale getters
4500
+ // and writes card styles — no path back into renderBar() — so this cannot recurse; it's `null`
4501
+ // whenever no popover is open (or a different overlay kind is), so this cannot throw either.
4502
+ this.popoverPosition?.();
3954
4503
  }
3955
4504
  setLayout() {
3956
4505
  this.renderBar();
@@ -3970,11 +4519,9 @@ class HtmlRenderer {
3970
4519
  }
3971
4520
  closeOverlay() {
3972
4521
  this.modalOnKey = undefined;
4522
+ this.popoverPosition = null;
3973
4523
  this.modalHost.innerHTML = '';
3974
4524
  }
3975
- refreshSoundIcon(_on) {
3976
- // Settings registers via host.setSoundRefresh; nothing extra here
3977
- }
3978
4525
  destroy() {
3979
4526
  if (this.destroyed)
3980
4527
  return Promise.resolve();
@@ -3995,6 +4542,10 @@ class HtmlRenderer {
3995
4542
  }
3996
4543
  /** Trigger a bar fit-scale pass (used by tests that stub geometry after the initial render). */
3997
4544
  fitBar() { this.applyFitScale(); }
4545
+ /** The scale factor applyFitScale() last applied to the bar — the menu popover multiplies its own
4546
+ * card by this SAME number so its typography/padding/row-heights carry the same visual weight
4547
+ * relationship the bar has, instead of ignoring the viewport like a fixed-px card would. */
4548
+ getBarScale() { return this.barScale; }
3998
4549
  // ── private ────────────────────────────────────────────────────────────────
3999
4550
  cancelMoneyAnims() {
4000
4551
  for (const cancel of this.moneyAnims)
@@ -4003,8 +4554,9 @@ class HtmlRenderer {
4003
4554
  }
4004
4555
  buildOverlay(req) {
4005
4556
  switch (req.kind) {
4006
- case 'settings': {
4007
- const root = openSettingsModal(this.host);
4557
+ case 'menu': {
4558
+ const { root, position } = openMenuPopover(this.host, this.root, () => this.getBarScale());
4559
+ this.popoverPosition = position;
4008
4560
  return { root };
4009
4561
  }
4010
4562
  case 'gameInfo': {
@@ -4048,6 +4600,7 @@ class HtmlRenderer {
4048
4600
  this.modalHost.appendChild(el);
4049
4601
  this.modalOnKey = onKey;
4050
4602
  this.fitModals();
4603
+ this.popoverPosition?.(); // measure + place now that the card is in the DOM
4051
4604
  }
4052
4605
  /** Uniformly scale every open centred card modal (.ge-sheet) down so it fits a short/narrow
4053
4606
  * popout. Covers pickers, generic + replay modals, AND the buy-bonus confirm (which is hosted
@@ -4098,13 +4651,18 @@ class HtmlRenderer {
4098
4651
  for (const row of Array.from(bar.children))
4099
4652
  need = Math.max(need, row.scrollWidth);
4100
4653
  const avail = bar.clientWidth;
4654
+ let s = 1;
4101
4655
  if (need > avail + 1 && avail > 0) {
4656
+ s = Math.max(0.4, avail / need);
4102
4657
  host.style.transformOrigin = 'bottom left';
4103
- host.style.transform = `scale(${Math.max(0.4, avail / need).toFixed(4)})`;
4658
+ host.style.transform = `scale(${s.toFixed(4)})`;
4104
4659
  }
4660
+ this.barScale = s;
4105
4661
  return;
4106
4662
  }
4663
+ let sApplied = 1;
4107
4664
  const zoomBar = (z) => {
4665
+ sApplied = z;
4108
4666
  const v = z < 0.999 ? z.toFixed(4) : '';
4109
4667
  const set = (el) => {
4110
4668
  if (!el)
@@ -4124,6 +4682,7 @@ class HtmlRenderer {
4124
4682
  if (bar.scrollWidth > bar.clientWidth + 1 && bar.scrollWidth > 0) {
4125
4683
  zoomBar(s * (bar.clientWidth / bar.scrollWidth));
4126
4684
  }
4685
+ this.barScale = sApplied;
4127
4686
  this.fitReadouts();
4128
4687
  }
4129
4688
  /** Unified number-fit: shrink EVERY readout's value span (`.ge-rd-val`) with a transform-scale so
@@ -4153,6 +4712,7 @@ class HtmlRenderer {
4153
4712
  this.host.notifyResize(w, h);
4154
4713
  this.applyFitScale();
4155
4714
  this.fitModals();
4715
+ this.popoverPosition?.(); // re-place the card if the surface itself resized
4156
4716
  });
4157
4717
  this.ro.observe(this.root);
4158
4718
  }
@@ -4176,5 +4736,5 @@ function removeGameShell() {
4176
4736
  return shell.destroy();
4177
4737
  }
4178
4738
 
4179
- export { DEFAULT_ACCENT, ShellController as GameShell, HtmlRenderer, PACKAGE_VERSION, SCHEMES, ShellController, createGameShell, createI18n, createShell, normalizeLang, removeGameShell, resolveConfig, resolveTheme, socialize };
4739
+ export { DEFAULT_ACCENT, DEFAULT_MENU, ShellController as GameShell, HtmlRenderer, PACKAGE_VERSION, POPOVER, SCHEMES, ShellController, createGameShell, createI18n, createShell, isPresetId, normalizeLang, placePopover, popoverWidth, rangeBounds, removeGameShell, resolveConfig, resolveMenu, resolveTheme, seedMenuValues, socialize };
4180
4740
  //# sourceMappingURL=html.esm.js.map