Yes, at the time of the civil war, the color of the trim on a uniform indicated the branch of service:
Infantry = light blue
Cavalry = yellow
Artillery = red
Medical Corps = green
We know that your young soldier's light-colored pants were a light-to-medium blue. In the black-&-white photo, the jacket's sleeve trim seems to be the same shade as the pants.... while the lapel trim and collar stripes seem just a bit darker. So, the jacket could be for either Infantry or yellow for Cavalry. Red would be even darker in a black-&-white photo.
I must comment that there seems to be THREE collar-insignia stripes, which (IIRC) signifies the rank of Captain. Even during the civil war, it seems unlikely that anybody under 18 could achieve that rank, even by a battlefield promotion for extreme valor. If so, there surely would be some historical documentation of such an event and that amazing promotion.