/* ===== 모달 팝업 ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.5s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: linear-gradient(145deg, #1a1040, #2a1555);
  border: 1px solid #8a5cc8;
  border-radius: 20px;
  padding: 40px 50px;
  text-align: center;
  box-shadow: 0 0 40px rgba(138, 92, 200, 0.4);
  animation: fadeIn 0.6s ease;
  max-width: 400px;
}

.modal-text {
  font-size: 1.2rem;
  color: #e0d5c1;
  line-height: 1.8;
  margin-bottom: 25px;
}

.modal-close-btn {
  background: linear-gradient(135deg, #6b3fa0, #3a1d6e);
  border: 1px solid #8a5cc8;
  color: #e0d5c1;
  font-family: 'Noto Serif KR', serif;
  font-size: 1rem;
  padding: 10px 30px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 2px;
}

.modal-close-btn:hover {
  background: linear-gradient(135deg, #8a5cc8, #5a2d9e);
  box-shadow: 0 0 25px rgba(138, 92, 200, 0.5);
  transform: translateY(-2px);
}

/* ===== 기본 리셋 & 폰트 ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Serif KR', serif;
  background: #0a0a14;
  color: #e0d5c1;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ===== 별 배경 ===== */
.stars {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  animation: twinkle var(--duration) ease-in-out infinite alternate;
}

@keyframes twinkle {
  0% { opacity: 0.2; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1.2); }
}

/* ===== 컨테이너 ===== */
.container {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
  text-align: center;
}

/* ===== 헤더 ===== */
.title {
  font-size: 2.4rem;
  color: #d4af37;
  text-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
  margin-bottom: 8px;
  letter-spacing: 4px;
}

.subtitle {
  color: #8a7e6b;
  font-size: 1rem;
  margin-bottom: 40px;
}

/* ===== 화면 전환 ===== */
.screen {
  display: none;
  animation: fadeIn 0.8s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 시작 화면 ===== */
.crystal-ball {
  position: relative;
  width: 150px;
  height: 150px;
  margin: 0 auto 30px;
}

.ball-icon {
  font-size: 100px;
  display: block;
  line-height: 150px;
  animation: float 3s ease-in-out infinite;
}

.ball-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(138, 79, 255, 0.3) 0%, transparent 70%);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
}

.intro-text {
  font-size: 1.1rem;
  line-height: 1.8;
  color: #b0a58e;
  margin-bottom: 30px;
}

/* ===== 버튼 ===== */
.btn {
  background: linear-gradient(135deg, #6b3fa0, #3a1d6e);
  border: 1px solid #8a5cc8;
  color: #e0d5c1;
  font-family: 'Noto Serif KR', serif;
  font-size: 1.1rem;
  padding: 14px 40px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 2px;
}

.btn:hover {
  background: linear-gradient(135deg, #8a5cc8, #5a2d9e);
  box-shadow: 0 0 25px rgba(138, 92, 200, 0.5);
  transform: translateY(-2px);
}

/* ===== 카드 스프레드 ===== */
.spread-guide {
  color: #8a7e6b;
  margin-bottom: 30px;
  font-size: 1rem;
}

.card-positions {
  display: flex;
  justify-content: center;
  gap: 30px;
  flex-wrap: wrap;
}

.position {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.position-label {
  font-size: 0.9rem;
  color: #d4af37;
  letter-spacing: 3px;
  text-transform: uppercase;
}

/* ===== 타로 카드 ===== */
.tarot-card {
  width: 180px;
  height: 300px;
  perspective: 800px;
  cursor: pointer;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.tarot-card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-back, .card-front {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  overflow: hidden;
}

.card-back {
  background: linear-gradient(145deg, #1a1040, #2a1555, #1a1040);
  border: 2px solid #5a3d8a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-back-design {
  width: 140px;
  height: 260px;
  border: 1px solid #5a3d8a;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-conic-gradient(
    rgba(90, 61, 138, 0.15) 0% 25%,
    transparent 0% 50%
  ) 0 0 / 20px 20px;
}

.card-back-design span {
  font-size: 50px;
  color: #8a5cc8;
  text-shadow: 0 0 15px rgba(138, 92, 200, 0.6);
}

.card-front {
  transform: rotateY(180deg);
  background: linear-gradient(170deg, #1c1235, #0f0a20);
  border: 2px solid #d4af37;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15px;
}

.card-symbol {
  font-size: 70px;
  margin-bottom: 10px;
}

.card-name {
  font-size: 0.95rem;
  color: #d4af37;
  font-weight: 700;
  text-align: center;
  letter-spacing: 1px;
}

.card-direction {
  font-size: 0.8rem;
  margin-top: 6px;
  padding: 3px 12px;
  border-radius: 20px;
  letter-spacing: 1px;
}

.card-direction.upright {
  color: #7ec8a0;
  border: 1px solid #7ec8a044;
}

.card-direction.reversed {
  color: #c87e7e;
  border: 1px solid #c87e7e44;
}

.tarot-card.reversed .card-symbol {
  transform: rotate(180deg);
}

/* 카드 호버 (뒤집기 전) */
.tarot-card:not(.flipped):hover .card-inner {
  transform: translateY(-8px);
  filter: brightness(1.1);
}

.tarot-card:not(.flipped):hover .card-back {
  box-shadow: 0 8px 30px rgba(138, 92, 200, 0.4);
}

/* 카드 등장 애니메이션 */
.tarot-card {
  opacity: 0;
  animation: cardAppear 0.6s ease forwards;
}

.tarot-card:nth-child(1) { animation-delay: 0s; }

.position:nth-child(1) .tarot-card { animation-delay: 0.2s; }
.position:nth-child(2) .tarot-card { animation-delay: 0.5s; }
.position:nth-child(3) .tarot-card { animation-delay: 0.8s; }

@keyframes cardAppear {
  from { opacity: 0; transform: translateY(40px) scale(0.8); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== 셔플 애니메이션 ===== */
@keyframes shuffleLeft {
  0% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-60px) rotate(-8deg); }
  50% { transform: translateX(0) rotate(0); }
  75% { transform: translateX(60px) rotate(8deg); }
  100% { transform: translateX(0) rotate(0); }
}

.tarot-card.shuffling {
  animation: shuffleLeft 0.4s ease-in-out;
}

/* ===== 해설 화면 ===== */
.reading-title {
  font-size: 1.8rem;
  color: #d4af37;
  margin-bottom: 30px;
  text-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.reading-content {
  text-align: left;
  max-width: 700px;
  margin: 0 auto 30px;
}

.reading-card {
  background: linear-gradient(145deg, rgba(26, 16, 64, 0.6), rgba(15, 10, 32, 0.8));
  border: 1px solid #3a2a5a;
  border-radius: 16px;
  padding: 25px;
  margin-bottom: 20px;
  animation: fadeIn 0.6s ease;
}

.reading-card:nth-child(2) { animation-delay: 0.2s; }
.reading-card:nth-child(3) { animation-delay: 0.4s; }

.reading-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
  padding-bottom: 12px;
  border-bottom: 1px solid #3a2a5a;
}

.reading-card-position {
  font-size: 0.8rem;
  color: #8a5cc8;
  background: rgba(138, 92, 200, 0.15);
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 2px;
}

.reading-card-name {
  font-size: 1.1rem;
  color: #d4af37;
  font-weight: 700;
}

.reading-card-dir {
  font-size: 0.8rem;
  padding: 2px 10px;
  border-radius: 12px;
}

.reading-card-dir.upright {
  color: #7ec8a0;
  background: rgba(126, 200, 160, 0.1);
}

.reading-card-dir.reversed {
  color: #c87e7e;
  background: rgba(200, 126, 126, 0.1);
}

.reading-card-keywords {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.keyword {
  font-size: 0.75rem;
  color: #b0a58e;
  background: rgba(176, 165, 142, 0.1);
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid rgba(176, 165, 142, 0.15);
}

.reading-card-meaning {
  font-size: 0.95rem;
  line-height: 1.8;
  color: #c8bda8;
}

/* 종합 해설 */
.reading-summary {
  background: linear-gradient(145deg, rgba(212, 175, 55, 0.08), rgba(138, 92, 200, 0.08));
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 16px;
  padding: 25px;
  margin: 0 auto 30px;
  max-width: 700px;
  text-align: left;
}

.summary-title {
  font-size: 1.1rem;
  color: #d4af37;
  margin-bottom: 12px;
}

.summary-text {
  font-size: 0.95rem;
  line-height: 1.9;
  color: #b0a58e;
}

/* ===== 반응형 ===== */
@media (max-width: 640px) {
  .title {
    font-size: 1.6rem;
  }

  .card-positions {
    gap: 20px;
  }

  .tarot-card {
    width: 140px;
    height: 240px;
  }

  .card-back-design {
    width: 110px;
    height: 210px;
  }

  .card-symbol {
    font-size: 50px;
  }

  .card-name {
    font-size: 0.8rem;
  }

  .reading-card {
    padding: 18px;
  }
}

@media (max-width: 480px) {
  .card-positions {
    flex-direction: column;
    align-items: center;
  }
}
