Exothermic reaction is when the system releases energy to the surrounding, the energy (in the perspective of the system) will have a sign of negative, as the system is transferring energy towards the surrounding.
Endothermic reaction is when the system is absorbing energy from the surrounding, the energy (in the perspective of the system) will have a sign of positive, as energy is transferred to the system.
It gives off a certain colour because when the spectrum is combined........I'm not sure if that's write but i think it is.....not 100% sure tho