Each level attempt costs one energy. Your energy replenishes automatically over time, with one energy refilling every hour. Keep in mind that you can store a maximum of 10 energies at once. If your energy level is full at 10, no additional energies will accumulate until you use some by playing levels.