II. (15 points) Let the quadratic function $f(x)$ have a maximum value of 12 on the interval $[-1,4]$, and the solution set of the inequality $f(x)<0$ with respect to $x$ is the interval $(0,5)$.
(1) Find the analytical expression of the function $f(x)$;
(2) If for any $x \in \mathbf{R}$, the inequality
$$
f(2-2 \cos x)<f(1-\cos x-m)
$$

always holds, find the range of the real number $m$.
(1) According to the problem, let
$$
f(x)=a x(x-5)(a>0),
$$

i.e., $f(x)=a\left(x-\frac{5}{2}\right)^{2}-\frac{25}{4} a$.
Since $f(x)$ achieves its maximum value of 12 on the interval $[-1,4]$, and $a>0$, when $x=-1$, $f(x)$ reaches its maximum value, i.e., $f(-1)=6 a=12$, thus $a=2$.
Therefore, $f(x)=2 x^{2}-10 x$.
(2) Let $t=1-\cos x(0 \leqslant t \leqslant 2)$. Then the original inequality transforms to $f(2 t)-\frac{5}{4}$ when $-m2,\end{array}\right.$ solving this gives $m>1$.

When $-m=\frac{m+5}{3}$, i.e., $m=-\frac{5}{4}$, $\left(t-\frac{5}{4}\right)^{2}\frac{m+5}{3}$, i.e., $m2,\end{array}\right.$ solving this gives $m<-5$.
In summary, the range of real values for $m$ is
$$
(-\infty,-5) \cup(1,+\infty)
$$