:root {
  color-scheme: light;
  font-family: "Courier New", Courier, monospace;
  background: #f4f1e8;
  color: #171717;
  user-select: none;
  -webkit-user-select: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

button {
  font: inherit;
}

.stage {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 360px;
  place-items: center;
  isolation: isolate;
}

.spinner {
  width: min(86vw, 980px, calc(96dvh * 16 / 9));
  max-width: 100%;
  aspect-ratio: 16 / 9;
  outline: none;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.spinner:active,
.spinner.isDragging {
  cursor: grabbing;
}

.spinner:focus-visible {
  filter: drop-shadow(0 0 1px #111) drop-shadow(0 0 5px #fff);
}

.spinner canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

.fallback {
  position: relative;
  display: none;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-size: 900% 800%;
  image-rendering: auto;
  pointer-events: none;
}

.fallbackVideo {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.fallbackVideo.isActive {
  display: block;
}

.spinner.isFallback .fallback {
  display: block;
}

.spinner.isFallback #scene {
  display: none;
}

.speed,
.sound {
  position: absolute;
  margin: 0;
  border: 0;
  color: #171717;
  font-size: clamp(0.65rem, 1.5vw, 0.8rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 8px 9px;
  background: #171717;
  color: #f4f1e8;
}

.sound {
  top: max(20px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sound[disabled] {
  cursor: not-allowed;
  opacity: 0.38;
}

.speed {
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  min-height: 44px;
  display: grid;
  align-items: center;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .spinner {
    width: min(96vw, calc(96dvh * 16 / 9));
  }

  .sound {
    left: max(12px, env(safe-area-inset-left));
  }

  .speed {
    right: max(12px, env(safe-area-inset-right));
  }

  .sound,
  .speed {
    top: max(12px, env(safe-area-inset-top));
  }
}

@media (max-height: 420px) and (orientation: landscape) {
  .stage {
    min-height: 0;
  }

  .spinner {
    width: min(82vw, calc(100dvh * 16 / 9));
  }

  .sound,
  .speed {
    top: max(8px, env(safe-area-inset-top));
  }

  .sound {
    left: max(8px, env(safe-area-inset-left));
  }

  .speed {
    right: max(8px, env(safe-area-inset-right));
  }
}
