* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #10131a;
  color: #e6e9ef;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.screen.active { display: flex; }

.card {
  background: #1a1f2b;
  border: 1px solid #262d3d;
  border-radius: 18px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
  padding: 28px;
}

.home-card { width: 100%; max-width: 380px; text-align: center; }
.home-card h1 { margin: 0 0 6px; font-size: 28px; }
.subtitle { color: #8b93a7; margin: 0 0 22px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; margin-bottom: 14px; }
.field span { font-size: 13px; color: #8b93a7; font-weight: 600; }
.field input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid #2c3446;
  font-size: 15px;
  outline: none;
  background: #141926;
  color: #e6e9ef;
}
.field input:focus { border-color: #e2574c; background: #171d2b; }

.btn {
  width: 100%;
  padding: 11px 16px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .06s ease, opacity .15s ease;
  margin-bottom: 8px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: #e2574c; color: #fff; }
.btn-secondary { background: #2c3446; color: #e6e9ef; }
.btn-ghost { background: transparent; color: #8b93a7; border: 1.5px solid #2c3446; }
.btn.small { width: auto; padding: 6px 12px; font-size: 13px; margin: 0; }

.divider { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: #5b6478; font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: #262d3d; }

.error-text { color: #ff7a6e; font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.hint { color: #6f7a90; font-size: 13px; margin: 8px 0 0; text-align: center; }

/* ---------------- 大厅 ---------------- */
.lobby-card { width: 100%; max-width: 460px; }
.lobby-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.lobby-header h2 { margin: 0; font-size: 13px; color: #8b93a7; font-weight: 600; }
.room-code { font-size: 30px; font-weight: 800; letter-spacing: 6px; color: #e2574c; }

.player-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.player-row {
  display: flex; align-items: center; gap: 10px;
  background: #141926; border-radius: 10px; padding: 9px 12px; font-size: 14px;
}
.player-dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.player-row .tag { margin-left: auto; font-size: 12px; color: #6f7a90; }

.rules { background: #141926; border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; }
.rules p { margin: 0 0 8px; font-size: 12.5px; color: #98a1b5; line-height: 1.6; }
.rules p:last-child { margin-bottom: 0; }
.rules b { color: #c3cbdd; }
kbd {
  display: inline-block; background: #232b3b; border: 1px solid #333d52; border-bottom-width: 2px;
  border-radius: 4px; padding: 0 5px; font-size: 11px; font-family: inherit; margin: 0 1px; color: #d5dbe8;
}

/* ---------------- 战斗 ---------------- */
#screen-game { align-items: flex-start; padding: 12px; }
.game-layout { width: 100%; max-width: 780px; margin: 0 auto; }

.scoreboard { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.score-chip {
  display: flex; align-items: center; gap: 8px;
  background: #1a1f2b; border: 1px solid #262d3d; border-radius: 10px; padding: 7px 12px;
  font-size: 13px; transition: border-color .2s;
}
.score-chip.dead { opacity: .45; }
.score-chip.me { border-color: #4a5771; }
.score-chip .n { font-weight: 700; font-size: 16px; margin-left: 2px; }

.arena-wrap { position: relative; width: 100%; }
canvas {
  display: block; width: 100%; height: auto;
  background: #0c0f16;
  border: 1px solid #262d3d;
  border-radius: 12px;
  touch-action: none;
}

.center-msg {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(26px, 6vw, 46px); font-weight: 800;
  color: #fff; text-shadow: 0 4px 20px rgba(0,0,0,.8);
  pointer-events: none; opacity: 0; transition: opacity .15s;
}
.center-msg.show { opacity: 1; }

.game-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; gap: 10px; flex-wrap: wrap;
}
.weapon-box {
  display: flex; align-items: center; gap: 8px;
  background: #1a1f2b; border: 1px solid #262d3d; border-radius: 10px; padding: 7px 14px;
}
.weapon-label { font-weight: 700; font-size: 14px; }
.weapon-ammo { color: #8b93a7; font-size: 13px; }
.footer-right { display: flex; align-items: center; gap: 8px; }
.round-tag { font-size: 13px; color: #6f7a90; }
.round-tag b { color: #c3cbdd; }

/* 触屏手柄 */
.touch-pad { display: none; margin-top: 12px; align-items: center; justify-content: space-between; gap: 12px; }
.pad-left { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 50px); gap: 6px; }
.pad-left .pad-btn:nth-child(1) { grid-area: 1 / 1 / 3 / 2; }
.pad-left .pad-btn:nth-child(2) { grid-area: 1 / 2 / 2 / 3; }
.pad-left .pad-btn:nth-child(3) { grid-area: 2 / 2 / 3 / 3; }
.pad-left .pad-btn:nth-child(4) { grid-area: 1 / 3 / 3 / 4; }
.pad-btn {
  background: #1a1f2b; border: 1px solid #303a4d; color: #c3cbdd;
  border-radius: 12px; font-size: 18px; font-weight: 700; cursor: pointer;
  user-select: none; -webkit-user-select: none;
}
.pad-btn:active, .pad-btn.on { background: #2c3446; }
.pad-btn.fire { width: 96px; height: 106px; font-size: 16px; background: #7a2f28; border-color: #a03a31; color: #fff; }
body.touch .touch-pad { display: flex; }

/* 结算 */
.overlay {
  position: fixed; inset: 0; background: rgba(8, 10, 16, .82);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20;
}
.overlay-card {
  background: #1a1f2b; border: 1px solid #262d3d; border-radius: 18px;
  padding: 28px; width: 100%; max-width: 360px; text-align: center;
}
.overlay-card h3 { margin: 0 0 18px; font-size: 22px; }
.final-scores { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.final-row {
  display: flex; align-items: center; gap: 10px;
  background: #141926; border-radius: 10px; padding: 9px 12px; font-size: 14px;
}
.final-row .n { margin-left: auto; font-weight: 800; font-size: 17px; }

@media (max-width: 620px) {
  .card { padding: 22px; }
  #screen-game { padding: 8px; }
}
