* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #0a0a0f;
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: #e0e0e0;
  /* 禁用长按选择、文本选择 */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* Screens */
.screen { display: none; position: absolute; inset: 0; }
.screen.active { display: flex; align-items: center; justify-content: center; }

/* Lobby */
.lobby-box {
  text-align: center;
  padding: 2rem;
  background: rgba(255,255,255,0.05);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1);
  width: min(90vw, 360px);
}
.lobby-box h1 { font-size: 2rem; margin-bottom: 0.3rem; }
.subtitle { color: #888; font-size: 0.9rem; margin-bottom: 1.5rem; }

.btn {
  display: inline-block;
  padding: 0.7rem 2rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  background: rgba(255,255,255,0.1);
  color: #e0e0e0;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { background: rgba(255,255,255,0.2); }
.btn.primary { background: #2d7d46; width: 100%; }
.btn.primary:active { background: #3a9e58; }

.divider { color: #555; margin: 1rem 0; font-size: 0.85rem; }

.join-row { display: flex; gap: 0.5rem; }
.join-row input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: #e0e0e0;
  font-size: 16px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  outline: none;
  -webkit-appearance: none;
}
.join-row input::placeholder { color: #555; letter-spacing: 0; text-transform: none; }
.join-row .btn { padding: 0.7rem 1.2rem; background: #2d5a7d; flex-shrink: 0; }
.join-row .btn:active { background: #3a7aa0; }

.msg { color: #e74c3c; margin-top: 1rem; font-size: 0.85rem; min-height: 1.2em; }

/* Help button */
.btn-help {
  display: inline-block;
  margin-top: 1.2rem;
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  background: rgba(255,255,255,0.06);
  color: #888;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-help:active { background: rgba(255,255,255,0.12); color: #bbb; }

/* Help overlay */
.help-box {
  text-align: left;
  background: rgba(15,15,30,0.95);
  border: 1px solid rgba(100,100,255,0.2);
  width: min(90vw, 380px);
  max-height: 80vh;
  overflow-y: auto;
}
.help-box h2 { text-align: center; margin-bottom: 1rem; }
.help-content { margin-bottom: 1.5rem; }
.help-section { margin-bottom: 1rem; }
.help-section h3 { font-size: 0.95rem; margin-bottom: 0.3rem; color: #aaa; }
.help-section p { font-size: 0.85rem; color: #777; line-height: 1.6; margin-left: 0.5rem; }

/* Waiting */
.room-code {
  font-size: 3rem;
  letter-spacing: 0.5em;
  font-weight: bold;
  color: #4ade80;
  margin: 0.5rem 0;
}
.loading-dots span { animation: blink 1.4s infinite; font-size: 2rem; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity: 0.2; } 40% { opacity: 1; } }

/* Game */
#game-canvas { display: block; width: 100%; height: 100%; }
#game-screen.active { display: block; }

#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  pointer-events: none;
  font-size: 0.95rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.exit-indicator { font-size: 1.3rem; }

/* Joystick */
#joystick-zone {
  position: absolute;
  bottom: 30px; left: 30px;
  width: 120px; height: 120px;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
}
#joystick-base {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  position: relative;
}
#joystick-stick {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  transition: background 0.1s;
  pointer-events: none;
}

/* Overlay */
.overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.overlay.hidden { display: none; }
.overlay-box {
  text-align: center;
  padding: 2.5rem;
  background: rgba(45,125,70,0.3);
  border-radius: 16px;
  border: 1px solid rgba(74,222,128,0.3);
  animation: popIn 0.4s ease;
}
.overlay-box h2 { font-size: 2rem; margin-bottom: 0.5rem; }
@keyframes popIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Mute button */
.mute-btn {
  font-size: 1.2rem;
  cursor: pointer;
  margin-right: 8px;
  opacity: 0.7;
  transition: opacity 0.2s;
  pointer-events: auto;
}
.mute-btn:active { opacity: 1; }
#hud-right { display: flex; align-items: center; }

/* Toast */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(0,0,0,0.85);
  color: #e0e0e0;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.95rem;
  z-index: 200;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
