:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  display: flex;
  justify-content: center;
  padding: 18px;
  background: radial-gradient(circle at top, #1a2747 0%, #0a1224 64%);
  color: #e8ecff;
  font-family: "Inter", "Segoe UI", sans-serif;
}

.swarm {
  width: min(920px, 100%);
  background: rgba(9, 14, 30, 0.86);
  border: 1px solid rgba(133, 157, 255, 0.35);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 18px 42px rgba(1, 3, 10, 0.55);
}

.swarm__header h1 {
  margin: 0;
  font-size: clamp(1.3rem, 3.6vw, 1.9rem);
}

.swarm__header p {
  margin: 8px 0 0;
  color: #b8c4ff;
}

.swarm__stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin: 14px 0 0;
}

.swarm__stats p {
  margin: 0;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(38, 58, 120, 0.28);
  border: 1px solid rgba(133, 157, 255, 0.34);
}

.swarm__controls {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swarm__controls li {
  font-size: 0.86rem;
  color: #d2ddff;
  border-radius: 999px;
  border: 1px solid rgba(133, 157, 255, 0.34);
  background: rgba(25, 37, 80, 0.36);
  padding: 5px 10px;
}

.swarm__stage {
  margin-top: 14px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(133, 157, 255, 0.34);
}

.swarm__stage canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  background: linear-gradient(180deg, #0b1123 0%, #111a34 100%);
  cursor: crosshair;
}

.swarm__status {
  margin: 12px 0 0;
  min-height: 1.6em;
  color: #dce4ff;
}

.swarm__touch {
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.swarm__stick {
  position: relative;
  width: 108px;
  height: 108px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid rgba(133, 157, 255, 0.38);
  background: radial-gradient(circle at 50% 42%, rgba(58, 78, 140, 0.55), rgba(12, 18, 40, 0.72));
  box-shadow: inset 0 0 0 10px rgba(8, 12, 28, 0.28);
}

.swarm__stick.is-active {
  border-color: rgba(120, 231, 255, 0.7);
}

.swarm__stick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border-radius: 50%;
  border: 1px solid rgba(230, 244, 255, 0.55);
  background: radial-gradient(circle at 35% 30%, #8cefff, #2494ff);
  box-shadow: 0 6px 14px rgba(12, 40, 90, 0.45);
  pointer-events: none;
}

.swarm__restart,
.swarm__fire {
  font: inherit;
  color: #eaf1ff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.swarm__restart {
  display: none;
  border: 1px solid rgba(133, 157, 255, 0.4);
  border-radius: 10px;
  padding: 7px 10px;
  background: rgba(25, 37, 80, 0.72);
  font-size: 0.86rem;
  font-weight: 700;
}

.swarm__fire {
  width: 74px;
  height: 74px;
  border: 1px solid rgba(255, 196, 120, 0.55);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd98a, #ff8a3d);
  color: #2a1606;
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(120, 48, 8, 0.35);
}

.swarm__fire.is-pressed {
  transform: translateY(1px) scale(0.96);
  filter: brightness(1.08);
}

.swarm__restart:focus-visible,
.swarm__fire:focus-visible {
  outline: 3px solid rgba(120, 231, 255, 0.45);
  outline-offset: 2px;
}

@media (max-width: 720px), (pointer: coarse) {
  .swarm__touch {
    display: flex;
  }

  .swarm__restart {
    display: inline-flex;
  }

  .swarm__stats {
    gap: 8px;
  }

  .swarm__stats p {
    padding: 6px 8px;
    font-size: 0.82rem;
  }

  .swarm__controls {
    display: none;
  }

  .swarm__stage canvas {
    touch-action: none;
  }
}

@media (max-width: 640px) {
  body {
    padding: 10px;
  }

  .swarm {
    padding: 12px;
  }

  .swarm__header p {
    font-size: 0.92rem;
  }

  .swarm__status {
    font-size: 0.88rem;
  }
}
