/* U2 WebGL template — canvas locked to 16:9, letterbox для нестандартных aspect ratio.
   U2-qdpv.9.1: страница с основным указателем «палец» (класс u2-touch) — рамка 16:10,
   см. раздел в конце файла. Правила ПК ниже от класса не зависят. */

body { padding: 0; margin: 0; background: #000; overflow: hidden; }

#unity-container {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  width: 100vw; height: 100vh;
}
#unity-container.unity-mobile { position: fixed; width: 100%; height: 100% }

/* Canvas с aspect-ratio 16:9 + max-* для letterbox/pillarbox. */
#unity-canvas {
  background: #231F20;
  display: block;
  aspect-ratio: 16 / 9;
  max-width: 100vw;
  max-height: 100vh;
}
@media (min-aspect-ratio: 16/9) { #unity-canvas { height: 100vh; width: auto; } }
@media (max-aspect-ratio: 16/9) { #unity-canvas { width: 100vw; height: auto; } }
/* U2-vyde: mobile НЕ переопределяет #unity-canvas — наследует 16:9-лок с
   леттербоксом (как desktop). Прежний override (aspect-ratio:auto + 100%/100%)
   растягивал canvas в родную пропорцию экрана, из-за чего HUD, свёрстанный под
   16:9, клипился: в landscape планшета нижний ряд и спидометр уходили за край,
   в портрете телефона панели перекрывались. */

#unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none; z-index: 10 }
#unity-logo { width: 154px; height: 130px; background: url('unity-logo-dark.png') no-repeat center }
#unity-progress-bar-empty { width: 141px; height: 18px; margin-top: 10px; margin-left: 6.5px; background: url('progress-bar-empty-dark.png') no-repeat center }
#unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('progress-bar-full-dark.png') no-repeat center }

#unity-warning { position: fixed; left: 50%; top: 5%; transform: translate(-50%); background: white; padding: 10px; display: none; z-index: 20 }

/* Top nav-полоса: информационная строка (версия, размер первой загрузки).
   pointer-events:none — после удаления кликабельной ссылки полоса не содержит
   интерактивных элементов, поэтому клики в верхней зоне должны проходить
   насквозь к Unity-canvas, а не перехватываться полосой (z-index выше canvas). */
#u2-nav {
  position: fixed; top: 0; left: 0; right: 0;
  height: 32px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: rgba(0, 0, 0, 0.7);
  color: #d4a85a;
  font-family: monospace; font-size: 13px;
  z-index: 30;
  pointer-events: none;
}
#u2-nav .u2-nav-title { opacity: 0.6; min-width: 0; margin-right: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unity-mobile + #u2-nav, .unity-mobile #u2-nav { display: none; }
/* U2-x9kc: по готовности Unity шапку версии полностью убрать — не перекрывать HUD. */
#u2-nav.u2-loaded { display: none; }

/* ===== U2-lsff: кастомный загрузочный экран (оверлей до старта Unity) =====
   Перекрывает canvas/Unity-splash (z-index между canvas и #u2-nav), показывает
   прогресс в процентах. Скрывается классом .u2-loaded по готовности Unity.
   Прежний #unity-loading-bar/#unity-progress-bar-full не тронуты (живут под
   оверлеем, JS их по-прежнему обновляет). */
#u2-loading {
  position: fixed; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #161210 0%, #0a0807 70%, #050403 100%);
  color: #d4a85a; font-family: monospace;
  opacity: 1; transition: opacity 0.6s ease;
}
#u2-loading.u2-loaded { opacity: 0; pointer-events: none; }
.u2-load-inner { width: min(420px, 84vw); text-align: center; }
.u2-load-mark {
  display: inline-block; padding: 6px 12px; margin-bottom: 22px;
  border: 1px solid #d4a85a; border-radius: 3px;
  font-size: 20px; letter-spacing: 4px; color: #ffcf7a;
}
.u2-load-title {
  margin: 0 0 8px; font-size: 26px; font-weight: 700;
  letter-spacing: 6px; color: #ffcf7a;
}
.u2-load-sub {
  margin: 0 0 32px; font-size: 13px; letter-spacing: 1px;
  color: #d4a85a; opacity: 0.7;
}
.u2-load-progress { width: 100%; }
.u2-load-track {
  height: 8px; border: 1px solid rgba(212, 168, 90, 0.5);
  border-radius: 2px; overflow: hidden; background: rgba(212, 168, 90, 0.08);
}
#u2-load-fill {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, #d4a85a, #ffcf7a);
  transition: width 0.2s ease;
}
.u2-load-status {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 10px; font-size: 12px; letter-spacing: 2px;
}
#u2-load-percent { color: #ffcf7a; font-size: 15px; }

/* ===== U2-qdpv.9.1: страница с основным указателем «палец» (класс u2-touch) =====
   Класс ставит index.html один раз при загрузке по основному указателю браузера:
   планшет и телефон — да; ПК с сенсорным монитором — нет, его основной указатель мышь,
   и он остаётся в рамке 16:9. Для класса: рамка 16:10 (решение оператора Р6; HUD
   0.26.3 проверен на 16:10 автотестом ChaseHudV2AspectGeometry_Tests), полотно целиком
   внутри безопасной области (вырез камеры, скруглённые углы; нужен viewport-fit=cover). */
html.u2-touch {
  --u2-view-w: 100vw;
  --u2-view-h: 100vh;
}
/* Динамический размер окна: строка адреса мобильного браузера не срезает низ полотна. */
@supports (height: 100dvh) {
  html.u2-touch { --u2-view-w: 100dvw; --u2-view-h: 100dvh; }
}
/* Щипок, прокрутка и «потянуть для обновления» не уводят страницу из-под пальцев. */
html.u2-touch body { touch-action: none; overscroll-behavior: none; }
html.u2-touch #unity-container {
  box-sizing: border-box;
  inset: 0; width: auto; height: auto;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
html.u2-touch #unity-canvas {
  --u2-safe-w: calc(var(--u2-view-w) - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  --u2-safe-h: calc(var(--u2-view-h) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  aspect-ratio: 16 / 10;
  width: min(var(--u2-safe-w), calc(var(--u2-safe-h) * 16 / 10));
  height: auto;
  max-width: var(--u2-safe-w);
  max-height: var(--u2-safe-h);
}

/* Кнопка полного экрана: видна только классу u2-touch и только когда index.html снял
   атрибут hidden (API полного экрана доступен; в полном экране кнопка снова скрыта). */
#u2-fullscreen { display: none; }
html.u2-touch #u2-fullscreen:not([hidden]) {
  display: flex; align-items: center; justify-content: center;
  position: fixed; z-index: 35;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: calc(env(safe-area-inset-right, 0px) + 8px);
  width: 44px; height: 44px; padding: 0;
  border: 1px solid rgba(212, 168, 90, 0.6); border-radius: 4px;
  background: rgba(10, 8, 7, 0.55); color: #ffcf7a;
  opacity: 0.85;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#u2-fullscreen svg { width: 24px; height: 24px; }

/* Подсказка «поверните горизонтально»: только класс u2-touch и только в портрете.
   Слой перекрывает всё, включая полотно и кнопку полного экрана, и сам принимает
   касания — полотно ему не предок, до игры они не доходят (index.html отменяет только
   действие браузера по умолчанию: прокрутку, масштаб, щелчок вслед за касанием). */
#u2-rotate { display: none; }
@media (orientation: portrait) {
  html.u2-touch #u2-rotate {
    display: flex; align-items: center; justify-content: center;
    position: fixed; inset: 0; z-index: 40;
    box-sizing: border-box;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
             env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    background: radial-gradient(ellipse at center, #161210 0%, #0a0807 70%, #050403 100%);
    color: #d4a85a; font-family: monospace; text-align: center;
    pointer-events: auto;
    touch-action: none;
  }
}
.u2-rotate-inner { width: min(420px, 84vw); }
.u2-rotate-mark {
  display: inline-block; padding: 6px 12px; margin-bottom: 22px;
  border: 1px solid #d4a85a; border-radius: 3px;
  font-size: 20px; letter-spacing: 4px; color: #ffcf7a;
}
.u2-rotate-title { margin: 0 0 8px; font-size: 20px; font-weight: 700; letter-spacing: 4px; color: #ffcf7a; }
.u2-rotate-sub { margin: 0; font-size: 13px; letter-spacing: 1px; opacity: 0.7; }
