/* --- Cài đặt chung & Font chữ --- */
body {
    background-color: #1a0f2d;
    background-image: url('../images/background.jpg');
    background-size: cover;
    background-attachment: fixed;
    color: #e0d8f0;
    font-family: 'Quicksand', sans-serif;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

h1, h2 {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.5);
}

/* --- Header & Footer --- */
header {
    width: 100%;
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5em;
    margin: 0;
}

header nav a {
    color: #d8c3ff;
    margin: 0 15px;
    text-decoration: none;
    font-size: 1.1em;
}

footer {
    margin-top: auto;
    padding-top: 20px;
    text-align: center;
    font-size: 0.9em;
    color: #a094b8;
}

/* --- Khu vực chính --- */
main {
    background-color: rgba(26, 15, 45, 0.8);
    backdrop-filter: blur(5px);
    border: 1px solid #4a3f6a;
    border-radius: 15px;
    padding: 30px;
    width: 100%;
    max-width: 800px;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
}

section {
    text-align: center;
}

/* --- Form lựa chọn --- */
.selection-box {
    margin: 20px 0;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 1.1em;
}

select {
    width: 100%;
    padding: 12px;
    background-color: #2c1d4a;
    border: 1px solid #4a3f6a;
    border-radius: 8px;
    color: #e0d8f0;
    font-size: 1em;
    font-family: 'Quicksand', sans-serif;
}

button {
    background: linear-gradient(45deg, #7b4397, #dc2430);
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 50px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(220, 36, 48, 0.5);
}

/* --- Khu vực kết quả --- */
#card-spread {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    flex-wrap: wrap; /* Cho phép xuống dòng trên màn hình nhỏ */
}

.card-placeholder {
    width: 120px;
    height: 200px;
    border: 2px dashed #4a3f6a;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-style: italic;
    color: #a094b8;
}

/* Lớp tiện ích để ẩn/hiện element */
.hidden {
    display: none;
}

/* --- Giai đoạn 2: Giao diện chọn bài (SỬA LỖI CLICK VÀ TỐI ƯU) --- */
#card-selection-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
}

/* Thêm mới: Wrapper để thiết lập vùng tương đối */
.deck-container {
    position: relative;
    width: 100%;
    height: 580px; /* Tăng chiều cao để chứa cả bộ bài và hàng chờ */
}

#card-deck {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 380px; /* Chiều cao của khu vực trải bài */
}

.card-back {
    width: 90px;
    height: 150px;
    background-image: url('../images/card-back.jpg');
    background-size: cover;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.7), -2px 0 3px rgba(0,0,0,0.5) inset;
    cursor: pointer;
    transition: all 0.4s ease;
    opacity: 0;
    position: absolute;
    transform-origin: center center;
}

.card-back.deal {
    opacity: 1;
}

.card-back:hover {
    transform: translateY(-15px) scale(1.1) !important;
    z-index: 100;
    box-shadow: 0 10px 20px rgba(123, 67, 151, 0.5);
}

/* Lá bài gốc khi được chọn sẽ biến mất */
.card-back.selected {
    opacity: 0;
    transform: scale(0.8) !important;
    pointer-events: none;
}

/* Hàng chờ nằm ở dưới cùng của container */
#selected-cards-area {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    pointer-events: none;
}

/* Lá bài sao chép được đưa xuống hàng chờ */
.card-staging {
    width: 100px; /* Kích thước to hơn một chút trong hàng chờ */
    height: 167px;
    background-image: url('../images/card-back.jpg');
    background-size: cover;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    opacity: 0;
    transform: translateY(-200px); /* Vị trí bắt đầu của animation */
    animation: dropIn 0.6s forwards cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dropIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#selection-prompt {
    margin-top: 10px;
    font-size: 1.2em;
    font-weight: bold;
    color: #e0d8f0;
}


/* --- Giai đoạn 3: Giao diện kết quả (ĐÃ TỐI ƯU) --- */
#card-spread-summary {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.summary-card {
    text-align: center;
}

.summary-card img {
    width: 100px;
    border-radius: 8px;
}

.summary-card p {
    margin-top: 8px;
    font-size: 0.9em;
}

#view-interpretation-button {
    background: linear-gradient(45deg, #c31432, #240b36);
}

#interpretation-details {
    text-align: left;
    margin-top: 30px;
}

/* Bố cục diễn giải mới */
.interpretation-item {
    background-color: rgba(14, 5, 27, 0.4);
    border-left: 4px solid #a134d6;
    padding: 20px;
    margin-bottom: 25px;
    border-radius: 0 8px 8px 0;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.interpretation-item img {
    width: 90px;
    border-radius: 6px;
    flex-shrink: 0; /* Ngăn ảnh bị co lại */
}

.interpretation-item .text-content h3 {
    margin-top: 0;
    color: #f0eaff;
}

.interpretation-item .text-content p {
    margin-bottom: 5px;
    line-height: 1.6;
}

/* --- CSS CHO LÁ BÀI INTRO (HIỆU ỨNG SHAKE) --- */
.intro-card-container {
    margin: 30px 0;
    display: flex;
    justify-content: center;
}

.intro-card-container img {
    width: 140px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: shakeAnimation 5s ease-in-out infinite; /* Áp dụng animation shake */
}

/* Định nghĩa animation shake nhẹ nhàng */
@keyframes shakeAnimation {
    0%, 100% { transform: rotate(0); }
    10%, 30%, 50%, 70% { transform: rotate(-1deg); }
    20%, 40%, 60%, 80% { transform: rotate(1deg); }
    90% { transform: rotate(0); }
}

/* --- CSS CHO TRANG BÓI BÀI HÔM NAY (PHIÊN BẢN CUỐI CÙNG) --- */
.daily-categories {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 30px auto; /* Giảm margin để bớt khoảng trống */
    flex-wrap: wrap;
}
.category-card {
    position: relative;
    width: 120px;
    padding: 10px 6px 12px;
    border-radius: 16px;
    background: transparent;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
    box-shadow: 0 0 0 1px rgba(148, 163, 255, .25); /* Viền mờ ban đầu */
    display: flex;
    flex-direction: column;
    align-items: center;
}
.category-card .card-image {
    width: 100%;
    height: 184px; /* Giữ chiều cao để ảnh đẹp */
    background-image: url('../images/card-back.jpg');
    background-size: cover;
    border-radius: 12px;
    margin-bottom: 10px;
}
.category-card span {
    font-size: 1em;
    font-weight: 500;
    color: #e0d8f0;
    transition: color .2s ease;
}

/* Hiệu ứng khi hover */
.category-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, .5);
}

/* HIỆU ỨNG KHI CHỌN (is-active) */
.category-card.selected {
    background: radial-gradient(circle at 50% 0%, #f97316 0, #581c87 40%, transparent 70%);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .7);
    transform: translateY(-6px) scale(1.04);
}

.category-card.selected span {
    color: #fff;
    font-weight: bold;
}

#daily-shuffle-button:disabled {
    background: #555;
    cursor: not-allowed;
    transform: scale(1);
    box-shadow: none;
}

/* --- CSS CHO GIAO DIỆN KẾT QUẢ BÓI BÀI HÔM NAY (TỐI ƯU) --- */
#result-section #daily-card-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
}
#result-section #daily-card-display img {
    width: 180px; /* Tăng kích thước lá bài kết quả */
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
#result-section #daily-card-display p {
    margin-top: 15px;
    font-size: 1.2em;
    font-weight: bold;
}
/* Style cho các nút trong khu vực kết quả */
#result-section button {
    margin: 10px;
    min-width: 250px;
}
#daily-interpretation-details {
    background-color: #fff;
    color: #333;
    border-radius: 15px;
    padding: 30px;
    margin: 20px 0;
    text-align: left;
    border: 4px solid #e6cfff;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}
#daily-interpretation-details h3 {
    color: #1a0f2d;
    font-family: 'Playfair Display', serif;
    font-size: 1.8em;
    margin-top: 0;
}
#daily-interpretation-details p {
    line-height: 1.7;
    margin-bottom: 1em;
}
#daily-interpretation-details hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 20px 0;
}
#reset-button {
    background: none;
    border: 2px solid #7b4397;
    color: #e0d8f0;
}
#reset-button:hover {
    background-color: #7b4397;
    color: #fff;
}

/* --- THÊM MỚI CHO BỘ BÀI TÂY 52 LÁ --- */


/* Class riêng cho mặt sau bài tây */
.card-back.playing-card {
    background-image: url('../images/card-back-bai-tay-52-la.jpg') !important;
    /* Bài tây thường thon dài hơn Tarot một chút, hoặc bạn giữ nguyên kích thước */
    /* width: 90px; height: 150px; (Giữ nguyên hoặc chỉnh nếu cần) */
}

/* Áp dụng ảnh bài tây cho các lá đang nằm ở hàng chờ (selected area) */
.card-staging.playing-card {
    background-image: url('../images/card-back-bai-tay-52-la.jpg') !important;
    width: 80px;  /* Đảm bảo kích thước đồng nhất với bộ bài */
    height: 125px;
    background-size: cover;
}

/* Tùy chỉnh input cho giống hình mẫu của bạn hơn */
.custom-input-group {
    background: #fff;
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
}

.custom-input-group input, 
.custom-input-group select {
    border: none;
    background: transparent;
    color: #333; /* Chữ màu đen trên nền trắng */
    font-weight: bold;
    width: 100%;
    padding: 15px;
    outline: none;
}

/* Nút bấm style tím giống hình */
.btn-purple-gradient {
    background: linear-gradient(90deg, #8A2BE2, #9400D3);
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.6);
    width: 100%;
    border-radius: 10px;
    padding: 15px;
    margin-top: 10px;
}

/* Hiệu ứng cho link trong menu */
header nav a {
    position: relative;
    transition: color 0.3s ease;
}

header nav a:hover {
    color: #ffffff;
    text-shadow: 0 0 5px #a134d6;
}

/* Tự động highlight link tương ứng với trang hiện tại (nếu bạn thêm class="active" vào HTML) */
header nav a.active {
    color: #fff;
    font-weight: bold;
    border-bottom: 2px solid #a134d6;
    padding-bottom: 5px;
}

/* --- CSS RIÊNG CHO TRANG BÀI TÂY 52 LÁ --- */

/* 1. Input/Select màu trắng bo tròn */
.custom-select-wrapper {
    margin-bottom: 15px;
    position: relative;
}

.white-style-input {
    width: 100%;
    padding: 15px 20px;
    border-radius: 8px;
    border: none;
    background-color: #ffffff;
    color: #333333; /* Chữ màu đen đậm */
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: 1em;
    appearance: none; /* Ẩn mũi tên mặc định của trình duyệt */
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    outline: none;
    cursor: pointer;
}

/* Thêm mũi tên chỉ xuống giả cho đẹp */
.custom-select-wrapper::after {
    content: '▼';
    font-size: 0.8em;
    color: #666;
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* 2. Nút Xào Bài màu tím sáng (Bright Purple) */
.btn-purple-bright {
    width: 100%;
    background: linear-gradient(90deg, #b02bf2, #7b2bf2); /* Tím sáng */
    color: white;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(176, 43, 242, 0.5);
    margin-top: 10px;
}

.btn-purple-bright:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 30px rgba(176, 43, 242, 0.8);
}

/* 3. Nút Xem Luận Giải màu đỏ/nâu */
.btn-red-gradient {
    background: linear-gradient(90deg, #a61e3d, #63142e);
    min-width: 200px;
    border-radius: 8px;
}

/* 4. Nút Bói Lại (Viền) */
.btn-outline {
    background: transparent;
    border: 2px solid #7b4397;
    min-width: 150px;
    border-radius: 8px;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* 5. Chỉnh lại kích thước ảnh lá bài 52 lá */
/* Ảnh bài tây thường hẹp hơn Tarot */
.card-back.playing-card {
    background-image: url('../images/card-back-bai-tay-52-la.jpg') !important;
    width: 80px;  /* Nhỏ hơn Tarot 1 chút để vừa 52 lá */
    height: 125px;
}

/* Kết quả hiển thị to rõ */
.summary-card img {
    width: 120px !important; /* Ảnh kết quả to hơn */
    height: auto;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}