/* Chess Game Modern Styles */
:root {
    /* Updated color palette */
    --light-square: #F1F5F9;  /* Light background */
    --dark-square: #1E3A8A;   /* Dark blue */
    --highlight: rgba(59, 130, 246, 0.5);  /* Bright blue highlight */
    --last-move: rgba(59, 130, 246, 0.3);  /* Lighter highlight for last move */
    --check: rgba(239, 68, 68, 0.4);  /* Red for check */
    --primary-color: #1E3A8A;  /* Dark blue for text */
    --secondary-color: #64748B;  /* Medium grey for secondary text */
    --border-color: #CBD5E1;  /* Lighter grey for borders */
    --accent-color: #10B981;  /* Green for success/valid moves */
    --warning-color: #F59E0B;  /* Amber for alerts */
    --error-color: #EF4444;  /* Red for errors/invalid moves */
    --background-color: #F8FAFC;  /* Light grey background */
    --card-background: #FFFFFF;  /* White for cards */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition-speed: 0.2s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: var(--primary-color);
    background-color: var(--background-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(to right, var(--primary-color), #3B82F6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    background-color: var(--card-background);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.difficulty-selector label {
    font-weight: 600;
    color: var(--primary-color);
}

select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    background-color: var(--card-background);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-speed) ease;
    cursor: pointer;
}

select:hover {
    border-color: #3B82F6;
}

select:focus {
    outline: none;
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.game-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin-bottom: 2rem;
}

.board-container {
    position: relative;
    flex: 1;
    min-width: 320px;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    border-radius: 0.5rem;
    overflow: hidden;
}

#board {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border: 2px solid var(--primary-color);
    border-radius: 0.5rem;
    overflow: hidden;
}

.square {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color var(--transition-speed) ease;
}

.square.light {
    background-color: var(--light-square);
}

.square.dark {
    background-color: var(--dark-square);
}

.square.selected {
    background-color: var(--highlight);
}

.square.last-move {
    background-color: var(--last-move);
}

.square.check {
    background-color: var(--check);
}

.piece {
    width: 80%;
    height: 80%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.square:hover .piece {
    transform: scale(1.05);
}

.coordinates {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.files {
    position: absolute;
    bottom: -25px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
}

.ranks {
    position: absolute;
    left: -25px;
    top: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.files span, .ranks span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary-color);
}

.game-info {
    flex: 1;
    min-width: 250px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.status {
    font-size: 1.2rem;
    font-weight: 600;
    padding: 1rem;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-speed) ease;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

button {
    padding: 0.75rem 1.25rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all var(--transition-speed) ease;
    box-shadow: var(--shadow-sm);
}

button:hover {
    background-color: #2563EB;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

button:disabled {
    background-color: var(--secondary-color);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.move-history-container {
    flex-grow: 1;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: var(--card-background);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.move-history-container h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.move-history {
    height: 200px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 0.5rem 1rem;
    padding: 0.5rem;
}

.move-number {
    font-weight: bold;
    color: var(--secondary-color);
}

.white-move, .black-move {
    transition: background-color var(--transition-speed) ease;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.white-move:hover, .black-move:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

footer {
    margin-top: 2rem;
    text-align: center;
    color: var(--secondary-color);
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Chess Instructions Section */
.chess-instructions {
    margin-top: 2rem;
    background-color: var(--card-background);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.instructions-header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.instructions-header h2 {
    color: white;
    margin: 0;
}

.instructions-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: background-color var(--transition-speed) ease;
}

.instructions-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.instructions-content {
    padding: 1.5rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease, padding 0.5s ease;
}

.instructions-content.expanded {
    max-height: 2000px;
    padding: 1.5rem;
}

.instructions-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-button {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--secondary-color);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    white-space: nowrap;
}

.tab-button:hover {
    color: var(--primary-color);
    background-color: rgba(59, 130, 246, 0.05);
    box-shadow: none;
    transform: none;
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.piece-movement {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.piece-card {
    flex: 1;
    min-width: 250px;
    background-color: var(--background-color);
    border-radius: 0.375rem;
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.piece-card h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.piece-icon {
    width: 2rem;
    height: 2rem;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.piece-description {
    margin-bottom: 0.75rem;
}

.movement-diagram {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 200px;
    margin: 0 auto;
    background-color: var(--light-square);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    position: relative;
}

/* Responsive design */
@media (max-width: 1024px) {
    .container {
        padding: 1.5rem;
    }
    
    .game-container {
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .game-container {
        flex-direction: column;
        align-items: center;
    }
    
    .board-container, .game-info {
        max-width: 100%;
    }
    
    header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .difficulty-selector {
        width: 100%;
    }
    
    select {
        flex-grow: 1;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .piece-movement {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    .controls {
        flex-direction: column;
    }
    
    button {
        width: 100%;
    }
    
    .instructions-tabs {
        gap: 0;
    }
    
    .tab-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* Animation for piece movement */
@keyframes movePiece {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
    100% {
        transform: translateY(0);
    }
}

.piece.moved {
    animation: movePiece 0.3s ease;
}
