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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #000000, #2a2a2a);
    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;
    text-align: center;
    width: 100%;
}

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

.game-section {
    display: none;
    background: transparent;
    padding: 30px;
    margin: 20px 0;
}

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

.board-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 30px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.board-wrapper {
    position: relative;
}

.coordinates {
    position: absolute;
    font-size: 14px;
    color: #333;
    font-weight: bold;
}

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

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

.coordinates span {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coordinates.hidden {
    display: none;
}

.checkers-board {
    width: 400px;
    height: 400px;
    border: 3px solid #2c3e50;
    border-radius: 8px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 0;
    background: #d4d4aa;
    position: relative;
}

.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;
}

.last-move-highlight {
    box-shadow: inset 0 0 0 2px #ffc107;
}

.piece {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid #000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
    box-shadow: 0 2px 4px 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;
}

.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::after {
    content: '♔';
    font-size: 18px;
    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;
}

.game-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 250px;
}

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

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    min-height: 45px;
    width: 100%;
}

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

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

.btn-icon {
    font-size: 18px;
}

.game-info, .difficulty-selector, .move-history, .color-choice, .setup-controls {
    background: #ecf0f1;
    padding: 15px;
    border-radius: 8px;
    width: 100%;
    min-width: 250px;
}

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

.difficulty-selector select {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 16px; /* Para evitar zoom no iOS */
}

#moveList {
    width: 100%;
    min-height: 100px;
    max-height: 150px;
    padding: 10px;
    font-family: monospace;
    font-size: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
    background: #f9f9f9;
    box-sizing: border-box;
}

.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;
}

/* ... (demais estilos de análise) ... */

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

/* ======================================== */
/* --- ESTILOS PARA SETUP E EDITOR --- */
/* ======================================== */

.setup-actions, .color-choice-setup, .color-buttons, .setup-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.setup-tabs .control-btn.active {
    background: #2980b9;
}

.starting-player-selector, .edit-controls {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.piece-selector {
    display: flex;
    gap: 10px;
    background: #f8f9fa;
    padding: 5px;
    border-radius: 5px;
    align-items: center;
    justify-content: center;
}

.piece-btn {
    width: 50px;
    height: 50px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    transition: all 0.2s;
    padding: 0;
}

.piece-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.piece-btn.active {
    background: rgba(52, 152, 219, 0.2);
}

.piece-btn .piece {
    width: 35px;
    height: 35px;
}

/* ======================================== */
/* --- RESPONSIVIDADE --- */
/* ======================================== */

@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }
    
    .main-content {
        padding: 10px 0;
    }
    
    .game-section {
        padding: 10px;
    }
    
    .board-container {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    
    .checkers-board {
        width: 90vw;
        max-width: 400px;
        height: 90vw;
        max-height: 400px;
    }

    .game-controls {
        width: 100%;
        max-width: 400px;
    }
    
    .controls-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .coordinates.rank {
        left: -30px;
    }
    
    .coordinates.file {
        bottom: -30px;
    }

    .piece {
        width: 80%;
        height: 80%;
    }
}

/* --- MODO PAISAGEM (CELULAR) --- */
@media (max-width: 920px) and (orientation: landscape) {
    .game-section.active {
        display: flex;
        flex-direction: row;
        gap: 15px;
        align-items: flex-start;
        /* A linha 'overflow-y: auto;' foi REMOVIDA daqui para corrigir o bug */
    }
    
    .board-wrapper {
        max-width: 300px;
    }
    
    .game-controls {
        flex: 1 1 auto;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .move-history, .difficulty-selector, .color-choice, .setup-controls {
        grid-column: 1 / -1;
    }
}

/* ============================================================= */
/* --- ESTILO FINAL E ÚNICO PARA AS COORDENADAS DE TEXTO --- */
/* ============================================================= */

/* 1. DEFINIÇÃO PRINCIPAL (PARA TODAS AS TELAS) */
.square-coordinate {
    position: absolute;
    top: 2px;
    left: 3px;
    font-family: Arial, sans-serif; /* Fonte legível e segura */
    font-size: 10px; /* Tamanho padrão para desktop e paisagem */
    font-weight: bold;
    color: rgba(255, 255, 255, 0.7); /* Cor branca com transparência */
    z-index: 11; /* Garante que fique acima da peça */
    pointer-events: none;
    user-select: none;
}

/* 2. AJUSTE RESPONSIVO (APENAS PARA TELAS MENORES QUE 480px) */
@media (max-width: 480px) {
    .square-coordinate {
        font-size: 8px; /* Reduz a fonte no modo retrato do celular */
    }
}

.analysis-wrapper {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
    display: none; /* O JavaScript muda para 'block' quando a análise começa */
}

/* O cabeçalho com o título e o botão de 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;
}

/* O contêiner do gráfico e dos botões de navegação */
.analysis-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

/* O contêiner específico do gráfico (dá a ele tamanho e borda) */
#analysisGraphContainer {
    width: 100%;
    max-width: 600px;
    height: 120px;
    background-color: #f8f9fa;
    border: 1px solid #ccc;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
}

/* Os botões de navegação da análise (início, anterior, próximo, fim) */
.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;
}

/* A área de informações (melhor lance, avaliação) */
#analysis-info {
    background: #ecf0f1;
    padding: 15px;
    border-radius: 5px;
    text-align: center;
    margin-top: 10px;
}

.analysis-notation {
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.6;
}

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

.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 */
.move-annotation.brilliant { color: #27ae60; } /* Verde para Brilhante */
.move-annotation.excellent { color: #4caf50; }

.best-variation {
    color: #2e7d32;
    font-style: italic;
}

.eval-value {
    color: #666;
    font-weight: bold;
}

.setup-actions,
.analysis-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Estilos para lances clicáveis */
.move-notation {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s;
    display: inline-block;
}

.move-notation:hover {
    background-color: rgba(52, 152, 219, 0.3);
}

.move-notation.active {
    background-color: #3498db !important;
    color: white !important;
    font-weight: bold;
    padding: 3px 6px;
}

.move-notation.analyzing {
    background-color: #f39c12;
    color: white;
    font-weight: bold;
    padding: 3px 6px;
}

/* Análise Detalhada de Lances */
#move-analysis-section {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.move-analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.move-analysis-header h4 {
    margin: 0;
    color: #2c3e50;
    font-size: 16px;
}

#move-analysis-content {
    background: white;
    border-radius: 6px;
    padding: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.analyzing-message {
    text-align: center;
    color: #7f8c8d;
    padding: 20px;
    font-style: italic;
}

.move-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    margin-bottom: 8px;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.move-option:hover {
    background: #f8f9fa;
    border-color: #3498db;
    transform: translateX(3px);
}

.move-option.best-move {
    background: #e3f2fd;
    border-color: #2196f3;
    border-width: 2px;
}

.move-option.best-move:hover {
    background: #bbdefb;
}

.move-notation-text {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 15px;
    color: #2c3e50;
}

.move-option.best-move .move-notation-text {
    color: #1976d2;
}

.move-evaluation {
    display: flex;
    align-items: center;
    gap: 10px;
}

.eval-score {
    font-weight: bold;
    font-size: 14px;
    min-width: 60px;
    text-align: right;
}

.eval-score.positive {
    color: #4caf50;
}

.eval-score.negative {
    color: #f44336;
}

.eval-score.neutral {
    color: #ff9800;
}

.eval-bar-container {
    width: 100px;
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
}

.eval-bar {
    height: 100%;
    background: #3498db;
    transition: width 0.3s;
}

.move-option.best-move .eval-bar {
    background: #2196f3;
}

.deep-analysis-active {
    background: #4caf50 !important;
}

.deep-analysis-progress {
    margin-top: 10px;
    padding: 15px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    text-align: center;
}

.deep-analysis-progress .progress-text {
    color: #856404;
    font-weight: bold;
    margin-bottom: 8px;
}

.progress-bar-container {
    width: 100%;
    height: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #ffc107 0%, #ff9800 100%);
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
}