* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --bg-dark: #0f0c29;
    --bg-darker: #0a0818;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #b8b8d1;
    --player-x: #f5576c;
    --player-o: #4facfe;
    --shadow-glow: 0 8px 32px 0 rgba(102, 126, 234, 0.37);
    --shadow-strong: 0 15px 50px rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-dark);
    background-image:
        radial-gradient(at 0% 0%, rgba(102, 126, 234, 0.2) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(118, 75, 162, 0.2) 0px, transparent 50%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
}

.game-wrapper {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 30px;
    border: 1px solid var(--card-border);
    padding: 40px;
    box-shadow: var(--shadow-strong);
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.title {
    text-align: center;
    font-size: 3rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.title-icon {
    font-size: 2.5rem;
    animation: bounce 2s infinite;
}

.title-icon:first-child {
    animation-delay: 0.2s;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 15px;
    border: 1px solid var(--card-border);
}

.player-indicator {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.current-player {
    font-weight: 700;
    color: var(--text-primary);
    padding: 5px 15px;
    background: var(--primary-gradient);
    border-radius: 10px;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

.score-board {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.5rem;
    font-weight: 700;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.score-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.score-value {
    font-size: 1.8rem;
    background: var(--success-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.score-divider {
    color: var(--text-secondary);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
    perspective: 1000px;
}

.cell {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--card-border);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cell:hover:not(.x):not(.o) {
    transform: translateY(-5px);
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: var(--shadow-glow);
}

.cell:hover:not(.x):not(.o)::before {
    opacity: 0.1;
}

.cell.x,
.cell.o {
    cursor: not-allowed;
    animation: cellPop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes cellPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.cell.x {
    color: var(--player-x);
    text-shadow: 0 0 20px rgba(245, 87, 108, 0.5);
}

.cell.o {
    color: var(--player-o);
    text-shadow: 0 0 20px rgba(79, 172, 254, 0.5);
}

.cell.winning {
    animation: winningCell 0.6s ease-in-out;
    background: var(--success-gradient);
    border-color: transparent;
}

@keyframes winningCell {

    0%,
    100% {
        transform: scale(1);
    }

    25% {
        transform: scale(1.1) rotate(5deg);
    }

    75% {
        transform: scale(1.1) rotate(-5deg);
    }
}

.cell.fade-out {
    animation: fadeOutCell 0.3s ease-out forwards;
}

@keyframes fadeOutCell {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.5);
    }
}

.reset-btn {
    width: 100%;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
    background: var(--primary-gradient);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.reset-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.reset-btn:active {
    transform: translateY(-1px);
}

.reset-icon {
    font-size: 1.5rem;
    display: inline-block;
    transition: transform 0.3s ease;
}

.reset-btn:hover .reset-icon {
    transform: rotate(180deg);
}

.winning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.winning-overlay.show {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.winning-message {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    border-radius: 30px;
    padding: 60px 80px;
    text-align: center;
    animation: scaleIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: var(--shadow-strong);
}

@keyframes scaleIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.winning-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: rotate 1s ease-in-out;
}

@keyframes rotate {
    from {
        transform: rotate(0deg) scale(0);
    }

    to {
        transform: rotate(360deg) scale(1);
    }
}

.winning-text {
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--success-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 30px;
}

.play-again-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
    background: var(--secondary-gradient);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.4);
}

.play-again-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(245, 87, 108, 0.6);
}

.play-again-btn:active {
    transform: translateY(-1px);
}

@media (max-width: 600px) {
    .game-wrapper {
        padding: 25px;
    }

    .title {
        font-size: 2rem;
        gap: 10px;
    }

    .title-icon {
        font-size: 1.8rem;
    }

    .status-bar {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .cell {
        font-size: 3rem;
    }

    .winning-message {
        padding: 40px 50px;
    }

    .winning-icon {
        font-size: 4rem;
    }

    .winning-text {
        font-size: 2rem;
    }
}