I bought a thing as a solution for exactly same problem. Don’t want to tell a specific brand, because IDK if it’s allowed here.
Essentially they send you a physical device with NFC inside. You use their app to put a phone in distraction free mode and the only way to unblock it is to tap the object.
It helped me a lot with my social media addiction. Probably, the best investment I ever made.