html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #140b08;
  color: #ffe3cf;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* The game handles all gestures itself. */
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#fatal {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: max(24px, env(safe-area-inset-top)) 24px 24px;
  background: #140b08;
  white-space: pre-wrap;
  font: 15px/1.5 ui-monospace, Menlo, Consolas, monospace;
}

#fatal[hidden] {
  display: none;
}

/* Loading screen until the first scene is drawn. Only transform and opacity are animated, so it
   keeps moving while the main thread is busy decoding and baking graphics. */
#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 5vmin, 32px);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #140b08;
  transition: opacity 0.4s ease-out;
}

#loading.done {
  opacity: 0;
  pointer-events: none;
}

.loading-emblem {
  position: relative;
  width: min(52vmin, 240px);
  aspect-ratio: 1;
  animation: loading-float 3.6s ease-in-out infinite;
}

.loading-emblem img {
  display: block;
  width: 100%;
  height: 100%;
}

/* Continues the icon's background beyond its edges, so no square shows: the same radial gradient
   as in tools/touch-icon.mjs, from the centre colour to the page colour at the corners. */
.loading-emblem::before {
  content: "";
  position: absolute;
  inset: -20.71%;
  z-index: -1;
  background: radial-gradient(closest-side, #3e1a10, #140b08);
}

/* A small satellite circling the planet. */
.loading-orbit {
  position: absolute;
  inset: -3%;
  border-radius: 50%;
  border: 1px solid rgba(255, 170, 120, 0.14);
  animation: loading-spin 4.8s linear infinite;
}

.loading-orbit::before {
  content: "";
  position: absolute;
  top: -4px;
  left: calc(50% - 4px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffd2a8;
  box-shadow: 0 0 6px 2px rgba(255, 138, 61, 0.8), 0 0 16px 4px rgba(255, 98, 30, 0.35);
}

.loading-bar {
  position: relative;
  width: min(60vmin, 280px);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: rgba(255, 227, 207, 0.12);
}

.loading-bar span {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #b8400f, #ff8a3d 70%, #ffd2a8);
  transform: scaleX(var(--progress, 0));
  transform-origin: left;
  transition: transform 0.3s ease-out;
}

/* Light sweeping over the bar: something is happening, even before the first progress report. */
.loading-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 227, 207, 0.35), transparent);
  animation: loading-sweep 1.6s ease-in-out infinite;
}

@keyframes loading-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2.5%); }
}

@keyframes loading-spin {
  to { transform: rotate(1turn); }
}

@keyframes loading-sweep {
  from { transform: translateX(-100%); }
  to { transform: translateX(250%); }
}

@media (prefers-reduced-motion: reduce) {
  .loading-emblem,
  .loading-orbit,
  .loading-bar::after {
    animation: none;
  }
}
