*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background: #f4f4f4;
  text-align: center;
  margin: 0;
}

header {
  background: #2c3e50;
  color: white;
  padding: 20px;
  position: relative;
}

.header-top-left {
  position: absolute;
  top: 20px;
  left: 20px;
}

.btn-admin {
  background: #3498db;
  color: white;
  padding: 12px 24px;
  text-decoration: none;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: 0.3s;
  display: inline-block;
}

.btn-admin:hover {
  background: #2980b9;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.tickets-remaining {
  margin: 18px 0 8px;
  font-size: 14px;
  color: #2c3e50;
  text-align: left;
}

.admin-panel {
  background: white;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  margin-bottom: 30px;
}

.admin-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin: 24px 0;
}

.admin-card {
  background: #fff;
  border: 1px solid rgba(44, 62, 80, 0.08);
  border-radius: 14px;
  padding: 18px;
  text-align: left;
}

.admin-card h3 {
  margin-top: 0;
  color: #2c3e50;
}

.admin-settings {
  margin-bottom: 24px;
  text-align: left;
}

.admin-settings label {
  display: block;
  margin-bottom: 10px;
  color: #2c3e50;
}

.admin-settings select {
  width: auto;
  min-width: 140px;
  margin-right: 12px;
}

.admin-clear-btn {
  margin-top: 10px;
}


.container {
  width: 90%;
  max-width: 1200px;
  margin: auto;
  margin-top: 30px;
}

@media (max-width: 900px) {
  .container {
    width: 95%;
    margin-top: 20px;
  }
}

/* GRID RESPONSIVE AUTOMÁTICO */

.rifa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
  gap: 8px;
}

.numbers-wrapper {
  max-height: 520px;
  overflow-y: auto;
  padding-right: 8px;
  margin-bottom: 12px;
}

.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.pagination-controls button {
  min-width: 100px;
}

.hidden-page {
  display: none !important;
}

/* NUMEROS */

.numero {
  position: relative;
  height: 52px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: white;
  border: 2px solid #333;
  cursor: not-allowed;
  font-weight: bold;
  font-size: 14px;
}

.numero.locked:hover {
  background: #f0f0f0;
  color: #999;
  cursor: not-allowed;
}

.numero.locked::after {
  content: "🔒";
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 14px;
}

.numero.unlocked {
  cursor: pointer;
}

.numero.unlocked:hover {
  background: #3498db;
  color: white;
}

.numero.vendido {
  background: #ff4d4d;
  color: white;
  transform: scale(1.15);
  cursor: not-allowed;
  transform: scale(1.1);
}

/* BOTÓN JUGAR */

.header-top {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.btn-jugar {
  background: #e74c3c;
  color: white;
  padding: 12px 30px;
  text-decoration: none;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: 0.3s;
  display: inline-block;
}

.btn-jugar:hover {
  background: #c0392b;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

  .btn-ruleta {
    background: #f1c40f;
    color: #2c3e50;
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: 0.3s;
    display: inline-block;
  }

  .btn-ruleta:hover {
    background: #d4ac0d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(241, 196, 15, 0.3);
  }

  .btn-ruleta:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
  }

  .btn-validar {
    background: #2ecc71;
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: 0.3s;
    display: inline-block;
  }

  .btn-validar:hover {
    background: #27ae60;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
  }

  .codigo-status {
    margin-top: 10px;
    font-size: 16px;
    color: #ecf0f1;
    font-weight: 600;
  }

  .codigo-status.exito {
    color: #2ecc71;
  }

  .codigo-status.error {
    color: #e74c3c;
  }

  .resultado-ruleta {
    margin-top: 20px;
    font-size: 20px;
    color: #f39c12;
    font-weight: 700;
  }

  .modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    padding: 20px;
  }

  .modal.hidden {
    display: none;
  }

  .modal-content {
    background: white;
    padding: 30px;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
    max-width: 420px;
    width: 100%;
    text-align: left;
    position: relative;
  }

  .modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #333;
  }

  .modal-number {
    font-size: 34px;
    margin: 16px 0 10px;
    color: #2c3e50;
    font-weight: 800;
  }

  .modal-user {
    margin-bottom: 20px;
  }

  .modal-user p {
    margin: 8px 0;
    color: #444;
  }

  .modal-user strong {
    color: #2c3e50;
  }

  .modal-content .btn-validar {
    width: 100%;
  }

  .numero.ganando {
    box-shadow: 0 0 18px rgba(241, 196, 15, 0.9);
    transform: scale(1.2);
  }

  .numero.winner {
    background: #f1c40f;
    color: #2c3e50;
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.8);
  }

.user-list-section {
  margin-top: 30px;
  text-align: left;
}

.user-list-section h2 {
  margin-bottom: 15px;
  font-size: 24px;
  color: #2c3e50;
}

.usuarios-registrados {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.usuario-card {
  background: white;
  padding: 16px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border: 1px solid #e0e0e0;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}

.usuario-card p {
  margin: 0;
  color: #333;
}

.usuario-meta {
  margin-top: 6px;
  font-size: 13px;
  color: #666;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.usuario-meta span {
  display: inline-flex;
  align-items: center;
}

.user-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 12px;
  color: #27ae60;
  background: rgba(39, 174, 96, 0.12);
  border-radius: 999px;
  font-weight: 700;
}

.user-winner {
  color: #27ae60;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.usuario-card span {
  background: #f1c40f;
  color: #2c3e50;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.lista-vacia {
  margin: 0;
  padding: 20px;
  background: #fff9e6;
  border: 1px solid #ffe8a1;
  border-radius: 12px;
  color: #7d6608;
}

/* ---------- MEDIA QUERIES ---------- */

/* Celulares */
@media (max-width: 600px) {
  header {
    padding: 16px;
  }

  header h1 {
    font-size: 20px;
    margin: 0 0 10px 0;
  }

  .header-top-left {
    position: static;
    margin-bottom: 15px;
  }

  .header-top {
    flex-direction: column;
    gap: 10px;
  }

  .btn-admin,
  .btn-jugar,
  .btn-ruleta,
  .btn-validar {
    width: 100%;
    max-width: 100%;
  }

  #codigo {
    width: 100%;
    max-width: 100%;
  }

  .rifa-grid {
    grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
    gap: 6px;
  }

  .numero {
    height: 48px;
    font-size: 13px;
  }

  .numbers-wrapper {
    max-height: 360px;
  }

  .pagination-controls {
    flex-wrap: wrap;
    gap: 10px;
  }

  .pagination-controls button {
    min-width: 80px;
  }

  .admin-panel,
  .admin-card {
    padding: 16px;
  }

  .admin-cards {
    grid-template-columns: 1fr;
  }

  .admin-settings select {
    width: 100%;
    margin-right: 0;
    margin-bottom: 12px;
  }

  .usuario-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .user-list-section h2 {
    font-size: 20px;
  }
}

/* Tablets */
@media (max-width: 900px) {
  .header-top-left {
    position: static;
    margin-bottom: 15px;
  }

  .header-top {
    flex-direction: column;
    gap: 12px;
  }

  .btn-admin,
  .btn-jugar,
  .btn-ruleta,
  .btn-validar {
    width: 100%;
    max-width: 100%;
  }

  .rifa-grid {
    grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
  }

  .numero {
    height: 52px;
    font-size: 13px;
  }

  .numbers-wrapper {
    max-height: 420px;
  }

  .admin-settings select {
    width: 100%;
    margin-right: 0;
  }

  .admin-cards {
    grid-template-columns: 1fr;
  }

  .usuarios-registrados {
    grid-template-columns: 1fr;
  }
}

/* Pantallas grandes */
@media (min-width: 1400px) {
  .numero {
    height: 70px;
    font-size: 18px;
  }
}
