:root {
  --bg: #ffffff;
  --ink: #1d1814;
  --ink-2: #6f675f;
  --ink-3: #a59d94;
  --line: #e6e0d8;
  --line-2: #cfc6bb;
  --pill-top: #3d322a;
  --pill-bottom: #1b1612;
  --accent: #d0774a;
  --chip-h: 36px;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.bar {
  width: min(540px, calc(100vw - 32px));
}

/* ---- the head: the rolling count, where we are, Clear ---- */
.bar__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  min-height: 34px;
}
.count {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 15px;
  font-variation-settings: "wdth" 100;
  font-weight: 560;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.count__num {
  display: inline-flex;
  font-size: 22px;
  font-weight: 640;
  letter-spacing: -0.03em;
  height: 1.15em;
  line-height: 1.15;
  overflow: hidden;
  transform: translateY(2px);
}
.d {
  position: relative;
  display: inline-block;
  overflow: hidden;
  height: 1.15em;
}
.d__in {
  display: block;
}
.d__in + .d__in {
  position: absolute;
  left: 0;
  top: 0;
}
.count__noun { color: var(--ink-2); font-weight: 480; }
.bar__where {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--ink-3);
  font-weight: 480;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.bar__where i { font-style: normal; padding: 0 2px; }

.clear {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  border-radius: 999px;
}
.clear__in {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 540;
  font-variation-settings: "wdth" 100;
  transition: color 0.3s, border-color 0.3s, background-color 0.3s, font-variation-settings 0.35s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.clear svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.5s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.clear:disabled { cursor: default; }
.clear:disabled .clear__in { color: var(--ink-3); border-color: #efeae4; }
@media (hover: hover) {
  .clear:not(:disabled):hover .clear__in { background: #f7f4f0; border-color: var(--line-2); font-variation-settings: "wdth" 112; }
  .clear:not(:disabled):hover svg { transform: rotate(-40deg); }
}
.clear.is-hot .clear__in { background: #f7f4f0; border-color: var(--line-2); font-variation-settings: "wdth" 112; }
.clear.is-hot svg { transform: rotate(-40deg); }
.clear:focus-visible { outline: none; }
.clear:focus-visible .clear__in { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }

/* ---- the chips ---- */
.chips {
  position: relative;
  height: 80px;
}

/* the liquid layer: every chosen chip has a fill here, and the goo filter fuses the fills that touch */
.goo {
  position: absolute;
  inset: 0;
  z-index: 2;
  filter: url(#goo) drop-shadow(0 6px 9px rgba(29, 24, 20, 0.16)) drop-shadow(0 1px 1.5px rgba(29, 24, 20, 0.22));
  pointer-events: none;
}
.fill, .tail {
  position: absolute;
  left: 0;
  top: 0;
  height: var(--chip-h);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--pill-top), var(--pill-bottom));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), inset 0 -1px 0 rgba(0, 0, 0, 0.3);
  opacity: 0;
}
.tail {
  width: 18px;
  height: 18px;
  box-shadow: none;
}

.chip {
  position: absolute;
  left: 0;
  top: 0;
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
  z-index: 1;
}
/* the chosen chips sit above the liquid, the free ones under it, so a running drop flows over them */
.chip.is-on { z-index: 3; }
.chip__in {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  height: var(--chip-h);
  padding: 0 15px 0 12px;
  border-radius: inherit;
  font-size: 14px;
  font-weight: 520;
  white-space: nowrap;
  letter-spacing: -0.005em;
  transition: transform 0.45s cubic-bezier(0.3, 1.6, 0.5, 1), color 0.32s ease;
}
/* the white face of an empty chip: it fades when the liquid comes under it */
.chip__face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, #ffffff, #fbf9f7);
  border: 1px solid var(--line);
  box-shadow: 0 1px 1.5px rgba(29, 24, 20, 0.05);
  transition: opacity 0.28s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
/* a soft light inside a chosen segment, on hover */
.chip__glow {
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  background: radial-gradient(60% 120% at 50% 0%, rgba(255, 255, 255, 0.16), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
/* the thin divider where two chosen chips are fused */
.chip__div {
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  opacity: 0;
  transform: scaleY(0.2);
  transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.chip.is-joined .chip__div { opacity: 1; transform: scaleY(1); }
.chip__label { position: relative; font-variation-settings: "wdth" 100; transition: font-variation-settings 0.4s cubic-bezier(0.3, 1.5, 0.5, 1); }
.chip__ic {
  position: relative;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  color: var(--ink-3);
  transition: transform 0.5s cubic-bezier(0.3, 1.6, 0.5, 1), color 0.3s ease;
}

.chip.is-on .chip__in { color: #fbf6f1; }
.chip.is-on .chip__face { opacity: 0; }
.chip.is-on .chip__ic { transform: rotate(135deg); color: rgba(251, 246, 241, 0.6); }
.chip.is-on .chip__label { font-variation-settings: "wdth" 104; }

@media (hover: hover) {
  .chip:not(.is-on):hover .chip__in { transform: translateY(-1px); }
  .chip:not(.is-on):hover .chip__face { border-color: var(--line-2); box-shadow: 0 3px 8px rgba(29, 24, 20, 0.08), 0 1px 1.5px rgba(29, 24, 20, 0.06); }
  .chip:not(.is-on):hover .chip__ic { color: var(--accent); transform: rotate(90deg); }
  .chip.is-on:hover .chip__glow { opacity: 1; }
  .chip.is-on:hover .chip__ic { color: #fbf6f1; }
}
.chip.is-hot:not(.is-on) .chip__in { transform: translateY(-1px); }
.chip.is-hot:not(.is-on) .chip__face { border-color: var(--line-2); box-shadow: 0 3px 8px rgba(29, 24, 20, 0.08), 0 1px 1.5px rgba(29, 24, 20, 0.06); }
.chip.is-hot:not(.is-on) .chip__ic { color: var(--accent); transform: rotate(90deg); }
.chip.is-hot.is-on .chip__glow { opacity: 1; }
.chip.is-hot.is-on .chip__ic { color: #fbf6f1; }

.chip:focus-visible { outline: none; }
.chip:focus-visible .chip__in { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.defs { position: absolute; }

/* the drawn pointer of the autopilot */
.ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  pointer-events: none;
  fill: #15110e;
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.28));
  opacity: 0;
  z-index: 5;
}

@media (max-width: 420px) {
  :root { --chip-h: 34px; }
  .chip__in { font-size: 13px; padding: 0 13px 0 10px; gap: 6px; }
  .bar__where { display: none; }
  .bar__head { justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  .chip__in, .chip__ic, .chip__div, .chip__label, .clear svg, .clear__in { transition-property: color, opacity, border-color, background-color; }
}
