* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: 'Courier New', monospace; background: #0a0612; touch-action: none; overscroll-behavior: none; }
#game { width: 100vw; height: 100vh; position: relative; }
canvas { display: block; }

#loading {
  position: absolute; inset: 0; background: radial-gradient(circle at center, #17121f 0%, #09060d 60%, #050308 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 200;
}
#loading h1, #start h1 { color: #e8b96a; font-size: clamp(28px, 7vw, 52px); letter-spacing: 6px; margin-bottom: 8px; font-weight: 300; text-align: center; }
#loading .sub, #start p.sub { color: #a89878; font-size: 11px; letter-spacing: 4px; margin-bottom: 24px; text-align: center; }
#load-bar-wrap { width: min(340px, 80vw); height: 4px; background: #1a1420; border-radius: 2px; overflow: hidden; }
#load-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #c89b4a, #e8b96a); transition: width 0.3s; }
#load-msg { color: #6a5a38; font-size: 10px; letter-spacing: 3px; margin-top: 14px; }

#start {
  position: absolute; inset: 0; background: radial-gradient(ellipse at 30% 20%, #3a1e4a 0%, #1a0e28 40%, #050308 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; z-index: 100; padding: 30px 15px; overflow-y: auto;
}
#start input {
  background: rgba(20,16,12,0.8); border: 1px solid #c89b4a; color: #e8b96a; padding: 12px 18px; font-family: inherit;
  font-size: 15px; text-align: center; letter-spacing: 2px; margin-bottom: 10px; width: min(280px, 80vw); border-radius: 3px;
}
.start-label, .start-help { color:#e8b96a; font-size:10px; letter-spacing:3px; margin-bottom:10px; text-align:center; }
.start-help { color:#a89878; letter-spacing:1px; margin-top:10px; max-width:340px; }
#char-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; max-width: 560px; width: 100%; margin-bottom: 14px; }
.char-card { background: rgba(20,16,12,0.8); border: 1px solid #3a2a1a; padding: 18px 6px; text-align: center; cursor: pointer; border-radius: 4px; }
.char-card.sel { border-color: #e8b96a; background: rgba(232,185,106,0.08); }
.char-card .cname { color: #e8b96a; font-weight: bold; font-size: 14px; }
.room-row { display:flex; gap:8px; align-items:center; margin-bottom:10px; flex-wrap:wrap; justify-content:center; }
.room-row input { margin-bottom:0; width:180px; padding:10px; font-size:13px; }
#begin { background: linear-gradient(135deg, #e8b96a, #c89b4a); color:#1a1510; border:none; padding:16px 40px; font-family:inherit; font-size:15px; letter-spacing:4px; cursor:pointer; font-weight:bold; min-height:54px; border-radius:3px; }

#hud { position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,0.55); color: #fff; padding: 8px 12px; font-size: 11px; border: 1px solid #c89b4a; pointer-events: none; line-height: 1.5; max-width: 220px; border-radius: 4px; backdrop-filter: blur(8px); }
#hud b { color: #e8b96a; }
#top-right { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.badge { background: rgba(0,0,0,0.6); color: #e8b96a; padding: 5px 10px; font-size: 10px; border: 1px solid #c89b4a; letter-spacing: 1px; pointer-events: auto; cursor: pointer; border-radius: 3px; backdrop-filter: blur(8px); }
.badge.live { background: #3a8a5a; color: #000; border-color: #7adf9a; }
.badge.offline { border-color: #a04040; color: #e88080; }
#crosshair { position:absolute; top:50%; left:50%; width:10px; height:10px; transform:translate(-50%,-50%); pointer-events:none; }
#crosshair::before, #crosshair::after { content:''; position:absolute; background:rgba(255,255,255,0.7); mix-blend-mode:difference; }
#crosshair::before { top:50%; left:0; right:0; height:1px; transform:translateY(-50%); }
#crosshair::after { left:50%; top:0; bottom:0; width:1px; transform:translateX(-50%); }
#prompt { position:absolute; bottom:200px; left:50%; transform:translateX(-50%); background:rgba(10,6,18,0.9); color:#e8b96a; padding:8px 18px; border:1px solid #c89b4a; font-size:12px; letter-spacing:2px; display:none; white-space:nowrap; border-radius:4px; box-shadow:0 0 20px rgba(200,155,74,0.3); backdrop-filter: blur(8px); }

.panel { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); background:#14100c; border:1px solid #c89b4a; padding:16px; display:none; z-index:10; box-shadow:0 20px 60px rgba(0,0,0,0.9), 0 0 40px rgba(200,155,74,0.1); max-width:95vw; max-height:92vh; overflow:auto; border-radius:6px; }
.panel h2 { color:#e8b96a; font-size:13px; margin-bottom:10px; letter-spacing:2px; text-align:center; font-weight:400; }
.panel .close { position:absolute; top:4px; right:8px; background:none; border:none; color:#e8b96a; font-size:22px; cursor:pointer; }
#whiteboard { width:min(660px,95vw); }
#board-canvas { background:#1a1814; border:1px solid #c89b4a; cursor:crosshair; width:100%; height:auto; touch-action:none; border-radius:3px; }
.tools { display:flex; gap:5px; margin-top:8px; flex-wrap:wrap; }
.tools button, .tools input[type=color], #ttt-reset, #fifa-reset, #ball-reset, #ball-shoot, #fifa-shoot {
  background:#1a1510; color:#e8b96a; border:1px solid #c89b4a; padding:8px 10px; font-family:inherit; font-size:11px; cursor:pointer; letter-spacing:1px; border-radius:3px;
}
#chat-panel, #fifa-panel, #basketball-panel { width:min(420px,94vw); }
#chat-log { background:#0f0b07; border:1px solid #4a3a28; height:min(240px,40vh); padding:10px; overflow-y:auto; font-size:12px; line-height:1.7; margin-bottom:10px; color:#d8c8a8; border-radius:3px; }
#chat-input { width:100%; background:#0f0b07; border:1px solid #c89b4a; color:#e8d8a8; padding:12px; font-family:inherit; font-size:14px; border-radius:3px; }
#ttt { display:grid; grid-template-columns:repeat(3,70px); gap:5px; justify-content:center; margin:12px 0; }
#ttt .cell { width:70px; height:70px; background:#1f1a12; border:1px solid #c89b4a; color:#e8b96a; font-size:42px; font-weight:bold; cursor:pointer; display:flex; align-items:center; justify-content:center; border-radius:3px; }
#ttt-status { text-align:center; color:#e8b96a; margin-bottom:8px; font-size:13px; }
#arcade-canvas { background:#000; border:1px solid #c89b4a; image-rendering:pixelated; margin:0 auto; border-radius:3px; }
.arcade-meta { color:#e8b96a; text-align:center; margin-top:8px; font-size:11px; }
.arcade-sub, .mini-sub { color:#a89878; font-size:11px; line-height:1.5; }
.mini-score { color:#e8b96a; font-size:16px; margin:12px 0; text-align:center; }

#error-overlay { position:absolute; inset:0; display:none; z-index:500; background:rgba(5,3,8,0.96); color:#ffb4b4; padding:24px; font:14px/1.5 monospace; overflow:auto; }
#error-overlay b { color:#ffd27a; display:block; margin-bottom:8px; }
#admin-badge, #host-badge { display:none; }
#admin-panel {
  position:absolute; left:50%; bottom:16px; transform:translateX(-50%); z-index:20; display:none; background:rgba(8,8,12,0.86); border:1px solid #c89b4a;
  border-radius:10px; padding:10px; width:min(380px,94vw); backdrop-filter: blur(10px); box-shadow:0 8px 30px rgba(0,0,0,0.5);
}
#admin-panel .admin-title { color:#e8b96a; font:700 12px/1 monospace; letter-spacing:2px; margin-bottom:8px; text-align:center; }
#admin-panel .admin-row { display:flex; gap:8px; justify-content:center; margin-bottom:8px; flex-wrap:wrap; }
#admin-panel button { background:#1a1510; color:#e8b96a; border:1px solid #c89b4a; border-radius:8px; min-width:56px; min-height:42px; padding:8px 10px; font:700 12px monospace; cursor:pointer; }
#admin-info { color:#d8c8a8; text-align:center; font:11px/1.35 monospace; min-height:28px; }

#host-panel {
  position:absolute; right:14px; top:140px; z-index:25; display:none; width:min(360px,92vw); background:rgba(9,10,16,0.94);
  border:1px solid #c89b4a; border-radius:12px; padding:12px; box-shadow:0 12px 34px rgba(0,0,0,0.55); backdrop-filter: blur(10px);
}
#host-panel h3 { color:#e8b96a; font:700 13px/1.2 monospace; letter-spacing:2px; text-align:center; margin-bottom:10px; }
#host-close { position:absolute; top:6px; right:10px; background:none; border:none; color:#e8b96a; font-size:22px; cursor:pointer; }
#host-panel .host-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:8px; margin-bottom:10px; }
#host-panel button, #host-panel input { background:#161821; color:#e8d8b0; border:1px solid #3a4a66; border-radius:8px; padding:10px; font:12px/1.2 monospace; }
#host-panel button { cursor:pointer; }
#host-panel .host-accent { border-color:#c89b4a; color:#e8b96a; }
#host-media-url { width:100%; margin-bottom:8px; }
#host-panel .host-row { display:flex; gap:8px; margin-bottom:8px; }
#host-panel .host-row > * { flex:1; }
#host-panel .host-info { color:#b8b2a5; font:11px/1.5 monospace; min-height:32px; margin-top:4px; text-align:center; }

#tv-overlay { position:fixed; display:none; z-index:18; overflow:hidden; border-radius:3px; pointer-events:none; background:#000; }
#tv-overlay iframe { width:100%; height:100%; border:none; pointer-events:none; }
#tv-audio-join {
  position:absolute; right:14px; top:250px; z-index:22; display:none; background:rgba(10,12,18,0.92); color:#e8b96a; border:1px solid #c89b4a; border-radius:10px;
  padding:8px 12px; font:11px/1.2 monospace; cursor:pointer; max-width:150px;
}

#mobile-ctrls { position:absolute; bottom:0; left:0; right:0; z-index:5; pointer-events:none; padding:15px; height:180px; display:none; }
#joystick { position:absolute; left:20px; bottom:20px; width:130px; height:130px; background:rgba(0,0,0,0.4); border:2px solid rgba(232,185,106,0.5); border-radius:50%; pointer-events:auto; touch-action:none; }
#joy-knob { position:absolute; left:40px; top:40px; width:50px; height:50px; background:rgba(232,185,106,0.85); border:2px solid #fff; border-radius:50%; pointer-events:none; }
#mobile-btns { position:absolute; right:15px; bottom:15px; display:flex; flex-direction:column; gap:8px; pointer-events:auto; }
#mobile-btns button { width:62px; height:62px; border-radius:50%; background:rgba(232,185,106,0.88); border:2px solid #fff; color:#1a1510; font-weight:bold; font-size:13px; touch-action:none; }
#mobile-btns .row { display:flex; gap:8px; }
#btn-jump { width:62px; }

@media (pointer: coarse), (max-width: 900px) {
  #mobile-ctrls { display:block; }
  #hud { font-size:10px; padding:6px 8px; max-width:160px; }
}
