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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.visitor-counter {
    font-size: 1.2em;
    opacity: 0.9;
}

.game-controls {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.grid-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.win-length-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.grid-selector label {
    font-weight: bold;
    font-size: 1.1em;
}

.grid-selector select,
.grid-selector input {
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 1em;
    outline: none;
    transition: border-color 0.3s;
}

.grid-selector select:focus,
.grid-selector input:focus {
    border-color: #764ba2;
}

.grid-selector input[type="number"] {
    width: 120px;
}

button {
    padding: 10px 20px;
    font-size: 1em;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#apply-grid-size {
    background: #667eea;
    color: white;
}

#apply-grid-size:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.game-buttons {
    display: flex;
    gap: 10px;
}

#new-game {
    background: #48bb78;
    color: white;
}

#new-game:hover {
    background: #38a169;
    transform: translateY(-2px);
}

#reset-game {
    background: #f56565;
    color: white;
}

#reset-game:hover {
    background: #e53e3e;
    transform: translateY(-2px);
}

.game-info {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.turn-indicator {
    font-size: 1.3em;
    font-weight: bold;
}

#current-player {
    color: #667eea;
    font-size: 1.2em;
}

.game-status {
    font-size: 1.3em;
    font-weight: bold;
    color: #48bb78;
}

.game-status.winner {
    color: #f6ad55;
    animation: pulse 1s infinite;
}

.game-status.draw {
    color: #4299e1;
}

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

.board-container {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
}

.game-board {
    display: grid;
    gap: 2px;
    background: #667eea;
    padding: 2px;
    border-radius: 0;
    margin: 0 auto;
    overflow: hidden;
}

.cell {
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.cell:hover:not(.filled) {
    background: #e6e6ff;
    transform: scale(0.95);
}

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

.cell.x {
    color: #667eea;
}

.cell.o {
    color: #f6ad55;
}

.cell.winning {
    background: #ffd700;
    animation: highlight 0.6s ease-in-out;
}

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

/* Responsive grid sizing */
.game-board.small-grid .cell {
    width: 80px;
    height: 80px;
    font-size: 2em;
}

.game-board.medium-grid .cell {
    width: 50px;
    height: 50px;
    font-size: 1.5em;
}

.game-board.large-grid .cell {
    width: 30px;
    height: 30px;
    font-size: 1em;
}

.game-board.xlarge-grid .cell {
    width: 20px;
    height: 20px;
    font-size: 0.8em;
}

.game-board.xxlarge-grid .cell {
    width: 12px;
    height: 12px;
    font-size: 0.6em;
}

/* Mobile responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }

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

    .grid-selector {
        justify-content: center;
    }

    .game-buttons {
        justify-content: center;
    }

    .game-info {
        flex-direction: column;
        text-align: center;
    }

    .game-board.small-grid .cell {
        width: 60px;
        height: 60px;
        font-size: 1.5em;
    }

    .game-board.medium-grid .cell {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }

    .game-board.large-grid .cell {
        width: 25px;
        height: 25px;
        font-size: 0.8em;
    }

    .game-board.xlarge-grid .cell {
        width: 18px;
        height: 18px;
        font-size: 0.6em;
    }

    .game-board.xxlarge-grid .cell {
        width: 10px;
        height: 10px;
        font-size: 0.5em;
    }
}
