/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --brand-blue: #003082;
  --brand-light: #0052cc;
  --accent: #c0392b;
  --accent-dark: #a93226;
  --bg: #f5f0e6;
  --bg-warm: #ebe5d6;
  --paper: #fefcf5;
  --paper-shadow: #e8e4d4;
  --text: #1a1a1a;
  --text-light: #555;
  --text-muted: #999;
  --border: #1a1a1a;
  --border-light: #ccc;
  --red: #c0392b;
  --green: #27ae60;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { height: 100%; }

body {
  font-family: 'Courier Prime', 'Courier New', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: 'Courier Prime', 'Courier New', monospace;
  -webkit-tap-highlight-color: transparent;
}

/* ===== STEPS SYSTEM ===== */
.step {
  display: none;
  position: relative;
  min-height: 100dvh;
  flex-direction: column;
}

.step-active {
  display: flex;
}

.step-bg {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 0;
}

.step-content {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1.25rem;
  padding-bottom: 100px; /* space for bottom bar */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== STEP HEADER ===== */
.step-header {
  text-align: center;
  margin-bottom: 1.5rem;
}


h1 {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: clamp(1.6rem, 5.5vw, 3rem);
  letter-spacing: 2px;
  color: var(--text);
  margin-bottom: 0.4rem;
  line-height: 1.1;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-light);
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.disclaimer {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ===== BOTTOM BAR (fixed) ===== */
.step-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  padding: 0.75rem 1.25rem calc(0.75rem + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.step-dots {
  display: flex;
  gap: 6px;
}

.step-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-light);
  transition: all 0.3s;
}

.step-dots .dot.active {
  background: var(--accent);
  width: 24px;
  border-radius: 4px;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 400px;
  padding: 16px 32px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: 'Courier Prime', monospace;
  letter-spacing: 2px;
  color: #fff;
  background: var(--accent);
  border: 2px solid var(--accent-dark);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.btn-primary:active {
  background: var(--accent-dark);
  transform: scale(0.97);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-arrow {
  font-size: 1.2rem;
  transition: transform 0.2s;
}

.btn-primary:active .btn-arrow {
  transform: translateX(3px);
}

.btn-genera {
  gap: 10px;
}

.btn-icon {
  font-size: 1.2rem;
}

/* ===== QUADRATO SEMIOTICO ===== */
.quadrato-section {
  width: 100%;
  max-width: 420px;
}

.section-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  text-align: center;
}

.quadrato-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 28px;
}

/* Axis labels */
.quadrato-axis-label {
  position: absolute;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
}

.quadrato-axis-label.top { top: 6px; left: 50%; transform: translateX(-50%); }
.quadrato-axis-label.bottom { bottom: 6px; left: 50%; transform: translateX(-50%); }
.quadrato-axis-label.left { left: -4px; top: 50%; transform: translateY(-50%) rotate(-90deg); }
.quadrato-axis-label.right { right: -4px; top: 50%; transform: translateY(-50%) rotate(90deg); }

/* Quadrant buttons (tappable) */
.quadrato-quadrant {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  z-index: 3;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.2s;
  min-width: 44px;
  min-height: 44px;
}

.quadrato-quadrant:active {
  transform: scale(1.05);
}

.q-emoji {
  font-size: 1.6rem;
  filter: grayscale(0.3);
  transition: all 0.3s;
}

.q-name {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
  transition: all 0.3s;
}

.q-tl { top: 30px; left: 30px; }
.q-tr { top: 30px; right: 30px; }
.q-bl { bottom: 30px; left: 30px; }
.q-br { bottom: 30px; right: 30px; }

/* Interactive area */
.quadrato-area {
  position: absolute;
  inset: 28px;
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: 2px;
  cursor: crosshair;
  overflow: hidden;
  z-index: 2;
  touch-action: none;
}

.quadrato-crosshair-h,
.quadrato-crosshair-v {
  position: absolute;
  background: var(--border-light);
  pointer-events: none;
}

.quadrato-crosshair-h { top: 50%; left: 0; right: 0; height: 1px; }
.quadrato-crosshair-v { left: 50%; top: 0; bottom: 0; width: 1px; }

/* Draggable dot — 44px touch target */
.quadrato-dot {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  left: 50%;
  top: 50%;
  cursor: grab;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quadrato-dot::after {
  content: '';
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--paper);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: all 0.2s;
}

.quadrato-dot:active {
  cursor: grabbing;
}

.quadrato-dot:active::after {
  width: 24px;
  height: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.dot-pulse {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: pulse 2.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0; }
  50% { transform: scale(1.5); opacity: 0.2; }
}

/* Active quadrant highlight */
.quadrato-wrapper[data-active-q="tl"] .q-tl .q-name,
.quadrato-wrapper[data-active-q="tr"] .q-tr .q-name,
.quadrato-wrapper[data-active-q="bl"] .q-bl .q-name,
.quadrato-wrapper[data-active-q="br"] .q-br .q-name {
  color: var(--accent);
}

.quadrato-wrapper[data-active-q="tl"] .q-tl .q-emoji,
.quadrato-wrapper[data-active-q="tr"] .q-tr .q-emoji,
.quadrato-wrapper[data-active-q="bl"] .q-bl .q-emoji,
.quadrato-wrapper[data-active-q="br"] .q-br .q-emoji {
  filter: grayscale(0);
  transform: scale(1.15);
}

.quadrato-result {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 0.5rem;
  min-height: 1.5em;
  transition: color 0.3s;
}

/* ===== STEP 2 ===== */
.btn-back-top {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 0.5rem;
  font-family: 'Courier Prime', monospace;
}

.btn-back-top:active { color: var(--text); }

.step2-title {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 1.5rem;
  text-align: center;
}

/* Anno picker */
.anno-picker {
  width: 100%;
  max-width: 400px;
  margin-bottom: 1.5rem;
}

.picker-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 0.6rem;
  text-align: center;
}

.anno-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 0.75rem;
}

.stepper-btn {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  border: 2px solid var(--border);
  background: var(--paper);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.stepper-btn:active {
  background: var(--text);
  color: var(--paper);
  transform: scale(0.95);
}

.anno-stepper input {
  width: 120px;
  text-align: center;
  font-size: 2.2rem;
  font-weight: 700;
  font-family: 'Playfair Display', serif;
  letter-spacing: 3px;
  background: none;
  border: none;
  color: var(--text);
  padding: 8px;
  -moz-appearance: textfield;
}

.anno-stepper input::-webkit-outer-spin-button,
.anno-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.anno-stepper input:focus {
  outline: none;
}

.anno-presets {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-pill {
  padding: 6px 12px;
  border-radius: 2px;
  border: 1.5px solid var(--border);
  background: var(--paper);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Courier Prime', monospace;
}

.preset-pill:active { transform: scale(0.95); }

.preset-pill.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--paper);
}

/* Serata picker */
.serata-picker {
  width: 100%;
  max-width: 400px;
  margin-bottom: 1.5rem;
}

.serata-pills {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.serata-pill {
  flex: 1;
  max-width: 72px;
  padding: 12px 4px;
  border-radius: 2px;
  border: 1.5px solid var(--border);
  background: var(--paper);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  font-family: 'Courier Prime', monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.serata-pill:active { transform: scale(0.95); }

.serata-pill.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--paper);
}

.pill-sub {
  display: block;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  opacity: 0.7;
}

/* Extra details */
.extra-details {
  width: 100%;
  max-width: 400px;
  margin-bottom: 0.5rem;
  border: 1.5px solid var(--border-light);
  border-radius: 2px;
  overflow: hidden;
}

.extra-details summary {
  padding: 14px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
  list-style: none;
  text-align: center;
}

.extra-details summary::-webkit-details-marker { display: none; }
.extra-details summary::before { content: '+ '; color: var(--accent); }
.extra-details[open] summary::before { content: '- '; }
.extra-details summary:active { background: var(--bg-warm); }

.details-content {
  padding: 0 16px 16px;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 0.4rem;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: 'Courier Prime', monospace;
  background: var(--paper);
  border: 1.5px solid var(--border-light);
  border-radius: 2px;
  color: var(--text);
  transition: all 0.2s;
}

.form-group input::placeholder { color: var(--text-muted); }

.form-group input:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: none;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(245, 240, 230, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-overlay.hidden { display: none; }

.loading-inner {
  text-align: center;
  padding: 2rem;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 1.25rem;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 0.95rem;
  color: var(--text-light);
  font-style: italic;
}

/* ===== OUTPUT ===== */
#output {
  min-height: auto;
  padding-top: 56px; /* topbar height */
}

#output.step-active {
  display: block;
}

/* Sticky top bar */
.output-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: 56px;
  background: var(--paper);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.topbar-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  padding: 10px 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-family: 'Courier Prime', monospace;
}

.topbar-btn:active { opacity: 0.6; }

.topbar-title {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 1px;
  color: var(--text);
  text-align: center;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== SCALETTA DOCUMENT — Photocopy style ===== */

/* Viewport wrapper — scales the fixed-width doc to fit screen */
.scaletta-viewport {
  overflow: hidden;
  padding: 1rem 0.75rem;
}

.scaletta-doc {
  width: 780px;
  position: relative;
  background: var(--paper);
  color: var(--text);
  font-family: 'Courier Prime', 'Courier New', monospace;
  padding: 2rem 2.5rem;
  transform-origin: top left;
  /* Photocopy effect */
  box-shadow:
    0 1px 3px rgba(0,0,0,0.1),
    0 8px 30px rgba(0,0,0,0.12),
    inset 0 0 80px rgba(0,0,0,0.04);
  filter: contrast(1.05) brightness(0.98);
}

/* Grain / noise overlay */
.scaletta-doc::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: multiply;
}

/* Faded edges / vignette */
.scaletta-doc::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.06) 100%);
  pointer-events: none;
  z-index: 1;
}

/* Stripe at top */
.scaletta-doc > .doc-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-light), var(--brand-blue));
}

/* Document header */
.doc-header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-top: 0.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid #333;
  position: relative;
}

.doc-watermark {
  font-size: 0.75rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--red);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.doc-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.doc-subtitle {
  font-size: 0.85rem;
  color: var(--text-light);
}

.doc-meta {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-light);
}

.doc-quadrant-badge {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 3px 14px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px solid #999;
  border-radius: 20px;
  color: var(--text-light);
  font-family: 'Inter', sans-serif;
}

/* ===== Grid blocks (4-column table) ===== */
.blocco {
  display: grid;
  grid-template-columns: 55px 1fr 100px 38px;
  border: 1px solid #999;
  border-bottom: none;
  font-size: 0.82rem;
  color: var(--text);
  background: transparent;
}

.blocco:last-of-type {
  border-bottom: 1px solid #999;
}

.blocco-ora {
  grid-column: 1;
  padding: 6px 4px;
  font-weight: 700;
  border-right: 1px solid #bbb;
  text-align: center;
  font-size: 0.75rem;
}

.blocco-num {
  font-size: 1.3rem;
  font-weight: 700;
  display: block;
  line-height: 1;
}

.blocco-content {
  grid-column: 2;
  padding: 6px 10px;
}

.blocco-tech {
  grid-column: 3;
  padding: 6px 4px;
  border-left: 1px solid #bbb;
  font-size: 0.7rem;
  color: var(--text-light);
  text-align: center;
  white-space: pre-line;
}

.blocco-dur {
  grid-column: 4;
  padding: 6px 4px;
  border-left: 1px solid #bbb;
  font-weight: 700;
  text-align: center;
  font-size: 0.8rem;
}

/* Content elements */
.artista-nome {
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  margin: 4px 0 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.canzone-titolo {
  text-align: center;
  font-style: italic;
  margin-bottom: 2px;
}

.canzone-durata {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-light);
}

.sezione-titolo {
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  border: 2px solid #333;
  display: inline-block;
  padding: 1px 12px;
  margin: 2px auto;
  background: #e8e4d4;
}

.sezione-wrapper { text-align: center; }

.sfida-vs {
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  margin: 4px 0;
}

.grafica-box {
  display: inline-block;
  border: 1px solid #666;
  padding: 1px 8px;
  font-size: 0.75rem;
  background: #ece8d8;
  margin: 2px 0;
}

.pubblicita {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  padding: 16px 0;
  letter-spacing: 4px;
}

.lista-big {
  margin: 6px 0;
  padding-left: 0;
}

.lista-big li {
  margin: 2px 0;
  list-style: none;
  font-size: 0.8rem;
}

.lista-big li::before {
  content: attr(data-code) " – ";
  font-weight: 700;
}

.bold { font-weight: 700; }
.center { text-align: center; }
.small { font-size: 0.78rem; }
.muted { color: var(--text-light); }
.italic { font-style: italic; }
.mt { margin-top: 5px; }
.mb { margin-bottom: 5px; }

.regolamento {
  font-size: 0.78rem;
  margin: 6px 0;
  padding-left: 16px;
}

.regolamento li { margin: 2px 0; }

.fine-blocco {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 3px;
}

.nota-stage {
  font-size: 0.78rem;
  font-style: italic;
  text-align: center;
  color: var(--text-light);
}

/* Output bottom actions */
.output-bottom {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem 1rem;
  flex-wrap: wrap;
}

.btn-secondary {
  padding: 12px 20px;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: 'Courier Prime', monospace;
  background: var(--paper);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
}

.btn-secondary:active {
  background: var(--text);
  color: var(--paper);
}

/* Floating share FAB */
.share-fab {
  position: fixed;
  bottom: calc(1.25rem + var(--safe-bottom));
  right: 1.25rem;
  z-index: 55;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 2px solid var(--accent-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: all 0.2s;
}

.share-fab:active {
  transform: scale(0.92);
  background: var(--accent-dark);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: calc(5rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--paper);
  padding: 12px 24px;
  border-radius: 2px;
  font-weight: 700;
  font-size: 0.85rem;
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.footer-brand {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-light);
}

.footer-brand a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.footer-brand a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}

.step-active .step-content {
  animation: fadeIn 0.35s ease;
}

/* ===== DESKTOP ENHANCEMENTS ===== */
@media (min-width: 640px) {
  .step-content {
    justify-content: center;
    padding: 2rem 2rem 120px;
  }

  .step-header {
    margin-bottom: 2rem;
  }

  h1 {
    font-size: 3rem;
    letter-spacing: 3px;
  }

  .quadrato-wrapper {
    max-width: 420px;
    padding: 36px;
  }

  .quadrato-area { inset: 36px; }
  .q-tl { top: 38px; left: 38px; }
  .q-tr { top: 38px; right: 38px; }
  .q-bl { bottom: 38px; left: 38px; }
  .q-br { bottom: 38px; right: 38px; }

  .q-emoji { font-size: 1.8rem; }
  .q-name { font-size: 0.6rem; }

  .anno-stepper input {
    font-size: 2.5rem;
    width: 140px;
  }

  .stepper-btn {
    width: 52px;
    height: 52px;
  }

  .serata-pill {
    max-width: 80px;
    padding: 14px 8px;
  }

  .btn-primary {
    padding: 18px 36px;
    font-size: 0.95rem;
  }

  .step-bottom-bar {
    padding: 1rem 2rem calc(1rem + var(--safe-bottom));
  }

  .output-topbar {
    padding: 0 1.5rem;
  }

  .scaletta-viewport {
    padding: 1.5rem;
  }
}

@media (min-width: 840px) {
  /* On wide screens, no scaling needed — show at full size, centered */
  .scaletta-doc {
    transform: none !important;
    margin: 0 auto;
  }
  .scaletta-viewport {
    overflow: visible;
  }
}
