:root {
  --canvas-ratio: 1.6;
  --footer-height: 38px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #17191f;
  color: #fff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
}

#unity-viewport {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: #17191f;
}

#unity-container {
  /* 폭과 높이 중 먼저 닿는 쪽에 맞춰 빌드의 캔버스 비율을 유지한다. */
  width: min(100%, 960px, calc((100vh - var(--safe-top) - var(--safe-bottom) - var(--footer-height)) * var(--canvas-ratio)));
  width: min(100%, 960px, calc((100dvh - var(--safe-top) - var(--safe-bottom) - var(--footer-height)) * var(--canvas-ratio)));
}

#unity-frame {
  position: relative;
  width: 100%;
  aspect-ratio: var(--canvas-ratio);
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: #231F20;
}

#unity-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  font-size: clamp(12px, 2vw, 16px);
  text-align: center;
}

#unity-progress {
  width: min(70%, 240px);
  accent-color: #709bff;
}

#unity-warning {
  position: absolute;
  inset: 8px 8px auto;
  max-height: calc(100% - 16px);
  overflow: auto;
  overflow-wrap: anywhere;
  padding: 12px;
  background: #6b2028;
  font-size: 14px;
}

#unity-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--footer-height);
  font-size: 14px;
}

#unity-fullscreen {
  padding: 6px 12px;
  border: 1px solid #768296;
  border-radius: 4px;
  background: #272d38;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

@media (max-width: 600px), (pointer: coarse) {
  :root {
    --footer-height: 0px;
  }

  #unity-footer {
    display: none;
  }
}
