/* Интерфейс игры: канвас на весь экран, HUD сверху, экраны-слои по центру. */

:root {
  --bg: #0c1226;
  --card: rgba(16, 22, 44, 0.94);
  --text: #eaf0ff;
  --muted: #9aa7c7;
  --accent: #ffd166;
  --accent-press: #f4b942;
  --chip-bg: rgba(12, 18, 38, 0.72);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Системный жест «потянуть вниз» (обновление страницы в Chromium) тоже
     снимается: он сдвигал страницу игры при свайпе приседа. */
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

body {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
  z-index: 20;
}

#hud .icon-btn {
  pointer-events: auto;
}

.hud-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 70%;
}

.hud-right {
  align-items: flex-end;
  flex-direction: row;
  max-width: none;
}

.chip {
  background: var(--chip-bg);
  border: 1px solid rgba(154, 167, 199, 0.25);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 14px;
  white-space: nowrap;
  align-self: flex-start;
}

.chip-soft {
  max-width: 100%;
  white-space: normal;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

#progress-track {
  display: inline-block;
  width: 84px;
  height: 8px;
  border-radius: 999px;
  background: rgba(154, 167, 199, 0.25);
  overflow: hidden;
  flex: none;
}

#progress-bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.35s ease;
}

.letter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  margin-left: 4px;
  border-radius: 6px;
  background: var(--accent);
  color: #1c2340;
  font-weight: 700;
  font-size: 14px;
}

.icon-btn {
  pointer-events: auto;
  border: 1px solid rgba(154, 167, 199, 0.25);
  border-radius: 10px;
  background: var(--chip-bg);
  color: var(--text);
  font-size: 16px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:active {
  background: rgba(58, 66, 96, 0.9);
}

/* Кнопка приседа: удержание, видна только в забеге. */
.duck-btn {
  position: fixed;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 1px solid rgba(154, 167, 199, 0.35);
  background: var(--chip-bg);
  color: var(--text);
  font-size: 26px;
  z-index: 20;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.duck-btn:active {
  background: var(--accent);
  color: #1c2340;
}

/* Кнопка прыжка: зеркало приседа у левого края, нажатие сразу прыгает. */
.jump-btn {
  position: fixed;
  left: 18px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 1px solid rgba(154, 167, 199, 0.35);
  background: var(--chip-bg);
  color: var(--text);
  font-size: 26px;
  z-index: 20;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.jump-btn:active {
  background: var(--accent);
  color: #1c2340;
}

/* ---------- Экраны ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

#screen-start {
  background: linear-gradient(rgba(6, 10, 24, 0.55), rgba(6, 10, 24, 0.82));
}

#screen-pause,
#screen-over {
  background: rgba(6, 10, 24, 0.78);
}

.card {
  background: var(--card);
  border: 1px solid rgba(154, 167, 199, 0.2);
  border-radius: var(--radius);
  padding: 22px 20px;
  width: min(420px, 100%);
  text-align: center;
  box-shadow: 0 14px 40px rgba(4, 7, 18, 0.55);
}

.title {
  margin: 0 0 10px;
  font-size: 26px;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.score-big {
  font-size: 44px;
  font-weight: 800;
  margin: 4px 0 10px;
  color: var(--accent);
}

.subtitle {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--muted);
}

.stat-line {
  margin: 6px 0;
  font-size: 15px;
}

.stat-line.muted {
  color: var(--muted);
  font-size: 13px;
}

/* Выбор персонажа: две карточки с превью. */
#char-select {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 12px 0 4px;
}

.char-card {
  flex: 1;
  max-width: 150px;
  padding: 8px 6px 10px;
  border-radius: var(--radius);
  border: 1px solid rgba(154, 167, 199, 0.25);
  background: rgba(58, 66, 96, 0.35);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.char-card img {
  height: 74px;
  object-fit: contain;
}

.char-card.selected {
  border-color: var(--accent);
  background: rgba(255, 209, 102, 0.12);
}

.section-title {
  margin: 18px 0 8px;
  font-size: 15px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.leaderboard {
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(154, 167, 199, 0.14);
  font-size: 14px;
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.leaderboard-empty {
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Кнопки ---------- */

.primary-btn,
.secondary-btn {
  display: block;
  width: 100%;
  margin: 10px 0 0;
  padding: 13px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.primary-btn {
  background: var(--accent);
  color: #1c2340;
}

.primary-btn:active {
  background: var(--accent-press);
}

.secondary-btn {
  background: rgba(58, 66, 96, 0.55);
  color: var(--text);
  border: 1px solid rgba(154, 167, 199, 0.25);
}

.secondary-btn:active {
  background: rgba(74, 83, 118, 0.75);
}

.notice {
  margin: 10px 0 2px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  background: rgba(154, 167, 199, 0.14);
  color: var(--muted);
}

.notice.accent {
  background: rgba(255, 209, 102, 0.16);
  color: var(--accent);
}

.offline {
  max-width: 260px;
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(196, 84, 84, 0.2);
  border: 1px solid rgba(220, 120, 120, 0.35);
  color: #f0c8c8;
  font-size: 12px;
  align-self: flex-start;
}

@media (max-width: 480px) {
  .card {
    padding: 18px 14px;
  }

  .title {
    font-size: 22px;
  }

  .score-big {
    font-size: 36px;
  }
}