/* --- Cài đặt chung --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-image: url('https://images.pexels.com/photos/176851/pexels-photo-176851.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2');
    color: #333;
    margin: 0;
    padding: 20px;
}

.container {
    background-color: #fff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    max-width: 900px;
    width: 100%;
    margin: auto;
    text-align: center;
}

h1 {
    color: #c0392b;
    margin-bottom: 10px;
}

/* --- Style cho nút Gieo Quẻ Ngẫu Nhiên --- */
.random-button {
    background-color: #c0392b;
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 18px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    margin-top: 10px;
    margin-bottom: 20px;
    font-weight: bold;
}

.random-button:hover {
    background-color: #a93226;
    transform: scale(1.05);
}

/* --- Style cho lưới lá xăm --- */
.xam-container {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 15px;
    margin-top: 30px;
    padding: 10px;
    justify-content: center;
}

/* --- Style cho từng lá xăm --- */
.xam-item {
    background-image: url('https://tarot.io.vn/100-que-quan-thanh/quanthanh.jpg'); 
    background-size: cover;
    background-position: center;
    
    color: #fff;
    font-size: 1.6em;
    font-weight: bold;
    border: 2px solid #a93226;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    text-shadow: 0px 0px 6px rgba(0, 0, 0, 1);

    position: relative;
    z-index: 1;

    aspect-ratio: 2 / 3;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
}

.xam-item::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    z-index: -1;
}


.xam-item:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 15px rgba(0,0,0,0.3);
}

.xam-item.highlight {
    box-shadow: 0 0 25px #27ae60;
    border-color: #27ae60;
    transform: scale(1.1);
}

/* --- Style cho Modal (cửa sổ pop-up) --- */
.modal {
    display: none; position: fixed; z-index: 1000;
    left: 0; top: 0; width: 100%; height: 100%;
    overflow: auto; background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background-color: #fff; margin: 10% auto;
    padding: 20px 30px 30px 30px; border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    width: 80%; max-width: 600px; position: relative;
    animation: slideIn 0.4s;
}

@keyframes slideIn { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.close-button {
    color: #aaa; float: right; font-size: 28px; font-weight: bold;
}
.close-button:hover, .close-button:focus {
    color: black; text-decoration: none; cursor: pointer;
}

#ketQua { margin-top: 0; text-align: left; }
#soQue { color: #c0392b; text-align: center; }
#loaiQue { text-align: center; font-weight: bold; font-size: 1.2em; margin-bottom: 20px; }
.noiDungQue h3 { color: #2980b9; border-bottom: 1px solid #ddd; padding-bottom: 5px; }
#baiThoQue, #giaiNghia { line-height: 1.6; white-space: pre-wrap; }


/**************************************************/
/* --- PHẦN RESPONSIVE CHO THIẾT BỊ DI ĐỘNG --- */
/* (Bản cập nhật hoàn chỉnh dựa trên phân tích)   */
/**************************************************/
@media screen and (max-width: 768px) {

    /* --- 1. Áp dụng bố cục "tràn viền" cho container --- */
    body {
        padding: 0; /* Xóa padding của body để container có thể tràn hết viền */
    }

    .container {
        width: 100%;
        min-height: 100vh;
        padding: 20px 15px;     /* Đặt padding bên trong để nội dung không bị sát lề */
        border-radius: 0;       /* Bỏ bo góc trên di động */
        box-shadow: none;         /* Bỏ đổ bóng */
        box-sizing: border-box; /* QUAN TRỌNG: Để padding không làm container rộng hơn 100% */
    }

    h1 {
        font-size: 1.8em; 
    }

    /* --- 2. Tinh chỉnh lại lưới lá xăm cho linh hoạt hơn --- */
    .xam-container {
        /* Vẫn giữ auto-fit để tương thích tốt nhất với mọi kích thước điện thoại */
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
        gap: 10px; /* Tăng khoảng cách một chút cho thoáng */
    }

    .xam-item {
        font-size: 1.2em;
    }

    /* --- 3. Sửa lỗi tràn viền cho Modal (Pop-up) --- */
    .modal-content {
        width: 92%;             /* Chiếm 92% chiều rộng màn hình, tạo khoảng hở 2 bên */
        margin: 15% auto;
        padding: 20px;
        box-sizing: border-box; /* QUAN TRỌNG: để padding không cộng dồn vào chiều rộng */
    }
}
/* --- Style cho Modal Nhập Key --- */
#keyInput {
    width: 100%;
    padding: 12px;
    margin-top: 15px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    box-sizing: border-box; /* Quan trọng để padding không làm thay đổi kích thước */
    text-align: center;
}

#submitKeyButton {
    width: 100%;
    margin-top: 0;
}