@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/assets/fonts/instrument-serif-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/assets/fonts/instrument-serif-latin-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}

:root {
  --bg: #080B10;
  --grass: #1C3317;
  --mask: #F4F2ED;
  --term: #00FF9C;
  --sky-dusk: #1a1f2e;
  --sky-midnight: #080B10;
  --sky-bloodmoon: #1a0808;
  --sky-sunrise: #241a2e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--mask);
  font-family: "JetBrains Mono", ui-monospace, "Courier New", monospace;
  overflow-x: hidden;
  min-height: 100vh;
  cursor: none;
}
img { max-width: 100%; display: block; }
.mono { font-family: "JetBrains Mono", monospace; }
a { color: inherit; }

.noscript-banner {
  position: fixed; inset: 0; z-index: 99998;
  background: var(--bg); color: var(--term);
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 2rem; font-size: 1.2rem;
}

/* ---------- sky / night cycle ---------- */
.sky-layer {
  position: fixed; inset: 0; z-index: -3;
  background: var(--sky-dusk);
  transition: background-color 1.2s ease;
}
.stars-far {
  position: absolute; inset: 0;
  background-image: radial-gradient(1px 1px at 10% 20%, #fff, transparent),
    radial-gradient(1px 1px at 80% 10%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 60% 40%, #fff, transparent),
    radial-gradient(1px 1px at 30% 70%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 90% 60%, #fff, transparent),
    radial-gradient(1px 1px at 45% 85%, #fff, transparent),
    radial-gradient(1px 1px at 15% 55%, #fff, transparent);
  background-repeat: repeat;
  background-size: 400px 400px;
  opacity: 0.5;
}
.moon {
  position: absolute; top: 6%; left: 50%;
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #d9d6ce 60%, #b7b3a8);
  box-shadow: 0 0 30px 8px rgba(244,242,237,0.25);
  transform: translate(-42vw, 4vh);
  transition: transform 1.6s ease, background 1.2s ease, box-shadow 1.2s ease, opacity 1.2s ease;
}

.phase-hud {
  position: fixed; top: 1rem; right: 1rem; z-index: 40;
  font-size: 0.68rem; letter-spacing: 0.18em;
  color: var(--term); opacity: 0.8;
  background: rgba(8,11,16,0.6);
  padding: 0.35rem 0.6rem;
  border: 1px solid rgba(0,255,156,0.3);
}

.ambient-toggle {
  position: fixed; top: 1rem; left: 1rem; z-index: 40;
  display: flex; align-items: center; gap: 0.4rem;
  background: rgba(8,11,16,0.7); color: var(--mask);
  border: 1px solid rgba(244,242,237,0.25);
  font-family: "JetBrains Mono", monospace; font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0.45rem 0.7rem; cursor: pointer;
}
.ambient-dot { width: 7px; height: 7px; border-radius: 50%; background: #555; display: inline-block; }
.ambient-toggle[aria-pressed="true"] .ambient-dot { background: var(--term); box-shadow: 0 0 6px var(--term); }

/* ---------- boot screen ---------- */
.boot-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: #000; color: var(--term);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
  transition: opacity 0.9s ease, visibility 0.9s ease;
}
.boot-screen.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-text {
  font-family: "JetBrains Mono", monospace;
  font-size: clamp(0.8rem, 2.6vw, 1.1rem);
  white-space: pre-wrap;
  max-width: 480px;
  margin: 0;
}

/* ---------- custom cigar-ember cursor ---------- */
.ember-cursor {
  position: fixed; z-index: 10000; width: 10px; height: 10px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, #ffb347 0%, #ff5b1f 45%, transparent 75%);
  box-shadow: 0 0 12px 4px rgba(255,120,30,0.55);
  transform: translate(-50%, -50%);
  transition: opacity 0.2s ease;
}
@media (hover: none) {
  body { cursor: auto; }
  .ember-cursor { display: none; }
}

.section {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  padding: 5rem 1.25rem;
}
.section-eyebrow {
  font-family: "Instrument Serif", serif;
  font-style: italic;
  text-transform: lowercase;
  font-size: clamp(2rem, 6vw, 3rem);
  color: var(--mask);
  margin: 0 0 0.5rem;
  text-align: center;
}
.section-sub {
  text-align: center; opacity: 0.65; font-size: 0.85rem;
  margin: 0 0 2.5rem;
}
.section-sub code { color: var(--term); }

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.parallax-field {
  position: absolute; inset: 0;
  overflow: hidden;
}
.layer { position: absolute; inset: 0; will-change: transform; }
.layer-stars {
  background-image: radial-gradient(1px 1px at 12% 15%, #fff, transparent),
    radial-gradient(1px 1px at 70% 25%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 40% 10%, #fff, transparent),
    radial-gradient(1px 1px at 85% 40%, #fff, transparent);
  background-size: 500px 300px;
  opacity: 0.7;
}
.layer-planets::before, .layer-planets::after {
  content: ""; position: absolute; border-radius: 50%;
}
.layer-planets::before {
  top: 8%; left: 10%; width: 46px; height: 46px;
  background: radial-gradient(circle at 35% 35%, #7fa8c9, #2c4a63 70%);
}
.layer-planets::after {
  top: 4%; right: 12%; width: 26px; height: 26px;
  background: radial-gradient(circle at 35% 35%, #cfcfcf, #6d6d6d 70%);
}
.layer-rainbow {
  top: -10%; left: 50%; transform: translateX(-50%);
  width: 140%; height: 60%;
  background: conic-gradient(from 180deg at 50% 100%,
    #ff3b3b 0deg, #ff9f1c 40deg, #ffe500 80deg, #39ff6a 120deg,
    #00e5ff 160deg, #7a5cff 200deg, #ff3ec9 240deg, #ff3b3b 280deg);
  mask: radial-gradient(circle at 50% 100%, transparent 38%, #000 40%, #000 46%, transparent 48%);
  -webkit-mask: radial-gradient(circle at 50% 100%, transparent 38%, #000 40%, #000 46%, transparent 48%);
  opacity: 0.55;
  filter: url(#ripple-wave) saturate(1);
  animation: rainbow-breathe 14s ease-in-out infinite;
}
@keyframes rainbow-breathe {
  0%, 100% { filter: saturate(0.8); }
  50% { filter: saturate(1.3); }
}
.layer-hills {
  bottom: 0; left: 0; right: 0; top: auto; height: 40%;
  background: linear-gradient(180deg, transparent, var(--grass) 60%);
  clip-path: polygon(0 60%, 15% 45%, 35% 55%, 55% 40%, 75% 52%, 100% 42%, 100% 100%, 0 100%);
}
.layer-figures {
  bottom: 0; left: 0; right: 0; top: auto;
  display: flex; align-items: flex-end; justify-content: center;
}
.figures-img { width: 100%; max-width: 1100px; min-width: 0; height: auto; max-height: 46vh; object-fit: contain; }
.eyes-overlay { position: absolute; inset: 0; pointer-events: none; }
.eye-pupil {
  position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: radial-gradient(circle, #fff, rgba(255,255,255,0) 70%);
  box-shadow: 0 0 5px 1px rgba(255,255,255,0.7);
  transform: translate(-50%, -50%);
}
.smoke-mount { position: absolute; inset: 0; pointer-events: none; }
.smoke-mount canvas { display: block; }

.filter-defs { position: absolute; }

.hero-copy {
  position: relative; z-index: 3; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  padding-top: 12vh;
}
.hero-title {
  font-family: "Instrument Serif", serif;
  font-size: clamp(3rem, 13vw, 6.5rem);
  letter-spacing: 0.05em;
  margin: 0;
  color: var(--mask);
  text-shadow: 0 0 40px rgba(244,242,237,0.25);
}
.hero-line { margin: 0; font-size: 0.95rem; letter-spacing: 0.04em; opacity: 0.85; }
.hero-line--dim { opacity: 0.5; }
.hero-cta {
  margin-top: 1.6rem;
  font-family: "JetBrains Mono", monospace; text-transform: lowercase;
  font-size: 0.85rem; letter-spacing: 0.08em;
  border: 1px solid var(--term); color: var(--term);
  padding: 0.7rem 1.6rem; text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}
.hero-cta:hover { background: var(--term); color: #000; }
.scroll-cue {
  position: absolute; bottom: 2rem; left: 50%; transform: translateX(-50%);
  font-size: 0.65rem; letter-spacing: 0.3em; text-transform: uppercase;
  opacity: 0.5; z-index: 3;
  animation: scroll-cue-bob 2.4s ease-in-out infinite;
}
@keyframes scroll-cue-bob {
  0%, 100% { transform: translate(-50%, 0); opacity: 0.3; }
  50% { transform: translate(-50%, 6px); opacity: 0.6; }
}

/* ---------- mask generator ---------- */
.mask-section { text-align: center; }
.mask-stage {
  position: relative; display: inline-block;
  border: 1px solid rgba(244,242,237,0.2);
  background: #05070a;
}
.mask-canvas { width: min(70vw, 320px); height: min(70vw, 320px); display: block; }
.mask-id {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.6rem 0.8rem; border-top: 1px solid rgba(244,242,237,0.15);
}
.mask-number { font-size: 0.85rem; letter-spacing: 0.05em; color: var(--term); }
.mask-born { font-size: 0.65rem; opacity: 0.55; }
.mask-actions { margin-top: 1.75rem; display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }
.btn {
  font-family: "JetBrains Mono", monospace; text-transform: lowercase; font-size: 0.8rem;
  letter-spacing: 0.05em; padding: 0.65rem 1.4rem; cursor: pointer; border-radius: 2px;
}
.btn-primary { background: var(--term); color: #000; border: 1px solid var(--term); }
.btn-ghost { background: transparent; color: var(--mask); border: 1px solid rgba(244,242,237,0.3); }
.btn-ghost:hover { border-color: var(--mask); }

/* ---------- graveyard ---------- */
.graveyard-section { max-width: 100%; }
.graveyard-scroll {
  overflow-x: auto; overflow-y: hidden;
  padding: 1rem 0 1.5rem;
  -webkit-overflow-scrolling: touch;
}
.graveyard-row {
  display: flex; gap: 1.5rem; padding: 0 1.25rem;
  width: max-content;
}
.tombstone {
  width: 190px; flex-shrink: 0;
  background: #0d1310;
  border: 1px solid rgba(244,242,237,0.15);
  display: flex; flex-direction: column;
}
.tombstone-art { width: 100%; height: 140px; object-fit: cover; filter: grayscale(0.2) brightness(0.85); }
.tombstone-plate { padding: 0.7rem 0.8rem; }
.tombstone-name { display: block; font-weight: 700; font-size: 0.85rem; letter-spacing: 0.04em; }
.tombstone-epitaph { display: block; font-size: 0.68rem; opacity: 0.6; margin-top: 0.3rem; }
.tombstone--fresh {
  animation: bury-in 0.7s cubic-bezier(.2,1.3,.4,1) both;
}
@keyframes bury-in {
  from { transform: translateY(-40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.tombstone-placeholder {
  width: 100%; height: 140px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: rgba(244,242,237,0.3);
  background: repeating-linear-gradient(45deg, #0d1310 0 8px, #10160f 8px 16px);
}

.graveyard-form { max-width: 360px; margin: 0 auto; text-align: center; }
.graveyard-label { display: block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.6; margin-bottom: 0.5rem; }
.graveyard-input-row { display: flex; gap: 0.5rem; }
.graveyard-input {
  flex: 1; background: #0d1310; border: 1px solid rgba(244,242,237,0.25);
  color: var(--mask); font-family: "JetBrains Mono", monospace; font-size: 0.85rem;
  padding: 0.6rem 0.7rem; text-transform: uppercase;
}
.graveyard-input:focus { outline: 1px solid var(--term); }

/* ---------- terminal ---------- */
.terminal-section { max-width: 720px; }
.terminal {
  border: 1px solid rgba(0,255,156,0.3);
  background: #04070a;
  box-shadow: 0 0 30px rgba(0,255,156,0.06);
}
.terminal-bar {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.7rem; border-bottom: 1px solid rgba(0,255,156,0.2);
}
.terminal-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(244,242,237,0.25); }
.terminal-title { margin-left: 0.6rem; font-size: 0.7rem; opacity: 0.5; }
.terminal-body {
  padding: 0.9rem 0.9rem 0.7rem;
  height: 320px; overflow-y: auto;
  font-size: 0.82rem; line-height: 1.55;
}
.terminal-output { white-space: pre-wrap; color: var(--term); }
.terminal-output .line-cmd { color: var(--mask); opacity: 0.8; }
.terminal-output .line-cmd::before { content: "netborn@field:~$ "; opacity: 0.5; }
.terminal-input-row { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.3rem; }
.terminal-prompt { color: var(--mask); opacity: 0.5; font-size: 0.82rem; }
.terminal-input {
  flex: 1; background: transparent; border: none; color: var(--term);
  font-family: "JetBrains Mono", monospace; font-size: 0.82rem; outline: none;
}
.terminal.is-crashed .terminal-body { animation: term-glitch 0.4s steps(2) 3; }
@keyframes term-glitch {
  0% { transform: translate(0); filter: none; }
  50% { transform: translate(-2px, 1px); filter: invert(1); }
  100% { transform: translate(0); filter: none; }
}

/* ---------- lore quotes / phase markers ---------- */
.quote-section { max-width: 620px; text-align: center; padding: 8rem 1.25rem; }
.lore-quote {
  font-family: "Instrument Serif", serif;
  font-style: italic;
  font-size: clamp(1.4rem, 4.5vw, 2.1rem);
  opacity: 0.85;
  margin: 0;
}

/* ---------- footer ---------- */
.footer {
  text-align: center; padding: 3rem 1.25rem 4rem;
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.footer-ca {
  background: #0d1310; border: 1px solid rgba(244,242,237,0.15);
  padding: 0.4rem 0.9rem; display: inline-flex; gap: 0.5rem;
  font-size: 0.72rem; max-width: 100%; overflow-wrap: anywhere;
}
.footer-ca-label { opacity: 0.5; }
.footer-ca-value { color: var(--term); }
.footer-links { display: flex; gap: 0.9rem; }
.footer-link {
  color: var(--mask); border: 1px solid rgba(244,242,237,0.25);
  border-radius: 50%; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s ease;
}
.footer-link:hover { border-color: var(--term); color: var(--term); }
.footer-fine { font-size: 0.68rem; opacity: 0.45; }

@media (min-width: 720px) {
  .terminal-body { height: 380px; }
}

@media (prefers-reduced-motion: reduce) {
  .layer-rainbow { animation: none; }
  .scroll-cue { animation: none; }
  .moon { transition: none; }
  .sky-layer { transition: none; }
  * { scroll-behavior: auto !important; }
}
