Blocking the movement of the gyroscope along the Y axis (Unity)


I’m making a game where by tilting my smartphone I can rotate an object in the z-axis. I made sure that the rotation is correct at different angles of the smartphone, but the problem is that if you pick up a smartphone and start turning around its axis, the angle of the object also changes. I’ve been looking for an answer on the Internet for several days, but have not found anything that would help. Is it possible to read only tilts along the z-axis and not count the movement of the smartphone along the y-axis (around its own axis)? I will be grateful for any help. I am stuck.

P.S. Similar behavior of the gyroscope in games like Traffic Racer and Traffic Rider, only when the smartphone is rotated, the object moves to the sides, and I need to rotate it.