Axions are hypothetical particles that may explain the observed dark matter (DM) density and the non-observation of a neutron electric dipole moment. An increasing number of axion laboratory searches are underway worldwide, but these efforts are made difficult by the fact that the axion mass is largely unconstrained. If the axion is generated after inflation there is a unique mass that gives rise to the observed DM abundance; due to nonlinearities and topological defects known as strings, computing this mass accurately has been a challenge for four decades. Recent works, making use of large static lattice simulations, have led to largely disparate predictions for the axion mass, spanning the range from 25 microelectronvolts to over 500 microelectronvolts. In this work we show that adaptive mesh refinement (AMR) simulations are better suited for axion cosmology than the previously-used static lattice simulations because only the string cores require high spatial resolution. Using dedicated AMR simulations we obtain an over three order of magnitude leap in dynamic range and provide evidence that axion strings radiate their energy with a scale-invariant spectrum, to within $sim$5% precision, leading to a mass prediction in the range (40,180) microelectronvolts.