/* microgames — lo strato da cabinato.
   Tutto quello che si muove oltre il kit: avvio, passaggio fra le pagine, demo nell'hero,
   micro gioco, griglia viva, tinta che cambia scorrendo, obiettivi, modalità arcade.
   Con «movimento ridotto» resta ferma ogni cosa (in fondo al file). */

@property --mg-tinta { syntax: "<color>"; inherits: true; initial-value: #e9a23b; }
:root { --mg-tinta: #e9a23b; --mg-grafite: #16150f; --mg-carta: #1e1d16; transition: --mg-tinta .9s ease; }

/* ------------------------------------------------------------------ velo: avvio e passaggio */
.mg-velo { position: fixed; inset: 0; z-index: 9000; display: none; pointer-events: none; color: #f3f1e9; }
.mg-boot .mg-velo, .mg-entra .mg-velo, .mg-esce .mg-velo { display: block; }
.mg-boot .mg-velo, .mg-entra .mg-velo { background: var(--mg-grafite); animation: mg-sicura 0s linear 5s forwards; }
.mg-entra .mg-velo { animation-delay: 2.2s; }
.mg-boot.mg-velo-via .mg-velo, .mg-entra.mg-velo-via .mg-velo { background: transparent; }
.mg-boot .mg-velo { pointer-events: auto; cursor: pointer; }
@keyframes mg-sicura { to { visibility: hidden; } }
.mg-velo__tela { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mg-velo__dentro { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; text-align: center; transition: opacity .18s steps(3); }
.mg-velo-via .mg-velo__dentro, .mg-entra .mg-velo__dentro { opacity: 0; }
.mg-esce .mg-velo__nome, .mg-esce .mg-velo__barra, .mg-esce .mg-velo__start { display: none; }
.mg-velo__m { width: min(34vw, 190px); height: auto; overflow: visible; color: #e9a23b; filter: drop-shadow(0 0 22px rgb(233 162 59 / .45)); }
.mg-velo__m rect { transform-box: fill-box; }
.mg-boot .mg-velo__m rect { animation: mg-cade .42s steps(5) both; animation-delay: calc(var(--i) * 34ms + 120ms); }
.mg-esce .mg-velo__m rect { animation: mg-cade .26s steps(4) both; animation-delay: calc(var(--i) * 12ms + 90ms); }
@keyframes mg-cade { from { transform: translateY(-46vh) scale(.6); opacity: 0; } 60% { opacity: 1; } to { transform: none; opacity: 1; } }
.mg-velo__nome { margin: 0; font: 700 clamp(20px, 3.4vw, 34px)/1 var(--mg-pixel, monospace); letter-spacing: .12em; text-transform: uppercase;
  animation: mg-scrive .5s steps(10) .62s both; overflow: hidden; white-space: nowrap; }
@keyframes mg-scrive { from { max-width: 0; } to { max-width: 12em; } }
.mg-velo__barra { margin: 0; width: min(46vw, 260px); height: 10px; padding: 2px; border: 2px solid #f3f1e9; }
.mg-velo__barra i { display: block; height: 100%; background: #e9a23b; transform-origin: left; animation: mg-carica .95s steps(9) .2s both; }
@keyframes mg-carica { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.mg-velo__start { margin: 0; font: 400 12px/1 var(--mg-pixel, monospace); letter-spacing: .16em; text-transform: uppercase; color: #a29c86;
  animation: mg-lampeggia-b .9s steps(2) 1.1s infinite both; }
@keyframes mg-lampeggia-b { 0% { opacity: 0; } 50%, 100% { opacity: 1; } }
/* la riga del tubo catodico che si apre */
.mg-boot .mg-velo::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: #f3f1e9; box-shadow: 0 0 24px 4px rgb(243 241 233 / .6);
  animation: mg-tubo .34s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes mg-tubo { 0% { transform: scaleX(0); opacity: 1; } 60% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1) scaleY(220); opacity: 0; } }

/* ------------------------------------------------------------------ griglia viva, scintille, bagliore di tinta */
.mg-griglia { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.mg-alone { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(48% 42% at 86% 8%, color-mix(in oklab, var(--mg-tinta) 20%, transparent), transparent 72%),
    radial-gradient(40% 36% at 6% 96%, color-mix(in oklab, var(--mg-tinta) 12%, transparent), transparent 72%); }
.mg-scintille { position: fixed; inset: 0; z-index: 8000; pointer-events: none; overflow: hidden; }
.mg-scintille i { position: absolute; width: 6px; height: 6px; margin: -3px 0 0 -3px; background: var(--c, var(--mg-tinta));
  animation: mg-scheggia .52s steps(7) forwards; }
@keyframes mg-scheggia { from { transform: translate(0, 0); opacity: 1; } to { transform: translate(var(--x), var(--y)); opacity: 0; } }

/* ------------------------------------------------------------------ barra XP e livello */
.mg-xp { position: fixed; inset: 0 0 auto 0; height: 4px; z-index: 950; pointer-events: none; background: rgb(22 21 15 / .6); }
.mg-xp i { display: block; height: 100%; background: var(--mg-tinta); transform-origin: left; transform: scaleX(var(--p, 0)); box-shadow: 0 0 12px var(--mg-tinta); }
.mg-xp.is-piena i { animation: mg-pieno .5s steps(2) 3; }
@keyframes mg-pieno { 50% { background: #f3f1e9; } }
/* a destra del pulsante dell'accessibilita' del sito (in basso a sinistra, 50px): non lo copre mai */
.mg-stage { position: fixed; left: 78px; bottom: 26px; z-index: 900; display: none; align-items: center; gap: 10px; padding: 8px 12px 8px 8px;
  font: 400 11px/1 var(--mg-pixel, monospace); letter-spacing: .1em; text-transform: uppercase; color: #f3f1e9;
  background: rgb(22 21 15 / .86); border: 1px solid var(--mg-bordo, #2f2d22); backdrop-filter: blur(6px); pointer-events: none; }
.mg-stage b { display: grid; place-items: center; min-width: 26px; height: 22px; padding: 0 4px; background: var(--mg-tinta); color: #16150f; font-weight: 700; }
.mg-stage.is-cambio b { animation: mg-lampo .3s steps(3); }
@keyframes mg-lampo { 0% { background: #f3f1e9; transform: scale(1.25); } 100% { transform: none; } }
@media (min-width: 900px) { .mg-stage { display: flex; } }

/* ------------------------------------------------------------------ hero: demo, tubo catodico, pulsante start */
.hero--film .hero__media { transform-style: preserve-3d; }
.hero--film.mg-vivo .hero__media { transform: perspective(1400px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .25s ease-out, box-shadow .4s;
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--mg-tinta) 45%, transparent), 0 30px 90px -30px color-mix(in oklab, var(--mg-tinta) 55%, transparent); }
.mg-demo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; z-index: 0; }
.mg-demo.is-on { opacity: 1; }
.mg-demo__tela { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.mg-crt { position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(to top, rgb(22 21 15 / .94) 0%, rgb(22 21 15 / .55) 34%, transparent 62%),
    repeating-linear-gradient(to bottom, rgb(0 0 0 / .22) 0 1px, transparent 1px 3px),
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgb(0 0 0 / .55) 100%); }
.mg-crt::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, transparent, rgb(255 255 255 / .07), transparent); height: 28%; animation: mg-riga 5.5s linear infinite; }
@keyframes mg-riga { from { transform: translateY(-110%); } to { transform: translateY(460%); } }
.mg-cabina { display: grid; gap: 12px; justify-items: end; }
.mg-demo__riga { margin: 0; display: flex; align-items: center; gap: 8px; font: 400 11px/1 var(--mg-pixel, monospace); letter-spacing: .1em; text-transform: uppercase; color: #f3f1e9; }
.mg-demo__riga b { font-weight: 700; color: var(--mg-tinta); }
.mg-demo__spia { width: 8px; height: 8px; background: #ff5f6d; animation: mg-lampeggia-b 1s steps(2) infinite; }
.mg-start { appearance: none; cursor: pointer; display: grid; gap: 8px; text-align: left; padding: 18px 22px; color: #16150f; background: #e9a23b; border: 0;
  font: 700 18px/1 var(--mg-pixel, monospace); letter-spacing: .08em; text-transform: uppercase;
  box-shadow: 0 5px 0 #8a5c16, 0 0 0 2px #16150f, 0 0 34px rgb(233 162 59 / .5); transition: transform .08s steps(2), box-shadow .08s steps(2); }
.mg-start small { font: 400 11px/1.2 var(--mg-pixel, monospace); letter-spacing: .06em; opacity: .78; }
.mg-start:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #8a5c16, 0 0 0 2px #16150f, 0 0 48px rgb(233 162 59 / .75); }
.mg-start:active { transform: translateY(4px); box-shadow: 0 1px 0 #8a5c16, 0 0 0 2px #16150f; }
.mg-start:focus-visible { outline: 3px solid #f3f1e9; outline-offset: 4px; }
.mg-start__punta { display: inline-block; animation: mg-lampeggia-b .8s steps(2) infinite; }
@media (max-width: 720px) { .mg-cabina { justify-items: start; } }
/* il titolo che si decifra: ogni parola tiene la sua larghezza */
.mg-parola { display: inline-block; white-space: nowrap; }

/* ------------------------------------------------------------------ micro gioco */
.mg-gioco { position: absolute; inset: 0; z-index: 5; display: none; background: rgb(22 21 15 / .93); color: #f3f1e9; touch-action: none; user-select: none; }
.mg-gioco.is-aperto { display: block; }
.mg-gioco canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.mg-gioco__hud { position: absolute; inset: 0 0 auto 0; z-index: 2; display: flex; gap: 18px; align-items: center; padding: 12px 14px; pointer-events: none;
  font: 400 12px/1 var(--mg-pixel, monospace); letter-spacing: .1em; text-transform: uppercase; background: linear-gradient(to bottom, rgb(22 21 15 / .9), transparent); }
.mg-gioco__hud b { color: #e9a23b; font-weight: 700; font-size: 16px; }
.mg-gioco__hud .mg-gioco__tempo { margin-left: auto; }
.mg-gioco__chiudi { pointer-events: auto; appearance: none; cursor: pointer; width: 30px; height: 30px; border: 2px solid #f3f1e9; background: transparent; color: #f3f1e9; font: 700 14px/1 var(--mg-pixel, monospace); }
.mg-gioco__chiudi:hover { background: #f3f1e9; color: #16150f; }
.mg-gioco__fine { position: absolute; inset: 0; z-index: 3; display: none; place-content: center; justify-items: center; gap: 14px; text-align: center; background: rgb(22 21 15 / .9); padding: 24px; }
.mg-gioco.is-finito .mg-gioco__fine { display: grid; }
.mg-gioco__fine p { margin: 0; font: 400 12px/1.4 var(--mg-pixel, monospace); letter-spacing: .12em; text-transform: uppercase; color: #a29c86; }
.mg-gioco__fine .mg-gioco__voto { font: 700 clamp(44px, 9vw, 96px)/.9 var(--mg-pixel, monospace); color: #e9a23b; text-shadow: 4px 4px 0 #8a5c16; animation: mg-lampo .4s steps(4); }
.mg-gioco__fine .mg-gioco__nuovo { color: #9fd94a; animation: mg-lampeggia-b .7s steps(2) infinite; }
.mg-gioco__fine div { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
.mg-tasto { appearance: none; cursor: pointer; display: inline-block; padding: 12px 16px; border: 2px solid #f3f1e9; background: transparent; color: #f3f1e9; text-decoration: none;
  font: 700 12px/1 var(--mg-pixel, monospace); letter-spacing: .08em; text-transform: uppercase; }
.mg-tasto:hover, .mg-tasto:focus-visible { background: #f3f1e9; color: #16150f; }
.mg-tasto--oro { background: #e9a23b; border-color: #e9a23b; color: #16150f; }
.mg-gioco.is-scossa canvas { animation: mg-scossa .16s steps(4); }
@keyframes mg-scossa { 25% { transform: translate(3px, -2px); } 50% { transform: translate(-3px, 2px); } 75% { transform: translate(2px, 3px); } }

/* ------------------------------------------------------------------ schede dei giochi nuovi: inclinazione, luce, tasselli */
#nuovi .grid { perspective: 1100px; }
#nuovi .tile { position: relative; transform-style: preserve-3d; will-change: transform;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(var(--tz, 0px)); transition: transform .28s cubic-bezier(.2, .8, .2, 1), box-shadow .28s; }
#nuovi .tile.is-sotto { transition: transform .06s linear, box-shadow .28s;
  box-shadow: 0 0 0 1px var(--mg-acc, var(--mg-tinta)), 0 26px 60px -22px var(--mg-acc, var(--mg-tinta)); }
.mg-luce { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; transition: opacity .25s; border-radius: inherit; mix-blend-mode: screen;
  background: radial-gradient(240px circle at var(--gx, 50%) var(--gy, 50%), color-mix(in oklab, var(--mg-acc, #e9a23b) 42%, transparent), transparent 70%); }
.tile.is-sotto .mg-luce { opacity: 1; }
.mg-tasselli { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }

/* ------------------------------------------------------------------ fascia gigante fra le sezioni */
.mg-fascia { position: relative; overflow: hidden; padding: clamp(28px, 5vw, 64px) 0; pointer-events: none; }
.mg-fascia__riga { display: block; white-space: nowrap; will-change: transform; font: 700 clamp(48px, 9.5vw, 150px)/.92 var(--font-display, "Anybody", sans-serif);
  font-stretch: 150%; font-variation-settings: "wdth" 150; text-transform: uppercase; letter-spacing: -.02em; }
.mg-fascia__riga--piena { color: #16150f; background: var(--mg-tinta); padding: .08em 0; transform: translate3d(var(--x, 0px), 0, 0) rotate(-1.6deg); transform-origin: 50% 50%; width: 220vw; margin-left: -20vw; }
.mg-fascia__riga--vuota { color: transparent; -webkit-text-stroke: 1.5px color-mix(in oklab, var(--mg-tinta) 70%, #f3f1e9); margin-top: .12em; transform: translate3d(var(--x2, 0px), 0, 0); }
.mg-fascia__riga i { font-style: normal; font-family: var(--mg-pixel, monospace); font-size: .42em; vertical-align: .3em; padding: 0 .5em; }

/* ------------------------------------------------------------------ catalogo: nome gigante e disturbo al cambio */
#giochi { position: relative; overflow: clip; }
.mg-fantasma { position: absolute; left: -1vw; bottom: -1.2vw; z-index: 0; margin: 0; pointer-events: none; white-space: nowrap; max-width: none;
  font: 700 clamp(72px, 12.5vw, 210px)/.8 var(--font-display, "Anybody", sans-serif); font-stretch: 150%; font-variation-settings: "wdth" 150; text-transform: uppercase; letter-spacing: -.03em;
  color: transparent; -webkit-text-stroke: 1.5px color-mix(in oklab, var(--mg-tinta) 34%, transparent); opacity: .9; }
.mg-fantasma.is-cambio { animation: mg-disturbo .28s steps(5); }
#giochi .wrap { position: relative; z-index: 1; }
#giochi .frame.is-disturbo { animation: mg-disturbo .24s steps(4); }
@keyframes mg-disturbo {
  0% { clip-path: inset(0 0 62% 0); transform: translateX(-10px); filter: drop-shadow(5px 0 0 #ff6ec7) drop-shadow(-5px 0 0 #3fd0c9); }
  25% { clip-path: inset(38% 0 20% 0); transform: translateX(9px); }
  50% { clip-path: inset(12% 0 55% 0); transform: translateX(-6px); filter: drop-shadow(-4px 0 0 #ff6ec7) drop-shadow(4px 0 0 #3fd0c9); }
  75% { clip-path: inset(60% 0 4% 0); transform: translateX(4px); }
  100% { clip-path: inset(0); transform: none; filter: none; } }
#giochi .rows li { transition: background-color .12s steps(2), box-shadow .12s steps(2); }
#giochi .rows li.is-on, #giochi .rows li:hover { background: color-mix(in oklab, var(--mg-tinta) 16%, transparent); box-shadow: inset 4px 0 0 var(--mg-tinta); }

/* ------------------------------------------------------------------ marchio gigante nel piede */
.mg-gigante { display: grid; justify-items: center; padding: clamp(40px, 7vw, 96px) 0 clamp(40px, 7vw, 96px); }
.mg-gigante svg { width: min(72vw, 520px); height: auto; overflow: visible; color: #e9a23b; cursor: pointer; }
.mg-gigante rect { transform-box: fill-box; transform-origin: center; transition: transform .35s cubic-bezier(.2, 1.6, .4, 1), fill .2s; transform: translate(var(--dx, 0px), var(--dy, 0px)) scale(var(--s, 1)); }
.mg-gigante.is-botto rect { transition: transform .5s cubic-bezier(.2, .8, .2, 1); }

/* ------------------------------------------------------------------ obiettivi */
.mg-avvisi { position: fixed; right: 16px; bottom: 16px; z-index: 8500; display: grid; gap: 10px; pointer-events: none; }
.mg-avviso { pointer-events: auto; cursor: pointer; display: flex; gap: 12px; align-items: center; width: min(340px, calc(100vw - 32px)); padding: 12px 14px;
  background: #1e1d16; border: 2px solid #e9a23b; color: #f3f1e9; box-shadow: 6px 6px 0 rgb(0 0 0 / .5), 0 0 40px rgb(233 162 59 / .35);
  transform: translateX(120%); transition: transform .28s steps(6); }
.mg-avviso.is-dentro { transform: none; }
.mg-avviso svg { flex: none; width: 34px; height: 28px; color: #e9a23b; animation: mg-saltino .5s steps(4) 2 .3s; }
@keyframes mg-saltino { 50% { transform: translateY(-6px); } }
.mg-avviso span { display: grid; gap: 3px; }
.mg-avviso em { font: 400 10px/1 var(--mg-pixel, monospace); font-style: normal; letter-spacing: .12em; text-transform: uppercase; color: #e9a23b; }
.mg-avviso strong { font-size: 15px; }
.mg-avviso small { font-size: 12px; color: #a29c86; line-height: 1.35; }
.mg-trofei { margin-top: 28px; padding-top: 20px; border-top: 1px solid color-mix(in oklab, currentColor 18%, transparent); }
.mg-trofei summary { cursor: pointer; display: flex; align-items: center; gap: 12px; font: 400 12px/1 var(--mg-pixel, monospace); letter-spacing: .1em; text-transform: uppercase; list-style: none; }
.mg-trofei summary::-webkit-details-marker { display: none; }
.mg-trofei summary b { color: #e9a23b; font-weight: 700; }
.mg-trofei__barra { flex: 0 1 160px; height: 8px; padding: 1px; border: 1px solid currentColor; }
.mg-trofei__barra i { display: block; height: 100%; width: var(--quota, 0%); background: #e9a23b; transition: width .5s steps(8); }
.mg-trofei__nota { margin: 12px 0; font-size: 13px; opacity: .7; }
.mg-trofei ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.mg-trofei li { display: grid; gap: 3px; padding: 10px 12px; border: 1px dashed color-mix(in oklab, currentColor 30%, transparent); opacity: .5; }
.mg-trofei li.is-preso { opacity: 1; border: 1px solid #e9a23b; background: rgb(233 162 59 / .08); }
.mg-trofei li small { font-size: 12px; opacity: .75; line-height: 1.35; }
.mg-suono { appearance: none; cursor: pointer; margin-left: auto; padding: 7px 10px; border: 1px solid currentColor; background: transparent; color: inherit;
  font: 400 11px/1 var(--mg-pixel, monospace); letter-spacing: .1em; text-transform: uppercase; }
.mg-suono[aria-pressed="true"] { background: #e9a23b; border-color: #e9a23b; color: #16150f; }

/* ------------------------------------------------------------------ modalità arcade (il codice segreto) */
html.mg-arcade { animation: mg-arcade 3.6s linear; }
@keyframes mg-arcade { 0%, 100% { filter: none; } 10% { filter: hue-rotate(60deg) saturate(1.5); } 50% { filter: hue-rotate(200deg) saturate(1.7); } 90% { filter: hue-rotate(320deg) saturate(1.5); } }
.mg-coriandoli { position: fixed; inset: 0; z-index: 8800; pointer-events: none; overflow: hidden; }
.mg-coriandoli i { position: absolute; top: -20px; background: var(--c); animation: mg-piove var(--d, 2s) steps(18) forwards; }
@keyframes mg-piove { to { transform: translate(var(--x), 110vh) rotate(var(--r)); } }

/* ------------------------------------------------------------------ telefono */
@media (max-width: 720px) {
  .mg-fantasma { display: none; }
  .mg-start { width: 100%; }
  .mg-avvisi { right: 8px; bottom: 8px; }
}

/* ------------------------------------------------------------------ movimento ridotto: tutto fermo */
@media (prefers-reduced-motion: reduce) {
  .mg-velo, .mg-griglia, .mg-scintille, .mg-crt::after, .mg-stage, .mg-demo, .mg-demo__tela, .mg-tasselli { display: none !important; }
  :root { transition: none; }
  .mg-start__punta, .mg-demo__spia { animation: none; }
  .hero--film.mg-vivo .hero__media, #nuovi .tile { transform: none !important; }
  .mg-fascia__riga { transform: none !important; }
  .mg-avviso { transition: none; }
}
