* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  color: #eee;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.4em;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5);
  background-color: #000;
  overflow: hidden;
}

#container {
  position: absolute;
  inset: 0;
  touch-action: none;
}

#container canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

a {
  color: white;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

#panel .gui {
  --gui-font: "DM Sans", system-ui, sans-serif;
}

#panel .gui-title {
  font-size: 14px;
}

#panel .gui-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#panel .gui-title-preset {
  font-weight: 400;
  color: #ffa683;
}

#panel .gui-title-preset:not(:empty)::before {
  content: " · ";
}

#help {
  margin-bottom: 12px;
  font-size: 12px;
  line-height: 1.45;
  opacity: 0.85;
}

#help p {
  margin-bottom: 8px;
}

#help .credits {
  opacity: 0.7;
}

#panel .stat-value {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

#panel .stat-value.stat-warn {
  color: #ff6b5a;
}

#panel .stat-range {
  flex: 0 0 7.5em;
  white-space: nowrap;
  text-align: right;
  font-size: 11px;
  opacity: 0.5;
  font-variant-numeric: tabular-nums;
}

#panel {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 10px;
  z-index: 2;
  width: 380px;
  max-width: calc(100vw - 20px);
}

#loading {
  display: inline-flex;
  margin-top: 8px;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  pointer-events: none;
}

#loading[hidden] {
  display: none;
}

/* A transform animation runs on the compositor, so it keeps turning while
   the Suzanne bake blocks the main thread. */
.loading-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
  will-change: transform;
}

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

@media (prefers-reduced-motion: reduce) {
  .loading-spinner {
    animation-duration: 2.4s;
  }
}

/* The toggle stays, alone in the corner, or nothing could bring the rest back. */
body.ui-hidden #panel,
body.ui-hidden #buttons > :not(#ui-toggle) {
  display: none;
}

body.ui-hidden #buttons {
  right: 10px;
}

body.ui-hidden #ui-toggle {
  opacity: 0.4;
}

body.ui-hidden #ui-toggle:hover,
body.ui-hidden #ui-toggle:focus-visible {
  opacity: 1;
}

#buttons {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: calc(10px + 380px + 8px);
  z-index: 2;
  display: flex;
  gap: 8px;
}

#buttons[hidden] {
  display: none;
}

/* The panel's own look, since guspira's variables only exist inside .gui.
   65px is the folded panel's measured height (20px padding either side of a
   24px title, plus 1px of its folding rows), so the two line up. */
.icon-button {
  display: grid;
  place-items: center;
  width: 65px;
  height: 65px;
  border: none;
  border-radius: 6px;
  background: #2c2c2c;
  color: #e0e0e0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.icon-button[hidden] {
  display: none;
}

.icon-button:hover {
  background: #3e3e3e;
  color: #fff;
}

.icon-button:active {
  background: #333;
}

.icon-button:focus-visible {
  outline: 2px solid #888;
  outline-offset: 2px;
}

.icon-button[aria-pressed="true"] .when-off,
.icon-button[aria-pressed="false"] .when-on {
  display: none;
}

/* Touch devices leave fullscreen with the system back gesture or a double
   tap, so there the button is only for going in. */
@media (hover: none) and (pointer: coarse) {
  #fullscreen[aria-pressed="true"] {
    display: none;
  }
}

#randomize svg {
  transition: transform 0.35s ease;
}

#randomize.turned svg {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  #randomize svg {
    transition: none;
  }
}

#options {
  position: absolute;
  z-index: 1;
  left: 10px;
  top: calc(10px + env(safe-area-inset-top, 0px));
  max-width: min(40em, calc(100vw - 20px));
}

@media (max-width: 600px) {

  #panel {
    width: auto;
    max-width: none;
    top: auto;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    left: 10px;
    right: 10px;
  }

  #panel .gui {
    --gui-max-height: 60vh;
  }

  #buttons {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }

  body.ui-hidden #buttons {
    left: auto;
    right: 10px;
    transform: none;
  }

  #options {
    left: 50%;
    top: calc(10px + env(safe-area-inset-top, 0px) + 65px);
    transform: translateX(-50%);
  }

}
