I looked into it and this turned out to be the problem exactly.
If you change the part of your code where you have
hsl(${i*120} 99%${K*99}%
To instead
hsl(${i*120} 99% ${K*99}%
(That is, by not omitting the space after 99%)
Then it works in the versions of Safari that I tested; Safari 14.0.3 on macOS Big Sur 11.2.2 running on a MacBook Pro M1, and Safari on iOS 14.4 running on an iPhone X.