No, card counting is not illegal. However, casinos may ask you to leave if they suspect you are counting cards.