:root {
  color-scheme: dark;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background: #111316;
  color: #f6f4ed;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  overscroll-behavior: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 50% 38%, rgba(222, 214, 197, 0.12), transparent 32%),
    linear-gradient(180deg, #1a1d20 0%, #101113 100%);
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  outline: none;
  touch-action: none;
}

#scene:active {
  cursor: grabbing;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background:
    linear-gradient(180deg, rgba(15, 17, 19, 0.82), rgba(15, 17, 19, 0.54)),
    radial-gradient(circle at center, rgba(236, 228, 212, 0.12), transparent 52%);
  backdrop-filter: blur(14px);
  transition:
    opacity 260ms ease,
    visibility 260ms ease;
}

.overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader {
  width: min(360px, 100%);
  display: grid;
  justify-items: center;
  gap: 16px;
  text-align: center;
}

.loader-ring {
  width: 54px;
  height: 54px;
  border: 3px solid rgba(246, 244, 237, 0.18);
  border-top-color: #e7c16b;
  border-radius: 999px;
  animation: spin 880ms linear infinite;
}

.loader h1 {
  margin: 2px 0 0;
  font-size: clamp(28px, 9vw, 44px);
  font-weight: 760;
  line-height: 1;
}

.loader p {
  min-height: 22px;
  margin: 0;
  color: rgba(246, 244, 237, 0.72);
  font-size: 14px;
}

.progress {
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(246, 244, 237, 0.16);
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e7c16b, #f1efe5);
  transition: width 180ms ease;
}

.loader button,
.actions button {
  min-width: 48px;
  min-height: 48px;
  border: 1px solid rgba(246, 244, 237, 0.22);
  border-radius: 8px;
  background: rgba(24, 27, 29, 0.78);
  color: #f6f4ed;
  font: inherit;
  font-weight: 700;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
  touch-action: manipulation;
}

.loader button {
  width: 136px;
  margin-top: 8px;
}

.loader button:disabled {
  color: rgba(246, 244, 237, 0.42);
  background: rgba(24, 27, 29, 0.38);
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.actions {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.actions button {
  width: 48px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
}

#speedButton {
  font-size: 14px;
}

.joystick {
  position: absolute;
  left: max(22px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 124px;
  height: 124px;
  border: 1px solid rgba(246, 244, 237, 0.16);
  border-radius: 999px;
  background: rgba(20, 23, 25, 0.34);
  box-shadow: inset 0 0 26px rgba(255, 255, 255, 0.05);
  pointer-events: auto;
  touch-action: none;
}

.joystick span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border-radius: 999px;
  background: rgba(246, 244, 237, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.68);
  transform: translate(-50%, -50%);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

@media (hover: hover) and (pointer: fine) {
  .joystick {
    opacity: 0;
    visibility: hidden;
  }
}

@media (max-width: 520px) {
  .actions {
    top: max(12px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
  }

  .actions button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .joystick {
    width: 112px;
    height: 112px;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
