How can I change the position of a menu based on the screen's tilt?

In my game, I wanted to tilt the pause menu depending on the camera tilt angle in Godot 4.

I’ve already written the code to tilt the screen according to the mouse cursor position, but I’d like to tilt the menu in the game depending on the phone tilt position (accelerometer). How can I implement my idea?

Code:

var menu_max_travel := 15
var center_of_screen := Vector2.ZERO
func _process(_delta: float) → void:
var dist_to_mouse = ((get_global_mouse_position() - center_of_screen) * -1).limit_length(menu_max_travel)
global_position = lerp(global_position, dist_to_mouse, _delta * 2 )

You can get the accelerometer values with Input.get_accelerometer() the gyroscope with Input.get_gyroscope() and the gravity with Input.get_gravity()