*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #e8f1ff;
  background:
    radial-gradient(ellipse at top, #1b2750 0%, transparent 55%),
    radial-gradient(ellipse at bottom, #12081f 0%, #05060d 70%);
  background-color: #05060d;
}

.game-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: clamp(10px, 2vw, 20px);
  gap: 12px;
}

.game-header {
  flex: 0 0 auto;
  text-align: center;
}

.game-header h1 {
  font-size: clamp(1.2rem, 2.4vw, 1.8rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f4fbff;
  text-shadow:
    0 0 12px rgba(90, 180, 255, 0.45),
    0 0 28px rgba(80, 120, 255, 0.25);
}

.game-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 20px;
  border: 1px solid rgba(140, 190, 255, 0.22);
  box-shadow:
    0 0 0 1px rgba(8, 12, 28, 0.8) inset,
    0 18px 40px rgba(0, 0, 0, 0.45),
    0 0 50px rgba(50, 110, 220, 0.12);
  background: #070b18;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 20px;
}

.game-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

/* ---------- Счёт ---------- */

.score-display {
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  color: #ffffff;
  text-shadow:
    0 0 16px rgba(90, 180, 255, 0.65),
    0 3px 10px rgba(0, 0, 0, 0.5);
}

.score-display.bump {
  animation: score-bump 0.25s ease;
}

@keyframes score-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* ---------- Копилка монет и активные эффекты ---------- */

.coins-display {
  position: absolute;
  top: clamp(60px, 10vh, 84px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(1.05rem, 2.4vw, 1.4rem);
  font-weight: 700;
  color: #ffd166;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.effects-display {
  position: absolute;
  top: clamp(48px, 8vh, 62px);
  left: 16px;
  display: flex;
  gap: 8px;
}

/* ---------- Жизни ---------- */

.lives-display {
  position: absolute;
  top: 12px;
  left: 16px;
  font-size: clamp(1.05rem, 2.2vw, 1.3rem);
  letter-spacing: 3px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

/* ---------- Уровни ---------- */

.level-display {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(9, 14, 34, 0.75);
  border: 1px solid rgba(140, 190, 255, 0.4);
  font-size: clamp(0.85rem, 1.8vw, 1rem);
  font-weight: 700;
  color: #e8f1ff;
  white-space: nowrap;
}

.level-banner {
  position: absolute;
  top: 34%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(1.5rem, 4.5vw, 2.6rem);
  font-weight: 800;
  color: #ffffff;
  opacity: 0;
  pointer-events: none;
  text-shadow:
    0 0 18px rgba(120, 180, 255, 0.7),
    0 4px 12px rgba(0, 0, 0, 0.6);
}

.level-banner.show {
  animation: level-banner 2.4s ease forwards;
}

@keyframes level-banner {
  0% { opacity: 0; transform: scale(0.6); }
  14% { opacity: 1; transform: scale(1.06); }
  22% { transform: scale(1); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-26px); }
}

.level-path {
  color: #8fa8d8;
  font-size: 0.88em;
}

.effect-chip {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(9, 14, 34, 0.75);
  border: 1px solid rgba(140, 190, 255, 0.4);
  font-size: clamp(0.85rem, 1.8vw, 1rem);
  font-weight: 700;
  color: #ffffff;
}

.effect-shield {
  border-color: rgba(127, 212, 255, 0.7);
  box-shadow: 0 0 12px rgba(127, 212, 255, 0.35);
}

.effect-boost {
  border-color: rgba(255, 154, 61, 0.7);
  box-shadow: 0 0 12px rgba(255, 154, 61, 0.35);
}

.effect-laser {
  border-color: rgba(255, 130, 60, 0.8);
  box-shadow: 0 0 14px rgba(255, 120, 40, 0.5);
  color: #ffd9a8;
}

.bonus-line {
  color: #a9c4ee;
}

/* ---------- Супер-лазер ---------- */

.laser-hud {
  position: absolute;
  top: 14px;
  right: 16px;
  text-align: right;
}

.laser-label {
  font-size: clamp(0.7rem, 1.6vw, 0.85rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #ffb072;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.laser-bar {
  margin-top: 4px;
  width: clamp(110px, 14vw, 150px);
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 160, 80, 0.5);
  background: rgba(9, 14, 34, 0.75);
  overflow: hidden;
}

.laser-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff8c42, #ffd166);
  transition: width 0.15s linear;
}

.laser-hud.ready .laser-fill {
  animation: laser-ready 0.9s ease-in-out infinite;
}

@keyframes laser-ready {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.55); }
}

.laser-button {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255, 190, 110, 0.9);
  background: radial-gradient(circle at 35% 30%, #ffd76a, #ff7a2e 70%);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  box-shadow:
    0 0 20px rgba(255, 140, 50, 0.6),
    0 6px 16px rgba(0, 0, 0, 0.4);
  animation: laser-ready 0.9s ease-in-out infinite;
}

.laser-button:active {
  transform: scale(0.92);
}

/* ---------- Экраны: старт, пауза, конец игры ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.panel {
  width: min(430px, 100%);
  text-align: center;
  padding: clamp(18px, 3vw, 28px) clamp(16px, 3vw, 26px);
  border-radius: 22px;
  background: rgba(9, 14, 34, 0.85);
  border: 1px solid rgba(140, 190, 255, 0.3);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(60, 120, 255, 0.12);
}

.panel h2 {
  margin-bottom: 12px;
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f4fbff;
  text-shadow: 0 0 14px rgba(90, 180, 255, 0.6);
}

.panel p {
  margin: 8px 0;
  font-size: clamp(0.92rem, 2vw, 1.02rem);
  line-height: 1.5;
  color: #c9d8f2;
}

.key {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  border: 1px solid rgba(140, 190, 255, 0.45);
  background: rgba(40, 70, 140, 0.35);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.9em;
}

.best-line {
  color: #ffd166;
  font-weight: 700;
}

.final-score {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 800;
  color: #ffd166;
  text-shadow: 0 0 18px rgba(255, 190, 80, 0.4);
}

.hint {
  margin-top: 14px;
  color: #8fa8d8;
  font-size: 0.9rem;
  animation: hint-pulse 1.6s ease-in-out infinite;
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.panel button {
  margin-top: 14px;
  padding: 12px 30px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  pointer-events: auto;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: #06122b;
  background: linear-gradient(180deg, #ffd76a, #ffb238);
  box-shadow:
    0 6px 0 #b97b17,
    0 12px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}

.panel button:hover {
  filter: brightness(1.06);
}

.panel button:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #b97b17,
    0 8px 18px rgba(0, 0, 0, 0.35);
}

.panel button.secondary {
  background: rgba(40, 70, 140, 0.35);
  color: #e8f1ff;
  border: 1px solid rgba(140, 190, 255, 0.5);
  box-shadow: none;
  margin-top: 10px;
  padding: 9px 20px;
}

/* ---------- Главное меню ---------- */

.menu-title {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  margin-bottom: 16px;
}

.menu-button {
  display: block;
  width: min(240px, 72%);
  margin: 10px auto 0;
  letter-spacing: 0.06em;
}

.menu-view.hidden {
  display: none;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
  color: #c9d8f2;
}

.setting-row input[type="range"] {
  pointer-events: auto;
  width: 130px;
  accent-color: #ffb238;
}

.setting-row input[type="range"]:disabled {
  opacity: 0.4;
}

.toggle-button {
  min-width: 86px;
}

.toggle-button.off {
  background: rgba(90, 40, 40, 0.6);
  color: #ffb9b9;
  box-shadow: 0 4px 0 #5a2424;
}

.volume-value {
  min-width: 44px;
  text-align: right;
  color: #ffd166;
  font-weight: 700;
}

.menu-hint {
  margin-top: 12px;
  color: #8fa8d8;
  font-size: 0.85rem;
}

/* ---------- Магазин улучшений ---------- */

.upgrades-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 44vh;
  overflow-y: auto;
  pointer-events: auto;
  margin: 10px 0 4px;
  padding-right: 4px;
}

.upgrade-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(20, 30, 60, 0.6);
  border: 1px solid rgba(140, 190, 255, 0.25);
  text-align: left;
}

.upgrade-name {
  font-weight: 700;
  color: #ffffff;
  font-size: 0.95rem;
}

.upgrade-pips {
  color: #ffd166;
  letter-spacing: 2px;
  font-size: 0.85rem;
}

.upgrade-desc {
  color: #9db4dd;
  font-size: 0.8rem;
  margin-top: 2px;
}

.upgrade-buy {
  margin: 0;
  padding: 8px 10px;
  font-size: 0.9rem;
  min-width: 92px;
  flex: 0 0 auto;
}

.upgrade-buy:disabled {
  filter: grayscale(0.7) brightness(0.75);
  cursor: default;
  transform: none;
}

.hidden {
  display: none !important;
}
