Theme color in template cards

I’m using some Mushroom Template Cards and vary icon color based on state. Now I’ve hardcoded colors in their hex values, which works, but is not optimal when using light / dark mode.

How can I get the colors defined in the theme in a custom card, like Mushroom Template Card?