Royal AM edge thriller with late goals