After you clear Aquatic Base, head to a computer or the store clerk. That's where you buy the gems, and fair warning, they're pretty pricey.
A good strategy is to finish Sonic's story first, then replay the last portion to farm more money and rings. That way you can afford the gems without running dry.