*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Helvetica Neue", Arial, sans-serif;
  background: #05060a;
  color: #f5f5f7;
}

body {
  display: flex;
  justify-content: center;
  padding: 32px 12px;
}

.hidden {
  display: none !important;
}

.game-wrapper {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.game-title-block h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 6px 0 0;
  font-size: 14px;
  opacity: 0.7;
}

.logo-block {
  text-align: right;
}

.brand-mark {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(10px);
}

/* HUD */

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 16px;
  background: radial-gradient(circle at top left, #151726, #05060a);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.hud-left,
.hud-center,
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-left {
  flex: 1;
}

.hud-center {
  flex-direction: column;
  align-items: flex-start;
  min-width: 160px;
}

.wave-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.reward-hint {
  font-size: 10px;
  opacity: 0.7;
}

.hud-score {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  opacity: 0.65;
}

.hud-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 16px;
}

.rep-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(90deg, #1b1c24, #111217);
}

.rep-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #34c759, #0a84ff);
  transition: width 0.2s.ease-out;
}

.rep-percent {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.wave-label {
  font-size: 11px;
  opacity: 0.75;
}

/* Canvas */

.canvas-container {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: radial-gradient(circle at top, #1b1f2e, #05060a 60%);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
}

/* Overlays */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, rgba(10, 10, 20, 0.94), rgba(0, 0, 0, 0.96));
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  z-index: 10;
}

.overlay-content {
  max-width: 520px;
  padding: 24px 28px 26px;
  border-radius: 24px;
  background: rgba(10, 10, 20, 0.98);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.overlay-content h2 {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 600;
}

.overlay-text {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.5;
  opacity: 0.8;
}

.controls {
  margin: 8px 0 18px;
  padding-left: 18px;
  font-size: 13px;
  opacity: 0.85;
}

.controls li + li {
  margin-top: 4px;
}

/* Wave popup */

.wave-popup {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  z-index: 8;
  pointer-events: none;
}

.wave-popup-box {
  min-width: 220px;
  max-width: 320px;
  padding: 16px 20px 14px;
  border-radius: 18px;
  background: rgba(10, 10, 20, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.7);
  text-align: center;
  animation: wavePopupFade 1.6s ease-out;
}

.wave-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.wave-subtitle {
  font-size: 13px;
  opacity: 0.8;
}

@keyframes wavePopupFade {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  20% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  80% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-4px) scale(0.99);
  }
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: #f5f5f7;
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out,
    background 0.12s ease-out, border-color 0.12s ease-out, opacity 0.12s;
}

.btn.primary {
  background: linear-gradient(135deg, #0a84ff, #30d158);
  box-shadow: 0 10px 25px rgba(10, 132, 255, 0.45);
  border-color: rgba(255, 255, 255, 0.06);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

.btn.link {
  background: transparent;
  border-color: transparent;
  opacity: 0.78;
}

.btn + .btn {
  margin-left: 8px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.55);
  opacity: 0.98;
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.footer-note {
  margin-top: 10px;
  font-size: 12px;
  opacity: 0.55;
}

/* Логотип в правом нижнем углу */

.game-logo {
  position: absolute;
  right: 16px;
  bottom: 12px;
  height: 26px;
  width: auto;
  opacity: 0.8;
  pointer-events: none;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
}

/* Мобильные кнопки управления */

.touch-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  padding: 8px 12px;
  display: none; /* по умолчанию скрыто, показываем только на мобилках */
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none; /* включаем события только на кнопках */
}

.touch-btn {
  flex: 1;
  max-width: 120px;
  pointer-events: auto;
  padding: 10px 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(5, 6, 10, 0.78);
  color: #f5f5f7;
  font-size: 20px;
  font-weight: 500;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}

/* Responsive */

@media (max-width: 640px) {
  .game-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .hud {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .hud-left {
    order: 1;
    width: 100%;
  }

  .hud-center,
  .hud-right {
    order: 2;
  }

  .game-logo {
    height: 22px;
    right: 10px;
    bottom: 48px; /* чуть выше, чтобы не пересекаться с кнопками */
  }

  .reward-hint {
    width: 100%;
  }

  .touch-controls {
    display: flex;
  }
}
