  The electronic structure of SrRuO$_3$ thin film with thickness from 50 to 1
unit cell (u.c.) is investigated via the resonant inelastic x-ray scattering
(RIXS) technique at the O K-edge to unravel the intriguing interplay of orbital
and charge degrees of freedom. We found that orbital-selective quantum
confinement effect (QCE) induces the splitting of Ru $4d$ orbitals. At the same
time, we observed a clear suppression of the electron-hole continuum across the
metal-to-insulator transition (MIT) occurring at the 4 u.c. sample. From these
two clear observations we conclude that QCE gives rise to a Mott insulating
phase in ultrathin SrRuO$_3$ films. Our interpretation of the RIXS spectra is
supported by the configuration interaction calculations of RuO$_6$ clusters.
