:root {
  --pink: #ff2e9a;
  --black: #0a0a0a;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  overflow: hidden;
}

/* overexposed white studio backdrop, like the snippet */
body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px;
  text-align: center;
  color: var(--black);
  font-family: "Archivo Black", "Arial Black", sans-serif;
  background: radial-gradient(ellipse at 50% 40%, #fff 35%, #ecebee 75%, #d9d7dc 100%);
}

main {
  position: relative;
  z-index: 3; /* timer always above balloons, even a dragged one */
  pointer-events: none; /* clicks pass through the timer to balloons behind it */
}

.countdown {
  font-size: clamp(3.4rem, 17vw, 12rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.countdown span {
  display: inline-block;
}

.sep {
  margin: 0 0.04em;
  color: var(--pink);
}

/* seconds bounce on every tick */
.pop {
  animation: pop 0.35s cubic-bezier(0.3, 1.8, 0.5, 1);
}

@keyframes pop {
  from { transform: scale(1.08); color: var(--pink); }
  to { transform: scale(1); }
}

.out {
  font-size: clamp(1.6rem, 7vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  animation: bounce 0.9s ease-in-out infinite alternate;
}

.out span {
  color: var(--pink);
}

@keyframes bounce {
  to { transform: translateY(-8px) scale(1.03); }
}

/* ---- floating balloons ---- */

.balloon {
  position: fixed;
  z-index: 1;
  left: var(--x);
  top: var(--y);
  width: calc(var(--s, 1) * clamp(80px, 13vw, 200px));
  aspect-ratio: 100 / 124;
  transform-origin: 50% 100%;
  pointer-events: none; /* only the balloon body is grabbable, not the string */
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.balloon.dragging {
  z-index: 2;
  cursor: grabbing;
}

/* pop: quick swell and vanish (also beats the respawn animation) */
.balloon.popped,
.balloon.respawn.popped {
  pointer-events: none;
  animation: burst 0.18s ease-out forwards;
}

@keyframes burst {
  to { transform: scale(1.35); opacity: 0; }
}

/* respawned balloon floats up from below */
.balloon.respawn {
  animation: rise 1.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes rise {
  from { transform: translateY(60vh); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* scraps flying out on pop */
.scrap {
  position: fixed;
  z-index: 6;
  width: 10px;
  height: 6px;
  border-radius: 2px;
  pointer-events: none;
  animation: scrap 0.6s cubic-bezier(0.2, 0.7, 0.4, 1) forwards;
}

@keyframes scrap {
  to {
    transform: translate(var(--dx), var(--dy)) rotate(var(--r));
    opacity: 0;
  }
}

.balloon svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.balloon .body {
  pointer-events: auto;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.18));
}

.balloon.popped .string {
  display: none;
}

/* the body has its own pointer-events, so switch it off too — a popped balloon can't be tapped */
.balloon.popped .body {
  pointer-events: none;
}

/* phones: a few balloons get their own spots so the corners aren't crowded */
@media (max-width: 600px) {
  .balloon {
    left: var(--mx, var(--x));
    top: var(--my, var(--y));
  }
}

/* ---- frame so the page doesn't melt into the browser ---- */

.frame {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  border: clamp(10px, 1.6vw, 22px) solid var(--black);
  box-shadow: inset 0 0 0 2px var(--pink), inset 0 0 60px rgba(0, 0, 0, 0.18);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
  }
}
