/* chess.css — visor de tablero estilo Lichess, responsive */

/* ─── Layout principal: tablero izquierda, panel derecha ─────────────────────── */
.chess-layout {
  display: flex;
  flex-direction: row;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
}

/* Layout 3 columnas: tablero | notación | lista de partidas */
.chess-layout-3col {
  align-items: flex-start;
  margin-bottom: 14px;
}

.chess-board-col {
  flex: 0 0 340px;
  width: 340px;
  min-width: 0;
}

/* Tablero más grande en el visor de 3 columnas */
.chess-layout-3col .chess-board-col {
  flex: 0 0 500px;
  width: 500px;
  display: flex;
  flex-direction: column;
}

.chess-panel-col {
  flex: 1 1 0;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}

/* Columna de notación (3-col) — altura = tablero, scroll interno */
.chess-notation-col {
  flex: 1 1 0;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.chess-notation-col .moves-panel {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chess-notation-col .moves-table {
  flex: 1;
  overflow-y: auto;
  max-height: none;
  min-height: 0;
}
.chess-notation-col .pgn-details { display: none; }

/* Columna de lista de partidas */
.chess-games-col {
  flex: 0 0 195px;
  min-width: 0;
  background: #1a1f3c;
  border-radius: 6px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.chess-games-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(255,255,255,.4);
  font-weight: 600;
  padding: 10px 12px 6px;
  border-bottom: 0.5px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.cv-game-item {
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 0.5px solid rgba(255,255,255,.06);
  transition: background .12s;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.cv-game-item:last-child { border-bottom: none; }
.cv-game-item:hover { background: rgba(255,255,255,.07); }
.cv-game-item.active { background: rgba(255,255,255,.13); }
.cv-game-num     { font-size: 10px; color: rgba(255,255,255,.35); margin-bottom: 3px; font-family: monospace; width: 100%; }
.cv-game-players { font-size: 12px; color: #fff; font-weight: 500; line-height: 1.3; }
.cv-game-event   { font-size: 11px; color: rgba(255,255,255,.45); margin-top: 2px; width: 100%; }

.cv-chapter-edit-btn {
  background: none; border: none; cursor: pointer; padding: 2px;
  color: rgba(255,255,255,.3); border-radius: 4px; margin-left: auto; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: color .12s, background .12s;
}
.cv-chapter-edit-btn:hover { color: #fff; background: rgba(255,255,255,.12); }

.chapter-edit-panel {
  padding: 10px 12px;
  border-top: 0.5px solid rgba(255,255,255,.1);
  background: rgba(0,0,0,.2);
  flex-shrink: 0;
}
.chapter-edit-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: rgba(255,255,255,.4); margin-bottom: 8px;
}
.chapter-edit-input {
  width: 100%; box-sizing: border-box;
  background: rgba(255,255,255,.08); border: 0.5px solid rgba(255,255,255,.15);
  border-radius: 6px; padding: 6px 8px; font-size: 12px; color: #fff;
  font-family: inherit; margin-bottom: 6px; outline: none;
}
.chapter-edit-input::placeholder { color: rgba(255,255,255,.3); }
.chapter-edit-input:focus { border-color: rgba(255,255,255,.4); }
.chapter-edit-actions { display: flex; gap: 6px; }
.chapter-edit-cancel {
  flex: 1; background: none; border: 0.5px solid rgba(255,255,255,.2);
  border-radius: 6px; padding: 5px; font-size: 11px; color: rgba(255,255,255,.5);
  cursor: pointer; font-family: inherit; transition: color .12s;
}
.chapter-edit-cancel:hover { color: #fff; }
.chapter-edit-save {
  flex: 1; background: rgba(255,255,255,.15); border: none;
  border-radius: 6px; padding: 5px; font-size: 11px; color: #fff;
  cursor: pointer; font-family: inherit; font-weight: 600;
  transition: background .12s;
}
.chapter-edit-save:hover { background: rgba(255,255,255,.25); }

.chess-games-add {
  margin-top: auto;
  padding: 10px 12px;
  font-size: 12px;
  color: rgba(255,255,255,.45);
  cursor: pointer;
  border-top: 0.5px solid rgba(255,255,255,.1);
  text-align: center;
  letter-spacing: 0.02em;
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.chess-games-add:hover { background: rgba(255,255,255,.07); color: #fff; }

/* ─── Tabs de preguntas y comentarios ────────────────────────────────────────── */
.cv-tabs-section {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  overflow: hidden;
  margin-top: 2px;
}
.cv-tabs-bar {
  display: flex;
  border-bottom: 0.5px solid rgba(0,0,0,.08);
}
.cv-tab {
  padding: 10px 18px;
  background: none; border: none; border-bottom: 2px solid transparent;
  font-size: 13px; font-family: inherit; cursor: pointer; color: #888;
  transition: color .13s; margin-bottom: -1px;
}
.cv-tab.active    { color: #1a1f3c; font-weight: 500; border-bottom-color: #1a1f3c; }
.cv-tab:hover:not(.active) { color: #555; }
.cv-tab-pane      { display: none; padding: 1rem 1.25rem; }
.cv-tab-pane.active { display: block; }
.cv-tab-empty     { font-size: 13px; color: #bbb; text-align: center; padding: 1rem 0; }
.cv-comments-area {
  width: 100%; min-height: 90px; resize: vertical;
  font-family: sans-serif; font-size: 13px; color: #444;
  border: 0.5px solid rgba(0,0,0,.12); border-radius: 8px;
  padding: 10px 12px; outline: none;
}
.cv-comments-area:focus { border-color: rgba(0,0,0,.28); }

/* ─── Contenedor responsive del tablero ─────────────────────────────────────── */
.board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.board-outer {
  display: flex;
  align-items: flex-start;
  gap: 0;
  width: 100%;
  height: 100%;
}

.coords-col {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 16px;
  flex-shrink: 0;
  height: 100%;
}
.coord-rank {
  font-size: 10px;
  color: #999;
  text-align: center;
  line-height: 1;
  font-family: monospace;
  user-select: none;
}

.board-and-files {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.board-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  border: 2px solid #b0b0b0;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.board-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
}

/* ─── Casillas ───────────────────────────────────────────────────────────────── */
.sq {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  position: relative;
}
.sq.light { background: #f0d9b5; }
.sq.dark  { background: #b58863; }
.sq.selected   { background: #7fc97f !important; }
.sq.last-from  { background: rgba(155,199,0,0.41) !important; }
.sq.last-to    { background: rgba(155,199,0,0.41) !important; }
.sq.possible::after {
  content: '';
  position: absolute;
  width: 28%; height: 28%;
  background: rgba(0,0,0,0.2);
  border-radius: 50%;
  pointer-events: none;
}
.sq.possible.has-piece::after {
  width: 100%; height: 100%;
  background: none; border-radius: 0;
  box-shadow: inset 0 0 0 4px rgba(0,0,0,0.2);
}

/* ─── Coordenadas archivos ───────────────────────────────────────────────────── */
.coords-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  margin-top: 2px;
}
.coord-file {
  text-align: center;
  font-size: 10px;
  color: #999;
  font-family: monospace;
  user-select: none;
}

/* ─── Piezas SVG ─────────────────────────────────────────────────────────────── */
.piece-svg {
  width: 90%; height: 90%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  display: block;
}

/* ─── Panel de notación estilo Lichess ───────────────────────────────────────── */
.moves-panel {
  background: #262421;
  border-radius: 4px;
  overflow: hidden;
  font-family: monospace;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Cabecera jugadores */
.moves-players {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  background: #302e2c;
  border-bottom: 1px solid #3a3835;
  font-size: 12px;
  color: #bab0a8;
  flex-shrink: 0;
}
.moves-player-name { font-weight: 600; color: #fff; }

/* Tabla de movimientos */
.moves-table {
  flex: 1;
  overflow-y: auto;
  display: block;
  min-height: 120px;
  max-height: 320px;
  scrollbar-width: thin;
  scrollbar-color: #555 #262421;
}
.moves-table::-webkit-scrollbar { width: 4px; }
.moves-table::-webkit-scrollbar-track { background: #262421; }
.moves-table::-webkit-scrollbar-thumb { background: #555; border-radius: 2px; }

.moves-row {
  display: grid;
  grid-template-columns: 32px 1fr 1fr;
  border-bottom: 1px solid #302e2c;
}
.moves-row:last-child { border-bottom: none; }
.moves-row:nth-child(even) { background: #2c2a27; }

.move-num {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 6px;
  font-size: 11px;
  color: #555;
  user-select: none;
  border-right: 1px solid #302e2c;
}

.move-cell {
  padding: 5px 8px;
  font-size: 13px;
  color: #bab0a8;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.move-cell:first-of-type { border-right: 1px solid #302e2c; }
.move-cell:hover { background: #3a3835; color: #fff; }
.move-cell.active    { background: #4a90d9; color: #fff; font-weight: 600; }
.move-cell.in-path-cell { color: #d4c4a8; }
.move-cell.empty     { cursor: default; color: #444; }
.move-cell.empty:hover { background: none; }

/* Variantes en bloque */
.moves-variant-block {
  grid-column: 1 / -1;
  padding: 4px 8px 4px 24px;
  background: #1e1c1a;
  border-top: 1px solid #302e2c;
  font-size: 12px;
  color: #9a8a78;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: baseline;
  line-height: 1.8;
}
.move-cell.variant {
  font-size: 12px;
  color: #9a8a78;
  padding: 2px 4px;
  border-radius: 3px;
}
.move-cell.variant:hover  { background: #3a3835; color: #d4b896; }
.move-cell.variant.active { background: #6b4e2a; color: #f0d9b5; }
.variant-paren { color: #555; font-size: 11px; padding: 0 2px; }
.move-comment-inline { font-size: 11px; color: #7a8a6a; font-style: italic; padding: 0 4px; }

/* Controles de navegación — debajo del tablero */
.nav-controls {
  display: flex;
  align-items: center;
  background: #302e2c;
  border-radius: 0 0 4px 4px;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  border-right: 1px solid #3a3835;
  height: 34px;
  font-size: 14px;
  cursor: pointer;
  color: #bab0a8;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}
.nav-btn:last-child { border-right: none; }
.nav-btn:hover:not(:disabled) { background: #3a3835; color: #fff; }
.nav-btn:disabled { opacity: 0.25; cursor: default; }
.move-counter {
  flex: 2;
  text-align: center;
  font-size: 11px;
  color: #888;
  font-family: monospace;
  border-right: 1px solid #3a3835;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Turno */
.board-turn-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: #302e2c;
  font-size: 11px;
  color: #9a8a78;
  border-top: 1px solid #3a3835;
  flex-shrink: 0;
}
.turn-dot {
  width: 9px; height: 9px;
  border-radius: 50%; flex-shrink: 0;
}
.turn-dot.white { background: #f0d9b5; border: 1px solid #888; }
.turn-dot.black { background: #1a1a1a; border: 1px solid #555; }

/* Selector de variantes */
.variant-selector {
  padding: 8px 10px;
  background: #1e1c1a;
  border-top: 1px solid #302e2c;
  font-size: 12px;
  flex-shrink: 0;
}
.variant-selector-label { color: #666; margin-bottom: 5px; }
.variant-btn {
  font-size: 11px; padding: 3px 8px; border-radius: 3px;
  border: 1px solid #3a3835; background: #302e2c; color: #bab0a8;
  cursor: pointer; margin-right: 5px; margin-bottom: 4px;
  font-family: monospace; transition: background 0.1s;
}
.variant-btn:hover { background: #3a3835; color: #fff; }
.variant-btn.main  { border-color: #4a90d9; color: #4a90d9; }

/* Comentario activo */
.move-comment {
  font-size: 11px; color: #9a8a78; font-style: italic;
  padding: 6px 10px; background: #1e1c1a;
  border-top: 1px solid #302e2c; flex-shrink: 0;
}

/* PGN colapsable */
.pgn-details { margin-top: 8px; }
.pgn-details summary { cursor: pointer; font-size: 11px; color: #4a90d9; user-select: none; padding: 4px 0; }
.pgn-details pre {
  font-size: 10px; color: #bab0a8; white-space: pre-wrap;
  margin-top: 6px; background: #1e1c1a; padding: 10px;
  border-radius: 4px; font-family: monospace; line-height: 1.6;
}

/* Solución guardada */
.saved-moves-wrap {
  margin-top: 8px; background: #1e2a1e;
  border: 1px solid #2d4a2d; border-radius: 4px; padding: 10px 12px;
}
.saved-moves-wrap h4 { font-size: 12px; font-weight: 600; color: #6aaa6a; margin-bottom: 5px; }
.saved-moves-list { font-size: 12px; color: #bab0a8; line-height: 1.8; font-family: monospace; }
.btn-clear-sol {
  font-size: 11px; background: none; border: 1px solid #a32d2d;
  color: #a32d2d; border-radius: 3px; padding: 3px 8px; cursor: pointer; margin-top: 6px;
}
.btn-clear-sol:hover { background: #a32d2d; color: #fff; }

/* Meta PGN */
.pgn-meta { font-size: 12px; color: #888; margin-bottom: 8px; line-height: 1.6; font-family: monospace; }
.pgn-meta strong { color: #bab0a8; }

/* Modo btn */
.board-mode-bar { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.mode-btn {
  font-size: 12px; padding: 5px 12px; border-radius: 4px;
  border: 1px solid rgba(0,0,0,.2); background: #f0f0f0;
  cursor: pointer; color: #444; transition: background 0.1s;
}
.mode-btn:hover  { background: #e0e0e0; }
.mode-btn.active { background: #4a90d9; color: #fff; border-color: #4a90d9; }


/* ─── Cabecera del visor ─────────────────────────────────────────────────────── */
.chess-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}
.chess-player {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: #222;
}
.chess-player .piece-icon { font-size: 16px; }
.chess-player .elo { font-size: 11px; color: #999; font-weight: 400; }

/* ─── Contenedor responsive del tablero ─────────────────────────────────────── */
.board-wrap {
  position: relative;
  width: 100%;
  /* Cuadrado perfecto */
  aspect-ratio: 1 / 1;
  container-type: inline-size;
}

.board-outer {
  display: flex;
  align-items: flex-start;
  gap: 0;
  width: 100%;
  height: 100%;
}

.coords-col {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 18px;
  flex-shrink: 0;
  height: 100%;
}
.coord-rank {
  font-size: 11px;
  color: #999;
  text-align: center;
  line-height: 1;
  font-family: monospace;
  user-select: none;
}

.board-and-files {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.board-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  border: 2px solid #b0b0b0;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.board-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
}

/* ─── Piezas SVG ─────────────────────────────────────────────────────────────── */
.piece-svg {
  width: 90%;
  height: 90%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  display: block;
}

/* ─── Casillas ───────────────────────────────────────────────────────────────── */
.sq {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  position: relative;
}

/* Colores Lichess */
.sq.light { background: #f0d9b5; }
.sq.dark  { background: #b58863; }

.sq.selected   { background: #7fc97f !important; }
.sq.last-from  { background: rgba(155, 199, 0, 0.41) !important; }
.sq.last-to    { background: rgba(155, 199, 0, 0.41) !important; }

/* Puntos de movimientos legales */
.sq.possible::after {
  content: '';
  position: absolute;
  width: 28%;
  height: 28%;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  pointer-events: none;
}
.sq.possible.has-piece::after {
  width: 100%;
  height: 100%;
  background: none;
  border-radius: 0;
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.2);
}

/* ─── Coordenadas de archivos ────────────────────────────────────────────────── */
.coords-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  margin-top: 2px;
}
.coord-file {
  text-align: center;
  font-size: 11px;
  color: #999;
  font-family: monospace;
  user-select: none;
}

/* ─── Barra de turno / info ──────────────────────────────────────────────────── */
.board-turn-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  color: #666;
}
.turn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid #999;
  flex-shrink: 0;
}
.turn-dot.white { background: #fff; }
.turn-dot.black { background: #333; border-color: #333; }

/* ─── Controles de navegación ────────────────────────────────────────────────── */
.nav-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-top: 8px;
  background: #1e1e2e;
  border: 1px solid rgba(120,120,200,0.3);
  border-radius: 10px;
  padding: 4px 8px;
}
/* Cuando el motor está activo, alinear con el tablero (eval-bar: 18px + gap: 6px) */
.eval-board-wrap + .nav-controls {
  margin-left: 24px;
}
.nav-btn {
  background: none;
  border: none;
  border-radius: 6px;
  width: 34px;
  height: 34px;
  font-size: 15px;
  cursor: pointer;
  color: #a8a8c8;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.nav-btn:hover:not(:disabled) {
  background: rgba(140,140,220,0.2);
  color: #dde;
  box-shadow: 0 0 8px rgba(140,140,255,0.3);
}
.nav-btn:disabled { opacity: 0.25; cursor: default; }

/* ─── Lista de movimientos ───────────────────────────────────────────────────── */
.moves-list {
  margin-top: 8px;
  max-height: 110px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1px 2px;
  align-items: baseline;
  padding: 6px 8px;
  background: #f7f7f7;
  border: 0.5px solid rgba(0,0,0,0.08);
  border-radius: 8px;
  font-family: monospace;
}
.move-number {
  font-size: 11px;
  color: #bbb;
  margin-right: 1px;
}
.move-pill {
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
  color: #333;
  transition: background 0.1s;
}
.move-pill:hover   { background: rgba(0,0,0,0.08); }
.move-pill.current {
  background: #4a90d9;
  color: #fff;
}

/* ─── Variantes ──────────────────────────────────────────────────────────────── */
.move-pill.variant { color: #8b5e00; }
.move-pill.variant:hover { background: rgba(139,94,0,0.1); }
.variant-paren { color: #ccc; font-size: 11px; }

/* ─── Comentario ─────────────────────────────────────────────────────────────── */
.move-comment {
  font-size: 11px;
  color: #888;
  font-style: italic;
  font-family: sans-serif;
  margin-top: 6px;
  padding: 5px 8px;
  background: #fffbe6;
  border-left: 3px solid #f0c040;
  border-radius: 0 4px 4px 0;
}

/* ─── Selector de variantes ──────────────────────────────────────────────────── */
.variant-selector {
  margin-top: 8px;
  padding: 8px;
  background: #fff8f0;
  border: 0.5px solid #f0c040;
  border-radius: 8px;
}
.variant-selector-label {
  font-size: 11px;
  color: #888;
  margin-bottom: 5px;
}
.variant-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 0.5px solid rgba(0,0,0,0.15);
  background: #fff;
  cursor: pointer;
  margin-right: 5px;
  margin-bottom: 4px;
  font-family: monospace;
  transition: background 0.1s;
}
.variant-btn:hover { background: #f0f0f0; }
.variant-btn.main  { border-color: #4a90d9; color: #4a90d9; }

/* ─── PGN colapsable ─────────────────────────────────────────────────────────── */
.pgn-details {
  margin-top: 10px;
}
.pgn-details summary {
  cursor: pointer;
  font-size: 11px;
  color: #4a90d9;
  user-select: none;
  padding: 4px 0;
}
.pgn-details pre {
  font-size: 10px;
  color: #444;
  white-space: pre-wrap;
  margin-top: 6px;
  background: #f7f7f7;
  padding: 10px;
  border-radius: 6px;
  border: 0.5px solid rgba(0,0,0,0.08);
  font-family: monospace;
  line-height: 1.6;
}

/* ─── Solución guardada ──────────────────────────────────────────────────────── */
.saved-moves-wrap {
  margin-top: 10px;
  background: #f0f7f0;
  border: 0.5px solid #b8ddb8;
  border-radius: 8px;
  padding: 10px 12px;
}
.saved-moves-wrap h4 {
  font-size: 12px;
  font-weight: 600;
  color: #2d6a2d;
  margin-bottom: 5px;
}
.saved-moves-list {
  font-size: 12px;
  color: #333;
  line-height: 1.8;
  font-family: monospace;
}
.btn-clear-sol {
  font-size: 11px;
  background: none;
  border: 0.5px solid #A32D2D;
  color: #A32D2D;
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  margin-top: 6px;
}
.btn-clear-sol:hover { background: #A32D2D; color: #fff; }

/* ─── Meta PGN ───────────────────────────────────────────────────────────────── */
.pgn-meta {
  font-size: 12px;
  color: #888;
  margin-bottom: 8px;
  line-height: 1.6;
  font-family: monospace;
}
.pgn-meta strong { color: #444; }

/* ─── Selector de coronación ─────────────────────────────────────────────────── */
.promo-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  background: #fffbe6;
  border: 1.5px solid #e0c040;
  border-radius: 8px;
  flex-wrap: wrap;
}
.promo-label {
  font-size: 12px;
  color: #7a6010;
  font-weight: 500;
  flex-shrink: 0;
}
.promo-btn {
  font-size: 26px;
  background: #fff;
  border: 1.5px solid #d0b040;
  border-radius: 6px;
  width: 44px; height: 44px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, border-color 0.1s;
  line-height: 1;
}
.promo-btn:hover { background: #fff8cc; border-color: #b08000; }

/* ─── Modo btn ───────────────────────────────────────────────────────────────── */
.board-mode-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.mode-btn {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 0.5px solid rgba(0,0,0,0.18);
  background: none;
  cursor: pointer;
  color: #444;
  transition: background 0.1s;
}
.mode-btn:hover  { background: rgba(0,0,0,0.05); }

/* ─── Barra de evaluación del motor ─────────────────────────────────────────── */

.eval-board-wrap {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 6px;
}

.eval-board-wrap .board-wrap {
  flex: 1;
  min-width: 0;
}

.eval-bar {
  width: 18px;
  flex-shrink: 0;
  background: #1a1a1a;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  min-height: 80px;
  margin-bottom: 18px;
}

.eval-bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: #f5f5f5;
  transition: height 0.45s ease;
}

/* Barra de puntuación + profundidad (debajo del tablero) */
.engine-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 2px 2px;
  min-height: 22px;
}

.engine-score {
  font-size: 14px;
  font-weight: 700;
  color: #C9943A;
  min-width: 44px;
}

.engine-depth {
  font-size: 11px;
  color: #aaa;
}

/* Línea principal (columna de notación) */
.engine-pv {
  padding: 6px 10px 4px;
  font-size: 11px;
  color: #777;
  font-family: monospace;
  border-top: 0.5px solid rgba(0,0,0,0.06);
  line-height: 1.6;
  min-height: 22px;
}

.engine-pv .pv-score {
  color: #4a90d9;
  font-weight: 600;
  margin-right: 6px;
}

.engine-pv-mobile {
  display: none;
}

@media (max-width: 520px) {
  .eval-bar { width: 12px; }
  .eval-board-wrap { gap: 4px; }
}

@media (max-width: 600px) {
  .engine-pv { display: none; }
  .engine-pv-mobile {
    display: block;
    flex: 1;
    font-size: 11px;
    font-family: monospace;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
}
.mode-btn.active { background: #4a90d9; color: #fff; border-color: #4a90d9; }

/* ─── Chess layout responsive ────────────────────────────────────────────── */

/* Tablet intermedio: reducir el tablero del layout 3 columnas
   para que no haga overflow con el panel de notación + partidas */
@media (max-width: 860px) {
  .chess-layout-3col .chess-board-col {
    flex: 0 0 auto;
    width: clamp(260px, 50%, 400px);
  }
  .chess-notation-col { flex: 1 1 140px; min-width: 140px; }
  .chess-games-col    { flex: 0 0 160px; }
}

/* Móvil: todo apilado en columna */
@media (max-width: 600px) {
  .chess-layout,
  .chess-layout-3col {
    flex-direction: column;
  }

  .chess-board-col,
  .chess-layout-3col .chess-board-col {
    flex: none;
    width: 100%;
    max-width: 100%;
  }

  .chess-panel-col,
  .chess-notation-col {
    width: 100%;
    min-width: 0;
  }

  /* Limitar altura del panel de movimientos para que no ocupe toda la pantalla */
  .chess-notation-col .moves-table,
  .chess-panel-col    .moves-table { max-height: 200px; }

  /* Lista de partidas: horizontal con scroll para no ocupar demasiado espacio */
  .chess-games-col {
    flex: none;
    width: 100%;
    max-height: 130px;
    overflow-y: auto;
  }

  /* Controles de navegación más grandes para touch */
  .nav-btn { width: 38px; height: 38px; font-size: 16px; }
}

/* ─── Carta exterior que envuelve todo el visor ─────────────────────────────── */
.chess-outer-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
  padding: 18px;
  box-sizing: border-box;
}

/* ─── Card layout: tablero y movimientos en tarjetas ────────────────────────── */
.chess-card-layout {
  align-items: stretch;
}

.chess-board-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
  padding: 14px;
  box-sizing: border-box;
}

.chess-moves-card {
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
  overflow: hidden;
}

.chess-card-layout .chess-games-col {
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
}

/* ── Modo ejercicio interactivo ─────────────────────────────────────────────── */
.ex-feedback {
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  border-top: 1px solid #302e2c;
  flex-shrink: 0;
}
.ex-feedback.correct   { color: #81c784; background: rgba(76,175,80,.1); }
.ex-feedback.incorrect { color: #ef9a9a; background: rgba(244,67,54,.08); }
.ex-feedback.hidden    { display: none; }

/* ─── Carrera Semanal ─────────────────────────────────────────────────────── */
.race-wrap {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
}

/* Tablero grande dentro de la carrera */
.race-wrap .chess-layout { width: 100%; }
.race-wrap .chess-board-col {
  flex: 1 1 auto;
  width: 100%;
  max-width: 540px;
}

.race-start-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 70px 20px;
  text-align: center;
}
.race-start-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1a1f3c;
}
.race-start-subtitle {
  font-size: 0.95rem;
  color: rgba(50, 49, 49, 0.842);
  max-width: 320px;
  line-height: 1.5;
}
.btn-race-start {
  background: #C9943A;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 18px 56px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-race-start:hover { background: #b5802e; }
.btn-race-start:active { transform: scale(.97); }

.race-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #1a1f3c;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}
.race-timer {
  font-family: monospace;
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.04em;
}
.race-timer.low { color: #ef5350; animation: race-pulse .6s ease infinite alternate; }
@keyframes race-pulse { from { opacity:1; } to { opacity:.55; } }
.race-score-display {
  color: #C9943A;
  font-size: 1.05rem;
  font-weight: 700;
}
.race-problem-badge {
  font-size: 10px;
  color: rgba(255,255,255,.4);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.race-result-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px 20px;
  text-align: center;
}
.race-result-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
}
.race-final-score {
  font-size: 4rem;
  font-weight: 800;
  color: #C9943A;
  line-height: 1;
}
.race-result-label {
  font-size: 1rem;
  color: rgba(255,255,255,.55);
  margin-top: -8px;
}
.btn-race-retry {
  background: transparent;
  border: 1.5px solid #C9943A;
  color: #C9943A;
  border-radius: 8px;
  padding: 11px 32px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  margin-top: 8px;
}
.btn-race-retry:hover { background: rgba(201,148,58,.1); }

.race-no-content {
  padding: 50px 20px;
  text-align: center;
  color: rgba(255,255,255,.4);
  font-size: 0.95rem;
  line-height: 1.6;
}

.race-skip-bar {
  padding: 7px 10px;
  background: rgba(239,83,80,.12);
  border-top: 1px solid rgba(239,83,80,.25);
  font-size: 12px;
  font-weight: 600;
  color: #ef9a9a;
  text-align: center;
  flex-shrink: 0;
}