/* ══════════════════════════════════════════════════════════════════
   MAH — foglio di stile del gioco
   TecnikGeek · pietrodefilippis.it
   ══════════════════════════════════════════════════════════════════ */

:root {
  --bg:        #0a0d1a;
  --bg-2:      #10142a;
  --surface:   rgba(255,255,255,.045);
  --surface-2: rgba(255,255,255,.075);
  --stroke:    rgba(255,255,255,.10);
  --stroke-2:  rgba(255,255,255,.18);

  --txt:       #eef1fb;
  --txt-dim:   #9aa3c4;
  --txt-faint: #626b8c;

  --acc:       #8b5cf6;
  --acc-2:     #22d3ee;
  --acc-glow:  rgba(139,92,246,.45);

  --gold:      #fbbf24;
  --gem:       #38bdf8;
  --win:       #34d399;
  --lose:      #f87171;

  --r:   16px;
  --r-s: 11px;
  --r-l: 24px;

  --shadow:    0 8px 30px rgba(0,0,0,.45);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.6);
  --ease:      cubic-bezier(.22,1,.36,1);

  --cell:  #1a2140;
  --board: #131832;
  --glow:  #8b5cf6;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(1100px 620px at 50% -10%, #241b4d 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 100%, #0d2b3f 0%, transparent 55%),
    var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button { font-family: inherit; cursor: pointer; border: 0; }
input  { font-family: inherit; }

/* ── Schermata di avvio ─────────────────────────────────────────
   Il sistema operativo, quando l'app è installata, mostra una sua schermata
   fissa (non animabile: la genera lui). Questa parte subito dopo e prende il
   testimone, così l'apertura sembra un unico movimento. */

#caricamento {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 100;
  background:
    radial-gradient(70% 45% at 50% 22%, #241b4d 0%, transparent 62%),
    radial-gradient(60% 40% at 100% 100%, #0d2b3f 0%, transparent 58%),
    var(--bg);
}
#caricamento.esce { animation: avvioEsce .45s ease forwards; }
@keyframes avvioEsce {
  to { opacity: 0; transform: scale(1.06); visibility: hidden; }
}

.avvio {
  text-align: center;
  /* Android mostra prima la SUA schermata col logo piccolo al centro: qui si
     riparte da quella misura e si cresce, così i due momenti sembrano uno solo
     e non si vede lo stacco fra la splash di sistema e l'app. */
  animation: avvioCresce .85s cubic-bezier(.2,1.35,.35,1) both;
}
@keyframes avvioCresce {
  0%   { transform: scale(.46); opacity: .82; }
  55%  { opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.avvio-nome {
  margin: 0;
  font-size: 88px; font-weight: 900; letter-spacing: -6px; line-height: 1;
  display: flex; justify-content: center;
}
.avvio-nome span {
  display: inline-block;
  background: linear-gradient(135deg, #fff 0%, var(--acc) 45%, var(--acc-2) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 8px 26px var(--acc-glow));
  animation: letteraSalta .5s cubic-bezier(.2,1.6,.4,1) calc(.5s + var(--i) * .07s) both;
}
@keyframes letteraSalta {
  0%   { transform: none; }
  45%  { transform: translateY(-14px) rotate(-4deg) scale(1.08); }
  100% { transform: none; }
}
/* il punto esclamativo rimbalza anche dopo, come se scalpitasse */
.avvio-nome .bang {
  animation: letteraSalta .5s cubic-bezier(.2,1.6,.4,1) .71s both,
             bangSalta 1.1s ease-in-out 1.25s infinite;
}
@keyframes bangSalta {
  0%, 100% { transform: none; }
  40%      { transform: translateY(-9px) rotate(6deg); }
  60%      { transform: translateY(0) rotate(-3deg); }
}

.avvio-pall { display: flex; gap: 11px; justify-content: center; margin-top: 20px; }
.avvio-pall i {
  width: 17px; height: 17px; border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,.6), rgba(255,255,255,0) 45%),
    linear-gradient(150deg, var(--a), var(--b));
  box-shadow: 0 4px 10px rgba(0,0,0,.45);
  animation: pallinaSchizza .55s cubic-bezier(.2,1.6,.4,1) calc(.45s + var(--i) * .07s) both,
             pallinaBalla 1.25s ease-in-out calc(1.1s + var(--i) * .12s) infinite;
}
@keyframes pallinaSchizza {
  from { opacity: 0; transform: scale(.2) translateY(-26px); }
  to   { opacity: 1; transform: none; }
}
@keyframes pallinaBalla {
  0%, 100% { transform: translateY(0); }
  45%      { transform: translateY(-9px); }
}

.avvio-claim {
  margin-top: 18px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 3.5px;
  text-transform: uppercase; color: var(--txt-faint);
  animation: claimEntra .6s ease .85s both;
}
@keyframes claimEntra {
  from { opacity: 0; letter-spacing: 8px; }
  to   { opacity: 1; letter-spacing: 3.5px; }
}

/* ── Impalcatura ─────────────────────────────────────────────── */

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding-bottom: 74px;         /* spazio per la barra di navigazione */
}

.vista { display: none; padding: 0 16px; animation: entra .32s var(--ease); }
.vista.on { display: block; }

/* Il tavolo resta al centro dello schermo anche quando avanza spazio sotto */
#v-gioco.on {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 160px);
}

@keyframes entra {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ── Intestazione ────────────────────────────────────────────── */

.top {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 12px;
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(180deg, rgba(10,13,26,.95) 55%, rgba(10,13,26,0));
  backdrop-filter: blur(12px);
}

.avatar {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 14px;
  background: linear-gradient(140deg, var(--acc), #4f46e5);
  display: grid; place-items: center;
  font-size: 22px;
  box-shadow: 0 6px 18px var(--acc-glow);
  border: 1px solid var(--stroke-2);
}

.top-id { min-width: 0; flex: 1; }
.top-nick {
  font-weight: 800; font-size: 15px; letter-spacing: -.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-grado { font-size: 11.5px; color: var(--txt-dim); font-weight: 600; }

.valute { display: flex; gap: 7px; }
.val {
  display: flex; align-items: center; gap: 5px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 50px;
  padding: 6px 11px 6px 8px;
  font-size: 12.5px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: transform .2s var(--ease);
}
.val i { font-style: normal; font-size: 13px; }
.val.gemme  { color: var(--gem); }
.val.monete { color: var(--gold); }
.val.pulse  { animation: valpop .5s var(--ease); }
@keyframes valpop {
  40% { transform: scale(1.22); }
  100%{ transform: scale(1); }
}

/* ── Elementi comuni ─────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 12px;
  backdrop-filter: blur(8px);
}

.titolo {
  font-size: 11px; font-weight: 800; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--txt-faint);
  margin: 22px 2px 10px;
}
.titolo:first-child { margin-top: 6px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%;
  padding: 15px 18px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  color: var(--txt);
  font-size: 15px; font-weight: 700;
  transition: transform .12s var(--ease), filter .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }

.btn-primario {
  background: linear-gradient(135deg, var(--acc) 0%, #6d28d9 100%);
  border-color: transparent;
  box-shadow: 0 10px 28px var(--acc-glow);
}
.btn-ciano {
  background: linear-gradient(135deg, var(--acc-2) 0%, #0891b2 100%);
  border-color: transparent;
  color: #04212b;
  box-shadow: 0 10px 28px rgba(34,211,238,.32);
}
.btn-oro {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  border-color: transparent; color: #3a2504;
  box-shadow: 0 10px 28px rgba(251,191,36,.3);
}
.btn-piccolo { padding: 10px 14px; font-size: 13.5px; border-radius: 11px; width: auto; }
.btn-fantasma { background: transparent; border-color: var(--stroke-2); }

.riga { display: flex; align-items: center; gap: 10px; }
.spazio { flex: 1; }

/* ── Menu principale ─────────────────────────────────────────── */

.marchio {
  text-align: center;
  padding: 20px 0 6px;
}
.marchio h1 {
  margin: 0;
  font-size: 62px; font-weight: 900; letter-spacing: -3px;
  background: linear-gradient(135deg, #fff 0%, var(--acc) 45%, var(--acc-2) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 8px 24px var(--acc-glow));
  line-height: 1;
}
.marchio p {
  margin: 6px 0 0;
  font-size: 11.5px; font-weight: 700; letter-spacing: 3.5px;
  text-transform: uppercase; color: var(--txt-faint);
}

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }

.modo {
  position: relative; overflow: hidden;
  border-radius: var(--r-l);
  padding: 20px 16px;
  border: 1px solid var(--stroke);
  background: var(--surface);
  text-align: left;
  color: var(--txt);
  transition: transform .14s var(--ease), border-color .2s;
}
.modo:active { transform: scale(.975); }
.modo .ico { font-size: 30px; display: block; margin-bottom: 8px; }
.modo b { display: block; font-size: 16.5px; font-weight: 800; letter-spacing: -.3px; }
.modo span.sub { display: block; font-size: 11.5px; color: var(--txt-dim); margin-top: 3px; font-weight: 600; }
.modo::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(120px 80px at 85% 0%, var(--bagliore, transparent), transparent 70%);
  pointer-events: none;
}
.modo.duello { --bagliore: rgba(139,92,246,.35); border-color: rgba(139,92,246,.3); }
.modo.solo   { --bagliore: rgba(34,211,238,.28); border-color: rgba(34,211,238,.25); }

.online {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--txt-dim); font-weight: 700;
}
.pallino {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--win);
  box-shadow: 0 0 0 0 rgba(52,211,153,.6);
  animation: batti 2s infinite;
}
@keyframes batti {
  0%   { box-shadow: 0 0 0 0 rgba(52,211,153,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}

/* ── Bonus giornaliero ───────────────────────────────────────── */

.daily {
  background: linear-gradient(135deg, rgba(251,191,36,.16), rgba(139,92,246,.14));
  border: 1px solid rgba(251,191,36,.32);
  position: relative; overflow: hidden;
}
.daily::before {
  content: ''; position: absolute; top: -60%; left: -30%;
  width: 60%; height: 220%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.16), transparent);
  transform: rotate(18deg);
  animation: luccica 3.4s infinite;
}
@keyframes luccica {
  0%   { left: -40%; }
  55%  { left: 120%; }
  100% { left: 120%; }
}
.daily-giorni { display: flex; gap: 5px; margin-top: 12px; }
.dg {
  flex: 1; text-align: center;
  padding: 7px 2px;
  border-radius: 9px;
  background: rgba(0,0,0,.28);
  border: 1px solid var(--stroke);
  font-size: 10px; font-weight: 800; color: var(--txt-faint);
}
.dg.fatto { background: rgba(52,211,153,.18); border-color: rgba(52,211,153,.4); color: var(--win); }
.dg.oggi  { background: rgba(251,191,36,.22); border-color: var(--gold); color: var(--gold); transform: scale(1.09); }

/* ══════════════════════════════════════════════════════════════
   TAVOLO DA GIOCO
   ══════════════════════════════════════════════════════════════ */

.hud {
  display: flex; align-items: stretch; gap: 9px;
  margin: 6px 0 12px;
}
.hud-box {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 13px;
  padding: 9px 12px;
  min-width: 0;
}
.hud-lbl {
  font-size: 9.5px; font-weight: 800; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--txt-faint);
}
.hud-val {
  font-size: 21px; font-weight: 900; letter-spacing: -.6px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hud-box.tempo .hud-val { color: var(--acc-2); }
.hud-box.tempo.rosso .hud-val { color: var(--lose); animation: allarme .9s infinite; }
@keyframes allarme { 50% { opacity: .35; } }

.guadagno {
  position: absolute; right: 14px; top: 4px;
  font-size: 15px; font-weight: 900; color: var(--win);
  pointer-events: none; opacity: 0;
}
.guadagno.va { animation: sali .85s var(--ease); }
@keyframes sali {
  0%   { opacity: 0; transform: translateY(6px) scale(.85); }
  25%  { opacity: 1; transform: translateY(-2px) scale(1.05); }
  100% { opacity: 0; transform: translateY(-24px) scale(1); }
}

/* Barra dell'avversario nel duello */
.sfida {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 13px;
  padding: 9px 12px;
  margin-bottom: 10px;
}
.sfida .fac { font-size: 22px; }
.sfida .chi { font-size: 12.5px; font-weight: 800; }
.sfida .pt  { font-size: 12px; color: var(--txt-dim); font-weight: 700; font-variant-numeric: tabular-nums; }
.sfida .bar {
  flex: 1; height: 7px; border-radius: 50px;
  background: rgba(0,0,0,.4); overflow: hidden;
  position: relative;
}
.sfida .bar i {
  position: absolute; inset: 0 auto 0 0;
  border-radius: 50px;
  background: linear-gradient(90deg, var(--lose), #fb7185);
  transition: width .4s var(--ease);
}
.sfida.avanti .bar i { background: linear-gradient(90deg, var(--win), #6ee7b7); }
.sfida .stato { font-size: 11px; font-weight: 800; }
.sfida.avanti .stato { color: var(--win); }

/* ── La griglia ──────────────────────────────────────────────── */

.tavolo {
  position: relative;
  width: 100%;
  aspect-ratio: 7 / 8;
  background: var(--board);
  border: 1px solid var(--stroke);
  border-radius: var(--r-l);
  padding: var(--gap, 6px);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,.05);
  touch-action: none;
  overflow: hidden;
}
.tavolo::after {
  content: ''; position: absolute; inset: 0;
  border-radius: var(--r-l);
  background: radial-gradient(70% 55% at 50% 0%, color-mix(in srgb, var(--glow) 18%, transparent), transparent 70%);
  pointer-events: none;
}

.celle {
  position: absolute; inset: var(--gap, 6px);
  display: grid;
  grid-template-columns: repeat(var(--w, 7), 1fr);
  grid-template-rows: repeat(var(--h, 8), 1fr);
  gap: var(--gap, 6px);
}
.cella {
  background: var(--cell);
  border-radius: 50%;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.35);
  opacity: .55;
}

.tessere { position: absolute; inset: var(--gap, 6px); }

/* -- Le palline ---------------------------------------------- */

.pallina {
  position: absolute;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,.55), rgba(255,255,255,0) 45%),
    linear-gradient(150deg, var(--c1), var(--c2));
  box-shadow: 0 4px 10px rgba(0,0,0,.45), inset 0 -3px 8px rgba(0,0,0,.28);
  /* Il movimento deve VEDERSI: niente scatti, la pallina scivola. */
  transition: transform .19s cubic-bezier(.34,1.4,.64,1);
  will-change: transform;
  cursor: pointer;
}
.pallina .pico {
  font-size: calc(var(--lato) * .46);
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.45));
  pointer-events: none;
}

/* Gruppo agganciato: le palline si accendono a ONDA partendo da quella toccata
   (il ritardo lo mette il JavaScript in --rit), poi restano a pulsare insieme.
   Serve a far sentire che il gruppo è un corpo solo. */
.pallina.pronta {
  box-shadow: 0 6px 16px rgba(0,0,0,.5), 0 0 0 3px #fff, inset 0 -3px 8px rgba(0,0,0,.28);
  z-index: 6;
  animation: agganciaPop .42s cubic-bezier(.34,1.6,.5,1) var(--rit, 0ms) both,
             prontaBatte 1.1s ease-in-out calc(var(--rit, 0ms) + 420ms) infinite;
}
@keyframes agganciaPop {
  0%   { filter: brightness(1); }
  45%  { filter: brightness(1.9) saturate(1.3); }
  100% { filter: brightness(1.12); }
}
@keyframes prontaBatte {
  0%, 100% { filter: brightness(1.12); }
  50%      { filter: brightness(1.5) saturate(1.25); }
}

/* alone che si allarga sulla pallina toccata, come un sasso nell'acqua */
.pallina.pronta::before {
  content: '';
  position: absolute; inset: -2px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.85);
  opacity: 0;
  animation: agganciaOnda .55s ease-out var(--rit, 0ms) both;
  pointer-events: none;
}
@keyframes agganciaOnda {
  0%   { transform: scale(.9); opacity: .9; }
  100% { transform: scale(1.55); opacity: 0; }
}

/* Targhetta con quante palline e quanti punti.
   Sta SOPRA il tavolo, fuori dal flusso: comparendo non deve spostare di un
   pixel il resto della schermata, altrimenti il tavolo balla sotto il dito. */
.anteprima {
  position: absolute;
  left: 50%; top: 10px;
  transform: translate(-50%, -8px) scale(.94);
  z-index: 14;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100% - 20px);
  overflow: hidden; text-overflow: ellipsis;
  text-align: center;
  font-size: 13.5px; font-weight: 700;
  color: var(--txt);
  padding: 9px 16px;
  border-radius: 50px;
  background: rgba(20,16,45,.92);
  border: 1px solid rgba(139,92,246,.6);
  box-shadow: 0 8px 26px rgba(0,0,0,.55), 0 0 18px rgba(139,92,246,.35);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .16s, transform .2s var(--ease);
}
.anteprima.on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.anteprima b { color: var(--acc-2); font-weight: 900; }

/* pallina isolata: una scrollata di spalle */
.pallina.nega { animation: nega .28s ease; }
@keyframes nega {
  25% { filter: brightness(.65); }
  50% { filter: brightness(1); }
  75% { filter: brightness(.65); }
}

/* caduta: un filo piu lenta e con un piccolo rimbalzo, cosi si segue con l'occhio */
.pallina.cade { transition: transform .3s cubic-bezier(.45,.05,.3,1.35); z-index: 2; }

/* LO SCOPPIO */
.pallina.scoppia {
  animation: scoppia .3s cubic-bezier(.3,0,.7,1) forwards;
  z-index: 8;
}
@keyframes scoppia {
  0%   { transform: scale(1); filter: brightness(1); }
  35%  { filter: brightness(2.1); }
  55%  { opacity: 1; }
  100% { opacity: 0; filter: brightness(2.4); }
}
.pallina.scoppia::after {
  content: '';
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 3px solid var(--c1);
  animation: onda-scoppio .3s ease-out forwards;
}
@keyframes onda-scoppio {
  from { transform: scale(.7); opacity: .9; }
  to   { transform: scale(1.9); opacity: 0; }
}

/* schegge che volano via */
.scintilla {
  position: fixed; z-index: 85;
  width: 8px; height: 8px; border-radius: 50%;
  pointer-events: none;
  animation: schizza .6s ease-out forwards;
}
@keyframes schizza {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to   { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.15); opacity: 0; }
}

/* suggerimento e martello */
.pallina.spia {
  box-shadow: 0 0 0 4px rgba(255,255,255,.9), 0 6px 16px rgba(0,0,0,.5);
  animation: spia 1s ease-in-out infinite; z-index: 5;
}
@keyframes spia { 50% { box-shadow: 0 0 0 4px rgba(255,255,255,.25), 0 6px 16px rgba(0,0,0,.5); } }
.pallina.mira { cursor: crosshair; animation: miraBatte 1.1s ease-in-out infinite; }
@keyframes miraBatte { 50% { filter: brightness(1.35) saturate(1.3); } }

/* annuncio della reazione a catena */
#catena {
  position: absolute; left: 50%; top: 42%;
  white-space: nowrap;
  transform: translate(-50%, -50%) scale(.4);
  z-index: 12; pointer-events: none; opacity: 0;
  font-size: 27px; font-weight: 900; letter-spacing: -1px;
  color: #fff;
  text-shadow: 0 0 18px var(--acc), 0 4px 12px rgba(0,0,0,.7);
}
#catena.on { animation: catenaPop 1s cubic-bezier(.22,1,.36,1); }
@keyframes catenaPop {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(.4) rotate(-8deg); }
  25%  { opacity: 1; transform: translate(-50%,-50%) scale(1.18) rotate(2deg); }
  70%  { opacity: 1; transform: translate(-50%,-60%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%,-90%) scale(.9); }
}

/* ── Suggerimento sotto la griglia ───────────────────────────── */

.consiglio {
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--txt-dim);
  padding: 9px 12px;
  margin-top: 10px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 11px;
  min-height: 38px;
  display: block;
  text-align: center;
  line-height: 1.45;
}
.consiglio b { color: var(--acc-2); }
.consiglio .mini {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 6px;
  font-size: 11.5px; font-weight: 900; color: #fff;
  background: linear-gradient(150deg, var(--c1, #0ea5e9), var(--c2, #0369a1));
}

/* ── Lezione iniziale ────────────────────────────────────────── */

.passo-fig {
  background: rgba(0,0,0,.3);
  border: 1px solid var(--stroke);
  border-radius: var(--r);
  padding: 20px 16px;
  margin: 16px 0 18px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 104px;
}
.dimo {
  width: 50px; height: 50px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,.5), rgba(255,255,255,0) 45%),
    linear-gradient(150deg, var(--c1, #38bdf8), var(--c2, #0369a1));
  box-shadow: 0 4px 10px rgba(0,0,0,.4), inset 0 -3px 8px rgba(0,0,0,.25);
  flex: 0 0 auto;
}
.dimo.vaDx { animation: vaDx 2.2s ease-in-out infinite; }
@keyframes vaDx { 0%,15% { transform: translateX(0); } 45%,100% { transform: translateX(58px); } }
.dimo.vaSx { animation: vaSx 2.2s ease-in-out infinite; }
@keyframes vaSx { 0%,15% { transform: translateX(0); } 45%,100% { transform: translateX(-58px); } }
.dimo.boom { animation: boomDemo 2.2s ease-in-out infinite; }
@keyframes boomDemo {
  0%,45%   { transform: scale(1); opacity: 1; filter: brightness(1); }
  60%      { transform: scale(1.3); filter: brightness(2.2); }
  75%,100% { transform: scale(.2); opacity: 0; }
}
.dimo.cadeDemo  { animation: cadeDemo 2.2s ease-in-out infinite; }
.dimo.cadeDemo2 { animation: cadeDemo 2.2s ease-in-out .18s infinite; }
@keyframes cadeDemo {
  0%,20%   { transform: translateY(-38px); opacity: 0; }
  45%      { transform: translateY(0); opacity: 1; }
  100%     { transform: translateY(0); opacity: 1; }
}

.freccia-giu {
  font-size: 26px;
  animation: puntagiu 1.5s ease-in-out infinite;
}
@keyframes puntagiu {
  50% { transform: translateY(9px); }
}
.punti-passo { display: flex; justify-content: center; gap: 6px; margin-bottom: 4px; }
.punto { width: 7px; height: 7px; border-radius: 50%; background: var(--stroke-2); }
.punto.on { background: var(--acc); width: 20px; border-radius: 50px; }

/* ── Scala delle tessere ─────────────────────────────────────── */

.scala { display: flex; flex-direction: column; gap: 7px; }
.scala-riga {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 8px 12px;
}
.scala-riga.presa { border-color: rgba(52,211,153,.45); background: rgba(52,211,153,.08); }
.scala-tes {
  width: 46px; height: 46px; flex: 0 0 46px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,.5), rgba(255,255,255,0) 45%),
    linear-gradient(150deg, var(--c1), var(--c2));
  box-shadow: 0 3px 8px rgba(0,0,0,.35), inset 0 -3px 6px rgba(0,0,0,.25);
}
.scala-info { flex: 1; min-width: 0; }
.scala-nome { font-size: 14px; font-weight: 800; }
.scala-nota { font-size: 11.5px; color: var(--txt-dim); }
.scala-ok { font-size: 15px; }

/* ── Barra dei poteri ────────────────────────────────────────── */

.poteri { display: flex; gap: 8px; margin: 12px 0 4px; }
.pot {
  flex: 1;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 13px;
  padding: 10px 4px 8px;
  color: var(--txt);
  transition: transform .12s var(--ease), border-color .2s;
}
.pot:active { transform: scale(.94); }
.pot .pi { font-size: 20px; display: block; }
.pot .pn { font-size: 9.5px; font-weight: 800; color: var(--txt-dim); text-transform: uppercase; letter-spacing: .4px; }
.pot .qt {
  position: absolute; top: -6px; right: -4px;
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 50px;
  background: var(--acc); color: #fff;
  font-size: 10.5px; font-weight: 900;
  display: grid; place-items: center;
  border: 2px solid var(--bg);
}
.pot.vuoto { opacity: .42; }
.pot.vuoto .qt { background: var(--txt-faint); }
.pot.attivo { border-color: var(--acc); background: rgba(139,92,246,.2); }

/* ── Navigazione in basso ────────────────────────────────────── */

.nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 40;
  display: flex;
  max-width: 520px; margin: 0 auto;
  background: rgba(12,15,32,.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--stroke);
  padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
}
.nav button {
  flex: 1; background: none; color: var(--txt-faint);
  padding: 6px 2px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .3px;
  transition: color .18s, background .18s;
}
.nav button .ni { font-size: 19px; line-height: 1; }
.nav button.on { color: var(--txt); background: var(--surface-2); }
.nav.via { display: none; }

/* ── Negozio e laboratorio ───────────────────────────────────── */

.tabs { display: flex; gap: 6px; margin: 4px 0 14px; }
.tab {
  flex: 1; padding: 9px 6px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  color: var(--txt-dim);
  font-size: 12.5px; font-weight: 800;
}
.tab.on { background: var(--surface-2); color: var(--txt); border-color: var(--stroke-2); }

.oggetto {
  display: flex; align-items: center; gap: 13px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--r);
  padding: 13px 14px;
  margin-bottom: 9px;
}
.oggetto .oi {
  width: 46px; height: 46px; flex: 0 0 46px;
  border-radius: 13px;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: 23px;
  border: 1px solid var(--stroke);
}
.oggetto .ot, .pacchetto .ot { flex: 1; min-width: 0; }
.oggetto .on, .pacchetto .on { font-size: 14.5px; font-weight: 800; letter-spacing: -.2px; }
.oggetto .od, .pacchetto .od { font-size: 11.5px; color: var(--txt-dim); line-height: 1.35; }
.oggetto .op { display: flex; align-items: center; gap: 4px; font-weight: 900; font-size: 13px; white-space: nowrap; }

.prezzo {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--stroke-2);
  border-radius: 50px;
  padding: 8px 14px;
  font-size: 13px; font-weight: 900;
  color: var(--txt);
  transition: transform .12s var(--ease);
}
.prezzo:active { transform: scale(.94); }
.prezzo.gemme  { color: var(--gem);  border-color: rgba(56,189,248,.4);  background: rgba(56,189,248,.12); }
.prezzo.monete { color: var(--gold); border-color: rgba(251,191,36,.4); background: rgba(251,191,36,.12); }
.prezzo.reale  { background: linear-gradient(135deg, var(--win), #10b981); color: #04261a; border: 0; }
.prezzo:disabled { opacity: .4; }

.livelli { display: flex; gap: 3px; margin-top: 6px; }
.lv { flex: 1; height: 5px; border-radius: 50px; background: rgba(255,255,255,.1); }
.lv.on { background: linear-gradient(90deg, var(--acc), var(--acc-2)); }

.pacchetto {
  position: relative;
  display: flex; align-items: center; gap: 13px;
  background: linear-gradient(135deg, rgba(56,189,248,.12), rgba(139,92,246,.12));
  border: 1px solid rgba(56,189,248,.28);
  border-radius: var(--r);
  padding: 15px 14px;
  margin-bottom: 10px;
}
.pacchetto .oi { background: rgba(0,0,0,.28); font-size: 26px; }
.bonus-tag {
  display: inline-block;
  background: var(--win); color: #04261a;
  font-size: 9.5px; font-weight: 900;
  padding: 2px 7px; border-radius: 50px;
  margin-left: 6px; text-transform: uppercase; letter-spacing: .4px;
}

/* ── Traguardi e inviti ─────────────────────────────────────── */

.trg { padding: 11px 0; border-bottom: 1px solid var(--stroke); }
.trg:last-child { border-bottom: 0; padding-bottom: 0; }
.trg.preso { opacity: .55; }
.trg-testa {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  font-size: 14px; margin-bottom: 7px;
}
.trg-gem { font-size: 12.5px; font-weight: 800; color: var(--gem); white-space: nowrap; }
.trg.preso .trg-gem { color: var(--win); }
.trg-barra {
  height: 6px; border-radius: 50px; background: rgba(0,0,0,.35);
  overflow: hidden; position: relative;
}
.trg-barra i {
  position: absolute; inset: 0 auto 0 0; border-radius: 50px;
  background: linear-gradient(90deg, var(--acc), var(--acc-2));
  transition: width .5s var(--ease);
}
.trg.preso .trg-barra i { background: linear-gradient(90deg, var(--win), #6ee7b7); }
.trg-conto {
  font-size: 11.5px; color: var(--txt-faint); margin-top: 5px;
  font-variant-numeric: tabular-nums;
}

.invito-card {
  background: linear-gradient(135deg, rgba(139,92,246,.18), rgba(34,211,238,.12));
  border-color: rgba(139,92,246,.4);
}
.codice-invito {
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 27px; font-weight: 800; letter-spacing: 7px;
  text-align: center; color: var(--txt);
  background: rgba(0,0,0,.32);
  border: 1px dashed var(--stroke-2);
  border-radius: 12px;
  padding: 13px 10px 13px 17px;
  user-select: all;
}

/* ── Classifica ──────────────────────────────────────────────── */

.riga-class {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 13px;
  margin-bottom: 7px;
}
.riga-class.io { border-color: var(--acc); background: rgba(139,92,246,.15); }
.pos {
  width: 27px; text-align: center;
  font-weight: 900; font-size: 13.5px; color: var(--txt-faint);
  font-variant-numeric: tabular-nums;
}
.pos.oro    { color: var(--gold); font-size: 17px; }
.pos.argento{ color: #cbd5e1; font-size: 16px; }
.pos.bronzo { color: #d97757; font-size: 15px; }
.riga-class .fac { font-size: 20px; }
.riga-class .nk { flex: 1; font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.riga-class .vl { font-weight: 900; font-size: 13.5px; font-variant-numeric: tabular-nums; }

/* ── Finestre modali ─────────────────────────────────────────── */

.velo {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5,7,16,.8);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.velo.on { display: flex; animation: sfuma .22s ease; }
@keyframes sfuma { from { opacity: 0; } }

.modale {
  width: 100%; max-width: 400px;
  background: linear-gradient(160deg, #1a1f3d, #12162c);
  border: 1px solid var(--stroke-2);
  border-radius: var(--r-l);
  padding: 24px 20px 20px;
  box-shadow: var(--shadow-lg);
  animation: entrasu .3s var(--ease);
  max-height: 88vh; overflow-y: auto;
}
@keyframes entrasu {
  from { transform: translateY(28px) scale(.96); opacity: 0; }
}
.modale h2 { margin: 0 0 4px; font-size: 21px; font-weight: 900; letter-spacing: -.5px; text-align: center; }
.modale .sub { text-align: center; color: var(--txt-dim); font-size: 13px; margin-bottom: 18px; }

.esito-ico { font-size: 52px; text-align: center; display: block; margin-bottom: 6px; }
.esito-punti {
  text-align: center;
  font-size: 44px; font-weight: 900; letter-spacing: -2px;
  background: linear-gradient(135deg, #fff, var(--acc-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  font-variant-numeric: tabular-nums;
}
.premi { display: flex; justify-content: center; gap: 9px; margin: 14px 0 18px; flex-wrap: wrap; }
.premio {
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  border-radius: 50px;
  padding: 7px 14px;
  font-size: 13px; font-weight: 800;
}

.campo { margin-bottom: 11px; }
.campo label {
  display: block; font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--txt-faint); margin-bottom: 5px;
}
.campo input {
  width: 100%;
  background: rgba(0,0,0,.32);
  border: 1px solid var(--stroke-2);
  border-radius: 11px;
  padding: 12px 14px;
  color: var(--txt);
  font-size: 15px;
  outline: 0;
  transition: border-color .18s, box-shadow .18s;
}
.campo input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(139,92,246,.22); }

.avviso {
  background: rgba(248,113,113,.14);
  border: 1px solid rgba(248,113,113,.35);
  color: #fca5a5;
  border-radius: 11px;
  padding: 10px 13px;
  font-size: 13px; font-weight: 600;
  margin-bottom: 12px;
}
.avviso.buono {
  background: rgba(52,211,153,.14);
  border-color: rgba(52,211,153,.35);
  color: #6ee7b7;
}

/* ── Ricerca avversario ──────────────────────────────────────── */

.cerca { text-align: center; padding: 30px 0 10px; }
.radar {
  width: 116px; height: 116px; margin: 0 auto 22px;
  border-radius: 50%;
  border: 2px solid rgba(139,92,246,.28);
  display: grid; place-items: center;
  font-size: 42px;
  position: relative;
}
.radar::before, .radar::after {
  content: ''; position: absolute; inset: -2px;
  border-radius: 50%;
  border: 2px solid var(--acc);
  animation: onda 2.1s var(--ease) infinite;
}
.radar::after { animation-delay: 1.05s; }
@keyframes onda {
  from { transform: scale(.7); opacity: .85; }
  to   { transform: scale(1.45); opacity: 0; }
}

/* ── Messaggi al volo ────────────────────────────────────────── */

#toast {
  position: fixed; left: 50%; bottom: 90px;
  transform: translateX(-50%) translateY(16px);
  z-index: 90;
  background: rgba(20,24,48,.97);
  border: 1px solid var(--stroke-2);
  border-radius: 13px;
  padding: 12px 18px;
  font-size: 13.5px; font-weight: 700;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s var(--ease);
  max-width: 88vw; text-align: center;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Coriandoli della vittoria ───────────────────────────────── */

.coriandolo {
  position: fixed; top: -12px; z-index: 80;
  width: 9px; height: 14px;
  pointer-events: none;
  animation: cade linear forwards;
}
@keyframes cade {
  to { transform: translateY(105vh) rotate(760deg); opacity: .15; }
}

/* ── Piè di pagina ───────────────────────────────────────────── */

.firma {
  text-align: center;
  padding: 22px 0 10px;
  font-size: 11px; color: var(--txt-faint);
}
.firma a { color: var(--txt-dim); text-decoration: none; font-weight: 700; }


/* ── Effetti delle speciali ─────────────────────────────────── */

.effetti {
  position: absolute; inset: var(--gap, 6px);
  pointer-events: none;
  z-index: 9;
  overflow: hidden;
  border-radius: var(--r-l);
}

/* la pallina speciale che sta per detonare */
.pallina.detona { animation: detona .3s ease-out forwards; z-index: 10; }
@keyframes detona {
  0%   { filter: brightness(1); }
  40%  { transform-origin: center; filter: brightness(3.5) saturate(1.5); }
  100% { filter: brightness(4); opacity: 0; }
}

/* 💣 onda d'urto: due anelli e una vampata, altrimenti sul telefono non si nota */
.fx-onda {
  position: absolute;
  border-radius: 50%;
  border: 7px solid #fecaca;
  background: radial-gradient(circle, rgba(254,202,202,.5) 0%, rgba(248,113,113,.22) 40%, transparent 62%);
  box-shadow: 0 0 60px 22px rgba(248,113,113,.75), inset 0 0 45px rgba(255,255,255,.5);
  animation: fxOnda .7s cubic-bezier(.15,.75,.3,1) forwards;
}
.fx-onda::after {
  content: '';
  position: absolute; inset: 12%;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,.95);
  animation: fxOnda2 .7s cubic-bezier(.15,.75,.3,1) forwards;
}
@keyframes fxOnda {
  0%   { transform: scale(.12); opacity: 1; border-width: 12px; }
  35%  { opacity: 1; }
  70%  { opacity: .65; }
  100% { transform: scale(1); opacity: 0; border-width: 1px; }
}
@keyframes fxOnda2 {
  0%   { transform: scale(.1); opacity: 1; }
  55%  { opacity: .75; }
  100% { transform: scale(1.15); opacity: 0; }
}
.tavolo.scossa { animation: scossa .34s ease-in-out; }
@keyframes scossa {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-4px, 3px); }
  40% { transform: translate(5px, -3px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(3px, 3px); }
}

/* 🚀 scie del razzo */
.fx-scia {
  position: absolute;
  border-radius: 50px;
  background: linear-gradient(90deg, rgba(56,189,248,0), #fff 42%, #7dd3fc 52%, #38bdf8 60%, rgba(56,189,248,0));
  box-shadow: 0 0 34px 12px rgba(56,189,248,.85);
  transition: all .26s cubic-bezier(.2,.8,.3,1);
  opacity: 1;
}
.fx-scia.vert {
  background: linear-gradient(180deg, rgba(56,189,248,0), #fff 42%, #7dd3fc 52%, #38bdf8 60%, rgba(56,189,248,0));
}
.fx-scia.svanisce { opacity: 0; transition: opacity .3s; }

/* 🌈 onda del prisma: un anello che attraversa il tavolo, non una vernice —
   deve far vedere il colore che sta spazzando via, non nascondere il gioco. */
.fx-prisma {
  position: absolute;
  width: 20px; height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  background: transparent;
  border: 10px solid var(--pc, #e879f9);
  animation: fxPrisma .8s cubic-bezier(.25,.7,.35,1) forwards;
}
@keyframes fxPrisma {
  0%   { transform: scale(1); opacity: .95; border-width: 12px;
         box-shadow: 0 0 60px 18px var(--pc, #e879f9); }
  55%  { opacity: .6; }
  100% { transform: scale(34); opacity: 0; border-width: 2px;
         box-shadow: 0 0 0 0 var(--pc, #e879f9); }
}

/* ── Palline speciali ───────────────────────────────────────── */

.pallina.speciale {
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,.6), rgba(255,255,255,0) 45%),
    linear-gradient(150deg, #4b5563, #111827);
  box-shadow: 0 4px 12px rgba(0,0,0,.55), 0 0 16px var(--sp-glow, #fff),
              inset 0 -3px 8px rgba(0,0,0,.35);
  animation: spBatte 1.6s ease-in-out infinite;
}
.pallina.sp100 { --sp-glow: #f87171; }   /* bomba */
.pallina.sp101 { --sp-glow: #38bdf8; }   /* razzo */
.pallina.sp102 { --sp-glow: #e879f9; }   /* prisma */
@keyframes spBatte {
  50% { box-shadow: 0 4px 12px rgba(0,0,0,.55), 0 0 26px var(--sp-glow, #fff),
                    inset 0 -3px 8px rgba(0,0,0,.35); }
}
.pallina.nasce-sp { animation: nasceSp .5s cubic-bezier(.22,1,.36,1); }
@keyframes nasceSp {
  0%   { transform-origin: center; filter: brightness(3); }
  100% { filter: brightness(1); }
}

/* la marea che entra dal basso */
.pallina.entra-dal-basso { animation: entraSotto .36s cubic-bezier(.22,1,.36,1); }
@keyframes entraSotto {
  from { opacity: 0; filter: brightness(2.2); }
  to   { opacity: 1; filter: brightness(1); }
}
.tavolo.marea-sale { box-shadow: var(--shadow-lg), inset 0 -14px 26px -10px rgba(248,113,113,.55); }

/* scelta delle righe prima della partita */
.scelte-righe { display: flex; flex-direction: column; gap: 7px; margin: 16px 0 4px; }
.scelta-riga {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  color: var(--txt);
  font-size: 14px;
  transition: var(--ease) .15s;
}
.scelta-riga span { font-size: 11.5px; color: var(--txt-dim); font-weight: 700; }
.scelta-riga.on {
  background: rgba(139,92,246,.2);
  border-color: var(--acc);
}
.scelta-riga.on span { color: var(--txt); }

/* ── Barra dell'obiettivo del livello ────────────────────────── */

.obb-barra {
  height: 8px; border-radius: 50px;
  background: rgba(0,0,0,.45);
  border: 1px solid var(--stroke);
  overflow: hidden;
  margin: 0 0 10px;
  position: relative;
}
.obb-barra i {
  position: absolute; inset: 0 auto 0 0;
  border-radius: 50px;
  background: linear-gradient(90deg, var(--acc), var(--acc-2));
  transition: width .45s var(--ease);
  box-shadow: 0 0 12px rgba(139,92,246,.5);
}
.obb-barra i.piena { background: linear-gradient(90deg, var(--win), #6ee7b7); }
.hud-box.verde .hud-val { color: var(--win); }
.modale .obb-barra { margin: 12px 0 6px; }

/* Partita lasciata in pausa: si riprende dal menu */
.riprendi {
  background: linear-gradient(135deg, rgba(34,211,238,.14), rgba(139,92,246,.12));
  border-color: rgba(34,211,238,.35);
}

/* ── Schermi grandi: si resta in colonna, è un gioco verticale ── */
@media (min-width: 640px) {
  #app { padding-bottom: 84px; }
  .marchio h1 { font-size: 74px; }
}

@media (max-height: 700px) {
  .marchio { padding: 8px 0 2px; }
  .marchio h1 { font-size: 48px; }
}

/* ── Chi preferisce meno movimento ───────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
