:root {
  --bg-main: #09090a;
  --bg-card: #111114;
  --bg-elevated: #17171c;
  --bg-hover: #1d1d23;
  --border: #2a2a31;
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --accent: #d4af37;
  --accent-strong: #f1c75b;
  --accent-soft: rgba(212, 175, 55, 0.12);
  --danger: #ef4444;
  --success: #10b981;
  --stripe: #635bff;
  --paypal: #ffc439;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(212, 175, 55, 0.08), transparent 35%),
    var(--bg-main);
  color: var(--text-main);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.page {
  max-width: 1150px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
}

.header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.header-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: center;
}

.shop-title {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
}

.server-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.ip-address {
  color: var(--accent);
}

.port {
  color: var(--text-muted);
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  max-width: 52ch;
  font-size: 0.95rem;
}

.icon-btn,
.btn,
.cart-item-remove,
.modal-close,
.dev-btn {
  -webkit-tap-highlight-color: transparent;
}

.icon-btn {
  position: relative;
  width: 2.85rem;
  height: 2.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(212, 175, 55, 0.35);
  background: rgba(255, 255, 255, 0.05);
}

.cart-badge {
  position: absolute;
  top: -0.3rem;
  right: -0.3rem;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: #fff;
  border: 2px solid var(--bg-main);
  font-size: 0.68rem;
  font-weight: 700;
}

.products-wrap {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.category-block {
  padding-top: 0.25rem;
}

.category-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.category-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.category-count {
  color: var(--text-muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.product-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 24%), var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1.05rem;
  padding: 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 225px;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.product-card:hover {
  transform: translateY(-3px);
  border-color: rgba(212, 175, 55, 0.4);
  background: linear-gradient(180deg, rgba(212,175,55,0.05), transparent 24%), var(--bg-card);
}

.product-head {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: center;
}

.product-price {
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 1rem;
}

.category-pill {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(212, 175, 55, 0.22);
  padding: 0.32rem 0.55rem;
  border-radius: 999px;
}

.product-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.product-description {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.55;
  flex: 1;
}

.card-actions,
.product-actions,
.cart-actions,
.payment-methods {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.card-actions {
  margin-top: auto;
}

.btn {
  min-height: 2.8rem;
  border: 1px solid transparent;
  border-radius: 0.9rem;
  padding: 0.74rem 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
  text-decoration: none;
  flex: 1 1 0;
  font-size: 0.95rem;
  max-width: 100%;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn-full {
  width: 100%;
  flex: 1 1 100%;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: #101010;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #f7d56f, var(--accent-strong));
}

.btn-cart {
  background: rgba(212, 175, 55, 0.12);
  color: var(--accent-strong);
  border-color: rgba(212, 175, 55, 0.42);
}

.btn-cart:hover {
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.6);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-stripe {
  background: var(--stripe);
  color: #fff;
}

.btn-paypal {
  background: var(--paypal);
  color: #101010;
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.28);
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.08);
}

/* MODALES SIEMPRE CENTRADOS */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(9px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  border-radius: 1.25rem;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent 18%),
    var(--bg-card);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
  animation: sheetUp 0.28s ease-out both;
}

.modal-card.drawer {
  width: min(100%, 760px);
}

.modal-content {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(100vh - 2rem);
}

.modal-close {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  border: none;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.modal-close:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.07);
}

.modal-kicker {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.5rem;
}

.modal-title {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  line-height: 1.15;
}

.modal-description {
  margin: 0 0 1rem;
  color: var(--text-muted);
  line-height: 1.65;
  font-size: 0.95rem;
}

.buy-summary {
  margin: 1rem 0 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.02);
}

.summary-price {
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 1.05rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.95rem;
}

.field span {
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 600;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper i {
  position: absolute;
  left: 0.9rem;
  color: var(--text-muted);
  font-size: 0.98rem;
}

.input-wrapper input {
  width: 100%;
  min-height: 2.85rem;
  border-radius: 0.85rem;
  border: 1px solid var(--border);
  background: #08080a;
  color: var(--text-main);
  padding: 0.8rem 0.95rem 0.8rem 2.65rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-wrapper input:focus {
  border-color: rgba(212, 175, 55, 0.55);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12);
}

.payment-methods {
  margin-top: 1rem;
}

.cart-items-container {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  padding: 0.9rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 1rem;
}

.cart-item-info {
  min-width: 0;
  flex: 1;
}

.cart-item-name {
  font-weight: 700;
  margin-bottom: 0.28rem;
  font-size: 0.95rem;
}

.cart-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.cart-item-price {
  color: var(--accent-strong);
  font-weight: 700;
}

.cart-item-remove {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.8rem;
  border: 1px solid rgba(239, 68, 68, 0.28);
  background: rgba(239, 68, 68, 0.07);
  color: #ff8b8b;
  cursor: pointer;
}

.empty-state {
  width: 100%;
  padding: 2rem 1rem;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 1.15rem;
  text-align: center;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.015);
}

.empty-state i {
  display: block;
  font-size: 1.8rem;
  margin-bottom: 0.55rem;
  color: var(--accent);
}

.footer {
  margin-top: 3.5rem;
  padding-top: 1.8rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.8rem 1.1rem;
  margin-bottom: 0.95rem;
}

.footer-links a,
.dev-btn {
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.88rem;
  padding: 0;
}

.footer-links a:hover,
.dev-btn:hover {
  color: var(--accent);
}

.copyright,
.disclaimer {
  margin: 0.22rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.loader-layer {
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loader-card {
  position: relative;
  z-index: 1;
  width: min(100%, 340px);
  padding: 1.35rem;
  border-radius: 1.2rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-align: center;
  box-shadow: var(--shadow);
}

.loader-icon {
  font-size: 2.35rem;
  color: var(--accent);
}

.dev-drawer {
  width: min(100%, 620px);
}

.dev-profile {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  padding: 0.95rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  margin-bottom: 0.95rem;
}

.dev-avatar {
  width: 3rem;
  height: 3rem;
  flex: 0 0 auto;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  background: rgba(212, 175, 55, 0.12);
  color: var(--accent-strong);
  font-size: 1.15rem;
  border: 1px solid rgba(212, 175, 55, 0.2);
}

.dev-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.dev-meta strong {
  font-size: 0.98rem;
}

.dev-meta span {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.dev-info-box {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.dev-link,
.dev-note {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 0.95rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.dev-link {
  text-decoration: none;
  color: var(--text-main);
}

.dev-link i {
  color: var(--accent);
  font-size: 1.05rem;
}

.dev-note {
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 0.92rem;
}

.toast {
  min-width: 220px;
  max-width: min(92vw, 360px);
  padding: 0.9rem 0.95rem;
  border-radius: 0.95rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease-out both;
  font-size: 0.9rem;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.3);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.35);
}

.toast.fade-out {
  opacity: 0;
  transition: opacity 0.25s ease;
}

#toast-container {
  position: fixed;
  right: 0.9rem;
  bottom: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  z-index: 200;
}

.doc-page {
  background:
    radial-gradient(circle at top, rgba(212, 175, 55, 0.08), transparent 35%),
    var(--bg-main);
}

.doc-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.15rem;
}

.doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.doc-back {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--text-main);
  padding: 0.7rem 0.95rem;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.doc-back:hover {
  border-color: rgba(212, 175, 55, 0.35);
  background: rgba(255, 255, 255, 0.05);
}

.doc-brand {
  color: var(--text-muted);
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
}

.doc-card {
  padding: 1.3rem;
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  background: var(--bg-card);
  box-shadow: var(--shadow);
}

.doc-kicker {
  margin: 0 0 0.45rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.doc-title {
  margin: 0 0 0.85rem;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  line-height: 1.1;
}

.doc-meta {
  margin: 0 0 1.1rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.doc-section + .doc-section {
  margin-top: 1.15rem;
}

.doc-section h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.doc-section p,
.doc-section li {
  color: var(--text-muted);
  line-height: 1.7;
  font-size: 0.95rem;
}

.doc-section ul {
  margin: 0.45rem 0 0;
  padding-left: 1.1rem;
}

@keyframes sheetUp {
  from {
    transform: translateY(26px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes toastIn {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================== */
/* RESPONSIVE: Unificado y sin drawer en móvil */
/* =========================================== */

@media (max-width: 820px) {
  .page,
  .doc-shell {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .header {
    margin-bottom: 1.8rem;
  }

  .category-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  /* Cards en columna */
  .products-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Botones: apilados verticalmente y con tamaño reducido */
  .card-actions,
  .product-actions,
  .cart-actions,
  .payment-methods {
    flex-direction: column;
    gap: 0.65rem;
  }

  .btn {
    width: 100%;
    min-height: 2.6rem;
    padding: 0.65rem 0.9rem;
    font-size: 0.9rem;
  }

  .server-status {
    flex-direction: column;
    gap: 0.3rem;
  }

  /* Modales: siempre centrados (sin drawer) */
  .modal {
    padding: 0.5rem;
  }

  .modal-card,
  .modal-card.drawer {
    width: calc(100% - 1rem);
    max-width: 560px;
    border-radius: 1.25rem;
  }

  .modal-content {
    padding: 1.2rem;
    max-height: calc(100vh - 2rem);
  }

  .modal-close {
    top: 0.7rem;
    right: 0.7rem;
  }

  .buy-summary {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .dev-profile {
    align-items: flex-start;
  }

  .footer-links {
    gap: 0.7rem 0.9rem;
  }

  .doc-header {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 640px) {
  .page {
    padding-top: 1.2rem;
  }

  .header {
    margin-bottom: 1.5rem;
  }

  .shop-title {
    font-size: clamp(1.8rem, 8vw, 2.3rem);
  }

  .subtitle {
    max-width: 30ch;
    font-size: 0.88rem;
  }

  .icon-btn {
    width: 2.5rem;
    height: 2.5rem;
  }

  .btn {
    min-height: 2.4rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
    gap: 0.4rem;
  }

  .modal-content {
    padding: 1rem;
  }

  .modal-title {
    font-size: 1.1rem;
  }

  .modal-description {
    font-size: 0.88rem;
  }

  .buy-summary,
  .cart-item,
  .dev-profile,
  .dev-link,
  .dev-note {
    padding: 0.75rem;
  }

  .input-wrapper input {
    min-height: 2.5rem;
    padding-left: 2.5rem;
  }
}

@media (max-width: 480px) {
  .page {
    padding: 1rem 0.8rem 2rem;
  }

  .shop-title {
    letter-spacing: 0.08em;
  }

  .subtitle {
    font-size: 0.85rem;
  }

  .product-card {
    padding: 0.85rem;
  }

  .product-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .product-price {
    font-size: 0.95rem;
  }

  .category-pill {
    font-size: 0.68rem;
  }

  .product-description {
    font-size: 0.85rem;
  }

  .btn {
    min-height: 2.3rem;
    padding: 0.5rem 0.7rem;
    font-size: 0.82rem;
  }

  .icon-btn {
    width: 2.4rem;
    height: 2.4rem;
  }

  .modal-title {
    font-size: 1rem;
  }

  .input-wrapper input {
    min-height: 2.4rem;
    padding: 0.6rem 0.8rem 0.6rem 2.3rem;
  }

  .input-wrapper i {
    left: 0.7rem;
    font-size: 0.9rem;
  }

  .cart-item-remove,
  .modal-close {
    width: 2rem;
    height: 2rem;
  }
}

@media (max-width: 400px) {
  .btn {
    font-size: 0.78rem;
    padding: 0.45rem 0.6rem;
  }

  .modal-content {
    padding: 0.8rem;
  }
}

/* ===== Último comprador ===== */
.last-buyer-section {
  margin: 0 0 1.5rem;
}

.last-buyer-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), transparent 24%),
    var(--bg-card);
  box-shadow: var(--shadow);
}

.last-buyer-avatar {
  position: relative;
  width: 4.1rem;
  height: 4.1rem;
  flex: 0 0 auto;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid rgba(212, 175, 55, 0.22);
  background: rgba(212, 175, 55, 0.08);
  display: grid;
  place-items: center;
}

.last-buyer-skin {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  display: block;
}

.last-buyer-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--accent-strong);
  font-size: 1.7rem;
  background: radial-gradient(circle at top, rgba(212,175,55,0.16), transparent 70%);
}

.last-buyer-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.last-buyer-kicker {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.last-buyer-name {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
}

.last-buyer-detail {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

/* ===== responsive ===== */
@media (max-width: 640px) {
  .last-buyer-card {
    padding: 0.85rem;
    gap: 0.85rem;
  }

  .last-buyer-avatar {
    width: 3.6rem;
    height: 3.6rem;
  }

  .last-buyer-name {
    font-size: 0.95rem;
  }

  .last-buyer-detail {
    font-size: 0.84rem;
  }
}