Caffeine works primarily by blocking the action of a neurotransmitter called adenosine, which promotes sleep and relaxation. This leads to increased neuronal firing and the release of other neurotransmitters like dopamine and norepinephrine, which enhance alertness and mood. However, excessive caffeine intake can lead to side effects such as insomnia, increased heart rate, and anxiety.