/* ============================================
   TAROT PAGE - Lunaple EN
   ============================================ */

body.page-tarot {
  padding-top: var(--header-height);
  padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
}

body.page-tarot .bg-cosmos {
  background-image: url('/assets/bg_tarot.png');
  background-size: cover;
  background-position: center center;
  inset: 0;
}

/* Text readability on busy background */
.tarot-header,
.spread-selector,
.tarot-question,
.tarot-draw,
.tarot-loading,
.tarot-result {
  position: relative;
  z-index: 1;
}

.tarot-header::before {
  content: '';
  position: absolute;
  inset: -20px -40px;
  background: radial-gradient(ellipse at center, rgba(244,249,247,0.7) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
}

/* --- Spread Selection --- */
.tarot-header {
  text-align: center;
  padding: var(--space-2xl) var(--space-md) var(--space-lg);
}

.tarot-header h1 {
  margin-bottom: var(--space-sm);
}

.tarot-header p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.spread-selector {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 var(--space-md) var(--space-lg);
}

.spread-btn {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  background: var(--bg-surface-1);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.spread-btn.active {
  background: var(--color-primary-dim);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.spread-btn:hover:not(.active) {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.spread-cost {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--color-secondary);
  margin-left: 4px;
}

/* --- Question Input --- */
.tarot-question {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--space-md) var(--space-lg);
}

.tarot-question input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-surface-1);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.tarot-question input:focus {
  border-color: var(--color-primary);
}

.tarot-question input::placeholder {
  color: var(--text-muted);
}

/* --- Grid Card Selection --- */
.card-grid-pick {
  display: grid !important;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  max-width: 600px !important;
  margin: 0 auto !important;
  padding: var(--space-md) !important;
  min-height: auto !important;
  flex-wrap: nowrap !important;
}

@media (max-width: 480px) {
  .card-grid-pick {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
}

.grid-card {
  aspect-ratio: 1.3;
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  transition: all 0.25s var(--ease-out);
  animation: gridCardAppear 0.3s var(--ease-out) both;
}

@keyframes gridCardAppear {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.grid-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
}

.grid-card-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.grid-card-number {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-family: var(--font-mono);
  font-size: 0.5rem;
  color: rgba(255,255,255,0.3);
}

.grid-card-check {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
  background: rgba(212, 175, 55, 0.4);
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.grid-card:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.3);
  z-index: 2;
}

.grid-card.grid-selected {
  transform: scale(1.05);
  box-shadow: 0 0 16px rgba(212, 175, 55, 0.6), 0 0 32px rgba(184, 169, 212, 0.3);
}

.grid-card.grid-selected .grid-card-check {
  opacity: 1;
}

.grid-card.grid-selected .grid-card-inner img {
  filter: brightness(1.2);
}

/* Sticky pick counter */
.pick-counter {
  position: sticky;
  top: var(--header-height);
  z-index: 10;
  text-align: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-header-scroll);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--color-secondary);
}

@keyframes selectedPulse {
  0%, 100% { box-shadow: 0 0 15px rgba(212,175,55,0.4), 0 0 30px rgba(184,169,212,0.2); }
  50% { box-shadow: 0 0 25px rgba(212,175,55,0.7), 0 0 50px rgba(184,169,212,0.4); }
}

/* Grid card flip animation */
.grid-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
}

.grid-card-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
  pointer-events: none;
  display: block;
}

/* Before flip: only back visible */
.grid-face-front {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.3s, transform 0.3s;
}

.grid-face-front.card-reversed {
  transform: scale(0.9) rotate(180deg);
}

/* Flipping animation */
.grid-card-inner.grid-flipping .grid-face-back {
  animation: gridBackHide 0.8s ease forwards;
}

.grid-card-inner.grid-flipping .grid-face-front {
  animation: gridFrontShow 0.8s ease forwards;
}

.grid-card-inner.grid-flipping .grid-face-front.card-reversed {
  animation: gridFrontShowReversed 0.8s ease forwards;
}

/* After flip: front visible */
.grid-card-inner.grid-flipped .grid-face-back {
  display: none;
}

.grid-card-inner.grid-flipped .grid-face-front {
  opacity: 1;
  transform: scale(1);
  position: relative;
}

.grid-card-inner.grid-flipped .grid-face-front.card-reversed {
  opacity: 1;
  transform: scale(1) rotate(180deg);
  position: relative;
}

@keyframes gridBackHide {
  0% { opacity: 1; transform: scale(1) rotateY(0deg); }
  40% { opacity: 1; transform: scale(1.05) rotateY(90deg); }
  50% { opacity: 0; transform: scale(1.05) rotateY(90deg); }
  100% { opacity: 0; transform: scale(0.9); }
}

@keyframes gridFrontShow {
  0% { opacity: 0; transform: scale(1.05) rotateY(-90deg); }
  50% { opacity: 0; transform: scale(1.05) rotateY(-90deg); }
  60% { opacity: 1; transform: scale(1.05) rotateY(0deg); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes gridFrontShowReversed {
  0% { opacity: 0; transform: scale(1.05) rotateY(-90deg) rotate(180deg); }
  50% { opacity: 0; transform: scale(1.05) rotateY(-90deg) rotate(180deg); }
  60% { opacity: 1; transform: scale(1.05) rotateY(0deg) rotate(180deg); }
  100% { opacity: 1; transform: scale(1) rotate(180deg); }
}

.grid-card.grid-picked {
  pointer-events: none;
  z-index: 5;
}

.grid-card.grid-picked::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-secondary);
  box-shadow: 0 0 12px rgba(212,175,55,0.4);
  pointer-events: none;
}

/* Picked cards display area */
.picked-area {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: var(--space-lg) var(--space-md);
  position: relative;
  z-index: 1;
}

.picked-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: fadeInUp 400ms var(--ease-out) both;
}

.picked-card-pos {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--color-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.picked-card-img {
  width: 120px;
  height: 92px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 12px rgba(212,175,55,0.2);
}

.picked-card-img.card-reversed {
  transform: rotate(180deg);
}

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

.picked-card-name {
  font-size: 0.6875rem;
  color: var(--text-primary);
  text-align: center;
  max-width: 120px;
}

@media (max-width: 480px) {
  .picked-card-img {
    width: 90px;
    height: 69px;
  }
  .picked-card-name { font-size: 0.6rem; max-width: 90px; }
}

/* Pick preview (selected cards shown below grid) */
.pick-preview {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: var(--space-lg) var(--space-md);
  flex-wrap: wrap;
}

.preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: fadeInUp 300ms var(--ease-out) both;
}

.preview-card-back {
  width: 80px;
  height: 62px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 0 12px rgba(212,175,55,0.3);
}

.preview-label {
  font-size: 0.625rem;
  color: var(--color-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Revealed spread cards (face up) */
.spread-card.revealed .spread-card-img {
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: cardRevealAppear 0.5s var(--ease-out) both;
}

.spread-card.revealed .spread-card-img.card-reversed {
  transform: rotate(180deg);
}

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

@keyframes cardRevealAppear {
  from { opacity: 0; transform: scale(0.7) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.spread-card.revealed .spread-card-img.card-reversed {
  animation: cardRevealAppearReversed 0.5s var(--ease-out) both;
}

@keyframes cardRevealAppearReversed {
  from { opacity: 0; transform: scale(0.7) translateY(20px) rotate(180deg); }
  to { opacity: 1; transform: scale(1) translateY(0) rotate(180deg); }
}

/* Spread card image sizes */
.spread-one .spread-card-img {
  width: 280px;
  height: 215px;
}

.spread-three .spread-card-img {
  width: 200px;
  height: 154px;
}

.spread-five .spread-card-img {
  width: 150px;
  height: 115px;
}

.spread-celtic .spread-card-img {
  width: 110px;
  height: 85px;
}

@media (max-width: 480px) {
  .spread-one .spread-card-img { width: 240px; height: 185px; }
  .spread-three .spread-card-img { width: 140px; height: 108px; }
  .spread-five .spread-card-img { width: 110px; height: 85px; }
  .spread-celtic .spread-card-img { width: 80px; height: 62px; }
}

/* --- Card Table --- */
.card-table {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 var(--space-md);
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  perspective: 1000px;
}

/* --- Spread Layouts --- */
.spread-layout {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
  padding: var(--space-xl) var(--space-md) !important;
  min-height: 60vh !important;
  align-content: center;
}

.spread-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: auto !important;
  height: auto !important;
}

.spread-position-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--color-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.spread-card-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  animation: fadeInUp 300ms var(--ease-out);
  max-width: 160px;
}

.tarot-card-inner {
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.tarot-card-inner .tarot-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.tarot-card-inner .tarot-card-front {
  transform: rotateY(180deg);
}

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

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

.tarot-card-inner.flipping {
  animation: cardFlipSpin 1.2s cubic-bezier(0.2, 0, 0.1, 1);
}

/* One Card: large center */
.spread-one .tarot-card-inner {
  width: 280px;
  height: 215px;
}

/* Three Cards: row */
.spread-three {
  gap: 20px;
}
.spread-three .tarot-card-inner {
  width: 200px;
  height: 154px;
}

/* Five Cards: 3 top + 2 bottom */
.spread-five {
  max-width: 500px;
}
.spread-five .tarot-card-inner {
  width: 150px;
  height: 115px;
}

/* Celtic Cross: special layout */
.spread-celtic {
  max-width: 600px;
  gap: 10px;
}
.spread-celtic .tarot-card-inner {
  width: 110px;
  height: 85px;
}

/* Glow effects on spread cards */
.spread-card::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: var(--radius-md);
  opacity: 0;
  background: conic-gradient(from 0deg, #D4AF37, #B8A9D4, #C4788E, #7EC8C8, #D4AF37);
  filter: blur(12px);
  transition: opacity 0.3s;
  z-index: -1;
  pointer-events: none;
}

.spread-card:not(.flipped):hover::after {
  opacity: 0.4;
}

.spread-card.flipping::after {
  opacity: 1;
  animation: particleGlow 1.2s cubic-bezier(0.2, 0, 0.1, 1);
}

.spread-card.revealing::before {
  content: '';
  position: absolute;
  inset: -60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212,175,55,0.8) 0%, rgba(184,169,212,0.4) 30%, transparent 70%);
  z-index: 10;
  animation: lightBurst 0.6s ease-out forwards;
  pointer-events: none;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .spread-one .tarot-card-inner {
    width: 240px;
    height: 185px;
  }
  .spread-three .tarot-card-inner {
    width: 140px;
    height: 108px;
  }
  .spread-five .tarot-card-inner {
    width: 120px;
    height: 92px;
  }
  .spread-celtic .tarot-card-inner {
    width: 85px;
    height: 65px;
  }
  .spread-celtic .spread-position-label {
    font-size: 0.5rem;
  }
}

/* --- Tarot Card --- */
.tarot-card {
  width: 280px;
  height: 215px;
  position: relative;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.tarot-card::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: var(--radius-md);
  opacity: 0;
  background: conic-gradient(from 0deg, #D4AF37, #B8A9D4, #C4788E, #7EC8C8, #D4AF37);
  filter: blur(12px);
  transition: opacity 0.3s;
  z-index: -1;
}

.tarot-card:hover::after {
  opacity: 0.4;
}

.tarot-card.flipping {
  animation: cardFlipSpin 1.2s cubic-bezier(0.2, 0, 0.1, 1);
}

.tarot-card.flipping::after {
  opacity: 1;
  animation: particleGlow 1.2s cubic-bezier(0.2, 0, 0.1, 1);
}

/* Light burst on reveal */
.tarot-card.revealing::before {
  content: '';
  position: absolute;
  inset: -60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212,175,55,0.8) 0%, rgba(184,169,212,0.4) 30%, transparent 70%);
  z-index: 10;
  animation: lightBurst 0.6s ease-out forwards;
  pointer-events: none;
}

.tarot-card.flipped {
  transform: rotateY(180deg);
}

.tarot-card.reversed.flipped {
  transform: rotateY(180deg) rotate(180deg);
}

/* Fast start → slow stop spin */
@keyframes cardFlipSpin {
  0% { transform: rotateY(0deg) scale(1); }
  15% { transform: rotateY(120deg) scale(1.08); }
  30% { transform: rotateY(300deg) scale(1.1); }
  50% { transform: rotateY(480deg) scale(1.06); }
  70% { transform: rotateY(600deg) scale(1.03); }
  85% { transform: rotateY(680deg) scale(1.01); }
  100% { transform: rotateY(720deg) scale(1); }
}

/* Particles spinning with card, exploding outward */
@keyframes particleGlow {
  0% {
    opacity: 0.4;
    inset: -8px;
    filter: blur(8px);
    background: conic-gradient(from 0deg, #D4AF37, transparent, #B8A9D4, transparent, #C4788E, transparent, #7EC8C8, transparent, #D4AF37);
  }
  20% {
    opacity: 1;
    inset: -15px;
    filter: blur(12px);
    background: conic-gradient(from 240deg, #D4AF37, transparent, #B8A9D4, transparent, #C4788E, transparent, #7EC8C8, transparent, #D4AF37);
  }
  40% {
    opacity: 0.9;
    inset: -25px;
    filter: blur(18px);
    background: conic-gradient(from 600deg, #D4AF37, transparent, #B8A9D4, transparent, #C4788E, transparent, #7EC8C8, transparent, #D4AF37);
  }
  60% {
    opacity: 0.7;
    inset: -35px;
    filter: blur(24px);
    background: conic-gradient(from 960deg, #D4AF37, transparent, #B8A9D4, transparent, #C4788E, transparent, #7EC8C8, transparent, #D4AF37);
  }
  80% {
    opacity: 0.5;
    inset: -20px;
    filter: blur(16px);
    background: conic-gradient(from 1200deg, #D4AF37, transparent, #B8A9D4, transparent, #C4788E, transparent, #7EC8C8, transparent, #D4AF37);
  }
  100% {
    opacity: 0;
    inset: -8px;
    filter: blur(8px);
  }
}

/* Light explosion when card face appears */
@keyframes lightBurst {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  30% {
    opacity: 1;
    transform: scale(1.2);
  }
  60% {
    opacity: 0.6;
    transform: scale(1.5);
  }
  100% {
    opacity: 0;
    transform: scale(2);
  }
}

.tarot-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.tarot-card-back {
  background: #E5EFEB;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

.tarot-card-back-pattern {
  width: 80%;
  height: 80%;
  border: 1px solid var(--color-secondary);
  border-radius: var(--radius-sm);
  opacity: 0.4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--color-secondary);
}

/* removed - defined below */

.tarot-card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.tarot-card-front {
  transform: rotateY(180deg);
  background: transparent;
  border: none;
}

.tarot-card-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px;
  background: rgba(244, 249, 247, 0.9);
  font-size: 0.5625rem;
  text-align: center;
  color: var(--text-primary);
  font-weight: 500;
}

/* Card hover (before flipping) */
.tarot-card:not(.flipped):hover {
  transform: translateY(-8px) scale(1.02);
}

/* --- Draw Button --- */
.tarot-draw {
  text-align: center;
  padding: var(--space-lg) var(--space-md);
}

/* --- Reading Result --- */
.tarot-result {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) var(--space-3xl);
  display: none;
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-lg);
}

.tarot-result.visible {
  display: block;
  animation: fadeInUp 400ms var(--ease-out);
}

.result-card {
  margin-bottom: var(--space-lg);
}

.result-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.result-card-img {
  width: 140px;
  height: 108px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-glass);
  flex-shrink: 0;
}

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

.result-card-img.card-reversed {
  transform: rotate(180deg);
}

.result-card-info h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
}

.result-card-position {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.result-card-keywords {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.keyword {
  font-size: 0.6875rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--color-secondary-dim);
  color: var(--color-secondary);
}

.result-interpretation {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* Summary */
.result-summary {
  margin-top: var(--space-xl);
  text-align: center;
}

.result-fortune {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.fortune-score {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-secondary);
}

.fortune-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ============================================
   MODE MESSAGE
   ============================================ */
.mode-message {
  text-align: center;
  padding: 0 var(--space-lg);
  margin-bottom: var(--space-sm);
}

.mode-message p {
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.6;
  font-style: italic;
  max-width: 400px;
  margin: 0 auto;
  font-weight: 500;
}

/* ============================================
   MODE SELECTOR
   ============================================ */
.mode-selector {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  background: var(--bg-surface-1);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  font-family: var(--font-body);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mode-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.mode-btn.active {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-dim);
  box-shadow: var(--shadow-glow);
}

.mode-btn svg {
  opacity: 0.7;
}

.mode-btn.active svg {
  opacity: 1;
}

/* ============================================
   MODE 2: FAN SWIPE
   ============================================ */
.card-fan-pick {
  padding: var(--space-lg) 0;
}

.fan-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  height: 220px;
  overflow: hidden;
}

.fan-container {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fan-card {
  position: absolute;
  width: 168px;
  height: 120px;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.4s var(--ease-out), opacity 0.3s;
  transform-origin: center bottom;
  box-shadow: var(--shadow-md);
}

.fan-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.fan-card.fan-center {
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.fan-card.fan-center::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-md);
  opacity: 0.5;
  pointer-events: none;
}

.fan-card.fan-picked {
  pointer-events: none;
}

.fan-card.fan-flipping {
  perspective: 600px;
}

.fan-flip-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s var(--ease-out);
}

.fan-card.fan-flipped .fan-flip-inner {
  transform: rotateY(180deg);
}

.fan-flip-back,
.fan-flip-front {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.fan-flip-back img,
.fan-flip-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fan-flip-front {
  transform: rotateY(180deg);
}

.fan-nav {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-glass);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
  z-index: 20;
}

.fan-nav:hover {
  background: var(--color-primary-dim);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.fan-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: var(--space-sm) 0;
}

/* ============================================
   MODE 3: DECK CUT
   ============================================ */
.card-deck-pick {
  padding: var(--space-xl) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xl);
}

.deck-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

.deck-stack {
  position: relative;
  width: 200px;
  height: 143px;
  cursor: pointer;
}

.deck-shadow-card {
  position: absolute;
  inset: 0;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.deck-top-card {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: transform 0.4s var(--ease-spring), opacity 0.3s;
  cursor: pointer;
}

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

.deck-top-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.deck-top-card.deck-drawing {
  transform: translateY(-60px) scale(0.9) rotateX(15deg);
  opacity: 0;
}

.deck-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-align: center;
  cursor: pointer;
}

.deck-reveal-area {
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.deck-revealed-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  animation: fadeInUp 0.5s var(--ease-out) both;
}

.deck-revealed-card .deck-flip-inner {
  width: 240px;
  height: 171px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg), var(--shadow-glow-gold);
  border: 2px solid var(--color-secondary);
}

.deck-revealed-card .deck-flip-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.deck-card-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text-primary);
  text-align: center;
}

/* ============================================
   MODE 4: FLOATING CARDS
   ============================================ */
.card-float-pick {
  position: relative;
  min-height: 500px;
  overflow: hidden;
}

.float-card {
  position: absolute;
  width: 112px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  animation: floatDrift linear infinite;
  transition: all 0.5s var(--ease-out);
}

.float-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.float-card:hover {
  transform: scale(1.2) !important;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  z-index: 50 !important;
}

@keyframes floatDrift {
  0% { transform: translateY(0) rotate(var(--rot, 0deg)); }
  25% { transform: translateY(-15px) rotate(calc(var(--rot, 0deg) + 3deg)); }
  50% { transform: translateY(-5px) rotate(var(--rot, 0deg)); }
  75% { transform: translateY(-20px) rotate(calc(var(--rot, 0deg) - 2deg)); }
  100% { transform: translateY(0) rotate(var(--rot, 0deg)); }
}

.float-card.float-picked {
  pointer-events: none;
}

.float-card.float-selecting {
  animation: none !important;
  position: absolute;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) scale(1.8) !important;
  z-index: 100 !important;
  box-shadow: var(--shadow-lg), 0 0 40px rgba(91, 168, 168, 0.3);
  transition: all 0.5s var(--ease-spring);
}

.float-card.float-revealed {
  border: 2px solid var(--color-secondary);
}

.float-card.float-done {
  transform: translate(-50%, -50%) scale(0.8) !important;
  opacity: 0.6;
  z-index: 5 !important;
}

.float-flip-inner {
  width: 100%;
  height: 100%;
}

.float-flip-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 480px) {
  .fan-card {
    width: 140px;
    height: 100px;
  }
  .fan-wrapper {
    height: 180px;
  }
  .deck-stack {
    width: 168px;
    height: 120px;
  }
  .deck-revealed-card .deck-flip-inner {
    width: 200px;
    height: 143px;
  }
  .float-card {
    width: 91px;
    height: 65px;
  }
}

.result-summary-text {
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: var(--space-lg);
}

.result-advice {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-style: italic;
  color: var(--color-primary);
  line-height: 1.6;
}

/* --- Loading Overlay --- */
.tarot-loading {
  display: none;
  text-align: center;
  padding: var(--space-2xl);
}

.tarot-loading.visible {
  display: block;
}

.loading-orb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--gradient-cta);
  margin: 0 auto var(--space-md);
  animation: pulse 1.5s ease-in-out infinite;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

/* --- Share Button --- */
.result-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  padding: var(--space-lg) 0;
}

/* Responsive: smaller cards on mobile */
@media (max-width: 480px) {
  .tarot-card {
    width: 220px;
    height: 169px;
  }
}

/* 10-card spread: smaller cards */
.card-table.celtic .tarot-card {
  width: 160px;
  height: 123px;
}
