How can I get the phone orientation?

I need to know the phone orientation of the phone , but only the axis in the plane of the screen. I don’t need the axis perpendicular to the screen (Z).
attitude gives the global orientation, but if I extract euler angles from here they are affected by the Z axis orientation.

I only need X and Y angles referenced to the horizontal.

How can I achieve this? Any operation with the quaternion to change the reference?

Thanks in advance.

I think you have to use Input.gyro.attitude.

Thanks thothoww. I think this is the way, but like I said before, input.gyro.attitude is a global orientation and I need the orientation referenced to the horizontal.
I made some test measuring the euler x,y,z from attitude and when you turn the phone in the z axis, the x and y euler angles are also affected.

Hey ManuelJOrtega, have you ever found a solution to this?
I also need exactly this (but also without bias of forces).