* {
    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;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
    max-width: 900px;
    width: 100%;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.computer-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 10px;
    background: #f7f7f7;
    border-radius: 8px;
}

.computer-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #555;
}

.computer-controls input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.ai-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-selector label {
    font-weight: 600;
    color: #555;
}

.ai-selector select {
    padding: 6px 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.3s;
}

.ai-selector select:hover {
    border-color: #667eea;
}

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

.difficulty-selector label {
    font-weight: 600;
    color: #555;
}

#difficulty {
    padding: 8px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: border-color 0.3s;
}

#difficulty:hover {
    border-color: #667eea;
}

.btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn:active {
    transform: translateY(0);
}

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

.status {
    text-align: center;
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
    padding: 15px;
    background: #f7f7f7;
    border-radius: 10px;
    margin-bottom: 15px;
}

.status.check {
    background: #fff3cd;
    color: #856404;
}

.status.checkmate {
    background: #f8d7da;
    color: #721c24;
}

.status.draw {
    background: #d1ecf1;
    color: #0c5460;
}

.captured {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.captured-pieces {
    font-size: 24px;
    padding: 10px;
    background: #f7f7f7;
    border-radius: 8px;
    min-height: 40px;
    flex: 1;
    margin: 0 5px;
}

.board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.board-wrapper {
    position: relative;
    display: inline-block;
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 60px);
    grid-template-rows: repeat(8, 60px);
    border: 3px solid #333;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.file-labels {
    display: flex;
    position: absolute;
    bottom: -25px;
    left: 0;
    right: 0;
}

.rank-labels {
    display: flex;
    flex-direction: column;
    position: absolute;
    left: -25px;
    top: 0;
    bottom: 0;
}

.file-label, .rank-label {
    font-weight: bold;
    color: #333;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-label {
    width: 60px;
    height: 25px;
}

.rank-label {
    width: 25px;
    height: 60px;
}

.square {
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: background-color 0.3s;
}

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

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

.square.selected {
    background-color: #8cc654 !important;
}

.square.highlight {
    background-color: #f6f669 !important;
}

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

.square.possible-capture {
    box-shadow: inset 0 0 0 3px rgba(255, 0, 0, 0.5);
}

.piece {
    font-size: 45px;
    cursor: grab;
    user-select: none;
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s;
}

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

.piece.dragging {
    cursor: grabbing;
    opacity: 0.5;
}

.move-history {
    margin-top: 20px;
}

.move-history h3 {
    color: #333;
    margin-bottom: 10px;
}

.move-list {
    background: #f7f7f7;
    border-radius: 8px;
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
}

.move-list::-webkit-scrollbar {
    width: 8px;
}

.move-list::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 4px;
}

.move-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.move-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.move-pair {
    display: flex;
    margin-bottom: 5px;
}

.move-number {
    font-weight: bold;
    margin-right: 10px;
    color: #666;
}

.move {
    flex: 1;
    padding: 2px 5px;
    cursor: pointer;
    border-radius: 3px;
}

.move:hover {
    background: #e0e0e0;
}

.gravity-toggle {
    display: flex;
    align-items: center;
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 15px;
    background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
    border-radius: 8px;
    transition: all 0.3s;
}

.toggle-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 165, 0, 0.4);
}

#gravityMode {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.toggle-text {
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.falling-piece {
    animation: fall 0.5s ease-in;
}

@keyframes fall {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(var(--fall-distance));
    }
}

.gravity-preview {
    opacity: 0.4;
    filter: brightness(1.5);
}

.computer-from {
    animation: pulse-red 0.6s ease-in-out;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
}

.computer-to {
    animation: pulse-blue 0.6s ease-in-out;
    box-shadow: 0 0 20px rgba(0, 100, 255, 0.8);
}

.square.gravity-fall-from::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, 
        rgba(255, 255, 0, 0.6) 0%, 
        transparent 100%);
    pointer-events: none;
    animation: fade-out 0.6s ease-in-out forwards;
    z-index: 1;
}

.square.gravity-fall-to::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, 
        rgba(0, 255, 0, 0.6) 0%, 
        transparent 70%);
    pointer-events: none;
    animation: fade-out 0.6s ease-in-out forwards;
    z-index: 1;
}

@keyframes pulse-red {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); background-color: rgba(255, 100, 100, 0.5); }
}

@keyframes pulse-blue {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); background-color: rgba(100, 150, 255, 0.5); }
}

@keyframes fall-indicator {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

@keyframes land-indicator {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0.7; }
}

@keyframes fade-out {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 0; visibility: hidden; }
}

@media (max-width: 768px) {
    .board {
        grid-template-columns: repeat(8, 40px);
        grid-template-rows: repeat(8, 40px);
    }
    
    .square {
        width: 40px;
        height: 40px;
    }
    
    .piece {
        font-size: 30px;
    }
    
    .file-label {
        width: 40px;
        height: 20px;
        font-size: 12px;
    }
    
    .rank-label {
        width: 20px;
        height: 40px;
        font-size: 12px;
    }
    
    .file-labels {
        bottom: -20px;
    }
    
    .rank-labels {
        left: -20px;
    }
    
    h1 {
        font-size: 1.8em;
    }
}