/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
  background: #f8fafc;
  -webkit-user-select: none;
  user-select: none;
}

/* ===== Game Container ===== */
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: url('https://zsz.kr/g/spear-stickman/stickman.png') no-repeat center center;
  background-size: cover;
}

canvas {
   display: block;
  cursor: crosshair;
  /* 배경을 보이게 하기 위해 배경색 제거 */
  background: transparent;
}

/* ===== HUD ===== */
.hud-left {
  position: absolute;
  top: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 16px;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid #e2e8f0;
}

.hud-pill .icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.hud-pill .value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
}

.hud-right {
  position: absolute;
  top: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px 12px;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid #e2e8f0;
}

.health-bar-bg {
  width: 128px;
  height: 12px;
  background: #f1f5f9;
  border-radius: 9999px;
  overflow: hidden;
}

.health-bar-fill {
  height: 100%;
  background: #ef4444;
  border-radius: 9999px;
  transition: width 0.3s ease;
}

/* ===== Overlays (Menu / Game Over) ===== */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay-menu {
  background: rgba(15, 23, 42, 0.40);
}

.overlay-gameover {
  background: rgba(136, 19, 55, 0.40);
}

.overlay-card {
  background: #fff;
  padding: 40px;
  border-radius: 2.5rem;
  box-shadow: 0 25px 50px rgba(0,0,0,0.15);
  text-align: center;
  max-width: 420px;
  width: calc(100% - 32px);
  border: 1px solid #f1f5f9;
  transform: scale(0.92) translateY(16px);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease;
  opacity: 0;
}

.overlay.visible .overlay-card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.overlay-card h1 {
  font-size: 3rem;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 4px;
  letter-spacing: -0.025em;
}

.overlay-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 32px;
  font-style: italic;
}

.overlay-card .final-label {
  color: #64748b;
  font-weight: 500;
  margin-bottom: 4px;
}

.overlay-card .final-score {
  font-size: 3.75rem;
  font-weight: 900;
  color: #0f172a;
  line-height: 1;
}

.score-area {
  margin: 32px 0;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 16px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.97);
}

.btn-start {
  background: #0f172a;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.2);
}

.btn-start:hover {
  background: #1e293b;
}

.btn-retry {
  background: #ef4444;
  box-shadow: 0 10px 20px rgba(239, 68, 68, 0.2);
}

.btn-retry:hover {
  background: #dc2626;
}

.btn .icon {
  width: 24px;
  height: 24px;
}

.hint-text {
  color: #94a3b8;
  font-size: 0.875rem;
  font-weight: 500;
  margin-top: 16px;
}

/* ===== In-game instruction hint ===== */
.instruction-hint {
  position: absolute;
  bottom: 128px;
  left: 50%;
  transform: translateX(-50%);
  color: #94a3b8;
  font-weight: 500;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.instruction-hint.visible {
  opacity: 1;
}

/* ===== SVG icon colors ===== */
.icon-trophy { color: #f59e0b; }
.icon-heart {
  width: 16px;  /* 기존보다 작게 조절 (기존 약 20~24px 대응) */
  height: 16px;
  color: #ef4444;
  flex-shrink: 0;
}

/* ===== Mobile Warning (Cartoon Style) ===== */
.mobile-only-overlay {
  display: none; /* 기본적으로는 숨김 */
  position: fixed;
  inset: 0;
  background-color: #ffde59; /* 카툰풍 노란색 배경 */
  z-index: 10000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  font-family: 'Inter', sans-serif;
}

/* 모바일/태블릿 해상도 (1024px 이하)에서 활성화 */
@media (max-width: 1024px) {
  .mobile-only-overlay {
    display: flex;
  }
  /* 게임 관련 요소 전부 숨김 */
  #game-canvas, .hud-left, .hud-right, .overlay, .instruction-hint {
    display: none !important;
  }
}

.cartoon-card {
  background: white;
  border: 6px solid #000; /* 굵은 검정 테두리 */
  border-radius: 40px;
  padding: 40px 30px;
  box-shadow: 12px 12px 0px #000; /* 카툰풍 그림자 */
  text-align: center;
  max-width: 320px;
  transform: rotate(-2deg); /* 살짝 기울여서 재미 요소 추가 */
}

.cartoon-icon {
  width: 80px;
  height: 80px;
  background: #ff5757;
  border: 4px solid #000;
  border-radius: 20px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.cartoon-icon svg {
  width: 50px;
  height: 50px;
}

.cartoon-card h1 {
  font-size: 2rem;
  font-weight: 900;
  color: #000;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.cartoon-card .main-msg {
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 15px;
  line-height: 1.4;
}

.cartoon-card .main-msg strong {
  background: linear-gradient(transparent 60%, #ffde59 40%);
}

.cartoon-card .sub-msg {
  font-size: 0.95rem;
  color: #666;
  margin-bottom: 25px;
  line-height: 1.6;
}

.cartoon-footer {
  display: inline-block;
  background: #000;
  color: #fff;
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

/* 닉네임 입력창 */
#nickname-input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 10px;
  font-size: 1rem;
  text-align: center;
  outline: none;
}
#nickname-input:focus { border-color: #0f172a; }

.btn-submit {
  background: #10b981;
  margin-bottom: 20px;
}
.btn-submit:hover { background: #059669; }

/* 랭킹 리스트 */
#leaderboard-area {
  margin: 20px 0;
  text-align: left;
  background: #f8fafc;
  padding: 15px;
  border-radius: 16px;
  max-height: 200px;
  overflow-y: auto;
}
#leaderboard-area h3 {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 10px;
  text-align: center;
}
#rank-list {
  list-style: none;
  padding: 0;
}
#rank-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.9rem;
  font-weight: 600;
}
#rank-list li:last-child { border-bottom: none; }
#rank-list li span.rank-num { color: #94a3b8; width: 25px; }
#rank-list li span.rank-name { flex: 1; color: #1e293b; }
#rank-list li span.rank-score { color: #f43f5e; }