:root {
  --purple: #6a659e;
  --white: #ffffff;
  color-scheme: light;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--purple);
  color: var(--white);
  font-family: "Monaco", "Consolas", monospace;
  overscroll-behavior: none;
}
body {
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#cabinet {
  position: relative;
  height: min(100%, 840px);
  aspect-ratio: 3/5;
  max-width: 100%;
  overflow: hidden;
  container-type: inline-size;
  border-inline: 1px solid white;
  touch-action: none;
  user-select: none;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
button {
  font:
    700 11px "Monaco",
    "Consolas",
    monospace;
  color: var(--white);
  background: var(--purple);
  border: 1px solid white;
  border-radius: 0;
  cursor: pointer;
  min-height: 44px;
  touch-action: none;
}
button:active,
button.pressed {
  background: var(--white);
  color: var(--purple);
}
button:focus-visible {
  outline: 3px dashed white;
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
.overlay {
  position: absolute;
  inset: 0;
  padding: 8% 9%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  text-align: center;
  background: var(--purple);
}
#menu {
  background: none;
  justify-content: flex-start;
  padding-top: 10%;
}
.eyebrow {
  font-size: 2.4cqw;
  letter-spacing: 0.15em;
  margin: 0 0 7%;
}
h1 {
  font-size: 15cqw;
  letter-spacing: -0.09em;
  line-height: 1;
  margin: 0 0 5%;
  font-weight: 900;
  animation: float 3s steps(4) infinite;
}
h1:after {
  content: "";
  display: block;
  width: 100%;
  height: 4px;
  background: white;
  margin-top: 8%;
}
.tagline {
  font-size: 3cqw;
  letter-spacing: 0.12em;
  line-height: 1.6;
  margin: 0;
}
.mission {
  display: flex;
  gap: 12px;
  text-align: left;
  align-items: center;
  margin-top: auto;
  margin-bottom: 7%;
  background: var(--purple);
  border-block: 1px solid white;
  padding: 4% 0;
  font-size: 3cqw;
}
.mission > span {
  font-size: 8cqw;
  border-right: 1px solid white;
  padding-right: 12px;
}
.mission small {
  display: block;
  font-size: 2cqw;
  margin-top: 5px;
}
.primary {
  font-size: 4cqw;
  letter-spacing: 0.15em;
  padding: 4% 6%;
  background: white;
  color: var(--purple);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
}
.hint {
  font-size: 2.1cqw;
  line-height: 1.8;
  margin: 5% 0;
}
.settings {
  display: flex;
  gap: 8px;
}
.settings button {
  flex: 1;
  font-size: 2.5cqw;
}
#best {
  font-size: 2.5cqw;
  letter-spacing: 0.13em;
  margin: 5% 0;
}
footer {
  font-size: 2cqw;
  letter-spacing: 0.12em;
}
#dialog {
  inset: 19% 7% 23%;
  border: 2px solid white;
  padding: 7%;
  gap: 12px;
  z-index: 4;
}
h2 {
  font-size: 9cqw;
  line-height: 1;
  margin: 0;
}
#dialogText {
  font-size: 3cqw;
  line-height: 1.8;
  white-space: pre-line;
}
#hud {
  position: absolute;
  inset: 0 0 auto;
  pointer-events: none;
}
#pause {
  position: absolute;
  right: 2%;
  top: 7px;
  width: 44px;
  pointer-events: auto;
  background: var(--purple);
}
/* Same bottom flight area; touch targets remain full rectangles around icons. */
#controls {
  position: absolute;
  bottom: 1%;
  left: 3%;
  right: 3%;
  height: 17.6%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 2px solid white;
  padding-top: 5%;
  background: var(--purple);
  isolation: isolate;
}
.panel-rail {
  position: absolute;
  top: 3%;
  left: 1%;
  right: 1%;
  display: flex;
  justify-content: space-between;
  font-size: 1.7cqw;
  letter-spacing: 0.06em;
  pointer-events: none;
}
#stick {
  position: relative;
  width: 32%;
  height: 96%;
  touch-action: none;
  max-width: 130px;
}
#stick span {
  position: absolute;
  display: grid;
  place-items: center;
  width: 34%;
  height: 34%;
  font-size: 2.8cqw;
  color: white;
  background: var(--purple);
  border: 1px solid white;
  pointer-events: none;
}
#stick .pad-up {
  left: 33%;
  top: 0;
  border-bottom: 0;
}
#stick .pad-down {
  left: 33%;
  top: 66%;
  border-top: 0;
}
#stick .pad-left {
  left: 0;
  top: 33%;
  border-right: 0;
}
#stick .pad-right {
  left: 66%;
  top: 33%;
  border-left: 0;
}
#stick #knob {
  left: 33%;
  top: 33%;
  border: 0;
  background: var(--purple);
}
#knob:after {
  transform: translate(var(--thumb-x, 0px), var(--thumb-y, 0px));
  content: "";
  width: 18%;
  height: 18%;
  background: white;
}
#stick[data-x="-1"] .pad-left,
#stick[data-x="1"] .pad-right,
#stick[data-y="-1"] .pad-up,
#stick[data-y="1"] .pad-down {
  background: white;
  color: var(--purple);
}
#controls button {
  position: relative;
  display: block;
  min-height: 44px;
  background: var(--purple);
  border: 0;
  touch-action: none;
}
#missile {
  width: 23%;
  height: 86%;
  margin: 0;
  outline: 1px solid white;
  outline-offset: -6px;
  clip-path: polygon(
    12% 0,
    88% 0,
    100% 12%,
    100% 88%,
    88% 100%,
    12% 100%,
    0 88%,
    0 12%
  );
}
#missile:before,
#missile:after {
  content: "";
  position: absolute;
  top: 15%;
  bottom: 15%;
  width: 3px;
  background: white;
}
#missile:before {
  left: 8%;
}
#missile:after {
  right: 8%;
}
.missile-symbol {
  position: absolute;
  inset: 15% 26% 30%;
  background: currentColor;
  mask: url(assets/M.svg) center/contain no-repeat;
  -webkit-mask: url(assets/M.svg) center/contain no-repeat;
  image-rendering: pixelated;
}
#ammo {
  position: absolute;
  bottom: 10%;
  left: 0;
  right: 0;
  font-size: 3cqw;
  letter-spacing: 0.12em;
}
#fire {
  width: 29%;
  height: 95%;
  aspect-ratio: 1;
  margin: 0;
}
.fire-ring {
  position: absolute;
  inset: 8%;
  border: 2px solid white;
  clip-path: polygon(
    25% 0,
    75% 0,
    100% 25%,
    100% 75%,
    75% 100%,
    25% 100%,
    0 75%,
    0 25%
  );
}
.fire-ring:after {
  content: "";
  position: absolute;
  inset: 10%;
  border: 1px dashed white;
}
.fire-symbol {
  position: absolute;
  inset: 28%;
  background: currentColor;
  mask: url(assets/fire.svg) center/contain no-repeat;
  -webkit-mask: url(assets/fire.svg) center/contain no-repeat;
  image-rendering: pixelated;
}
#controls button.pressed .fire-symbol {
  transform: scale(0.86);
}
#controls button.pressed {
  background: white;
  color: var(--purple);
}
#controls button.pressed .fire-ring {
  border-color: var(--purple);
}
#missile.empty {
  outline-style: dashed;
}
#missile.empty .missile-symbol {
  background: none;
  border-top: 2px solid white;
  transform: rotate(-45deg);
  mask: none;
  -webkit-mask: none;
  top: 46%;
  bottom: 46%;
}
#missile.empty:before,
#missile.empty:after {
  background: none;
  border: 1px dashed white;
}
#missile.launching .missile-symbol {
  animation: launch 0.18s steps(3);
}
@keyframes launch {
  50% {
    transform: translateY(-20%);
  }
}
@keyframes float {
  50% {
    transform: translateY(-3px);
  }
}
@media (prefers-reduced-motion: reduce) {
  h1 {
    animation: none;
  }
}
@media (max-aspect-ratio: 3/5) {
  #cabinet {
    width: 100%;
    height: auto;
  }
}

.hint {
  background: var(--purple);
  padding: 6px 0;
}
h1 {
  font-size: 0;
  height: 14cqw;
  background: url(title.svg) center/100% auto no-repeat;
}
h1:after {
  margin-top: 16cqw;
}

#dialog {
  inset: 15% 7% 21%;
  gap: 9px;
}
#dialog .primary {
  font-size: 2.9cqw;
  letter-spacing: 0.04em;
}
#dialog h2 {
  font-size: 8cqw;
}
#dialog .eyebrow {
  margin-bottom: 2%;
}
#dialogText {
  margin: 3% 0;
}
#dialog button {
  flex-shrink: 0;
}

