@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* ── Reset & base ──────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:         #1a1a2e;
  --surface:    #16213e;
  --surface2:   #0f172a;
  --accent:     #ff6b00;
  --accent2:    #cc5200;
  --accent-blue:#00d4ff;
  --text:       #f0f0f0;
  --muted:      #8888aa;
  --danger:     #ff4757;
  --ring-bg:    #2a2a4a;
  --ring-fg:    #ff6b00;
  --radius:     16px;
  --radius-sm:  10px;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ── Setup Screen ──────────────────────────────────────────────────────── */
#setup-screen {
  width: 100%;
  max-width: 420px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px 40px;
  overflow-y: auto;
}

#setup-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding-top: 36px;
}

/* ── Setup hero: mascot + brand side-by-side ───────────────────────────── */
.setup-hero {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 20px;
  width: 100%;
  padding: 4px 0 8px;
}

.setup-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.setup-title {
  font-family: 'Press Start 2P', monospace;
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1.25;
}

.title-power {
  font-size: 1.55rem;
  color: var(--accent);
  text-shadow:
    4px 4px 0 #6b2400,
    0 0 22px rgba(255, 107, 0, 0.45);
  letter-spacing: 0.04em;
}

.title-hour {
  font-size: 1.55rem;
  color: var(--accent-blue);
  text-shadow:
    4px 4px 0 #005566,
    0 0 22px rgba(0, 212, 255, 0.4);
  letter-spacing: 0.04em;
}

.setup-subtitle {
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 2px;
}

@keyframes bob {
  from { transform: translateY(0) scaleX(1); }
  to   { transform: translateY(-8px) scaleX(1.03); }
}

.mascot-img {
  width: 100px;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 18px rgba(255, 107, 0, 0.35));
  animation: bob 1.8s ease-in-out infinite alternate;
  flex-shrink: 0;
}

.setup-section {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setup-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ── Preset buttons ────────────────────────────────────────────────────── */
.preset-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-btn {
  flex: 1;
  min-width: 48px;
  padding: 10px 8px;
  border: 2px solid var(--ring-bg);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.preset-btn:hover {
  border-color: var(--muted);
  color: var(--text);
}

.preset-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 107, 0, 0.1);
}

.preset-btn-endless {
  font-size: 1.15rem;
}

.preset-btn-endless.active {
  border-color: #7b61ff;
  color: #7b61ff;
  background: rgba(123, 97, 255, 0.12);
}

/* ── Rounds slider ─────────────────────────────────────────────────────── */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-min,
.slider-max {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 24px;
}

.slider-max { text-align: right; }

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 99px;
  background: var(--ring-bg);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.slider-value-badge {
  min-width: 36px;
  padding: 4px 8px;
  background: var(--accent);
  color: #1a1a2e;
  font-size: 0.85rem;
  font-weight: 800;
  border-radius: 8px;
  text-align: center;
}

/* ── Toggle switches ───────────────────────────────────────────────────── */
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--ring-bg);
  cursor: pointer;
  user-select: none;
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-label {
  font-size: 0.95rem;
  color: var(--text);
}

.toggle-switch {
  position: relative;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-knob {
  position: absolute;
  inset: 0;
  background: var(--ring-bg);
  border-radius: 99px;
  transition: background 0.2s;
  cursor: pointer;
}

.toggle-knob::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  top: 4px;
  left: 4px;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.toggle-switch input:checked + .toggle-knob {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-knob::after {
  transform: translateX(22px);
}

/* ── Player setup section ──────────────────────────────────────────────── */
.player-input-row {
  display: flex;
  gap: 8px;
}

.player-text-input {
  flex: 1;
  background: var(--surface2);
  border: 2px solid var(--ring-bg);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
}

.player-text-input::placeholder { color: var(--muted); }
.player-text-input:focus { border-color: var(--accent); }

.btn-add-player {
  padding: 10px 16px;
  background: var(--accent);
  color: #1a1a2e;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn-add-player:hover  { background: var(--accent2); }
.btn-add-player:active { transform: scale(0.95); }

.player-setup-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-setup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.player-setup-name {
  flex: 1;
  color: var(--text);
}

.btn-remove-player {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.btn-remove-player:hover {
  color: var(--danger);
  background: rgba(255, 71, 87, 0.1);
}

/* ── Player board (game screen) ────────────────────────────────────────── */
#player-board {
  width: 100%;
}

.player-board-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
  text-align: center;
}

#player-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  gap: 12px;
}

.player-card-name {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-card-count {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
  min-width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.btn-add-drink,
.btn-remove-drink {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #1a1a2e;
  font-size: 1.3rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-remove-drink {
  background: var(--surface2, #2a2a4a);
  color: var(--accent);
  border: 2px solid var(--accent);
}

.btn-add-drink:hover,
.btn-remove-drink:hover  { background: var(--accent2); color: #1a1a2e; border-color: transparent; }
.btn-add-drink:active,
.btn-remove-drink:active { transform: scale(0.9); }

.btn-clear-debt {
  height: 30px;
  padding: 0 10px;
  border-radius: 14px;
  background: transparent;
  color: var(--text-muted, #8888aa);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--text-muted, #8888aa);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-clear-debt:hover  { background: rgba(255,80,80,0.15); color: #ff6060; border-color: #ff6060; }
.btn-clear-debt:active { transform: scale(0.93); }

/* ── Launch button ─────────────────────────────────────────────────────── */
.btn-launch {
  width: 100%;
  padding: 18px;
  font-size: 1.2rem;
  letter-spacing: 0.03em;
}

/* ── App shell ─────────────────────────────────────────────────────────── */
#app {
  width: 100%;
  max-width: 420px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 20px 32px;
}

/* ── Header ────────────────────────────────────────────────────────────── */
header {
  padding: 16px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

header h1 {
  flex: 1;
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-shadow: 0 0 14px rgba(255, 107, 0, 0.5);
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 2px solid var(--ring-bg);
  border-radius: 10px;
  font-size: 1.1rem;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color 0.15s, transform 0.1s;
}

.icon-btn:hover  { border-color: var(--muted); }
.icon-btn:active { transform: scale(0.93); }

.icon-btn-placeholder {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

/* ── Main content ──────────────────────────────────────────────────────── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-top: 8px;
}

/* ── Round display ─────────────────────────────────────────────────────── */
#round-display {
  font-size: 1.15rem;
  color: var(--muted);
  display: flex;
  gap: 6px;
  align-items: baseline;
}

#round-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Ring timer ────────────────────────────────────────────────────────── */
#timer-ring {
  position: relative;
  width: min(72vw, 280px);
  height: min(72vw, 280px);
}

#timer-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--ring-bg);
  stroke-width: 10;
}

.ring-fg {
  fill: none;
  stroke: var(--ring-fg);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s linear, stroke 0.3s;
}

#timer-display {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(3rem, 14vw, 4.5rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* ── Drink alert (fullscreen overlay) ─────────────────────────────────── */
#drink-alert {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  animation: alertFadeIn 0.25s ease both;
}

#drink-alert.hidden { display: none !important; }

@keyframes alertFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* GIF fills the whole screen */
#drink-gif {
  display: none;       /* shown via JS once loaded */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

/* Text sits on top of the GIF */
.drink-overlay {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.35);
}

.drink-text {
  font-size: clamp(3.5rem, 18vw, 6rem);
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.06em;
  text-shadow:
    0 0 30px rgba(255, 71, 87, 0.9),
    0 0 60px rgba(255, 71, 87, 0.5),
    0 4px 12px rgba(0,0,0,0.8);
  animation: pulse 0.45s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1);    opacity: 1; }
  to   { transform: scale(1.08); opacity: 0.9; }
}

/* ── Progress bar ──────────────────────────────────────────────────────── */
#progress-bar-container {
  width: 100%;
}

#progress-bar {
  height: 6px;
  background: var(--ring-bg);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

#progress-bar::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 99px;
  transition: width 0.4s ease;
}

#progress-label {
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
}

/* ── Controls ──────────────────────────────────────────────────────────── */
#controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

.btn {
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 14px 28px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--accent);
  color: #1a1a2e;
  min-width: 140px;
  box-shadow: 0 0 18px rgba(255, 107, 0, 0.45), 0 2px 8px rgba(0,0,0,0.4);
}

.btn-primary:hover  { background: var(--accent2); box-shadow: 0 0 24px rgba(255, 107, 0, 0.6), 0 2px 8px rgba(0,0,0,0.4); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--muted);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 2px solid var(--ring-bg);
}

/* ── Sound notice ──────────────────────────────────────────────────────── */
#sound-notice {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* ── Game over overlay ─────────────────────────────────────────────────── */
#game-over {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#game-over-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#game-over-icon {
  font-size: 5rem;
  animation: bounce 0.8s ease infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-14px); }
}

#game-over h2 {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--accent);
}

#game-over p {
  font-size: 1.1rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ── Drink Visualiser ──────────────────────────────────────────────────── */
#drink-viz {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 16px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.dv-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  align-self: flex-start;
}

/* Mug stage — bigger and more prominent now that pouring happens above it */
#dv-stage {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

#dv-mug-wrap {
  width: 140px;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,0.35));
}

#dv-mug-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Slosh — quick wobble while liquid hits */
@keyframes dv-mug-slosh {
  0%   { transform: rotate(0deg)  scale(1); }
  20%  { transform: rotate(-3deg) scale(1.04, 0.98); }
  45%  { transform: rotate(2deg)  scale(0.98, 1.03); }
  70%  { transform: rotate(-1deg) scale(1.01, 0.99); }
  100% { transform: rotate(0deg)  scale(1); }
}
#dv-mug-wrap.dv-mug-slosh { animation: dv-mug-slosh 0.55s ease-out; }

/* Chug — tilts way back as if held to a mouth, then settles */
@keyframes dv-mug-chug {
  0%   { transform: rotate(0deg)   translateY(0)   scale(1); }
  18%  { transform: rotate(-12deg) translateY(-6px) scale(1.04); }
  35%  { transform: rotate(-58deg) translateY(-22px) scale(1.02); }
  60%  { transform: rotate(-62deg) translateY(-26px) scale(1.02); }
  78%  { transform: rotate(-30deg) translateY(-10px) scale(1.0); }
  100% { transform: rotate(0deg)   translateY(0)   scale(1); }
}
#dv-mug-wrap.dv-mug-chug {
  animation: dv-mug-chug 2.1s cubic-bezier(0.45, 0.05, 0.3, 1) forwards;
}

/* shot pips */
#dv-pips {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
}

.dv-pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ring-bg);
  border: 2px solid #3a4a6a;
  transition: background 0.18s, border-color 0.18s, transform 0.15s;
}

.dv-pip.filled {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.25);
  box-shadow: 0 0 8px rgba(255, 107, 0, 0.6);
}

/* ── Beer Collection (the empties shelf) ───────────────────────────────── */
#beer-collection {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bc-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.bc-count {
  font-size: 0.85rem;
  font-weight: 800;
  color: #1a1a2e;
  background: var(--accent);
  padding: 3px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: center;
}

#bc-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
  min-height: 56px;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  -webkit-overflow-scrolling: touch;
}

.bc-empty-placeholder {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  width: 100%;
  text-align: center;
  align-self: center;
  padding: 14px 0;
}

.bc-slot {
  width: 38px;
  height: 46px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
}

.bc-slot svg {
  width: 100%;
  height: auto;
  display: block;
}

@keyframes bc-slot-land {
  0%   { transform: scale(1.6) rotate(-8deg); opacity: 0; }
  35%  { transform: scale(0.85) rotate(4deg); opacity: 1; }
  60%  { transform: scale(1.08) rotate(-2deg); }
  100% { transform: scale(1)    rotate(0deg); }
}

.bc-slot-new {
  animation: bc-slot-land 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#bc-status {
  font-size: 0.85rem;
  color: var(--text);
  text-align: center;
  font-weight: 600;
  min-height: 1.2em;
}

/* ── Animation overlay (viewport-wide, pointer-events disabled) ────────── */
#dv-overlay {
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: none;
  overflow: hidden;
}

#dv-pour-hand,
#dv-chug-hand,
#dv-flying-mug {
  position: absolute;
  left: -9999px;
  top: 0;
  pointer-events: none;
  will-change: transform, opacity;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,0.4));
}

#dv-pour-hand svg,
#dv-chug-hand svg,
#dv-flying-mug svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* ── Wonky pour: hand swoops in, tilts, pours, leaves ──────────────────── */
#dv-pour-hand {
  --ex: 0px;
  --ey: 0px;
  --base-tilt: 0deg;
  --x-jitter: 0px;
  transform-origin: 50% 100%;       /* pivot at bottle's pour spout */
  opacity: 0;
}

@keyframes dv-wonky-pour {
  0%   {
    transform: translate(var(--ex), var(--ey))
               rotate(calc(var(--base-tilt) + 18deg))
               scale(0.92);
    opacity: 0;
  }
  10%  { opacity: 1; }
  22%  {
    transform: translate(calc(var(--x-jitter) + 4px), -10px)
               rotate(calc(var(--base-tilt) + 8deg))
               scale(1.04);
    opacity: 1;
  }
  32%  {
    transform: translate(var(--x-jitter), 0)
               rotate(var(--base-tilt))
               scale(1);
  }
  42%  {
    transform: translate(var(--x-jitter), 0)
               rotate(calc(var(--base-tilt) - 38deg))
               scale(1);
  }
  52%  {
    transform: translate(var(--x-jitter), 0)
               rotate(calc(var(--base-tilt) - 52deg))
               scale(1);
  }
  62%  {
    transform: translate(var(--x-jitter), 0)
               rotate(calc(var(--base-tilt) - 46deg))
               scale(1);
  }
  72%  {
    transform: translate(var(--x-jitter), 0)
               rotate(calc(var(--base-tilt) - 50deg))
               scale(1);
  }
  82%  {
    transform: translate(var(--x-jitter), -4px)
               rotate(calc(var(--base-tilt) - 10deg))
               scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--ex), var(--ey))
               rotate(calc(var(--base-tilt) + 22deg))
               scale(0.9);
    opacity: 0;
  }
}

#dv-pour-hand.pouring {
  animation: dv-wonky-pour 3.8s cubic-bezier(0.34, 1.36, 0.64, 1) forwards;
}

/* Shot glass wrist-flick — leans toward the entry side once the pour begins.
   Pivot is the LEFT rim of the glass (matches the element's pour pivot at
   bbox-x 0%, bbox-y 4.5%) so the pour-stream stays anchored. */
.dv-shot-glass {
  transform-box: fill-box;
  transform-origin: 0% 4.5%;
  transition: transform 0.7s linear;
}

/* ── Chug hand: reaches in, holds while mug chugs, exits ──────────────── */
#dv-chug-hand {
  --ex: 0px;
  --mirror: 1;
  transform-origin: 50% 100%;
  opacity: 0;
}

@keyframes dv-chug-hand-in {
  0%   { transform: translate(var(--ex), 60px) scaleX(var(--mirror)) rotate(0deg);   opacity: 0; }
  15%  { opacity: 1; }
  30%  { transform: translate(0, 0)            scaleX(var(--mirror)) rotate(-6deg); opacity: 1; }
  55%  { transform: translate(0, -6px)         scaleX(var(--mirror)) rotate(-12deg); }
  78%  { transform: translate(0, 0)            scaleX(var(--mirror)) rotate(-4deg); }
  92%  { transform: translate(0, 0)            scaleX(var(--mirror)) rotate(0deg);  opacity: 1; }
  100% { transform: translate(var(--ex), 30px) scaleX(var(--mirror)) rotate(8deg);   opacity: 0; }
}

#dv-chug-hand.chugging {
  animation: dv-chug-hand-in 2.7s cubic-bezier(0.36, 0.6, 0.4, 1) forwards;
}

/* ── Flying empty mug: arc to the shelf ────────────────────────────────── */
#dv-flying-mug {
  --fly-dx: 0px;
  --fly-dy: 0px;
  --fly-peak: -200px;
  --fly-end-scale: 0.4;
  --fly-spin: 720deg;
  opacity: 0;
}

@keyframes dv-fly-throw {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1);          opacity: 1; }
  50%  { transform: translate(calc(var(--fly-dx) * 0.5), var(--fly-peak))
                    rotate(calc(var(--fly-spin) * 0.5))
                    scale(calc((1 + var(--fly-end-scale)) / 2));    opacity: 1; }
  100% { transform: translate(var(--fly-dx), var(--fly-dy))
                    rotate(var(--fly-spin))
                    scale(var(--fly-end-scale));                    opacity: 1; }
}

#dv-flying-mug.throwing {
  animation: dv-fly-throw 1.15s cubic-bezier(0.4, -0.1, 0.6, 1.1) forwards;
}

@keyframes dv-fly-place {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1);          opacity: 1; }
  40%  { transform: translate(calc(var(--fly-dx) * 0.4),
                              calc(var(--fly-peak) * 0.5))
                    rotate(-8deg)
                    scale(0.9);                                     opacity: 1; }
  100% { transform: translate(var(--fly-dx), var(--fly-dy))
                    rotate(var(--fly-spin))
                    scale(var(--fly-end-scale));                    opacity: 1; }
}

#dv-flying-mug.placing {
  animation: dv-fly-place 1.45s cubic-bezier(0.45, 0.05, 0.4, 1) forwards;
}

/* ── Liquid droplets streaming into the mug ────────────────────────────── */
.dv-drop {
  position: absolute;
  width: 8px;
  height: 12px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: linear-gradient(180deg, #ffd860 0%, #e8881a 100%);
  border: 2px solid #1a1a2e;
  pointer-events: none;
  animation: dv-drop-fall 0.4s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes dv-drop-fall {
  0%   { transform: translateY(0)   scale(0.6); opacity: 0; }
  20%  { transform: translateY(0)   scale(1);   opacity: 1; }
  100% { transform: translateY(var(--drop-dy)) scale(0.7); opacity: 0; }
}

/* Spill drops — fly sideways and tumble past the mug */
.dv-drop-spill {
  --drop-dx: 0px;
  animation: dv-drop-spill 0.85s cubic-bezier(0.4, 0.05, 0.7, 0.95) forwards;
}

@keyframes dv-drop-spill {
  0%   { transform: translate(0, 0)                                rotate(0deg)   scale(0.5); opacity: 0; }
  18%  { transform: translate(calc(var(--drop-dx) * 0.25),
                              calc(var(--drop-dy) * 0.05))         rotate(45deg)  scale(1);   opacity: 1; }
  70%  { transform: translate(calc(var(--drop-dx) * 0.85),
                              calc(var(--drop-dy) * 0.55))         rotate(180deg) scale(0.95); opacity: 1; }
  100% { transform: translate(var(--drop-dx), var(--drop-dy))      rotate(280deg) scale(0.7); opacity: 0; }
}

/* ── Continuous beer stream from spout to mug ──────────────────────────── */
.dv-stream {
  position: absolute;
  width: 14px;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      180deg,
      #fff2b0 0px,
      #ffd860 6px,
      #f5a623 14px,
      #e8881a 22px,
      #ffd860 30px
    );
  background-size: 100% 30px;
  border-left: 2.5px solid #1a1a2e;
  border-right: 2.5px solid #1a1a2e;
  border-radius: 8px 8px 4px 4px;
  transform-origin: top center;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3));
  animation:
    dv-stream-flow 0.32s linear infinite,
    dv-stream-wiggle 0.18s ease-in-out infinite alternate,
    dv-stream-life 1.3s ease-out forwards;
}

.dv-stream::before {
  content: '';
  position: absolute;
  left: -2.5px;
  right: -2.5px;
  bottom: -7px;
  height: 14px;
  background: linear-gradient(180deg, #ffd860 0%, #f5a623 70%, #e8881a 100%);
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  border-left: 2.5px solid #1a1a2e;
  border-right: 2.5px solid #1a1a2e;
  border-bottom: 2.5px solid #1a1a2e;
  animation: dv-stream-tip 0.22s ease-in-out infinite alternate;
}

@keyframes dv-stream-tip {
  0%   { transform: scaleY(0.85) translateY(0); }
  100% { transform: scaleY(1.15) translateY(2px); }
}

.dv-stream::after {
  content: '';
  position: absolute;
  top: -3px;
  left: 1px;
  width: 4px;
  height: 60%;
  background: rgba(255, 255, 220, 0.55);
  border-radius: 4px;
  filter: blur(0.5px);
}

@keyframes dv-stream-flow {
  0%   { background-position: 0 0; }
  100% { background-position: 0 30px; }
}

@keyframes dv-stream-wiggle {
  0%   { transform: translateX(-1px) rotate(-1.5deg); }
  100% { transform: translateX(1px)  rotate(1.5deg); }
}

@keyframes dv-stream-life {
  0%   { opacity: 0; height: var(--stream-h, 100px); clip-path: inset(0 0 100% 0); }
  18%  { opacity: 1; clip-path: inset(0 0 0% 0); }
  82%  { opacity: 1; clip-path: inset(0 0 0% 0); }
  100% { opacity: 0; clip-path: inset(100% 0 0 0); }
}

/* ── Desktop layout: collection becomes a floating sidebar ─────────────── */
@media (min-width: 1024px) {
  #beer-collection {
    position: fixed;
    top: 80px;
    left: calc(50% + 240px);
    width: min(340px, calc((100vw - 460px) / 2));
    max-height: calc(100vh - 120px);
    overflow: hidden;
    padding: 22px;
    z-index: 5;
  }
  #bc-shelf {
    max-height: calc(100vh - 280px);
  }
}

/* On really wide screens, give it a little more breathing room */
@media (min-width: 1440px) {
  #beer-collection {
    left: calc(50% + 260px);
    width: 360px;
  }
}

/* Reduced motion: tone down (still functional) */
@media (prefers-reduced-motion: reduce) {
  #dv-pour-hand.pouring,
  #dv-chug-hand.chugging,
  #dv-flying-mug.throwing,
  #dv-flying-mug.placing,
  #dv-mug-wrap.dv-mug-chug,
  #dv-mug-wrap.dv-mug-slosh,
  .bc-slot-new,
  .dv-drop,
  .dv-stream {
    animation-duration: 0.3s !important;
  }
}

/* ── Utility ───────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Flash animation (visual cue when sound is blocked) ────────────────── */
@keyframes flash-bg {
  0%   { background: var(--bg); }
  15%  { background: #3d0a0a; }
  40%  { background: var(--bg); }
  55%  { background: #3d0a0a; }
  100% { background: var(--bg); }
}

body.flash-alert {
  animation: flash-bg 0.7s ease forwards;
}

/* ── Countdown urgency pulse ───────────────────────────────────────────── */
@keyframes ring-urgent {
  0%, 100% { filter: drop-shadow(0 0 0px var(--danger)); }
  50%       { filter: drop-shadow(0 0 8px var(--danger)); }
}

#timer-ring.urgent svg {
  animation: ring-urgent 0.5s ease-in-out infinite;
}
