/* =============================================================
   GAME: Alien Invasion
   ============================================================= */
.board-alieninvasion { display: flex; flex-direction: column; align-items: center; gap: 12px; outline: none; }
.ai-stage { position: relative; touch-action: none; }
.ai-canvas {
  display: block; width: min(calc(100vw - 60px), 420px, calc((100vh - 230px) * .75)); min-width: 240px; aspect-ratio: 3 / 4;
  border-radius: 12px; background: #0a0418;
  box-shadow: 0 0 0 2px #ff6ad5, 0 0 26px rgba(255, 106, 213, .38);
}
.board-alieninvasion:focus-visible .ai-canvas { box-shadow: 0 0 0 3px #fff, 0 0 26px rgba(255, 106, 213, .55); }
.ai-msg {
  position: absolute; left: 50%; top: 56%; transform: translate(-50%, -50%); width: max-content; max-width: 84%;
  padding: 10px 16px; border-radius: 12px; background: rgba(10, 4, 24, .88); color: #ffe6f8; font-weight: 700; text-align: center;
  box-shadow: 0 0 0 1px rgba(255, 106, 213, .6); pointer-events: none;
}
.ai-msg[hidden] { display: none; }
.ai-num { color: #ff9be6; font-variant-numeric: tabular-nums; }
.ai-lives { color: #7dffb0; letter-spacing: 2px; text-shadow: 0 0 8px rgba(125, 255, 176, .6); }

/* on-screen buttons: phones and tablets only */
.ai-pad { display: none; grid-template-columns: 1fr 1.3fr 54px 1fr; gap: 8px; width: min(100%, 380px); touch-action: none; }
.ai-key {
  display: grid; place-items: center; height: 52px; border: 0; border-radius: 14px; cursor: pointer; color: #ff9be6;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px rgba(255, 106, 213, .5), 0 4px 0 rgba(0, 0, 0, .35);
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.ai-key svg { width: 26px; height: 26px; fill: currentColor; }
.ai-key.down { background: #3a1036; transform: translateY(2px); box-shadow: inset 0 0 0 1px #ff6ad5, 0 2px 0 rgba(0, 0, 0, .35); }
.ai-key-fire { color: #7dffb0; box-shadow: inset 0 0 0 1px rgba(125, 255, 176, .5), 0 4px 0 rgba(0, 0, 0, .35); }
.ai-key-pause { color: var(--ink); }
.ai-key-pause svg { width: 20px; height: 20px; }
@media (pointer: coarse) {
  .ai-pad { display: grid; }
  .board-alieninvasion { gap: 8px; }
  .ai-canvas { width: min(calc(100vw - 60px), 420px, calc((100vh - 320px) * .75)); }
}

/* hit: a short shake + red flash of the frame (off when motion is reduced) */
.ai-hit { animation: aiShake .4s cubic-bezier(.36, .07, .19, .97); }
.ai-hit .ai-canvas { box-shadow: 0 0 0 2px #ff4b5c, 0 0 30px rgba(255, 75, 92, .55); transition: box-shadow .3s; }
@keyframes aiShake { 15%, 55% { translate: -5px 0; } 35%, 75% { translate: 5px 0; } 90% { translate: -2px 0; } }
@media (prefers-reduced-motion: reduce) { .ai-hit { animation: none; } }
