@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Montserrat', sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: manipulation;
}

body {
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.back-button {
    position: absolute;
    left: 16px;
    top: 16px;
    font-size: 24px;
    color: var(--text-color);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: var(--transition);
}

.back-button:hover {
    transform: translateX(-5px);
}

.game-container {
    width: 100%;
    max-width: 400px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.3s ease-out;
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

.title {
    font-size: 24px;
    font-weight: bold;
    color: var(--tg-theme-text-color);
    margin-bottom: 12px;
}

.score-container {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 12px;
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--tg-theme-bg-color);
    padding: 8px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.player-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--tg-theme-hint-color);
    margin-bottom: 4px;
}

.score {
    font-size: 32px;
    font-weight: bold;
    color: var(--tg-theme-text-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.score-box:first-child .score {
    color: #e74c3c;
}

.score-box:last-child .score {
    color: #3498db;
}

.game-status {
    font-size: 16px;
    color: var(--tg-theme-hint-color);
}

.game-board {
    width: 100%;
    aspect-ratio: 1;
    background: var(--tg-theme-bg-color);
    border-radius: 16px;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cell {
    aspect-ratio: 1;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.cell:active {
    transform: scale(0.95);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.cell.x {
    color: #e74c3c;
}

.cell.o {
    color: #3498db;
}

.game-controls {
    display: flex;
    gap: 8px;
    width: 100%;
}

.game-controls button {
    flex: 1;
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.game-controls button:active {
    transform: scale(0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.game-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.game-over-content {
    background: var(--tg-theme-bg-color);
    padding: 24px;
    border-radius: 16px;
    text-align: center;
    max-width: 90%;
    width: 300px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.game-over h2 {
    font-size: 24px;
    margin-bottom: 16px;
    color: var(--tg-theme-text-color);
}

.game-over p {
    font-size: 18px;
    color: var(--tg-theme-hint-color);
    margin-bottom: 24px;
}

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

.status {
    font-size: 20px;
    font-weight: bold;
    color: var(--text-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

#reset-scores {
    background: linear-gradient(135deg, var(--secondary-color), #c0392b);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: var(--tg-theme-bg-color);
    padding: 24px;
    border-radius: 16px;
    text-align: center;
    max-width: 90%;
    width: 300px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease-out;
}

.modal h2 {
    font-size: 24px;
    margin-bottom: 16px;
    color: var(--tg-theme-text-color);
}

.modal p {
    font-size: 18px;
    color: var(--tg-theme-hint-color);
    margin-bottom: 24px;
}

.modal button {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.modal button:active {
    transform: scale(0.95);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.win-animation {
    width: 120px;
    height: 120px;
    margin: 2rem auto;
    background: linear-gradient(135deg, var(--accent-color), #27ae60);
    border-radius: 50%;
    animation: win-pulse 1s ease infinite;
    box-shadow: 0 0 20px rgba(46, 204, 113, 0.3);
}

@media (max-width: 480px) {
    .game-container {
        padding: 16px;
        border-radius: 20px;
    }

    .title {
        font-size: 20px;
    }

    .score-container {
        gap: 24px;
    }

    .score-box {
        padding: 6px 12px;
    }

    .player-name {
        font-size: 12px;
    }

    .score {
        font-size: 28px;
    }

    .game-status {
        font-size: 14px;
    }

    .game-board {
        padding: 8px;
        gap: 6px;
    }

    .cell {
        font-size: 28px;
    }

    .game-controls button {
        padding: 10px 20px;
        font-size: 14px;
    }
}

@media (max-width: 360px) {
    .game-container {
        padding: 12px;
        border-radius: 16px;
    }

    .title {
        font-size: 18px;
    }

    .score-container {
        gap: 16px;
    }

    .score-box {
        padding: 4px 8px;
    }

    .player-name {
        font-size: 11px;
    }

    .score {
        font-size: 24px;
    }

    .game-status {
        font-size: 13px;
    }

    .game-board {
        padding: 6px;
        gap: 4px;
    }

    .cell {
        font-size: 24px;
    }

    .game-controls button {
        padding: 8px 16px;
        font-size: 13px;
    }
} 