Spin dynamics in a two-dimensional quantum gas