/* Native American Themed Tic Tac Toe Styles */

:root {
    /* Earth and Nature Colors */
    --primary-brown: #8B4513;
    --secondary-brown: #A0522D;
    --light-brown: #DEB887;
    --dark-brown: #654321;
    --turquoise: #40E0D0;
    --feather-white: #FFF8DC;
    --shell-pearl: #FFF5EE;
    --forest-green: #228B22;
    --sunset-orange: #FF6B35;
    --sky-blue: #87CEEB;
    --sand: #F5DEB3;
    --shadow: rgba(0, 0, 0, 0.3);
    --grass-green: #7CFC00;
    --flower-pink: #FF69B4;
    --flower-yellow: #FFD700;
}

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

body {
    font-family: 'Cinzel', serif;
    background: linear-gradient(135deg, #8B4513 0%, #DEB887 50%, #87CEEB 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

body::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(255, 107, 53, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(64, 224, 208, 0.1) 0%, transparent 50%);
    animation: floatBackground 20s ease-in-out infinite;
}

@keyframes floatBackground {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(-5%, -5%) rotate(120deg); }
    66% { transform: translate(5%, -5%) rotate(240deg); }
}

#game-container {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    position: relative;
    z-index: 1;
}

/* Screens */
.screen {
    display: none;
    width: 100%;
    height: 100vh;
    padding: 20px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Start Screen */
.title-container {
    text-align: center;
    margin-bottom: 40px;
}

.game-title {
    font-family: 'Uncial Antiqua', cursive;
    font-size: clamp(2.5rem, 8vw, 4rem);
    color: var(--feather-white);
    text-shadow: 
        3px 3px 6px var(--shadow),
        0 0 20px rgba(64, 224, 208, 0.5);
    margin-bottom: 10px;
    animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 3px 3px 6px var(--shadow), 0 0 20px rgba(64, 224, 208, 0.5); }
    50% { text-shadow: 3px 3px 6px var(--shadow), 0 0 30px rgba(64, 224, 208, 0.8); }
}

.subtitle {
    font-size: clamp(1rem, 3vw, 1.3rem);
    color: var(--shell-pearl);
    opacity: 0.9;
}

.menu-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 300px;
}

.menu-btn, .back-btn, .control-btn, .modal-btn, .reset-stats-btn {
    background: linear-gradient(145deg, var(--primary-brown), var(--secondary-brown));
    color: var(--feather-white);
    border: 2px solid var(--dark-brown);
    padding: 15px 30px;
    font-size: 1.1rem;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 
        0 4px 6px var(--shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: 'Cinzel', serif;
    font-weight: 600;
}

.menu-btn:hover, .back-btn:hover, .control-btn:hover, .modal-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 
        0 6px 12px var(--shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    background: linear-gradient(145deg, var(--secondary-brown), var(--primary-brown));
}

.btn-icon {
    font-size: 1.3rem;
}

.decorative-border {
    position: absolute;
    bottom: 20px;
    width: 80%;
    height: 3px;
    background: linear-gradient(90deg, 
        transparent, 
        var(--turquoise) 20%, 
        var(--sunset-orange) 50%, 
        var(--turquoise) 80%, 
        transparent);
    border-radius: 2px;
}

/* Game Mode Selection */
.game-mode-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
    width: 100%;
    max-width: 400px;
    margin-bottom: 40px;
}

.mode-btn {
    background: linear-gradient(145deg, rgba(139, 69, 19, 0.9), rgba(160, 82, 45, 0.9));
    backdrop-filter: blur(10px);
    border: 3px solid var(--dark-brown);
    border-radius: 20px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: 0 5px 15px var(--shadow);
}

.mode-btn:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 8px 20px var(--shadow);
    background: linear-gradient(145deg, var(--turquoise), rgba(64, 224, 208, 0.7));
}

.mode-icon {
    font-size: 2.5rem;
}

.mode-title {
    font-family: 'Uncial Antiqua', cursive;
    font-size: 1.5rem;
    color: var(--feather-white);
    text-shadow: 1px 1px 2px var(--shadow);
}

.mode-desc {
    font-size: 0.9rem;
    color: var(--shell-pearl);
    opacity: 0.9;
}

/* Settings Screen */
.screen-header {
    text-align: center;
    margin-bottom: 40px;
}

.screen-header h2 {
    font-family: 'Uncial Antiqua', cursive;
    font-size: clamp(2rem, 6vw, 3rem);
    color: var(--feather-white);
    text-shadow: 2px 2px 4px var(--shadow);
}

.settings-container {
    background: rgba(139, 69, 19, 0.3);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    border: 2px solid var(--dark-brown);
    box-shadow: 0 8px 16px var(--shadow);
    width: 100%;
    max-width: 400px;
    margin-bottom: 30px;
}

.setting-item {
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.setting-label {
    font-size: 1.2rem;
    color: var(--feather-white);
    text-shadow: 1px 1px 2px var(--shadow);
}

/* Toggle Switch */
.toggle-container {
    display: flex;
    align-items: center;
}

.toggle-switch {
    position: relative;
    width: 60px;
    height: 30px;
    background: var(--dark-brown);
    border-radius: 15px;
    cursor: pointer;
    transition: background 0.3s;
}

#audio-toggle, #music-toggle {
    display: none;
}

#audio-toggle:checked + .toggle-switch,
#music-toggle:checked + .toggle-switch {
    background: var(--forest-green);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 26px;
    height: 26px;
    background: var(--feather-white);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px var(--shadow);
}

#audio-toggle:checked + .toggle-switch::after,
#music-toggle:checked + .toggle-switch::after {
    transform: translateX(30px);
}

/* Difficulty and Symbol Selectors */
.difficulty-selector, .symbol-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.diff-btn, .symbol-btn {
    flex: 1;
    padding: 10px 15px;
    background: var(--dark-brown);
    color: var(--feather-white);
    border: 2px solid var(--primary-brown);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Cinzel', serif;
    min-width: 80px;
}

.diff-btn.active, .symbol-btn.active {
    background: var(--turquoise);
    color: var(--dark-brown);
    transform: scale(1.05);
    box-shadow: 0 4px 8px var(--shadow);
}

.diff-btn:hover, .symbol-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

/* Stats Screen - Fixed Layout */
.stats-scroll-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 500px;
    height: 100%;
    overflow-y: auto;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    width: 100%;
    margin-bottom: 30px;
    background: rgba(139, 69, 19, 0.3);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    border: 2px solid var(--dark-brown);
    box-shadow: 0 8px 16px var(--shadow);
}

.stat-card {
    background: linear-gradient(145deg, rgba(64, 224, 208, 0.2), rgba(255, 107, 53, 0.2));
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    border: 2px solid var(--dark-brown);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card.full-width {
    grid-column: 1 / -1;
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 2rem;
    color: var(--feather-white);
    font-weight: bold;
    text-shadow: 2px 2px 4px var(--shadow);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--shell-pearl);
    margin-top: 5px;
}

.stats-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 300px;
}

.reset-stats-btn {
    background: linear-gradient(145deg, var(--sunset-orange), #FF8C42);
}

/* Game Screen */
.game-header {
    background: rgba(139, 69, 19, 0.4);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 15px 25px;
    margin-bottom: 30px;
    border: 2px solid var(--dark-brown);
    box-shadow: 0 4px 8px var(--shadow);
    width: 100%;
    max-width: 500px;
}

.score-display {
    text-align: center;
    color: var(--feather-white);
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.score-separator {
    margin: 0 15px;
    color: var(--turquoise);
}

.turn-indicator {
    text-align: center;
    font-size: 1.2rem;
    color: var(--turquoise);
    font-weight: 600;
    text-shadow: 1px 1px 2px var(--shadow);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Game Board */
.game-board {
    position: relative;
    width: min(90vw, 450px);
    height: min(90vw, 450px);
    margin: 0 auto 30px;
    background: radial-gradient(circle, rgba(222, 184, 135, 0.3), rgba(139, 69, 19, 0.3));
    border-radius: 20px;
    padding: 10px;
    box-shadow: 
        0 10px 30px var(--shadow),
        inset 0 2px 5px rgba(255, 255, 255, 0.2);
    border: 3px solid var(--dark-brown);
}

#game-canvas {
    width: 100%;
    height: 100%;
    border-radius: 15px;
}

.board-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
    pointer-events: all;
}

.cell {
    background: rgba(255, 248, 220, 0.1);
    border: 2px solid rgba(139, 69, 19, 0.3);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.cell:hover:not(.occupied) {
    background: rgba(64, 224, 208, 0.2);
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(64, 224, 208, 0.3);
}

.cell.occupied {
    cursor: not-allowed;
    animation: placeSymbol 0.5s ease;
}

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

.cell.winner {
    animation: winnerGlow 1s ease infinite;
}

@keyframes winnerGlow {
    0%, 100% { 
        background: rgba(255, 215, 0, 0.3);
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    }
    50% { 
        background: rgba(255, 215, 0, 0.5);
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    }
}

/* Celebration Container */
.celebration-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 100;
}

.grass-blade {
    position: absolute;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to top, var(--forest-green), var(--grass-green));
    border-radius: 2px 2px 0 0;
    animation: growGrass 2s ease-out forwards;
    transform-origin: bottom center;
}

@keyframes growGrass {
    from { 
        height: 0;
        transform: scaleX(0);
    }
    to { 
        height: 60px;
        transform: scaleX(1) rotate(var(--rotation));
    }
}

.flower {
    position: absolute;
    width: 30px;
    height: 30px;
    animation: bloomFlower 1.5s ease-out forwards;
    transform: scale(0);
}

.flower::before {
    content: '🌸';
    font-size: 30px;
    position: absolute;
    animation: rotateFlower 3s linear infinite;
}

.flower.yellow::before {
    content: '🌻';
}

.flower.red::before {
    content: '🌺';
}

.flower.white::before {
    content: '🌼';
}

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

@keyframes rotateFlower {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.butterfly {
    position: absolute;
    font-size: 25px;
    animation: flyButterfly 8s ease-in-out infinite;
}

@keyframes flyButterfly {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(50px, -30px) rotate(10deg);
    }
    50% {
        transform: translate(100px, 0) rotate(-10deg);
    }
    75% {
        transform: translate(50px, 30px) rotate(5deg);
    }
}

.game-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.control-btn {
    padding: 12px 25px;
    font-size: 1rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: linear-gradient(145deg, var(--primary-brown), var(--secondary-brown));
    border-radius: 25px;
    padding: 40px;
    text-align: center;
    border: 3px solid var(--dark-brown);
    box-shadow: 0 10px 40px var(--shadow);
    max-width: 90%;
    animation: modalSlide 0.5s ease;
}

@keyframes modalSlide {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

#modal-title {
    font-family: 'Uncial Antiqua', cursive;
    font-size: 2.5rem;
    color: var(--turquoise);
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px var(--shadow);
}

#modal-message {
    font-size: 1.2rem;
    color: var(--feather-white);
    margin-bottom: 30px;
}

.modal-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-btn {
    min-width: 120px;
    padding: 12px 20px;
    font-size: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .screen {
        padding: 15px;
    }
    
    .game-title {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .menu-btn, .back-btn {
        padding: 12px 25px;
        font-size: 1rem;
    }
    
    .settings-container, .stats-container {
        padding: 20px;
    }
    
    .game-board {
        width: 85vw;
        height: 85vw;
    }
    
    .cell {
        font-size: 2.5rem;
    }
    
    .modal-content {
        padding: 30px 20px;
    }
    
    #modal-title {
        font-size: 2rem;
    }
    
    .mode-btn {
        padding: 20px;
    }
    
    .mode-title {
        font-size: 1.3rem;
    }
    
    .mode-icon {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 2rem;
    }
    
    .screen-header h2 {
        font-size: 1.8rem;
    }
    
    .diff-btn, .symbol-btn {
        min-width: 70px;
        font-size: 0.9rem;
        padding: 8px 10px;
    }
    
    .game-header {
        padding: 12px 20px;
    }
    
    .score-display {
        font-size: 1rem;
    }
    
    .turn-indicator {
        font-size: 1.1rem;
    }
    
    .cell {
        font-size: 2rem;
    }
    
    .control-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .stats-scroll-container {
        padding: 10px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-icon {
        font-size: 1.5rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
}

/* Loading Animation */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Touch feedback for mobile */
@media (hover: none) {
    .menu-btn:active, .back-btn:active, 
    .control-btn:active, .modal-btn:active,
    .diff-btn:active, .symbol-btn:active,
    .mode-btn:active {
        transform: scale(0.95);
    }
    
    .cell:active:not(.occupied) {
        transform: scale(0.95);
        background: rgba(64, 224, 208, 0.3);
    }
}