/* ============================================================
   FULLY — Componenti riutilizzabili
   bottoni, card, pill, badge, progress, header, toast, modali,
   bolla personaggio, HUD missione
   ============================================================ */

/* ---------- Bottoni ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px; padding: 0 26px;
  border: none; border-radius: var(--r-pill);
  font-weight: 800; font-size: 15px; letter-spacing: 0.2px;
  transition: transform var(--t), box-shadow var(--t), background var(--t);
  position: relative; overflow: hidden; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn--primary { color: var(--ink); background: var(--grad-gold); box-shadow: var(--shadow-gold); }
.btn--primary:hover { transform: translateY(-2px) scale(1.02); }
.btn--secondary { color: #fff; background: var(--card-2); border: 1px solid var(--border); backdrop-filter: blur(12px); }
.btn--secondary:hover { background: var(--card-3); transform: translateY(-2px); }
.btn--ghost { color: #fff; background: transparent; border: 1px solid var(--border-soft); }
.btn--blue { color: #fff; background: var(--grad-blue); box-shadow: 0 18px 36px rgba(47,143,255,0.28); }
.btn--big { min-height: 62px; padding: 0 36px; font-size: 16px; }
.btn--full { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* ---------- Pill / Badge ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 800; letter-spacing: 1.2px;
  background: var(--card-2); border: 1px solid var(--border); backdrop-filter: blur(10px);
}
.pill--gold { background: rgba(247,213,72,0.12); border-color: rgba(247,213,72,0.28); }
.pill--blue { background: rgba(47,143,255,0.16); border-color: rgba(47,143,255,0.30); }

.kicker {
  display: inline-block; font-size: 12px; font-weight: 800;
  letter-spacing: 1.8px; text-transform: uppercase; color: var(--gold);
}

/* ---------- Card glass ---------- */
.card {
  padding: 24px; border-radius: var(--r-lg);
  background: var(--card-2); border: 1px solid var(--border);
  box-shadow: 0 18px 38px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
}

/* ---------- Barra progresso ---------- */
.progress { width: 100%; height: 14px; border-radius: var(--r-pill);
  background: rgba(255,255,255,0.10); overflow: hidden; border: 1px solid var(--border-soft); }
.progress__fill { height: 100%; border-radius: var(--r-pill);
  background: var(--grad-gold); box-shadow: 0 0 18px rgba(247,213,72,0.30);
  transition: width var(--t-slow); width: 0; }

/* ---------- Header app ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  height: var(--header-h); padding: 0 18px;
  background: rgba(3,6,17,0.72); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-soft);
}
.app-header__brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 20px; letter-spacing: -0.5px; }
.app-header__brand img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; }
.app-header__nav { display: flex; align-items: center; gap: 8px; }
.app-header__chip {
  display: flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: var(--r-pill);
  background: var(--card-2); border: 1px solid var(--border-soft); font-size: 13px; font-weight: 800;
}
.app-header__chip b { color: var(--gold); }
.app-header__chip--map { cursor: pointer; border-color: rgba(247,213,72,0.5); background: rgba(247,213,72,0.12); }
.app-header__chip--map:hover { background: rgba(247,213,72,0.2); }
.app-header__chip--map b { color: var(--gold); }
.app-header__avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; color: var(--ink); background: var(--grad-gold); border: 2px solid rgba(255,255,255,0.5);
  flex: 0 0 auto;
}
/* ---------- Header compatto su telefono (evita sovrapposizioni) ---------- */
@media (max-width: 480px) {
  .app-header { padding: 0 10px; gap: 6px; }
  .app-header__brand { flex: 0 0 auto; font-size: 16px; }
  .app-header__brand span { display: none; }        /* tengo solo il logo, tolgo la scritta "Fully" */
  .app-header__brand img { width: 30px; height: 30px; }
  .app-header__nav { gap: 5px; flex: 1 1 auto; min-width: 0; justify-content: flex-end; }
  .app-header__chip { padding: 6px 8px; font-size: 12px; gap: 3px; }
  .app-header__avatar { width: 34px; height: 34px; }
}

/* ---------- Bolla personaggio ---------- */
.char-bubble {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px; border-radius: var(--r-md);
  background: var(--card-2); border: 1px solid var(--border); backdrop-filter: blur(12px);
}
.char-bubble__avatar { width: 60px; height: 60px; border-radius: 16px; object-fit: cover; flex: 0 0 auto;
  border: 1px solid var(--border); animation: charPulse 2.4s ease-in-out infinite; }
.char-bubble__body { flex: 1; }
.char-bubble__name { font-weight: 900; font-size: 15px; color: var(--gold); }
.char-bubble__text { margin-top: 4px; font-size: 15px; line-height: 1.55; color: #fff; }

/* ---------- Succo extra: feedback al tocco + entrate animate ---------- */
.card { transition: transform var(--t), box-shadow var(--t); }
.mcard:active, .world:active, .guide:active, .plan:active, .instr-chip:active { transform: scale(0.97); }
@keyframes pop-bounce { 0% { opacity: 0; transform: scale(0.5); } 60% { opacity: 1; transform: scale(1.12); } 100% { transform: scale(1); } }
.summary__art { animation: pop-bounce 0.55s cubic-bezier(0.22,1.2,0.4,1); }
@keyframes charPulse { 0%,100%{ transform: translateY(0); } 50%{ transform: translateY(-4px); } }

/* ---------- Toast ---------- */
.toast-layer {
  position: fixed; left: 0; right: 0; bottom: 22px; z-index: 9000;
  display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 13px 20px; border-radius: var(--r-pill);
  background: rgba(9,15,38,0.95); border: 1px solid var(--border);
  box-shadow: var(--shadow); font-weight: 700; font-size: 14px;
  animation: toastIn 0.3s ease, toastOut 0.3s ease forwards var(--toast-life, 2.6s);
}
.toast--ok { border-color: rgba(54,211,153,0.5); }
.toast--err { border-color: rgba(255,107,107,0.5); }
.toast--xp { border-color: rgba(247,213,72,0.55); color: var(--gold); }
@keyframes toastIn { from{ opacity:0; transform: translateY(16px);} to{opacity:1; transform:translateY(0);} }
@keyframes toastOut { to { opacity: 0; transform: translateY(16px); } }

/* ---------- Modali / dialoghi ---------- */
.modal-layer { position: fixed; inset: 0; z-index: 8000; display: none; }
.modal-layer.is-open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,5,14,0.78); backdrop-filter: blur(6px); animation: screenIn 0.3s ease; }
.modal-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(92vw, 480px); padding: 28px; border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(13,21,52,0.96), rgba(8,14,38,0.97));
  border: 1px solid var(--border); box-shadow: var(--shadow-strong);
  animation: modalIn 0.35s cubic-bezier(0.22,1,0.36,1);
}
@keyframes modalIn { from{ opacity:0; transform: translate(-50%,-46%) scale(0.96);} to{opacity:1; transform: translate(-50%,-50%) scale(1);} }

/* ---------- Stelle ---------- */
.stars { display: inline-flex; gap: 6px; }
.stars__item { font-size: 28px; color: rgba(255,255,255,0.18); transition: transform var(--t), color var(--t); }
.stars__item.is-on { color: var(--gold); text-shadow: 0 0 16px rgba(247,213,72,0.55); transform: scale(1.12);
  animation: fx-star-twinkle 2s ease-in-out infinite; }
@keyframes fx-star-twinkle {
  0%, 100% { text-shadow: 0 0 16px rgba(247,213,72,0.55); }
  50%      { text-shadow: 0 0 24px rgba(247,213,72,0.9), 0 0 40px rgba(247,213,72,0.35); }
}

/* ---------- Impostazioni: toggle + righe ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.set-row b { display: block; font-size: 16px; font-weight: 800; }
.set-row span { display: block; font-size: 13px; color: rgba(255,255,255,.65); margin-top: 2px; }
.toggle { width: 54px; height: 31px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,.1); position: relative; flex: 0 0 auto; cursor: pointer; transition: background .2s; }
.toggle i { position: absolute; top: 3px; left: 3px; width: 23px; height: 23px; border-radius: 50%; background: #fff; transition: left .2s; }
.toggle.is-on { background: var(--grad-gold); border-color: transparent; box-shadow: 0 0 10px rgba(247,213,72,.35); }
.toggle.is-on i { left: 27px; }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; }

/* striscia giornaliera */
.streak-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--r-pill);
  background: rgba(255,107,107,.14); border: 1px solid rgba(255,107,107,.35); font-size: 13px; font-weight: 800; }

/* ---------- Lettore video ---------- */
.video-overlay { position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(2,5,14,0.92); backdrop-filter: blur(6px); animation: screenIn 0.3s ease; padding: 18px; }
.video-overlay__box { width: auto; max-width: 92vw; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.video-overlay__badge { padding: 9px 16px; border-radius: var(--r-pill); background: rgba(247,213,72,0.14);
  border: 1px solid rgba(247,213,72,0.32); font-size: 12px; font-weight: 800; letter-spacing: 1.4px; }
/* Player ADATTIVO: rispetta il formato reale del video (orizzontale o verticale),
   limitato da larghezza e altezza. Un video 9:16 apparirà alto/portrait da solo,
   uno 16:9 apparirà largo — mai deformato, mai bande nere inutili. */
.video-overlay__player { display: block; width: auto; height: auto;
  max-width: min(92vw, 460px); max-height: 78dvh;
  border-radius: var(--r-lg); border: 1px solid var(--border);
  box-shadow: var(--shadow-strong); background: #000; }

/* ---------- Effetti "wow" su risposta ---------- */
.flash { position: fixed; inset: 0; z-index: 8600; pointer-events: none; animation: flashFade .6s ease forwards; }
.flash--ok { box-shadow: inset 0 0 150px rgba(54,211,153,.55); }
.flash--err { box-shadow: inset 0 0 150px rgba(255,107,107,.5); }
@keyframes flashFade { from { opacity: 1; } to { opacity: 0; } }
.sparkles { position: fixed; inset: 0; z-index: 8700; pointer-events: none; }
.sparkles i { position: absolute; color: var(--gold); font-size: 22px; font-style: normal; animation: spark .9s ease-out forwards; text-shadow: 0 0 10px rgba(247,213,72,.85); }
@keyframes spark { from { transform: translate(0,0) scale(.4); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(1.3); opacity: 0; } }
.shake { animation: appShake .4s ease; }
@keyframes appShake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }

/* ---------- Reazione personaggio ---------- */
.reactchar { position: fixed; left: 18px; bottom: 18px; z-index: 8650; pointer-events: none; }
.reactchar img { width: 104px; height: 104px; border-radius: 24px; object-fit: cover; border: 3px solid var(--gold); box-shadow: var(--shadow-strong); }
.reactchar span { position: absolute; top: -12px; right: -12px; font-size: 36px; filter: drop-shadow(0 3px 6px rgba(0,0,0,.4)); }
.reactchar.is-ok { animation: reactOk 1.35s cubic-bezier(.22,1,.36,1); }
.reactchar.is-no { animation: reactNo 1.05s ease; }
.reactchar.is-no img { border-color: var(--err); }
@keyframes reactOk {
  0%   { transform: translateY(140px) scale(.5) rotate(-8deg); opacity: 0; }
  16%  { transform: translateY(0) scale(1.3) rotate(5deg); opacity: 1; }
  30%  { transform: translateY(-26px) scale(1.08) rotate(-4deg); }
  44%  { transform: translateY(0) scale(1.18) rotate(3deg); }
  58%  { transform: translateY(-12px) scale(1.04); }
  72%  { transform: translateY(0) scale(1); }
  86%  { opacity: 1; }
  100% { transform: translateY(140px) scale(.6); opacity: 0; }
}
@keyframes reactNo {
  0%   { transform: translateY(140px) scale(.6); opacity: 0; }
  16%  { transform: translateY(0) scale(1.14); opacity: 1; }
  28%  { transform: translateX(-14px) rotate(-7deg); }
  42%  { transform: translateX(14px) rotate(7deg); }
  56%  { transform: translateX(-9px) rotate(-4deg); }
  70%  { transform: translateX(0) rotate(0); }
  100% { transform: translateY(140px) scale(.7); opacity: 0; }
}

/* ---------- Transizione WARP (entrata in un mondo) ---------- */
.warpfx { position: fixed; inset: 0; z-index: 9000; pointer-events: none; opacity: 0;
  --x: 50%; --y: 50%; --wc: #5aa9ff; transform-origin: var(--x) var(--y);
  background: radial-gradient(circle at var(--x) var(--y), var(--wc) 0%, rgba(8,12,28,0) 16%, rgba(3,6,17,0) 42%);
  animation: warp-bg .92s cubic-bezier(.55,0,.9,1) forwards; }
/* scie "iperspazio" che partono dal punto toccato e accelerano */
.warpfx::before { content: ''; position: absolute; inset: -25%; mix-blend-mode: screen; opacity: 0;
  transform-origin: var(--x) var(--y);
  background: repeating-conic-gradient(from 0deg at var(--x) var(--y), rgba(255,255,255,0) 0deg, rgba(255,255,255,.22) 1.3deg, rgba(255,255,255,0) 3deg);
  animation: warp-streaks .92s cubic-bezier(.55,0,.9,1) forwards; }
/* anelli del "tunnel temporale" che rincorrono verso di te */
.warpfx__rings { position: absolute; inset: -30%; transform-origin: var(--x) var(--y); opacity: 0; mix-blend-mode: screen;
  background: repeating-radial-gradient(circle at var(--x) var(--y), rgba(255,255,255,0) 0 13px, color-mix(in srgb, var(--wc) 65%, #fff) 13px 16px, rgba(255,255,255,0) 16px 34px);
  animation: warp-rings .92s cubic-bezier(.5,0,.9,1) forwards; }
@keyframes warp-rings { 0% { opacity: 0; transform: scale(.18) rotate(0); } 40% { opacity: .7; } 100% { opacity: 0; transform: scale(4.2) rotate(70deg); } }
/* lampo finale che copre il cambio schermata */
.warpfx::after { content: ''; position: absolute; inset: 0; background: #fff; opacity: 0; animation: warp-flash .92s ease-in forwards; }
@keyframes warp-bg { 0% { opacity: 0; transform: scale(1); } 30% { opacity: 1; } 100% { opacity: 1; transform: scale(3.6); } }
@keyframes warp-streaks { 0% { opacity: 0; transform: scale(.25) rotate(0); } 45% { opacity: .9; } 100% { opacity: .15; transform: scale(3.2) rotate(48deg); } }
@keyframes warp-flash { 0%,68% { opacity: 0; } 86% { opacity: .92; } 100% { opacity: 0; } }
.reduce-motion .warpfx { display: none; }

/* ---------- Combo ---------- */
.combo { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); z-index: 8700; pointer-events: none;
  font-size: clamp(28px,6vw,46px); font-weight: 900; letter-spacing: -1px;
  color: var(--gold); text-shadow: 0 4px 24px rgba(247,213,72,.6); animation: comboPop .95s cubic-bezier(.22,1,.36,1); }
@keyframes comboPop { 0% { transform: translate(-50%,10px) scale(.4); opacity: 0; } 25% { transform: translate(-50%,0) scale(1.15); opacity: 1; } 40% { transform: translate(-50%,0) scale(1); } 80% { opacity: 1; } 100% { transform: translate(-50%,-30px) scale(1); opacity: 0; } }

/* ---------- Coriandoli ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 8500; overflow: hidden; }
.confetti i {
  position: absolute; top: -10px; width: 10px; height: 14px; border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.2; }
}
