If you obtain a new gem and don't have space for it in the inventory, there are three possible scenarios:

1. If the new gem is less valuable than any of your current gems, it is automatically sold and you receive gold instead.

2. If the new gem is more valuable than any of your current gems, the lesser gem is sold, and the new one takes its place.

3. Now, if your totem is broken, it will still have one slot for your gem. So even if your inventory is full, you can carry the gem over to your next totem!

You can also increase the inventory capacity by purchasing more gem slots.