/* Layout general de la sección de juegos */

.juegos-main {
  max-width: 1200px;
  margin-inline: auto;
}

.juegos-hero {
  margin-bottom: 2.5rem;
}

.juegos-hero h1 {
  font-size: clamp(2.2rem, 3vw, 2.8rem);
  margin-bottom: 0.5rem;
}

.juegos-hero p {
  max-width: 650px;
  line-height: 1.5;
}

/* GRID principal */

.juegos-layout {
  display: grid;
  grid-template-columns: minmax(260px, 280px) minmax(0, 1fr);
  gap: 1.75rem;
  align-items: flex-start;
}

/* Sidebar de juegos */

.juegos-sidebar {
  background: radial-gradient(circle at top, rgba(0, 240, 255, 0.05), transparent),
              rgba(4, 10, 29, 0.9);
  border-radius: 1.5rem;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.juegos-sidebar h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
}

.juegos-list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.juego-item {
  background: radial-gradient(circle at top left, rgba(0, 240, 255, 0.12), transparent);
  border-radius: 1rem;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease,
    background 0.15s ease;
}

.juego-item .juego-title {
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.juego-item small {
  opacity: 0.7;
  font-size: 0.75rem;
}

.juego-item:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 240, 255, 0.7);
  box-shadow: 0 0 0 1px rgba(0, 240, 255, 0.4);
}

.juego-item.active {
  border-color: rgba(0, 240, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 240, 255, 0.7);
}

.juego-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* Caja de perfil jugador */

.player-box {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 1rem;
  margin-top: 0.75rem;
}

.player-box h3 {
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

#playerStatus {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-bottom: 0.6rem;
}

.player-username {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  opacity: 0.9;
}

/* Panel principal de juego */

.juegos-main-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Tarjeta del juego */

.game-container {
  background: radial-gradient(circle at top right, rgba(0, 240, 255, 0.12), transparent),
              rgba(4, 10, 29, 0.95);
  border-radius: 1.5rem;
  padding: 1.4rem 1.6rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.65);
}

.game-header h2 {
  font-size: 1.4rem;
  margin-bottom: 0.2rem;
}

.game-header p {
  font-size: 0.9rem;
  opacity: 0.85;
}

.game-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 1.3rem;
  margin-top: 1.2rem;
}

/* Canvas del Snake */

#snakeCanvas {
  width: 100%;
  max-width: 460px;
  border-radius: 1rem;
  background: radial-gradient(circle at top, rgba(0, 240, 255, 0.05), #050816);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.7);
  display: block;
  margin-inline: auto;
}

/* Controles juego */

.game-controls {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  justify-content: center;
}

.score-box {
  font-weight: 600;
  font-size: 1rem;
}

.controls-hint {
  font-size: 0.8rem;
  opacity: 0.75;
}

/* Leaderboard */

.leaderboard-container {
  background: radial-gradient(circle at top left, rgba(0, 240, 255, 0.12), transparent),
              rgba(4, 10, 29, 0.95);
  border-radius: 1.5rem;
  padding: 1.4rem 1.6rem 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.65);
}

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9rem;
}

.leaderboard-header span {
  font-size: 0.85rem;
  opacity: 0.8;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 0.45rem 0.4rem;
  text-align: left;
}

.leaderboard-table th {
  opacity: 0.7;
  font-weight: 500;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.leaderboard-table tbody tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.02);
}

.leaderboard-table tbody tr:first-child td {
  font-weight: 600;
}

.leaderboard-note {
  margin-top: 0.7rem;
  font-size: 0.8rem;
  opacity: 0.7;
}

/* Botón reutiliza estilos .button de tu style.css; aquí solo ajustes pequeños */

.button.button-small {
  font-size: 0.8rem;
  padding: 0.45rem 0.8rem;
}

/* Responsive */

@media (max-width: 900px) {
  .juegos-layout {
    grid-template-columns: 1fr;
  }

  .juegos-sidebar {
    order: 2;
  }

  .juegos-main-panel {
    order: 1;
  }

  .game-inner {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  #snakeCanvas {
    max-width: 100%;
  }
}

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

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: radial-gradient(circle at top, rgba(0, 240, 255, 0.15), #050816);
  border-radius: 1.3rem;
  padding: 1.4rem 1.6rem 1.2rem;
  max-width: 380px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  position: relative;
}

.modal h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.modal p {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-bottom: 0.8rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.7rem;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.7;
}

.modal-close:hover {
  opacity: 1;
}

#usernameInput {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(4, 10, 29, 0.9);
  color: #fff;
  margin-bottom: 0.7rem;
  font-size: 0.9rem;
}

#usernameInput:focus {
  outline: none;
  border-color: rgba(0, 240, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(0, 240, 255, 0.4);
}

.gameover-note {
  font-size: 0.82rem;
  opacity: 0.75;
}

/* =========================
   TOAST NOTIFICATIONS
   ========================= */
#toastContainer {
  position: fixed;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10000;
}

.toast {
  background: rgba(10, 14, 25, 0.9);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: #fff;
  padding: 0.9rem 1.2rem;
  border-radius: 0.8rem;
  font-size: 0.9rem;
  max-width: 280px;
  animation: fadeIn 0.3s ease forwards;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

.toast.hide {
  animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(100%) translateY(-50%);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(-50%);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateX(0) translateY(-50%);
  }
  to {
    opacity: 0;
    transform: translateX(120%) translateY(-50%);
  }
}

/* Cabecera del juego con botón de pausa */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

/* Que la tarjeta pueda ser contenedor relativo para el overlay */
.game-container {
  position: relative;
}

/* Overlay de pausa / cuenta atrás */
.game-overlay {
  position: absolute;
  left: 1.2rem;
  right: 1.2rem;
  bottom: 1.2rem;
  top: 3.4rem; /* debajo de la cabecera */
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 1.2rem;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 10;
  pointer-events: none;
}

.game-overlay span {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
}

.leaderboard-admin {
  display: flex;
  gap: 0.5rem;
}

.leaderboard-admin .button.button-small {
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
}

.lb-delete {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.15rem 0.35rem;
  border-radius: 0.4rem;
  opacity: 0.8;
}

.lb-delete:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}
