* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: #0f172a;
  color: #f8fafc;
  font-family: 'Pretendard', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}

/* 메인 화면 레이아웃 */
main.npc-container {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 50px !important;
  width: 95% !important;
  max-width: 1050px !important;
  margin: 0 auto;
}

.npc-section {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 15px !important;
  width: 320px !important;
  flex-shrink: 0 !important;
}

.npc-section .dialogue-box {
  width: 100% !important;
  padding: 16px 20px !important;
  background: rgba(30, 27, 75, 0.95) !important;
  border: 1px solid rgba(167, 139, 250, 0.6) !important;
  border-radius: 14px !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4) !important;
  text-align: center;
}

.npc-section .dialogue-box p {
  font-size: 1.05rem !important;
  color: #ffffff !important;
  line-height: 1.5;
  word-break: keep-all;
}

.npc-section .dialogue-box p::after,
.modal-npc-area .dialogue-box p::after {
  content: '❚';
  display: inline-block;
  margin-left: 4px;
  font-size: 0.9em;
  color: #a78bfa;
  animation: blink 0.8s infinite;
}

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

.npc-section #npc-img {
  width: 180px !important;
  height: 180px !important;
  border-radius: 50% !important;
  border: 4px solid #a78bfa !important;
  box-shadow: 0 0 20px rgba(167, 139, 250, 0.4) !important;
  object-fit: cover !important;
  object-position: top center !important;
}

/* 선택지 버튼 */
.choice-section {
  display: flex !important;
  flex-direction: column !important;
  gap: 14px !important;
  width: 360px !important;
  max-width: 100% !important;
  flex-shrink: 0 !important;
}

.choice-btn {
  width: 100% !important;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #fff;
  font-size: 1.1rem;
  font-weight: bold;
  padding: 16px 24px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap !important;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.choice-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.choice-btn.secondary {
  background: #334155;
  color: #cbd5e1;
  box-shadow: none;
}

.choice-btn.secondary:hover {
  background: #475569;
  color: #fff;
}

/* 모달 레이아웃 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.modal-overlay:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 20px;
  width: 90%;
  max-width: 1000px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 30px;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  transform: translateY(30px) scale(0.95);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay:not(.hidden) .modal-content {
  transform: translateY(0) scale(1);
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 20px;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 2.5rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.close-btn:hover { color: #f8fafc; }

.modal-header {
  text-align: center;
  margin-bottom: 15px;
}

.modal-header h1 {
  color: #c084fc;
  font-size: 1.5rem;
}

/* 모달 내 NPC 대화 상자 */
.modal-npc-area {
  display: flex !important;
  align-items: flex-start !important;
  gap: 14px !important;
  background: rgba(30, 27, 75, 0.7) !important;
  border: 1px solid rgba(167, 139, 250, 0.4) !important;
  padding: 16px 20px !important;
  border-radius: 14px !important;
  margin: 10px 0 20px 0 !important;
}

.modal-npc-area img.modal-npc-avatar {
  width: 52px !important;
  height: 52px !important;
  border-radius: 50% !important;
  border: 2px solid #a78bfa !important;
  object-fit: cover !important;
  flex-shrink: 0 !important;
}

.modal-npc-area .dialogue-box {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: none !important;
  margin: 0 !important;
  flex: 1;
}

.modal-npc-area .dialogue-box p {
  font-size: 1rem !important;
  color: #e2e8f0 !important;
  line-height: 1.5;
}

.modal-choice-box {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.modal-choice-box.hidden {
  display: none !important;
}

.npc-choice-btn {
  padding: 9px 18px;
  font-size: 0.92rem;
  font-weight: bold;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.npc-choice-btn.primary {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.npc-choice-btn.primary:hover {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.5);
}

.npc-choice-btn.secondary {
  background: #334155;
  color: #cbd5e1;
}

.npc-choice-btn.secondary:hover {
  background: #475569;
  color: #ffffff;
  transform: translateY(-2px);
}

/* 3D 타로 카드 캐러셀 레아아웃 */
.deck-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 380px;
  background: radial-gradient(circle, rgba(30, 27, 75, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
  border-radius: 16px;
  border: 1px solid rgba(167, 139, 250, 0.2);
  overflow: hidden;
  perspective: 1200px;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.deck-container.hidden {
  display: none !important;
}

.carousel-indicator {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(167, 139, 250, 0.4);
  color: #a78bfa;
  font-size: 0.85rem;
  font-weight: bold;
  padding: 4px 14px;
  border-radius: 20px;
  z-index: 1000;
  pointer-events: none;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  background: rgba(167, 139, 250, 0.2);
  border: 1px solid rgba(167, 139, 250, 0.5);
  color: #fff;
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.carousel-btn:hover {
  background: rgba(167, 139, 250, 0.6);
  transform: translateY(-50%) scale(1.1);
}

.carousel-btn.prev { left: 15px; }
.carousel-btn.next { right: 15px; }

.carousel-track {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  transform-style: preserve-3d;
}

/* ==========================================
   고급 카드 연출 (3D & Glow 효과)
   ========================================== */
.card {
  position: absolute;
  width: 110px;
  height: 180px;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.35s ease, filter 0.35s ease;
  cursor: pointer;
  user-select: none;
  transform-style: preserve-3d;
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  overflow: hidden;
  backface-visibility: hidden;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(234, 179, 8, 0.3);
  border: 1px solid rgba(250, 204, 21, 0.4);
  transition: box-shadow 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

.card-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-back { transform: rotateY(0deg); z-index: 2; }
.card-front { transform: rotateY(180deg); z-index: 1; }

/* 중앙 선택 집중 카드 스타일 및 호버 마법 효과 */
.card.center-card {
  filter: drop-shadow(0 0 18px rgba(168, 85, 247, 0.85));
}

.card.center-card .card-face {
  border-color: rgba(250, 204, 21, 0.9);
}

.card:hover .card-face {
  border-color: #facc15;
  box-shadow: 0 14px 28px rgba(168, 85, 247, 0.5), 0 0 15px rgba(250, 204, 21, 0.6);
}

.card.selected-disabled {
  opacity: 0.25 !important;
  cursor: default !important;
  filter: grayscale(100%) !important;
}

/* 결과 영역 */
.result-section {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.result-section.hidden {
  display: none !important;
}

.selected-cards-container {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin: 20px 0;
}

.result-card-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  padding: 15px;
  border-radius: 12px;
  width: 180px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.result-card-item.show {
  opacity: 1;
  transform: translateY(0);
}

.result-card-item .card {
  position: relative;
  width: 100px;
  height: 160px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-style: preserve-3d;
}

.card-inner.flipped { transform: rotateY(180deg); }
.card-inner.flipped-reversed { transform: rotateY(180deg) rotateZ(180deg); }

.card-info {
  margin-top: 12px;
  text-align: center;
  font-size: 0.85rem;
}

.interpretation-box {
  background: rgba(30, 27, 75, 0.5);
  border: 1px solid rgba(167, 139, 250, 0.3);
  padding: 20px;
  border-radius: 12px;
  line-height: 1.6;
}

.loading-box {
  text-align: center;
  padding: 30px;
  font-size: 1.1rem;
  color: #c084fc;
  animation: pulse 1.5s infinite alternate;
}

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

.bgm-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  padding: 8px 14px;
  font-size: 0.8rem;
  color: #a78bfa;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 20px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.bgm-btn.muted {
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.3);
}

.next-indicator {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 0.85rem;
  color: #c084fc;
  animation: bounceNext 0.7s infinite alternate;
}

.next-indicator.hidden {
  display: none !important;
}

@keyframes bounceNext {
  0% { transform: translateY(0); opacity: 0.4; }
  100% { transform: translateY(4px); opacity: 1; }
}

.result-interpretation-card {
  background: rgba(30, 27, 75, 0.6);
  border-left: 4px solid #a78bfa;
  padding: 14px 18px;
  margin-bottom: 12px;
  border-radius: 0 10px 10px 0;
}

.interp-header {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.interp-pos {
  color: #c084fc;
  font-weight: bold;
  font-size: 0.9rem;
}

.interp-name {
  color: #f8fafc;
  font-weight: bold;
  font-size: 1rem;
}

.interp-text {
  color: #cbd5e1;
  line-height: 1.6;
  font-size: 0.95rem;
}

.history-list {
  max-height: 300px;
  overflow-y: auto;
  margin-top: 15px;
  text-align: left;
}

.history-item:last-child {
  border-bottom: none !important;
}