/* --- VARIABLES DE TEMA --- */
:root {
    --color-background: #2c3e50;
    --color-text: #ecf0f1;
    --color-ui-box: #34495e;
    --color-border: #1c2833;
}

body.theme-blue { --color-light-square: #a9d6e5; --color-dark-square: #468faf; --color-highlight: rgba(241, 196, 15, 0.7); --color-last-move: rgba(241, 196, 15, 0.4); --color-selected: #f1c40f; }
body.theme-wood { --color-light-square: #f0d9b5; --color-dark-square: #b58863; --color-highlight: rgba(139, 172, 137, 0.8); --color-last-move: rgba(139, 172, 137, 0.5); --color-selected: #8bac89; }
body.theme-marble { --color-light-square: #EAECEE; --color-dark-square: #85929E; --color-highlight: rgba(212, 172, 13, 0.7); --color-last-move: rgba(212, 172, 13, 0.4); --color-selected: #D4AC0D; }

/* --- ESTILOS GENERALES --- */
body { font-family: Arial, sans-serif; display: flex; flex-direction: column; background-color: var(--color-background); color: var(--color-text); margin: 0; height: 100vh; overflow: hidden; }
.header-container { display: flex; justify-content: center; align-items: center; padding: 15px 0; flex-shrink: 0; position: relative; }
.main-title { font-size: 2.2em; margin: 0; text-align: center; }
.info-link { position: absolute; right: 30px; top: 50%; transform: translateY(-50%); color: var(--color-text); text-decoration: none; background-color: var(--color-ui-box); padding: 8px 15px; border-radius: 6px; transition: background-color 0.2s; }
.info-link:hover { background-color: #4a637e; }

/* LAYOUT PRINCIPAL */
.main-layout { display: flex; justify-content: space-between; align-items: stretch; gap: 30px; width: 100%; padding: 0 30px 30px 30px; box-sizing: border-box; flex-grow: 1; overflow: hidden; }
.profiles-column { display: flex; flex-direction: column; gap: 20px; width: 220px; flex-shrink: 0; }
.sidebar { width: 280px; display: flex; flex-direction: column; gap: 20px; flex-shrink: 0; }
.profile-box { width: 100%; padding: 15px; background-color: var(--color-ui-box); border-radius: 12px; text-align: center; border: 3px solid transparent; transition: all 0.3s ease; }
.avatar { font-size: 80px; line-height: 1; margin-bottom: 10px; }
.profile-name { margin: 0; font-size: 1.3em; color: var(--color-text); }

@keyframes glowing-border { 0% { box-shadow: 0 0 3px 2px #3498db; } 50% { box-shadow: 0 0 15px 5px #3498db; } 100% { box-shadow: 0 0 3px 2px #3498db; } }
.active-turn { border-color: #3498db; animation: glowing-border 2s infinite; }

/* CONTENEDOR DEL JUEGO */
.game-container { display: flex; justify-content: center; align-items: center; flex-grow: 1; height: 100%; overflow: hidden; }
#chessboard { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); width: 100%; height: 100%; max-width: calc(100vh - 120px); aspect-ratio: 1 / 1; border: 5px solid var(--color-border); box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
.square { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; font-size: clamp(20px, 7vh, 60px); user-select: none; position: relative; }
.white { background-color: var(--color-light-square); } 
.black { background-color: var(--color-dark-square); }
.piece { cursor: pointer; text-shadow: 1px 1px 3px rgba(0,0,0,0.5); transition: transform 0.2s ease-in-out; }
.selected { background-color: var(--color-selected) !important; }
.valid-move-dot { width: 25%; height: 25%; background-color: var(--color-highlight); border-radius: 50%; pointer-events: none; }
.highlight-last-move::after { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: var(--color-last-move); pointer-events: none; }

/* PIEZAS BLANCO Y NEGRO */
#chessboard.pieces-bw .white-piece { color: #ffffff; text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7); }
#chessboard.pieces-bw .black-piece { color: #000000; }

/* CONTROLES Y SIDEBAR */
#game-info, #settings, #move-history-container { background-color: var(--color-ui-box); padding: 15px; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); }
#game-info h3 { margin-top: 0; }
#status { color: #f1c40f; font-weight: bold; min-height: 24px; }
.timers p { margin: 5px 0; font-size: 0.9em; }
#settings select { width: 100%; padding: 8px; border-radius: 4px; border: 1px solid #555; background-color: #34495e; color: #eee; margin-bottom: 5px; }
#move-history-container { flex-grow: 1; overflow-y: auto; }
#move-history p { margin: 4px 0; padding-bottom: 4px; border-bottom: 1px solid #555; font-size: 0.9em; }
#move-history p:last-child { border-bottom: none; }
#reset-button { width: 100%; padding: 15px; font-size: 1.1em; font-weight: bold; cursor: pointer; border: none; border-radius: 8px; background-color: #e74c3c; color: white; transition: background-color 0.2s; }
#reset-button:hover { background-color: #c0392b; }

/* DISEÑO RESPONSIVO */
@media (max-width: 1024px) {
    body { height: auto; overflow: auto; }
    .main-layout { flex-direction: column; align-items: center; gap: 20px; padding: 0 15px 20px 15px; height: auto; }
    .profiles-column { flex-direction: row; width: 100%; max-width: 560px; justify-content: space-between; order: 1; }
    .game-container { order: 2; width: 100%; }
    #chessboard { width: 90vw; max-width: 560px; margin: 0 auto; }
    .sidebar { width: 100%; max-width: 560px; order: 3; }
    .profile-box { width: 48%; }
    .square { font-size: clamp(20px, 8vw, 50px); }
    .info-link { position: static; transform: none; display: block; text-align: center; margin: 0 auto 15px auto; width: fit-content; }
    .header-container { flex-direction: column-reverse; }
}

/* ================== MODAL DE PROMOCIÓN ================== */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.8); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal.hidden { display: none; }
.modal-content { background-color: var(--color-ui-box); padding: 25px; border-radius: 12px; text-align: center; border: 2px solid var(--color-border); box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.promotion-options { display: flex; gap: 15px; margin-top: 20px; justify-content: center; }
.promo-btn { font-size: 50px; background-color: var(--color-background); border: 2px solid var(--color-border); border-radius: 8px; cursor: pointer; padding: 10px 15px; color: var(--color-text); transition: all 0.2s ease; }
.promo-btn:hover { background-color: var(--color-selected); transform: scale(1.1); }