5. 21
Since $\triangle C A B \cong \triangle E F D$, it follows that $A C=E F, A B=F D$, and $B C=E D$. Thus, we need to solve the following system of linear equations:
$$
\left\{\begin{aligned}
x+y+z & =3 \\
z+6 & =2 y-z \\
x+8 z & =y+2 .
\end{aligned}\right.
$$

Solving the system gives $x=-2, y=4$, and $z=1$.
5. It is given that $\triangle C A B \cong \triangle E F D$. If $A C=x+y+z, A B=z+6$, $B C=x+8 z, E F=3, D F=2 y-z$, and $D E=y+2$, find $x^{2}+y^{2}+z^{2}$.