:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #02030a;
}

* {
  box-sizing: border-box;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

html,
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

html {
  height: -webkit-fill-available;
}

body {
  display: grid;
  place-items: center;
  min-height: 100%;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  height: 100%;
  height: -webkit-fill-available;
  height: 100dvh;
  background:
    radial-gradient(circle at 50% 40%, #111a3a 0%, #050713 45%, #02030a 100%);
}

.game-shell {
  position: fixed;
  inset: 0;
  display: grid;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  place-items: center;
  overflow: hidden;
  touch-action: none;
}

#game {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: #050713;
  border: 0;
  outline: none;
  touch-action: none;
  user-select: none;
}

#game:focus-visible {
  box-shadow: 0 0 0 2px #6fffea, 0 0 24px #36d9ff66;
}

.sound-enable {
  position: fixed;
  left: 50%;
  top: auto;
  right: auto;
  bottom: max(148px, calc(18dvh + env(safe-area-inset-bottom)));
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  padding: 12px 18px;
  max-width: min(280px, calc(100% - 40px));
  border: 1px solid #72fff188;
  border-radius: 999px;
  color: #eaffff;
  background: rgba(5, 12, 28, 0.9);
  box-shadow: 0 0 22px #43e7ff33, inset 0 0 12px #43e7ff18;
  font: 700 15px/1.25 "Segoe UI", sans-serif;
  text-align: center;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: auto;
  touch-action: manipulation;
  cursor: pointer;
  opacity: 0.96;
}

.sound-enable-icon {
  display: block;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M3 10v4h4l5 5V5L7 10H3zm13.5 2c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z'/%3E%3C/svg%3E")
    center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M3 10v4h4l5 5V5L7 10H3zm13.5 2c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.sound-enable-label {
  min-width: 0;
}

.sound-enable:active {
  background: #72fff1;
  color: #06101c;
}

body[data-game-state="TITLE"] .sound-enable:not([hidden]) {
  display: inline-flex;
}

@media (hover: none), (pointer: coarse) {
  .sound-enable {
    bottom: max(168px, calc(22dvh + env(safe-area-inset-bottom)));
    padding: 14px 20px;
    max-width: min(300px, calc(100% - 32px));
    font-size: 16px;
    gap: 12px;
  }

  .sound-enable-icon {
    width: 22px;
    height: 22px;
  }
}

@media (max-width: 360px) {
  .sound-enable {
    white-space: normal;
    max-width: calc(100% - 28px);
    padding: 12px 16px;
    font-size: 14px;
  }
}

.touch-controls {
  position: fixed;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 12px;
  display: none;
  grid-template-columns: minmax(100px, 116px) 1fr minmax(82px, 100px);
  grid-template-rows: 116px;
  gap: 8px;
  align-items: end;
  pointer-events: none;
}

.touch-controls button {
  display: none;
  min-width: 0;
  min-height: 54px;
  border: 1px solid #72fff188;
  border-radius: 12px;
  color: #eaffff;
  background: #07132ccc;
  box-shadow: inset 0 0 16px #43e7ff1f;
  font: 700 16px "Segoe UI", sans-serif;
  pointer-events: auto;
  touch-action: none;
}

.touch-controls button:active {
  color: #06101c;
  background: #72fff1;
}

.virtual-joystick {
  position: relative;
  display: none;
  grid-column: 1;
  grid-row: 1;
  width: min(116px, 28vw);
  height: min(116px, 28vw);
  align-self: end;
  justify-self: start;
  border: 2px solid #72fff155;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    #14305055 0 22%,
    #07132c88 24% 68%,
    #72fff10f 70%
  );
  box-shadow: inset 0 0 22px #43e7ff1a, 0 0 14px #43e7ff12;
  opacity: 0.55;
  pointer-events: auto;
  touch-action: none;
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  border: 1px solid #c7ffff77;
  border-radius: 50%;
  background: #52cfe0bb;
  box-shadow: 0 0 16px #43e7ff66;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.touch-controls .fire-button {
  grid-column: 3;
  grid-row: 1;
  width: min(92px, 24vw);
  height: min(92px, 24vw);
  min-height: 0;
  align-self: end;
  justify-self: end;
  border-color: #ff55bd99;
  border-radius: 50%;
  opacity: 0.62;
}

.touch-controls .start-button {
  grid-column: 1 / span 3;
  grid-row: 1;
  align-self: center;
  justify-self: center;
  width: min(220px, 70vw);
}

body[data-game-state="TITLE"] .start-button,
body[data-game-state="GAME_OVER"] .start-button,
body[data-game-state="VICTORY"] .start-button {
  display: block;
}

body[data-game-state="PLAYING"] .virtual-joystick,
body[data-game-state="PLAYER_DEAD"] .virtual-joystick,
body[data-game-state="PLAYING"] .fire-button,
body[data-game-state="PLAYER_DEAD"] .fire-button {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (hover: none), (pointer: coarse) {
  .touch-controls {
    display: grid;
  }

  #game:focus-visible {
    box-shadow: none;
  }
}
