/* LumiMagic – stile base (versione statica). Mobile first. Palette: blu notte + oro. */
@font-face {
  font-family: "Cinzel";
  src: url("/fonts/cinzel-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-display: swap;
}
@font-face {
  font-family: "Cinzel";
  src: url("/fonts/cinzel-latin-800-normal.woff2") format("woff2");
  font-weight: 800; font-display: swap;
}

:root {
  --night: #0b1630;
  --night-2: #12224a;
  --night-3: #1b3163;
  --ink: #e8ecf5;
  --muted: #8a96b3;
  --gold: #f2b544;
  --gold-2: #ffd27a;
  --danger: #ff5c6c;
  --ok: #3fbf5f;
  --line: rgba(242, 181, 68, .22);
  --card: rgba(18, 34, 74, .82);
  --radius: 16px;
  --tabbar-h: 64px;
  --r-common: #f4f4f4; --r-uncommon: #3fbf5f; --r-rare: #45b3ff; --r-epic: #a35cff; --r-legendary: #ff8a1f;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); background: var(--night);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body.has-tabs { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
a { color: var(--gold); }
img { max-width: 100%; }
h1, h2, h3, .title { font-family: "Cinzel", Georgia, serif; font-weight: 600; letter-spacing: .02em; }
h1, .title { color: var(--gold); font-size: 1.6rem; margin: .2em 0 .5em; }
h2 { font-size: 1.2rem; margin: 1.2em 0 .5em; }
h3 { font-size: 1rem; margin: 1em 0 .4em; }
code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.gold { color: var(--gold); }

/* Inquadratura statica di sfondo (nella versione dinamica diventerà un video) */
.scene-bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(242,181,68,.18), transparent 55%),
    radial-gradient(ellipse at 15% 85%, rgba(69,179,255,.10), transparent 50%),
    radial-gradient(ellipse at 90% 70%, rgba(163,92,255,.10), transparent 45%),
    linear-gradient(180deg, #0b1630 0%, #060d1f 100%);
}
.scene-bg::after {
  content: ""; position: absolute; inset: 0; opacity: .5;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff8, transparent),
    radial-gradient(1px 1px at 70% 15%, #fff6, transparent),
    radial-gradient(1.5px 1.5px at 40% 70%, #ffd27a88, transparent),
    radial-gradient(1px 1px at 85% 45%, #fff5, transparent),
    radial-gradient(1px 1px at 10% 60%, #fff4, transparent);
}

/* ---------------------------------------------------------------- struttura */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(11,22,48,.88); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
@media (max-width: 420px) { .topbar-admin .brand span { display: none; } }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--gold); font-family: "Cinzel", Georgia, serif; font-weight: 800; font-size: 1.15rem; }
.topnav { display: flex; align-items: center; gap: 8px; }
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 14px 24px; }
.wrap.wide { max-width: 1000px; }
.footer { text-align: center; padding: 18px 14px 28px; color: var(--muted); }
.lang-switch { display: inline-flex; gap: 4px; background: rgba(255,255,255,.05); border-radius: 999px; padding: 4px; }
.lang-switch a { text-decoration: none; color: var(--muted); padding: 4px 10px; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.lang-switch a.active { background: var(--gold); color: var(--night); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(8,16,36,.96); border-top: 1px solid var(--line);
}
.tabbar a { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: .7rem; }
.tabbar a svg { width: 24px; height: 24px; stroke: currentColor; fill: none; }
.tabbar a.active { color: var(--gold); }
.tabbar .badge { position: absolute; top: 8px; left: 55%; min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .7rem; display: grid; place-items: center; padding: 0 4px; }

/* ---------------------------------------------------------------- componenti */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 500; }
.flash-ok { background: rgba(63,191,95,.15); border: 1px solid rgba(63,191,95,.5); }
.flash-error { background: rgba(255,92,108,.15); border: 1px solid rgba(255,92,108,.5); }
.flash-info { background: rgba(69,179,255,.12); border: 1px solid rgba(69,179,255,.45); }

.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px;
  border: 0; border-radius: 12px; cursor: pointer; text-decoration: none; font: 600 1rem system-ui, sans-serif;
  color: var(--night); background: linear-gradient(180deg, var(--gold-2), var(--gold)); box-shadow: 0 4px 14px rgba(242,181,68,.25);
}
.btn.block { display: flex; width: 100%; }
.btn.ghost { background: transparent; color: var(--gold); border: 1px solid var(--gold); box-shadow: none; }
.btn.danger { background: var(--danger); color: #fff; box-shadow: none; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > * { flex: 1; }
.pill { display: inline-block; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: .85rem; font-weight: 600; }
.pill-gold { border-color: var(--gold); color: var(--gold); }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); color: var(--gold); }
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .75rem; font-weight: 700; background: rgba(255,255,255,.1); }
.tag.ok { background: rgba(63,191,95,.2); color: #8ff0a8; }
.tag.warn { background: rgba(242,181,68,.2); color: var(--gold-2); }
.tag.bad { background: rgba(255,92,108,.2); color: #ffb3bb; }

/* ---------------------------------------------------------------- form */
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=tel],
input[type=time], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; font: inherit; color: var(--ink);
  background: rgba(6,13,31,.75); border: 1px solid rgba(255,255,255,.14);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
textarea { min-height: 100px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 22px; height: 22px; margin-top: 1px; flex: none; accent-color: var(--gold); }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px 12px; margin: 14px 0; }
legend { color: var(--gold); font-weight: 700; padding: 0 6px; }

/* ---------------------------------------------------------------- tabelle e liste */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.07); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list a.row-link { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; width: 100%; }
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,.08); text-align: left; vertical-align: top; }
.tbl th { color: var(--gold); font-weight: 600; white-space: nowrap; }

/* ---------------------------------------------------------------- avatar e gradi */
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--night-3); border: 2px solid var(--gold); flex: none; object-fit: cover; }
.avatar.lg { width: 96px; height: 96px; }
.avatar.sm { width: 40px; height: 40px; border-width: 1px; }
.grade { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; font-family: "Cinzel", Georgia, serif; font-weight: 800; font-size: 1.1rem; color: var(--night); background: var(--gold); transform: rotate(45deg); }
.grade > span { transform: rotate(-45deg); }
.grade.lg { width: 54px; height: 54px; font-size: 1.6rem; }
.grade-E { background: #9aa6c1; } .grade-D { background: #3fbf5f; } .grade-C { background: #45b3ff; }
.grade-B { background: #a35cff; } .grade-A { background: #ff8a1f; } .grade-S { background: linear-gradient(135deg, #fff2c4, #f2b544 50%, #c88a12); box-shadow: 0 0 18px rgba(242,181,68,.7); }
.progress { height: 10px; border-radius: 6px; background: rgba(255,255,255,.08); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); }

/* ---------------------------------------------------------------- scheda + swipe equipaggiamento */
.swipe { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; gap: 14px; margin: 0 -14px; padding: 0 14px; }
.swipe::-webkit-scrollbar { display: none; }
.swipe > .panel { flex: 0 0 100%; scroll-snap-align: center; min-width: 0; }
.swipe-dots { display: flex; justify-content: center; gap: 8px; margin: 6px 0 12px; }
.swipe-dots button { width: auto; min-height: 30px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: 600 .8rem system-ui; }
.swipe-dots button.active { background: var(--gold); color: var(--night); border-color: var(--gold); }

.hero { display: flex; align-items: center; gap: 14px; }
.hero .name { font-family: "Cinzel", Georgia, serif; font-size: 1.35rem; color: #fff; line-height: 1.2; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: rgba(6,13,31,.55); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.35rem; color: #fff; }
.stat span { font-size: .75rem; color: var(--muted); }
.medals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.medal { text-align: center; font-size: .75rem; color: var(--muted); }
.medal i { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 4px; border-radius: 50%; font-style: normal; font-weight: 800; color: var(--night); font-size: 1.05rem; }
.medal.gold i { background: radial-gradient(circle at 35% 30%, #fff1b8, #f2b544 60%, #a8740a); }
.medal.silver i { background: radial-gradient(circle at 35% 30%, #fff, #c9d1de 60%, #7d8798); }
.medal.bronze i { background: radial-gradient(circle at 35% 30%, #ffd5b0, #cd7f32 60%, #7a4515); }
.medal.platinum i { background: radial-gradient(circle at 35% 30%, #fff, #b9f2ff 55%, #6aa9c2); box-shadow: 0 0 12px rgba(185,242,255,.6); }
.qr-box { background: #fff; border-radius: 14px; padding: 14px; width: min(260px, 80vw); margin: 10px auto; }
.qr-box canvas, .qr-box img, .qr-box svg { display: block; width: 100%; height: auto; }

/* Equipaggiamento: sagoma con slot */
.equip { position: relative; display: grid; grid-template-columns: 1fr 76px; gap: 10px; }
.figure { position: relative; aspect-ratio: 3 / 4.4; background: rgba(6,13,31,.45); border-radius: var(--radius); border: 1px solid var(--line); }
.figure > svg.body { position: absolute; inset: 6% 18%; width: 64%; height: 88%; opacity: .5; }
.slot {
  position: absolute; width: 62px; height: 62px; transform: translate(-50%, -50%);
  border-radius: 12px; border: 2px solid rgba(255,255,255,.25); background: rgba(11,22,48,.9);
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.slot img, .slot svg { width: 70%; height: 70%; }
.slot svg { stroke: var(--muted); fill: none; opacity: .6; }
.slot.filled img { width: 88%; height: 88%; object-fit: contain; }
.slot[data-rarity=common] { border-color: var(--r-common); } .slot[data-rarity=uncommon] { border-color: var(--r-uncommon); }
.slot[data-rarity=rare] { border-color: var(--r-rare); } .slot[data-rarity=epic] { border-color: var(--r-epic); }
.slot[data-rarity=legendary] { border-color: var(--r-legendary); box-shadow: 0 0 14px rgba(255,138,31,.55); }
.slot.s-head { left: 50%; top: 11%; } .slot.s-body { left: 50%; top: 36%; } .slot.s-hands { left: 17%; top: 50%; }
.slot.s-legs { left: 50%; top: 64%; } .slot.s-feet { left: 50%; top: 89%; }
.side-slots { display: flex; flex-direction: column; gap: 10px; align-items: center; padding-top: 8px; }
.side-slots .slot { position: static; transform: none; }
.side-slots .lbl { font-size: .7rem; color: var(--muted); margin-top: -6px; }
.wand { margin-top: 14px; display: flex; align-items: center; gap: 12px; }
.wand svg.wand-img { width: 70%; height: 46px; }
.wand .slot { position: static; transform: none; flex: none; }

.rar-common { color: var(--r-common); } .rar-uncommon { color: var(--r-uncommon); } .rar-rare { color: var(--r-rare); }
.rar-epic { color: var(--r-epic); } .rar-legendary { color: var(--r-legendary); }
.item-thumb { width: 48px; height: 48px; border-radius: 10px; border: 2px solid; display: grid; place-items: center; background: rgba(6,13,31,.7); flex: none; overflow: hidden; }
.item-thumb img { width: 100%; height: 100%; object-fit: contain; }
.item-thumb svg { width: 60%; height: 60%; stroke: var(--muted); fill: none; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare > div { background: rgba(6,13,31,.55); border-radius: 12px; padding: 10px; font-size: .9rem; }
.compare h4 { margin: 0 0 6px; font-size: .75rem; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }

/* Finestra di dettaglio (bottom sheet) */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.6); display: none; }
.sheet-backdrop.open { display: block; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 86vh; overflow-y: auto; background: var(--night-2); border-top: 2px solid var(--gold); border-radius: 20px 20px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); transform: translateY(105%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; }
.sheet.open { transform: none; visibility: visible; transition: transform .25s ease; }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); margin: -6px auto 12px; }

/* Partite */
.match { display: flex; gap: 12px; align-items: center; }
.match .time { font-family: "Cinzel", Georgia, serif; font-size: 1.2rem; color: #fff; min-width: 58px; }
.seats { font-size: .8rem; color: var(--muted); }

/* Toggle grafica dinamica (presente ma disattivato) */
.gfx-toggle { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 14px 0; font-weight: 500; font-size: .85rem; color: var(--muted); }
.gfx-toggle input { display: none; }
.gfx-toggle .switch { width: 40px; height: 22px; border-radius: 11px; background: rgba(255,255,255,.12); position: relative; opacity: .6; }
.gfx-toggle .switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); }

/* Home pubblica */
.home-hero { text-align: center; padding: 26px 0 10px; }
.home-hero img.logo { width: min(320px, 85%); }
.home-hero p.lead { font-size: 1.1rem; color: #d7deee; }

/* Staff */
.scanner { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 1; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 18%; border: 3px solid var(--gold); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.net { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; }
.net i { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.net.off i { background: var(--danger); }
.seg { display: flex; background: rgba(6,13,31,.6); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 600 .9rem system-ui; }
.seg button.active { background: var(--gold); color: var(--night); }
.reg { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.07); }
.reg .grow { flex: 1; min-width: 0; }
.reg .sel { display: flex; gap: 6px; }
.reg .sel button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); font-weight: 800; }
.reg .sel button.on { background: var(--gold); color: var(--night); }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.admin-grid a { display: block; padding: 16px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600; }
.admin-grid a b { display: block; font-size: 1.4rem; color: var(--gold); }

@media (min-width: 760px) {
  .wrap { padding-top: 24px; }
  h1, .title { font-size: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Pixel art: ingrandita senza sfocature */
img[src^="/img/px/"] { image-rendering: pixelated; image-rendering: crisp-edges; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 10px; max-height: 520px; overflow-y: auto; padding: 4px; margin-top: 6px; border-radius: 12px; background: rgba(6,13,31,.45); }
.avatar-grid label { margin: 0; cursor: pointer; position: relative; display: block; }
.avatar-grid input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.avatar-grid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 2px solid transparent; }
.avatar-grid input:checked + img { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.avatar-grid input:focus-visible + img { outline: 2px solid #fff; }
.avatar { object-fit: cover; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; max-height: 280px; overflow-y: auto; padding: 4px; border-radius: 12px; background: rgba(6,13,31,.45); }
.img-grid label { margin: 0; cursor: pointer; text-align: center; }
.img-grid label { position: relative; display: block; }
.img-grid input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.img-grid img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 10px; border: 2px solid rgba(255,255,255,.12); background: rgba(11,22,48,.9); }
.img-grid input:checked + img { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.lib-card { position: relative; text-align: center; font-size: .7rem; color: var(--muted); }
.lib-card img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 10px; background: rgba(11,22,48,.9); border: 1px solid var(--line); }
img[src*="%2Fpx-"] { image-rendering: pixelated; image-rendering: crisp-edges; }

/* ===================== Equipaggiamento in stile "inventario dark fantasy" ===================== */
.doll-frame {
  --u: calc(min(100vw - 116px, 336px) / 6);
  position: relative; margin: 0 auto 10px; padding: 14px 10px; width: fit-content; border-radius: 6px;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(120, 84, 40, .35), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.015) 0 2px, rgba(0,0,0,.03) 2px 4px),
    linear-gradient(180deg, #2b1d12, #1a110a 70%, #120b06);
  border: 3px solid #5a3d1e;
  box-shadow: inset 0 0 0 1px #c9a060, inset 0 0 0 4px #2a1a0c, inset 0 0 40px rgba(0,0,0,.8), 0 10px 30px rgba(0,0,0,.5);
}
.doll-frame::before {   /* borchie decorative nei quattro angoli */
  content: ""; position: absolute; inset: 4px; pointer-events: none;
  --rivet: radial-gradient(circle, #ffe2a0 0 1.5px, #a8742a 2.5px, #4a2a0c 4px, transparent 4.5px);
  background: var(--rivet) top left / 10px 10px no-repeat, var(--rivet) top right / 10px 10px no-repeat,
              var(--rivet) bottom left / 10px 10px no-repeat, var(--rivet) bottom right / 10px 10px no-repeat;
}
.doll { display: grid; grid-template-columns: repeat(6, var(--u)); grid-template-rows: repeat(7, var(--u)); gap: 4px; }
.dslot {
  position: relative; display: grid; place-items: center; padding: 0; cursor: pointer; overflow: hidden;
  border-radius: 3px; border: 2px solid #6b4a24;
  background: radial-gradient(ellipse at 50% 40%, #241a12, #0d0905 75%);
  box-shadow: inset 0 0 0 1px #1a0f06, inset 0 0 18px rgba(0,0,0,.9), 0 0 0 1px #2a1a0c, 0 2px 4px rgba(0,0,0,.6);
  transition: box-shadow .15s, border-color .15s;
}
.dslot::after { /* filo dorato interno */
  content: ""; position: absolute; inset: 3px; border: 1px solid rgba(201,160,96,.28); border-radius: 2px; pointer-events: none;
}
.dslot:hover, .dslot:focus-visible { border-color: #c9a060; outline: none; }
.dslot svg.ghost { width: 56%; height: 56%; stroke: #8a6a40; fill: none; opacity: .5; }
.dslot .dlbl { position: absolute; bottom: 3px; left: 0; right: 0; text-align: center; font: 600 .58rem/1 "Cinzel", Georgia, serif; color: #8a6a40; letter-spacing: .04em; text-transform: uppercase; }
.dslot img { width: 82%; height: 82%; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0,0,0,.8)); position: relative; z-index: 1; }
/* oggetto equipaggiato: sfondo tinto con il colore della rarità */
.dslot.filled[data-rarity] { background: radial-gradient(ellipse at 50% 45%, var(--rc-bg), #0d0905 80%); border-color: var(--rc); box-shadow: inset 0 0 0 1px #1a0f06, inset 0 0 14px rgba(0,0,0,.8), 0 0 10px var(--rc-glow); }
.dslot[data-rarity=common]    { --rc: #b8b8b8; --rc-bg: rgba(220,220,220,.16); --rc-glow: rgba(220,220,220,.15); }
.dslot[data-rarity=uncommon]  { --rc: #3fbf5f; --rc-bg: rgba(63,191,95,.28);   --rc-glow: rgba(63,191,95,.35); }
.dslot[data-rarity=rare]      { --rc: #45b3ff; --rc-bg: rgba(69,179,255,.28);  --rc-glow: rgba(69,179,255,.4); }
.dslot[data-rarity=epic]      { --rc: #a35cff; --rc-bg: rgba(163,92,255,.30);  --rc-glow: rgba(163,92,255,.45); }
.dslot[data-rarity=legendary] { --rc: #ff8a1f; --rc-bg: rgba(255,138,31,.32);  --rc-glow: rgba(255,138,31,.6); }
/* bacchetta con zoccolo per la pietra */
.wand-slot { cursor: default; display: block; }
.wand-slot .wand-art { position: absolute; inset: 6% 18% 4%; width: 64%; height: 90%; }
.wand-slot > .dslot {   /* lo zoccolo della pietra, sulla punta della bacchetta */
  position: absolute; left: 50%; top: 6%; transform: translateX(-50%);
  width: calc(var(--u) * .95); height: calc(var(--u) * .95); border-radius: 50%; z-index: 2;
  border-color: #a8742a; background: radial-gradient(circle at 45% 40%, #2a1d12, #000 80%);
}
.wand-slot > .dslot::after { border-radius: 50%; }
.wand-slot > .dslot .dlbl { display: none; }
.wand-slot > .dslot img { width: 74%; height: 74%; }
.dslot .slot-art { width: 72%; height: 72%; opacity: .62; filter: drop-shadow(0 1px 0 rgba(0,0,0,.6)); }
.dslot:hover .slot-art { opacity: .85; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 10px; }
.lib-item { position: relative; margin: 0; cursor: pointer; text-align: center; font-size: .65rem; font-weight: 500; color: var(--muted); }
.lib-item input { position: absolute; top: 5px; left: 5px; width: 20px; height: 20px; accent-color: var(--gold); z-index: 2; }
.lib-item img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 10px; background: rgba(11,22,48,.9); border: 2px solid var(--line); }
.lib-item input:checked ~ img { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.lib-item span { display: block; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-item.off img { opacity: .35; }
.bulk-bar { position: sticky; bottom: calc(var(--tabbar-h) + 8px); display: flex; gap: 8px; align-items: center; margin-top: 12px; padding: 8px; border-radius: 12px; background: var(--night-2); border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.bulk-bar select { min-height: 38px; padding: 6px; flex: 1; }
body:not(.has-tabs) .bulk-bar { bottom: 8px; }

/* Pulsante "Scarica l'app": solo nel browser */
.install-app { margin: 12px 0 0; }
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) { .install-app { display: none !important; } }
html.is-standalone .install-app { display: none !important; }
#install-sheet ol { padding-left: 20px; line-height: 1.7; }
#install-sheet [data-os] { display: none; }
#install-sheet[data-os-show="ios"] [data-os="ios"], #install-sheet[data-os-show="android"] [data-os="android"], #install-sheet[data-os-show="other"] [data-os="other"] { display: block; }
.admin-menu { padding: 4px 16px; }
.admin-menu a { display: flex; align-items: center; gap: 10px; padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.07); color: var(--ink); text-decoration: none; font-weight: 600; }
.admin-menu a:last-child { border-bottom: 0; }

/* ===== Spazi dell'equipaggiamento su pergamena (disegni a inchiostro); gli oggetti veri restano a colori ===== */
.dslot {
  --parch: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .22 0 0 0 0 .08 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  border-color: #4a2e14;
  background: var(--parch), radial-gradient(ellipse at 40% 35%, #f6e9c8 0%, #ead5a3 45%, #d4b57a 80%, #b08a4e 100%);
  box-shadow: inset 0 0 0 1px #2a1a0c, inset 0 0 14px rgba(92,52,14,.55), inset 0 0 3px rgba(60,30,8,.7), 0 0 0 1px #1a0f06, 0 2px 5px rgba(0,0,0,.65);
}
.dslot::after { border-color: rgba(90,58,24,.35); }
.dslot:hover, .dslot:focus-visible { border-color: #c9a060; }
.dslot .slot-art { width: 86%; height: 86%; opacity: .92; filter: none; }
.dslot:hover .slot-art { opacity: 1; }
.dslot .dlbl { color: #5a3814; font-weight: 700; bottom: 4px; text-shadow: 0 0 3px #f1e2bd, 0 0 2px #f1e2bd; }
.dslot.filled[data-rarity] {
  background: radial-gradient(ellipse at 50% 50%, var(--rc-bg), transparent 72%), var(--parch), radial-gradient(ellipse at 40% 35%, #f6e9c8 0%, #ead5a3 45%, #d4b57a 80%, #b08a4e 100%);
  box-shadow: inset 0 0 0 1px #2a1a0c, inset 0 0 12px rgba(92,52,14,.5), 0 0 10px var(--rc-glow);
}
.dslot[data-rarity=common] { --rc: #9a9a9a; --rc-bg: rgba(255,255,255,.35); }
.dslot img { filter: drop-shadow(0 2px 3px rgba(40,20,5,.55)); }
.wand-slot .wand-art { inset: 4% 18% 3%; height: 93%; }
.wand-slot > .dslot { border-color: #4a2e14; border-radius: 50%; background: var(--parch), radial-gradient(circle at 45% 40%, #f6e9c8, #d4b57a 85%); }
.wand-slot > .dslot .slot-art { width: 80%; height: 80%; }
.dslot.has-lbl .slot-art { width: 78%; height: 78%; transform: translateY(-8%); }
/* avatar scelto a tutto schermo */
.avatar-zoom { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(4,8,20,0); transition: background .35s ease; cursor: pointer; }
.avatar-zoom img { width: 100vw; max-width: 100vw; max-height: 100vh; aspect-ratio: 1; object-fit: contain; opacity: 0; transform: scale(.35) rotate(-6deg); filter: drop-shadow(0 0 30px rgba(255,200,90,.35));
  transition: opacity .35s ease, transform .35s cubic-bezier(.2,1.3,.4,1), filter .35s; }
.avatar-zoom.in { background: rgba(4,8,20,.88); }
.avatar-zoom.in img { opacity: 1; transform: scale(1) rotate(0); animation: avatar-float 1.5s ease-in-out .35s both; }
.avatar-zoom.out { background: rgba(4,8,20,0); transition: background .6s ease; }
.avatar-zoom.out img { opacity: 0; transform: scale(1.12); filter: blur(6px) drop-shadow(0 0 40px rgba(255,200,90,.6)); transition: opacity .6s ease, transform .6s ease, filter .6s ease; animation: none; }
@keyframes avatar-float { 0% { transform: scale(1); } 100% { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .avatar-zoom img, .avatar-zoom.in img, .avatar-zoom.out img { transform: none !important; animation: none !important; filter: none; } }

/* pallino rosso per le novità */
.dot { position: absolute; top: 7px; left: 58%; width: 10px; height: 10px; border-radius: 50%; background: #ff3b3b; box-shadow: 0 0 0 2px #0b1428, 0 0 8px rgba(255,59,59,.8); }
.dot-inline { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #ff3b3b; box-shadow: 0 0 6px rgba(255,59,59,.8); vertical-align: middle; margin-right: 4px; }
/* presentazione creazione personaggio */
.intro-line { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; padding: 0 22px; text-align: center;
  font-family: Cinzel, serif; font-size: 1.35rem; line-height: 1.35; color: #ffe2a8; text-shadow: 0 0 14px rgba(255,190,90,.7), 0 0 2px #000;
  opacity: 0; animation: intro-line 9s ease-in-out infinite; }
.intro-line:nth-of-type(2) { animation-delay: 4.5s; }
@keyframes intro-line { 0% { opacity: 0; transform: translateY(8px); filter: blur(4px); } 10%, 40% { opacity: 1; transform: none; filter: none; } 50%, 100% { opacity: 0; transform: translateY(-8px); filter: blur(4px); } }

/* ===== Creazione personaggio a tutto schermo ===== */
body.immersive { background: radial-gradient(ellipse at 50% 110%, #2a1c08 0%, #0a1024 45%, #04070f 100%) fixed; min-height: 100vh; }
.sky-particles { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; }
.immersive-intro { position: fixed; inset: 0; z-index: 5; cursor: pointer; transition: opacity .8s ease; }
.immersive-intro .intro-line { font-size: 1.7rem; padding: 0 28px; animation: intro-once 3.8s ease-in-out both; }
.immersive-intro .intro-line:nth-of-type(2) { animation-delay: 3.8s; }
@keyframes intro-once { 0% { opacity: 0; transform: translateY(12px) scale(.97); filter: blur(6px); } 22%, 72% { opacity: 1; transform: none; filter: none; } 100% { opacity: 0; transform: translateY(-12px) scale(1.02); filter: blur(6px); } }
body.intro-done .immersive-intro { opacity: 0; pointer-events: none; }
.immersive-main { position: relative; z-index: 2; padding-top: max(24px, env(safe-area-inset-top)); opacity: 0; transform: translateY(26px); pointer-events: none; transition: opacity 1s ease .15s, transform 1s cubic-bezier(.2,.9,.3,1) .15s; }
body.intro-done .immersive-main { opacity: 1; transform: none; pointer-events: auto; }
body.no-scroll .immersive-main { transition: none; transform: none !important; }
.immersive-card { background: rgba(10,17,38,.8); border-color: rgba(255,200,110,.35); box-shadow: 0 0 40px rgba(255,180,80,.12), 0 10px 40px rgba(0,0,0,.5); }
.immersive-back { margin: 0 0 10px; }

/* ===== Scelta avatar: anteprima + scheda a tutto schermo ===== */
.avatar-current { display: flex; align-items: center; gap: 14px; width: 100%; background: none; border: 0; padding: 4px 0; color: inherit; cursor: pointer; text-align: left; }
.avatar-current img { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(255,200,90,.3); }
.avatar-sheet { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; background: #070d1f; }
.avatar-sheet[hidden] { display: none; }
.avatar-sheet .as-top { display: flex; align-items: center; gap: 12px; padding: max(12px, env(safe-area-inset-top)) 14px 12px; border-bottom: 1px solid rgba(255,200,110,.2); }
.avatar-sheet .avatar-grid { flex: 1; max-height: none; overflow-y: auto; padding: 14px; align-content: start; }
.avatar-sheet .as-bottom { padding: 12px 14px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid rgba(255,200,110,.2); background: #070d1f; }
body.no-scroll { overflow: hidden; }

/* ===== Famiglio ===== */
[data-rarity=common] { --fc: var(--r-common); } [data-rarity=uncommon] { --fc: var(--r-uncommon); } [data-rarity=rare] { --fc: var(--r-rare); }
[data-rarity=epic] { --fc: var(--r-epic); } [data-rarity=legendary] { --fc: var(--r-legendary); }
.familiar-card { display: flex; align-items: center; gap: 14px; }
.familiar-card img { width: 84px; height: 84px; object-fit: contain; border-radius: 14px; cursor: zoom-in;
  background: radial-gradient(circle, color-mix(in srgb, var(--fc) 35%, transparent), transparent 70%); filter: drop-shadow(0 0 8px color-mix(in srgb, var(--fc) 60%, transparent)); }
.familiar-reveal { position: fixed; inset: 0; z-index: 95; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--fc) 30%, #050a18) 0%, #050a18 65%); cursor: pointer; overflow: hidden;
  animation: fr-in .6s ease both; }
.familiar-reveal.out { animation: fr-out .6s ease both; }
.familiar-reveal .fr-rays { position: absolute; left: 50%; top: 45%; width: 180vmax; height: 180vmax; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--fc) 22%, transparent) 0 6deg, transparent 6deg 18deg);
  -webkit-mask: radial-gradient(circle, #000 0, transparent 55%); mask: radial-gradient(circle, #000 0, transparent 55%); animation: fr-spin 18s linear infinite; opacity: .9; }
.familiar-reveal img { position: relative; width: min(86vw, 420px); aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 0 30px var(--fc));
  animation: fr-pop 1.4s cubic-bezier(.2,1.2,.3,1) .5s both; }
.familiar-reveal .fr-title { position: relative; font-family: Cinzel, serif; font-size: 1.4rem; color: #ffe2a8; text-align: center; margin: 0 20px; text-shadow: 0 0 12px rgba(255,190,90,.6); animation: fr-fade .8s ease .2s both; }
.familiar-reveal .fr-rarity { position: relative; font-family: Cinzel, serif; font-size: 1.6rem; font-weight: 700; margin: 0; text-shadow: 0 0 16px var(--fc); animation: fr-fade .8s ease 1.6s both; }
.familiar-reveal .fr-tap { position: relative; animation: fr-fade .8s ease 2.4s both; }
@keyframes fr-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fr-out { to { opacity: 0; transform: scale(1.05); } }
@keyframes fr-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes fr-pop { 0% { opacity: 0; transform: scale(.2) rotate(-12deg); filter: brightness(3) blur(10px) drop-shadow(0 0 30px var(--fc)); } 60% { opacity: 1; transform: scale(1.06); filter: brightness(1.4) drop-shadow(0 0 40px var(--fc)); } 100% { transform: scale(1); filter: drop-shadow(0 0 30px var(--fc)); } }
@keyframes fr-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Minigiochi ===== */
body.game-body { margin: 0; background: #04070f; overflow: hidden; overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; }
.mg { position: fixed; inset: 0; }
.mg canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mg-hud { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 12px; padding: max(10px, env(safe-area-inset-top)) 14px 8px;
  font-family: Cinzel, serif; color: #ffe2a8; text-shadow: 0 0 8px rgba(255,190,90,.6); pointer-events: none; }
.mg-hud .mg-x { pointer-events: auto; color: #ffe2a8; text-decoration: none; font-size: 1.3rem; width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid rgba(255,200,110,.35); border-radius: 50%; background: rgba(4,7,15,.6); }
.mg-hud .mg-level { flex: 1; text-align: center; font-size: 1.05rem; }
.mg-hud .mg-time { min-width: 60px; text-align: right; font-variant-numeric: tabular-nums; }
.mg-panel { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 45%, rgba(20,30,70,.82), rgba(4,7,15,.94)); text-align: center; }
.mg-panel.hidden { display: none; }
.mg-panel h1 { font-family: Cinzel, serif; color: #ffe2a8; text-shadow: 0 0 16px rgba(255,190,90,.7); margin: 0 0 12px; font-size: 1.9rem; }
.mg-panel p { color: #c9d3ee; max-width: 340px; margin: 0 auto 18px; line-height: 1.45; }
.mg-panel .big { font-family: Cinzel, serif; font-size: 2.4rem; color: #fff; text-shadow: 0 0 18px rgba(120,190,255,.8); margin: 4px 0 6px; }
.mg-panel .btn { min-width: 200px; }
.mg-toast { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); font-family: Cinzel, serif; color: #ffb4b4; font-size: 1.3rem; text-shadow: 0 0 12px rgba(255,60,60,.8);
  opacity: 0; transition: opacity .3s; pointer-events: none; white-space: nowrap; }
.mg-toast.show { opacity: 1; }

.mg-hint { position: absolute; left: 12px; right: 12px; bottom: max(16px, env(safe-area-inset-bottom)); padding: 14px; border-radius: 14px; background: rgba(6,10,24,.94);
  border: 1px solid rgba(255,200,110,.35); color: #dfe6fb; font-size: .92rem; line-height: 1.4; text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.6); }
.mg-hint p { margin: 0 0 10px; }

/* controllo sensori */
.sc-level { width: 120px; height: 120px; margin: 10px auto; border-radius: 50%; border: 2px solid rgba(255,200,110,.45); position: relative;
  background: radial-gradient(circle, rgba(255,200,110,.08), transparent 70%); }
.sc-level::after { content: ''; position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px; border-radius: 50%; border: 1px dashed rgba(255,200,110,.5); }
.sc-bubble { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px; border-radius: 50%; transition: transform .08s linear;
  background: radial-gradient(circle at 35% 35%, #fff, #ffd27a 50%, #f0a040); box-shadow: 0 0 14px rgba(255,200,100,.9); }
#sensor-check.sc-good .sc-level { border-color: #3fbf5f; }
.mg-hud .mg-vibe { pointer-events: auto; font-size: 1rem; cursor: pointer; padding: 0; }
.mg-test { color: #ffcf6e !important; font-weight: 600; border: 1px dashed rgba(255,207,110,.5); border-radius: 10px; padding: 8px; }
.mg-testtag { position: absolute; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 26px); transform: translateX(-50%); font-family: system-ui, sans-serif; font-size: .65rem; letter-spacing: .15em; color: #04070f; background: #ffcf6e; border-radius: 6px; padding: 1px 6px; }
/* l'intestazione dei minigiochi (✕ per uscire, suono, vibrazione) resta sempre sopra le schermate */
.mg-hud { z-index: 5; }
.mg-panel { z-index: 4; padding-top: 70px; }
.mg-hud .mg-level { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mg-hint { z-index: 6; }
/* stelle, livelli, classifica dei minigiochi */
.mg-stars i { font-style: normal; color: rgba(255,255,255,.18); margin: 0 1px; font-size: .9rem; }
.mg-stars i.on { color: #ffd34d; text-shadow: 0 0 8px rgba(255,200,60,.8); }
.mg-stars.big i { font-size: 2.6rem; display: inline-block; }
.mg-stars.big i.on { animation: mg-star .5s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes mg-star { from { transform: scale(0) rotate(-40deg); opacity: 0; } to { transform: none; opacity: 1; } }
.mg-levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-width: 360px; margin: 0 auto 10px; max-height: 50vh; overflow-y: auto; }
.mg-levels .mg-ch { grid-column: 1 / -1; text-align: left; font-family: Cinzel, serif; color: #ffe2a8; font-size: .8rem; margin-top: 6px; }
.mg-lv { background: rgba(255,255,255,.05); border: 1px solid rgba(255,200,110,.25); border-radius: 10px; color: #dfe6fb; padding: 6px 0 4px; cursor: pointer; }
.mg-lv b { display: block; font-size: 1rem; }
.mg-lv.done { border-color: rgba(255,200,110,.6); }
.mg-lv .mg-stars i { font-size: .62rem; }
.mg-board { text-align: left; max-width: 300px; margin: 0 auto 14px; padding-left: 26px; color: #dfe6fb; }
.mg-board li { padding: 3px 0; }
.mg-board li span { display: inline-block; width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.mg-board li b { float: right; }
.mg-board li.me { color: #ffd34d; }
.mg-chap { font-family: Cinzel, serif; color: #9cc8ff; letter-spacing: .1em; margin-bottom: 6px; }
.mg-reward { color: #ffd34d !important; font-weight: 700; }
