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

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: #111216;
  -webkit-tap-highlight-color: transparent;
}

#canvas {
  position: absolute;
  top: env(safe-area-inset-top, 0);
  right: env(safe-area-inset-right, 0);
  bottom: env(safe-area-inset-bottom, 0);
  left: env(safe-area-inset-left, 0);
  display: block;
  width: calc(100% - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  height: calc(100% - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  contain: strict;
}

/* In the empty end of the menu bar, clear of the panels and status bar. */
#fullscreen-toggle {
  position: fixed;
  z-index: 20;
  top: env(safe-area-inset-top, 0px);
  right: env(safe-area-inset-right, 0px);
  display: none;
  width: 44px;
  height: 44px;
  padding-bottom: 14px;
  border: 0;
  background: transparent;
  color: #e2e5eb;
  font: 22px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  touch-action: manipulation;
}

#fullscreen-toggle:focus-visible {
  outline: 2px solid #9d7cd8;
  outline-offset: 2px;
}

@media (max-width: 700px), (max-width: 1000px) and (max-height: 700px) {
  #fullscreen-toggle:not([hidden]) {
    display: block;
  }
}

#loading {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #111216;
  color: #aeb2bd;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#loading .title {
  margin-bottom: 16px;
  color: #e2e5eb;
  font-size: 20px;
}

#progress-bar {
  width: min(320px, 70vw);
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: #2a2d34;
}

#progress-bar .fill {
  width: 0%;
  height: 100%;
  background: #9d7cd8;
  transition: width 0.2s;
}

#loading .status {
  margin-top: 9px;
  color: #737986;
  font-size: 12px;
}

#loading .status.error {
  max-width: min(520px, 86vw);
  color: #e8b4b4;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}

.noscript {
  position: fixed;
  z-index: 30;
  inset: 0;
  padding: 32px;
  background: #111216;
  color: #e8b4b4;
  font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
}

/* Must stay focusable for the phone keyboard to open, so it is clear and not hidden. */
#soft-input {
  position: fixed;
  z-index: -1;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px; /* iOS zooms the page when a focused field is smaller */
  opacity: 0;
  pointer-events: none;
}

#busy {
  position: fixed;
  z-index: 15;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 40px);
  width: min(360px, 80vw);
  padding: 10px 14px;
  transform: translateX(-50%);
  border: 1px solid #656b78;
  border-radius: 6px;
  background: rgba(17, 18, 22, 0.94);
  color: #e2e5eb;
  font: 13px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
  pointer-events: none;
}

#busy[hidden],
#busy-bar[hidden],
#file-prompt[hidden] {
  display: none;
}

#busy-bar {
  height: 4px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 2px;
  background: #2a2d34;
}

#busy-fill {
  width: 0%;
  height: 100%;
  background: #9d7cd8;
}

#file-prompt {
  position: fixed;
  z-index: 25;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}

#file-prompt .panel {
  width: min(460px, 100%);
  padding: 20px;
  border: 1px solid #656b78;
  border-radius: 6px;
  background: #1a1c22;
  color: #e2e5eb;
  font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

#file-prompt .buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

#file-prompt button {
  min-width: 88px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #656b78;
  border-radius: 6px;
  background: #2a2d34;
  color: #e2e5eb;
  font: inherit;
  touch-action: manipulation;
}

#file-prompt button:focus-visible {
  outline: 2px solid #9d7cd8;
  outline-offset: 2px;
}
