* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Trebuchet MS', system-ui, sans-serif;
  background: linear-gradient(180deg, #1d2b53 0%, #3a3f8f 60%, #5b6cb8 100%);
  color: #fff;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  overflow: hidden;
  padding-top: 55px;
}

#game {
  position: relative;
  width: 1100px;
  max-width: 100vw;
  height: calc(100vh - 55px);
  max-height: calc(100vh - 55px);
  display: flex;
  flex-direction: column;
}

/* HUD */
#hud {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  margin: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 14px;
  letter-spacing: 1px;
}
.stat .label {
  text-transform: uppercase;
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 4px;
}
.stat span:not(.label) {
  font-size: 28px;
  font-weight: bold;
  color: #ffe66d;
}
#spills { color: #ff6b6b; }

/* Table */
#table {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  padding: 24px;
  background: linear-gradient(180deg, transparent 0%, transparent 55%, #6b4423 55%, #5a3818 100%);
  border-radius: 12px;
  margin: 0 16px 16px;
  position: relative;
}

.station {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 60px;
}

.dispenser {
  position: absolute;
  top: 10px;
  width: 80px;
  height: 120px;
  background: linear-gradient(180deg, #c0c0c0 0%, #808080 100%);
  border-radius: 12px 12px 8px 8px;
  border: 3px solid #404040;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}
.dispenser::before {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 16px;
  background: #404040;
  border-radius: 0 0 6px 6px;
}
.dispenser img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
}

.stream {
  position: absolute;
  top: 145px;
  width: 14px;
  height: 0;
  background: linear-gradient(180deg, #ff5e8a, #c91d6a);
  border-radius: 0 0 6px 6px;
  opacity: 0;
  transition: opacity 0.05s linear;
  pointer-events: none;
}
.station.dispensing .stream {
  opacity: 1;
  height: 140px;
}
.station.dispensing.cleanup .stream { opacity: 0; height: 0; }

/* Slot color tints */
.station[data-slot="0"] .stream { background: linear-gradient(180deg, #ff5e8a, #c91d6a); }
.station[data-slot="1"] .stream { background: linear-gradient(180deg, #5ec3ff, #1d6ec9); }
.station[data-slot="2"] .stream { background: linear-gradient(180deg, #5eff8a, #1dc94a); }
.station[data-slot="3"] .stream { background: linear-gradient(180deg, #ffd95e, #c98a1d); }
.station[data-slot="4"] .stream { background: linear-gradient(180deg, #b85eff, #6a1dc9); }

.station[data-slot="0"] .fill { background: linear-gradient(180deg, #ff8aaf, #c91d6a); }
.station[data-slot="1"] .fill { background: linear-gradient(180deg, #8acfff, #1d6ec9); }
.station[data-slot="2"] .fill { background: linear-gradient(180deg, #8affab, #1dc94a); }
.station[data-slot="3"] .fill { background: linear-gradient(180deg, #ffe28a, #c98a1d); }
.station[data-slot="4"] .fill { background: linear-gradient(180deg, #c98aff, #6a1dc9); }

.station[data-slot="0"] .puddle { background: radial-gradient(ellipse, rgba(201,29,106,0.7), rgba(201,29,106,0)); }
.station[data-slot="1"] .puddle { background: radial-gradient(ellipse, rgba(29,110,201,0.7), rgba(29,110,201,0)); }
.station[data-slot="2"] .puddle { background: radial-gradient(ellipse, rgba(29,201,74,0.7), rgba(29,201,74,0)); }
.station[data-slot="3"] .puddle { background: radial-gradient(ellipse, rgba(201,138,29,0.7), rgba(201,138,29,0)); }
.station[data-slot="4"] .puddle { background: radial-gradient(ellipse, rgba(106,29,201,0.7), rgba(106,29,201,0)); }

.spot {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 200px;
}

@keyframes slidein {
  from {
    opacity: 0;
    transform: translateY(100px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cup {
  position: relative;
  background: rgba(255, 255, 255, 0.25);
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-top: none;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.3);
  transition: transform 0.2s;
  animation: slidein 0.5s ease;
}
.cup.size-S { width: 60px; height: 80px; }
.cup.size-M { width: 75px; height: 110px; }
.cup.size-L { width: 90px; height: 140px; }
.cup.size-XL { width: 100px; height: 170px; }
.cup.empty { display: none; }
.cup.served { animation: served 0.4s ease forwards; }
@keyframes served {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(60px) scale(0.6); opacity: 0; }
}

.fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  transition: height 0.05s linear;
}
.fill::after {
  content: '';
  position: absolute;
  top: -3px;
  left: 0;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
}

.puddle {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%) scaleY(0.4);
  width: 0;
  height: 30px;
  border-radius: 50%;
  transition: width 0.3s ease;
  pointer-events: none;
}
.station.cleanup .puddle { width: 110px; }
.station.cleanup .cup { opacity: 0.4; }

.station.cleanup::after {
  content: '🧽 ' attr(data-cleanup) 's';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  color: #ffcc00;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: bold;
}

.key {
  position: absolute;
  bottom: 20px;
  width: 36px;
  height: 36px;
  background: #fff;
  color: #1d2b53;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 18px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
  transition: transform 0.05s, box-shadow 0.05s;
}
.station.dispensing .key {
  transform: translateY(3px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.4);
  background: #ffe66d;
}

/* Overlay */
#overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  z-index: 10;
}
#overlay.show { display: flex; }
.panel {
  background: #2d3a7b;
  padding: 40px 50px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  max-width: 500px;
}
.panel h1 {
  font-size: 42px;
  margin-bottom: 16px;
  color: #ffe66d;
  letter-spacing: 2px;
}
.panel p { margin-bottom: 12px; line-height: 1.5; }
.panel button {
  margin-top: 20px;
  padding: 14px 36px;
  font-size: 18px;
  font-weight: bold;
  background: #ffe66d;
  color: #1d2b53;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 0 #c9a900;
  transition: transform 0.05s;
}
.panel button:hover { transform: translateY(-1px); }
.panel button:active { transform: translateY(2px); box-shadow: 0 2px 0 #c9a900; }
