/* Chess Challenger - Professional Chess Game */

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

:root {
    /* Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #fafbfc;
    --bg-tertiary: #f5f7fa;
    --bg-elevated: #ffffff;
    --border-color: #e4e7eb;
    --border-light: #f0f2f5;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-tertiary: #718096;
    --accent-primary: #5b63d3;
    --accent-hover: #4c54b8;
    --accent-light: #eef0fd;
    --success: #0ca678;
    --success-light: #e6f7f1;
    --danger: #e53e3e;
    --warning: #f59e0b;
    --board-light: #f0d9b5;
    --board-dark: #b58863;
    --board-highlight: rgba(91, 99, 211, 0.3);
    --board-selected: rgba(91, 99, 211, 0.5);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-md: 0 2px 8px 0 rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px 0 rgba(0, 0, 0, 0.12);
    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px 0 rgba(0, 0, 0, 0.02);
}

/* Dark Theme */
body.dark-mode {
    --bg-primary: #0d1117;
    --bg-secondary: #0d1117;
    --bg-tertiary: #161b22;
    --bg-elevated: #161b22;
    --border-color: #30363d;
    --border-light: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #a5b1c2;
    --text-tertiary: #7d8590;
    --accent-primary: #7c85db;
    --accent-hover: #8b93e0;
    --accent-light: #1c2128;
    --success: #3fb68b;
    --success-light: #1b2e26;
    --danger: #f85149;
    --warning: #f59e0b;
    --board-light: #eeeed2;
    --board-dark: #769656;
    --board-highlight: rgba(124, 133, 219, 0.3);
    --board-selected: rgba(124, 133, 219, 0.5);
    --shadow-sm: 0 0 transparent;
    --shadow-md: 0 0 transparent;
    --shadow-lg: 0 0 transparent;
    --shadow-card: 0 0 transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: var(--shadow-card);
}

.theme-toggle:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-primary);
    background: var(--accent-light);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.theme-toggle:hover svg {
    color: var(--accent-primary);
}

.theme-toggle .sun-icon {
    display: block;
}

.theme-toggle .moon-icon {
    display: none;
}

body.dark-mode .theme-toggle .sun-icon {
    display: none;
}

body.dark-mode .theme-toggle .moon-icon {
    display: block;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    color: var(--accent-primary);
}

header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.subtitle {
    font-size: 0.9375rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* Game Info Bar */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-card);
}

.player-info {
    display: flex;
    gap: 2rem;
}

.player {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--text-tertiary);
    transition: all 0.2s;
}

.player.active {
    color: var(--text-primary);
}

.player-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: all 0.2s;
}

.player.active .player-indicator {
    background: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary);
}

.game-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-text {
    font-weight: 600;
    color: var(--text-secondary);
}

/* Game Layout */
.game-layout {
    display: grid;
    grid-template-columns: 1fr minmax(300px, 380px);
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: start;
}

/* Chess Board - Premium Glass Effect */
.board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 1.5rem;
    min-height: 600px;
}

.board-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(91, 99, 211, 0.1), rgba(124, 133, 219, 0.05));
    border-radius: 20px;
    backdrop-filter: blur(10px);
    pointer-events: none;
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    overflow: visible;
    box-shadow: 
        0 8px 32px 0 rgba(31, 38, 135, 0.37),
        inset 0 0 20px rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    aspect-ratio: 1;
    width: 100%;
    max-width: 700px;
    position: relative;
}

body.dark-mode .board {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    box-shadow: 
        0 8px 32px 0 rgba(0, 0, 0, 0.5),
        inset 0 0 20px rgba(255, 255, 255, 0.02);
}

.square {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(2.5rem, 6vw, 4rem);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
    backdrop-filter: blur(5px);
    padding: 0.25rem;
    overflow: visible;
}

.square.light {
    background: linear-gradient(135deg, 
        rgba(240, 217, 181, 0.9), 
        rgba(240, 217, 181, 0.7));
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.2);
}

.square.dark {
    background: linear-gradient(135deg, 
        rgba(181, 136, 99, 0.9), 
        rgba(181, 136, 99, 0.7));
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}

body.dark-mode .square.light {
    background: linear-gradient(135deg, 
        rgba(238, 238, 210, 0.15), 
        rgba(238, 238, 210, 0.1));
}

body.dark-mode .square.dark {
    background: linear-gradient(135deg, 
        rgba(118, 150, 86, 0.25), 
        rgba(118, 150, 86, 0.15));
}

.square:hover {
    transform: scale(1.02);
    box-shadow: 
        inset 0 0 20px rgba(91, 99, 211, 0.3),
        0 0 15px rgba(91, 99, 211, 0.2);
}

.square.selected {
    background: linear-gradient(135deg, 
        rgba(91, 99, 211, 0.5), 
        rgba(91, 99, 211, 0.3)) !important;
    box-shadow: 
        inset 0 0 0 3px rgba(91, 99, 211, 0.8),
        0 0 20px rgba(91, 99, 211, 0.5),
        inset 0 0 30px rgba(91, 99, 211, 0.2);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: inset 0 0 0 3px rgba(91, 99, 211, 0.8), 0 0 20px rgba(91, 99, 211, 0.5); }
    50% { box-shadow: inset 0 0 0 3px rgba(91, 99, 211, 1), 0 0 30px rgba(91, 99, 211, 0.8); }
}

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

.square.valid-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: radial-gradient(circle, rgba(91, 99, 211, 0.6), rgba(91, 99, 211, 0.3));
    border-radius: 50%;
    pointer-events: none;
    animation: validMoveGlow 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(91, 99, 211, 0.5);
}

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

.square.valid-move.has-piece::after {
    width: 85%;
    height: 85%;
    border-radius: 50%;
    background: transparent;
    border: 3px solid rgba(91, 99, 211, 0.6);
    box-shadow: 
        0 0 15px rgba(91, 99, 211, 0.5),
        inset 0 0 15px rgba(91, 99, 211, 0.3);
}

.square.last-move {
    background: linear-gradient(135deg, 
        rgba(255, 235, 59, 0.35), 
        rgba(255, 235, 59, 0.2)) !important;
    box-shadow: inset 0 0 20px rgba(255, 235, 59, 0.3);
}

.piece {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    animation: pieceFloat 0.3s ease-out;
}

@keyframes pieceFloat {
    0% { transform: translateY(10px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.square:hover .piece {
    transform: scale(1.08) translateY(-2px);
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.4));
}

.square.selected .piece {
    animation: selectedPiece 0.5s ease-in-out;
}

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

/* Side Panel */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.controls-panel,
.history-panel,
.captured-panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
}

.controls-panel h3,
.history-panel h3,
.captured-panel h3 {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: none;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    margin-bottom: 0.75rem;
}

.btn:last-child {
    margin-bottom: 0;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--accent-light);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:disabled:hover {
    transform: none;
}

/* Move History */
.move-history {
    max-height: 300px;
    overflow-y: auto;
    font-size: 0.875rem;
}

.no-moves {
    text-align: center;
    color: var(--text-tertiary);
    padding: 1rem;
}

.move-item {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
    margin-bottom: 0.25rem;
    font-family: ui-monospace, 'Cascadia Code', monospace;
}

.move-item:hover {
    background: var(--bg-tertiary);
}

.move-number {
    color: var(--text-tertiary);
    min-width: 2rem;
}

.move-notation {
    color: var(--text-primary);
    font-weight: 500;
}

/* Captured Pieces */
.captured-pieces {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.captured-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.captured-group .label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-tertiary);
    min-width: 50px;
}

.captured-group .pieces {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    font-size: 1.25rem;
}

/* Info Banner */
.info-banner {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1rem 1.25rem;
    background: var(--accent-light);
    border: 1px solid var(--accent-light);
    border-radius: 10px;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    font-weight: 500;
}

.info-item svg {
    color: var(--accent-primary);
    flex-shrink: 0;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-layout {
        grid-template-columns: 1fr minmax(280px, 320px);
    }
    
    .board {
        max-width: 600px;
    }
}

@media (max-width: 1024px) {
    .game-layout {
        grid-template-columns: 1fr;
    }

    .board {
        max-width: 550px;
    }
    
    .board-container {
        min-height: 500px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .theme-toggle {
        top: 1rem;
        right: 1rem;
    }

    .game-info {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .player-info {
        justify-content: center;
    }

    .board {
        max-width: 100%;
    }
    
    .board-container {
        min-height: 400px;
        padding: 1rem;
    }

    .square {
        font-size: clamp(2rem, 10vw, 3rem);
        padding: 0.125rem;
    }

    .info-banner {
        flex-direction: column;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .game-layout {
        gap: 1rem;
    }

    .side-panel {
        gap: 1rem;
    }
    
    .board-container {
        min-height: 350px;
        padding: 0.75rem;
    }
    
    .square {
        font-size: clamp(1.75rem, 9vw, 2.5rem);
    }
}

