const games = {
poker:{name:'德州扑克',icon:'♠️',people:'2-9人',tag:'策略',accent:'#ff4d6d',desc:'经典翻牌局,支持筹码、公共牌、喝酒惩罚。'},
dice:{name:'大话骰',icon:'🎲',people:'2-12人',tag:'酒局',accent:'#ffd166',desc:'叫点、开骰、劈/斋玩法,最适合酒桌热场。'},
six:{name:'六张牌',icon:'🃏',people:'2-8人',tag:'快节奏',accent:'#38bdf8',desc:'每人六张牌,快速比牌,节奏快、惩罚明确。'},
catch:{name:'抓二游',icon:'🧩',people:'4-8人',tag:'组队',accent:'#43e97b',desc:'抓牌、组队、对抗、结算,适合地方酒桌玩法。'}
};
let state={game:'dice',room:'A102',locked:false,history:['home']};
const $=s=>document.querySelector(s);const $$=s=>document.querySelectorAll(s);
const players=['小鱼','阿杰','Mia','老陈','可乐','Luna'];
function toast(t){const el=$('#toast');el.textContent=t;el.classList.add('show');setTimeout(()=>el.classList.remove('show'),1200)}
function show(id,push=true){$$('.screen').forEach(x=>x.classList.remove('active'));$('#'+id).classList.add('active');$$('.bottom-nav a').forEach(a=>a.classList.toggle('active',a.dataset.go===id));$('[data-back]').hidden=id==='home';$('#subtitle').textContent=id==='home'?'Drinking Game Hub':id==='room'?'房间等待中':id==='game'?'游戏进行中':id==='result'?'本局结算':'个人中心';if(push&&state.history.at(-1)!==id)state.history.push(id);window.scrollTo(0,0)}
function openModal(type){let html='';if(type==='create')html=`
`;$('#modalContent').innerHTML=html;$('#modal').classList.add('show')}
function closeModal(){$('#modal').classList.remove('show')}
function enterRoom(game='dice'){state.game=game;state.room=Math.random().toString(36).slice(2,6).toUpperCase();renderRoom();closeModal();show('room')}
function renderHome(){const grid=$('#gameGrid');grid.innerHTML=Object.entries(games).map(([k,g])=>`
`).join('')}
function renderRoom(){const g=games[state.game];$('#roomCode').textContent=state.room;$('#roomTitle').textContent=g.name+'房间';$('#roomDesc').textContent=g.desc+' 等待玩家加入,房主可调整规则并开始游戏。';$('#playerCount').textContent=players.length+'/'+g.people.split('-').pop();$('#players').innerHTML=players.map((p,i)=>`
${i===0?'👑':'🙂'}
${p}${i===0?'房主':'已准备'}
`).join('')}
function startGame(){const g=games[state.game];$('#gameTitle').textContent=g.name;$('#gameMode').textContent=state.room+' · Round 03';if(state.game==='dice'){$('#gameHint').textContent='轮到阿杰叫点,小鱼可以选择跟、加码或开骰。';$('#gameBoard').innerHTML=`