* {
    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;
    padding: 20px;
    color: #333;
}

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

/* Header Styles */
.game-header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.player-info-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.player-badge {
    background: white;
    padding: 12px 25px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    font-weight: bold;
    font-size: 1.1em;
    transition: all 0.3s ease;
}

.player-badge.white-player {
    color: #0066ff;
    border: 3px solid #0066ff;
}

.player-badge.black-player {
    color: #ff0000;
    border: 3px solid #ff0000;
}

.player-badge .player-icon {
    font-size: 1.3em;
}

.vs-badge {
    font-size: 1.5em;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.game-header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #667eea;
    }
    to {
        text-shadow: 0 0 20px #fff, 0 0 30px #764ba2, 0 0 40px #764ba2;
    }
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
}

/* Game Layout */
.game-layout {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 20px;
    align-items: start;
}

/* Side Panels */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.info-box {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.info-box h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

.info-box h4 {
    color: #764ba2;
    margin: 10px 0 5px 0;
    font-size: 1em;
}

/* Captured Pieces */
.captured-section {
    margin-bottom: 15px;
}

.captured-pieces {
    min-height: 40px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.captured-piece {
    font-size: 1.5em;
    animation: captureAnimation 0.5s ease-out;
}

@keyframes captureAnimation {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

/* Stats */
.stats p {
    margin: 10px 0;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 5px;
    border-left: 4px solid #667eea;
}

.stats strong {
    color: #764ba2;
}

/* Chess Container */
.chess-container {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Turn Indicator */
.turn-indicator {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    font-size: 1.5em;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    animation: pulse 2s ease-in-out infinite;
}

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

.turn-icon {
    font-size: 1.3em;
    margin-right: 10px;
}

/* Chessboard */
.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 0;
    margin: 0 auto;
    border: 5px solid #333;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1 / 1;
}

.square {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(2em, 4vw, 3em);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.square.light {
    background: linear-gradient(135deg, #f0d9b5 0%, #e8d1a7 100%);
}

.square.dark {
    background: linear-gradient(135deg, #b58863 0%, #a67c52 100%);
}

.square:hover {
    transform: scale(1.05);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.3);
    z-index: 10;
}

.square.selected {
    background: linear-gradient(135deg, #90EE90 0%, #7CFC00 100%) !important;
    box-shadow: 0 0 20px rgba(124, 252, 0, 0.6), inset 0 0 20px rgba(255, 255, 255, 0.5);
    animation: selectedPulse 1s ease-in-out infinite;
}

.square.ai-hint {
    background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%) !important;
    box-shadow: 0 0 25px rgba(0, 210, 255, 0.8), inset 0 0 20px rgba(255, 255, 255, 0.5);
    animation: aiHintPulse 1.5s ease-in-out infinite;
}

@keyframes aiHintPulse {
    0%, 100% {
        box-shadow: 0 0 25px rgba(0, 210, 255, 0.8), inset 0 0 20px rgba(255, 255, 255, 0.5);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 35px rgba(0, 210, 255, 1), inset 0 0 30px rgba(255, 255, 255, 0.7);
        transform: scale(1.05);
    }
}

@keyframes selectedPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(124, 252, 0, 0.6), inset 0 0 20px rgba(255, 255, 255, 0.5);
    }
    50% {
        box-shadow: 0 0 30px rgba(124, 252, 0, 0.9), inset 0 0 30px rgba(255, 255, 255, 0.8);
    }
}

.square.valid-move {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%) !important;
    animation: validMovePulse 1.5s ease-in-out infinite;
}

@keyframes validMovePulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

.square.valid-move::after {
    content: '●';
    position: absolute;
    font-size: 0.5em;
    color: rgba(0, 0, 0, 0.4);
    animation: dotPulse 1s ease-in-out infinite;
}

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

.piece {
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

.piece.white {
    color: #0066ff;
    filter: drop-shadow(0 2px 4px rgba(0, 102, 255, 0.3));
}

.piece.black {
    color: #ff0000;
    filter: drop-shadow(0 2px 4px rgba(255, 0, 0, 0.3));
}

.square:hover .piece {
    transform: scale(1.1) rotate(5deg);
}

/* Board Labels */
.board-labels {
    margin-top: 10px;
}

.column-labels {
    display: grid;
    grid-template-columns: repeat(8, 70px);
    justify-content: center;
    text-align: center;
    font-weight: bold;
    color: #667eea;
    font-size: 1.2em;
}

.column-labels span {
    padding: 5px;
}

/* Move History */
.move-history {
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

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

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

.move-history::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.move-history::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

.move-item {
    padding: 8px;
    margin: 5px 0;
    background: white;
    border-radius: 5px;
    border-left: 4px solid #667eea;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.move-item.white-move {
    border-left-color: #0066ff;
}

.move-item.black-move {
    border-left-color: #ff0000;
}

.no-moves {
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

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

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

/* Message Display */
.message {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 30px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    font-size: 1.1em;
    font-weight: bold;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.message.show {
    opacity: 1;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        transform: translateX(-50%) translateY(20px);
    }
    to {
        transform: translateX(-50%) translateY(0);
    }
}

.message.success {
    border-left: 5px solid #28a745;
    color: #28a745;
}

.message.error {
    border-left: 5px solid #dc3545;
    color: #dc3545;
}

.message.info {
    border-left: 5px solid #17a2b8;
    color: #17a2b8;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    animation: modalSlide 0.3s ease-out;
}

.promotion-modal-content {
    max-width: 400px;
    text-align: center;
}

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

.promotion-choice {
    font-size: 4em;
    padding: 20px;
    background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
    border: 3px solid #667eea;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.promotion-choice:hover {
    transform: translateY(-5px) scale(1.1);
    background: linear-gradient(135deg, #667eea, #764ba2);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);
}

/* Player Stats */
.player-stats {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.player-stat-card {
    padding: 15px;
    border-radius: 10px;
    background: #f8f9fa;
    border-left: 5px solid;
}

.player-stat-card.white-stat {
    border-left-color: #0066ff;
}

.player-stat-card.black-stat {
    border-left-color: #ff0000;
}

.player-stat-card h4 {
    margin: 0 0 10px 0;
    font-size: 1.1em;
}

.player-stat-card.white-stat h4 {
    color: #0066ff;
}

.player-stat-card.black-stat h4 {
    color: #ff0000;
}

.player-stat-card p {
    margin: 5px 0;
    font-size: 0.9em;
}

/* Player Registration Modal */
.player-registration-content {
    max-width: 500px;
    text-align: center;
}

.player-input-group {
    margin: 20px 0;
    text-align: left;
}

.player-input-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 1.1em;
    color: #667eea;
}

.player-input-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s ease;
}

.player-input-group input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.btn-large {
    width: 100%;
    margin: 10px 0;
    font-size: 1.1em;
    padding: 15px;
}

@keyframes modalSlide {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover,
.close:focus {
    color: #000;
}

.help-content {
    margin-top: 20px;
}

.help-content h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.help-content h3 {
    color: #764ba2;
    margin: 15px 0 10px 0;
}

.help-content ul {
    list-style: none;
    padding-left: 0;
}

.help-content li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
}

.help-content li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #28a745;
    font-weight: bold;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .side-panel {
        flex-direction: row;
    }

    .chessboard {
        max-width: 500px;
    }
}

@media (max-width: 768px) {
    .game-header h1 {
        font-size: 2em;
    }

    .chessboard {
        max-width: 400px;
    }

    .info-box {
        padding: 15px;
    }

    .side-panel {
        flex-direction: column;
    }
}