:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: rgba(247, 251, 255, 0.68);
  --panel: rgba(9, 17, 25, 0.74);
  --line: rgba(255, 255, 255, 0.16);
  --pink: #ff4f9f;
  --cyan: #2be7ff;
  --gold: #ffd35a;
  --green: #5dff9b;
  --violet: #a57cff;
  --danger: #ff6464;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #071016;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 520px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(43, 231, 255, 0.18), transparent 28%),
    radial-gradient(circle at 82% 22%, rgba(255, 211, 90, 0.15), transparent 26%),
    radial-gradient(circle at 78% 82%, rgba(255, 79, 159, 0.16), transparent 29%),
    linear-gradient(140deg, #071016 0%, #101724 46%, #071d1b 100%);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
}

.hud,
.top-actions,
.energy,
.target-strip,
.hint,
.toast,
.panel {
  position: absolute;
  z-index: 2;
}

.hud {
  left: max(16px, env(safe-area-inset-left));
  top: max(14px, env(safe-area-inset-top));
  display: grid;
  grid-template-columns: repeat(3, minmax(70px, 1fr));
  gap: 8px;
  width: min(390px, calc(100vw - 112px));
}

.stat {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 8, 12, 0.42);
  backdrop-filter: blur(14px);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(1.05rem, 2.4vw, 1.55rem);
  line-height: 1;
}

.top-actions {
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 8, 12, 0.42);
  color: var(--ink);
  cursor: pointer;
  backdrop-filter: blur(14px);
}

.icon-btn:focus-visible,
.mode-btn:focus-visible,
.primary-btn:focus-visible {
  outline: 3px solid rgba(43, 231, 255, 0.72);
  outline-offset: 3px;
}

.energy {
  left: 50%;
  bottom: max(74px, calc(env(safe-area-inset-bottom) + 68px));
  display: flex;
  gap: 9px;
  transform: translateX(-50%);
}

.energy span {
  width: 26px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 18px rgba(93, 255, 155, 0.7);
  transition: opacity 160ms ease, transform 160ms ease, background 160ms ease;
}

.energy span.is-empty {
  opacity: 0.28;
  transform: scaleX(0.72);
  background: rgba(255, 255, 255, 0.36);
  box-shadow: none;
}

.target-strip {
  left: 50%;
  top: max(78px, calc(env(safe-area-inset-top) + 76px));
  display: inline-grid;
  grid-template-columns: 18px auto auto;
  align-items: center;
  gap: 8px;
  min-width: 148px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(3, 8, 12, 0.38);
  box-shadow: inset 0 0 28px rgba(255, 255, 255, 0.05), 0 18px 50px rgba(0, 0, 0, 0.22);
  transform: translateX(-50%);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

.target-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 18px var(--pink);
}

.target-label {
  color: rgba(247, 251, 255, 0.62);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.target-strip strong {
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1;
}

.hint {
  left: 50%;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 18px));
  margin: 0;
  color: rgba(247, 251, 255, 0.6);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  transform: translateX(-50%);
  user-select: none;
}

.toast {
  left: 50%;
  top: 22%;
  min-width: 120px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(2, 8, 12, 0.56);
  color: var(--ink);
  font-weight: 900;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.panel {
  width: min(430px, calc(100vw - 32px));
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px);
}

.panel-center {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.is-hidden {
  display: none;
}

.kicker {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-size: clamp(3rem, 12vw, 5.8rem);
  line-height: 0.9;
}

#gameOverPanel h2,
#pausePanel h2 {
  font-size: clamp(2.5rem, 10vw, 4.7rem);
}

.lead {
  margin: 14px 0 20px;
  color: var(--muted);
  font-size: clamp(0.98rem, 2.8vw, 1.08rem);
  line-height: 1.45;
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.mode-btn,
.primary-btn {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.mode-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
}

.mode-btn.is-active {
  border-color: rgba(43, 231, 255, 0.64);
  background: rgba(43, 231, 255, 0.18);
}

.primary-btn {
  width: 100%;
  background: linear-gradient(90deg, var(--pink), var(--cyan), var(--gold));
  box-shadow: 0 18px 44px rgba(43, 231, 255, 0.22);
  color: #031014;
}

.primary-btn:active,
.mode-btn:active,
.icon-btn:active {
  transform: translateY(1px);
}

@media (max-width: 580px) {
  .game-shell {
    min-height: 460px;
  }

  .hud {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: calc(100vw - 128px);
  }

  .target-strip {
    top: 76px;
    min-width: 134px;
    padding: 8px 10px;
  }

  .stat {
    padding: 8px 7px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .panel {
    padding: 21px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
