Gyrokinetic theory is based on an asymptotic expansion in the small parameter $\epsilon$, defined as the ratio of the gyroradius and the characteristic length of variation of the magnetic field. In this article, this ordering is strictly implemented to compute the electrostatic gyrokinetic phase-space Lagrangian in general magnetic geometry to order $\epsilon^2$. In particular, a new expression for the complete second-order gyrokinetic Hamiltonian is provided, showing that in a rigorous treatment of gyrokinetic theory magnetic geometry and turbulence cannot be dealt with independently. The new phase-space gyrokinetic Lagrangian gives a Vlasov equation accurate to order $\epsilon^2$ and a Poisson equation accurate to order $\epsilon$. The fi...