The same thing just happened to me. I had youtube paused and other tabs open in safari, I was typing in the notes app at the time and it was plugged in to charge. I didn't move my screen to my knowledge although it was on my bed with me so it could move slightly.
The screen went black with very similar pink patches and square also in the bottom right corner. I unplugged it and hit the power off button. It restarted itself and displayed a message during startup which I could not catch.
Debugger message: Panic
Core 0 panicked.
It works completely fine still. It may have slight water damage from the past but is not to my knowledge effecting it.
Others describe this issue here too
https://discussions.apple.com/thread/252210055