Performance of superconducting resonators, particularly cavities for particle accelerators and micro cavities and thin film resonators for quantum computations and photon detectors has been improved substantially by recent materials treatments and technological advances. As a result, the niobium cavities 
have reached the quality factors $Q\sim 10^{11}$ at 1-2 GHz and 1.5 K and the breakdown radio-frequency (rf) fields $H$
close to the dc superheating field of the Meissner state. These advances raise the question whether the state-of-the-art cavities are close to the 
fundamental limits, what these limits actually are, and to what extent the $Q$ and $H$ limits can be pushed 
by the materials nano structuring and impurity management. These issues are also relevant to many applications using high-Q thin film resonators, 
including single-photon detectors and quantum circuits. This topical review outlines basic physical mechanisms of the rf nonlinear surface 
impedance controlled by quasiparticles, dielectric losses and trapped vortices, as well as the dynamic field limit of the Meissner state. 
Sections cover ways of engineering an optimum quasiparticle density of states and superfluid density to reduce rf losses 
and kinetic inductance by pairbreaking mechanisms related to magnetic impurities, rf currents, and proximity-coupled metallic layers at the surface. 
A section focuses on mechanisms of residual surface resistance which dominates rf losses at ultra low temperatures. Microwave losses 
of trapped vortices and their reduction by optimizing the concentration of impurities and pinning potential are also discussed.