:root {
  color-scheme: dark;
  --fg: #f4ede4;
  --dim: rgba(244, 237, 228, 0.62);
  --accent: #ffb36b;
  font-family: "Inter", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: #000;
  color: var(--fg);
}

canvas#gl {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
}

/* Black fade used when the camera crosses the horizon */
.veil {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

main { position: relative; z-index: 2; }

.scene {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 8vw;
  max-width: 46rem;
  opacity: 0;
  transform: translateY(2.5rem);
  filter: blur(6px);
  transition: opacity 1.1s ease, transform 1.1s ease, filter 1.1s ease;
}
.scene.visible { opacity: 1; transform: none; filter: none; }
.scene.right { margin-left: auto; text-align: right; }
.scene.center { margin: 0 auto; text-align: center; align-items: center; }

.scene h2 {
  font-size: clamp(1.8rem, 4.5vw, 3.4rem);
  font-weight: 300;
  letter-spacing: 0.08em;
  margin: 0 0 1rem;
  text-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
}
.scene p {
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  line-height: 1.9;
  color: var(--dim);
  margin: 0;
  text-shadow: 0 0 18px rgba(0, 0, 0, 1), 0 0 4px rgba(0, 0, 0, 1);
}
.scene .quiet { color: var(--dim); letter-spacing: 0.6em; }

.hero { max-width: none; align-items: center; text-align: center; margin: 0 auto; }
.hero h1 {
  font-size: clamp(3.2rem, 13vw, 10rem);
  font-weight: 200;
  letter-spacing: 0.18em;
  margin: 0.2em 0 0.25em 0.18em; /* offset trailing letter-spacing */
  background: linear-gradient(180deg, #fff 20%, #ffcf9a 60%, #ff7a2f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 40px rgba(255, 140, 60, 0.35));
}
.kicker {
  font-size: 0.75rem !important;
  letter-spacing: 0.4em;
  color: var(--accent) !important;
}
.hint {
  margin-top: 18vh !important;
  font-size: 0.8rem !important;
  letter-spacing: 0.4em;
  animation: breathe 2.6s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.25; } }

.hud {
  position: fixed;
  top: 1.4rem;
  right: 1.6rem;
  z-index: 3;
  font: 0.78rem/1.7 ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  color: var(--dim);
  text-align: right;
  pointer-events: none;
}
.hud div { display: flex; gap: 0.6rem; justify-content: flex-end; align-items: baseline; }
.hud span { letter-spacing: 0.15em; }
.hud b { color: var(--fg); font-weight: 500; min-width: 4.5em; font-variant-numeric: tabular-nums; }
.hud i { font-style: normal; min-width: 1.6em; text-align: left; }

.progress {
  position: fixed;
  left: 0; bottom: 0;
  width: 100%;
  height: 2px;
  z-index: 3;
  background: rgba(255, 255, 255, 0.06);
}
#progress-bar {
  height: 100%;
  width: 100%;
  transform-origin: left;
  transform: scaleX(0);
  background: linear-gradient(90deg, #ff7a2f, #ffd9a8);
}

#restart {
  margin-top: 2.5rem;
  padding: 0.8rem 2.2rem;
  font: inherit;
  letter-spacing: 0.3em;
  color: var(--fg);
  background: transparent;
  border: 1px solid rgba(244, 237, 228, 0.4);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s;
}
#restart:hover { background: rgba(255, 179, 107, 0.12); border-color: var(--accent); }
#restart:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.fallback {
  position: fixed;
  inset: auto 0 2rem;
  z-index: 4;
  text-align: center;
  color: var(--dim);
}

@media (max-width: 640px) {
  .scene.right { text-align: left; margin-left: 0; }
  .hud { top: auto; bottom: 1rem; right: 0.9rem; font-size: 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .scene { transition: opacity 0.4s ease; transform: none; filter: none; }
  .hint { animation: none; }
}
