:root {
  --fondo: #ffffff;
  --carta: #ffffff;
  --inchiostro: #0a0a0a;
  --grigio: #71717a;
  --grigio-chiaro: #a1a1aa;
  --morbido: #f4f4f5;
  --linea: rgba(10, 10, 10, 0.08);
  --accento: #ff6a2b;
  --quadrante: min(232px, 64vw, 40vh);
}

* { 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;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

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

.card {
  position: relative;
  width: min(320px, calc(100vw - 32px));
  background: var(--carta);
  border: 1px solid var(--linea);
  border-radius: 22px;
  padding: clamp(12px, 3.6vh, 18px) 18px clamp(12px, 3.6vh, 18px);
  box-shadow: 0 1px 2px rgba(10, 10, 10, 0.04), 0 18px 40px -18px rgba(10, 10, 10, 0.22);
  display: grid;
  justify-items: center;
}

.top { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.brand__mark { width: 18px; height: 18px; fill: none; stroke: var(--accento); stroke-width: 1.8; stroke-linecap: round; }

.ampm {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--morbido);
  border-radius: 999px;
  padding: 3px;
}
.ampm__pill {
  position: absolute; left: 3px; top: 3px; bottom: 3px;
  width: calc(50% - 3px);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(10, 10, 10, 0.12), 0 0 0 0.5px rgba(10, 10, 10, 0.06);
}
.ampm__opt {
  position: relative;
  min-width: 38px; height: 24px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--grigio);
  transition: color 0.25s;
}
.ampm__opt[aria-checked="true"] { color: var(--inchiostro); }

.time {
  display: flex; align-items: center;
  margin-top: clamp(4px, 1.6vh, 10px);
  font-size: clamp(34px, 9.6vh, 46px);
  font-weight: 640;
  font-variation-settings: "wdth" 92;
  letter-spacing: -0.03em;
  line-height: 1;
}
.time__part {
  display: flex;
  border-radius: 10px;
  padding: 2px 3px;
  color: var(--grigio-chiaro);
  transition: color 0.3s, background-color 0.3s;
}
.time__part[data-active] { color: var(--inchiostro); }
.time__colon { color: var(--grigio-chiaro); padding: 0 1px; transform: translateY(-0.06em); }
.digit {
  display: block;
  height: 1.2em;
  overflow: hidden;
  width: 0.6em;
  -webkit-mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent);
}
.digit__roll { display: flex; flex-direction: column; text-align: center; }
.digit__roll span { display: block; height: 1.2em; line-height: 1.2em; }

.sub {
  height: 16px; overflow: hidden;
  margin-top: 4px;
  font-size: 12px; color: var(--grigio);
  white-space: nowrap;
}
.sub__line { display: block; line-height: 16px; }

.dial {
  position: relative;
  width: var(--quadrante); height: var(--quadrante);
  margin-top: clamp(6px, 2vh, 14px);
}
.dial__svg { width: 100%; height: 100%; overflow: visible; display: block; }
.dial__face { fill: var(--morbido); }
.tick { stroke: rgba(10, 10, 10, 0.22); stroke-width: 1; stroke-linecap: round; }
.tick--major { stroke: rgba(10, 10, 10, 0.4); stroke-width: 1.4; }
.dial__labels text {
  font-size: 12.5px; font-weight: 560;
  fill: var(--inchiostro);
  text-anchor: middle; dominant-baseline: central;
}
.hand__line { stroke: var(--accento); stroke-width: 1.6; stroke-linecap: round; }
.hand__pivot { fill: var(--accento); }
.knob { fill: var(--accento); }
.knob__ring { fill: none; stroke: var(--accento); stroke-width: 1; opacity: 0; }
.knob-text {
  font-size: 12.5px; font-weight: 640;
  fill: #fff;
  text-anchor: middle; dominant-baseline: central;
}
.dial__hit {
  position: absolute; inset: 0;
  border-radius: 50%;
  touch-action: none;
  cursor: grab;
  outline: none;
}
.dial__hit:active { cursor: grabbing; }
.dial__hit:focus-visible { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accento); }

.set {
  position: relative;
  width: 100%;
  height: 42px;
  margin-top: clamp(8px, 2.4vh, 16px);
  border-radius: 12px;
  background: var(--inchiostro);
  color: #fff;
  font-size: 14px; font-weight: 600;
  overflow: hidden;
}
.set__label, .set__done {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.set__done { opacity: 0; }
.set__done svg { width: 18px; height: 18px; fill: none; stroke: var(--accento); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.set:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

@media (hover: hover) {
  .time__part:hover { background: var(--morbido); }
  .ampm__opt:hover { color: var(--inchiostro); }
}

/* the drawn pointer of the autopilot */
.ghost {
  position: absolute; left: 0; top: 0;
  width: 22px; height: 22px;
  fill: var(--inchiostro);
  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: 10;
}
