iPhone 12 Pro Max overheating
i got a brand new iPhone 12 Pro max purchased on January 3rd 2021. I got all the necessary cables and plug from Apple shop itself to make things easier and no conflict regarding charging. Only yesterday that while using it that it got so hot. It displayed a message regarding its temperature then shut off by itself. I also charged it this morning at when it reached 50%, it got hot again and displayed the same message as yesterday and stopped charging by itself. What should I do best? Need your help badly... Thanks in advance
iPhone 12 Pro Max, iOS 14