Sure! Here's an example of a single HTML file implementing the game you described. The game has a 1000x1000 grid, arrow buttons to move, and random red squares that appear at the edges and move towards the player. Clicking on red squares within 2 grids of the player deals damage and increases the score. When the player is touched by a red square, they lose 1 HP. The spawn rate of red squares increases over time, and the player gains 1 HP for each red square killed. The game resets on death.
Please note that implementing this type of game logic in a single HTML file can make the code quite long and difficult to maintain. It's usually recommended to split the code into separate files and utilize external libraries for better organization and maintainability.