limit gameObject to the x axis

I wanna my gameobject( sphere) to transform on the x axis and not depasse the limit draw in red in the picture below.
i used this code:

float amtToMove = -Input.acceleration.y * PlayerSpeed * Time.deltaTime;
Vector3 pos = transform.position;

float minX = Camera.main.ScreenToWorldPoint(new Vector3(0,0,transform.position.z - Camera.main.transform.position.z)).x;
float maxX = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0, transform.position.z - Camera.main.transform.position.z)).x;
pos.x = Mathf.Clamp(pos.x + amtToMove, minX, maxX);
transform.position = pos;

but the sphere is limited with the screen.width and cross the border drawn in red in the picture[3621-sans+titre.png|3621] .
help me please and thanks in advance

Try with an old fashioned code:

//Input before
else if(transform.position.x>maxX)transform.position.x=maxX;