.beer-tap {
  --beer-level: 0%;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  color: #403126;
  font-family: system-ui, sans-serif;
}
.beer-tap *, .beer-tap *::before, .beer-tap *::after { box-sizing: border-box; }
.beer-tap__scene {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.12;
  overflow: hidden;
  border-radius: 18px;
  background: radial-gradient(circle at 50% 35%, #fff9e9, #f3dfbb);
}
.beer-tap button { appearance: none; border: 0; padding: 0; background: none; cursor: pointer; touch-action: manipulation; }
.beer-tap button:focus-visible { outline: 3px solid #513e2a; outline-offset: 3px; }
.beer-tap__tap { position: absolute; z-index: 4; left: 33%; top: 2%; width: 34%; height: 36%; }
.beer-tap__handle { position: absolute; left: 41%; top: 0; width: 18%; height: 59%; border: 3px solid #553528; border-radius: 45% 45% 20% 20%; background: linear-gradient(90deg, #694132, #bd8256 55%, #684032); transform-origin: bottom; transition: transform .2s; }
.is-flowing .beer-tap__handle { transform: rotate(-20deg); }
.beer-tap__pipe { position: absolute; left: 4%; right: 4%; top: 55%; height: 21%; border: 3px solid #6c7977; border-radius: 20px; background: linear-gradient(#f8ffff, #a8b8b5 55%, #71817f); }
.beer-tap__spout { position: absolute; left: 39%; top: 70%; width: 22%; height: 22%; border: 3px solid #6c7977; border-radius: 0 0 7px 7px; background: #b8c9c6; }
.beer-tap__stream { display: none; position: absolute; z-index: 2; left: 48.5%; top: 34%; width: 3%; height: 30%; border-radius: 8px; background: #e8a324; }
.is-flowing .beer-tap__stream { display: block; }
.beer-tap__mug { position: absolute; z-index: 3; left: 25%; top: 55%; width: 54%; height: 35%; }
.beer-tap__glass { position: absolute; z-index: 2; left: 0; top: 0; width: 78%; height: 100%; overflow: hidden; border: 5px solid #819795; border-top: 4px solid #819795; border-radius: 5px 5px 19% 19%; background: rgba(255,255,255,.45); box-shadow: inset 6px 0 rgba(255,255,255,.55); }
.beer-tap__liquid { position: absolute; bottom: 0; left: 0; width: 100%; height: var(--beer-level); background: linear-gradient(90deg, #d78a0d, #f8bf43 50%, #d88a0d); }
.beer-tap__foam { display: none; position: absolute; left: 0; right: 0; top: 0; height: min(22%, 18px); min-height: 6px; background: #fff7df; border-radius: 45% 45% 5px 5px; }
.has-beer .beer-tap__foam { display: block; }
.beer-tap__mug-handle { position: absolute; left: 72%; top: 15%; width: 27%; height: 58%; border: 6px solid #819795; border-left: 0; border-radius: 0 40% 40% 0; }
.beer-tap__spill { display: none; position: absolute; z-index: 5; top: 55%; width: 5%; height: 30%; border-radius: 8px; background: linear-gradient(#fff7df 0 12%, #e7a229 13% 65%, transparent 100%); animation: beer-tap-drip 1s linear infinite; pointer-events: none; }
.beer-tap__spill--left { left: 25%; }
.beer-tap__spill--right { left: 64%; animation-delay: -.5s; }
.is-full.is-flowing .beer-tap__spill { display: block; }
.beer-tap__counter { position: absolute; bottom: 8%; left: 8%; right: 8%; height: 3%; border-radius: 4px; background: #a56a40; }
.beer-tap__hint { margin: .6em 0 0; text-align: center; font-size: .85rem; line-height: 1.4; }
@keyframes beer-tap-drip { from { transform: translateY(-5%); opacity: .9; } to { transform: translateY(15%); opacity: .3; } }
/* Moving highlights and bubbles bring the pour to life without extra markup. */
.beer-tap__stream {
  height: var(--stream-height, 56%);
  transform-origin: top;
  background: repeating-linear-gradient(165deg, #ffd372 0 5px, #e8a324 6px 14px, #c77c0c 15px 18px);
  background-size: 100% 28px;
  box-shadow: 0 0 5px rgba(205, 128, 17, .35);
}
.is-flowing .beer-tap__stream { animation: beer-tap-pour .4s linear infinite; }
.beer-tap__liquid::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: .7;
  background-image: radial-gradient(circle, rgba(255, 244, 181, .9) 0 2px, transparent 3px), radial-gradient(circle, rgba(255, 245, 196, .7) 0 1px, transparent 2px);
  background-size: 29px 42px, 19px 31px;
  animation: beer-tap-bubbles 2.2s linear infinite;
  animation-play-state: paused;
}
.is-flowing .beer-tap__liquid::before { animation-play-state: running; }
.beer-tap__foam {
  background: radial-gradient(circle at 12% 30%, #fffdf2 0 5px, transparent 6px), radial-gradient(circle at 35% 20%, #fffdf2 0 7px, transparent 8px), radial-gradient(circle at 65% 20%, #fffdf2 0 6px, transparent 7px), radial-gradient(circle at 88% 30%, #fffdf2 0 5px, transparent 6px), #f8eac9;
  box-shadow: 0 2px 4px rgba(143, 91, 25, .2);
}
.is-flowing .beer-tap__foam { animation: beer-tap-foam 1.1s ease-in-out infinite alternate; }
.beer-tap__spill { animation: beer-tap-drip .85s ease-in infinite; }
.beer-tap__spill--right { animation-delay: -.42s; }
@keyframes beer-tap-pour { to { background-position: 0 28px; } }
@keyframes beer-tap-bubbles { to { background-position: 0 -42px, 0 -62px; } }
@keyframes beer-tap-foam { from { border-radius: 45% 35% 5px 5px; } to { border-radius: 35% 45% 5px 5px; } }
@media (prefers-reduced-motion: reduce) {
  .beer-tap__spill, .is-flowing .beer-tap__stream, .beer-tap__liquid::before, .is-flowing .beer-tap__foam { animation: none; }
  .beer-tap__handle { transition: none; }
}
