/* The Ninth Forge: a low-resolution 3D scene upscaled with nearest-neighbour,
   with a quiet editorial overlay that never covers the fire. */
:root {
  --night: #171321;
  --cream: #f4e7cf;
  --cream-dim: rgba(244, 231, 207, 0.78);
  --cream-faint: rgba(244, 231, 207, 0.7);
  --ember: #ffb45a;
  --ember-hot: #ffd59a;
  --ink: #0f0b12;
  --mono: "JetBrains Mono Variable", ui-monospace, monospace;
  --sans: "Fraunces Variable", "Iowan Old Style", Georgia, serif;
  --display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--night);
}
body {
  color: var(--cream);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  color: inherit;
}
[hidden] {
  display: none !important;
}
#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
  touch-action: none;
  outline: none;
  background: var(--night);
}
#scene:focus-visible {
  outline: 2px solid var(--ember-hot);
  outline-offset: -4px;
}
.ui {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  padding:
    max(24px, env(safe-area-inset-top))
    max(26px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(26px, env(safe-area-inset-left));
}
.ui > * {
  pointer-events: auto;
}
.title {
  position: absolute;
  left: max(26px, env(safe-area-inset-left));
  top: max(24px, env(safe-area-inset-top));
  max-width: min(560px, 52vw);
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.55);
}
.eyebrow {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ember-hot);
  opacity: 0.78;
}
.title h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(34px, 4.2vw, 66px);
  letter-spacing: 0.005em;
  line-height: 0.9;
  color: #fbf0dc;
}
.title .line {
  margin: 10px 0 0;
  max-width: 34em;
  font-size: clamp(12px, 1.05vw, 15px);
  line-height: 1.45;
  color: var(--cream-dim);
}
.dock {
  position: absolute;
  left: max(26px, env(safe-area-inset-left));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: grid;
  gap: 7px;
  max-width: min(520px, 62vw);
}
.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.keys button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(244, 231, 207, 0.22);
  border-radius: 999px;
  background: rgba(20, 15, 22, 0.62);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  cursor: pointer;
  backdrop-filter: blur(9px);
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}
.keys button:hover {
  border-color: rgba(255, 213, 154, 0.6);
  background: rgba(44, 29, 24, 0.82);
}
.keys button[aria-pressed="true"] {
  border-color: rgba(255, 213, 154, 0.7);
  color: var(--ember-hot);
}
.keys button:focus-visible {
  outline: 3px solid var(--ember-hot);
  outline-offset: 3px;
}
.status {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.08em;
  color: var(--ember);
  min-height: 1.4em;
}
.hint {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: var(--cream-faint);
}
.note {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(244, 231, 207, 0.72);
}
.fallback {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: var(--night);
  text-align: center;
  padding: 24px;
}
.fallback svg {
  width: min(420px, 76vw);
  height: auto;
  border: 1px solid rgba(244, 231, 207, 0.14);
  border-radius: 4px;
}
.fallback p {
  margin: 0;
  max-width: 44ch;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--cream-dim);
}

body.capture .ui {
  display: none;
}

@media (max-width: 700px) {
  .ui {
    padding:
      max(18px, env(safe-area-inset-top))
      max(18px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(18px, env(safe-area-inset-left));
  }
  .title {
    left: max(18px, env(safe-area-inset-left));
    top: max(18px, env(safe-area-inset-top));
    max-width: calc(100vw - 36px);
  }
  .title h1 {
    font-size: 36px;
  }
  .title .line {
    max-width: 30em;
    font-size: 12px;
  }
  .dock {
    left: max(18px, env(safe-area-inset-left));
    right: max(18px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    max-width: none;
  }
  .hint {
    display: none;
  }
  .note {
    font-size: 11px;
  }
}
@media (max-width: 420px) {
  .title h1 {
    font-size: 32px;
  }
  .title .line {
    font-size: 12px;
  }
  .keys button {
    padding: 0 12px;
    font-size: 12px;
  }
  .status {
    font-size: 11px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .keys button {
    transition: none;
  }
}
