2 of 3 deleted 17 characters in body

Perl 5, 96 + 1 (-p) = 97 bytes

@a=0..3*$_;@a[$d,$s]=@a[$s=$a[$_]+$a[$_-1],$d=abs$a[$_]-$a[$_-1]],push@r,$a[1]for 1..$_;$_=pop@r

Try it online!