html,
body {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  overflow: hidden;
  background: #020814;
}

body {
  display: flex;
  flex-direction: column;
}

.game-hud {
  position: relative;
  z-index: 15;
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 1px;
  width: 100%;
  border-bottom: 3px solid #ffd33d;
  background: #06182b;
  box-shadow: 0 5px 18px rgba(0, 0, 0, .28);
  color: #fff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.game-hud span {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  padding: 9px 12px 8px;
  background: #0b2a49;
}

.game-hud small {
  color: #78b9f7;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
}

.game-hud strong {
  color: #ffd33d;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

canvas {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: auto;
  object-fit: contain;
  background: #fff;
  touch-action: none;
}

.touch-controls {
  position: relative;
  z-index: 20;
  display: none;
  flex: 0 0 auto;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(2, 58px);
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  width: 100%;
  padding: 9px max(9px, env(safe-area-inset-right)) max(9px, env(safe-area-inset-bottom)) max(9px, env(safe-area-inset-left));
  border-top: 2px solid #ffd33d;
  background: #06182b;
  box-shadow: 0 -5px 18px rgba(0, 0, 0, .26);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.touch-control {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 13px;
  background: #0c335b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16);
  color: #fff;
  font: 900 28px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-control--up { grid-column: 2; grid-row: 1; }
.touch-control--left { grid-column: 1; grid-row: 2; }
.touch-control--down { grid-column: 2; grid-row: 2; }
.touch-control--right { grid-column: 3; grid-row: 2; }

.touch-control:active,
.touch-control.is-active {
  border-color: #ffd33d;
  background: #ffd33d;
  color: #06182b;
  transform: translateY(1px);
}

@media (hover: none), (pointer: coarse), (max-width: 760px) {
  .touch-controls { display: grid; }
}

@media (max-width: 430px), (max-height: 520px) {
  .game-hud {
    grid-template-columns: repeat(3, 1fr);
    border-bottom-width: 2px;
  }

  .game-hud span {
    display: grid;
    gap: 2px;
    padding: 5px 6px 6px;
    text-align: center;
  }

  .game-hud small { font-size: 8px; }
  .game-hud strong { font-size: 17px; }

  .touch-controls {
    grid-template-columns: repeat(3, 56px);
    grid-template-rows: repeat(2, 56px);
    gap: 8px;
    padding-top: 7px;
    padding-bottom: max(7px, env(safe-area-inset-bottom));
  }

  .touch-control {
    width: 56px;
    height: 56px;
    border-radius: 13px;
    font-size: 28px;
  }
}
