First of all, you might have needed a little more after staying up that long, or have a headache from another (possibly related, like water intake, or screen-time-related) source.
Secondly, people have something called a circadian rhythm, which is basically an internal clock that tells you when to be tired and when not. The circadian rhythm can be shifted and for most people isn’t exactly 24h anyway, but shifting it takes some more time than just one night. Another way too see it do its thing is jetlag, some people take more than a week to get accustomed to a new time zone.
Latest Answers