Dopamine is why you couldn’t sleep. Dopamine is the expectation of a reward. You had good reason to expect reward the instant you regained consciousness. (Yay for your app and your win!) Dopamine creates the excitement that gets us to take action to meet our needs. Habit causes us to wake up and dopamine makes it hard to get back to sleep.
Simple answer : take a nap later on if you have a sleep deficit!
Of course, when you don’t get rewards, your thoughts can turn dark, which can trigger stress chemicals that make it hard to sleep. The inbetween position is great — I call it neutral. Imagine a monkey who has confidence in their ability to find bananas tomorrow but doesn’t feel the need for a banana right now.