Original prompt
Act as an expert software engineer specializing in simulation algorithms and 2D grid graphics. Build a Slime Mold Pathfinding simulation as a single self-contained HTML file using vanilla HTML, CSS, and JavaScript only - NO external libraries. Agents explore a perfect maze from a fixed start tile toward a fixed goal tile while depositing scent, so over time a visible reinforced trail emerges between S and G. Visuals: a cohesive dark dashboard with centered canvas and a control panel containing a Regenerate Maze button (builds a new maze and resets the simulation), a Reset Agents button (clears scent and respawns agents without changing the maze), and a stats readout showing agent count, tick count, and how many agents have arrived at the goal this run. Canvas fixed at 500x500 pixels with image-rendering: pixelated and an internal grid of exactly 50x50 cells (10x10 pixels each). Colors: background/floor #1a1a2e, walls #4a4e69, start tile #2a9d8f, goal tile #e76f51, agents bright green #55ff33 dots, plus a translucent warm scent heat overlay (yellow through orange to red by intensity) so the emerging trail is clearly visible. Maze: recursive backtracker (or equivalent perfect-maze algorithm) on the odd-sized grid so walls form coherent corridors; start sits near the top-left region and goal near the bottom-right region, both always floor tiles with a valid route between them. Simulation rules to implement exactly: keep two 2D arrays - grid (wall/floor/start/goal) and scent (non-negative floats). Run exactly 40 agents, all spawned on the start tile. Each tick decay runs FIRST: multiply every cell's scent by 0.90 across the full grid. Then each agent moves exactly one cell orthogonally (no diagonals, never into walls); agent processing order is shuffled every tick. After moving, an agent deposits 0.8 scent ONLY on the cell it left, never the entered cell, and scent on the start tile is clamped to a maximum of 2.0. An agent reaching the goal is removed from the active set and increments the arrived counter. Movement choice per agent: track previousX/previousY; build candidate orthogonal in-bounds non-wall neighbors; if two or more candidates exist remove the previous cell (anti-backtracking), restoring all candidates if that empties the list (dead-end exception); with probability 0.15 pick uniformly at random among candidates (exploration); otherwise weight each candidate by max(0, scent[candidate] - scent[current]) + 0.05 - the gradient, not raw neighbor scent - and pick by weighted random with uniform tie-breaks. Drive everything from requestAnimationFrame or a ~30 fps timer, running continuously until reset. Do not use pathfinding libraries or precomputed shortest paths - the route must emerge purely from agent behavior. SCORING & STATS (REQUIRED): The simulation MUST track meaningful statistics and persist its best/run stats (e.g. fastest solve ticks, best explored percent, best population) to localStorage so they survive restarts; load and display them on startup. SUCCESS CRITERIA: the page must (1) generate a fresh recursive-backtracker perfect maze with a guaranteed start-to-goal route and render it on the 500x500 canvas, (2) simulate exactly 40 agents with orthogonal-only moves, shuffled per-tick order, one-sided 0.8 scent deposit on the departed cell, start-scent cap 2.0 and x0.90 full-grid decay before movement, (3) choose moves via gradient weights max(0, scent[neighbor]-scent[current])+0.05 with anti-backtracking and a 15% uniform exploration roll, (4) show live agent/tick/arrived stats with Regenerate Maze and Reset Agents controls wired correctly, and (5) auto-start / render its initial state without any user gesture so the headless renderer captures a non-blank frame. OUTPUT FORMAT: Respond with the COMPLETE, self-contained HTML document in ONE single ```html code block. Do NOT split the code across multiple blocks, do NOT include a thinking summary inside the block, and do NOT place any prose, explanation, or comments between the opening and closing of the code block. The entire document (doctype through </html>) must be inside one fenced code block so it can be extracted and rendered verbatim. OUTPUT REQUIREMENT: Respond with ONLY the raw, runnable source code in a single fenced code block, with the first line starting at column 0 (no leading indentation). Do not include any thinking, explanation, summary, or prose before or after the code, and keep comments inside the code minimal.