:root {
  --fondo: #ffffff;
  --inchiostro: #111318;      /* the pill */
  --inchiostro-2: #23262e;    /* the pill under the pointer */
  --testo-2: #7a808c;         /* the lines under the button */
  --linea: #e7e9ee;
  --accento: #7c5cff;         /* the only colour: the active box, the new credit */
  --errore: #ff5a52;          /* only for a moment, on a wrong code */
  --bianco: #ffffff;
  --casella: clamp(22px, 6.4vw, 34px);
}

* { box-sizing: border-box; margin: 0; padding: 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;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

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

.wrap {
  position: relative;
  display: grid;
  justify-items: center;
  gap: clamp(10px, 2.4vh, 16px);
}

/* ---- the pill: GSAP moves .pill__lift and its width, the CSS keeps the rest ---- */
.pill {
  position: relative;
  height: 60px;
  width: 210px;
}
.pill__lift {
  position: absolute;
  left: 50%;
  top: 0;
  height: 100%;
  width: 210px;
  border-radius: 999px;
}
.pill__bg {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--inchiostro);
  box-shadow:
    0 1px 1px rgba(17, 19, 24, 0.10),
    0 6px 14px -6px rgba(17, 19, 24, 0.38),
    0 18px 32px -18px rgba(17, 19, 24, 0.40),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
  transition: background-color 0.25s ease;
}
.pill__sheen {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0) 55%);
  pointer-events: none;
}

.face {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 26px 0 22px;
  color: var(--bianco);
  font-size: 18px;
  font-weight: 560;
  font-stretch: 104%;
  letter-spacing: 0.005em;
  white-space: nowrap;
  border-radius: 999px;
  outline: none;
}
.face:focus-visible { box-shadow: 0 0 0 3px var(--fondo), 0 0 0 5px var(--accento); }
.face--field { padding: 0 8px 0 14px; gap: 10px; opacity: 0; visibility: hidden; }
.face--done { padding-left: 21px; gap: 9px; opacity: 0; visibility: hidden; }

.ticket { display: block; width: 22px; height: 22px; }
.ticket svg { display: block; width: 100%; height: 100%; overflow: visible; }
.ticket__body { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.ticket__cut { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-dasharray: 1.4 2.2; }

/* ---- the eight boxes ---- */
.slots {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}
.slots__input {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  opacity: 0;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  z-index: 2;
  cursor: text;
}
.slot {
  position: relative;
  width: var(--casella);
  height: calc(var(--casella) * 1.18);
  border-radius: 8px;
}
.slot__box {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.13);
}
.slot__ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1.5px var(--accento), 0 0 0 3px rgba(124, 92, 255, 0.22);
  opacity: 0;
}
.slot__bad {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1.5px var(--errore);
  background: rgba(255, 90, 82, 0.12);
  opacity: 0;
}
.slot__ch {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "JetBrains Mono Variable", ui-monospace, monospace;
  font-size: calc(var(--casella) * 0.56);
  font-weight: 560;
  color: var(--bianco);
}
.slot__caret {
  position: absolute;
  left: 50%;
  top: 24%;
  width: 1.5px;
  height: 52%;
  margin-left: -0.75px;
  border-radius: 1px;
  background: var(--bianco);
  opacity: 0;
}
.dash {
  width: 8px;
  height: 1.5px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.35);
  margin: 0 2px;
}

.apply {
  position: relative;
  height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--bianco);
  color: var(--inchiostro);
  font-size: 15px;
  font-weight: 600;
  font-stretch: 102%;
  opacity: 0.38;
  transition: opacity 0.25s ease;
  outline: none;
}
.apply.is-ready { opacity: 1; }
.apply:focus-visible { box-shadow: 0 0 0 2px var(--inchiostro), 0 0 0 4px var(--accento); }

.tick { width: 22px; height: 22px; display: block; }
.tick path { fill: none; stroke: var(--bianco); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1 1; stroke-dashoffset: 1; }

/* ---- the lines under the button ---- */
.note {
  position: relative;
  height: 1.3em;
  overflow: hidden;
  font-size: 14px;
  color: var(--testo-2);
  letter-spacing: 0.01em;
  text-align: center;
  min-width: 20em;
}
.note__line { display: inline-block; white-space: nowrap; }
.note.is-bad { color: var(--errore); }

.credit {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 14px;
  border-radius: 999px;
  background: #f5f6f8;
  box-shadow: inset 0 0 0 1px var(--linea);
  font-size: 13px;
  color: var(--testo-2);
}
.credit__label { letter-spacing: 0.02em; }
.money {
  display: inline-flex;
  height: 1.3em;
  line-height: 1.3em;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  color: var(--inchiostro);
  font-variant-numeric: tabular-nums;
}
.money.is-new { color: var(--accento); transition: color 0.4s ease; }
.money__c { display: inline-block; height: 1.3em; overflow: hidden; }
.money__strip { display: block; }
.money__strip span { display: block; height: 1.3em; text-align: center; }

/* on big screens the whole piece grows with a CSS scale; GSAP never touches .wrap */
@media (min-width: 900px) and (min-height: 620px) { .wrap { transform: scale(1.3); } }
@media (min-width: 1200px) and (min-height: 780px) { .wrap { transform: scale(1.45); } }

@media (max-width: 520px), (max-height: 460px) {
  .pill { height: 52px; }
  .face { font-size: 16px; padding: 0 22px 0 18px; }
  .face--field { padding: 0 6px 0 10px; gap: 6px; }
  .slots { gap: 3px; }
  .dash { width: 6px; margin: 0 1px; }
  .apply { height: 38px; padding: 0 12px; font-size: 14px; }
  .note { font-size: 13px; min-width: 0; }
}
