This is more of an issue with the way chat messages are currently designed, as they just follow the player exactly.
It will have to be redesigned to be adaptive similar to the library Popper: https://popper.js.org/
This means chat messages change their size and position dependant on their placement in the game, whether it's behind a DOM element or outside the sides of the game screen.

