/* RESET */
* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 20% 10%, #f2f6ff 0%, #ffffff 45%, #f7f7fb 100%);
  color: #111;
}

/* APP: niente centro verticale -> così il testo lungo non "taglia" */
.app {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 22px;
}

/* CARD: max-height + scroll interno */
.card {
  width: min(720px, 92vw);
  max-height: calc(100vh - 44px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  background: rgba(255,255,255,0.75);
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: 18px;
  padding: 18px 18px 20px;

  box-shadow:
    0 10px 30px rgba(0,0,0,0.08),
    inset 0 1px 0 rgba(255,255,255,0.7);
  backdrop-filter: blur(8px);
}

/* TOP */
.top {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 999px; background: #111; }
.title { font-weight: 700; letter-spacing: 0.2px; }

/* HUD */
.hud { text-align: right; min-width: 240px; }
.hud-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.small { font-size: 12px; opacity: 0.72; }

.dev-btn {
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px dashed rgba(0,0,0,0.25);
  background: rgba(255,255,255,0.75);
  cursor: pointer;
}
.dev-btn:hover { border-color: rgba(0,0,0,0.45); }

/* PROGRESS */
.progress-wrap {
  width: 240px;
  height: 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.08);
  overflow: hidden;
  margin-top: 6px;
}
#progress-bar {
  height: 100%;
  width: 0%;
  background: #111;
  transition: width 220ms ease;
}

/* QUIZ */
#question { margin: 10px 0 14px; line-height: 1.2; font-size: 22px; }

.btn-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 12px 0;
}

/* BUTTONS */
button {
  appearance: none;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.9);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

button:hover { border-color: rgba(0,0,0,0.22); transform: translateY(-1px); }
button:active { transform: translateY(0) scale(0.99); }

button.primary { background: #111; color: #fff; border-color: #111; }
button.correct { background: rgba(22,163,74,0.12); border-color: rgba(22,163,74,0.65); }
button.wrong { background: rgba(220,38,38,0.10); border-color: rgba(220,38,38,0.65); }

/* INPUT */
#input-container { margin: 10px 0 12px; }
.input-row { display: flex; gap: 10px; align-items: center; }

#text-answer {
  flex: 1;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.12);
  padding: 12px 14px;
  font-size: 15px;
  background: rgba(255,255,255,0.9);
}

#text-answer:focus {
  outline: none;
  border-color: rgba(0,0,0,0.28);
  box-shadow: 0 0 0 4px rgba(0,0,0,0.06);
}

#text-answer.correct {
  border-color: rgba(22,163,74,0.65);
  box-shadow: 0 0 0 4px rgba(22,163,74,0.12);
  background: rgba(22,163,74,0.06);
}

#text-answer.wrong {
  border-color: rgba(220,38,38,0.65);
  box-shadow: 0 0 0 4px rgba(220,38,38,0.10);
  background: rgba(220,38,38,0.05);
}

.message { min-height: 22px; margin: 6px 0 0; font-weight: 650; }
.hint { margin-top: 6px; }

.hide { display: none; }

/* SHAKE */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.shake { animation: shake 280ms ease; }

/* ===== FINALE ===== */
.final { text-align: center; padding-top: 10px; }
.final-inner { display: grid; gap: 16px; justify-items: center; }

.final-text { font-weight: 750; font-size: 20px; letter-spacing: 0.2px; }
.final-text.big { font-size: 24px; }

.final-svg { width: min(640px, 92vw); height: auto; color: #111; }

/* draw animation */
.draw {
  stroke-dasharray: 1400;
  stroke-dashoffset: 1400;
  animation: drawLine 4s ease forwards;
}
@keyframes drawLine { to { stroke-dashoffset: 0; } }

/* STEP 3 (testo) */
.text-screen { width: 100%; }
.center-text { text-align: center; }

.final-letter {
  width: min(640px, 92vw);
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

.final-letter p {
  margin: 0;
  line-height: 1.6;
  font-size: 15px;
}

/* testo lungo: scroll DENTRO step 3 */
#final-step-3 .final-letter {
  max-height: 55vh;
  overflow-y: auto;
  padding: 6px 8px;
  -webkit-overflow-scrolling: touch;
}

.divider { opacity: 0.7; font-weight: 700; letter-spacing: 1px; }
.lyrics { font-style: italic; opacity: 0.9; }

/* bottone sempre raggiungibile */
#final-step-3 #restart {
  position: sticky;
  bottom: 12px;
  margin-top: 10px;
}

#dev-skip { display: none !important; }