html, body {
  height: 100%;
}
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: url('./assets/game-bg.png') center center / cover no-repeat;
  background-attachment: fixed;
  display: flex;
  align-items: center;
  flex-direction: column;
}
canvas {
  background-color: #222;
  background-image: url('./assets/bg.png');
  background-size: cover;
  background-position: center center;
  border: 5px solid #1d2a25;
  width: 90%;
  height: auto;
}

#cards {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 10px 0;
  width: 100%;
}

.card-slot {
  width: 20%;
  height: auto;
  background: #999;
  border-radius: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: Arial, sans-serif;
  color: white;
}

.card-slot img {
  width: 100%;
  object-fit: cover;
}

/* Estilos para la pantalla de inicio con fondo de imagen y botones como imágenes */
#startScreen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: url('./assets/start-screen-bg.png') center center / cover no-repeat;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5vh 0;
  color: white;
  z-index: 10;
}
#startScreen #logo {
  max-height: 45vh;
  width: auto;
  margin-bottom: 2vh;
}
#startScreen button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
#startScreen button img {
  max-height: 15vh;
  width: auto;
  margin: 0;
}
#startScreen #enterHint {
  font-family: Arial, sans-serif;
  font-size: 4vh;
  color: white;
  text-shadow: 0 0 5px #fff;
  display: none;
}
#startScreen #footer {
  padding-top: 15px;
  font-family: Arial, sans-serif;
  font-size: 2vh;
}

/* Contenedor para agrupar botones e hint */
#startScreen .actions-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2vh;
}

#modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: #333;
  padding: 20px;
  border-radius: 12px;
  color: white;
  font-family: Arial, sans-serif;
  width: 80%;
  text-align: center;
  display: none;
  z-index: 20;
  box-shadow: 0 0 30px rgba(0,0,0,0.7);
}
#modal h2 {
  font-size: 5rem;
  margin-top: 0;
}
#modal button {
  margin-top: 15px;
  padding: 8px 16px;
  font-size: 4rem;
  background: #555;
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
}

/* Estilos para el botón de cerrar modal con imagen y posición */
#modal #closeModal {
  position: absolute;
  top: -30px;
  right: -30px;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}
#modal #closeModal img {
  width: 120px;
  height: auto;
  display: block;
}

/* Overlay negro semitransparente detrás del modal de Hi-Scores */
#modalOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  z-index: 19;
}

#controls {
  margin: 0;
  padding: 10px 0;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  user-select: none;
  width: 100%;
}
#row-up, #row-down {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 5px 0;
  width: 100%;
}
#row-middle {
  display: flex;
  justify-content: center;
  gap: 10px;
  width: 100%;
}
.control-button {
  padding: 0;
  background: transparent;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  width: 20%;
  height: auto;
  text-align: center;
}
.control-button:active {
  background: transparent;
}

/* Estilos para la sección de High Scores */
.highscores-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-top: 10px;
}
.hs-header, .hs-row {
  display: grid;
  grid-template-columns: 0.3fr 0.1fr 0.8fr 0.5fr  ;
  font-size: 2rem;
  align-items: center;
  padding: 8px 12px;
}
.hs-header {
  background-color: #3cb371;
  font-size: 3rem;
  font-weight: bold;
  border-radius: 8px 8px 0 0;
}
.hs-row:nth-child(odd) {
  background-color: rgba(255, 255, 255, 0.05);
}
.hs-row:last-child {
  border-radius: 0 0 8px 8px;
}
.hs-cell {
  color: white;
}
.hs-cell.hs-rank, .hs-cell.hs-rank-header {
  text-align: center;
}
.hs-cell.hs-player, .hs-cell.hs-player-header {
  font-weight: bold;
  text-transform: uppercase;
}
.hs-cell.hs-score, .hs-cell.hs-score-header {
  font-weight: bold;
  text-align: center;
}
.hs-cell.hs-medal, .hs-cell.hs-medal-header {
  display: flex;
  justify-content: center;
}
.hs-cell.hs-medal img {
  display: block;
}

/* Animaciones para la aparición y desaparición de cartas */
@keyframes card-enter {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes card-exit {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-20px);
  }
}

.card-enter {
  animation: card-enter 0.3s ease-out forwards;
}

.card-exit {
  animation: card-exit 0.3s ease-in forwards;
}

/* Estilos de iconos direccionales */
.control-button img {
  width: 100%;
  height: auto;
  display: block;
}
.control-button#up img {
  transform: rotate(0deg);
}
.control-button#right img {
  transform: rotate(90deg);
}
.control-button#down img {
  transform: rotate(180deg);
}
.control-button#left img {
  transform: rotate(-90deg);
}

@media (min-width: 768px) {
  #startScreen #footer {
    font-size: 1.5vh;
  }
}
@media (min-width: 1024px) {
  .card-slot {
    width: 30%;
  }
  canvas {
    width: 500px;
    /* height: auto; seguirá respetando la proporción */
  }

  #cards {
    max-width: 500px;
  }

  #controls {
    display: none !important;
  }

  #startScreen #footer {
    font-size: 1.2vh;
  }

  #startScreen #enterHint {
    display: block;
  }

  #startScreen #startButton {
    display: none;;
  }
}