This weekend I learnt what temperature actually is. It is a measure of the activity of molecules. As they bang together as a consequence of an energy source, they release energy of their own. This is why it gets colder as you rise. There are less molecules (the air is less dense) so they are less likely to bang into each other, so less heat is released, so it is colder.