:root {
  --bg-0: #111313;
  --bg-1: #171b1b;
  --ink: #d4dbd7;
  --ink-dim: #8d9b95;
  --accent: #4ea292;
  --panel: #121616;
  --edge: #26302c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 25% 10%, #1d2322, var(--bg-0) 55%);
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
  text-rendering: optimizeSpeed;
  -webkit-font-smoothing: none;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.75rem;
  padding: 1rem;
  max-width: 1100px;
  margin: 0 auto;
}

.hud,
.help {
  border: 1px solid var(--edge);
  background: linear-gradient(180deg, #161b1b, #121616);
  padding: 0.65rem 0.8rem;
}

.hud h1 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.hud p,
.help p {
  margin: 0.45rem 0 0;
  color: var(--ink-dim);
  font-size: 0.9rem;
}

.stage {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
  min-height: 0;
}

#barren-canvas {
  width: min(96vw, calc(100vh * 1.3333));
  max-width: 100%;
  border: 2px solid #384540;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.viewport-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.viewport-controls button {
  background: #182220;
  color: #cae9e1;
  border: 1px solid #315046;
  padding: 0.35rem 0.6rem;
  font: inherit;
  cursor: pointer;
}

.viewport-controls button[aria-pressed="true"] {
  border-color: #6dc1ad;
  background: #213430;
}

.stage.stage-enlarged {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgb(0 0 0 / 0.9);
  padding: 0.75rem;
}

.stage.stage-enlarged #barren-canvas {
  width: min(96vw, calc((100vh - 72px) * 1.3333));
  max-width: none;
}

#game-stage:fullscreen {
  background: #000;
  padding: 0.75rem;
}

#game-stage:fullscreen #barren-canvas {
  width: min(96vw, calc((100vh - 72px) * 1.3333));
  max-width: none;
}

#terminal-overlay {
  position: fixed;
  inset: 0;
  place-items: center;
  background: rgb(0 0 0 / 0.7);
  z-index: 100;
}

#terminal-overlay[hidden] {
  display: none;
}

#terminal-overlay:not([hidden]) {
  display: grid;
  position: fixed;
  inset: 0;
}

.terminal-window {
  width: min(500px, 94vw);
  background: #0e1111;
  border: 1px solid #2e413b;
  box-shadow: 0 16px 42px rgb(0 0 0 / 0.5);
}

.terminal-window header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid #2e413b;
  color: #81d3bf;
}

.terminal-window button {
  background: #182220;
  color: #cae9e1;
  border: 1px solid #315046;
  padding: 0.25rem 0.45rem;
  font: inherit;
  cursor: pointer;
}

.terminal-window canvas[data-terminal-canvas] {
  display: block;
  width: min(480px, 100%);
  margin: 0 auto;
  aspect-ratio: 4 / 3;
  max-height: min(72vh, 70vw);
  background: #050709;
  border-top: 1px solid #2e413b;
  border-bottom: 1px solid #2e413b;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.terminal-window pre {
  display: none;
}

.terminal-window form {
  border-top: 1px solid #2e413b;
  padding: 0.45rem 0.7rem;
}

.terminal-window label {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.4rem;
}

.terminal-window input {
  width: 100%;
  background: #081010;
  border: 1px solid #2b4a40;
  color: #d7eee5;
  padding: 0.35rem 0.45rem;
  font: inherit;
}
