Modes of a twisted optical cavity