/* M5.1 GAME FOCUS MODE
   Goal:
   - after a module is active, hide that setup panel
   - during the game, show the playfield first
   - keep sensors active in background
*/

/* Hide START GAMEZONE once controller is active */
body.controller-started #hudMainButton {
  display: none !important;
}

/* Hide module setup panels once activated */
body.motion-armed .motion-panel {
  display: none !important;
}

body.gps-active .gps-panel {
  display: none !important;
}

body.camera-active .camera-panel {
  display: none !important;
}

/* Keep the module strip as compact status while preparing */
body.motion-armed #motionGyroState::after,
body.gps-active #gpsModuleState::after,
body.camera-active #cameraModuleState::after {
  content: " ✓";
}

/* Game panel becomes the main product surface */
.game-panel {
  order: -1;
}

/* During active play: remove dashboard clutter */
body.game-running .hud-v2-hero,
body.game-running .hud-v2-stats,
body.game-running .motion-panel,
body.game-running .gps-panel,
body.game-running .camera-panel,
body.game-running .hud-v2-module-strip,
body.game-running #hudMainButton,
body.game-running .hud-v2-footnote {
  display: none !important;
}

/* After finish: keep result/playfield in focus */
body.game-finished .hud-v2-hero,
body.game-finished .hud-v2-stats,
body.game-finished .motion-panel,
body.game-finished .gps-panel,
body.game-finished .camera-panel,
body.game-finished .hud-v2-module-strip,
body.game-finished #hudMainButton,
body.game-finished .hud-v2-footnote {
  display: none !important;
}

/* Game-running layout feels like a real fullscreen controller game */
body.game-running .hud-v2,
body.game-finished .hud-v2 {
  min-height: calc(100svh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  align-content: start;
}

body.game-running .game-panel,
body.game-finished .game-panel {
  min-height: calc(100svh - 58px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) auto auto auto;
}

body.game-running .game-arena,
body.game-finished .game-arena {
  min-height: min(52svh, 420px);
}

/* Make play button more product-like before start */
#startDemoButton {
  position: relative;
  overflow: hidden;
}

#startDemoButton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.24), transparent);
  transform: translateX(-140%);
  animation: gameButtonSweep 2.2s ease-in-out infinite;
}

/* Once running, no distracting sweep */
body.game-running #startDemoButton::after,
body.game-finished #startDemoButton::after {
  display: none;
}

/* Compact preparation mode */
body.motion-armed.gps-active.camera-active .game-panel {
  border-color: rgba(82, 255, 154, 0.48);
  box-shadow:
    0 0 42px rgba(82, 255, 154, 0.22),
    inset 0 0 32px rgba(0, 255, 213, 0.055);
}

body.motion-armed.gps-active.camera-active #gameStatusPill {
  color: #001412;
  background: linear-gradient(90deg, #52ff9a, #00ffd5);
  box-shadow: 0 0 24px rgba(82, 255, 154, 0.32);
}

body.motion-armed.gps-active.camera-active #gameStatusPill::after {
  content: "";
}

/* Reduce remaining technical module area */
.hud-v2-module-strip {
  order: 50;
}

@keyframes gameButtonSweep {
  0% {
    transform: translateX(-140%);
  }

  55% {
    transform: translateX(140%);
  }

  100% {
    transform: translateX(140%);
  }
}

@media (max-width: 390px), (max-height: 780px) {
  body.game-running .hud-v2,
  body.game-finished .hud-v2 {
    padding: 12px;
    gap: 8px;
  }

  body.game-running .game-panel,
  body.game-finished .game-panel {
    min-height: calc(100svh - 42px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  body.game-running .game-arena,
  body.game-finished .game-arena {
    min-height: min(50svh, 340px);
  }
}
