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

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

.button {
  background-color: #2c2c2c;
  color: #e0e0e0;
  font-family: "Segoe UI", sans-serif;
  font-size: 13px;
  padding: 20px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  cursor: pointer;

  &:hover {
    background-color: #3a3a3a;
  }

  &:active {
    background-color: #1e1e1e;
  }
}

#gui-container {
  flex: 1;
  min-width: 0;
}

.hide-ui #main-gui {
  display: none;
}

.action,
#randomize-button {
  padding: 15px;
}

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

#main-gui {
  z-index: 10;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
}

@media (min-width: 951px) {
  #main-gui {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 520px;
  }
}

@media (max-width: 950px) {
  /* Buttons in a row at the top right, the panel full width along the bottom. */
  #main-gui {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: calc(10px + env(safe-area-inset-left));
    right: calc(10px + env(safe-area-inset-right));
    flex-wrap: wrap;
    justify-content: flex-end;
    align-content: space-between;
    gap: 6px;
    pointer-events: none;

    > * {
      pointer-events: auto;
    }

    .action,
    #randomize-button {
      padding: 11px;
      flex-shrink: 0;
    }

    .gui-scroller {
      max-height: 50vh;
    }
  }

  #gui-container {
    flex: 0 0 100%;
  }
}

.paused #pause-button {
  background-color: #4a4a4a;
}

#info {
  position: fixed;
  left: calc(10px + env(safe-area-inset-left));
  top: calc(10px + env(safe-area-inset-top));
  z-index: 10;
  display: flex;
  gap: 12px;
  font-family: "Segoe UI", sans-serif;
  font-size: 13px;
  background-color: #2c2c2c;
  color: #e0e0e0;
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);

  a {
    color: inherit;
    text-decoration: none;

    &:hover {
      text-decoration: underline;
    }
  }
}

.hide-ui #info {
  display: none;
}

/* Placeholder from first paint until the sketch's first frame (see ready() in common.js). */
#loading {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--loading-background, #e9e7e3);
  color: var(--loading-color, rgba(0, 0, 0, 0.42));
  font-family: "Segoe UI", sans-serif;
  font-size: 13px;
  letter-spacing: 0.06em;
  pointer-events: none;
  transition: opacity 0.6s ease;

  span {
    animation: loading-pulse 1.4s ease-in-out infinite alternate;
  }

  &.done {
    opacity: 0;
  }
}

@keyframes loading-pulse {
  from {
    opacity: 0.35;
  }
  to {
    opacity: 1;
  }
}
