How to Stop Camera From Rotating when x,y,and z is equal to 90 degrees

Here is my code i need to stop the camera from rotating when its 90 degrees

 public float borderthickness = 10f;
    public float cameramovespeed = 10000f;
    

    // Update is called once per frame
    void Update()
    {
        Quaternion pos = transform.rotation;

  
            if (Input.mousePosition.y >= Screen.height - borderthickness && pos.x < 90f)
            {
                pos.x -= cameramovespeed * Time.deltaTime;
               Debug.Log("up");

            }
           if (Input.mousePosition.y <= borderthickness && pos.x < 90f)
          {
            pos.x += cameramovespeed * Time.deltaTime;
   Debug.Log("down");
            
        }
        if (Input.mousePosition.x >= Screen.width - borderthickness && pos.y < 90f)
        {
            pos.y += cameramovespeed * Time.deltaTime;
            
   Debug.Log("right");
        }
        if (Input.mousePosition.x <= borderthickness && pos.y < 90)
        {
            pos.y -= cameramovespeed * Time.deltaTime;
               Debug.Log("left");

        }
        transform.rotation = pos;

Hello!

 public float borderthickness = 10f;
     public float cameramovespeed = 10000f;
bool canRotate = true;

     
 
     // Update is called once per frame
     void Update()
     {
         Quaternion pos = transform.rotation;
 
   
             if (Input.mousePosition.y >= Screen.height - borderthickness && pos.x < 90f && canRotate)
             {
                 pos.x -= cameramovespeed * Time.deltaTime;
                Debug.Log("up");
 
             }
             if (pos.x == 90f || pos.y == 90f)
{
canRotate = false;
}

You can add a bool called “canRotate” and do the changes I did above