/* ============================================================================ */
/* 🎯 INSTRUCCIONES PARA CAMBIAR TEMA                                         */
/* ============================================================================ */

/*
🎨 CÓMO CAMBIAR EL TEMA DE COLORES:

1. Ve al inicio del archivo (líneas 6-15) donde están las variables CSS
2. Cambia los valores de estas 3 variables principales:
   --primary: #007bff;         (Color principal)
   --primary-dark: #0056b3;    (Color oscuro para hover)
   --primary-darker: #004085;  (Color muy oscuro para active)

3. También actualiza los valores RGB correspondientes:
   --primary-rgb: 0, 123, 255;     (RGB del color principal)
   --primary-dark-rgb: 0, 86, 179; (RGB del color oscuro)

📋 TEMAS PREDEFINIDOS:

🟡 DORADO (Original):
--primary: #ffab00;
--primary-dark: #ff8f00;
--primary-darker: #ff6f00;
--primary-rgb: 255, 171, 0;
--primary-dark-rgb: 255, 143, 0;

🟢 VERDE:
--primary: #28a745;
--primary-dark: #1e7e34;
--primary-darker: #155724;
--primary-rgb: 40, 167, 69;
--primary-dark-rgb: 30, 126, 52;

🔴 ROJO:
--primary: #dc3545;
--primary-dark: #c82333;
--primary-darker: #a71e2a;
--primary-rgb: 220, 53, 69;
--primary-dark-rgb: 200, 35, 51;

🟣 PÚRPURA:
--primary: #6f42c1;
--primary-dark: #5a32a3;
--primary-darker: #4c2a85;
--primary-rgb: 111, 66, 193;
--primary-dark-rgb: 90, 50, 163;

🟠 NARANJA:
--primary: #fd7e14;
--primary-dark: #e8590c;
--primary-darker: #d63384;
--primary-rgb: 253, 126, 20;
--primary-dark-rgb: 232, 89, 12;

💡 CONSEJO: Solo cambia las variables al inicio del archivo y todo el tema se actualizará automáticamente.
*/


/* ============================================================================ */
/* 🎨 VARIABLES CSS - PERSONALIZACIÓN DEL TEMA                                */
/* ============================================================================ */
/* Para cambiar el tema completo, solo modifica estos valores:                */

:root {
    /* 🔵 COLORES PRINCIPALES (Actualmente: Azul) */
    --primary: #007bff;         /* Azul principal */
    --primary-dark: #0056b3;    /* Azul oscuro (hover) */
    --primary-darker: #004085;  /* Azul muy oscuro (active) */
    
    /* 🎨 ALTERNATIVAS DE TEMA: */
    /* DORADO: #ffab00, #ff8f00, #ff6f00 */
    /* VERDE:  #28a745, #1e7e34, #155724 */
    /* ROJO:   #dc3545, #c82333, #a71e2a */
    /* PÚRPURA: #6f42c1, #5a32a3, #4c2a85 */
    
    /* 🌈 COLORES RGBA (se calculan automáticamente) */
    --primary-rgb: 0, 123, 255;     /* RGB del color principal */
    --primary-dark-rgb: 0, 86, 179; /* RGB del color oscuro */
    
    /* 🎨 FONDOS Y SUPERFICIES */
    --bg-main: #0a0a0a;            /* Fondo principal muy oscuro */
    --bg-secondary: #1a1a1a;        /* Fondo secundario oscuro */
    --bg-card: #2a2a2a;            /* Fondo de tarjetas */
    --bg-overlay: rgba(26, 26, 26, 0.95); /* Overlay con transparencia */
    
    /* 📝 TEXTOS */
    --text-primary: #ffffff;        /* Texto principal (blanco) */
    --text-secondary: #ccc;         /* Texto secundario (gris claro) */
    --text-muted: #888;            /* Texto apagado (gris) */
    --text-on-primary: #000;       /* Texto sobre color primario */
    
    /* 🔳 BORDES Y LÍNEAS */
    --border-light: #333;          /* Bordes claros */
    --border-medium: #555;         /* Bordes medios */
    --border-glass: rgba(255, 255, 255, 0.2); /* Bordes cristal */
    
    /* 🏁 TABLERO DE AJEDREZ */
    --board-light: #f0d9b5;        /* Casillas claras */
    --board-dark: #b58863;         /* Casillas oscuras */
    
    /* 🎯 ESTADOS ESPECIALES */
    --success: #28a745;            /* Verde para éxito */
    --danger: #dc3545;             /* Rojo para peligro/jaque */
    --warning: #ffc107;            /* Amarillo para advertencias */
    --info: var(--primary);        /* Azul para información */
}

/* ============================================================================ */
/* 🏗️ ESTILOS BASE                                                            */
/* ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
  overflow: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-main) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    overflow-x: hidden;
    overflow-y: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior-y: contain;
}

.container {
    max-width: 100vw;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* ============================================================================ */
/* 🏠 PANTALLA DE INICIO Y ESPERA                                              */
/* ============================================================================ */

.start-screen, .waiting-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 20px;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-main) 0%, var(--bg-secondary) 100%);
    z-index: 500;
}

.start-screen.hidden, .waiting-screen.hidden {
    display: none;
}

.app-icon {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 60px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(var(--primary-rgb), 0.3);
    animation: pulse 2s infinite;
    position: relative;
}

.app-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.app-icon img:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.app-icon span {
    font-size: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.app-title {
    font-size: 48px;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
      font-family: "Cinzel", "Playfair Display", "Cardo", "Trajan Pro", serif;
}

.app-title .last3 {
  color: #fff;
}

.app-subtitle {
    font-size: 18px;
    color: #FF8C00;
    margin-bottom: 50px;

}

.start-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 300px;
}

.btn-icon {
    margin-right: 10px;
    font-size: 20px;
}

.waiting-title {
    font-size: 36px;
    color: var(--primary);
    margin-bottom: 15px;
}

.waiting-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 25px;
}

.game-code-container {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 15px 25px;
    margin-bottom: 25px;
    border: 1px solid var(--border-light);
}

#game-code-display {
    font-size: 32px;
    font-weight: bold;
    letter-spacing: 5px;
    color: var(--text-primary);
    margin-right: 20px;
}

#copy-code-btn {
    padding: 10px;
}

#waiting-status {
    color: var(--text-muted);
    margin-bottom: 30px;
    min-height: 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-light);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
    margin-bottom: 30px;
}

/* ============================================================================ */
/* 📱 HEADER Y NAVEGACIÓN                                                      */
/* ============================================================================ */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-overlay);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    border-bottom: 1px solid var(--border-light);
}

.header.hidden {
    display: none;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
}

.menu-btn {
    background: linear-gradient(135deg, var(--border-light), var(--border-medium));
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.menu-btn:hover {
    background: linear-gradient(135deg, var(--border-medium), #666);
    transform: translateY(-1px);
}

/* ============================================================================ */
/* 🎮 ÁREA DE JUEGO                                                           */
/* ============================================================================ */

.game-area {
    margin-top: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 500px;
}

.game-area.hidden {
    display: none;
}

.timer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
    padding: 0 10px;
}

.timer-container.hidden {
    display: none !important;
}

.timer {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: bold;
    min-width: 80px;
    text-align: center;
    transition: all 0.3s;
}

.timer.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-on-primary);
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.4);
}

.timer.disabled {
    opacity: 0.3;
}

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

/* ============================================================================ */
/* 🤖 INDICADOR IA PENSANDO                                                   */
/* ============================================================================ */

.ai-thinking {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(var(--primary-rgb), 0.1);
    border: 1px solid rgba(var(--primary-rgb), 0.3);
    border-radius: 12px;
    padding: 12px 20px;
    margin-top: 10px;
    backdrop-filter: blur(10px);
    animation: thinking-pulse 2s infinite;
}

.ai-thinking.hidden {
    display: none;
}

.thinking-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(var(--primary-rgb), 0.3);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes thinking-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.ai-thinking span {
    color: var(--primary);
    font-weight: bold;
    font-size: 14px;
}

/* ============================================================================ */
/* ♟️ TABLERO DE AJEDREZ                                                       */
/* ============================================================================ */

.chessboard {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border: 3px solid var(--primary);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
}

.square {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
    box-sizing: border-box;
    min-height: 0;
    min-width: 0;
}

.square.light {
    background: var(--board-light);
}

.square.dark {
    background: var(--board-dark);
}

.square.selected {
    background: var(--primary) !important;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.4);
}

.square.possible-move {
    background: rgba(0, 255, 0, 0.3) !important;
}

.square.possible-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: rgba(0, 255, 0, 0.8);
    border-radius: 50%;
}

.square.last-move {
    background: rgba(var(--primary-rgb), 0.4) !important;
}

.square.in-check {
    background: rgba(220, 53, 69, 0.6) !important;
    animation: check-flash 1s infinite;
}

@keyframes check-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.piece {
    width: 85%;
    height: 85%;
    transition: all 0.3s;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    font-size: 28px;
    font-weight: bold;
    text-align: center;
}

.piece img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ============================================================================ */
/* 🏆 PIEZAS CAPTURADAS                                                        */
/* ============================================================================ */

.captured-pieces {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
    margin-bottom: 15px;
    padding: 0 10px;
}

.captured-section {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 8px;
    min-height: 50px;
    max-height: 80px;
    width: 48%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
}

.captured-section h4 {
    font-size: 11px;
    margin-bottom: 5px;
    color: var(--text-secondary);
    text-align: center;
}

.captured-list {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: center;
}

.captured-piece {
    width: 20px;
    height: 20px;
    opacity: 0.8;
}

.captured-piece img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ============================================================================ */
/* 🔘 BOTONES                                                                 */
/* ============================================================================ */

.btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-on-primary);
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.3);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.btn:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-darker));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.4);
}

.btn:hover::before {
    left: 100%;
}

.btn:active {
    transform: translateY(0) scale(0.95);
}

.btn:disabled {
    background: linear-gradient(135deg, var(--border-medium), #444);
    color: #999;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn:disabled::before {
    display: none;
}

.btn.secondary {
    background: linear-gradient(135deg, var(--border-light), var(--border-medium));
    color: var(--text-primary);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn.secondary:hover {
    background: linear-gradient(135deg, var(--border-medium), #666);
}

.btn.icon-btn {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    position: relative;
    overflow: hidden;
}

.btn.icon-btn img {
    width: 20px;
    height: 20px;
    filter: brightness(0);
    transition: all 0.3s ease;
}

.btn.secondary.icon-btn img {
    filter: brightness(0) invert(1);
}

.btn.icon-btn:hover img {
    transform: scale(1.1);
}

.btn.icon-btn:active {
    transform: scale(0.95);
}

/* ============================================================================ */
/* 📊 ESTADO DEL JUEGO                                                        */
/* ============================================================================ */

.status {
    text-align: center;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: bold;
    min-height: 25px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

/* ============================================================================ */
/* 📋 MENÚ LATERAL                                                            */
/* ============================================================================ */

.sidebar {
    position: fixed;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100vh;
    background: rgba(26, 26, 26, 0.98);
    backdrop-filter: blur(20px);
    padding: 20px;
    transition: right 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
    border-left: 1px solid var(--border-light);
}

.sidebar.open {
    right: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-light);
}

.close-btn {
    background: linear-gradient(135deg, var(--border-light), var(--border-medium));
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s;
}

.close-btn:hover {
    background: linear-gradient(135deg, var(--border-medium), #666);
}

.menu-section {
    margin-bottom: 25px;
}

.menu-section h3 {
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 16px;
}

.menu-option {
    margin-bottom: 15px;
}

.menu-option label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

select, input[type="range"], input[type="number"] {
    width: 100%;
    padding: 10px;
    background: var(--border-light) !important; /* Forzar color de fondo */
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    color: var(--text-primary) !important; /* Forzar color de texto */
    font-size: 14px;
    transition: all 0.3s;
    
    /* Fix específico para Windows */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    
    /* Flecha personalizada */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 40px;
}

select:focus, input[type="range"]:focus, input[type="number"]:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.3);
    background: var(--bg-card) !important; /* Color más claro al hacer focus */
}

/* Fix específico para opciones del select en Windows */
select option {
    background: var(--border-light) !important;
    color: var(--text-primary) !important;
    padding: 8px;
}

select option:hover {
    background: var(--primary) !important;
    color: var(--text-on-primary) !important;
}

select option:checked {
    background: var(--primary) !important;
    color: var(--text-on-primary) !important;
}

/* Fix adicional para navegadores WebKit (Chrome, Edge) */
select::-webkit-scrollbar {
    width: 8px;
}

select::-webkit-scrollbar-track {
    background: var(--border-light);
}

select::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

select::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}
.toggle-btn {
    background: linear-gradient(135deg, var(--border-light), var(--bg-card));
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-size: 14px;
    transition: all 0.3s;
}

.toggle-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-on-primary);
    border-color: var(--primary);
}

.toggle-btn:hover {
    background: linear-gradient(135deg, var(--border-medium), var(--border-light));
}

.toggle-btn.active:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-darker));
}

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

.time-controls input {
    grid-column: span 1;
}

/* ============================================================================ */
/* 🪟 MODALES                                                                 */
/* ============================================================================ */

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

.modal.show {
    display: flex;
    animation: modal-fade-in 0.3s ease-out;
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
    border: 1px solid var(--border-light);
    border-radius: 15px;
    padding: 30px;
    max-width: 450px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal h2 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 24px;
}

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

.color-selection {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 20px 0;
}

.color-option {
    padding: 15px 25px;
    border: 2px solid var(--border-medium);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.1);
    flex-grow: 1;
}

.color-option:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.color-option.selected {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.2);
}

/* Estilos para el modal multijugador */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary);
    font-weight: bold;
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
    animation: tab-fade-in 0.5s;
}

.tab-content.active {
    display: block;
}

@keyframes tab-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-input {
    width: 100%;
    padding: 12px;
    background: var(--border-light);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: 15px;
    margin-top: 20px;
    text-align: center;
    text-transform: uppercase;
}

.modal-input::placeholder {
    color: var(--text-muted);
    text-transform: none;
}

.modal-input:focus {
    border-color: var(--primary);
    outline: none;
}


/* Modal de pérdida de foco */
#focus-lost-modal {
    z-index: 2100;
}

#focus-lost-modal .modal-content {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
    border: 2px solid var(--primary);
    animation: pulse-border 2s infinite;
    box-shadow: 0 0 30px rgba(var(--primary-rgb), 0.5);
}

@keyframes pulse-border {
    0%, 100% { 
        border-color: var(--primary); 
        box-shadow: 0 0 30px rgba(var(--primary-rgb), 0.5);
    }
    50% { 
        border-color: var(--primary-dark); 
        box-shadow: 0 0 50px rgba(var(--primary-dark-rgb), 0.7);
    }
}

#focus-lost-modal h2 {
    animation: pulse-text 1.5s infinite;
    color: var(--primary);
    margin-bottom: 15px;
}

@keyframes pulse-text {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.02); }
}

#focus-lost-modal .modal-content > div {
    animation: bounce-icon 2s infinite;
}

@keyframes bounce-icon {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

#focus-lost-modal p {
    font-size: 16px;
    margin: 10px 0;
    color: var(--text-secondary);
}

#focus-lost-modal .modal-buttons .btn {
    font-size: 18px;
    padding: 15px 30px;
    animation: pulse-button 3s infinite;
}

@keyframes pulse-button {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

#focus-lost-modal.show {
    animation: focus-modal-fade-in 0.5s ease-out;
}

@keyframes focus-modal-fade-in {
    from {
        opacity: 0;
        transform: scale(0.8);
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        transform: scale(1);
        backdrop-filter: blur(5px);
    }
}

/* ============================================================================ */
/* 🦶 FOOTER                                                                  */
/* ============================================================================ */

.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(10px);
    padding: 10px;
    text-align: center;
    font-size: 12px;
    border-top: 1px solid var(--border-light);
}

.version {
    margin-bottom: 5px;
    color: var(--text-muted);
}

.footer a {
    color: var(--primary);
    text-decoration: none;
}

/* ============================================================================ */
/* 🌊 OVERLAY                                                                 */
/* ============================================================================ */

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 999;
}

.overlay.show {
    display: block;
}

/* ============================================================================ */
/* 🍞 NOTIFICACIÓN TOAST                                                      */
/* ============================================================================ */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-card);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, bottom 0.3s;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    bottom: 100px;
}

.toast.error {
    background-color: var(--danger);
    color: var(--text-primary);
    border-color: var(--danger);
}

.toast.success {
    background-color: var(--success);
    color: var(--text-primary);
    border-color: var(--success);
}


/* 🎨 TEMAS DEL TABLERO */
.board-classic .square.light { background: #f0d9b5; }
.board-classic .square.dark { background: #b58863; }

.board-blue .square.light { background: #dee3e6; }
.board-blue .square.dark { background: #8ca2ad; }

.board-green .square.light { background: #ffffdd; }
.board-green .square.dark { background: #86a666; }

.board-purple .square.light { background: #e6e6fa; }
.board-purple .square.dark { background: #9370db; }

/* 🌸 Tema Rosa */
.board-rosa .square.light { background: #ffc0cb; }
.board-rosa .square.dark { background: #ff69b4; }

/* 🌊 Tema Océano */
.board-oceano .square.light { background: #87ceeb; }
.board-oceano .square.dark { background: #4682b4; }

/* 🌙 Tema Noche */
.board-noche .square.light { background: #34495e; }
.board-noche .square.dark { background: #2c3e50; }

/* 🔥 Tema Fuego */
.board-fuego .square.light { background: #ff6b35; }
.board-fuego .square.dark { background: #f7931e; }

/* ❄️ Tema Hielo */
.board-hielo .square.light { background: #e6f3ff; }
.board-hielo .square.dark { background: #b3d9ff; }

/* 🍫 Tema Chocolate */
.board-chocolate .square.light { background: #d2b48c; }
.board-chocolate .square.dark { background: #8b4513; }

/* 🌅 Tema Atardecer */
.board-atardecer .square.light { background: #ffd700; }
.board-atardecer .square.dark { background: #ff8c00; }

/* 🌲 Tema Bosque */
.board-bosque .square.light { background: #90ee90; }
.board-bosque .square.dark { background: #228b22; }

/* 🎭 Tema Elegante */
.board-elegante .square.light { background: #f8f8ff; }
.board-elegante .square.dark { background: #696969; }

/* 🌈 Tema Vibrante */
.board-vibrante .square.light { background: #00ffff; }
.board-vibrante .square.dark { background: #ff00ff; }



/* ============================================================================ */
/* 📱 RESPONSIVE DESIGN                                                       */
/* ============================================================================ */

@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    .header {
        padding: 0 15px;
    }
    
    .logo {
        font-size: 20px;
    }
    
    .sidebar {
        width: 300px;
    }
    
    .chessboard {
        max-width: 350px;
    }

    .app-title {
        font-size: 36px;
    }

    .app-icon {
        width: 100px;
        height: 100px;
        font-size: 50px;
    }

    .app-icon img {
        border-radius: 15px;
    }
    
    .app-icon span {
        font-size: 50px;
    }

    .start-buttons {
        max-width: 280px;
    }

    .modal-content {
        padding: 20px;
        margin: 10px;
    }

    .color-selection {
        flex-direction: column;
        gap: 10px;
    }

    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .btn {
        width: 100%;
    }

    .controls {
        gap: 5px;
    }

    .btn.icon-btn {
        padding: 6px 10px;
        min-width: 35px;
    }

    .captured-section {
        padding: 6px;
        min-height: 45px;
        max-height: 70px;
    }

    .captured-section h4 {
        font-size: 10px;
        margin-bottom: 3px;
    }

    .captured-piece {
        width: 18px;
        height: 18px;
    }

    .ai-thinking {
        padding: 8px 15px;
        font-size: 12px;
    }

    .thinking-spinner {
        width: 16px;
        height: 16px;
    }

    #focus-lost-modal .modal-content {
        margin: 20px;
        padding: 25px;
    }
    
    #focus-lost-modal h2 {
        font-size: 20px;
    }
    
    #focus-lost-modal .modal-content > div {
        font-size: 40px;
        margin: 15px 0;
    }
    
    #focus-lost-modal .modal-buttons .btn {
        font-size: 16px;
        padding: 12px 25px;
        width: 100%;
    }
}

@media (max-width: 320px) {
    .app-title {
        font-size: 28px;
    }

    .app-icon {
        width: 100px;
        height: 100px;
        font-size: 50px;
    }

    .chessboard {
        max-width: 300px;
    }

    .timer {
        min-width: 70px;
        padding: 8px 12px;
        font-size: 14px;
    }

    .status {
        font-size: 16px;
        padding: 8px;
    }
}

/* ============================================================================ */
/* 🌙 MODO OSCURO MEJORADO                                                    */
/* ============================================================================ */

@media (prefers-color-scheme: dark) {
    body {
        background: black;
    }
}

/* ============================================================================ */
/* ♿ ALTO CONTRASTE                                                          */
/* ============================================================================ */

@media (prefers-contrast: high) {
    .square.light {
        background: #ffffff;
    }

    .square.dark {
        background: #000000;
    }

    .piece img {
        filter: contrast(1.5);
    }
}

/* ============================================================================ */
/* 🎬 MOVIMIENTO REDUCIDO                                                     */
/* ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .app-icon {
        animation: none;
    }

    .ai-thinking {
        animation: none;
    }

    .thinking-spinner {
        animation: none;
    }
}

/* ============================================================================ */
/* 🖨️ ESTILOS PARA IMPRESIÓN                                                 */
/* ============================================================================ */

@media print {
    .header,
    .footer,
    .sidebar,
    .modal,
    .overlay,
    .controls,
    .ai-thinking {
        display: none !important;
    }

    .chessboard {
        max-width: 400px;
        border: 2px solid #000;
    }

    .square.light {
        background: #fff !important;
    }

    .square.dark {
        background: #ddd !important;
    }
}


/* ============================================================================ */
/* 🏆 ESTILOS PARA FINAL DEL JUEGO                                            */
/* ============================================================================ */

@keyframes game-end-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.02);
        opacity: 0.95;
    }
}

.status.game-ended {
    background: linear-gradient(135deg, var(--danger), #e74c3c) !important;
    color: #ffffff !important;
    font-weight: bold !important;
    font-size: 20px !important;
    padding: 15px !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
    animation: game-end-pulse 2s infinite !important;
    text-align: center;
    min-height: auto;
}

.status.player-won {
    background: linear-gradient(135deg, var(--success), #20c997) !important;
}

.status.player-lost {
    background: linear-gradient(135deg, var(--danger), #e74c3c) !important;
}

.status.game-draw {
    background: linear-gradient(135deg, var(--warning), #fd7e14) !important;
    color: var(--text-on-primary) !important;
}

#game-end-details-btn {
    margin-top: 10px !important;
    width: 100% !important;
    max-width: 400px !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05)) !important;
    border: 1px solid var(--border-glass) !important;
    backdrop-filter: blur(10px) !important;
    transition: all 0.3s ease !important;
}

#game-end-details-btn:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1)) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3) !important;
}

@media (max-width: 480px) {
    .status.game-ended {
        font-size: 18px !important;
        padding: 12px !important;
    }

    #game-end-details-btn {
        font-size: 14px !important;
        padding: 10px 20px !important;
    }
}

@media (max-width: 320px) {
    .status.game-ended {
        font-size: 16px !important;
        padding: 10px !important;
    }
}





/* ============================================================================ */
/* 🧠 SUGERENCIA DE MOVIMIENTO - ACTUALIZADO                                   */
/* ============================================================================ */

/* Casilla con movimiento sugerido (destino) */
.square.suggested-move {
    background: rgba(255, 0, 255, 0.4) !important;
    position: relative;
    animation: suggested-pulse 2s infinite;
}

.square.suggested-move::before {
    content: '';
    position: absolute;
    width: 20%;
    height: 20%;
    background: #ff00ff;
    border-radius: 50%;
    top: 5%;
    right: 5%;
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.8);
    animation: suggested-glow 1.5s infinite alternate;
}

/* Nueva: Pieza sugerida globalmente (cuando no hay selección) */
.square.suggested-piece {
    position: relative;
    animation: suggested-piece-pulse 2.5s infinite;
}

.square.suggested-piece::after {
    content: '';
    position: absolute;
    inset: 2px;
    border: 3px solid #ff00ff;
    border-radius: 8px;
    box-shadow:
        inset 0 0 15px rgba(255, 0, 255, 0.3),
        0 0 20px rgba(255, 0, 255, 0.6);
    animation: suggested-piece-border 2s infinite;
    pointer-events: none;
}

@keyframes suggested-pulse {
    0%, 100% {
        background: rgba(255, 0, 255, 0.4) !important;
    }
    50% {
        background: rgba(255, 0, 255, 0.6) !important;
    }
}

@keyframes suggested-glow {
    0% {
        opacity: 0.8;
        transform: scale(1);
        box-shadow: 0 0 10px rgba(255, 0, 255, 0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1.2);
        box-shadow: 0 0 15px rgba(255, 0, 255, 1);
    }
}

@keyframes suggested-piece-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

@keyframes suggested-piece-border {
    0%, 100% {
        border-color: #ff00ff;
        box-shadow:
            inset 0 0 15px rgba(255, 0, 255, 0.3),
            0 0 20px rgba(255, 0, 255, 0.6);
    }
    50% {
        border-color: #ff66ff;
        box-shadow:
            inset 0 0 20px rgba(255, 0, 255, 0.5),
            0 0 25px rgba(255, 0, 255, 0.8);
    }
}

/* Botón toggle deshabilitado en multijugador */
.toggle-btn.disabled {
    background: linear-gradient(135deg, #222, #333) !important;
    color: #666 !important;
    border-color: #444 !important;
    cursor: not-allowed !important;
    opacity: 0.6;
}

.toggle-btn.disabled:hover {
    background: linear-gradient(135deg, #222, #333) !important;
    transform: none !important;
}

/* Indicador de modo debug (discreto) */
.debug-indicator {
    position: fixed;
    top: 70px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: #ff00ff;
    border-radius: 50%;
    z-index: 1001;
    opacity: 0.7;
    animation: debug-blink 3s infinite;
    display: none;
}

@keyframes debug-blink {
    0%, 90%, 100% { opacity: 0.7; }
    95% { opacity: 0.3; }
}

/* Animación para activación de modo debug */
.debug-activation {
    animation: debug-flash 0.5s ease-out;
}

@keyframes debug-flash {
    0% {
        background: linear-gradient(135deg, var(--bg-main), var(--bg-secondary));
    }
    50% {
        background: linear-gradient(135deg, rgba(255, 0, 255, 0.1), rgba(255, 0, 255, 0.05));
    }
    100% {
        background: linear-gradient(135deg, var(--bg-main), var(--bg-secondary));
    }
}

/* Estilo especial para el logo del header cuando es clickeable para debug */
.header .logo {
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
}

.header .logo:hover {
    color: var(--primary-dark);
    transform: scale(1.02);
}

.header .logo:active {
    transform: scale(0.98);
}

/* Indicación visual sutil durante el press para debug */
.header .logo.debug-pressing {
    background: linear-gradient(135deg, rgba(255, 0, 255, 0.1), rgba(255, 0, 255, 0.05));
    border-radius: 8px;
    padding: 4px 8px;
    margin: -4px -8px;
    animation: debug-press-pulse 0.5s infinite;
}

@keyframes debug-press-pulse {
    0%, 100% {
        background: linear-gradient(135deg, rgba(255, 0, 255, 0.1), rgba(255, 0, 255, 0.05));
    }
    50% {
        background: linear-gradient(135deg, rgba(255, 0, 255, 0.2), rgba(255, 0, 255, 0.1));
    }
}

/* Responsive para dispositivos móviles */
@media (max-width: 480px) {
    .square.suggested-move::before {
        width: 25%;
        height: 25%;
        top: 3%;
        right: 3%;
    }

    .square.suggested-piece::after {
        inset: 1px;
        border-width: 2px;
        border-radius: 6px;
    }

    .debug-indicator {
        width: 6px;
        height: 6px;
        top: 65px;
        right: 8px;
    }
}

@media (max-width: 320px) {
    .square.suggested-move::before {
        width: 30%;
        height: 30%;
    }

    .square.suggested-piece::after {
        border-width: 2px;
        border-radius: 4px;
    }
}


/* ============================================================================ */
/* 🎯 CÓDIGO DE PARTIDA PERMANENTE                                             */
/* ============================================================================ */

.game-code-permanent {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.1), rgba(0, 123, 255, 0.05));
    border: 1px solid rgba(0, 123, 255, 0.3);
    border-radius: 12px;
    padding: 12px 20px;
    margin: 10px 0;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    max-width: 400px;
    width: 100%;
}

.game-code-permanent:hover {
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.15), rgba(0, 123, 255, 0.08));
    border-color: rgba(0, 123, 255, 0.4);
    transform: translateY(-1px);
}

.game-code-permanent.hidden {
    display: none;
}

.code-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: bold;
}

.code-label {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: normal;
}

.code-value {
    color: var(--primary);
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid rgba(var(--primary-rgb), 0.3);
}

.code-copy-btn {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.8), rgba(var(--primary-dark-rgb), 0.9));
    border: 1px solid rgba(var(--primary-rgb), 0.5);
    color: var(--text-on-primary);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
}

.code-copy-btn:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.4);
}

.code-copy-btn:active {
    transform: translateY(0) scale(0.95);
}

.code-copy-btn img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}

.code-description {
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
    line-height: 1.3;
    max-width: 280px;
}

/* ============================================================================ */
/* 📱 RESPONSIVE PARA CÓDIGO PERMANENTE                                        */
/* ============================================================================ */

@media (max-width: 480px) {
    .game-code-permanent {
        padding: 10px 15px;
        margin: 8px 0;
        gap: 6px;
    }

    .code-info {
        gap: 8px;
        flex-wrap: wrap;
    }

    .code-label {
        font-size: 12px;
    }

    .code-value {
        font-size: 18px;
        letter-spacing: 1px;
        padding: 3px 8px;
    }

    .code-copy-btn {
        min-width: 28px;
        min-height: 28px;
        padding: 4px 6px;
    }

    .code-copy-btn img {
        width: 14px;
        height: 14px;
    }

    .code-description {
        font-size: 11px;
        max-width: 260px;
    }
}

@media (max-width: 320px) {
    .game-code-permanent {
        padding: 8px 12px;
    }

    .code-info {
        gap: 6px;
    }

    .code-value {
        font-size: 16px;
        letter-spacing: 1px;
    }

    .code-description {
        font-size: 10px;
        max-width: 240px;
    }
}