Rough–flat–rough transition of crystal surfaces