:root {
  --fondo: #ffffff;
  --carta: #ffffff;
  --bordo: rgba(20, 20, 34, 0.08);
  --linea: #ececf1;
  --testo: #15151f;
  --testo-2: #686a78;
  --testo-3: #a4a6b3;
  --accento: #5b4cf0;        /* the campaign violet: the budget, the switch, the clicks line */
  --accento-tenue: #efedfe;  /* the soft violet behind the brand mark and the tooltip edge */
  --spento: #b8bac6;         /* the line and the switch when the campaign is paused */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--fondo);
  color: var(--testo);
  font-family: "Mona Sans Variable", 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; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vh, 28px) 12px;
}

/* ---- the card ---- */
.card {
  position: relative;
  width: min(392px, 100%);
  background: var(--carta);
  border-radius: 22px;
  box-shadow:
    0 0 0 1px var(--bordo),
    0 1px 2px rgba(20, 20, 34, 0.04),
    0 10px 26px -12px rgba(20, 20, 34, 0.16),
    0 36px 64px -34px rgba(40, 30, 110, 0.24);
}
.card::before { /* a hairline of light along the top edge */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0) 30%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}
.card__in { position: relative; padding: clamp(13px, 3.4vh, 20px) clamp(14px, 4.4vw, 20px) clamp(11px, 2.8vh, 16px); }
.label { font-size: 11.5px; font-weight: 500; color: var(--testo-2); letter-spacing: 0.005em; }

/* ---- the head ---- */
.head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; }
.brand {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(160deg, #f4f2ff, var(--accento-tenue));
  box-shadow: inset 0 0 0 1px rgba(91,76,240,0.12), inset 0 1px 0 #fff, 0 2px 6px -3px rgba(91,76,240,0.35);
}
.brand svg { width: 16px; height: 16px; fill: none; stroke: var(--accento); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.head__text { min-width: 0; }
.head__name { font-size: 15px; font-weight: 640; letter-spacing: -0.014em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head__meta { font-size: 12px; color: var(--testo-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.state { display: flex; align-items: center; gap: 9px; }
.state__label { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--accento); transition: color .35s; }
.state__label.is-off { color: var(--testo-2); }
.state__word { display: inline-block; }
.eq { width: 12px; height: 12px; overflow: visible; }
.eq rect { fill: currentColor; transform-box: fill-box; transform-origin: 50% 100%; }

.switch { position: relative; width: 40px; height: 24px; flex: none; border-radius: 999px; }
.switch__track {
  position: absolute; inset: 0; border-radius: inherit; background: var(--accento);
  box-shadow: inset 0 1px 2px rgba(20,10,80,0.28), inset 0 0 0 1px rgba(20,10,80,0.08);
}
.switch__knob {
  position: absolute; left: 0; top: 3px; width: 18px; height: 18px; border-radius: 999px; background: #fff;
  box-shadow: 0 1px 1px rgba(20,20,34,0.12), 0 2px 6px -1px rgba(20,20,34,0.28), inset 0 -1px 0 rgba(20,20,34,0.05);
}
.switch:focus-visible { outline: 2px solid var(--testo); outline-offset: 3px; }

/* ---- the budget ---- */
.budget { margin-top: clamp(12px, 3vh, 18px); }
.budget__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.budget__nums { display: inline-flex; align-items: center; font-size: 12.5px; color: var(--testo-2); white-space: nowrap; }
.budget__of { white-space: nowrap; }
.roll--strong { color: var(--testo); font-weight: 650; font-size: 13.5px; }
.bar { position: relative; height: 8px; margin: 7px 0 6px; border-radius: 99px; background: #f1f1f5; box-shadow: inset 0 1px 1px rgba(20,20,34,0.06); overflow: hidden; }
.bar__fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: inherit; overflow: hidden;
  background: linear-gradient(90deg, #8a7ff7, var(--accento));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
  transition: filter .5s;
}
.bar.is-off .bar__fill { filter: saturate(0.15) brightness(1.18); }
.bar__sheen { position: absolute; top: 0; bottom: 0; left: 0; width: 40%; background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.45), rgba(255,255,255,0)); transform: translateX(-110%); }
.bar__tick { position: absolute; top: 2px; bottom: 2px; width: 1px; background: rgba(255,255,255,0.7); mix-blend-mode: normal; }
.budget__row--small { font-size: 11.5px; color: var(--testo-3); }
.budget__row--small .roll { color: var(--testo-2); font-weight: 550; }

/* ---- the three numbers ---- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: clamp(10px, 2.6vh, 16px); padding: clamp(8px, 2vh, 11px) 0; border-top: 1px solid var(--linea); border-bottom: 1px solid var(--linea); }
.stat { display: flex; flex-direction: column; gap: 3px; padding-left: 12px; border-left: 1px solid var(--linea); }
.stat:first-child { padding-left: 0; border-left: 0; }
.roll--big { font-size: clamp(16px, 4.6vh, 19px); font-weight: 640; letter-spacing: -0.02em; color: var(--testo); transition: color .4s; }
.stats.is-off .roll--big { color: #545664; }

/* ---- the chart ---- */
.chart { margin-top: clamp(9px, 2.4vh, 14px); }
.chart__cap { display: flex; justify-content: space-between; align-items: center; }
.chart__hint { font-size: 11px; color: var(--testo-3); }
.chart__box { position: relative; height: clamp(54px, 15vh, 86px); margin-top: 6px; touch-action: pan-y; cursor: crosshair; }
.chart__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; display: block; }
.chart__base { stroke: var(--linea); stroke-width: 1; }
.chart__mid { stroke: var(--linea); stroke-width: 1; stroke-dasharray: 2 4; }
.chart__line { fill: none; stroke: var(--accento); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: stroke .45s; }
.chart__area { transition: opacity .45s; }
.chart.is-off .chart__line { stroke: var(--spento); }
.chart.is-off .chart__area { opacity: 0.25; }
.chart__cursor { stroke: rgba(20,20,34,0.22); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0; }
.chart__ring { fill: #fff; stroke: var(--accento); stroke-width: 1.8; opacity: 0; }
.chart.is-off .chart__ring { stroke: var(--spento); }
.chart__axis { display: flex; justify-content: space-between; margin-top: 5px; font-size: 10.5px; color: var(--testo-3); }

.tip {
  position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; opacity: 0;
  display: flex; flex-direction: column; gap: 1px; padding: 5px 8px 6px; border-radius: 9px; white-space: nowrap;
  background: #15151f; color: #fff;
  box-shadow: 0 8px 18px -8px rgba(20,20,34,0.55), inset 0 1px 0 rgba(255,255,255,0.08);
}
.tip__time { font-size: 10.5px; color: #a9abb9; }
.tip__val { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- the rolling digits ---- */
.roll { display: inline-flex; align-items: flex-start; height: 1.2em; line-height: 1.2em; overflow: hidden; font-variant-numeric: tabular-nums; }
.roll .s, .roll .d { display: block; height: 1.2em; }
.roll .d { overflow: hidden; }
.roll .d__col { display: block; }
.roll .d__col > span { display: block; height: 1.2em; }

@media (max-width: 360px) {
  .head__meta { font-size: 11.5px; }
  .stat { padding-left: 9px; }
}
@media (max-height: 430px) {
  .chart__axis { display: none; }
}
