/* ==========================================================================
   DESIGN SYSTEM & BASIC VARIABLES
   ========================================================================== */
:root {
    --color-bg-darkest: #05020c;
    --color-bg-dark: #0f0720;
    --color-bg-glass: rgba(15, 7, 32, 0.75);
    --color-gold: #d4af37;
    --color-gold-glow: rgba(212, 175, 55, 0.4);
    --color-gold-light: #f3d06c;
    --color-text-light: #f4f1fa;
    --color-text-muted: #b0a7c4;
    --color-accent-purple: #8a2be2;
    --color-shadow-red: #ff4d4d;
    --color-light-cyan: #e0f7fa;
    --font-serif: 'Cinzel', Georgia, serif;
    --font-sans: 'Montserrat', Helvetica, Arial, sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-card: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-bg-darkest);
    color: var(--color-text-light);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ==========================================================================
   STARRY SKY BACKGROUND ANIMATION
   ========================================================================== */
.stars, .twinkling {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: -10;
}

.stars {
    background: #05020c url('assets/card-back.png') no-repeat center center fixed;
    background-size: cover;
    opacity: 0.14; /* Slightly increased opacity to make the pattern more visible */
    filter: blur(5px); /* Soft blur to prevent visual clutter */
}

.twinkling {
    background: transparent url('https://cdnjs.cloudflare.com/ajax/libs/twinkle/0.1.0/twinkle.min.js') repeat top center;
    background: radial-gradient(circle, transparent 20%, var(--color-bg-darkest) 80%);
    opacity: 0.8;
}

/* Custom scrollbars */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--color-bg-darkest);
}
::-webkit-scrollbar-thumb {
    background: var(--color-gold-glow);
    border-radius: 4px;
    border: 1px solid var(--color-bg-dark);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-gold);
}

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-serif);
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--color-text-light);
}

h1 {
    font-size: 2.2rem;
    font-weight: 700;
    text-transform: uppercase;
    background: linear-gradient(135deg, #fff 30%, var(--color-gold-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 10px rgba(255,255,255,0.1);
}

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 1px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
    text-transform: uppercase;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-gold) 0%, #b8860b 100%);
    color: var(--color-bg-darkest);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
    background: linear-gradient(135deg, var(--color-gold-light) 0%, var(--color-gold) 100%);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    color: var(--color-gold);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.btn-secondary:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: var(--color-gold);
    color: var(--color-text-light);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.15);
}

.btn-icon {
    margin-right: 8px;
    font-size: 1.1rem;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   APP HEADER
   ========================================================================== */
.app-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* Left spacer, centered logo, right nav */
    align-items: center;
    padding: 20px 40px;
    background: rgba(5, 2, 12, 0.6);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
    position: relative;
    z-index: 100;
}

.header-left {
    grid-column: 1; /* Left column */
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.logo-triangle {
    height: 65px; /* Increased to match text block height */
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(212, 175, 55, 0.4));
    transition: transform 0.3s ease, filter 0.3s ease;
    cursor: pointer;
}

.logo-triangle:hover {
    transform: scale(1.08);
    filter: drop-shadow(0 0 12px rgba(212, 175, 55, 0.6));
}

.header-center {
    grid-column: 2; /* Center column */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.logo-scarab {
    height: 95px; /* Increased for a more majestic center presence */
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.45));
    transition: transform 0.3s ease, filter 0.3s ease;
    cursor: pointer;
}

.logo-scarab:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 16px rgba(212, 175, 55, 0.7));
}

.scarab-date-label {
    font-family: var(--font-serif);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(212, 175, 55, 0.65);
    cursor: pointer;
    transition: var(--transition-smooth);
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    user-select: none;
    text-align: center;
}

.scarab-date-label:hover {
    color: var(--color-gold-light);
    text-shadow: 0 0 8px var(--color-gold-glow);
}

@keyframes pulseGlow {
    0%, 100% { text-shadow: 0 0 10px var(--color-gold-glow); opacity: 0.8; }
    50% { text-shadow: 0 0 20px var(--color-gold), 0 0 30px var(--color-accent-purple); opacity: 1; }
}

.logo-text h1 {
    margin: 0;
    line-height: 1.1;
}

.logo-text .subtitle {
    font-family: var(--font-serif);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: var(--color-gold);
    margin-top: 2px;
}

.header-nav {
    grid-column: 3; /* Right column */
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

/* ==========================================================================
   APP CONTAINER & SCREENS
   ========================================================================== */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    position: relative;
    z-index: 10;
}

.screen {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    display: none;
}

.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   1. SELECTION SCREEN
   ========================================================================== */
.welcome-section {
    text-align: center;
    max-width: 700px;
    margin: 40px auto 60px;
}

.intro-p {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-style: italic;
    color: var(--color-text-muted);
    line-height: 1.8;
    position: relative;
}

.intro-p::before, .intro-p::after {
    content: "“";
    font-size: 3rem;
    color: var(--color-gold-glow);
    position: absolute;
    line-height: 0;
}
.intro-p::before { left: -30px; top: 15px; }
.intro-p::after { right: -30px; bottom: -10px; content: "”"; }

.spread-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 40px;
    margin-top: 20px;
}

.spread-card {
    background: rgba(15, 7, 32, 0.4);
    border: 1px solid rgba(212, 175, 55, 0.15);
    border-radius: 8px;
    padding: 40px 30px;
    text-align: center;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(5px);
}

.spread-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--color-gold), transparent);
    opacity: 0;
    transition: var(--transition-smooth);
}

.spread-card:hover {
    transform: translateY(-8px);
    background: rgba(25, 12, 50, 0.6);
    border-color: rgba(212, 175, 55, 0.4);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 20px rgba(212, 175, 55, 0.05);
}

.spread-card:hover::before {
    opacity: 1;
}

.spread-icon {
    font-size: 3.5rem;
    color: var(--color-gold);
    margin-bottom: 20px;
    filter: drop-shadow(0 0 10px var(--color-gold-glow));
    transition: var(--transition-smooth);
}

.spread-card:hover .spread-icon {
    transform: scale(1.1);
    filter: drop-shadow(0 0 15px var(--color-gold));
}

.spread-card h3 {
    font-size: 1.6rem;
    margin-bottom: 15px;
    text-transform: uppercase;
    color: var(--color-text-light);
}

.spread-desc {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin-bottom: 30px;
    min-height: 80px;
}

.spread-card .btn {
    width: 100%;
}

/* ==========================================================================
   2. TABLE SCREEN (Tapete de Tirada)
   ========================================================================== */
.table-info {
    text-align: center;
    margin-bottom: 35px;
}

.table-info h2 {
    font-size: 2rem;
    text-transform: uppercase;
    color: var(--color-gold);
    margin-bottom: 10px;
}

.instruction-text {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    font-style: italic;
    min-height: 28px;
}

.table-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

.tarot-table {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* Center vertically when only deck is shown */
    gap: 30px;
    background: radial-gradient(circle, rgba(40, 15, 80, 0.15) 0%, rgba(5, 2, 12, 0) 70%);
    padding: 30px;
    border-radius: 16px;
    min-height: 500px;
}

/* Deck Container */
.deck-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.deck-container.fade-out {
    opacity: 0;
    transform: scale(0.8) translateY(-20px);
    pointer-events: none;
}

.deck-label {
    font-family: var(--font-serif);
    font-size: 0.8rem;
    color: var(--color-gold);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.deck {
    position: relative;
    width: 130px;
    height: 220px;
    cursor: pointer;
}

.deck-card {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.6);
    transition: var(--transition-smooth);
}

.deck-card:nth-child(1) { transform: translate(0, 0); z-index: 3; }
.deck-card:nth-child(2) { transform: translate(2px, -3px); z-index: 2; }
.deck-card:nth-child(3) { transform: translate(4px, -6px); z-index: 1; }

.deck:hover .deck-card:nth-child(1) { transform: translate(-5px, 0) rotate(-2deg); }
.deck:hover .deck-card:nth-child(2) { transform: translate(2px, -2px); }
.deck:hover .deck-card:nth-child(3) { transform: translate(7px, 0) rotate(2deg); }

/* Shuffling Animation class */
.shuffling-animation .deck-card:nth-child(1) { animation: shuffleLeft 0.5s ease-in-out infinite alternate; }
.shuffling-animation .deck-card:nth-child(3) { animation: shuffleRight 0.5s ease-in-out infinite alternate; }

@keyframes shuffleLeft {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-60px, 0) rotate(-10deg) z-index: 5; }
}

@keyframes shuffleRight {
    0% { transform: translate(4px, -6px); }
    100% { transform: translate(60px, 0) rotate(10deg) z-index: 5; }
}

/* Card Back Design (Using user's custom image) */
.card-back-design {
    background: #000 url('assets/card-back.png') no-repeat center center;
    background-size: cover;
    border: 2px solid var(--color-gold);
    box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.4), 0 5px 15px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-back-design::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    bottom: 6px;
    border: 1px solid rgba(212, 175, 55, 0.35);
    pointer-events: none;
    z-index: 2;
}

/* Remove CSS Ankh since card-back.png has its own design */
.card-back-design::after {
    display: none;
}

/* Layout Slots */
.spread-layout {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: nowrap; /* Disable wrap on desktop to force perfect horizontal layout */
    width: 100%;
    margin-top: 20px;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1), transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

#screen-table[data-state="dealt"] .spread-layout {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.card-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 240px; /* Increased from 220px */
}

.card-revealed-name {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--color-gold-light);
    text-shadow: 0 0 8px var(--color-gold-glow);
    text-align: center;
    margin-top: 15px;
    min-height: 24px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.card-revealed-name.visible {
    opacity: 1;
    transform: translateY(0);
}

.modal-header-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.btn-speak {
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid var(--color-gold);
    color: var(--color-gold);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    padding: 0;
    outline: none;
}

.btn-speak:hover {
    background: var(--color-gold);
    color: var(--color-bg-darkest);
    box-shadow: 0 0 12px var(--color-gold);
    transform: scale(1.1);
}

.btn-speak:active {
    transform: scale(0.95);
}

.slot-label {
    font-family: var(--font-serif);
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--color-gold);
    letter-spacing: 1px;
    text-align: center;
    min-height: 40px;
    display: flex;
    align-items: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.slot-target {
    width: 240px; /* Increased from 220px */
    height: 400px; /* Increased from 366px to maintain aspect ratio */
    border: 2px dashed transparent; /* Invisible border before deal */
    border-radius: 12px;
    background: transparent; /* No background before deal */
    position: relative;
    transition: var(--transition-smooth);
}

.slot-target.active-drop {
    border-color: var(--color-gold);
    background: rgba(212, 175, 55, 0.05);
    box-shadow: inset 0 0 20px rgba(212, 175, 55, 0.15);
}

/* Card Component in Slot */
.tarot-card-item {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    cursor: pointer;
    opacity: 0;
    /* Slide in from deck position (centered above slots) and scaled down */
    transform: scale(0.2) translateY(-250px) rotate(-10deg);
    transition: opacity 0.8s cubic-bezier(0.25, 1, 0.5, 1), transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 10;
}

.tarot-card-item.dealt {
    opacity: 1;
    transform: scale(1) translateY(0) rotate(0);
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 10px;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s ease;
}

.tarot-card-item:hover .card-inner {
    transform: translateY(-8px);
    box-shadow: 0 10px 25px rgba(212, 175, 55, 0.35);
}

.tarot-card-item.flipped .card-inner {
    animation: flip2D 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes flip2D {
    0% {
        transform: scaleX(1);
    }
    50% {
        transform: scaleX(0);
    }
    100% {
        transform: scaleX(1);
    }
}

/* Card Inverted state */
.tarot-card-item.inverted .card-front-face img {
    transform: rotate(180deg);
}

.card-face {
    position: absolute !important;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    overflow: hidden;
}

/* Back Face */
.card-back {
    opacity: 1;
    transition: opacity 0s 0.3s; /* Switch opacity at exactly 50% (0.3s) of 0.6s */
}

.tarot-card-item.flipped .card-back {
    opacity: 0;
}

/* Front Face (Artwork) */
.card-front-face {
    background: #000;
    border: 2px solid var(--color-gold);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0s 0.3s; /* Switch opacity at exactly 50% (0.3s) of 0.6s */
}

.tarot-card-item.flipped .card-front-face {
    opacity: 1;
}

.card-front-face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

/* Small card label on hover when face-up */
.card-quick-label {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(5, 2, 12, 0.85);
    color: var(--color-gold);
    font-family: var(--font-serif);
    font-size: 0.75rem;
    text-align: center;
    padding: 6px 2px;
    border-top: 1px solid var(--color-gold);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 5;
    pointer-events: none;
}

.tarot-card-item.flipped:hover .card-quick-label {
    transform: translateY(0);
}

/* Summary Panel */
.summary-panel {
    width: 100%;
    max-width: 800px;
    margin: 40px auto 0;
    background: rgba(15, 7, 32, 0.5);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 12px;
    padding: 25px;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    text-align: center;
}

.summary-panel h3 {
    color: var(--color-gold);
    text-transform: uppercase;
    font-size: 1.3rem;
    margin-bottom: 5px;
}

.summary-panel p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.summary-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    text-align: left;
}

.summary-card-item {
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid var(--color-gold);
    border-radius: 0 6px 6px 0;
    padding: 15px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.summary-card-item:hover {
    background: rgba(212, 175, 55, 0.08);
    transform: translateX(4px);
}

.summary-card-item h4 {
    font-size: 0.95rem;
    text-transform: uppercase;
    color: var(--color-text-light);
    margin-bottom: 4px;
}

.summary-card-item .sc-role {
    font-family: var(--font-serif);
    font-size: 0.75rem;
    color: var(--color-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.summary-card-item .sc-text {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==========================================================================
   3. MODAL (Detail View & Glassmorphism)
   ========================================================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(5, 2, 12, 0.85);
    backdrop-filter: blur(6px);
}

.modal-content.glass {
    position: relative;
    background: var(--color-bg-glass);
    border: 1px solid rgba(212, 175, 55, 0.25);
    box-shadow: 0 20px 50px rgba(0,0,0,0.8), 0 0 30px rgba(212, 175, 55, 0.05), inset 0 0 30px rgba(255,255,255,0.02);
    border-radius: 16px;
    width: 90%;
    max-width: 900px;
    height: 650px; /* Fixed height for desktop to make scrolling work correctly */
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1010;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2.2rem;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
    z-index: 50;
}

.modal-close:hover {
    color: var(--color-gold);
    transform: rotate(90deg);
}

/* Modal Grid */
.modal-grid {
    display: grid;
    grid-template-columns: 370px 1fr; /* Increased left column width from 350px to 370px */
    height: 100%;
    overflow: hidden; /* Ensure it stays inside the modal-content height */
}

.modal-card-display {
    background: rgba(5, 2, 12, 0.4);
    border-right: 1px solid rgba(212, 175, 55, 0.15);
    padding: 30px 20px; /* Adjusted padding */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    height: 100%;
    overflow: hidden;
}

.card-image-wrapper {
    width: 100%;
    max-width: 300px; /* Increased max-width from 280px to 300px to make it even larger */
    height: auto;
    max-height: 55vh; /* Increased max-height slightly to allow vertical growth */
    aspect-ratio: 2 / 3.3; /* Keep aspect ratio correct */
    border: 3px solid var(--color-gold);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8), 0 0 25px var(--color-gold-glow);
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Avoid cutting card borders or text */
}

.modal-card-badges {
    display: flex;
    gap: 10px;
}

.badge-id {
    background: rgba(212, 175, 55, 0.1);
    color: var(--color-gold);
    border: 1px solid var(--color-gold);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-orientation {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-light);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-orientation.inverted-badge {
    background: rgba(255, 77, 77, 0.1);
    color: var(--color-shadow-red);
    border-color: var(--color-shadow-red);
}

/* Modal details */
.modal-card-details {
    padding: 40px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    height: 100%; /* Fill space to trigger overflow scrolling */
}

.modal-header-info {
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
    padding-bottom: 20px;
}

.badge-circle {
    display: inline-block;
    background: var(--color-accent-purple);
    color: #fff;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 10px;
    box-shadow: 0 2px 10px rgba(138, 43, 226, 0.3);
}

.modal-card-details h2 {
    font-size: 2.2rem;
    margin: 5px 0;
    color: var(--color-gold-light);
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.1);
}

.modal-card-details h4 {
    font-size: 1rem;
    color: var(--color-text-muted);
    font-style: italic;
    font-weight: 400;
}

.modal-sections-scroll {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.detail-section h5 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--color-gold);
    margin-bottom: 6px;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-section p {
    color: var(--color-text-light);
    font-size: 0.95rem;
    line-height: 1.7;
}

.meaning-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.meaning-light {
    border-left: 2px solid var(--color-gold);
    padding-left: 15px;
}

.meaning-light h5 {
    color: #ffd700;
}

.meaning-shadow {
    border-left: 2px solid var(--color-shadow-red);
    padding-left: 15px;
}

.meaning-shadow h5 {
    color: var(--color-shadow-red);
}

/* Highlight boxes */
.highlight-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 18px 20px;
}

.highlight-box.gold {
    border-color: rgba(212, 175, 55, 0.25);
    background: rgba(212, 175, 55, 0.02);
    box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.02);
}

.quote-box {
    border-top: 1px double rgba(212, 175, 55, 0.3);
    border-bottom: 1px double rgba(212, 175, 55, 0.3);
    padding: 20px 10px;
    text-align: center;
}

.quote-box h5 {
    justify-content: center;
}

.quote-box blockquote {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    color: var(--color-text-light);
    font-style: italic;
    line-height: 1.6;
}

/* Highlight style when details view is for inverted card */
.modal-card-details.card-view-inverted .meaning-shadow {
    background: rgba(255, 77, 77, 0.05);
    border-radius: 4px;
    padding: 10px 15px;
}

.modal-card-details.card-view-inverted .meaning-light {
    opacity: 0.6;
}

/* ==========================================================================
   4. MANUAL MODAL (Instructions & Tabbed layout)
   ========================================================================== */
.manual-content {
    max-width: 800px;
    max-height: 80vh;
}

.manual-header {
    padding: 30px 40px 15px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
}

.manual-header h2 {
    font-size: 1.8rem;
    color: var(--color-gold);
    text-transform: uppercase;
}

.manual-header p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.manual-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
    padding: 0 40px;
    gap: 5px;
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    padding: 15px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition-smooth);
    white-space: nowrap;
    letter-spacing: 1px;
}

.tab-btn:hover {
    color: var(--color-gold);
}

.tab-btn.active {
    color: var(--color-gold-light);
    border-bottom-color: var(--color-gold);
}

.manual-tabs-content {
    padding: 35px 40px;
    overflow-y: auto;
    flex-grow: 1;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-pane.active {
    display: block;
}

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

.tab-pane h3 {
    font-size: 1.3rem;
    color: var(--color-gold-light);
    margin-bottom: 15px;
}

.tab-pane p {
    color: var(--color-text-light);
    font-size: 0.95rem;
    margin-bottom: 15px;
    line-height: 1.7;
}

.tab-pane ul, .tab-pane ol {
    margin-left: 20px;
    margin-bottom: 20px;
    color: var(--color-text-light);
}

.tab-pane li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.tab-pane strong {
    color: var(--color-gold);
}

.ritual-box, .tip-box {
    background: rgba(212, 175, 55, 0.02);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.tip-box {
    border-color: rgba(138, 43, 226, 0.25);
    background: rgba(138, 43, 226, 0.01);
}

.tip-box h5 {
    color: var(--color-accent-purple);
    font-size: 0.9rem;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.mystical-quote {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-style: italic;
    text-align: center;
    color: var(--color-gold-light);
    border-top: 1px dashed rgba(212, 175, 55, 0.3);
    border-bottom: 1px dashed rgba(212, 175, 55, 0.3);
    padding: 15px;
    margin: 15px 0;
    line-height: 1.8;
}

.gold-text {
    color: var(--color-gold-light);
}

/* Circles Tab Grid */
.circles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.circle-info-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 20px;
    position: relative;
    padding-left: 55px;
}

.circle-num {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 30px;
    height: 30px;
    background: rgba(138, 43, 226, 0.15);
    border: 1px solid var(--color-accent-purple);
    color: #fff;
    font-family: var(--font-serif);
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.circle-info-card h5 {
    color: var(--color-gold);
    font-size: 0.95rem;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.circle-info-card p {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* ==========================================================================
   MEDIA QUERIES (Responsive Design)
   ========================================================================== */
@media (max-width: 850px) {
    .modal-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr; /* Top row for card, bottom for text */
        height: 100%;
        overflow: hidden;
    }

    .modal-content.glass {
        height: 85vh; /* Take full height on mobile */
        max-height: 90vh;
    }

    .modal-card-display {
        border-right: none;
        border-bottom: 1px solid rgba(212, 175, 55, 0.15);
        padding: 15px 10px;
        height: auto;
    }

    .card-image-wrapper {
        width: 110px;
        height: auto;
        max-height: 25vh; /* Keep card compact on mobile screens */
        aspect-ratio: 2 / 3.3;
    }

    .modal-card-details {
        padding: 20px;
        overflow-y: auto;
        height: 100%;
    }

    .meaning-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 651px) and (max-width: 880px) {
    .card-slot {
        width: 180px;
    }
    .slot-target {
        width: 180px;
        height: 300px;
    }
}

@media (max-width: 650px) {
    .app-header {
        display: flex; /* Force flex column instead of grid */
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
        align-items: center;
    }

    .header-center {
        order: 1;
    }

    .header-left {
        order: 2;
        display: flex;
        flex-direction: column; /* Stack triangle and text vertically on mobile */
        align-items: center;
        text-align: center;
        gap: 8px;
    }

    .header-nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .logo-text h1 {
        font-size: 1.6rem;
    }

    .welcome-section {
        margin: 20px auto 30px;
    }

    .intro-p {
        font-size: 1rem;
    }

    .intro-p::before, .intro-p::after {
        display: none;
    }

    .spread-options {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .tarot-table {
        padding: 15px 5px;
        gap: 30px;
    }

    .spread-layout {
        flex-direction: column; /* Force clean vertical stack on small screens */
        align-items: center;
        gap: 30px;
    }

    .card-slot {
        width: 200px; /* Increased from 140px for better visibility */
    }

    .slot-target {
        width: 200px; /* Increased from 140px */
        height: 333px; /* Increased from 233px */
    }

    .manual-tabs {
        padding: 0 15px;
    }

    .manual-tabs-content {
        padding: 20px;
    }
}

/* ==========================================================================
   BIOGRAPHY (AUTHOR) & PREMIUM MODAL STYLING
   ========================================================================== */
.author-modal-content {
    max-width: 650px;
    height: auto;
    max-height: 85vh;
    overflow-y: auto;
}

.author-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 30px;
    padding: 40px;
    align-items: center;
}

.author-image-wrapper {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid var(--color-gold);
    overflow: hidden;
    box-shadow: 0 0 15px var(--color-gold-glow);
}

.author-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.author-details h2 {
    color: var(--color-gold-light);
    font-size: 1.8rem;
    text-transform: uppercase;
}

.author-details .subtitle {
    font-family: var(--font-serif);
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--color-gold);
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.author-bio {
    color: var(--color-text-light);
    font-size: 0.95rem;
    line-height: 1.6;
}

.author-bio p {
    margin-bottom: 12px;
}

.premium-modal-content {
    max-width: 500px;
    height: auto;
    max-height: 85vh;
}

.premium-info {
    padding: 40px;
    text-align: center;
}

.premium-info h2 {
    color: var(--color-gold-light);
    font-size: 1.6rem;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.premium-intro {
    font-style: italic;
    color: var(--color-text-muted);
    margin-top: 15px;
    margin-bottom: 20px;
}

.premium-features {
    text-align: left;
    margin: 20px 0;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 20px;
}

.premium-features p {
    margin-bottom: 10px;
    color: var(--color-text-light);
}

.premium-features p:last-child {
    margin-bottom: 0;
}

/* Custom pointer for clickable logos */
.logo-triangle, .logo-scarab {
    cursor: pointer;
}

@media (max-width: 650px) {
    .author-grid {
        grid-template-columns: 1fr;
        text-align: center;
        padding: 20px;
    }
    .author-image-wrapper {
        width: 150px;
        margin: 0 auto;
    }
    .premium-info {
        padding: 20px;
    }
}

/* ==========================================================================
   4. MOTOR ALQUÍMICO DE LECTURAS (SUMMARY PANEL EXTENSION)
   ========================================================================== */
.alchemical-divider {
    background: linear-gradient(to right, transparent, var(--color-gold), transparent);
    height: 1px;
    margin: 40px 0 30px;
}

.alchemical-title {
    font-family: var(--font-serif);
    color: var(--color-gold-light);
    font-size: 1.6rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 10px var(--color-gold-glow);
    margin-bottom: 25px;
    text-align: center;
}

.alchemical-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(212, 175, 55, 0.15);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: left;
    transition: var(--transition-smooth);
}

.alchemical-section:hover {
    border-color: rgba(212, 175, 55, 0.35);
    background: rgba(255, 255, 255, 0.03);
}

.alchemical-section h4 {
    color: var(--color-gold);
    font-family: var(--font-serif);
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    padding-bottom: 6px;
    margin-top: 0;
}

/* Circle Section */
.alchemical-circle {
    text-align: center;
    border: 1px dashed var(--color-gold);
    background: rgba(212, 175, 55, 0.03);
}

.circle-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--color-text-muted);
    letter-spacing: 1px;
}

.circle-title {
    font-family: var(--font-serif);
    color: var(--color-gold-light);
    font-size: 1.4rem;
    text-transform: uppercase;
    margin: 5px 0 12px;
    letter-spacing: 1px;
    text-shadow: 0 0 6px var(--color-gold-glow);
}

.circle-msg {
    font-style: italic;
    color: var(--color-text-light);
    font-size: 1rem;
    margin-bottom: 10px;
}

.circle-keywords {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 0;
}

/* Balance Section */
.balance-percentage-labels {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-serif);
    font-size: 0.9rem;
    color: var(--color-text-light);
    margin-bottom: 6px;
    font-weight: 500;
}

.alchemical-progress-bar {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.2);
    margin-bottom: 15px;
}

.alchemical-progress-light {
    background: linear-gradient(90deg, #d4af37, #f3e5ab);
    box-shadow: 0 0 8px #d4af37;
    height: 100%;
    transition: width 1s ease-in-out;
}

.alchemical-progress-shadow {
    background: linear-gradient(90deg, #1f1235, #0f0720);
    height: 100%;
    transition: width 1s ease-in-out;
}

.balance-desc {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--color-text-light);
    margin-bottom: 0;
}

/* Combinations Section */
.alchemical-combinations {
    background: rgba(212, 175, 55, 0.04);
    border-color: rgba(212, 175, 55, 0.3);
}

.alchemical-combinations ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.alchemical-combinations li {
    font-size: 0.9rem;
    color: var(--color-text-light);
    line-height: 1.6;
    padding: 6px 0;
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
}

.alchemical-combinations li:last-child {
    border-bottom: none;
}

/* Narrative Section */
.narrative-body p {
    font-size: 0.95rem;
    color: var(--color-text-light);
    line-height: 1.6;
    margin-bottom: 12px;
    text-align: justify;
}

.narrative-body p:last-child {
    margin-bottom: 0;
}

/* Ritual Section */
.alchemical-ritual p {
    font-size: 0.95rem;
    color: var(--color-text-light);
    line-height: 1.6;
    margin-bottom: 0;
}

/* Aisset Message Section */
.alchemical-aisset-msg {
    text-align: center;
    border: none;
    background: transparent;
    padding: 20px 10px;
    margin-bottom: 10px;
}

.aisset-quote {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-style: italic;
    color: var(--color-gold-light);
    line-height: 1.5;
    margin: 0 auto 10px;
    max-width: 600px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.aisset-signature {
    font-family: var(--font-serif);
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--color-gold);
    letter-spacing: 2px;
}

/* Codes Section */
.alchemical-codes {
    border: none;
    background: rgba(212, 175, 55, 0.05);
    border-top: 1px solid rgba(212, 175, 55, 0.3);
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding: 15px 0;
    text-align: center;
    border-radius: 0;
    margin: 20px 0;
}

.codes-inner {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--color-gold-light);
    letter-spacing: 4px;
    text-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
}

/* Footer Quote */
.alchemical-footer-quote {
    font-family: var(--font-serif);
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--color-gold);
    letter-spacing: 3px;
    margin-top: 30px;
    margin-bottom: 10px;
    text-align: center;
    opacity: 0.85;
}

/* Animation utilities */
.animate-fade-in {
    animation: fadeIn 0.8s ease-out forwards;
}

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

/* Copy & Download button active states and animations */
.btn-copy-reading, .btn-download-reading {
    transition: var(--transition-smooth);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.btn-copy-reading:hover, .btn-download-reading:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: var(--color-gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

.btn-copy-reading.copied, .btn-download-reading.copied {
    background: rgba(46, 204, 113, 0.15) !important;
    border-color: #2ecc71 !important;
    color: #2ecc71 !important;
    box-shadow: 0 0 12px rgba(70, 240, 140, 0.3) !important;
}

/* ==========================================================================
   IFRAME EMBED OVERRIDES
   ========================================================================== */
html.is-embedded body {
    background-color: transparent !important;
    background-image: none !important;
}
html.is-embedded .app-header {
    display: none !important;
}
html.is-embedded .app-container {
    padding-top: 15px !important;
    padding-bottom: 20px !important;
    min-height: auto !important;
}
html.is-embedded .stars, html.is-embedded .twinkling {
    display: none !important;
}


