:root {
  --ink: #1b1b1b;
  --paper: #fffdf4;
  --yellow: #ffd23f;
  --red: #ff4d4d;
  --red-dark: #c92a2a;
  --blue: #3fa7ff;
  --grey: #d9d4c7;
  --pink: #ff8fc7;
  --gold: #ffb627;
  --gold-dark: #d98a00;
  --diamond: #bdeeff;
  --outline: 4px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background-color: var(--yellow);
  /* comic halftone dots */
  background-image: radial-gradient(rgba(0,0,0,.13) 2px, transparent 2.5px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: "Comic Neue", "Comic Sans MS", system-ui, sans-serif;
  font-weight: 700;
  overflow-x: hidden;
}

.page {
  max-width: 460px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.hidden { display: none !important; }

/* ---------- Title ---------- */
.title-wrap { text-align: center; }

.title {
  font-family: "Bangers", Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(42px, 13vw, 64px);
  letter-spacing: 2px;
  line-height: .95;
  margin: 0;
  color: var(--red);
  -webkit-text-stroke: 2.5px var(--ink);
  text-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-3deg);
}

.subtitle {
  display: inline-block;
  margin: 14px 0 0;
  padding: 6px 12px;
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(1.5deg);
  font-size: 15px;
}

/* ---------- Panel ---------- */
.panel {
  width: 100%;
  background: var(--paper);
  border: var(--outline);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.panel-text { margin: 0; font-size: 18px; }

.loading {
  font-family: "Bangers", Impact, sans-serif;
  font-size: 28px;
  letter-spacing: 1px;
}

.bubble {
  position: relative;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 24px;
  padding: 10px 18px;
  font-family: "Bangers", Impact, sans-serif;
  font-size: 26px;
  letter-spacing: 1px;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 28px;
  bottom: -16px;
  border-width: 16px 12px 0 0;
  border-style: solid;
  border-color: var(--ink) transparent transparent transparent;
}

/* ---------- Count burst ---------- */
.burst-wrap {
  position: relative;
  width: 250px;
  height: 275px;
  perspective: 700px;
}

.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  animation: ring-spin 6s linear infinite;
  transform-style: preserve-3d;
}
.ring .band-outline { fill: none; stroke: var(--ink); stroke-width: 32; }
.ring .band-gold    { fill: none; stroke: var(--gold); stroke-width: 22; }
.ring .band-shine   { fill: none; stroke: #fff6c9; stroke-width: 6; stroke-linecap: round; }
.ring .band-shade   { fill: none; stroke: var(--gold-dark); stroke-width: 7; stroke-linecap: round; }
.ring .setting { fill: var(--gold); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.ring .gem     { fill: var(--diamond); stroke: var(--ink); stroke-width: 4.5; stroke-linejoin: round; }
.ring .facet   { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.ring .gem-shine { fill: #fff; }
.ring .sparkle {
  fill: #fff;
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linejoin: round;
  transform-box: fill-box;
  transform-origin: center;
  animation: twinkle 1.4s ease-in-out infinite;
}
.ring .s2 { animation-delay: .7s; }

.count {
  position: absolute;
  left: 50%;
  top: 61.4%;
  translate: -50% -50%;
  font-family: "Bangers", Impact, sans-serif;
  font-size: 92px;
  line-height: 1;
  color: #fff;
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 5px 5px 0 var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.count.digits-3 { font-size: 66px; -webkit-text-stroke-width: 2.5px; text-shadow: 4px 4px 0 var(--ink); }
.count.digits-4 { font-size: 46px; -webkit-text-stroke-width: 2px; text-shadow: 3px 3px 0 var(--ink); }
.count.pop { animation: pop .45s cubic-bezier(.2, 1.8, .4, 1); }
.count.shrink { animation: shrink .4s ease; }

.milestone {
  margin: 0;
  min-height: 1.4em;
  font-size: 17px;
}

.last-by {
  margin: 0;
  min-height: 1.2em;
  font-size: 14px;
  opacity: .75;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: "Bangers", Impact, sans-serif;
  letter-spacing: 1.5px;
  border: var(--outline);
  border-radius: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  color: var(--ink);
  transition: transform .06s ease, box-shadow .06s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active:not(:disabled) {
  transform: translate(5px, 5px);
  box-shadow: 1px 1px 0 var(--ink);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 3px dashed var(--blue); outline-offset: 4px; }

.btn-huge {
  width: 100%;
  font-size: 44px;
  padding: 18px 12px 12px;
  line-height: 1;
}
.btn-sub {
  display: block;
  font-family: "Comic Neue", sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0;
  margin-top: 6px;
}

.btn-red {
  background: var(--red);
  color: #fff;
  -webkit-text-stroke: 1.5px var(--ink);
}
.btn-red .btn-sub { -webkit-text-stroke: 0; color: #fff; }
.btn-red:hover:not(:disabled) { background: #ff6262; }

.btn-grey {
  background: var(--grey);
  font-size: 24px;
  padding: 10px 28px 6px;
  transform: rotate(-1.5deg);
}
.btn-grey:active:not(:disabled) { transform: rotate(-1.5deg) translate(5px, 5px); }

.btn-blue {
  background: var(--blue);
  color: #fff;
  -webkit-text-stroke: 1.2px var(--ink);
  font-size: 28px;
  padding: 14px 24px 10px;
}

.link-btn {
  background: none;
  border: none;
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
  color: var(--ink);
  padding: 4px;
}

.footer-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-top: 3px dashed var(--ink);
  padding-top: 12px;
  font-size: 14px;
}
.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.error {
  margin: 0;
  color: var(--red-dark);
  font-size: 15px;
}

/* ---------- Floating effects ---------- */
#fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.fx-word {
  position: absolute;
  font-family: "Bangers", Impact, sans-serif;
  font-size: 40px;
  color: var(--yellow);
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 3px 3px 0 var(--ink);
  white-space: nowrap;
  animation: float-up 1.1s ease-out forwards;
}
.fx-word.sad { color: var(--grey); font-size: 30px; }

.fx-heart {
  position: absolute;
  font-size: 26px;
  animation: heart-fly 1s ease-out forwards;
}

/* ---------- Animations ---------- */
@keyframes ring-spin {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}

@keyframes twinkle {
  0%, 100% { transform: scale(.4) rotate(0deg); opacity: .3; }
  50% { transform: scale(1.1) rotate(45deg); opacity: 1; }
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.45) rotate(-6deg); }
  100% { transform: scale(1); }
}

@keyframes shrink {
  0% { transform: scale(1); }
  40% { transform: scale(.7) rotate(4deg); }
  100% { transform: scale(1); }
}

@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.4) rotate(var(--rot)); }
  20% { opacity: 1; transform: translate(-50%, -20px) scale(1.15) rotate(var(--rot)); }
  100% { opacity: 0; transform: translate(-50%, -140px) scale(1) rotate(var(--rot)); }
}

@keyframes heart-fly {
  0% { opacity: 1; transform: translate(0, 0) scale(.6); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.2); }
}

@media (prefers-reduced-motion: reduce) {
  .ring, .ring .sparkle, .count.pop, .count.shrink, .fx-word, .fx-heart { animation: none; }
  .fx-word, .fx-heart { display: none; }
}
