  Given an i.i.d. sample from a distribution $F$ on $\mathbb{R}$ with uniformly
continuous density $p_0$, purely data-driven estimators are constructed that
efficiently estimate $F$ in sup-norm loss and simultaneously estimate $p_0$ at
the best possible rate of convergence over H\"older balls, also in sup-norm
loss. The estimators are obtained by applying a model selection procedure close
to Lepski's method with random thresholds to projections of the empirical
measure onto spaces spanned by wavelets or $B$-splines. The random thresholds
are based on suprema of Rademacher processes indexed by wavelet or spline
projection kernels. This requires Bernstein-type analogs of the inequalities in
Koltchinskii [Ann. Statist. 34 (2006) 2593-2656] for the deviation of suprema
of empirical processes from their Rademacher symmetrizations.
