- Clamp ops, trust, compute to >= 0 in tick() to prevent negative
values from Fenrir drain and debuff effects
- Add keyboard focus trap to tutorial overlay for accessibility
(prevents Tab from escaping the dialog)
- Clean up focus trap handler on tutorial close
- Add isEndgame() helper to detect endgame conditions
- Skip non-ReCKoning project activation in checkProjects() during endgame
- Filter out non-ReCKoning projects in renderProjects() during endgame
Closes#128, closes#130
Tooltips now show three lines: name (bold), description (gray),
and educational text (italic). Previously only showed name + edu,
leaving building functional descriptions hidden.
Part of #57
BUG-08: Add null check on closest('.res') in renderResources to
prevent TypeError if DOM structure is unexpected.
BUG-11: Add role='dialog', aria-modal='true', aria-label='Tutorial'
to tutorial overlay. Add aria-label to Skip and Next buttons for
screen reader accessibility.
Smoke test: all 19 checks passed.
Implements Reasoning Battles — a Paperclips-inspired canvas combat system
where structured reasoning (blue) fights adversarial testing (red) using
boid flocking (cohesion, aggression, separation) on a 310x150 grid.
Features:
- Boid flocking AI for ship movement
- Grid-based combat resolution with OODA loop speed bonus
- Napoleonic War battle names
- Auto-trigger battles scaled to drift and phase
- Battle history log
- Rewards: structured wins = knowledge, adversarial wins = code
- Unlocks at Phase 3
- Integrated into tick loop and render pipeline
Saves lastSaveTime timestamp. On load, calculates elapsed time
and awards 50% efficiency production. Shows summary toast.
Min 30 seconds away to trigger.
Visual Identity Pass:
- Smooth phase transition overlay with staggered fade-in animation and particle burst
- Building purchase confetti at x10 milestones (gold + green particles)
- Animated resource counters (pulse on gain, shake on loss) - already existed, verified working
Ending Cinematic Enhancement:
- Beacon ending: fade-to-black transition, staggered text reveal, golden light rays,
continuous floating particles, expanded stat summary, 'Play Again' button
- Drift ending: glitch animation on title, fade-in overlay, stat summary with
buildings/projects/clicks/time/phase, dramatic line-by-line log reveal
Accessibility (#57):
- Sound mute toggle button (M key) with localStorage persistence
- High contrast mode toggle (C key) with CSS variable overrides
- Both toggles in fixed bottom-left toolbar with aria-labels
- Keyboard shortcuts M and C added, help overlay updated
- Drift ending button changed to 'Play AGAIN' with proper aria-label
Adds DOM-based particle burst animations when buying buildings and
completing research projects. Blue particles for buildings, gold for
projects. Lightweight CSS animation with no external dependencies.
Refs #57 — Night of Polish, Task 1 (Visual Identity)
Replace native browser title= tooltips with styled custom tooltips
that match the game's dark theme. Tooltips appear instantly on hover
with building/project name and educational content.
- Add CSS for #custom-tooltip with dark theme styling
- Add tooltip div to HTML body
- Add event delegation in main.js for [data-edu] elements
- Convert renderBuildings and renderProjects to use data-edu
and data-tooltip-label attrs instead of title=
- Tooltip follows cursor with screen-edge clamping
Refs: Epic #57 — Night of Polish, Task 4 (Tooltip system)
- Add CSS keyframes: res-pulse (scale up + blue flash) and res-shake (horizontal shake + red flash)
- Track previous resource values in _prevRes object
- Detect gain/loss on each renderResources() call and trigger appropriate animation
- Add rate color coding: green for positive, red for negative, dim for zero
- Clean up animation classes after 400ms to allow re-triggering
- No external dependencies, pure CSS + vanilla JS
- Remove duplicate clipboard/prompt-based exportSave/importSave from utils.js
(render.js file-based versions were already overriding them)
- Add toast notifications for export success and import errors
- Add isValidSaveData() with robust validation (checks totalCode, code, buildings, phase)
- Prevent duplicate file dialogs on rapid E key presses
- Clean up file input element when user cancels dialog
- Add toast for JSON parse errors on import
Auto-save game state when the browser tab is hidden (visibilitychange)
or closed/navigated away (beforeunload). Prevents data loss on mobile
where tab switching can kill the page without a save interval firing.
Part of epic #57 Night of Polish — Task 6: Mobile Polish.
playTime was defined in globals but never incremented and never
included in save/load. Now incremented each tick and persisted
in localStorage via the whitelist and save data.
applyFn was multiplying G.codeBoost by 0.7 on every updateRates() call
(building purchase, project, click, etc.), permanently degrading it.
After 10 calls the boost was effectively zero.
Fix: apply penalty to G.codeRate (computed per-tick) instead of
G.codeBoost (persistent multiplier). Debuffs must never mutate boost state.
Part of #57 — Task 4: Tutorial & Onboarding
- 5 click-through screens introducing game concepts (code, buildings,
research, phases, keyboard shortcuts)
- Skip button on every screen, keyboard support (Enter/Escape/arrows)
- Stores completion in localStorage — only shows once for new players
- Matches existing visual style (dark theme, accent colors, monospace)
- Start Playing button on final screen with shortcut hint (? overlay)
- index.html: role=region on phase-bar, strategy-panel; role=dialog+aria-modal on help overlay, offline popup, drift ending; aria-label on help button, close button, continue button, start over button; aria-live on progress label
- render.js: aria-label on alignment event buttons; fix exportSave() URL revoke race with setTimeout delay
- engine.js: aria-label+aria-pressed on buy amount buttons; role=button+tabindex+aria-expanded+aria-controls on completed projects header
- Building rate display now shows actual boosted rates (after multipliers)
instead of raw base rates, so players see their real production
- WRITE CODE button area now displays current click power dynamically
(updates each render tick as boosts change)
- Click power also reflected in button aria-label for accessibility
Closes#61