.tarot-view {
  min-height: calc(100vh - 74px);
  padding-bottom: 108px;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 206, 119, 0.34), transparent 28%),
    linear-gradient(180deg, #26314b 0 180px, #fffaf0 180px);
}

.tarot-title {
  color: #fff;
  background: transparent;
}

.tarot-title button {
  color: #fff;
}

.tarot-title p {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.74);
  font-size: 12px;
  font-weight: 750;
}

.tarot-stage {
  padding: 18px 16px 40px;
}

.tarot-intro,
.tarot-result-head,
.tarot-loading,
.tarot-error {
  padding: 22px 18px;
  border: 1px solid rgba(103, 77, 42, 0.14);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 34px rgba(38, 31, 24, 0.1);
  text-align: center;
}

.tarot-intro span,
.tarot-result-head span,
.tarot-advice span {
  color: #d24a8d;
  font-size: 12px;
  font-weight: 900;
}

.tarot-intro h2,
.tarot-result-head h2 {
  margin: 7px 0 9px;
  color: #243145;
  font-size: 22px;
  line-height: 1.3;
  word-break: keep-all;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.tarot-intro p,
.tarot-result-head p,
.tarot-loading p,
.tarot-error p,
.tarot-result-card p {
  margin: 0;
  color: #69675f;
  font-size: 13px;
  line-height: 1.65;
}

.tarot-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 2px 12px;
  color: #5c554d;
  font-size: 11px;
}

.tarot-selection-bar b {
  color: #243145;
  font-size: 15px;
}

.tarot-picked {
  display: grid;
  grid-template-columns: repeat(3, 68px);
  justify-content: center;
  gap: 14px;
  margin: 0 auto 14px;
}

.tarot-picked-slot {
  position: relative;
  aspect-ratio: 0.67;
  padding: 0;
  overflow: hidden;
  border: 1px dashed rgba(73, 85, 123, 0.32);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.58);
  color: #8a857d;
}

.tarot-picked-slot.is-filled {
  border: 2px solid #ffcf59;
  background: #49557b;
  box-shadow: 0 7px 16px rgba(37, 35, 54, 0.2);
  animation: tarot-slot-in 280ms cubic-bezier(.23, 1, .32, 1);
}

.tarot-picked-slot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tarot-deck-scene {
  position: relative;
  height: 250px;
  overflow: hidden;
  border: 1px solid rgba(103, 77, 42, 0.12);
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 68%, rgba(255, 207, 89, 0.24), transparent 38%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(249, 242, 229, 0.84));
}

.tarot-shuffle {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #39445e;
  font-size: 13px;
  opacity: 1;
  transition: opacity 420ms ease-in;
}

.tarot-deck-scene.is-spreading .tarot-shuffle {
  opacity: 0;
}

.tarot-shuffle[hidden],
.tarot-deck-window[hidden],
.tarot-deck-guide button[hidden] {
  display: none;
}

.tarot-stack {
  position: relative;
  display: block;
  width: 78px;
  height: 118px;
}

.tarot-stack img {
  position: absolute;
  inset: 0;
  display: block;
  width: 78px;
  height: 118px;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(37, 35, 54, 0.22);
  transition: transform 320ms cubic-bezier(.645, .045, .355, 1);
}

.tarot-stack img:nth-child(1) { transform: translate(-5px, 4px) rotate(-4deg); }
.tarot-stack img:nth-child(2) { transform: translate(5px, 2px) rotate(3deg); }
.tarot-stack img:nth-child(3) { transform: translate(0, -2px); }

.tarot-deck-scene.is-shuffling .tarot-stack img:nth-child(1) { animation: tarot-shuffle-left 1480ms cubic-bezier(.45, 0, .2, 1); }
.tarot-deck-scene.is-shuffling .tarot-stack img:nth-child(2) { animation: tarot-shuffle-right 1480ms cubic-bezier(.45, 0, .2, 1); }
.tarot-deck-scene.is-shuffling .tarot-stack img:nth-child(3) { animation: tarot-shuffle-center 1480ms cubic-bezier(.45, 0, .2, 1); }

.tarot-deck-window {
  position: absolute;
  inset: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  touch-action: pan-x;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 420ms ease-out, transform 520ms cubic-bezier(.23, 1, .32, 1);
}

.tarot-deck-window::-webkit-scrollbar {
  display: none;
}

.tarot-deck-window.is-visible {
  opacity: 1;
  transform: scale(1);
}

.tarot-deck-window.is-visible .tarot-card-back {
  animation: tarot-spread-in 560ms cubic-bezier(.23, 1, .32, 1) both;
  animation-delay: calc(var(--deal-index) * 9ms);
}

.tarot-deck {
  display: flex;
  align-items: flex-end;
  width: max-content;
  min-width: 100%;
  height: 100%;
  padding: 30px 150px 34px;
}

.tarot-card-back {
  position: relative;
  flex: 0 0 72px;
  aspect-ratio: 0.67;
  margin-left: -49px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #49557b;
  box-shadow: 0 4px 9px rgba(37, 35, 54, 0.16);
  transform: translateY(var(--lift)) rotate(var(--tilt));
  transition: transform 220ms cubic-bezier(.23, 1, .32, 1), border-color 160ms ease, box-shadow 160ms ease;
}

.tarot-card-back:first-child {
  margin-left: 0;
}

.tarot-card-back img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tarot-card-back.is-selected {
  z-index: 100;
  border-color: #ffcf59;
  box-shadow: 0 0 0 3px rgba(255, 207, 89, 0.3), 0 8px 16px rgba(37, 35, 54, 0.2);
  transform: translateY(-28px) rotate(0) scale(1.08);
}

.tarot-card-back.is-picking {
  transform: translateY(-38px) rotate(0) scale(1.12);
}

.tarot-card-back:focus-visible {
  z-index: 101;
  outline: 3px solid #d24a8d;
  outline-offset: 3px;
}

.tarot-deck-guide {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 8px 4px 0;
  color: #777168;
  font-size: 11px;
}

.tarot-deck-guide button {
  padding: 6px 10px;
  border: 1px solid rgba(73, 85, 123, 0.2);
  border-radius: 999px;
  background: #fff;
  color: #46516d;
  font-size: 11px;
  font-weight: 850;
}

.tarot-confirm-wrap {
  position: sticky;
  bottom: 78px;
  z-index: 4;
  padding: 18px 0 4px;
  background: linear-gradient(180deg, transparent, #fffaf0 28%);
}

.tarot-confirm-wrap button:disabled {
  opacity: 0.48;
}

.tarot-loading,
.tarot-error {
  margin-top: 40px;
}

.tarot-loading-card {
  display: block;
  width: 68px;
  aspect-ratio: 0.67;
  margin: 0 auto 18px;
  border-radius: 9px;
  background: url("/assets/tarot/cards/back.webp") center / cover;
  box-shadow: 0 9px 22px rgba(47, 48, 79, 0.24);
  animation: tarot-breathe 1.4s ease-in-out infinite;
}

.tarot-result-cards {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.tarot-result-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  column-gap: 16px;
  padding: 16px;
  border: 1px solid rgba(103, 77, 42, 0.14);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 9px 24px rgba(38, 31, 24, 0.07);
}

.tarot-card-face {
  grid-row: 1 / span 4;
  align-self: start;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 7px 18px rgba(37, 35, 54, 0.18);
}

.tarot-card-face img {
  display: block;
  width: 100%;
  height: auto;
}

.tarot-result-card small {
  color: #d24a8d;
  font-size: 11px;
  font-weight: 900;
}

.tarot-result-card h3 {
  margin: 4px 0 8px;
  color: #243145;
  font-size: 17px;
  line-height: 1.35;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.tarot-result-card p + p {
  margin-top: 8px;
}

.tarot-advice {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, #fff0b9, #ffe5f1);
}

.tarot-advice p {
  margin: 7px 0 0;
  color: #3e3940;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.55;
}

.tarot-disclaimer {
  margin: 16px 4px 0;
  color: #817b72;
  font-size: 11px;
  line-height: 1.55;
  text-align: center;
}

@keyframes tarot-breathe {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-7px) rotate(2deg); }
}

@keyframes tarot-slot-in {
  from { opacity: 0; transform: translateY(10px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes tarot-shuffle-left {
  0%, 100% { transform: translate(-5px, 4px) rotate(-4deg); }
  18% { transform: translate(-48px, 11px) rotate(-16deg); }
  40% { transform: translate(22px, -5px) rotate(8deg); }
  60% { transform: translate(-38px, 8px) rotate(-12deg); }
  80% { transform: translate(18px, -3px) rotate(6deg); }
}

@keyframes tarot-shuffle-right {
  0%, 100% { transform: translate(5px, 2px) rotate(3deg); }
  18% { transform: translate(46px, 9px) rotate(15deg); }
  40% { transform: translate(-23px, -6px) rotate(-8deg); }
  60% { transform: translate(37px, 7px) rotate(12deg); }
  80% { transform: translate(-17px, -4px) rotate(-6deg); }
}

@keyframes tarot-shuffle-center {
  0%, 100% { transform: translate(0, -2px); }
  24% { transform: translateY(-17px) rotate(2deg); }
  50% { transform: translateY(5px) rotate(-2deg); }
  76% { transform: translateY(-13px) rotate(1deg); }
}

@keyframes tarot-spread-in {
  from { opacity: 0; translate: 0 20px; scale: 0.94; }
  60% { opacity: 1; }
  to { opacity: 1; translate: 0 0; scale: 1; }
}

@media (max-width: 390px) {
  .tarot-picked { grid-template-columns: repeat(3, 62px); gap: 12px; }
  .tarot-deck { padding-inline: 130px; }
  .tarot-card-back { flex-basis: 68px; margin-left: -47px; }
  .tarot-result-card { grid-template-columns: 92px minmax(0, 1fr); column-gap: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .tarot-loading-card { animation: none; }
  .tarot-card-back,
  .tarot-stack img,
  .tarot-deck-window,
  .tarot-shuffle { transition: none; }
  .tarot-deck-scene.is-shuffling .tarot-stack img { animation: none; }
  .tarot-deck-window.is-visible .tarot-card-back { animation: none; }
  .tarot-picked-slot.is-filled { animation: none; }
}

.tarot-loading {
  min-height: min(590px, calc(100svh - 170px));
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 0;
  padding: 4px 0 0;
  border: 0;
  background: #fff;
  box-shadow: none;
}

.tarot-loading .fortune-loading-scene {
  flex: 0 0 auto;
}

.tarot-loading .fortune-loading-dots {
  margin-top: 36px;
}

.tarot-loading .fortune-loading-message {
  min-height: 112px;
  margin-top: 24px;
}

.tarot-loading .fortune-loading-message h2 {
  margin: 0;
  color: #243145;
  font-size: 20px;
  line-height: 1.4;
  word-break: keep-all;
}

.tarot-loading .fortune-loading-message p {
  max-width: 310px;
  margin: 10px auto 0;
}

.tarot-loading .fortune-loading-footer {
  margin-top: auto;
}

.tarot-error {
  border: 0;
  background: var(--coral-soft);
  box-shadow: none;
}

.tarot-loading .app-state-symbol,
.tarot-error .app-state-symbol {
  margin-bottom: 10px;
}
