/* ============ Animal Scanner — bestiario notturno ============ */
:root {
  --bg: #0a110d;
  --bg-2: #0f1a14;
  --panel: rgba(22, 36, 28, 0.55);
  --panel-solid: #14211a;
  --line: rgba(126, 178, 142, 0.16);
  --line-strong: rgba(126, 178, 142, 0.32);
  --ink: #eef3ea;
  --ink-soft: #aebbac;
  --ink-faint: #7d8c7e;
  --accent: #d8a24a;        /* ambra */
  --accent-2: #6fd49a;      /* verde lucciola */
  --danger: #e5564b;

  /* rarità (7 livelli) */
  --r-comune: #8b929a;       /* grigio */
  --r-noncomune: #41b65a;    /* verde */
  --r-rara: #4a8ff0;         /* blu */
  --r-epica: #b06ee8;        /* viola */
  --r-mitica: #ec4899;       /* magenta */
  --r-leggendaria: #e0922b;  /* oro */
  --r-mega: #ff5347;         /* rosso fuoco */

  --shadow: 0 24px 60px -24px rgba(0,0,0,0.7);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Spline Sans", system-ui, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, #16271d 0%, transparent 60%),
    radial-gradient(90% 60% at 85% 110%, #102b20 0%, transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* grana sottile su tutto */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

main { position: relative; z-index: 1; max-width: 640px; margin: 0 auto; padding: 0 18px 40px; }

/* ============ Topbar ============ */
.topbar {
  position: relative; z-index: 2;
  max-width: 640px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 18px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-family: var(--font-mono); font-size: 22px; color: var(--accent);
  border: 1px solid var(--line-strong); border-radius: 12px;
  width: 46px; height: 46px; display: grid; place-items: center;
  background: var(--panel); backdrop-filter: blur(6px);
  box-shadow: inset 0 0 18px rgba(216,162,74,0.12);
}
.brand-text h1 {
  font-family: var(--font-display); font-weight: 600; font-size: 22px;
  letter-spacing: -0.01em; line-height: 1;
}
.brand-text p {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-faint); margin-top: 4px;
}
.badges { display: flex; align-items: stretch; gap: 8px; }
.coins {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 14px; background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  backdrop-filter: blur(6px);
}
.coins-ico { font-size: 16px; }
.coins-num { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--accent); line-height: 1; }
.quota {
  display: flex; flex-direction: column; align-items: center;
  padding: 7px 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); backdrop-filter: blur(6px); min-width: 58px;
}
.quota-num { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--accent-2); line-height: 1; }
.quota-lbl { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); margin-top: 3px; }

/* ============ Scanner ============ */
.scanner { margin-top: 8px; }
.dropzone {
  position: relative; display: block; cursor: pointer;
  border: 1.5px dashed var(--line-strong); border-radius: 24px;
  background:
    radial-gradient(80% 60% at 50% 0%, rgba(111,212,154,0.06), transparent 70%),
    var(--panel);
  backdrop-filter: blur(10px);
  aspect-ratio: 4 / 3; overflow: hidden;
  transition: border-color .25s, box-shadow .25s, transform .25s;
}
.dropzone:focus-visible { outline: none; border-color: var(--accent-2); }
.dropzone.dragover { border-color: var(--accent-2); box-shadow: 0 0 0 4px rgba(111,212,154,0.12); }
.dropzone.has-image { border-style: solid; }

.dz-inner {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 24px;
}
.dz-ring {
  width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line-strong); margin-bottom: 12px;
  box-shadow: inset 0 0 24px rgba(111,212,154,0.1), 0 0 0 8px rgba(111,212,154,0.03);
  animation: breathe 3.4s ease-in-out infinite;
}
.dz-icon { font-size: 34px; color: var(--accent-2); }
@keyframes breathe { 0%,100% { transform: scale(1); opacity: .9 } 50% { transform: scale(1.06); opacity: 1 } }
.dz-title { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.dz-sub { font-size: 13px; color: var(--ink-soft); max-width: 240px; }

.preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* linea di scansione animata */
.scanline {
  position: absolute; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
  box-shadow: 0 0 16px 3px rgba(111,212,154,0.6);
  animation: scan 1.5s ease-in-out infinite;
}
@keyframes scan { 0% { top: 4%; } 50% { top: 96%; } 100% { top: 4%; } }

.scan-actions { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1; font-family: var(--font-body); font-weight: 600; font-size: 15px;
  padding: 14px 16px; border-radius: 14px; border: 1px solid transparent;
  cursor: pointer; transition: transform .15s, background .2s, box-shadow .2s, opacity .2s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary {
  background: linear-gradient(180deg, #e7b256, var(--accent));
  color: #2a1c05; box-shadow: 0 10px 26px -10px rgba(216,162,74,0.7);
}
.btn-primary:disabled { background: #3a3a32; color: #7d7d70; box-shadow: none; cursor: not-allowed; }
.btn-primary.is-cancel { background: linear-gradient(180deg, #ff7a6e, var(--danger)); color: #2a0c08; box-shadow: 0 10px 26px -10px rgba(229,86,75,0.7); }
.btn-ghost { background: var(--panel); color: var(--ink); border-color: var(--line-strong); backdrop-filter: blur(6px); }
.btn-ghost:hover { border-color: var(--accent-2); }
.scan-actions .btn { flex: 1; }
.btn-scan-main { width: 100%; margin-top: 10px; }

/* ===== Riquadro scanner: stato "foto rifiutata" (grande, rosso) ===== */
.dropzone.rejected {
  border-style: solid; border-color: var(--danger);
  background: radial-gradient(80% 60% at 50% 38%, rgba(229,86,75,0.14), transparent 70%), var(--panel);
  animation: rejShake .45s ease both;
}
.dropzone.rejected .dz-ring { border-color: var(--danger); box-shadow: inset 0 0 24px rgba(229,86,75,0.28); animation: none; }
.dropzone.rejected .dz-icon { color: var(--danger); }
.dropzone.rejected .dz-title { color: var(--danger); font-size: 27px; line-height: 1.1; }
.dropzone.rejected .dz-sub { color: #ffb4ac; font-size: 15.5px; max-width: 320px; }
@keyframes rejShake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-9px); } 40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); } 80% { transform: translateX(6px); }
}

.status { min-height: 20px; margin-top: 12px; text-align: center; font-size: 13.5px; color: var(--ink-soft); font-family: var(--font-mono); }
.status.error { color: var(--danger); }
.status.ok { color: var(--accent-2); }

/* ============ Collezione (dentro il modale) ============ */
.coll-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px; padding: 14px 18px 6px;
}
.coll-empty { color: var(--ink-faint); font-size: 14px; text-align: center; padding: 24px 20px; }

.cardlet {
  position: relative; border-radius: 16px; overflow: hidden; cursor: pointer;
  border: 1px solid var(--rc, var(--line)); background: var(--panel-solid);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2), 0 12px 24px -16px var(--rc, #000);
  transition: transform .2s, box-shadow .2s;
  animation: pop .35s cubic-bezier(.2,.9,.3,1.2) both;
}
.cardlet:hover { transform: translateY(-4px); box-shadow: 0 18px 30px -16px var(--rc, #000); }
@keyframes pop { from { opacity: 0; transform: scale(.9) } to { opacity: 1; transform: scale(1) } }
.cardlet img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.cardlet .cl-body { padding: 8px 10px 10px; }
.cardlet .cl-name { font-family: var(--font-display); font-weight: 600; font-size: 14px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cardlet .cl-rar { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--rc, var(--ink-faint)); margin-top: 3px; }
.cardlet .cl-glow { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 40px -10px var(--rc, transparent); }

/* ============ Scheda animale + Negozio (modale centrato) ============ */
/* IMPORTANTE: senza questa riga il `display:grid` qui sotto vincerebbe
   sull'attributo [hidden] e le finestre non si chiuderebbero mai. */
.sheet-backdrop[hidden] { display: none !important; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  padding: 16px;
  background: rgba(5,9,7,0.66); backdrop-filter: blur(6px);
  animation: fade .25s ease both;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  position: relative; width: 100%; max-width: 480px; max-height: 86dvh;
  background: linear-gradient(180deg, var(--panel-solid), #0e1812);
  border: 1px solid var(--rc, var(--line-strong));
  border-radius: 24px; box-shadow: var(--shadow), 0 0 60px -20px var(--rc, transparent);
  display: flex; flex-direction: column; overflow: hidden;
  animation: slideup .3s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes slideup { from { transform: translateY(24px) scale(.98); opacity: .5 } to { transform: translateY(0) scale(1); opacity: 1 } }
.sheet-close {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line-strong);
  background: rgba(10,17,13,0.78); color: var(--ink); font-size: 19px; font-weight: 700;
  cursor: pointer; backdrop-filter: blur(8px); line-height: 1;
  display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  transition: transform .12s, background .2s;
}
.sheet-close:hover { background: var(--danger); border-color: var(--danger); }
.sheet-close:active { transform: scale(0.92); }
.sheet-scroll { overflow-y: auto; padding-bottom: 24px; -webkit-overflow-scrolling: touch; }
.hero img { border-radius: 24px 24px 0 0; }

.hero { position: relative; }
.hero img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, #0e1812 99%); }
.hero-glow { position: absolute; inset: 0; box-shadow: inset 0 0 90px -10px var(--rc, transparent); pointer-events: none; }
.hero-cap { position: absolute; left: 20px; right: 20px; bottom: 14px; z-index: 2; }
.hero-name { font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 1.05; letter-spacing: -0.01em; }
.hero-sci { font-style: italic; font-family: var(--font-display); color: var(--ink-soft); font-size: 15px; margin-top: 2px; }

/* badge rarità + stelle */
.rar-row { display: flex; align-items: center; gap: 8px; margin: 16px 20px 4px; flex-wrap: wrap; }
.rar-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 22px;
  border: 1.4px solid var(--rc); color: var(--rc); background: color-mix(in srgb, var(--rc) 14%, transparent);
  font-weight: 700; font-size: 13.5px; letter-spacing: 0.02em;
}
.rar-stars { letter-spacing: 2px; font-size: 12px; }
.conf {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint);
  border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px;
}

/* griglia statistiche chiave */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 20px; }
.stat { border: 1px solid var(--line); border-radius: 14px; padding: 11px 13px; background: rgba(255,255,255,0.015); }
.stat .s-lbl { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); display: flex; align-items: center; gap: 5px; }
.stat .s-val { font-family: var(--font-display); font-weight: 600; font-size: 17px; margin-top: 5px; }
.stat.coins .s-val { color: var(--accent); }

/* badge pericolo */
.danger-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 8px 1px currentColor; }

/* righe informative */
.info { margin: 6px 20px; }
.info-card {
  border: 1px solid var(--line); border-radius: 14px; padding: 13px 15px; margin-top: 10px;
  background: rgba(255,255,255,0.015);
}
.info-card .i-head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.info-card .i-ico { font-size: 16px; width: 20px; text-align: center; }
.info-card .i-lbl { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.info-card .i-txt { font-size: 14.5px; color: var(--ink); line-height: 1.55; }
.info-card.good { border-color: color-mix(in srgb, var(--r-noncomune) 40%, var(--line)); }
.info-card.bad { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

.curio {
  margin: 14px 20px 4px; padding: 14px 16px; border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}
.curio .i-lbl { color: var(--accent); }

.sheet-foot { display: flex; gap: 10px; margin: 18px 20px 4px; }

/* azioni elimina nella scheda */
.btn-danger { background: rgba(229,86,75,0.12); color: #ff8e85; border: 1px solid rgba(229,86,75,0.4); }
.btn-danger:hover { background: rgba(229,86,75,0.2); }

.footer { position: relative; z-index: 1; text-align: center; font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-faint); padding: 8px 20px 120px; letter-spacing: 0.04em; }

/* ============ Barra inferiore + pulsante negozio (FAB centrale) ============ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: 84px;
  display: flex; justify-content: center; align-items: flex-end; gap: 10px; padding-bottom: 16px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(7,12,9,0.85) 60%);
}
.tab-fab {
  pointer-events: auto; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 78px; height: 78px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  background: radial-gradient(120% 120% at 50% 20%, #1c2b22, #0e1812);
  color: var(--ink);
  box-shadow: 0 12px 30px -8px rgba(216,162,74,0.55), inset 0 0 22px rgba(216,162,74,0.12);
  transform: translateY(-6px); transition: transform .15s, box-shadow .2s;
  animation: fabPulse 2.6s ease-in-out infinite;
}
.tab-fab:hover { transform: translateY(-10px); box-shadow: 0 18px 36px -8px rgba(216,162,74,0.7); }
.tab-fab:active { transform: translateY(-2px) scale(0.97); }
.tab-fab-ico { font-size: 30px; line-height: 1; margin-top: 12px; }
.tab-fab-lbl { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
@keyframes fabPulse {
  0%, 100% { box-shadow: 0 12px 30px -8px rgba(216,162,74,0.5), inset 0 0 22px rgba(216,162,74,0.12); }
  50% { box-shadow: 0 12px 38px -6px rgba(216,162,74,0.85), inset 0 0 26px rgba(216,162,74,0.2); }
}

/* pulsante Collezione: affiancato al negozio (al centro), verde */
.tab-fab-coll {
  border-color: color-mix(in srgb, var(--accent-2) 55%, transparent);
  animation: fabPulseGreen 2.6s ease-in-out infinite;
}
.tab-fab-coll .tab-fab-lbl { color: var(--accent-2); }
@keyframes fabPulseGreen {
  0%, 100% { box-shadow: 0 12px 30px -8px rgba(111,212,154,0.5), inset 0 0 22px rgba(111,212,154,0.12); }
  50% { box-shadow: 0 12px 38px -6px rgba(111,212,154,0.9), inset 0 0 26px rgba(111,212,154,0.22); }
}

/* pulsante Classifica: a sinistra del negozio, oro */
.tab-fab-lb {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  animation: fabPulse 2.6s ease-in-out infinite;
}
.tab-fab-lb .tab-fab-lbl { color: var(--accent); }

/* la scheda animale appare SOPRA il modale collezione */
#sheetBackdrop { z-index: 60; }
.coll { --rc: var(--accent-2); }
.lb { --rc: var(--accent); }

/* lista classifica */
.lb-list { display: flex; flex-direction: column; gap: 8px; padding: 14px 18px 4px; }
.lb-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,0.02);
}
.lb-row.is-me { border-color: color-mix(in srgb, var(--accent-2) 55%, transparent); background: color-mix(in srgb, var(--accent-2) 10%, transparent); }
.lb-rank { font-family: var(--font-display); font-weight: 700; font-size: 18px; min-width: 38px; text-align: center; }
.lb-name { flex: 1 1 auto; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-coins { font-family: var(--font-mono); font-size: 13.5px; color: var(--accent); white-space: nowrap; }

/* ============ Negozio ============ */
.shop { --rc: var(--accent); }
.shop-head { text-align: center; padding: 22px 20px 4px; }
.shop-emoji { font-size: 38px; display: block; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
.shop-head h2 { font-family: var(--font-display); font-weight: 700; font-size: 23px; margin-top: 4px; }
.shop-head p { color: var(--ink-soft); font-size: 13px; max-width: 340px; margin: 6px auto 0; line-height: 1.45; }
.shop-wallet {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 12px;
  font-size: 14px; color: var(--ink);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 22px; padding: 7px 14px;
}
.shop-wallet b { font-family: var(--font-display); color: var(--accent); }
.shop-sep { color: var(--ink-faint); }

/* pacchetti in righe orizzontali compatte */
.shop-grid { display: flex; flex-direction: column; gap: 10px; padding: 14px 18px 4px; }
.pack {
  position: relative; display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line-strong); border-radius: 16px;
  padding: 12px 14px; background: rgba(255,255,255,0.02);
}
.pack.best { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.pack-emoji { font-size: 30px; flex: 0 0 auto; }
.pack-info { flex: 1 1 auto; min-width: 0; text-align: left; }
.pack-scans { font-family: var(--font-display); font-weight: 700; font-size: 19px; line-height: 1.1; }
.pack-scans small { font-weight: 500; font-size: 13px; color: var(--ink-soft); }
.pack-price { display: flex; align-items: center; gap: 5px; margin-top: 2px; font-family: var(--font-mono); font-size: 13px; color: var(--accent); }
.pack-tag {
  display: inline-block; margin-left: 6px; vertical-align: middle;
  font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--accent); color: #2a1c05; padding: 2px 7px; border-radius: 20px; font-weight: 700;
}
.pack-buy {
  flex: 0 0 auto; min-width: 92px; padding: 11px 14px; border-radius: 12px; cursor: pointer;
  font-family: var(--font-body); font-weight: 700; font-size: 14px; border: none;
  background: linear-gradient(180deg, #e7b256, var(--accent)); color: #2a1c05;
  box-shadow: 0 8px 18px -8px rgba(216,162,74,0.7); transition: transform .12s, opacity .2s;
}
.pack-buy:active { transform: translateY(1px) scale(0.98); }
.pack-buy:disabled { background: #3a3a32; color: #80806f; box-shadow: none; cursor: not-allowed; }
.shop-msg { min-height: 22px; text-align: center; font-family: var(--font-mono); font-size: 13px; padding: 8px 20px 4px; color: var(--ink-soft); }
.shop-msg.ok { color: var(--accent-2); }
.shop-msg.error { color: var(--danger); }

/* ============ Distintivo PRO ============ */
.pro-badge {
  align-self: center; display: inline-flex; align-items: center; white-space: nowrap;
  padding: 7px 11px; border-radius: 12px; font-family: var(--font-display);
  font-weight: 800; font-size: 13px; letter-spacing: 0.04em;
  color: #2a1c05; background: linear-gradient(180deg, #ffd98a, var(--accent));
  border: 1px solid color-mix(in srgb, var(--accent) 70%, #fff);
  box-shadow: 0 6px 16px -6px rgba(216,162,74,0.8), inset 0 0 10px rgba(255,255,255,0.35);
  animation: proShine 2.4s ease-in-out infinite;
}
@keyframes proShine {
  0%,100% { box-shadow: 0 6px 16px -6px rgba(216,162,74,0.7), inset 0 0 10px rgba(255,255,255,0.3); }
  50% { box-shadow: 0 6px 22px -4px rgba(216,162,74,1), inset 0 0 14px rgba(255,255,255,0.5); }
}

/* ============ Tasto icona nell'header (impostazioni) ============ */
.icon-btn {
  align-self: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--ink); font-size: 18px; cursor: pointer;
  backdrop-filter: blur(6px); transition: transform .25s, border-color .2s;
}
.icon-btn:hover { border-color: var(--accent-2); transform: rotate(45deg); }

/* tasto pubblicità (non ruota, lampeggia leggermente) */
.ad-btn { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.ad-btn:hover { transform: scale(1.08); border-color: var(--accent); }

/* finestra pubblicità */
.ad { --rc: var(--accent); }
.ad-box {
  margin: 8px 20px 4px; min-height: 150px; border-radius: 16px;
  display: grid; place-items: center; text-align: center; gap: 6px; padding: 22px 18px;
  background: linear-gradient(135deg, #1d2a5a, #4a2b6b 55%, #6b2b4a);
  border: 1px solid rgba(255,255,255,0.12); position: relative; overflow: hidden;
}
.ad-box::after {
  content: "AD"; position: absolute; top: 8px; right: 10px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  background: rgba(0,0,0,0.45); color: #fff; padding: 2px 7px; border-radius: 6px;
}
.ad-box .ad-emoji { font-size: 52px; line-height: 1; }
.ad-box .ad-title2 { font-family: var(--font-display); font-weight: 800; font-size: 22px; color: #fff; }
.ad-box .ad-line { font-size: 13.5px; color: rgba(255,255,255,0.85); }

/* ============ Impostazioni ============ */
.settings { --rc: var(--accent-2); }
.settings-body { display: flex; flex-direction: column; gap: 10px; padding: 14px 20px 4px; }
.set-card { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 15px; }
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-lbl { font-size: 13.5px; color: var(--ink-soft); }
.set-val { font-family: var(--font-display); font-weight: 600; font-size: 15px; text-align: right; word-break: break-word; }
.set-action { width: 100%; margin-top: 4px; }
.lang-select {
  cursor: pointer; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: rgba(255,255,255,0.04); color: var(--ink);
  font-family: var(--font-body); font-weight: 600; font-size: 14px; max-width: 170px;
}
.lang-select:focus { outline: none; border-color: var(--accent-2); }
.lang-select option { background: var(--panel-solid); color: var(--ink); }

/* ============ Schermata di accesso ============ */
.auth {
  position: fixed; inset: 0; z-index: 100; overflow-y: auto;
  display: grid; place-items: center; padding: 24px 18px;
  background:
    radial-gradient(120% 80% at 50% -10%, #16271d 0%, transparent 60%),
    radial-gradient(90% 60% at 85% 110%, #102b20 0%, transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}
.auth[hidden] { display: none !important; }
.auth-card {
  width: 100%; max-width: 400px;
  background: linear-gradient(180deg, var(--panel-solid), #0e1812);
  border: 1px solid var(--line-strong); border-radius: 26px;
  box-shadow: var(--shadow); padding: 28px 22px 22px;
  animation: slideup .4s cubic-bezier(.2,.8,.2,1) both;
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-emoji { font-size: 44px; display: block; animation: bob 2.6s ease-in-out infinite; }
.auth-brand h1 { font-family: var(--font-display); font-weight: 700; font-size: 27px; margin-top: 6px; letter-spacing: -0.01em; }
.auth-brand p { color: var(--ink-soft); font-size: 13.5px; margin-top: 6px; }

.auth-tabs {
  display: flex; gap: 6px; padding: 5px; margin-bottom: 18px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: 14px;
}
.auth-tab {
  flex: 1; padding: 10px; border: none; border-radius: 10px; cursor: pointer;
  font-family: var(--font-body); font-weight: 700; font-size: 14px;
  background: transparent; color: var(--ink-soft); transition: background .2s, color .2s;
}
.auth-tab.is-active { background: color-mix(in srgb, var(--accent-2) 18%, transparent); color: var(--ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-2) 40%, transparent); }

.auth-form { display: flex; flex-direction: column; gap: 13px; }
.auth-form[hidden] { display: none; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }
.field input {
  width: 100%; padding: 13px 14px; border-radius: 13px;
  border: 1.5px solid var(--line-strong); background: rgba(255,255,255,0.03);
  color: var(--ink); font-family: var(--font-body); font-size: 16px;
  transition: border-color .2s, box-shadow .2s;
}
.field input::placeholder { color: var(--ink-faint); }
.field input:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 15%, transparent); }
#verifyCode { text-align: center; font-family: var(--font-mono); font-size: 26px; letter-spacing: 10px; padding-left: 24px; }

.auth-btn {
  margin-top: 6px; padding: 14px; border-radius: 13px; border: none; cursor: pointer;
  font-family: var(--font-body); font-weight: 700; font-size: 15.5px;
  background: linear-gradient(180deg, #84e3b0, var(--accent-2)); color: #08160e;
  box-shadow: 0 10px 24px -10px rgba(111,212,154,0.7); transition: transform .14s;
}
.auth-btn:active { transform: translateY(1px) scale(0.99); }
.auth-link {
  background: none; border: none; cursor: pointer; color: var(--ink-soft);
  font-family: var(--font-body); font-size: 13px; padding: 4px; text-decoration: underline;
}
.auth-link:hover { color: var(--accent-2); }
.verify-info { color: var(--ink-soft); font-size: 13.5px; line-height: 1.5; text-align: center; margin-bottom: 2px; }
.auth-msg { min-height: 20px; text-align: center; font-family: var(--font-mono); font-size: 12.5px; margin-top: 12px; color: var(--ink-soft); }
.auth-msg.ok { color: var(--accent-2); }
.auth-msg.error { color: var(--danger); }

/* ===== Avatar nell'header ===== */
.brand-mark { position: relative; overflow: hidden; }
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

/* ===== 4 pulsanti in basso (centrati) ===== */
.tabbar { gap: 8px; }
.tab-fab { width: 72px; height: 72px; }
.tab-fab-arena { border-color: color-mix(in srgb, var(--r-mega) 55%, transparent); animation: fabPulse 2.6s ease-in-out infinite; }
.tab-fab-arena .tab-fab-lbl { color: var(--r-mega); }

/* ===== Avatar + rimozione in classifica ===== */
.lb-av { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; }
.lb-av-ph { display: grid; place-items: center; font-size: 16px; background: rgba(255,255,255,0.05); }
.lb-del { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; border: 1px solid rgba(229,86,75,.4); background: rgba(229,86,75,.12); color: #ff8e85; cursor: pointer; font-size: 13px; }
.lb-del:hover { background: rgba(229,86,75,.25); }

/* ===== Fotocamera in-app ===== */
.cam-wrap { margin: 8px 20px; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; }
.cam-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ===== Arena (gioco di carte) ===== */
.ar-rounds { display: flex; flex-direction: column; gap: 10px; padding: 6px 18px; }
.ar-round { border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.ar-rlabel { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px; text-align: center; }
.ar-vs { display: flex; align-items: center; gap: 8px; }
.ar-card { flex: 1; min-width: 0; border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 8px; text-align: center; background: rgba(255,255,255,0.02); }
.ar-card img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; }
.ar-emoji { font-size: 46px; line-height: 1; }
.ar-nm { font-family: var(--font-display); font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ar-st { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.ar-mid { font-family: var(--font-display); font-weight: 800; color: var(--ink-faint); font-size: 13px; }
.ar-reward { text-align: center; color: var(--accent); font-family: var(--font-display); font-weight: 700; font-size: 18px; margin: 6px 0; }

@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr; }
  .tab-fab { width: 66px; height: 66px; }
  .tab-fab-ico { font-size: 26px; }
}
