/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;

    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --surface: #1e293b;
    --surface-light: #2d3748;

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --border-color: #334155;
    --border-radius: 16px;
    --border-radius-sm: 8px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    --transition: all 0.2s ease-in-out;
    --transition-fast: all 0.15s ease-in-out;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.logo .title {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo .subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: 2px;
}

.score-board {
    display: flex;
    align-items: center;
    gap: 16px;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.score-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.score-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.vs-divider {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Game Status */
.game-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.status-message {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.turn-indicator {
    display: flex;
    gap: 8px;
}

.player-indicator,
.ai-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-color);
    transition: var(--transition);
    background: var(--bg-tertiary);
}

.player-indicator.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.ai-indicator.active {
    border-color: var(--danger-color);
    background: var(--danger-color);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.symbol {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Game Board */
.game-board-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 24px;
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    max-width: 320px;
    width: 100%;
}

.cell {
    aspect-ratio: 1;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.cell:hover {
    border-color: var(--primary-color);
    background: var(--surface-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.cell:active {
    transform: translateY(0);
}

.cell.x {
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary-color);
}

.cell.o {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger-color);
}

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

.cell.old {
    opacity: 0.5;
    animation: fadeOut 0.3s ease-in-out;
}

.cell.fade-out {
    animation: fadeOutRemove 0.2s ease-in-out forwards;
}

.cell.moving {
    animation: pulseMove 0.3s ease-in-out;
    z-index: 10;
}

.cell.new {
    animation: placeAnimation 0.3s ease-out;
}

@keyframes placeAnimation {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0.5;
        transform: scale(0.9);
    }
}

@keyframes fadeOutRemove {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.8);
    }
}

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

/* Winning Line */
.winning-line {
    position: absolute;
    background: var(--success-color);
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
}

.winning-line.show {
    opacity: 1;
}

/* Game Controls */
.game-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--surface-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

/* Game Info */
.game-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-card {
    padding: 20px;
    background: var(--surface);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.info-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.info-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.pieces-counter {
    display: flex;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--surface);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.counter-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.counter-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.counter-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1000;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    max-width: 400px;
    width: 90%;
    margin: 20px;
    transform: scale(0.9) translateY(20px);
    transition: var(--transition);
}

.modal.show .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
}

.modal-body {
    padding: 24px;
    text-align: center;
}

.modal-body p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.final-score {
    display: flex;
    justify-content: space-around;
    gap: 16px;
    margin-top: 20px;
}

.final-score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 480px) {
    .container {
        padding: 16px;
        gap: 20px;
    }

    .header {
        padding: 20px;
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .logo .title {
        font-size: 1.5rem;
    }

    .game-board {
        padding: 20px;
        max-width: 280px;
    }

    .cell {
        font-size: 1.75rem;
    }

    .game-controls {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 100%;
        max-width: 200px;
    }
}

/* Animation for winning celebration */
@keyframes winCelebration {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.win-animation {
    animation: winCelebration 0.6s ease-in-out;
}

/* Pulse animation for active indicators */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 1s infinite;
}