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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #cdcdcd;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none; /* 모바일 브라우저 기본 제스처, 스크롤, 핀치줌 방지 */
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* 상단 레벨 및 경험치 바 UI (심플 & 단색) */
#header-ui {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
}

.level-badge {
  background: #ff9800;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1.5px solid #444444;
  min-width: 48px;
  text-align: center;
}

.exp-container {
  position: relative;
  width: 240px;
  height: 16px;
}

.exp-bar-bg {
  width: 100%;
  height: 100%;
  background: #333333;
  border: 1.5px solid #444444;
  border-radius: 6px;
  overflow: hidden;
}

.exp-bar-fill {
  width: 0%;
  height: 100%;
  background: #00b2e1;
  border-radius: 4px;
  transition: width 0.15s ease-out;
}

.exp-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.3px;
}

/* ==========================================
   좌측 하단 Diep.io 스타일 스탯 HUD
   ========================================== */
#stat-hud {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 15;
  background: rgba(26, 26, 28, 0.92);
  border: 1.5px solid #444444;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
}

#stat-hud.hidden {
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
}

.stat-points-badge {
  background: #ff9800;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid #444444;
  margin-bottom: 6px;
  text-align: center;
  letter-spacing: 0.3px;
  animation: pulsePoint 1.2s infinite ease-in-out;
}

.stat-points-badge.hidden {
  display: none;
}

@keyframes pulsePoint {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.03); filter: brightness(1.2); }
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-btn {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid #555555;
  background: #37474f;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}

.stat-btn:hover:not(:disabled) {
  transform: scale(1.15);
  filter: brightness(1.25);
}

.stat-btn.active {
  background: #ff9800;
  border-color: #ffe082;
  box-shadow: 0 0 6px rgba(255, 152, 0, 0.6);
}

.stat-btn:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

.stat-key {
  font-size: 10px;
  font-weight: 800;
  color: #888888;
  background: #262626;
  border: 1px solid #444444;
  border-radius: 3px;
  padding: 1px 4px;
  min-width: 16px;
  text-align: center;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  color: #cfd8dc;
  width: 52px;
  letter-spacing: 0.2px;
}

.stat-bar-track {
  position: relative;
  width: 110px;
  height: 13px;
  background: #1c1c1e;
  border: 1.5px solid #444444;
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.15s ease-out;
}

.stat-hp { background: #00e676; }
.stat-def { background: #00b0ff; }
.stat-atk { background: #ff5252; }
.stat-spd { background: #ffd600; }

.stat-segments {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
}

.stat-segments span {
  flex: 1;
  border-right: 1px solid rgba(0, 0, 0, 0.5);
}

.stat-segments span:last-child {
  border-right: none;
}

.stat-val {
  font-size: 10px;
  font-weight: 700;
  color: #90a4ae;
  width: 24px;
  text-align: right;
  font-family: monospace;
}

/* 우측 하단 무기 및 탄약 HUD */
#weapon-hud {
  position: absolute;
  bottom: 20px;
  right: 22px;
  background: rgba(26, 26, 28, 0.9);
  border: 1.5px solid #444444;
  border-radius: 10px;
  padding: 8px 14px;
  min-width: 135px;
  color: #ffffff;
  pointer-events: none;
  z-index: 10;
}

.weapon-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.weapon-name {
  font-size: 11px;
  font-weight: 700;
  color: #b0bec5;
  letter-spacing: 0.2px;
}

.ammo-counter {
  display: flex;
  align-items: baseline;
}

.ammo-num {
  font-size: 18px;
  font-weight: 900;
  color: #ffe066;
}

.ammo-slash {
  font-size: 12px;
  color: #777777;
  margin: 0 2px;
}

.ammo-max {
  font-size: 12px;
  color: #9e9e9e;
  font-weight: 600;
}

.ammo-bar-bg {
  width: 100%;
  height: 5px;
  background: #222222;
  border-radius: 3px;
  overflow: hidden;
}

.ammo-bar-fill {
  width: 100%;
  height: 100%;
  background: #ffcc00;
  border-radius: 3px;
  transition: width 0.1s linear, background-color 0.2s;
}

.reload-status {
  font-size: 10px;
  font-weight: 700;
  color: #ff5252;
  margin-top: 4px;
  text-align: right;
  letter-spacing: 0.3px;
}

.reload-status.hidden {
  display: none;
}

/* 레벨업 알림 */
#levelup-notice {
  position: absolute;
  top: 75px;
  left: 50%;
  transform: translateX(-50%) scale(1);
  background: #ff9800;
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  padding: 6px 20px;
  border-radius: 8px;
  border: 2px solid #444444;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  animation: levelPop 1.2s ease-out forwards;
  z-index: 20;
}

#levelup-notice.hidden {
  display: none;
}

@keyframes levelPop {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.6) translateY(-8px);
  }
  30% {
    opacity: 1;
    transform: translateX(-50%) scale(1.08) translateY(0);
  }
  50% {
    transform: translateX(-50%) scale(1) translateY(0);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(1.03) translateY(-14px);
  }
}

/* ==========================================
   5레벨 주기 무기 진화 선택 모달 (화면 하단)
   ========================================== */
#evolution-modal {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(20, 22, 28, 0.94);
  backdrop-filter: blur(8px);
  border: 2px solid #00e5ff;
  border-radius: 16px;
  padding: 16px 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 229, 255, 0.25);
  z-index: 100;
  animation: modalSlideUp 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

#evolution-modal.hidden {
  display: none;
}

.evolution-title {
  font-size: 16px;
  font-weight: 800;
  color: #00e5ff;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
}

.evolution-subtitle {
  font-size: 11px;
  font-weight: 600;
  color: #b0bec5;
  margin-top: -6px;
  letter-spacing: 0.5px;
}

.evolution-cards {
  display: flex;
  gap: 12px;
}

.evolution-card {
  position: relative;
  width: 124px;
  background: #262933;
  border: 1.5px solid #3e4452;
  border-radius: 12px;
  padding: 12px 8px 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.evolution-card:hover {
  transform: translateY(-8px) scale(1.04);
  background: #313644;
  border-color: #00e5ff;
  box-shadow: 0 8px 20px rgba(0, 229, 255, 0.3);
}

.evolution-card:active {
  transform: translateY(-2px) scale(0.98);
}

.evolution-card .card-num {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 11px;
  font-weight: 800;
  color: #ff9800;
  background: rgba(0, 0, 0, 0.45);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #555;
}

.card-icon-wrap {
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  margin-bottom: 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 4px;
}

.weapon-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.card-name {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 4px;
  text-align: center;
}

.card-desc {
  font-size: 9.5px;
  font-weight: 500;
  color: #90a4ae;
  text-align: center;
  line-height: 1.35;
}

@keyframes modalSlideUp {
  0% {
    opacity: 0;
    transform: translate(-50%, 40px) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

/* ==========================================
   모바일 듀얼 가상 조이스틱 & 전용 액션 버튼
   ========================================== */
#mobile-controls {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
}

.joystick-zone {
  position: absolute;
  bottom: 30px;
  width: 140px;
  height: 140px;
  pointer-events: auto;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#joystick-move {
  left: 30px;
}

#joystick-aim {
  right: 30px;
}

.joystick-base {
  position: relative;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, rgba(20, 22, 28, 0.45) 100%);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s ease;
}

.joystick-base.aim-base {
  border-color: rgba(255, 82, 82, 0.4);
  background: radial-gradient(circle, rgba(255, 82, 82, 0.08) 0%, rgba(20, 22, 28, 0.45) 100%);
}

.joystick-thumb {
  position: absolute;
  width: 52px;
  height: 52px;
  background: radial-gradient(circle at 35% 35%, #00e5ff 0%, #00838f 100%);
  border: 2.5px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 229, 255, 0.5);
  pointer-events: none;
  transform: translate(0px, 0px);
}

.joystick-thumb.aim-thumb {
  background: radial-gradient(circle at 35% 35%, #ff5252 0%, #b71c1c 100%);
  box-shadow: 0 2px 10px rgba(255, 82, 82, 0.5);
}

.joystick-label {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  letter-spacing: 0.5px;
  pointer-events: none;
}

/* 모바일 전용 재장전 플로팅 버튼 */
.mobile-action-btn {
  position: absolute;
  bottom: 185px;
  right: 48px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(30, 33, 42, 0.88);
  border: 2px solid #ffcc00;
  color: #ffcc00;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s ease, background 0.15s;
}

.mobile-action-btn:active {
  transform: scale(0.92);
  background: rgba(255, 204, 0, 0.25);
}

.mobile-action-btn .reload-icon {
  font-size: 18px;
  line-height: 1;
}

.mobile-action-btn .reload-text {
  font-size: 10px;
  font-weight: 800;
  margin-top: 2px;
}

/* ==========================================
   모바일 화면 반응형 최적화 (스마트폰 & 태블릿)
   ========================================== */
@media (max-width: 900px), (max-height: 600px) {
  /* 상단 경험치 바 축소 */
  #header-ui {
    top: 8px;
    gap: 6px;
  }
  .level-badge {
    font-size: 11px;
    padding: 3px 8px;
    min-width: 40px;
  }
  .exp-container {
    width: 170px;
    height: 14px;
  }
  .exp-text {
    font-size: 9px;
  }

  /* 좌측 하단 스탯 HUD: 조이스틱 위쪽으로 자연스럽게 배치 및 터치 타겟 확대 */
  #stat-hud {
    bottom: 180px;
    left: 16px;
    padding: 8px 10px;
    max-width: 200px;
    gap: 3px;
    background: rgba(20, 22, 28, 0.94);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
  }
  .stat-row {
    gap: 6px;
  }
  .stat-btn {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
  .stat-key {
    display: none; /* 모바일에서는 키보드 단축키 뱃지 숨김 */
  }
  .stat-label {
    font-size: 10px;
    width: 44px;
  }
  .stat-bar-track {
    width: 65px;
    height: 10px;
  }
  .stat-val {
    font-size: 9px;
    width: 22px;
  }

  /* 우측 하단 탄약 HUD */
  #weapon-hud {
    bottom: auto;
    top: 8px;
    right: 12px;
    padding: 6px 10px;
    min-width: 120px;
  }
  .weapon-name {
    font-size: 11px;
  }
  .ammo-counter {
    font-size: 11px;
  }

  /* 조이스틱 크기 최적화 */
  .joystick-zone {
    width: 125px;
    height: 125px;
    bottom: 20px;
  }
  #joystick-move {
    left: 20px;
  }
  #joystick-aim {
    right: 20px;
  }
  .joystick-base {
    width: 110px;
    height: 110px;
  }
  .joystick-thumb {
    width: 48px;
    height: 48px;
  }
  .mobile-action-btn {
    bottom: 155px;
    right: 32px;
    width: 48px;
    height: 48px;
  }

  /* 무기 진화 모달: 모바일 가로 스크롤 및 카드 터치 최적화 */
  #evolution-modal {
    bottom: 14px;
    max-width: 95vw;
    padding: 12px 14px;
    border-radius: 14px;
  }
  .evolution-title {
    font-size: 14px;
    letter-spacing: 1px;
  }
  .evolution-subtitle {
    font-size: 10px;
  }
  .evolution-cards {
    gap: 8px;
    overflow-x: auto;
    max-width: 100%;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .evolution-card {
    width: 95px;
    min-width: 95px;
    padding: 8px 6px;
    border-radius: 10px;
  }
  .card-icon-wrap {
    width: 44px;
    height: 44px;
    margin-bottom: 4px;
  }
  .card-name {
    font-size: 11px;
    margin-bottom: 2px;
  }
  .card-desc {
    font-size: 8.5px;
    line-height: 1.25;
  }
  .evolution-card .card-num {
    font-size: 9px;
    padding: 0 4px;
  }
}
