:root {
  --bg: #120f1d;
  --bg2: #1c1830;
  --panel: rgba(24, 20, 40, 0.92);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f2eefc;
  --muted: #a69fbf;
  --gold: #f4c15d;
  --accent: #8b6cff;
  --accent2: #47d6c4;
  --danger: #ff5d73;
  --xp: linear-gradient(90deg, #8b6cff, #c88bff);
  --hp: linear-gradient(90deg, #ff5d73, #ff9a6b);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: block; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--bg2); border-radius: 14px;
  padding: 12px 16px; font-weight: 600; transition: transform .08s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, #8b6cff, #5d43e0); border-color: transparent; box-shadow: 0 6px 24px rgba(139,108,255,.35); }
.btn.ghost { background: rgba(255,255,255,.06); }
.btn.big { width: 100%; max-width: 340px; padding: 16px; font-size: 16px; margin: 6px 0; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.small { padding: 8px 12px; font-size: 13px; }
.btn:disabled { opacity: .45; box-shadow: none; cursor: not-allowed; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); font-size: 18px; display: grid; place-items: center; backdrop-filter: blur(8px);
}

/* ---------- start ---------- */
#start-screen {
  background: radial-gradient(ellipse at 50% 20%, #3a2a7a 0%, var(--bg) 60%);
}
.start-inner { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.logo-rune { font-size: 64px; color: var(--gold); text-shadow: 0 0 30px rgba(244,193,93,.6); animation: pulse 3s ease-in-out infinite; }
h1 { font-size: 34px; margin: 8px 0; letter-spacing: .5px; }
.tagline { color: var(--muted); max-width: 340px; line-height: 1.5; margin-bottom: 24px; }
.warn-box { background: rgba(255,93,115,.12); border: 1px solid rgba(255,93,115,.4); border-radius: 12px; padding: 10px 12px; font-size: 13px; max-width: 340px; text-align: left; }
@keyframes pulse { 50% { transform: scale(1.08); opacity: .8; } }

/* ---------- map ---------- */
#map { position: absolute; inset: 0; background: #1b1b24; }
.leaflet-container { background: #1b1b24; font: inherit; }
.leaflet-tile-pane { filter: saturate(.75) brightness(.85) hue-rotate(-10deg); }
.leaflet-control-attribution { font-size: 9px; background: rgba(0,0,0,.45) !important; color: #ccc !important; }
.leaflet-control-attribution a { color: #ddd !important; }
.leaflet-control-zoom { display: none; }

.player-marker { position: relative; }
.player-marker .core { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px; border-radius: 50%; background: var(--accent2); border: 3px solid #fff; box-shadow: 0 0 12px var(--accent2); }
.player-marker .ping { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px; border-radius: 50%; background: var(--accent2); animation: ping 2s ease-out infinite; }
@keyframes ping { to { transform: scale(4); opacity: 0; } }

.poi { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; border: 2px solid rgba(255,255,255,.85); box-shadow: 0 4px 14px rgba(0,0,0,.5); animation: bob 2.4s ease-in-out infinite; }
.poi.encounter { background: radial-gradient(circle at 35% 30%, #ff8a9a, #b0253d); }
.poi.relic { background: radial-gradient(circle at 35% 30%, #ffe39a, #c28a1a); }
.poi.quest { background: radial-gradient(circle at 35% 30%, #9ff5ea, #208c80); }
.poi.in-range { box-shadow: 0 0 0 4px rgba(255,255,255,.25), 0 0 24px #fff; }
.poi.done { filter: grayscale(1); opacity: .45; animation: none; }
.poi.premium { border-color: var(--gold); }
@keyframes bob { 50% { transform: translateY(-5px); } }

#hud {
  position: absolute; top: calc(10px + var(--safe-top)); left: 10px; right: 10px; z-index: 500;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px);
}
.lvl { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 18px; background: conic-gradient(var(--accent) var(--lvlp, 0%), rgba(255,255,255,.08) 0); position: relative; flex: none; }
.lvl::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--bg2); z-index: -0; }
.lvl { isolation: isolate; }
.lvl::before { z-index: -1; }
.bars { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.bar-row { display: flex; align-items: center; gap: 6px; }
.lbl { font-size: 10px; font-weight: 700; color: var(--muted); width: 18px; }
.num { font-size: 10px; color: var(--muted); width: 54px; text-align: right; font-variant-numeric: tabular-nums; }
.bar { flex: 1; height: 7px; border-radius: 6px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 6px; transition: width .4s ease; }
.bar.xp i { background: var(--xp); }
.bar.hp i { background: var(--hp); }
.bar.enemy i { background: linear-gradient(90deg, #ff3b55, #ff8a3b); }
.wallet { display: flex; flex-direction: column; gap: 2px; font-size: 13px; text-align: right; }

#mission-chip {
  position: absolute; top: calc(78px + var(--safe-top)); left: 10px; z-index: 500; max-width: calc(100% - 120px);
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-size: 13px; text-align: left;
  max-width: calc(100% - 170px); flex-wrap: wrap; row-gap: 0; border-radius: 16px;
}
#mission-chip-progress { font-size: 11px; width: 100%; }
#mission-chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-tag { font-size: 9px; font-weight: 800; letter-spacing: 1px; color: var(--gold); }
#mission-chip.bump { animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.08); border-color: var(--gold); } }

#top-actions { position: absolute; top: calc(78px + var(--safe-top)); right: 10px; z-index: 500; display: flex; gap: 8px; align-items: center; }
.switch { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 12px; cursor: pointer; }
.switch input { display: none; }
.switch .track { width: 32px; height: 18px; border-radius: 9px; background: rgba(255,255,255,.15); position: relative; transition: background .2s; }
.switch .thumb { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(14px); }

.status-pill { position: absolute; top: calc(124px + var(--safe-top)); left: 50%; transform: translateX(-50%); z-index: 500; font-size: 12px; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); white-space: nowrap; }
.status-pill.ok { opacity: 0; pointer-events: none; transition: opacity 1s 2s; }

#sim-pad { position: absolute; right: 12px; bottom: calc(92px + var(--safe-bottom)); z-index: 500; text-align: center; }
.sim-help { font-size: 10px; color: var(--muted); background: var(--panel); padding: 4px 8px; border-radius: 8px; margin: 0 0 6px; max-width: 160px; }
.pad { display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); gap: 4px; justify-content: end; }
.pad button { border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 16px; }
.pad [data-move="n"] { grid-column: 2; grid-row: 1; }
.pad [data-move="w"] { grid-column: 1; grid-row: 2; }
.pad [data-move="e"] { grid-column: 3; grid-row: 2; }
.pad [data-move="s"] { grid-column: 2; grid-row: 3; }

#bottom-bar {
  position: absolute; left: 10px; right: 10px; bottom: calc(10px + var(--safe-bottom)); z-index: 500;
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px; gap: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(10px);
}
#bottom-bar button { background: none; border: 0; border-radius: 12px; padding: 6px 0; font-size: 20px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
#bottom-bar button span { font-size: 11px; color: var(--muted); position: relative; }
#bottom-bar button:active { background: rgba(255,255,255,.06); }
.dot { position: absolute; top: -2px; right: -8px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }

/* ---------- sheets ---------- */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 800;
  background: var(--panel); border-top: 1px solid var(--line); border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(18px + var(--safe-bottom)); backdrop-filter: blur(14px);
  transform: translateY(110%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  max-width: 560px; margin: 0 auto;
}
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.2); margin: 0 auto 10px; }
.ps-head { display: flex; gap: 12px; align-items: center; }
.ps-head .close, .panel-head .close { margin-left: auto; width: 34px; height: 34px; font-size: 14px; }
.ps-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 28px; background: rgba(255,255,255,.07); }
.ps-type { font-size: 10px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--gold); }
.ps-head h3 { margin: 2px 0 0; font-size: 19px; }
.ps-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }

.panel { max-height: 78vh; overflow-y: auto; }
.panel-head { display: flex; align-items: center; }
.panel-head h3 { margin: 0; }
.tabs-body { padding-top: 6px; }
.card { background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 10px 0; }
.card h4 { margin: 0 0 6px; font-size: 15px; }
.card p { margin: 4px 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { text-align: center; padding: 10px 4px; border-radius: 12px; background: rgba(255,255,255,.05); }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 11px; color: var(--muted); }
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.inv-item { position: relative; text-align: center; padding: 12px 6px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid var(--line); }
.inv-item .ico { font-size: 28px; }
.inv-item .nm { font-size: 12px; margin-top: 4px; }
.inv-item .qty { position: absolute; top: 6px; right: 8px; font-size: 11px; font-weight: 700; color: var(--gold); }
.inv-item button { margin-top: 6px; }
.prog { height: 8px; border-radius: 6px; background: rgba(255,255,255,.08); overflow: hidden; margin: 6px 0 2px; }
.prog i { display: block; height: 100%; background: var(--xp); }
.badge { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .8px; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; }
.badge.free { background: rgba(71,214,196,.15); color: var(--accent2); }
.badge.season { background: rgba(244,193,93,.15); color: var(--gold); border: 1px solid rgba(244,193,93,.4); }
.badge.done { background: rgba(255,255,255,.08); color: var(--muted); }
.card.season { border-color: rgba(244,193,93,.35); background: linear-gradient(160deg, rgba(244,193,93,.09), rgba(255,255,255,.03)); }
.card.locked { opacity: .75; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.model-row { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.model-row:last-child { border-bottom: 0; }
.ok-txt { color: var(--accent2); } .warn-txt { color: var(--gold); }
.setting { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-size: 14px; }

/* ---------- AR ---------- */
#ar-screen { background: #000; overflow: hidden; touch-action: none; }
#ar-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#ar-fallback-bg { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 30%, #3b3166 0%, #15121f 70%); overflow: hidden; }
.fb-grid { position: absolute; left: -50%; right: -50%; bottom: -10%; height: 60%; background-image: linear-gradient(rgba(139,108,255,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(139,108,255,.35) 1px, transparent 1px); background-size: 48px 48px; transform: perspective(400px) rotateX(62deg); transform-origin: bottom; mask-image: linear-gradient(transparent, #000 60%); -webkit-mask-image: linear-gradient(transparent, #000 60%); }
.fb-label { position: absolute; top: calc(120px + var(--safe-top)); left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); background: rgba(0,0,0,.35); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
#ar-stage { position: absolute; inset: 0; }
#ar-stage canvas { display: block; width: 100%; height: 100%; }
#ar-fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#ar-top { position: absolute; top: calc(10px + var(--safe-top)); left: 10px; right: 10px; display: flex; align-items: center; gap: 10px; }
.ar-title-wrap { flex: 1; min-width: 0; text-shadow: 0 1px 6px rgba(0,0,0,.7); }
#ar-title { font-weight: 700; font-size: 17px; }
.mini-hp { width: 110px; display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--panel); }
#ar-enemy { position: absolute; top: calc(66px + var(--safe-top)); left: 50%; transform: translateX(-50%); width: min(320px, 80%); text-align: center; text-shadow: 0 1px 6px #000; }
#ar-enemy .bar { height: 10px; border: 1px solid rgba(255,255,255,.3); }
.enemy-name { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
#ar-hint { position: absolute; left: 50%; bottom: calc(168px + var(--safe-bottom)); transform: translateX(-50%); padding: 10px 16px; border-radius: 999px; background: var(--panel); font-size: 14px; white-space: nowrap; border: 1px solid var(--line); pointer-events: none; transition: opacity .3s; }
#ar-controls { position: absolute; left: 0; right: 0; bottom: calc(20px + var(--safe-bottom)); display: flex; justify-content: center; gap: 10px; }
#ar-controls .btn { background: var(--panel); backdrop-filter: blur(8px); }
#ar-dialog { position: absolute; left: 12px; right: 12px; bottom: calc(80px + var(--safe-bottom)); max-width: 520px; margin: 0 auto; padding: 14px 16px; border-radius: 16px; background: var(--panel); border: 1px solid rgba(71,214,196,.4); }
#ar-dialog .speaker { font-size: 11px; font-weight: 800; letter-spacing: 1px; color: var(--accent2); text-transform: uppercase; }
#ar-dialog p { margin: 6px 0; line-height: 1.45; }
.tap-next { font-size: 11px; color: var(--muted); }

.float-txt { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 26px; text-shadow: 0 2px 8px #000, 0 0 2px #000; animation: floatUp .9s ease-out forwards; white-space: nowrap; }
.float-txt.crit { color: var(--gold); font-size: 34px; }
.float-txt.dmg { color: #fff; }
.float-txt.hurt { color: var(--danger); }
.float-txt.good { color: var(--accent2); }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -220%) scale(1); } }
.screen-flash { position: absolute; inset: 0; background: radial-gradient(transparent 40%, rgba(255,40,60,.55)); animation: flash .4s ease-out forwards; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

.modal { position: absolute; inset: 0; z-index: 900; background: rgba(5,4,10,.6); display: grid; place-items: center; padding: 20px; backdrop-filter: blur(4px); }
.modal-card { width: min(360px, 100%); background: var(--bg2); border: 1px solid var(--line); border-radius: 22px; padding: 22px; text-align: center; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.result-icon { font-size: 56px; }
.modal-card h2 { margin: 6px 0 10px; }
.reward-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0; }
.reward-list span { background: rgba(255,255,255,.07); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; }
.levelup { color: var(--gold); font-weight: 800; margin: 8px 0; }
.mission-done { color: var(--accent2); font-weight: 700; margin: 8px 0; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: calc(130px + var(--safe-top)); left: 0; right: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; animation: toastIn .3s ease-out, toastOut .4s ease-in 2.6s forwards; max-width: 90%; text-align: center; }
.toast.gold { border-color: rgba(244,193,93,.5); }
.toast.good { border-color: rgba(71,214,196,.5); }
.toast.bad { border-color: rgba(255,93,115,.5); }
@keyframes toastIn { from { transform: translateY(-10px); opacity: 0; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

#model-warning { position: fixed; left: 10px; bottom: calc(84px + var(--safe-bottom)); z-index: 950; max-width: 260px; font-size: 11px; padding: 8px 10px; border-radius: 10px; background: rgba(40,30,10,.88); border: 1px solid rgba(244,193,93,.4); color: #f6dca0; line-height: 1.35; cursor: pointer; }
.ar-open #model-warning { bottom: auto; top: calc(112px + var(--safe-top)); }

@media (min-width: 900px) {
  #hud { max-width: 560px; }
}
.poi.personal { border-style: dashed; border-color: var(--accent2); }

/* ---------------- Mirino iconico ---------------- */
.crosshair { --ch-size: 110px; --ch-color: #47d6c4; width: var(--ch-size); height: var(--ch-size); pointer-events: none; transition: transform .2s, filter .2s; }
.crosshair svg { width: 100%; height: 100%; overflow: visible; }
.crosshair.spin .ch-spin { transform-origin: 60px 60px; animation: chspin 8s linear infinite; }
#ar-crosshair { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3; opacity: .9; }
#ar-crosshair.locked { transform: translate(-50%, -50%) scale(.82); filter: hue-rotate(140deg) saturate(2) drop-shadow(0 0 10px #ff3b5c); }
#ar-crosshair.locked .ch-spin { animation-duration: 1.2s; }
#ar-crosshair.shot { animation: chshot .25s ease-out; }
@keyframes chspin { to { transform: rotate(360deg); } }
@keyframes chshot { 0% { transform: translate(-50%,-50%) scale(.7); } 100% { transform: translate(-50%,-50%) scale(1); } }

#ar-tracker { position: absolute; z-index: 4; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; pointer-events: none; }
#ar-tracker i { font-style: normal; font-size: 34px; color: var(--gold, #f4c15d); text-shadow: 0 0 12px #000; animation: trk 1s ease-in-out infinite; display: inline-block; }
#ar-tracker span { font-size: 11px; font-weight: 800; background: var(--panel); padding: 2px 8px; border-radius: 999px; margin-top: 2px; }
@keyframes trk { 50% { opacity: .55; } }

#ar-actions { position: absolute; left: 0; right: 0; bottom: calc(70px + var(--safe-bottom)); display: flex; justify-content: center; align-items: center; gap: 18px; z-index: 4; pointer-events: none; }
#ar-actions button { pointer-events: auto; }
.fire-btn { width: 78px; height: 78px; border-radius: 50%; border: 3px solid rgba(255,255,255,.85); background: radial-gradient(circle, rgba(255,59,92,.55), rgba(120,20,40,.75)); color: #fff; font-size: 30px; box-shadow: 0 0 20px rgba(255,59,92,.4); }
.fire-btn.locked { box-shadow: 0 0 34px #ff3b5c; transform: scale(1.06); }
.fire-btn:active { transform: scale(.92); }
.power-btn { --cd: 10s; position: relative; width: 58px; height: 58px; border-radius: 50%; border: 2px solid var(--accent2); background: rgba(20,16,36,.8); font-size: 24px; color: #fff; overflow: hidden; order: 2; }
.power-btn::after { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,.65); transform-origin: bottom; transform: scaleY(0); }
.power-btn.cooling::after { animation: cooldown var(--cd) linear forwards; }
@keyframes cooldown { from { transform: scaleY(1); } to { transform: scaleY(0); } }
#ar-shield { position: absolute; left: 50%; bottom: calc(160px + var(--safe-bottom)); transform: translateX(-50%); font-size: 40px; filter: drop-shadow(0 0 12px #47d6c4); z-index: 4; }
#ar-dialog { z-index: 6; }
#ar-gyro-fix { position: absolute; left: 50%; top: calc(120px + var(--safe-top)); transform: translateX(-50%); z-index: 7; white-space: nowrap; }

/* ---------------- Strumenti GOD ---------------- */
#ar-god { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 5; }
#ar-god button { width: 46px; height: 46px; border-radius: 14px; border: 1px solid #f4c15d; background: rgba(40,30,8,.8); color: #ffe6a8; font-size: 20px; }
.summon-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 50vh; overflow: auto; margin: 10px 0; }
.summon-list button { padding: 12px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 13px; }
.icon-btn.god { border-color: #f4c15d; color: #f4c15d; }
#god-banner { position: absolute; top: calc(130px + var(--safe-top)); left: 50%; transform: translateX(-50%); z-index: 600; background: rgba(40,30,8,.92); border: 1px solid #f4c15d; color: #ffe6a8; padding: 8px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap; }
.poi.god { border-color: #f4c15d !important; box-shadow: 0 0 16px rgba(244,193,93,.7); }
.god-form label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.god-form select, .god-form input { width: 100%; box-sizing: border-box; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 14px; }

/* ---------------- Creazione personaggio ---------------- */
#create-screen { overflow-y: auto; background: radial-gradient(ellipse at 50% 0%, #2c2160 0%, var(--bg) 55%); -webkit-overflow-scrolling: touch; }
.create-inner { max-width: 560px; margin: 0 auto; padding: calc(20px + var(--safe-top)) 16px calc(40px + var(--safe-bottom)); }
.create-inner h2 { margin: 0 0 4px; }
.cr-preview { display: flex; align-items: center; gap: 14px; background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 10px; margin: 12px 0; }
#cr-summary { font-size: 13px; color: var(--muted); line-height: 1.5; }
#cr-summary b { color: var(--text); }
.cr-label { display: block; font-size: 12px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--accent2); margin: 16px 0 8px; }
.cr-input { width: 100%; box-sizing: border-box; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 16px; }
.cr-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cr-card { text-align: left; padding: 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 13px; }
.cr-card b { display: block; font-size: 14px; margin-bottom: 2px; }
.cr-card small { color: var(--muted); display: block; line-height: 1.35; }
.cr-card .tag { display: inline-block; margin-top: 6px; font-size: 11px; color: var(--gold, #f4c15d); }
.cr-card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset, 0 0 18px rgba(139,108,255,.35); }
.cr-look { display: grid; gap: 10px; }
.cr-look > div > span { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.swatches, .pills { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(255,255,255,.2); }
.swatches button.sel { border-color: #fff; box-shadow: 0 0 0 3px var(--accent); }
.pills button { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 13px; }
.pills button.sel { background: var(--accent); border-color: var(--accent); }
.cr-ch { display: flex; gap: 14px; align-items: center; background: #0b0a12 url() center/cover; border: 1px solid var(--line); border-radius: 18px; padding: 12px; }
#cr-ch-preview { flex: none; }
.cr-ch-opts { flex: 1; display: grid; gap: 10px; min-width: 0; }
#cr-done { margin-top: 22px; max-width: none; }
#cr-cancel { width: 100%; margin-top: 8px; }
.hero-card { display: flex; gap: 12px; align-items: center; }
.locked-note { font-size: 11px; color: var(--muted); }

/* ---------------- v0.2: accesso, galleria, giocatori, buoni, attività ---------------- */
.login-box { width: 100%; max-width: 340px; display: grid; gap: 8px; }
.code-input { text-align: center; font-size: 28px; letter-spacing: 10px; font-variant-numeric: tabular-nums; }
#login-screen .start-inner, #start-screen .start-inner { min-height: 100%; }

.hud-portrait { width: 44px; height: 44px; border-radius: 12px; flex: none; padding: 0; border: 2px solid var(--hero-aura, #47d6c4); background: radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--hero-aura, #47d6c4) 45%, transparent), #120f1d 75%); overflow: hidden; box-shadow: 0 0 12px color-mix(in srgb, var(--hero-aura, #47d6c4) 50%, transparent); }
.hud-portrait img { width: 100%; height: 130%; object-fit: cover; object-position: 50% 8%; }
.hud-portrait:empty { display: none; }
.hud-rank { font-size: 11px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-rank:empty { display: none; }

.portrait { position: relative; border-radius: 18px; overflow: hidden; flex: none;
  background: radial-gradient(ellipse at 50% 85%, color-mix(in srgb, var(--aura) 55%, transparent) 0%, #0d0b16 70%);
  border: 2px solid var(--fac); box-shadow: 0 0 22px color-mix(in srgb, var(--aura) 45%, transparent), inset 0 -30px 40px rgba(0,0,0,.5); }
.portrait img { position: absolute; inset: 4% 4% 0; width: 92%; height: 96%; object-fit: contain; object-position: 50% 100%; filter: drop-shadow(0 6px 10px rgba(0,0,0,.6)); animation: breathe 3.2s ease-in-out infinite; transform-origin: 50% 100%; }
.portrait.empty { width: 110px; height: 138px; display: grid; place-items: center; font-size: 40px; color: var(--muted); border: 2px dashed var(--line); background: var(--bg2); }
@keyframes breathe { 50% { transform: scale(1.025, 0.985); } }

.lineage-tabs { margin-bottom: 6px; }
.lineage-tabs button { font-size: 12px; padding: 6px 10px; }
.lineage-info { min-height: 2.6em; margin: 4px 0 8px; }
.lineage-info .tag { color: var(--gold); font-weight: 700; margin-left: 4px; }
.char-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; max-height: 420px; overflow-y: auto; padding: 4px; border-radius: 14px; background: #0b0a12; border: 1px solid var(--line); }
.char-card { position: relative; padding: 4px 2px 6px; border-radius: 12px; border: 1px solid transparent; background: radial-gradient(ellipse at 50% 90%, #2a2346 0%, #0e0c17 70%); color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.char-card img { width: 100%; height: 104px; object-fit: contain; object-position: 50% 100%; transition: transform .2s; }
.char-card span { font-size: 10px; line-height: 1.15; text-align: center; color: var(--muted); }
.char-card:hover img { transform: translateY(-3px) scale(1.04); }
.char-card.sel { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset, 0 0 18px rgba(244,193,93,.4); }
.char-card.sel span { color: var(--gold); font-weight: 700; }

.other-player { position: relative; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--aura); background: #120f1d; overflow: visible; box-shadow: 0 0 12px var(--aura); display: grid; place-items: center; }
.other-player img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 10%; border-radius: 50%; }
.other-player span { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 2px; font-size: 10px; font-weight: 700; white-space: nowrap; background: rgba(18,15,29,.85); padding: 1px 6px; border-radius: 999px; color: #fff; }
.poi img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; border-radius: 50%; }
.poi.sponsor { background: radial-gradient(circle at 35% 30%, #ffe39a, #c26a1a); border-color: var(--gold); box-shadow: 0 0 0 3px rgba(244,193,93,.35), 0 0 22px rgba(244,193,93,.8); }
.poi.creation { background: radial-gradient(circle at 35% 30%, #fff1b8, #a8821e); }
.ps-icon img { width: 100%; height: 100%; object-fit: contain; }
.player-marker .core { background: var(--hero-aura, #47d6c4); box-shadow: 0 0 12px var(--hero-aura, #47d6c4); }

.coupon { margin: 10px 0; padding: 14px; border-radius: 16px; background: linear-gradient(135deg, #fff8e6, #f4e0b0); color: #2a1d05; text-align: center; border: 2px dashed #c28a1a; }
.coupon.used { filter: grayscale(.8); opacity: .7; }
.coupon-shop { font-weight: 800; font-size: 18px; }
.coupon-reward { font-size: 15px; margin: 4px 0 8px; }
.coupon-qr svg { width: 180px; height: 180px; background: #fff; border-radius: 8px; }
.coupon-code { font-family: ui-monospace, monospace; font-size: 22px; letter-spacing: 3px; font-weight: 800; margin: 6px 0; }
.coupon .small { color: #6b5420; }
.coupon-row { width: 100%; text-align: left; color: var(--text); }
#coupon-modal .modal-card { max-height: 90vh; overflow-y: auto; }

.villain-prev img { max-height: 140px; margin-top: 8px; border-radius: 10px; background: repeating-conic-gradient(#333 0 25%, #222 0 50%) 0 0/16px 16px; }
.shop-line { display: flex; gap: 10px; align-items: center; }
.shop-line img { width: 60px; height: 70px; object-fit: contain; border-radius: 8px; background: #0e0c17; flex: none; }
.shop-line p { margin: 0; }
.shop-admin { padding: 10px 0; border-bottom: 1px solid var(--line); }
.shop-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
#bottom-bar button { flex: 1; min-width: 0; }
