The clump of all-white wires is actually neutral. The lamp actually needs neutral, and neutral must be white. Add it to the clump.
Now let's talk about color codes. You may think that the colors of wires are for the sole purpose of helping novices wire things up. I have an alternate theory for you. Go down to the building supply and look at all the different kinds of cables, especially the variety of color combinations available. There isn't any. Variety. All cables are black-white, or black-white-red. So clearly, this is a standard of manufacture, and every installation is forced to use the same colors!
So outside of "neutral is white", colors aren't a lot of help. White isn't even necessarily neutral. Now that's debunked, this gets a bit clearer.
- the red wire is an orphan.
- the fan was connected to the red wire previously, and nothing was connected to the black cluster.
Based on both facts, the lamp black needs to go to the solo red.