:root {
    --bg-color: #252525;
    --cell-bg: #414141;
    --cell-hover: #505050;
    --text-color: #ffffff;
    --accent-red: #FF0000;
    --accent-dark-red: #AF0404;
    --border-radius: 10px;
    --gap: 10px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.container {
    text-align: center;
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.game-title {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: var(--accent-red);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* Mode Selector */
.mode-selector {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 15px;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background-color: var(--cell-bg);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-color);
}

.mode-btn:hover {
    background-color: var(--cell-hover);
}

.mode-btn.active {
    border-color: var(--accent-red);
    background-color: rgba(255, 0, 0, 0.15);
}

.mode-icon {
    font-size: 1.5rem;
}

.mode-text {
    font-size: 0.85rem;
    font-weight: bold;
}

/* Difficulty Selector */
.difficulty-selector {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
}

.difficulty-selector.hidden {
    display: none;
}

.diff-btn {
    background-color: var(--cell-bg);
    border: 2px solid transparent;
    border-radius: 20px;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-color);
    font-size: 0.8rem;
    font-weight: bold;
}

.diff-btn:hover {
    background-color: var(--cell-hover);
}

.diff-btn.active {
    border-color: var(--accent-red);
    background-color: rgba(255, 0, 0, 0.15);
}

/* Impossible Mode Button */
.diff-btn.impossible {
    background: linear-gradient(135deg, #8B0000 0%, #FF4500 50%, #8B0000 100%);
    background-size: 200% 200%;
    animation: evilGlow 2s ease infinite;
    border-color: #FF4500;
}

.diff-btn.impossible:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 69, 0, 0.5);
}

.diff-btn.impossible.active {
    border-color: #FF4500;
    background: linear-gradient(135deg, #8B0000 0%, #FF4500 50%, #8B0000 100%);
    background-size: 200% 200%;
    animation: evilGlow 1s ease infinite;
    box-shadow: 0 0 20px rgba(255, 69, 0, 0.7);
}

@keyframes evilGlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* AI thinking indicator */
.thinking {
    opacity: 0.7;
    pointer-events: none;
}

.thinking::after {
    content: " 🤔";
    animation: thinking 1s infinite;
}

.thinking.evil::after {
    content: " 😈";
    animation: evilThinking 0.5s infinite;
}

@keyframes thinking {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

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

/* Cell stolen animation */
.cell.stolen {
    animation: stolenCell 0.6s ease;
    background-color: rgba(255, 69, 0, 0.3) !important;
}

@keyframes stolenCell {
    0% { transform: scale(1); }
    25% { transform: scale(0.8) rotate(-10deg); }
    50% { transform: scale(0.5); opacity: 0.5; }
    75% { transform: scale(0.8) rotate(10deg); }
    100% { transform: scale(1); opacity: 1; }
}

/* Cheat message */
.cheat-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #8B0000, #FF4500);
    color: white;
    padding: 20px 40px;
    border-radius: 15px;
    font-size: 1.5rem;
    font-weight: bold;
    z-index: 1000;
    animation: cheatPopup 0.5s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.cheat-message::after {
    content: " 😈";
    font-size: 2rem;
}

@keyframes cheatPopup {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.score-board {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    background-color: var(--cell-bg);
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.score-box {
    display: flex;
    flex-direction: column;
    font-weight: bold;
}

.player-name {
    font-size: 0.9rem;
    color: #cccccc;
}

.score {
    font-size: 1.5rem;
    margin-top: 5px;
}

.game-status {
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    height: 1.5rem; /* Fixed height to prevent jumping */
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gap);
    background-color: var(--bg-color);
    margin-bottom: 20px;
}

.cell {
    background-color: var(--cell-bg);
    height: 100px; /* Suitable height for mobile */
    border: none;
    border-radius: var(--border-radius);
    font-size: 3rem;
    font-weight: bold;
    color: var(--text-color);
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.cell:active {
    transform: scale(0.95);
}

.cell.x {
    color: var(--accent-red);
}

.cell.o {
    color: #ffffff; /* White O */
}

.cell.win {
    background-color: var(--accent-dark-red);
    color: #fff;
    animation: pulse 1s infinite;
}

.btn-restart {
    background-color: var(--accent-red);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    font-weight: bold;
}

.btn-restart:hover {
    background-color: var(--accent-dark-red);
}

.btn-restart:active {
    transform: scale(0.95);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Footer / Sign */
.sign {
    margin-top: auto;
    padding: 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.sign a {
    color: var(--accent-red);
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.sign a:hover {
    color: #ff4444;
    text-shadow: 0 0 8px rgba(255, 0, 0, 0.5);
}

.sign a:focus {
    outline: 2px solid var(--accent-red);
    outline-offset: 2px;
    border-radius: 3px;
}

/* Media queries for larger screens */
@media (min-width: 600px) {
    .cell {
        height: 120px;
        font-size: 4rem;
    }
    
    .game-title {
        font-size: 3.5rem;
    }
}
