/*
bản Quyền Thuộc về: tung
hay tôn trọng mình
ver:1.0.1
*/
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    text-align: center;
    background: linear-gradient(135deg, #121212, #1f1f1f);
    color: #fff;
    margin: 0;
    padding: 0;
}

h1 {
    margin-top: 20px;
    font-size: 32px;
    font-weight: bold;
    text-shadow: 0 0 10px #00ffff;
}

/* ================================
   KHU VỰC NÚT & SELECT
================================ */
.controls {
    margin: 15px;
}

button, select {
    padding: 10px 15px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    background: #222;
    color: white;
    cursor: pointer;
    transition: 0.25s;
    box-shadow: 0 0 8px #00ffaa55;
}

button:hover, select:hover {
    background: #333;
    transform: scale(1.05);
}

/* ================================
   BẢNG CỜ
================================ */
#board {
    display: grid;
    grid-template-columns: repeat(15, 45px);
    grid-template-rows: repeat(15, 45px);
    gap: 2px;
    margin: 20px auto;
    width: fit-content;
    background: #000;
    padding: 12px;
    border-radius: 15px;
    box-shadow: 0 0 20px #00ccff55;
}

/* ================================
   Ô CỜ
================================ */
.cell {
    width: 45px;
    height: 45px;
    background: #1a1a1a;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    color: white;
    transition: 0.15s;
    user-select: none;
    position: relative;
}

.cell:hover {
    background: #2a2a2a;
    transform: scale(1.08);
}

/* ================================
   VÒNG TRÒN NEON BAO QUANH X & O
================================ */

.cell.X::before,
.cell.O::before {
    content: "";
    position: absolute;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    z-index: -1;
    animation: pulseGlow 1.7s infinite ease-out;
}

/* X màu đỏ neon */
.cell.X {
    color: #ff4040;
    text-shadow: 0 0 10px #ff2020, 0 0 18px #ff0000;
}

.cell.X::before {
    border: 3px solid #ff4040;
    box-shadow: 0 0 12px #ff2020, 0 0 25px #ff0000;
}

/* O màu xanh neon */
.cell.O {
    color: #40aaff;
    text-shadow: 0 0 10px #2080ff, 0 0 18px #0066ff;
}

.cell.O::before {
    border: 3px solid #40aaff;
    box-shadow: 0 0 12px #2090ff, 0 0 25px #0080ff;
}

/* Hiệu ứng nhịp tim vòng tròn */
@keyframes pulseGlow {
    0%   { transform: scale(1); opacity: 0.9; }
    50%  { transform: scale(1.25); opacity: 0.3; }
    100% { transform: scale(1); opacity: 0.9; }
}

/* ================================
   HIỆU ỨNG ĐẶT QUÂN (POP)
================================ */
.cell.placed {
    animation: pop 0.25s ease-out;
}

@keyframes pop {
    0% { transform: scale(0.3); opacity: 0.2; }
    100% { transform: scale(1); opacity: 1; }
}

/* ================================
   Ô THẮNG – VÀNG RỰC RỠ
================================ */
.winCell {
    background: #ffe066 !important;
    color: #000 !important;
    font-weight: bold;
    transform: scale(1.25);
    box-shadow: 0 0 15px #ffea00, 0 0 25px #ffdd00;
    border-radius: 12px;
}

/* ================================
   HỘP THÔNG BÁO TÙY CHỈNH
================================ */
#message-box {
    position: fixed; /* Giữ cố định trên màn hình */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Canh giữa hoàn hảo */
    background: linear-gradient(135deg, #1f1f1f, #2a2a2a);
    padding: 30px 40px;
    border-radius: 20px;
    box-shadow: 0 0 30px rgba(0, 204, 255, 0.6), 0 0 50px rgba(0, 102, 255, 0.4);
    z-index: 1000; /* Đảm bảo nó luôn ở trên cùng */
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    border: 2px solid #00ccff; /* Đường viền neon */
    min-width: 280px; /* Chiều rộng tối thiểu */
    max-width: 90vw; /* Chiều rộng tối đa trên di động */
    animation: fadeInScale 0.3s ease-out forwards; /* Hiệu ứng xuất hiện */
}

#message-box p {
    margin-bottom: 25px;
    text-shadow: 0 0 8px #00ffff;
    color: #e0f7fa; /* Màu chữ sáng hơn */
}

#message-box button {
    padding: 12px 25px;
    font-size: 18px;
    border-radius: 12px;
    background: linear-gradient(45deg, #007bff, #00c7ff); /* Nút màu gradient */
    box-shadow: 0 0 15px rgba(0, 199, 255, 0.7);
    transition: all 0.2s ease-in-out;
}

#message-box button:hover {
    transform: scale(1.1);
    background: linear-gradient(45deg, #00c7ff, #007bff);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.9);
}

/* Ẩn/hiện thông báo */
.hidden {
    display: none;
    opacity: 0;
    pointer-events: none; /* Không nhận sự kiện khi ẩn */
}

/* Hiệu ứng xuất hiện */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}
/* ================================
   CẢNH BÁO CHUỖI 3 & 4 QUÂN
================================ */

/* CẢNH BÁO 3 QUÂN – MỨC CẢNH GIÁC (Vàng nhạt) */
.threat-3 {
    background: #4a4100 !important; /* Nền tối hơn */
    box-shadow: 0 0 10px #ffff0055, inset 0 0 5px #ffff0077;
    /* Dùng animation nhẹ để thu hút sự chú ý */
    animation: threatPulse 1.5s infinite alternate;
}

/* CẢNH BÁO 4 QUÂN – MỨC NGUY HIỂM (Cam đậm) */
.threat-4 {
    background: #6e2e00 !important;
    box-shadow: 0 0 15px #ff8c00aa, inset 0 0 7px #ff8c00cc;
    animation: threatPulse 1s infinite alternate;
}

/* Hiệu ứng nhấp nháy cho cảnh báo */
@keyframes threatPulse {
    from { opacity: 0.8; }
    to { opacity: 1; }
}
/* ================================
   VÙNG NGUY CƠ NỔ (Ô TRỐNG)
================================ */

/* Vùng xung quanh chuỗi 3 quân - Báo hiệu nguy cơ bị "xóa quân" */
.threat-3-zone {
    background: #401f1f !important; /* Nền đỏ đậm */
    border: 1px solid #ff4040 !important;
    box-shadow: 0 0 8px #ff202055, inset 0 0 4px #ff000077;
    animation: dangerPulse 1s infinite alternate;
}

@keyframes dangerPulse {
    from { opacity: 0.9; }
    to { opacity: 1; }
}
/* ================================
   Ô ĐÓNG BĂNG (FROZEN CELL)
================================ */
.frozen {
    background: #112233 !important; /* Màu xanh băng */
    box-shadow: 0 0 10px #00ccff88, inset 0 0 5px #00aaffaa;
    cursor: not-allowed !important; /* Chuột cấm */
    animation: pulseFreeze 2s infinite alternate;
}

@keyframes pulseFreeze {
    from { opacity: 0.9; }
    to { opacity: 1; }
}