Here's the updated CSS that should work on the latest Flarum version. It will "invert" the text color based on the background. However, this may still produce unreadable colors in some edge cases (colors that have equal/similar RGB values, I think - because inverted equality equals the previous equality, e. g.: pure grey color). So, you should probably adjust the color property to be always readable, according to your tags color schema:
.TagHero .Hero-title {
color: #ffffff;
mix-blend-mode: difference; /* remove this line if you want the text to be always white, regardless of background */
}