html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  /* dvh follows Safari's collapsing toolbar; the percentage is the fallback for browsers without it. */
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  overscroll-behavior: none;
  background: #050507;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Sized in script from the visual viewport: on iOS the document box runs on under the toolbar, and the
   part of the canvas hidden beneath it comes back as a black band when the toolbar slides away. */
#game {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

#unity-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #050507;
  outline: none;
}

#loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: #efece6;
  background: radial-gradient(ellipse at 50% 38%, #1b1a1f 0%, #07070a 62%, #030304 100%);
  transition: opacity 0.6s ease;
}

#loader.done {
  opacity: 0;
  pointer-events: none;
}

#loader .piece {
  font-size: 120px;
  line-height: 1;
  color: #f0c566;
  text-shadow: 0 0 36px rgba(240, 197, 102, 0.45), 0 0 4px rgba(255, 240, 200, 0.6);
  animation: turn 3.2s ease-in-out infinite;
}

#loader .title {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: 0.32em;
  padding-left: 0.32em; /* balance the letter spacing */
}

#loader .bar {
  width: min(460px, 70vw);
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-top: 12px;
}

#loader .fill {
  width: 0%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #b8862f, #f0c566, #fff1c4);
  box-shadow: 0 0 12px rgba(240, 197, 102, 0.6);
  transition: width 0.25s ease;
}

#loader .percent {
  font-size: 15px;
  font-weight: 700;
  color: #f0c566;
  letter-spacing: 0.12em;
}

#loader .hint {
  font-size: 15px;
  font-style: italic;
  color: #9a9ca6;
}

@keyframes turn {
  0%   { transform: perspective(400px) rotateY(0deg) translateY(0); }
  50%  { transform: perspective(400px) rotateY(180deg) translateY(-6px); }
  100% { transform: perspective(400px) rotateY(360deg) translateY(0); }
}

#banner {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  max-width: 90vw;
}

#banner div {
  padding: 10px 16px;
  margin-bottom: 8px;
  border-radius: 8px;
  font-size: 14px;
}

#banner .warning { background: rgba(240, 197, 102, 0.95); color: #1a1405; }
#banner .error { background: rgba(220, 70, 60, 0.95); color: #fff; }
