* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}
#map { position: absolute; inset: 0; }

.ver { font-weight: 400; font-size: 11px; opacity: .8; }

/* HUD сверху */
/* контролы MapLibre (зум, линейка) — ниже шапки GPS-статуса, чтобы не накладывались */
.maplibregl-ctrl-top-left { top: calc(env(safe-area-inset-top) + 40px); }

#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 8px) 14px 8px;
  background: linear-gradient(180deg, rgba(15,81,50,.92), rgba(15,81,50,0));
  color: #fff; font-size: 14px; font-weight: 600;
  pointer-events: none; z-index: 10;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
}

/* Кнопки */
#controls {
  position: absolute; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 18px);
  display: flex; flex-direction: column; gap: 10px; z-index: 10;
}
/* на низких экранах (альбомная ориентация) колонка из 6 кнопок не влезает — ужимаем */
@media (max-height: 600px) {
  #controls { gap: 6px; }
  #controls button { width: 44px !important; height: 44px !important; font-size: 17px !important; }
}
#controls button {
  width: 52px; height: 52px; border: none; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.3);
  font-size: 22px; cursor: pointer;
}
#controls button:active { transform: scale(.94); }
/* активный тумблер — заливка + белое кольцо, чтобы было видно на солнце */
#controls button.active { color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.85), 0 2px 8px rgba(0,0,0,.45); }
#btn-follow.active, #btn-home.active { background: #0f5132; }
#btn-eco.active, #btn-test.active { background: #d98a00; }

/* Оценка маршрута (звёзды на экране финиша) */
#rate-box { text-align: center; margin: 8px 0 4px; }
#rate-box.hidden { display: none; }
#rate-title { margin: 0 0 6px; font-size: 14px; color: #555; }
#rate-stars button {
  border: none; background: none; font-size: 34px; line-height: 1;
  color: #ccc; cursor: pointer; padding: 2px 6px;
}
#rate-stars button.sel { color: #f5a623; }

/* Подсказка установки PWA на iOS */
#ios-hint {
  position: absolute; left: 12px; right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 12;
  background: rgba(20,20,20,.92); color: #fff; border-radius: 12px;
  padding: 10px 12px; font-size: 13px; line-height: 1.35;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
#ios-hint.hidden { display: none; }
#ios-hint button {
  flex: 0 0 auto; width: 28px; height: 28px; border: none; border-radius: 50%;
  background: rgba(255,255,255,.18); color: #fff; font-size: 14px; cursor: pointer;
}

/* Подсказка навигации */
#nav-hint {
  position: absolute; left: 12px; bottom: calc(env(safe-area-inset-bottom) + 18px);
  z-index: 10; background: rgba(15,81,50,.92); color: #fff;
  border-radius: 22px; padding: 8px 14px; display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.3); max-width: 60%;
}
#nav-hint.hidden { display: none; }
#nav-arrow { font-size: 18px; display: inline-block; transition: transform .2s; }
/* две строки справа от стрелки: сверху время, снизу направление до точки */
#nav-hint .nav-col { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
#nav-hint .nav-col span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nav-time { font-size: 12px; opacity: .85; }

/* Маркеры — нумерованные кружки */
.pin {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4);
  cursor: pointer;
  background: #b0b0b0;            /* locked = серый */
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; line-height: 1;
}
.pin.unlocked { background: #2e9e4f; }   /* unlocked = зелёный */
.pin.start { background: #e8a317; }       /* стартовая точка квеста — золотая */

/* Объект (музей и т.п.) — синий круглый пин с иконкой */
.opin {
  width: 30px; height: 30px; border-radius: 50%;
  background: #2b6cb0; border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; cursor: pointer; line-height: 1;
}

/* Описание в карточке */
#modal-desc { margin: 12px 0 0; font-size: 15px; line-height: 1.45; color: #2a3a30; white-space: pre-wrap; }
#modal-desc:empty { display: none; }

/* Метка пользователя */
.me {
  width: 18px; height: 18px; border-radius: 50%;
  background: #1a73e8; border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(26,115,232,.25);
}

/* Модалка */
#modal {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 16px;
}
#modal.hidden, #toast.hidden { display: none; }
.modal-card {
  position: relative; background: #fff; border-radius: 16px;
  width: 100%; max-width: 420px; max-height: 86vh; overflow: auto;
  padding: 18px;
}
.modal-card h2 { margin: 0 36px 12px 0; font-size: 19px; }
.modal-card img {
  width: 100%; border-radius: 10px; display: block; background: #eee;
}
.gallery { position: relative; }
.gal-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border: none; border-radius: 50%;
  background: rgba(0,0,0,.5); color: #fff; font-size: 22px; cursor: pointer;
}
#gal-prev { left: 8px; } #gal-next { right: 8px; }
.gal-nav.hidden { display: none; }
#gal-count {
  position: absolute; bottom: 8px; right: 10px;
  background: rgba(0,0,0,.6); color: #fff; padding: 2px 8px; border-radius: 12px; font-size: 12px;
}
#gal-count:empty { display: none; }
#modal-close {
  position: absolute; top: 10px; right: 10px;
  width: 34px; height: 34px; border: none; border-radius: 50%;
  background: #eee; font-size: 16px; cursor: pointer;
}
.modal-audio { margin-top: 14px; }
#modal-replay {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: #0f5132; color: #fff; font-size: 16px; cursor: pointer;
}
#modal-replay.pulse { animation: btnpulse 1s ease-in-out infinite; }
@keyframes btnpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(15,81,50,.5); } 50% { box-shadow: 0 0 0 8px rgba(15,81,50,0); } }

/* Индикатор офлайна */
#offline-status {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 42px); z-index: 11;
  background: #fff; border-radius: 14px; padding: 6px 14px;
  font-size: 13px; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.25);
  cursor: pointer; max-width: 90%; text-align: center;
}
/* строки плашки: имя тура, (в квесте) оставшееся время, статус; длинное обрезается многоточием */
#offline-status .off-name,
#offline-status .off-time,
#offline-status .off-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#offline-status .off-name { font-weight: 700; }
#offline-status .off-time { font-size: 12px; opacity: .85; }
#offline-status.ok { background: #cdeccd; color: #0f5132; }
#offline-status.warn { background: #fff4d6; color: #7a5b00; }
#offline-status.err { background: #f3d6d4; color: #8a1a14; }

/* Выбор города / «нас тут пока нет» */
#nocity-overlay {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15,40,28,.92); padding: 16px;
}
#nocity-overlay.hidden { display: none; }
#nocity-overlay .modal-card { max-width: 380px; }
#nocity-list button {
  display: block; width: 100%; margin: 8px 0; padding: 12px;
  border: none; border-radius: 10px; background: #0f5132; color: #fff;
  font-size: 16px; cursor: pointer;
}

/* О проекте */
#about-overlay {
  position: absolute; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 16px;
}
#about-overlay.hidden { display: none; }
#about-overlay .modal-card { max-width: 380px; position: relative; }
#about-close {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px;
  border: none; border-radius: 50%; background: #eee; cursor: pointer; font-size: 14px;
}
.about-text { margin: 0 0 10px; font-size: 15px; line-height: 1.45; color: #2c3b32; }
.about-contact { margin: 4px 0 10px; font-size: 18px; font-weight: 700; }
.about-contact a { color: #0f5132; }
.about-ver { font-size: 12px; color: #8a958e; margin: 0; }
.about-h3 { margin: 16px 0 8px; font-size: 16px; color: #0f5132; }

/* Панель информации (активный маршрут туриста) */
#info-overlay {
  position: absolute; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 16px;
}
#info-overlay.hidden { display: none; }
#info-overlay .modal-card { max-width: 400px; position: relative; }
#info-close {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px;
  border: none; border-radius: 50%; background: #eee; cursor: pointer; font-size: 14px;
}
.info-cover { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 12px; display: block; margin-bottom: 10px; background: #dce6df; }
.info-route-name { font-size: 18px; font-weight: 700; color: #14321f; margin-bottom: 6px; }
.info-route-desc { font-size: 15px; line-height: 1.45; color: #2c3b32; white-space: pre-wrap; margin-bottom: 10px; }
.info-progress { font-size: 15px; font-weight: 600; color: #0f5132; margin: 10px 0 6px; }
.btn-finish { width: 100%; margin-top: 6px; padding: 12px; border: none; border-radius: 10px; background: #0f5132; color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn-finish:active { background: #0c3f28; }
.btn-about-open {
  width: 100%; margin-top: 6px; padding: 11px; border: none; border-radius: 10px;
  background: #eaf3ee; color: #0f5132; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-about-open:active { background: #d9ebe0; }

/* Блок компании (управляющего) — в инфо и в каталоге */
.info-company, .cat-company {
  display: flex; gap: 10px; align-items: flex-start;
  background: #f4f8f5; border-radius: 12px; padding: 10px; margin: 8px 0;
}
.info-company .co-logo, .cat-company .co-logo {
  width: 48px; height: 48px; object-fit: contain; border-radius: 8px;
  background: #fff; flex: none; display: block;
}
.co-text { min-width: 0; }
.co-name { font-weight: 700; font-size: 15px; color: #14321f; }
.co-about { font-size: 13px; color: #3c4a40; line-height: 1.4; margin-top: 2px; white-space: pre-wrap; }
.co-contacts { font-size: 13px; color: #0f5132; line-height: 1.4; margin-top: 4px; white-space: pre-wrap; }

/* Каталог городов/маршрутов в «О проекте» */
.cat-city { border: 1px solid #e2e8e4; border-radius: 12px; margin-bottom: 8px; overflow: hidden; }
.cat-city > summary { cursor: pointer; padding: 11px 12px; font-weight: 600; font-size: 15px; background: #f4f8f5; list-style: none; }
.cat-city > summary::-webkit-details-marker { display: none; }
.cat-body { padding: 8px 12px 12px; }
.cat-group { margin-bottom: 8px; }
.cat-route { padding: 7px 0; border-top: 1px solid #eef2ef; display: flex; gap: 10px; align-items: flex-start; }
.cat-route:first-child { border-top: none; }
.cat-cover { width: 64px; height: 44px; object-fit: cover; border-radius: 8px; flex: none; background: #dce6df; }
.cat-route-tx { min-width: 0; }
.cat-route-name { font-weight: 600; font-size: 14px; color: #14321f; }
.cat-route-desc { font-size: 13px; color: #4a574e; line-height: 1.4; margin-top: 2px; white-space: pre-wrap; }

/* Оверлей входа */
#login-overlay {
  position: absolute; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 16px;
}
#login-overlay.hidden { display: none; }
#login-overlay .modal-card { max-width: 360px; }
#login-overlay .muted { color: #6a7a70; font-size: 14px; margin: 4px 0 12px; }
#login-code {
  width: 100%; padding: 12px; font-size: 20px; text-align: center;
  letter-spacing: 2px; text-transform: uppercase; font-family: ui-monospace, monospace;
  border: 1px solid #cbd5d0; border-radius: 10px;
}
#login-submit {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: #0f5132; color: #fff; font-size: 16px; cursor: pointer;
}
#login-error { color: #b3261e; font-size: 14px; min-height: 18px; margin-top: 8px; text-align: center; }
.linklike { display: block; margin: 12px auto 0; background: none; border: none;
  color: #6a7a70; text-decoration: underline; cursor: pointer; font-size: 14px; }

/* Тост */
#toast {
  position: absolute; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: #fff; padding: 10px 16px;
  border-radius: 20px; font-size: 14px; z-index: 30; max-width: 80%;
  text-align: center;
}
