* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: #0b0e14; font-family: 'Segoe UI', 'Noto Sans', sans-serif; color: #e8ecf4; -webkit-user-select: none; user-select: none; }
canvas.gl { display: block; position: fixed; inset: 0; }
.hidden { display: none !important; }
.touch-only { display: none; }
body.touch .touch-only { display: block; }
body.touch #hint { display: none; }

#menu { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 700px at 50% 20%, #1d2a44 0%, #0b0e14 70%); }
.menu-inner { text-align: center; padding: 24px; max-width: 560px; width: 100%; }
.logo-sub { letter-spacing: 4px; font-size: 12px; color: #7fd0ff; margin-bottom: 10px; }
h1 { font-size: clamp(44px, 9vw, 84px); font-weight: 900; font-style: italic; letter-spacing: 2px; line-height: .95;
  color: #f4f7ff; text-shadow: 0 6px 30px rgba(60,140,255,.45); }
h1 span { display: block; color: #ffc23d; }
.tag { margin: 14px 0 26px; color: #9fb0c8; font-size: 14px; }
.nick-label { display: block; text-align: left; font-size: 11px; letter-spacing: 2px; color: #7fd0ff; margin-bottom: 6px; }
#nick { width: 100%; padding: 13px 16px; font-size: 17px; background: #121826; border: 1px solid #2c3a55; color: #fff; border-radius: 6px; outline: none; }
#nick:focus { border-color: #ffc23d; }
#play { margin-top: 16px; width: 100%; padding: 15px; font-size: 17px; font-weight: 800; letter-spacing: 2px; cursor: pointer;
  background: linear-gradient(180deg, #ffd35e, #f0a92c); color: #201500; border: 0; border-radius: 6px; }
#play:active { transform: scale(.98); }
.menu-foot { margin-top: 18px; font-size: 12px; color: #6d7d96; }
#srv-status.ok { color: #4ade80; }

#loading { position: fixed; inset: 0; z-index: 25; background: #0b0e14; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; color: #ffc23d; letter-spacing: 2px; }
.star { font-size: 44px; animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#topbar { position: absolute; top: 12px; left: 12px; }
#srv-box { background: rgba(10,14,22,.72); border: 1px solid #2c3a55; border-left: 4px solid #ffc23d; padding: 8px 12px; border-radius: 4px; display: flex; gap: 12px; align-items: baseline; font-size: 12px; }
#srv-box b { letter-spacing: 2px; font-size: 13px; }
#ping { color: #7fd0ff; } #online { color: #4ade80; }
#players-panel { position: absolute; top: 12px; right: 12px; width: 210px; background: rgba(10,14,22,.72); border: 1px solid #2c3a55; border-radius: 4px; padding: 8px 10px; font-size: 12px; }
.pp-title { font-size: 10px; letter-spacing: 2px; color: #7fd0ff; margin-bottom: 6px; }
#players-list div { display: flex; justify-content: space-between; padding: 2px 0; }
#players-list .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
#chat-log { position: absolute; left: 12px; bottom: 64px; width: min(420px, 70vw); font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
#chat-log div { background: rgba(10,14,22,.66); padding: 4px 8px; border-radius: 4px; animation: fade 12s forwards; }
@keyframes fade { 0%,80% { opacity: 1; } 100% { opacity: 0; } }
#chat-bar { position: absolute; left: 12px; bottom: 20px; width: min(420px, 80vw); pointer-events: auto; }
#chat-input { width: 100%; padding: 10px 12px; background: rgba(12,18,30,.92); border: 1px solid #ffc23d; color: #fff; border-radius: 6px; font-size: 14px; outline: none; }
#hint { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); background: rgba(10,14,22,.72); border: 1px solid #2c3a55; padding: 7px 14px; border-radius: 4px; font-size: 12px; color: #cfd8e6; white-space: nowrap; }
#conn-lost { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); background: #5a1620; border: 1px solid #ff4d5e; padding: 8px 16px; border-radius: 4px; font-size: 13px; }

#joy { position: absolute; left: 22px; bottom: 26px; width: 128px; height: 128px; border-radius: 50%; background: rgba(20,28,44,.5); border: 2px solid rgba(127,208,255,.4); pointer-events: auto; touch-action: none; }
#joy-knob { position: absolute; left: 44px; top: 44px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,194,61,.85); }
#touch-btns { position: absolute; right: 18px; bottom: 30px; display: flex; gap: 12px; pointer-events: auto; }
#touch-btns button { width: 62px; height: 62px; border-radius: 50%; border: 2px solid rgba(127,208,255,.5); background: rgba(20,28,44,.6); color: #fff; font-size: 20px; font-weight: 700; touch-action: none; }
#touch-btns button:active { background: rgba(255,194,61,.7); color: #201500; }
@media (max-width: 700px) {
  #players-panel { width: 150px; font-size: 11px; }
  #chat-log { bottom: 170px; }
}
