:root {
  --fondo: #08080b;
  --card: #111218;
  --inchiostro: #ececf3;
  --grigio: #8a8b98;
  --grigio-scuro: #4a4b57;
  --linea: rgba(255, 255, 255, 0.07);
  --accento: #8f91ff;
  --awake: #e2e2ff;
  --rem: #b3b4ff;
  --light: #8486f2;
  --deep: #5457d9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
  background: radial-gradient(120% 80% at 50% 0%, #11121a 0%, var(--fondo) 60%);
}

.sleep {
  width: min(400px, 94vw);
  padding: 16px 16px 14px;
  border-radius: 20px;
  background: linear-gradient(180deg, #14151c, var(--card));
  border: 1px solid var(--linea);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 24px 60px -24px rgba(0, 0, 0, 0.8);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.sleep__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sleep__title { display: flex; align-items: center; gap: 10px; }
.sleep__mark { width: 30px; height: 30px; padding: 6px; border-radius: 9px; background: rgba(143, 145, 255, 0.12); fill: var(--accento); }
.sleep__brand { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.sleep__night { font-size: 11.5px; color: var(--grigio); margin-top: 1px; }

.score { position: relative; width: 48px; height: 48px; flex: none; }
.score__ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.score__track { fill: none; stroke: rgba(255, 255, 255, 0.07); stroke-width: 4; }
.score__fill { fill: none; stroke: var(--accento); stroke-width: 4; stroke-linecap: round; }
.score__num {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 700;
  font-variation-settings: "wdth" 90;
}

.chart { position: relative; margin-top: 12px; cursor: ew-resize; }
.chart__svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart__rows line { stroke: var(--linea); stroke-width: 1; }
.chart__rows text { fill: var(--grigio); font-size: 8.6px; font-weight: 550; transition: fill 0.25s; }
.chart__rows text.is-on { fill: var(--inchiostro); }
.chart__links line { stroke: rgba(255, 255, 255, 0.16); stroke-width: 1; }
.chart__steps rect { transform-box: fill-box; transform-origin: left center; }
.chart__axis text { fill: var(--grigio-scuro); font-size: 7.6px; font-weight: 550; text-anchor: middle; }
.chart__cursor { stroke: var(--inchiostro); stroke-width: 1; stroke-dasharray: 2 2.5; opacity: 0; }
.chart__knob { fill: var(--card); stroke: var(--inchiostro); stroke-width: 1.6; opacity: 0; }

.tip {
  position: absolute; top: -6px; left: 0;
  display: flex; align-items: baseline; gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--inchiostro);
  color: #111218;
  font-size: 11px; font-weight: 650;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.7);
}
.tip__phase { font-weight: 550; color: #4a4b57; }

.chart__hint {
  position: absolute; right: 0; top: -2px;
  font-size: 10.5px; color: var(--grigio);
  pointer-events: none;
}

.phases { list-style: none; margin-top: 12px; display: grid; gap: 7px; }
.phase {
  display: grid;
  grid-template-columns: 52px 1fr 56px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--grigio);
  transition: color 0.25s;
}
.phase__name { font-weight: 600; }
.phase__bar { position: relative; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.phase__bar i { position: absolute; inset: 0; border-radius: 4px; background: var(--c); transform-origin: left center; }
.phase__time { text-align: right; font-weight: 600; color: var(--inchiostro); font-variation-settings: "wdth" 92; }
.phase.is-on { color: var(--inchiostro); }

.sleep__foot {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--linea);
  font-size: 12px; color: var(--grigio);
}
.sleep__foot strong { color: var(--inchiostro); font-size: 13px; font-weight: 650; }

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

@media (max-width: 380px) {
  .sleep { padding: 13px 12px 11px; }
  .phases { gap: 5px; }
  .phase { grid-template-columns: 46px 1fr 52px; font-size: 11px; }
}

@media (max-height: 460px) {
  .phases { margin-top: 8px; gap: 4px; }
  .sleep__foot { margin-top: 8px; padding-top: 7px; }
  .chart { margin-top: 8px; }
}
