* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #111;
  color: #fff;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background-color: #3a5a40;
}

/* UI 패널 (좌측 상단) */
#ui-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  background-color: rgba(30, 30, 30, 0.85);
  border: 2px solid #555;
  border-radius: 8px;
  width: 200px;
  padding: 15px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  z-index: 10;
}

#ui-panel h2 {
  font-size: 1rem;
  border-bottom: 1px solid #555;
  padding-bottom: 5px;
  margin-bottom: 10px;
  color: #ffcc00;
}

#ui-panel p {
  margin-bottom: 2px;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

hr {
  border: 0;
  border-top: 1px solid #555;
  margin: 10px 0;
}

.stat-btn {
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  width: 22px;
  height: 22px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: none;
  line-height: 1;
}

.stat-btn:active {
  background-color: #3e8e41;
}

#action-hint {
  margin-top: 15px;
  text-align: center;
  font-size: 0.75rem;
  color: #aaa;
}

/* 시스템 메뉴 (가방 등 - 우측 하단) */
#system-menu {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 10;
}

.sys-btn {
  background-color: #34495e;
  border: 2px solid #2c3e50;
  color: white;
  padding: 12px 18px;
  font-size: 1.1rem;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
.sys-btn:active {
  background-color: #2c3e50;
  transform: translateY(2px);
}

/* NPC 상호작용 중앙 하단 프롬프트 버튼 */
#interact-prompt {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(255, 165, 0, 0.9);
  color: #fff;
  border: 4px solid #fff;
  padding: 15px 30px;
  font-size: 1.2rem;
  font-weight: bold;
  border-radius: 30px;
  cursor: pointer;
  z-index: 20;
  box-shadow: 0 0 15px rgba(255, 165, 0, 0.5);
  animation: pulse 1.5s infinite;
}
#interact-prompt.hidden {
  display: none;
}
@keyframes pulse {
  0% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
  100% { transform: translateX(-50%) scale(1); }
}

/* 장비/가방 모달 특화 CSS */
.equip-slot {
  background-color: #1e272e;
  padding: 15px;
  border-radius: 8px;
  border: 1px dashed #7f8fa6;
  margin-bottom: 20px;
  text-align: left;
}
.equip-slot p { margin-bottom: 10px; color: #fbc531; font-size: 0.9rem; }

.equip-box {
  display: flex;
  align-items: center;
  background-color: #2f3640;
  padding: 10px;
  border-radius: 5px;
  border: 2px solid transparent;
}
.equip-box.clickable { cursor: pointer; }
.equip-box.clickable:hover { border-color: #fbc531; background-color: #353b48; }

#equip-icon { font-size: 2rem; margin-right: 15px; }
#equip-name { font-size: 1.1rem; font-weight: bold; }

/* 20칸 인벤토리 그리드 시스템 (4x5) */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 15px;
  max-height: 250px;
  overflow-y: auto;
}
/* 스크롤바 디자인 */
.inventory-grid::-webkit-scrollbar { width: 6px; }
.inventory-grid::-webkit-scrollbar-thumb { background: #555; border-radius: 3px; }

.inven-slot {
  aspect-ratio: 1;
  background-color: #2f3640;
  border: 2px solid #57606f;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  position: relative;
  cursor: pointer;
  transition: all 0.1s ease;
}
.inven-slot:hover { border-color: #fbc531; transform: scale(1.05); }
.inven-slot.empty { cursor: default; }
.inven-slot.empty:hover { border-color: #57606f; transform: none; }

.slot-count {
  position: absolute;
  bottom: 2px; right: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 2px #000;
}
.slot-enhance {
  position: absolute;
  top: 2px; left: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  color: #2ecc71;
  text-shadow: 1px 1px 2px #000;
}

/* 모바일 전용 컨트롤 */
#mobile-controls {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 40%;
  pointer-events: none; z-index: 5;
}

#joystick-zone {
  position: absolute;
  bottom: 20px; left: 20px;
  width: 120px; height: 120px;
  pointer-events: auto;
}

#joystick-base {
  width: 100px; height: 100px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  position: absolute; top: 10px; left: 10px;
}

#joystick-stick {
  width: 40px; height: 40px;
  background: rgba(200, 200, 200, 0.8);
  border-radius: 50%;
  position: absolute; top: 30px; left: 30px;
}

#action-zone {
  position: absolute;
  bottom: 80px; 
  right: 20px;
  pointer-events: auto;
}

#mine-btn {
  width: 80px; height: 80px;
  border-radius: 50%;
  background-color: rgba(255, 165, 0, 0.8);
  border: 3px solid rgba(255, 200, 0, 0.9);
  color: white; font-size: 1rem; font-weight: bold;
  box-shadow: 0 5px 15px rgba(0,0,0,0.5);
  cursor: pointer;
}
#mine-btn:active { background-color: rgba(200, 130, 0, 0.9); transform: scale(0.95); }

/* Modal UI */
.modal {
  position: absolute;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100; opacity: 1; transition: opacity 0.2s ease;
}
.modal.hidden { opacity: 0; pointer-events: none; }

.modal-content {
  position: relative;
  background-color: #1e272e;
  border: 3px solid #718093;
  border-radius: 12px;
  padding: 25px; width: 340px;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  pointer-events: auto;
}

/* 상단 닫기 X 버튼 & 헤더 */
.shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.shop-header h2 { color: #fbc531; font-size: 1.3rem; margin: 0; }
.modal-close-small {
  background-color: #ff4757; color: white;
  border: none; border-radius: 5px;
  width: 30px; height: 30px;
  font-weight: bold; cursor: pointer;
}

.modal-content .desc { font-size: 0.85rem; color: #dcdde1; }

/* 탭 버튼 구조 (상점용) */
.tab-container {
  display: flex; border-bottom: 2px solid #57606f; margin-bottom: 15px;
}
.tab-btn {
  flex: 1; background: transparent; border: none; color: #aaa;
  padding: 10px; cursor: pointer; font-weight: bold;
}
.tab-btn.active { color: #fbc531; border-bottom: 3px solid #fbc531; }

.shop-items { display: flex; flex-direction: column; gap: 10px; margin-top: 15px; }

.shop-item {
  background-color: #2f3640; border: 1px solid #718093; color: white;
  padding: 12px; border-radius: 6px; cursor: pointer; text-align: left;
  display: flex; align-items: center;
}
.shop-item:hover { background-color: #353b48; border-color: #fbc531; }
.shop-item-icon { font-size: 1.8rem; margin-right: 15px; }
.shop-item-info strong { display: block; margin-top: 5px; color: #fbc531; }

/* 공용 레이아웃 헬퍼 */
.hidden { display: none !important; }
.action-btn { padding: 10px 15px; border: none; border-radius: 5px; font-weight: bold; cursor: pointer; }
.action-btn.heal { background-color: #4cd137; color: white; }
.action-btn.cancel { background-color: #7f8fa6; color: white; }

@media screen and (max-width: 600px) {
  #ui-panel { transform: scale(0.8); transform-origin: top left; }
}
