All your accumulated energy is saved and can be used in the future. However, the excess energy doesn't affect the maximum supply. Spent energy is only restored to the edge of the counter, no more.
Energy that you accumulate above the maximum energy is saved after you upgrade your experience level and get a larger energy counter.