When I shift to the smallest cog, it's suddenly too loose
Check your cassette is on properly. The smallest rear sprocket spinning around sounds like it is not on the freehub and spinning freely between the frame and the freehub.

There is a lockring on the outermost of the cassette which fastens the cassette to the freehub on the wheel. The cassette has notches machined out of it to match the freehub body and allow engagement.

If the lockring comes loose - the smallest cog may pop-off the freehub and not be engaged at all. You should be able to see this but you will also have a wobbling cassette.