/* Reset general */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Fuente y fondo */
body {
  font-family: 'Poppins', Arial, sans-serif;
  background: linear-gradient(to right, #004c2f, #007144);
  color: #fff;
  text-align: center;
  padding: 20px;
  animation: fadeIn 0.5s ease;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Animación entrada */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Menú principal */
#menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#menu h1 {
  font-size: 65px;
  font-weight: bold;
  margin-bottom: 30px;
  color: #ffcc00;
  text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.7);
}

/* Botones del menú */
#menu button {
  display: block;
  margin: 20px auto;
  padding: 17px 32px;
  font-size: 20px;
  font-weight: bold;
  border-radius: 15px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #ffcc00, #ffd633);
  color: #222;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
  transition: all 0.25s ease;
}

#menu button:hover {
  transform: translateY(-3px);
  background: linear-gradient(135deg, #ffd633, #fff08a);
  box-shadow: 0 8px 18px rgba(0,0,0,0.5);
}

/* Cómo jugar */
#how-to-play {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 700px;
  background: rgba(0, 0, 0, 0.95);
  border: 3px solid #ffcc00;
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
  padding: 30px 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #fff;
}

#how-to-play h1 {
  font-size: 42px;
  color: #ffcc00;
  margin-bottom: 20px;
  text-shadow: 2px 2px 10px rgba(0,0,0,0.7);
  text-align: center;
}

#how-to-play p {
  font-size: 18px;
  text-align: center;
  margin-bottom: 15px;
  line-height: 1.6;
  color: #fff8b0;
}

#how-to-play ul {
  list-style: inside disc;
  text-align: left;
  padding-left: 0;
  margin-bottom: 25px;
  width: 100%;
}

#how-to-play li {
  font-size: 16px;
  margin: 8px 0;
  line-height: 1.5;
}

/* Botón Volver al menú */
#close-howto-btn {
  padding: 14px 30px;
  font-size: 18px;
  font-weight: bold;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #ffcc00, #ffd633);
  color: #222;
  box-shadow: 0 6px 14px rgba(0,0,0,0.4);
  transition: transform 0.2s ease, box-shadow 0.3s ease, background 0.3s ease;
}

#close-howto-btn:hover {
  transform: translateY(-3px);
  background: linear-gradient(135deg, #ffd633, #fff08a);
  box-shadow: 0 8px 18px rgba(0,0,0,0.5);
}

/* Botón de jugar */
#start-btn {
  padding: 16px 32px;
  font-size: 20px;
  background: linear-gradient(135deg, #ffcc00, #ffd633);
  color: #222;
  border: none;
  border-radius: 14px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease, box-shadow 0.3s ease, background 0.3s ease;
}

#start-btn:hover {
  transform: translateY(-3px);
  background: linear-gradient(135deg, #ffd633, #fff08a);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5);
}

/* Juego */
#game {
  margin: 0 auto;
  max-width: 960px;
  padding-bottom: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Dealer y Tú */
#game h2 {
  font-size: 28px;
  color: #ffcc00;
  text-shadow: 1px 1px 4px black;
  margin: 10px 0;
}

/* Mano de cartas */
.hand {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  margin: 25px 0;
}

/* Mano de cartas del dealer */
#dealer-hand {
  margin-top: 10px;
  gap: 15px;
}

/* Total del dealer */
#dealer-total {
  margin-bottom: 47px;
  font-size: 20px;
  color: #ffdd33;
  text-shadow: 1px 1px 4px black;
}

/* Mano de cartas del jugador */
#player-hand {
  margin-top: 10px;
  gap: 15px;
}

/* Total del jugador */
#player-total {
  margin-bottom: 47px;
  font-size: 20px;
  color: #ffdd33;
  text-shadow: 1px 1px 4px black;
}

/* Carta individual */
.card {
  width: 80px;
  height: 120px;
  background-size: cover;
  background-position: center;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: scale(1.15) rotate(2deg);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

/* Controles */
#controls {
  margin: 35px auto;
  padding: 25px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 18px;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

/* Botones */
button {
  padding: 14px 26px;
  font-size: 16px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: linear-gradient(135deg, #ffcc00, #ffd633);
  color: #222;
  text-transform: uppercase;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: all 0.25s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #ffd633, #fff08a);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}

button:disabled {
  background-color: #999;
  color: #444;
  cursor: not-allowed;
}

/* Botón Jugar de nuevo */
#play-again-btn {
  margin-top: 12px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #28a745, #38d23f);
  color: #fff;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

#play-again-btn:hover {
  background: linear-gradient(135deg, #218838, #2ecc71);
  transform: translateY(-2px);
}

/* Resultado del juego */
#result {
  font-size: 28px;
  font-weight: bold;
  min-height: 30px;
  margin: 25px 0;
  color: #ffdd33;
  text-shadow: 1px 1px 6px black;
}

/* Tabla de puntuación */
#scoreboard {
  position: fixed;
  display: none;
  margin:20px auto;
  top: 80px;
  left: 20px;
  padding: 20px;
  background: rgba(0, 0, 0, 0.95);
  border: 2px solid #ffcc00;
  border-radius: 18px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
  max-width:400px;
  text-align: center;
  font-size: 16px;
  z-index: 1005;
}

#scoreboard h3 {
  font-size: 22px;
  margin-bottom: 12px;
  color: #ffcc00;
  text-shadow: 1px 1px 4px black;
}

#scoreboard table {
  width: 100%;
  border-collapse: collapse;
  color: #fff;
  font-size: 14px;
}

#scoreboard th,
#scoreboard td {
  padding: 8px 12px;
  text-align: center;
  border-radius: 6px;
}

#scoreboard thead tr {
  border-bottom: 2px solid #ffcc00;
}

#scoreboard tbody tr {
  transition: background 0.3s ease;
}

#scoreboard tbody tr:hover {
  background: rgba(255, 204, 0, 0.15);
}

/* Botón para mostrar/ocultar scoreboard */
#scoreboard-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  background: transparent;
  color: #ffcc00;
  font-size: 32px;
  cursor: pointer;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  z-index: 1006;
  transition: transform 0.3s ease, background-color 0.2s ease;
}

#scoreboard-toggle:hover {
  transform: rotate(25deg) scale(1.1);
  background-color: rgba(255, 204, 0, 0.15);
}

/* Panel de configuración */
#settings {
  position: fixed;
  top: 80px;
  right: 30px;
  padding: 24px 20px;
  width: 320px;
  max-width: 90%;
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid #ffcc00;
  border-radius: 18px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  text-align: left;
  display: none;
  z-index: 1002;
}

#settings h2 {
  font-size: 24px;
  margin-bottom: 12px;
  color: #ffcc00;
  text-align: center;
  text-shadow: 1px 1px 4px black;
}

#settings label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: 12px;
  font-weight: 600;
  color: #fff;
}

#settings input[type="text"] {
  width: 100%;
  margin-top: 5px;
  padding: 5px;
  border-radius: 5px;
  border: none;
}

#save-settings {
  margin-top: 15px;
  width: 100%;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 25px;
  margin-top: 8px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0;
  right: 0; bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 25px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background: linear-gradient(135deg, #ffcc00, #ffd633);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.toggle-label {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  color: #fff;
  margin-top: 12px;
  align-items: flex-start;
}

/* Botón de configuración */
#settings-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  color: #ffcc00;
  font-size: 32px;
  cursor: pointer;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  z-index: 1006;
  transition: transform 0.3s ease, background-color 0.2s ease;
}

#settings-toggle:hover {
  transform: rotate(25deg) scale(1.1);
  background-color: rgba(255, 204, 0, 0.15);
}

/* Responsive */
@media (max-width: 600px) {
  #scoreboard table,
  #scoreboard thead,
  #scoreboard tbody,
  #scoreboard th,
  #scoreboard td,
  #scoreboard tr {
    display: block;
    width: 100%;
  }

  #scoreboard thead {
    display: none;
  }

  #scoreboard tr {
    margin-bottom: 12px;
    border: 1px solid #ffcc00;
    border-radius: 10px;
    padding: 10px;
    background: rgba(0,0,0,0.5);
  }

  #scoreboard td {
    text-align: right;
    padding-left: 50%;
    position: relative;
  }

  #scoreboard td::before {
    content: attr(data-label);
    position: absolute;
    left: 10px;
    width: 45%;
    text-align: left;
    font-weight: bold;
    color: #ffcc00;
  }
}

@media (max-width: 600px) {
  #how-to-play h1 { font-size: 32px; }
  #how-to-play p, #how-to-play li { font-size: 14px; }
  #close-howto-btn { font-size: 16px; padding: 12px 24px; }
  .card { width: 60px; height: 90px; }
  button { width: 100%; font-size: 14px; padding: 12px; }
  #controls { gap: 12px; padding: 18px; }
  #settings { width: 90%; font-size: 16px; padding: 16px; top: 60px; right: 10px; }
  #settings-toggle { top: 10px; right: 10px; }
  #scoreboard { max-width: 160px; padding: 10px; font-size: 13px; }
  #scoreboard table th, #scoreboard table td { padding: 4px 6px; font-size: 12px; }
}
