* { margin:0; padding:0; box-sizing:border-box; }
:root {
  --bg:#0f1220; --panel:#1a1f35; --panel2:#232a48; --line:#2e375c;
  --text:#e8ecff; --muted:#8b94b8; --accent:#5b8cff; --accent2:#34d399;
}
html,body {
  height:100%; background:var(--bg); color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,'PingFang SC','Microsoft YaHei',sans-serif;
  -webkit-user-select:none; user-select:none;
}
#app { min-height:100vh; padding:0; }
.panel-wrap { min-height:100vh; }
.hidden { display:none !important; }

/* ============ 面板 1：登录/注册 ============ */
#panel-auth {
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  background: radial-gradient(800px 600px at 50% -20%, #1e2a5a 0%, var(--bg) 60%);
}
.auth-card {
  width:min(420px,92%); background:var(--panel); border:1px solid var(--line);
  border-radius:18px; padding:34px 30px; box-shadow:0 20px 60px rgba(0,0,0,.5);
}
.auth-card h1 { font-size:28px; text-align:center; margin-bottom:4px; }
.auth-sub { color:var(--muted); text-align:center; font-size:13px; margin-bottom:18px; }
.auth-tabs { display:flex; gap:4px; background:var(--panel2); border-radius:10px; padding:4px; margin-bottom:16px; }
.auth-tabs .tab {
  flex:1; padding:8px 0; border:none; background:transparent; color:var(--muted);
  border-radius:8px; font-size:14px; font-weight:600; cursor:pointer;
}
.auth-tabs .tab.active { background:var(--accent); color:#fff; }
.auth-body input {
  width:100%; padding:12px 14px; margin-bottom:10px; border-radius:10px;
  border:1px solid var(--line); background:var(--panel2); color:var(--text);
  font-size:15px; outline:none;
}
.auth-body input:focus { border-color:var(--accent); }
.auth-body button, .auth-foot button {
  width:100%; padding:12px; font-size:16px; font-weight:700; color:#fff;
  background:linear-gradient(135deg,var(--accent),#7c5bff); border:none;
  border-radius:10px; cursor:pointer; margin-top:6px;
}
.auth-foot { margin-top:18px; border-top:1px solid var(--line); padding-top:14px; font-size:12px; color:var(--muted); line-height:1.8; }
.error { color:#ff7b7b; font-size:13px; margin-top:8px; min-height:18px; text-align:center; }

/* ============ 面板 2：大厅 ============ */
#lobby-header {
  display:flex; justify-content:space-between; align-items:center;
  padding:14px 24px; border-bottom:1px solid var(--line); background:var(--panel);
}
.lobby-brand { font-size:18px; font-weight:700; }
.lobby-user { display:flex; gap:12px; align-items:center; font-size:14px; color:var(--muted); }
.lobby-user button {
  padding:5px 12px; border-radius:8px; border:1px solid var(--line);
  background:var(--panel2); color:var(--muted); font-size:13px; cursor:pointer;
}
.lobby-user button:hover { color:#fff; border-color:#ff6b6b; }
#lobbyUserName { color:var(--text); font-weight:600; }
#lobbyBest { font-size:12px; color:var(--accent2); }

.lobby-body {
  display:flex; gap:16px; padding:16px 24px; max-width:1120px; margin:0 auto;
}
.lobby-left { flex:1; min-width:0; }
.lobby-right { width:300px; flex-shrink:0; }
.lobby-left h3, .lobby-right h3 { font-size:14px; margin-bottom:10px; color:var(--muted); display:flex; justify-content:space-between; align-items:center; }
.ghost-btn {
  padding:4px 10px; border-radius:6px; border:1px solid var(--line); background:transparent;
  color:var(--muted); font-size:12px; cursor:pointer;
}
.ghost-btn:hover { color:#fff; border-color:var(--accent); }

.room-list { display:flex; flex-direction:column; gap:8px; }
.room-row {
  display:flex; justify-content:space-between; align-items:center;
  background:var(--panel); border:1px solid var(--line); border-radius:10px;
  padding:10px 14px; cursor:pointer; transition:border-color .15s;
}
.room-row:hover { border-color:var(--accent); }
.room-row.locked { opacity:.7; }
.room-row .room-name { font-weight:600; color:var(--text); }
.room-row .room-meta { font-size:12px; color:var(--muted); }
.room-row .room-pass { font-size:11px; color:#fbbf24; margin-left:8px; }

.create-room { background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:14px; display:flex; gap:8px; flex-wrap:wrap; }
.create-room input {
  flex:1; min-width:120px; padding:8px 10px; border-radius:8px; border:1px solid var(--line);
  background:var(--panel2); color:var(--text); font-size:14px; outline:none;
}
.create-room input:focus { border-color:var(--accent); }
.create-room button {
  padding:8px 16px; border-radius:8px; border:none; cursor:pointer; font-weight:600; font-size:14px;
  background:linear-gradient(135deg,var(--accent),#7c5bff); color:#fff;
}

/* 排行榜 */
#rankList { list-style:none; background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:10px; }
#rankList li {
  display:flex; justify-content:space-between; padding:6px 8px; border-radius:6px; font-size:14px;
}
#rankList li.me { background:var(--panel2); }
#rankList .rk { color:var(--muted); font-weight:700; width:24px; }
#rankList li.top1 .rk { color:#ffd34d; }
#rankList li.top2 .rk { color:#cfd8e3; }
#rankList li.top3 .rk { color:#e0915b; }
#rankList .nm { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#rankList .sc { font-weight:700; color:var(--accent2); }

/* ============ 聊天（大厅 + 房间） ============ */
.chat-box {
  background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:10px;
  height:160px; overflow-y:auto; font-size:13px; line-height:1.7;
}
.chat-box .msg { margin-bottom:2px; word-break:break-all; }
.chat-box .from { color:var(--accent); font-weight:600; margin-right:6px; }
.chat-box .from.sys { color:#fbbf24; font-weight:600; }
.chat-box .from.me { color:var(--accent2); font-weight:600; }
.chat-input { display:flex; gap:8px; margin-top:6px; }
.chat-input input {
  flex:1; padding:8px 10px; border-radius:8px; border:1px solid var(--line);
  background:var(--panel2); color:var(--text); font-size:13px; outline:none;
}
.chat-input input:focus { border-color:var(--accent); }
#roomChatInput { width:100%; }

/* ============ 面板 3：游戏 ============ */
#panel-game { padding:16px; max-width:1200px; margin:0 auto; display:flex; gap:16px; align-items:flex-start; }
#stage { width:840px; max-width:100%; }
#topbar { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; flex-wrap:wrap; gap:8px; }
.brand { font-size:18px; font-weight:700; }
.brand span { color:var(--accent); }
.hud-item {
  background:var(--panel); border:1px solid var(--line); border-radius:999px;
  padding:6px 14px; margin-left:8px; font-size:13px;
}

#canvasWrap {
  position:relative; width:100%; aspect-ratio:840/600; border-radius:14px; overflow:hidden;
  border:1px solid var(--line); box-shadow:0 12px 40px rgba(0,0,0,.45);
}
#game { display:block; width:100%; height:100%; background:#11152a; touch-action:none; }

.overlay {
  position:absolute; inset:0; background:rgba(10,13,28,.85); backdrop-filter:blur(4px);
  display:flex; align-items:center; justify-content:center; z-index:10;
}
.overlay.hidden { display:none; }
.panel {
  background:var(--panel); border:1px solid var(--line); border-radius:16px;
  padding:28px 32px; text-align:center; width:min(420px,90%);
}
.panel.small { width:min(340px,86%); padding:24px; }
.panel h2 { font-size:20px; margin-bottom:14px; }

.speed-row { display:flex; gap:8px; margin-bottom:14px; }
.speed-btn {
  flex:1; padding:9px 0; font-size:13px; font-weight:600;
  background:var(--panel2); border:1px solid var(--line); border-radius:10px; color:var(--muted);
  cursor:pointer;
}
.speed-btn.active { background:var(--accent); border-color:var(--accent); color:#fff; }

#enterBtn, #respawnBtn {
  width:100%; padding:12px; font-size:15px; font-weight:700; color:#fff;
  background:linear-gradient(135deg,var(--accent),#7c5bff); border:none;
  border-radius:10px; cursor:pointer;
}
.dead-msg { color:var(--muted); font-size:13px; margin:8px 0; }

/* 房间侧栏 */
#sidebar { width:260px; flex-shrink:0; }
.sidebar-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.member-list { list-style:none; background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:8px 10px; }
.member-list li { display:flex; justify-content:space-between; padding:5px 4px; font-size:13px; }
.member-list li.me { color:var(--accent2); font-weight:600; }
.member-list .dot { width:10px; height:10px; border-radius:3px; flex-shrink:0; }
.member-list .left { display:flex; align-items:center; gap:6px; min-width:0; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.member-list .nm { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* 排行游戏面板里的侧栏 */
.game-sidebar #rankList { max-height:180px; overflow-y:auto; }
.game-sidebar h3 { margin-top:14px; }

/* toast 提示 */
#toast {
  position:absolute; top:14px; left:50%; transform:translateX(-50%);
  background:rgba(220,70,70,.95); color:#fff; padding:8px 18px; border-radius:999px; font-size:14px; z-index:20;
}

/* 响应式 */
@media (max-width:1100px) {
  #panel-game { flex-direction:column; }
  #sidebar { width:840px; max-width:100%; }
  .lobby-body { flex-direction:column; }
  .lobby-right { width:100%; }
}
