:root {
  --fondo: #f5f2ec;
  --carta: #ffffff;
  --inchiostro: #1d2433;
  --testo: #1b1b1f;
  --grigio: #8a8781;
  --riga: #ebe7df;
  --linea: #dcd7cc;
  --accento: #2f55e4;
  --accento-chiaro: #e7ecfd;
  --ombra: 0 1px 2px rgba(30, 26, 20, 0.06), 0 14px 34px -14px rgba(30, 26, 20, 0.22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--fondo);
  color: var(--testo);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.stage { position: relative; width: 100%; height: 100vh; overflow: hidden; }

/* the whole piece is drawn in its own pixels and the wrapper scales it to the box, height included */
.fit {
  position: absolute; left: 50%; top: 50%;
  width: 400px; height: 488px;
  padding: 0 14px 0 30px;
  transform-origin: 50% 50%;
}

.top { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 2px 0 4px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; font-variation-settings: "wdth" 96; }
.brand__mark {
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  background: var(--inchiostro); color: #fff; font-size: 12px; font-weight: 700;
}
.count { font-size: 12px; color: var(--grigio); display: flex; align-items: center; gap: 4px; }
.count__win { display: inline-block; height: 16px; overflow: hidden; position: relative; min-width: 8px; }
.count__num { display: block; line-height: 16px; color: var(--testo); font-weight: 650; }

.paper {
  position: relative;
  background: var(--carta);
  border-radius: 14px;
  box-shadow: var(--ombra);
  padding: 22px 22px 18px;
  height: 376px;
}
.paper__title { font-size: 19px; font-weight: 680; letter-spacing: -0.01em; font-variation-settings: "wdth" 94; }
.paper__meta { margin-top: 4px; font-size: 12px; color: var(--grigio); }
.paper__meta span { color: var(--testo); font-weight: 560; }

.lines { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.lines span { display: block; height: 6px; border-radius: 3px; background: var(--riga); }
.lines--short { flex: 1; margin-top: 0; }

.clause { display: flex; align-items: flex-start; gap: 14px; margin-top: 16px; }

.field { position: relative; text-align: left; border-radius: 8px; }
.field__label { display: block; font-size: 10.5px; color: var(--grigio); letter-spacing: 0.01em; }

.field--initials {
  flex: 0 0 74px; height: 56px;
  border: 1px dashed var(--linea);
  padding: 4px 6px;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: border-color 0.25s, background-color 0.25s;
}
.field--initials.is-on { border-color: var(--accento); background: var(--accento-chiaro); }
.field--initials.is-done { border-style: solid; border-color: var(--linea); background: transparent; }
.ink--initials { position: absolute; left: 16px; top: 15px; width: 44px; height: 33px; }

.signrow { display: flex; align-items: flex-end; gap: 16px; margin-top: 22px; }
.field--sign { flex: 1 1 auto; height: 92px; padding-top: 2px; }
.field--date { flex: 0 0 96px; height: 92px; display: flex; flex-direction: column; justify-content: flex-end; }
.ink--sign { position: absolute; left: -2px; bottom: 19px; width: 196px; height: 52px; overflow: visible; }

.field__rule {
  position: absolute; left: 0; right: 0; bottom: 16px; height: 1px; background: var(--linea);
}
.field--sign .field__label, .field--date .field__label { position: absolute; left: 0; bottom: 0; }
.field__glow {
  position: absolute; inset: -1px 0 0 0; height: 2px; background: var(--accento);
  transform: scaleX(0); transform-origin: 0 50%; border-radius: 2px;
}

.date {
  position: absolute; left: 0; bottom: 21px;
  font-size: 13px; font-weight: 520; color: var(--inchiostro); white-space: pre;
  font-variation-settings: "wdth" 92;
}
.caret {
  position: absolute; bottom: 21px; left: 0; width: 1.5px; height: 15px; background: var(--accento); opacity: 0;
}

.ink path {
  fill: none; stroke: var(--inchiostro); stroke-linecap: round; stroke-linejoin: round;
}
.ink--sign path { stroke-width: 2.4; }
.ink--sign path.dot { stroke-width: 4.8; }
.ink--initials path { stroke-width: 1.9; }
.ink circle { fill: var(--inchiostro); }

.pen {
  position: absolute; left: 0; top: 0; width: 30px; height: 30px; pointer-events: none;
  opacity: 0; filter: drop-shadow(0 4px 4px rgba(20, 24, 40, 0.22));
}
.pen__body { fill: var(--inchiostro); }
.pen__nib { fill: #c9a24a; }
.pen__shine { stroke: rgba(255, 255, 255, 0.35); stroke-width: 1.2; stroke-linecap: round; fill: none; }

.flag {
  position: absolute; left: 0; top: 0;
  height: 26px; padding: 0 7px 0 10px; border-radius: 0 13px 13px 0;
  display: flex; align-items: center; gap: 2px;
  background: var(--accento); color: #fff; font-size: 11.5px; font-weight: 640;
  box-shadow: 0 6px 14px -6px rgba(47, 85, 228, 0.6);
  font-variation-settings: "wdth" 100;
}
.flag svg { width: 12px; height: 12px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.foot { display: flex; align-items: center; justify-content: space-between; height: 72px; padding: 0 2px; }
.finish {
  position: relative; overflow: hidden;
  height: 42px; min-width: 176px; padding: 0 20px; border-radius: 21px;
  background: #d9d5cd; color: #fff; font-size: 14px; font-weight: 620;
  transition: background-color 0.3s;
}
.finish:not([disabled]) { background: var(--inchiostro); }
.finish[disabled] { cursor: default; }
.finish__fill { position: absolute; inset: 0; background: var(--accento); transform: scaleX(0); transform-origin: 0 50%; }
.finish__a, .finish__b { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; }
.finish__b { position: absolute; inset: 0; opacity: 0; }
.finish__b svg { width: 15px; height: 15px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.replay {
  display: flex; align-items: center; gap: 5px; height: 30px; padding: 0 12px; border-radius: 15px;
  font-size: 12px; color: var(--grigio); background: rgba(255, 255, 255, 0.6); border: 1px solid var(--linea);
  opacity: 0; pointer-events: none;
}
.replay.is-on { pointer-events: auto; }
.replay svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

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

@media (hover: hover) {
  .field--initials:not(.is-done):hover { border-color: var(--accento); }
  .replay:hover { color: var(--testo); }
}
