Pointwise almost sure convergence implies global convergence

Sorry in advance if this is not sufficiently research-level, it is really more of a reference request since the proof is not difficult. Let $$\mathcal{Y}$$ be a compact set, let $$\{X_n\}$$ denote a sequence of random variables, and let $$f(x,y)$$ and $$g(y)$$ be "nice" functions. Suppose that for each fixed $$y\in\mathcal{Y}$$, we have $$\liminf_{n\to\infty} f(X_n,y)\geq g(y)$$ almost surely. What is the appropriate theorem to cite that says that (for sufficiently nice functions), we have $$\liminf_{n\to\infty} \min_{y\in\mathcal{Y}} f(X_n,y)\geq \min_{y\in\mathcal{Y}} g(y)$$ almost surely?

First here, without loss of generality (wlog) $$g=0$$ (otherwise, replace $$f(x,y)$$ and $$g(y)$$ by $$f(x,y)-g(y)$$ and $$0$$, respectively). Second, in view of the almost-sure (a.s.) condition and the a.s. desired conclusion, wlog each random variable $$X_n$$ takes only one value, say $$x_n$$ -- which let us assume for simplicity to be a real number.

So, the desired result takes this simplified form:

If
$$\liminf_{n\to\infty} f(x_n,y)\ge0 \tag{1}$$ for some "nice" function $$f$$ and all $$y$$ in a compact set $$Y:=\mathcal Y$$, then $$\liminf_{n\to\infty}\min_{y\in Y} f(x_n,y)\ge0. \tag{2}$$

Consider now the following example: Let $$Y:=[-1,1]$$ and let $$f(x,y):=-xy^2\,e^{-xy^2}$$ for real $$x$$ and $$y\in Y$$. Probably everyone will agree that this function $$f$$ is nice. Let $$x_n\to\infty$$ (as $$n\to\infty$$). Then $$f(x_n,y)\to0$$ for each $$y\in Y$$, so that (1) holds. However, $$\min_{y\in Y} f(x_n,y)=-1/e$$ for each large enough $$n$$ (namely, for each $$n$$ such that $$x_n\ge1$$), so that (2) fails to hold.

The obvious reason for the just described phenomenon is that the sequence $$(x_n)$$ is unbounded.

So, it is natural to assume that $$|x_n|\le M$$ for some real $$M>0$$ and all $$n$$. It is also natural to assume that the "nice" function $$f$$ is continuous. So, $$f$$ is uniformly continuous on the compact set $$[-M,M]\times Y$$. Also, passing to a subsequence, wlog assume that $$x_n\to x_\infty$$ for some real $$x_\infty$$.

So, $$f(x_n,y)\to f(x_\infty,y)$$ uniformly in $$y\in Y$$ and hence $$\lim_{n\to\infty}\min_{y\in Y} f(x_n,y) =\min_{y\in Y} f(x_\infty,y) =\min_{y\in Y}\lim_{n\to\infty}f(x_n,y)\ge0,$$ by (1). So, we have deduced, very simply, (2) from (1).

Essentially, all we used here is that any function continuous on a compact set $$K$$ is uniformly continuous on $$K$$. So, one can hardly expect a reference involving something more substantial than this.