@font-face {
  font-family: prstart;
  src: url('../fonts/prstart.ttf');
}
body {
  font-family: prstart;
  font-size: 16px;
  background-color: black;
  margin-top: 30px;
}
#main {
  margin: 0 auto;
  width: min(90vw, 768px);
  color: white;
}

#main canvas {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
#help {
  border-top: 4px solid white;
  margin-top: 10px;
  padding-top: 7px;
}
#help img {
  vertical-align: middle;
}
#help td {
  padding-left: 1em;
}

#cheat-status {
  margin-top: 10px;
  border-top: 4px solid #666;
  padding-top: 7px;
  color: #aaa;
  line-height: 1.6;
}

#touch-controls {
  display: none;
  margin-top: 16px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#touch-controls * {
  box-sizing: border-box;
}

.touch-row,
.touch-actions,
.touch-pad-middle {
  display: flex;
  gap: 10px;
}

.touch-top,
.touch-bottom,
.touch-attack {
  display: flex;
  gap: 10px;
}

.touch-row,
.touch-actions {
  justify-content: center;
  margin-bottom: 10px;
}

.touch-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.touch-top {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.touch-bottom {
  justify-content: space-between;
  align-items: center;
}

.touch-attack {
  flex-direction: column;
  align-items: stretch;
}

.touch-btn {
  min-width: 74px;
  min-height: 54px;
  border-radius: 12px;
  border: 3px solid white;
  background: #111;
  color: white;
  font-family: prstart;
  font-size: 12px;
  padding: 8px 10px;
}

.touch-btn.is-active {
  background: white;
  color: black;
}

.touch-btn-fire,
.touch-btn-rapid {
  min-width: 96px;
}

@media (max-width: 700px) {
  body {
    margin-top: 12px;
    margin-left: 0;
    margin-right: 0;
  }

  #main {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 512px;
  }

  #main,
  #help,
  #touch-controls {
    margin-left: auto;
    margin-right: auto;
  }

  #help {
    padding-left: 8px;
    padding-right: 8px;
    order: 3;
  }

  #cheat-status {
    display: none !important;
  }

  #touch-controls {
    display: block;
    order: 2;
    padding: 10px 8px 20px;
    width: 100%;
  }

  #main canvas {
    order: 1;
  }

  .touch-btn {
    min-width: 84px;
    min-height: 62px;
    font-size: 11px;
  }

  .touch-top {
    align-items: flex-start;
  }

  .touch-pad {
    margin-bottom: 0;
  }

  .touch-pad-middle {
    gap: 6px;
  }

  .touch-attack {
    width: 42%;
    max-width: 180px;
  }

  .touch-btn-fire,
  .touch-btn-rapid {
    width: 100%;
    min-width: 0;
    min-height: 72px;
  }

  .touch-btn-select,
  .touch-btn-start {
    flex: 0 0 calc(50% - 6px);
    min-height: 52px;
  }

  .touch-btn-up,
  .touch-btn-down {
    min-width: 92px;
  }

  .touch-btn-left,
  .touch-btn-right {
    min-width: 110px;
  }
}

@media (max-width: 700px) and (orientation: portrait) {
  #touch-controls {
    max-width: 512px;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  body {
    margin-top: 8px;
  }

  #main {
    max-width: 100%;
    padding: 0 8px 16px;
  }

  #help {
    display: none;
  }

  #cheat-status {
    display: none !important;
  }

  #touch-controls {
    display: block;
    max-width: 900px;
    padding: 12px 0 0;
  }

  .touch-btn {
    min-height: 52px;
  }

  .touch-top {
    justify-content: space-between;
    align-items: center;
  }

  .touch-attack {
    width: 220px;
  }

  .touch-bottom {
    justify-content: center;
    gap: 18px;
  }

  .touch-btn-up,
  .touch-btn-down {
    min-width: 110px;
  }

  .touch-btn-left,
  .touch-btn-right {
    min-width: 120px;
  }
}
