:root {
  color-scheme: dark;
  --ink: #f2ead6;
  --gold: #e3aa19;
  --green: #285a42;
  --blue: #102f55;
  --brick: #8b2f25;
  --asphalt: #202a31;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(63, 111, 137, 0.35), transparent 36rem),
    linear-gradient(135deg, #111616, #091322 55%, #1c1610);
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
  touch-action: manipulation;
}

.shell {
  width: min(100vw, 1180px);
  padding: 16px;
}

.game-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1064 / 944;
  border: 5px solid #050505;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  background: #0b1013;
  overflow: hidden;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  touch-action: manipulation;
}

.pause-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  min-width: 86px;
  padding: 10px 12px;
  background: #efe8d8;
  color: #101010;
  border-radius: 8px;
}

.pause-button.hidden {
  display: none;
}

.success-button {
  position: absolute;
  left: 50%;
  top: 64%;
  z-index: 4;
  transform: translateX(-50%);
  min-width: 136px;
  padding: 12px 18px;
  background: var(--gold);
  border-radius: 10px;
  box-shadow:
    inset -3px -3px 0 rgba(0, 0, 0, 0.28),
    inset 3px 3px 0 rgba(255, 255, 255, 0.36),
    0 6px 0 rgba(0, 0, 0, 0.36);
}

.success-button.hidden {
  display: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 9, 11, 0.42);
  transition: opacity 160ms ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.panel {
  width: min(520px, calc(100% - 32px));
  border: 4px solid #0c0c0c;
  background: #efe8d8;
  color: #151515;
  padding: 24px;
  text-align: center;
  box-shadow: inset 0 0 0 4px #b79a68, 0 16px 36px rgba(0, 0, 0, 0.55);
}

.panel h1 {
  margin: 0 0 12px;
  color: var(--green);
  font-size: clamp(1.8rem, 5vw, 3.5rem);
  text-transform: uppercase;
  letter-spacing: 0;
}

.panel p {
  margin: 0 0 18px;
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  line-height: 1.35;
}

button {
  border: 3px solid #0b0b0b;
  background: var(--gold);
  color: #101010;
  font: 700 1.05rem/1 "Courier New", Courier, monospace;
  padding: 12px 18px;
  cursor: pointer;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.22);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button:active {
  transform: translateY(1px);
}

.success-button:active {
  transform: translateX(-50%) translateY(1px);
}

.controls {
  display: none;
  width: min(320px, 100%);
  margin: 14px auto 0;
  grid-template-rows: auto auto;
  gap: 8px;
  justify-items: center;
  touch-action: none;
}

.controls.hidden {
  display: none !important;
}

.controls div {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 10px;
}

.controls button {
  width: 72px;
  height: 58px;
  padding: 0;
  background: #d9d1be;
  border-radius: 10px;
  font-size: 1.4rem;
  touch-action: none;
}

@media (hover: none), (pointer: coarse) {
  .controls {
    display: grid;
  }
}

@media (max-width: 720px) {
  body {
    align-content: start;
  }

  .shell {
    padding: 8px;
  }

  .game-frame {
    border-width: 3px;
  }

  .pause-button {
    top: 8px;
    right: 8px;
    min-width: 74px;
    padding: 9px 10px;
    font-size: 0.9rem;
  }

  .success-button {
    top: 65%;
    min-width: 128px;
    padding: 11px 16px;
  }
}
