/* StickersMachine! — ricalca la bozza: crema chiaro, card bianche, arancio come
   accento, barra scura in basso; l'introduzione è un'officina steampunk.
   Font dei titoli grandi: Sour Gummy (SIL Open Font License). */

@font-face {
  font-family: "Sour Gummy";
  src: url("fonts/SourGummy-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #f7f0e3;
  --bg-2: #efe5d2;
  --card: #fffdf8;
  --line: #eadcc4;
  --ink: #1f1811;
  --ink-soft: #857461;
  --orange-1: #ffd46c;
  --orange-2: #f7a52d;
  --orange-3: #d9820e;
  --orange-ink: #3a2408;
  --selected: #f29a1c;
  --selected-soft: #fff1dc;
  --nav: #1c140d;
  --nav-ink: #c9b99f;
  --nav-active: #f7a825;
  --danger: #d6453a;
  --shadow: 0 1px 2px rgb(60 40 15 / 0.06), 0 4px 14px rgb(60 40 15 / 0.07);
  --radius: 18px;
  --nav-h: 66px;
  --checker-a: #f1e8d6;
  --checker-b: #fdf9f1;
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Sour Gummy", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
}

/* Telegram in tema scuro: officina di notte. */
:root[data-scheme="dark"] {
  --bg: #17110b;
  --bg-2: #211810;
  --card: #261c13;
  --line: #3d2e1f;
  --ink: #f6ead4;
  --ink-soft: #b3a086;
  --selected-soft: #3a2812;
  --nav: #0d0906;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 14px rgb(0 0 0 / 0.25);
  --checker-a: #2b2016;
  --checker-b: #221910;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 var(--ui);
  -webkit-tap-highlight-color: transparent;
  /* clip e non hidden: hidden rompe il pulsante «Genera» fisso in basso (sticky). */
  overflow-x: clip;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.icon { display: inline-flex; width: 1.25em; height: 1.25em; flex: none; }
.icon svg, [data-art] svg, [data-logo] svg { width: 100%; height: 100%; display: block; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 6px 16px calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
}

/* --- Intestazione con il logo --- */
.top { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; padding: 6px 0 12px; }
.logo { display: block; width: min(250px, 100%); margin: 0 auto; aspect-ratio: 300 / 62; }
.logo.big { width: min(300px, 82%); aspect-ratio: 300 / 150; }
.icon-plain { border: 0; background: none; padding: 6px; color: var(--ink); }
.icon-plain .icon { width: 24px; height: 24px; }

.notice {
  margin: 30px 0;
  padding: 22px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: center;
  line-height: 1.5;
}

/* --- Schermata Crea --- */
.view { display: grid; gap: 12px; }
.label { margin: 8px 0 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.view-title { margin: 4px 0 2px; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.view-head { display: flex; align-items: center; justify-content: space-between; }

.text-card {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 14px 16px 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.text-card textarea { width: 100%; border: 0; outline: 0; resize: none; background: transparent; font-size: 17px; font-weight: 600; }
.text-card textarea::placeholder { color: var(--ink-soft); font-weight: 500; }
.text-example { color: var(--ink-soft); font-size: 13px; }
.counter { position: absolute; right: 14px; bottom: 9px; font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.source-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.source-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 20px 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.source-card .icon { width: 34px; height: 34px; }
.source-card:active { transform: scale(0.98); }
.text-link { justify-self: start; border: 0; background: none; padding: 2px 0; color: var(--ink-soft); font-size: 14px; }
.text-link b { color: var(--orange-3); }
.text-link.small { font-size: 13px; font-weight: 700; color: var(--orange-3); }

.media-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.media-stage {
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: 12px;
  background-color: var(--checker-b);
  background-image:
    linear-gradient(45deg, var(--checker-a) 25%, transparent 25%, transparent 75%, var(--checker-a) 75%),
    linear-gradient(45deg, var(--checker-a) 25%, transparent 25%, transparent 75%, var(--checker-a) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}
.media-frame { position: relative; max-width: 100%; overflow: hidden; border-radius: 8px; touch-action: none; user-select: none; -webkit-user-select: none; }
.media-frame img, .media-frame video { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgb(28 20 13 / 0.55); cursor: move; touch-action: none; }
.crop-box::before, .crop-box::after {
  content: "";
  position: absolute;
  inset: 33.33% 0;
  border-top: 1px solid rgb(255 255 255 / 0.45);
  border-bottom: 1px solid rgb(255 255 255 / 0.45);
  pointer-events: none;
}
.crop-box::after { inset: 0 33.33%; border: 0; border-left: 1px solid rgb(255 255 255 / 0.45); border-right: 1px solid rgb(255 255 255 / 0.45); }
.handle { position: absolute; width: 28px; height: 28px; touch-action: none; }
.handle::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--orange-1); border: 2px solid var(--orange-ink); }
.handle[data-handle="nw"] { left: -14px; top: -14px; cursor: nwse-resize; }
.handle[data-handle="ne"] { right: -14px; top: -14px; cursor: nesw-resize; }
.handle[data-handle="sw"] { left: -14px; bottom: -14px; cursor: nesw-resize; }
.handle[data-handle="se"] { right: -14px; bottom: -14px; cursor: nwse-resize; }
.media-loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; background: rgb(28 20 13 / 0.55); color: #fff3d6; font-weight: 700; }
.spinner { width: 28px; height: 28px; border: 3px solid rgb(255 212 108 / 0.35); border-top-color: var(--orange-1); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.media-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.trim { display: grid; gap: 6px; border-top: 1px dashed var(--line); padding-top: 8px; }
.trim-head { display: flex; justify-content: space-between; font-weight: 700; }
.trim-head span:last-child { color: var(--orange-3); font-variant-numeric: tabular-nums; }
.trim-row { display: grid; grid-template-columns: 46px 1fr; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 13px; }
input[type="range"] { width: 100%; accent-color: var(--orange-2); }

/* Schede di stile illustrate, come nella bozza */
.style-cards { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px; scrollbar-width: none; }
.style-cards::-webkit-scrollbar { display: none; }
.style-card {
  flex: none;
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 84px;
  padding: 8px 4px 7px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 600;
}
.style-card [data-art] { width: 60px; height: 60px; }
.style-card[aria-pressed="true"] { border: 2px solid var(--selected); background: var(--selected-soft); box-shadow: 0 0 0 3px rgb(242 154 28 / 0.18); }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg-2);
}
.segmented button { padding: 8px 4px; border: 0; border-radius: 9px; background: transparent; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgb(60 40 15 / 0.15); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.chip[aria-pressed="true"] { border-color: var(--selected); background: var(--selected-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--selected); }
.chips.dark .chip { border-color: transparent; background: var(--bg-2); color: var(--ink-soft); }
.chips.dark .chip[aria-pressed="true"] { background: var(--nav); color: #fff6e6; box-shadow: none; }
.chip .count { opacity: 0.65; margin-left: 5px; font-size: 12px; }
.emoji-row .chip { padding: 4px 9px; font-size: 22px; line-height: 1.2; }

.input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); outline: 0; }
.input:focus { border-color: var(--selected); }

/* --- Pulsanti --- */
.gold-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 14px 22px;
  border: 1.5px solid var(--orange-3);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe39a 0%, var(--orange-1) 30%, var(--orange-2) 100%);
  color: var(--orange-ink);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 0 #c9780c, 0 10px 22px rgb(217 130 14 / 0.3), inset 0 2px 0 rgb(255 255 255 / 0.55);
}
.gold-button .icon { width: 22px; height: 22px; }
.gold-button:active { transform: translateY(2px); box-shadow: 0 2px 0 #c9780c, 0 6px 14px rgb(217 130 14 / 0.25), inset 0 2px 0 rgb(255 255 255 / 0.55); }
.gold-button:disabled { opacity: 0.6; }
.gold-button.small { width: auto; min-height: 0; padding: 10px 18px; font-size: 14px; box-shadow: 0 3px 0 #c9780c, inset 0 1px 0 rgb(255 255 255 / 0.55); }
.sparkle-mark { font-size: 16px; }
.soft-button {
  display: block;
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}
.soft-button.danger { color: var(--danger); }
.icon-square { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); }
.icon-square .icon { width: 20px; height: 20px; }
.hint { margin: 0; color: var(--ink-soft); font-size: 13px; }
.hint.center { text-align: center; }

.cta-bar {
  position: sticky;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  display: grid;
  gap: 6px;
  margin: 4px -16px 0;
  padding: 18px 16px 10px;
  z-index: 3;
  background: linear-gradient(to bottom, transparent, var(--bg) 30%);
}

/* --- Esplora e griglie --- */
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.search-bar { display: flex; align-items: center; gap: 8px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); box-shadow: var(--shadow); }
.search-bar .icon { color: var(--ink-soft); }
.search-bar input { flex: 1; min-width: 0; padding: 11px 0; border: 0; outline: 0; background: transparent; }
.link-bar { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid:empty { display: none; }
.tile {
  position: relative;
  aspect-ratio: 1;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tile img { width: 100%; height: 100%; object-fit: contain; display: block; filter: drop-shadow(0 2px 3px rgb(60 40 15 / 0.18)); }
.tile.photo { padding: 0; }
.tile.photo img { object-fit: cover; filter: none; }
.tile[aria-pressed="true"] { border-color: var(--selected); box-shadow: 0 0 0 2px var(--selected); }
.tile .tag { position: absolute; left: 6px; top: 6px; padding: 1px 6px; border-radius: 6px; background: var(--nav); color: var(--nav-active); font-size: 10px; font-weight: 800; }
.tile .fav { position: absolute; right: 6px; top: 5px; font-size: 13px; color: var(--danger); }
.paper-card { display: grid; gap: 10px; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); }
.paper-card p { margin: 0; }

.pack-banner {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #2a1d12, #4a3218);
  color: #fbeed6;
  box-shadow: var(--shadow);
}
.pack-banner-text { display: grid; gap: 3px; font-size: 13px; line-height: 1.35; }
.pack-banner-text b { font-size: 15px; color: #ffd46c; }
.empty { display: grid; justify-items: center; gap: 10px; padding: 12px 0; text-align: center; color: var(--ink-soft); }
.empty p { margin: 0; }
.empty-art { width: 180px; }
.empty-heart { width: 90px; height: 90px; }
.storage { display: grid; gap: 6px; }
.storage-track { height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; }
.storage-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--orange-1), var(--orange-2)); transition: width 0.3s; }

/* --- Barra in basso --- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--nav);
  box-shadow: 0 -6px 20px rgb(0 0 0 / 0.18);
}
.bottom-nav button {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--nav-ink);
  font-size: 11px;
  font-weight: 600;
}
.bottom-nav .icon { width: 25px; height: 25px; }
.bottom-nav button[aria-current="page"] { color: var(--nav-active); }
.bottom-nav button[aria-current="page"] .icon svg { fill: currentColor; fill-opacity: 0.25; }
.bottom-nav button[aria-current="page"]::after { content: ""; position: absolute; bottom: 5px; width: 24px; height: 3px; border-radius: 2px; background: var(--nav-active); }
.badge { position: absolute; top: 7px; left: calc(50% + 7px); min-width: 17px; padding: 0 5px; border-radius: 999px; background: var(--nav-active); color: var(--orange-ink); font-size: 10px; line-height: 16px; }
.badge:empty { display: none; }

/* --- Schermate a tutto schermo --- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 8;
  overflow-y: auto;
  padding: 18px 20px calc(24px + env(safe-area-inset-bottom));
  background: var(--bg);
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 14px;
  animation: fade 0.25s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.screen > * { max-width: 520px; width: 100%; }
.display-title { margin: 8px 0 0; font-family: var(--display); font-weight: 400; font-size: 34px; line-height: 1.05; text-align: center; transform: rotate(-2deg); }
.dots { display: flex; justify-content: center; gap: 8px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.3; }
.dots span.on { opacity: 1; }

/* Introduzione: officina steampunk */
.splash {
  align-content: center;
  color: #fbeed6;
  background:
    radial-gradient(ellipse at 50% 30%, rgb(255 190 90 / 0.28), transparent 55%),
    radial-gradient(ellipse at 50% 110%, #4a3018 0%, transparent 60%),
    linear-gradient(180deg, #3a2c1f 0%, #1d140c 70%, #120c07 100%);
  text-align: center;
}
.splash-gears { position: absolute; inset: 0; pointer-events: none; opacity: 0.18; overflow: hidden; }
.splash-gears svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.splash > *:not(.splash-gears) { position: relative; }
.tagline { margin: -6px 0 0; font-family: var(--display); font-size: 22px; line-height: 1.15; color: #fff3d6; transform: rotate(-3deg); text-shadow: 0 2px 0 #1d140c; }
.splash-art { width: min(340px, 92%); }
.splash-foot { margin: 0; font-size: 14px; color: #e9d7b8; }
.splash .dots { color: #fbeed6; }

.intro { align-content: center; }
.skip { position: absolute; top: 14px; right: 16px; width: auto !important; border: 0; background: none; color: var(--ink-soft); font-weight: 600; }
.features { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.features li { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: var(--shadow); }
.feature-art { width: 52px; height: 52px; flex: none; padding: 6px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); }
.features b { display: block; font-size: 15px; }
.features small { color: var(--ink-soft); font-size: 13px; }
.intro .dots { color: var(--ink); }

/* La macchina è al lavoro */
.working {
  align-content: center;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 42%, rgb(255 205 110 / 0.45), transparent 55%),
    radial-gradient(ellipse at 50% 50%, transparent 55%, rgb(120 80 30 / 0.18) 100%),
    var(--bg);
}
.working-art { width: min(330px, 90%); }
.progress { height: 16px; border-radius: 999px; background: var(--nav); padding: 3px; box-shadow: inset 0 1px 3px rgb(0 0 0 / 0.5); }
.progress-bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(180deg, #ffe39a, var(--orange-2)); box-shadow: 0 0 8px rgb(255 190 80 / 0.7); }
.working-status { margin: 0; font-weight: 600; color: var(--ink-soft); }
.quote { margin: 10px 0 0; font-family: var(--display); font-size: 20px; }

/* Sticker pronto */
.sticker-screen { text-align: center; }
.screen-bar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; }
.screen-bar .logo { width: min(200px, 100%); }
.back, .more { width: 44px; height: 44px; border: 0; background: none; color: var(--ink); display: grid; place-items: center; }
.back .icon, .more .icon { width: 24px; height: 24px; }
.screen-title { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.showcase { position: relative; display: grid; place-items: center; min-height: 290px; }
.showcase img, .showcase video { max-width: 270px; max-height: 270px; filter: drop-shadow(0 10px 18px rgb(60 40 15 / 0.28)); }
.star { position: absolute; width: 26px; height: 26px; animation: twinkle 1.8s ease-in-out infinite; }
.star.a { left: 8%; top: 18%; width: 30px; height: 30px; }
.star.b { right: 9%; top: 10%; animation-delay: 0.6s; }
.star.c { right: 6%; bottom: 20%; width: 22px; height: 22px; animation-delay: 1.1s; }
.star.d { left: 12%; bottom: 12%; width: 18px; height: 18px; animation-delay: 0.3s; }
@keyframes twinkle { 50% { transform: scale(0.55) rotate(25deg); opacity: 0.55; } }
.facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.facts span { padding: 3px 10px; border-radius: 999px; background: var(--bg-2); font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.round-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.round-actions button { display: grid; justify-items: center; gap: 7px; border: 0; background: none; font-size: 13px; color: var(--ink); }
.round-actions .circle { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); }
.round-actions .circle .icon { width: 24px; height: 24px; }
.round-actions button.on .circle { color: var(--danger); }
.round-actions button.on .circle svg { fill: currentColor; }
.pack-note { margin: -4px 0 0; font-size: 13px; color: var(--ink-soft); }
.related { display: grid; gap: 10px; text-align: left; }
.related h3 { margin: 0; font-size: 16px; font-weight: 700; }
.related .row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* --- Foglio in basso --- */
.sheet-backdrop { position: fixed; inset: 0; background: rgb(20 12 5 / 0.45); z-index: 10; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 11;
  max-height: 85vh;
  overflow-y: auto;
  padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  box-shadow: 0 -8px 30px rgb(0 0 0 / 0.25);
  animation: rise 0.2s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet-grip { width: 40px; height: 4px; margin: 0 auto 12px; border-radius: 2px; background: var(--line); }
#sheetBody { display: grid; gap: 12px; max-width: 520px; margin: 0 auto; }
.sheet h2 { margin: 0; font-size: 19px; font-weight: 800; text-align: center; }
.sheet p { margin: 0; }
.sheet .menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); text-align: left; font-weight: 600; }
.sheet .menu-item .icon { width: 22px; height: 22px; }
.sheet .menu-item.danger { color: var(--danger); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 96px + env(safe-area-inset-bottom));
  z-index: 20;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 14px;
  background: var(--nav);
  color: #fff6e6;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.3);
}

/* --- Animazioni della macchina --- */
[data-machine] svg { width: 100%; height: auto; display: block; }
.gear { transform-box: fill-box; transform-origin: center; animation: spin 9s linear infinite; }
.gear.reverse { animation-direction: reverse; animation-duration: 7s; }
.working .gear { animation-duration: 2.6s; }
.working .gear.reverse { animation-duration: 2s; }
.steam { opacity: 0; transform-box: fill-box; transform-origin: center; animation: steam 3s ease-out infinite; }
.steam.s2 { animation-delay: 1s; }
.steam.s3 { animation-delay: 2s; }
@keyframes steam {
  0% { opacity: 0; transform: translateY(0) scale(0.5); }
  30% { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-34px) scale(1.5); }
}
.paper-out { transform-box: fill-box; animation: paper 3.2s ease-in-out infinite; }
@keyframes paper {
  0%, 12% { transform: translate(-8px, -22px) rotate(0deg); }
  70%, 100% { transform: translate(0, 0) rotate(-6deg); }
}
.bulb-glow { animation: glow 1.4s ease-in-out infinite alternate; }
@keyframes glow { from { opacity: 0.45; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
