How to avoid Gimbal Lock on a camera facing a ball rolling on a spherical planet

Hello! I am making a game where there is a spherical planet maze where the player has to move a ball from one area to another. I have implemented radial gravity already and have set up a camera to follow the ball, but whenever the ball reaches the top or bottom of the planet, the camera experiences gimbal lock and everything rotates around.

I have been researching the heck out of quaternions but I am unsure how to implement them in a way that the camera is always facing directly at the ball towards the center of the planet. Does anyone have any ideas?

Thanks a bunch in advance!

I’m experiencing a similar issue, have you or anyone else found a solution?