/* ============================================
   贪吃蛇大乱斗 - 暗黑电竞风格
   ============================================ */
:root {
  --bg-dark: #0a0f1a;
  --bg-card: #121a2d;
  --bg-input: #1a2540;
  --accent: #00f0ff;
  --accent2: #ff3377;
  --accent3: #ffcc00;
  --text: #c8d6e5;
  --text-light: #6b7a8f;
  --border: #1e3050;
  --radius: 12px;
  --radius-sm: 8px;
}
* { margin:0; padding:0; box-sizing:border-box; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text);
  font-family: -apple-system, 'Helvetica Neue', 'PingFang SC', sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* ── 通用 ── */
.screen { display:none; width:100%; height:100%; position:fixed; inset:0; }
.screen.active { display:flex; flex-direction:column; }

.btn {
  display:inline-flex; align-items:center; justify-content:center;
  border:none; border-radius:var(--radius);
  font-size:1rem; font-weight:600; padding:12px 24px;
  cursor:pointer; transition:all 0.2s;
  letter-spacing:1px;
}
.btn:active { transform:scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #0090cc);
  color: #000; box-shadow: 0 0 20px rgba(0,240,255,0.3);
}
.btn-primary:disabled {
  opacity:0.4; cursor:not-allowed; box-shadow:none;
}
.btn-outline {
  background:transparent; border:2px solid var(--border);
  color: var(--text);
}
.btn-danger { background:var(--accent2); color:#fff; }
.btn-sm { padding:8px 16px; font-size:0.85rem; }
.btn-lg { padding:16px 48px; font-size:1.2rem; }

/* ── 匹配大厅 ── */
.lobby-bg {
  position:absolute; inset:0;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(0,240,255,0.08) 0%, transparent 60%),
    linear-gradient(180deg, #0a0f1a 0%, #060a12 100%);
}
.lobby-content {
  position:relative; z-index:1;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  height:100%; padding:20px;
}
.logo { text-align:center; margin-bottom:40px; }
.logo h1 { font-size:2.8rem; color:var(--accent); text-shadow:0 0 30px rgba(0,240,255,0.5); }
.logo p { color:var(--text-light); margin-top:8px; font-size:0.95rem; }
.lobby-form { display:flex; flex-direction:column; gap:16px; width:80%; max-width:320px; }
.lobby-form input {
  background:var(--bg-input); border:2px solid var(--border);
  color:var(--text); font-size:1.1rem; padding:14px 20px;
  border-radius:var(--radius); text-align:center; outline:none;
}
.lobby-form input:focus { border-color:var(--accent); }
.lobby-form .btn { width:100%; }
.lobby-tips {
  display:flex; flex-direction:column; gap:6px;
  margin-top:30px; text-align:center;
  color:var(--text-light); font-size:0.85rem;
}

/* ── 等待房间 ── */
.room-header {
  display:flex; justify-content:space-between;
  padding:16px 20px; background:var(--bg-card);
  border-bottom:1px solid var(--border);
  font-size:1rem; font-weight:600;
}
.room-players {
  flex:1; display:grid; grid-template-columns:1fr 1fr;
  gap:12px; padding:20px; align-content:start;
  overflow-y:auto;
}
.room-player {
  background:var(--bg-card); border-radius:var(--radius);
  padding:16px; text-align:center;
  border:2px solid var(--border);
}
.room-player .color-dot {
  width:24px; height:24px; border-radius:50%;
  margin:0 auto 8px;
}
.room-player .name { font-size:0.95rem; font-weight:600; }
.room-player .status { font-size:0.8rem; color:var(--text-light); }
.room-player .status.ready { color:var(--accent3); }
.room-actions {
  display:flex; gap:12px; padding:16px 20px;
  background:var(--bg-card); border-top:1px solid var(--border);
}
.room-actions .btn { flex:1; }

/* ── 聊天 ── */
.room-chat {
  border-top:1px solid var(--border);
  background:var(--bg-card);
}
.chat-msgs {
  height:80px; overflow-y:auto; padding:8px 12px;
  font-size:0.85rem;
}
.chat-msgs .msg { padding:2px 0; }
.chat-msgs .msg .cname { font-weight:600; margin-right:4px; }
.chat-input-wrap {
  display:flex; border-top:1px solid var(--border);
}
.chat-input-wrap input {
  flex:1; background:var(--bg-input); border:none;
  color:var(--text); padding:10px 12px; font-size:0.9rem;
  outline:none;
}
.chat-input-wrap button {
  background:var(--accent); color:#000; border:none;
  padding:0 16px; font-weight:600; cursor:pointer;
}

/* ── 游戏界面 ── */
#game { background:#000; }
#game-hud {
  position:absolute; top:0; left:0; right:0; z-index:10;
  display:flex; justify-content:space-between; align-items:center;
  padding:8px 12px; background:rgba(0,0,0,0.6);
  font-size:0.85rem;
}
.hud-left, .hud-right { display:flex; align-items:center; gap:12px; }
#game-score { color:var(--accent3); font-weight:600; }
#game-rank { color:var(--accent); font-weight:600; }
#game-timer { color:var(--text-light); }

#game-canvas-wrap {
  position:relative; width:100%; height:100%; overflow:hidden;
}

/* ── 摇杆 ── */
#joystick-zone {
  position:absolute; bottom:40px; left:40px;
  width:140px; height:140px; z-index:20;
}
#joystick-base {
  width:100%; height:100%; border-radius:50%;
  background:rgba(255,255,255,0.08);
  border:2px solid rgba(255,255,255,0.15);
  position:relative;
}
#joystick-knob {
  width:56px; height:56px; border-radius:50%;
  background:radial-gradient(circle, var(--accent) 0%, #0090cc 100%);
  position:absolute; top:50%; left:50%;
  transform:translate(-50%,-50%);
  box-shadow:0 0 20px rgba(0,240,255,0.4);
  pointer-events:none;
}

/* ── 加速 ── */
#btn-boost {
  position:absolute; bottom:50px; right:40px; z-index:20;
  width:70px; height:70px; border-radius:50%;
  background:radial-gradient(circle, var(--accent2), #991144);
  border:3px solid rgba(255,51,119,0.5);
  color:#fff; font-size:1.5rem;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 0 25px rgba(255,51,119,0.3);
}
#btn-boost:active { transform:scale(0.92); box-shadow:0 0 40px rgba(255,51,119,0.6); }

/* ── 游戏内聊天 ── */
#btn-chat-toggle {
  position:absolute; bottom:50px; right:130px; z-index:20;
  width:50px; height:50px; border-radius:50%;
  background:rgba(255,255,255,0.1);
  border:2px solid rgba(255,255,255,0.2);
  color:#fff; font-size:1.2rem;
  display:flex; align-items:center; justify-content:center;
}
#game-chat-overlay {
  position:absolute; bottom:0; left:0; right:0; z-index:15;
  background:rgba(0,0,0,0.7);
  display:none;
}
#game-chat-overlay.open { display:block; }
#game-chat-msgs {
  height:150px; overflow-y:auto; padding:10px;
  font-size:0.85rem;
}
#game-chat-input-wrap input {
  width:100%; background:var(--bg-input); border:none;
  color:var(--text); padding:10px 12px; font-size:0.9rem;
  outline:none;
}

/* ── 死亡遮罩 ── */
#death-overlay {
  position:absolute; inset:0; z-index:30;
  background:rgba(0,0,0,0.7);
  display:flex; align-items:center; justify-content:center;
}
#death-overlay.hidden { display:none; }
.death-content { text-align:center; }
.death-content h2 { color:var(--accent2); font-size:2rem; margin-bottom:12px; }
.death-content p { color:var(--text); font-size:1.2rem; }

/* ── 玩家颜色 ── */
.color-0 { background:#ff3377; }
.color-1 { background:#00f0ff; }
.color-2 { background:#ffcc00; }
.color-3 { background:#33ff77; }
.color-4 { background:#ff8800; }
.color-5 { background:#bb77ff; }

/* ── 响应式 ── */
@media (max-width:480px) {
  .logo h1 { font-size:2rem; }
  .room-players { grid-template-columns:1fr 1fr; gap:8px; padding:12px; }
  #joystick-zone { width:120px; height:120px; bottom:30px; left:30px; }
  #joystick-knob { width:48px; height:48px; }
  #btn-boost { width:60px; height:60px; bottom:40px; right:30px; font-size:1.2rem; }
}
