:root {
  color-scheme: dark;
  --sky: #77c9ff;
  --deep: #163a78;
  --ink: #fff7d6;
  --line: #1661a8;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 30% 20%, #ffe66d 0 1px, transparent 1px 100%),
    linear-gradient(180deg, #3ac6ff 0%, #3f8cff 45%, #24603d 100%);
  background-size: 18px 18px, auto;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
}

.shell {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: center;
  padding: 18px;
}

.game-wrap {
  aspect-ratio: 16 / 9;
  background: #77c9ff;
  border: 2px solid #083b78;
  box-shadow: 0 24px 80px #08214c99, inset 0 0 0 1px #b6edff;
  max-height: calc(100vh - 36px);
  max-width: min(100vw - 36px, 1180px);
  position: relative;
  width: 100%;
  touch-action: none;
}

.game-wrap:fullscreen {
  align-items: center;
  background: #050914;
  border: 0;
  box-shadow: none;
  display: flex;
  height: 100vh;
  justify-content: center;
  max-height: none;
  max-width: none;
  width: 100vw;
}

.game-wrap:fullscreen canvas {
  flex: 0 0 auto;
  height: 100vh;
  max-height: none;
  max-width: none;
  object-fit: fill;
  width: 100vw;
}

.game-wrap:fullscreen .hud,
.game-wrap:fullscreen .toast {
  z-index: 2;
}

canvas {
  display: block;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
  width: 100%;
}

.hud {
  display: flex;
  gap: 10px;
  left: 16px;
  pointer-events: none;
  position: absolute;
  top: 14px;
}

.hud div {
  align-items: baseline;
  background: #17275dcc;
  border: 1px solid #fff4a3;
  border-radius: 8px;
  display: flex;
  gap: 7px;
  min-width: 84px;
  padding: 7px 10px;
}

.hud span {
  color: #fff4a3;
  font-size: clamp(16px, 2vw, 24px);
  font-weight: 850;
  line-height: 1;
  tabular-nums: lining-nums;
}

.hud small {
  color: #c8efff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.toast {
  background: #fff4a3;
  border: 2px solid #17275d;
  border-radius: 8px;
  bottom: 22px;
  box-shadow: 5px 5px 0 #17275d;
  color: #17275d;
  font-size: clamp(14px, 1.7vw, 20px);
  font-weight: 850;
  left: 50%;
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  position: absolute;
  text-align: center;
  transform: translateX(-50%);
  transition: opacity .2s ease, transform .2s ease;
  white-space: nowrap;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}

.start-volume {
  background: #17275dcc;
  border: 2px solid #fff4a3;
  border-radius: 8px;
  box-shadow: 0 5px 0 #08183e99;
  color: #fff4a3;
  cursor: pointer;
  font-size: 17px;
  font-weight: 900;
  padding: 10px 14px;
  pointer-events: auto;
  position: absolute;
  right: 92px;
  top: 28px;
  z-index: 4;
}

.start-volume.hidden {
  display: none;
}

.start-volume:active {
  background: #fff4a3;
  box-shadow: 0 2px 0 #08183e99;
  color: #17275d;
  transform: translateY(3px);
}

.touch-controls {
  bottom: max(14px, env(safe-area-inset-bottom));
  display: none;
  left: max(14px, env(safe-area-inset-left));
  pointer-events: none;
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  top: max(14px, env(safe-area-inset-top));
  z-index: 3;
}

body.touch-enabled .touch-controls {
  display: block;
}

.touch-move,
.touch-actions {
  display: flex;
  gap: 10px;
  position: absolute;
}

.touch-move {
  bottom: 0;
  left: 0;
}

.touch-actions {
  right: 0;
  top: 0;
}

.touch-button,
.touch-chip {
  align-items: center;
  background: #17275dcc;
  border: 2px solid #fff4a3;
  box-shadow: 0 6px 0 #08183e99;
  color: #fff7df;
  display: flex;
  font-weight: 900;
  justify-content: center;
  line-height: 1;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-button {
  border-radius: 999px;
  font-size: clamp(28px, 6vw, 46px);
  height: clamp(64px, 13vmin, 92px);
  width: clamp(64px, 13vmin, 92px);
}

.touch-chip {
  border-radius: 8px;
  font-size: clamp(13px, 2.5vw, 18px);
  height: clamp(36px, 7vmin, 48px);
  width: clamp(36px, 7vmin, 48px);
}

.touch-jump {
  bottom: 0;
  position: absolute;
  right: 0;
}

.touch-button:active,
.touch-button.is-held,
.touch-chip:active {
  background: #fff4a3;
  color: #17275d;
  transform: translateY(4px);
  box-shadow: 0 2px 0 #08183e99;
}

@media (pointer: coarse), (max-width: 900px) {
  .shell {
    padding: 0;
  }

  .game-wrap {
    aspect-ratio: auto;
    border: 0;
    box-shadow: none;
    height: 100vh;
    max-height: none;
    max-width: none;
    width: 100vw;
  }

  .touch-controls {
    display: block;
  }

  .toast {
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + clamp(78px, 15vmin, 110px));
  }
}

@media (max-aspect-ratio: 4 / 3) {
  .touch-actions {
    gap: 6px;
  }

  .touch-chip {
    height: 34px;
    width: 34px;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 0;
  }

  .game-wrap {
    border: 0;
    max-height: 100vh;
    max-width: 100vw;
  }

  .hud {
    gap: 6px;
    left: 8px;
    top: 8px;
  }

  .hud div {
    min-width: 62px;
    padding: 5px 7px;
  }

  .hud small {
    display: none;
  }
}
