:root {
  color-scheme: dark;
  --bg: #050816;
  --frame: #111a2f;
  --line: #31415f;
  --text: #edf2ff;
  --accent: #7dd3fc;
  --accent-2: #facc15;
  --danger: #fb7185;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #050816;
  overflow: hidden;
  font-family: "Courier New", monospace;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.app-shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
}

.stage-wrap {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.stage-frame {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(4, 8, 18, 0.9), rgba(8, 14, 28, 0.92));
  border: 4px solid var(--line);
  box-shadow:
    0 0 0 4px rgba(7, 12, 22, 0.92),
    0 18px 40px rgba(0, 0, 0, 0.4);
  image-rendering: pixelated;
}

canvas {
  display: block;
  width: 640px;
  height: 360px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #050816;
  touch-action: none;
}

.touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.touch-cluster {
  position: absolute;
  bottom: 10px;
  display: grid;
  gap: 8px;
  pointer-events: auto;
}

.touch-dpad {
  left: 10px;
  width: 140px;
  height: 116px;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  grid-template-areas:
    ". up ."
    "left down right";
}

.touch-actions {
  right: 10px;
  width: 170px;
  grid-template-columns: repeat(2, 1fr);
}

.touch-btn {
  appearance: none;
  border: 3px solid #385079;
  background: rgba(17, 26, 47, 0.92);
  color: var(--text);
  min-height: 48px;
  padding: 0 10px;
  font: 700 13px/1 "Courier New", monospace;
  letter-spacing: 0.04em;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.26);
  touch-action: manipulation;
  user-select: none;
}

.touch-btn:active,
.touch-btn.is-active {
  transform: translateY(2px);
  background: rgba(41, 64, 107, 0.98);
}

.touch-btn.up {
  grid-area: up;
}

.touch-btn.left {
  grid-area: left;
}

.touch-btn.down {
  grid-area: down;
}

.touch-btn.right {
  grid-area: right;
}

.touch-btn.jump {
  border-color: #6b7da8;
  background: rgba(28, 45, 73, 0.94);
}

.touch-btn.pause {
  border-color: #8b4256;
  background: rgba(61, 26, 43, 0.94);
}

@media (pointer: fine) {
  .touch-controls {
    display: none;
  }
}
