:root {
  --night: #05030f;
  --indigo: #241a4a;
  --indigo2: #3a2a66;
  --mist: #8a84b8;
  --lantern: #fcd860;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--night);
  color: var(--mist);
  font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding-top: env(safe-area-inset-top);
}

#stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100vw;
}

#screen {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: var(--night);
  outline: none;
}

#info {
  margin: 6px 12px 0;
  text-align: center;
  font-size: 11px;
}

footer {
  padding: 4px 12px calc(6px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 10px;
  color: #5a5480;
}

.noscript { text-align: center; color: var(--lantern); }

/* On-screen controls for phones */
#touch {
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#touch[hidden] { display: none; }

.dpad {
  position: relative;
  width: 132px;
  height: 132px;
  touch-action: none;
}
.dpad .arm, .dpad .hub {
  position: absolute;
  background: var(--indigo);
  border: 2px solid var(--indigo2);
}
.dpad .up, .dpad .down { left: 44px; width: 44px; height: 46px; }
.dpad .up { top: 0; border-radius: 6px 6px 0 0; }
.dpad .down { bottom: 0; border-radius: 0 0 6px 6px; }
.dpad .left, .dpad .right { top: 44px; width: 46px; height: 44px; }
.dpad .left { left: 0; border-radius: 6px 0 0 6px; }
.dpad .right { right: 0; border-radius: 0 6px 6px 0; }
.dpad .hub { left: 44px; top: 44px; width: 44px; height: 44px; border: none; }
.dpad[data-dir="up"] .up,
.dpad[data-dir="down"] .down,
.dpad[data-dir="left"] .left,
.dpad[data-dir="right"] .right { background: var(--indigo2); border-color: var(--lantern); }

.small {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.small button, .abtn {
  font: inherit;
  color: var(--mist);
  background: var(--indigo);
  border: 2px solid var(--indigo2);
  touch-action: none;
}
.small button {
  width: 44px;
  height: 30px;
  border-radius: 15px;
  font-size: 11px;
}
.abtn {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  font-size: 26px;
  font-weight: bold;
  color: var(--lantern);
  border-color: var(--lantern);
}
.abtn.down, .small button.down { background: var(--indigo2); }

@media (max-width: 359px) {
  .dpad { transform: scale(0.85); transform-origin: left center; }
  .abtn { width: 70px; height: 70px; }
}
