/* Maze grid */
.maze-grid {
  display: grid;
  position: relative;
  gap: 1px;
  background: var(--maze-grid-bg);
  border: 2px solid var(--maze-grid-border);
  border-radius: 4px;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
}

/* Cells */
.maze-cell {
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
}

.maze-cell.wall {
  background: var(--maze-wall);
}

.maze-cell.path {
  background: var(--maze-path);
}

.maze-cell.start {
  background: var(--maze-start);
}

.maze-cell.goal {
  background: var(--maze-goal);
  position: relative;
}

.maze-cell.goal::after {
  content: '\2691';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.4em;
  color: var(--maze-goal-flag);
  animation: goalPulse 2s ease-in-out infinite;
}

@keyframes goalPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.2); }
}

.maze-cell.visited {
  background: var(--maze-visited);
}

/* Player */
.maze-player {
  position: absolute;
  width: 0;
  height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: top 300ms ease-in-out, left 300ms ease-in-out;
  z-index: 5;
  pointer-events: none;
}

.player-sprite {
  width: 70%;
  height: 70%;
  position: absolute;
  top: 15%;
  left: 15%;
  transition: transform 200ms ease;
}

/* Player as CSS triangle/arrow */
.player-sprite::before {
  content: '';
  position: absolute;
  top: 10%;
  left: 15%;
  width: 70%;
  height: 80%;
  background: var(--blue);
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  border-radius: 2px;
}

/* Direction rotations */
.maze-player[data-dir="NORTH"] .player-sprite { transform: rotate(0deg); }
.maze-player[data-dir="EAST"] .player-sprite { transform: rotate(90deg); }
.maze-player[data-dir="SOUTH"] .player-sprite { transform: rotate(180deg); }
.maze-player[data-dir="WEST"] .player-sprite { transform: rotate(-90deg); }

/* Collision animation */
@keyframes bump {
  0%, 100% { filter: none; }
  50% { filter: brightness(0.5) sepia(1) hue-rotate(-30deg) saturate(5); }
}

.maze-player.collision {
  animation: bump 0.4s ease;
}

/* Success glow */
@keyframes successGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
  50% { box-shadow: 0 0 20px 6px var(--success-glow); }
}

.maze-player.success .player-sprite::before {
  background: var(--green);
}

.maze-cell.goal.reached {
  animation: successGlow 1s ease-in-out 3;
  background: var(--maze-reached);
}

/* Sonar - verificacao de caminho */
@keyframes sonarPulseOpen {
  0% { box-shadow: inset 0 0 0 0 rgba(0,0,0,0); }
  40% { box-shadow: inset 0 0 12px 4px var(--sonar-open); }
  100% { box-shadow: inset 0 0 0 0 rgba(0,0,0,0); }
}

@keyframes sonarPulseBlocked {
  0% { box-shadow: inset 0 0 0 0 rgba(0,0,0,0); }
  40% { box-shadow: inset 0 0 12px 4px var(--sonar-blocked); }
  100% { box-shadow: inset 0 0 0 0 rgba(0,0,0,0); }
}

.maze-cell.sonar-open {
  animation: sonarPulseOpen 0.4s ease-out;
  z-index: 2;
  position: relative;
}

.maze-cell.sonar-blocked {
  animation: sonarPulseBlocked 0.4s ease-out;
  z-index: 2;
  position: relative;
}
