/* Chess Game Styles */
* {
    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 {
    max-width: 1400px;
    width: 100%;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 20px 30px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 15px;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.player-info {
    display: flex;
    gap: 20px;
    font-size: 1.1em;
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
}

button:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
}

select {
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #bdc3c7;
    font-size: 1em;
    cursor: pointer;
    background: white;
}

main {
    padding: 30px;
}

.game-container {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 30px;
    max-width: 100%;
}

.board-container {
    position: relative;
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 80px);
    grid-template-rows: repeat(8, 80px);
    border: 3px solid #34495e;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
}

.square {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5em;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    user-select: none;
}

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

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

.square:hover {
    opacity: 0.8;
}

.square.selected {
    background-color: #7fa650 !important;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

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

.square.legal-move::after {
    content: '';
    position: absolute;
    width: 25px;
    height: 25px;
    background-color: rgba(0, 128, 0, 0.4);
    border-radius: 50%;
    pointer-events: none;
}

.square.legal-move.capture::after {
    width: 70px;
    height: 70px;
    background-color: transparent;
    border: 4px solid rgba(255, 0, 0, 0.5);
    border-radius: 50%;
}

.square.last-move {
    background-color: #cdd26a !important;
}

.square.move-from {
    animation: moveFlashFrom 2s linear;
}

.square.move-to {
    animation: moveFlashTo 1.5s linear;
}

@keyframes moveFlashFrom {
    0%, 100% {
        box-shadow: inset 0 0 0 0px rgba(52, 152, 219, 0);
    }
    10%, 30% {
        box-shadow: inset 0 0 0 8px rgba(52, 152, 219, 1);
    }
    20%, 40% {
        box-shadow: inset 0 0 0 0px rgba(52, 152, 219, 0);
    }
    50%, 70% {
        box-shadow: inset 0 0 0 8px rgba(52, 152, 219, 1);
    }
    60%, 80% {
        box-shadow: inset 0 0 0 0px rgba(52, 152, 219, 0);
    }
}

@keyframes moveFlashTo {
    0%, 100% {
        box-shadow: inset 0 0 0 0px rgba(231, 76, 60, 0);
    }
    10%, 30% {
        box-shadow: inset 0 0 0 8px rgba(231, 76, 60, 1);
    }
    20%, 40% {
        box-shadow: inset 0 0 0 0px rgba(231, 76, 60, 0);
    }
    50%, 70% {
        box-shadow: inset 0 0 0 8px rgba(231, 76, 60, 1);
    }
    60%, 80% {
        box-shadow: inset 0 0 0 0px rgba(231, 76, 60, 0);
    }
}

.square.under-attack {
    box-shadow: inset 0 0 0 3px rgba(255, 0, 0, 0.6);
}

.square.protected {
    box-shadow: inset 0 0 0 3px rgba(255, 165, 0, 0.6);
}

.coordinates {
    position: relative;
    margin-top: 5px;
}

.files {
    display: grid;
    grid-template-columns: repeat(8, 80px);
    text-align: center;
    font-weight: bold;
    color: #34495e;
    margin-left: 3px;
}

.ranks {
    position: absolute;
    left: -25px;
    top: -648px;
    display: grid;
    grid-template-rows: repeat(8, 80px);
    font-weight: bold;
    color: #34495e;
}

.ranks span {
    display: flex;
    align-items: center;
    height: 80px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 300px;
}

.move-history, .captured-pieces {
    background: #ecf0f1;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.move-history h3, .captured-pieces h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

#moves-list {
    max-height: 400px;
    overflow-y: auto;
    background: white;
    padding: 10px;
    border-radius: 5px;
}

.move-pair {
    display: grid;
    grid-template-columns: 40px 1fr 1fr;
    gap: 10px;
    padding: 5px;
    border-bottom: 1px solid #ecf0f1;
}

.move-number {
    font-weight: bold;
    color: #7f8c8d;
}

.move-pair span {
    padding: 5px;
}

.move-pair span.white-move {
    background: #f8f9fa;
    border-radius: 3px;
}

.move-pair span.black-move {
    background: #e9ecef;
    border-radius: 3px;
}

.captured-white, .captured-black {
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.captured-pieces div {
    min-height: 40px;
}

#captured-white-pieces, #captured-black-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    font-size: 1.5em;
}

.game-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.game-actions button {
    width: 100%;
}

#resign-btn {
    background: #e74c3c;
}

#resign-btn:hover {
    background: #c0392b;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #2c3e50;
}

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

.promotion-piece {
    font-size: 3em;
    padding: 20px;
    background: #ecf0f1;
    border: 2px solid #bdc3c7;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.promotion-piece:hover {
    background: #3498db;
    transform: scale(1.1);
}

/* Status Messages */
#game-status {
    padding: 5px 15px;
    border-radius: 5px;
    font-weight: bold;
}

#game-status.check {
    background: #f39c12;
    color: white;
}

#game-status.checkmate {
    background: #e74c3c;
    color: white;
}

#game-status.draw {
    background: #95a5a6;
    color: white;
}

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

    .sidebar {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .chess-board {
        grid-template-columns: repeat(8, 60px);
        grid-template-rows: repeat(8, 60px);
    }

    .square {
        width: 60px;
        height: 60px;
        font-size: 2.5em;
    }

    .files {
        grid-template-columns: repeat(8, 60px);
    }

    .ranks {
        top: -488px;
    }

    .ranks span {
        height: 60px;
    }

    header h1 {
        font-size: 1.8em;
    }

    .game-info {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .chess-board {
        grid-template-columns: repeat(8, 45px);
        grid-template-rows: repeat(8, 45px);
    }

    .square {
        width: 45px;
        height: 45px;
        font-size: 2em;
    }

    .files {
        grid-template-columns: repeat(8, 45px);
    }

    .ranks {
        top: -368px;
    }

    .ranks span {
        height: 45px;
    }
}

/* Copy button animation */
@keyframes copySuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.copy-success {
    animation: copySuccess 0.3s ease;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.2);
    padding: 12px 30px;
    font-size: 1.1em;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-bottom: 3px solid #3498db;
}

.hidden {
    display: none !important;
}

/* Replay Controls */
.replay-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.speed-control {
    display: flex;
    gap: 15px;
    align-items: center;
    padding: 5px 15px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
}

.speed-control label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    color: #2c3e50;
    font-weight: 500;
    font-size: 14px;
}

.speed-control label:first-child {
    font-weight: 600;
}

.speed-control input[type="radio"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.game-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Games Accordion */
.games-accordion {
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.game-filters-header {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.game-filters-header label {
    color: white;
    font-weight: bold;
}

.game-filters-header select {
    flex: 1;
    max-width: 200px;
}

.game-filters-header #games-count-inline {
    color: #3498db;
    font-weight: bold;
}

.replay-controls-in-accordion {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.accordion-toggle {
    width: 100%;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    padding: 15px 20px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.accordion-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: none;
    box-shadow: none;
}

#accordion-arrow {
    transition: transform 0.3s;
    font-size: 0.8em;
}

.accordion-toggle.collapsed #accordion-arrow {
    transform: rotate(-90deg);
}

.accordion-content {
    max-height: 800px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: white;
    padding: 20px;
}

.accordion-content.collapsed {
    max-height: 0;
    padding: 0 20px;
}

.game-filters-inline {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
}

.game-filters-inline label {
    color: #2c3e50;
    font-weight: bold;
}

.game-filters-inline select {
    flex: 1;
    max-width: 200px;
}

#games-count-inline {
    color: #3498db;
    font-weight: bold;
}

.games-dropdown-list {
    max-height: 400px;
    overflow-y: auto;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
}

.game-item {
    padding: 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid #3498db;
}

.game-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.game-item.selected {
    background: #d1ecf1;
    border-left-color: #27ae60;
}

.game-item-title {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.game-item-details {
    font-size: 0.9em;
    color: #7f8c8d;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.game-item-elo {
    color: #e74c3c;
    font-weight: bold;
}

.current-game-info {
    background: white;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    border: 2px solid #3498db;
}

.current-game-info strong {
    display: block;
    color: #2c3e50;
    font-size: 1.1em;
    margin-bottom: 8px;
}

#game-details {
    color: #7f8c8d;
    font-size: 0.9em;
    margin-bottom: 10px;
}

#replay-progress {
    margin-top: 10px;
    padding: 12px;
    background: #ecf0f1;
    border-radius: 5px;
    font-size: 1em;
    text-align: center;
    font-weight: bold;
    transition: all 0.3s;
}

#replay-progress.game-over {
    background: #27ae60;
    color: white;
    font-size: 1.1em;
    padding: 15px;
    box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3);
}

#replay-progress.game-draw {
    background: #95a5a6;
    color: white;
    font-size: 1.1em;
    padding: 15px;
}

#games-count {
    color: #3498db;
    font-size: 0.9em;
    font-weight: normal;
}
