/* Personaliza el estilo de la barra de desplazamiento */
body, html {
  scrollbar-width: thin;
  scrollbar-color: #c50039 #000;
}

html, body {
  height: 100%;
  margin: 0;
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

@media only screen and (max-width: 767px) {
  body {
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh;
  }
}

body::-webkit-scrollbar, html::-webkit-scrollbar {
  width: 10px;
}

body::-webkit-scrollbar-track, html::-webkit-scrollbar-track {
  background-color: #000;
}

body::-webkit-scrollbar-thumb, html::-webkit-scrollbar-thumb {
  background-color: #c50039;
  border-radius: 5px;
}

/* Estilos para el diálogo de formulario PGN */
.pgn-dialog {
  background-color: #C50039;
  color: white;
  font-family: 'Poppins', sans-serif;
}

/* Barra de desplazamiento personalizada */
.pgn-content::-webkit-scrollbar {
  width: 10px;
  background-color: #000;
}

.pgn-content::-webkit-scrollbar-thumb {
  background-color: #c50039;
  border-radius: 5px;
}

/* Eliminado: .pgn-content - causa scroll no deseado */

.pgn-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  justify-items: center;
  margin-bottom: 20px;
  gap: 15px;
  width: 480px;
  max-width: 480px;
  order: 2;
  flex-shrink: 0;
  padding: 0 10px;
}

/* PGN Estático */
#pgn-static {
  background-color: #2c2c2c;
  padding: 20px;
  font-family: 'Segoe UI', 'Roboto', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  /* ⚠️ Reemplaza lo que tengas de overflow: */
  overflow-y: auto !important;
  overflow-x: hidden !important;
  border-radius: 10px;
  height: 420px !important;
  width: 440px !important;
  min-width: 440px !important;
  max-width: 440px !important;
  color: #e8e8e8;
  margin: 20px auto !important; /* Centrado horizontalmente */
  box-sizing: border-box;
  border: 1px solid #404040;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  position: static !important;
  display: block !important;
  order: 4;
  flex-shrink: 0;
  
  /* Suavidad y control del desplazamiento */
  overscroll-behavior: contain;
  scroll-behavior: smooth;

  /* Para que el posible ancho del scrollbar no "mueva" el contenido */
  padding-right: 6px;   /* ayuda a que no tape texto si aparece el scrollbar */
  box-sizing: border-box;
  
  /* Scrollbar fino y con tus colores (Firefox) */
  scrollbar-width: thin;
  scrollbar-color: #C50039 #1a1a1a;
}

.pgn-static-area {
  margin-top: 20px;
  margin-bottom: 20px;
}





/* Estilos para las jugadas en el PGN */
.pgn-move-pair {
  display: flex;
  align-items: center;
  margin-bottom: 2px;
  font-family: 'Segoe UI', 'Roboto', sans-serif;
  font-size: 14px;
  line-height: 1.4;
  padding: 2px 0;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.pgn-move-pair:hover {
  background-color: rgba(64, 64, 64, 0.3);
}

.pgn-move-pair.current-pair {
  background-color: rgba(197, 0, 57, 0.15);
  border-left: 3px solid #C50039;
  padding-left: 12px;
}

.pgn-move-number {
  color: #999999;
  font-weight: 600;
  min-width: 28px;
  display: inline-block;
  text-align: right;
  margin-right: 8px;
  flex-shrink: 0;
}

.pgn-moves-container {
  display: flex;
  flex: 1;
  gap: 4px;
}

.pgn-move {
  color: #e8e8e8;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
  min-width: 45px;
  text-align: center;
  font-weight: 500;
  flex: 1;
}

.pgn-move:hover {
  background-color: #505050;
  color: #ffffff;
  transform: translateY(-1px);
}

.pgn-move.current-move {
  background-color: #C50039;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(197, 0, 57, 0.4);
}

.pgn-move.current-move:hover {
  background-color: #a4002e;
  transform: translateY(-1px);
}

.pgn-move-empty {
  flex: 1;
  min-width: 45px;
}

.pgn-result {
  color: #C50039;
  font-weight: bold;
  margin-top: 10px;
  text-align: center;
  font-size: 16px;
  padding: 5px;
}

/* Barra de FEN */
.fen-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding: 15px;
  background-color: #2c2c2c;
  border-radius: 10px;
  border: 1px solid #404040;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  width: 440px !important;
  min-width: 440px !important;
  max-width: 440px !important;
  box-sizing: border-box;
  order: 5;
  flex-shrink: 0;
}

.fen-label {
  color: #C50039;
  font-family: 'Segoe UI', 'Roboto', sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  flex-shrink: 0;
  min-width: 35px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.fen-input {
  flex: 1;
  background: linear-gradient(145deg, rgba(20, 20, 20, 0.95) 0%, rgba(15, 15, 15, 0.98) 100%);
  border: 1px solid rgba(64, 64, 64, 0.4);
  border-radius: 10px;
  color: #e8e8e8;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 12px 14px;
  outline: none;
  transition: all 0.3s ease;
  min-width: 0;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.fen-input:focus {
  border-color: #C50039;
  background-color: #222222;
  box-shadow: 0 0 0 2px rgba(197, 0, 57, 0.1);
}

.fen-input.readonly {
  cursor: default;
  user-select: all;
}

.fen-button {
  background: linear-gradient(145deg, rgba(50, 50, 50, 0.9) 0%, rgba(35, 35, 35, 0.95) 100%);
  border: 1px solid rgba(85, 85, 85, 0.4);
  border-radius: 10px;
  color: #e8e8e8;
  cursor: pointer;
  padding: 8px 10px;
  font-size: 16px;
  transition: all 0.3s ease;
  min-width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 
    0 3px 8px rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.2);
}

.fen-button:hover {
  background: linear-gradient(145deg, rgba(60, 60, 60, 0.9) 0%, rgba(45, 45, 45, 0.95) 100%);
  border-color: rgba(197, 0, 57, 0.5);
  transform: translateY(-2px);
  box-shadow: 
    0 5px 15px rgba(0, 0, 0, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.3);
  color: #C50039;
}

.fen-button:active {
  transform: translateY(0);
}

.chess-container {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  height: 100vh;
  width: 100%;
  margin: 0;
  padding: 20px;
  gap: 30px;
  overflow: hidden;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .chess-container {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 15px;
    overflow-y: auto;
  }
}

.board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 100vh;
  padding: 0;
  box-sizing: border-box;
  flex-shrink: 0;
  order: 1;
}

@media (max-width: 768px) {
  .board-wrapper {
    height: auto;
    order: 1;
  }
}

/* Eliminado: .pgn-wrapper - causa scroll no deseado */

/* Eliminado: .pgn-wrapper media query - causa scroll no deseado */

.pgn-title {
  order: 1;
  margin: 0 0 10px 0;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'Segoe UI', 'Roboto', sans-serif;
  color: #C50039;
  position: relative;
  background-color: transparent;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#board1.board {
  margin: 0;
}

#board1 {
  width: min(85vh, 70vw);
  height: min(85vh, 70vw);
  max-width: 85vh;
  max-height: 85vh;
  min-width: 320px;
  min-height: 320px;
  margin: 0;
  display: block;
  touch-action: none;
  position: relative;
  overflow: visible;
}

@media (max-width: 768px) {
  #board1 {
    width: min(90vw, 80vh);
    height: min(90vw, 80vh);
    max-width: 90vw;
    max-height: 80vh;
  }
}

/* Estilos generales */
body {
  background-color: #101010;
  overflow-x: hidden;
}

/* Botones principales rediseñados con máxima elegancia */
.button {
  background: linear-gradient(135deg, #C50039 0%, #8B0000 50%, #C50039 100%) !important;
  border: 2px solid rgba(255, 255, 255, 0.1) !important;
  color: white !important;
  font-family: 'Poppins', sans-serif !important;
  font-size: 0.85rem !important;
  font-weight: 700 !important;
  padding: 14px 20px !important;
  text-align: center !important;
  text-decoration: none !important;
  cursor: pointer !important;
  width: 100% !important;
  max-width: 220px !important;
  margin: 0 !important;
  border-radius: 14px !important;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
  box-shadow: 
    0 4px 12px rgba(197, 0, 57, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
  position: relative !important;
  overflow: hidden !important;
  letter-spacing: 0.4px !important;
  height: 44px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-transform: uppercase !important;
  backdrop-filter: blur(10px) !important;
  line-height: 1.2 !important;
  word-wrap: break-word !important;
  white-space: normal !important;
  min-height: 44px !important;
  box-sizing: border-box !important;
}

.button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.button:hover {
  background: linear-gradient(135deg, #FF0040 0%, #C50039 50%, #FF0040 100%);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 
    0 8px 25px rgba(197, 0, 57, 0.5),
    0 4px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0.7px;
}

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

.button:active {
  transform: translateY(-1px) scale(0.98);
  box-shadow: 
    0 4px 12px rgba(197, 0, 57, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.2);
  transition: all 0.1s ease;
}

.button-container {
  display: flex;
  justify-content: center;
  margin-top: 15px;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0 12px;
  max-width: 100%;
}

/* Botones de navegación rediseñados para alineación perfecta */
.navigation-buttons-redesigned {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 20px;
  margin-bottom: 20px;
  width: 440px;
  max-width: 440px;
  order: 3;
  flex-shrink: 0;
}

.nav-button {
  background: linear-gradient(145deg, #333333 0%, #1f1f1f 100%);
  border: 1px solid #555555;
  color: #ffffff;
  font-family: 'Poppins', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 10px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 45px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.nav-button .nav-icon {
  font-size: 1rem;
  margin-bottom: 1px;
  display: block;
  transition: all 0.3s ease;
}

.nav-button .nav-text {
  font-size: 0.6rem;
  font-weight: 400;
  opacity: 0.9;
  transition: all 0.3s ease;
  letter-spacing: 0.1px;
  text-align: center;
  line-height: 1;
}

.nav-button:hover {
  background: linear-gradient(145deg, #444444 0%, #2f2f2f 100%);
  border-color: #666666;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.nav-button:hover .nav-icon {
  transform: scale(1.05);
}

.nav-button:hover .nav-text {
  opacity: 1;
  font-weight: 500;
}

.nav-button:active {
  transform: translateY(0px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Estados especiales para navegación */
.nav-button.disabled-fake {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  background: linear-gradient(145deg, #1a1a1a 0%, #0f0f0f 100%);
  border-color: #2a2a2a;
}

.nav-button.disabled-fake:hover {
  transform: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Define los colores de las casillas */
.board-b72b1.board-b72b1 .square-55d63.white-1e1d7 {
  background-color: #EEE4D1 !important;
}

.board-b72b1.board-b72b1 .square-55d63.black-3c85d {
  background-color: #1a8e78 !important;
}

.board-b72b1.board-b72b1 {
  border: none;
}

.board-b72b1.board-b72b1 .square-55d63 {
  border-radius: 0;
}

/* Responsive para móviles */
@media only screen and (max-width: 767px) {
  .chess-container {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 15px;
    gap: 20px;
    height: auto;
    min-height: 100vh;
  }

  .board-wrapper {
    width: 100%;
    height: auto;
    margin: 0;
    position: relative;
    padding: 0;
  }

  .pgn-wrapper {
    width: 85%;
    min-width: 85%;
    max-width: 85%;
    margin: 15px auto 0 auto;
    box-sizing: border-box;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
  }
  
  .pgn-buttons {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 15px;
  }
  
  .pgn-buttons .button {
    height: 44px !important;
    font-size: 0.85rem !important;
    padding: 14px 20px !important;
    border-radius: 14px !important;
    max-width: 220px !important;
    min-height: 44px !important;
    line-height: 1.2 !important;
    letter-spacing: 0.4px !important;
    box-sizing: border-box !important;
  }
  
  .navigation-buttons-redesigned {
    gap: 6px;
    margin: 15px 0;
  }
  
  .navigation-buttons-redesigned .nav-button {
    height: 42px;
    font-size: 0.7rem;
    padding: 6px 3px;
    border-radius: 10px;
  }
  
  #pgn-static {
    height: 300px !important;
    padding: 15px;
    border-radius: 12px;
    margin: 15px 0;
  }
  
  .fen-bar {
    padding: 12px;
    border-radius: 12px;
    margin: 15px 0 0 0;
    gap: 8px;
  }
  
  .fen-label {
    font-size: 12px;
    min-width: 30px;
  }
  
  .fen-input {
    font-size: 11px;
    padding: 10px 12px;
    border-radius: 8px;
  }
  
  .fen-button {
    min-width: 36px;
    height: 36px;
    font-size: 14px;
    padding: 6px 8px;
    border-radius: 8px;
  }
}
  .promotion-dialog {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-around;
    align-items: center;
    width: 60vw;
    background-color: #C50039 !important;
  }

  .board-wrapper {
    width: 100%;
    height: auto;
    margin: 0;
    padding: 10px 0 10px 0;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
  }

  #board1 {
    width: min(85vw, 320px);
    height: min(85vw, 320px);
    min-width: 260px;
    min-height: 260px;
    margin: 0;
  }

  .navigation-buttons-redesigned,
  .pgn-buttons,
  .button-container {
    justify-content: center;
    margin-left: 0;
  }

  .pgn-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    justify-items: center;
    gap: 8px;
    width: 85%;
    max-width: none;
    margin: 0 auto 15px auto;
    box-sizing: border-box;
  }

  .button {
    width: 100% !important;
    max-width: 220px !important;
    font-size: 0.85rem !important;
    height: 44px !important;
    min-width: 120px !important;
    box-sizing: border-box !important;
    padding: 14px 20px !important;
    border-radius: 14px !important;
    min-height: 44px !important;
    line-height: 1.2 !important;
    letter-spacing: 0.4px !important;
  }

  .navigation-buttons-redesigned {
    gap: 8px;
    margin: 15px auto;
    max-width: 85%;
    width: auto;
    justify-content: center;
    box-sizing: border-box;
    display: flex;
  }

  .nav-button {
    width: auto;
    min-width: 55px;
    height: 42px;
    font-size: 0.75rem;
    flex: 1;
  }

  .nav-button .nav-icon {
    font-size: 1.1rem;
  }

  .nav-button .nav-text {
    font-size: 0.65rem;
  }

  .chess-container {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    margin: 0;
    padding: 0 0 80px 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
    box-sizing: border-box;
    min-height: auto;
  }

  #pgn-static {
    height: 200px !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    font-size: 13px;
    padding: 12px;
    margin-bottom: 15px;
  }

  .pgn-move-pair {
    font-size: 13px;
  }

  .pgn-move {
    padding: 2px 4px;
    min-width: 40px;
    font-size: 13px;
  }

  .pgn-move-number {
    min-width: 24px;
    font-size: 13px;
  }

  .pgn-wrapper {
    width: 85%;
    min-width: 85%;
    max-width: 85%;
    margin: 15px auto 0 auto;
    box-sizing: border-box;
  }

  .fen-bar {
    gap: 6px;
    padding: 8px;
    margin-top: 0;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
  }

  .fen-label {
    font-size: 11px;
    min-width: 28px;
  }

  .fen-input {
    font-size: 10px;
    padding: 6px 8px;
  }

  .fen-button {
    min-width: 28px;
    height: 28px;
    font-size: 12px;
  }
	
  .logo-column {
  display: flex !important;
  align-items: center;
  justify-content: center;
  margin-right: 20px;
  width: 120px;
  flex-shrink: 0;
}

.logo-column img {
  height: 120px;
  width: auto;
  object-fit: contain;
}

@media only screen and (min-width: 768px) and (max-width: 1199px) {
  .chess-container {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 15px;
    overflow-y: auto;
  }
  
  .board-wrapper {
    height: auto;
  }
  
  /* Eliminado: .pgn-wrapper - causa scroll no deseado */
}

  .pgn-buttons {
    margin-top: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-left: 0;
    max-width: 360px;
  }

  .button {
    max-width: 170px;
    height: 38px;
    font-size: 0.8rem;
  }

  .navigation-buttons-redesigned {
    margin-top: 15px;
    margin-bottom: 15px;
    max-width: 360px;
  }

  #board1 {
    width: min(92vh, 70vw);
    height: min(92vh, 70vw);
    max-width: calc(92vh - 10px);
    max-height: calc(100vh - 20px);
    min-width: 400px;
    min-height: 400px;
    margin: 3px auto 12px auto;
  }
}

@media screen and (min-width: 1200px) {
  #board1 {
    width: min(85vh, 70vw);
    height: min(85vh, 70vw);
    max-width: 85vh;
    max-height: 85vh;
    margin: 0;
  }

  .chess-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 20px;
    gap: 30px;
    overflow: hidden;
    box-sizing: border-box;
  }

  .board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 100vh;
    padding: 0;
    box-sizing: border-box;
    flex-shrink: 0;
    order: 1;
  }

  /* Eliminado: .pgn-wrapper - causa scroll no deseado */

  .pgn-buttons {
    max-width: 400px;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  #pgn-static {
    width: 360px !important;
    min-width: 360px !important;
    max-width: 360px !important;
    height: 380px !important;
    flex: none;
  }

  .fen-bar {
    width: 360px !important;
    min-width: 360px !important;
    max-width: 360px !important;
  }

  .button {
    max-width: 180px;
    width: 100%;
    height: 38px;
    font-size: 0.8rem;
  }

  .navigation-buttons-redesigned {
    gap: 6px;
    max-width: 400px;
  }

  .nav-button {
    height: 38px;
  }

  .nav-button .nav-icon {
    font-size: 1rem;
  }

  .nav-button .nav-text {
    font-size: 0.7rem;
  }
}

/* Pantallas extra grandes - Máximo espaciado para zoom */
@media screen and (min-width: 1400px) {
  .chess-container {
    gap: 40px;
    padding: 30px;
  }

  .board-wrapper {
    width: auto;
  }

  #board1 {
    width: min(85vh, 60vw);
    height: min(85vh, 60vw);
    max-width: 900px;
    max-height: 85vh;
  }

  /* Eliminado: .pgn-wrapper - causa scroll no deseado */
}

  .logo-column {
    margin-right: 40px;
  }

  #pgn-static {
    width: 320px !important;
    min-width: 320px !important;
    max-width: 320px !important;
    height: 600px !important;
    flex: none;
  }

  .fen-bar {
    width: 320px !important;
    min-width: 320px !important;
    max-width: 320px !important;
  }

  .button {
    max-width: 110px;
    width: 110px;
    height: 36px;
    font-size: 0.7rem;
  }

  .pgn-buttons {
    max-width: 360px;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }

  .navigation-buttons-redesigned {
    gap: 6px;
    max-width: 360px;
  }
}

/* Pantallas muy grandes - Espaciado máximo */
@media screen and (min-width: 1600px) {
  .chess-container {
    padding-left: 120px;
    gap: 120px;
    max-width: none;
    height: 100vh;
  }

  .board-wrapper {
    margin-right: 120px;
    height: 100vh;
    padding-top: 2px;
    padding-bottom: 12px;
  }

  #board1 {
    width: min(95vh, 55vw);
    height: min(95vh, 55vw);
    max-width: 1100px;
    max-height: calc(100vh - 10px);
    margin: 5px auto 18px auto;
  }

  /* Eliminado: .pgn-wrapper - causa scroll no deseado */

  .logo-column {
    margin-right: 40px;
  }

  #pgn-static {
    width: 380px !important;
    min-width: 380px !important;
    max-width: 380px !important;
    height: 650px !important;
    flex: none;
  }

  .fen-bar {
    width: 380px !important;
    min-width: 380px !important;
    max-width: 380px !important;
  }

  .button {
    max-width: 125px;
    width: 125px;
    height: 36px;
    font-size: 0.7rem;
  }

  .pgn-buttons {
    max-width: 400px;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }

  .navigation-buttons-redesigned {
    gap: 6px;
    max-width: 400px;
  }
}

/* ===== SOLUCIÓN PARA PANTALLAS DE ALTA RESOLUCIÓN ===== */
/* Detectar pantallas de alta resolución con escalado (como Asus Zenbook Duo) */
@media screen and (min-width: 2000px), 
       screen and (min-resolution: 2dppx),
       screen and (-webkit-device-pixel-ratio: 2) and (min-width: 1400px) {
  
  /* Ajustar el layout principal para evitar desbordamiento */
  .chess-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
    padding: 0;
    box-sizing: border-box;
  }
  
  /* Reducir el padding del contenedor principal */
  .chess-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 20px;
    gap: 30px;
    overflow: hidden;
    box-sizing: border-box;
}
  
  /* Ajustar el wrapper del tablero */
  .board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 100vh;
    padding: 0;
    box-sizing: border-box;
    flex-shrink: 0;
    order: 1;
  }
  
  /* Reducir el tamaño del tablero para evitar desbordamiento */
  #board1 {
    width: min(85vh, 45vw) !important;
    height: min(85vh, 45vw) !important;
    max-width: 800px !important;
    max-height: calc(100vh - 20px) !important;
    margin: 5px auto 15px auto !important;
  }
  
  /* Eliminado: .pgn-wrapper - causa scroll no deseado */
  
  /* Reducir el tamaño del logo */
  .logo-column {
    margin-right: 20px !important;
    width: 120px !important;
  }
  
  .logo-column img {
    height: 120px !important;
    width: auto;
    object-fit: contain;
  }
  
  /* Ajustar el área PGN */
  #pgn-static {
    width: 360px !important;
    min-width: 360px !important;
    max-width: 360px !important;
    height: 380px !important;
    flex: none;
  }
  
  /* Ajustar la barra FEN */
  .fen-bar {
    width: 360px !important;
    min-width: 360px !important;
    max-width: 360px !important;
  }
  
  /* Reducir el tamaño de los botones */
  .button {
    max-width: 180px !important;
    width: 100% !important;
    height: 38px !important;
    font-size: 0.8rem !important;
  }

  .pgn-buttons {
    max-width: 400px !important;
    gap: 6px !important;
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Ajustar botones de navegación */
  .navigation-buttons-redesigned {
    gap: 6px !important;
    max-width: 400px !important;
  }

  .nav-button {
    height: 38px !important;
    font-size: 0.7rem !important;
  }
  
  .nav-button .nav-icon {
    font-size: 1rem !important;
  }
  
  .nav-button .nav-text {
    font-size: 0.6rem !important;
  }
}

/* Reglas específicas para pantallas ultra-altas (como 4K con escalado) */
@media screen and (min-width: 2500px) {
  .chess-container {
    padding-left: 60px !important;
    gap: 60px !important;
  }
  
  .board-wrapper {
    margin-right: 60px !important;
  }
  
  #board1 {
    width: min(80vh, 40vw) !important;
    height: min(80vh, 40vw) !important;
    max-width: 700px !important;
  }
  
  /* Eliminado: .pgn-wrapper - causa scroll no deseado */
  
  #pgn-static {
    width: 260px !important;
    min-width: 260px !important;
    max-width: 260px !important;
    height: 450px !important;
    flex: none;
  }
  
  .fen-bar {
    width: 260px !important;
    margin-top: auto;
    min-width: 260px !important;
    max-width: 260px !important;
  }
  
  .pgn-buttons {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 3px !important;
  }
  
  .button {
    max-width: 80px !important;
    width: 80px !important;
    height: 30px !important;
    font-size: 0.6rem !important;
  }
  
  .button {
    max-width: 120px !important;
    width: 120px !important;
    height: 32px !important;
    font-size: 0.7rem !important;
  }
  
  .pgn-buttons {
    max-width: 280px !important;
  }
  
  .navigation-buttons-redesigned {
    max-width: 280px !important;
  }
}

/* Detectar específicamente escalado de Windows (zoom del navegador o escalado del sistema) */
@media screen and (min-width: 1400px) and (max-width: 1999px) {
  /* Detectar si hay escalado aplicado */
  @supports (zoom: 1) {
    /* Para navegadores que soportan zoom */
    .chess-layout {
      zoom: 0.9;
    }
  }
  
  /* Alternativa usando transform scale */
  @supports not (zoom: 1) {
    .chess-layout {
      transform: scale(0.9);
      transform-origin: top left;
      width: 111.11%; /* Compensar el scale */
    }
  }
}

/* Reglas específicas para pantallas con escalado del sistema operativo */
@media screen and (min-width: 1400px) {
  /* Detectar escalado del sistema usando device-pixel-ratio */
  @media screen and (-webkit-device-pixel-ratio: 2) {
    .chess-container {
      padding-left: 30px !important;
      gap: 30px !important;
    }
    
    .board-wrapper {
      margin-right: 30px !important;
    }
    
    #board1 {
      width: min(90vh, 50vw) !important;
      height: min(90vh, 50vw) !important;
      max-width: 900px !important;
    }
    
    /* Eliminado: .pgn-wrapper - causa scroll no deseado */
    
    #pgn-static {
      width: 300px !important;
      min-width: 300px !important;
      max-width: 300px !important;
      height: 550px !important;
      flex: none;
    }
    
    .fen-bar {
      width: 300px !important;
      min-width: 300px !important;
      max-width: 300px !important;
    }
  }
  
  /* Para escalado 1.5x */
  @media screen and (-webkit-device-pixel-ratio: 1.5) {
    .chess-container {
      padding-left: 35px !important;
      gap: 35px !important;
    }
    
    .board-wrapper {
      margin-right: 35px !important;
    }
    
    #board1 {
      width: min(92vh, 52vw) !important;
      height: min(92vh, 52vw) !important;
      max-width: 950px !important;
    }
  }
}

/* ===== FIN DE SOLUCIÓN PARA PANTALLAS DE ALTA RESOLUCIÓN ===== */

/* ===== REGLAS ESPECÍFICAS PARA LA CLASE HIGH-RES-DISPLAY ===== */
/* Estas reglas se aplican cuando el JavaScript detecta una pantalla de alta resolución */

body.high-res-display .chess-layout {
  max-width: 100vw !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

body.high-res-display .chess-container {
  box-sizing: border-box !important;
  max-width: calc(100vw - 40px) !important;
}

body.high-res-display .board-wrapper {
  flex-shrink: 0 !important;
}

/* Eliminado: .pgn-wrapper - causa scroll no deseado */

body.high-res-display .logo-column {
  flex-shrink: 0 !important;
}

/* Asegurar que las piezas del tablero no se desborden */
body.high-res-display #board1 {
  box-sizing: border-box !important;
  overflow: hidden !important;
}

/* Ajustar el área PGN para evitar desbordamiento */
body.high-res-display #pgn-static {
  box-sizing: border-box !important;
  overflow: visible !important;
  overflow-x: hidden !important;
  height: 500px !important;
  flex: none !important;
}

/* Asegurar que los botones no se desborden */
body.high-res-display .pgn-buttons {
  box-sizing: border-box !important;
  flex-wrap: wrap !important;
  gap: 4px !important;
  grid-template-columns: repeat(3, 1fr) !important;
}

body.high-res-display .button {
  box-sizing: border-box !important;
  flex-shrink: 0 !important;
}

/* Ajustar botones de navegación */
body.high-res-display .navigation-buttons-redesigned {
  box-sizing: border-box !important;
  flex-wrap: wrap !important;
  gap: 4px !important;
}

body.high-res-display .nav-button {
  box-sizing: border-box !important;
  flex-shrink: 0 !important;
}

/* Asegurar que la barra FEN no se desborde */
body.high-res-display .fen-bar {
  box-sizing: border-box !important;
  overflow: hidden !important;
}

body.high-res-display .fen-input {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
}

/* Ajustes específicos para el editor en pantallas de alta resolución */
body.high-res-display .piece-palette {
  box-sizing: border-box !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

body.high-res-display .piece-grid {
  box-sizing: border-box !important;
  flex-wrap: wrap !important;
}

body.high-res-display .piece-item {
  box-sizing: border-box !important;
  flex-shrink: 0 !important;
}

/* Asegurar que los modales no se desborden */
body.high-res-display .validation-modal {
  box-sizing: border-box !important;
}

body.high-res-display .modal-content {
  box-sizing: border-box !important;
  max-width: 90vw !important;
  max-height: 90vh !important;
  overflow: auto !important;
}

/* ===== FIN DE REGLAS ESPECÍFICAS PARA HIGH-RES-DISPLAY ===== */


.chess-layout {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 20px;
  width: 100%;
  max-width: none;
}

.logo-column {
  width: 160px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.logo-column img {
  height: 150px;
  width: auto;
  object-fit: contain;
}

#overlayBloqueo .pgn-dialog {
  background-color: #C50039;
  color: white;
  font-family: 'Poppins', sans-serif;
  z-index: 1001;
  pointer-events: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 15px;
  border: 1px solid white;
  box-shadow: 0 0 15px rgba(0,0,0,0.6);
}
#overlayBloqueo {
  display: none; /* este será sobrescrito por JS */
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0,0,0,0.3);
  z-index: 999;
  pointer-events: auto;
}
#overlayBloqueo input,
#overlayBloqueo select,
#overlayBloqueo button,
#overlayBloqueo label {
  pointer-events: auto;
  z-index: 1002;
  position: relative;
}

/* Estilos para la paleta de piezas y editor de posición */
.piece-palette {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 320px;
    max-height: 90vh;
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
    border: 2px solid #C50039;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    z-index: 1000;
    overflow-y: auto;
    font-family: 'Poppins', sans-serif;
    color: white;
    backdrop-filter: blur(10px);
}

.palette-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #C50039 0%, #a4002e 100%);
    border-radius: 13px 13px 0 0;
    border-bottom: 2px solid #C50039;
}

.palette-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.palette-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.palette-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.palette-content {
    padding: 20px;
}

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

.palette-section h4 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    color: #C50039;
    font-weight: 600;
    border-bottom: 1px solid #333;
    padding-bottom: 8px;
}

.piece-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.piece-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #353535 60%, #232323 100%);
    border: 2px solid #555;
    border-radius: 8px;
    cursor: pointer;
    font-size: 24px;
    transition: all 0.3s ease;
    user-select: none;
}

.piece-item:hover {
    border-color: #C50039;
    background: linear-gradient(135deg, #444 0%, #555 100%);
    transform: scale(1.05);
}

.piece-item.selected {
    border-color: #C50039;
    background: linear-gradient(135deg, #C50039 0%, #a4002e 100%);
    box-shadow: 0 0 10px rgba(197, 0, 57, 0.5);
}

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

.action-btn {
    background: linear-gradient(135deg, #333 0%, #444 100%);
    border: 2px solid #555;
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.action-btn:hover {
    border-color: #C50039;
    background: linear-gradient(135deg, #444 0%, #555 100%);
}

.action-btn.active {
    border-color: #C50039;
    background: linear-gradient(135deg, #C50039 0%, #a4002e 100%);
}

.fen-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group label {
    font-size: 0.9rem;
    color: #ccc;
    font-weight: 500;
}

.control-group select,
.control-group input {
    background: #333;
    border: 2px solid #555;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: #C50039;
}

.castling-controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.castling-controls label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.9rem;
}

.castling-controls input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #C50039;
}

.palette-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
}

.apply-btn {
    background: linear-gradient(135deg, #C50039 0%, #a4002e 100%);
    border: none;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    flex: 1;
    transition: all 0.3s ease;
}

.apply-btn:hover {
    background: linear-gradient(135deg, #a4002e 0%, #8a0026 100%);
    transform: translateY(-2px);
}

.cancel-btn {
    background: linear-gradient(135deg, #555 0%, #666 100%);
    border: none;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    flex: 1;
    transition: all 0.3s ease;
}

.cancel-btn:hover {
    background: linear-gradient(135deg, #666 0%, #777 100%);
}

/* Modal de validación */
.validation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
    border: 2px solid #C50039;
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    font-family: 'Poppins', sans-serif;
    color: white;
}

.modal-content h3 {
    margin: 0 0 20px 0;
    color: #C50039;
    font-size: 1.3rem;
}

#validationMessage {
    margin: 20px 0;
    padding: 15px;
    background: rgba(197, 0, 57, 0.1);
    border: 1px solid #C50039;
    border-radius: 8px;
    text-align: left;
    font-size: 0.9rem;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

/* Botón para activar el editor */
#editPositionBtn {
    background: linear-gradient(135deg, #C50039 0%, #a4002e 100%);
    border: none;
    color: white;
    font-family: 'Poppins', sans-serif;
    font-size: 0.8rem;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    flex: 1 1 auto;
    margin: 5px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

#editPositionBtn:hover {
    background: linear-gradient(135deg, #a4002e 0%, #8a0026 100%);
    transform: translateY(-2px);
}

/* Responsive design */
@media only screen and (max-width: 768px) {
    .piece-palette {
        right: 10px;
        left: 10px;
        width: auto;
        max-height: 80vh;
        transform: translateY(-50%);
    }
    
    .piece-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .piece-item {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .palette-actions {
        flex-direction: column;
    }
    
    .castling-controls {
        flex-direction: column;
        gap: 8px;
    }
}

/* Indicador de modo edición */
.board.editing {
    position: relative;
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.piece-palette {
    animation: fadeIn 0.3s ease-out;
}

/* Scrollbar personalizada para la paleta */
.piece-palette::-webkit-scrollbar {
    width: 8px;
}

.piece-palette::-webkit-scrollbar-track {
    background: #333;
    border-radius: 4px;
}

.piece-palette::-webkit-scrollbar-thumb {
    background: #C50039;
    border-radius: 4px;
}

.piece-palette::-webkit-scrollbar-thumb:hover {
    background: #a4002e;
}

#editorOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background: transparent;
    pointer-events: all;
    cursor: not-allowed;
}

#editorOverlay[style*="display: none"] {
    pointer-events: none;
}

/* Eliminar overlay */
#editorOverlay { display: none !important; }

/* Bloquear arrastre de piezas en modo edición */
.board.editing .piece-417db {
    pointer-events: none !important;
    cursor: not-allowed !important;
}

.piece-item img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    display: block;
    margin: auto;
    filter: drop-shadow(0 1px 2px #0005);
    transition: transform 0.15s, box-shadow 0.15s;
}
.piece-item.selected img,
.piece-item:hover img {
    transform: scale(1.12);
    box-shadow: 0 0 0 2px #C50039, 0 2px 8px #0006;
    z-index: 2;
}
@media (max-width: 700px) {
    .piece-item img {
        width: 28px;
        height: 28px;
    }
}

.piece-item[data-piece^="b"] {
    background: linear-gradient(135deg, #444 60%, #222 100%);
}
.piece-item[data-piece^="b"]:hover,
.piece-item[data-piece^="b"].selected {
    background: linear-gradient(135deg, #666 60%, #333 100%);
}
.piece-item[data-piece^="b"] img {
    filter: drop-shadow(0 1px 2px #0005) drop-shadow(0 0 4px #fff8);
}

.castling-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 2px;
}

.castling-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
    background: #232323;
    border-radius: 7px;
    padding: 4px 10px 4px 8px;
    box-shadow: 0 1px 2px #0001;
    min-width: 0;
}

.castling-label {
    font-weight: 500;
    color: #e0e0e0;
    min-width: 60px;
    font-size: 0.98rem;
    letter-spacing: 0.2px;
    margin-right: 2px;
}

.castling-option {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.97rem;
    color: #fff;
    background: none;
    border-radius: 5px;
    padding: 0 4px;
    box-shadow: none;
    transition: background 0.2s;
    min-width: 0;
}

.castling-option input[type="checkbox"] {
    accent-color: #C50039;
    width: 16px;
    height: 16px;
    margin-right: 1px;
    margin-left: 0;
}

.castling-option:hover {
    background: #292929;
}

@media only screen and (max-width: 768px) {
    .castling-grid {
        gap: 4px;
    }
    .castling-row {
        gap: 7px;
        padding: 3px 5px 3px 5px;
    }
    .castling-label {
        min-width: 48px;
        font-size: 0.93rem;
    }
    .castling-option {
        font-size: 0.93rem;
        padding: 0 2px;
    }
    .castling-option input[type="checkbox"] {
        width: 15px;
        height: 15px;
    }
}

/* Cursor de borrador para modo edición */
.board.editing.borrador-activo {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23ff0000" stroke-width="2"><path d="M3 21l18-18M6 3l15 15M9 6l9 9"/></svg>') 12 12, auto !important;
}

.board.editing.borrador-activo .square-55d63 {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23ff0000" stroke-width="2"><path d="M3 21l18-18M6 3l15 15M9 6l9 9"/></svg>') 12 12, auto !important;
}

/* Cursor de piezas específicas para modo edición */
.board.editing.pieza-seleccionada {
    cursor: none !important;
}

.board.editing.pieza-seleccionada .square-55d63 {
    cursor: none !important;
}

/* Elemento flotante que sigue al cursor */
.cursor-pieza {
    position: fixed;
    width: 32px;
    height: 32px;
    pointer-events: none;
    z-index: 10000;
    display: none;
}

.cursor-pieza img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.disabled-fake {
    filter: brightness(0.6) grayscale(0.3);
    pointer-events: none;
    cursor: not-allowed !important;
    opacity: 0.7;
    transition: filter 0.2s, opacity 0.2s;
}

/* Clase para ocultar temporalmente el tablero durante transiciones */
.board-transitioning {
    opacity: 0;
    transition: opacity 0.05s ease-out;
}

/* Clase para una transición más suave al aplicar posición */
.board-applying {
    opacity: 0.3;
    transition: opacity 0.1s ease-in-out;
    filter: blur(0.5px);
}

.section-divider {
  border: none;
  border-bottom: 1.5px solid #eee;
  margin: 0 0 15px 0;
  background: none;
  height: 0;
  opacity: 0.7;
}

.export-icon {
  width: 28px;
  height: 28px;
  max-width: 100%;
  display: block;
  margin: 0;
  cursor: pointer;
  /* Blanco por defecto */
  filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(120%) contrast(120%);
  transition: filter 0.2s;
}
.export-icon:hover {
  /* Rojo al hacer hover */
  filter: brightness(0) saturate(100%) invert(18%) sepia(97%) saturate(7492%) hue-rotate(334deg) brightness(92%) contrast(108%);
}

.export-tooltip-wrapper, .export-tooltip {
  /* Eliminado: ahora el tooltip es flotante y controlado por JS */
  all: unset;
}

/* Eliminar override de overflow para restaurar scroll */
.piece-palette,
.palette-content {
  overflow: auto;
}

/* Estilos para el loader mejorado con caballo de circuitos */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%, #0a0a0a 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
    overflow: hidden;
}

.loader-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
    position: relative;
    z-index: 2;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
}

/* Responsive design para diferentes dispositivos */
@media (max-width: 480px) {
    .loader-container {
        gap: 20px;
        padding: 15px;
    }
    
    .loader-knight {
        width: 150px;
        height: 150px;
    }
    
    .loader-text {
        font-size: 1.1rem;
        letter-spacing: 1px;
    }
    
    .loader-subtitle {
        font-size: 0.9rem;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .loader-container {
        gap: 25px;
        padding: 20px;
    }
    
    .loader-knight {
        width: 180px;
        height: 180px;
    }
    
    .loader-text {
        font-size: 1.2rem;
        letter-spacing: 1.5px;
    }
    
    .loader-subtitle {
        font-size: 1rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .loader-container {
        gap: 30px;
        padding: 25px;
    }
    
    .loader-knight {
        width: 200px;
        height: 200px;
    }
    
    .loader-text {
        font-size: 1.3rem;
        letter-spacing: 2px;
    }
    
    .loader-subtitle {
        font-size: 1.1rem;
    }
}

@media (min-width: 1025px) {
    .loader-container {
        gap: 35px;
        padding: 30px;
    }
    
    .loader-knight {
        width: 220px;
        height: 220px;
    }
    
    .loader-text {
        font-size: 1.4rem;
        letter-spacing: 2px;
    }
    
    .loader-subtitle {
        font-size: 1.2rem;
    }
}

/* Caballo de circuitos mejorado */
.loader-knight {
    width: 200px;
    height: 200px;
    position: relative;
    animation: knight-float 4s ease-in-out infinite;
}

/* Animaciones responsivas para el caballo */
@media (max-width: 480px) {
    @keyframes knight-float {
        0%, 100% {
            transform: translateY(0px) rotate(0deg) translateX(-25px);
        }
        25% {
            transform: translateY(-6px) rotate(1deg) translateX(-25px);
        }
        50% {
            transform: translateY(-12px) rotate(0deg) translateX(-25px);
        }
        75% {
            transform: translateY(-6px) rotate(-1deg) translateX(-25px);
        }
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    @keyframes knight-float {
        0%, 100% {
            transform: translateY(0px) rotate(0deg) translateX(-30px);
        }
        25% {
            transform: translateY(-7px) rotate(1deg) translateX(-30px);
        }
        50% {
            transform: translateY(-13px) rotate(0deg) translateX(-30px);
        }
        75% {
            transform: translateY(-7px) rotate(-1deg) translateX(-30px);
        }
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    @keyframes knight-float {
        0%, 100% {
            transform: translateY(0px) rotate(0deg) translateX(-40px);
        }
        25% {
            transform: translateY(-8px) rotate(1deg) translateX(-40px);
        }
        50% {
            transform: translateY(-15px) rotate(0deg) translateX(-40px);
        }
        75% {
            transform: translateY(-8px) rotate(-1deg) translateX(-40px);
        }
    }
}

@media (min-width: 1025px) {
    @keyframes knight-float {
        0%, 100% {
            transform: translateY(0px) rotate(0deg) translateX(-50px);
        }
        25% {
            transform: translateY(-10px) rotate(1deg) translateX(-50px);
        }
        50% {
            transform: translateY(-18px) rotate(0deg) translateX(-50px);
        }
        75% {
            transform: translateY(-10px) rotate(-1deg) translateX(-50px);
        }
    }
}

.loader-knight svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 30px rgba(255, 0, 0, 0.8)) brightness(1.2);
}

@keyframes knight-float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg) translateX(-45px);
    }
    25% {
        transform: translateY(-8px) rotate(1deg) translateX(-45px);
    }
    50% {
        transform: translateY(-15px) rotate(0deg) translateX(-45px);
    }
    75% {
        transform: translateY(-8px) rotate(-1deg) translateX(-45px);
    }
}

/* Estilos para el texto del loader */
.loader-text {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2px;
    color: #ffffff;
    font-family: 'Poppins', sans-serif;
    font-size: 1.4rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: 2px;
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
    flex-wrap: wrap;
    max-width: 100%;
    padding: 0 10px;
    box-sizing: border-box;
}

.text-char {
    opacity: 0;
    transform: translateY(20px);
    animation: char-appear 0.1s ease-out forwards;
}

.text-char:nth-child(1) { animation-delay: 0.1s; }
.text-char:nth-child(2) { animation-delay: 0.2s; }
.text-char:nth-child(3) { animation-delay: 0.3s; }
.text-char:nth-child(4) { animation-delay: 0.4s; }
.text-char:nth-child(5) { animation-delay: 0.5s; }
.text-char:nth-child(6) { animation-delay: 0.6s; }
.text-char:nth-child(7) { animation-delay: 0.7s; }
.text-char:nth-child(8) { animation-delay: 0.8s; }
.text-char:nth-child(9) { animation-delay: 0.9s; }
.text-char:nth-child(10) { animation-delay: 1.0s; }
.text-char:nth-child(11) { animation-delay: 1.1s; }
.text-char:nth-child(12) { animation-delay: 1.2s; }
.text-char:nth-child(13) { animation-delay: 1.3s; }
.text-char:nth-child(14) { animation-delay: 1.4s; }
.text-char:nth-child(15) { animation-delay: 1.5s; }
.text-char:nth-child(16) { animation-delay: 1.6s; }
.text-char:nth-child(17) { animation-delay: 1.7s; }
.text-char:nth-child(18) { animation-delay: 1.8s; }
.text-char:nth-child(19) { animation-delay: 1.9s; }
.text-char:nth-child(20) { animation-delay: 2.0s; }
.text-char:nth-child(21) { animation-delay: 2.1s; }
.text-char:nth-child(22) { animation-delay: 2.2s; }
.text-char:nth-child(23) { animation-delay: 2.3s; }
.text-char:nth-child(24) { animation-delay: 2.4s; }
.text-char:nth-child(25) { animation-delay: 2.5s; }
.text-char:nth-child(26) { animation-delay: 2.6s; }
.text-char:nth-child(27) { animation-delay: 2.7s; }
.text-char:nth-child(28) { animation-delay: 2.8s; }
.text-char:nth-child(29) { animation-delay: 2.9s; }
.text-char:nth-child(30) { animation-delay: 3.0s; }

@keyframes char-appear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Subtítulo del loader */
.loader-subtitle {
    color: #ff0000;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    text-align: center;
    letter-spacing: 1px;
    opacity: 0;
    padding: 0 15px;
    box-sizing: border-box;
    max-width: 100%;
    word-wrap: break-word;
    animation: subtitle-fade 4s ease-in-out infinite;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

@keyframes subtitle-fade {
    0%, 20% {
        opacity: 0;
        transform: translateY(10px);
    }
    30%, 70% {
        opacity: 0.9;
        transform: translateY(0);
    }
    80%, 100% {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Barra de progreso */
.loader-progress {
    width: 300px;
    height: 6px;
    position: relative;
    margin-top: 30px;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
    padding: 0 15px;
    box-sizing: border-box;
}

/* Responsive para barra de progreso */
@media (max-width: 480px) {
    .loader-progress {
        width: 250px;
        max-width: 95%;
        height: 5px;
        margin-top: 20px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .loader-progress {
        width: 280px;
        max-width: 92%;
        height: 6px;
        margin-top: 25px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .loader-progress {
        width: 320px;
        max-width: 88%;
        height: 7px;
        margin-top: 30px;
    }
}

@media (min-width: 1025px) {
    .loader-progress {
        width: 350px;
        max-width: 85%;
        height: 8px;
        margin-top: 35px;
    }
}

.progress-track {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.loader-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #00ff00, #ff0000, #0066ff);
    background-size: 200% 100%;
    border-radius: 3px;
    width: 0%;
    transition: width 0.4s ease;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.8);
    animation: progress-glow 2s ease-in-out infinite;
}

.progress-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: glow-sweep 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes progress-glow {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@keyframes glow-sweep {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Animaciones de circuitos del caballo */
.circuit-line {
    animation: circuit-flow 3s ease-in-out infinite;
}

.node {
    animation: node-pulse 2s ease-in-out infinite;
}

.particle {
    animation: particle-float 3s ease-in-out infinite;
}

@keyframes circuit-flow {
    0% {
        stroke-dashoffset: 200;
        opacity: 0.3;
    }
    50% {
        stroke-dashoffset: 0;
        opacity: 1;
    }
    100% {
        stroke-dashoffset: -200;
        opacity: 0.3;
    }
}

@keyframes node-pulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

@keyframes particle-float {
    0%, 100% {
        transform: translateY(0px) scale(1);
        opacity: 0.8;
    }
    50% {
        transform: translateY(-10px) scale(1.2);
        opacity: 1;
    }
}

/* Responsive para el loader */
@media only screen and (max-width: 768px) {
    .loader-knight {
        width: 150px;
        height: 150px;
    }
    
    .loader-text {
        font-size: 1.1rem;
        letter-spacing: 1px;
        gap: 1px;
    }
    
    .loader-subtitle {
        font-size: 0.9rem;
    }
    
    .loader-progress {
        width: 250px;
        height: 5px;
    }
}

@media only screen and (max-width: 480px) {
    .loader-knight {
        width: 120px;
        height: 120px;
    }
    
    .loader-text {
        font-size: 1rem;
        letter-spacing: 0.5px;
    }
    
    .loader-subtitle {
        font-size: 0.8rem;
    }
    
    .loader-progress {
        width: 200px;
        height: 4px;
    }
}

/* Ocultar el contenido principal mientras carga */
.chess-layout {
    opacity: 0;
    transition: opacity 0.5s ease-in;
}

.chess-layout.loaded {
    opacity: 1;
}

/* Ocultar elementos de audio durante la carga */
audio {
    display: none;
}

/* Reglas de forzado para asegurar el layout horizontal */
.chess-container {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  width: 100% !important;
  padding-right: 0 !important;
}

.board-wrapper {
  order: 1 !important;
}

.pgn-wrapper {
  order: 2 !important;
  width: 500px !important;
  min-width: 500px !important;
  max-width: 500px !important;
  margin-right: 0 !important;
  padding-right: 0 !important;
  position: relative !important;
  right: 0 !important;
}

#pgn-static {
  width: 440px !important;
  min-width: 440px !important;
  max-width: 440px !important;
  height: auto !important;
  min-height: 420px !important;
  overflow: visible !important;
}

.fen-bar {
  width: 440px !important;
  min-width: 440px !important;
  max-width: 440px !important;
}

.pgn-buttons {
  max-width: 500px !important;
}

.navigation-buttons-redesigned {
  max-width: 500px !important;
}

/* Forzar scroll en el extremo derecho */
body {
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

.chess-layout {
  width: 100% !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
  overflow-y: visible !important;
}

.pgn-wrapper {
  border-right: none !important;
  box-shadow: none !important;
  overflow-y: visible !important;
}

/* Eliminar cualquier scroll interno - COMENTADO */
/*
#pgn-static {
  overflow: visible !important;
  scrollbar-width: none !important;
  height: auto !important;
  max-height: none !important;
}

#pgn-static::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
}

#pgn-static::-webkit-scrollbar-track {
  display: none !important;
}

#pgn-static::-webkit-scrollbar-thumb {
  display: none !important;
}

/* Forzar que no haya scroll en ningún elemento interno */
.pgn-content {
  overflow-y: visible !important;
  max-height: none !important;
}

.pgn-content::-webkit-scrollbar {
  display: none !important;
}

/* Eliminar scroll de todos los elementos PGN */
.pgn-content,
#pgn-static {
  overflow: visible !important;
  overflow-x: hidden !important;
  max-height: none !important;
  scrollbar-width: none !important;
}

.pgn-content::-webkit-scrollbar,
#pgn-static::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
}
*/

/* REGLA FINAL - ELIMINAR SCROLL COMPLETAMENTE - COMENTADA */
/*
#pgn-static {
  overflow: visible !important;
  overflow-y: visible !important;
  overflow-x: visible !important;
  max-height: none !important;
  height: 420px !important;
  scrollbar-width: none !important;
  position: static !important;
  display: block !important;
}

#pgn-static::-webkit-scrollbar,
#pgn-static::-webkit-scrollbar-track,
#pgn-static::-webkit-scrollbar-thumb {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.pgn-content {
  overflow: visible !important;
  overflow-y: visible !important;
  overflow-x: visible !important;
  max-height: none !important;
  height: auto !important;
  position: static !important;
  display: block !important;
}

.pgn-content::-webkit-scrollbar,
.pgn-content::-webkit-scrollbar-track,
.pgn-content::-webkit-scrollbar-thumb {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* REGLA ULTRA ESPECÍFICA */
div#pgn-static.pgn-content,
div#pgn-static,
div.pgn-content {
  overflow: visible !important;
  overflow-y: visible !important;
  overflow-x: visible !important;
  max-height: none !important;
  height: 420px !important;
  scrollbar-width: none !important;
  position: static !important;
  display: block !important;
}

div#pgn-static.pgn-content::-webkit-scrollbar,
div#pgn-static::-webkit-scrollbar,
div.pgn-content::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* REGLA FINAL ABSOLUTA */
html body .chess-layout .chess-container #pgn-static {
  overflow: visible !important;
  overflow-y: visible !important;
  overflow-x: visible !important;
  max-height: none !important;
  height: 420px !important;
  scrollbar-width: none !important;
  position: static !important;
  display: block !important;
  -webkit-overflow-scrolling: auto !important;
}

html body .chess-layout .chess-container #pgn-static::-webkit-scrollbar,
html body .chess-layout .chess-container #pgn-static::-webkit-scrollbar-track,
html body .chess-layout .chess-container #pgn-static::-webkit-scrollbar-thumb {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
*/

/* === FIX LAYOUT (14-08-2025): tablero y panel derecho encajados === */

/* 1) El contenedor horizontal ahora es Grid y se estira a la altura del tablero */
.chess-container{
  display: grid !important;
  grid-template-columns: minmax(520px,1fr) 500px !important; /* tablero | panel */
  align-items: stretch !important;      /* ambas columnas a la misma altura */
  gap: 20px !important;
  width: 100% !important;               /* evita 100vw y scroll lateral */
  min-height: 0 !important;             /* sin alto mínimo forzado */
  height: auto !important;
  margin-bottom: 0 !important;
}

/* 2) Tablero: sin cambios de tamaño, pero el wrapper ocupa toda la celda */
.board-wrapper{
  height: 100% !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* 3) Panel derecho: se estira y luce como tarjeta */
.pgn-wrapper{
  height: 100% !important;              /* igual al tablero */
  align-self: stretch !important;
  display: flex !important;
  flex-direction: column;
  background: #141414;                  /* panel sólido, sin "fondo de mesa" */
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

/* 4) Contenidos del panel: botones arriba, PGN al medio con scroll, FEN abajo */
.pgn-buttons,
.navigation-buttons-redesigned,
.fen-bar{
  flex-shrink: 0;                        /* no se aplastan */
  margin-top: 8px;
  margin-bottom: 8px;
}

.pgn-content{
  flex: 1 1 auto !important;             /* ocupa todo el alto disponible */
  min-height: 0;                          /* habilita overflow correcto */
  overflow-y: auto !important;            /* scroll interno solo cuando haga falta */
  margin-top: 4px;
}

/* 5) Responsivo: en móviles vuelve a columna, sin alturas forzadas */
@media (max-width: 767px){
  .chess-container{
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
  }
  .pgn-wrapper{
    height: auto !important;
    box-shadow: none;
    border-radius: 10px;
    width: 100%;
    max-width: 600px;
  }
}

/* === FIX LAYOUT: igualar alturas tablero/panel y quitar sobrantes === */

/* El contenedor principal deja de forzar 100vh y estira ambas columnas */
.chess-layout{
  align-items: stretch !important;
  height: auto !important;
  min-height: 100vh;           /* solo para llenar pantalla, sin forzar desajustes */
}

/* La columna del tablero no fuerza 100vh ni deja paddings grandes */
.chess-container{
  height: auto !important;
  padding: 10px !important;    /* reduce el "margen negro" alrededor del tablero */
  gap: 20px !important;
}

/* El panel derecho se estira exactamente a la altura del tablero */
.controls-container{
  height: auto !important;           /* anula el alto forzado anterior */
  min-height: 0 !important;
  max-height: none !important;
  align-self: stretch !important;    /* iguala la altura con la otra columna */
  display: flex !important;
  flex-direction: column;
  background: #141414;               /* look uniforme (sin fondo raro detrás) */
  border-radius: 12px;
  padding: 12px;
  overflow: hidden;
  width: 500px;                      /* ancho fijo cómodo en desktop */
}

/* Secciones internas del panel ocupan bien el espacio disponible */
.pgn-buttons,
.navigation-buttons-redesigned,
.fen-bar{
  width: 100% !important;
  max-width: none !important;
  flex-shrink: 0;
  margin: 8px 0;
}

.pgn-section{
  flex: 1 1 auto !important;         /* el PGN crece para llenar el alto */
  min-height: 0 !important;
  display: flex;
  justify-content: center;           /* centrar horizontalmente */
  align-items: flex-start;           /* alinear al inicio verticalmente */
}

#pgn-static{
  flex: 0 0 440px;                    /* ancho fijo de 440px, igual a los botones */
  min-height: 0;
  overflow-y: auto;                   /* scroll interno solo cuando haga falta */
}

/* Responsivo: en móviles el panel pasa debajo del tablero */
@media (max-width: 767px){
  .chess-layout{ align-items: flex-start !important; }
  .controls-container{
    width: 100% !important;
    border-radius: 10px;
    box-shadow: none;
  }
}

/* Scrollbar fino y temático (Chromium/WebKit) */
#pgn-static::-webkit-scrollbar {
  width: 6px;
}
#pgn-static::-webkit-scrollbar-track {
  background: #1a1a1a;
  border-radius: 6px;
}
#pgn-static::-webkit-scrollbar-thumb {
  background: #C50039;
  border-radius: 6px;
}
#pgn-static::-webkit-scrollbar-thumb:hover {
  background: #a4002e;
}

/* === PGN: scrollbar fino y clickeable (FIX 2025-08-14) === */
html body .chess-layout .controls-container .pgn-section #pgn-static{
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scrollbar-gutter: stable both-edges;     /* sin saltos de ancho */
  scrollbar-width: thin;                    /* Firefox */
  scrollbar-color: #C50039 #1a1a1a;
}

/* WebKit/Chromium */
html body .chess-layout .controls-container .pgn-section #pgn-static::-webkit-scrollbar{
  display: initial !important;              /* revierte display:none anterior */
  width: 6px !important;                    /* sutil */
}
html body .chess-layout .controls-container .pgn-section #pgn-static::-webkit-scrollbar-track{
  background: #1a1a1a !important;
  border-radius: 6px;
}
html body .chess-layout .controls-container .pgn-section #pgn-static::-webkit-scrollbar-thumb{
  background: #C50039 !important;
  border-radius: 6px;
}
html body .chess-layout .controls-container .pgn-section #pgn-static::-webkit-scrollbar-thumb:hover{
  background: #a4002e !important;
}

/* === FIX DEFINITIVO – Scroll PGN interno, fino y temático === */
html body .chess-layout .controls-container .pgn-section #pgn-static{
  height: 420px !important;           /* alto fijo existente, necesario para overflow */
  overflow-y: auto !important;        /* genera el scroll vertical interno */
  overflow-x: hidden !important;
  scrollbar-gutter: stable both-edges;/* sin saltos de ancho */
  scrollbar-width: thin;              /* Firefox */
  scrollbar-color: #C50039 #1a1a1a;
}

/* WebKit/Chromium — re-habilita la barra y dale estilo sutil */
html body .chess-layout .controls-container .pgn-section #pgn-static::-webkit-scrollbar{
  display: initial !important;  /* revierte los display:none anteriores */
  width: 6px !important;        /* fino; no "engorda" el layout */
}
html body .chess-layout .controls-container .pgn-section #pgn-static::-webkit-scrollbar-track{
  background: #1a1a1a !important; border-radius: 6px;
}
html body .chess-layout .controls-container .pgn-section #pgn-static::-webkit-scrollbar-thumb{
  background: #C50039 !important; border-radius: 6px;
}
html body .chess-layout .controls-container .pgn-section #pgn-static::-webkit-scrollbar-thumb:hover{
  background: #a4002e !important;
}

/* ===== ESTILOS PARA EL DIÁLOGO DE PROMOCIÓN ===== */
/* Diálogo de promoción elegante y moderno */
.promotion-dialog {
    display: none;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: linear-gradient(145deg, #1a1a1a 0%, #2a2a2a 50%, #1f1f1f 100%);
    border: 2px solid #C50039;
    border-radius: 18px;
    padding: 20px 25px;
    z-index: 10000 !important;
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(197, 0, 57, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    pointer-events: auto !important;
    backdrop-filter: blur(8px);
    animation: promotionDialogFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 260px;
    max-width: 260px;
    text-align: center;
}

/* Título del diálogo */
.promotion-dialog::before {
    content: "Elige tu promoción";
    display: block;
    color: #C50039;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 18px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    position: relative;
}

.promotion-dialog::after {
    content: "";
    position: absolute;
    top: 45px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #C50039, transparent);
    border-radius: 1px;
}

/* Contenedor de las piezas */
.promotion-dialog > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #2c2c2c 0%, #1f1f1f 100%);
    border-radius: 15px;
    border: 1px solid #444;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    justify-items: center;
    align-items: center;
}

/* Piezas de promoción elegantes */
.promotion-piece {
    width: 60px;
    height: 60px;
    cursor: pointer;
    object-fit: contain;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
    padding: 5px;
    background: linear-gradient(135deg, #353535 0%, #2a2a2a 100%);
    border: 2px solid #555;
    box-shadow: 
        0 3px 6px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    position: relative;
}

.promotion-piece:hover {
    transform: scale(1.1) translateY(-2px);
    border-color: #C50039;
    background: linear-gradient(135deg, #444 0%, #555 100%);
    box-shadow: 
        0 6px 12px rgba(197, 0, 57, 0.3),
        0 3px 6px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    filter: drop-shadow(0 3px 6px rgba(197, 0, 57, 0.2));
}

.promotion-piece:active {
    transform: scale(1.05) translateY(-1px);
    transition: all 0.1s ease;
}

/* Animación de entrada del diálogo */
@keyframes promotionDialogFadeIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    50% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Efecto de brillo en las piezas */
.promotion-piece {
    position: relative;
    overflow: hidden;
}

.promotion-piece::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: left 0.6s ease;
    pointer-events: none;
    z-index: 1;
}

.promotion-piece:hover::after {
    left: 100%;
}

/* Efecto de pulso para piezas importantes */
.promotion-piece[data-piece="q"] {
    animation: queenPulse 2s ease-in-out infinite;
}

@keyframes queenPulse {
    0%, 100% {
        box-shadow: 
            0 4px 8px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
    50% {
        box-shadow: 
            0 4px 8px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.1),
            0 0 15px rgba(197, 0, 57, 0.3);
    }
}

/* Tooltip para las piezas */
.promotion-piece::before {
    content: attr(title);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #C50039 0%, #a4002e 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
    z-index: 10;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.promotion-piece:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
}

/* Indicador de pieza recomendada (Dama) */
.promotion-piece[data-piece="q"] {
    border-color: #C50039;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 0 0 2px rgba(197, 0, 57, 0.3);
}

.promotion-piece[data-piece="q"]::after {
    content: "★";
    position: absolute;
    top: -8px;
    right: -8px;
    background: #C50039;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 5;
}

/* Resplandor especial para piezas negras */
.promotion-piece[src*="/b"] {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)) 
            drop-shadow(0 0 8px rgba(255, 255, 255, 0.6))
            drop-shadow(0 0 12px rgba(255, 255, 255, 0.4))
            drop-shadow(0 0 16px rgba(255, 255, 255, 0.3));
    background: linear-gradient(135deg, #444 0%, #333 100%);
    border-color: #666;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.1);
}

.promotion-piece[src*="/b"]:hover {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6)) 
            drop-shadow(0 0 12px rgba(255, 255, 255, 0.8))
            drop-shadow(0 0 18px rgba(255, 255, 255, 0.6))
            drop-shadow(0 0 24px rgba(255, 255, 255, 0.4))
            drop-shadow(0 0 30px rgba(197, 0, 57, 0.5));
    background: linear-gradient(135deg, #555 0%, #444 100%);
    border-color: #777;
    box-shadow: 
        0 8px 16px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 0 0 2px rgba(255, 255, 255, 0.2);
}

/* Overlay de bloqueo elegante */
#overlayBloqueo {
    display: none;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.7) 100%);
    z-index: 999;
    pointer-events: auto;
    backdrop-filter: blur(3px);
    animation: overlayFadeIn 0.3s ease-out;
}

/* Animación del overlay */
@keyframes overlayFadeIn {
    0% {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    100% {
        opacity: 1;
        backdrop-filter: blur(3px);
    }
}

#overlayBloqueo .pgn-dialog {
    background-color: #C50039;
    color: white;
    font-family: 'Poppins', sans-serif;
    z-index: 1001;
    pointer-events: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 15px;
    border: 1px solid white;
    box-shadow: 0 0 15px rgba(0,0,0,0.6);
}

#overlayBloqueo input,
#overlayBloqueo select,
#overlayBloqueo button,
#overlayBloqueo label {
    pointer-events: auto;
    z-index: 1002;
    position: relative;
}

/* Asegurar que el contenedor del tablero permita overflow para el diálogo */
.chess-container {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    height: 100vh;
    width: 100vw;
    margin-bottom: 0;
    overflow-x: hidden;
    /* CAMBIO: Permitir overflow-y para el diálogo de promoción */
    overflow-y: visible;
    max-width: 100vw;
    box-sizing: border-box;
}

/* Asegurar que el board wrapper también permita overflow */
.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: 100vh;
    padding-top: 1px;
    padding-bottom: 5px;
    box-sizing: border-box;
    /* Asegurar que no bloquee el diálogo */
    overflow: visible;
}

/* Asegurar que el tablero mismo permita overflow */
#board1 {
    width: min(98vh, 90vw);
    height: min(98vh, 90vw);
    max-width: 98vh;
    max-height: calc(100vh - 10px);
    min-width: 320px;
    min-height: 320px;
    margin: 5px auto 10px auto;
    display: block;
    touch-action: none;
    position: relative;
    /* CAMBIO: Permitir overflow visible para el diálogo */
    overflow: visible;
}

/* Responsive para el diálogo de promoción */
@media only screen and (max-width: 767px) {
    .promotion-dialog {
        width: 85vw !important;
        max-width: 280px;
        padding: 18px 15px !important;
        border-radius: 15px !important;
        min-width: auto !important;
    }
    
    .promotion-dialog::before {
        font-size: 0.9rem !important;
        margin-bottom: 15px !important;
    }
    
    .promotion-dialog > div {
        gap: 12px !important;
        padding: 10px !important;
    }
    
    .promotion-piece {
        width: 48px !important;
        height: 48px !important;
        padding: 4px !important;
        border-radius: 8px !important;
    }
    
    .promotion-piece:hover {
        transform: scale(1.08) translateY(-1px) !important;
    }
}

/* Para pantallas muy pequeñas */
@media only screen and (max-width: 480px) {
    .promotion-dialog {
        width: 90vw !important;
        max-width: 260px;
        padding: 15px 10px !important;
    }
    
    .promotion-dialog > div {
        gap: 10px !important;
        padding: 8px !important;
    }
    
    .promotion-piece {
        width: 45px !important;
        height: 45px !important;
        padding: 4px !important;
    }
    
    /* Ocultar indicador de estrella en móviles */
    .promotion-piece[data-piece="q"]::after {
        display: none !important;
    }
    
    /* Ajustar tooltip en móviles */
    .promotion-piece::before {
        font-size: 0.65rem !important;
        padding: 4px 8px !important;
        bottom: -25px !important;
    }
}

/* Asegurar que el overlay de bloqueo esté por encima de todo */
#overlayBloqueo {
    z-index: 9999 !important;
}

/* Asegurar que el diálogo de promoción esté por encima del overlay */
.promotion-dialog {
    z-index: 10001 !important;
}

/* ===== FIN DE ESTILOS PARA EL DIÁLOGO DE PROMOCIÓN ===== */

