:root { --pipes-glow: #85ead8; }
.pipes-board {
  display: grid;
  width: min(100%, 570px);
  grid-template-columns: repeat(var(--pipe-columns), minmax(0, 1fr));
  gap: clamp(3px, 1vw, 7px);
  margin-inline: auto;
}
.pipe-tile {
  position: relative;
  display: grid;
  min-width: 0;
  aspect-ratio: 1;
  place-items: center;
  padding: 2px;
  overflow: hidden;
  border: 1px solid rgba(132, 163, 184, 0.22);
  border-radius: clamp(8px, 2.2vw, 14px);
  background: linear-gradient(145deg, rgba(35, 45, 64, 0.92), rgba(17, 26, 41, 0.96));
  color: #91a9bd;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 150ms ease;
}
.pipe-tile:hover { transform: translateY(-1px); border-color: rgba(197, 218, 236, 0.5); }
.pipe-tile.is-connected {
  border-color: rgba(133, 234, 216, 0.68);
  background: linear-gradient(145deg, rgba(35, 98, 95, 0.7), rgba(21, 51, 62, 0.96));
  color: var(--pipes-glow);
  box-shadow: inset 0 0 16px rgba(133, 234, 216, 0.08), 0 0 12px rgba(133, 234, 216, 0.1);
}
.pipe-tile[data-endpoint="source"] { border-color: rgba(120, 184, 255, 0.75); }
.pipe-tile[data-endpoint="garden"] { border-color: rgba(244, 211, 123, 0.8); }
.pipe-art {
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(var(--turn));
  transform-origin: center;
  transition: transform 220ms cubic-bezier(.2,.75,.3,1);
}
.pipe-art path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 18;
}
.pipe-art circle {
  fill: currentColor;
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 2;
}
.pipe-endpoint {
  position: absolute;
  z-index: 1;
  top: 2px;
  right: 2px;
  padding: 0.08rem 0.24rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: rgba(8, 15, 25, 0.88);
  color: inherit;
  font-size: clamp(0.46rem, 1.8vw, 0.65rem);
  font-weight: 900;
  line-height: 1.25;
  letter-spacing: 0.02em;
}
.pipes-progress {
  margin: 0;
  color: var(--quick-muted);
  font-size: 0.92rem;
  font-weight: 800;
  text-align: center;
}
.pipes-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.55rem 1.2rem; color: var(--quick-muted); font-size: 0.88rem; }
.pipes-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.pipes-key { display: inline-block; width: 0.72rem; height: 0.72rem; border-radius: 50%; background: #91a9bd; }
.pipes-key.is-connected { background: var(--pipes-glow); }
.pipes-key.is-source { background: #78b8ff; }
.pipes-key.is-garden { background: var(--quick-gold); }
@keyframes pipe-celebrate {
  50% { box-shadow: 0 0 24px rgba(133, 234, 216, 0.24); }
}
#status[data-state="won"] { animation: pipe-celebrate 620ms ease both; }
@media (max-width: 360px) {
  .game-panel { padding: 0.65rem; }
  .pipes-board { gap: 1px; }
}
