How to keep Z axis at zero

Hello. I am trying to make a 2d Car game where you tilt the car left and right to avoid obstacles. I am trying to be able to tilt it only on the x axis. Any time I tilt the device the car moves on the z axis and the y axis. Please help friends.:

using UnityEngine;
using System.Collections;

public class carController : MonoBehaviour {
public float CarSpeed;
public float maxPos = 2.2f;

void Update () 
{

		
	

	transform.Translate (Input.acceleration.x, 0, +Input.acceleration.x);
	
}

}

Rigidbody component has a freeze rotation field that allows you to specify which axis to rotate/freeze. If you are not using physics, then you have to set the rotation by yourself. Something like:

transform.rotation = Quaternion.Euler(transform.euler.x, 0.0f, 0.0f);