:root {
  --fondo: #ffffff;
  --carta: #ffffff;
  --inchiostro: #141416;
  --grigio: #7d7c85;
  --grigio-chiaro: #b9b8c0;
  --linea: rgba(20, 20, 22, 0.09);
  --vassoio: #f4f4f2;
  --accento: #1f6b55;
  --accento-chiaro: #e6f1ec;
  --card-w: min(420px, 92vw);
  --chip-h: clamp(27px, 6.6vh, 32px);
  --gap-riga: 6px;
  --pad-vassoio: 7px;
}

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

html, body { height: 100%; }

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

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2vh 4vw;
}

.card {
  position: relative;
  width: var(--card-w);
  padding: clamp(12px, 3.6vh, 20px) clamp(12px, 4vw, 20px);
  border-radius: 20px;
  background: var(--carta);
  border: 1px solid var(--linea);
  box-shadow: 0 1px 0 rgba(20, 20, 22, 0.02), 0 24px 48px -28px rgba(20, 20, 22, 0.28);
  display: flex;
  flex-direction: column;
  gap: clamp(7px, 2.2vh, 12px);
}

.head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.head__kicker {
  display: block;
  font-size: 11px;
  font-weight: 560;
  letter-spacing: 0.02em;
  color: var(--grigio);
}

.head__title {
  margin-top: 2px;
  font-size: clamp(17px, 4.6vh, 21px);
  font-weight: 680;
  font-stretch: 92%;
  letter-spacing: -0.015em;
  line-height: 1.1;
}

.clear {
  font-size: 12px;
  font-weight: 580;
  color: var(--accento);
  padding: 4px 2px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s;
}

.clear.is-vista { opacity: 1; visibility: visible; }

.tray {
  position: relative;
  height: calc(2 * var(--chip-h) + var(--gap-riga) + 2 * var(--pad-vassoio));
  border-radius: 14px;
  background: var(--vassoio);
  box-shadow: inset 0 1px 2px rgba(20, 20, 22, 0.06), inset 0 0 0 1px rgba(20, 20, 22, 0.04);
}

/* la riga sottile fra le due righe del vassoio, appena segnata */
.tray::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(var(--pad-vassoio) + var(--chip-h) + var(--gap-riga) / 2);
  height: 1px;
  background: rgba(20, 20, 22, 0.045);
}

.tray__ph {
  position: absolute;
  left: 14px;
  top: calc(var(--pad-vassoio) + var(--chip-h) / 2);
  transform: translateY(-50%);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--grigio-chiaro);
  white-space: nowrap;
}

.label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--grigio);
  margin-bottom: -3px;
}

.opts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.opt {
  height: var(--chip-h);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 11px 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(20, 20, 22, 0.13);
  background: var(--carta);
  font-size: 12.5px;
  font-weight: 560;
  white-space: nowrap;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease, transform 0.18s ease;
}

.opt svg, .chip svg.ico {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.opt svg { color: var(--accento); }

/* il filtro già scelto resta come un'impronta tratteggiata: il suo gettone è nella barra */
.opt.is-on {
  border-style: dashed;
  border-color: rgba(20, 20, 22, 0.18);
  color: var(--grigio-chiaro);
  background: transparent;
}

.opt.is-on svg { color: var(--grigio-chiaro); }

.opt.is-giu { transform: scale(0.96); }

@media (hover: hover) {
  .opt:not(.is-on):hover { border-color: rgba(20, 20, 22, 0.32); transform: translateY(-1px); }
  .clear:hover { color: var(--inchiostro); }
  .show:hover .show__in { background: #26262a; }
  .chip__x:hover { background: rgba(20, 20, 22, 0.1); color: var(--inchiostro); }
}

.show {
  margin-top: 2px;
  height: clamp(38px, 9.6vh, 44px);
  width: 100%;
}

.show__in {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.32em;
  border-radius: 999px;
  background: var(--inchiostro);
  color: #fff;
  font-size: 13.5px;
  font-weight: 620;
  line-height: 1.2;
  box-shadow: 0 10px 20px -14px rgba(20, 20, 22, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: background-color 0.2s ease;
}

/* il numero a rulli: una colonna di cifre per posizione, ognuna larga quanto la sua cifra */
.count {
  display: inline-flex;
  height: 1.2em;
  line-height: 1.2em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22%, #000 78%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 22%, #000 78%, transparent 100%);
}

.dig {
  display: inline-block;
  height: 1.2em;
  overflow: hidden;
  text-align: center;
}

.dig__st { display: block; will-change: transform; }

.dig__st span { display: block; height: 1.2em; }

.layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

/* il gettone nella barra: l'elemento esterno lo muove la fisica, quello interno il CSS */
.chip {
  position: absolute;
  left: 0;
  top: 0;
  height: var(--chip-h);
  pointer-events: auto;
  will-change: transform;
  transform-origin: 50% 70%;
}

.chip__in {
  height: 100%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 4px 0 8px;
  border-radius: 999px;
  background: var(--carta);
  border: 1px solid rgba(20, 20, 22, 0.1);
  box-shadow: 0 1px 1px rgba(20, 20, 22, 0.05), 0 6px 12px -8px rgba(20, 20, 22, 0.35);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: box-shadow 0.25s ease;
}

/* in volo il gettone si stacca: l'ombra si allarga e si allontana */
.chip.is-volo .chip__in {
  box-shadow: 0 1px 1px rgba(20, 20, 22, 0.04), 0 16px 22px -12px rgba(20, 20, 22, 0.38);
}

.chip svg.ico { color: var(--accento); }

.chip__x {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--grigio);
  background: rgba(20, 20, 22, 0.05);
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.15s ease;
}

.chip__x svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.chip__x.is-giu { transform: scale(0.85); }

.cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  fill: var(--inchiostro);
  stroke: #fff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
}

@media (max-width: 400px) {
  .opt, .chip__in { font-size: 11.5px; }
  .opt { padding: 0 9px 0 8px; gap: 5px; }
  .chip__in { gap: 4px; padding: 0 3px 0 7px; }
  .opt svg, .chip svg.ico { width: 14px; height: 14px; }
  .chip__x { width: 17px; height: 17px; }
}
