:root{
  --page-bg: #ffd700;
  --safe-top: var(--tg-content-safe-area-inset-top, var(--tg-safe-area-inset-top, env(safe-area-inset-top)));
  --safe-right: var(--tg-content-safe-area-inset-right, var(--tg-safe-area-inset-right, env(safe-area-inset-right)));
  --safe-bottom: var(--tg-content-safe-area-inset-bottom, var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom)));
  --safe-left: var(--tg-content-safe-area-inset-left, var(--tg-safe-area-inset-left, env(safe-area-inset-left)));

  --loading-z: 2;
  --ui-z: 3;
  --warning-z: 4;
  --telegram-modal-z: 10;

  --version-bottom: calc(clamp(12px, 1.56vh, 30px) + var(--safe-bottom));
  --version-font-size: clamp(12px, 1.6vw, 24px);
  --version-side-gap: 24px;

  --warning-padding: 10px;
  --warning-font-size: 14px;
  --telegram-modal-backdrop: #ffd700;
  --telegram-modal-card-bg: #ffffff;
  --telegram-modal-card-text: #230f0A;
  --telegram-modal-card-shadow: rgba(35, 15, 10, 0.2);
  --telegram-modal-card-width: min(86vw, 420px);
  --telegram-modal-card-radius: 16px;
  --telegram-modal-card-padding: clamp(14px, 2.4vw, 20px);
  --telegram-modal-font-size: clamp(14px, 2.2vw, 20px);

  /*
   * One Figma pixel of the 1080x1920 loading stage. Unity's panel (PanelSettings: 1080x1920, Expand) scales
   * by the same rule, so this page and the in-game loading screen (Assets/UI/Loading.uss) line up.
   */
  --u: min(100vw / 1080, 100vh / 1920);
}

@supports (height: 100dvh){
  :root{
    --u: min(100vw / 1080, 100dvh / 1920);
  }
}


html,
body{
  margin: 0;
  background: var(--page-bg);
  overflow: hidden;
}

#unity-container{
  position: absolute;
  inset: 0;
}

#unity-canvas{
  width: 100%;
  height: 100%;
  display: block;
  background: var(--page-bg);
  outline: none;
}

#unity-loading{
  position: absolute;
  inset: 0;
  background: var(--page-bg);
  z-index: var(--loading-z);
}

#unity-version{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--version-bottom);
  font-size: var(--version-font-size);

  color: #fff;
  font-family: "YS Geo", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  white-space: nowrap;
  max-width: calc(100vw - var(--version-side-gap));
  overflow: hidden;
  text-overflow: ellipsis;

  z-index: var(--ui-z);
}


#unity-warning{
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  padding: var(--warning-padding);
  text-align: center;
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: var(--warning-font-size);
  pointer-events: none;
  z-index: var(--warning-z);
}

#telegram-only-modal{
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background: var(--telegram-modal-backdrop);
  z-index: var(--telegram-modal-z);
}

.telegram-only-modal__card{
  width: var(--telegram-modal-card-width);
  background: var(--telegram-modal-card-bg);
  border-radius: var(--telegram-modal-card-radius);
  box-shadow: 0 12px 30px var(--telegram-modal-card-shadow);
  padding: var(--telegram-modal-card-padding);
}

.telegram-only-modal__text{
  margin: 0;
  text-align: center;
  color: var(--telegram-modal-card-text);
  font-family: "YS Geo", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: var(--telegram-modal-font-size);
  line-height: 1.2;
}

/* Figma: "интерфейс/ анимация" > Загрузка_1, without the walking courier. Sizes are Figma px times --u. */
.loading-stage{
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(1080 * var(--u));
  height: calc(1920 * var(--u));
  transform: translate(-50%, -50%);
  z-index: var(--ui-z);
}

.loading-stage > *{
  position: absolute;
  box-sizing: border-box;
}

.loading-courier{
  left: calc(227.5 * var(--u));
  top: calc(66 * var(--u));
  width: calc(642 * var(--u));
  height: calc(869 * var(--u));
  background: url("./loading-courier.png") center / contain no-repeat;
}

.loading-clouds{
  left: calc(33 * var(--u));
  top: calc(174 * var(--u));
  width: calc(884 * var(--u));
  height: calc(428 * var(--u));
  background: url("./loading-clouds.png") center / contain no-repeat;
}

.loading-text{
  left: calc(200 * var(--u));
  top: calc(986 * var(--u));
  width: calc(680 * var(--u));
  margin: 0;

  color: #230f0A;
  font-family: "YS Geo", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 900;
  font-size: calc(130 * var(--u));
  line-height: 0.9;
  text-align: center;
  white-space: nowrap;
}

.progress{
  --p: 0%;
  left: calc(108 * var(--u));
  top: calc(1603 * var(--u));
  width: calc(865 * var(--u));
  height: calc(64 * var(--u));
  padding: calc(10 * var(--u)) calc(16 * var(--u));
  border-radius: calc(32 * var(--u));
  background: #ffffff;
}

.progress__fill{
  position: relative;
  box-sizing: border-box;
  height: 100%;
  border-radius: calc(22 * var(--u));
  border-bottom: calc(6 * var(--u)) solid #edad01;
  background: #ffd700;
}

/* Width follows the download; the 28x38 tile repeats sideways and scrolls one tile every 2 s. */
.progress__stripes{
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--p);
  border-radius: calc(22 * var(--u)) 0 0 calc(16 * var(--u));
  background: url("./loading-stripes.png") 0 0 / calc(28 * var(--u)) calc(38 * var(--u)) repeat-x;
  animation: stripes 2s linear infinite;
  transition: width 150ms linear;
  pointer-events: none;
}

@keyframes stripes{
  from { background-position-x: 0; }
  to   { background-position-x: calc(28 * var(--u)); }
}

@font-face{
  font-family: "YS Geo";
  src: url("./YS_Geo-Black.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

/* Unity's mobile keyboard bar (an unnamed div with an input and an OK button, MobileKeyboard.js): the game shows the
   text in its own field. It stays focusable, or the keyboard would not open, and sits at the top, or the browser
   pans the page up to bring a bottom input above the keyboard. */
body > div:has(> :is(input, textarea) + button) {
  top: 0 !important;
  bottom: auto !important;
  opacity: 0;
  pointer-events: none;
}
