@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Exo+2:wght@300;400;600;700&display=swap');

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

body {
    font-family: 'Exo 2', sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Animated Background */
.stars, .twinkling {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: -1;
}

.stars {
    background: #000 url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="10" cy="10" r="0.5" fill="white" opacity="0.8"/><circle cx="25" cy="30" r="0.3" fill="white" opacity="0.6"/><circle cx="40" cy="20" r="0.4" fill="white" opacity="0.7"/><circle cx="60" cy="40" r="0.2" fill="white" opacity="0.5"/><circle cx="80" cy="15" r="0.6" fill="white" opacity="0.9"/><circle cx="90" cy="35" r="0.3" fill="white" opacity="0.6"/><circle cx="15" cy="60" r="0.4" fill="white" opacity="0.7"/><circle cx="35" cy="80" r="0.2" fill="white" opacity="0.5"/><circle cx="70" cy="70" r="0.5" fill="white" opacity="0.8"/><circle cx="85" cy="90" r="0.3" fill="white" opacity="0.6"/></svg>') repeat;
    background-size: 400px 400px;
}

.twinkling {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="0.2" fill="white"><animate attributeName="opacity" values="0;1;0" dur="3s" repeatCount="indefinite"/></circle><circle cx="80" cy="80" r="0.2" fill="white"><animate attributeName="opacity" values="1;0;1" dur="4s" repeatCount="indefinite"/></circle><circle cx="60" cy="30" r="0.2" fill="white"><animate attributeName="opacity" values="0;1;0" dur="2s" repeatCount="indefinite"/></circle></svg>') repeat;
    background-size: 600px 600px;
    animation: move-twink-back 200s linear infinite;
}

@keyframes move-twink-back {
    from { background-position: 0 0; }
    to { background-position: -10000px 5000px; }
}

.game-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.title {
    font-family: 'Orbitron', monospace;
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 900;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.title-char {
    background: linear-gradient(45deg, #00d4ff, #0099cc, #0066aa, #003388);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(0, 212, 255, 0.5);
    animation: glow-pulse 2s ease-in-out infinite alternate;
    transition: transform 0.3s ease;
}

.title-char:hover {
    transform: scale(1.2) rotateY(180deg);
}

.title-space {
    width: 20px;
}

@keyframes glow-pulse {
    0% { text-shadow: 0 0 20px rgba(0, 212, 255, 0.5), 0 0 30px rgba(0, 212, 255, 0.3); }
    100% { text-shadow: 0 0 30px rgba(0, 212, 255, 0.8), 0 0 40px rgba(0, 212, 255, 0.5); }
}

.subtitle {
    color: #8892b0;
    font-size: 1.1rem;
    font-weight: 300;
    opacity: 0.8;
}

/* Game Info */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.turn-display {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 15px;
    padding: 15px 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.player-indicator {
    display: flex;
    align-items: center;
    gap: 15px;
}

.player-label {
    color: #8892b0;
    font-size: 0.9rem;
    font-weight: 400;
}

.current-player {
    background: linear-gradient(45deg, #00d4ff, #0099cc);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
    animation: player-pulse 1.5s ease-in-out infinite;
}

.cur-player {
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    font-family: 'Orbitron', monospace;
}

@keyframes player-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(0, 212, 255, 0.5); }
    50% { transform: scale(1.1); box-shadow: 0 0 30px rgba(0, 212, 255, 0.8); }
}

.score-board {
    display: flex;
    align-items: center;
    gap: 20px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 15px;
    padding: 15px 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

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

.score-label {
    color: #8892b0;
    font-size: 0.8rem;
    font-weight: 400;
}

.score-value {
    color: #00d4ff;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Orbitron', monospace;
}

.score-divider {
    width: 2px;
    height: 30px;
    background: linear-gradient(180deg, transparent, #00d4ff, transparent);
}

/* Game Board */
.game-board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
    position: relative;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 120px);
    grid-template-rows: repeat(3, 120px);
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(15px);
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(90deg, transparent 0%, rgba(0, 212, 255, 0.1) 50%, transparent 100%),
        linear-gradient(0deg, transparent 0%, rgba(0, 212, 255, 0.1) 50%, transparent 100%);
    animation: grid-scan 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes grid-scan {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

.box {
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(0, 212, 255, 0.2);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.box:hover {
    border-color: rgba(0, 212, 255, 0.6);
    background: rgba(0, 212, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 212, 255, 0.3);
}

.box.filled {
    pointer-events: none;
}

.box.winner {
    background: rgba(0, 212, 255, 0.2) !important;
    border-color: #00d4ff !important;
    animation: winner-glow 1s ease-in-out infinite alternate;
}

@keyframes winner-glow {
    0% { box-shadow: 0 0 20px rgba(0, 212, 255, 0.5); }
    100% { box-shadow: 0 0 40px rgba(0, 212, 255, 0.8), inset 0 0 20px rgba(0, 212, 255, 0.3); }
}

.box-content {
    font-size: 3rem;
    font-weight: 700;
    font-family: 'Orbitron', monospace;
    z-index: 2;
    position: relative;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    opacity: 0;
    transform: scale(0) rotate(180deg);
}

.box-content.show {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.box-content.x {
    color: #ff6b6b;
    text-shadow: 0 0 20px rgba(255, 107, 107, 0.6);
}

.box-content.o {
    color: #4ecdc4;
    text-shadow: 0 0 20px rgba(78, 205, 196, 0.6);
}

.hover-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
    pointer-events: none;
}

.box:hover .hover-effect {
    width: 100px;
    height: 100px;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.reset-btn, .new-game-btn, .play-again-btn, .draw-play-again-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 50px;
    padding: 15px 30px;
    color: #00d4ff;
    font-family: 'Orbitron', monospace;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.reset-btn:hover, .new-game-btn:hover, .play-again-btn:hover, .draw-play-again-btn:hover {
    border-color: #00d4ff;
    background: rgba(0, 212, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 212, 255, 0.3);
}

.btn-text {
    position: relative;
    z-index: 2;
}

.btn-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.reset-btn:hover .btn-glow, .new-game-btn:hover .btn-glow, 
.play-again-btn:hover .btn-glow, .draw-play-again-btn:hover .btn-glow {
    left: 100%;
}

/* Winning Overlay */
.winning-overlay, .draw-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.winning-overlay.show, .draw-overlay.show {
    opacity: 1;
    visibility: visible;
}

.winning-content, .draw-content {
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 30px;
    padding: 50px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.5);
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.winning-overlay.show .winning-content, .draw-overlay.show .draw-content {
    transform: scale(1);
}

.trophy-container {
    position: relative;
    margin-bottom: 30px;
}

.trophy {
    font-size: 5rem;
    animation: trophy-bounce 2s ease-in-out infinite;
}

.trophy-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    animation: glow-pulse 2s ease-in-out infinite alternate;
}

@keyframes trophy-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.winner-text {
    font-family: 'Orbitron', monospace;
    font-size: 2.5rem;
    font-weight: 900;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.winner-player {
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 3rem;
}

.winner-label {
    color: #00d4ff;
    text-shadow: 0 0 30px rgba(0, 212, 255, 0.6);
}

.celebration-text {
    color: #8892b0;
    font-size: 1.2rem;
    margin-bottom: 30px;
    opacity: 0.9;
}

.draw-icon {
    font-size: 5rem;
    margin-bottom: 30px;
    animation: trophy-bounce 2s ease-in-out infinite;
}

.draw-text {
    font-family: 'Orbitron', monospace;
    font-size: 2.5rem;
    font-weight: 900;
    color: #00d4ff;
    text-shadow: 0 0 30px rgba(0, 212, 255, 0.6);
    margin-bottom: 20px;
}

.draw-subtitle {
    color: #8892b0;
    font-size: 1.2rem;
    margin-bottom: 30px;
    opacity: 0.9;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container {
        padding: 15px;
    }
    
    .game-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .game-board {
        grid-template-columns: repeat(3, 100px);
        grid-template-rows: repeat(3, 100px);
        gap: 6px;
        padding: 15px;
    }
    
    .box-content {
        font-size: 2.5rem;
    }
    
    .winning-content, .draw-content {
        padding: 30px;
        margin: 20px;
    }
    
    .winner-text, .draw-text {
        font-size: 2rem;
    }
    
    .controls {
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .game-board {
        grid-template-columns: repeat(3, 80px);
        grid-template-rows: repeat(3, 80px);
        gap: 4px;
        padding: 10px;
    }
    
    .box-content {
        font-size: 2rem;
    }
    
    .title {
        font-size: 2rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
}