/* ============================================================
   Chess Game - Estilos completos
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #e0e0e0;
}

/* ===== TELA DE SELEÇÃO DE COR ===== */
#color-selection {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

#color-selection h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    color: #e94560;
    text-shadow: 0 0 20px rgba(233, 69, 96, 0.3);
}

#color-selection h2 {
    font-size: 1.3em;
    margin-bottom: 40px;
    color: #a0a0b0;
    font-weight: 300;
}

.color-buttons {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.color-btn {
    width: 200px;
    height: 200px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    font-weight: bold;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.color-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.color-btn .piece-icon {
    font-size: 4em;
    margin-bottom: 10px;
}

.color-btn.white-btn {
    background: linear-gradient(145deg, #f0f0f0, #c0c0c0);
    color: #333;
}

.color-btn.white-btn:hover {
    border-color: #e94560;
    box-shadow: 0 10px 30px rgba(233, 69, 96, 0.3);
}

.color-btn.black-btn {
    background: linear-gradient(145deg, #444, #222);
    color: #eee;
}

.color-btn.black-btn:hover {
    border-color: #e94560;
    box-shadow: 0 10px 30px rgba(233, 69, 96, 0.3);
}

/* ===== TELA DO JOGO ===== */
#game-screen {
    display: none;
    padding: 15px;
    max-width: 1400px;
    margin: 0 auto;
}

.game-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: start;
}

/* ===== PAINEL ESQUERDO - MOVIMENTOS ===== */
.left-panel {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.left-panel h3 {
    color: #e94560;
    margin-bottom: 10px;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

#move-history {
    max-height: 500px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

#move-history::-webkit-scrollbar {
    width: 6px;
}

#move-history::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

#move-history::-webkit-scrollbar-thumb {
    background: rgba(233, 69, 96, 0.5);
    border-radius: 3px;
}

.move-row {
    display: grid;
    grid-template-columns: 35px 1fr 1fr;
    gap: 5px;
    padding: 4px 6px;
    border-radius: 4px;
}

.move-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.03);
}

.move-number {
    color: #888;
    text-align: right;
    padding-right: 5px;
}

.move-white, .move-black {
    padding: 2px 6px;
    border-radius: 3px;
    cursor: default;
}

.move-white:hover, .move-black:hover {
    background: rgba(233, 69, 96, 0.2);
}

.move-white.last-move, .move-black.last-move {
    background: rgba(233, 69, 96, 0.3);
    color: #fff;
}

/* ===== TABULEIRO ===== */
.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin: 8px 0;
    width: 100%;
    max-width: 520px;
}

.player-info .player-icon {
    font-size: 1.5em;
}

.player-info .player-name {
    font-weight: bold;
    flex: 1;
}

.player-info .captured-pieces {
    font-size: 1.1em;
    letter-spacing: 1px;
}

.player-info.active-player {
    border: 1px solid #e94560;
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.3);
}

#chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(520px, 90vw);
    height: min(520px, 90vw);
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    position: relative;
}

.square {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: min(3.5em, 8vw);
    cursor: pointer;
    transition: background-color 0.15s;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.square.light {
    background-color: #eedfcc;
}

.square.dark {
    background-color: #7b9e57;
}

.square.selected {
    background-color: #f6f669 !important;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.square.legal-move::after {
    content: '';
    position: absolute;
    width: 25%;
    height: 25%;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
}

.square.legal-capture {
    background: radial-gradient(transparent 55%, rgba(0, 0, 0, 0.25) 55%) !important;
}

.square.last-move-from {
    background-color: #cdd26a !important;
}

.square.last-move-to {
    background-color: #a6b834 !important;
}

.square.check {
    background: radial-gradient(circle, #ff0000 0%, rgba(255, 0, 0, 0.3) 60%, transparent 100%) !important;
}

.square .piece {
    cursor: grab;
    z-index: 1;
    transition: transform 0.05s;
    line-height: 1;
}

.square .piece.piece-w {
    color: #ffffff;
    text-shadow:
        -1px -1px 0 #333,
         1px -1px 0 #333,
        -1px  1px 0 #333,
         1px  1px 0 #333,
         0   -1px 0 #333,
         0    1px 0 #333,
        -1px  0   0 #333,
         1px  0   0 #333;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.3));
}

.square .piece.piece-b {
    color: #1a1a1a;
    text-shadow:
        -1px -1px 0 #aaa,
         1px -1px 0 #aaa,
        -1px  1px 0 #aaa,
         1px  1px 0 #aaa,
         0   -1px 0 #aaa,
         0    1px 0 #aaa,
        -1px  0   0 #aaa,
         1px  0   0 #aaa;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.2));
}

.square .piece:active {
    cursor: grabbing;
    transform: scale(1.1);
}

.file-label, .rank-label {
    position: absolute;
    font-size: 0.18em;
    font-weight: bold;
    opacity: 0.6;
    pointer-events: none;
}

.file-label {
    bottom: 2px;
    right: 4px;
}

.rank-label {
    top: 2px;
    left: 4px;
}

.square.light .file-label, .square.light .rank-label {
    color: #7b9e57;
}

.square.dark .file-label, .square.dark .rank-label {
    color: #eedfcc;
}

/* ===== PAINEL DIREITO - JUSTIFICATIVA DA IA ===== */
.right-panel {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.right-panel h3 {
    color: #e94560;
    margin-bottom: 10px;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

#ai-justification {
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.9em;
    line-height: 1.6;
}

#ai-justification::-webkit-scrollbar {
    width: 6px;
}

#ai-justification::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

#ai-justification::-webkit-scrollbar-thumb {
    background: rgba(233, 69, 96, 0.5);
    border-radius: 3px;
}

.justification-entry {
    padding: 10px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-left: 3px solid #e94560;
}

.justification-entry .move-label {
    font-weight: bold;
    color: #e94560;
    margin-bottom: 5px;
    font-size: 1em;
}

.justification-entry .reasons {
    color: #c0c0d0;
    white-space: pre-wrap;
    font-size: 0.85em;
    line-height: 1.7;
}

/* ===== CONTROLES ===== */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.game-controls button {
    padding: 10px 20px;
    background: rgba(233, 69, 96, 0.2);
    border: 1px solid #e94560;
    color: #e94560;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.2s;
}

.game-controls button:hover {
    background: #e94560;
    color: #fff;
}

/* ===== STATUS BAR ===== */
.status-bar {
    text-align: center;
    padding: 12px;
    font-size: 1.1em;
    font-weight: 500;
    margin: 10px 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.status-bar.thinking {
    color: #ffa726;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== MODAL DE PROMOÇÃO ===== */
#promotion-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

#promotion-modal.show {
    display: flex;
}

.promotion-dialog {
    background: #2a2a3e;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    border: 2px solid #e94560;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.promotion-dialog h3 {
    margin-bottom: 16px;
    color: #e94560;
}

.promotion-pieces {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.promotion-piece {
    width: 70px;
    height: 70px;
    font-size: 2.5em;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.promotion-piece:hover {
    background: rgba(233, 69, 96, 0.3);
    border-color: #e94560;
    transform: scale(1.1);
}

/* ===== MODAL DE FIM DE JOGO ===== */
#game-over-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

#game-over-modal.show {
    display: flex;
}

.game-over-dialog {
    background: #2a2a3e;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    border: 2px solid #e94560;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    max-width: 400px;
}

.game-over-dialog h2 {
    font-size: 2em;
    color: #e94560;
    margin-bottom: 10px;
}

.game-over-dialog .result-text {
    font-size: 1.2em;
    color: #c0c0d0;
    margin-bottom: 20px;
}

.game-over-dialog .result-icon {
    font-size: 4em;
    margin-bottom: 15px;
}

.game-over-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.game-over-buttons button {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    border: none;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-new-game {
    background: #e94560;
    color: #fff;
}

.btn-new-game:hover {
    background: #d63651;
}

.btn-download-log {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.btn-download-log:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-close-modal {
    background: rgba(255, 255, 255, 0.05);
    color: #aaa;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

.btn-close-modal:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 1100px) {
    .game-layout {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .left-panel, .right-panel {
        width: 100%;
        max-width: 520px;
    }

    #move-history {
        max-height: 200px;
    }

    #ai-justification {
        max-height: 200px;
    }
}

@media (max-width: 600px) {
    #color-selection h1 {
        font-size: 1.8em;
    }

    .color-btn {
        width: 150px;
        height: 150px;
    }

    .color-btn .piece-icon {
        font-size: 3em;
    }

    .square {
        font-size: min(2.5em, 10vw);
    }
}
