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

body {
    font-family: 'Arial', sans-serif;
    background: 
        linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400"><rect width="400" height="400" fill="%23000"/><circle cx="200" cy="150" r="80" fill="%23330000"/><circle cx="170" cy="130" r="15" fill="%23ff0000"/><circle cx="230" cy="130" r="15" fill="%23ff0000"/><rect x="190" y="160" width="20" height="30" fill="%23660000"/><path d="M150 220 Q200 250 250 220" stroke="%23ff0000" stroke-width="5" fill="none"/><rect x="180" y="200" width="8" height="15" fill="%23ffffff"/><rect x="200" y="200" width="8" height="15" fill="%23ffffff"/><rect x="220" y="200" width="8" height="15" fill="%23ffffff"/><text x="200" y="350" text-anchor="middle" font-size="20" fill="%23ff0000" font-family="serif">FREDDY</text></svg>') center/cover,
        linear-gradient(135deg, #1a0000 0%, #330000 50%, #1a0000 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 20%, rgba(255, 0, 0, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 0, 0, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 60%, rgba(139, 0, 0, 0.1) 0%, transparent 50%);
    animation: spookyGlow 4s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: -1;
}

@keyframes spookyGlow {
    0% { opacity: 0.3; }
    100% { opacity: 0.7; }
}

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

.modal-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(240, 240, 240, 0.95));
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(255, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    max-width: 600px;
    width: 90%;
    color: #333;
    border: 2px solid rgba(255, 0, 0, 0.3);
}

.player-setup {
    display: flex;
    gap: 30px;
    margin: 20px 0;
}

.player-config {
    flex: 1;
    text-align: center;
}

.player-config h3 {
    margin-bottom: 15px;
    color: #333;
}

.player-config input {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 10px;
    margin-bottom: 15px;
    font-size: 16px;
}

.avatar-selection {
    margin-top: 15px;
}

.avatar-options {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
}

.avatar-option {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
}

.avatar-option:hover {
    transform: scale(1.1);
}

.avatar-option.selected {
    border-color: #667eea;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
}

.upload-btn {
    padding: 8px 16px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.container {
    background: rgba(0, 0, 0, 0.8);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(255, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    max-width: 1000px;
    width: 100%;
    border: 2px solid rgba(255, 0, 0, 0.3);
}

h1 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #ff6b6b, #ff0000);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 15px;
    background: rgba(255, 0, 0, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(255, 0, 0, 0.3);
}

.current-player {
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.current-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #ff6b6b;
}

.score {
    display: flex;
    gap: 20px;
    font-weight: bold;
}

.game-area {
    display: flex;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
    margin-bottom: 30px;
}

.player-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 150px;
}

.left-player {
    order: 1;
}

.right-player {
    order: 3;
}

.board {
    order: 2;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background: #000;
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(255, 0, 0, 0.5);
    border: 2px solid rgba(255, 0, 0, 0.3);
}

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

.player-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #ff6b6b;
    margin-bottom: 10px;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.4);
}

.player-info h3 {
    color: #fff;
    font-size: 1.2rem;
}

.pieces {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
    padding: 15px;
    background: rgba(255, 0, 0, 0.1);
    border-radius: 10px;
    border: 2px dashed rgba(255, 0, 0, 0.3);
}

.piece {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: all 0.3s ease;
    user-select: none;
    border: 2px solid rgba(255, 0, 0, 0.3);
    background: rgba(0, 0, 0, 0.5);
}

.piece:active {
    cursor: grabbing;
}

.piece-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.piece:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(255, 0, 0, 0.5);
}

.piece.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.cell {
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    border: 2px solid rgba(255, 0, 0, 0.2);
}

.cell:hover {
    background: rgba(255, 0, 0, 0.2);
    transform: scale(1.05);
}

.cell.drag-over {
    background: rgba(255, 107, 107, 0.3);
    border: 3px dashed #ff6b6b;
}

.cell.occupied {
    cursor: not-allowed;
}

.cell.winning {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    animation: pulse 1s infinite;
}

.cell img {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    object-fit: cover;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(45deg, #ff6b6b, #ff0000);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
    border: 1px solid rgba(255, 0, 0, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

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

.message {
    text-align: center;
    font-size: 1.3rem;
    font-weight: bold;
    min-height: 30px;
    padding: 10px;
    border-radius: 10px;
    transition: all 0.3s ease;
    color: #fff;
}

.message.winner {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #333;
    animation: celebration 0.5s ease-in-out;
}

.message.tie {
    background: linear-gradient(45deg, #95a5a6, #7f8c8d);
    color: white;
}

.message.computer-thinking {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Winner Modal */
.winner-modal .modal-content {
    text-align: center;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #333;
}

.taco-celebration {
    position: relative;
    padding: 20px;
}

.taco {
    font-size: 5rem;
    animation: tacoSpin 2s ease-in-out infinite;
    display: block;
    margin-bottom: 20px;
}

@keyframes tacoSpin {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(10deg) scale(1.1); }
    50% { transform: rotate(0deg) scale(1.2); }
    75% { transform: rotate(-10deg) scale(1.1); }
}

.confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.confetti::before,
.confetti::after {
    content: '🎉';
    position: absolute;
    font-size: 2rem;
    animation: confettiFall 3s ease-in-out infinite;
}

.confetti::before {
    left: 20%;
    animation-delay: 0.5s;
}

.confetti::after {
    right: 20%;
    animation-delay: 1s;
}

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

/* Game History */
.game-history {
    margin-top: 30px;
    padding: 20px;
    background: rgba(255, 0, 0, 0.1);
    border-radius: 15px;
    border: 1px solid rgba(255, 0, 0, 0.3);
}

.game-history h3 {
    color: #fff;
    margin-bottom: 15px;
    text-align: center;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border-left: 4px solid #ff6b6b;
    color: #fff;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item.winner-x {
    border-left-color: #ff6b6b;
}

.history-item.winner-o {
    border-left-color: #4ecdc4;
}

.history-item.tie {
    border-left-color: #95a5a6;
}

.history-time {
    font-size: 0.8rem;
    opacity: 0.7;
}

@keyframes celebration {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
        margin: 10px;
    }
    
    .game-area {
        flex-direction: column;
        align-items: center;
    }
    
    .pieces-container {
        flex-direction: row;
        justify-content: center;
        gap: 20px;
    }
    
    .cell {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }
    
    .piece {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    h1 {
        font-size: 2rem;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
        margin: 10px;
    }
    
    .game-area {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    
    .player-side {
        flex-direction: row;
        min-width: auto;
        gap: 15px;
    }
    
    .pieces {
        flex-direction: row;
        min-height: auto;
        padding: 10px;
        gap: 5px;
    }
    
    .cell {
        width: 80px;
        height: 80px;
    }
    
    .piece {
        width: 50px;
        height: 50px;
    }
    
    .player-avatar {
        width: 60px;
        height: 60px;
    }
    
    .current-avatar {
        width: 30px;
        height: 30px;
    }
    
    .modal-content {
        padding: 20px;
        margin: 10px;
    }
    
    .player-setup {
        flex-direction: column;
        gap: 20px;
    }
    
    .avatar-options {
        gap: 5px;
    }
    
    .avatar-option {
        width: 40px;
        height: 40px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .game-info {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .score {
        gap: 15px;
    }
    
    .controls {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .board {
        gap: 5px;
        padding: 5px;
    }
    
    .cell {
        width: 70px;
        height: 70px;
    }
    
    .piece {
        width: 40px;
        height: 40px;
    }
    
    .player-avatar {
        width: 50px;
        height: 50px;
    }
    
    .game-history {
        padding: 15px;
    }
    
    .history-item {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}