:root {
  --bg-void: #050816;
  --bg-deep: #0a0f25;
  --text-cream: #f5f0e1;
  --text-muted: #c5bea3;
  --text-dim: #8a8470;
  --gold-glow: #f5d28a;
  --gold-rich: #d4af37;
  --line-soft: rgba(245, 240, 225, 0.12);
  --display: 'Cormorant Garamond', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-void);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(125, 211, 252, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 80% 85%, rgba(212, 175, 55, 0.04) 0%, transparent 55%),
    radial-gradient(circle at 50% 50%, var(--bg-deep) 0%, var(--bg-void) 80%);
}

/* background twinkling starfield (DOM, behind canvas) */
#bg-stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
#bg-stars .twinkle {
  position: absolute;
  border-radius: 50%;
  background: #fef8e7;
  animation: twinkle var(--dur, 4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes twinkle {
  0%, 100% { opacity: 0.12; transform: scale(0.8); }
  50% { opacity: 0.9; transform: scale(1.15); }
}

.sim-wrap {
  position: fixed;
  inset: 0;
  z-index: 1;
}

#sim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

/* ============ HUD ============ */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  pointer-events: none;
  z-index: 3;
}

.hud-title {
  font-family: var(--display);
  font-size: 22px;
  font-style: italic;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud-title .mark {
  color: var(--gold-rich);
  font-style: normal;
  font-size: 14px;
}

.hud-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
}

.counter {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  background: rgba(26, 33, 72, 0.6);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  color: var(--text-muted);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.ctrl-btn:hover {
  border-color: var(--gold-rich);
  color: var(--gold-glow);
  transform: translateY(-1px);
}
.ctrl-btn:active { transform: translateY(0) scale(0.95); }

/* ============ ONBOARDING GESTURE ============ */
.onboard {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 4;
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.onboard.gone { opacity: 0; transform: translateX(-50%) translateY(12px); }

.g-demo { width: 132px; height: 84px; }
.g-demo svg { width: 100%; height: 100%; overflow: visible; }

.g-line {
  stroke: var(--gold-glow);
  stroke-width: 1.6;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  stroke-linecap: round;
  opacity: 0;
  animation: gLine 3.4s ease-in-out infinite;
}
.g-arrow {
  stroke: var(--gold-glow);
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  opacity: 0;
  animation: gArrow 3.4s ease-in-out infinite;
}
.g-anchor {
  fill: none;
  stroke: rgba(245, 210, 138, 0.5);
  stroke-width: 1.2;
}
.g-world {
  fill: #fff;
  filter: drop-shadow(0 0 6px var(--gold-glow));
  animation: gWorld 3.4s ease-in-out infinite;
}
@keyframes gLine {
  0%, 5% { stroke-dashoffset: 1; opacity: 0; }
  12% { opacity: 0.9; }
  38% { stroke-dashoffset: 0; opacity: 0.9; }
  62% { opacity: 0.9; }
  78%, 100% { stroke-dashoffset: 0; opacity: 0; }
}
@keyframes gArrow {
  0%, 38% { opacity: 0; }
  46% { opacity: 0.9; }
  62% { opacity: 0.9; }
  78%, 100% { opacity: 0; }
}
@keyframes gWorld {
  0%, 12% { transform: translate(0, 0); opacity: 0.95; }
  38% { transform: translate(70px, 14px); opacity: 1; }     /* follows the drag */
  44% { transform: translate(70px, 14px); opacity: 1; }     /* release */
  72% { transform: translate(112px, -16px); opacity: 1; }   /* flung into orbit */
  85% { opacity: 0; }
  100% { transform: translate(0, 0); opacity: 0; }
}

.onboard-text {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  padding: 7px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(5, 8, 22, 0.5);
  backdrop-filter: blur(8px);
}

/* ============ PERSISTENT CTA ============ */
.cta-pill {
  position: absolute;
  bottom: 22px;
  right: 22px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-cream);
  text-decoration: none;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: rgba(26, 33, 72, 0.55);
  backdrop-filter: blur(10px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.cta-pill .mark { color: var(--gold-rich); }
.cta-pill svg { transition: transform 0.3s ease; }
.cta-pill:hover {
  border-color: var(--gold-rich);
  color: #fff;
  background: rgba(26, 33, 72, 0.85);
  transform: translateY(-2px);
}
.cta-pill:hover svg { transform: translateX(3px); }

/* ============ CONVERSION PROMPT ============ */
.convert-prompt {
  position: absolute;
  bottom: 22px;
  left: 22px;
  z-index: 6;
  max-width: 290px;
  padding: 18px 20px 20px;
  border-radius: 6px;
  border: 1px solid var(--gold-deep);
  background: linear-gradient(160deg, rgba(26, 33, 72, 0.95), rgba(10, 15, 37, 0.95));
  backdrop-filter: blur(14px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.5s var(--spring, ease), transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.convert-prompt.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.convert-close {
  position: absolute;
  top: 8px; right: 10px;
  background: none; border: none;
  color: var(--text-dim);
  font-size: 20px; line-height: 1;
  cursor: pointer;
  transition: color 0.2s;
}
.convert-close:hover { color: var(--text-cream); }
.convert-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-glow);
  margin-bottom: 6px;
}
.convert-title {
  font-family: var(--display);
  font-size: 19px;
  line-height: 1.25;
  color: var(--text-cream);
  margin-bottom: 14px;
}
.convert-btn {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #1a1409;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--gold-glow), var(--gold-rich));
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.convert-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(212, 175, 55, 0.3); }

@media (max-width: 540px) {
  .hud { padding: 14px 16px; }
  .hud-title { font-size: 18px; }
  .onboard { bottom: 13%; }
  .onboard-text { font-size: 10px; letter-spacing: 0.12em; }
  .cta-pill { bottom: 16px; right: 14px; font-size: 10px; padding: 9px 13px; }
  .convert-prompt { left: 14px; right: 14px; bottom: 70px; max-width: none; }
}

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .g-line, .g-arrow, .g-world { animation: none !important; }
  .g-line, .g-arrow { opacity: 0.9; stroke-dashoffset: 0; }
}