[UI fork, 23:55] Request (RAM): please let the kernel place the engine scratch. In evars.inc write
    if   ENG_SCRATCH_EXT
e_scratch = ENG_SCRATCH_EXT        ; the kernel's slot A (shared with screen overlays)
    else
e_scratch: rmb ENG_SCRATCH_SIZE
    endif
and define ENG_SCRATCH_SIZE with `=` (not inside the if) so the kernel can size slot A to max(overlays, scratch).
The kernel defines ENG_SCRATCH_EXT (0 = engine keeps its own; else an address) before including evars.inc.
Also: please keep e_lm (the eng_legal list) OUTSIDE the scratch — the board screen reads it between engine calls.
The kernel calls engine routines only from resident kernel code, so sharing with slot A is safe.

[UI fork, 00:02] RAM is the blocker. First build with the real engine (movegen only, search still to come):
  engine code+tables ~7.4K, engine vars ~2.0K + scratch 3,084 (its own: e_scratch is rmb'd, not shared),
  kernel+screens code 6.8K (I am cutting this to ~3K by moving the board UI into slot-A overlays),
  kernel vars 1.9K (cutting), TT >= 2K.  Before the TT: 22,976 bytes.
  The real ceiling for the whole array m%() on an empty LZ64 is about 20,980 bytes (Drakeloft measured it;
  the launcher itself needs ~1.15K of the 22.2K free). So: engine code+tables+vars+TT+slotA(>=scratch)+kernel <= ~21.0K.
  If the engine ends at ~10.5K code+tables + 2K vars, that leaves ~8.5K for slot A (>= your 3.1K scratch),
  TT (2K at 256 entries) and my kernel + vars (~3.4K) — just about possible, nothing to spare.
  Requests, in order:
   1. ENG_SCRATCH_EXT hook (see my first note) so the scratch IS slot A — saves 3.1K. Essential.
   2. e_lm OUTSIDE the scratch (screen overlays are loaded into slot A between engine calls).
      A separate 2*128-byte list would do (positions with >128 legal moves don't happen in games);
      eng_legal could stop at 128.
   3. Anything you can trim in engine vars/tables (e_khist size? Zobrist 3K -> generate at eng_init into... no gain;
      maybe 24-bit keys = 2.3K?). Every 0.5K is TT entries or margin.
   4. Please allow e_ttn = 128 (1K TT) as a fallback minimum.

[UI fork, 00:20] Budget after my restructure (board UI, clocks, book, saving now load into slot A between engine
calls; resident kernel 3.3K code + 1.9K vars incl. the 750-byte game record and a 256-byte copy of e_lm):
  build/game/budget.txt with --engine real: kernel+engine code 13,759 (engine ~10.5K code+tables already),
  variables 5,601 (engine ~3.8K of it, of which 3,084 is e_scratch, NOT shared yet), slot A 3,296.
  Hard ceiling for the array: ~20,980 bytes (I'll re-measure in the emulator). Fitting needs, roughly:
     engine code+tables <= ~11.0K, engine vars outside scratch <= ~0.7K, scratch shared with slot A (<= 3.1K),
     my kernel ~3.2K + vars ~1.7K, TT 256 entries (2K)  ->  ~21.0K. So search code has almost no room.
  Please: (1) honour ENG_SCRATCH_EXT (essential), (2) keep the engine (incl. search) within ~11K code+tables,
  (3) say if you can't, so I trim TT to 128 entries / the record to 100 moves each, and tell the user.
  I'll also cut the launcher by ~250 bytes (bootstrap poked into the array instead of an OPL string variable).

[UI fork, 00:35] MEASURED in the headless LZ64 (tests in build/memtest): FREE on an empty LZ64 = 22,246.
  Largest array my launcher can allocate and still start the game: ~21,500 bytes. The save file on A: (game
  record, ~850 bytes, fixed size) comes out of the same RAM, so the real ceiling for m%() is ~20,640.
  Today (real engine, your scratch NOT yet shared): 22,656 before the TT. If shared: ~19,570 before the TT.
  I will cut ~1K more on my side (game record moves to the A: file, slot A trimmed to your scratch size).
  Then TT 256 entries (2K) fits only if the engine stays at today's 10.6K code+tables and ~0.6K vars.
  I'm making the TT tiers 128 / 256 / 512 entries (1K / 2K / 4K) so it always runs.
  -> Still need ENG_SCRATCH_EXT, please. e_lm may stay in the scratch: I copy it after eng_legal.

[UI fork, 00:30] Timing granularity: at ~95 nodes/s, checking time/keys every 256 nodes = every ~2.7 s.
  A 2-second hint/draw look took >3 s in the emulator, level 1 (1 s) will overshoot ~2x, and "any key = move now"
  waits up to 2.7 s. Suggest: check TMW_FRAM (and KB$TEST? that's in think_poll) every 16-32 nodes, and call
  think_poll when the frame counter has moved >= 10 frames (0.5 s) since the last call, rather than by node count.
  Integration status: real engine builds and runs in the game (tests/ui/t_ui.js, t_game.js all pass: mate, result,
  promotion, SAN disambiguation, take back, levels, thinking display). RAM: TT 256 entries fits an empty LZ64.
