body.game {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #14110e;
  touch-action: none;
  user-select: none;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(42, 22, 10, 0.16) 68%, rgba(8, 6, 6, 0.62) 100%);
}

#inset-frame {
  position: fixed;
  left: 16px;
  bottom: 16px;
  width: 240px;
  height: 146px;
  border: 1px solid rgba(255, 176, 32, 0.7);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  z-index: 2;
  pointer-events: none;
}

#inset-frame span {
  position: absolute;
  left: 6px;
  top: 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
}

#hud { position: fixed; inset: 0; z-index: 3; pointer-events: none; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 14px 28px;
  background: linear-gradient(180deg, rgba(7, 8, 13, 0.82), rgba(7, 8, 13, 0));
}

.topbar .brand { pointer-events: auto; font-size: 0.78rem; }

.stat { min-width: 64px; }

.stat span {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat b {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
}

.stat-time b { color: var(--amber); }

.top-actions { margin-left: auto; display: flex; gap: 8px; pointer-events: auto; }

.top-actions button,
#btn-fire {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(10, 12, 18, 0.8);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.top-actions button:hover,
#btn-fire:hover { border-color: var(--amber); }

#reticle { position: fixed; left: 50%; top: 46%; width: 0; height: 0; z-index: 3; }

.arm {
  position: absolute;
  background: rgba(243, 239, 228, 0.92);
}

.arm.up { width: 2px; height: 16px; left: -1px; top: -26px; }
.arm.down { width: 2px; height: 12px; left: -1px; top: 12px; }
.arm.left { width: 16px; height: 2px; top: -1px; left: -26px; }
.arm.right { width: 16px; height: 2px; top: -1px; left: 10px; }

#reticle.hit .arm { background: var(--cyan); }

#reticle.kick { animation: kick 0.16s linear; }

@keyframes kick {
  20% { transform: translate(4px, 2px); }
  55% { transform: translate(-3px, 1px); }
  100% { transform: translate(0, 0); }
}

#ladder { position: absolute; left: 0; top: 0; }

.mark {
  position: absolute;
  left: 0;
  width: 26px;
  margin-left: -13px;
  border-top: 2px solid var(--amber);
  height: 0;
}

.mark span {
  position: absolute;
  left: 30px;
  top: -7px;
  color: var(--amber);
  font: 600 11px/1 var(--mono);
  text-shadow: 0 1px 0 #000, 0 0 6px #000;
}

#near {
  position: absolute;
  left: 0;
  transform: translateX(-50%);
  color: var(--ink);
  font: 600 13px/1 var(--mono);
  text-shadow: 0 1px 0 #000, 0 0 6px #000;
  white-space: nowrap;
}

#cool {
  position: absolute;
  top: 120px;
  left: -36px;
  width: 72px;
  height: 3px;
  background: rgba(255, 255, 255, 0.16);
}

#cool-bar {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--cyan);
  transform-origin: left center;
}

#popup {
  position: fixed;
  left: 50%;
  top: calc(46% - 78px);
  transform: translateX(-50%);
  margin: 0;
  color: var(--amber);
  font: 750 28px/1 var(--mono);
  text-shadow: 0 2px 0 #000;
  opacity: 0;
  z-index: 4;
}

#popup.show { animation: floatup 760ms ease-out; }

@keyframes floatup {
  0% { opacity: 1; transform: translateX(-50%) translateY(6px); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-28px); }
}

#markers { position: fixed; inset: 0; z-index: 3; pointer-events: none; }

.marker {
  position: absolute;
  transform: translate(-50%, -50%);
  color: var(--amber);
  font: 700 12px/1 var(--mono);
  text-shadow: 0 1px 0 #000;
}

.marker.rover { color: var(--cyan); }

#attitude,
#hint {
  position: fixed;
  margin: 0;
  z-index: 3;
  font: 12px/1.35 var(--mono);
  color: #d7dbe3;
  background: rgba(8, 10, 16, 0.55);
  border: 1px solid var(--line);
  padding: 6px 8px;
}

#attitude { left: 16px; bottom: 174px; }
#hint {
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  color: #c5cad3;
  white-space: nowrap;
}

.touch-bar { position: fixed; inset: 0; z-index: 4; pointer-events: none; }

#stick {
  position: fixed;
  left: calc(18px + env(safe-area-inset-left));
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(8, 10, 16, 0.45);
  pointer-events: auto;
  touch-action: none;
}

#knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(255, 176, 32, 0.85);
}

#btn-fire {
  position: fixed;
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(28px + env(safe-area-inset-bottom));
  width: 92px;
  height: 92px;
  border-radius: 50%;
  pointer-events: auto;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#overlay {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow: auto;
  background: rgba(5, 6, 10, 0.42);
}

.panel {
  width: min(520px, 100%);
  padding: 22px 22px 18px;
  background: #10141c;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.panel h1,
.panel h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

.panel .note,
.panel .bestline { color: #c5cad3; margin: 12px 0 0; }

.controls {
  display: grid;
  gap: 6px;
  margin: 14px 0 0;
}

.controls div {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
}

.controls dt {
  margin: 0;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.controls dd { margin: 0; color: var(--ink); }

.end-score {
  margin: 10px 0 0;
  font: 760 3rem/1 var(--mono);
  color: var(--amber);
}

.panel .actions { margin-top: 16px; }

.noscript {
  position: fixed;
  z-index: 7;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
}

body.touch #inset-frame {
  left: 50%;
  right: auto;
  bottom: auto;
  top: calc(108px + env(safe-area-inset-top));
  width: 168px;
  height: 104px;
  transform: translateX(-50%);
}

body.touch #attitude {
  left: auto;
  right: 14px;
  bottom: auto;
  top: calc(174px + env(safe-area-inset-top));
}

body.touch #hint { display: none; }

@media (max-width: 820px) {
  #hint { display: none; }
  .stat b { font-size: 1rem; }
  #inset-frame { width: 168px; height: 104px; }
  #attitude { bottom: 128px; }
}

@media (max-width: 560px) {
  .controls div { grid-template-columns: 78px 1fr; }
  #attitude { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #popup.show { animation: none; opacity: 1; }
}
