/* Design System Playable Cards — mobile first, stile game */
@font-face {
  font-family: 'Plumpfull';
  src: url('../fonts/Plumpfull.woff') format('woff'); /* self-hosted: il CDN di playablecards.com non manda header CORS */
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --background: 215 87% 11%;
  --foreground: 210 40% 96%;
  --card: 217 33% 17%;
  --card-2: 217 33% 14%;
  --primary: 48 96% 53%;
  --primary-dark: 40 90% 38%;
  --primary-foreground: 215 87% 11%;
  --secondary: 217 33% 22%;
  --secondary-dark: 217 33% 12%;
  --secondary-foreground: 215 20% 80%;
  --muted-foreground: 215 16% 60%;
  --accent: 217 33% 26%;
  --destructive: 0 72% 51%;
  --border: 215 25% 27%;
  --ring: 48 96% 53%;
  --radius: 1rem;
  --card-yellow: 48 96% 53%;
  --card-blue: 217 91% 60%;
  --card-red: 0 72% 51%;
  --card-green: 142 71% 45%;
  --ok: 142 71% 45%;
  --ok-dark: 142 71% 28%;
  --dock-h: 0px;
  --bb-h: 0px;
}

* { box-sizing: border-box; border-color: hsl(var(--border)); }
/* manipulation evita lo zoom da doppio tap su iOS (i tap rapidi sui nodi/celle sono frequenti);
   le legature sono disattivate perché il glifo "fi" di Plumpfull sembra "FI" maiuscolo */
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
/* Plumpfull registra la legatura "fi" (che sembra "FI") anche come rlig/calt;
   i button non ereditano le proprietà tipografiche, quindi la regola va anche su di loro */
html, button, input, select, textarea {
  font-variant-ligatures: none;
  font-feature-settings: 'liga' 0, 'clig' 0, 'dlig' 0, 'rlig' 0, 'calt' 0, 'hlig' 0;
}

body {
  margin: 0;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  background-image: url('https://playablecards.com/img/Stelle.svg');
  background-position: center;
  background-repeat: repeat;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: 'Plumpfull', 'Nunito', sans-serif;
  color: hsl(var(--primary));
  margin: 0 0 .5rem;
  letter-spacing: .02em;
  font-weight: normal;
}

a { color: hsl(var(--primary)); }
p { line-height: 1.55; margin: 0 0 .8rem; }
.muted { color: hsl(var(--muted-foreground)); }
.center { text-align: center; }
.hidden { display: none !important; }
.desktop-only { display: none; }
.page-title { font-size: 1.5rem; margin: .6rem 0 .8rem; }

main {
  flex: 1; width: 100%; max-width: 920px; margin: 0 auto;
  padding: .9rem .9rem calc(1.5rem + var(--dock-h) + var(--bb-h));
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .55rem .9rem;
  padding-top: max(.55rem, env(safe-area-inset-top));
  background: hsl(var(--background) / .9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid hsl(var(--border));
  position: sticky; top: 0; z-index: 50;
}
.brand { background: none; border: none; cursor: pointer; padding: 0; display: flex; align-items: center; gap: .5rem; }
.brand-crown { width: 32px; height: 32px; border-radius: 50%; }
.brand-title { font-family: 'Plumpfull', sans-serif; color: hsl(var(--foreground)); font-size: 1.05rem; white-space: nowrap; }
.brand-title em { color: hsl(var(--primary)); font-style: normal; }
.topnav { display: flex; align-items: center; gap: .4rem; }
.nav-btn {
  background: none; border: none; color: hsl(var(--secondary-foreground));
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .92rem;
  padding: .4rem .6rem; border-radius: 999px; cursor: pointer;
}
.nav-btn:hover { color: hsl(var(--primary)); }
.pill { background: hsl(var(--secondary)); border-radius: 999px; padding: .1rem .5rem; font-size: .75rem; color: hsl(var(--primary)); font-weight: 800; }
.points-pill {
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  font-weight: 800; border-radius: 999px; padding: .32rem .75rem; font-size: .9rem; white-space: nowrap;
  box-shadow: 0 3px 0 hsl(var(--primary-dark));
  display: inline-flex; align-items: center; gap: .3rem;
}
.points-pill.bump { animation: bump .45s; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* ---------- bottoni game-like ---------- */
.btn {
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .98rem;
  border-radius: 14px; padding: .75rem 1.4rem; cursor: pointer;
  border: none; text-decoration: none; display: inline-block; text-transform: uppercase; letter-spacing: .03em;
}
.btn-primary {
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  box-shadow: 0 4px 0 hsl(var(--primary-dark));
}
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 hsl(var(--primary-dark)); }
.btn-ghost {
  background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground));
  box-shadow: 0 4px 0 hsl(var(--secondary-dark));
}
.btn-ghost:active { transform: translateY(3px); box-shadow: 0 1px 0 hsl(var(--secondary-dark)); }
.btn-link { background: none; border: none; color: hsl(var(--muted-foreground)); font-weight: 700; cursor: pointer; text-transform: none; letter-spacing: 0; box-shadow: none; }
.icon-btn {
  background: hsl(var(--secondary)); border: none; color: hsl(var(--foreground));
  width: 42px; height: 42px; border-radius: 12px; font-size: 1.05rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 3px 0 hsl(var(--secondary-dark)); font-weight: 800;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 hsl(var(--secondary-dark)); }

/* ---------- Magnus (dosato) ---------- */
.magnus-line { display: flex; gap: .7rem; align-items: center; margin: .8rem 0 1rem; }
.magnus-line img {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid hsl(var(--primary));
  animation: bob 3.4s ease-in-out infinite;
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.magnus-line p {
  margin: 0; font-size: .92rem; line-height: 1.45; font-style: italic;
  color: hsl(var(--secondary-foreground));
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: 14px; border-top-left-radius: 4px; padding: .6rem .85rem; flex: 1;
}

/* ---------- percorso ---------- */
.path { position: relative; max-width: 380px; margin: .4rem auto 1.5rem; }
.path-svg { position: absolute; top: 0; left: 0; z-index: 0; pointer-events: none; }
.path-svg .seg {
  fill: none; stroke: hsl(var(--secondary)); stroke-width: 13; stroke-linecap: round;
  stroke-dasharray: 0.1 24;
}
.path-svg .seg.on { stroke: hsl(var(--primary)); stroke-dasharray: none; stroke-width: 11; opacity: .9; }
.path-level { position: relative; text-align: center; margin: 2.4rem 0 2.2rem; z-index: 1; }
.path-level span {
  position: relative; background: hsl(var(--secondary)); color: hsl(var(--primary));
  font-family: 'Plumpfull', sans-serif; font-size: .95rem; letter-spacing: .03em;
  padding: .45rem 1.2rem; border-radius: 999px; box-shadow: 0 3px 0 hsl(var(--secondary-dark));
}
.path-node { position: relative; display: flex; flex-direction: column; align-items: center; margin: 2.3rem 0; z-index: 1; }
.node-btn { background: none; border: none; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; transform: translateX(var(--off, 0)); }
.node-circle {
  width: 76px; height: 76px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 1.7rem;
  background: hsl(var(--card)); box-shadow: 0 6px 0 hsl(var(--secondary-dark)), inset 0 -4px 0 hsl(215 87% 8% / .35);
  position: relative; transition: transform .12s;
}
.node-btn:active .node-circle { transform: translateY(4px); box-shadow: 0 2px 0 hsl(var(--secondary-dark)); }
.node-btn.locked { cursor: default; }
.node-btn.locked .node-circle {
  background: hsl(217 33% 19%); color: hsl(var(--muted-foreground));
  box-shadow: 0 6px 0 hsl(var(--secondary-dark)), inset 0 -4px 0 hsl(215 87% 8% / .35);
}
.node-btn.locked .node-circle, .node-btn.locked .node-title { filter: grayscale(.5); }
.node-btn.done .node-circle {
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); font-weight: 800;
  box-shadow: 0 6px 0 hsl(var(--primary-dark)), inset 0 -4px 0 hsl(215 87% 8% / .2);
}
.node-btn.active .node-circle {
  background: hsl(var(--primary)); box-shadow: 0 6px 0 hsl(var(--primary-dark)), inset 0 -4px 0 hsl(215 87% 8% / .2);
}
.node-btn.active .node-circle::after {
  content: ''; position: absolute; inset: -9px; border-radius: 50%;
  border: 3px solid hsl(var(--primary) / .55); animation: ring 1.6s infinite;
}
@keyframes ring { 0% { transform: scale(.92); opacity: 1; } 70% { transform: scale(1.08); opacity: .2; } 100% { transform: scale(.92); opacity: 1; } }
.node-stars {
  font-size: .85rem; color: hsl(var(--primary)); letter-spacing: .1em; margin-top: .35rem;
  position: relative; z-index: 1; background: hsl(var(--background)); padding: 0 .35rem; border-radius: 6px;
}
.node-title {
  font-size: .8rem; font-weight: 800; color: hsl(var(--secondary-foreground)); margin-top: .25rem;
  max-width: 140px; text-align: center; line-height: 1.25;
  position: relative; z-index: 1; background: hsl(var(--background)); padding: .1rem .45rem; border-radius: 6px;
}
.node-btn.active .node-circle { animation: nfloat 2.6s ease-in-out infinite; }
@keyframes nfloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.node-btn.locked .node-title { color: hsl(var(--muted-foreground)); }

/* ---------- promo ---------- */
.promo {
  margin: 2rem auto 0; max-width: 460px;
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: var(--radius); padding: 1.1rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
}
.promo-crown { width: 52px; height: 52px; border-radius: 50%; }
.promo h2 { font-size: 1.05rem; margin: .3rem 0 .2rem; }
.promo p { color: hsl(var(--secondary-foreground)); font-size: .88rem; margin-bottom: .8rem; }

/* ---------- puzzle ---------- */
.pz-top { display: flex; align-items: center; gap: .55rem; margin-top: .3rem; }
.pz-title { flex: 1; min-width: 0; }
.pz-title h2 { margin: 0; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pz-title span { color: hsl(var(--muted-foreground)); font-size: .76rem; font-weight: 700; }
.pz-stats { display: flex; gap: .4rem; align-items: center; }
.stat {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  padding: .3rem .65rem; border-radius: 999px; font-weight: 800; font-size: .88rem; white-space: nowrap;
}
.stat.combo { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: transparent; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }

.progress-wrap { display: flex; align-items: center; gap: .6rem; margin: .7rem 0 .5rem; }
.progress-bar {
  flex: 1; height: 14px; background: hsl(var(--secondary)); border-radius: 999px; overflow: hidden;
  box-shadow: inset 0 2px 3px hsl(215 87% 6% / .5);
}
.progress-fill {
  height: 100%; width: 0%; background: hsl(var(--primary)); border-radius: 999px; transition: width .4s;
  box-shadow: inset 0 -4px 0 hsl(var(--primary-dark) / .55);
  position: relative; overflow: hidden;
}
.progress-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 35%, hsl(52 100% 80% / .8) 50%, transparent 65%);
  animation: shimmer 2.4s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 60%, 100% { transform: translateX(100%); } }
.progress-label { font-size: .8rem; color: hsl(var(--muted-foreground)); white-space: nowrap; font-weight: 800; }

.grid-wrap { overflow-x: auto; padding: .3rem 0 .5rem; -webkit-overflow-scrolling: touch; }
.grid { display: grid; gap: 2px; width: max-content; margin: 0 auto; touch-action: manipulation; }
.cell {
  width: var(--cell, 32px); height: var(--cell, 32px);
  position: relative; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: calc(var(--cell, 32px) * .52);
  user-select: none; -webkit-user-select: none;
}
.cell.empty { background: transparent; }
.cell.input { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); cursor: pointer; color: hsl(var(--foreground)); box-shadow: inset 0 -2px 0 hsl(215 87% 8% / .4); }
.cell.input.in-word { background: hsl(var(--accent)); border-color: hsl(var(--primary) / .45); }
.cell.input.selected { outline: 2px solid hsl(var(--ring)); outline-offset: -1px; background: hsl(var(--primary) / .25); }
.cell.input.solved { background: hsl(var(--ok) / .16); border-color: hsl(var(--ok) / .5); }
.cell.input.solved.in-word { background: hsl(var(--ok) / .3); }
.cell.input.error { animation: shake .4s; background: hsl(var(--destructive) / .35); }
.cell.input.pop { animation: pop .35s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.22); } 100% { transform: scale(1); } }
.cell .num {
  position: absolute; top: 0; left: 2px; font-size: calc(var(--cell, 32px) * .27);
  font-weight: 700; color: hsl(var(--muted-foreground));
}
.cell.in-word .num { color: hsl(var(--primary)); }

/* ---------- dock ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: hsl(var(--card-2) / .97); backdrop-filter: blur(12px);
  border-top: 1px solid hsl(var(--border));
  padding: .55rem .7rem;
  padding-bottom: max(.55rem, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: .45rem;
}
.dock-clue { display: flex; align-items: center; gap: .5rem; max-width: 640px; margin: 0 auto; width: 100%; }
.dock-clue .icon-btn { width: 38px; height: 38px; }
.active-clue { flex: 1; font-size: .88rem; line-height: 1.35; min-height: 38px; display: flex; align-items: center; }
.active-clue .ac-num { color: hsl(var(--primary)); font-weight: 800; margin-right: .35rem; white-space: nowrap; }
.dock-hints { display: flex; gap: .45rem; max-width: 640px; margin: 0 auto; width: 100%; }
.hint-btn {
  flex: 1; background: hsl(var(--secondary)); border: none; border-radius: 12px;
  color: hsl(var(--foreground)); font-family: 'Nunito', sans-serif; font-weight: 700; font-size: .78rem;
  padding: .5rem .3rem; cursor: pointer; white-space: nowrap;
  box-shadow: 0 3px 0 hsl(var(--secondary-dark));
}
.hint-btn b { color: hsl(var(--primary)); font-weight: 800; }
.hint-btn:disabled { opacity: .4; cursor: not-allowed; }
.hint-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 hsl(var(--secondary-dark)); }

/* ---------- tastiera (sempre visibile) ---------- */
.keyboard { display: flex; flex-direction: column; gap: .3rem; max-width: 640px; margin: 0 auto; width: 100%; }
.kb-row { display: flex; gap: .3rem; justify-content: center; }
.kb-key {
  flex: 1; max-width: 42px; height: 46px;
  background: hsl(var(--secondary)); color: hsl(var(--foreground));
  border: none; border-radius: 9px;
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
  box-shadow: 0 3px 0 hsl(var(--secondary-dark));
}
.kb-key:active { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); transform: translateY(2px); box-shadow: 0 1px 0 hsl(var(--primary-dark)); }
.kb-key.wide { max-width: 64px; }

/* ---------- definizioni (accordion / desktop) ---------- */
.clues-acc { margin-top: .6rem; }
.clues-acc summary {
  cursor: pointer; font-weight: 800; color: hsl(var(--secondary-foreground)); font-size: .9rem;
  padding: .55rem .8rem; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: 12px;
  list-style: none;
}
.clues-acc summary::before { content: '▸ '; color: hsl(var(--primary)); }
.clues-acc[open] summary::before { content: '▾ '; }
.clues { display: grid; grid-template-columns: 1fr; gap: .8rem; margin-top: .6rem; }
.clue-col h3 { font-size: 1rem; }
.clue-col ol { list-style: none; margin: 0; padding: 0; }
.clue-col li {
  padding: .42rem .55rem; border-radius: 8px; font-size: .88rem; cursor: pointer;
  line-height: 1.4; display: flex; gap: .5rem; font-weight: 600;
}
.clue-col li:hover { background: hsl(var(--secondary)); }
.clue-col li.active { background: hsl(var(--accent)); outline: 1px solid hsl(var(--primary) / .5); }
.clue-col li.solved { color: hsl(var(--muted-foreground)); text-decoration: line-through; }
.clue-col li .c-num { color: hsl(var(--primary)); font-weight: 800; min-width: 1.4em; text-align: right; }
.clue-col li.solved .c-num { color: hsl(var(--muted-foreground)); }

/* ---------- libreria ---------- */
.coll-section-title { margin-top: 1.6rem; font-size: 1.05rem; }
.coll-filters { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0 .9rem; }
.filter-btn {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border)); color: hsl(var(--secondary-foreground));
  border-radius: 999px; padding: .35rem .85rem; font-family: 'Nunito', sans-serif; font-weight: 700;
  font-size: .85rem; cursor: pointer;
}
.filter-btn.active { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: transparent; }
.f-gialla.active { background: hsl(var(--card-yellow)); }
.f-blu.active { background: hsl(var(--card-blue)); color: white; }
.f-rossa.active { background: hsl(var(--card-red)); color: white; }
.f-verde.active { background: hsl(var(--card-green)); color: white; }

.coll-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; }
.coll-card {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: 12px;
  overflow: hidden; cursor: pointer; padding: 0; transition: transform .15s;
  position: relative; font-family: 'Nunito', sans-serif;
}
.coll-card:active { transform: scale(.97); }
.coll-card img { width: 100%; display: block; aspect-ratio: 63/88; object-fit: cover; }
.coll-card.locked { cursor: default; }
.coll-card.locked .ph {
  aspect-ratio: 63/88; display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; color: hsl(var(--muted-foreground)); font-weight: 800;
  border-top: 4px solid var(--cc, hsl(var(--border)));
}
.coll-card .cc-name {
  font-size: .73rem; font-weight: 700; padding: .35rem .4rem; display: block; text-align: center;
  color: hsl(var(--secondary-foreground));
}
.coll-card.magnus { box-shadow: 0 0 16px hsl(var(--primary) / .5); border-color: hsl(var(--primary)); }
.coll-cta { font-size: .85rem; margin-top: 1rem; }

.gloss-list { display: grid; grid-template-columns: 1fr; gap: .6rem; }
.gloss-item {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  padding: .8rem .95rem;
}
.gloss-item h4 { margin: 0 0 .25rem; font-size: .98rem; }
.gloss-item p { margin: 0; font-size: .85rem; color: hsl(var(--secondary-foreground)); font-weight: 400; }
.gloss-item.locked { opacity: .45; }
.gloss-item.locked p { filter: blur(3px); user-select: none; }

/* ---------- trofei ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin-bottom: .5rem; }
.stat-tile {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  padding: .85rem; text-align: center;
}
.stat-tile .s-val { font-family: 'Plumpfull', sans-serif; font-size: 1.5rem; color: hsl(var(--primary)); display: block; }
.stat-tile .s-label { font-size: .78rem; color: hsl(var(--muted-foreground)); font-weight: 700; }
.badge-shelf { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-top: .7rem; }
.badge-tile {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  padding: .75rem .5rem; text-align: center;
}
.badge-tile.locked { opacity: .4; filter: grayscale(.9); }
.badge-tile .b-icon { font-size: 1.6rem; display: block; }
.badge-tile .b-name { font-weight: 800; font-size: .8rem; display: block; margin-top: .25rem; color: hsl(var(--primary)); line-height: 1.2; }
.badge-tile .b-desc { font-size: .7rem; color: hsl(var(--muted-foreground)); display: block; margin-top: .2rem; line-height: 1.25; }

/* ---------- bottombar ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  display: flex; background: hsl(var(--card-2) / .97); backdrop-filter: blur(12px);
  border-top: 1px solid hsl(var(--border));
  padding-bottom: env(safe-area-inset-bottom);
}
.bb-btn {
  flex: 1; background: none; border: none; color: hsl(var(--muted-foreground));
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .72rem; cursor: pointer;
  padding: .45rem 0 .5rem; display: flex; flex-direction: column; align-items: center; gap: .1rem;
}
.bb-btn .bb-icon { font-size: 1.35rem; }
.bb-btn.active { color: hsl(var(--primary)); }

/* ---------- modali ---------- */
.modal {
  position: fixed; inset: 0; background: hsl(var(--background) / .82); backdrop-filter: blur(5px);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
}
.modal-box {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: var(--radius) var(--radius) 0 0;
  max-width: 540px; width: 100%; max-height: 88dvh; overflow-y: auto; padding: 1.3rem 1.2rem;
  padding-bottom: max(1.3rem, env(safe-area-inset-bottom));
  position: relative; animation: sheet-in .25s ease-out;
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-close {
  position: absolute; top: .5rem; right: .7rem; background: none; border: none;
  color: hsl(var(--muted-foreground)); font-size: 1.7rem; cursor: pointer; line-height: 1; z-index: 1;
}

/* onboarding */
.onb-box { text-align: center; display: flex; flex-direction: column; gap: .7rem; }
.onb-slide { min-height: 250px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; }
.onb-slide img.onb-magnus { width: 110px; height: 110px; border-radius: 50%; border: 3px solid hsl(var(--primary)); }
.onb-slide img.onb-card { width: 110px; border-radius: 10px; box-shadow: 0 6px 20px hsl(215 87% 5% / .6); }
.onb-slide h2 { font-size: 1.25rem; margin: 0; }
.onb-slide p { color: hsl(var(--secondary-foreground)); font-size: .95rem; max-width: 380px; margin: 0; }
.onb-demo { display: flex; gap: 3px; }
.onb-demo span {
  width: 44px; height: 44px; border-radius: 7px; background: hsl(var(--accent));
  border: 1px solid hsl(var(--primary) / .5); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.2rem;
}
.onb-demo span.ok { background: hsl(var(--ok) / .25); border-color: hsl(var(--ok)); }
.onb-dots { display: flex; gap: .4rem; justify-content: center; }
.onb-dots i { width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--secondary)); }
.onb-dots i.on { background: hsl(var(--primary)); }
.onb-next { width: 100%; }

.card-modal-box { display: flex; flex-direction: column; gap: .9rem; align-items: center; text-align: center; }
.card-modal-box img { width: min(58%, 220px); border-radius: 12px; }
.card-modal-info p { font-size: .9rem; color: hsl(var(--secondary-foreground)); font-weight: 400; }

.end-modal-box { text-align: center; }
.end-stars { font-size: 2.4rem; letter-spacing: .12em; margin: .2rem 0 .3rem; color: hsl(var(--primary)); }
.end-stars span { display: inline-block; animation: star-in .45s backwards; }
.end-stars span:nth-child(2) { animation-delay: .15s; }
.end-stars span:nth-child(3) { animation-delay: .3s; }
@keyframes star-in { 0% { transform: scale(0) rotate(-40deg); opacity: 0; } 70% { transform: scale(1.3); } 100% { transform: scale(1); opacity: 1; } }
.end-points { font-size: 1rem; font-weight: 800; color: hsl(var(--secondary-foreground)); }

/* citazione di Magnus: niente scatola, solo voce */
.end-quote {
  display: flex; align-items: center; gap: .7rem; justify-content: center;
  max-width: 380px; margin: .9rem auto;
}
.end-quote img { width: 44px; height: 44px; border-radius: 50%; border: 2px solid hsl(var(--primary)); flex-shrink: 0; }
.end-quote p { margin: 0; font-style: italic; font-size: .92rem; line-height: 1.45; color: hsl(var(--secondary-foreground)); text-align: left; }
.end-quote small { display: block; font-style: normal; font-weight: 800; color: hsl(var(--primary)); font-size: .72rem; margin-top: .2rem; letter-spacing: .05em; text-transform: uppercase; }

/* sezioni del riepilogo: gruppi omogenei, non un minestrone */
.end-sec { margin: 1.1rem 0 0; }
.end-sec h4 {
  font-family: 'Nunito', sans-serif; font-size: .7rem; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase; color: hsl(var(--muted-foreground));
  margin: 0 0 .5rem;
}
.end-cards { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.end-cards img {
  width: 68px; border-radius: 8px;
  box-shadow: 0 4px 12px hsl(215 87% 5% / .6);
}
.end-cards img:nth-child(odd) { transform: rotate(-2.5deg); }
.end-cards img:nth-child(even) { transform: rotate(2.5deg); }
.end-terms { margin: 0; font-size: .88rem; color: hsl(var(--secondary-foreground)); line-height: 1.6; }
.end-badges { display: flex; justify-content: center; }
.end-badge-new {
  display: flex; align-items: center; gap: .6rem; text-align: left;
  background: hsl(var(--primary) / .1); border: 1px solid hsl(var(--primary) / .45);
  border-radius: 12px; padding: .55rem .9rem; max-width: 340px;
}
.end-badge-new .eb-icon { font-size: 1.5rem; }
.end-badge-new b { display: block; color: hsl(var(--primary)); font-size: .9rem; }
.end-badge-new small { color: hsl(var(--secondary-foreground)); font-size: .76rem; line-height: 1.3; }
.end-actions { display: flex; flex-direction: column; gap: .55rem; margin-top: .9rem; }
.end-actions .btn { width: 100%; }

/* ---------- effetti game ---------- */
.float-pts {
  position: fixed; z-index: 95; pointer-events: none;
  font-weight: 800; font-size: 1.05rem; color: hsl(var(--primary));
  text-shadow: 0 2px 6px hsl(215 87% 5% / .8);
  display: flex; align-items: center; gap: .25rem;
  animation: rise 1s ease-out forwards;
}
@keyframes rise { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-48px); opacity: 0; } }

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.confetti i {
  position: absolute; top: -16px; width: 9px; height: 15px; border-radius: 2px; opacity: .95;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(105vh) rotate(660deg); opacity: .7; }
}

.reward-card { width: 130px; border-radius: 10px; box-shadow: 0 0 20px hsl(var(--primary) / .55); margin: .4rem 0; }
.promo-code {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  background: hsl(var(--background)); border: 2px dashed hsl(var(--primary));
  border-radius: 12px; padding: .6rem .9rem; margin: .6rem auto .2rem; max-width: 320px;
}
.promo-code span {
  font-family: 'Plumpfull', sans-serif; font-size: 1.25rem; color: hsl(var(--primary)); letter-spacing: .12em;
}
.btn-copy { padding: .45rem .9rem; font-size: .8rem; }
.reward-note { font-size: .82rem; margin: 0 0 .4rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--dock-h) + var(--bb-h) + 1rem); transform: translateX(-50%);
  background: hsl(var(--card)); border: 1px solid hsl(var(--primary) / .6); border-radius: 14px;
  padding: .55rem .85rem; display: flex; align-items: center; gap: .65rem; z-index: 90;
  box-shadow: 0 8px 30px hsl(215 87% 4% / .7);
  animation: toast-in .3s ease-out; max-width: min(92vw, 420px);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast img { width: 42px; border-radius: 6px; flex-shrink: 0; }
.toast img.round { border-radius: 50%; border: 2px solid hsl(var(--primary)); }
.toast img.none { display: none; }
.toast strong { display: block; color: hsl(var(--primary)); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; }
.toast span { font-weight: 600; font-size: .88rem; line-height: 1.3; display: block; }

/* ---------- consenso cookie ---------- */
.consent {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bb-h) + .8rem);
  z-index: 120; width: min(94vw, 480px);
  background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  padding: .9rem 1rem; box-shadow: 0 10px 40px hsl(215 87% 4% / .8);
}
.consent p { margin: 0 0 .7rem; font-size: .85rem; color: hsl(var(--secondary-foreground)); }
.consent-actions { display: flex; gap: .5rem; }
.consent-actions .btn { flex: 1; padding: .55rem 1rem; font-size: .85rem; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid hsl(var(--border)); padding: 1rem; padding-bottom: calc(1rem + var(--bb-h)); text-align: center; font-size: .8rem; color: hsl(var(--muted-foreground)); }

/* ============ desktop (≥768px) ============ */
@media (min-width: 768px) {
  .desktop-only { display: inline-block; }
  .bottombar { display: none; }
  main { padding: 1.2rem 1.2rem 3rem; }
  .magnus-line { max-width: 560px; margin: 1rem auto; }
  .path { max-width: 420px; }
  .promo { flex-direction: row; text-align: left; gap: 1rem; max-width: 640px; }
  .promo-body { flex: 1; }
  .promo .btn { flex-shrink: 0; }
  .badge-shelf { grid-template-columns: repeat(6, 1fr); }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .coll-grid { grid-template-columns: repeat(5, 1fr); }
  .gloss-list { grid-template-columns: 1fr 1fr; }
  .clues { grid-template-columns: 1fr 1fr; gap: 1.2rem; }
  .clues-acc summary { display: none; }
  .clues-acc { margin-top: 1rem; }
  .dock {
    position: sticky; bottom: 0;
    border: 1px solid hsl(var(--border)); border-radius: var(--radius);
    margin-top: .8rem;
  }
  .modal { align-items: center; padding: 1rem; }
  .modal-box { border-radius: var(--radius); animation: none; }
  .card-modal-box { flex-direction: row; text-align: left; align-items: flex-start; }
  .card-modal-box img { width: 200px; }
  .end-actions { flex-direction: row; justify-content: center; }
  .end-actions .btn { width: auto; }
}

/* ---------------- account / cloud ---------------- */
.cloud-box { display: flex; flex-direction: column; gap: .65rem; text-align: center; }
.cloud-box input[type="email"], .cloud-box input[type="password"] {
  padding: .7rem .9rem; border-radius: 12px; border: 2px solid hsl(var(--border));
  background: hsl(var(--card-2)); color: hsl(var(--foreground)); font: inherit;
}
.cloud-box input:focus { outline: none; border-color: hsl(var(--ring)); }
.cloud-divider { display: flex; align-items: center; gap: .6rem; color: hsl(var(--muted-foreground)); font-size: .85rem; }
.cloud-divider::before, .cloud-divider::after { content: ''; flex: 1; height: 1px; background: hsl(var(--border)); }
.cloud-check { display: flex; gap: .5rem; align-items: flex-start; text-align: left; font-size: .85rem; color: hsl(var(--secondary-foreground)); }
.cloud-check input { margin-top: .2rem; }
.cloud-error { color: hsl(0 80% 70%); font-size: .9rem; }
.cloud-privacy { font-size: .75rem; }
.cloud-status { display: flex; flex-direction: column; gap: .6rem; align-items: flex-start; }
.cloud-status .cloud-mail { color: hsl(var(--secondary-foreground)); font-size: .9rem; word-break: break-all; }
