Rotating on Z (roll) affects the object's local X and Y axes. When you roll (tilt on the Z-axis), your local right (Vector3.right) and up (Vector3.up) directions change. This makes your mouse look behave unexpectedly because it's based on local axes, which are no longer aligned with world space. Mouse look rotates in local space, so when tilted, X and Y behave differently. It is better to use Quaternions instead of separate euler rotations.
Quaternion currentRotation = transform.rotation;
// Apply rotation based on world space (avoiding local axis issues)
Quaternion yRotation = Quaternion.Euler(0, rotationY, 0); // Yaw (left-right)
Quaternion xRotation = Quaternion.Euler(rotationX, 0, 0); // Pitch (up-down)
// Apply new rotation while preserving Z-axis roll
transform.rotation = yRotation * currentRotation * xRotation;
Instead of applying Rotate() separately for each axis, this creates a single new rotation using quaternions. Please reply to this comment for further queries I will try my best to help. And Notify me if the problem has been solved I will be grateful. I apologize in advance if I was unable to understand the scenario to maximum detail.