
@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@700&display=swap');

@keyframes twinkle {
    0% { opacity: 0; } 50% { opacity: 0.8; } 100% { opacity: 0; }
}

body {
    font-family: 'Baloo 2', cursive, Arial, sans-serif;
    display: flex; flex-direction: column; align-items: center; 
    justify-content: flex-start;
    min-height: 100vh; margin: 0; 
    overflow-x: hidden; overflow-y: auto;
    background: linear-gradient(135deg, #0B204A 0%, #040F24 100%) fixed;
    position: relative;
    padding: 2vh 0;
    box-sizing: border-box;
}

body::before, body::after {
    content: ''; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: -1;
}
body::before {
    background-image: radial-gradient(1px 1px at 20px 30px, #eee, transparent), radial-gradient(1.5px 1.5px at 70px 80px, #fff, transparent);
    background-size: 200px 200px; animation: twinkle 10s infinite linear;
}
body::after {
    background-image: radial-gradient(1.5px 1.5px at 50px 120px, #ddd, transparent), radial-gradient(1px 1px at 150px 50px, #fff, transparent);
    background-size: 300px 300px; animation: twinkle 15s infinite linear -5s;
}

h1, #status-display, #game-board, .button-container, #menu-button, #score-board {
    z-index: 1;
}

#score-board {
    display: flex; gap: 30px; background-color: rgba(255, 255, 255, 0.1);
    padding: 10px 25px; border-radius: 15px; margin-top: 60px; margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.score-player { color: #fff; font-size: 1.8em; font-weight: 700; text-shadow: 1px 1px 2px rgba(0,0,0,0.2); }
#score-x-value { color: #ff4136; }
#score-o-value { color: #0074d9; }

h1 { font-size: 3.5em; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.2), 0 4px 10px rgba(0,0,0,0.15); text-align: center; margin-top: 0; margin-bottom: 15px;}
#status-display { margin-bottom: 15px; font-size: 1.8em; font-weight: bold; color: #fff; text-shadow: 1px 1px 2px rgba(0,0,0,0.1); }

#game-board {
    --grid-size: 5;
    --board-total-size: 75vmin;
    width: var(--board-total-size);
    max-width: 700px;

    display: grid;
    grid-template-columns: repeat(var(--grid-size), 1fr);
    grid-template-rows: repeat(var(--grid-size), 1fr);
    gap: calc(var(--board-total-size) / 100);
    padding: calc(var(--board-total-size) / 100);
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.cell {
    background-color: rgba(255, 255, 255, 0.9);
    display: flex; align-items: center; justify-content: center;
    font-size: clamp(0.8rem, calc(var(--board-total-size) / var(--grid-size) * 0.35), 3.5rem);
    line-height: 1;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.3s;
    border-radius: 10px;
}

.cell:hover { background-color: #fff; }
.cell.x { color: #ff4136; }
.cell.o { color: #0074d9; }

.button-container {
    margin-top: 25px;
    display: flex; /* Sắp xếp các nút cạnh nhau */
    gap: 20px; /* Khoảng cách giữa các nút */
}

#restart-button, #guide-button {
    padding: 15px 30px; font-size: 1.5em; font-family: 'Baloo 2', cursive, Arial, sans-serif;
    font-weight: 700; cursor: pointer; border: none; border-radius: 10px;
    background-color: #fff; color: #0056b3; transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
#restart-button:hover, #guide-button:hover {
    background-color: #f1f1f1; transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

#menu-button {
    position: absolute; top: 20px; left: 20px; padding: 10px 20px; font-size: 1.2em;
    font-family: 'Baloo 2', cursive, Arial, sans-serif; font-weight: 700; cursor: pointer;
    border: none; border-radius: 10px; background-color: rgba(255, 255, 255, 0.85);
    color: #0056b3; text-decoration: none; transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
#menu-button:hover { background-color: #fff; transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }

/* --- ĐỊNH DẠNG CHO HỘP THOẠI (MODAL) --- */
.modal {
    display: none; /* Ẩn mặc định */
    position: fixed; 
    z-index: 10; 
    left: 0; top: 0; 
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.6); 
    align-items: center; 
    justify-content: center;
}
.modal-content {
    background-color: #fff; 
    padding: 30px; 
    border-radius: 15px; 
    text-align: center;
    max-width: 90%; 
    width: 500px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    position: relative;
    color: #333;
}
.close-button {
    position: absolute; 
    top: 10px; right: 20px; 
    font-size: 2em; 
    font-weight: bold; 
    cursor: pointer;
    color: #aaa;
}
.close-button:hover { color: #333; }
