/* 전체 영역 컨테이너 */
.tarotSection {
  width: 100%;
  height: 260px;
  display: flex;
  flex-direction: column;
  text-align: center;
  position: relative;
  padding: 24px 0;
  border-radius: var(--border-radius-r);
  background-color: #4b425c;
}

/* 안의 카드와 텍스트가 위에 보이도록 */
.tarotSection > * {
  position: relative;
  z-index: 1;
}

.tarotContainer,
.secondTarot {
  flex: 1;
  width: 100%;
  overflow: hidden;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -ms-overflow-style: none;
  display: flex;
  flex-direction: row;
  justify-content: center;
  padding-top: 10px;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.5));
}

.tarotCard:first-child {
  margin-left: 0px !important;
}

.tarotContainer::-webkit-scrollbar {
  display: none;
}

/* 카드 고정 사이즈 */
.tarotCard {
  width: 62px;
  height: calc(62px * 1.65);
  display: inline-block;
  position: relative;
  margin-left: -46px;
  cursor: pointer;
  transform-style: preserve-3d;
}

/* 앞/뒤 공통 스타일 */
.tarotCard .front,
.tarotCard .back {
  width: 100%;
  height: 100%;
  position: absolute;
  backface-visibility: hidden;
  overflow: hidden;
}

.tarotCard .back {
  transform: rotateY(180deg);
}

.tarotCard img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.tarotCard.show {
  animation: cardAppear 0.4s ease forwards;
  animation-fill-mode: backwards; /* ✅ 딜레이 동안 from 상태 유지 */
}

/* 선택된 카드 강조 */
.tarotCard.flipped {
  transform: rotateY(180deg) translateY(0px);
  z-index: 20;
}
/* 카드 이미지 */
.tarotCard img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 뒷면은 플립 상태 */
.tarotCard .back {
  transform: rotateY(180deg);
}
.cta_button_box {
  width: 100%;
  display: flex;
  justify-content: center;
}
.cta_button_box {
  width: 100%;
  display: flex;
  justify-content: center;
}
button.spreadBtn,
button.resultBtn,
button.nextBtn {
  background-color: #645979;
  color: #fff3cb;
  padding: 8px 16px;
  border-radius: var(--border-radius-xs);
  border: 0.3px solid #fff3cb;
  display: block;
  font-size: var(--size-sm);
  font-weight: var(--weight-large);
  cursor: pointer;
  width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
button.spreadBtn.nonborder,
button.resultBtn.nonborder,
button.nextBtn.nonborder {
  border: none;
  background-color: var(--color-purple2);
  color: var(--color-white);
}

.secondCard {
  width: 62px;
  height: calc(62px * 1.65);
  display: inline-block;
  margin: 0 10px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.35s ease;
}

.secondCard img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.secondCard.flipped {
  transform: rotateY(180deg);
}

.tarotSection .introText {
  color: #ffefb8;
  font-size: var(--size-sm);
  font-weight: 500;
  text-align: center;
}

.homeMain #tarotSection .tarotSection {
  height: auto;
  min-height: 280px;
  overflow: hidden;
  padding: 22px 22px 20px;
  border: 1px solid rgba(255, 239, 184, 0.22);
  border-radius: 18px;
  background: radial-gradient(circle at 18% 24%, rgba(255, 255, 255, 0.14) 0 1px, transparent 2px),
    radial-gradient(circle at 82% 18%, rgba(255, 255, 255, 0.16) 0 1px, transparent 2px),
    radial-gradient(circle at 12% 86%, rgba(152, 120, 224, 0.22), transparent 30%),
    radial-gradient(circle at 88% 88%, rgba(152, 120, 224, 0.2), transparent 28%),
    linear-gradient(135deg, #201548 0%, #30205f 48%, #171339 100%);
  box-shadow: 0 14px 34px rgba(31, 21, 72, 0.22);
}

.homeMain #tarotSection .tarotSection::before,
.homeMain #tarotSection .tarotSection::after {
  content: '';
  position: absolute;
  z-index: 0;
  width: 140px;
  height: 70px;
  border-radius: 999px 999px 0 0;
  background: rgba(143, 110, 216, 0.13);
  filter: blur(1px);
  pointer-events: none;
}

.homeMain #tarotSection .tarotSection::before {
  right: -28px;
  bottom: -8px;
}

.homeMain #tarotSection .tarotSection::after {
  left: -34px;
  bottom: -12px;
}

.homeMain #tarotSection .introText {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #f6e9c7;
}

.homeMain #tarotSection .introText p {
  margin: 0;
}

.homeMain #tarotSection .tarotIntroEyebrow {
  color: rgba(255, 246, 220, 0.86);
  font-size: var(--size-sm);
  line-height: 1.45;
}

.homeMain #tarotSection .tarotIntroTitle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-white);
  font-size: clamp(17px, 2.3vw, 22px);
  line-height: 1.28;
  font-weight: var(--weight-black);
  word-break: keep-all;
}

.homeMain #tarotSection .tarotContainer.main {
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 102px;
  margin: 12px auto 0;
  padding: 2px 10px 4px;
  filter: drop-shadow(0 12px 12px rgba(8, 7, 22, 0.35));
}

.homeMain #tarotSection .tarotCard {
  width: 64px;
  height: calc(64px * 1.62);
  margin-left: -36px;
}

.homeMain #tarotSection .tarotCard:first-child {
  margin-left: 0 !important;
}

.homeMain #tarotSection .tarotCard img {
  border-radius: 5px;
}

.homeMain #tarotSection .cta_button_box {
  margin-top: 10px;
}

.homeMain #tarotSection button.spreadBtn,
.homeMain #tarotSection button.resultBtn,
.homeMain #tarotSection button.nextBtn {
  width: min(100%, 420px);
  min-height: 40px;
  padding: 8px 20px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #9f80e8 0%, #8264ce 100%);
  box-shadow: 0 10px 24px rgba(15, 11, 44, 0.24);
  color: var(--color-white);
  font-size: var(--size-sm);
}

.fadeOut {
  opacity: 0 !important;
  transform: translateY(10px) !important;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.fadeIn {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.wrapEveryThing {
  width: 100%;
  aspect-ratio: 2/1;
  background: radial-gradient(circle at 50% 18%, rgba(155, 126, 226, 0.22), transparent 32%),
    radial-gradient(circle at 14% 18%, rgba(111, 77, 196, 0.18), transparent 34%),
    linear-gradient(145deg, #f5f1ff 0%, #e6dcfb 48%, #d3c6f2 100%);
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.frontimg {
  width: 80px;
  height: 137px;
  border-radius: 4px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.8);
}

.tarotResultReading {
  gap: 22px;
  min-width: 0;
  padding: 10px 8px 4px;
}

.tarotResultHeader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px dashed color-mix(in srgb, var(--color-purple2) 30%, var(--color-lightGray));
  text-align: center;
}

.tarotResultHeader .cardName {
  color: #251845;
  font-size: 26px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: 0;
}

.tarotResultHeader .cardNameKo {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--color-purple2);
  font-size: var(--size-base);
  line-height: 1.3;
  font-weight: var(--weight-large);
}

.tarotResultHeader .cardNameKo::before,
.tarotResultHeader .cardNameKo::after {
  content: '';
  width: 34px;
  height: 1px;
  background-color: color-mix(in srgb, var(--color-purple2) 36%, var(--color-lightGray));
}

.tarotResultReading #restext {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  color: var(--color-black2);
  font-size: var(--size-base);
  line-height: 1.9;
  font-weight: var(--weight-regular);
  line-break: strict;
  word-break: normal;
  overflow-wrap: anywhere;
}

.swipe_desc {
  font-size: var(--size-xs);
  color: var(--color-white);
  opacity: 0.7;
}
.tarot_theme_select_box,
.card_select_box {
  width: 100%;
}
.tarot_theme_select_box .tarot_box_inner {
  gap: 18px;
  padding: 28px 24px 30px;
  border: 1px solid rgba(255, 239, 184, 0.22);
  border-radius: 18px;
  background: radial-gradient(circle at 18% 24%, rgba(255, 255, 255, 0.12) 0 1px, transparent 2px),
    radial-gradient(circle at 82% 18%, rgba(255, 255, 255, 0.14) 0 1px, transparent 2px),
    radial-gradient(circle at 12% 86%, rgba(152, 120, 224, 0.2), transparent 30%),
    radial-gradient(circle at 88% 88%, rgba(152, 120, 224, 0.18), transparent 28%),
    linear-gradient(135deg, #201548 0%, #30205f 48%, #171339 100%);
  box-shadow: 0 14px 34px rgba(31, 21, 72, 0.18);
}
.tarot_theme_select_box .tarot_box_inner::before {
  display: none;
}
.tarot_theme_select_box .tarot_title_box {
  gap: 8px;
}
.tarot_theme_select_box .tarot_title {
  color: var(--color-white);
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.28;
}
.tarot_theme_select_box .tarot_sub_title {
  color: rgba(255, 246, 220, 0.86);
  font-size: var(--size-sm);
  line-height: 1.5;
}
.card_select_box .tarot_box_inner {
  gap: 16px;
  padding: 28px 24px;
  border: 1px solid rgba(255, 239, 184, 0.22);
  border-radius: 18px;
  background: radial-gradient(circle at 18% 24%, rgba(255, 255, 255, 0.12) 0 1px, transparent 2px),
    radial-gradient(circle at 82% 18%, rgba(255, 255, 255, 0.14) 0 1px, transparent 2px),
    radial-gradient(circle at 12% 86%, rgba(152, 120, 224, 0.2), transparent 30%),
    radial-gradient(circle at 88% 88%, rgba(152, 120, 224, 0.18), transparent 28%),
    linear-gradient(135deg, #201548 0%, #30205f 48%, #171339 100%);
  box-shadow: 0 14px 34px rgba(31, 21, 72, 0.18);
}
.card_select_box .tarot_box_inner::before {
  display: none;
}
.card_select_box .tarot_title_box {
  gap: 8px;
}
.card_select_box .tarot_title {
  color: var(--color-white);
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.28;
}
.card_select_box .tarot_sub_title {
  color: rgba(255, 246, 220, 0.86);
  font-size: var(--size-sm);
  line-height: 1.5;
}
.tarot_box_inner {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  background-color: var(--color-boxGray);
  padding: 30px;
  background: url('/img/tarot/tarot_box_bg.webp') center/cover no-repeat;
  border-radius: var(--border-radius-l);
  position: relative;
  overflow: hidden;
  z-index: 1;
}
.tarot_box_inner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, rgba(75, 66, 92, 0.7), rgba(158, 139, 194, 0.7));
  z-index: -1;
}
.tarot_title_box {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.tarot_title {
  font-size: var(--size-3xl);
  font-weight: 800;
  color: var(--color-white);
}
.tarot_sub_title {
  font-size: var(--size-sm);
  font-weight: var(--weight-regular);
  color: var(--color-white);
  text-align: center;
  white-space: pre-line;
}
.tarot_category_box {
  display: grid;
  grid-template-columns: repeat(2, 132px);
  justify-content: center;
  gap: 12px;
  width: 100%;
}
.tarot_category_card {
  flex: 1;
  width: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  gap: 8px;
  background-color: transparent;
  border: 0;
  border-radius: 14px;
  box-shadow: none;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.tarot_category_card:hover,
.tarot_category_card:focus-visible {
  transform: translateY(-4px);
  filter: drop-shadow(0 12px 18px rgba(12, 8, 36, 0.28));
}
.tarot_category_card:focus-visible {
  outline: 2px solid #f6d986;
  outline-offset: 4px;
}
.tarot_category_visual {
  position: relative;
  width: 132px;
  aspect-ratio: 2 / 3;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 18px rgba(8, 7, 22, 0.34);
}
.tarot_category_card_img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tarot_category_card_text_box {
  position: absolute;
  left: 50%;
  bottom: 15%;
  transform: translateX(-50%);
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 12px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.78);
  text-align: center;
  gap: 4px;
  text-shadow: 0 2px 8px rgba(7, 4, 24, 0.72);
  pointer-events: none;
}
.category_name {
  max-width: 100%;
  font-size: clamp(12px, 1.5vw, 15px);
  line-height: 1.22;
  color: #f6e9c7;
  font-weight: var(--weight-black);
  word-break: normal;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.tarot_category_card_text_box span {
  color: #f6e9c7;
  font-weight: var(--weight-large);
  font-size: 9px;
  line-height: 1.35;
  word-break: normal;
  overflow-wrap: anywhere;
}
.card_select_box .tarotContainer {
  flex-wrap: wrap;
  overflow-x: hidden;
  justify-content: center;
  align-items: flex-start;
  align-content: flex-start;
  padding: 8px 10px 6px;
  gap: 10px;
  height: auto;
  min-height: 170px;
  filter: drop-shadow(0 12px 12px rgba(8, 7, 22, 0.35));
}

.card_select_box .tarotCard {
  margin-left: 0;
  width: 56px;
  height: calc(56px * 1.65);
}
.card_select_box .secondTarot {
  flex: 0 0 auto;
  justify-content: center;
  min-height: 120px;
  padding: 8px 0 2px;
  filter: drop-shadow(0 12px 12px rgba(8, 7, 22, 0.35));
}
.card_select_box .secondCard {
  width: 64px;
  height: calc(64px * 1.62);
}
.card_select_box .cta_button_box {
  margin-top: 2px;
}
.card_select_box button.spreadBtn,
.card_select_box button.resultBtn,
.card_select_box button.nextBtn {
  width: min(100%, 360px);
  min-height: 42px;
  padding: 9px 20px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #9f80e8 0%, #8264ce 100%);
  box-shadow: 0 10px 24px rgba(15, 11, 44, 0.24);
  color: var(--color-white);
  font-size: var(--size-sm);
}
.card_select_box .cta_button_box + .tarot_sub_title {
  width: min(100%, 560px);
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: var(--border-radius-r);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  line-height: 1.5;
}

@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media screen and (max-width: 431px) {
  .homeMain #tarotSection .tarotContainer.main {
    justify-content: flex-start;
  }
  .homeMain #tarotSection .tarotCard {
    margin-left: -44px;
  }
  .homeMain #tarotSection .tarotCard:first-child {
    margin-left: 0 !important;
  }
  .tarotCard {
    margin-left: -51px;
  }
  .frontimg {
    width: 70px;
    height: 120px;
  }
  .tarotResultReading {
    gap: 18px;
    padding: 6px 0 0;
  }
  .tarotResultHeader {
    gap: 8px;
    padding-bottom: 14px;
  }
  .tarotResultHeader .cardName {
    font-size: 20px;
  }
  .tarotResultHeader .cardNameKo {
    font-size: var(--size-sm);
  }
  .tarotResultHeader .cardNameKo::before,
  .tarotResultHeader .cardNameKo::after {
    width: 24px;
  }
  .tarot_box_inner {
    padding: 30px 16px;
  }
  .tarot_theme_select_box .tarot_box_inner {
    gap: 16px;
    padding: 24px 16px;
  }
  .tarot_category_box {
    grid-template-columns: repeat(2, 108px);
    gap: 8px;
    width: 100%;
  }
  .tarot_category_card {
    width: 108px;
  }
  .tarot_category_visual {
    width: 108px;
    border-radius: 10px;
  }
  .category_name {
    font-size: 11px;
  }
  .tarot_category_card_text_box {
    bottom: 14%;
    padding: 0 10px;
    font-size: 9px;
  }
  .tarot_category_card_text_box span {
    font-size: 8px;
  }
  .card_select_box .tarotCard {
    margin-left: 0;
    width: 52px;
    height: calc(52px * 1.65);
  }
  .card_select_box .tarot_box_inner {
    gap: 14px;
    padding: 24px 16px;
  }
  .card_select_box .tarotContainer {
    min-height: 150px;
    padding: 4px 0;
  }
  .card_select_box .secondTarot {
    min-height: 108px;
  }
  .card_select_box .secondCard {
    width: 56px;
    height: calc(56px * 1.62);
  }
  .card_select_box .cta_button_box + .tarot_sub_title {
    padding: 10px 14px;
    border-radius: 12px;
  }
}

@media screen and (max-width: 320px) {
  .tarotSection {
    height: 220px;
    width: 100%;
  }
  .tarotContainer.main {
    justify-content: flex-start;
  }
  .tarotCard {
    width: 62px;
    height: calc(62px * 1.2);
    margin-left: -51px;
    flex-shrink: 0;
  }
  .secondCard {
    width: 62px;
    height: calc(62px * 1.2);
    margin: 0;
    flex-shrink: 0;
  }
  .frontimg {
    width: 60px;
    height: 102px;
  }
  .tarotContainer::-webkit-scrollbar,
  .secondTarot::-webkit-scrollbar {
    display: none;
  }
  .tarot_category_box {
    grid-template-columns: repeat(2, 96px);
    gap: 10px;
  }
  .tarot_category_card {
    width: 96px;
  }
  .tarot_category_visual {
    width: 96px;
  }
  .tarot_title {
    font-size: var(--size-xl);
  }
  .card_select_box .tarotContainer {
    padding: 0;
  }
}
