:root {
  --bg: #0f0b1a;
  --bg-panel: #17122a;
  --bg-panel-2: #1e1836;
  --border: #2e2650;
  --text: #f1eefc;
  --text-dim: #b3a8d9;
  --text-dim-2: #8a7cb8;
  --accent-a: #8b5cf6;
  --accent-b: #ec4899;
  --success: #36d068;
  --danger: #f55656;
  --warn: #ffbc0b;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 0%, rgba(139,92,246,0.25), transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(236,72,153,0.18), transparent 40%);
  color: var(--text);
  line-height: 1.5;
}

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

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

.gradient-text {
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 26px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  color: #fff;
  box-shadow: 0 8px 24px rgba(139,92,246,0.35);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(139,92,246,0.45); }

.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--border);
}

/* Rainbow glow border: a rotating conic-gradient ring plus a blurred halo
   behind the button. The real .btn paints on top of both (separate element,
   higher z-index) so its own background/text are untouched. */
@property --glow-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}
.btn-glow {
  position: relative;
  display: inline-flex;
  border-radius: 10px;
}
.btn-glow::before,
.btn-glow::after {
  content: "";
  position: absolute;
  border-radius: 13px;
  background: conic-gradient(from var(--glow-angle), #12A89D, #92278F, #12A89D);
  animation: glow-spin 5s linear infinite;
}
.btn-glow::before { inset: -2px; z-index: 0; }
.btn-glow::after { inset: -8px; z-index: -1; filter: blur(16px); opacity: 0.55; }
.btn-glow .btn { position: relative; z-index: 1; }
@keyframes glow-spin { to { --glow-angle: 360deg; } }
@media (prefers-reduced-motion: reduce) {
  .btn-glow::before, .btn-glow::after { animation: none; }
}

/* Header */
/* header itself is also a .wrap ("<header class="wrap">"), and .wrap's own
   padding: 0 24px (specificity 0,1,0) beats a plain "header" element
   selector (0,0,1) regardless of source order - confirmed live, this exact
   rule was silently never winning the cascade. header.wrap (0,1,1) beats
   .wrap alone, so it actually applies. */
header.wrap {
  padding-top: 40px;
  padding-bottom: 20px;
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 17px; }
.brand img { width: 36px; height: 36px; border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; }
.tagline { font-size: 13px; font-style: italic; color: var(--text-dim); }
.tagline-bang { font-family: "SF Mono", Menlo, Consolas, monospace; font-style: normal; font-weight: 700; color: var(--accent-b); }
/* Two copies of the tagline (see index.php): one sits to the right of the
   header on wider screens (tagline-desktop), the other stacks under the
   title next to a slightly bigger logo on narrow ones (tagline-mobile) -
   simplest robust way to keep both layouts pixel-exact without fighting
   flexbox/grid reordering across the breakpoint. */
.tagline-mobile { display: none; }

/* Hero */
.hero { padding: 72px 0 56px; text-align: center; }
.hero h1 { font-size: 44px; font-weight: 700; margin: 0 0 20px; letter-spacing: -0.02em; }
.hero p.lead { font-size: 18px; color: var(--text-dim); max-width: 620px; margin: 0 auto 36px; }
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* Feature grid */
.section { padding: 56px 0; }
.section h2 { font-size: 28px; text-align: center; margin: 0 0 12px; }
.section p.section-lead { text-align: center; color: var(--text-dim); max-width: 560px; margin: 0 auto 40px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
}

/* Fixed 3-per-row for grids with a card count that's a multiple of 3
   (currently just #features, 6 cards) - auto-fit alone packs as many
   230px+ columns as the container allows, which gave 4+2 instead of
   3+3 at this section's actual width. */
.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .grid-3 { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card .icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(139,92,246,0.25), rgba(236,72,153,0.2));
  margin-bottom: 16px;
  color: var(--accent-a);
}
.card h3 { font-size: 16px; margin: 0 0 8px; }
.card p { font-size: 14px; color: var(--text-dim); margin: 0; }

/* What's new / changelog */
.changelog-list {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.changelog-item {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  gap: 16px;
  align-items: baseline;
}
.changelog-version {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-a);
  background: rgba(139,92,246,0.15);
  border-radius: 999px;
  padding: 3px 10px;
}
.changelog-item p { margin: 0; font-size: 14px; color: var(--text-dim); }

/* Video walkthrough */
.video-heading {
  max-width: 960px;
  margin: 0 auto 16px;
  font-size: 18px;
  color: var(--text);
}
.video-wrap {
  position: relative;
  padding-top: 56.25%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  max-width: 960px;
  margin: 0 auto;
}
.video-wrap + .video-heading {
  margin-top: 48px;
}
.video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Screenshots */
.screenshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}
.screenshot {
  margin: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.screenshot-link { display: block; border-radius: 8px; }
.screenshot-link:focus-visible { outline: 2px solid var(--accent-a); outline-offset: 2px; }
.screenshot img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  cursor: zoom-in;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.screenshot-link:hover img {
  transform: scale(1.015);
  box-shadow: 0 0 0 2px var(--accent-a);
}
.screenshot figcaption {
  font-size: 13px;
  color: var(--text-dim);
  padding: 14px 8px 6px;
  text-align: center;
}

/* Screenshot lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,7,20,0.92);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  z-index: 1000;
  cursor: zoom-out;
}
.lightbox-overlay.active { display: flex; }
.lightbox-overlay img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.16); }

/* Flow steps */
.steps { counter-reset: step; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; }
.step { position: relative; padding-left: 44px; }
.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.step h4 { margin: 4px 0 6px; font-size: 15px; }
.step p { margin: 0; font-size: 13px; color: var(--text-dim); }

/* Download form panel */
.download-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px;
  text-align: center;
}
.download-panel h2 { margin-top: 0; }
.download-count-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(139,92,246,0.12);
  border: 1px solid rgba(139,92,246,0.35);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.download-form {
  display: flex;
  gap: 10px;
  max-width: 440px;
  margin: 24px auto 0;
  flex-wrap: wrap;
  justify-content: center;
}
.download-form input[type=email] {
  flex: 1;
  min-width: 220px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-panel-2);
  color: var(--text);
  font-size: 15px;
}
.download-form input[type=email]:focus { outline: 2px solid var(--accent-a); }

.hint { font-size: 12px; color: var(--text-dim-2); margin-top: 14px; }

.alert {
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 14px;
  margin: 20px auto 0;
  max-width: 440px;
  text-align: left;
}
.alert-success { background: rgba(54,208,104,0.12); border: 1px solid rgba(54,208,104,0.35); color: #8ff0ae; }
.alert-error { background: rgba(245,86,86,0.12); border: 1px solid rgba(245,86,86,0.35); color: #ffb3b3; }

footer {
  padding: 40px 0 64px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
  text-align: center;
  color: var(--text-dim-2);
  font-size: 13px;
}
footer a { color: var(--text-dim); display: inline-flex; align-items: center; gap: 6px; }
footer .links { margin-top: 10px; display:flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
footer .links img { width: 16px; height: 16px; border-radius: 4px; }

/* Standalone status pages (download success/expired/invalid) */
.status-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.status-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px;
  max-width: 460px;
}
.status-card .icon-big { font-size: 44px; margin-bottom: 16px; }
.status-card h1 { font-size: 22px; margin: 0 0 12px; }
.status-card p { color: var(--text-dim); font-size: 14px; }

/* Admin */
.admin-body { background: #0f0b1a; }
.wrap.admin-wrap { max-width: 1400px; }
.admin-header { display:flex; align-items:center; justify-content: space-between; padding: 20px 0; border-bottom: 1px solid var(--border); margin-bottom: 32px; }
.stat-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 16px; margin-bottom: 40px; }
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}
.stat-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .stat-value { font-size: 30px; font-weight: 700; background: linear-gradient(135deg, var(--accent-a), var(--accent-b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-card .stat-label { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

.admin-table-wrap { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; overflow-x: auto; }
.admin-map-card { overflow: visible; padding: 16px; }
.admin-map-card .svgMap-wrapper { background: transparent; }
.admin-map-card .svgMap-map-wrapper { background: var(--bg-panel); border-radius: 10px; }
/* Higher specificity than svgMap's own .svgMap-map-wrapper .svgMap-map-controls-zoom
   rule (same specificity, but its stylesheet loads after ours, so it would
   otherwise win the cascade tie). */
#admin-world-map .svgMap-map-controls-zoom { display: none; }
/* Not scoped under .admin-map-card - svgMap appends its tooltip to
   document.body, not inside the map's own container, so a descendant
   selector never matched it (confirmed live: it kept inheriting the
   site's own near-white text color against the tooltip's white background,
   unreadable). */
.svgMap-tooltip-title { color: #111; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.admin-table th { text-align: left; padding: 12px 16px; color: var(--text-dim); font-weight: 600; border-bottom: 1px solid var(--border); background: var(--bg-panel-2); white-space: nowrap; }
table.admin-table td { padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.admin-table tr:last-child td { border-bottom: none; }
table.admin-table td.admin-table-wrap-cell { white-space: normal; max-width: 480px; }

.badge { display:inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-ok { background: rgba(54,208,104,0.15); color: #8ff0ae; }
.badge-warn { background: rgba(255,188,11,0.15); color: #ffd873; }
.badge-err { background: rgba(245,86,86,0.15); color: #ffb3b3; }

.admin-chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
/* Single source of truth for the gap above every admin section title, so
   it's the same regardless of what precedes it (chart grid, table, ...) -
   deliberately not left up to each preceding block's own margin-bottom. */
.admin-section-title { font-size: 16px; margin: 40px 0 12px; color: var(--text); }

.range-selector { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.range-pill {
  display: inline-flex;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  text-decoration: none;
}
.range-pill:hover { color: var(--text); border-color: var(--accent-a); }
.range-pill.active {
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  border-color: transparent;
  color: #fff;
}

.chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding: 12px 0; }
.chart-bar { flex: 1; background: linear-gradient(180deg, var(--accent-a), var(--accent-b)); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.chart-bar-alt { background: linear-gradient(180deg, #4ade80, var(--success)); }
.chart-bar-visitors { background: linear-gradient(180deg, #38bdf8, #0ea5e9); }

/* Custom hover tooltip for chart bars - the native title="" attribute this
   also carries works but is slow/easy to miss, this shows immediately. */
.chart-bar[data-tooltip] { cursor: default; }
.chart-bar[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel-solid, #1a1330);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}
.chart-bar[data-tooltip]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--border);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 5;
}
.chart-bar[data-tooltip]:hover::after,
.chart-bar[data-tooltip]:hover::before {
  opacity: 1;
}
.chart-labels { display: flex; gap: 4px; font-size: 10px; color: var(--text-dim-2); }
.chart-labels span { flex: 1; text-align: center; white-space: nowrap; }

@media (max-width: 600px) {
  .hero h1 { font-size: 32px; }
  .download-panel { padding: 32px 20px; }
  .changelog-item { flex-direction: column; gap: 6px; }
  .brand img { width: 48px; height: 48px; }
  .tagline-desktop { display: none; }
  .tagline-mobile { display: block; font-size: 12px; margin-top: 2px; }
}
