@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Lato:wght@300;400;700&display=swap');

/* ─── CSS Variables ─────────────────────────────────────── */
:root {
  --bg-deep: #0a0612;
  --bg-mid: #110d1e;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.08);
  --border-glow: rgba(168,85,247,0.4);
  --purple: #a855f7;
  --purple-light: #c084fc;
  --purple-dark: #7c3aed;
  --gold: #f59e0b;
  --gold-light: #fcd34d;
  --text-primary: #f3e8ff;
  --text-secondary: #c4b5fd;
  --text-muted: #7c6a9e;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-glow: 0 0 30px rgba(168,85,247,0.2);
  --shadow-card: 0 8px 32px rgba(0,0,0,0.4);
  --transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* ─── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Lato', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ─── Animated Background ───────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(120,40,200,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(30,15,80,0.3) 0%, transparent 60%),
    radial-gradient(ellipse 100% 100% at 50% 50%, rgba(10,6,18,1) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Stars Background ──────────────────────────────────── */
#stars-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
}

/* ─── Layout ────────────────────────────────────────────── */
.container {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ─── Header ────────────────────────────────────────────── */
header {
  text-align: center;
  padding: 60px 24px 40px;
  position: relative;
  z-index: 1;
}

.site-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold-light), var(--purple-light), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 20px rgba(168,85,247,0.4));
}

.site-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0.8;
}

/* ─── Status Bar ────────────────────────────────────────── */
#status-bar {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 40px;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  backdrop-filter: blur(10px);
  transition: var(--transition);
}

.status-pill.warning { border-color: rgba(245,158,11,0.3); color: var(--gold); }
.status-pill.success { border-color: rgba(16,185,129,0.3); color: var(--success); }
.status-pill.danger  { border-color: rgba(239,68,68,0.3); color: var(--error); }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-dot 2s infinite;
}
.status-dot.warning { background: var(--warning); }
.status-dot.danger  { background: var(--error); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ─── Ban Overlay ───────────────────────────────────────── */
#ban-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

#ban-overlay.active { display: flex; }

.ban-card {
  background: linear-gradient(135deg, rgba(239,68,68,0.1), rgba(20,10,30,0.9));
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  padding: 48px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: 0 0 60px rgba(239,68,68,0.2);
}

.ban-icon { font-size: 4rem; margin-bottom: 16px; }
.ban-title {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  color: var(--error);
  margin-bottom: 12px;
}
.ban-reason { color: var(--text-secondary); margin-bottom: 16px; }
.ban-timer {
  font-size: 1.1rem;
  color: var(--gold);
  font-weight: 700;
  padding: 12px 24px;
  background: rgba(245,158,11,0.1);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(245,158,11,0.2);
}

/* ─── Section ───────────────────────────────────────────── */
.section {
  position: relative;
  z-index: 1;
  margin-bottom: 48px;
}

.section-title {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  color: var(--text-secondary);
  text-align: center;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.section-title::before, .section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-glow), transparent);
}

/* ─── Step Indicator ─────────────────────────────────────── */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 48px;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
}

.step-num {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-mid);
  transition: var(--transition);
}

.step.active .step-num {
  border-color: var(--purple);
  color: var(--purple-light);
  background: rgba(168,85,247,0.1);
  box-shadow: 0 0 16px rgba(168,85,247,0.3);
}

.step.done .step-num {
  border-color: var(--success);
  background: rgba(16,185,129,0.15);
  color: var(--success);
}

.step-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
  white-space: nowrap;
}

.step.active .step-label { color: var(--text-secondary); }

.step-line {
  width: 60px; height: 2px;
  background: var(--border);
  margin-bottom: 20px;
  transition: var(--transition);
}
.step-line.done { background: linear-gradient(90deg, var(--success), var(--purple)); }

/* ─── Question Form ─────────────────────────────────────── */
#question-section {
  padding: 0 24px;
  margin-bottom: 48px;
}

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.question-card:focus-within {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-card), 0 0 20px rgba(168,85,247,0.1);
}

.question-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}

#question-input {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--text-primary);
  font-family: 'Lato', sans-serif;
  font-size: 1rem;
  resize: vertical;
  min-height: 90px;
  max-height: 200px;
  transition: var(--transition);
  outline: none;
}

#question-input::placeholder { color: var(--text-muted); }
#question-input:focus {
  border-color: rgba(168,85,247,0.5);
  background: rgba(255,255,255,0.05);
}

.question-hint {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.char-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: var(--transition);
}

.char-count.warning { color: var(--warning); }
.char-count.danger  { color: var(--error); }

/* ─── Card Selection Area ───────────────────────────────── */
#card-section {
  padding: 0 24px;
  margin-bottom: 48px;
}

.card-instruction {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
  opacity: 0.8;
}

.card-counter {
  text-align: center;
  margin-bottom: 20px;
}

.card-counter-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: rgba(168,85,247,0.1);
  border: 1px solid var(--border-glow);
  border-radius: 100px;
  font-size: 0.85rem;
  color: var(--purple-light);
}

/* Fan / Deck Area */
#deck-container {
  position: relative;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  margin-bottom: 32px;
}

.deck-shuffle-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 20px 32px;
  background: linear-gradient(135deg, rgba(168,85,247,0.2), rgba(124,58,237,0.1));
  border: 1px solid var(--border-glow);
  border-radius: var(--radius);
  color: var(--purple-light);
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  letter-spacing: 0.05em;
  transition: var(--transition);
  backdrop-filter: blur(10px);
}

.deck-shuffle-btn:hover {
  background: linear-gradient(135deg, rgba(168,85,247,0.35), rgba(124,58,237,0.2));
  box-shadow: 0 0 30px rgba(168,85,247,0.3);
  transform: translate(-50%, -50%) scale(1.03);
}

.deck-shuffle-btn .shuffle-icon {
  font-size: 2.5rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Fan Cards */
#fan-container {
  position: relative;
  width: 100%;
  height: 280px;
  display: none;
}

.fan-card {
  position: absolute;
  width: 75px;
  height: 120px;
  border-radius: 10px;
  cursor: pointer;
  transform-origin: bottom center;
  background: linear-gradient(135deg, rgba(26,15,51,0.8), rgba(45,27,94,0.8));
  border: 1px solid rgba(168,85,247,0.4);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), box-shadow 0.3s ease, border-color 0.3s ease;
  will-change: transform;
  top: 50%;
  left: 50%;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5), inset 0 0 10px rgba(168,85,247,0.1);
}

.fan-card::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 5px;
  background: linear-gradient(135deg,
    rgba(168,85,247,0.08),
    rgba(30,20,60,0.5)
  );
}

.fan-card .card-back-pattern {
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(45deg, rgba(168,85,247,0.06) 0px, rgba(168,85,247,0.06) 1px, transparent 1px, transparent 8px),
    repeating-linear-gradient(-45deg, rgba(168,85,247,0.06) 0px, rgba(168,85,247,0.06) 1px, transparent 1px, transparent 8px);
  border-radius: 7px;
}

.fan-card:hover:not(.selected):not(.disabled) {
  transform: var(--fan-transform) translateY(-25px) scale(1.05) !important;
  box-shadow: 0 15px 35px rgba(168,85,247,0.5), 0 0 20px rgba(168,85,247,0.3);
  border-color: var(--purple-light);
  z-index: 100 !important;
}

.fan-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(245,158,11,0.5);
  animation: selected-pulse 1.5s ease-in-out infinite;
}

@keyframes selected-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(245,158,11,0.4); }
  50% { box-shadow: 0 0 35px rgba(245,158,11,0.7); }
}

.fan-card.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ─── Selected Cards Display ─────────────────────────────── */
#selected-display {
  display: none;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 24px;
}

.selected-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 120px;
}

.selected-slot-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.tarot-card {
  width: 130px;
  height: 200px;
  border-radius: 12px;
  perspective: 1200px;
  cursor: default;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tarot-card:hover {
  transform: translateY(-10px) scale(1.05);
  box-shadow: 0 15px 40px rgba(168,85,247,0.3);
}

.tarot-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.4,0,0.2,1);
}

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

.tarot-card-front, .tarot-card-back {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.tarot-card-back {
  background: linear-gradient(135deg, rgba(26,15,51,0.9), rgba(45,27,94,0.9));
  border: 1px solid rgba(168,85,247,0.4);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  box-shadow: inset 0 0 15px rgba(168,85,247,0.2);
}

.tarot-card-front {
  background: linear-gradient(160deg, rgba(30,16,64,0.95), rgba(15,8,32,0.95));
  border: 1px solid rgba(168,85,247,0.5);
  backdrop-filter: blur(10px);
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  gap: 8px;
  box-shadow: 0 0 25px rgba(168,85,247,0.3), inset 0 0 15px rgba(168,85,247,0.1);
}

.card-front-symbol { font-size: 2.2rem; }
.card-front-name {
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  color: var(--gold-light);
  text-align: center;
  letter-spacing: 0.05em;
  line-height: 1.3;
}
.card-front-keyword {
  font-size: 0.55rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}

.card-reversed-badge {
  font-size: 0.5rem;
  color: var(--error);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: rgba(239,68,68,0.1);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(239,68,68,0.3);
}

/* ─── CTA Button ─────────────────────────────────────────── */
.cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 32px;
  margin-top: 24px;
  background: linear-gradient(135deg, var(--purple-dark), var(--purple));
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.cta-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: var(--transition);
}

.cta-btn:hover:not(:disabled)::before { opacity: 1; }

.cta-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(124,58,237,0.5);
}

.cta-btn:active:not(:disabled) { transform: translateY(0); }

.cta-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.cta-btn.loading {
  pointer-events: none;
}

/* ─── Reading Result ─────────────────────────────────────── */
#result-section {
  padding: 0 24px;
  margin-bottom: 60px;
  display: none;
}

.result-card {
  background: linear-gradient(135deg, rgba(168,85,247,0.05), rgba(15,8,32,0.8));
  border: 1px solid rgba(168,85,247,0.2);
  border-radius: var(--radius);
  padding: 36px;
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
  position: relative;
  overflow: hidden;
}

.result-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--purple-light), transparent);
}

.result-api-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.7rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.result-title {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  color: var(--gold-light);
  margin-bottom: 20px;
  text-align: center;
}

.result-cards-row {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.result-text {
  color: var(--text-primary);
  line-height: 1.9;
  font-size: 1rem;
  white-space: pre-wrap;
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background: var(--purple-light);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.7s step-end infinite;
}

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

/* ─── Particles ─────────────────────────────────────────── */
.particle {
  position: fixed;
  pointer-events: none;
  z-index: 999;
  border-radius: 50%;
  animation: particle-rise 2s ease-out forwards;
}

@keyframes particle-rise {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-120px) scale(0); opacity: 0; }
}

/* ─── Loading Spinner ───────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Reset Button ──────────────────────────────────────── */
#reset-btn {
  display: none;
  margin: 0 auto 60px;
  padding: 12px 32px;
  background: transparent;
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-sm);
  color: var(--purple-light);
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.05em;
  position: relative;
  z-index: 1;
}

#reset-btn:hover {
  background: rgba(168,85,247,0.1);
  box-shadow: 0 0 20px rgba(168,85,247,0.2);
}

/* ─── Toast Notifications ───────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  animation: toast-in 0.3s ease;
  max-width: 320px;
  pointer-events: all;
}

.toast.success {
  background: rgba(16,185,129,0.15);
  border-color: rgba(16,185,129,0.3);
  color: #6ee7b7;
}

.toast.error {
  background: rgba(239,68,68,0.15);
  border-color: rgba(239,68,68,0.3);
  color: #fca5a5;
}

.toast.warning {
  background: rgba(245,158,11,0.15);
  border-color: rgba(245,158,11,0.3);
  color: var(--gold-light);
}

@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: rgba(168,85,247,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(168,85,247,0.5); }

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 600px) {
  header { padding: 40px 16px 28px; }
  .question-card { padding: 20px; }
  .result-card { padding: 24px; }
  .fan-card { width: 55px; height: 88px; }
  .step-line { width: 36px; }
}
