/*! Agentchat Mini Game v1.0.1 — canvas frame and touch controls. Extends Mini UI; load mini.css first. */

/* Mini UI already owns `.mini-game`, scoreboards, buttons, spacing, and type.
   This sheet adds only what a canvas game needs: a stable aspect-ratio frame,
   a thumb-reachable control cluster, and reduced-effects behaviour. */

.mini-game-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: var(--mini-game-aspect, 16 / 9);
  max-height: min(70dvh, 620px);
  overflow: hidden;
  border: 1px solid var(--mini-border);
  border-radius: var(--mini-radius);
  background: var(--mini-surface-muted);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

[data-mini-game] {
  width: 100%;
  min-width: 0;
}

[data-mini-game] > *,
.mini-game-hud,
.mini-game-controls,
.mini-scoreboard {
  min-width: 0;
  max-width: 100%;
}

.mini-game-hud > .mini-scoreboard {
  width: 100%;
}

.mini-game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  color: var(--mini-text-muted);
  font-size: var(--mini-text-sm);
}

.mini-game:focus-visible,
.mini-game-stage:focus-visible {
  outline: 2px solid var(--mini-accent);
  outline-offset: 2px;
}

/* Status and score stay real DOM above the canvas so screen readers and the
   design audit can read them. */
.mini-game-hud {
  order: -1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--mini-space-2);
  align-items: center;
  justify-content: space-between;
  min-height: var(--mini-control-height);
}

/* The runtime appends its stage to the end of the root, so the HUD and the
   control cluster declare their own order instead of depending on source
   position. */
.mini-game-controls {
  order: 1;
  display: flex;
  gap: var(--mini-space-2);
  align-items: center;
  justify-content: space-between;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mini-game-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(44px, 1fr));
  grid-template-areas: '. up .' 'left down right';
  gap: var(--mini-space-1);
}

.mini-game-pad > [data-game-action='up'] {
  grid-area: up;
}
.mini-game-pad > [data-game-action='down'] {
  grid-area: down;
}
.mini-game-pad > [data-game-action='left'] {
  grid-area: left;
}
.mini-game-pad > [data-game-action='right'] {
  grid-area: right;
}

.mini-game-cluster {
  display: flex;
  gap: var(--mini-space-2);
  align-items: end;
}

[data-game-action] {
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

[data-game-action]:active {
  background: var(--mini-accent-hover);
  border-color: var(--mini-accent-hover);
}

/* A pointer-capable device does not need the thumb cluster taking up the
   frame; keyboard and mouse still work, and the markup stays in the DOM for
   assistive technology. */
@media (pointer: fine) and (min-width: 721px) {
  .mini-game-controls[data-game-touch-only] {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mini-game-stage {
    scroll-behavior: auto;
  }
  [data-game-action] {
    transition: none;
  }
}

/* Scenes read this to drop decorative particles and flashes; simulation speed
   never changes with it. */
@media (prefers-reduced-transparency: reduce) {
  .mini-game-stage {
    backdrop-filter: none;
  }
}
