/* ========= Reset & Base ========= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  width: 100%;
  height: 100%;
  font-family: "Pixelify Sans", sans-serif;
  background: #0d0d0d;
  color: #fff;
  display: flex;
  flex-direction: column;
}

/* ========= HEADER ========= */
.header-bar {
  background: #18181b;
  border-bottom: 2px solid #ffcc00;
  box-shadow: 0 2px 6px #0006;
  padding: 20px 0;
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 28px;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;

  /* -------------- CAMBIO: permitir “flex-wrap” para pantallas más angostas -------------- */
  flex-wrap: wrap;
  justify-content: center;
}
.header-title {
  color: #ffcc00;
  font-size: 2.1rem;
  font-weight: bold;
  letter-spacing: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}
.header-divider {
  display: inline-block;
  width: 4px;
  height: 40px;
  background: #ffcc00;
  border-radius: 6px;
  margin: 0 18px;
}
.hero-subtitle {
  color: #fff;
  font-size: 1.09rem;
  font-family: "Inter", sans-serif;
  font-weight: 500;
  letter-spacing: 0.3px;
  flex: 1;
  min-width: 0;
  text-align: left;
  line-height: 1.3;
  max-width: 600px;
  word-break: break-word;

  /* -------------- CAMBIO: centrar texto en móviles -------------- */
  text-align: center;
}
.pixel-chip-big {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: transparent;
  color: #fff;
  padding: 4px 13px;
  border-radius: 10px;
  font-family: "Inter", sans-serif;
  font-size: 0.94rem;
  min-width: 90px;
  margin-left: 18px;
  font-weight: 600;
  border: 1.2px solid #fff;
  line-height: 1.13;
  gap: 2px;
  opacity: 0.96;
  /* -------------- CAMBIO: en pantallas reducidas centrar bajo el subtitle -------------- */
  margin-top: 12px;
  margin-left: auto;
  margin-right: auto;
}
.chip-available,
.chip-sold {
  color: #fff;
  font-size: 1em;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.chip-sold {
  font-size: 0.78em;
  opacity: 0.53;
  margin-top: -1px;
}
.chip-available strong,
.chip-sold span {
  color: #22c55e;
  font-size: 1em;
  font-weight: 700;
  margin-left: 2px;
}

/* ========= NAV MENU ========= */
.topbar-menu {
  width: 100%;
  height: 24px;
  background: linear-gradient(180deg, #e5be4b 85%, #b89d3a 100%);
  border-bottom: 1.5px solid #ae8707;
  box-shadow: 0 2px 6px #0002;
  position: sticky;
  top: 0;
  left: 0;
  z-index: 99;
  font-size: 0.96em;
  padding: 0;
}
.menu-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  font-family: "Pixelify Sans", "Inter", Arial, sans-serif;
  font-size: 0.98em;
  font-weight: 600;
  padding: 0 7px;
  overflow-x: auto;

  /* -------------- CAMBIO: permitir que el menú “wrappee” si es necesario -------------- */
  flex-wrap: wrap;
}
.menu-link {
  color: #111;
  text-decoration: none;
  margin: 0 4px;
  font-size: 0.99em;
  transition: color 0.15s;
  padding: 0 2px;
}
.menu-link:hover {
  color: #ffd700;
  text-shadow: 0 1px 2px #fff7;
}
.divider {
  display: inline-block;
  margin: 0 6px;
  color: #32290a;
  font-size: 1.11em;
  opacity: 0.45;
  font-family: "Inter", Arial, sans-serif;
}

/* ========= MAIN & CANVAS ========= */
main {
  flex: 1;
  padding: 16px;
  text-align: center;
}
#pixelCanvas {
  width: 100%;
  max-width: 1300px;
  height: auto;
  aspect-ratio: 1 / 1;
  margin: 0 auto 24px auto;
  display: block;
  background: #111;
  image-rendering: pixelated;
  border-radius: 8px;
  box-shadow: 0 0 14px #0007;
}

/* ========= BUTTONS & COUNTERS ========= */
.selection-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-bottom: 18px;
  margin-top: 6px;

  /* -------------- CAMBIO: permitir wrap en pantallas estrechas -------------- */
  flex-wrap: wrap;
}
.btn-base {
  /* -------------- CAMBIO: quitar min-width fijo para que se reduzca correctamente -------------- */
  min-width: unset;
  min-height: 46px;
  padding: 0 20px;
  font-size: 1.05rem;
  font-family: "Inter", sans-serif;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.18s, box-shadow 0.18s, color 0.16s;
  box-shadow: 0 0 12px #0002;
  display: flex;
  align-items: center;
  justify-content: center;
}
.clear-btn {
  background: transparent;
  color: #ff4747;
  border: 1.7px solid #ff4747;
  box-shadow: none;
}
.clear-btn:hover {
  background: #ff474715;
  color: #fff;
}
.clear-btn-small {
  background: transparent;
  color: #ff4747;
  border: 1.5px solid #ff4747;
  font-size: 0.87rem;
  padding: 4px 8px;
  margin-top: 6px;
}
.clear-btn-small:hover {
  background: #ff474715;
  color: #fff;
}
.pay-btn {
  background: #22c55e;
  color: #18181b;
  box-shadow: 0 0 10px #22c55e99;
  border: none;
}
.pay-btn:hover {
  background: #199947;
  color: #fff;
}
.counter-box {
  font-family: "Inter", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  background: #ffcc00;
  color: #000;
  padding: 6px 18px;
  border-radius: 6px;
  box-shadow: 0 0 5px #ffcc00b0;
}

/* Mensajes de error / advertencia */
.adjacent-msg {
  color: #ffcc00;
  background: #23221a;
  font-size: 0.93rem;
  font-family: "Inter", sans-serif;
  font-weight: 500;
  border-radius: 8px;
  padding: 4px 14px;
  margin: 0 auto 14px auto;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 0 4px #0003;
  letter-spacing: 0.03em;
}
.fade-hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
.fade-visible {
  opacity: 1;
  visibility: visible;
}
.fade-transition {
  transition: opacity 0.3s ease-in-out;
}

/* ========= MODAL BASE ========= */
/* ========= MODAL (VERSIÓN ORIGINAL EN DESKTOP) ========= */
.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #18181b;
  border-radius: 14px;
  padding: 32px 22px 22px 22px;
  box-shadow: 0 14px 50px #000c;
  min-width: 380px;
  min-height: 350px;
  z-index: 1001;
  max-width: 94vw;
  max-height: 94vh;
  overflow: auto;
}
.modal-dragbar {
  width: 100%;
  height: 24px;
  background: #ffd70033;
  cursor: grab;
  margin: -32px -22px 12px -22px;
  border-radius: 14px 14px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffd700;
  font-size: 1rem;
  font-family: "Pixelify Sans", sans-serif;
  font-weight: bold;
  letter-spacing: 2px;
  user-select: none;
}
/* Estilo para el enlace del nombre en el footer */
.footer-name-link {
  color: inherit; /* Mantiene el color del texto del footer */
  text-decoration: underline; /* Subraya el texto */
}
.footer-name-link:hover {
  color: #ffcc00; /* Cambia a color amarillo al pasar el mouse, opcional */
}
.modal-close-x {
  position: absolute;
  top: calc(8px - 0.6rem);
  right: 12px;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}
.modal-close-x:hover {
  background: #ff474715;
}

/* ========= MINI‐GRILLA (selectedBlocksGrid) ========= */
.selected-blocks-grid {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
  justify-items: center;

  /* -------------- CAMBIO: si el contenedor es muy estrecho, reducir la mini‐grilla -------------- */
  grid-auto-rows: 1fr;
  grid-auto-columns: 1fr;
}
.selected-block {
  width: 34px;
  height: 34px;
  background: transparent;
  border: 2px solid #fff;
  border-radius: 5px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}
.selected-block.empty {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  pointer-events: none;
}
.selected-block.selected {
  border: 3.5px solid #ff4747;
  z-index: 2;
}
.selected-block .mini-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 3px;
  position: absolute;
  top: 0;
  left: 0;
}

/* ========= DROPZONE ========= */
.dropzone {
  border: 2px dashed #ffcc00;
  background: #18181b;
  color: #ffcc00;
  padding: 24px;
  margin: 0 auto 12px auto;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: background 0.18s;
}
.dropzone.dragover {
  background: #ffd70033;
}

/* ========= DRAW AREA ========= */
.draw-area {
  text-align: center;
  margin-bottom: 12px;
}
.draw-area-label {
  font-family: "Inter", sans-serif;
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: #fff;
}
.color-picker-intro {
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: #ffd700;
  text-align: center;
}
.color-picker-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 10px;
  margin-top: 3px;
}
.color-pick {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: 2px solid #fff;
  cursor: pointer;
  outline: none;
  transition: border 0.1s;
}
.color-pick.selected {
  border: 3px solid #222;
}

/* Contenedor para el input de color personalizado */
.custom-color-input-wrapper {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 28px;
}
.custom-color-input-wrapper::after {
  content: "\270E"; /* Carácter Unicode para lápiz */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  color: #ffd700;
  pointer-events: none;
  z-index: 1;
}
.custom-color-input {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  /* -------------- CAMBIO: en pantallas muy pequeñas, reducir el tamaño -------------- */
  max-width: 28px;
  max-height: 28px;
}

/* Canvas de dibujo 10×10 */
.draw-canvas {
  background: #222;
  border: 2px solid #ffcc00;
  border-radius: 6px;
  cursor: crosshair;
  margin-bottom: 6px;
  /* -------------- CAMBIO: tamaño más pequeño en móviles -------------- */
  width: 100%;
  max-width: 200px;
  height: auto;
  aspect-ratio: 1 / 1;
}
/* Botón 'Clear Drawing' */
.draw-clear-btn {
  margin-top: 6px;
  margin-left: auto;
  margin-right: auto;
  font-size: 0.87rem;
}

/* ========= INPUTS Link / Title ========= */
.inputs-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;

  /* -------------- CAMBIO: anchura completa en pantallas reducidas -------------- */
  width: 100%;
  max-width: 320px;
  margin: 0 auto 14px auto;
}
.input-label {
  display: flex;
  flex-direction: column;
  font-family: "Inter", sans-serif;
  font-weight: 500;
  font-size: 0.95rem;
  color: #fff;
}
.input-label input {
  margin-top: 4px;
  padding: 6px 8px;
  font-size: 0.94rem;
  border-radius: 4px;
  border: 1.2px solid #555;
  background: #222;
  color: #fff;
  resize: vertical;
}

/* ========= TOOLTIPS (Título) ========= */
.title-tooltip {
  position: absolute;
  background: #ffffff; /* Fondo blanco */
  color: #000000; /* Letras negras */
  padding: 6px 10px;
  border-radius: 5px;
  border: 1.5px solid #ff4747; /* Borde rojo */
  font-size: 0.9rem;
  font-family: "Inter", sans-serif;
  font-weight: 600; /* Un poco más de peso para el título */
  max-width: 220px;
  z-index: 2001; /* Por encima de otros elementos */
  pointer-events: none;
  display: none;
}

/* ========= MENSAJE DE VALIDACIÓN EN EL MODAL ========= */
.modal-footer {
  margin-top: 16px;
}
.purchase-validation-msg {
  color: #ffcc00;
  background: #23221a;
  font-size: 0.9rem;
  font-family: "Inter", sans-serif;
  font-weight: 500;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  text-align: center;
  box-shadow: 0 0 4px #0003;
}

/* ========= BOTONES AL FINAL DEL MODAL ========= */
.modal-footer-buttons {
  display: flex;
  justify-content: center; /* Centrar los botones */
  gap: 12px;
  flex-wrap: wrap; /* -------------- CAMBIO: permitir que se “rompa” en móviles  -------------- */
}
.modal-footer-buttons .btn-base {
  min-width: unset; /* -------------- CAMBIO: quitar restricción estricta de ancho  -------------- */
  margin-bottom: 8px;
}
.modal-footer-buttons .pay-btn {
  background: #22c55e;
  color: #18181b;
}
.modal-footer-buttons .clear-btn {
  background: transparent;
  color: #ff4747;
  border: 1.7px solid #ff4747;
}
.modal-footer-buttons .clear-btn:hover {
  background: #ff474715;
  color: #fff;
}

/* Botones deshabilitados */
.btn-base:disabled {
  background-color: #555 !important;
  color: #999 !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
}

/* Hover/Focus en botones de color */
.color-pick:hover,
.color-pick:focus {
  border-color: #ffd700;
}

/* ========= FOOTER ========= */
.footer-legal {
  width: 100%;
  text-align: center;
  color: #aaa;
  font-size: 0.74rem;
  font-family: "Inter", sans-serif;
  padding: 18px 8px 12px 8px;
  letter-spacing: 0.03em;
  background: transparent;
  margin-top: 20px;
  line-height: 1.6;
  user-select: none;
}

/* ========= MEDIA QUERIES ========= */
@media (max-width: 900px) {
  .header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 0 12px;
  }
  .header-title {
    font-size: 1.3rem;
    text-align: center;
  }
  .header-divider {
    display: none;
  }
  .hero-subtitle {
    font-size: 1.01rem;
    max-width: 100%;
    margin-bottom: 4px;
    text-align: center; /* ya estaba */
  }
  .pixel-chip-big {
    align-self: center;
    margin-left: 0;
    margin-top: 7px;
    min-width: unset;
    padding: 4px 11px;
    border-radius: 8px;
    font-size: 0.94rem;
  }
  .selection-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 10px;
  }
  .btn-base,
  .counter-box,
  #payButton,
  #clearButton {
    width: 100%;
    font-size: 0.96rem;
  }
  .selected-block {
    width: 28px;
    height: 28px;
  }
  #drawCanvas {
    width: 90px;
    height: 90px;
  }
  .modal {
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    top: 0;
    left: 0;
    transform: none;
    border-radius: 0;
    padding: 20px;
    min-width: 0;
    min-height: 0;
    box-shadow: none;
  }
  .modal-dragbar {
    margin: -20px -20px 12px -20px;
  }
  .color-picker-bar {
    flex-wrap: wrap;
    gap: 6px;
  }
  .color-pick {
    width: 20px;
    height: 20px;
  }
}
@media (max-width: 600px) {
  .header-bar {
    padding: 12px 0;
  }
  .header-row {
    gap: 8px;
    padding: 0 5px;
  }
  .header-title {
    font-size: 1.05rem;
    letter-spacing: 1px;
    text-align: center;
  }
  .hero-subtitle {
    font-size: 0.99rem;
    padding: 0 0 4px 0;
    text-align: center;
  }
  .pixel-chip-big {
    font-size: 0.91rem;
    padding: 3px 8px;
    border-radius: 7px;
    margin-top: 5px;
  }
  .selected-block {
    width: 24px;
    height: 24px;
  }
  #drawCanvas {
    width: 72px;
    height: 72px;
  }
  .modal {
    padding: 15px;
  }
  .modal-dragbar {
    margin: -15px -15px 12px -15px;
  }
  .inputs-area {
    max-width: 100%;
    padding: 0 12px;
  }
}
#modalOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1000;
  display: none;
}
#checkoutModal.fade-visible {
  z-index: 1010;
}
.content-policy-warning {
  font-size: 0.85em;
  color: #6c757d; /* A neutral, secondary text color */
  text-align: center;
  margin-top: 8px; /* Adds some space if the validation message above is visible */
  margin-bottom: 15px; /* Provides good spacing before the buttons */
  padding: 0 15px; /* Horizontal padding for better text flow if it wraps */
  line-height: 1.4; /* Improves readability for multi-line text */
}

#selectionBar {
  display: none !important;
}
