  We provide a systematic assessment of the order-$\alpha^5$ nuclear
contributions to the Lamb shift of muonic deuterium, including the accompanying
radiative corrections due to vacuum polarization, up to
next-to-next-to-next-to-leading order (N3LO) within the pionless effective
field theory (EFT). We also evaluate higher-order corrections due to the
single-nucleon structure, which are expected to be the most important
corrections beyond N3LO. We find a correlation between the deuteron charge and
Friar radii, which can be useful to judge the quality of charge form factor
parametrisations. We refine the theoretical description of the
$2\gamma$-exchange contribution, especially in the elastic contribution and the
radiative corrections, ameliorating the original discrepancy between theory and
experiment in the size of $2\gamma$-exchange effects. Based on the experimental
Lamb shift of muonic deuterium, we obtain the deuteron charge radius,
$r_d(\mu\text{D})=2.12763(13)_\text{exp}(77)_\text{theory}$~fm, which is
consistent with (but less precise than) the value obtained by combining the H-D
isotope shift with the muonic hydrogen Lamb shift. The theory uncertainty is
evaluated using a Bayesian procedure and is dominated by the truncation of the
pionless EFT series.
