You don't need any trigonometry at all, just division.

Imagine the diagram below is a phone kept flat with screen pointing up, and you're looking at the screen directly vertically down.

Documentation is

here.

From observations, accelerometer values for a stationary phone that is tilted are:

- phone is flat with screen pointing up: x=0, y=0, z=+g (g = accel due to gravity, ~9.8)

- BC is tilted down towards the floor 45 degrees clockwise so that AD moves up (ie, clockwise rotation around y-axis): x = -g/2, y=0, z=+g/2

- BC is tilted down towards the floor 90 degrees clockwise so that AD is directly above it (clockwise rotation around y-axis): x = -g, y=0, z=0

- AD is tilted down towards the floor 45 degrees counterclockwise so that BC moves up (ie, CCW rotation around y-axis): x = +g/2, y=0, z=+g/2

- AD is tilted down towards the floor 90 degrees counterclockwise so that BC is directly above it (CCW rotation around y-axis): x = +g, y=0, z=0

- AB is tilted down towards the floor 45 degrees clockwise so that DC moves up (ie, clockwise rotation around x-axis): x=0, y=-g/2, z=g/2

- AB is tilted down towards the floor 90 degrees clockwise so that DC moves directly above it (ie, clockwise rotation around x-axis): x=0, y=-g, z=0

- DC is tilted down towards the floor 45 degrees counterclockwise so that AB moves up (ie, CCW rotation around x-axis): x=0, y=+g/2, z=g/2

- DC is tilted down towards the floor 90 degrees counterclockwise so that AB moves directly above it (ie, CCW rotation around x-axis): x=0, y=+g, z=0

So you can see that 45 degree angle corresponds to g/2 (I can see it's approximate; not sure why - but probably good enough for a game). You can use simple proportion of measured value / g to get angles.