* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  background: #0b1f2a;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
#game-root {
  width: 100vw;
  height: 100vh;   /* фолбэк */
  height: 100dvh;  /* видимая высота экрана: на мобиле НЕ включает полосу URL → низ/верх с кнопками не уезжают за хром браузера */
}
canvas { display: block; touch-action: none; }

/* Панель баг-репорта */
#bugpanel { position: fixed; inset: 0; z-index: 95; display: none; align-items: center; justify-content: center; background: rgba(0, 0, 0, .6); padding: 16px; }
.bug-box { width: min(420px, 92vw); background: #0e2a38; border: 3px solid #ff8a65; border-radius: 16px; padding: 18px; box-shadow: 0 8px 30px #000a; }
.bug-title { font: 800 22px/1 -apple-system, "Segoe UI", sans-serif; color: #ffab91; margin-bottom: 12px; }
#bug-text { width: 100%; height: 120px; resize: none; border-radius: 10px; border: 2px solid #3aa0ff; background: #06141c; color: #fff; font-size: 16px; padding: 10px; outline: none; box-sizing: border-box; }
#bug-status { color: #7fd3ff; font: 600 14px sans-serif; min-height: 18px; margin: 8px 2px; }
.bug-actions { display: flex; gap: 12px; justify-content: flex-end; }
.bug-actions button { padding: 12px 20px; border-radius: 10px; border: none; font: 800 16px sans-serif; touch-action: none; -webkit-tap-highlight-color: transparent; }
#bug-cancel { background: #37474f; color: #fff; }
#bug-send { background: #ff8a65; color: #1a0a00; }

/* Панель ачивок — DOM-оверлей, скроллится, крупные названия + описания */
#achpanel {
  position: fixed; inset: 0; z-index: 90; display: none; flex-direction: column;
  background: rgba(6, 20, 28, .97); color: #cfe8f5;
  padding: calc(10px + env(safe-area-inset-top)) 14px calc(10px + env(safe-area-inset-bottom));
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
#ach-title, #album-title { font: 800 22px/1.1 -apple-system, "Segoe UI", sans-serif; color: #fff; }
/* музыкальный альбом */
#albumpanel {
  position: fixed; inset: 0; z-index: 90; display: none; flex-direction: column;
  background: rgba(6, 20, 28, .97); color: #cfe8f5;
  padding: calc(10px + env(safe-area-inset-top)) 14px calc(10px + env(safe-area-inset-bottom));
}
#album-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-wrap: wrap; gap: 9px; align-content: flex-start; }
.alb-item { background: #0e2a38; border: 2px solid #2a4a5a; border-radius: 10px; padding: 10px 13px; font: 700 14px -apple-system, "Segoe UI", sans-serif; color: #8aa3b0; }
.alb-item.got { color: #fff; border-color: #7fd3ff; }
.alb-item.secret { border-color: #ffd54f; box-shadow: 0 0 9px #ffd54f55; color: #ffd54f; }
.alb-item.secret.got { color: #fff; background: #3a2e00; }
#ach-close, #album-close { width: 44px; height: 44px; border-radius: 10px; border: 2px solid #fff; background: #7fd3ff; color: #0b1f2a; font: 800 20px/1 sans-serif; touch-action: none; }
#ach-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ach-item { padding: 8px 4px; border-bottom: 1px solid #ffffff14; opacity: .55; }
.ach-item.got { opacity: 1; }
.ach-name { font: 800 19px/1.2 -apple-system, "Segoe UI", sans-serif; color: #ffe082; }
.ach-item.got .ach-name { color: #aee571; }
.ach-desc { font: 400 14px/1.3 -apple-system, "Segoe UI", sans-serif; color: #cfe8f5; margin-top: 2px; }

/* Тост ачивки — по центру-сверху, золотой, с поп-анимацией */
#achtoast {
  position: fixed; left: 50%; top: 22%; transform: translateX(-50%);
  z-index: 82; display: none; text-align: center;
  background: rgba(36, 22, 0, .95); border: 3px solid #ffd54f; border-radius: 16px;
  padding: 12px 22px; color: #ffd54f; font: 800 16px/1.2 -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 0 26px #ffd54f88, 0 6px 20px #000a; pointer-events: none; max-width: 92vw;
}
#achtoast .at-name { color: #fff; font-size: 23px; margin-top: 4px; text-shadow: 0 2px 4px #000; }
#achtoast.pop { animation: atpop .55s ease-out; }
@keyframes atpop { 0% { transform: translateX(-50%) scale(.3); opacity: 0; } 60% { transform: translateX(-50%) scale(1.12); opacity: 1; } 100% { transform: translateX(-50%) scale(1); } }

/* Центр-промпт замка музыки — крупная заметная кнопка по центру */
#musicprompt {
  position: fixed; left: 50%; top: 38%;
  transform: translate(-50%, -50%); z-index: 80;
  background: rgba(255, 138, 101, .95); color: #1a0a00;
  border: 4px solid #fff; border-radius: 16px;
  font: 800 24px/1.1 -apple-system, "Segoe UI", sans-serif;
  padding: 16px 22px; text-align: center;
  box-shadow: 0 6px 24px #000a; touch-action: none; -webkit-tap-highlight-color: transparent;
  animation: mppop .25s ease-out;
}
@keyframes mppop { from { transform: translate(-50%, -50%) scale(.6); } to { transform: translate(-50%, -50%) scale(1); } }

/* Счётчик секунд спец-ивента (под шкалой трассы) */
#eventcd {
  position: fixed; left: 50%; top: 44px; transform: translateX(-50%); z-index: 70;
  background: rgba(10, 12, 30, .82); color: #9be7ff;
  border: 2px solid #6fe3ff; border-radius: 12px;
  font: 800 20px/1 -apple-system, "Segoe UI", sans-serif;
  padding: 7px 16px; text-align: center; pointer-events: none;
  box-shadow: 0 3px 14px #000a;
}

/* HTML-шкала трассы (телефон): прибита к видимому верху, точки = позиции гонщиков */
#trackbar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 60;
  display: none; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px; /* отступ сверху — из-под нотча/панели браузера */
  pointer-events: none; /* фон прозрачный — верхний HUD (стамина/счёт) виден */
}
#trackbar.on { display: flex; }
.tb-cap { color: #fff; font: 800 15px/1 -apple-system, "Segoe UI", sans-serif; white-space: nowrap; text-shadow: 0 0 4px #000, 0 0 4px #000; }
.tb-line { position: relative; flex: 1; height: 9px; background: rgba(0, 0, 0, .35); border: 2px solid rgba(255, 255, 255, .7); border-radius: 6px; }
#tb-dots { position: absolute; inset: 0; }
.tb-dot { position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; transform: translate(-50%, -50%); border: 2px solid rgba(0, 0, 0, .6); box-shadow: 0 0 4px #000; }
.tb-dot.me { width: 22px; height: 22px; border: 3px solid #fff; z-index: 2; }
.tb-ctl { pointer-events: auto; width: 42px; height: 42px; border-radius: 50%; background: rgba(7, 49, 74, .62); border: 2.5px solid rgba(255, 255, 255, .9); color: #fff; font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center; touch-action: none; -webkit-tap-highlight-color: transparent; flex: 0 0 auto; }
.tb-ctl:active { background: rgba(255, 255, 255, .4); }

/* HTML-кнопки управления (телефон): прибиты к видимому низу экрана, всегда поверх игры */
#touchpad {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: none; justify-content: space-between; align-items: flex-end;
  padding: 0 18px calc(16px + env(safe-area-inset-bottom));
  pointer-events: none;
}
#touchpad.on { display: flex; }
.tp-left, .tp-right { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.tp-right { align-items: flex-end; }
.tp-arrows { display: flex; gap: 16px; }
.tp-row { display: flex; gap: 14px; align-items: flex-end; }
.tp-btn {
  pointer-events: auto;
  width: 96px; height: 96px; border-radius: 50%;
  background: rgba(7, 49, 74, .6);
  border: 4px solid rgba(255, 255, 255, .92);
  color: #fff; font: 700 34px/1 -apple-system, "Segoe UI", sans-serif;
  display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none; touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.tp-btn:active { background: rgba(255, 255, 255, .45); }
.tp-small { width: 70px; height: 70px; font-size: 28px; }

/* Кнопка полноэкранного режима — маленькая, левый-нижний угол, поверх всего */
#fsbtn {
  position: fixed; left: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 95;
  width: 40px; height: 40px; border-radius: 9px; border: 2px solid rgba(255,255,255,.6);
  background: rgba(7,49,74,.7); color: #fff; font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center; touch-action: none; -webkit-tap-highlight-color: transparent; cursor: pointer;
}
#fsbtn:active { background: rgba(255,255,255,.35); }

/* Скрытая секретная ачивка в списке — золотая рамка, замаскированная «???» */
.ach-item.secret .ach-name { color: #ffd54f; }
.ach-item.secret { border-left: 3px solid #ffd54f55; }

/* Текстовые разделы (абилки/предметы/как играть) — скроллируемая панель */
#infopanel {
  position: fixed; inset: 0; z-index: 90; display: none; flex-direction: column;
  background: rgba(6, 20, 28, .97); color: #cfe8f5;
  padding: calc(10px + env(safe-area-inset-top)) 14px calc(10px + env(safe-area-inset-bottom));
}
#info-title { font: 800 22px/1.1 -apple-system, "Segoe UI", sans-serif; color: #fff; }
#info-close { width: 44px; height: 44px; border-radius: 10px; border: 2px solid #fff; background: #7fd3ff; color: #0b1f2a; font: 800 20px/1 sans-serif; touch-action: none; }
#info-list {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; margin-top: 8px;
  white-space: pre-wrap; word-break: break-word;
  font: 400 15px/1.45 -apple-system, "Segoe UI", sans-serif; color: #cfe8f5;
}

/* Доска почёта — две таблицы рядом (дневной | глобальный) */
#honorpanel {
  position: fixed; inset: 0; z-index: 90; display: none; flex-direction: column;
  background: rgba(6, 20, 28, .97); color: #cfe8f5;
  padding: calc(10px + env(safe-area-inset-top)) 14px calc(10px + env(safe-area-inset-bottom));
}
#honor-title { font: 800 22px/1.1 -apple-system, "Segoe UI", sans-serif; color: #ffd54f; }
#honor-close { width: 44px; height: 44px; border-radius: 10px; border: 2px solid #fff; background: #7fd3ff; color: #0b1f2a; font: 800 20px/1 sans-serif; touch-action: none; }
.hb-cols { flex: 1; display: flex; gap: 12px; overflow: hidden; }
.hb-col { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #0e2a38; border: 2px solid #2a4a5a; border-radius: 12px; overflow: hidden; }
.hb-col-title { font: 800 17px/1.1 -apple-system, "Segoe UI", sans-serif; color: #fff; text-align: center; padding: 10px 6px; background: #123445; border-bottom: 2px solid #2a4a5a; }
.hb-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 0; }
.hb-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid #ffffff10; font: 700 17px/1.2 -apple-system, "Segoe UI", sans-serif; }
.hb-rank { flex: 0 0 30px; text-align: center; color: #ffe082; font-weight: 800; }
.hb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #cfe8f5; }
.hb-score { flex: 0 0 auto; color: #aee571; font-weight: 800; }
.hb-empty { color: #7f9aa8; justify-content: center; font-weight: 400; }

/* ДЕСКТОП-кнопки: DOM-оверлеи в боковых чёрных полях (вне игрового кадра). Позицию (left/right/top) ставит JS по rect канваса. */
.deskpad {
  position: fixed; z-index: 50; display: none;
  flex-direction: column; align-items: center; gap: 22px;
  pointer-events: none;
}
.deskpad.on { display: flex; }
.dp-arrows { display: flex; gap: 14px; }
.dp-btn {
  pointer-events: auto; position: relative;
  width: 78px; height: 78px; border-radius: 50%;
  background: rgba(7, 49, 74, .88); border: 3px solid rgba(255, 255, 255, .92);
  color: #fff; font: 700 30px/1 -apple-system, "Segoe UI", sans-serif;
  display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none; touch-action: none;
  -webkit-tap-highlight-color: transparent; cursor: pointer;
}
.dp-btn:active { background: rgba(255, 255, 255, .42); }
.dp-ico { line-height: 1; pointer-events: none; }
.dp-btn i {
  position: absolute; bottom: -19px; left: 50%; transform: translateX(-50%);
  font: 800 13px/1 -apple-system, "Segoe UI", sans-serif; font-style: normal;
  color: #ffe082; background: rgba(6, 34, 44, .92); padding: 3px 7px;
  border-radius: 6px; white-space: nowrap; pointer-events: none;
}

/* Поле ника — HTML-оверлей поверх канваса (показывается только в меню) */
#nick {
  position: fixed;
  top: 10.5%; left: 50%; transform: translateX(-50%);
  width: 200px; padding: 8px 10px;
  border-radius: 8px; border: 2px solid #3aa0ff;
  background: #0e2a38; color: #fff;
  font-size: 17px; text-align: center; outline: none;
  display: none; z-index: 10;
}
