.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2.2rem, 5.2vh, 4.4rem) clamp(1rem, 3vw, 2rem) .65rem;
  background: transparent;
  pointer-events: none;
}

.topbar .nav-stack {
  display: inline-grid;
  justify-items: center;
  gap: 1.15rem;
  padding: .08rem .25rem 0;
  pointer-events: auto;
  transition: opacity 2800ms ease, transform 2800ms ease, filter 2800ms ease;
}

.topbar.is-reading-scrolled .nav-stack {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-.35rem);
  filter: blur(1px);
}

.topbar.is-reading-scrolled:hover .nav-stack,
.topbar.is-reading-scrolled:focus-within .nav-stack {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  filter: blur(0);
  transition-duration: 180ms;
}

.topbar .nav-home {
  min-height: 0;
  padding: 0 .12rem .12rem;
  color: #fff;
  font: 400 1.12rem/1.42 "Micro 5", monospace;
  letter-spacing: .42rem;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .18rem;
  text-transform: uppercase;
}

.topbar .center-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(8rem, 1fr));
  gap: .55rem;
  align-items: center;
  justify-items: center;
  width: min(27rem, 92vw);
  pointer-events: auto;
}

.topbar nav button {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  padding: .45rem .65rem;
  border: 0;
  background: transparent;
  color: #f2efe8;
  font: 1.15rem "Micro 5", monospace;
  letter-spacing: .18rem;
  text-transform: uppercase;
}

.topbar nav button:hover,
.topbar nav button:focus-visible {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: .18rem;
  outline: 0;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  filter: contrast(1.32) brightness(.88) saturate(.62) sepia(.18);
  image-rendering: pixelated;
}

#play-screen.is-falling #game {
  filter: contrast(var(--fall-contrast, 1.32)) brightness(var(--fall-brightness, .88)) saturate(var(--fall-saturation, .62)) sepia(.2);
}

#play-screen.is-falling .ascii-noise {
  opacity: var(--fall-noise, .34);
}

.ascii-noise,
.glitch-scan {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}

.ascii-noise {
  opacity: .34;
  background-image:
    repeating-radial-gradient(circle at 17% 31%, rgba(255,220,190,.19) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, transparent 0 5px, rgba(255,70,30,.08) 5px 6px),
    repeating-linear-gradient(0deg, transparent 0 5px, rgba(0,0,0,.3) 5px 6px);
  background-size: 9px 11px, 6px 100%, 100% 6px;
  mix-blend-mode: soft-light;
  animation: radiation-static .16s steps(2) infinite;
}

.glitch-scan {
  opacity: .24;
  background:
    linear-gradient(90deg, rgba(255,35,12,.08), transparent 18%, transparent 76%, rgba(0,0,0,.22)),
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(0,0,0,.68) 2px 3px);
  mix-blend-mode: multiply;
  animation: red-signal-glitch 4.8s steps(1) infinite;
}

.glitch-scan::before,
.glitch-scan::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 31px, rgba(255,86,43,.09) 31px 33px);
  opacity: .34;
  clip-path: inset(38% 0 54%);
  animation: signal-slice 3.1s steps(1) infinite;
}

.glitch-scan::after {
  opacity: .22;
  clip-path: inset(71% 0 20%);
  animation-delay: -1.7s;
}

.first-person-reticle {
  position: absolute;
  z-index: 14;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255,166,120,.56);
  font: 1rem monospace;
  text-shadow: 0 0 8px #a21c0a;
  pointer-events: none;
}

@keyframes red-signal-glitch {
  0%, 85%, 100% { transform: translate(0); clip-path: inset(0); }
  86% { transform: translateX(12px); clip-path: inset(14% 0 70%); }
  87% { transform: translateX(-18px); clip-path: inset(58% 0 25%); }
  88% { transform: translateX(5px); clip-path: inset(31% 0 51%); }
  94% { transform: translateX(-7px); filter: contrast(1.6); }
}

@keyframes radiation-static {
  0% { background-position: 0 0, 0 0, 0 0; }
  25% { background-position: 3px -5px, 1px 0, 0 2px; }
  50% { background-position: -4px 2px, -2px 0, 0 -1px; }
  75% { background-position: 5px 4px, 2px 0, 0 1px; }
}

@keyframes signal-slice {
  0%, 78%, 100% { transform: translateX(0); }
  79% { transform: translateX(24px); }
  81% { transform: translateX(-17px); }
  83% { transform: translateX(6px); }
}

.hud {
  top: 1rem;
}

.hud > button {
  display: none;
}

.control-hud {
  position: absolute;
  z-index: 13;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 2rem);
  color: rgba(239,222,199,.72);
  font: .76rem "Micro 5", monospace;
  letter-spacing: .13em;
  text-align: center;
  text-shadow: 0 2px 8px #000;
  pointer-events: none;
}

.compass {
  position: absolute;
  z-index: 13;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: .25rem .85rem .5rem;
  color: rgba(220,202,180,.45);
  font: .7rem "Micro 5", monospace;
  letter-spacing: .16em;
  text-shadow: 0 2px 8px #000;
}

.compass strong {
  color: #f1d0ab;
  font-size: 1rem;
}

.compass i {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 1px;
  height: .4rem;
  background: #d46849;
  transform-origin: 50% 100%;
  transition: transform 120ms linear;
}

.dialogue {
  top: 7.2rem;
  bottom: auto;
  width: min(42rem, calc(100% - 2rem));
  min-height: 0;
  padding: .75rem 1rem;
  background: rgba(12, 4, 3, .72);
  backdrop-filter: blur(5px);
  pointer-events: none;
}

.dialogue button,
.dialogue-choices {
  pointer-events: auto;
}

#game-shell::after {
  opacity: .14;
}

@media (max-width: 760px) {
  .topbar {
    padding-top: 1.5rem;
  }

  .topbar .center-nav {
    grid-template-columns: repeat(2, minmax(6rem, 1fr));
  }

  .topbar nav button {
    font-size: .92rem;
  }

  .control-hud {
    display: none;
  }
}
