We study the crossover from low-temperature to high-temperature fluctuations including Goldstone-dominated and critical fluctuations in confined isotropic and weakly anisotropic O(n)-symmetric systems on the basis of a finite-size renormalization-group approach at fixed dimension d introduced previously [V. Dohm, Phys. Rev. Lett. 110, 107207 (2013)]. Our theory is formulated within the phi(4) lattice model in a d-dimensional block geometry with periodic boundary conditions. We calculate the finite-size scaling functions Fex and X of the excess free-energy density and the thermodynamic Casimir force, respectively, for 1 <= n <= infinity, 2 < d < 4. Exact results are derived for n -> infinity. Applications are given for L-parallel to(d-1) slab geometry with an aspect ratio rho = L/L-parallel to > 0 and for film geometry (rho = 0). Good overall agreement is found with Monte Carlo (MC) data for isotropic spin models with n = 1,2,3. For rho = 0, the low-temperature limits of F-ex and X vanish for n = 1, whereas they are finite for n >= 2. For rho > 0 and n = 1, we find a finite low-temperature limit of F-ex, which deviates from that of the Ising model. We attribute this deviation to the nonuniversal difference between the phi(4) model with continuous variables and the Ising model with discrete variables. For n >= 2 and rho > 0, a logarithmic divergence of Fex in the low-temperature limit is predicted, in excellent agreement with MC data. For 2 <= n <= infinity and rho < rho(0) = 0.8567 the Goldstone modes generate a negative low-temperature Casimir force that vanishes for rho = rho(0) and becomes positive for rho > rho(0). For anisotropic systems a unified hypothesis of multiparameter universality is introduced for both bulk and confined systems. The dependence of their scaling functions on d(d + 1)/2 - 1 microscopic anisotropy parameters implies a substantial reduction of the predictive power of the theory for anisotropic systems as compared to isotropic systems. An exact representation is derived for the nonuniversal large-distance behavior of the bulk correlation function of anisotropic systems and quantitative predictions aremade. The validity of multiparameter universality is proven analytically for the d = 2, n = 1 universality class. A nonuniversal anisotropy-dependent minimum of the Casimir force scaling function X is found. Both the sign and magnitude of X and the shift of the film critical temperature are affected by the lattice anisotropy.