:root {
    --bg-color: #0b0716;
    --panel-bg: rgba(22, 14, 38, 0.7);
    --gold: #d4af37;
    --gold-glow: rgba(212, 175, 55, 0.4);
    --text-primary: #f0e6ff;
    --text-secondary: #b3a0cc;
    --user-msg-bg: rgba(62, 39, 102, 0.6);
    --sys-msg-bg: rgba(30, 19, 51, 0.6);
    --border-color: rgba(212, 175, 55, 0.2);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Background Effects */
.stars-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 40px 70px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 50px 160px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 90px 40px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 130px 80px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 160px 120px, #ffffff, rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0.3;
    z-index: -2;
    animation: twinkle 10s infinite linear;
}

.crystal-ball-bg {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(62, 39, 102, 0.2) 0%, rgba(11, 7, 22, 0) 70%);
    filter: blur(40px);
    z-index: -1;
    animation: breathe 8s infinite alternate ease-in-out;
}

@keyframes breathe {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.2); opacity: 0.8; }
}

@keyframes twinkle {
    0% { transform: translateY(0); }
    100% { transform: translateY(-200px); }
}

/* Chat Container */
.chat-container {
    width: 95%;
    max-width: 800px;
    height: 90dvh;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(16px);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), 0 0 20px var(--gold-glow);
    overflow: hidden;
    transition: max-width 0.5s ease;
}

.chat-container.split-mode {
    max-width: 1600px;
}

/* Header */
.header {
    padding: 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.3);
}

.avatar {
    position: relative;
    width: 60px;
    height: 60px;
    margin-right: 20px;
}

.avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--gold);
    position: relative;
    z-index: 1;
}

.mystic-glow {
    position: absolute;
    top: -5px; left: -5px; right: -5px; bottom: -5px;
    background: var(--gold);
    border-radius: 50%;
    filter: blur(10px);
    opacity: 0.5;
    animation: pulse 3s infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.3; }
    100% { transform: scale(1.1); opacity: 0.7; }
}

.header-info h1 {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: var(--gold);
    margin-bottom: 4px;
    letter-spacing: 2px;
}

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

.panels-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
    flex-direction: column;
}

.chat-container.split-mode .panels-wrapper {
    flex-direction: row;
}

.messages-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-right: none;
    transition: border 0.3s;
}

.chat-container.split-mode .messages-area {
    border-right: 1px solid var(--border-color);
}

.message {
    max-width: 80%;
    padding: 15px 20px;
    border-radius: 15px;
    line-height: 1.5;
    font-size: 0.95rem;
    position: relative;
    animation: fadeIn 0.4s ease-out forwards;
}

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

.system-msg {
    align-self: flex-start;
    background: var(--sys-msg-bg);
    border-left: 3px solid var(--gold);
    border-bottom-left-radius: 4px;
    font-family: 'Cinzel', serif;
    font-size: 1.05rem;
    color: #fff;
}

.user-msg {
    align-self: flex-end;
    background: var(--user-msg-bg);
    border-right: 3px solid #8e62d4;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 10px 15px;
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--gold);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Area */
.input-area {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    gap: 15px;
}

input[type="text"] {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px 20px;
    border-radius: 30px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: all 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--gold);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 15px var(--gold-glow);
}

button {
    background: transparent;
    border: 1px solid var(--gold);
    color: var(--gold);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
}

button:hover {
    background: var(--gold);
    color: var(--bg-color);
    box-shadow: 0 0 15px var(--gold);
    transform: scale(1.05);
}

button svg {
    width: 20px;
    height: 20px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2); 
}
::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3); 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.6); 
}

/* Tarot Table */
.tarot-table {
    flex: 1.2;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
}

.tarot-grid {
    display: grid;
    grid-template-columns: auto auto auto 3vw auto;
    grid-template-rows: auto auto auto auto;
    gap: 1.5vh;
    justify-content: center;
    align-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

.tarot-slot {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Deja pasar los clics a través de la caja invisible */
}

.tarot-card {
    height: min(18dvh, 150px);
    aspect-ratio: 2 / 3;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    perspective: 1000px;
    pointer-events: auto; /* Reactiva los clics solo en la carta visual */
}

.horizontal-card {
    transform: rotate(-90deg);
}

/* Posiciones de la Cruz Celta (Asignadas a los slots) */
.slot-pos-1 { grid-column: 2; grid-row: 2 / span 2; align-self: center; justify-self: center; z-index: 1; }
.slot-pos-2 { grid-column: 2; grid-row: 2 / span 2; align-self: center; justify-self: center; z-index: 2; transition: transform 0.5s ease; }

.tarot-grid.card1-revealed .slot-pos-2 {
    transform: translateY(60px);
}
.slot-pos-3 { grid-column: 2; grid-row: 1; align-self: center; justify-self: center; }
.slot-pos-4 { grid-column: 2; grid-row: 4; align-self: center; justify-self: center; }
.slot-pos-5 { grid-column: 1; grid-row: 2 / span 2; align-self: center; justify-self: center; }
.slot-pos-6 { grid-column: 3; grid-row: 2 / span 2; align-self: center; justify-self: center; }
.slot-pos-7 { grid-column: 5; grid-row: 4; align-self: center; justify-self: center; }
.slot-pos-8 { grid-column: 5; grid-row: 3; align-self: center; justify-self: center; }
.slot-pos-9 { grid-column: 5; grid-row: 2; align-self: center; justify-self: center; }
.slot-pos-10 { grid-column: 5; grid-row: 1; align-self: center; justify-self: center; }

.tarot-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    border-radius: 10px;
}

.tarot-card:hover .tarot-card-inner {
    box-shadow: 0 0 15px var(--gold);
}

.tarot-card-front, .tarot-card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    border-radius: 10px;
    border: 2px solid var(--gold);
    transition: opacity 0.6s ease;
}

.tarot-card-front {
    background: linear-gradient(135deg, #2b1b3d, #1e1333);
    color: var(--gold);
    font-size: 2rem;
    position: relative;
    opacity: 1;
    z-index: 2;
}

.tarot-card-back {
    background-color: #1e1333;
    background-size: cover;
    background-position: center;
    color: var(--gold);
    font-family: 'Cinzel', serif;
    font-weight: bold;
    font-size: 0.8rem;
    border-color: var(--gold);
    opacity: 0;
    z-index: 1;
    align-items: flex-end; /* Empuja el texto hacia abajo */
    padding: 0;
    overflow: hidden;
}

.card-name-overlay {
    width: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 60%, transparent 100%);
    padding: 20px 5px 8px 5px;
    text-align: center;
    text-shadow: 1px 1px 4px black;
    line-height: 1.1;
}

.tarot-card.revealed .tarot-card-front {
    opacity: 0;
    pointer-events: none;
}

.tarot-card.revealed .tarot-card-back {
    opacity: 1;
    z-index: 3;
}

.card-number {
    position: absolute;
    top: 5px;
    left: 8px;
    font-size: 1rem;
    font-family: 'Cinzel', serif;
    color: rgba(212, 175, 55, 0.6);
}


.back-btn {
    margin: 10px auto;
    padding: 10px 20px;
    border-radius: 20px;
    width: auto;
    background: var(--gold);
    color: var(--bg-color);
    font-family: 'Inter', sans-serif;
    font-weight: bold;
}

/* ========================================= */
/* LANDING PAGE STYLES                       */
/* ========================================= */

.landing-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(circle at center, #1e1333, var(--bg-color));
}

.landing-header {
    text-align: center;
    margin-bottom: 50px;
}

.landing-header .header-avatar {
    width: 120px;
    height: 120px;
    margin: 0 auto 20px auto;
    border-radius: 50%;
    border: 3px solid var(--gold);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
    overflow: hidden;
}

.landing-header .header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.landing-header h1 {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    font-size: 3rem;
    margin: 0;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.landing-header p {
    color: #e0d8f0;
    font-size: 1.2rem;
    margin-top: 10px;
}

.landing-methods {
    display: flex;
    gap: 30px;
    max-width: 900px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}

.method-card {
    background: linear-gradient(145deg, #2b1b3d, #1a1025);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 15px;
    padding: 40px 30px;
    width: 300px;
    text-align: center;
    text-decoration: none;
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

.method-card:not(.disabled):hover {
    transform: translateY(-10px);
    border-color: var(--gold);
    box-shadow: 0 15px 40px rgba(212, 175, 55, 0.2);
}

.method-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(80%);
}

.method-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    text-shadow: 0 0 15px var(--gold);
}

.method-card h2 {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    margin: 0 0 15px 0;
    font-size: 1.5rem;
}

.method-card p {
    color: #bfaee3;
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0;
}

.badge {
    position: absolute;
    top: 20px;
    right: -30px;
    background: var(--gold);
    color: var(--bg-color);
    font-family: 'Inter', sans-serif;
    font-weight: bold;
    font-size: 0.7rem;
    padding: 5px 35px;
    transform: rotate(45deg);
    text-transform: uppercase;
}

.back-home-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    color: var(--gold);
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 10px 15px;
    background: rgba(43, 27, 61, 0.8);
    border: 1px solid var(--gold);
    border-radius: 8px;
    z-index: 1000;
    transition: all 0.3s ease;
}

.back-home-btn:hover {
    background: var(--gold);
    color: var(--bg-color);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
}

/* ========================================= */
/* RESPONSIVE DESIGN (MÓVILES)               */
/* ========================================= */
@media (max-width: 768px) {
    .chat-container {
        height: 100dvh; /* Aprovecha toda la pantalla dinámica */
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        border: none;
    }
    
    .chat-container.split-mode {
        max-width: 100%;
    }
    
    .chat-container.split-mode .panels-wrapper {
        flex-direction: column;
    }

    .tarot-card {
        height: min(15dvh, 25vw); /* Escala las cartas para que entren todas */
    }

    .tarot-grid {
        gap: 1.5vw;
    }

    .header {
        padding: 10px;
    }

    .header-info h1 {
        font-size: 1.2rem;
    }

    .avatar {
        width: 45px;
        height: 45px;
    }
    
    .input-area {
        padding: 10px;
    }
    
    .mobile-view-toggle {
        display: block !important;
        position: absolute;
        top: 85px; /* Debajo de la cabecera */
        right: 15px;
        z-index: 100;
        background: var(--gold);
        color: var(--bg-color);
        padding: 8px 15px;
        border-radius: 20px;
        font-family: 'Inter', sans-serif;
        font-weight: bold;
        font-size: 0.85rem;
        border: none;
        box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    }
    
    .chat-container.split-mode:not(.cards-expanded) .tarot-table {
        order: -1;
        flex: 0 0 35%; /* Cartas pequeñas arriba */
        padding: 5px;
    }
    
    .chat-container.split-mode:not(.cards-expanded) .messages-area {
        order: 1;
        flex: 1; /* Chat ocupa el resto */
        padding: 10px;
    }

    .chat-container.split-mode.cards-expanded .tarot-table {
        order: -1;
        flex: 1; /* Cartas ocupan toda la pantalla */
        padding: 10px;
    }
    
    .chat-container.split-mode.cards-expanded .tarot-card {
        height: min(20dvh, 32vw); /* Cartas más grandes al expandirse */
    }

    .chat-container.split-mode.cards-expanded .messages-area,
    .chat-container.split-mode.cards-expanded .input-area {
        display: none; /* Oculta el chat y el input */
    }
}
