/* --- Global Reset & Mystic Background --- */
body {
    background-color: #050510;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(76, 29, 149, 0.4) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.3) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(30, 30, 60, 0.5) 0%, transparent 70%);
    color: #ecebff;
    font-family: 'Quicksand', sans-serif;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

/* --- Full Width Container --- */
.tarot-page-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

/* --- Glassmorphism Chat Wrapper --- */
.tarot-chat-wrapper {
    width: 95%;
    max-width: 1600px;
    height: 90vh;
    background: rgba(20, 20, 35, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow:
        0 0 40px rgba(124, 58, 237, 0.15),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* --- Header --- */
.tarot-header {
    text-align: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 10;
}

.tarot-header h2 {
    font-family: 'Cinzel', serif;
    color: #d8b4fe;
    margin: 0;
    font-size: 2.2rem;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.6);
}

.tarot-header p {
    font-size: 1rem;
    color: #a78bfa;
    opacity: 0.8;
    margin-top: 5px;
    letter-spacing: 1px;
}

/* --- Chat Area --- */
.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scrollbar-width: thin;
    scrollbar-color: #4c1d95 rgba(0, 0, 0, 0.3);
    position: relative;
}

/* Scrollbar Styling */
.chat-box::-webkit-scrollbar {
    width: 8px;
}

.chat-box::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.chat-box::-webkit-scrollbar-thumb {
    background-color: #4c1d95;
    border-radius: 4px;
}

/* --- Messages --- */
.message {
    max-width: 70%;
    padding: 15px 25px;
    border-radius: 18px;
    font-size: 1.1rem;
    line-height: 1.6;
    position: relative;
    animation: fadeIn 0.4s ease-out;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.system-message {
    align-self: center;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.3);
    color: #d8b4fe;
    text-align: center;
    font-style: italic;
    width: fit-content;
    max-width: 90%;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.1);
}

.bot-message {
    align-self: flex-start;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    color: #e0e7ff;
    border-bottom-left-radius: 2px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(167, 139, 250, 0.2);
}

.bot-message strong {
    color: #c4b5fd;
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #7c3aed 0%, #be185d 100%);
    color: #ffffff;
    border-bottom-right-radius: 2px;
    box-shadow: 0 4px 15px rgba(190, 24, 93, 0.4);
    text-align: right;
}

/* --- Reading Selection Options --- */
.reading-selection-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.reading-category {
    margin-bottom: 20px;
}

.category-title {
    color: #d8b4fe;
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(168, 85, 247, 0.3);
    padding-bottom: 5px;
    text-shadow: 0 0 5px rgba(168, 85, 247, 0.5);
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.reading-btn {
    background: rgba(30, 27, 75, 0.6);
    border: 1px solid rgba(168, 85, 247, 0.4);
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    text-align: left;
}

.reading-btn:hover {
    background: rgba(168, 85, 247, 0.2);
    border-color: #d8b4fe;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(124, 58, 237, 0.3);
}

.btn-icon {
    font-size: 1.5rem;
}

.btn-text strong {
    display: block;
    color: #ecebff;
    font-size: 1rem;
    margin-bottom: 3px;
}

.btn-text small {
    color: #a78bfa;
    font-size: 0.8rem;
    display: block;
    line-height: 1.2;
}

/* --- DECK PILE (Hidden until reading) --- */
#deck-pile {
    position: absolute;
    bottom: 100px;
    left: 50px;
    width: 100px;
    height: 160px;
    background: #1e1b4b;
    border: 2px solid #a855f7;
    border-radius: 8px;
    box-shadow: 5px 5px 0 #312e81, 10px 10px 0 #1e1b4b;
    display: none;
    /* Shown during shuffle */
    z-index: 100;
}

#deck-pile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('cards/card_back.jpg');
    background-size: cover;
    border-radius: 6px;
}

/* --- 3D Card Flip Visuals --- */
.card-spread {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
    perspective: 1000px;
    min-height: 260px;
    /* Reserve space */
}

.tarot-card-container {
    width: 140px;
    height: 240px;
    perspective: 1000px;
    flex-shrink: 0;
    margin-bottom: 15px;
    transition: all 0.5s ease;
    opacity: 0;
    /* Hidden initially, dealt by JS */
}

.spread-large .tarot-card-container {
    width: 100px;
    height: 170px;
}

.spread-large .card-name {
    font-size: 0.7rem;
    padding: 5px;
}

.tarot-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

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

.tarot-card-front,
.tarot-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 8px;
    border: 1px solid #a855f7;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
    background-size: cover;
    background-position: center;
}

.tarot-card-front {
    background-color: #1e1b4b;
}

.tarot-card-back {
    background-color: #1e1b4b;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
}

.tarot-card-back::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 100%);
    z-index: 1;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

.tarot-card-back .card-name {
    font-family: 'Cinzel', serif;
    color: #fff;
    font-size: 0.85rem;
    font-weight: bold;
    z-index: 2;
    padding: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 1);
    width: 100%;
}

/* Animation: Deal from Deck */
@keyframes dealCard {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.8);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

#user-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px 25px;
    border-radius: 30px;
    color: white;
    font-size: 1rem;
    font-family: 'Quicksand', sans-serif;
    outline: none;
    transition: all 0.3s ease;
}

#user-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: #a78bfa;
    box-shadow: 0 0 15px rgba(167, 139, 250, 0.2);
}

#send-btn {
    background: linear-gradient(45deg, #7c3aed, #d946ef);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

#send-btn:disabled,
#user-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

#send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
    filter: brightness(1.2);
}

/* --- Typing Animation --- */
.typing-indicator {
    display: none;
    align-self: flex-start;
    background: rgba(30, 27, 75, 0.8);
    padding: 12px 20px;
    border-radius: 20px;
    margin-bottom: 20px;
    align-items: center;
    gap: 6px;
    width: fit-content;
    border: 1px solid rgba(167, 139, 250, 0.1);
}

.dot {
    width: 6px;
    height: 6px;
    background-color: #a78bfa;
    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);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}