/* css/styles.css */
:root {
    --primary: #e74c3c;
    --secondary: #3498db;
    --bg: #f8f9fa;
    --text: #2c3e50;
    --white: #ffffff;
    --success: #27ae60;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: rgbBG 15s ease infinite;
    color: var(--text);
    overflow-x: hidden;
    line-height: 1.5;
}

@keyframes rgbBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* ... (giữ nguyên #app và các phần khác) ... */

/* Hiệu ứng nhấp nháy MẠNH MẼ khi số mới được gọi */
.cell.flash {
    animation: flashAnim 0.2s ease-in-out infinite;
    /* Nhanh hơn và lặp vô hạn trong 3s (xử lý ở JS) */
    border: 2px solid red;
    z-index: 10;
    transform: scale(1.1);
}

@keyframes flashAnim {

    0%,
    100% {
        background: white;
        transform: scale(1);
    }

    50% {
        background: #ff0000;
        color: white;
        transform: scale(1.15);
        box-shadow: 0 0 10px #ff0000;
    }
}

.cell.called.flash {
    animation: flashCalledAnim 0.2s ease-in-out infinite;
}

@keyframes flashCalledAnim {

    0%,
    100% {
        background: #d5f5e3;
    }

    50% {
        background: #ff0000;
        color: white;
        box-shadow: 0 0 15px #ff0000;
    }
}

#app {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Container chính dạng thẻ bài (Card/Panel) */
.screen {
    width: 100%;
    background: rgba(255, 255, 255, 0.85);
    /* Nền trắng mờ */
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    border: 1px solid rgba(255, 255, 255, 0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
}

.hidden {
    display: none !important;
}

h1 {
    font-size: 3.5rem;
    color: var(--primary);
    text-shadow: 2px 2px 0px #fff;
    margin-bottom: 20px;
    font-weight: 800;
}

h2 {
    color: var(--text);
    margin-bottom: 10px;
}

.actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

button {
    padding: 15px;
    border: none;
    border-radius: 12px;
    font-weight: bold;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    /* Đảm bảo nút full width trong container */
}

button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #95a5a6 !important;
    color: #ecf0f1 !important;
}

.btn-primary {
    background: linear-gradient(to right, #e74c3c, #c0392b);
    color: white;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-secondary {
    background: linear-gradient(to right, #3498db, #2980b9);
    color: white;
}

.btn-text {
    background: transparent;
    color: #7f8c8d;
    box-shadow: none;
    border: 1px solid #bdc3c7;
}

.btn-text:hover {
    background: #ecf0f1;
    color: var(--text);
}

.btn-kinh {
    background: var(--success);
    color: white;
    width: 100%;
    font-size: 1.5rem;
    margin-top: 10px;
}

.btn-host {
    background: #34495e;
    color: white;
    flex: 1;
    font-size: 0.85rem;
    padding: 10px 5px;
}

.btn-next {
    background: #e67e22;
}

.btn-new-game {
    background: #27ae60;
    width: 100%;
    margin-top: 5px;
    font-size: 1rem;
}

.form-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

input,
select {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}

/* Game Styles */
.game-header {
    width: 100%;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.highlight {
    color: var(--primary);
    font-weight: bold;
}

.call-area {
    width: 100%;
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 15px;
    align-items: center;
    background: #fff;
    padding: 15px;
    border-radius: 8px;
}

.last-number {
    width: 80px;
    height: 80px;
    flex: 0 0 80px;
    /* KHÔNG co giãn, luôn giữ 80px */
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: bold;
    line-height: normal;
    /* Reset line-height để căn giữa tốt hơn */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    border: 3px solid white;
}

.recent-numbers .label {
    font-size: 0.8rem;
    color: #7f8c8d;
}

.numbers-row {
    font-family: monospace;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ticket Styles */
.ticket {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.block {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 2px;
    background: #bdc3c7;
    border: 2px solid #34495e;
    padding: 2px;
}

.cell {
    background: white;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.cell.empty {
    background: #ecf0f1;
    cursor: default;
}

/* Số đã được gọi nhưng chưa tick → viền sáng */
.cell.called {
    background: #d5f5e3;
    border: 1px solid #27ae60;
}

/* Số đã tick + server đã đọc → vàng (hợp lệ) */
.cell.marked {
    background: #f1c40f;
    color: #2c3e50;
    font-weight: bold;
}

/* Số đã tick nhưng server chưa đọc → xám (đánh dấu trước) */
.cell.pre-marked {
    background: #bdc3c7;
    color: #636e72;
}

/* Hiệu ứng nhấp nháy khi số mới được gọi */
.cell.flash {
    animation: flashAnim 0.5s ease-in-out 6;
}


.game-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#host-controls {
    display: flex;
    gap: 5px;
    width: 100%;
    flex-wrap: wrap;
}

.footer-note {
    margin-top: 30px;
    font-size: 0.9rem;
    color: #7f8c8d;
    width: 100%;
}

.footer-note ul {
    padding-left: 20px;
    margin-top: 5px;
}

/* Overlay chúc mừng */
.win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.win-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    max-width: 350px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.win-icon {
    font-size: 4rem;
    margin-bottom: 10px;
}

.win-content h2 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.win-content p {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: #7f8c8d;
}

/* === 16 MÀU VÉ SỐ RGB RỰC RỠ === */
.ticket-container {
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    /* Mặc định Theme 0 */
    background: linear-gradient(135deg, #fceabb 0%, #f8b500 100%);
}

.ticket-theme-0 {
    background: linear-gradient(135deg, #fceabb 0%, #f8b500 100%);
    border: 3px solid #f39c12;
}

.ticket-theme-1 {
    background: linear-gradient(135deg, #FF9A9E 0%, #FECFEF 99%, #FECFEF 100%);
    border: 3px solid #ff6b6b;
}

.ticket-theme-2 {
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
    border: 3px solid #9b59b6;
}

.ticket-theme-3 {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    border: 3px solid #2ecc71;
}

.ticket-theme-4 {
    background: linear-gradient(135deg, #a6c0fe 0%, #f68084 100%);
    border: 3px solid #3498db;
}

.ticket-theme-5 {
    background: linear-gradient(135deg, #fccb90 0%, #d57eeb 100%);
    border: 3px solid #9b59b6;
}

.ticket-theme-6 {
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    border: 3px solid #3498db;
}

.ticket-theme-7 {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border: 3px solid #e74c3c;
}

.ticket-theme-8 {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    border: 3px solid #2980b9;
}

.ticket-theme-9 {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    border: 3px solid #1abc9c;
}

.ticket-theme-10 {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    border: 3px solid #e67e22;
}

.ticket-theme-11 {
    background: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
    border: 3px solid #8e44ad;
    color: white;
}

.ticket-theme-12 {
    background: linear-gradient(135deg, #c471f5 0%, #fa71cd 100%);
    border: 3px solid #d35400;
}

.ticket-theme-13 {
    background: linear-gradient(135deg, #0ba360 0%, #3cba92 100%);
    border: 3px solid #27ae60;
}

.ticket-theme-14 {
    background: linear-gradient(135deg, #ff758c 0%, #ff7eb3 100%);
    border: 3px solid #c0392b;
}

.ticket-theme-15 {
    background: linear-gradient(135deg, #2af598 0%, #009efd 100%);
    border: 3px solid #2980b9;
}

/* Điều chỉnh lại màu block để trong suốt hơn 1 chút */
.block {
    background: rgba(255, 255, 255, 0.4);
    border: none;
    padding: 3px;
    border-radius: 4px;
}

/* Cell trong suốt nhẹ để ăn màu nền */
.cell {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 3px;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.cell.empty {
    background: rgba(255, 255, 255, 0.3);
    box-shadow: none;
}