:root {
    --background-color: #ffffff;
    --primary-color: #000000;
    --secondary-color: #f0f0f0;
    --border-color: #cccccc;
    --hover-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --modal-bg: rgba(255, 255, 255, 0.9);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes draw {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    80% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    animation: fadeIn 0.5s ease-out forwards;
}

.game-header {
    text-align: center;
}

h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 600;
}

#difficulty-display {
    margin-top: 0.5rem;
    color: #555;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#board {
    display: grid;
    grid-template-columns: repeat(3, 100px);
    grid-template-rows: repeat(3, 100px);
    gap: 10px;
    padding: 10px;
    background-color: var(--primary-color);
    border-radius: 10px;
    box-shadow: 0 10px 25px var(--shadow-color);
}

.cell {
    background-color: var(--background-color);
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease;
}

.cell:not(.x):not(.o):hover {
    background-color: var(--hover-color);
}

.cell.x, .cell.o {
    cursor: not-allowed;
}

.cell svg {
    width: 70%;
    height: 70%;
    animation: popIn 0.3s ease-out forwards;
}

.cell svg .shape {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: draw 0.8s ease forwards;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--background-color);
    padding: 2rem 3rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 10px 30px var(--shadow-color);
    animation: fadeIn 0.4s ease-out forwards;
}

#mode-selection .modal-content {
     padding: 3rem 4rem;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.modal-content button {
    background-color: var(--primary-color);
    color: var(--background-color);
    border: none;
    padding: 0.8rem 1.8rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 5px;
    cursor: pointer;
    margin: 0.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.modal-content button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
}

#result-message {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    animation: popIn 0.5s ease-out;
}

.end-game-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}