:root {
  --ink: #07070a;
  --bone: #ebe7e0;
  --smoke: rgba(235, 231, 224, 0.52);
  --hair: rgba(235, 231, 224, 0.16);
  --edge: clamp(20px, 3.2vw, 44px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
}

body {
  color: var(--bone);
  font-family: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* fine film grain at full resolution, above the upscaled render */
body::after {
  content: "";
  position: fixed;
  inset: -50%;
  z-index: 1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.045;
  mix-blend-mode: overlay;
  animation: grain 0.5s steps(4) infinite;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  75% { transform: translate(2%, 2%); }
}

.bar {
  position: fixed;
  z-index: 2;
  left: var(--edge);
  right: var(--edge);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--smoke);
}

.top { top: var(--edge); }
.bottom { bottom: var(--edge); justify-content: flex-end; pointer-events: none; }

.status { display: inline-flex; align-items: center; gap: 10px; }
.status i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #f1d9bf;
  box-shadow: 0 0 10px 2px rgba(241, 200, 160, 0.45);
  animation: pulse 3.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

.hero {
  position: fixed;
  z-index: 2;
  left: var(--edge);
  bottom: var(--edge);
  max-width: calc(100vw - 2 * var(--edge) - 120px);
  pointer-events: none;
  user-select: none;
}

h1 {
  margin: 0;
  font-weight: 300;
  font-size: clamp(32px, 4.4vw, 68px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  color: var(--bone);
}

#sound {
  pointer-events: auto;
  padding: 8px 0 8px 12px;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--smoke);
  cursor: pointer;
  transition: color 0.3s ease;
}

#sound span { color: var(--bone); }
#sound:hover { color: var(--bone); }
#sound:focus-visible { outline: 1px solid var(--bone); outline-offset: 4px; }

/* entrance: the text never waits for the scene */
.bar, .hero { animation: enter 1.6s ease 0.3s both; }
@keyframes enter { from { opacity: 0; } to { opacity: 1; } }

#scene { opacity: 0; transition: opacity 1.2s ease; }
.ready #scene { opacity: 1; }

.no-webgl body {
  background: radial-gradient(ellipse at 45% 70%, #1a1820 0%, var(--ink) 60%);
}
.no-webgl #sound { display: none; }

@media (max-width: 640px) {
  .hero { max-width: none; right: var(--edge); bottom: calc(var(--edge) + 34px); }
  .bottom { justify-content: flex-start; }
  #sound { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  body::after, .status i, .bar, .hero { animation: none; }
}
