Good question re: what is a closet. The panel may go in a "utility closet" but not in a "clothes closet". If it has closet rods, it's a clothes closet. Do not install shelving above or below the panel (see below).
A few other details in the NEC about locating panels have to do with what's called "working space". The purpose of working space is to ensure a safe working environment above, below and in front of the panel, free of obstacles:
Measured from the back of the panel, there must be at least 36" in front of the panel where a worker can stand. That space also has to be a minimum of 30" wide to allow room for your shoulders and arms. This 36" x 30" (minimum) space extends from floor to ceiling. No other obstacles should be in that space, so no pipes, ducts, etc. Also, don't fasten a workbench underneath the panel. A worker shouldn't have to kneel on a workbench or reach around obstacles to do panel work. It is okay to store things in that space so long as they can easily be moved out of the way. The top breaker in the panel must be no higher than 6'6" above the floor so short people like me can reach it without standing on a ladder or chair. Isn't this fun?!
So, if you build a utility closet for your panel, and the closet is only 2' deep, the panel can go on the back wall, opposite the doorway. If the doorway is at least 30" wide, then you've satisfied the requirements. One more thing I just remembered, any room with electrical equipment must have a light.
Cheers! Mike