Trying to identify time period, soldier rank and war for this ancestor who live 1876-1918. Probably served in Austria Hungarian war. He was a Croat. It appears that the uniform is dark navy?
He was clearly was an officer of the infantry given the sleeves, hat and sword. From the sleeves, he looks to be a Lieutenant (or possibly a 2nd Lieutenant, it's hard to tell whether he has one or two gold braids on the sleeve).
You are correct about the time period, the uniform he is wearing were worn from about 1900 to 1913