If you have two decoupled oscillators, they satisfy differential equations
$$-\frac{d^2}{dt^2}x_i=\omega^2_{i} x_i$$
where $i=1,2$. The solutions are clearly multiples of $\cos(\omega_i t+\phi_i)$. Now, consider two interacting oscillators. Each oscillator must know about the phase of the other, so the simplest dependence is to add a multiple of $x_2$ (a linear multiple) to the equation for $x_1$ and vice versa:
$$-\frac{d^2}{dt^2}\vec x=\Omega \cdot \vec x$$
Here, $\Omega$ (capital omega) is a $2\times 2$ matrix, and if you don't know how to multiply matrices, you should learn it. The matrix $\Omega$ has diagonal elements $\omega_1^2$ and $\omega_2^2$ but we have just added real nonzero off-diagonal elements $\Omega_{12}$ and $\Omega_{21}$, too.
Such a system of two linear differential equations may be easily solved by diagonalizing the matrix $\Omega$. In other words, there exist two linear combinations of the two equations such that the second time-derivative of the combination of $x_1,x_2$ will only depend on the multiple of the same combination of $x_1,x_2$.
Diagonalizing the matrix means to find the eigenvalues. The eigenvalues of the $2\times 2$ matrix $\Omega$ are solutions to the charcteristic equation
$$0 = \det(\Omega-\lambda\cdot{\bf 1}) = (\omega_1^2-\lambda)(\omega_2^2-\lambda)-\Omega_{12}\Omega_{21}$$
That's a quadratic equation for the eigenvalue $\lambda$ that has two solutions
$$\lambda_\pm = \frac{\omega_1^2+\omega_2^2\pm\sqrt{(\omega_1^2-\omega_2^2)^2+4\Omega_{12}\Omega_{21}}}{2} $$
Note that under the square root, there is a difference of the squared frequencies. It's because the $+2\omega_1^2\omega_2^2$ term got overcompensated by $-4\omega_1^2\omega_2^2$ and switched the sign. For a fixed coupling between the two degrees of freedom, i.e. for a fixed $\Omega_{12}\Omega_{21}$, the square root - representing the difference between the two eigenfrequencies - is minimized for $\omega_1^2$ close to $\omega_2^2$. This proximity is what you want for a resonance, an effective transfer of energy.
If the energy is being transferred from one oscillator to the other by the (small) off-diagonal $\Omega_{12}$ and $\Omega_{21}$ elements, the kinetic energy stored in $x_1$ (plus the corresponding potential energy) will be slowly moved to the kinetic energy stored in $x_2$ (plus the corresponding potential energy). Energy conservation implies that the energies of the two oscillators have to go like
$$E_1 = E \cos^2(\omega_d t), \quad E_2 = E \sin^2(\omega_d t)$$
because they sum up to constant (coefficients omitted). That means that $x_1^{max}$ itself has to go like $\cos(\omega_d t)$ and similarly for $x_2^{max}$ and $\sin$. The phase difference between $x_1$ and $x_2$ is therefore $\pm \pi/2$.