/* 전체 배경과 캔버스 중앙 정렬 */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* 게임 캔버스를 감싸는 컨테이너: 대화창을 캔버스 위에 절대 위치로 겹치기 위한 기준점 */
#gameContainer {
  position: relative;
  line-height: 0; /* 캔버스 하단에 생기는 여백 제거 */
  max-width: 100vw;
  max-height: 100vh;
}

/* 게임 캔버스: 도트 스타일 유지를 위해 이미지 스무딩을 끄고, 화면(특히 폰 세로 화면)보다
   크면 가로세로 비율을 유지한 채 화면에 맞춰 줄어들게 한다. 캔버스의 실제 그리기 해상도
   (width/height 속성, 640x480)는 그대로 두고 CSS로 표시 크기만 조절한다. */
#gameCanvas {
  image-rendering: pixelated;
  border: 2px solid #333;
  background: #000;
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  display: block;
}

/* ===== 터치 조작(모바일/태블릿에서만 JS로 표시) ===== */
#touchControls {
  position: absolute;
  inset: 0;
  pointer-events: none; /* 버튼이 아닌 빈 영역은 캔버스 조작을 막지 않는다 */
  user-select: none;
  -webkit-user-select: none;
  line-height: normal;
}

.touch-menu-bar {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.touch-menu-btn {
  pointer-events: auto;
  padding: 6px 10px;
  background: rgba(20, 20, 20, 0.6);
  border: 1px solid rgba(201, 162, 39, 0.6);
  border-radius: 4px;
  color: #eee;
  font-size: 11px;
  font-family: sans-serif;
  touch-action: none;
}

.touch-dpad {
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: 150px;
  height: 150px;
}

.touch-dpad-btn {
  position: absolute;
  width: 50px;
  height: 50px;
  background: rgba(20, 20, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: #fff;
  font-size: 18px;
  pointer-events: auto;
  touch-action: none;
}
.touch-dpad-up { top: 0; left: 50px; }
.touch-dpad-left { top: 50px; left: 0; }
.touch-dpad-right { top: 50px; left: 100px; }
.touch-dpad-down { top: 100px; left: 50px; }

.touch-actions {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.touch-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.touch-small-btn {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #eee;
  font-size: 11px;
  font-family: sans-serif;
  touch-action: none;
}

.touch-interact-btn {
  pointer-events: auto;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(126, 200, 255, 0.35);
  border: 1px solid #7ec8ff;
  color: #fff;
  font-size: 15px;
  font-weight: bold;
  font-family: sans-serif;
  touch-action: none;
}

.touch-attack-btn {
  pointer-events: auto;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: rgba(201, 162, 39, 0.45);
  border: 2px solid #c9a227;
  color: #fff;
  font-size: 15px;
  font-weight: bold;
  font-family: sans-serif;
  touch-action: none;
}

/* ===== NPC 대화창 ===== */
#dialogueBox {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 2px;
  background: rgba(10, 10, 10, 0.9);
  border: 2px solid #c9a227;
  border-radius: 4px;
  padding: 12px 16px;
  color: #eee;
  font-family: sans-serif;
  box-sizing: border-box;
}

.dialogue-name {
  font-weight: bold;
  color: #c9a227;
  margin-bottom: 6px;
  font-size: 14px;
}

.dialogue-text {
  font-size: 14px;
  line-height: 1.5;
  min-height: 42px;
}

.dialogue-hint {
  margin-top: 8px;
  font-size: 11px;
  color: #888;
  text-align: right;
}

/* ===== 인벤토리 / 스탯 창, 몬스터 도감 창, 지도 창 ===== */
#inventoryPanel,
#bestiaryPanel,
#mapPanel {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  bottom: 20px;
  background: rgba(15, 15, 15, 0.95);
  border: 2px solid #c9a227;
  border-radius: 6px;
  color: #eee;
  font-family: sans-serif;
  padding: 16px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* ===== 엔딩 화면 ===== */
#endingPanel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5, 5, 5, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: sans-serif;
}

.ending-content {
  max-width: 420px;
  padding: 32px;
  box-sizing: border-box;
  background: #1c1c1c;
  border: 2px solid #ffd23f;
  border-radius: 8px;
  text-align: center;
  color: #eee;
}

.ending-content h1 {
  margin: 0 0 16px;
  font-size: 20px;
  color: #ffd23f;
}

.ending-text {
  white-space: pre-line;
  line-height: 1.6;
  font-size: 14px;
  color: #ddd;
  margin: 0 0 16px;
}

.ending-stats {
  font-size: 13px;
  color: #7ec8ff;
  margin: 0 0 20px;
}

.world-map-overview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  margin-bottom: 8px;
}

.world-map-node {
  padding: 6px 14px;
  background: #262626;
  border: 1px solid #444;
  border-radius: 4px;
  font-size: 13px;
  color: #999;
}

.world-map-node.current {
  background: #3a2f10;
  border-color: #ffd23f;
  color: #ffd23f;
  font-weight: bold;
}

.world-map-arrow {
  color: #555;
}

.local-map-canvas {
  align-self: center;
  border: 1px solid #444;
  border-radius: 4px;
  image-rendering: pixelated;
}

.inventory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #333;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.inventory-header h2 {
  margin: 0;
  font-size: 16px;
}

.inventory-header button {
  background: #333;
  color: #eee;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
}

.inventory-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.inventory-column h3 {
  font-size: 13px;
  color: #bbb;
  margin: 12px 0 6px;
}

.inventory-column h3:first-child {
  margin-top: 0;
}

#enhancePanel h3,
#inventoryPanel h3 {
  font-size: 13px;
  color: #bbb;
  margin: 12px 0 6px;
}

.stat-summary {
  margin: 0 0 4px;
  padding: 8px 10px;
  background: #1f1f1f;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  color: #7ec8ff;
  font-size: 13px;
}

.chain-display {
  margin: 0 0 4px;
  padding: 8px 10px;
  background: #1f1f1f;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.6;
}

.equip-slot {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  background: #262626;
  border: 1px solid #444;
  border-radius: 4px;
  color: #eee;
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 13px;
}

.equip-slot:hover {
  border-color: #c9a227;
}

.inventory-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inventory-item {
  text-align: left;
  background: #1f1f1f;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  color: #eee;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
}

.inventory-item:hover {
  border-color: #c9a227;
}

.inventory-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.shop-gold {
  color: #ffd23f;
  font-size: 13px;
  margin-left: auto;
  margin-right: 12px;
}

.enhance-result {
  min-height: 18px;
  margin-top: 12px;
  font-size: 13px;
}

.stat-allocate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1f1f1f;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 13px;
}

.stat-row button {
  background: #c9a227;
  border: none;
  border-radius: 4px;
  color: #1a1a1a;
  width: 24px;
  height: 24px;
  font-weight: bold;
  cursor: pointer;
}

.stat-row button:disabled {
  background: #555;
  color: #999;
  cursor: not-allowed;
}

/* 강화 버튼처럼 텍스트가 긴 경우 고정 24px 폭 대신 내용에 맞춰 넓힌다 */
#enhanceSlotList .stat-row button {
  width: auto;
  padding: 0 12px;
}

/* 공통: 화면에서 제거할 요소에 사용하는 클래스 */
.hidden {
  display: none !important;
}

/* ===== 캐릭터 생성 화면 ===== */
#characterCreateScreen {
  width: 640px;
  max-width: 100%;
  color: #eee;
  font-family: sans-serif;
}

.create-panel {
  background: #1c1c1c;
  border: 2px solid #333;
  border-radius: 6px;
  padding: 24px;
  box-sizing: border-box;
}

.continue-panel {
  border-color: #5dd35d;
  margin-bottom: 16px;
}

.continue-summary {
  margin: 0 0 16px;
  color: #eee;
  font-size: 14px;
}

.continue-actions {
  display: flex;
  gap: 8px;
}

.continue-actions .start-button {
  flex: 1;
  margin-top: 0;
}

.delete-save-button {
  padding: 10px 16px;
  background: #262626;
  border: 1px solid #7a3b3b;
  border-radius: 4px;
  color: #e05a5a;
  font-size: 14px;
  cursor: pointer;
}

.delete-save-button:hover {
  background: #3a1f1f;
}

.create-panel h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: 1px;
}

.subtitle {
  margin: 0 0 20px;
  color: #999;
  font-size: 13px;
}

#characterCreateScreen label,
.section-label {
  display: block;
  margin: 16px 0 6px;
  font-size: 13px;
  color: #bbb;
}

#nicknameInput {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  background: #111;
  border: 1px solid #444;
  border-radius: 4px;
  color: #eee;
  font-size: 14px;
}

.controls-hint {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #333;
}

.controls-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  row-gap: 4px;
  font-size: 12px;
}

.controls-grid span:nth-child(odd) {
  color: #999;
}

.controls-grid span:nth-child(even) {
  color: #eee;
  font-weight: bold;
}

.controls-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: #777;
}

.class-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.class-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  background: #262626;
  border: 2px solid #3a3a3a;
  border-radius: 4px;
  padding: 10px 12px;
  cursor: pointer;
  font-family: inherit;
}

.class-card:hover {
  border-color: #666;
}

.class-card.selected {
  border-color: #c9a227;
  background: #2f2a1a;
}

.class-name {
  font-size: 15px;
  font-weight: bold;
}

.class-desc {
  font-size: 12px;
  color: #bbb;
}

.class-stats {
  font-size: 11px;
  color: #888;
}

.error-text {
  min-height: 16px;
  margin: 12px 0 0;
  color: #e05a5a;
  font-size: 12px;
}

.start-button {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  background: #c9a227;
  border: none;
  border-radius: 4px;
  color: #1a1a1a;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}

.start-button:hover {
  background: #ddb943;
}
