:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  background: #e6dcff;
  color: #11120f;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  margin: 0;
  background: #e6dcff;
}

html {
  scrollbar-width: none;
}

body::-webkit-scrollbar {
  display: none;
}

body {
  overflow-x: hidden;
}

button {
  font: inherit;
}

.scroll-space {
  width: 1px;
  height: 500svh;
  pointer-events: none;
}

.viewport {
  --backdrop: #e6dcff;
  --ink: #11120f;
  --room: 0;
  position: fixed;
  z-index: 1;
  inset: 0;
  min-height: 32rem;
  overflow: hidden;
  color: var(--ink);
  background: var(--backdrop);
  transition: background-color 120ms linear, color 120ms linear;
}

.masthead {
  position: absolute;
  z-index: 10;
  top: clamp(1.25rem, 3.5vw, 3rem);
  left: clamp(1.25rem, 3.5vw, 3rem);
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  pointer-events: none;
}

.masthead p,
.masthead h1,
.phase,
.instruction {
  margin: 0;
  font-size: clamp(0.65rem, 1vw, 0.82rem);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.masthead h1 {
  font-size: clamp(0.78rem, 1.2vw, 0.98rem);
}

.scene {
  position: absolute;
  z-index: 1;
  inset: 0;
  perspective: 900px;
  perspective-origin: 50% 48%;
  overflow: hidden;
}

.world {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.piece {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  transform-style: preserve-3d;
  transform-origin: center;
  backface-visibility: visible;
  will-change: transform, opacity;
}

.source-blue {
  width: min(48vw, 42rem);
  height: min(19vh, 10rem);
  background: #1550dc;
  box-shadow: 0.8rem 0.8rem 0 #11120f;
}

.source-red {
  width: min(27vmin, 15rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #f04732;
  box-shadow: 0.6rem 0.6rem 0 #11120f;
}

.source-yellow {
  width: min(58vw, 48rem);
  height: min(9vh, 4.8rem);
  background: #efff4f;
  box-shadow: 0.55rem 0.55rem 0 #11120f;
}

.source-pink {
  width: min(22vw, 12rem);
  height: min(37vh, 20rem);
  border-radius: 8rem 8rem 0 0;
  background: #ff71c8;
  box-shadow: 0.6rem 0.6rem 0 #11120f;
}

.source-ring {
  width: min(34vmin, 19rem);
  aspect-ratio: 1;
  border: clamp(0.8rem, 2.2vw, 1.6rem) solid #11120f;
  border-radius: 50%;
}

.source-mark,
.destination-mark {
  color: #11120f;
  font-size: clamp(6rem, 20vw, 17rem);
  font-weight: 900;
  line-height: 0.75;
  letter-spacing: -0.1em;
}

.destination-blue {
  width: min(31vmin, 18rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #1550dc;
}

.destination-coral {
  width: min(25vmin, 14rem);
  aspect-ratio: 1;
  background: #f04732;
  box-shadow: 0.65rem 0.65rem 0 #11120f;
}

.destination-frame {
  width: min(34vw, 20rem);
  aspect-ratio: 1.2;
  border: clamp(0.7rem, 2vw, 1.4rem) solid #11120f;
}

.destination-pink {
  width: min(60vw, 48rem);
  height: min(10vh, 5.4rem);
  background: #ff71c8;
  box-shadow: 0.55rem 0.55rem 0 #11120f;
}

.destination-black {
  width: min(16vmin, 9rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #11120f;
}

.grid-floor {
  position: absolute;
  top: 72%;
  left: 50%;
  width: 180vw;
  height: 130vh;
  opacity: var(--room);
  background-image: repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.34) 0,
      rgba(255, 255, 255, 0.34) 1px,
      transparent 1px,
      transparent 8vw
    ),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.34) 0,
      rgba(255, 255, 255, 0.34) 1px,
      transparent 1px,
      transparent 8vh
    );
  transform: translate(-50%, -50%) rotateX(68deg) translateZ(-22rem);
  transform-origin: center;
}

.phase {
  position: absolute;
  z-index: 10;
  top: clamp(1.25rem, 3.5vw, 3rem);
  right: clamp(2.6rem, 5vw, 4.2rem);
}

.progress {
  position: absolute;
  z-index: 10;
  top: 18%;
  right: clamp(1.25rem, 2.3vw, 2rem);
  width: 1px;
  height: 64%;
  background: color-mix(in srgb, currentColor 32%, transparent);
}

.progress span {
  position: absolute;
  top: 0;
  left: 50%;
  width: 0.7rem;
  height: 0.7rem;
  border: 1px solid currentColor;
  background: var(--backdrop);
  transform: translate(-50%, -50%);
}

.instruction {
  position: absolute;
  z-index: 10;
  right: clamp(2.6rem, 5vw, 4.2rem);
  bottom: clamp(1.25rem, 3.5vw, 3rem);
  padding: 0.32rem 0.42rem;
  line-height: 1.45;
  text-align: right;
  background: color-mix(in srgb, var(--backdrop) 88%, transparent);
  pointer-events: none;
}

.controls {
  position: absolute;
  z-index: 11;
  left: clamp(1.25rem, 3.5vw, 3rem);
  bottom: clamp(1.25rem, 3.5vw, 3rem);
  display: flex;
  border: 1px solid currentColor;
}

.controls button {
  min-width: 5.3rem;
  min-height: 2.75rem;
  padding: 0.72rem 1rem;
  border: 0;
  border-right: 1px solid currentColor;
  border-radius: 0;
  color: inherit;
  background: color-mix(in srgb, var(--backdrop) 78%, transparent);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.controls button:last-child {
  border-right: 0;
}

.controls button:hover:not(:disabled) {
  color: var(--backdrop);
  background: var(--ink);
}

.controls button:disabled {
  opacity: 0.38;
  cursor: default;
}

.controls button:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid #f04732;
  outline-offset: 3px;
}

.screen-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html.reduced,
html.reduced body {
  height: 100%;
  overflow: hidden;
}

html.reduced .scroll-space {
  height: 100svh;
}

html.reduced .instruction {
  display: none;
}

@media (max-width: 40rem) {
  .viewport {
    min-height: 28rem;
  }

  .scene {
    perspective: 650px;
  }

  .source-blue {
    width: 60vw;
  }

  .source-pink {
    width: 30vw;
  }

  .destination-frame {
    width: 44vw;
  }

  .instruction {
    right: 2.7rem;
    bottom: 5rem;
  }

  .phase {
    top: 3.5rem;
    right: 2.7rem;
  }

  .progress {
    right: 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .viewport {
    transition: none;
  }
}
