:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --muted: #767671;
  --line: #e5e4e0;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --danger: #d1453b;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

.dev-banner {
  background: #fff4e0;
  color: #7a4e00;
  text-align: center;
  font-size: 13px;
  padding: 10px 16px;
  border-bottom: 1px solid #f0d9a8;
}

header.hero {
  text-align: center;
  margin-bottom: 40px;
}

header.hero h1 {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}

header.hero p {
  color: var(--muted);
  font-size: 16px;
  max-width: 560px;
  margin: 0 auto 20px;
  line-height: 1.5;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.stat {
  text-align: center;
}

.stat .num {
  font-size: 22px;
  font-weight: 700;
}

.stat .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.canvas-frame {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.grid {
  display: grid;
  grid-template-columns: repeat(40, 1fr);
  gap: 2px;
  background: var(--line);
  border-radius: 8px;
  /* visible (not hidden) so hovered cells can pop out above their neighbours */
  overflow: visible;
}

.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--surface);
  cursor: pointer;
  background-size: cover;
  background-position: center;
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.18s ease, filter 0.18s ease;
}

.cell.empty:hover {
  background: #f0eeea;
  transform: scale(1.15);
  z-index: 2;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}

.cell.sold {
  cursor: pointer;
}

.cell.sold:hover,
.cell.sold:focus-visible {
  transform: scale(1.9);
  z-index: 3;
  box-shadow: 0 10px 28px rgba(0,0,0,0.22);
  outline: none;
}

.cell.reserved {
  cursor: not-allowed;
  background: repeating-linear-gradient(45deg, #f0d9a8, #f0d9a8 3px, #fff4e0 3px, #fff4e0 6px);
}

.legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
}

.legend span { display: inline-flex; align-items: center; gap: 8px; }

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.swatch.empty { background: #fff; border: 1px solid var(--line); }
.swatch.sold { background: linear-gradient(135deg, var(--accent), #8fb3ff); }
.swatch.reserved {
  background: repeating-linear-gradient(45deg, #f0d9a8, #f0d9a8 4px, #fff4e0 4px, #fff4e0 8px);
  border: 1px solid #e0bd77;
}

footer {
  text-align: center;
  margin-top: 56px;
  color: var(--muted);
  font-size: 13px;
}

/* ---- Modal ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 18, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.overlay .modal,
.overlay .lightbox {
  transform: scale(0.94) translateY(6px);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.overlay.open .modal,
.overlay.open .lightbox {
  transform: scale(1) translateY(0);
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.modal h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.modal .sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 20px;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="url"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
}

.field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.15s;
}

.dropzone.has-image { padding: 0; overflow: hidden; border-style: solid; }
.dropzone.has-image img { width: 100%; display: block; max-height: 160px; object-fit: cover; }
.dropzone:hover { border-color: var(--accent); }

.price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  margin-top: 6px;
  margin-bottom: 18px;
  font-size: 14px;
}

.price-row .amount { font-size: 20px; font-weight: 700; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 16px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
  text-decoration: none;
  box-sizing: border-box;
}

.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); }

.reserved-notice {
  text-align: center;
  padding-top: 6px;
}

.reserved-notice-icon { font-size: 28px; margin-bottom: 8px; }

.reserved-notice p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 16px;
}

.reserved-notice p strong { color: var(--ink); }

.close-x {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body { position: relative; }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin: -6px 0 14px;
  display: none;
}

.error-msg.show { display: block; }

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff4e0;
  color: #9a6a00;
  margin-bottom: 14px;
}

/* ---- Standalone pages (success/edit) ---- */
.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow);
  text-align: center;
}

.card .icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #e9f4e9;
  color: #2e8b3f;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  font-size: 26px;
}

.card h1 { font-size: 22px; margin: 0 0 10px; }
.card p { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0 0 22px; }

.token-box {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  word-break: break-all;
  margin-bottom: 18px;
  text-align: left;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 18px;
  animation: spin 0.8s linear infinite;
}

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

/* ---- Lightbox: увеличенный просмотр картинки квадрата ---- */
.lightbox {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.lightbox-image-wrap {
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lightbox-body {
  padding: 16px 6px 4px;
  text-align: center;
}

.lightbox-body .lightbox-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.lightbox-body .lightbox-text {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  word-break: break-word;
}

.lightbox-body .lightbox-text:empty { display: none; }

.lightbox .close-x {
  z-index: 2;
  background: var(--surface);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  top: 10px;
  right: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(25, 1fr); }
  .stats { gap: 18px; }
}
