* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  background: #e8edf4;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  cursor: crosshair;
}

.hidden { display: none !important; }

/* ============ HUD ============ */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

#leaderboard {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 190px;
  background: rgba(16, 22, 38, 0.62);
  border-radius: 12px;
  padding: 10px 12px;
  color: #fff;
  backdrop-filter: blur(4px);
}
#leaderboard h3 {
  font-size: 13px;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 6px;
  color: #ffd43b;
}
#lb-list { list-style: none; }
#lb-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2.5px 6px;
  border-radius: 6px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.88);
}
#lb-list li.me {
  background: rgba(255, 212, 64, 0.22);
  color: #ffe08a;
  font-weight: 700;
}
.lb-rank { width: 16px; text-align: right; color: rgba(255, 255, 255, 0.55); flex: none; }
#lb-list li.me .lb-rank { color: #ffe08a; }
.lb-name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lb-mass { color: rgba(255, 255, 255, 0.65); font-size: 12px; flex: none; }

#word-hud {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  background: rgba(38, 30, 8, 0.68);
  border: 1px solid rgba(255, 176, 46, 0.45);
  border-radius: 12px;
  padding: 8px 18px;
  text-align: center;
  color: #fff;
  backdrop-filter: blur(4px);
  pointer-events: none;
}
#word-hud.hidden { display: none; }
#wg-title { font-size: 12px; color: #ffd98a; font-weight: 700; letter-spacing: 1px; }
#wg-word { font-size: 22px; font-weight: 800; letter-spacing: 4px; color: #fff; margin-top: 2px; }
#wg-tip { font-size: 11px; color: rgba(255, 255, 255, 0.6); margin-top: 2px; }

#wg-announce {
  position: fixed;
  top: 26%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 30px;
  font-weight: 900;
  color: #ffe9a8;
  text-shadow: 0 0 14px rgba(255, 176, 46, .8), 2px 2px 0 rgba(60, 40, 0, .8);
  opacity: 0;
  pointer-events: none;
  z-index: 60;
  white-space: nowrap;
}
#wg-announce.show { animation: wgAnn 2.2s ease forwards; }
@keyframes wgAnn {
  0% { opacity: 0; transform: translateX(-50%) scale(.5); }
  14% { opacity: 1; transform: translateX(-50%) scale(1.1); }
  24% { transform: translateX(-50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1.04); }
}

#score-panel {
  position: absolute;
  left: 16px;
  bottom: 16px;
  background: rgba(16, 22, 38, 0.62);
  border-radius: 12px;
  padding: 10px 14px;
  color: #fff;
  backdrop-filter: blur(4px);
  min-width: 120px;
}
.score-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-size: 14px;
  line-height: 1.7;
}
.score-label { color: rgba(255, 255, 255, 0.55); }
#score-mass { font-weight: 700; color: #ffd43b; }

#minimap {
  position: absolute;
  right: 16px;
  bottom: 16px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

#killfeed {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.feed-item {
  background: rgba(16, 22, 38, 0.68);
  color: #fff;
  font-size: 13px;
  padding: 5px 16px;
  border-radius: 999px;
  transition: opacity 0.2s;
}

#hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 22, 38, 0.55);
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  padding: 6px 18px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.6s;
}
#hint.show { opacity: 1; }

/* 触屏按钮 */
#touch-controls {
  position: fixed;
  right: 18px;
  bottom: 190px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 6;
}
.touch-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(16, 22, 38, 0.55);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  outline: none;
}
.touch-btn:active { background: rgba(77, 150, 255, 0.75); }

/* ============ 覆盖层通用 ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 18, 32, 0.52);
  backdrop-filter: blur(5px);
}
.panel {
  background: linear-gradient(180deg, #ffffff 0%, #f2f6fc 100%);
  border-radius: 22px;
  padding: 34px 46px 30px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  max-width: 92vw;
}

/* 开始菜单 */
.title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.game-title {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(120deg, #ff5b7f, #ff922b 35%, #339af0 70%, #845ef7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.deco-ball {
  display: inline-block;
  border-radius: 50%;
  box-shadow: inset -4px -6px 10px rgba(0, 0, 0, 0.15);
}
.deco-ball.b1 { width: 26px; height: 26px; background: #ff5b7f; }
.deco-ball.b2 { width: 16px; height: 16px; background: #339af0; }

.subtitle {
  margin: 10px 0 22px;
  color: #5b6b82;
  font-size: 14.5px;
}

.form-row { margin-bottom: 18px; }
#name-input {
  width: 260px;
  max-width: 80vw;
  padding: 12px 16px;
  font-size: 16px;
  text-align: center;
  border: 2px solid #dbe4f0;
  border-radius: 12px;
  outline: none;
  color: #23324a;
  background: #fff;
  transition: border-color 0.2s;
}
#name-input:focus { border-color: #339af0; }

#color-swatches {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.12s;
}
.swatch:hover { transform: scale(1.15); }
.swatch.active {
  border-color: #23324a;
  transform: scale(1.2);
  box-shadow: 0 0 0 3px rgba(51, 154, 240, 0.35);
}

.btn {
  border: none;
  border-radius: 999px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  padding: 12px 34px;
  color: #3b4a63;
  background: #e6ecf5;
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  display: block;
  margin: 4px auto 20px;
  padding: 14px 64px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #fff;
  background: linear-gradient(120deg, #339af0, #845ef7);
  box-shadow: 0 8px 20px rgba(80, 110, 240, 0.4);
}
.btn.primary:hover { box-shadow: 0 10px 26px rgba(80, 110, 240, 0.55); }

.help {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.help-item { font-size: 13px; color: #5b6b82; }
.key {
  display: inline-block;
  background: #eef2f8;
  border: 1px solid #d5deec;
  border-bottom-width: 2.5px;
  border-radius: 6px;
  padding: 1px 8px;
  margin-right: 5px;
  font-size: 12px;
  color: #23324a;
  font-weight: 700;
}
.tips { font-size: 12px; color: #93a3ba; line-height: 1.7; max-width: 340px; margin: 0 auto; }

/* 死亡结算 */
.death-title {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 3px;
  background: linear-gradient(120deg, #ff6b6b, #e8590c);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.death-killer { margin: 8px 0 22px; color: #5b6b82; font-size: 14.5px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 26px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #eef2f8;
  border-radius: 12px;
  padding: 14px 10px;
}
.stat-num { font-size: 24px; font-weight: 800; color: #23324a; }
.stat-label { font-size: 12px; color: #93a3ba; }
.btn-row { display: flex; gap: 14px; justify-content: center; }

@media (max-width: 560px) {
  .panel { padding: 26px 22px 24px; }
  .game-title { font-size: 30px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  #leaderboard { width: 150px; }
  #minimap { display: none; }
}
