:root { color-scheme: dark; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05070f;
}

body {
  position: fixed;
  inset: 0;
  touch-action: none;            /* no scroll / pinch-zoom on mobile */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* the canvas is rendered at low resolution and scaled up crisply */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Intro overlay — the only text on the page. Fades on first tap, forever. */
#intro {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  pointer-events: none;          /* taps always reach the canvas */
  text-align: center;
  color: #e6f4cb;
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  transition: opacity 2.6s ease;
  opacity: 1;
  padding: 1rem;
}

#intro.gone { opacity: 0; }

#intro h1 {
  font-size: clamp(2.1rem, 9vw, 4.2rem);
  font-weight: 200;
  letter-spacing: 0.34em;
  text-indent: 0.34em;           /* compensate trailing letter-spacing */
  text-transform: lowercase;
  text-shadow:
    0 0 4px  rgba(226, 255, 188, 0.85),
    0 0 18px rgba(170, 240, 120, 0.55),
    0 0 40px rgba(120, 210, 70, 0.35);
  animation: breathe 4.5s ease-in-out infinite;
}

#intro p {
  font-size: clamp(0.78rem, 3.4vw, 1.05rem);
  font-weight: 300;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  text-transform: lowercase;
  opacity: 0.62;
  animation: breathe 4.5s ease-in-out 0.4s infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.42; }
  50%      { opacity: 0.92; }
}

@media (prefers-reduced-motion: reduce) {
  #intro h1, #intro p { animation: none; }
}

/* ---- the "?" on the start screen ---- */
#help {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 0.9rem);
  right: calc(env(safe-area-inset-right, 0px) + 1rem);
  width: 2.1em;
  height: 2.1em;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
  font-size: clamp(1rem, 4.2vw, 1.25rem);
  font-weight: 300;
  line-height: 1;
  color: #e6f4cb;
  background: rgba(10, 20, 14, 0.25);
  border: 1px solid rgba(180, 240, 130, 0.35);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;                  /* clickable even though #intro is not */
  text-shadow: 0 0 10px rgba(170, 240, 120, 0.6);
  box-shadow: 0 0 14px rgba(120, 210, 70, 0.18);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  transition: color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
#help:hover {
  color: #fff;
  border-color: rgba(200, 255, 150, 0.7);
  box-shadow: 0 0 22px rgba(150, 235, 90, 0.4);
}
#intro.gone #help { pointer-events: none; }   /* gone once the sim starts */

/* ---- the about overlay ---- */
#about {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  opacity: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;                    /* allow scrolling the text on mobile */
  background: rgba(4, 7, 14, 0.95);
  color: #cad8b2;
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  transition: opacity .45s ease;
}
#about.open { display: block; opacity: 1; }

#about .wrap {
  max-width: 40rem;
  margin: 0 auto;
  padding: clamp(3.6rem, 10vw, 6rem) 1.4rem 4rem;
  font-weight: 300;
  font-size: clamp(0.92rem, 3.5vw, 1.02rem);
  line-height: 1.72;
}

#about h2 {
  margin: 0 0 1.6rem;
  font-size: clamp(1.8rem, 8vw, 2.8rem);
  font-weight: 200;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  text-transform: lowercase;
  color: #e6f4cb;
  text-shadow: 0 0 4px rgba(226, 255, 188, 0.7), 0 0 20px rgba(170, 240, 120, 0.45);
}
#about h3 {
  margin: 2.2rem 0 0.7rem;
  font-size: clamp(1rem, 4.4vw, 1.18rem);
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: #bfe886;
  text-shadow: 0 0 12px rgba(150, 235, 90, 0.3);
}
#about p { margin: 0 0 1rem; }

#about a {
  color: #aef05f;
  text-decoration: none;
  border-bottom: 1px solid rgba(174, 240, 95, 0.35);
  transition: color .2s ease, border-color .2s ease;
}
#about a:hover { color: #e0ffa6; border-color: rgba(224, 255, 166, 0.85); }

#about .refs { list-style: none; padding: 0; margin: 0.3rem 0 0; }
#about .refs li { margin: 0 0 0.6rem; padding-left: 1.1em; text-indent: -1.1em; }

#about .dedication {
  margin-top: 3.2rem;
  padding-top: 1.6rem;
  border-top: 1px solid rgba(120, 160, 100, 0.16);
  text-align: center;
  color: #93ab7d;
  letter-spacing: 0.2em;
  text-transform: lowercase;
  font-size: clamp(0.82rem, 3.3vw, 0.92rem);
  line-height: 2;
}
#about .dedication strong {
  display: block;
  font-weight: 300;
  letter-spacing: 0.26em;
  color: #e6f4cb;
  text-shadow: 0 0 14px rgba(170, 240, 120, 0.5);
}

#about-close {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 0.8rem);
  right: calc(env(safe-area-inset-right, 0px) + 1rem);
  z-index: 11;
  width: 2.1em;
  height: 2.1em;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
  font-size: clamp(1.3rem, 5vw, 1.6rem);
  font-weight: 200;
  line-height: 1;
  color: #e6f4cb;
  background: rgba(10, 20, 14, 0.4);
  border: 1px solid rgba(180, 240, 130, 0.3);
  border-radius: 50%;
  cursor: pointer;
  text-shadow: 0 0 10px rgba(170, 240, 120, 0.55);
  transition: color .2s ease, border-color .2s ease;
}
#about-close:hover { color: #fff; border-color: rgba(200, 255, 150, 0.7); }
