Not sure how it is 2022 & people still forget that for HTML, CSS & JavaScript they can create a JSBin, JSFiddle or plunkr to show their code running.
Here I created a jsbin that has your code plus some additional behavior.
Is this what you're looking for:
JS Bin - Collaborative JavaScript Debugging[
^]
If you run the code and change the transition to 0s you will see that the background color changes instantly from yellow to green & green to yellow (no fading).