/* ─── 연화사 디자인 시스템 (한국 전통 사찰 감성 & 모바일/데스크탑 반응형) ─── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Noto Serif KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #e5ede7;
  color: #3b3127;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* ─── 로딩 화면 ─── */
#loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #faf6ee 0%, #e6ded0 100%);
  z-index: 1000;
}

.loading-content {
  text-align: center;
  padding: 20px;
}

.lotus-icon {
  font-size: 58px;
  animation: floatLotus 3s ease-in-out infinite;
  margin-bottom: 16px;
  filter: drop-shadow(0 6px 12px rgba(180, 140, 100, 0.2));
}

@keyframes floatLotus {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

#loading-screen h1, #channel-screen h1 {
  font-size: 38px;
  font-weight: 700;
  color: #4a3424;
  letter-spacing: 6px;
  margin-bottom: 4px;
}

.loading-subtitle, .channel-subtitle {
  font-size: 13px;
  color: #8c7b6c;
  letter-spacing: 4px;
  margin-bottom: 24px;
}

.loading-text {
  font-size: 14px;
  color: #7d6c5d;
  margin-bottom: 16px;
  animation: pulse 2.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.loading-bar {
  width: 220px;
  height: 4px;
  background: #ded7c8;
  border-radius: 4px;
  margin: 0 auto;
  overflow: hidden;
}

.loading-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #c99357, #e0ba89);
  border-radius: 4px;
  transition: width 0.1s ease;
}

/* 로딩 퍼센트 텍스트 */
#loading-percent {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #8c6a46;
  letter-spacing: 1px;
}

/* ─── 전각(장소) 선택 화면 ─── */
#channel-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #faf6ee 0%, #e6dfd1 100%);
  z-index: 900;
}

.channel-content {
  text-align: center;
  max-width: 460px;
  width: 90%;
}

.channel-subtitle {
  margin-bottom: 26px;
}

#channel-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 30px;
}

.channel-card {
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px solid rgba(190, 175, 155, 0.45);
  border-radius: 16px;
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 14px rgba(120, 100, 80, 0.06);
  backdrop-filter: blur(8px);
}

.channel-card:hover {
  background: #ffffff;
  border-color: #c99357;
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(180, 130, 80, 0.18);
}

.ch-info {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.channel-card .ch-name {
  font-size: 16px;
  font-weight: 600;
  color: #3b2818;
}

.channel-card .ch-desc {
  font-size: 12px;
  color: #807060;
}

.channel-card .ch-count {
  font-size: 13px;
  color: #8c7b6c;
  font-weight: 600;
  background: #f5eedf;
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

.sponsor-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(190, 175, 155, 0.3);
}

.sponsor-label {
  font-size: 12px;
  color: #8c7b6c;
  margin-bottom: 4px;
}

.sponsor-account {
  font-size: 13px;
  color: #5c4a3b;
  min-height: 20px;
}

/* ─── 3D 메인 게임 화면 ─── */
#game-screen {
  position: fixed;
  inset: 0;
  background: #e5ede7;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#game-canvas:active {
  cursor: grabbing;
}

/* ─── 상단 바 ─── */
#top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(255, 252, 246, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(180, 160, 135, 0.2);
  z-index: 100;
}

.top-left {
  font-size: 14px;
  font-weight: 600;
  color: #5c412b;
}

.top-center .temple-title {
  font-size: 17px;
  font-weight: 600;
  color: #3d281a;
  letter-spacing: 5px;
}

.top-right {
  font-size: 13px;
  color: #7a6654;
  display: flex;
  align-items: center;
  gap: 10px;
}

#user-count {
  font-weight: 600;
  color: #4a3424;
}

#btn-change-channel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(180, 160, 135, 0.35);
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #5c412b;
  font-family: inherit;
  transition: all 0.2s;
}

#btn-change-channel:hover {
  background: #f0e6d6;
  border-color: #c99357;
}

/* ─── 닉네임 배지 ─── */
#my-nickname-display {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 600;
  color: #5c4432;
  background: rgba(255, 252, 246, 0.92);
  padding: 5px 16px;
  border-radius: 20px;
  border: 1.5px solid #d49f50;
  box-shadow: 0 3px 10px rgba(212, 159, 80, 0.2);
  z-index: 100;
  white-space: nowrap;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

#my-nickname-display:hover {
  transform: translateX(-50%) scale(1.05);
  background: #ffffff;
}

.edit-icon {
  font-size: 11px;
  opacity: 0.65;
}

/* ─── WASD 키보드 조작 가이드 ─── */
#controls-guide {
  position: fixed;
  top: 64px;
  right: 20px;
  font-size: 11px;
  color: #7a6a58;
  background: rgba(255, 252, 246, 0.8);
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(180, 160, 135, 0.2);
  pointer-events: none;
  z-index: 90;
}

/* ─── 3D 닉네임 라벨 (NPC 명확화) ─── */
#label-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

.monk-label {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 11px;
  font-weight: 500;
  background: rgba(255, 252, 246, 0.9);
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid rgba(180, 160, 135, 0.3);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.monk-label.player-label {
  font-size: 12px;
  font-weight: 600;
  color: #3b2210;
  background: rgba(255, 248, 230, 0.96);
  border: 1.5px solid #d49f50;
  box-shadow: 0 3px 10px rgba(212, 159, 80, 0.25);
}

.badge-me {
  background: #d49f50;
  color: #fff;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 4px;
}

.monk-label.remote-label {
  color: #4a3424;
  border-color: #ba8c5b;
}

.monk-label.npc-label {
  color: #3e5241;
}

.badge-npc {
  background: #4a7a5d;
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
}

/* ─── 앉기 / 일어나기 플로팅 옵션 팝업 ─── */
#seat-prompt {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 105;
  animation: popIn 0.25s ease-out forwards;
}

@keyframes popIn {
  0% { transform: translate(-50%, 15px) scale(0.9); opacity: 0; }
  100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

.seat-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #fffbf2 0%, #faeed7 100%);
  border: 1.8px solid #c99357;
  border-radius: 30px;
  color: #4a3220;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(180, 130, 60, 0.25);
  transition: all 0.2s ease;
}

.seat-action-btn:hover {
  background: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(180, 130, 60, 0.35);
}

/* ─── 하단 액션 버튼 바 ─── */
#action-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(255, 252, 246, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 24px;
  border: 1px solid rgba(180, 155, 125, 0.3);
  box-shadow: 0 8px 24px rgba(100, 75, 50, 0.12);
  z-index: 100;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(180, 155, 125, 0.25);
  border-radius: 14px;
  padding: 9px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 64px;
}

.action-btn:hover {
  background: #ffffff;
  border-color: #c99357;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(180, 130, 80, 0.15);
}

.action-btn.active {
  background: #faeedc;
  border-color: #d49f50;
}

.action-icon {
  font-size: 22px;
}

.action-label {
  font-size: 11px;
  color: #634b39;
  font-weight: 500;
}

/* ─── 사운드 패널 ─── */
#sound-panel-toggle {
  position: fixed;
  bottom: 92px;
  right: 18px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 252, 246, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(180, 155, 125, 0.3);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  z-index: 100;
  transition: all 0.2s;
}

#sound-panel-toggle:hover {
  background: #ffffff;
  transform: scale(1.05);
}

#sound-panel {
  position: fixed;
  bottom: 148px;
  right: 18px;
  width: 240px;
  background: rgba(255, 252, 246, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(180, 155, 125, 0.3);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.12);
  border-radius: 18px;
  padding: 18px;
  z-index: 100;
}

#sound-panel h3 {
  font-size: 14px;
  font-weight: 600;
  color: #4a3424;
  margin-bottom: 14px;
  text-align: center;
}

.sound-control {
  margin-bottom: 12px;
}

.sound-control label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #5c4432;
  margin-bottom: 5px;
  cursor: pointer;
}

.sound-control input[type="checkbox"] {
  accent-color: #c99357;
  width: 15px;
  height: 15px;
}

.sound-control input[type="range"] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #ded7c8;
  border-radius: 2px;
  outline: none;
}

.sound-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: #c99357;
  border-radius: 50%;
  cursor: pointer;
}

/* ─── 커스텀 모달 공통 스타일 ─── */
.custom-modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 10, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: radial-gradient(circle at center, #fffef9 0%, #faeed7 100%);
  border: 1.5px solid #d4a768;
  border-radius: 20px;
  padding: 24px 28px;
  width: 90%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 16px 36px rgba(60, 40, 20, 0.25);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 18px;
  color: #8c7866;
  cursor: pointer;
  padding: 4px;
}

.modal-card h3 {
  font-size: 19px;
  font-weight: 700;
  color: #4a3220;
  margin-bottom: 6px;
}

.modal-desc {
  font-size: 13px;
  color: #7d6b58;
  margin-bottom: 16px;
}

.modal-card input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-family: inherit;
  border: 1.5px solid #c99357;
  border-radius: 12px;
  background: #ffffff;
  color: #3b2818;
  outline: none;
  margin-bottom: 10px;
  text-align: center;
}

.modal-card input[type="text"]:focus {
  border-color: #a86c2e;
  box-shadow: 0 0 0 3px rgba(201, 147, 87, 0.2);
}

.error-msg {
  font-size: 12px;
  color: #b83d2e;
  margin-bottom: 14px;
  font-weight: 500;
}

.modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}

.modal-buttons button {
  padding: 10px 18px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.primary-btn {
  background: #c99357;
  color: #ffffff;
  border: none;
}
.primary-btn:hover { background: #b07e47; }

.sub-btn {
  background: #f0e2ce;
  color: #5c412a;
  border: 1px solid #d4b58c;
}
.sub-btn:hover { background: #e6d3ba; }

.cancel-btn {
  background: #ffffff;
  color: #7a6a58;
  border: 1px solid #d4c8b6;
}
.cancel-btn:hover { background: #f5efe6; }

/* ─── 목탁 두드리기 모달 ─── */
.moktak-card {
  max-width: 380px;
}

.moktak-interactive-area {
  margin: 10px auto 16px;
  width: 220px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}

.moktak-visual-wrapper {
  position: relative;
  width: 180px;
  height: 140px;
}

.moktak-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 8px 16px rgba(80, 40, 10, 0.25));
}

#moktak-stick {
  transition: transform 0.08s ease-out;
  transform-origin: 140px 20px;
}

#moktak-ripple {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(212, 160, 60, 0.8);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  opacity: 0;
}

#moktak-ripple.active {
  animation: rippleAnim 0.5s ease-out forwards;
}

@keyframes rippleAnim {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(14); opacity: 0; }
}

.counter-badge {
  font-size: 14px;
  font-weight: 600;
  color: #63442a;
  background: rgba(255, 255, 255, 0.75);
  padding: 6px 16px;
  border-radius: 20px;
  display: inline-block;
  border: 1px solid rgba(200, 160, 100, 0.3);
}

/* ─── 108 염주 모달 ─── */
.beads-card {
  max-width: 380px;
}

.beads-interactive-area {
  margin: 12px auto 16px;
  width: 140px;
  height: 180px;
  overflow: hidden;
  position: relative;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 24px;
  border: 1px solid rgba(190, 155, 115, 0.4);
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.05);
  cursor: ns-resize;
  display: flex;
  justify-content: center;
}

.beads-visual-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: transform 0.15s ease-out;
  padding: 10px 0;
}

.bead-item {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #a86237 0%, #572a12 85%);
  box-shadow: 0 4px 8px rgba(50, 25, 10, 0.35);
  flex-shrink: 0;
}

/* ─── 모바일 최적화 ─── */
@media (max-width: 600px) {
  #top-bar {
    height: 46px;
    padding: 0 14px;
  }

  .top-left { font-size: 12px; }
  .top-center .temple-title { font-size: 15px; letter-spacing: 3px; }
  .top-right { font-size: 12px; gap: 6px; }

  #btn-change-channel {
    padding: 4px 8px;
    font-size: 11px;
  }

  #my-nickname-display {
    top: 52px;
    font-size: 11px;
    padding: 4px 12px;
  }

  #controls-guide {
    display: none;
  }

  #loading-screen h1, #channel-screen h1 {
    font-size: 30px;
    letter-spacing: 4px;
  }

  .lotus-icon { font-size: 44px; }

  .channel-card {
    padding: 14px 16px;
  }
  .channel-card .ch-name { font-size: 14px; }
  .channel-card .ch-desc { font-size: 11px; }

  #seat-prompt {
    bottom: 84px;
  }

  .seat-action-btn {
    padding: 10px 20px;
    font-size: 13px;
  }

  #action-bar {
    gap: 8px;
    padding: 8px 12px;
    bottom: 14px;
  }

  .action-btn {
    padding: 8px 10px;
    min-width: 52px;
    border-radius: 12px;
  }

  .action-icon { font-size: 19px; }
  .action-label { font-size: 10px; }

  #sound-panel-toggle {
    bottom: 80px;
    right: 12px;
    width: 38px;
    height: 38px;
    font-size: 16px;
  }

  #sound-panel {
    right: 10px;
    bottom: 128px;
    width: 215px;
    padding: 14px;
  }

  .modal-card {
    padding: 20px 20px;
  }
}
