* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05051a;
  font-family: 'Segoe UI', 'Malgun Gothic', sans-serif;
  touch-action: none;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
  font-weight: 700;
}

#hud-top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hud-box {
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 13px;
  letter-spacing: .3px;
  white-space: nowrap;
}

#hud-lives {
  display: flex;
  gap: 3px;
  font-size: 16px;
  padding-left: 2px;
}

#hud-weapon {
  font-size: 11px;
  font-weight: 800;
  color: #ffe680;
  padding-left: 2px;
  letter-spacing: .3px;
}

.icon-btn {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 7;
  pointer-events: auto;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  font-size: 14px;
}
.icon-btn:active { background: rgba(255,255,255,.25); }
.icon-btn.hidden { display: none; }
#btn-pause { right: calc(max(10px, env(safe-area-inset-right)) + 42px); }

#wave-banner {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  font-size: 26px;
  font-weight: 900;
  color: #ffd766;
  text-shadow: 0 0 14px rgba(255,215,102,.8), 0 2px 4px rgba(0,0,0,.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
}
#wave-banner.show {
  opacity: 1;
  animation: waveBannerPop .5s cubic-bezier(.2,1.4,.4,1);
}
@keyframes waveBannerPop {
  from { transform: translate(-50%, -50%) scale(.6); }
  to   { transform: translate(-50%, -50%) scale(1); }
}

/* ---------- Screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 3, 15, .68);
  backdrop-filter: blur(2px);
}
.screen.hidden { display: none; }

.panel {
  background: rgba(12, 12, 34, .94);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 16px;
  padding: 26px 24px;
  max-width: 420px;
  width: 88%;
  text-align: center;
  color: #fff;
}

.panel h1 { font-size: 24px; margin: 0 0 14px; }
.panel h2 { font-size: 24px; margin: 0 0 10px; }
.panel .tips { font-size: 13px; line-height: 1.8; opacity: .85; margin-bottom: 20px; }
#result-score { font-size: 16px; color: #ffd766; margin-bottom: 16px; font-weight: 700; }

.big-btn {
  display: block;
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
  background: linear-gradient(#7fe8ff, #4fa8ff);
  border: none;
  color: #061428;
  font-weight: 800;
  font-size: 17px;
  padding: 14px 34px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.big-btn:active { filter: brightness(.9); }

.small-btn {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 999px;
  margin-top: 12px;
}
.small-btn:active { background: rgba(255,255,255,.25); }

.name-input {
  display: block;
  width: 100%;
  max-width: 220px;
  margin: 0 auto 4px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 999px;
  padding: 9px 16px;
  color: #fff;
  font-size: 14px;
  text-align: center;
}
.name-input::placeholder { color: rgba(255,255,255,.45); }

#submit-status {
  font-size: 12px;
  color: #ffd766;
  min-height: 16px;
  margin-top: 6px;
}

.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.lb-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  max-height: 50vh;
  overflow-y: auto;
  text-align: left;
}
.lb-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  font-size: 14px;
}
.lb-list li:first-child { color: #ffd766; font-weight: 800; }
.lb-list li:nth-child(2) { color: #d8d8e0; font-weight: 700; }
.lb-list li:nth-child(3) { color: #e0a86b; font-weight: 700; }
.lb-rank { width: 22px; opacity: .7; font-size: 12px; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 700; }
.lb-empty { text-align: center; opacity: .6; padding: 20px 0; justify-content: center; }
