* {
    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%);
    color: #333;
    min-height: 100vh;
}

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

.header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 2.5em;
    color: #2c3e50;
    margin-bottom: 15px;
}

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

.controls select, .controls button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.controls select {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
}

.controls button {
    background: #007bff;
    color: white;
}

.controls button:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

.game-container {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 20px;
    align-items: start;
}

.left-panel, .right-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.left-panel h3, .right-panel h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.game-status {
    margin-bottom: 30px;
}

.game-status div {
    padding: 10px;
    margin: 5px 0;
    background: #f8f9fa;
    border-radius: 8px;
    font-weight: 500;
}

.move-history {
    margin-bottom: 30px;
}

#move-list {
    max-height: 200px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
    font-family: monospace;
    font-size: 14px;
}

.move-item {
    padding: 2px 0;
    border-bottom: 1px solid #dee2e6;
}

.move-item:last-child {
    border-bottom: none;
}

.game-controls {
    margin-bottom: 30px;
}

.control-group {
    margin: 10px 0;
}

.control-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.control-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.analysis-panel {
    background: #e8f5e8;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    display: none;
}

.analysis-panel.active {
    display: block;
}

.analysis-panel div {
    margin: 8px 0;
    font-weight: 500;
}

.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.chess-board {
    width: 480px;
    height: 480px;
    border: 4px solid #8B4513;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    background: #f0d9b5;
}

.square {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 36px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

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

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

.square.highlighted {
    background-color: #ffeb3b !important;
    box-shadow: inset 0 0 0 3px #fbc02d;
}

.square.selected {
    background-color: #4caf50 !important;
    box-shadow: inset 0 0 0 3px #2e7d32;
}

.square.valid-move {
    background-color: #81c784 !important;
}

.square.valid-move::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: rgba(76, 175, 80, 0.7);
}

.square.capture-move {
    background-color: #f44336 !important;
}

.square.capture-move::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid #d32f2f;
    border-radius: 50%;
    pointer-events: none;
}

.square.last-move {
    background-color: #ffcc80 !important;
}

.square.best-move {
    background-color: #e1bee7 !important;
    box-shadow: inset 0 0 0 3px #8e24aa;
}

.piece {
    font-size: 36px;
    cursor: grab;
    transition: transform 0.2s ease;
    z-index: 10;
}

.piece:hover {
    transform: scale(1.1);
}

.piece.dragging {
    cursor: grabbing;
    transform: scale(1.2);
    z-index: 100;
    pointer-events: none;
}

.promotion-dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 2px solid #333;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: none;
}

.promotion-dialog.active {
    display: block;
}

.promotion-pieces {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 15px;
}

.promotion-piece {
    width: 60px;
    height: 60px;
    font-size: 36px;
    border: 2px solid #333;
    border-radius: 8px;
    background: #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.promotion-piece:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

.pgn-controls {
    margin-bottom: 30px;
}

.pgn-controls button {
    width: 100%;
    padding: 10px;
    margin: 5px 0;
    border: none;
    border-radius: 8px;
    background: #28a745;
    color: white;
    cursor: pointer;
    transition: background 0.3s ease;
}

.pgn-controls button:hover {
    background: #218838;
}

.pgn-display {
    margin-bottom: 30px;
}

#pgn-text {
    width: 100%;
    height: 150px;
    padding: 10px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-family: monospace;
    font-size: 12px;
    resize: vertical;
    background: #f8f9fa;
}

.engine-debug {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
}

#engine-output {
    max-height: 150px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 12px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
    white-space: pre-wrap;
}

.footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    color: #666;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .chess-board {
        width: 400px;
        height: 400px;
    }
    
    .piece {
        font-size: 30px;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 10px;
    }
    
    .chess-board {
        width: 320px;
        height: 320px;
    }
    
    .piece {
        font-size: 24px;
    }
    
    .controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .controls select, .controls button {
        width: 100%;
        max-width: 200px;
    }
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

.piece-move {
    animation: pieceMove 0.3s ease-out;
}

@keyframes pieceMove {
    from { transform: scale(1.2); }
    to { transform: scale(1); }
}

/* Status indicators */
.status-white { color: #2196F3; }
.status-black { color: #424242; }
.status-check { color: #F44336; font-weight: bold; }
.status-checkmate { color: #D32F2F; font-weight: bold; }
.status-stalemate { color: #FF9800; font-weight: bold; }
