Mana is obtained by playing the Mana Slot before each wave. The mana payout ranges from 1-3 at a time. There are 5 types of mana, each of which corresponds to the class of the same color. Only mana that corresponds to classes in your active party will come out of the Mana Slot. The maximum mana you can hold at one time is 8.
During a boss wave, Pirica will bring you a single mana, the type of which is determined in a similar fashion to the Mana Slot. The mana she carries is cycled through in a fixed order, making it feasible to "choose" mana if timed properly.