Change box color based on content

Hello.
There is a box with text. It’s tied to a database. If the text contains “loss”, then the box is red, and if “win”, then the box is green. How can this be done? What code should be written?

I think this one might help: