How much space do I need at the top of the stairs?
Yes, a landing is required at the top and bottom of residential stairs. The simple answer is it should be 36" in the direction of travel. (There is an "exception" to that, but does not apply to you. )

To solve your problem, (and I get points taken off my "reputation" for offering advice that doesn't stick to the question, but I'll offer it anyway...) try a 2 or 3 step winding step stair (pie-shaped treads) for the last few steps. Basically you're making a 90 degree "left-turn" at the top of the stairs. There are several requirements to those steps, which I'm not smart enough to figure out, but basically each step should not be less than 6" wide "where you walk". Where-you-walk is defined as a point 12" from the narrowest point of each step... Oh, the widest depth of a "winder " step can't be more than 12" at furthest point out...

Don't forget the handrail (mount between 32" and 38" from nosing of each step.) Handrails in residential construction is required on one side of stair only.