@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700;900&display=swap");

body {
  margin: 0;
  overflow: hidden;
  background-color: #222;
  font-family: "Noto Sans KR", sans-serif;
  touch-action: none; /* 모바일 터치 방지 */
  user-select: none;
  -webkit-user-select: none;
}

#gameCanvas {
  display: block;
}

/* UI 공통 스타일 */
.ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.hidden {
  display: none !important;
}

/* 메인 화면 */
#start-screen {
  background-color: rgba(0, 0, 0, 0.8);
  background-image: url("asset/main.png"); /* 에셋 이미지 경로 */
  background-size: cover;
  background-position: center;
  pointer-events: auto;
  z-index: 100;
}

.start-menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
  margin-top: 50px; /* 버튼 그룹 위치 아래로 조정 */
}

.title {
  font-size: 4rem;
  color: #fff;
  text-shadow: 4px 4px 0 #3498db;
  margin-bottom: 20px;
  text-align: center;
  font-weight: 900;
}

.btn {
  padding: 15px 40px;
  font-size: 1.5rem;
  background-color: #f1c40f;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  transition:
    transform 0.2s,
    background-color 0.2s;
  color: #333;
  pointer-events: auto;
}

.btn:hover {
  transform: scale(1.1);
  background-color: #f39c12;
}

#back-btn {
  background-color: #e74c3c; /* 빨간색으로 변경 */
}

#back-btn:hover {
  background-color: #c0392b; /* 호버 시 더 어두운 빨간색 */
}

/* HUD (헤드업 디스플레이) */
#hud {
  justify-content: flex-start; /* 상단 정렬 복구 */
  align-items: stretch;
  padding: 20px;
  box-sizing: border-box;
}

.hud-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px; /* 경험치 바 아래 여백 */
  font-family: "Courier New", Courier, monospace; /* 오피스 느낌 폰트 */
  text-shadow: 1px 1px 0 #000;
  background: rgba(0, 0, 0, 0.3); /* 가독성을 위한 배경 */
  padding: 5px 15px;
  border-radius: 5px;
}

.exp-bar-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 10px;
  background-color: #333;
  z-index: 10;
}

#exp-bar {
  width: 0%;
  height: 100%;
  background-color: #3498db;
  transition: width 0.2s;
}

.stats {
  color: white;
  font-size: 1.2rem;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

#timer {
  font-size: 2rem;
  color: #fff;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  font-family: "Courier New", Courier, monospace;
}

/* 능력 목록 (오른쪽 세로 나열) */
#ability-dock {
  position: absolute;
  top: 100px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.ability-icon {
  width: 50px;
  height: 50px;
  background-color: rgba(0, 0, 0, 0.5);
  border: 2px solid #fff;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  color: #fff;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  position: relative;
}

.ability-level {
  position: absolute;
  bottom: -5px;
  right: -5px;
  background-color: #f1c40f;
  color: #333;
  font-size: 12px;
  font-weight: bold;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid #fff;
}

/* 레벨업 모달 */
#levelup-modal {
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 50;
  pointer-events: auto;
  /* 모달 내용 중앙 정렬을 위해 flex 속성 추가 */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.card-container {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.card {
  background: #fdfaf4; /* Off-white paper color */
  color: #333;
  width: 200px;
  height: 280px;
  border-radius: 5px; /* Sharp corners like paper */
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s;
  border: 1px solid #ddd;
  box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.2);
}

.card:hover {
  transform: translateY(-10px) rotate(1deg);
  border-color: #e74c3c;
}

.card-icon {
  font-size: 4rem;
  margin-bottom: 10px;
}

.card-title {
  font-size: 1.3rem;
  font-weight: bold;
  margin-bottom: 10px;
  color: #2c3e50;
  font-family: "Courier New", Courier, monospace; /* Typewriter font */
}

.card-desc {
  font-size: 0.9rem;
  color: #555;
  font-family: "Times New Roman", Times, serif; /* Serif font for body */
  white-space: pre-wrap; /* Allow \n for line breaks */
}

#gold-reward-btn:hover {
  transform: scale(1.05);
  background-color: #e67e22 !important;
  box-shadow: 0 0 15px gold;
}

/* 보물상자 애니메이션 */
.chest-anim-box {
  font-size: 100px;
  margin: 30px;
  animation: chestShake 0.5s infinite;
  cursor: default;
}

@keyframes chestShake {
  0% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-10deg);
  }
  50% {
    transform: rotate(10deg);
  }
  75% {
    transform: rotate(-10deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

.chest-open {
  font-size: 120px;
  margin: 30px;
  animation: chestPop 0.5s ease-out;
}

@keyframes chestPop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.reward-card {
  animation: cardAppear 0.5s ease-out backwards;
  border-color: gold;
  box-shadow: 0 0 15px gold;
}

@keyframes cardAppear {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 보물상자 보상 레이아웃 */
.chest-cards-row {
  display: flex;
  gap: 20px;
  justify-content: center;
  width: 100%;
  flex-wrap: nowrap; /* 한 줄로 표시 */
  overflow-x: auto; /* 화면 넘치면 스크롤 */
  padding: 10px;
}

/* 보물상자 확인 버튼 */
.chest-confirm-btn {
  margin-top: 25px;
  padding: 10px 40px;
  font-size: 1.2rem;
  border-radius: 10px; /* 약간 뭉툭한 모서리 */
  background-color: #2ecc71;
  color: white;
}

/* 패시브 게이지 바 */
.gauge-container {
  display: flex;
  gap: 5px;
  margin-top: 15px;
  justify-content: center;
}

.gauge-segment {
  width: 30px;
  height: 8px;
  background-color: #555;
  border-radius: 2px;
  border: 1px solid #333;
}

.gauge-segment.filled {
  background-color: #f1c40f;
  box-shadow: 0 0 5px #f1c40f;
}

/* 게임 오버 모달 */
#gameover-modal {
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 60;
  pointer-events: auto;
}

.gameover-title {
  font-size: 3rem;
  color: #e74c3c;
  margin-bottom: 20px;
  font-weight: 900;
}

.gameover-score {
  font-size: 1.5rem;
  color: #fff;
  margin-bottom: 30px;
}

/* 보스 경고 */
#boss-warning {
  color: #e74c3c;
  font-size: 3rem;
  font-weight: 900;
  text-shadow: 0 0 10px red;
  animation: blink 0.5s infinite;
  display: none;
}

@keyframes blink {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* 일시정지 모달 */
#pause-modal {
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 55; /* 레벨업 모달(50)보다 위, 게임오버(60)보다 아래 */
  pointer-events: auto;
}

/* 게임 방법 모달 */
#howto-modal {
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 110; /* 시작 화면(100)보다 위에 */
  pointer-events: auto;
}

.modal-content {
  background: #fff;
  padding: 30px 40px;
  border-radius: 20px;
  width: 90%;
  max-width: 600px;
  text-align: center;
  color: #333;
  border: 5px solid #3498db;
}

.modal-content h2 {
  font-size: 2rem;
  margin-top: 0;
  margin-bottom: 20px;
  color: #2c3e50;
}

.rules-list {
  list-style: none;
  padding: 0;
  margin: 0 0 30px 0;
  text-align: left;
}

.rules-list li {
  margin-bottom: 15px;
  line-height: 1.6;
  font-size: 1rem;
}

.rules-list li strong {
  color: #e74c3c;
}

/* 웨이브 시작 메시지 */
#wave-start-message {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  font-size: 4rem;
  font-weight: 900;
  color: white;
  text-shadow: 0 0 15px #3498db;
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  z-index: 40;
}

#wave-start-message.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* 모바일 조이스틱 */
#mobile-controls {
  position: absolute;
  bottom: 50px;
  left: 50px;
  z-index: 20;
  pointer-events: auto;
}

#joystick-zone {
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  position: relative;
  touch-action: none;
}

#joystick-knob {
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* 모바일 일시정지 버튼 */
#mobile-pause-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 20;
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  color: white;
  font-size: 20px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  cursor: pointer;
}

/* 미디어 쿼리: 모바일 화면 조정 */
@media (max-width: 768px) {
  .title {
    font-size: 2.5rem;
  }
  .btn {
    padding: 10px 30px;
    font-size: 1.2rem;
  }
  .card {
    width: 140px;
    height: 200px;
    padding: 10px;
  }
  .card-icon {
    font-size: 2.5rem;
  }
  .card-title {
    font-size: 1rem;
  }
  .card-desc {
    font-size: 0.7rem;
  }
  #mobile-controls {
    display: block; /* 모바일에서 보임 */
  }
}

@media (min-width: 769px) {
  #mobile-controls {
    display: none; /* 데스크탑에서 숨김 */
  }
  #mobile-pause-btn {
    display: none !important;
  }
}
