SOURCE / PINNED RELEASE
Made of little things.
Find the Invisible Cow
- Release
- e48b3dced31c…
- Author-recorded commit
- cf79302f143d…
- License
- Check the original source
- Author’s source reference
- nostr://npub1p8rxwea4e0l4jml0q53n5mvh3n7pywq523jk3lm336v04r8ny9jqtq7ttf/wss%3A%2F%2Fgit.napplet.soy%2F/n-3b179f1d7df
The hash-verified playable HTML, which may contain bundled or minified code. This view does not execute it.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Find the Invisible Cow</title>
<script type="module" crossorigin>var Zt=Object.defineProperty;var Kt=(t,e,n)=>e in t?Zt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var M=(t,e,n)=>Kt(t,typeof e!="symbol"?e+"":e,n);function Qt(){const t=new Map;function e(i,o){if(t.has(i))throw new Error(`NAP domain "${i}" is already registered`);t.set(i,o)}function n(i){const o=i.type.indexOf(".");if(o<=0)return!1;const u=i.type.slice(0,o),x=t.get(u);return x?(x(i),!0):!1}function s(){return Array.from(t.keys())}return{registerNap:e,dispatch:n,getRegisteredDomains:s}}var Xt=Qt(),Lt=Xt.registerNap,Bt="identity";Lt(Bt,t=>{});var gt="storage";Lt(gt,t=>{});function Ut(){const t=window;if(!t.napplet)throw new Error("window.napplet is unavailable -- runtime did not inject the napplet namespace");return t.napplet}function a(t){const n=Ut()[t];if(!n)throw new Error(`window.napplet.${String(t)} is unavailable -- runtime did not inject this domain`);return n}var Nt={getItem(t){return a("storage").getItem(t)},setItem(t,e){return a("storage").setItem(t,e)},removeItem(t){return a("storage").removeItem(t)},keys(){return a("storage").keys()},instance:{getItem(t){return a("storage").instance.getItem(t)},setItem(t,e){return a("storage").instance.setItem(t,e)},removeItem(t){return a("storage").instance.removeItem(t)},keys(){return a("storage").instance.keys()}}},Jt={createSession(t){return a("media").createSession(t)},updateSession(t,e){a("media").updateSession(t,e)},destroySession(t){a("media").destroySession(t)},reportState(t,e){a("media").reportState(t,e)},reportCapabilities(t,e){a("media").reportCapabilities(t,e)},sendCommand(t,e,n){a("media").sendCommand(t,e,n)},onCommand(t,e){return a("media").onCommand(t,e)},onState(t,e){return a("media").onState(t,e)},onCapabilities(t,e){return a("media").onCapabilities(t,e)},onControls(t,e){return a("media").onControls(t,e)}},Wt={getPublicKey(){return a("identity").getPublicKey()},onChanged(t){return a("identity").onChanged(t)},getRelays(){return a("identity").getRelays()},getProfile(){return a("identity").getProfile()},getFollows(){return a("identity").getFollows()},getList(t){return a("identity").getList(t)},getZaps(){return a("identity").getZaps()},getMutes(){return a("identity").getMutes()},getBlocked(){return a("identity").getBlocked()},getBadges(){return a("identity").getBadges()}},at={get(){return a("config").get()},subscribe(t){return a("config").subscribe(t)},openSettings(t){a("config").openSettings(t)},registerSchema(t,e){return a("config").registerSchema(t,e)},onSchemaError(t){return a("config").onSchemaError(t)},get schema(){return a("config").schema}};function te(t,e){return!!(t!=null&&t[e])}function nt(t){return te(window.napplet,t)}const ee="http://json-schema.org/draft-07/schema#",ne=1,ie="object",se=!1,oe={hintMode:{type:"string",title:"Visual hints",description:"Optional on-screen guidance toward the cow, for playing without sound. Subtle shows a meter once you are close; full adds a direction arrow.",enum:["off","subtle","full"],default:"off","x-napplet-section":"Assistance","x-napplet-order":1},catchSize:{type:"string",title:"Catch area",description:"How close the pointer must be to catch the cow. Large widens the catch area, which helps on touch screens.",enum:["normal","large"],default:"normal","x-napplet-section":"Assistance","x-napplet-order":2}},ae={$schema:ee,$version:ne,type:ie,additionalProperties:se,properties:oe},re={hintMode:"off",catchSize:"normal"},ce=new Set(["off","subtle","full"]),ue=new Set(["normal","large"]),dt=new Set;let R={...re};function Ft(){return R}function de(t){return dt.add(t),()=>dt.delete(t)}function le(t){const e={...R};if(typeof t.hintMode=="string"&&ce.has(t.hintMode)&&(e.hintMode=t.hintMode),typeof t.catchSize=="string"&&ue.has(t.catchSize)&&(e.catchSize=t.catchSize),!(e.hintMode===R.hintMode&&e.catchSize===R.catchSize)){R=e;for(const n of dt)n(R)}}function he(){nt("config")&&(async()=>{at.schema||await at.registerSchema(ae);const t=at.subscribe(e=>{e&&typeof e=="object"&&le(e)});window.addEventListener("pagehide",()=>t.close(),{once:!0})})().catch(()=>{})}class fe{constructor(e,n,s={}){M(this,"context");M(this,"output");M(this,"session","");M(this,"pending",!1);M(this,"blocked",!1);M(this,"disposed",!1);M(this,"userMuted",!1);M(this,"volume",1);M(this,"stopped",!1);M(this,"listener");this.media=e,this.title=n,this.options=s}activate(){var e,n;if(!this.media||this.disposed||this.blocked)return!1;try{return this.context||(this.context=((n=(e=this.options).createContext)==null?void 0:n.call(e))??new AudioContext,this.output=this.context.createGain(),this.output.gain.value=0,this.output.connect(this.context.destination),this.context.onstatechange=()=>this.report()),!this.session&&!this.pending&&(this.pending=!0,this.register()),this.context.state==="suspended"&&this.resume(),this.audible}catch{return this.dispose(),!1}}get audible(){var e;return!!this.session&&!this.disposed&&!this.blocked&&!this.userMuted&&((e=this.context)==null?void 0:e.state)==="running"}get muted(){return this.userMuted}get unavailable(){return this.disposed||this.blocked}get hasMedia(){return!!this.media}get hostPaused(){return this.blocked}reset(){this.disposed&&(this.disposed=!1,this.blocked=!1,this.stopped=!1,this.session="",this.context=void 0,this.output=void 0)}setMuted(e){this.userMuted=e,this.applyGain(),this.report()}applyGain(){this.output&&(this.output.gain.value=this.audible?this.volume:0)}report(){var e,n;if(this.applyGain(),(n=(e=this.options).onChange)==null||n.call(e),!(!this.session||this.disposed))try{this.media.reportState(this.session,{status:this.audible?"playing":this.stopped?"stopped":"paused",volume:this.muted?0:this.volume})}catch{this.dispose()}}async resume(){var e;try{await((e=this.context)==null?void 0:e.resume()),this.report()}catch{this.applyGain()}}async register(){try{const e=await this.media.createSession({owner:"napplet",metadata:{title:this.title,mediaType:"audio"},capabilities:["play","pause","stop","volume"]});if(this.disposed){e.sessionId&&this.media.destroySession(e.sessionId);return}if(e.error||!e.sessionId||e.owner!=="napplet"){e.sessionId&&this.media.destroySession(e.sessionId),this.dispose();return}this.session=e.sessionId,this.listener=this.media.onCommand(this.session,(n,s)=>{var i;this.disposed||(n==="pause"||n==="stop"?(this.blocked=!0,this.stopped=n==="stop",this.applyGain(),(i=this.context)==null||i.suspend().then(()=>this.report()).catch(()=>{})):n==="play"?(this.blocked=!1,this.stopped=!1,this.resume()):n==="volume"&&typeof s=="number"&&Number.isFinite(s)&&(this.volume=Math.max(0,Math.min(1,s))),this.report())}),this.report()}catch{this.dispose()}finally{this.pending=!1}}dispose(){var e;if(!this.disposed){this.disposed=!0,this.applyGain();try{(e=this.listener)==null||e.close()}catch{}if(this.context&&(this.context.onstatechange=null,this.context.close().catch(()=>{})),this.session)try{this.media.destroySession(this.session)}catch{}this.session=""}}}class pe{constructor(e,n){M(this,"noiseBuffer");this.context=e,this.destination=n}play({volume:e,pan:n,pitch:s}){var S;const i=this.context,o=i.currentTime+.02,u=.72+Math.random()*.14,x=Math.max(0,Math.min(1,e)),g=i.createGain();g.gain.setValueAtTime(1e-4,o),g.gain.linearRampToValueAtTime(x,o+.09),g.gain.setValueAtTime(Math.max(1e-4,x*.85),o+u-.3),g.gain.exponentialRampToValueAtTime(1e-4,o+u);const w=i.createBiquadFilter();w.type="lowpass",w.Q.value=1.4,w.frequency.setValueAtTime(950,o),w.frequency.exponentialRampToValueAtTime(480,o+u*.8);const c=i.createBiquadFilter();c.type="peaking",c.frequency.value=340,c.Q.value=1.1,c.gain.value=9,g.connect(w),w.connect(c);const N=i.createStereoPanner();N.pan.value=Math.max(-.85,Math.min(.85,n)),c.connect(N),N.connect(this.destination);const st=(p,v)=>{p.frequency.setValueAtTime(v*1.12,o),p.frequency.linearRampToValueAtTime(v*1.28,o+.12),p.frequency.exponentialRampToValueAtTime(v*.74,o+u-.12)},F=i.createOscillator();F.frequency.value=5.3+Math.random()*1.2;const E=i.createGain();E.gain.value=6.5,F.connect(E);const h=[],m=(p,v,U)=>{const T=i.createOscillator();T.type=p,st(T,v);const $=i.createGain();return $.gain.value=U,E.connect(T.frequency),T.connect($),$.connect(g),T.start(o),T.stop(o+u+.05),h.push(T),T};m("sawtooth",s,.5),m("sawtooth",s*1.006,.42),m("sine",s/2,.6),F.start(o),F.stop(o+u+.05);const y=i.createBufferSource();y.buffer=this.noise();const k=i.createBiquadFilter();k.type="bandpass",k.frequency.value=300,k.Q.value=.9;const I=i.createGain();I.gain.setValueAtTime(x*.3,o),I.gain.exponentialRampToValueAtTime(1e-4,o+.18),y.connect(k),k.connect(I),I.connect(g),y.start(o),y.stop(o+.2),h.push(y);const P=h[h.length-1],r=()=>{for(const p of[g,w,c,N,E,k,I])try{p.disconnect()}catch{}};return P instanceof OscillatorNode?P.onended=r:(S=h[0])==null||S.addEventListener("ended",r),u}fanfare(){this.play({volume:.9,pan:0,pitch:175}),window.setTimeout(()=>{this.context.state==="running"&&this.play({volume:1,pan:0,pitch:158})},550)}noise(){if(this.noiseBuffer)return this.noiseBuffer;const e=Math.ceil(this.context.sampleRate*.25),n=this.context.createBuffer(1,e,this.context.sampleRate),s=n.getChannelData(0);for(let i=0;i<e;i+=1)s[i]=Math.random()*2-1;return this.noiseBuffer=n,n}}const me={moveX:[{axis:0},{button:14,scale:-1},{button:15}],moveY:[{axis:1},{button:12,scale:-1},{button:13}],catch:[{button:0}]};function kt(t){const e=Object.create(null);for(const[n,s]of Object.entries(t))e[n]=s.map(i=>{const o="button"in i?i.button:i.axis;if(!Number.isInteger(o)||o<0||i.scale!==void 0&&![1,-1].includes(i.scale))throw new Error("Controller bindings need nonnegative integer indices and a scale of 1 or -1.");return{...i}});return e}const At=(t,e=-1)=>Number.isFinite(t)?Math.max(e,Math.min(1,t)):0;function ge(t=me,e={}){const n=kt(t),s=e.deadZone??.18,i=e.buttonThreshold??.5;if(!Number.isFinite(s)||s<0||s>=1||!Number.isFinite(i)||i<=0||i>1)throw new Error("Use a dead zone from 0 up to (excluding) 1 and a button threshold above 0 through 1.");let o=new Map,u=!1,x=!1;const g=new Map,w=()=>{u=!1},c=typeof window<"u"?window:void 0;c==null||c.addEventListener("blur",w),c==null||c.document.addEventListener("visibilitychange",w);const N=()=>{var h;return(h=c==null?void 0:c.napplet)==null?void 0:h.gamepad},st=e.active??(()=>{var h;return!!c&&!c.document.hidden&&c.document.hasFocus()&&((h=N())==null?void 0:h.focused)!==!1}),F=e.read??(()=>{if(typeof navigator>"u"||!navigator.getGamepads)throw new Error("Gamepad API unavailable");return navigator.getGamepads()});function E(h){const m=[...o.keys()];return o.clear(),g.clear(),u=!1,{status:h,players:[],connected:[],disconnected:m}}return{poll(){var P;if(x)return E("closed");let h;try{h=Array.from(F()).filter(r=>!!(r!=null&&r.connected))}catch(r){return E(r instanceof Error&&r.name==="SecurityError"?"blocked":"unavailable")}const m=st(),y=new Map,k=[],I=[];for(const r of h){const S=o.get(r.index),p=(S==null?void 0:S.id)===r.id&&S.mapping===r.mapping;p||(k.push(r.index),g.delete(r.index));const v=g.get(r.index),U=r.mapping==="standard"||(v==null?void 0:v.id)===r.id,T=(v==null?void 0:v.bindings)??n,$=r.axes.map(q=>m?At(q):0),bt=r.buttons.map(q=>m?At(q.value,0):0),St=Object.create(null);for(const[q,Yt]of Object.entries(T)){let z=0,V=0;if(m&&U)for(const j of Yt){let O="button"in j?bt[j.button]??0:$[j.axis]??0;"axis"in j&&(O=Math.sign(O)*Math.max(0,(Math.abs(O)-s)/(1-s))),O*=j.scale??1,z=Math.max(z,O),V=Math.min(V,O)}const Ct=z===-V?0:z>-V?z:V,ot=Math.abs(Ct)>=i,Tt=p&&!!((P=S.actions[q])!=null&&P.down);St[q]={value:Ct,down:ot,pressed:m&&u&&p&&ot&&!Tt,released:m&&Tt&&!ot}}y.set(r.index,{index:r.index,id:r.id,mapping:r.mapping,mapped:U,axes:$,buttons:bt,actions:St})}for(const[r,S]of o){const p=y.get(r);(!p||p.id!==S.id||p.mapping!==S.mapping)&&(I.push(r),p||g.delete(r))}return o=y,u=m,{status:m?y.size?"ready":"waiting":"inactive",players:structuredClone([...y.values()]),connected:k,disconnected:I}},remap(h,m){const y=o.get(h);if(!y||x)throw new Error("Connect and poll this controller before mapping it.");g.set(h,{id:y.id,bindings:kt(m)}),u=!1},reset:w,dispose(){x=!0,E("closed"),c==null||c.removeEventListener("blur",w),c==null||c.document.removeEventListener("visibilitychange",w)}}}function ye(t,e){if(!Number.isFinite(t)||!Number.isFinite(e)||e<=0)return 0;const n=1-Math.max(0,t)/e;return Math.max(0,Math.min(1,n))}function we(t){const e=Math.max(0,Math.min(1,t));return .05+.95*Math.pow(e,1.6)}function xe(t){return 1150-800*Math.max(0,Math.min(1,t))}function ve(t,e,n){const s=Math.max(26,Math.min(72,Math.min(t,e)*.09));return n==="large"?s*1.7:s}function lt(t){const e=Math.max(0,t),n=Math.floor(e/6e4),s=Math.floor(e%6e4/1e3),i=Math.floor(e%1e3/100);return`${n}:${String(s).padStart(2,"0")}.${i}`}function Me(t,e){const n=t<.3333333333333333?"left":t>.6666666666666666?"right":"middle",s=e<1/3?"top":e>2/3?"bottom":"middle";return n==="middle"&&s==="middle"?"It was hiding smack in the middle of the pasture.":s==="middle"?`It was hiding along the ${n} side.`:n==="middle"?`It was hiding along the ${s} edge.`:`It was hiding near the ${s}-${n} corner.`}const K=f("#field"),G=f("#probe"),be=f("#hintMeterWrap"),Se=f("#hintMeter"),rt=f("#hintArrow"),J=f("#cowReveal"),Ce=f("#timer"),$t=f("#mooCount"),ht=f("#soundToggle"),qt=f("#coach"),ct=f("#notice"),Te=f("#startOverlay"),ke=f("#startButton"),Ot=f("#winOverlay"),Rt=f("#againButton"),Ae=f("#resultTime"),Ee=f("#resultMoos"),Ie=f("#resultBest"),Le=f("#resultSpot");function f(t){const e=document.querySelector(t);if(!e)throw new Error(`Missing required element: ${t}`);return e}const d=new fe(Jt,"Invisible Cow moo",{onChange:()=>yt()});let _=null,ft=!1;function Be(){return!d.context||!d.output?null:(_||(_=new pe(d.context,d.output)),_)}function Dt(){d.activate(),window.setTimeout(()=>{!d.audible&&(d.unavailable||!d.hasMedia)&&!ft&&(ft=!0,et("Audio is unavailable here — visual hints are on so you can still hunt.",8e3))},2e3)}function yt(){const t=!d.muted;ht.setAttribute("aria-pressed",String(t)),ht.setAttribute("aria-label",t?"Sound is on. Turn sound off.":"Sound is off. Turn sound on.")}ht.addEventListener("click",()=>{d.muted?(d.setMuted(!1),d.unavailable?(d.reset(),Dt()):d.activate()):d.setMuted(!0),yt()});let C="idle",Z={fx:.5,fy:.5},l={x:0,y:0};const b=new Set;let W={x:0,y:0},A="pointer",pt=0,H=0,tt=0,L=null,D=null,mt=!1,ut=0;const Et=430;function B(){const t=K.getBoundingClientRect();return{w:t.width,h:t.height}}function Q(){const{w:t,h:e}=B();return{x:Z.fx*t,y:Z.fy*e}}function Ne(){const{w:t,h:e}=B();return ve(t,e,Ft().catchSize)}function X(){const{w:t,h:e}=B(),n=Q(),s=Math.hypot(t,e)/2||1;return ye(Math.hypot(n.x-l.x,n.y-l.y),s)}function Fe(){const{w:t,h:e}=B(),n=Math.hypot(t,e)/2||1;for(let s=0;s<12;s+=1){const i=.06+Math.random()*.88,o=.1+Math.random()*.8,u=(i-l.x/t)*t,x=(o-l.y/e)*e;if(Math.hypot(u,x)>n*.45||s===11){Z={fx:i,fy:o};return}}}function $e(t){return xe(t)*(.88+Math.random()*.24)}function qe(){if(C!=="hunting")return;const t=X();if(d.audible){const e=Be();if(e){const{w:n}=B(),s=Q(),i=Math.max(-1,Math.min(1,(l.x-s.x)/n*2));e.play({volume:we(t),pan:i,pitch:150*(.9+Math.random()*.2)}),H+=1,$t.textContent=`${H} moo${H===1?"":"s"}`}}it(t)}function Gt(){pt=window.setTimeout(()=>{qe(),Gt()},$e(X()))}function wt(){window.clearTimeout(pt),pt=0}function Oe(){tt=0,L=performance.now()}function xt(){return L!==null&&(tt+=performance.now()-L,L=null),tt}function vt(){C==="hunting"&&L===null&&(L=performance.now())}function Re(){return tt+(L!==null?performance.now()-L:0)}let It=0;function et(t,e=5e3){ct.textContent=t,ct.hidden=!1,window.clearTimeout(It),e>0&&(It=window.setTimeout(()=>{ct.hidden=!0},e))}async function De(){if(nt(gt))try{const t=await Nt.getItem("best-time-ms"),e=t===null?Number.NaN:Number(t);Number.isFinite(e)&&e>0&&(D=e,mt=!0)}catch{}}async function Ge(t){if(!nt(gt)){mt||et("Best time not saved — this host has no storage.",4e3);return}try{await Nt.setItem("best-time-ms",String(t)),mt=!0}catch{et("Best time not saved — storage refused the write.",4e3)}}function Mt(){if(C!=="hunting")return;const t=Q();Math.hypot(t.x-l.x,t.y-l.y)<=Ne()&&Pe()}function Pe(){C="found",wt();const t=xt();_&&d.audible&&_.fanfare();const e=Q();J.style.left=`${e.x}px`,J.style.top=`${e.y}px`,J.hidden=!1;const n=D===null||t<D;n&&(D=t),Ae.textContent=lt(t),Ee.textContent=String(H),Ie.textContent=D===null?"—":lt(D),Le.textContent=Me(Z.fx,Z.fy)+(n?" A new best!":""),Ge(t),qt.textContent="Got her! Listen for the next hiding spot.",window.setTimeout(()=>{Ot.hidden=!1,Rt.focus()},850)}function Pt(){Te.hidden=!0,Ot.hidden=!0,J.hidden=!0,H=0,$t.textContent="0 moos",Fe(),C="hunting",qt.textContent="Listen — the moo gets louder and quicker as you close in.",Oe(),vt(),wt(),Gt(),K.focus({preventScroll:!0})}ke.addEventListener("click",()=>{Dt(),Pt()});Rt.addEventListener("click",()=>{Pt()});function zt(t){const e=K.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}K.addEventListener("pointermove",t=>{l=zt(t),A="pointer",G.classList.remove("active")});K.addEventListener("pointerdown",t=>{l=zt(t),A="pointer",G.classList.remove("active"),Mt()});const Vt=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","w","a","s","d","W","A","S","D"]);window.addEventListener("keydown",t=>{const e=t.target;if(!(e!=null&&e.closest("button, input, textarea, select"))){if(Vt.has(t.key)){t.preventDefault(),b.add(t.key.toLowerCase()),A="keys",G.classList.add("active");return}(t.key==="Enter"||t.key===" ")&&C==="hunting"&&(t.preventDefault(),Mt())}});window.addEventListener("keyup",t=>{Vt.has(t.key)&&b.delete(t.key.toLowerCase())});window.addEventListener("blur",()=>b.clear());const jt=ge();function ze(){var i,o,u;const e=jt.poll().players[0];if(!e)return;const n=((i=e.actions.moveX)==null?void 0:i.value)??0,s=((o=e.actions.moveY)==null?void 0:o.value)??0;n!==0||s!==0?(W={x:n,y:s},A="pad",G.classList.add("active")):A==="pad"&&(W={x:0,y:0}),(u=e.actions.catch)!=null&&u.pressed&&Mt()}function _t(){const{w:t,h:e}=B();l.x=Math.max(0,Math.min(t,l.x)),l.y=Math.max(0,Math.min(e,l.y))}function Ve(){const t=Ft().hintMode;return t!=="off"?t:ft?"subtle":"off"}function it(t){const e=C==="hunting",n=Ve(),s=e&&n!=="off"&&(n==="full"||t>=.7);be.classList.toggle("on",s),Se.style.width=`${Math.round(t*100)}%`;const i=e&&n==="full";if(rt.classList.toggle("on",i),i){const o=Q(),u=Math.atan2(o.y-l.y,o.x-l.x)+Math.PI/2;rt.style.transform=`rotate(${u*180/Math.PI}deg)`,rt.style.opacity=String(.25+.75*t)}}function Ht(t){const e=ut?Math.min(.1,(t-ut)/1e3):0;if(ut=t,ze(),A==="keys"||A==="pad"){let n=0,s=0;A==="keys"?((b.has("arrowleft")||b.has("a"))&&(n-=1),(b.has("arrowright")||b.has("d"))&&(n+=1),(b.has("arrowup")||b.has("w"))&&(s-=1),(b.has("arrowdown")||b.has("s"))&&(s+=1)):(n=W.x,s=W.y);const i=Math.hypot(n,s);i>0&&(l.x+=n/Math.max(1,i)*Et*e,l.y+=s/Math.max(1,i)*Et*e,_t())}A!=="pointer"&&(G.style.left=`${l.x}px`,G.style.top=`${l.y}px`),C==="hunting"&&(d.hostPaused?xt():vt(),Ce.textContent=lt(Re()),it(X())),window.requestAnimationFrame(Ht)}window.requestAnimationFrame(Ht);window.addEventListener("resize",()=>{_t(),C==="hunting"&&it(X())});document.addEventListener("visibilitychange",()=>{document.hidden?(xt(),b.clear()):vt()});let Y=null;if(nt(Bt))try{Y=Wt.onChanged(()=>{d.audible&&C==="hunting"&&(d.setMuted(!0),et("Account changed — sound paused. Press the sound button to resume.",6e3))})}catch{Y=null}he();de(()=>{C==="hunting"&&it(X())});l={x:B().w/2,y:B().h/2};yt();De();window.addEventListener("pagehide",()=>{wt(),jt.dispose(),Y==null||Y.close(),d.dispose()});
</script>
<style>:root{--night-0: #0b1026;--night-1: #14203f;--night-2: #1d2f56;--moss: #0e1f2e;--cream: #f4ead2;--cream-dim: rgba(244, 234, 210, .72);--amber: #ffb648;--amber-deep: #e28a2b;--cold: #5aa7d8;--warm: #ff8c42;--ink: #1d1405;--card-bg: rgba(13, 19, 40, .94);--control-h: 48px;--napplet-text-selection: none;color-scheme:dark;box-sizing:border-box}*,*:before,*:after{box-sizing:border-box}html,body,#app{height:100%}body{margin:0;font-family:Trebuchet MS,Segoe UI,Verdana,system-ui,sans-serif;font-size:15px;line-height:1.45;color:var(--cream);background:var(--night-0);-webkit-user-select:var(--napplet-text-selection, none);user-select:var(--napplet-text-selection, none);overflow:hidden}.app{position:relative;overflow:hidden}.field{position:absolute;top:0;right:0;bottom:0;left:0;background:radial-gradient(120% 90% at 50% -10%,var(--night-2) 0%,var(--night-1) 46%,var(--night-0) 100%);cursor:crosshair;touch-action:none}.field:after{content:"";position:absolute;inset:auto 0 0 0;height:12%;background:linear-gradient(to top,#090e1ee6,#090e1e00);pointer-events:none}.stars,.grass{position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none}.stars{background-image:radial-gradient(1.5px 1.5px at 12% 18%,rgba(244,234,210,.85) 49%,transparent 51%),radial-gradient(1px 1px at 34% 9%,rgba(244,234,210,.6) 49%,transparent 51%),radial-gradient(1.5px 1.5px at 58% 15%,rgba(244,234,210,.75) 49%,transparent 51%),radial-gradient(1px 1px at 71% 6%,rgba(244,234,210,.5) 49%,transparent 51%),radial-gradient(2px 2px at 86% 20%,rgba(244,234,210,.8) 49%,transparent 51%),radial-gradient(1px 1px at 22% 32%,rgba(244,234,210,.45) 49%,transparent 51%),radial-gradient(1px 1px at 47% 27%,rgba(244,234,210,.5) 49%,transparent 51%),radial-gradient(1.5px 1.5px at 92% 34%,rgba(244,234,210,.6) 49%,transparent 51%)}.grass{background-image:radial-gradient(14px 26px at 8% 100%,var(--moss) 60%,transparent 61%),radial-gradient(18px 30px at 17% 100%,#12283a 60%,transparent 61%),radial-gradient(12px 24px at 31% 100%,var(--moss) 60%,transparent 61%),radial-gradient(20px 34px at 44% 100%,#12283a 60%,transparent 61%),radial-gradient(13px 26px at 57% 100%,var(--moss) 60%,transparent 61%),radial-gradient(17px 30px at 69% 100%,#12283a 60%,transparent 61%),radial-gradient(14px 28px at 82% 100%,var(--moss) 60%,transparent 61%),radial-gradient(19px 32px at 93% 100%,#12283a 60%,transparent 61%);background-repeat:no-repeat}.fireflies i{position:absolute;width:5px;height:5px;border-radius:50%;background:#ffd682bf;box-shadow:0 0 8px 2px #ffb64859;opacity:.5;animation:drift 9s ease-in-out infinite alternate}.fireflies i:nth-child(1){left:14%;top:58%;animation-delay:0s}.fireflies i:nth-child(2){left:78%;top:44%;animation-delay:-2.2s}.fireflies i:nth-child(3){left:36%;top:76%;animation-delay:-4.1s}.fireflies i:nth-child(4){left:62%;top:68%;animation-delay:-5.7s}.fireflies i:nth-child(5){left:88%;top:82%;animation-delay:-7.3s}.fireflies i:nth-child(6){left:25%;top:38%;animation-delay:-3.4s}@keyframes drift{0%{transform:translate(0);opacity:.25}50%{opacity:.8}to{transform:translate(14px,-18px);opacity:.3}}.probe{position:absolute;width:30px;height:30px;margin:-15px 0 0 -15px;border:2px solid rgba(244,234,210,.9);border-radius:50%;box-shadow:0 0 0 3px #f4ead22e,0 0 14px #f4ead240;display:none;pointer-events:none}.probe.active{display:block}.probe:after{content:"";position:absolute;left:50%;top:50%;width:4px;height:4px;margin:-2px 0 0 -2px;border-radius:50%;background:var(--cream)}.hint-meter-wrap{position:absolute;left:50%;bottom:52px;transform:translate(-50%);width:min(300px,62%);height:10px;border-radius:999px;background:#090e1eb8;border:1px solid rgba(244,234,210,.22);overflow:hidden;display:none;pointer-events:none}.hint-meter-wrap.on{display:block}.hint-meter{height:100%;width:0%;border-radius:999px;background:linear-gradient(90deg,var(--cold),var(--warm))}.hint-arrow{position:absolute;left:50%;bottom:70px;width:26px;height:26px;margin-left:-13px;color:var(--amber);opacity:0;display:none;pointer-events:none;filter:drop-shadow(0 0 6px rgba(255,182,72,.5))}.hint-arrow.on{display:block}.cow-reveal{position:absolute;transform:translate(-50%,-100%);pointer-events:none;animation:pop .5s cubic-bezier(.2,1.6,.4,1) both}.cow{width:clamp(72px,14vw,120px);height:auto;display:block}.cow-body,.cow-head,.cow-ear,.cow-leg{fill:#f7f3e8}.cow-patch{fill:#35302a}.cow-muzzle{fill:#eda3b4}.cow-nostril{fill:#b95f76}.cow-eye{fill:#26221d}.cow-horn{fill:none;stroke:#e5dcc4;stroke-width:4;stroke-linecap:round}.cow-shadow{fill:#0508128c}@keyframes pop{0%{transform:translate(-50%,-100%) scale(.3);opacity:0}to{transform:translate(-50%,-100%) scale(1);opacity:1}}.hud{position:absolute;top:10px;left:10px;right:10px;display:flex;align-items:flex-start;justify-content:space-between;gap:8px;pointer-events:none}.hud-readout{display:flex;align-items:baseline;gap:12px;background:#090e1eb8;border:1px solid rgba(244,234,210,.18);border-radius:999px;padding:8px 16px;font-variant-numeric:tabular-nums}.timer{font-size:1.15rem;font-weight:700;letter-spacing:.03em}.moo-count{color:var(--cream-dim);font-size:.85rem}.sound-toggle{pointer-events:auto;min-width:var(--control-h);min-height:var(--control-h);border-radius:50%;border:1px solid rgba(244,234,210,.25);background:#090e1eb8;color:var(--cream);cursor:pointer;display:grid;place-items:center}.sound-toggle .icon{width:22px;height:22px}.sound-toggle .icon-off,.sound-toggle[aria-pressed=false] .icon-on{display:none}.sound-toggle[aria-pressed=false] .icon-off{display:block}.sound-toggle[aria-pressed=false]{color:var(--cream-dim)}.sound-toggle:focus-visible,.primary:focus-visible{outline:3px solid var(--amber);outline-offset:2px}.coach{position:absolute;left:50%;bottom:16px;transform:translate(-50%);margin:0;width:max-content;max-width:calc(100% - 24px);text-align:center;font-size:.85rem;color:var(--cream-dim);text-shadow:0 1px 3px rgba(5,8,18,.8);pointer-events:none}.notice{position:absolute;top:64px;left:50%;transform:translate(-50%);margin:0;max-width:calc(100% - 24px);padding:9px 16px;border-radius:12px;background:#2b1a08eb;border:1px solid rgba(255,182,72,.5);color:var(--cream);font-size:.85rem;text-align:center;z-index:40}.overlay{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center;padding:16px;background:#0609169e;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);z-index:50}.overlay[hidden]{display:none}.card{background:var(--card-bg);border:1px solid rgba(255,182,72,.38);border-radius:20px;box-shadow:0 18px 48px #03050e99;padding:clamp(16px,4vmin,30px);max-width:540px;width:100%;max-height:100%;overflow-y:auto;text-align:center}.logo{margin:0 0 12px;font-size:clamp(1.7rem,7vw,2.9rem);line-height:1.06;font-weight:800;letter-spacing:.02em;color:var(--amber);text-shadow:0 2px 0 rgba(226,138,43,.35),0 0 24px rgba(255,182,72,.28)}.pitch{margin:0 auto 14px;max-width:44ch;color:var(--cream-dim)}.howto{margin:0 auto 18px;max-width:52ch;font-size:.85rem;line-height:1.7;color:var(--cream-dim)}.howto strong{color:var(--cream);font-weight:700}.primary{min-height:var(--control-h);padding:10px 30px;border:0;border-radius:999px;background:linear-gradient(180deg,var(--amber),var(--amber-deep));color:var(--ink);font:inherit;font-size:1.05rem;font-weight:800;letter-spacing:.02em;cursor:pointer;box-shadow:0 6px 18px #ffb6484d}.primary:active{transform:translateY(1px)}.tip{margin:12px auto 0;font-size:.78rem;color:#f4ead28c}.win-title{margin:4px 0 14px;font-size:clamp(1.5rem,6vw,2.2rem);font-weight:800;color:var(--amber)}.results{display:flex;justify-content:center;gap:clamp(14px,4vw,34px);margin:0 0 10px}.result dt{font-size:.75rem;text-transform:uppercase;letter-spacing:.12em;color:var(--cream-dim)}.result dd{margin:2px 0 0;font-size:1.35rem;font-weight:800;font-variant-numeric:tabular-nums}.spot{margin:0 auto 16px;font-size:.88rem;color:var(--cream-dim)}@media(max-width:480px),(max-height:460px){body{font-size:14px}.hud-readout{padding:6px 12px;gap:8px}.timer{font-size:1rem}}@media(max-height:340px){.pitch,.tip{display:none}.howto{margin-bottom:12px}.logo{margin-bottom:8px}.coach{display:none}.card{border-radius:14px}}@media(max-height:240px){.howto{display:none}.logo{font-size:1.4rem}.win-title{font-size:1.2rem;margin:0 0 10px}.results{margin-bottom:8px}}@media(prefers-reduced-motion:reduce){.fireflies i{animation:none;opacity:.4}.cow-reveal{animation:none}.primary:active{transform:none}}
</style>
<meta name="napplet-type" content="find-the-invisible-cow">
<meta name="napplet-requires" content="media">
<meta name="napplet-config-schema" content="{"$schema":"http://json-schema.org/draft-07/schema#","$version":1,"type":"object","additionalProperties":false,"properties":{"hintMode":{"type":"string","title":"Visual hints","description":"Optional on-screen guidance toward the cow, for playing without sound. Subtle shows a meter once you are close; full adds a direction arrow.","enum":["off","subtle","full"],"default":"off","x-napplet-section":"Assistance","x-napplet-order":1},"catchSize":{"type":"string","title":"Catch area","description":"How close the pointer must be to catch the cow. Large widens the catch area, which helps on touch screens.","enum":["normal","large"],"default":"normal","x-napplet-section":"Assistance","x-napplet-order":2}}}">
</head>
<body>
<!--
The runtime frames this napplet and already shows its name, so the pasture
fills the frame from the first pixel. Overlays handle start / win states.
-->
<main id="app" class="app">
<div
id="field"
class="field"
tabindex="-1"
role="application"
aria-label="Pasture. Move around to hear the invisible cow, then click or tap its spot to catch it."
>
<div class="stars" aria-hidden="true"></div>
<div class="grass" aria-hidden="true"></div>
<div class="fireflies" aria-hidden="true"><i></i><i></i><i></i><i></i><i></i><i></i></div>
<div id="probe" class="probe" aria-hidden="true"></div>
<div id="hintMeterWrap" class="hint-meter-wrap" aria-hidden="true">
<div id="hintMeter" class="hint-meter"></div>
</div>
<svg id="hintArrow" class="hint-arrow" viewBox="0 0 24 24" aria-hidden="true">
<path d="M12 2 19 20 12 16 5 20Z" fill="currentColor" />
</svg>
<div id="cowReveal" class="cow-reveal" aria-hidden="true" hidden>
<svg class="cow" viewBox="0 0 120 96" role="img" aria-label="A cartoon cow">
<ellipse cx="60" cy="88" rx="34" ry="5" class="cow-shadow" />
<rect x="26" y="34" width="64" height="40" rx="18" class="cow-body" />
<circle cx="40" cy="52" r="11" class="cow-patch" />
<circle cx="74" cy="44" r="8" class="cow-patch" />
<rect x="30" y="72" width="9" height="16" rx="4" class="cow-leg" />
<rect x="48" y="72" width="9" height="16" rx="4" class="cow-leg" />
<rect x="63" y="72" width="9" height="16" rx="4" class="cow-leg" />
<rect x="80" y="72" width="9" height="16" rx="4" class="cow-leg" />
<circle cx="90" cy="30" r="16" class="cow-head" />
<ellipse cx="46" cy="26" r="9" class="cow-ear" transform="rotate(-24 46 26)" />
<ellipse cx="76" cy="18" r="9" class="cow-ear" transform="rotate(20 76 18)" />
<path d="M100 14c3-4 8-4 9 0" class="cow-horn" />
<circle cx="96" cy="26" r="3.2" class="cow-eye" />
<circle cx="84" cy="26" r="3.2" class="cow-eye" />
<ellipse cx="90" cy="40" rx="11" ry="8" class="cow-muzzle" />
<ellipse cx="86" cy="39" rx="2.2" ry="3" class="cow-nostril" />
<ellipse cx="94" cy="39" rx="2.2" ry="3" class="cow-nostril" />
</svg>
</div>
</div>
<header class="hud">
<div class="hud-readout">
<span id="timer" class="timer">0:00.0</span>
<span id="mooCount" class="moo-count">0 moos</span>
</div>
<button
id="soundToggle"
type="button"
class="sound-toggle"
aria-pressed="true"
aria-label="Sound is on. Turn sound off."
>
<svg class="icon icon-on" viewBox="0 0 24 24" aria-hidden="true">
<path d="M4 9v6h4l5 4V5L8 9H4Z" fill="currentColor" />
<path d="M16 9c1.4 1.6 1.4 4.4 0 6M18.5 6.5c2.6 3 2.6 8 0 11" stroke="currentColor" stroke-width="1.8" fill="none" stroke-linecap="round" />
</svg>
<svg class="icon icon-off" viewBox="0 0 24 24" aria-hidden="true">
<path d="M4 9v6h4l5 4V5L8 9H4Z" fill="currentColor" />
<path d="M16.5 9.5l5 5m0-5-5 5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" />
</svg>
</button>
</header>
<p id="coach" class="coach">Listen — the moo gets louder and quicker as you close in.</p>
<p id="notice" class="notice" role="status" hidden></p>
<div id="startOverlay" class="overlay">
<div class="card">
<h1 class="logo"><span>Find the</span><br /><span>Invisible Cow</span></h1>
<p class="pitch">
An invisible cow is hiding in this pasture. Wander around: its moo gets
louder and more frequent as you get close. Catch it with a click — then it
is invisible again somewhere new.
</p>
<p class="howto" id="howto">
<strong>Mouse:</strong> move to listen, click to catch · 
<strong>Touch:</strong> press and drag, tap to catch · 
<strong>Keys:</strong> arrows to wander, Enter to catch · 
<strong>Pad:</strong> stick to wander, A to catch
</p>
<button id="startButton" type="button" class="primary" autofocus>Start hunting</button>
<p class="tip">Sound on · headphones make the hiding spot easier to hear</p>
</div>
</div>
<div id="winOverlay" class="overlay" hidden>
<div class="card">
<h2 class="win-title">You found the cow!</h2>
<dl class="results">
<div class="result">
<dt>Time</dt>
<dd id="resultTime">—</dd>
</div>
<div class="result">
<dt>Moos</dt>
<dd id="resultMoos">—</dd>
</div>
<div class="result">
<dt>Best</dt>
<dd id="resultBest">—</dd>
</div>
</dl>
<p id="resultSpot" class="spot"></p>
<button id="againButton" type="button" class="primary">Hunt again</button>
</div>
</div>
</main>
</body>
</html>
