.huyen-khong-container { 
    max-width: 900px; 
    margin: 20px auto; 
    font-family: sans-serif; 
    line-height: 1.6; 
    padding: 0 15px; 
}
.huyen-khong-form-main{
    width: 100%;
    display: flex;
    justify-content: center;
}
.huyen-khong-form { 
    background: #f9f9f9; 
    border: 1px solid #ddd; 
    padding: 20px; 
    border-radius: 8px; 
    max-width: 700px;
    margin-bottom: 30px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
}
    .hk-form-row { 
        display: flex; 
        flex-wrap: wrap; 
        gap: 10px; 
        margin-bottom: 15px; 
    }
    .hk-form-row label{
        font-size: 16pt;
        font-weight: bold;
        margin-bottom: 10px;
    }
    #birth_date_display {
    width: 100% !important;
    box-sizing: border-box; /* tránh bị tràn do padding/border */
}

    .radio-sex{
         font-size: 18pt;
        font-weight: 400 !important;
    }
    .hk-form-group { flex: 1; min-width: 200px; }
    .hk-form-group label { display: block; font-weight: bold; margin-bottom: 5px;font-size: 0.9rem; }
    .hk-form-group input, .hk-form-group select { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
    .hk-grid-wrapper { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; max-width: 600px; height: auto; aspect-ratio: 1 / 1; border: 3px solid #333; margin: 30px auto; }
    .hk-palace { position: relative; border: 1px solid #ccc; text-align: center; display: flex; align-items: center; justify-content: center; }
    .hk-palace .palace-name { position: absolute; bottom: 5px; left: 0; right: 0; font-size: 12px; color: #555; font-weight: bold; }
    .hk-palace .star-v { 
            font-size: 8rem;
            font-weight: bold;
            color: #e6e6e6;
            opacity: 0.5;
    }
    .hk-palace .star-s { position: absolute; top: 5px; left: 8px; font-size: clamp(1rem, 5vw, 2.8rem); font-weight: bold; color: #8B4513; }
    .hk-palace .star-h { position: absolute; top: 5px; right: 8px; font-size: clamp(1rem, 5vw, 2.8rem); font-weight: bold; color: #4682B4; }
    
    .hk-palace.is-facing { background-color: #e0f7fa; }
    .hk-palace.is-sitting { background-color: #fff8e1; }
    .hk-palace .direction-label {             
        position: absolute;
        color: rgba(0, 0, 0, 0.7);
        font-size: 0.9rem;
        font-weight: bold;
        z-index: 1;
        bottom: 5px;
        text-align: center;
        width: 100%;
    }
    .stars-cell { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
    .stars-cell span[class*='star-'] { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; color: white; font-weight: bold; font-size: 14px; flex-shrink: 0; }
    .star-v-9 { background-color: #9932CC; } .star-s-9 { background-color: #8B4513; } .star-h-9 { background-color: #4682B4; } .star-n-9 { background-color: #2E8B57; }
    .hk-advice ul { margin: 0; padding-left: 20px; } .hk-advice li { margin-bottom: 8px; }
    .rating { font-weight: bold; display: block; margin-bottom: 8px; text-transform: uppercase;padding: 10px;}
    .rating-dai-cat { color: #d00000; } .rating-thu-cat { color: #007f5f; } .rating-binh-thuong { color: #5f5f5f; } .rating-hung { color: #ff8c00; } .rating-dai-hung { color: #b20000; }
        
        
      

        .center-palace-info {
                position: absolute;
                top: 50px;
                left: 0;
                right: 0;
                z-index: 9;
                font-size: clamp(8px, 2.5vw, 14px);
                line-height: 1.3;
                color: #333;
                font-weight: bold;
                text-align: center;
        }

        .annual-center-info {
            font-weight: bold;
            font-size: clamp(12px, 4vw, 16px);
            line-height: 1.4;
            text-align: center;
            color: inherit;
            opacity: 0.8;
            z-index: 1;
            position: relative;
        }
        
        .hk-annual-grid-wrapper {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            width: 100%;
            max-width: 500px;
            height: auto;
            aspect-ratio: 1 / 1;
            border: 2px solid #666;
            margin: 20px auto;
        }
        .hk-annual-palace {
            border: 1px solid #ccc;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            position: relative;
            background-color: #fdfdfd;
        }
        #hk-results-wrapper.loading-results::after {
            content: 'Đang tính toán...';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(255, 255, 255, 0.8);
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 1.2em;
            font-weight: bold;
            z-index: 10;
        }
        #hk-results-wrapper {
            position: relative; /* Cần thiết cho ::after */
        }
        
        /* Định nghĩa màu nền và màu chữ cho từng Hành */
        .hanh-kim { background-color: #f1f3f4; color: #202124; }
        .hanh-moc { background-color: #e6f4ea; color: #137333; }
        .hanh-thuy { background-color: #e8f0fe; color: #1967d2; }
        .hanh-hoa { background-color: #fce8e6; color: #d93025; }
        .hanh-tho { background-color: #feefc3; color: #b06000; }
        
        /* =================================== */
        /* === CSS MỚI THEO YÊU CẦU === */
        /* =================================== */

        /* 1. ĐỒ HÌNH TINH BÀN NHÀ */

        /* Container cho Niên tinh và Mệnh */
        .annual-star-group {
            position: absolute;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            align-items: baseline;
            gap: 4px;
            line-height: 1;
        }

        /* Niên tinh (số) - bỏ định vị tuyệt đối cũ, màu sắc sẽ kế thừa */
        .annual-star-group .star-n {
            position: static;
            transform: none;
            font-size: clamp(1.5rem, 4.5vw, 3rem);
            color: inherit;
            font-weight: bold;
        }

        /* Mệnh (chữ) - bỏ định vị tuyệt đối cũ, màu sắc kế thừa */
        .annual-star-group .palace-element {
            position: static;
            transform: none;
            font-size: clamp(0.7rem, 2.5vw, 1rem);
            opacity: 0.7;
            font-weight: normal;
            color: inherit;
        }

        /* 2. ĐỒ HÌNH NIÊN VẬN */
        
        /* Số Lạc Thư mờ ở nền */
        .hk-annual-palace .star-v {
            font-size: 6rem;
            font-weight: bold;
            color: #e6e6e6;
            opacity: 0.5;
            position: absolute;
            z-index: 0;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        /* Tên phương vị ở dưới */
        .hk-annual-palace .direction-label {
            position: absolute;
            bottom: 5px;
            font-size: 12px;
            font-weight: bold;
            color: #555;
            z-index: 1;
        }

        /* Container cho sao và mệnh */
        .hk-annual-palace .star-container {
            display: flex;
            align-items: baseline;
            justify-content: center;
            gap: 5px;
            z-index: 1;
        }

        /* Sao năm (số) */
        .hk-annual-palace .star {
            font-size: clamp(1.5rem, 6vw, 3rem);
            font-weight: bold;
            color: inherit;
            opacity: 0.85;
        }
        
        /* Mệnh của sao (chữ) */
        .hk-annual-palace .element-beside {
            font-size: clamp(0.7rem, 2.5vw, 1rem);
            font-weight: normal;
            color: inherit;
            opacity: 0.7;
        }
        /* === Bảng kết quả trên Mobile === */
    
        /* Thêm vào trong thẻ <style> của bạn */
        .annual-center-top-text {
            position: absolute;
            top: 8px; /* Đặt ở phía trên */
            left: 0;
            right: 0;
            font-size: clamp(10px, 2.5vw, 12px); /* Cỡ chữ nhỏ */
            font-weight: bold;
            z-index: 2;
            color: inherit;
            opacity: 0.9;
            text-align: center;
        }
        /* Thêm vào cuối file huyen-khong-style.css */
/* Tạo kiểu cho nút bấm "Xem kết quả" */
.hk-button {
    background-color: #0073aa;
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.hk-button:hover {
    background-color: #005a87;
}
/* === Màu sắc cho Đánh giá Luận giải === */
.rating-dai-cat, .rating-cat { 
    color: #28a745; /* ✔️ Màu xanh lá cây tốt đẹp */
}
.rating-binh { 
    color: #5f5f5f; /* Màu xám trung tính */
}
.rating-hung { 
    color: #ffc107; /* ⚠️ Màu vàng cảnh báo */
}
.rating-dai-hung { 
    color: #dc3545; /* ❌ Màu đỏ nguy hiểm */
}
/*
 * ==================================================================
 * CSS FIX: Chống ghi đè CSS cho Bảng Luận Giải trên Desktop
 * ==================================================================
 */

/*
 * ==================================================================
 * CSS HOÀN CHỈNH CHO BẢNG LUẬN GIẢI
 * (Tách biệt hoàn toàn giao diện Mobile và Desktop)
 * ==================================================================
 */

/* === Giao diện MÁY TÍNH (Từ 769px trở lên) === */
@media (min-width: 769px) {
    .huyen-khong-container .hk-results-table {
        display: table !important;
        width: 100%;
        border-collapse: collapse;
        table-layout: fixed;
    }

    .huyen-khong-container .hk-results-table th,
    .huyen-khong-container .hk-results-table td {
        display: table-cell !important;
        padding: 12px;
        border: 1px solid #ddd;
        vertical-align: top;
        word-wrap: break-word;
    }

    .huyen-khong-container .hk-results-table th:nth-of-type(1),
    .huyen-khong-container .hk-results-table td:nth-of-type(1) {
        width: 16%;
    }

    .huyen-khong-container .hk-results-table th:nth-of-type(2),
    .huyen-khong-container .hk-results-table td:nth-of-type(2) {
        width: 18%;
        text-align: center;
    }

    .huyen-khong-container .hk-results-table th:nth-of-type(3),
    .huyen-khong-container .hk-results-table td:nth-of-type(3) {
        width: 66%;
    }
}

#hk-results-wrapper h3, h4{
    margin-bottom: 25px !important;
}
/* === Giao diện MOBILE (Từ 768px trở xuống) === */
@media (max-width: 768px) {
    .hk-results-table{
        border: none !important;
    }
    /* Ẩn tiêu đề của bảng */
    .hk-results-table thead {
        display: none;
    }
    .huyen-khong-container{
        padding: 0;
    }
    #hk-results-wrapper h3,h4{
        text-align: center !important;
        margin-bottom: 15px !important;
    }
    /* Biến mỗi hàng <tr> thành một "card" */
    .hk-results-table tr {
        display: block;
        border: none !important;
        border-radius: 5px;
        margin-bottom: 20px;
        padding: 0;
        box-shadow: none;
    }

    /* Mỗi ô <td> sẽ là một dòng riêng, không có padding thừa */
    .hk-results-table td {
        display: block;
        width: 100% !important;
        padding: 0px!important;
        text-align: left;
        border: none !important;
        position: static; /* Đặt lại position */
    }

    .hk-results-table tr td:last-child {
        border-bottom: none;
    }

    /* Tạo label cho mỗi dòng từ thuộc tính data-label */
    .hk-results-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: bold;
        margin: 15px 0 10px;
        color: #0067e1;
        font-size: 1.1rem;
    }

    /* Căn chỉnh lại cho các ô có nội dung dài */
    .hk-results-table .hk-advice ul {
        padding-left: 15px;
        margin: 5px 0 0;
    }

    .hk-results-table .stars-cell {
        justify-content: flex-start;
    }

    /* Định dạng cho các mục luận giải li */
    .hk-advice ul li {
        padding-bottom: 10px;
        margin-bottom: 10px;
        border-bottom: 1px dashed #e0e0e0;
    }

    .hk-advice ul li:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    /* Biến các nhãn (in đậm) thành một dòng riêng */
    .hk-advice ul li b {
        display: block;
        margin-bottom: 6px;
    }
}
/*
 * ==================================================================
 * CSS CHO MA TRẬN TƯƠNG HỢP (TÍNH NĂNG MỚI)
 * ==================================================================
 */

.hk-matrix-table {
    width: 100%;
    margin-top: 20px;
    border-collapse: collapse;
    font-size: 15px;
}

.hk-matrix-table th,
.hk-matrix-table td {
    border: 1px solid #ddd;
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
}

.hk-matrix-table thead th {
    background-color: #f2f2f2;
}

/* Định dạng màu sắc cho kết luận */
.ket-luan-tot { color: #28a745; font-weight: bold; }
.ket-luan-xau { color: #dc3545; font-weight: bold; }
.ket-luan-can-than { color: #ffc107; color: #333; }


/* Giao diện Ma Trận trên Mobile */
@media (max-width: 768px) {
    .hk-matrix-table thead {
        display: none;
    }

    .hk-matrix-table tr {
        display: block;
        border: 1px solid #e0e0e0;
        border-radius: 5px;
        margin-bottom: 15px;
        padding: 10px;
    }

    .hk-matrix-table td {
        display: block;
        text-align: right;
        padding-left: 100px;
        position: relative;
        border-bottom: 1px dashed #eee;
    }
    
    .hk-matrix-table tr td:last-child {
        border-bottom: none;
    }

    .hk-matrix-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 90px;
        text-align: left;
        font-weight: bold;
    }
    .mq-direction {
    font-size: 0.55rem;
}
}
/*
 * ==================================================================
 * CSS CHO SƠ ĐỒ MỆNH QUÁI (TÍNH NĂNG MỚI)
 * ==================================================================
 */

.hk-menh-quai-grid-wrapper {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    max-width: 450px; /* Giới hạn chiều rộng tối đa */
    aspect-ratio: 1 / 1;
    border: 2px solid #333;
    margin: 25px auto;
    font-weight: bold;
}

.mq-palace {
    position: relative;
    border: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
    box-sizing: border-box;
}

/* Màu nền cho cung tốt/xấu */
.mq-tot { background-color: #e6f4ea; }
.mq-xau { background-color: #fce8e6; }
.mq-trung-cung { background-color: #feefc3; }

/* Định dạng các thành phần bên trong */
.mq-main-name {
    font-size: clamp(1rem, 4vw, 1.5rem);
    line-height: 1.2;
}
.mq-tot .mq-main-name { color: #137333; }
.mq-xau .mq-main-name { color: #d93025; }

/* Số cung Lạc Thư to, mờ, ở giữa */
.mq-lo-shu-num {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(3rem, 15vw, 5.5rem); /* Chữ to hơn */
    color: #000;
    opacity: 0.1; /* Mờ đi */
    z-index: 0;
}
.mq-gua-name {
    font-size: 0.8rem;
    color: #555;
    margin-top: 5px;
}

.mq-direction {
    position: absolute;
    bottom: 5px;
    left: 0;
    right: 0;
    font-size: 0.75rem;
    color: #777;
    text-align: center;
}
/* CSS cho các trường nhập liệu ngày/tháng */
.hk-date-selector {
    display: flex;
    gap: 10px;
}
.margin-15-tb {
    margin: 15px  0;
}
.hk-date-selector .hk-form-group {
    min-width: 0;
}
.hk-form-col-50{
    width: 48%;
}
.radio-sex{
    display: flex;
    gap: 6px;
}
.hk-date-selector .lvn-pro-form__date-group input[type=text]{
    width: 100% !important;
}
.lvn-pro-form__date-group{
    width: 90%;
}
.hk-form-col-40{
    width: 31%;
}
.hk-form-col-60{
    width: 60%;
}

/* CSS cho các mục phân tích nâng cao trong bảng luận giải */
.hk-advice .advanced-analysis-item {
    padding-left: 15px;
    border-left: 3px solid #0073aa;
    margin-top: 10px;
    font-size: 0.95em;
}
/*
 * ==================================================================
 * CSS FIX: Sắp xếp lại Form nhập liệu
 * ==================================================================
 */

/* Căn chỉnh các nhóm trong một hàng */
.hk-form-row {
    align-items: flex-end; /* Căn các mục theo đáy, giúp các ô input thẳng hàng */
}

/* Căn chỉnh nhóm ngày tháng và giới tính */
.hk-date-selector {
    display: flex;
    align-items: center; /* Căn các mục bên trong theo chiều dọc */
    gap: 10px;
}

/* Sắp xếp các nút radio giới tính nằm ngang */
.gender-options {
    display: flex;
    gap: 15px;
    white-space: nowrap; /* Tránh chữ bị xuống dòng */
}
@media (max-width: 768px) {
    .annual-star-group .star-n { 
        font-size: 1.5rem; 
        bottom: 22px;
    }
    .hk-form-col-60, .hk-form-col-40 ,.lvn-pro-form__date-group{
        width: 100%;
    }
    .palace-element{
        display: none;
    }
    .annual-star-group{
        bottom: 20px;
    }
    .center-palace-info{
        display: none;
    }
    .hk-annual-palace .star-v { font-size: 3rem; }
    .annual-center-top-text {
    font-size: 0.5rem !important; /* Cỡ chữ nhỏ */
    }
.hk-annual-palace .element-beside {
    display: none;
}

    /* Sửa lỗi hiển thị cho phần Luận Giải trên mobile */
    .hk-advice ul li {
        padding-bottom: 10px; /* Tăng khoảng cách giữa các mục */
        margin-left: 5px !important;
        margin-bottom: 10px;
        border-bottom: 1px dashed #e0e0e0;

    }

    .hk-advice ul li:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    /* Quan trọng: Biến các nhãn (in đậm) thành một dòng riêng */
    .hk-advice ul li b {
        display: block; /* Buộc nhãn chiếm 100% chiều rộng và xuống dòng */
        margin-bottom: 6px; /* Tạo khoảng cách với nội dung bên dưới */
        margin-left: -5px;
    }
}
