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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  font-family: system-ui, sans-serif;
  touch-action: none; /* 휴대폰에서 화면이 끌려 다니지 않게 */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

canvas { display: block; }

#hud {
  position: fixed;
  top: 12px;
  left: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #fff;
  text-align: center;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}

#hud .hint { font-size: 12px; opacity: 0.7; }

/* ---------- 체력바 ---------- */
#hp-bar {
  position: relative;
  width: min(260px, 70vw);
  height: 18px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.5);
  overflow: hidden;
}

#hp-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(#ff6b5a, #d7322a);
  transition: width 0.15s;
}

#hp-text {
  position: absolute;
  inset: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
}

/* ---------- 점수 ---------- */
#score-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

#score {
  font-size: 30px;
  font-weight: 900;
  color: #ffd75a;
  display: inline-block;
}

/* 점수가 오를 때 톡 튀어요 */
#score.bump { animation: bump 0.2s ease-out; }

@keyframes bump {
  50% { transform: scale(1.25); }
}

#best { font-size: 12px; opacity: 0.75; }

/* ---------- 웨이브 ---------- */
#wave-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
}

#wave-bar {
  width: 90px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

#wave-fill {
  width: 0%;
  height: 100%;
  background: #ff9a3c;
}

#stats { font-size: 13px; font-weight: 700; }
#ammo.empty { color: #ff6b5a; }
#buff { font-size: 13px; font-weight: 700; color: #5fe3ff; min-height: 1em; }

/* ---------- 떠오르는 글자 (+40 탄약 등) ---------- */
.pop {
  position: fixed;
  transform: translate(-50%, -100%);
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
  text-shadow: 0 1px 3px #000, 0 0 2px #000;
  pointer-events: none;
  animation: pop-up 0.9s ease-out forwards;
}

/* 특수 능력을 얻었을 때 화면 가운데에 크게 */
.pop.big {
  font-size: 30px;
  animation-duration: 1.6s;
}

@keyframes pop-up {
  from { opacity: 1; margin-top: 0; }
  to { opacity: 0; margin-top: -40px; }
}

/* ---------- 맞았을 때 빨간 테두리 ---------- */
#hurt {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(220, 20, 20, 0.85) 100%);
  opacity: 0;
}

/* ---------- 소리 버튼 ---------- */
#mute-btn {
  position: fixed;
  top: 10px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  font-size: 20px;
  cursor: pointer;
  z-index: 5;
}

/* ---------- 시작 / 게임 오버 화면 ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  text-align: center;
  animation: fade-in 0.4s ease-out;
}

.screen[hidden] { display: none; }
.screen p { font-size: 17px; line-height: 1.6; }

@keyframes fade-in {
  from { opacity: 0; }
}

.title {
  font-size: 52px;
  font-weight: 900;
  line-height: 1.05;
  color: #9bd35a;
  text-shadow: 0 4px 0 #2d4a12, 0 0 24px rgba(155, 211, 90, 0.5);
}

.how { opacity: 0.85; }
#start-best { color: #ffd75a; font-weight: 800; }

.go-title {
  font-size: 46px;
  font-weight: 900;
  color: #ff5a4a;
  text-shadow: 0 4px 0 #5a1010;
  animation: drop-in 0.5s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@keyframes drop-in {
  from { transform: translateY(-80px) scale(1.4); opacity: 0; }
}

#new-record {
  font-size: 22px;
  font-weight: 900;
  color: #ffd75a;
  animation: shine 0.8s ease-in-out infinite alternate;
}

#new-record[hidden] { display: none; }

@keyframes shine {
  to { transform: scale(1.12); text-shadow: 0 0 18px #ffd75a; }
}

.final-score { display: flex; flex-direction: column; align-items: center; }
.final-score small { font-size: 14px; opacity: 0.75; }
.final-score b { font-size: 56px; font-weight: 900; color: #ffd75a; line-height: 1.1; }

.btn-row { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.big-btn {
  padding: 14px 44px;
  border: none;
  border-radius: 999px;
  background: #ffcc33;
  color: #222;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0 #b8860b;
}

.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #b8860b; }

.small-btn {
  padding: 8px 20px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- 조이스틱 ---------- */
/* 평소에는 화면 아래 가운데에 흐리게 있다가, 누르면 누른 자리로 옮겨 가요 */
.stick {
  position: fixed;
  left: 50%;
  bottom: 40px;
  width: 130px;
  height: 130px;
  margin-left: -65px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.25);
  opacity: 0.5;
  pointer-events: none;
}

.stick.active {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.6);
}

.knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
}
