/* Tic Tac Toe Board */
.ttt-board {
    display: inline-grid;
    grid-template-columns: repeat(3, 120px);
    gap: 10px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin: 0 auto;
    max-width: 90vw;
}

/* Cell Styles */
.ttt-cell {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 60px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    min-width: 40px;
    min-height: 40px;
}

.ttt-cell:hover:not(.taken):not(.disabled) {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.ttt-cell.taken {
    cursor: not-allowed;
}

.ttt-cell.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* X and O Marks */
.ttt-cell.x {
    color: #e74c3c;
    animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.ttt-cell.o {
    color: #3498db;
    animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Pop-in Animation */
@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Winning Cell Highlight */
.ttt-cell.winner {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white !important;
    animation: winPulse 0.6s ease-in-out;
}

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

/* Stat Cards */
.stat-card {
    padding: 15px;
    border-radius: 10px;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    color: var(--bs-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* AI Thinking Animation */
.ai-thinking .ttt-cell:not(.taken) {
    animation: thinking 1s infinite;
}

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

/* Fullscreen Mode */
#ticTacToeGame.fullscreen-mode {
    background: var(--bs-body-bg);
    padding: 20px;
    overflow-y: auto;
}

#ticTacToeGame.fullscreen-mode .ttt-board {
    max-width: 95vh;
}

#ticTacToeGame.fullscreen-mode .ttt-cell {
    font-size: 80px;
}

/* Dynamic Board Sizes */
.ttt-board[style*="grid-template-columns: repeat(5"] .ttt-cell {
    font-size: 45px;
}

.ttt-board[style*="grid-template-columns: repeat(7"] .ttt-cell {
    font-size: 35px;
}

.ttt-board[style*="grid-template-columns: repeat(9"] .ttt-cell {
    font-size: 28px;
}

.ttt-board[style*="grid-template-columns: repeat(18"] .ttt-cell {
    font-size: 18px;
}

/* Adjust gap for larger boards */
.ttt-board[style*="grid-template-columns: repeat(7"],
.ttt-board[style*="grid-template-columns: repeat(9"],
.ttt-board[style*="grid-template-columns: repeat(18"] {
    gap: 6px;
    padding: 15px;
}

/* Dark Mode */
[data-bs-theme="dark"] .ttt-cell {
    background: rgba(255, 255, 255, 0.1);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .ttt-cell:hover:not(.taken):not(.disabled) {
    background: rgba(255, 255, 255, 0.2);
}

[data-bs-theme="dark"] .ttt-board {
    background: linear-gradient(135deg, #434343 0%, #000000 100%);
}

[data-bs-theme="dark"] #ticTacToeGame.fullscreen-mode {
    background: var(--bs-body-bg);
}

/* Responsive Design */
@media (max-width: 768px) {
    .ttt-board {
        gap: 8px;
        padding: 15px;
    }

    .ttt-cell {
        font-size: 48px;
    }

    .ttt-board[style*="grid-template-columns: repeat(5"] .ttt-cell {
        font-size: 35px;
    }

    .ttt-board[style*="grid-template-columns: repeat(7"] .ttt-cell {
        font-size: 25px;
    }

    .ttt-board[style*="grid-template-columns: repeat(9"] .ttt-cell {
        font-size: 20px;
    }

    .ttt-board[style*="grid-template-columns: repeat(18"] .ttt-cell {
        font-size: 14px;
    }

    .stat-value {
        font-size: 24px;
    }

    #ticTacToeGame.fullscreen-mode .ttt-cell {
        font-size: 60px;
    }
}

@media (max-width: 576px) {
    .ttt-board {
        gap: 6px;
        padding: 10px;
    }

    .ttt-cell {
        font-size: 40px;
    }

    .ttt-board[style*="grid-template-columns: repeat(5"] .ttt-cell {
        font-size: 28px;
    }

    .ttt-board[style*="grid-template-columns: repeat(7"] .ttt-cell {
        font-size: 20px;
    }

    .ttt-board[style*="grid-template-columns: repeat(9"] .ttt-cell {
        font-size: 16px;
    }

    .ttt-board[style*="grid-template-columns: repeat(18"] .ttt-cell {
        font-size: 11px;
    }

    .stat-value {
        font-size: 20px;
    }

    .stat-label {
        font-size: 11px;
    }

    #ticTacToeGame.fullscreen-mode .ttt-cell {
        font-size: 50px;
    }

    #ticTacToeGame.fullscreen-mode .ttt-board[style*="grid-template-columns: repeat(5"] .ttt-cell {
        font-size: 40px;
    }

    #ticTacToeGame.fullscreen-mode .ttt-board[style*="grid-template-columns: repeat(18"] .ttt-cell {
        font-size: 25px;
    }
}

/* Draw Animation */
.draw-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    animation: drawFade 2s ease-out;
    pointer-events: none;
}

@keyframes drawFade {
    0% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Game Over Overlay */
.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-in;
    z-index: 10;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Win Line Animation */
.win-line {
    position: absolute;
    background: linear-gradient(90deg, transparent, #f5576c, transparent);
    animation: winLineGlow 1s infinite;
    pointer-events: none;
}

.win-line.horizontal {
    height: 5px;
    width: 100%;
    left: 0;
}

.win-line.vertical {
    width: 5px;
    height: 100%;
    top: 0;
}

.win-line.diagonal {
    height: 5px;
    width: 141%;
    top: 50%;
    left: -20%;
}

.win-line.diagonal-1 {
    transform: rotate(45deg);
}

.win-line.diagonal-2 {
    transform: rotate(-45deg);
}

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