:root { color-scheme: dark; }
html.light-mode { color-scheme: light; }
* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 5vh 4vw;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  background:
    repeating-linear-gradient(90deg, transparent 0 94px, rgba(42, 50, 66, .042) 94px 95px),
    #f6f6f7;
}

.preview-shell { width: min(1080px, 92vw); }

html.embed-mode,
html.embed-mode body {
  width: 100%;
  height: 100%;
  min-height: 0;
}

html.embed-mode body {
  display: block;
  padding: 0;
  background: #010205;
}

html.embed-mode.light-mode body { background: transparent; }

.embed-mode .preview-shell {
  width: 100%;
  height: 100%;
}

.embed-mode .preview-meta { display: none; }

.embed-mode .stage {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.light-mode .stage {
  background:
    radial-gradient(ellipse at 58% 48%, rgba(250, 252, 255, .94) 0%, rgba(226, 236, 250, .82) 42%, rgba(207, 221, 242, .7) 100%);
}

.light-mode .stage::before {
  opacity: .09;
  mix-blend-mode: multiply;
}

.light-mode .stage::after {
  background:
    radial-gradient(ellipse at 58% 48%, transparent 22%, rgba(117, 135, 169, .1) 100%),
    linear-gradient(110deg, transparent 0 58%, rgba(255, 255, 255, .2) 66%, transparent 73%);
}

.light-mode .ambient {
  opacity: .76;
  background: radial-gradient(ellipse, rgba(53, 94, 225, .3), rgba(86, 111, 210, .1) 50%, transparent 74%);
}

.light-mode .loading {
  color: rgba(48, 67, 101, .28);
  text-shadow: 0 0 12px rgba(53, 95, 216, .16);
}

.backdrop-mode .loading { display: none; }

.controller-mode .stage {
  background: transparent;
}

html.controller-mode { background: transparent; }

.controller-mode .stage::before,
.controller-mode .stage::after { display: none; }

.controller-mode .loading { display: none; }

.preview-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 2px;
  color: rgba(29, 34, 43, .46);
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  aspect-ratio: 2.16 / 1;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, .92);
  border-radius: 12px;
  background:
    radial-gradient(ellipse at 50% 49%, rgba(17, 17, 37, .96) 0%, rgba(5, 6, 14, .99) 46%, #010205 100%);
  box-shadow:
    0 34px 90px rgba(53, 62, 82, .2),
    inset 0 1px 0 rgba(255, 255, 255, .1),
    inset 0 0 0 1px rgba(0, 0, 0, .3);
}

.stage::before {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  content: "";
  opacity: .2;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.76' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.13'/%3E%3C/svg%3E");
}

.stage::after {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  content: "";
  background:
    radial-gradient(ellipse at 50% 49%, transparent 24%, rgba(0, 0, 0, .58) 100%),
    linear-gradient(110deg, transparent 0 58%, rgba(99, 94, 255, .025) 66%, transparent 73%);
}

.ambient {
  position: absolute;
  left: 33%;
  top: 26%;
  z-index: 0;
  width: 34%;
  height: 35%;
  border-radius: 50%;
  opacity: .58;
  filter: blur(52px);
  background: radial-gradient(ellipse, rgba(77, 54, 255, .2), rgba(47, 59, 190, .06) 50%, transparent 74%);
  animation: breathe 3.7s ease-in-out infinite alternate;
}

canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
}

.stage.is-tracking canvas { cursor: crosshair; }

.stage.is-tracking .ambient {
  opacity: .84;
  transform: scale(1.08);
}

.loading {
  position: absolute;
  left: 50%;
  top: 61.8%;
  z-index: 5;
  margin: 0;
  color: rgba(193, 198, 224, .32);
  font-size: 9px;
  letter-spacing: .02em;
  transform: translateX(-50%);
  text-shadow: 0 0 12px rgba(98, 88, 255, .28);
}

.loading::after {
  display: inline-block;
  width: 12px;
  overflow: hidden;
  vertical-align: bottom;
  content: "...";
  animation: dots 1.2s steps(4, end) infinite;
}

.fallback {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: none;
  place-items: center;
  color: rgba(220, 225, 244, .5);
  font-size: 11px;
}

@keyframes breathe {
  to { opacity: .84; transform: scale(1.08); }
}

@keyframes dots {
  0% { width: 0; }
  100% { width: 12px; }
}

@media (max-width: 680px) {
  body { padding: 24px 14px; }
  .preview-shell { width: 100%; }
  .preview-meta span:last-child { display: none; }
  .stage { aspect-ratio: 4 / 3; }
  .loading { top: 62.5%; }
}

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