html, body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #0e1117;
  width: 100%;
  height: 100%;
  position: fixed; /* Evitar scroll en móviles */
}

/* ---------- FONDO ---------- */
#bg-wrapper {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

#bg {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 350vh; /* Altura aumentada para evitar áreas negras */
  min-height: 350vh; /* Mínimo 350% de la altura de la ventana */
  background-image: url("../img/fondo0.svg");
  background-repeat: no-repeat;
  background-size: 100% auto;
  background-position: bottom center;
  will-change: transform;
}

/* Para resoluciones pequeñas (móviles), usar fondo1.jpeg y ajustar posicionamiento */
@media (max-width: 768px) {
  #bg {
    background-image: url("../img/fondo1.jpeg");
    background-size: 220% auto; /* Más alejado - mostrar más del fondo */
    background-position: bottom center; /* Posicionar desde abajo */
    top: auto;
    bottom: 0;
    height: 500vh; /* Altura aumentada para pantallas pequeñas y evitar áreas negras */
    min-height: 500vh;
    transform: translateY(0); /* Empezar visible desde el inicio */
    z-index: 0; /* Asegurar que esté detrás del canvas */
  }
  
  /* Asegurar que el canvas esté visible en móviles */
  canvas {
    z-index: 10 !important;
    position: fixed !important; /* Cambiado a fixed para móviles */
    width: 100vw !important;
    height: 100vh !important;
  }
}

/* ---------- CANVAS ---------- */
canvas {
  position: fixed; /* Cambiado a fixed para asegurar posicionamiento en móviles */
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10; /* Aumentado para asegurar que esté por encima del fondo */
  display: block;
  pointer-events: none; /* Permite que los toques pasen a través si es necesario */
  background: transparent; /* Asegurar que sea transparente */
}

/* ---------- PERSONALIZADOR ---------- */
.customize-button {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 10;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 8px;
  font-size: clamp(12px, 4vw, 16px);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  display: none; /* Oculto por defecto, se muestra si ENABLE_CUSTOMIZER es true */
  touch-action: manipulation; /* Mejora la respuesta táctil */
}

.customize-button:hover {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.05);
}

.modal {
  display: none;
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #1a1f2e;
  border-radius: 12px;
  width: 95%;
  max-width: 600px;
  max-height: 95vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  color: #fff;
  margin: 10px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
  margin: 0;
  font-size: clamp(18px, 5vw, 24px);
}

.close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.3s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 15px 20px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #fff;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: clamp(14px, 4vw, 16px);
  font-family: inherit;
  box-sizing: border-box;
  -webkit-appearance: none; /* Elimina estilos nativos en iOS */
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.form-group small {
  display: block;
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.apply-button,
.reset-button {
  flex: 1;
  padding: 14px 20px;
  border: none;
  border-radius: 6px;
  font-size: clamp(14px, 4vw, 16px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  touch-action: manipulation; /* Mejora la respuesta táctil */
  min-height: 44px; /* Tamaño mínimo táctil recomendado */
}

.apply-button {
  background: #4CAF50;
  color: white;
}

.apply-button:hover {
  background: #45a049;
  transform: translateY(-2px);
}

.reset-button {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.reset-button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

/* Estilos para selectores de color */
#color-selector-container {
  max-height: 400px;
  overflow-y: auto;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}

.racer-color-group {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.racer-color-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.racer-color-label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-wrapper {
  display: flex;
  align-items: center;
}

.radio-wrapper input[type="radio"] {
  display: none;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: clamp(11px, 3vw, 13px);
  color: rgba(255, 255, 255, 0.8);
  touch-action: manipulation; /* Mejora la respuesta táctil */
  min-height: 44px; /* Tamaño mínimo táctil recomendado */
}

.radio-label:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.radio-wrapper input[type="radio"]:checked + .radio-label {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
  font-weight: 600;
}

.color-preview {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  display: inline-block;
  flex-shrink: 0;
}
