/* Grid do Tabuleiro de Canos */
.board-gameplay-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 80px;
  position: relative;
  background: var(--grid-bg-texture, radial-gradient(circle at center, #2e1d16 0%, #150d0a 100%));
  overflow: visible;
}

.board-wrapper {
  position: relative;
  display: inline-block;
}

.board-grid-container {
  display: grid;
  position: relative;
  background: rgba(0, 0, 0, 0.6);
  padding: 6px;
  border-radius: var(--radius-md);
  border: 3px solid var(--grid-tile-border, #412a20);
  box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.9), 0 10px 30px rgba(0, 0, 0, 0.5);
  touch-action: manipulation;
  gap: 2px;
}

/* Canvas de renderização da água sobreposto ao grid */
.water-flow-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 12;
}

/* Célula individual do tabuleiro */
.pipe-cell {
  position: relative;
  background: var(--grid-tile-bg, #2b1c16);
  border: 1px solid var(--grid-tile-border, #3a251c);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.7);
  transition: background var(--transition-fast);
  outline: none;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  padding: 0;
}

.pipe-cell:hover:not(.locked) {
  filter: brightness(1.15);
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.1);
}

.pipe-cell:focus-visible {
  outline: 2px solid #00d2ff;
  outline-offset: 2px;
  z-index: 10;
}

/* Rotação do cano dentro da célula */
.pipe-graphic-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: 50% 50%;
}

.pipe-svg-render {
  width: 100%;
  height: 100%;
  display: block;
}

/* Válvula de Entrada (Start) - Fixada rente à esquerda */
.source-valve-fixture {
  position: absolute;
  right: 100%;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: top 0.3s ease;
  margin-right: 0px;
}

.valve-pump-housing {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #3a4b5d 0%, #1a232c 100%);
  border: 3px solid #6b8299;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.3), 0 8px 18px rgba(0, 0, 0, 0.7);
  position: relative;
}

.valve-glow-reservoir {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle, #00ffff 0%, #0077aa 100%);
  box-shadow: 0 0 16px #00d2ff, inset 0 0 8px #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  animation: pumpPulse 2s infinite ease-in-out;
}

.valve-nozzle-right {
  position: absolute;
  right: -10px;
  width: 12px;
  height: 38px;
  background: linear-gradient(180deg, #94a3b8 0%, #475569 100%);
  border-radius: 0 4px 4px 0;
  border: 2px solid #334155;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.5);
}

/* Destino Final (End) - Fixado rente à direita */
.target-destination-fixture {
  position: absolute;
  left: 100%;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: top 0.3s ease;
  margin-left: 0px;
}

.dest-housing {
  width: 64px;
  height: 64px;
  background: var(--dest-housing-bg, linear-gradient(135deg, #573322 0%, #2e1a10 100%));
  border: 3px solid var(--dest-border, #a86c43);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.3), 0 8px 18px rgba(0, 0, 0, 0.7);
  position: relative;
  transition: var(--transition-bounce);
}

.dest-nozzle-left {
  position: absolute;
  left: -10px;
  width: 12px;
  height: 38px;
  background: var(--pipe-metal-gradient, linear-gradient(180deg, #d38f5f 0%, #874921 100%));
  border-radius: 4px 0 0 4px;
  border: 2px solid var(--pipe-metal-border, #522d15);
}

.dest-housing.active-success {
  border-color: #00ffff;
  box-shadow: 0 0 28px #00d2ff, inset 0 0 10px #ffffff;
  transform: scale(1.12);
}

/* Tamanhos de grid padronizados */
.grid-size-3 { width: 340px; height: 340px; }
.grid-size-4 { width: 380px; height: 380px; }
.grid-size-5 { width: 420px; height: 420px; }
.grid-size-6 { width: 450px; height: 450px; }
.grid-size-7 { width: 480px; height: 480px; }

@media (max-width: 768px) {
  .board-gameplay-area {
    padding: 20px 50px;
  }
  .grid-size-3,
  .grid-size-4,
  .grid-size-5,
  .grid-size-6,
  .grid-size-7 {
    width: min(76vw, 360px);
    height: min(76vw, 360px);
  }
  .source-valve-fixture,
  .target-destination-fixture {
    width: 48px;
    height: 48px;
  }
  .valve-pump-housing,
  .dest-housing {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }
  .valve-glow-reservoir {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
  }
  .valve-nozzle-right,
  .dest-nozzle-left {
    height: 26px;
    width: 8px;
  }
}
