Think of Spirit as your number of lives remaining in this game. When it reaches 0, you will incur a Game Over.
Spirit can be restored when you reach a new Episode of the Story or purchase it within the Credit Shop right here. It does not restore as time passes.
Typically you will lose Spirit whenever you fail to win a battle. There are, however, these exceptions:
You should never lose Spirit when failing the above types of battles.