According to the Oxford English Dictionary, gender is defined as "Either of the two sexes (male and female), especially when considered with reference to social and cultural differences rather than biological ones."
So while gender pertains to the characteristics of a person and sex is the biology, there are still only two.
A man may have effeminate characteristics or traits, but they are still male. Likewise, you can have a masculine woman who has qualities or appearance traditionally associated with men, but they are still a biological female.