:root {
  --bg: #10141f;
  --panel: #171d2d;
  --panel-soft: #20283c;
  --text: #f1f5ff;
  --text-dim: #a7b4d6;
  --accent: #6aa8ff;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top, #1b2440, var(--bg));
  color: var(--text);
  font-family: "Avenir Next", "Helvetica Neue", "Segoe UI", sans-serif;
  touch-action: manipulation;
}

body {
  min-height: 100dvh;
}

.app {
  width: min(520px, 100vw);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(10px + var(--safe-top)) 14px calc(14px + var(--safe-bottom));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.hud-group {
  background: color-mix(in srgb, var(--panel) 92%, white);
  border: 1px solid #303b58;
  border-radius: var(--radius);
  padding: 8px 10px;
}

.hud-label {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 3px;
}

.hud-value {
  font-size: 19px;
  font-weight: 700;
}

.target-group {
  display: flex;
  flex-direction: column;
}

.target-chip {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid #ffffff66;
}

.board-wrap {
  display: grid;
  place-items: center;
  padding: 4px 0;
}

.board {
  width: min(92vw, 480px);
  aspect-ratio: 1 / 1;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid #2f3a57;
  padding: 8px;
  display: grid;
  gap: 4px;
  box-shadow: inset 0 0 0 1px #00000040;
}

.cell {
  border-radius: 7px;
  border: 1px solid #ffffff26;
  cursor: pointer;
  transform: scale(1);
  transition: transform 90ms ease, filter 90ms ease, box-shadow 130ms ease;
}

.cell:active {
  transform: scale(0.95);
}

.cell.changed {
  animation: pop 180ms ease;
}

@keyframes pop {
  0% { transform: scale(0.9); filter: brightness(0.85); }
  70% { transform: scale(1.05); filter: brightness(1.12); }
  100% { transform: scale(1); filter: brightness(1); }
}

.controls {
  display: grid;
  gap: 12px;
}

.palette {
  background: var(--panel-soft);
  border: 1px solid #2f3a57;
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.swatch-btn {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-width: 48px;
  min-height: 48px;
  border-radius: 999px;
  border: 2px solid #ffffff38;
  background: #999;
  cursor: pointer;
}

.swatch-btn.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--accent);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

button {
  appearance: none;
  border: 0;
  color: var(--text);
  border-radius: 12px;
  min-height: 44px;
  font-size: 15px;
  font-weight: 600;
}

.primary-btn {
  background: linear-gradient(180deg, #66a7ff, #4f84ff);
}

.secondary-btn {
  background: #2a3553;
}

.overlay {
  position: fixed;
  inset: 0;
  background: #0a0f1add;
  display: grid;
  place-items: center;
  padding: 16px;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(420px, 100%);
  background: #182138;
  border: 1px solid #344267;
  border-radius: 16px;
  padding: 18px;
}

.overlay-card h1 {
  margin: 0 0 8px;
}

.overlay-card p {
  margin: 0 0 14px;
  color: var(--text-dim);
}
