/* ── Tank wrapper ────────────────────────────────────────────── */
.tank-wrap {
  position: relative;
  width: min(96vw, 500px);
  background: rgba(0, 0, 0, 0.30);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 2px 14px rgba(0,0,0,0.45), 0 6px 24px rgba(0,0,0,0.30);
}

/* ── Rising water ────────────────────────────────────────────── */
.water-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 0%;
  background: linear-gradient(to top,
    rgba(3, 169, 244, 0.55),
    rgba(100, 220, 255, 0.18));
  pointer-events: none;
  z-index: 1;
  border-radius: 0 0 12px 12px;
}

.water-fill.danger {
  background: linear-gradient(to top,
    rgba(244, 67, 54, 0.58),
    rgba(255, 130, 110, 0.18));
}

.water-fill::after {
  content: '';
  position: absolute;
  top: -5px; left: -5%; right: -5%;
  height: 10px;
  background: rgba(100, 220, 255, 0.60);
  border-radius: 50%;
  animation: tbWave 2.5s ease-in-out infinite;
}

.water-fill.danger::after {
  background: rgba(255, 130, 110, 0.65);
}

@keyframes tbWave {
  0%, 100% { transform: scaleX(1) translateY(0); }
  50%       { transform: scaleX(1.05) translateY(-2px); }
}

/* ── Pipe grid ───────────────────────────────────────────────── */
.pipe-grid {
  display: grid;
  gap: 3px;
  padding: 10px;
  position: relative;
  z-index: 2;
}

/* ── Pipe cell ───────────────────────────────────────────────── */
.pipe-cell {
  aspect-ratio: 1;
  cursor: pointer;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
  transition: background 0.12s, transform 0.08s;
}

.pipe-cell:hover  { background: rgba(255,255,255,0.14); }
.pipe-cell:active { transform: scale(0.85); }

/* ── Pipe SVG ────────────────────────────────────────────────── */
.psv {
  width: 100%;
  height: 100%;
  display: block;
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.15s ease;
}

/* Unconnected pipe colors */
.ps { fill: #607D8B; }
.pc { fill: #78909C; }

/* Connected (water flowing) */
.pipe-cell.connected .ps { fill: #29B6F6; }
.pipe-cell.connected .pc { fill: #4FC3F7; }

/* Source cell — always green */
.pipe-cell.is-source .ps { fill: #66BB6A; }
.pipe-cell.is-source .pc { fill: #81C784; }
.pipe-cell.is-source.connected .ps { fill: #29B6F6; }
.pipe-cell.is-source.connected .pc { fill: #4FC3F7; }

/* Sink cell */
.pipe-cell.is-sink .ps { fill: #90A4AE; }
.pipe-cell.is-sink .pc { fill: #B0BEC5; }
.pipe-cell.is-sink.connected .ps { fill: #26C6DA; }
.pipe-cell.is-sink.connected .pc { fill: #4DD0E1; }
.pipe-cell.is-sink.connected {
  box-shadow: 0 0 16px 5px rgba(41, 182, 246, 0.70);
}

/* ── Port indicators (entry / exit) ─────────────────────────── */
.pipe-cell.is-source::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 36px;
  background: #66BB6A;
  border-radius: 0 7px 7px 0;
  box-shadow: 0 0 14px rgba(102, 187, 106, 0.9), 3px 0 8px rgba(102, 187, 106, 0.5);
  z-index: 3;
  animation: portPulse 1.8s ease-in-out infinite;
}

.pipe-cell.is-source.connected::before {
  background: #29B6F6;
  box-shadow: 0 0 14px rgba(41, 182, 246, 0.9), 3px 0 8px rgba(41, 182, 246, 0.5);
  animation: none;
}

.pipe-cell.is-sink::after {
  content: '';
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 36px;
  background: #607D8B;
  border-radius: 7px 0 0 7px;
  box-shadow: 0 0 8px rgba(96, 125, 139, 0.7);
  z-index: 3;
  transition: background 0.35s, box-shadow 0.35s;
}

.pipe-cell.is-sink.connected::after {
  background: #26C6DA;
  box-shadow: 0 0 16px rgba(38, 198, 218, 0.95), -3px 0 10px rgba(38, 198, 218, 0.5);
}

@keyframes portPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Hint text ───────────────────────────────────────────────── */
.hint-text {
  font-size: 0.88rem;
  opacity: 0.55;
  margin-top: 0.8rem;
  text-align: center;
  transition: opacity 0.4s;
}
.hint-text.hidden-hint { opacity: 0; }

/* ── Lose overlay ────────────────────────────────────────────── */
.game-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 2, 28, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.overlay-box {
  background: rgba(22, 12, 65, 0.97);
  border-radius: 24px;
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: 0 8px 48px rgba(0,0,0,0.5);
  max-width: 340px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  animation: pop-in 0.35s cubic-bezier(0.34,1.56,0.64,1) both;
}

.ol-icon { font-size: 4rem; line-height: 1.1; }
.overlay-box h2 { font-size: 1.7rem; font-weight: 900; }
.overlay-box p  { font-size: 0.95rem; opacity: 0.80; line-height: 1.4; }

.ol-btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: 1rem;
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 48px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  transition: transform 0.10s;
}
.ol-btn:active { transform: scale(0.95); }

.ol-btn-next {
  background: var(--c-tuberias, #14B8A6);
  color: #fff;
  font-size: 1.1rem;
}
.ol-btn-menu {
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 0.9rem;
}
