/* ---------- Tokens (matched to the game's RefractTheme.swift) ---------- */
:root {
  --bg:          #1b1622;  /* plum night */
  --bg-deep:     #120e18;
  --bg-top:      #322642;
  --bg-panel:    #211b2b;
  --bg-panel-2:  #2a2336;

  --ink:         #f6f1e7;  /* cream */
  --ink-dim:     #c8c1b6;
  --ink-muted:   #9b94a4;
  --line:        #ffffff14;

  --prism:       #5fd478;  /* prism green accent */
  --prism-light: #8df0a4;
  --prism-dark:  #43b65e;
  --amber:       #ffc56b;
  --peach:       #ff9b7d;
  --star:        #ffd96b;

  /* Beam colors (game identity) */
  --red:    #ff4040;
  --blue:   #4d80ff;
  --yellow: #ffe640;
  --purple: #b34dff;
  --orange: #ff9933;
  --green:  #40d973;
  --white:  #f2f2f2;

  --radius:      14px;
  --radius-lg:   22px;
  --max:         1100px;

  --font-sans:   "Avenir Next", "AvenirNext-Bold", -apple-system,
                 BlinkMacSystemFont, "SF Pro Rounded", "SF Pro Display",
                 "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
  width: 100%;
}
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
  position: relative;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Twilight background: plum gradient + soft glows + board grid ---------- */
.cosmos {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(1200px 820px at 50% -10%, #3a2c50 0%, transparent 60%),
    radial-gradient(900px 700px at 90% 110%, #2a1d44 0%, transparent 60%),
    radial-gradient(circle at 50% 30%, var(--bg-top) 0%, var(--bg) 45%, var(--bg-deep) 100%);
}

/* Soft color glows — prism green + violet, slowly drifting */
.nebula {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.40;
  will-change: transform;
}
.nebula-a {
  width: 540px; height: 540px;
  top: -140px; left: -120px;
  background: radial-gradient(circle, #5fd47855 0%, transparent 65%);
  animation: nebula-drift-a 34s ease-in-out infinite alternate;
}
.nebula-b {
  width: 620px; height: 620px;
  bottom: -200px; right: -180px;
  background: radial-gradient(circle, #8c4dff55 0%, transparent 65%);
  animation: nebula-drift-b 40s ease-in-out infinite alternate;
}
@keyframes nebula-drift-a {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(60px, 40px) scale(1.08); }
}
@keyframes nebula-drift-b {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-50px, -30px) scale(1.05); }
}

/* Faint board-grid texture — nods to the puzzle grid, parallax-drifted */
.grid-veil {
  position: absolute;
  top: -10vh; left: 0;
  width: 100%;
  height: 130vh;
  background-image:
    linear-gradient(to right,  #ffffff08 1px, transparent 1px),
    linear-gradient(to bottom, #ffffff08 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(circle at 50% 35%, #000 0%, transparent 78%);
          mask-image: radial-gradient(circle at 50% 35%, #000 0%, transparent 78%);
  opacity: 0.6;
  will-change: transform;
}

/* Drifting color motes — soft beam-colored sparks instead of stars */
.motes {
  position: absolute;
  top: -10vh; left: 0;
  width: 100%;
  height: 130vh;
  background-repeat: repeat;
  will-change: transform;
}
.motes-far {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='340' height='340'><g><circle cx='40' cy='30' r='1.4' fill='%235fd478' opacity='0.5'/><circle cx='180' cy='70' r='1.2' fill='%23b34dff' opacity='0.45'/><circle cx='280' cy='40' r='1.3' fill='%23ffc56b' opacity='0.4'/><circle cx='90' cy='180' r='1.2' fill='%234d80ff' opacity='0.4'/><circle cx='250' cy='220' r='1.4' fill='%235fd478' opacity='0.45'/><circle cx='310' cy='150' r='1.1' fill='%23ff9b7d' opacity='0.4'/><circle cx='30' cy='270' r='1.2' fill='%23ffe640' opacity='0.4'/><circle cx='200' cy='300' r='1.3' fill='%23b34dff' opacity='0.45'/></g></svg>");
  opacity: 0.7;
  animation: twinkle 6.5s ease-in-out infinite 1s;
}
.motes-near {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='480' height='480'><g><circle cx='60' cy='80' r='1.8' fill='%238df0a4' opacity='0.55'/><circle cx='250' cy='50' r='1.6' fill='%23ff9b7d' opacity='0.5'/><circle cx='410' cy='160' r='1.8' fill='%234d80ff' opacity='0.5'/><circle cx='90' cy='280' r='1.7' fill='%23ffc56b' opacity='0.5'/><circle cx='330' cy='350' r='1.8' fill='%235fd478' opacity='0.55'/><circle cx='160' cy='410' r='1.5' fill='%23b34dff' opacity='0.45'/></g></svg>");
  opacity: 0.85;
  animation: twinkle 4.8s ease-in-out infinite;
}
@keyframes twinkle {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.5); }
}

/* ---------- Header ---------- */
.site-header {
  max-width: var(--max);
  margin: 0 auto;
  padding: 22px 24px;
  padding-right: max(24px, env(safe-area-inset-right));
  padding-left:  max(24px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 22%;
  background: url('/icon.png') center/cover no-repeat;
  box-shadow: 0 0 0 1.5px #ffffff20, 0 2px 8px #00000059;
  flex: 0 0 auto;
}
.brand-mark.small { width: 30px; height: 30px; box-shadow: 0 0 0 1px #ffffff26, 0 1px 4px #0000004d; }
.brand-name { font-size: 1.05rem; }
.site-nav { display: flex; gap: 22px; }
.site-nav a {
  color: var(--ink-dim);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color 150ms ease, border-color 150ms ease;
}
.site-nav a:hover { color: var(--ink); text-decoration: none; }
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--prism);
}

/* ---------- Hero ---------- */
.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: 16px 24px 56px;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 56px;
  align-items: center;
}
.hero-copy h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.05;
  margin: 0 0 20px;
  letter-spacing: -0.01em;
}
.hero-copy h1 .accent { color: var(--prism); }
.hero-copy .tagline {
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  color: var(--ink-dim);
  max-width: 52ch;
  margin: 0 0 28px;
}
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; align-items: center; }
.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 22px;
  border-radius: var(--radius);
  font-weight: 700;
  line-height: 1.1;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease, box-shadow 200ms ease;
}
.cta:hover { text-decoration: none; transform: translateY(-1px); }
.cta.primary {
  background: var(--prism);
  color: #10210f;
  box-shadow: 0 8px 26px -10px #5fd478cc;
}
.cta.primary:hover { background: var(--prism-light); box-shadow: 0 12px 32px -10px #5fd478; }
.cta.ghost {
  border: 1px solid var(--line);
  color: var(--ink-dim);
}
.cta.ghost:hover { color: var(--ink); border-color: var(--ink-dim); }

/* "Coming soon" App Store pill (swap for a real badge link once live) */
.coming-soon {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #ffffff06;
  color: var(--ink-dim);
  font-weight: 600;
  font-size: 0.92rem;
}
.coming-soon .apple { width: 18px; height: 18px; flex: 0 0 auto; fill: var(--ink-dim); }
.coming-soon strong { color: var(--ink); font-weight: 700; }
.meta { color: var(--ink-muted); font-size: 0.85rem; margin: 10px 0 0; }

/* Hero visual */
.hero-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
}
.board-svg {
  width: 100%;
  max-width: 460px;
  height: auto;
  filter: drop-shadow(0 30px 50px #0009);
}

/* ---------- Beam primitives (shared by hero + mechanics) ---------- */
/* Beams are drawn the way the game renders them: a soft wide glow under a
   bright solid core, round caps. Composites render as a single core
   distinguished by color (not a doubled line). No animated dashes — the life
   comes from the soft glow pulses below. */
.pulse-soft { animation: pulse-soft 2.6s ease-in-out infinite; transform-origin: center; }
@keyframes pulse-soft {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}
.target-glow { animation: target-glow 2.6s ease-in-out infinite; transform-origin: center; }
@keyframes target-glow {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.06); }
}
.spin-slow { animation: spin-slow 24s linear infinite; transform-origin: center; }
@keyframes spin-slow { to { transform: rotate(360deg); } }

/* ---------- Features ---------- */
.features {
  max-width: var(--max);
  margin: 0 auto;
  padding: 48px 24px 32px;
}
.features h2 {
  font-size: clamp(1.6rem, 3vw, 2rem);
  margin: 0 0 32px;
}
/* Screenshot walkthrough */
.shots {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2.5vw, 24px);
}
.shot {
  display: flex;
  align-items: center;
  gap: clamp(28px, 5vw, 72px);
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}
.shot:nth-of-type(even) { flex-direction: row-reverse; }
.shot-frame {
  flex: 0 0 auto;
  width: clamp(132px, 19vw, 190px);
  padding: 6px;
  border-radius: 24px;
  background: linear-gradient(160deg, var(--bg-panel-2), var(--bg-deep));
  border: 1px solid var(--line);
  box-shadow: 0 26px 64px -22px rgba(0, 0, 0, 0.72),
              0 0 70px -34px var(--prism);
}
.shot-frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
}
.shot-copy { flex: 1 1 0; min-width: 0; }
.shot-copy h3 {
  margin: 0 0 12px;
  font-size: clamp(1.25rem, 2.6vw, 1.6rem);
}
.shot-copy p {
  margin: 0;
  max-width: 46ch;
  color: var(--ink-dim);
  font-size: 1.02rem;
  line-height: 1.7;
}
@media (max-width: 720px) {
  .shot,
  .shot:nth-of-type(even) {
    flex-direction: column;
    text-align: center;
    gap: 18px;
  }
  .shot-copy p { margin-inline: auto; }
}

/* ---------- Mechanics ---------- */
.mechanics {
  max-width: var(--max);
  margin: 0 auto;
  padding: 56px 24px 56px;
}
.mechanics-heading { max-width: 720px; margin: 0 0 32px; }
.mechanics-heading h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.mechanics-heading .lead { color: var(--ink-dim); margin: 0; font-size: 1.02rem; }
.mechanics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}
.mechanic {
  padding: 18px 20px 22px;
  background: #ffffff05;
  border: 1px solid #ffffff0d;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 200ms ease, border-color 200ms ease;
}
.mechanic:hover {
  transform: translateY(-2px);
  border-color: #ffffff1f;
}
.mechanic-art {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 10px;
  background:
    linear-gradient(#0000, #0000) padding-box,
    #0e0b14;
  border: 1px solid #ffffff0a;
}
.mechanic-art svg { width: 100%; height: 100%; display: block; }
.mechanic-body { padding: 0; }
.mechanic-body h3 { margin: 0 0 6px; font-size: 1.05rem; }
.mechanic-body p { margin: 0; color: var(--ink-dim); font-size: 0.94rem; }

/* ---------- Pitch ---------- */
.pitch {
  max-width: var(--max);
  margin: 0 auto;
  padding: 72px 24px 104px;
  text-align: center;
}
.pitch-inner { margin: 0 auto; }
.pitch-inner h2 {
  margin: 0 0 28px;
  font-size: clamp(2rem, 4.2vw, 2.8rem);
  letter-spacing: -0.01em;
  color: var(--ink);
}
.pitch-inner .cta-row { justify-content: center; margin-bottom: 0; }
.pitch-swatch {
  display: block;
  width: 100%;
  max-width: 300px;
  height: auto;
  margin: 0 auto 22px;
}

/* ---------- Prose (privacy + support) ---------- */
.prose {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.prose h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 12px 0 8px; }
.prose h2 { font-size: 1.2rem; margin: 32px 0 8px; color: var(--ink); }
.prose h3 { font-size: 1.02rem; margin: 22px 0 6px; color: var(--ink); }
.prose p, .prose li { color: var(--ink-dim); }
.prose a { color: var(--prism); text-decoration: underline; text-decoration-color: #2d6b4d; }
.prose a:hover { text-decoration-color: var(--prism); }
.prose .updated { color: var(--ink-muted); font-size: 0.9rem; margin: 0 0 18px; }
.contact-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin: 24px 0 12px;
}
.contact-label { color: var(--ink-muted); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 6px; }
.contact-email { display: inline-block; font-size: 1.25rem; font-weight: 700; color: var(--ink); max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.contact-hint { margin: 12px 0 0; color: var(--ink-dim); font-size: 0.95rem; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: #120e18cc;
  backdrop-filter: blur(6px);
}
.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px 24px 12px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.footer-brand { display: flex; align-items: center; gap: 10px; }
.footer-name { font-weight: 800; }
.footer-by { font-size: 0.85rem; color: var(--ink-muted); }
.footer-by a { color: var(--ink-dim); }
.footer-nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-nav a { color: var(--ink-dim); font-size: 0.9rem; }
.footer-copy { max-width: var(--max); margin: 0 auto; padding: 4px 24px 28px; color: var(--ink-muted); font-size: 0.8rem; }

/* ---------- Scroll reveal (only active when JS sets .js on <html>) ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 700ms ease, transform 700ms ease;
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
.js .reveal[data-reveal="fade-in"]  { transform: none; }
.js .reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 20px 24px 56px;
  }
  .hero-visual { order: -1; min-height: 0; }
  .board-svg { max-width: 340px; }
  .site-header { padding: 18px 20px; gap: 10px 20px; }
  .site-nav { gap: 14px; }
  .mechanic-art { height: 160px; }
}
@media (max-width: 640px) {
  .site-header { justify-content: center; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-name { font-size: 1rem; }
  .site-nav { width: 100%; gap: 10px 18px; flex-wrap: wrap; justify-content: center; }
  .site-nav a { font-size: 0.9rem; padding: 2px 0; }
}
@media (max-width: 480px) {
  .site-header { padding: 14px 16px; gap: 8px 14px; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-name { font-size: 0.95rem; }
  .site-nav { gap: 8px 14px; }
  .site-nav a { font-size: 0.85rem; }
  .hero { padding: 16px 20px 48px; }
  .features, .pitch, .prose, .mechanics { padding-left: 20px; padding-right: 20px; }
  .nebula-a { width: 360px; height: 360px; }
  .nebula-b { width: 420px; height: 420px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}
