:root {
    --primary-color: #d32f2f;
    --bg-color: #000;
    /* Nền đen cho giống TV */
    --table-header-bg: #b71c1c;
    --text-color: #000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    /* Cấm cuộn */
    margin: 0;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* === TV BROADCAST MODE (FULL HEIGHT FILL) === */

.nav-bar {
    height: 4vh;
    background: #212121;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 11;
}

.nav-bar a {
    color: #fff;
    text-decoration: none;
    font-size: 1.8vh;
    font-weight: bold;
    text-transform: uppercase;
    padding: 0 10px;
}

.nav-bar a:hover {
    color: var(--primary-color);
}

header {
    height: 6vh;
    /* Header 6% */
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 10;
    flex-shrink: 0;
}

header h1 {
    font-size: 3vh;
    margin: 0;
    text-transform: uppercase;
    font-weight: 700;
}

.live-indicator {
    background: white;
    color: red;
    padding: 0.5vh 1.5vh;
    border-radius: 2vh;
    font-weight: bold;
    font-size: 1.8vh;
    display: flex;
    align-items: center;
}

.dot {
    height: 1vh;
    width: 1vh;
    background: red;
    border-radius: 50%;
    margin-right: 0.5vh;
    animation: blink 1s infinite;
}

@keyframes blink {
    50% {
        opacity: 0.5;
    }
}

#current-date {
    display: none;
}

main {
    flex: 1;
    /* Automatically fill remaining space */
    width: 100vw;
    padding: 0;
    display: block;
    overflow: hidden;
    /* Block để table fill height */
}

.lottery-table {
    width: 100%;
    height: 100%;
    /* Ép bảng cao bằng main */
    border-collapse: collapse;
    table-layout: fixed;
    border: 2px solid #b71c1c;
    background: white;
}

/* --- PHÂN CHIA CHIỀU CAO CÁC DÒNG (TỔNG ~ 100%) --- */

/* Tiêu đề bảng (Header Row) */
.lottery-table thead tr {
    height: 7%;
}

.lottery-table th {
    background: var(--table-header-bg);
    color: white;
    font-size: 2.5vh;
    font-weight: 700;
    text-transform: uppercase;
    border: 1px solid white;
}

.lottery-table th:first-child {
    width: 10%;
}


/* Các dòng nội dung (Body Rows) */
.lottery-table tbody tr {
    height: 9.2%;
    /* Mặc định các dòng chiếm 9.2% */
}

/* Giải Tư (Dòng 5) - Cần nhiều đất hơn (3 dòng chữ) */
.lottery-table tbody tr:nth-child(5) {
    height: 15%;
    /* Chiếm 15% diện tích bảng */
}

/* Giải Đặc Biệt (Dòng 9) - Cần to */
.lottery-table tbody tr:nth-child(9) {
    height: 12%;
    /* Chiếm 12% */
    background-color: #ffebee;
}


/* === CELL STYLING === */
.lottery-table td {
    text-align: center;
    /* vertical-align: middle; QUAN TRỌNG: Căn giữa theo chiều dọc */
    border: 1px solid #ccc;
    font-family: 'Arial', sans-serif;
    font-weight: 700;
    color: #000;
    padding: 0;
    /* Bỏ padding để text tự do */

    font-size: 3.5vh;
    /* Cỡ chữ chuẩn */
    line-height: 1.3;
    white-space: pre-wrap;
    /* Cho phép xuống dòng */
}

.prize-col {
    font-family: 'Roboto', sans-serif !important;
    color: var(--primary-color) !important;
    font-size: 2.2vh !important;
    background-color: #fff3e0 !important;
    border-right: 2px solid #b71c1c !important;
}

/* Tinh chỉnh Giải Tư cho gọn */
.lottery-table tbody tr:nth-child(5) td:not(.prize-col) {
    font-size: 2.6vh;
    /* Giảm nhẹ font để các số không dính nhau quá */
    line-height: 1.4;
}

/* Tinh chỉnh Giải ĐB */
.lottery-table tbody tr:nth-child(9) td:not(.prize-col) {
    font-size: 5vh;
    color: #d32f2f;
    font-weight: 900;
    letter-spacing: 2px;
}

/* Background tối ưu */
.lottery-table tr:nth-child(even) td {
    background-color: #fafafa;
}

footer {
    display: block;
    text-align: center;
    padding: 10px;
    font-size: 0.8rem;
    color: #ccc;
    background-color: #111;
    border-top: 1px solid #333;
}

footer p:last-child {
    margin-top: 15px !important;
    opacity: 0.5 !important;
}

/* === MOBILE PRESERVATION === */
@media (max-width: 768px) {
    body {
        height: auto;
        overflow: auto;
        display: block;
        background: #fff;
    }

    header {
        height: auto;
        flex-direction: column;
        padding: 10px;
    }

    main {
        height: auto;
        padding: 5px;
    }

    .lottery-table {
        height: auto;
        border: none;
    }

    .lottery-table thead tr,
    .lottery-table tbody tr {
        height: auto;
    }

    .lottery-table th,
    .lottery-table td {
        font-size: 14px !important;
        height: auto;
        padding: 8px;
        border: 1px solid #eee;
    }

    .prize-col {
        font-size: 12px !important;
        width: 18%;
    }

    .lottery-table tbody tr:nth-child(5) {
        height: auto;
    }

    .lottery-table tbody tr:nth-child(9) {
        height: auto;
    }

    .lottery-table tbody tr:nth-child(9) td:not(.prize-col) {
        font-size: 18px !important;
        letter-spacing: 0;
    }

    footer {
        display: block;
        padding: 20px;
        text-align: center;
    }
}