/* ── Fonts ──────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Outfit:wght@300;400;500;600&display=swap');

/* ── Design tokens ──────────────────────────────────────── */
:root {
  --bg:           #08080f;
  --surface:      #101018;
  --surface-2:    #181822;
  --surface-3:    #22222e;
  --border:       #2a2a3a;
  --border-soft:  rgba(100,120,200,.10);
  --accent:       #7c6aef;
  --accent-hover: #6b58e0;
  --accent-dim:   rgba(124,106,239,.10);
  --accent-glow:  rgba(124,106,239,.22);
  --text:         #e8e6f0;
  --text-muted:   #6e6e88;
  --text-faint:   #3e3e52;
  --radius:       6px;
  --navbar-h:     54px;
  --toolbar-h:    50px;
  --status-h:     28px;
  --stats-h:      32px;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* ── Navbar ─────────────────────────────────────────────── */
#navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 100;
  gap: 12px;
}

#navTitle {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  white-space: nowrap;
  text-shadow: 0 0 28px var(--accent-glow);
  text-decoration: none;
  cursor: pointer;
}
#navTitle:visited { color: var(--text); }
#navTitle:hover { color: #fff; }

/* Mobile-only "Support" entry inside the scrollable nav row — on desktop the
   centered #navSupport covers it, so hide this one there. */
#navSupportM { display: none; }
@media (max-width: 860px) { #navSupportM { display: inline-flex; } }

/* Centered "Support" call-to-action in the navbar — same scale as the brand
   title. Absolutely centered so it stays mid-bar regardless of the side
   widths; hidden on narrow screens (the footer "♥ Support" still covers it). */
#navSupport {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f472b6;
  text-decoration: none;
  white-space: nowrap;
  text-shadow: 0 0 28px rgba(244, 114, 182, 0.45);
  transition: transform 0.15s ease, text-shadow 0.15s ease;
}
#navSupport:hover {
  transform: translate(-50%, -50%) scale(1.07);
  text-shadow: 0 0 38px rgba(244, 114, 182, 0.75);
}
@media (max-width: 860px) {
  #navSupport { display: none; }
}

#navRight {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

#userName {
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
  padding: 4px 9px;
  border-radius: var(--radius);
  transition: background .15s;
}
#userName:hover { background: var(--accent-dim); }

/* ── Toolbar ─────────────────────────────────────────────── */
#toolbar {
  position: fixed;
  top: var(--navbar-h);
  left: 0; right: 0;
  height: var(--toolbar-h);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 8px;
  z-index: 99;
}

#toolsLeft, #toolsRight {
  display: flex;
  align-items: center;
  gap: 6px;
}

.divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
  opacity: .7;
}

#colorPicker {
  width: 36px;
  height: 30px;
  padding: 2px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
#colorPicker:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ── Status bar ─────────────────────────────────────────── */
#statusBar {
  position: fixed;
  top: calc(var(--navbar-h) + var(--toolbar-h));
  left: 0; right: 0;
  height: var(--status-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 12px;
  color: var(--text-muted);
  z-index: 98;
  letter-spacing: 0.01em;
}

#reserveTimer { color: var(--accent); font-weight: 500; }

/* ── Canvas area ─────────────────────────────────────────── */
#canvasOuter {
  position: fixed;
  top: calc(var(--navbar-h) + var(--toolbar-h) + var(--status-h));
  bottom: var(--stats-h);
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
}

/* Parallax dot-grid background */
#parallaxBg {
  position: absolute;
  inset: -25%;
  width: 150%;
  height: 150%;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(124,106,239,.04) 1px, transparent 1px);
  background-size: 28px 28px;
  will-change: background-position;
  z-index: 0;
}

/* Vignette: darkens edges, keeps focus on canvas */
#canvasOuter::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 88% 80% at 50% 50%,
    transparent 48%,
    rgba(8, 8, 15, .75) 100%
  );
  pointer-events: none;
  z-index: 3;
}

#canvasContainer {
  position: relative;
  width: 90vw;
  aspect-ratio: 16 / 9;
  max-height: 100%;
  z-index: 1;
  /* Ambient glow — no hard border */
  border-radius: 2px;
  box-shadow:
    0 0 0 1px rgba(124,106,239,.12),
    0 0 80px rgba(124,106,239,.05),
    0 20px 60px rgba(0,0,0,.7);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  image-rendering: pixelated;
  border-radius: 2px;
  touch-action: none;  /* prevent browser gestures — we handle touch ourselves */
}

/* ── Stats panel ─────────────────────────────────────────── */
#statsPanel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
}

#statsToggle {
  height: var(--stats-h);
  width: 100%;
  border-radius: 0;
  justify-content: center;
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-faint);
  border: none;
}
#statsToggle:hover { background: var(--surface-2); color: var(--text-muted); }

#statsContent {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  max-height: 120px;
  transition: max-height .22s ease, padding .22s ease;
}
#statsContent.collapsed { max-height: 0; padding: 0 16px; }

#topColors { display: flex; gap: 10px; list-style: none; flex-wrap: wrap; }
#topColors li { display: flex; align-items: center; gap: 5px; }

/* Persistent legal links, pinned to the bottom-right over the stats bar */
#legalStrip {
  position: fixed; right: 0; bottom: 0; height: var(--stats-h);
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: var(--surface); border-left: 1px solid var(--border);
  z-index: 102;
}
#legalStrip a { color: var(--text-faint); text-decoration: none; font-size: 11px; }
#legalStrip a:hover { color: var(--accent); }
@media (max-width: 760px) { #legalStrip { display: none; } }

.color-swatch {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, opacity .15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.btn-primary:active { opacity: .82; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--surface-2); border-color: var(--text-muted); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-icon {
  padding: 6px 9px;
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  font-size: 15px;
  min-width: 32px;
}
.btn-icon:hover { background: var(--surface-3); border-color: var(--text-muted); }

.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-full { width: 100%; }

/* ── Inputs ─────────────────────────────────────────────── */
.input {
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.input::placeholder { color: var(--text-faint); }

/* ── Modal ──────────────────────────────────────────────── */
#modalBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#authModal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  width: 360px;
  max-width: 95vw;
  box-shadow:
    0 28px 70px rgba(0,0,0,.8),
    0 0 0 1px rgba(124,106,239,.1);
  animation: modalIn .2s cubic-bezier(.34,1.45,.64,1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.91) translateY(-14px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

#modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 2px;
}

#modalHeader h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 19px;
  font-weight: 600;
}

#modalBody {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 20px 22px;
}

/* ── Tooltip ────────────────────────────────────────────── */
#pixelTooltip {
  position: fixed;
  background: rgba(14,14,24,.95);
  color: var(--text);
  padding: 5px 9px;
  font-size: 11px;
  border-radius: 5px;
  pointer-events: none;
  display: none;
  z-index: 300;
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0,0,0,.6);
}

/* ── Profile / About pages ──────────────────────────────── */
.page-content {
  max-width: 820px;
  margin: 44px auto;
  padding: 0 22px;
}
.page-content h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 30px;
  margin-bottom: 18px;
  font-weight: 700;
}
.page-content h2 {
  font-size: 16px;
  margin: 26px 0 10px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.page-content p, .page-content li { line-height: 1.75; color: var(--text-muted); }
.page-content ul { padding-left: 20px; }
.page-content a { color: var(--accent); text-decoration: none; }
.page-content a:hover { text-decoration: underline; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  :root {
    --navbar-h: 46px;
    --toolbar-h: 42px;
    --status-h: 24px;
    --stats-h: 28px;
  }

  #toolsRight { display: none; }
  #canvasContainer { width: 100vw; }
  #navTitle { font-size: 16px; }

  /* Larger tap targets on mobile (main content buttons) */
  .page-content .btn { padding: 10px 16px; font-size: 14px; min-height: 44px; }
  .page-content .btn-sm { padding: 8px 14px; font-size: 13px; min-height: 40px; }

  /* Toolbar buttons — compact but tappable */
  #toolbar .btn-icon { padding: 8px 8px; font-size: 14px; min-width: 36px; min-height: 36px; }
  #toolbar .btn { padding: 6px 10px; font-size: 12px; min-height: 36px; }
  #colorPicker { width: 38px; height: 34px; }

  /* Compact navbar — brand pinned left, the action row takes the remaining
     width and scrolls horizontally (swipe). The missing piece before was
     min-width:0 / flex: without it the flex item refused to shrink, so the
     buttons overflowed off-screen and nothing scrolled. */
  #navbar { padding: 0 8px; gap: 6px; }
  #navbar > div:first-child { flex-shrink: 0; }
  #navRight {
    flex: 1 1 auto;
    min-width: 0;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #navRight::-webkit-scrollbar { display: none; }
  #navRight .btn { padding: 6px 8px; font-size: 11px; min-height: 32px; white-space: nowrap; }
  #navRight .btn-ghost { padding: 6px 6px; font-size: 11px; min-height: 32px; }
  #navRight .btn-icon { min-width: 32px; min-height: 32px; padding: 6px; }

  /* Truncate username on mobile */
  #userName { font-size: 12px; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Toolbar compact */
  #toolbar { padding: 0 8px; gap: 4px; }
  #toolsLeft { gap: 4px; }
  .divider { margin: 0 2px; }

  /* Status bar compact */
  #statusBar { padding: 0 10px; font-size: 11px; }

  /* Tooltip — position above finger, not beside */
  #pixelTooltip { font-size: 12px; max-width: 200px; }

  /* Canvas takes full width minus safe areas */
  canvas { touch-action: none; }
}

@media (max-width: 380px) {
  /* Very small phones — hide nav labels, keep icons */
  #navRight .btn-ghost { font-size: 11px; padding: 8px 6px; }
  #navTitle { font-size: 14px; }
}

/* Mobile-friendly tooltip — tappable links */
@media (hover: none) {
  #pixelTooltip { pointer-events: auto; }
}

/* Sub-pages on mobile */
@media (max-width: 640px) {
  .page-content { margin: 28px auto; padding: 0 14px; }
  .page-content h1 { font-size: 24px; }
}

/* Toolbar on phones/tablets: the tools row overflows the screen — turn it into
   a horizontal swipe strip (same min-width:0 / flex-shrink fix as the navbar)
   instead of spilling off-screen unreachable. Placed after the ≤640 block so
   it also re-shows the secondary tools (Share/Grid) hidden there. */
@media (max-width: 860px) {
  #toolbar {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #toolbar::-webkit-scrollbar { display: none; }
  #toolsLeft, #toolsRight { flex-shrink: 0; }
  #toolsRight { display: flex; }
}

/* ── Profile extras ─────────────────────────────────────── */
.pixel-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  background: var(--surface-2);
  margin-top: 8px;
}
.pixel-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .12s;
  color: var(--text-muted);
  font-size: 13px;
}
.pixel-list li:hover { background: var(--surface-3); color: var(--text); }

.color-box {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.12);
  flex-shrink: 0;
}

.nav-link { color: var(--accent); text-decoration: none; font-weight: 500; }

/* ── Info tooltip (ⓘ) — instant on hover, toggles on click/tap. Used for the
   free-pixel cap explainer on the profile + purchase modal. ────────────── */
.cap-info {
  position: relative; display: inline-flex; align-items: center;
  margin-left: 5px; width: 16px; height: 16px; border-radius: 50%;
  font-size: 11px; font-weight: 700; line-height: 1; justify-content: center;
  color: var(--text-muted); border: 1px solid var(--border);
  cursor: help; user-select: none; vertical-align: middle;
}
.cap-info:hover { color: var(--accent); border-color: var(--accent); }
.cap-tip {
  display: none; position: absolute; left: 50%; bottom: 150%;
  transform: translateX(-50%); z-index: 2000;
  width: 250px; padding: 10px 12px; border-radius: 8px;
  background: var(--surface-2, #181822); color: var(--text, #e2e2ea);
  border: 1px solid var(--border, #2a2a3a);
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  font-size: 12px; font-weight: 400; line-height: 1.5;
  text-align: left; white-space: normal; cursor: default;
}
/* Little arrow */
.cap-tip::after {
  content: ""; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--border, #2a2a3a);
}
.cap-info:hover .cap-tip,
.cap-info:focus .cap-tip,
.cap-info.open .cap-tip { display: block; }

/* ── Payment / Add-funds modal ───────────────────────────── */
.pay-card{
  position:relative; background:var(--surface); border:1px solid var(--border);
  border-radius:18px; padding:26px 28px 22px; width:420px; max-width:92vw;
  box-shadow:0 30px 80px rgba(0,0,0,.55); overflow:hidden;
}
.pay-card::before{content:""; position:absolute; top:0; left:0; right:0; height:3px;
  background:linear-gradient(90deg,transparent,var(--accent),transparent); opacity:.8}
.pay-eyebrow{font-size:11px; letter-spacing:2px; text-transform:uppercase;
  color:var(--text-muted); font-weight:600; margin:0 0 6px}
.pay-amount{font-size:40px; font-weight:700; line-height:1; margin:0 0 4px}
.pay-amount .cur{color:var(--text-faint); font-size:24px; font-weight:600; vertical-align:6px; margin-right:2px}
.pay-amount .val{background:linear-gradient(135deg,#a99bff,var(--accent));
  -webkit-background-clip:text; background-clip:text; color:transparent}
.pay-help{color:var(--text-muted); font-size:13.5px; margin:0 0 18px}
.pay-consent{display:flex; align-items:flex-start; gap:9px; margin:0 0 16px;
  font-size:12.5px; color:var(--text-muted); cursor:pointer; line-height:1.45;
  background:var(--surface-2); border:1px solid var(--border); border-radius:10px; padding:11px 12px}
.pay-consent input{margin-top:1px; flex-shrink:0; cursor:pointer; width:16px; height:16px; accent-color:var(--accent)}
.pay-consent a{color:var(--accent); text-decoration:none; font-weight:500}
.pay-consent a:hover{text-decoration:underline}
.pay-methods{display:flex; flex-direction:column; gap:10px}
.pay-method{display:flex; align-items:center; gap:14px; width:100%; padding:13px 15px; text-align:left;
  cursor:pointer; background:var(--surface-2); border:1px solid var(--border); border-radius:13px; color:var(--text);
  font:inherit; transition:transform .15s ease,border-color .15s ease,box-shadow .15s ease,background .15s ease}
.pay-method:hover{transform:translateY(-2px); border-color:var(--accent); background:var(--surface-3);
  box-shadow:0 12px 30px rgba(0,0,0,.4),0 0 24px var(--accent-glow)}
.pm-badge{flex-shrink:0; width:48px; height:48px; border-radius:12px; display:flex; align-items:center; justify-content:center;
  background:linear-gradient(135deg,rgba(34,34,46,0),#2c2c3e); border:1px solid var(--border); transition:border-color .15s}
.pay-method:hover .pm-badge{border-color:var(--accent)}
.pm-text{display:flex; flex-direction:column; min-width:0}
.pm-title{font-weight:600; font-size:14.5px; color:var(--text)}
.pm-sub{font-size:12px; color:var(--text-muted); margin-top:2px}
.pm-chevron{margin-left:auto; color:var(--text-faint); font-size:22px; line-height:1; transition:color .15s,transform .15s}
.pay-method:hover .pm-chevron{color:var(--accent); transform:translateX(3px)}
.pay-cancel{display:block; margin:16px auto 0; background:none; border:0; color:var(--text-muted);
  font:inherit; font-size:13.5px; cursor:pointer; padding:6px 14px; border-radius:8px}
.pay-cancel:hover{color:var(--text); background:var(--surface-2)}

/* ── Site-wide announcement / maintenance banner (admin Config) ──────────── */
#siteBanner {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 18px; z-index: 200; max-width: min(680px, 92vw);
  padding: 10px 14px 10px 16px; border-radius: 12px;
  font-size: 13.5px; font-weight: 500; line-height: 1.35;
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff; border: 1px solid var(--accent-glow);
  box-shadow: 0 10px 30px rgba(124,106,239,.35);
  animation: sbIn .35s cubic-bezier(.2,.9,.3,1.2) both;
}
#siteBanner.maint {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-color: rgba(255,150,150,.4);
  box-shadow: 0 10px 30px rgba(185,28,28,.4);
}
#siteBanner .sb-close {
  cursor: pointer; opacity: .75; font-weight: 700; font-size: 13px;
  padding: 0 2px; user-select: none;
}
#siteBanner .sb-close:hover { opacity: 1; }
@keyframes sbIn { from { opacity: 0; transform: translate(-50%, 14px); }
                  to   { opacity: 1; transform: translate(-50%, 0); } }
