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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #1e3c72 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    padding: 20px;
    color: #333;
    position: relative;
    overflow-x: hidden;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.6s ease-out;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.8em;
    margin-bottom: 20px;
    font-weight: 700;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    border-radius: 12px;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.turn-indicator {
    font-size: 1.2em;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    box-shadow: 
        0 4px 15px rgba(102, 126, 234, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.turn-indicator::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.game-status {
    font-size: 1.1em;
    font-weight: 700;
    color: #2d3748;
    padding: 8px 16px;
    border-radius: 8px;
    min-height: 20px;
}

.game-status:not(:empty) {
    background: linear-gradient(135deg, #ffd700 0%, #ffb347 100%);
    color: #1a202c;
    animation: pulse 1.5s ease-in-out infinite;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

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

.chess-board-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 30px;
    padding: 25px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    backdrop-filter: blur(5px);
}

.board-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 10px 5px;
}

.left-labels {
    align-items: center;
    height: 640px;
}

.left-labels .label {
    font-weight: 700;
    font-size: 1.3em;
    color: #2d3748;
    width: 30px;
    text-align: center;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    transition: all 0.2s ease;
}

.left-labels .label:hover {
    transform: scale(1.15);
    color: #667eea;
}

.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bottom-labels {
    display: flex;
    justify-content: space-around;
    width: 640px;
    padding: 8px 10px;
}

.bottom-labels .label {
    font-weight: 700;
    font-size: 1.3em;
    color: #2d3748;
    width: 70px;
    text-align: center;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    transition: all 0.2s ease;
}

.bottom-labels .label:hover {
    transform: scale(1.15);
    color: #667eea;
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 80px);
    grid-template-rows: repeat(8, 80px);
    border: 5px solid #2d3748;
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.4),
        inset 0 0 0 3px rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.chess-board::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-radius: 6px;
    z-index: -1;
    animation: borderGlow 3s ease-in-out infinite;
}

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

.square {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.square::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, transparent 0%, rgba(0, 0, 0, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.2s;
}

.square:hover::before {
    opacity: 1;
}

.square.light {
    background-color: #f0d9b5;
    background-image: 
        linear-gradient(45deg, rgba(255, 255, 255, 0.1) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255, 255, 255, 0.1) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.1) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.1) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.square.dark {
    background-color: #b58863;
    background-image: 
        linear-gradient(45deg, rgba(0, 0, 0, 0.1) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(0, 0, 0, 0.1) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.1) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.1) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.square:hover:not(.selected):not(.in-check) {
    filter: brightness(1.1);
    transform: scale(1.02);
}

.square.selected {
    background-color: #f6f669 !important;
    box-shadow: 
        inset 0 0 30px rgba(246, 246, 105, 0.9),
        0 0 15px rgba(246, 246, 105, 0.6);
    transform: scale(1.05);
    z-index: 5;
    animation: selectedPulse 1.5s ease-in-out infinite;
}

@keyframes selectedPulse {
    0%, 100% {
        box-shadow: 
            inset 0 0 30px rgba(246, 246, 105, 0.9),
            0 0 15px rgba(246, 246, 105, 0.6);
    }
    50% {
        box-shadow: 
            inset 0 0 40px rgba(246, 246, 105, 1),
            0 0 25px rgba(246, 246, 105, 0.8);
    }
}

.square.valid-move {
    position: relative;
}

.square.valid-move::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.6) 0%, rgba(102, 126, 234, 0.3) 50%, transparent 100%);
    border-radius: 50%;
    animation: validMovePulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

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

.square.valid-move:hover::after {
    transform: scale(1.3);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.8);
}

.square.valid-capture {
    position: relative;
}

.square.valid-capture::after {
    content: '';
    position: absolute;
    width: 76px;
    height: 76px;
    border: 5px solid rgba(255, 87, 87, 0.8);
    border-radius: 8px;
    animation: capturePulse 1s ease-in-out infinite;
    box-shadow: 
        inset 0 0 15px rgba(255, 87, 87, 0.3),
        0 0 20px rgba(255, 87, 87, 0.5);
}

@keyframes capturePulse {
    0%, 100% {
        border-color: rgba(255, 87, 87, 0.8);
        box-shadow: 
            inset 0 0 15px rgba(255, 87, 87, 0.3),
            0 0 20px rgba(255, 87, 87, 0.5);
    }
    50% {
        border-color: rgba(255, 87, 87, 1);
        box-shadow: 
            inset 0 0 25px rgba(255, 87, 87, 0.5),
            0 0 30px rgba(255, 87, 87, 0.8);
    }
}

.square.in-check {
    background-color: #ff6b6b !important;
    animation: checkPulse 1s infinite, checkShake 0.5s ease-in-out;
    box-shadow: 
        inset 0 0 40px rgba(255, 107, 107, 1),
        0 0 30px rgba(255, 107, 107, 0.8);
}

@keyframes checkPulse {
    0%, 100% {
        box-shadow: 
            inset 0 0 40px rgba(255, 107, 107, 1),
            0 0 30px rgba(255, 107, 107, 0.8);
    }
    50% {
        box-shadow: 
            inset 0 0 50px rgba(255, 107, 107, 1),
            0 0 40px rgba(255, 107, 107, 1);
    }
}

@keyframes checkShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

.piece {
    font-size: 50px;
    cursor: grab;
    user-select: none;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 10;
}

.piece:hover {
    transform: scale(1.15);
    filter: drop-shadow(4px 4px 8px rgba(0, 0, 0, 0.4));
}

.piece:active {
    cursor: grabbing;
}

.piece.dragging {
    opacity: 0.85;
    transform: scale(1.3) rotate(5deg);
    z-index: 100;
    filter: drop-shadow(8px 8px 16px rgba(0, 0, 0, 0.5));
}

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

.btn {
    padding: 14px 28px;
    font-size: 1em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    box-shadow: 
        0 4px 15px rgba(102, 126, 234, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 
        0 8px 20px rgba(102, 126, 234, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn:active {
    transform: translateY(-1px);
    box-shadow: 
        0 4px 12px rgba(102, 126, 234, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.famous-games-selector {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    border-radius: 12px;
    margin-top: 15px;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.famous-games-selector h3 {
    margin: 0;
    color: #667eea;
    font-size: 1.1em;
    font-weight: 600;
}

.famous-select {
    flex: 1;
    padding: 12px;
    font-size: 1em;
    border: 2px solid #667eea;
    border-radius: 10px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.famous-select:hover {
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.famous-select:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* AI Settings Styles */
.ai-settings {
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.ai-settings h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.2em;
    font-weight: 600;
}

.ai-options {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.player-option {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.player-option label {
    font-weight: 600;
    color: #2d3748;
    font-size: 0.9em;
}

.player-select {
    padding: 10px 15px;
    font-size: 1em;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    min-width: 120px;
}

.player-select:hover {
    border-color: #764ba2;
}

.player-select:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.ai-delay-input {
    padding: 10px 15px;
    font-size: 1em;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
    color: #333;
    width: 100px;
    transition: all 0.3s ease;
}

.ai-delay-input:hover {
    border-color: #764ba2;
}

.ai-delay-input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.ai-status {
    margin-top: 15px;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
}

.ai-status.ai-vs-ai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.ai-status.ai-white {
    background: linear-gradient(135deg, #f0d9b5 0%, #d4c4a8 100%);
    color: #333;
    border: 2px solid #667eea;
}

.ai-status.ai-black {
    background: linear-gradient(135deg, #b58863 0%, #8b6c54 100%);
    color: white;
    border: 2px solid #667eea;
}

.ai-status.human-vs-human {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    color: #2d3748;
}

.btn-small {
    padding: 10px 20px;
    font-size: 0.9em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

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

.famous-game-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 
        0 8px 20px rgba(102, 126, 234, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.famous-game-info h3 {
    margin-bottom: 15px;
    font-size: 1.6em;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.famous-game-info p {
    margin: 8px 0;
    line-height: 1.7;
    opacity: 0.95;
}

.replay-controls {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.move-history {
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    padding: 20px;
    border-radius: 12px;
    max-height: 350px;
    overflow-y: auto;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

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

.move-history::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.move-history::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
}

.move-history::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5568d3 0%, #5a3d7a 100%);
}

.move-history h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
    font-weight: 700;
    text-align: center;
}

.move-item {
    padding: 10px 15px;
    margin: 5px 0;
    background: white;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.move-item:hover {
    transform: translateX(5px);
    border-left-color: #667eea;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.move-item:nth-child(even) {
    background: #f8f9fa;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .game-container {
        padding: 20px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .chess-board {
        grid-template-columns: repeat(8, 40px);
        grid-template-rows: repeat(8, 40px);
        border-width: 3px;
    }
    
    .square {
        width: 40px;
        height: 40px;
    }
    
    .piece {
        font-size: 25px;
    }
    
    .bottom-labels {
        width: 320px;
    }
    
    .bottom-labels .label {
        width: 35px;
        font-size: 1em;
    }
    
    .left-labels {
        height: 320px;
    }
    
    .left-labels .label {
        font-size: 1em;
    }
    
    .chess-board-container {
        padding: 15px;
    }
    
    .famous-games-selector {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
    }
    
    .famous-games-selector h3 {
        text-align: center;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .turn-indicator {
        text-align: center;
    }
}
