Given $T$ tokens with green count $|s|_G$ and target green fraction $\gamma$, compute $z = \bigl(|s|_G - \gamma T\bigr) \big/ \sqrt{T\gamma(1-\gamma)}$, then read off a $p$-value from the standard normal tail.
Kirchenbauer et al., ICML 2023, § 4. Gaussian here is the large-$T$ limit; for small $T$, it would be more accurate to evaluate the binomial $\sum_{j=g}^T \binom{T}{j}\gamma^j(1-\gamma)^{T-j}$ directly.