/* Reset e Variáveis */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --dark-bg: #1a1a2e;
    --darker-bg: #16213e;
    --light-bg: #f8f9fa;
    --text-light: #ffffff;
    --text-dark: #333333;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s ease;
    --border-radius: 12px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--darker-bg) 100%);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.chess-loader {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.chess-piece {
    width: 40px;
    height: 40px;
    background: var(--secondary-color);
    border-radius: 8px;
    animation: bounce 1.5s infinite;
}

.chess-piece.king { animation-delay: 0s; }
.chess-piece.queen { animation-delay: 0.2s; }
.chess-piece.bishop { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

/* Container Principal */
.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 20px;
    opacity: 0;
    animation: fadeIn 0.8s ease forwards;
}

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

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.header-left h1 {
    font-size: 2.2em;
    background: linear-gradient(90deg, #f8b500, #fceabb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 15px;
}

.game-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(46, 204, 113, 0.2);
    border-radius: 20px;
    margin-top: 10px;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.header-center {
    display: flex;
    align-items: center;
    gap: 30px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 25px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    transition: var(--transition);
    min-width: 200px;
}

.player-info.active-player {
    background: rgba(52, 152, 219, 0.15);
    border: 2px solid var(--secondary-color);
    transform: scale(1.05);
}

.player-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.player-avatar.jogador1 {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: var(--dark-bg);
}

.player-avatar.jogador2 {
    background: linear-gradient(135deg, #2c3e50 0%, #4a6278 100%);
}

.player-timer {
    font-family: 'Courier New', monospace;
    font-size: 1.4em;
    font-weight: bold;
    padding: 8px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 2px solid var(--secondary-color);
}

.vs-separator {
    background: var(--accent-color);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-avatar {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2em;
}

.btn-logout {
    padding: 10px 20px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-logout:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

/* Layout Principal */
.main-content {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 25px;
    margin-bottom: 30px;
}

@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    .sidebar {
        display: none;
    }
}

/* Sidebars */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.sidebar-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    padding: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-section h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    color: #f8b500;
    font-size: 1.2em;
}

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

.control-btn {
    padding: 12px;
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.control-btn.primary {
    background: var(--secondary-color);
}

.control-btn.success {
    background: var(--success-color);
}

.control-btn.warning {
    background: var(--warning-color);
}

.control-btn.danger {
    background: var(--accent-color);
}

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

/* Histórico de Jogadas */
.move-history {
    max-height: 300px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 15px;
}

.move-entry {
    display: grid;
    grid-template-columns: 40px 1fr 1fr;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: var(--transition);
}

.move-entry:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Área Principal do Jogo */
.game-main {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: var(--border-radius);
}

.turn-indicator {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 25px;
    border-radius: 30px;
    font-weight: bold;
    font-size: 1.1em;
    transition: var(--transition);
}

.turn-indicator.your-turn {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    animation: pulse 2s infinite;
}

.turn-indicator.opponent-turn {
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
}

.indicator-dot {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Tabuleiro Aprimorado */
.chess-board-container {
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--border-radius);
    padding: 30px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.coordenadas-colunas {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    margin-bottom: 10px;
    margin-left: 40px;
}

.coordenadas-linhas {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin-right: 10px;
}

.coordenada {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    font-weight: bold;
}

.board-and-coords {
    display: flex;
}

.chess-board {
    display: inline-block;
    border: 3px solid #8b4513;
    border-radius: 8px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.row {
    display: flex;
}

.square {
    width: 70px;
    height: 70px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

@media (max-width: 768px) {
    .square {
        width: 45px;
        height: 45px;
    }
}

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

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

.square:hover {
    filter: brightness(1.2);
    transform: scale(1.05);
    z-index: 2;
}

.square.selected {
    box-shadow: inset 0 0 0 4px var(--secondary-color);
    z-index: 3;
}

.square.valid-move::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: rgba(46, 204, 113, 0.6);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.square.valid-capture {
    box-shadow: inset 0 0 0 3px var(--accent-color);
}

.piece {
    width: 85%;
    height: 85%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 4;
    transition: transform 0.3s ease;
}

.piece.branco::before, .piece.preto::before {
    font-size: 50px;
    line-height: 1;
    font-weight: normal;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

@media (max-width: 768px) {
    .piece.branco::before, .piece.preto::before {
        font-size: 35px;
    }
}

.piece.branco.rei::before { content: '♔'; color: white; }
.piece.branco.rainha::before { content: '♕'; color: white; }
.piece.branco.torre::before { content: '♖'; color: white; }
.piece.branco.bispo::before { content: '♗'; color: white; }
.piece.branco.cavalo::before { content: '♘'; color: white; }
.piece.branco.peao::before { content: '♙'; color: white; }

.piece.preto.rei::before { content: '♚'; color: #2c3e50; }
.piece.preto.rainha::before { content: '♛'; color: #2c3e50; }
.piece.preto.torre::before { content: '♜'; color: #2c3e50; }
.piece.preto.bispo::before { content: '♝'; color: #2c3e50; }
.piece.preto.cavalo::before { content: '♞'; color: #2c3e50; }
.piece.preto.peao::before { content: '♟'; color: #2c3e50; }

/* Footer do Jogo */
.game-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: var(--border-radius);
}

.selected-info {
    display: flex;
    gap: 30px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-label {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.7);
}

.info-value {
    font-weight: bold;
    font-size: 1.1em;
    color: #f8b500;
}

/* Análise e Estatísticas */
.evaluation-bar {
    height: 40px;
    background: linear-gradient(to right, #e74c3c, #f39c12, #2ecc71);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
}

.evaluation-fill {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    transform: translateX(-50%);
}

.evaluation-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.1);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
}

.stat-icon.win { background: rgba(46, 204, 113, 0.2); color: #2ecc71; }
.stat-icon.loss { background: rgba(231, 76, 60, 0.2); color: #e74c3c; }
.stat-icon.draw { background: rgba(52, 152, 219, 0.2); color: #3498db; }
.stat-icon.rating { background: rgba(155, 89, 182, 0.2); color: #9b59b6; }

/* Notificações */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    background: white;
    color: #333;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideInRight 0.3s ease;
    min-width: 300px;
}

.notification.success {
    border-left: 5px solid var(--success-color);
}

.notification.error {
    border-left: 5px solid var(--accent-color);
}

.notification.info {
    border-left: 5px solid var(--secondary-color);
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    backdrop-filter: blur(5px);
}

.modal {
    background: var(--darker-bg);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Responsividade */
@media (max-width: 1024px) {
    .main-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .header-center {
        order: 1;
        width: 100%;
    }
    
    .header-left, .header-right {
        width: 100%;
        text-align: center;
    }
    
    .game-main {
        order: 2;
    }
    
    .square {
        width: 55px;
        height: 55px;
    }
}

@media (max-width: 768px) {
    .player-info {
        min-width: auto;
        flex-direction: column;
        text-align: center;
    }
    
    .game-header, .game-footer {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .selected-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .square {
        width: 40px;
        height: 40px;
    }
    
    .piece.branco::before, .piece.preto::before {
        font-size: 30px;
    }
}

/* Estilos para Orientação Invertida */
.container[data-orientacao="invertido"] .chess-board-container {
    transform: rotate(180deg);
}

.container[data-orientacao="invertido"] .chess-board-container .coordenada,
.container[data-orientacao="invertido"] .chess-board-container .piece {
    transform: rotate(180deg);
}

/* Efeitos de Captura */
.capture-effect {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(231, 76, 60, 0.3) 0%, transparent 70%);
    pointer-events: none;
    z-index: 5;
    animation: capturePulse 0.5s ease-out;
}

@keyframes capturePulse {
    0% { transform: scale(0.5); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Peças Capturadas */
.captured-container {
    display: flex;
    gap: 20px;
}

.captured-white, .captured-black {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 40px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    min-width: 200px;
}

.captured-piece {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Botões de Modo */
.mode-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: 8px;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.mode-btn:hover, .mode-btn.active {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    transform: translateY(-2px);
}

/* Ações Rápidas */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}