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

.header {
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.8em;
    font-weight: bold;
    color: #2c3e50;
}

.nav-links {
    display: flex;
    gap: 30px;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: #2c3e50;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: #3498db;
}

.main-content {
    padding: 40px 0;
}

.rule-selector {
    text-align: center;
    margin-bottom: 40px;
}

.rule-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.rule-btn {
    padding: 12px 24px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.rule-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.rule-btn.active {
    background: #e74c3c;
}

.game-section {
    display: none;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    margin: 20px 0;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.game-section.active {
    display: block;
}

.board-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: clamp(1rem, 5vw, 2rem);
    margin: clamp(1rem, 4vw, 2rem) 0;
    flex-wrap: wrap;
}

.board-wrapper {
    position: relative;
}

.coordinates {
    position: absolute;
    font-size: clamp(0.7rem, 2vw, 1rem);
    color: #333;
    font-weight: bold;
}

.coordinates.rank {
    left: -2.5rem;
    top: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
}

.coordinates.file {
    bottom: -2.5rem;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.coordinates span {
    width: 12.5%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coordinates.hidden {
    display: none;
}

.checkers-board {
    width: min(50vw, 50vh, 500px);
    height: min(50vw, 50vh, 500px);
    max-width: 90vw;
    max-height: 90vh;
    border: 0.2rem solid #2c3e50;
    border-radius: 0.5rem;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 0;
    background: #d4d4aa;
    position: relative;
    margin: 0 auto;
    /* Propriedades do openings para garantir foco */
    transition: transform 0.3s ease-in-out;
    transform-origin: center center !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
}

.square {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

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

.square.selected {
    background-color: #ff5722 !important;
}

.square.possible-move {
    background-color: rgba(76, 175, 80, 0.6) !important;
}

.square.possible-capture {
    background-color: rgba(244, 67, 54, 0.7) !important;
}

/* Highlight do ultimo lance desativado (mantem pre-move intocado) */
.last-move-highlight {
    box-shadow: none !important;
    outline: none !important;
    border: none !important;
    background: inherit !important;
}

.piece {
    width: 85%;
    height: 85%;
    max-width: 3rem;
    max-height: 3rem;
    border-radius: 50%;
    border: 0.15rem solid #000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    text-shadow: 0.05rem 0.05rem 0.1rem rgba(0,0,0,0.7);
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
    box-shadow: 0 0.1rem 0.25rem rgba(0,0,0,0.3);
    position: relative;
    z-index: 10;
}

.piece:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.piece:active {
    cursor: grabbing;
}

.piece.dragging {
    visibility: hidden; /* CorreÃ§Ã£o para o arraste de peÃ§a */
}

.piece.white {
    background: radial-gradient(circle, #fff 30%, #ddd 100%);
    color: #000;
    text-shadow: none;
}

.piece.black {
    background: radial-gradient(circle, #444 30%, #000 100%);
}

.piece.king {
    position: relative;
}

.piece.king::after {
    content: 'â™”';
    font-size: clamp(0.8rem, 3vw, 1.2rem);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 15;
    line-height: 1;
}

.piece.white.king::after {
    color: #000;
    text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}

.piece.black.king::after {
    color: #fff;
    text-shadow: 0 0 3px #000, 0 0 3px #000;
}

/* Garante que a coroa apareÃ§a mesmo com transformaÃ§Ãµes */
.piece.king.dragging::after {
    display: block;
}

/* Corrigir foco quando tabuleiro estÃ¡ virado - copiado do openings */
.checkers-board[style*="rotate(180deg)"] {
    /* Manter propriedades de foco mesmo virado */
    backface-visibility: visible !important;
    -webkit-backface-visibility: visible !important;
    /* ForÃ§ar renderizaÃ§Ã£o correta */
    transform-style: flat !important;
    -webkit-transform-style: flat !important;
}

/* Ajuste para quando o tabuleiro estÃ¡ virado */
.checkers-board[style*="rotate(180deg)"] .piece.king::after {
    transform: translate(-50%, -50%) rotate(-180deg);
}

.game-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 15rem;
    width: 100%;
    max-width: 20rem;
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.control-btn {
    padding: 0.75rem 1.25rem;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    font-weight: 500;
    transition: all 0.3s;
}

.control-btn:hover {
    background: #2980b9;
}

.control-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.game-info, .difficulty-selector, .move-history {
    background: #ecf0f1;
    padding: 1rem;
    border-radius: 0.5rem;
    width: 100%;
}

.move-history h4, .difficulty-selector h4, .game-info h4 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.difficulty-selector select {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 14px;
}

.move-list {
    font-family: monospace;
    font-size: 12px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* CorreÃ§Ã£o para alinhar os nÃºmeros da lista */
.move-history ol {
    padding-left: 30px; 
}

/* Estilos para a "Tarja Azul" no lance ativo */
.move-notation {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s, color 0.2s;
}

.move-notation:hover {
    background-color: #e9ecef;
}

.move-notation.active {
    background-color: #3498db;
    color: white;
}

.status-bar {
    text-align: center;
    padding: 15px;
    background: #3498db;
    color: white;
    border-radius: 8px;
    margin: 20px 0;
}

.analysis-wrapper {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
    display: none;
}

.analysis-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

#analysisGraphContainer {
    width: 100%;
    max-width: 37.5rem;
    height: clamp(6rem, 15vh, 8rem);
    background-color: #f8f9fa;
    border: 0.06rem solid #ccc;
    border-radius: 0.5rem;
    overflow: hidden;
    cursor: pointer;
}

.analysis-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.analysis-controls button {
    padding: 8px 16px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.analysis-controls button:hover {
    background: #2980b9;
}

.analysis-controls button:disabled {
    background: #f1f1f1;
    color: #aaa;
    cursor: not-allowed;
    border-color: #ddd;
}

#analysis-info {
    background: #ecf0f1;
    padding: 15px;
    border-radius: 5px;
    text-align: center;
    margin-top: 10px;
}

#analysis-info p {
    margin: 5px 0;
}

.footer {
    background: rgba(44, 62, 80, 0.9);
    color: white;
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
}

/* Responsividade melhorada */
@media (max-width: 1200px) {
    .checkers-board {
        width: min(60vw, 60vh, 450px);
        height: min(60vw, 60vh, 450px);
    }
    .game-controls {
        min-width: 12rem;
    }
}

@media (max-width: 992px) {
    .board-container {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    .checkers-board {
        width: min(70vw, 70vh, 400px);
        height: min(70vw, 70vh, 400px);
    }
    .game-controls {
        width: 100%;
        max-width: none;
        order: -1;
    }
    .controls-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.8rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 0.5rem;
    }
    .nav {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    .nav-links {
        flex-direction: row;
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    .board-container {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
    .checkers-board {
        width: min(85vw, 85vh, 350px);
        height: min(85vw, 85vh, 350px);
        border-width: 0.15rem;
    }
    .game-controls {
        width: 100%;
        order: -1;
    }
    .controls-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
    }
    .move-history {
        width: 100%;
    }
    .control-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
    .coordinates {
        font-size: 0.7rem;
    }
    .coordinates.rank {
        left: -1.8rem;
    }
    .coordinates.file {
        bottom: -1.8rem;
    }
}

@media (max-width: 480px) {
    .checkers-board {
        width: min(95vw, 95vh, 300px);
        height: min(95vw, 95vh, 300px);
    }
    .control-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
    }
    .game-info, .difficulty-selector, .move-history {
        padding: 0.8rem;
    }
    .coordinates {
        font-size: 0.6rem;
    }
    .coordinates.rank {
        left: -1.5rem;
    }
    .coordinates.file {
        bottom: -1.5rem;
    }
}

/* OrientaÃ§Ã£o landscape em dispositivos mÃ³veis */
@media (max-height: 500px) and (orientation: landscape) {
    .checkers-board {
        width: min(40vw, 80vh, 350px);
        height: min(40vw, 80vh, 350px);
    }
    .board-container {
        flex-direction: row;
        justify-content: center;
        align-items: flex-start;
        gap: 1rem;
    }
    .game-controls {
        order: 0;
        width: auto;
        min-width: 12rem;
        max-width: 15rem;
    }
}

.move-annotation {
    font-weight: bold;
    margin-left: 5px;
}

.move-annotation.brilliant { color: #27ae60; } /* Verde para Brilhante */
.move-annotation.inaccuracy { color: #f39c12; } /* Laranja para ImprecisÃ£o */
.move-annotation.mistake { color: #e74c3c; }    /* Vermelho para Erro */
.move-annotation.blunder { color: #c0392b; }     /* Vermelho Escuro para Erro Grave */

.arrow-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Permite clicar atravÃ©s do overlay */
    z-index: 20;
}

/* Estilos para modo de anÃ¡lise progressiva */
.move-notation.analyzing {
    background-color: #ffc107 !important;
    color: #000 !important;
    animation: pulse 1s infinite;
}

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

.stop-analysis-btn {
    background: #e74c3c !important;
}

.stop-analysis-btn:hover {
    background: #c0392b !important;
}

/* Layout para modo de anÃ¡lise */
.board-container.analysis-mode {
    flex-direction: column;
    align-items: center;
}

.analysis-section {
    width: 100%;
    max-width: 800px;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.board-container.analysis-mode .game-controls {
    order: 3;
}

.board-container.analysis-mode .board-wrapper {
    order: 1;
}

.board-container.analysis-mode .analysis-section {
    order: 2;
}

/* CabeÃ§alho da anÃ¡lise com botÃ£o fechar */
.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.close-analysis-btn {
    padding: 8px 16px !important;
    font-size: 12px !important;
    background: #7f8c8d !important;
}

.close-analysis-btn:hover {
    background: #5a6c7d !important;
}

}

/* Override final: manter contorno do ultimo lance sem overlay interno */
.square.last-move-highlight,
.last-move-highlight,
.last-move-highlight::after,
.last-move-highlight::before {
    outline: 3px solid #81b64c !important;
    outline-offset: -2px !important;
    box-shadow: none !important;
    border: none !important;
    background: inherit !important;
}


/* Override final: manter contorno do ultimo lance sem overlay interno */
.square.last-move-highlight,
.last-move-highlight,
.last-move-highlight::after,
.last-move-highlight::before {
    outline: 3px solid #81b64c !important;
    outline-offset: -2px !important;
    box-shadow: none !important;
    border: none !important;
    background: inherit !important;
}


/* Override final: unico contorno do ultimo lance, sem overlay interno */
.square.last-move-highlight,
.last-move-highlight,
.last-move-highlight::after,
.last-move-highlight::before {
    border: 2px solid #81b64c !important;
    outline: none !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
    background: inherit !important;
}
/* Se combinar com possible-move/capture, remove fundo adicional */
.last-move-highlight.possible-move,
.last-move-highlight.possible-capture,
.square.last-move-highlight.possible-move,
.square.last-move-highlight.possible-capture {
    background: inherit !important;
}

