Try:
A bit like a twin-stick shooter.
We shoot a (red) beam from the camera towards the mouse cursor projected into the 3d world, it will eventually intersect (yellow) a virtual horizontal plane (teal) at player’s depth, we find rotation from the player to that intersection (green):
This way you do not need to rely on level topology. Hope it helps.