Card counting is a blackjack strategy based on tracking which cards have already been played. A shoe rich in tens and aces favours the player, so a counter keeps a running tally — commonly adding or subtracting one per card — and raises bets when the remaining cards look favourable.
It is not magic. Counting does not predict the next card; it only shifts the odds slightly, demands intense concentration and still produces losing sessions. Done well, it can turn the small house edge into a small player edge.
Counting in your head is generally not illegal, but casinos may ask counters to stop playing blackjack or to leave. Countermeasures include dealing from a shoe of several decks, cutting off a large part of the shoe, shuffling often or using continuous shuffling machines. Online RNG blackjack reshuffles every round, so counting has no effect there. A more advanced relative is shuffle tracking.