How to lock z axis

Hey friends, I have a camera that I’m trying to set up with first person perspective using Input.GetAxis(“vertical”) and horizontal. So far it’s kind of working, but the camera appears to be rotating along the z axis (the direction it’s pointed towards) when I look around. What I’d like to do is stop this rotation around the z axis. Here’s my code:

if (zoomedIn)
{
    float h = Input.GetAxis("Horizontal");
    float v = Input.GetAxis("Vertical");
    if (v < -0.3f)
    {
        //Debug.Log("look down");
        cameraTransform.Rotate(Vector3.right, firstPersonLookSpeed * Time.deltaTime);
    }
    if (v > 0.3f)
    {
        //Debug.Log("look up");
        cameraTransform.Rotate(Vector3.right, -firstPersonLookSpeed * Time.deltaTime);
    }
    if (h > -0.3f)
    {
        //Debug.Log("look right");
        cameraTransform.Rotate(controller.transform.up, firstPersonLookSpeed * Time.deltaTime);
    }
    if (h < 0.3f)
    {
        //Debug.Log("look left");
        cameraTransform.Rotate(controller.transform.up, -firstPersonLookSpeed * Time.deltaTime);
    }
}

A way you could fix this is keep the x axis for moving you’re character but move the y axis onto the camera. This way, they don’t interfere with each other and you can just look up down left and right. It also keeps the player upright so if you also want that.

Also, you dont need to do the up down left right. You can just do something as simple as this

player script
public float speed = 10;
public float sensitivity = 5;

CharacterController characterController;

void Start()
{
    Cursor.lockState = CursorLockMode.Locked;
    characterController = GetComponent<CharacterController>();
}

void Update()
{
    float xRotation = Input.GetAxis("Mouse X") * sensitivity;
    transform.Rotate(0, xRotation, 0);
}

//camera script
public float sensitivity = 5;

void Start()
{
    
}

void Update()
{
    float yRotation = Input.GetAxis("Mouse Y") * sensitivity;
    transform.Rotate(-yRotation, 0, 0);
}

hope this helps!!