for(var d=Math,e=d.random,g=d.floor,h=requestAnimationFrame,k=[g(256*e()),g(256*e()),g(256*e())],l=g(a.width/9),m=d.round(a.height/l),n=Date.now(),p=[],r=l-10,t=2,u,v;t<9*m;t++)9!==t&&10!==t&&(u=[w(k[0]),w(k[1]),w(k[2])],p.push({x:parseInt(t%9*l,10),y:g(t/9)*l,a:"rgb("+u.join(",")+")"}));v=g(e()*p.length);p[v].a="rgb("+k.join(",")+")";c.font="36px sans-serif";c.textAlign="center";x();function x(f){var q=r;c.fillStyle="#333";c.fillRect(0,0,a.width,a.height);c.beginPath();c.arc(l,l,q,0,2*d.PI);c.fillStyle="rgb("+k.join(",")+")";c.fill();for(t=0;t<p.length;t++)c.fillStyle=p[t].a,c.fillRect(p[t].x+5,p[t].y+5,l-10,l-10);f&&(c.fillStyle="#FFF",c.fillText("Bingo!",p[v].x+l/2,p[v].y+l/2+20),c.fillText(n,l,l+20))}function w(f){f+=d.round(.7*f*e()*(.5<e()?1:-1));return 255<f?255:f}function z(f,q,y){return f>=d.min(q,y)&&f<=d.max(q,y)}function A(){x(!0);r+=25;r<a.width+l&&h(A)}b.onclick=function(f){z(f.pageX,p[v].x,p[v].x+l)&&z(f.pageY,p[v].y,p[v].y+l)&&(n=((Date.now()-n)/1E3).toFixed(2)+" sec",h(A))};
var m = Math,
mr = m.random,
mf = m.floor,
raf = requestAnimationFrame,
q = [W(), W(), W()],
s = mf(a.width/9),
r = m.round(a.height/s),
t = Date.now(),
d = [],
z = s - 10,
i = 2,
f,
n;
for ( ; i < r * 9; i++ ) {
if ( i !== 9 && i !== 10 ) {
f = [U(q[0]), U(q[1]), U(q[2])];
d.push({
x: parseInt((i%9) * s, 10),
y: mf(i/9) * s,
c: X(f)
});
}
}
n = mf(mr() * d.length);
d[n].c = X(q);
c.font = '36px sans-serif';
c.textAlign = 'center';
J(z);
function J(radius, bingo) {
c.fillStyle = '#333';
c.fillRect(0, 0, a.width, a.height);
c.beginPath();
c.arc(s, s, radius, 0, 2 * m.PI);
c.fillStyle = X(q);
c.fill();
for ( i = 0; i < d.length; i++ ) {
c.fillStyle = d[i].c;
c.fillRect(d[i].x + 5, d[i].y + 5, s - 10, s - 10);
}
if ( bingo ) {
c.fillStyle = '#FFF';
c.fillText('Bingo!', d[n].x + s/2, d[n].y + s/2 + 20);
c.fillText(t, s, s + 20);
}
}
function X(arr) { return 'rgb('+ arr.join(',') + ')'; }
function U(c) {
var h = c + m.round( c * ( mr() * 0.7 ) * ( ( mr() > 0.5 ) ? 1 : -1 ) );
return h > 255 ? 255 : h;
}
function W() { return mf(mr() * 256); }
function G(value, min, max) { return value >= m.min(min, max) && value <= m.max(min, max); }
function L() {
J(z, true);
z += 25;
if ( z < a.width + s ) { raf(L); }
}
b.onclick = function (e) {
if ( G(e.pageX, d[n].x, d[n].x + s) && G(e.pageY, d[n].y, d[n].y + s) ) {
t = ((Date.now() - t)/1000).toFixed(2) + ' sec';
raf(L);
}
}