body {
  font-family: "Sarabun", sans-serif;
  background: radial-gradient(circle at center, #0f172a 0%, #020617 100%);
  background-attachment: fixed;
  color: #f8fafc;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-tap-highlight-color: transparent;
}

.tarot-font {
  font-family: "Sarabun", sans-serif;
  font-weight: 700;
}

#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  padding-bottom: 380px;
}

@media (min-width: 768px) {
  #app-container {
    padding-bottom: 520px;
  }
}

/* --- SPREAD POSITIONS --- */
.spread-layout {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  transition: all 0.4s ease;
}

.spread-1 {
  min-height: 380px;
}
.spread-3 {
  min-height: 380px;
}
.spread-5 {
  min-height: 700px;
}
.spread-10 {
  min-height: 850px;
}

@media (min-width: 768px) {
  .spread-1 {
    min-height: 500px;
  }
  .spread-3 {
    min-height: 500px;
  }
  .spread-5 {
    min-height: 950px;
  }
  .spread-10 {
    min-height: 1200px;
  }
}

/* Mobile viewport scaling for large spreads */
@media (max-width: 640px) {
  .spread-10 {
    transform: scale(0.8);
    transform-origin: top center;
    margin-bottom: -150px;
  }
  .spread-5 {
    transform: scale(0.85);
    transform-origin: top center;
    margin-bottom: -80px;
  }
}

.cc-1-center {
  top: 50%;
  left: 50%;
}
.cc-3-left {
  top: 50%;
  left: 18%;
}
.cc-3-center {
  top: 50%;
  left: 50%;
}
.cc-3-right {
  top: 50%;
  left: 82%;
}
.cc-5-top {
  top: 12%;
  left: 50%;
}
.cc-5-bottom {
  top: 88%;
  left: 50%;
}
.cc-5-left {
  top: 50%;
  left: 18%;
}
.cc-5-center {
  top: 50%;
  left: 50%;
}
.cc-5-right {
  top: 50%;
  left: 82%;
}
.cc-1 {
  top: 40%;
  left: 35%;
}
.cc-2 {
  top: 40%;
  left: 35%;
  transform: translate(-50%, -50%) rotate(90deg) !important;
}
.cc-3 {
  top: 68%;
  left: 35%;
}
.cc-4 {
  top: 40%;
  left: 15%;
}
.cc-5 {
  top: 12%;
  left: 35%;
}
.cc-6 {
  top: 40%;
  left: 55%;
}
.cc-7 {
  top: 85%;
  left: 80%;
}
.cc-8 {
  top: 63.3%;
  left: 80%;
}
.cc-9 {
  top: 41.6%;
  left: 80%;
}
.cc-10 {
  top: 20%;
  left: 80%;
}

/* --- DYNAMIC CARD SIZING --- */
.spread-10 .card-placeholder {
  width: 80px;
  height: 128px;
  font-size: 0.6rem;
}
@media (min-width: 768px) {
  .spread-10 .card-placeholder {
    width: 130px;
    height: 208px;
    font-size: 0.8rem;
  }
}

.spread-5 .card-placeholder {
  width: 95px;
  height: 152px;
}
@media (min-width: 768px) {
  .spread-5 .card-placeholder {
    width: 160px;
    height: 256px;
  }
}

.spread-3 .card-placeholder {
  width: 105px;
  height: 168px;
}
@media (min-width: 768px) {
  .spread-3 .card-placeholder {
    width: 200px;
    height: 320px;
  }
}

.spread-1 .card-placeholder {
  width: 190px;
  height: 304px;
  font-size: 1.1rem;
}
@media (min-width: 768px) {
  .spread-1 .card-placeholder {
    width: 320px;
    height: 512px;
    font-size: 1.5rem;
  }
  .spread-1 .drawn-card-title {
    font-size: 1.8rem;
  }
}

.card-placeholder {
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: rgba(15, 23, 42, 0.6);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #cbd5e1;
  text-align: center;
  padding: 0.5rem;
  position: absolute;
  transform: translate(-50%, -50%);
  transition: all 0.4s ease;
}

.card-placeholder::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(251, 191, 36, 0.3);
  border-radius: 6px;
}

/* --- CARD FACES --- */
.drawn-card {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-shadow:
    0 10px 25px rgba(0, 0, 0, 0.7),
    0 0 15px rgba(251, 191, 36, 0.3);
  border: 1px solid rgba(251, 191, 36, 0.6);
  background: #090d16;
}

.glow-pulse {
  animation: cardGlow 3s infinite alternate;
}

@keyframes cardGlow {
  0% {
    box-shadow:
      0 10px 25px rgba(0, 0, 0, 0.7),
      0 0 10px rgba(251, 191, 36, 0.2);
  }
  100% {
    box-shadow:
      0 15px 35px rgba(0, 0, 0, 0.8),
      0 0 25px rgba(251, 191, 36, 0.5);
  }
}

.card-art-frame {
  width: 100%;
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background-size: cover;
  background-position: center;
}

/* Modern Minimalist Card Themes */
.theme-major {
  background: radial-gradient(circle, #2e1065 0%, #090d16 100%);
}
.theme-wands {
  background: radial-gradient(circle, #451a03 0%, #090d16 100%);
}
.theme-cups {
  background: radial-gradient(circle, #0c4a6e 0%, #090d16 100%);
}
.theme-swords {
  background: radial-gradient(circle, #1e293b 0%, #090d16 100%);
}
.theme-pentacles {
  background: radial-gradient(circle, #14532d 0%, #090d16 100%);
}

.card-title-banner {
  width: 100%;
  padding: 6px 4px;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid rgba(251, 191, 36, 0.4);
  text-align: center;
  z-index: 10;
}

.drawn-card-title {
  font-family: "Sarabun", sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fef08a;
  letter-spacing: 0.05em;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Classic Rider-Waite Art Overlay */
.classic-art-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 15;
}

.classic-foil {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    transparent 0%,
    rgba(255, 255, 255, 0.25) 45%,
    rgba(251, 191, 36, 0.4) 50%,
    rgba(255, 255, 255, 0.25) 55%,
    transparent 100%
  );
  background-size: 200% 200%;
  mix-blend-mode: overlay;
  opacity: 0.7;
  z-index: 16;
  pointer-events: none;
  animation: holoFoil 4s infinite linear;
}

.classic-art-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    45deg,
    rgba(255, 0, 128, 0.15),
    rgba(0, 255, 255, 0.15),
    rgba(255, 255, 0, 0.15),
    rgba(128, 0, 255, 0.15)
  );
  background-size: 300% 300%;
  mix-blend-mode: hard-light;
  opacity: 0.6;
  z-index: 16;
  pointer-events: none;
  animation: holoFoil 6s infinite linear;
}

@keyframes holoFoil {
  0% {
    background-position: 100% 100%;
  }
  100% {
    background-position: 0% 0%;
  }
}

/* --- MASSIVE FANNED DECK --- */
.fan-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 20px;
}

@media (min-width: 768px) {
  .fan-container {
    padding-bottom: 30px;
  }
}

.fan-card {
  position: absolute;
  bottom: 0px;
  width: 58px;
  height: 92px;
  background-color: #0f172a;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30'%3E%3Crect width='15' height='15' fill='%23ffffff' fill-opacity='0.05'/%3E%3Crect x='15' y='15' width='15' height='15' fill='%23ffffff' fill-opacity='0.05'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at bottom, rgba(79, 70, 229, 0.6) 0%, #020617 100%);
  border: 2px solid #fbbf24;
  border-radius: 6px;
  transform-origin: center center;
  transition:
    transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    box-shadow 0.3s,
    border-color 0.3s;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow:
    -3px 0 12px rgba(0, 0, 0, 0.7),
    inset 0 0 15px rgba(0, 0, 0, 0.5);
}

@media (min-width: 768px) {
  .fan-card {
    width: 90px;
    height: 144px;
    border-radius: 8px;
  }
}

.fan-card:hover,
.fan-card:active {
  transform: var(--base-transform) translateY(-50px) scale(1.3) !important;
  box-shadow:
    0 25px 50px rgba(0, 0, 0, 0.9),
    0 0 30px rgba(251, 191, 36, 0.6);
  z-index: 200 !important;
  border-color: #fef08a;
}

@media (min-width: 768px) {
  .fan-card:hover {
    transform: var(--base-transform) translateY(-60px) scale(1.4) !important;
  }
}

.fan-card::after {
  content: "";
  position: absolute;
  top: -20px;
  left: -20px;
  right: -20px;
  bottom: -60px;
  z-index: -1;
}

.reading-complete-fan {
  filter: grayscale(40%) opacity(0.7);
  transform: translateY(110px);
  transition:
    filter 0.5s ease,
    opacity 0.5s ease,
    transform 0.5s ease;
}
.reading-complete-fan,
.reading-complete-fan * {
  cursor: not-allowed !important;
}

.custom-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23fbbf24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1em;
}

/* --- ANIMATIONS & EFFECTS --- */
@keyframes sweepAcross {
  0% {
    transform: translate(100vw, -10vh) rotate(60deg) scale(0.5);
  }
  15% {
    transform: translate(-20vw, 15vh) rotate(-30deg) scale(1.5);
  }
  30% {
    transform: translate(30vw, 5vh) rotate(40deg) scale(1.5);
  }
  45% {
    transform: translate(-30vw, 20vh) rotate(-45deg) scale(1.5);
  }
  60% {
    transform: translate(25vw, 10vh) rotate(35deg) scale(1.5);
  }
  75% {
    transform: translate(-40vw, 25vh) rotate(-50deg) scale(1.5);
  }
  100% {
    transform: translate(-150vw, -20vh) rotate(-90deg) scale(0.5);
  }
}
.animate-sweep {
  animation: sweepAcross 1.6s ease-in-out forwards;
}

.fly-away {
  transform: translate(var(--fly-x, -100vw), var(--fly-y, -30vh))
    rotate(var(--fly-rot, -720deg)) scale(0.2) !important;
  opacity: 0 !important;
  transition: all 0.8s cubic-bezier(0.55, 0.085, 0.68, 0.53) !important;
}

@keyframes warningShake {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
  }
  20% {
    transform: translate(-50%, -50%) rotate(-5deg) scale(1.1);
  }
  40% {
    transform: translate(-50%, -50%) rotate(5deg) scale(1.1);
  }
  60% {
    transform: translate(-50%, -50%) rotate(-5deg) scale(1.1);
  }
  80% {
    transform: translate(-50%, -50%) rotate(5deg) scale(1.1);
  }
}
.warning-active {
  animation: warningShake 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  opacity: 1 !important;
  transition: opacity 0.1s;
}

@keyframes flashRed {
  0%,
  100% {
    box-shadow: inset 0 0 0 rgba(239, 68, 68, 0);
  }
  20% {
    box-shadow: inset 0 0 150px rgba(239, 68, 68, 0.6);
  }
}
.flash-screen {
  animation: flashRed 0.6s ease-in-out;
}

@keyframes auraExpand {
  0% {
    transform: scale(0.8);
    opacity: 1;
    border-width: 4px;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
    border-width: 1px;
  }
}
.aura-ripple {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 12px;
  border: solid #fbbf24;
  box-shadow:
    0 0 30px #c084fc,
    inset 0 0 20px #fbbf24;
  animation: auraExpand 0.8s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
  pointer-events: none;
  z-index: 5;
}

/* Toggles */
.toggle-checkbox:checked {
  right: 0;
  border-color: #fbbf24;
}
.toggle-checkbox:checked + .toggle-label {
  background-color: #fbbf24;
}
.toggle-checkbox:checked + .toggle-label:after {
  transform: translateX(100%);
  border-color: white;
}

.art-locked {
  opacity: 0.5;
  pointer-events: none;
  filter: grayscale(100%);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #0f172a;
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* --- ITCH VERSION: AI PROVIDER & API KEY MODAL STYLES --- */
.ai-modal-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
  transition: all 0.3s ease-in-out;
}

.ai-modal-visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
  transition: all 0.3s ease-in-out;
}

.gold-glow-button {
  box-shadow: 0 0 15px rgba(251, 191, 36, 0.2);
  transition: all 0.3s ease;
}

.gold-glow-button:hover {
  box-shadow: 0 0 25px rgba(251, 191, 36, 0.5);
  transform: translateY(-1px);
}

.key-badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-configured {
  background-color: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #4ade80;
}

.status-missing {
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}

/* --- WELCOME HERO SCREEN & COVER PREVIEW STYLES --- */
#welcome-screen {
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s;
}

.welcome-screen-hidden {
  opacity: 0 !important;
  transform: scale(1.05) !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.welcome-stars {
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(2px 2px at 20px 30px, #ffffff, rgba(0,0,0,0)),
    radial-gradient(2px 2px at 40px 70px, #fbbf24, rgba(0,0,0,0)),
    radial-gradient(1px 1px at 90px 40px, #ffffff, rgba(0,0,0,0)),
    radial-gradient(2px 2px at 160px 120px, #c084fc, rgba(0,0,0,0)),
    radial-gradient(2px 2px at 230px 190px, #ffffff, rgba(0,0,0,0)),
    radial-gradient(1px 1px at 310px 250px, #fbbf24, rgba(0,0,0,0));
  background-repeat: repeat;
  background-size: 350px 350px;
  opacity: 0.6;
  animation: starPulse 6s ease-in-out infinite alternate;
}

@keyframes starPulse {
  0% { opacity: 0.4; transform: scale(1); }
  100% { opacity: 0.8; transform: scale(1.02); }
}

.welcome-card {
  width: 90px;
  height: 144px;
  border-radius: 10px;
  border: 1.5px solid #fbbf24;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8), 0 0 20px rgba(251,191,36,0.3);
  transition: transform 0.4s ease, box-shadow 0.4s ease;
}

@media (min-width: 768px) {
  .welcome-card {
    width: 120px;
    height: 192px;
    border-radius: 12px;
  }
}

.welcome-card .card-inner {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.card-left {
  transform: rotate(-12deg) translateY(10px) scale(0.95);
  animation: floatLeft 4s ease-in-out infinite alternate;
}

.card-center {
  transform: rotate(0deg) translateY(-10px) scale(1.1);
  z-index: 10;
  animation: floatCenter 4s ease-in-out infinite alternate;
}

.card-right {
  transform: rotate(12deg) translateY(10px) scale(0.95);
  animation: floatRight 4s ease-in-out infinite alternate 0.5s;
}

@keyframes floatLeft {
  0% { transform: rotate(-12deg) translateY(10px) scale(0.95); }
  100% { transform: rotate(-15deg) translateY(-5px) scale(0.95); }
}

@keyframes floatCenter {
  0% { transform: rotate(0deg) translateY(-10px) scale(1.1); }
  100% { transform: rotate(0deg) translateY(-22px) scale(1.12); }
}

@keyframes floatRight {
  0% { transform: rotate(12deg) translateY(10px) scale(0.95); }
  100% { transform: rotate(15deg) translateY(-5px) scale(0.95); }
}

.glow-pulse-gold {
  box-shadow: 0 0 35px rgba(251, 191, 36, 0.6), inset 0 0 20px rgba(251, 191, 36, 0.4);
}
