* {
    font-family: 'Pangolin', sans-serif;
}

body {
    font-family: 'Pangolin', sans-serif;
    color: #4c2719;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    flex-direction: column;
    position: relative;
    background-color: #e0f7fa;
}

h1 {
    color: #adadad;
    margin-top: 50px;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 100px);
    grid-template-rows: repeat(3, 100px);
    gap: 20px;
    justify-content: center;
    margin-top: 20px;
}

.cell {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    font-size: 2rem;
    cursor: pointer;
    background-color: #d9f0ff;
    border: 2px solid #a3d5ff;
    box-sizing: border-box;
}

button {
    background-color: transparent;
    border: none;
    width: 80%;
    height: 80%;
    font-size: 2rem;
    color: #4c2719;
    cursor: pointer;
}

.popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #ffe0b5;
    padding: 20px;
    text-align: center;
    font-size: 2rem;
    font-weight: bold;
    word-spacing: 0.3rem;
    color: #000;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    z-index: 1000;
    display: none;
    opacity: 1;
    visibility: visible;
    transition: opacity 1s ease, visibility 0s 1s;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 50%;
}

.popup.fade-out {
    opacity: 0;
    visibility: hidden;
}

.winner-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #ffe0b5;
    border: 2px solid #4c2719;
    padding: 20px;
    text-align: center;
    font-size: 2rem;
    font-weight: bold;
    color: #000;
    box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    z-index: 1000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 50%;
}

.scoreboard {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 2rem;
    z-index: 998;
    display: flex;
    flex-direction: column;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.scoreboard p {
    margin: 5px 0;
}

.glow {
    animation: glowEffect 1.5s infinite;
    font-weight: bold;
}

@keyframes glowEffect {
    0% {
        color: #f39c12; text-shadow: 0 0 10px #f39c12, 0 0 20px #f39c12, 0 0 30px #f39c12; }
    50% {
        color: #e67e22; text-shadow: 0 0 20px #e67e22, 0 0 30px #e67e22, 0 0 40px #e67e22; }
    100% {
        color: #f39c12; text-shadow: 0 0 10px #f39c12, 0 0 20px #f39c12, 0 0 30px #f39c12; }
}

.flames {
    animation: flameEffect 1.5s infinite;
    font-weight: bold;
}

@keyframes flameEffect {
    0% {
        color: #ff4500; text-shadow: 0 0 5px #ff4500, 0 0 10px #ff4500, 0 0 15px #ff6347, 0 0 20px #ff6347; }
    25% {
        color: #ff6347; text-shadow: 0 0 5px #ff6347, 0 0 10px #ff6347, 0 0 15px #ff4500, 0 0 20 #ff4500; }
    50% {
        color: #ff4500; text-shadow: 0 0 5px #ff4500, 0 0 10px #ff4500, 0 0 15px #ff6347, 0 0 20px #ff6347; }
    75% {
        color: #ff6347; text-shadow: 0 0 5px #ff6347, 0 0 10px #ff6347, 0 0 15px #ff4500, 0 0 20px #ff4500; }
    100% {
        color: #ff4500; text-shadow: 0 0 5px #ff4500, 0 0 10px #ff4500, 0 0 15px #ff6347, 0 0 20px #ff6347; }
}

#scoreboard p {
    margin: 5px 0;
}

.popup p, .winner-popup p {
    color: #000;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.4);
}

.popup button, .winner-popup button {
    background-color: #a4af69;
    border: none;
    color: #fff;
    font-size: 2rem;
    font-weight: bold;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 5px;
    margin-top: 20px;
    display: inline-block;
    text-align: center;
    width: auto;
}

.popup.active {
    display: block;
    opacity: 1;
}

.overlay {
    position: fixed;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 999;
    display: none;
    opacity: 1;
    transition: opacity 1s ease;
    backdrop-filter: blur(10px);
}

.overlay.active {
    opacity: 0.5;
    transition: opacity 1s ease;
}

#gameModeSelector {
    position: fixed;
    display: none;
    flex-direction: column;
    align-items: center;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin-top: 10px;
    background-color: #ffe0b5;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    display: none;
}

#cpuModeSelector {
    display: none;
    visibility: visible;
    opacity: 1;
    position: relative;
    z-index: 10;
}

@keyframes popInX {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); }
}

@keyframes popInO {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1); }
}

button span.X {
    animation: popInX 0.4s ease-out;
    color: red;
}

button span.O {
    animation: popInO 0.4s ease-out;
    color: green;
}