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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

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

.nav {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.back-btn {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    transition: background 0.2s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.nav h1 {
    color: white;
    font-size: 2rem;
    font-weight: 700;
}

.main-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-height: 600px;
}

/* Menu Screen */
.menu-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 600px;
    padding: 40px;
}

.menu-content {
    text-align: center;
    max-width: 400px;
}

.menu-content h2 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 40px;
}

.difficulty-selector {
    margin-bottom: 40px;
}

.difficulty-selector h3 {
    font-size: 1.2rem;
    color: #555;
    margin-bottom: 15px;
}

.difficulty-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.difficulty-btn {
    padding: 10px 20px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.difficulty-btn:hover {
    border-color: #3498db;
    color: #3498db;
}

.difficulty-btn.active {
    background: #3498db;
    border-color: #3498db;
    color: white;
}

.game-mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.mode-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

.ai-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.ai-btn:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: translateY(-2px);
}

.player-btn {
    background: linear-gradient(135deg, #27ae60, #229954);
}

.player-btn:hover {
    background: linear-gradient(135deg, #229954, #1e8449);
    transform: translateY(-2px);
}

/* Game Screen */
.game-screen {
    padding: 20px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 10px;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.turn-indicator {
    font-size: 1.3rem;
    font-weight: 600;
    color: #2c3e50;
}

.game-status {
    font-size: 1rem;
    color: #7f8c8d;
    min-height: 20px;
}

.game-status.check {
    color: #e74c3c;
    font-weight: 600;
}

.back-menu-btn {
    padding: 10px 20px;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.back-menu-btn:hover {
    background: #3498db;
    color: white;
}

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

.captured-pieces {
    width: 120px;
    min-height: 200px;
}

.captured-pieces h4 {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 10px;
    text-align: center;
}

.captured-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
}

.captured-piece {
    font-size: 1.2rem;
    padding: 2px;
    border-radius: 4px;
    background: #f8f9fa;
}

/* Chessboard */
.chessboard-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 480px;
    height: 480px;
    border: 3px solid #2c3e50;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.chess-square {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.chess-square.light {
    background: #f0d9b5;
}

.chess-square.dark {
    background: #b58863;
}

.chess-square:hover {
    filter: brightness(1.1);
}

.chess-square.selected {
    background: #7fb3d5 !important;
    box-shadow: inset 0 0 0 3px #3498db;
}

.chess-square.possible-move {
    background: #82e082 !important;
}

.chess-square.possible-move::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 128, 0, 0.6);
}

.chess-square.possible-capture {
    background: #ff6b6b !important;
}

.chess-square.possible-capture::after {
    content: '';
    position: absolute;
    inset: 2px;
    border: 3px solid rgba(255, 0, 0, 0.7);
    border-radius: 4px;
}

.chess-square.last-move {
    background: #ffd93d !important;
}

.chess-piece {
    font-size: 3rem;
    user-select: none;
    pointer-events: none;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
                 0 0 1px rgba(0, 0, 0, 0.8);
    font-weight: bold;
    -webkit-text-stroke: 0.5px rgba(0, 0, 0, 0.3);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

/* White pieces - enhanced visibility */
.chess-piece.white-piece {
    color: #ffffff;
    text-shadow: 0 0 3px rgba(0, 0, 0, 1),
                 1px 1px 2px rgba(0, 0, 0, 0.8),
                 2px 2px 4px rgba(0, 0, 0, 0.6);
    -webkit-text-stroke: 1.5px #000000;
}

/* Black pieces - enhanced visibility */
.chess-piece.black-piece {
    color: #1a1a1a;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.9),
                 1px 1px 3px rgba(255, 255, 255, 0.7),
                 2px 2px 5px rgba(0, 0, 0, 0.5);
    -webkit-text-stroke: 0.8px rgba(255, 255, 255, 0.6);
}

/* Enhanced mobile visibility for pieces */
@media (max-width: 768px) {
    .chess-piece.white-piece {
        color: #ffffff;
        text-shadow: 0 0 4px rgba(0, 0, 0, 1),
                     1px 1px 3px rgba(0, 0, 0, 0.9),
                     2px 2px 5px rgba(0, 0, 0, 0.7),
                     -1px -1px 1px rgba(0, 0, 0, 0.5);
        -webkit-text-stroke: 2px #000000;
        font-weight: 900;
    }
    
    .chess-piece.black-piece {
        color: #000000;
        text-shadow: 0 0 3px rgba(255, 255, 255, 1),
                     1px 1px 4px rgba(255, 255, 255, 0.9),
                     2px 2px 6px rgba(255, 255, 255, 0.8),
                     -1px -1px 2px rgba(255, 255, 255, 0.7);
        -webkit-text-stroke: 1.5px rgba(255, 255, 255, 0.9);
        font-weight: 900;
    }
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.control-btn {
    padding: 12px 24px;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.control-btn:hover:not(:disabled) {
    background: #3498db;
    color: white;
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #bdc3c7;
    color: #bdc3c7;
}

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

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.modal-header {
    padding: 24px;
    text-align: center;
    background: #f8f9fa;
}

.modal-header h3 {
    font-size: 1.5rem;
    color: #2c3e50;
    font-weight: 700;
}

.modal-body {
    padding: 24px;
    text-align: center;
}

.modal-body p {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 24px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
}

.modal-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn.primary {
    background: #3498db;
    color: white;
}

.modal-btn.primary:hover {
    background: #2980b9;
}

.modal-btn.secondary {
    background: #ecf0f1;
    color: #7f8c8d;
}

.modal-btn.secondary:hover {
    background: #d5dbdb;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }
    
    .captured-pieces {
        width: 100%;
        max-width: 480px;
        order: 2;
        margin-top: 20px;
    }
    
    .chessboard {
        width: min(90vw, 400px);
        height: min(90vw, 400px);
    }
    
    .chess-square {
        font-size: calc(min(90vw, 400px) / 10);
    }
    
    .chess-piece {
        font-size: calc(min(90vw, 400px) / 10);
        text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.6),
                     0 0 2px rgba(0, 0, 0, 0.9),
                     1px 1px 0 rgba(255, 255, 255, 0.3);
        -webkit-text-stroke: 1px rgba(0, 0, 0, 0.4);
        filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
    }
    
    .game-controls {
        flex-wrap: wrap;
    }
    
    .control-btn {
        flex: 1;
        min-width: 140px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .nav h1 {
        font-size: 1.5rem;
    }
    
    .menu-content h2 {
        font-size: 2rem;
    }
    
    .difficulty-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .chessboard {
        width: min(95vw, 350px);
        height: min(95vw, 350px);
    }
    
    .chess-square {
        font-size: calc(min(95vw, 350px) / 9);
    }
    
    .chess-piece {
        font-size: calc(min(95vw, 350px) / 9);
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7),
                     0 0 3px rgba(0, 0, 0, 1),
                     1px 1px 0 rgba(255, 255, 255, 0.4);
        -webkit-text-stroke: 1.2px rgba(0, 0, 0, 0.5);
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
        font-weight: 900;
    }
}