This book provides a theoretical, step-by-step comprehensive explanation of superconductivity for undergraduate and graduate students who have completed elementary courses on thermodynamics and quantum mechanics. To this end, it adopts the unique approach of starting with the statistical mechanics of quantum ideal gases and successively adding and clarifying elements and techniques indispensible for understanding it. They include the spin-statistics theorem, second quantization, density matrices, the Bloch-De Dominicis theorem, the variational principle in statistical mechanics, attractive interaction and bound states. Ample examples of their usage are also provided in terms of topics from advanced statistical mechanics such as two-particle correlations of quantum ideal gases, derivation of the Hartree-Fock equations, and Landau's Fermi-liquid theory, among others. With these preliminaries, the fundamental mean-field equations of superconductivity are derived with maximum mathematical clarity based on a coherent state in terms of the Cooper-pair creation operator, a quasiparticle field for describing the excitation and the variational principle in statistical mechanics. They have the advantage that the phase coherence due to the Cooper-pair condensation can be clearly seen making the superfluidity comprehensible naturally. Subsequently, they are applied to homogeneous cases to describe the BCS theory for classic s-wave superconductors and its extension to the p-wave superfluidity of 3He. Later, the mean-field equations are simplified to the Eilenberger and Ginzburg-Landau equations so as to describe inhomogeneous superconductivity such as Abrikosov's flux-line lattice concisely and transparently. Chapters provide the latest studies on the quasiclassical theory of superconductivity and a discovery of p-wave superfluidity in liquid 3He. The book serves as a standard reference for advanced courses of statistical mechanics with exercises along with detailed answers.