/* ==================== Переменные ==================== */
:root {
  --bg: #0a0a15;
  --bg-2: #12122a;
  --card: rgba(30, 30, 60, 0.55);
  --card-solid: #1a1a35;
  --border: rgba(140, 120, 255, 0.25);
  --text: #f0f0ff;
  --text-dim: #9a9ac0;
  --neon-pink: #ff2fb9;
  --neon-cyan: #00e5ff;
  --neon-purple: #8b5cf6;
  --neon-yellow: #ffd93d;
  --danger: #ff4d6d;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-neon: 0 0 20px rgba(139, 92, 246, 0.45);
  --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.5);
  --font-title: 'Orbitron', sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
}

/* ==================== Базовое ==================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ==================== Неоновый фон ==================== */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}
.bg-glow--1 {
  width: 500px; height: 500px;
  background: var(--neon-purple);
  top: -150px; left: -150px;
  animation: float1 12s ease-in-out infinite;
}
.bg-glow--2 {
  width: 450px; height: 450px;
  background: var(--neon-cyan);
  bottom: -150px; right: -150px;
  opacity: 0.3;
  animation: float2 14s ease-in-out infinite;
}
@keyframes float1 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(60px, 40px); }
}
@keyframes float2 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-50px, -30px); }
}

/* ==================== Шапка ==================== */
.header {
  flex: 0 0 auto;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(10, 10, 21, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.logo__bomb {
  font-size: 1.6rem;
  filter: drop-shadow(0 0 8px var(--neon-pink));
  animation: pulseBomb 2s ease-in-out infinite;
}
@keyframes pulseBomb {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
.logo__text {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.coins, .stars {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-weight: 800;
  font-size: 0.9rem;
}
.coins__icon, .stars__icon { font-size: 1rem; }
.coins__value { color: var(--neon-yellow); }
.stars__value { color: var(--neon-yellow); }

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { transform: scale(0.9); }
.icon-btn:hover { background: rgba(140, 120, 255, 0.2); }
.icon-btn.hidden { display: none; }

/* ==================== Основное ==================== */
.app {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.app:has(.screen--game:not(.hidden)) {
  max-width: none;
  padding: 0;
}

.screen {
  animation: fadeUp 0.35s ease;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.screen.hidden { display: none; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== Главное меню ==================== */
.screen--menu {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 24px;
  padding: 20px;
  overflow-y: auto;
}

.hero { text-align: center; }

.hero__bomb {
  font-size: 5rem;
  margin-bottom: 12px;
  display: inline-block;
  filter: drop-shadow(0 0 24px var(--neon-pink));
  animation: heroFloat 3s ease-in-out infinite;
}
@keyframes heroFloat {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-10px) rotate(4deg); }
}

.hero__title {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: clamp(2rem, 8vw, 3.4rem);
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, var(--neon-cyan) 0%, var(--neon-purple) 50%, var(--neon-pink) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.6));
  margin-bottom: 8px;
}

.hero__sub {
  color: var(--text-dim);
  font-size: 1rem;
  max-width: 420px;
  margin: 0 auto 28px;
  line-height: 1.5;
}

.hero__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 320px;
  margin: 0 auto;
}

/* ==================== Кнопки ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 15px 26px;
  border-radius: var(--radius);
  border: none;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s, background 0.2s;
  user-select: none;
}

.btn--primary {
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink));
  color: #fff;
  box-shadow: 0 0 24px rgba(255, 47, 185, 0.55), 0 6px 20px rgba(0,0,0,0.4);
}
.btn--primary:hover {
  box-shadow: 0 0 32px rgba(255, 47, 185, 0.8), 0 8px 26px rgba(0,0,0,0.5);
}
.btn--primary:active { transform: scale(0.96); }

.btn--ghost {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--ghost:hover { background: rgba(140, 120, 255, 0.18); }
.btn--ghost:active { transform: scale(0.96); }

.btn--sm {
  padding: 10px 18px;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
}

/* ==================== Экран кампании ==================== */
.screen--campaign {
  padding: 0;
  overflow: hidden;
}

.campaign-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(10, 10, 21, 0.5);
  border-bottom: 1px solid var(--border);
}
.campaign-header__title {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  color: var(--neon-cyan);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
}
.campaign-header__spacer { width: 90px; }

.campaign-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* --------- Глава --------- */
.chapter {
  animation: fadeUp 0.4s ease;
}

.chapter__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid color-mix(in srgb, var(--chapter-color, #fff) 40%, transparent);
}

.chapter__title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chapter__icon {
  font-size: 2rem;
  filter: drop-shadow(0 0 8px var(--chapter-color, #fff));
}
.chapter__num {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.chapter__name {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--chapter-color, #fff);
  text-shadow: 0 0 12px var(--chapter-color, #fff);
}

.chapter__stars {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--neon-yellow);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.chapter__star-icon { font-size: 1rem; }

.chapter--locked { opacity: 0.6; }

/* --------- Сетка уровней --------- */
.levels-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* --------- Карточка уровня --------- */
.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  min-height: 130px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
  overflow: hidden;
}

/* Пройден */
.level-card--completed {
  border-color: rgba(0, 217, 163, 0.6);
  background: linear-gradient(180deg, rgba(0, 217, 163, 0.08), var(--card));
}
.level-card--completed:hover {
  box-shadow: 0 0 20px rgba(0, 217, 163, 0.4);
  transform: translateY(-3px);
}

/* Доступен (открыт, но не пройден) */
.level-card--available {
  border-color: rgba(0, 229, 255, 0.6);
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.08), var(--card));
  animation: pulseAvailable 2.5s ease-in-out infinite;
}
.level-card--available:hover {
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.5);
  transform: translateY(-3px);
}
@keyframes pulseAvailable {
  0%, 100% { box-shadow: 0 0 12px rgba(0, 229, 255, 0.2); }
  50% { box-shadow: 0 0 20px rgba(0, 229, 255, 0.45); }
}

/* Закрыт */
.level-card--locked {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: rgba(100, 100, 130, 0.3);
  filter: grayscale(0.7);
}
.level-card--locked:hover { transform: none; box-shadow: none; }

/* Босс */
.level-card--boss {
  border-width: 3px;
  border-color: rgba(255, 47, 185, 0.7);
  background: linear-gradient(180deg, rgba(255, 47, 185, 0.10), var(--card));
}
.level-card--boss.level-card--completed {
  border-color: rgba(0, 217, 163, 0.7);
}

.level-card__number {
  position: absolute;
  top: 6px;
  left: 8px;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.level-card__boss-icon {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 1.1rem;
  filter: drop-shadow(0 0 4px var(--neon-pink));
}

.level-card__name {
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  margin-top: 8px;
  line-height: 1.2;
  color: var(--text);
}

.level-card__stars {
  display: flex;
  gap: 3px;
  margin-top: 6px;
}
.level-card__star {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.2);
  transition: color 0.2s, transform 0.2s;
}
.level-card__star.is-filled {
  color: var(--neon-yellow);
  filter: drop-shadow(0 0 6px rgba(255, 217, 61, 0.8));
}

.level-card__play {
  font-size: 1.8rem;
  color: var(--neon-cyan);
  filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.7));
  margin-top: 4px;
}

.level-card__lock {
  font-size: 1.6rem;
  opacity: 0.5;
  margin-top: 4px;
}

/* ==================== Рекорд (если используется) ==================== */
.best-box {
  text-align: center;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 280px;
  margin: 0 auto;
  backdrop-filter: blur(10px);
}
.best-box__label {
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.best-box__value {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 2rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 16px rgba(0, 229, 255, 0.7);
}

/* ==================== Экран игры ==================== */
.screen--game {
  gap: 0;
  margin: -20px;
  padding: 0;
  width: auto;
  height: auto;
}

.game-stage {
  flex: 1 1 auto;
  min-height: 0;
  background: #0a0a15;
  overflow: hidden;
  position: relative;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.game-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ==================== Футер ==================== */
.footer {
  flex: 0 0 auto;
  text-align: center;
  padding: 10px;
  color: var(--text-dim);
  font-size: 0.78rem;
  position: relative;
  z-index: 1;
}

/* ==================== Мобилки ==================== */
@media (max-width: 480px) {
  .header { padding: 10px 12px; gap: 8px; }
  .logo { gap: 6px; }
  .logo__bomb { font-size: 1.3rem; }
  .logo__text { font-size: 0.95rem; }
  .header__right { gap: 6px; }
  .coins, .stars { padding: 6px 10px; font-size: 0.8rem; }
  .icon-btn { width: 38px; height: 38px; font-size: 1rem; }

  .app { padding: 12px; }
  .hero__bomb { font-size: 3.5rem; margin-bottom: 6px; }
  .hero__sub { font-size: 0.9rem; margin-bottom: 20px; }
  .btn { padding: 13px 22px; font-size: 0.98rem; }
  .footer { font-size: 0.7rem; padding: 8px; }

  .campaign-content { padding: 14px; gap: 24px; }
  .levels-grid { gap: 8px; }
  .level-card { padding: 10px 6px; min-height: 110px; }
  .level-card__name { font-size: 0.8rem; }
  .level-card__star { font-size: 0.95rem; }
  .chapter__icon { font-size: 1.6rem; }
  .chapter__name { font-size: 0.95rem; }

  .screen--game { margin: -12px; }
}

@media (max-height: 560px) {
  .hero__bomb { font-size: 2.6rem; margin-bottom: 4px; }
  .hero__sub { display: none; }
  .footer { padding: 6px; }
}