/* CSS content */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.screen.active {
    display: flex;
}

/* Mode Selection Screen */
#modeSelection {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.container {
    background: white;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 450px;
    width: 100%;
    text-align: center;
}

.game-header {
    margin-bottom: 40px;
}

.game-header .icon {
    font-size: 4rem;
    color: #667eea;
    margin-bottom: 20px;
}

.game-header h1 {
    font-size: 3rem;
    color: #333;
    margin-bottom: 10px;
    font-weight: bold;
}

.game-header p {
    color: #666;
    font-size: 1.1rem;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.mode-btn {
    width: 100%;
    padding: 20px 30px;
    border: none;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
}

.single-player {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
}

.single-player:hover {
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
}

.two-player {
    background: linear-gradient(135deg, #10b981 0%, #0d9488 100%);
}

.two-player:hover {
    background: linear-gradient(135deg, #059669 0%, #0f766e 100%);
}

/* Game Screen */
#gameScreen {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #ec4899 100%);
}

.game-container {
    max-width: 600px;
}

.game-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.back-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 1rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.back-btn:hover {
    color: #333;
    background: #f3f4f6;
}

.game-nav h1 {
    font-size: 1.5rem;
    color: #333;
    font-weight: bold;
}

.spacer {
    width: 60px;
}

/* Scoreboard */
.scoreboard {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
}

.score-item {
    text-align: center;
}

.score-value {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.x-score {
    color: #3b82f6;
}

.o-score {
    color: #ef4444;
}

.tie-score {
    color: #6b7280;
}

.score-label {
    font-size: 0.9rem;
    color: #666;
}

/* Game Status */
.game-status {
    text-align: center;
    margin-bottom: 30px;
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.turn-indicator {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.x-turn {
    background: #3b82f6;
}

.o-turn {
    background: #ef4444;
}

.status-indicator span {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

/* Game Board */
.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 30px;
}

.cell {
    width: 96px;
    height: 96px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 15px;
    font-size: 2.5rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.cell:hover {
    background: #f9fafb;
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.cell.x {
    color: #3b82f6;
    animation: cellPulse 0.3s ease;
}

.cell.o {
    color: #ef4444;
    animation: cellBounce 0.3s ease;
}

.cell.winning {
    background: #dcfce7;
    border-color: #16a34a;
    animation: winningCell 0.5s ease;
}

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

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.action-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.new-game {
    background: #3b82f6;
    color: white;
}

.new-game:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

.reset-scores {
    background: #6b7280;
    color: white;
}

.reset-scores:hover {
    background: #4b5563;
    transform: translateY(-2px);
}

/* Thinking Animation */
.thinking-animation {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
}

.thinking-animation.hidden {
    display: none;
}

.thinking-animation i {
    color: #ef4444;
    font-size: 1.5rem;
    animation: robotBlink 1s infinite;
}

.thinking-animation span {
    font-weight: 600;
    color: #333;
}

dots {
    display: flex;
    gap: 3px;
}

dots span {
    width: 6px;
    height: 6px;
    background: #666;
    border-radius: 50%;
    animation: dotBounce 1.4s infinite ease-in-out;
}

dots span:nth-child(1) { animation-delay: -0.32s; }

dots span:nth-child(2) { animation-delay: -0.16s; }

/* Celebration */
.celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.celebration.hidden {
    display: none;
}

.celebration-content {
    background: white;
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.celebration-icon {
    font-size: 4rem;
    color: #fbbf24;
    margin-bottom: 20px;
    animation: trophySpin 2s ease-in-out;
}

.celebration-content h2 {
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 20px;
}

/* Confetti Animation */
.confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fbbf24;
    animation: confettiFall 3s linear infinite;
}

.confetti-piece:nth-child(1) {
    left: 10%;
    animation-delay: 0s;
    background: #ef4444;
}

.confetti-piece:nth-child(2) {
    left: 30%;
    animation-delay: 0.5s;
    background: #3b82f6;
}

.confetti-piece:nth-child(3) {
    left: 50%;
    animation-delay: 1s;
    background: #10b981;
}

.confetti-piece:nth-child(4) {
    left: 70%;
    animation-delay: 1.5s;
    background: #8b5cf6;
}

.confetti-piece:nth-child(5) {
    left: 90%;
    animation-delay: 2s;
    background: #f59e0b;
}

/* Animations */
@keyframes cellPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes cellBounce {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes winningCell {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

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

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@keyframes trophySpin {
    0% { transform: rotate(0deg) scale(0.5); }
    50% { transform: rotate(180deg) scale(1.1); }
    100% { transform: rotate(360deg) scale(1); }
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
        margin: 10px;
    }
    
    .game-header h1 {
        font-size: 2rem;
    }
    
    .cell {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }
    
    .scoreboard {
        gap: 20px;
    }
    
    .score-value {
        font-size: 1.5rem;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .celebration-content {
        padding: 30px;
        margin: 20px;
    }
    
    .celebration-content h2 {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .cell {
        width: 70px;
        height: 70px;
        font-size: 1.8rem;
    }
    
    .game-board {
        gap: 8px;
    }
