* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #000000;
  color: #f4efe6;
  font-family: "Press Start 2P", monospace;
}

body {
  min-height: 100dvh;
}

#title-splash {
  position: fixed;
  inset: 0;
  z-index: 40;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000000;
  display: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body.title-mode #title-splash {
  display: block;
}

body.title-mode #touch {
  display: none;
}

body.title-mode #app {
  visibility: hidden;
  pointer-events: none;
}

body.title-mode #mute {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: calc(8px + env(safe-area-inset-left));
  z-index: 50;
  visibility: visible;
  pointer-events: auto;
}

#title-splash img,
#legal-splash img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

#legal-splash {
  position: fixed;
  inset: 0;
  z-index: 45;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000000;
  display: none;
  pointer-events: none;
}

body.legal-mode #legal-splash {
  display: block;
}

body.legal-mode #title-splash {
  display: none;
}

body.legal-mode #touch {
  display: none;
}

body.legal-mode #app {
  visibility: hidden;
  pointer-events: none;
}

body.legal-mode #mute {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: calc(8px + env(safe-area-inset-left));
  z-index: 50;
  visibility: visible;
  pointer-events: auto;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
}

#stage {
  position: relative;
  width: min(100%, calc((100dvh - 210px) * 256 / 224));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#game {
  width: 100%;
  height: auto;
  background: #000000;
  touch-action: none;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#mute {
  position: static;
  margin-top: 8px;
  z-index: 2;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: #f4efe6;
  background: #0a0c0e;
  border: 3px solid #45b1d1;
  padding: 8px 10px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#mute[aria-pressed="true"] {
  color: #000000;
  background: #e07a2a;
  border-color: #e07a2a;
}

#touch {
  width: min(100%, 520px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#stick {
  position: relative;
  width: 128px;
  height: 128px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 3px solid #2a343c;
  background:
    radial-gradient(circle at 50% 42%, #2a333a 0 18%, transparent 19%),
    radial-gradient(circle at 50% 58%, #101418 0 46%, #07090b 47% 100%);
  box-shadow: inset 0 8px 14px rgba(0, 0, 0, 0.55);
  touch-action: none;
}

#stick-knob {
  position: absolute;
  left: calc(50% - 26px);
  top: calc(50% - 26px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #f2f5f7, #b7c0c8 62%, #8d979f);
  border: 3px solid #6d767e;
  box-shadow: 0 4px 0 #3a4248;
  pointer-events: none;
}

.face {
  display: grid;
  grid-template-columns: 56px 56px 56px;
  grid-template-rows: 56px 56px 56px;
  gap: 6px;
  flex: 0 0 auto;
}

#special { grid-column: 2; grid-row: 1; }
#attack { grid-column: 1; grid-row: 2; }
#talk { grid-column: 3; grid-row: 2; }
#jump { grid-column: 2; grid-row: 3; }

#touch button {
  font-family: inherit;
  color: inherit;
  background: #0a0c0e;
  border: 3px solid #2c3338;
  width: 56px;
  height: 56px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.face svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

#touch #special { color: #3dcc6d; }
#touch #attack { color: #e07ad1; }
#touch #talk { color: #e23d4a; }
#touch #jump { color: #4c8dff; }

#touch button:active {
  background: #1a2228;
  border-color: currentColor;
}

@media (max-width: 899px) {
  #app {
    height: 100dvh;
    justify-content: flex-start;
    gap: 8px;
    padding:
      env(safe-area-inset-top)
      0
      calc(8px + env(safe-area-inset-bottom));
  }

  #stage {
    width: 100%;
    flex: 1;
    min-height: 0;
    align-items: center;
    justify-content: center;
  }

  #mute {
    position: absolute;
    top: 48px;
    left: 8px;
    right: auto;
    bottom: auto;
    margin-top: 0;
  }

  #touch {
    width: 100%;
    padding: 0 12px 4px;
  }
}

@media (max-width: 359px) {
  #stick {
    width: 104px;
    height: 104px;
  }

  #stick-knob {
    width: 44px;
    height: 44px;
    left: calc(50% - 22px);
    top: calc(50% - 22px);
  }

  .face {
    grid-template-columns: 46px 46px 46px;
    grid-template-rows: 46px 46px 46px;
    gap: 4px;
  }

  #touch button {
    width: 46px;
    height: 46px;
  }
}

@media (pointer: fine) and (min-width: 900px) {
  #app {
    gap: 0;
  }

  #stage {
    width: min(92vw, calc(92dvh * 256 / 224));
    display: block;
  }

  #mute {
    position: absolute;
    top: 8px;
    right: 8px;
    margin-top: 0;
  }

  #touch {
    display: none;
  }
}
