body {
    font-family: Arial, sans-serif;
    text-align: center;
    background-color: #f0f0f0;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 400px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

h1 {
    color: #333;
    margin-bottom: 20px;
}

.game-info {
    margin-bottom: 20px;
    font-size: 18px;
}

.current-player {
    font-weight: bold;
    font-size: 24px;
    padding: 8px 16px;
    border-radius: 8px;
    display: inline-block;
    margin: 0 8px;
    transition: all 0.3s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.current-player.player-o {
    color: #ffffff;
    background: linear-gradient(135deg, #3498db, #2980b9);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.current-player.player-x {
    color: #ffffff;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 2px;
    margin: 20px auto;
    max-width: 300px;
    background-color: #2c3e50;
    padding: 8px;
    border-radius: 12px;
    border: 4px solid #34495e;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.cell {
    width: 90px;
    height: 90px;
    background-color: #ffffff;
    border: 1px solid #ecf0f1;
    font-size: 36px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cell:hover {
    background-color: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

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

.cell.x {
    color: #e74c3c;
    text-shadow: 0 2px 4px rgba(231, 76, 60, 0.3);
}

.cell.o {
    color: #3498db;
    text-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

.reset-button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 20px;
    transition: background-color 0.2s;
}

.reset-button:hover {
    background-color: #218838;
}

.winner-announcement {
    font-size: 24px;
    font-weight: bold;
    margin-top: 20px;
    padding: 10px;
    border-radius: 5px;
}

.winner {
    background-color: #d4edda;
    color: #155724;
}

.draw {
    background-color: #fff3cd;
    color: #856404;
}

.score {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

.score div {
    font-weight: bold;
}

.mode-selection, .symbol-selection {
    margin-bottom: 20px;
}

.mode-button, .symbol-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    margin: 0 5px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.mode-button:hover, .symbol-button:hover {
    background-color: #0056b3;
}

.mode-button.active, .symbol-button.active {
    background-color: #28a745;
}

.symbol-selection {
    display: none;
}

.symbol-selection.show {
    display: block;
}

.difficulty-selection {
    margin-bottom: 20px;
    display: none;
}

.difficulty-selection.show {
    display: block;
}

.difficulty-button {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 6px 12px;
    margin: 0 3px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
}

.difficulty-button:hover {
    background-color: #5a6268;
}

.difficulty-button.active {
    background-color: #ffc107;
    color: #212529;
}

.thinking {
    color: #ffc107;
    font-style: italic;
}

.ai-indicator {
    display: inline-block;
    margin-left: 5px;
    font-size: 14px;
    color: #dc3545;
}

.audio-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
}

.audio-button {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.audio-button:hover {
    background-color: #5a6268;
}

.audio-button.muted {
    background-color: #dc3545;
}

.theme-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theme-button {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.theme-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.theme-button:active {
    transform: translateY(0);
}

.theme-button#colorBlindToggle {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.theme-button#colorBlindToggle.active {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* Background Theme Selection */
.background-theme-selection {
    margin-bottom: 20px;
}

.theme-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.bg-theme-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background-color: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px;
    min-width: 70px;
}

.bg-theme-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.bg-theme-button.active {
    border-color: #007bff;
    background-color: #e7f3ff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.theme-preview {
    width: 30px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

.default-preview {
    background: linear-gradient(135deg, #f0f0f0 0%, #ffffff 100%);
}

.space-preview {
    background: linear-gradient(135deg, #000428 0%, #004e92 100%);
    position: relative;
}

.space-preview::after {
    content: '✦';
    position: absolute;
    color: white;
    font-size: 8px;
    top: 2px;
    right: 3px;
}

.ocean-preview {
    background: linear-gradient(135deg, #006994 0%, #0093E6 50%, #00D4FF 100%);
}

.forest-preview {
    background: linear-gradient(135deg, #2F5233 0%, #4A7C59 50%, #6BAA75 100%);
}

/* Particle Effects */
.particle-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.particle {
    position: absolute;
    pointer-events: none;
    z-index: 1001;
}

.firework {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    animation: firework 1.5s ease-out forwards;
}

.star {
    color: #FFD700;
    font-size: 16px;
    animation: starfall 2s ease-out forwards;
}

@keyframes firework {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(0) rotate(360deg);
        opacity: 0;
    }
}

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

@keyframes bubble-rise {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    50% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(-100vh) scale(0.5);
        opacity: 0;
    }
}

@keyframes leaf-fall {
    0% {
        transform: translateY(-50px) rotate(0deg);
        opacity: 1;
    }
    25% {
        transform: translateY(25vh) rotate(90deg);
    }
    50% {
        transform: translateY(50vh) rotate(180deg);
    }
    75% {
        transform: translateY(75vh) rotate(270deg);
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Background Theme Styles */
body.space-theme {
    background: linear-gradient(135deg, #000428 0%, #004e92 100%);
    position: relative;
}

body.space-theme::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, #eee, transparent),
        radial-gradient(2px 2px at 40px 70px, #fff, transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(1px 1px at 130px 80px, #fff, transparent),
        radial-gradient(2px 2px at 160px 30px, #ddd, transparent);
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: twinkle 10s infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes twinkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

body.ocean-theme {
    background: linear-gradient(135deg, #006994 0%, #0093E6 50%, #00D4FF 100%);
    position: relative;
}

body.ocean-theme::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(255,255,255,0.2) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(255,255,255,0.1) 0%, transparent 50%);
    background-size: 100px 100px;
    animation: wave 8s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

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

body.forest-theme {
    background: linear-gradient(135deg, #2F5233 0%, #4A7C59 50%, #6BAA75 100%);
    position: relative;
}

body.forest-theme::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(107,170,117,0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(74,124,89,0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(47,82,51,0.2) 0%, transparent 50%);
    background-size: 150px 150px;
    animation: forest-breath 12s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes forest-breath {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Theme-specific Container Styles */
body.space-theme .container {
    background: rgba(45, 45, 45, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.ocean-theme .container {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 150, 230, 0.3);
}

body.forest-theme .container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(107, 170, 117, 0.3);
}

/* Responsive Design - Mobile Support */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        max-width: 100%;
        padding: 15px;
        margin: 0;
    }
    
    h1 {
        font-size: 24px;
        margin-bottom: 15px;
    }
    
    .game-info {
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    .game-board {
        max-width: 90vw;
        grid-gap: 2px;
        padding: 6px;
        border: 3px solid #34495e;
    }
    
    .cell {
        width: calc(90vw / 3 - 6px);
        height: calc(90vw / 3 - 6px);
        max-width: 100px;
        max-height: 100px;
        min-width: 60px;
        min-height: 60px;
        font-size: 28px;
        /* Touch operation optimization */
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .mode-button, .symbol-button {
        padding: 12px 20px;
        margin: 5px;
        font-size: 14px;
        min-height: 44px;
        min-width: 44px;
    }
    
    .difficulty-button {
        padding: 10px 16px;
        margin: 3px;
        font-size: 13px;
        min-height: 44px;
    }
    
    .reset-button {
        padding: 15px 25px;
        font-size: 16px;
        min-height: 44px;
    }
    
    .score {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .winner-announcement {
        font-size: 20px;
        padding: 15px;
    }
    
    .audio-controls {
        position: relative;
        top: 0;
        right: 0;
        justify-content: center;
        margin-bottom: 15px;
    }
    
    .theme-controls {
        position: relative;
        top: 0;
        left: 0;
        flex-direction: row;
        justify-content: center;
        margin-bottom: 15px;
    }
    
    .theme-button {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
    
    .audio-button {
        padding: 8px 12px;
        font-size: 14px;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    .game-info {
        font-size: 14px;
    }
    
    .cell {
        font-size: 24px;
    }
    
    .mode-button, .symbol-button {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    .difficulty-button {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .reset-button {
        padding: 12px 20px;
        font-size: 15px;
    }
    
    .winner-announcement {
        font-size: 18px;
        padding: 12px;
    }
}

/* Touch Device Specific Optimizations */
@media (hover: none) and (pointer: coarse) {
    .cell:hover,
    .mode-button:hover,
    .symbol-button:hover,
    .difficulty-button:hover,
    .reset-button:hover,
    .audio-button:hover {
        background-color: initial;
    }
    
    .cell:active {
        background-color: #e9ecef;
        transform: scale(0.95);
    }
    
    .mode-button:active,
    .symbol-button:active {
        background-color: #004085;
        transform: scale(0.95);
    }
    
    .difficulty-button:active {
        background-color: #495057;
        transform: scale(0.95);
    }
    
    .reset-button:active {
        background-color: #1e7e34;
        transform: scale(0.95);
    }
    
    .audio-button:active {
        background-color: #495057;
        transform: scale(0.95);
    }
}

/* Animation Keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.3);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes winningGlow {
    0%, 100% {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        background-color: #ffffff;
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.6);
        background-color: #fff9c4;
    }
}

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

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-10deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* Animation Classes */
.cell.fade-in {
    animation: fadeIn 0.4s ease-out;
}

.cell.bounce-in {
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.cell.winning-cell {
    animation: winningGlow 1.5s ease-in-out infinite;
    z-index: 10;
    position: relative;
}

.winner-announcement.animate {
    animation: pulse 0.8s ease-in-out;
}

/* Dark Mode Styles */
body.dark-mode {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

body.dark-mode .container {
    background: #2d2d2d;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body.dark-mode h1 {
    color: #ffffff;
}

body.dark-mode .game-board {
    background-color: #1e1e1e;
    border-color: #404040;
}

body.dark-mode .cell {
    background-color: #3a3a3a;
    border-color: #505050;
    color: #ffffff;
}

body.dark-mode .cell:hover {
    background-color: #4a4a4a;
}

body.dark-mode .score {
    background-color: #3a3a3a;
}

body.dark-mode .mode-button,
body.dark-mode .symbol-button {
    background-color: #404040;
}

body.dark-mode .mode-button:hover,
body.dark-mode .symbol-button:hover {
    background-color: #505050;
}

body.dark-mode .mode-button.active,
body.dark-mode .symbol-button.active {
    background-color: #28a745;
}

body.dark-mode .difficulty-button {
    background-color: #505050;
}

body.dark-mode .difficulty-button:hover {
    background-color: #606060;
}

body.dark-mode .difficulty-button.active {
    background-color: #ffc107;
    color: #212529;
}

body.dark-mode .reset-button {
    background-color: #28a745;
}

body.dark-mode .reset-button:hover {
    background-color: #218838;
}

body.dark-mode .audio-button {
    background-color: #505050;
}

body.dark-mode .audio-button:hover {
    background-color: #606060;
}

body.dark-mode .winner-announcement.winner {
    background-color: #2d5016;
    color: #d4edda;
}

body.dark-mode .winner-announcement.draw {
    background-color: #664d03;
    color: #fff3cd;
}

/* Color Blind Mode */
body.colorblind-mode .current-player.player-o {
    background: linear-gradient(135deg, #0077be, #005a8b);
}

body.colorblind-mode .current-player.player-x {
    background: linear-gradient(135deg, #d2691e, #a0522d);
}

body.colorblind-mode .cell.o {
    color: #0077be;
}

body.colorblind-mode .cell.x {
    color: #d2691e;
}

body.colorblind-mode .mode-button.active,
body.colorblind-mode .symbol-button.active {
    background-color: #0077be;
}

body.colorblind-mode .difficulty-button.active {
    background-color: #d2691e;
    color: #ffffff;
}

body.colorblind-mode .reset-button {
    background-color: #0077be;
}

body.colorblind-mode .reset-button:hover {
    background-color: #005a8b;
}

/* Dark Mode + Color Blind Mode Combination */
body.dark-mode.colorblind-mode .current-player.player-o {
    background: linear-gradient(135deg, #4da6d9, #0077be);
}

body.dark-mode.colorblind-mode .current-player.player-x {
    background: linear-gradient(135deg, #ff8c42, #d2691e);
}

/* Landscape Mode (Horizontal) Adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 18px;
        margin-bottom: 10px;
    }
    
    .game-info {
        font-size: 14px;
        margin-bottom: 10px;
    }
    
    .game-board {
        max-width: 40vh;
        border: 3px solid #34495e;
        padding: 6px;
    }
    
    .cell {
        width: calc(40vh / 3 - 6px);
        height: calc(40vh / 3 - 6px);
        font-size: 20px;
    }
    
    .mode-selection,
    .symbol-selection,
    .difficulty-selection {
        margin-bottom: 10px;
    }
    
    .winner-announcement {
        font-size: 16px;
        padding: 8px;
    }
}