:root {
  --fondo: #f2f2f2;
  --carta: #ffffff;
  --bordo: rgba(0, 0, 0, 0.07);
  --testo: #111113;
  --testo-2: #6e6e76;
  --testo-3: #a1a1aa;
  --barra-spenta: #e4e4e7;
  --barra: #18181b;
  --accento: #18181b;
  --maniglia: #ffffff;
}

* { 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;
}

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.card {
  width: min(440px, 100%);
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: 24px;
  padding: clamp(16px, 4.2vmin, 24px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 18px 40px -18px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 3vh, 18px);
}

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.head__title { font-size: 16px; font-weight: 620; letter-spacing: -0.01em; }
.head__meta { font-size: 12.5px; color: var(--testo-2); margin-top: 3px; }

.reset {
  font: inherit; font-size: 12.5px; font-weight: 520; color: var(--testo-2);
  background: none; border: 0; padding: 4px 8px; margin: -4px -8px 0 0; border-radius: 8px;
  cursor: pointer; transition: color .2s, background-color .2s;
}
@media (hover: hover) { .reset:hover { color: var(--testo); background: #f4f4f5; } }
.reset:focus-visible { outline: 2px solid var(--accento); outline-offset: 1px; }

.chart { position: relative; padding: 0 13px; }

.bars {
  height: clamp(56px, 15vh, 84px);
  display: flex; align-items: flex-end; gap: 2px;
}
.bar {
  flex: 1 1 0;
  border-radius: 2px 2px 1px 1px;
  background: var(--barra-spenta);
  transform-origin: 50% 100%;
}
.bar__in { display: block; width: 100%; height: 100%; border-radius: inherit; background: var(--barra); }

.track { position: relative; height: 28px; margin-top: 2px; }
.track__rail, .track__fill {
  position: absolute; top: 50%; height: 4px; margin-top: -2px; border-radius: 4px;
}
.track__rail { left: 0; right: 0; background: var(--barra-spenta); }
.track__fill { left: 0; width: 0; background: var(--accento); }

.handle {
  position: absolute; top: 50%; left: 0;
  width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: var(--maniglia);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 2px 5px rgba(0, 0, 0, 0.14);
  cursor: grab;
  outline: none;
}
.handle::after {
  content: ""; position: absolute; inset: 9px; border-radius: 50%;
  background: var(--accento); opacity: 0.85;
}
.handle.is-grab { cursor: grabbing; }
.handle:focus-visible { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 0 0 4px rgba(24, 24, 27, 0.18), 0 2px 5px rgba(0, 0, 0, 0.14); }

.fields { display: flex; align-items: center; gap: 10px; }
.fields__dash { width: 10px; height: 1px; background: var(--testo-3); flex: none; }
.field {
  flex: 1 1 0;
  border: 1px solid var(--bordo);
  border-radius: 12px;
  padding: 7px 12px 8px;
  transition: border-color .25s, box-shadow .25s;
}
.field.is-live { border-color: rgba(0, 0, 0, 0.22); box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04); }
.field__label { display: block; font-size: 11px; color: var(--testo-3); letter-spacing: 0.01em; }
.field__value { display: flex; align-items: baseline; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; margin-top: 1px; }
.field__cur { color: var(--testo-2); font-weight: 500; margin-right: 1px; }

.roll { display: inline-flex; font-variant-numeric: tabular-nums; overflow: hidden; height: 1.2em; line-height: 1.2em; vertical-align: bottom; }
.roll__col { display: inline-block; position: relative; height: 1.2em; overflow: hidden; }
.roll__strip { display: block; }
.roll__strip span { display: block; height: 1.2em; text-align: center; }
.roll__sep { display: inline-block; }

.show {
  font: inherit; font-size: 14.5px; font-weight: 600; letter-spacing: -0.005em;
  display: flex; align-items: center; justify-content: center; gap: 0.32em;
  height: 46px; border: 0; border-radius: 14px;
  background: var(--accento); color: #fff;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 6px 14px -8px rgba(0, 0, 0, 0.5);
}
.show:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }
.roll--light { color: #fff; }

.ghost {
  position: absolute; left: 0; top: 0;
  width: 26px; height: 26px;
  fill: #111; stroke: #fff; stroke-width: 1.4; stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}
