:root {
  --fondo: #fafafa;
  --carta: #ffffff;
  --bordo: rgba(17, 17, 19, 0.08);
  --riga: #f4f4f5;
  --riga-sopra: #ececee;
  --barra: #e8e6fb;
  --barra-scelta: #d9d4ff;
  --testo: #18181b;
  --testo-2: #71717a;
  --testo-3: #a1a1aa;
  --accento: #6d5efc;
}

* { box-sizing: border-box; margin: 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;
}

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

.card {
  width: min(380px, 100%);
  padding: clamp(14px, 3.4vmin, 20px);
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(17, 17, 19, 0.04), 0 22px 46px -26px rgba(17, 17, 19, 0.32);
}

.card__top { display: flex; align-items: center; gap: 10px; }

.badge {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  background: linear-gradient(140deg, #8b7dff, #5a4ae0);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.who { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.who__name { font-weight: 650; font-size: 14px; }
.who__meta { font-size: 12.5px; color: var(--testo-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who__meta b { font-weight: 600; color: var(--testo); }

.q {
  margin: clamp(10px, 2.6vmin, 16px) 0 clamp(10px, 2.4vmin, 14px);
  font-size: clamp(17px, 4.6vmin, 20px);
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.opts { display: flex; flex-direction: column; gap: clamp(6px, 1.4vmin, 8px); }

/* each answer is a whole row; the GSAP element for the bar is .opt__fill (scaleX), the row is the CSS element */
.opt {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(38px, 9vmin, 46px);
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--riga);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: background-color 0.2s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.opt:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }
@media (hover: hover) {
  .opt:hover { background: var(--riga-sopra); }
}
.opt.is-hover { background: var(--riga-sopra); }

.is-voted .opt { cursor: default; background: var(--riga); }
.is-voted .opt.is-pick { border-color: var(--accento); box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.12); }

.opt__fill {
  position: absolute;
  inset: 0;
  background: var(--barra);
  transform-origin: 0 50%;
  transform: scaleX(0);
}
.opt.is-pick .opt__fill { background: var(--barra-scelta); }

.opt__row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 14px;
}

.opt__label {
  flex: 1;
  min-width: 0;
  font-size: clamp(13.5px, 3.6vmin, 15px);
  font-weight: 460;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: font-weight 0.35s ease;
}
.opt.is-lead .opt__label { font-weight: 700; }

.opt__tick {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--accento);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.opt__pct {
  flex: none;
  min-width: 3.2em;
  text-align: right;
  font-size: clamp(13px, 3.4vmin, 14.5px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--testo);
  opacity: 0;
}
.opt.is-lead .opt__pct { font-weight: 750; }

/* one column of digits for each figure */
.digit {
  display: inline-block;
  height: 1.25em;
  line-height: 1.25em;
  overflow: hidden;
  vertical-align: bottom;
}
.digit__col { display: block; }
.digit__col span { display: block; height: 1.25em; }

.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: clamp(10px, 2.4vmin, 14px);
  min-height: 30px;
}
.total { font-size: 12.5px; color: var(--testo-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

.change {
  padding: 6px 12px;
  border: 1px solid var(--bordo);
  border-radius: 999px;
  background: var(--carta);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--testo);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}
@media (hover: hover) {
  .change:hover { background: var(--riga); }
}
.change.is-hover { background: var(--riga); }
.change:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

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