:root {
  --bg: #0b0d12;
  --fg: #e6e9ef;
  --muted: #8a93a6;
  --panel: rgba(14, 18, 26, .78);
  --border: rgba(120, 140, 180, .22);
  --accent: #6ee7b7;
  --danger: #ff6b6b;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  z-index: 10;
  display: flex;
  gap: 18px;
  pointer-events: none;
}

#hud.hidden {
  display: none;
}

.hud-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.hud-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  line-height: 1;
}

.hud-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  color: var(--fg);
}

/* ---------- Кнопка языка ---------- */

#lang-btn {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  z-index: 30;
  min-width: 52px;
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .04em;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color .15s ease, color .15s ease, transform .1s ease;
}

#lang-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#lang-btn:active {
  transform: scale(.94);
}

#lang-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Оверлеи ---------- */

#overlay,
#gameover {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 10, 15, .72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 20;
}

#gameover {
  z-index: 25;
}

#overlay-panel,
#gameover-panel {
  width: 100%;
  max-width: 520px;
  padding: 30px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
  text-align: center;
}

#overlay-title {
  margin: 0 0 10px;
  font-size: 40px;
  line-height: 1.1;
  letter-spacing: .14em;
  font-weight: 800;
  color: var(--fg);
}

#overlay-subtitle {
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}

#overlay-how {
  margin: 16px 0 20px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

#overlay-hint {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted);
  opacity: .8;
}

/* ---------- Переключатель языка в меню ---------- */

#lang-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.lang-opt {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.lang-opt:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lang-opt.active {
  background: var(--accent);
  color: #06231a;
  border-color: var(--accent);
}

.lang-opt:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Кнопки ---------- */

#play-btn,
#restart-btn {
  display: inline-block;
  padding: 14px 36px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #06231a;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .04em;
  cursor: pointer;
  transition: filter .15s ease, transform .1s ease;
}

#play-btn:hover,
#restart-btn:hover {
  filter: brightness(1.08);
}

#play-btn:active,
#restart-btn:active {
  transform: scale(.97);
}

#play-btn:focus-visible,
#restart-btn:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

#menu-btn {
  display: inline-block;
  margin-left: 10px;
  padding: 13px 26px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, transform .1s ease;
}

#menu-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#menu-btn:active {
  transform: scale(.97);
}

#menu-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- Game over ---------- */

#gameover-title {
  margin: 0 0 12px;
  font-size: 30px;
  letter-spacing: .1em;
  font-weight: 800;
  color: var(--danger);
}

#gameover-score {
  margin: 0 0 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

#gameover-record {
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

/* ---------- Подсказка тач-управления ---------- */

#touch-hint {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  z-index: 12;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  opacity: .75;
  pointer-events: none;
}

#touch-hint.hidden {
  display: none;
}

/* ---------- Вспышка ---------- */

#flash {
  position: fixed;
  inset: 0;
  background: #b9ffd6;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms linear;
  z-index: 40;
}

/* ---------- Служебное ---------- */

.hidden {
  display: none !important;
}

/* ---------- Мобильные ---------- */

@media (max-width: 560px) {
  #hud {
    gap: 12px;
  }

  .hud-value {
    font-size: 15px;
  }

  #overlay-title {
    font-size: 30px;
  }

  #play-btn {
    width: 100%;
  }

  #overlay-panel,
  #gameover-panel {
    padding: 24px 20px;
  }
}

@media (max-height: 460px) {
  #overlay-panel,
  #gameover-panel {
    padding: 16px 20px;
  }

  #overlay-title {
    font-size: 26px;
    margin-bottom: 6px;
  }

  #overlay-subtitle {
    margin-bottom: 10px;
  }

  #overlay-how {
    margin: 10px 0 12px;
  }

  #play-btn,
  #restart-btn {
    padding: 10px 26px;
  }

  #overlay-hint {
    margin-top: 8px;
  }
}
