:root {
  --brand: #f04e30;
  --brand-dark: #c93d24;
  --bg: #ffffff;
  --bg-soft: #f5f3f0;
  --ink: #2a2a30;
  --ink-muted: #6b6b75;
  --line: #e2e0dc;
  --card: #ffffff;
  --page-max: 1280px;
  --header-pad-x: 0.85rem;
  --header-pad-x-desktop: 3rem;
  --header-h: 3rem;
  --header-h-desktop: 5.75rem;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  touch-action: manipulation;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg);
}

/* --- Шапка (оранжевая на всю ширину, контент — в контейнере) --- */
.site-header {
  flex: 0 0 auto;
  width: 100%;
  background: var(--brand);
  border-bottom: 3px solid var(--brand-dark);
  z-index: 10;
}

.header-inner {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0.55rem var(--header-pad-x);
  min-height: var(--header-h);
  box-sizing: border-box;
}

body.mode-desktop .header-inner {
  padding: 1rem var(--header-pad-x-desktop);
  min-height: var(--header-h-desktop);
}

.header-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  flex: 0 1 auto;
  min-width: 0;
}

.header-game {
  font-size: clamp(1.05rem, 4vw, 1.4rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--bg-soft);
  line-height: 1.15;
}

body.mode-desktop .header-game {
  font-size: 1.75rem;
}

.header-decor {
  display: none;
  align-items: center;
  gap: 0.65rem;
  flex: 0 0 auto;
}

@media (min-width: 720px) {
  .header-decor:not(:empty) {
    display: flex;
  }
}

.header-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

body.mode-desktop .header-img {
  width: 52px;
  height: 52px;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  flex: 0 0 auto;
  margin-left: auto;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.9rem 0.48rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--bg-soft);
}

.hud-pill .hud-label,
.hud-pill strong {
  transform: translateY(-2px);
}

body.mode-desktop .hud-pill {
  padding: 0.38rem 1.05rem 0.58rem;
  font-size: 0.88rem;
}

.hud-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.9;
}

body.mode-desktop .hud-label {
  font-size: 0.72rem;
}

.hud strong {
  font-weight: 800;
  font-size: 0.95rem;
}

body.mode-desktop .hud strong {
  font-size: 1.1rem;
}

/* --- Игра = весь фон страницы --- */
.game-wrap {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  background: var(--bg);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: var(--bg);
}

/* --- Оверлеи: светлая инфографика, без «тёмного кино» --- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.88);
  z-index: 5;
  overflow-y: auto;
}

.overlay.hidden {
  display: none;
}

.overlay-modal {
  background: rgba(255, 255, 255, 0.72);
}

#overlay-nickname {
  z-index: 8;
}

.menu-layout {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 680px;
}

@media (min-width: 640px) {
  .menu-layout {
    flex-direction: row;
    align-items: stretch;
  }
  .menu-main {
    flex: 1.1;
  }
  .leaderboard-panel {
    flex: 0.9;
  }
}

.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: 0 2px 0 var(--line);
}

.modal-card {
  max-width: 20rem;
  width: 100%;
  text-align: center;
}

.card h2,
.card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: 0.04em;
}

.card p {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ink-muted);
}

.stat-big {
  font-size: 1.75rem;
  color: var(--ink);
  margin-bottom: 1rem !important;
}

.btn {
  border: 2px solid var(--brand-dark);
  border-radius: 8px;
  padding: 0.7rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  letter-spacing: 0.04em;
  width: 100%;
  max-width: 14rem;
}

.btn:active {
  transform: translateY(1px);
  background: var(--brand-dark);
}

.card input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  text-align: center;
  color: var(--ink);
}

.hint {
  margin: 0.65rem 0 0;
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.lb-error {
  color: #c62828;
}

.leaderboard-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.8rem;
}

.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}

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

.leaderboard-list .lb-rank {
  color: var(--brand);
  font-weight: 800;
  min-width: 1.5rem;
}

.leaderboard-list .lb-nick {
  flex: 1;
  color: var(--ink);
  font-weight: 600;
}

.leaderboard-list .lb-dist {
  color: var(--ink-muted);
  font-weight: 700;
}

.leaderboard-list .lb-empty {
  justify-content: center;
  border: none;
  color: var(--ink-muted);
}

body.mode-mobile .hint-desktop {
  display: none;
}

body.mode-desktop .hint-mobile {
  display: none;
}

.game-hud-bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.35rem 0.85rem;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  z-index: 4;
}

.game-hud-bar.hidden {
  display: none;
}

.upgrade-choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 18rem;
  margin: 0 auto;
}

.upgrade-btn {
  max-width: none;
}

.ad-slot {
  margin-top: 0.75rem;
  min-height: 50px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  font-size: 0.7rem;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Мобильное управление --- */
.mobile-controls {
  flex: 0 0 auto;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.85rem;
  background: var(--bg-soft);
  border-top: 2px solid var(--line);
}

body.mode-mobile .mobile-controls:not(.hidden) {
  display: flex;
}

.joystick {
  position: relative;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid var(--line);
  touch-action: none;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--brand-dark);
  pointer-events: none;
}

.ctrl-btn {
  border: 2px solid var(--brand-dark);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 800;
  background: var(--brand);
  color: #fff;
  min-width: 5.5rem;
}

.ctrl-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ctrl-btn.nitro {
  flex: 1;
  max-width: 10rem;
}
