:root {
  --fondo: #ffffff;
  --carta: #ffffff;
  --inchiostro: #111114;
  --grigio: #6b6b76;
  --grigio-chiaro: #9a9aa4;
  --bordo: rgba(17, 17, 20, 0.08);
  --giorno: #f3f2ee;
  --lavoro: #e4e1fb;
  --notte: #22222b;
  --accento: #4f46e5;
  --accento-tenue: rgba(79, 70, 229, 0.12);
  --ombra: 0 24px 60px -24px rgba(17, 17, 20, 0.22), 0 2px 6px rgba(17, 17, 20, 0.05);
  --riga: clamp(36px, 7.4vh, 50px);
}

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

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: min(4vh, 28px) min(4vw, 28px);
  overflow: hidden;
}

.card {
  width: min(760px, 100%);
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: clamp(16px, 2.4vw, 22px);
  box-shadow: var(--ombra);
  padding: clamp(14px, 3vh, 26px) clamp(14px, 3vw, 28px);
  display: grid;
  gap: clamp(10px, 2.4vh, 20px);
}

.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.head__brand { font-size: 12px; font-weight: 600; color: var(--accento); letter-spacing: 0.01em; }
.head__title { font-size: clamp(17px, 2.8vw, 22px); font-weight: 650; letter-spacing: -0.01em; margin-top: 2px; }
.head__sub { font-size: 12.5px; color: var(--grigio); margin-top: 2px; }
.head__now { display: grid; justify-items: end; gap: 2px; }
.head__label { font-size: 11px; color: var(--grigio-chiaro); }

.clock { display: inline-flex; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; line-height: 1; height: 1em; overflow: hidden; }
.clock--big { font-size: clamp(20px, 3.4vw, 28px); font-weight: 600; letter-spacing: -0.01em; }
.clock__col { display: block; height: 1em; overflow: hidden; }
.clock__reel { display: flex; flex-direction: column; will-change: transform; }
.clock__reel span, .clock__sep { display: block; height: 1em; line-height: 1em; text-align: center; }
.clock__sep { width: 0.32em; }

.board {
  display: grid;
  grid-template-columns: minmax(0, clamp(150px, 34%, 250px)) minmax(0, 1fr);
  column-gap: clamp(10px, 2vw, 18px);
}

.people { list-style: none; display: grid; grid-auto-rows: var(--riga); padding-top: 18px; }

.person { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; border-top: 1px solid var(--bordo); }
.person:first-child { border-top: 0; }
.person__face {
  width: clamp(24px, 4vh, 30px); height: clamp(24px, 4vh, 30px); border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 650; color: #fff; letter-spacing: 0.02em;
}
.person__who { min-width: 0; }
.person__name { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person__city { display: block; margin-top: 1px; font-size: 11.5px; color: var(--grigio); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person__time { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.person__sky { position: relative; width: 15px; height: 15px; flex: none; }
.person__sky svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: var(--grigio); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.tracks { position: relative; padding-top: 18px; padding-bottom: 14px; touch-action: none; cursor: ew-resize; user-select: none; }

.ticks { position: absolute; left: 0; right: 0; top: 0; height: 14px; }
.ticks span { position: absolute; left: calc(var(--at) / 24 * 100%); transform: translateX(-50%); font-size: 10px; color: var(--grigio-chiaro); font-variant-numeric: tabular-nums; }
.ticks span:first-child { transform: none; }
.ticks span:last-child { transform: translateX(-100%); }

.lanes { display: grid; grid-auto-rows: var(--riga); }
.lane { display: flex; align-items: center; border-top: 1px solid var(--bordo); }
.lane:first-child { border-top: 0; }
.lane__band { display: flex; width: 100%; height: 46%; border-radius: 7px; overflow: hidden; gap: 1px; }
.lane__cell { flex: 1; background: var(--giorno); transition: opacity 0.3s; }
.lane__cell.is-work { background: var(--lavoro); }
.lane__cell.is-night { background: var(--notte); }

.best {
  position: absolute; top: 18px; bottom: 14px;
  left: calc(var(--from) / 24 * 100%); width: calc(var(--len) / 24 * 100%);
  border-radius: 10px;
  border: 1.5px dashed rgba(79, 70, 229, 0.35);
  background: transparent;
  pointer-events: none;
}
.best__label {
  position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%);
  white-space: nowrap; font-size: 10.5px; font-weight: 600; color: var(--accento);
  background: #fff; padding: 2px 7px; border-radius: 999px; border: 1px solid rgba(79, 70, 229, 0.25);
  opacity: 0;
}

.now { position: absolute; top: 14px; bottom: 6px; left: calc(var(--h, 9) / 24 * 100%); width: 0; outline: none; }
.now__line { position: absolute; top: 0; bottom: 4px; left: -1px; width: 2px; border-radius: 2px; background: var(--inchiostro); }
.now__handle {
  position: absolute; bottom: -9px; left: -13px; width: 26px; height: 18px; border-radius: 999px;
  background: var(--inchiostro); display: grid; place-items: center;
  box-shadow: 0 4px 12px -4px rgba(17, 17, 20, 0.5);
}
.now__grip { width: 10px; height: 6px; border-left: 1.5px solid rgba(255,255,255,0.7); border-right: 1.5px solid rgba(255,255,255,0.7); }
.now:focus-visible .now__handle { outline: 2px solid var(--accento); outline-offset: 2px; }

.foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.foot__hint { font-size: 12.5px; color: var(--grigio); min-width: 0; }
.foot__btn {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--bordo);
  background: #f1f1f3; color: var(--grigio-chiaro); cursor: not-allowed;
}
.foot__btn:not(:disabled) { cursor: pointer; }
.foot__icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.foot__icon--done { display: none; }
.foot__btn.is-done .foot__icon--cal { display: none; }
.foot__btn.is-done .foot__icon--done { display: block; }

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

@media (max-width: 560px) {
  .board { grid-template-columns: minmax(0, 46%) minmax(0, 1fr); }
  .person { gap: 7px; }
  .person__city { display: none; }
  .person__last { display: none; }
  .person__name { font-size: 12px; }
  .person__time { font-size: 12px; gap: 4px; }
  .person__sky { width: 13px; height: 13px; }
  .foot { flex-direction: column; align-items: stretch; gap: 8px; }
  .foot__hint { font-size: 11.5px; text-align: center; }
  .foot__btn { justify-content: center; padding: 9px 14px; font-size: 13px; }
  .head__sub { font-size: 11.5px; }
}

@media (max-height: 460px) {
  .head__sub { display: none; }
  .foot__hint { display: none; }
  .card { gap: 8px; }
}
