* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  background: #f3f4f6;
}

.container {
  max-width: 900px;
  margin: 30px auto;
  background: #ffffff;
  padding: 20px;
  border-radius: 14px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
}

h1, h2, h3 {
  margin-top: 0;
}

form {
  margin-bottom: 16px;
}

input, select, button {
  font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"] {
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  margin-bottom: 8px;
}

input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

.btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  margin-right: 6px;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
}

.btn-secondary {
  background: #e5e7eb;
  color: #111827;
}

.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.alert {
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 14px;
}

.alert-info {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.alert-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th, .table td {
  border: 1px solid #e5e7eb;
  padding: 6px 8px;
}

.table th {
  background: #f9fafb;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  background: #e5e7eb;
  color: #374151;
}

/* Cajas del sorteo mejoradas */
.boxes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.box-button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.box-button.disabled {
  cursor: default;
}

.box {
  position: relative;
  width: 100%;
  min-height: 90px;
  border-radius: 14px;
  perspective: 600px;
}

.box-inner {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Parte inferior de la caja */
.box-base {
  background: linear-gradient(145deg, #1d4ed8, #2563eb);
  border-radius: 12px;
  padding: 16px 8px 14px;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.3);
  text-align: center;
  color: #fff;
  position: relative;
  overflow: hidden;
}

/* Tapa de la caja */
.box-lid {
  position: absolute;
  top: -2px;
  left: 6px;
  right: 6px;
  height: 18px;
  background: linear-gradient(145deg, #1e40af, #1d4ed8);
  border-radius: 12px 12px 6px 6px;
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.4);
  transform-origin: left bottom;
  transition: transform 0.4s ease, translateY 0.4s ease;
}

/* Cinta */
.box-ribbon {
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: calc(100% + 18px);
  background: rgba(248, 250, 252, 0.8);
}

/* Animación tapa abierta */
.box.opened .box-lid {
  transform: rotate(-55deg) translateY(-6px);
}

/* Contenido de la caja */
.box-label {
  font-size: 12px;
  opacity: 0.85;
}

.box-number {
  font-size: 16px;
  font-weight: 700;
  margin-top: 4px;
}

.box-state {
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.9;
}

/* Nombre del amigo secreto */
.box-content {
  position: absolute;
  bottom: 8px;
  left: 4px;
  right: 4px;
  padding: 6px 4px;
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.94);
  color: #1f2937;
  font-size: 12px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.box.opened .box-content {
  opacity: 1;
  transform: translateY(0);
}

/* Cajas usadas por otros: grises */
.box.used .box-base {
  background: #d1d5db;
  color: #4b5563;
  box-shadow: none;
}

.box.used .box-lid {
  background: #9ca3af;
  box-shadow: none;
}

/* Hover sólo si es clickable */
.box-button.clickable .box-base:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.35);
}

/* Utilidad */
.hidden { display: none !important; }

/* MODAL DE BIENVENIDA */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  width: 90%;
  max-width: 420px;
  background: #ffffff;
  border-radius: 14px;
  padding: 20px 18px 18px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.45);
}
.modal h2 {
  margin-top: 0;
  margin-bottom: 6px;
}
.modal p {
  font-size: 13px;
  color: #4b5563;
  margin-top: 0;
  margin-bottom: 10px;
}

/* GRID DE CAJAS EN FILAS 3-2-3-2... */
.boxes-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.boxes-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: nowrap;
}
.box-button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
.box-button.disabled {
  cursor: default;
}

/* CAJA CON IMAGENES (cerrada/abierta) */
.box {
  position: relative;
  width: 110px;
  height: 110px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}
.box-image {
  width: 100%;
  height: 80px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  transition: transform 0.35s ease;
  background-image: url("../assets/box-closed.png"); /* cerrada por defecto */
}

.box.open .box-image {
  background-image: url("../assets/box-open.png");
  transform: translateY(-4px) scale(1.05);
}

/* Caja ya usada por alguien → siempre abierta y bloqueada, sin gris */
.box.used .box-image {
  background-image: url("../assets/box-open.png");
  filter: none;
  opacity: 1;
}

.box-label {
  font-size: 11px;
  color: #4b5563;
}
.box-state {
  font-size: 11px;
  color: #6b7280;
}

/* OVERLAY GRANDE DEL NOMBRE (10s) */
.friend-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.friend-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.friend-card {
  background: #ffffff;
  padding: 26px 24px;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.6);
}
.friend-card h2 {
  margin: 0 0 8px;
}
.friend-name {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
}
.friend-sub {
  font-size: 13px;
  color: #4b5563;
}














/* Centrado general */
body {
  margin: 0;
  background: #f3f4f6;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.container {
  max-width: 900px;
  margin: 30px auto;
  background: #ffffff;
  padding: 20px;
  border-radius: 14px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
  text-align: center;
}

/* Botones: centrados por defecto */
.btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  margin: 6px 4px;
}

/* Tarjeta del participante */
.participant-card {
  margin: 16px auto 12px;
  max-width: 260px;
  padding: 12px 16px;
  border-radius: 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.participant-photo,
.friend-photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #e5e7eb;
  background: #ffffff;
}

.participant-photo img,
.friend-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


.participant-name-main {
  font-weight: 700;
  font-size: 1rem;
}

.participant-id {
  font-size: 13px;
  color: #6b7280;
}

/* GRID CAJAS (ya centrado) */
.boxes-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.boxes-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* Imágenes de cajas */
.box-image {
  width: 100%;
  height: 80px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  transition: transform 0.35s ease;
  background-image: url("../assets/box-closed.png"); /* cerrada */
}

.box.open .box-image {
  background-image: url("../assets/box-open.png");    /* abierta animación */
  transform: translateY(-4px) scale(1.05);
}

/* Caja usada: abierta y bloqueada (sin gris) */
.box.used .box-image {
  background-image: url("../assets/box-open.png");
  filter: none;
  opacity: 1;
}

/* OVERLAY DEL AMIGO SECRETO */
.friend-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.friend-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.friend-card {
  position: relative;
  background: #ffffff;
  padding: 24px 24px 20px;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.6);
}
.friend-card h2 {
  margin: 0 0 8px;
}
.friend-name {
  font-size: 22px;
  font-weight: 700;
  margin-top: 6px;
}
.friend-sub {
  font-size: 13px;
  color: #4b5563;
  margin-top: 8px;
}

/* Botón cerrar (X) del overlay */
.friend-close-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: #4b5563;
}
.friend-close-btn:hover {
  color: #111827;
}

/* Layout foto amigo + mensajes */
.chat-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  text-align: left;
}

.chat-panel {
  flex: 1;
  max-width: 420px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* Lista de mensajes */
.chat-messages {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 8px 10px;
  background: #f9fafb;
  max-height: 220px;
  overflow-y: auto;
  font-size: 13px;
}

.chat-message {
  margin-bottom: 6px;
}

.chat-message .meta {
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 2px;
}

.chat-message .bubble {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 14px;
  max-width: 100%;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Tus mensajes a la derecha, los del amigo a la izquierda */
.chat-message.me {
  text-align: right;
}

.chat-message.me .bubble {
  background: #2563eb;
  color: #ffffff;
  margin-left: auto;
}

.chat-message.friend .bubble {
  background: #e5e7eb;
  color: #111827;
  margin-right: auto;
}

/* Form de envío */
.chat-input {
  margin-top: 8px;
}

.chat-input textarea {
  width: 100%;
  min-height: 60px;
  max-height: 120px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  resize: vertical;
  font-size: 13px;
}

.chat-input button {
  margin-top: 6px;
}



/* ========== RESPONSIVE GENERAL ========== */
@media (max-width: 768px) {

  .container {
    width: 95%;
    padding: 12px;
    margin: 10px auto;
  }

  h1, h2, h3 {
    font-size: 1.2rem;
    text-align: center;
  }

  .participant-card,
  .chat-panel,
  .friend-card {
    max-width: 100%;
  }

  /* Foto circular ajustada en móviles */
  .participant-photo,
  .friend-photo {
    width: 90px;
    height: 90px;
    border-width: 2px;
  }

  /* Layout de chat → vertical */
  .chat-row {
    flex-direction: column;
    align-items: center;
  }

  .chat-panel {
    width: 100%;
    max-width: 100%;
  }

  /* Contenedor de mensajes */
  .chat-messages {
    max-height: 160px;
    font-size: 12px;
  }

  /* Grid responsivo de cajas */
  .boxes-row {
    flex-wrap: wrap;
    justify-content: center;
  }

  .box-button {
    flex: 1 1 calc(45% - 10px);
    max-width: 45%;
  }

  .box-image {
    height: 70px;
  }

  /* Overlay amigo secreto */
  .friend-card {
    width: 90%;
    padding: 16px;
  }

  .friend-name {
    font-size: 18px;
  }

  /* Botón “Salir” */
  .btn {
    width: 100%;
    max-width: 250px;
    margin: 6px auto;
    display: block;
    text-align: center;
  }
}

/* ========== TAMAÑO EXTRA PEQUEÑO ========== */
@media (max-width: 480px) {

  .participant-photo,
  .friend-photo {
    width: 70px;
    height: 70px;
  }

  .box-button {
    flex: 1 1 calc(48% - 6px);
    max-width: 48%;
  }

  .box-image {
    height: 60px;
  }

  .friend-card h2 {
    font-size: 1rem;
  }

  .friend-name {
    font-size: 16px;
  }
}