<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Friends Casino 3D — Browser Prototype</title>
<style>
:root{--gold:#ffc95c;--panel:rgba(8,10,18,.88);--line:rgba(255,205,94,.45)}
*{box-sizing:border-box} html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#080812;color:#fff;font-family:Inter,system-ui,Segoe UI,Arial,sans-serif}
canvas{display:block}
#hud{position:fixed;inset:0;pointer-events:none}
.panel{background:var(--panel);border:1px solid var(--line);box-shadow:0 10px 30px #0008;border-radius:12px;backdrop-filter:blur(10px)}
#brand{position:absolute;left:16px;top:14px;padding:12px 15px;min-width:205px}
#brand b{display:block;color:var(--gold);letter-spacing:2px;font-size:13px} #brand strong{display:block;font-size:21px;margin-top:3px}
#wallet{position:absolute;right:16px;top:14px;padding:12px 16px;color:var(--gold);font-weight:800;font-size:18px}
#help{position:absolute;left:16px;bottom:16px;padding:12px 14px;line-height:1.7;color:#d9dbe5;font-size:13px}
kbd{background:#292b37;border:1px solid #55586a;border-radius:5px;padding:2px 6px;color:#fff}
#crosshair{position:absolute;left:50%;top:50%;width:7px;height:7px;transform:translate(-50%,-50%);border:1px solid #fff;border-radius:50%;box-shadow:0 0 6px #fff}
#hint{position:absolute;left:50%;bottom:19%;transform:translateX(-50%);padding:10px 16px;display:none;text-align:center;color:#fff;font-weight:650}
#hint span{color:var(--gold)}
#toast{position:absolute;left:50%;top:19%;transform:translateX(-50%);padding:10px 18px;opacity:0;transition:opacity .2s}
#lobby{position:fixed;inset:0;display:grid;place-items:center;background:linear-gradient(120deg,#070812eF,#0b0718d9);z-index:5}
#lobby .card{width:min(560px,calc(100% - 28px));padding:28px;background:linear-gradient(145deg,#171521f5,#080a12f5);border:1px solid #bd8b43;border-radius:20px;box-shadow:0 25px 90px #000c;text-align:center}
.eyebrow{color:var(--gold);font-size:12px;letter-spacing:4px;font-weight:800}
h1{font-size:clamp(32px,6vw,54px);line-height:.98;margin:12px 0;color:#fff;text-shadow:0 0 25px #ffb42e55}
.sub{color:#c7c6d1;line-height:1.55;margin:14px auto 22px;max-width:440px}
input{width:100%;padding:13px 14px;border-radius:9px;border:1px solid #454050;background:#0b0b14;color:#fff;font:inherit;margin:6px 0 12px;outline:none}
button{border:0;border-radius:9px;padding:13px 18px;background:linear-gradient(135deg,#ffd87b,#dc8d27);color:#211508;font-weight:900;font-size:15px;cursor:pointer}
button:hover{filter:brightness(1.1)} button.secondary{background:#242331;color:#fff;border:1px solid #514a5b}
.row{display:flex;gap:9px}.row button{flex:1}
.fine{font-size:11px;color:#9998a8;margin-top:15px}
#gameModal{position:fixed;z-index:4;inset:0;display:none;place-items:center;background:#05050bc9}
#gameModal .card{width:min(420px,calc(100% - 30px));padding:23px;text-align:center}
#gameModal h2{margin:4px 0 8px;color:var(--gold)}
#gameModal p{color:#c8c6d4;line-height:1.5}
#gameResult{min-height:25px;color:#fff;font-weight:800;margin:12px}
#players{position:absolute;right:16px;top:75px;padding:10px 13px;font-size:12px;color:#d9d7e1}
#players b{color:var(--gold)}
@media(max-width:600px){#brand{min-width:0}#brand strong{font-size:16px}#help{font-size:11px}#players{display:none}}
</style>
</head>
<body>
<div id="lobby">
<div class="card">
<div class="eyebrow">A 3D BROWSER PARTY GAME</div>
<h1>FRIENDS<br><span style="color:#ffc95c">CASINO</span></h1>
<p class="sub">Explore a neon-lit casino, wander between tables, and try arcade mini-games using <b>virtual coins only</b>. This is a playable single-browser prototype; online multiplayer is not connected yet.</p>
<input id="playerName" maxlength="16" placeholder="Your player name" value="Player">
<div class="row"><button id="startBtn">ENTER CASINO</button><button class="secondary" id="howBtn">HOW TO PLAY</button></div>
<p class="fine" id="howText">WASD move · Mouse look · E play nearby table · Esc release mouse</p>
</div>
</div>
<div id="hud">
<div id="brand" class="panel"><b>FRIENDS CASINO</b><strong>NEON LOUNGE</strong></div>
<div id="wallet" class="panel">◉ <span id="coins">1,000</span> coins</div>
<div id="players" class="panel">ROOM <b id="roomCode">LOCAL</b><br>1 PLAYER · OFFLINE</div>
<div id="crosshair"></div>
<div id="hint" class="panel"><span>E</span> — Play <b id="hintName">Mini-game</b></div>
<div id="toast" class="panel"></div>
<div id="help" class="panel"><b style="color:#ffc95c">CONTROLS</b><br><kbd>W</kbd><kbd>A</kbd><kbd>S</kbd><kbd>D</kbd> Move &nbsp; <kbd>Mouse</kbd> Look<br><kbd>E</kbd> Play nearby game &nbsp; <kbd>Esc</kbd> Unlock mouse</div>
</div>
<div id="gameModal">
<div class="card panel">
<div class="eyebrow">VIRTUAL COINS ONLY</div><h2 id="modalTitle">Lucky Dice</h2>
<p id="modalDesc">Pick a number. Win virtual coins if the dice match.</p>
<div id="modalActions" class="row"></div>
<div id="gameResult"></div>
<button class="secondary" id="closeModal">Back to casino</button>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.min.js"></script>
<script>
(() => {
const $ = id => document.getElementById(id);
let scene,camera,renderer,clock,coins=1000,active=false,nearby=null,playerName='Player';
const keys={},colliders=[],stations=[];
const modal=$('gameModal');
function setCoins(n){coins=Math.max(0,n);$('coins').textContent=coins.toLocaleString();}
function toast(msg){const t=$('toast');t.textContent=msg;t.style.opacity=1;clearTimeout(toast.timer);toast.timer=setTimeout(()=>t.style.opacity=0,2100);}
$('howBtn').onclick=()=>{$('howText').textContent='Walk around the casino and approach a glowing table or arcade machine. Press E to play a quick mini-game. Coins are imaginary and stay in this browser session.'};
$('startBtn').onclick=()=>{
playerName=($('playerName').value.trim()||'Player').slice(0,16);
$('lobby').style.display='none';
if(!renderer) init();
active=true; renderer.domElement.requestPointerLock?.(); toast('Welcome, '+playerName+'! Find a glowing game table.');
};
$('closeModal').onclick=()=>{modal.style.display='none';if(active)renderer.domElement.requestPointerLock?.();};
document.addEventListener('pointerlockchange',()=>{active=document.pointerLockElement===renderer?.domElement;});
document.addEventListener('keydown',e=>{keys[e.code]=true;if(e.code==='KeyE'&&nearby&&modal.style.display!=='grid')openGame(nearby);});
document.addEventListener('keyup',e=>keys[e.code]=false);
function mat(color,rough=.7,metal=0){return new THREE.MeshStandardMaterial({color,roughness:rough,metalness:metal});}
function box(x,y,z,sx,sy,sz,material,group=scene){const m=new THREE.Mesh(new THREE.BoxGeometry(sx,sy,sz),material);m.position.set(x,y,z);m.castShadow=true;m.receiveShadow=true;group.add(m);return m;}
function cylinder(x,y,z,rt,rb,h,material,group=scene,segments=24){const m=new THREE.Mesh(new THREE.CylinderGeometry(rt,rb,h,segments),material);m.position.set(x,y,z);m.castShadow=true;m.receiveShadow=true;group.add(m);return m;}
function glow(color,intensity=2){return new THREE.MeshStandardMaterial({color,emissive:color,emissiveIntensity:intensity,roughness:.3,metalness:.15});}
function addStation(x,z,name,type,color){
const group=new THREE.Group();group.position.set(x,0,z);scene.add(group);
cylinder(0,.45,0,1.05,1.15,.9,mat(0x26182d,.28,.35),group);
cylinder(0,.93,0,1.0,1.0,.12,glow(color,1.2),group);
cylinder(0,1.02,0,.91,.91,.08,mat(type==='dice'?0x176d53:0x132443,.3,.15),group);
cylinder(0,1.09,0,.86,.86,.035,mat(0xe5c17a,.25,.5),group);
const post=cylinder(0,1.5,0,.07,.07,.75,mat(0x5e3d24,.3,.4),group);
const sign=box(0,2.15,0,1.5,.48,.12,glow(color,2),group);sign.rotation.x=-.12;
// Textures via canvas for crisp table signage
const c=document.createElement('canvas');c.width=512;c.height=128;const ctx=c.getContext('2d');
ctx.fillStyle='#11101a';ctx.fillRect(0,0,512,128);ctx.strokeStyle='#ffcf70';ctx.lineWidth=6;ctx.strokeRect(4,4,504,120);
ctx.fillStyle='#fff2cb';ctx.font='bold 43px Arial';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(name.toUpperCase(),256,65);
const tex=new THREE.CanvasTexture(c);const signMat=new THREE.MeshBasicMaterial({map:tex,transparent:false});
const signFace=new THREE.Mesh(new THREE.PlaneGeometry(1.46,.36),signMat);signFace.position.set(0,2.15,.071);group.add(signFace);
stations.push({x,z,name,type,color,group});
const light=new THREE.PointLight(color,3,7);light.position.set(x,2,z);scene.add(light);
}
function buildCasino(){
scene.background=new THREE.Color(0x080713);scene.fog=new THREE.FogExp2(0x080713,.018);
scene.add(new THREE.HemisphereLight(0x9b9bff,0x2b111b,1.4));
const floor=mat(0x260f27,.55,.18);box(0,-.25,0,42,.5,42,floor);
// Red carpet runner and gold floor accents
box(0,.015,0,8,.025,34,mat(0x5b1028,.9));
for(let z=-15;z<=15;z+=5){box(0,.035,z,8.1,.025,.08,glow(0xc88a3a,.65));}
const wall=mat(0x170f22,.8,.1),dark=mat(0x080a16,.35,.2),gold=mat(0xc58a3b,.25,.65);
box(0,3,-20,42,6,.7,wall);box(-20,3,0,.7,6,40,wall);box(20,3,0,.7,6,40,wall);
// Wall panels, gold columns, high windows
for(let x=-17;x<=17;x+=4.25){
box(x,3,-19.55,.16,5.2,.18,gold);
box(x,4.4,-19.48,2.8,1.8,.08,dark);
box(x,5.28,-19.4,2.9,.07,.14,glow(0xffa633,1.2));
}
for(let x=-18;x<=18;x+=6){cylinder(x,3,-16.5,.28,.36,6,gold);cylinder(x,5.95,-16.5,.52,.52,.18,glow(0xffb74b,1.5));}
// Ceiling beams
for(let x=-16;x<=16;x+=8)box(x,6.1,0,.12,.12,38,gold);
// Chandelier-like rings
for(const p of [[-8,4,-7],[8,4,-7],[-8,4,8],[8,4,8]]){
const ring=new THREE.Mesh(new THREE.TorusGeometry(1.25,.08,8,36),glow(0xffb83d,2));ring.rotation.x=Math.PI/2;ring.position.set(p[0],p[1],p[2]);scene.add(ring);
const l=new THREE.PointLight(0xff9c31,2.4,10);l.position.set(...p);scene.add(l);
}
// Giant central dice
const dice=box(0,2.4,-3,1.65,1.65,1.65,mat(0xb71e36,.24,.15));dice.rotation.set(.28,.5,.22);
const plinth=cylinder(0,.5,-3,1.8,2.05,1,mat(0x22192b,.25,.5));cylinder(0,1.03,-3,1.55,1.55,.12,glow(0xffa72f,1.5));
// Dice pips on visible faces
for(let i=0;i<3;i++)for(let j=0;j<3;j++){const pip=cylinder(-.45+i*.45,2.4-.45+j*.45,-2.15,.09,.09,.035,mat(0xffe5d4));pip.rotation.x=Math.PI/2;}
addStation(-7,-1,'Lucky Dice','dice',0xff3e62);
addStation(7,-1,'Prize Wheel','wheel',0x32d9ff);
addStation(-7,7,'Card Draw','cards',0xb35cff);
addStation(7,7,'Coin Flip','coin',0xffc247);
// Slot machine arcade row
for(let i=0;i<5;i++){
const x=-14+i*2.1;
box(x,1.25,-12,.95,2.4,.7,mat(0x151625,.25,.55));
box(x,1.55,-11.62,.72,.75,.06,glow([0xff28a8,0x30d8ff,0xffb52e][i%3],1.4));
box(x,.55,-11.59,.65,.36,.07,mat(0x090a13));
cylinder(x,.3,-11.5,.1,.1,.18,gold);
const light=new THREE.PointLight([0xff28a8,0x30d8ff,0xffb52e][i%3],.8,3);light.position.set(x,1.5,-11);scene.add(light);
}
// Plants / decoration
for(const p of [[-13,-4],[13,-4],[-13,11],[13,11],[-3,-13],[3,-13]]){
cylinder(p[0],.45,p[1],.55,.65,.9,mat(0x38251e));
for(let i=0;i<7;i++){const leaf=new THREE.Mesh(new THREE.ConeGeometry(.18,1.2,6),mat(0x176746));leaf.position.set(p[0]+Math.cos(i)*.35,1.35+Math.sin(i*.7)*.15,p[1]+Math.sin(i)*.35);leaf.rotation.z=Math.cos(i)*.35;scene.add(leaf);}
}
// Decorative lamps along side walls
for(const side of [-1,1])for(let z=-12;z<=12;z+=6){
box(side*19.45,2.8,z,.12,1.1,.45,glow(side<0?0x1e9bff:0xff2b9c,1.8));
const l=new THREE.PointLight(side<0?0x1e73ff:0xff287f,1.1,8);l.position.set(side*18.6,3,z);scene.add(l);
}
}
function init(){
scene=new THREE.Scene();clock=new THREE.Clock();camera=new THREE.PerspectiveCamera(75,innerWidth/innerHeight,.1,1000);
camera.position.set(0,1.7,13);camera.rotation.order='YXZ';
renderer=new THREE.WebGLRenderer({antialias:true});renderer.setSize(innerWidth,innerHeight);renderer.setPixelRatio(Math.min(devicePixelRatio,2));renderer.shadowMap.enabled=true;renderer.shadowMap.type=THREE.PCFSoftShadowMap;renderer.toneMapping=THREE.ACESFilmicToneMapping;renderer.toneMappingExposure=1.15;document.body.appendChild(renderer.domElement);
buildCasino();
document.addEventListener('mousemove',e=>{if(document.pointerLockElement===renderer.domElement&&modal.style.display!=='grid'){camera.rotation.y-=e.movementX*.0022;camera.rotation.x-=e.movementY*.0022;camera.rotation.x=Math.max(-1.35,Math.min(1.35,camera.rotation.x));}});
addEventListener('resize',()=>{camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();renderer.setSize(innerWidth,innerHeight);});
animate();
}
function openGame(station){
document.exitPointerLock?.();$('modalTitle').textContent=station.name;$('gameResult').textContent='';
$('modalDesc').textContent='Play for fun with virtual coins. No real money is used.';
const actions=$('modalActions');actions.innerHTML='';
const add=(label,fn)=>{const b=document.createElement('button');b.textContent=label;b.onclick=fn;actions.appendChild(b);};
if(station.type==='dice'){
$('modalDesc').textContent='Choose a number from 1–6. Costs 25 virtual coins; matching the roll awards 125.';
for(let n=1;n<=6;n++)add(''+n,()=>{if(coins<25){$('gameResult').textContent='Not enough virtual coins.';return;}setCoins(coins-25);const r=1+Math.floor(Math.random()*6);$('gameResult').textContent='🎲 Rolled '+r+(r===n?' — MATCH! +125 coins':' — no match this time');if(r===n)setCoins(coins+125);});
}else if(station.type==='wheel'){
$('modalDesc').textContent='Spin the prize wheel for free. Rewards are random virtual coins.';
add('SPIN WHEEL',()=>{const r=Math.floor(Math.random()*5);const wins=[0,25,50,100,200];setCoins(coins+wins[r]);$('gameResult').textContent=wins[r]?'🎡 You won '+wins[r]+' virtual coins!':'🎡 No prize this spin — try again!';});
}else if(station.type==='cards'){
$('modalDesc').textContent='Draw a card. Red cards earn 40 virtual coins; black cards earn 10.';
add('DRAW CARD',()=>{const red=Math.random()<.5;const rank=['A','2','3','4','5','6','7','8','9','10','J','Q','K'][Math.floor(Math.random()*13)];const suit=red?['♥','♦'][Math.floor(Math.random()*2)]:['♣','♠'][Math.floor(Math.random()*2)];const win=red?40:10;setCoins(coins+win);$('gameResult').textContent=rank+suit+' — +' + win+' virtual coins';});
}else{
$('modalDesc').textContent='Call heads or tails. Costs 10 virtual coins; a correct call earns 20 back.';
add('HEADS',()=>flip('Heads'));add('TAILS',()=>flip('Tails'));
function flip(choice){if(coins<10){$('gameResult').textContent='Not enough virtual coins.';return;}setCoins(coins-10);const r=Math.random()<.5?'Heads':'Tails';if(choice===r){setCoins(coins+20);$('gameResult').textContent='🪙 '+r+' — correct! +20 coins';}else $('gameResult').textContent='🪙 '+r+' — try again!';}
}
modal.style.display='grid';
}
function animate(){
requestAnimationFrame(animate);if(!renderer)return;
const dt=Math.min(clock.getDelta(),.05);
if(document.pointerLockElement===renderer.domElement&&modal.style.display!=='grid'){
const forward=new THREE.Vector3(-Math.sin(camera.rotation.y),0,-Math.cos(camera.rotation.y));
const right=new THREE.Vector3(Math.cos(camera.rotation.y),0,-Math.sin(camera.rotation.y));
const dir=new THREE.Vector3();
if(keys.KeyW||keys.ArrowUp)dir.add(forward);if(keys.KeyS||keys.ArrowDown)dir.sub(forward);
if(keys.KeyD||keys.ArrowRight)dir.add(right);if(keys.KeyA||keys.ArrowLeft)dir.sub(right);
if(dir.lengthSq())dir.normalize().multiplyScalar(6*dt);
camera.position.x=THREE.MathUtils.clamp(camera.position.x+dir.x,-18.5,18.5);
camera.position.z=THREE.MathUtils.clamp(camera.position.z+dir.z,-18.5,18.5);
// Keep players on the floor and out of the central display
if(Math.abs(camera.position.x)<1.2&&camera.position.z>-5.2&&camera.position.z<-1.7){camera.position.x+=camera.position.x<0?-1:1;}
}
let best=2.8;nearby=null;
for(const s of stations){const d=Math.hypot(camera.position.x-s.x,camera.position.z-s.z);if(d<best){best=d;nearby=s;}}
$('hint').style.display=nearby&&document.pointerLockElement===renderer.domElement?'block':'none';
if(nearby)$('hintName').textContent=nearby.name;
renderer.render(scene,camera);
}
})();
</script>
</body>
</html>