/* ===== Font (incluso nell'app, licenza SIL OFL: funziona offline) ===== */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("../fonts/nunito-latin.woff2") format("woff2");
}

/* ===== Token di design (condivisi da tutti i giochi) ===== */
:root {
  --bg: #f3f4fa;
  --surface: #ffffff;
  --surface-2: #eef0f7;
  --border: #e3e6f0;
  --text: #161a2e;
  --text-2: #6a7089;
  --accent: #5b5bf6;
  --accent-2: #8b5cf6;
  --accent-text: #ffffff;
  --ok: #1fae6b;
  --ok-soft: #dcf5e9;
  --bad: #ef4f5a;
  --bad-soft: #fde4e6;
  --warn: #f5a524;
  --gold: #f5b301;
  --gold-ink: #9a6a00;
  --shadow: 0 1px 2px rgba(22,26,46,.06), 0 8px 24px rgba(22,26,46,.07);
  --shadow-lg: 0 2px 6px rgba(22,26,46,.08), 0 18px 40px rgba(22,26,46,.12);
  --radius: 20px;
  --radius-sm: 12px;
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --emoji: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", "Twemoji Mozilla", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f1c; --surface: #171a2c; --surface-2: #20243a; --border: #2a2f4a;
    --text: #eef0fb; --text-2: #9aa1c3; --accent: #7c7cff; --accent-2: #a78bfa; --accent-text: #ffffff; --gold-ink: #f7c948;
    --ok: #34d399; --ok-soft: #12352a; --bad: #fb7185; --bad-soft: #3b1b25;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.3);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.4), 0 18px 40px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f1c; --surface: #171a2c; --surface-2: #20243a; --border: #2a2f4a;
  --text: #eef0fb; --text-2: #9aa1c3; --accent: #7c7cff; --accent-2: #a78bfa; --accent-text: #ffffff; --gold-ink: #f7c948;
  --ok: #34d399; --ok-soft: #12352a; --bad: #fb7185; --bad-soft: #3b1b25;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.3);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.4), 0 18px 40px rgba(0,0,0,.45);
  color-scheme: dark;
}

/* ===== Base ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  color: var(--text); font-family: var(--font);
  background:
    radial-gradient(900px 420px at 50% -180px, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  font-size: 16px; line-height: 1.4; -webkit-font-smoothing: antialiased;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
.app {
  max-width: 480px; margin: 0 auto; min-height: 100%;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 20px);
}
.screen { display: flex; flex-direction: column; flex: 1; animation: fade .22s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* ===== Barra superiore ===== */
.topbar { display: flex; align-items: center; gap: 8px; height: 60px; }
.topbar h1 {
  font-size: 20px; font-weight: 900; line-height: 1.1; margin: 0; flex: 1; min-width: 0; letter-spacing: -.01em;
  /* Sui telefoni stretti il titolo va a capo invece di essere tagliato. */
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
@media (max-width: 380px) { .topbar h1 { font-size: 18px; } }
.topbar .brand { font-size: 22px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  color: var(--text); background: var(--surface); box-shadow: var(--shadow);
  transition: transform .1s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 22px; height: 22px; }

/* ===== Componenti ===== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.btn {
  --btn: var(--accent);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 54px; padding: 0 20px; border-radius: 16px; font-weight: 800; font-size: 17px; width: 100%;
  color: var(--accent-text);
  background: linear-gradient(180deg, color-mix(in srgb, var(--btn) 82%, white), var(--btn));
  box-shadow: 0 4px 0 color-mix(in srgb, var(--btn) 62%, black), 0 8px 18px -6px color-mix(in srgb, var(--btn) 60%, transparent);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--btn) 62%, black); }
.btn:disabled { filter: grayscale(.6); opacity: .55; }
.btn.secondary {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 3px 0 var(--border);
}
.btn.secondary:active:not(:disabled) { box-shadow: 0 0 0 var(--border); }
.btn.ghost { background: transparent; color: var(--text-2); height: 44px; box-shadow: none; font-weight: 700; }
.btn.ghost:active:not(:disabled) { transform: scale(.97); box-shadow: none; }
.btn.danger { --btn: var(--bad); }
.btn svg { width: 20px; height: 20px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.section-title { font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); margin: 24px 4px 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 800; background: var(--surface-2); color: var(--text-2);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.todo { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > span {
  display: block; height: 100%; border-radius: inherit; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .8s cubic-bezier(.2,.8,.2,1);
}

/* ===== Home ===== */
.home-head { display: flex; align-items: center; gap: 12px; padding: 14px 0 6px; }
.lvl-badge {
  width: 52px; height: 52px; border-radius: 18px; flex: none; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-2)); color: #fff;
  font-weight: 900; font-size: 22px; box-shadow: 0 8px 18px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}
.home-head .who { flex: 1; min-width: 0; }
.home-head .who b { font-size: 18px; font-weight: 900; display: block; }
.home-head .who .bar { margin-top: 6px; height: 8px; }
.home-head .who small { color: var(--text-2); font-weight: 700; font-size: 12px; }
.home-head .tools { display: flex; gap: 8px; }

.goals { padding: 14px 16px; animation: rise .4s both; }
.goals-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.goals-head b { font-weight: 900; display: flex; align-items: center; gap: 8px; }
.goal { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.goal + .goal { border-top: 1px solid var(--border); }
.goal .check {
  width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center;
  border: 2px solid var(--border); color: transparent; font-size: 14px; font-weight: 900;
}
.goal.done .check { background: var(--ok); border-color: var(--ok); color: #fff; animation: pop-box .35s ease both; }
.goal .txt { flex: 1; font-weight: 700; font-size: 15px; }
.goal.done .txt { color: var(--text-2); text-decoration: line-through; }
.goal .prog { display: flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 900; color: var(--gold-ink); font-variant-numeric: tabular-nums; }
.goal .prog .coin-ic { width: 17px; height: 17px; }
.goal.done .prog { opacity: .45; }
.goal .txt .muted { font-weight: 800; }

/* Monete */
.coin-ic { display: inline-block; width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.coin-ic svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
.wallet {
  display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 11px 0 8px; border-radius: 999px; flex: none;
  background: color-mix(in srgb, var(--gold) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  font-weight: 900; font-size: 15px; font-variant-numeric: tabular-nums;
}
.wallet .coin-ic { width: 20px; height: 20px; }
.wallet.bump { animation: bump .45s ease; }
.topbar .wallet { height: 42px; padding: 0 13px 0 10px; }
.pill.coins { background: color-mix(in srgb, var(--gold) 20%, var(--surface)); color: var(--gold-ink); }
.pill.coins .coin-ic { width: 15px; height: 15px; }
.unlock .pill.coins { margin-left: auto; flex: none; }
.price { display: inline-flex; align-items: center; gap: 3px; font-weight: 900; font-size: 13px; font-variant-numeric: tabular-nums; }
.price .coin-ic { width: 16px; height: 16px; }

/* Pulsante aiuto a pagamento */
.help-row { display: flex; justify-content: center; }
.help-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 44px; padding: 0 8px 0 16px;
  border-radius: 14px; font-weight: 800; font-size: 15px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 3px 0 var(--border); transition: transform .08s, box-shadow .08s, opacity .2s;
}
.help-btn .price { padding: 5px 9px 5px 7px; border-radius: 10px; background: color-mix(in srgb, var(--gold) 18%, var(--surface-2)); color: var(--gold-ink); }
.help-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.help-btn:disabled { opacity: .45; }
.help-btn.poor .price { filter: grayscale(1); opacity: .6; }

/* Bonus di apertura */
.bonus-dialog { text-align: center; }
.bonus-dialog p { margin-bottom: 12px; }
.bonus-coin { width: 84px; height: 84px; margin: 4px auto 10px; animation: coin-spin 2.4s ease-in-out infinite; }
.bonus-coin svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 6px 10px rgba(0,0,0,.25)); }
@keyframes coin-spin { 0%, 40%, 100% { transform: rotateY(0); } 70% { transform: rotateY(360deg); } }
.bonus-amount { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 16px; font-size: 34px; font-weight: 900; color: var(--gold-ink); }
.bonus-amount .coin-ic { width: 32px; height: 32px; }

/* Scrigno del giorno */
.chest-ic { width: 46px; height: 40px; flex: none; display: block; }
.chest-ic svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chest-glow { opacity: 0; transition: opacity .4s .15s; }
.chest-lid { transform-box: fill-box; transform-origin: 0% 100%; transition: transform .5s cubic-bezier(.3,1.6,.5,1); }
.chest-row {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 10px; padding: 10px 12px;
  border-radius: 16px; text-align: left; background: var(--surface-2);
}
.chest-row > div { flex: 1; min-width: 0; }
.chest-row b { display: block; font-weight: 900; font-size: 15px; }
.chest-row small { display: block; color: var(--text-2); font-weight: 700; font-size: 12.5px; }
.chest-row.locked .chest-ic { filter: grayscale(.9); opacity: .55; }
.chest-row.ready, .chest-unlock {
  background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 32%, var(--surface)), color-mix(in srgb, var(--gold) 10%, var(--surface)));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 75%, transparent), 0 10px 22px -10px color-mix(in srgb, var(--gold) 90%, transparent);
}
.chest-row.ready .chest-ic, .chest-unlock:not(.opened) .chest-ic { animation: wiggle 1.8s ease-in-out infinite; }
.chest-row.opened .chest-lid, .chest-unlock.opened .chest-lid { transform: translate(-3px, -9px) rotate(-22deg); }
.chest-row.opened .chest-glow, .chest-unlock.opened .chest-glow { opacity: 1; }
.chest-row:active:is(button) { transform: scale(.98); }
.chest-unlock > div { flex: 1; min-width: 0; }
.chest-unlock .chest-ic { width: 40px; height: 35px; }
.chest-go {
  flex: none; padding: 8px 16px; border-radius: 12px; font-weight: 900; font-size: 14px;
  background: linear-gradient(180deg, #ffd34d, var(--gold)); color: #4a3000; box-shadow: 0 3px 0 #c48f00;
}
.chest-unlock.opened .chest-go { background: var(--surface); color: var(--text); box-shadow: 0 3px 0 var(--border); }
@keyframes wiggle {
  0%, 62%, 100% { transform: none; }
  70% { transform: rotate(-9deg) scale(1.06); } 78% { transform: rotate(8deg) scale(1.06); }
  86% { transform: rotate(-5deg); } 94% { transform: rotate(3deg); }
}

.chest-dialog { text-align: center; overflow: hidden; }
.chest-dialog p { margin-bottom: 14px; }
.chest-big { position: relative; display: block; width: 170px; height: 142px; margin: 30px auto 8px; }
.chest-big svg { position: relative; width: 100%; height: 100%; overflow: visible; }
.chest-big::before {
  content: ""; position: absolute; inset: -46px; border-radius: 50%; opacity: 0; transition: opacity .5s;
  background: repeating-conic-gradient(color-mix(in srgb, var(--gold) 50%, transparent) 0 9deg, transparent 9deg 24deg);
  -webkit-mask: radial-gradient(circle, #000 18%, transparent 66%); mask: radial-gradient(circle, #000 18%, transparent 66%);
}
.chest-big:not(.open):not(.shake) svg { animation: wiggle 1.8s ease-in-out infinite; }
.chest-big.shake svg { animation: chest-shake .3s ease-in-out 3; }
.chest-big.open::before { opacity: 1; animation: spin 16s linear infinite; }
.chest-big.open .chest-lid { transform: translate(-4px, -14px) rotate(-17deg); }
.chest-big.open .chest-glow { opacity: 1; }
@keyframes chest-shake { 25% { transform: rotate(-7deg) scale(1.05); } 75% { transform: rotate(7deg) scale(1.05); } }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(1turn); } }
.chest-prize { display: none; flex-direction: column; align-items: center; gap: 10px; margin: -4px 0 16px; }
.chest-prize.show { display: flex; animation: bounce-in .5s cubic-bezier(.3,1.6,.5,1) both; }
.prize-xp { font-family: var(--emoji); font-size: 44px; line-height: 1; }
.btn.gold { --btn: var(--gold); color: #4a3000; }

/* Premi: pallino colore e dorso in miniatura (anche in Impostazioni) */
.swatch {
  display: block; width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(140deg, var(--sw-a), var(--sw-b));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.3), 0 3px 8px -3px rgba(0,0,0,.45);
}
.swatch.big { width: 70px; height: 70px; }
.back-prev { position: relative; display: block; width: 32px; aspect-ratio: 1 / 1.15; --game-color: #e0782e; }
.back-prev .mem-face { border-radius: 7px; }
.back-prev .mem-back::after { font-size: 10px; width: 52%; }
.back-prev.big { width: 70px; }
.back-prev.big .mem-face { border-radius: 13px; }
.back-prev.big .mem-back::after { font-size: 19px; width: 46%; }
.chest-row .swatch, .chest-row .back-prev { flex: none; }

.featured {
  position: relative; overflow: hidden; margin-top: 14px; padding: 18px; border-radius: 24px; color: #fff; text-align: left;
  background: linear-gradient(140deg, color-mix(in srgb, var(--game-color) 75%, white), var(--game-color) 50%, color-mix(in srgb, var(--game-color) 70%, black));
  box-shadow: 0 16px 30px -14px color-mix(in srgb, var(--game-color) 80%, transparent), inset 0 1px 0 rgba(255,255,255,.3);
  display: flex; flex-direction: column; gap: 10px; animation: rise .45s .05s both;
}
.featured .kicker { font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; opacity: .85; }
.featured h2 { margin: 0; font-size: 26px; font-weight: 900; line-height: 1.1; max-width: 68%; position: relative; }
.featured .kicker, .featured > span:not(.art) { position: relative; }
.featured .art { position: absolute; right: -16px; bottom: -18px; width: 140px; height: 140px; opacity: .9; pointer-events: none; }
.featured .go {
  align-self: flex-start; margin-top: 4px; padding: 10px 18px; border-radius: 14px; font-weight: 900;
  background: #fff; color: var(--game-color); box-shadow: 0 4px 0 rgba(0,0,0,.18);
}
.featured:active { transform: scale(.985); }

.games { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.game-card {
  position: relative; overflow: hidden; text-align: left; color: #fff;
  display: flex; flex-direction: column; gap: 4px; min-height: 158px; padding: 16px; border-radius: 22px;
  background: linear-gradient(150deg, color-mix(in srgb, var(--game-color) 78%, white), var(--game-color) 55%, color-mix(in srgb, var(--game-color) 72%, black));
  box-shadow: 0 12px 24px -12px color-mix(in srgb, var(--game-color) 80%, transparent), inset 0 1px 0 rgba(255,255,255,.28);
  transition: transform .12s; animation: rise .45s both;
}
.games .game-card:nth-child(2) { animation-delay: .06s; }
.games .game-card:nth-child(3) { animation-delay: .12s; }
.games .game-card:nth-child(4) { animation-delay: .18s; }
.games .game-card:nth-child(5) { animation-delay: .24s; }
/* Numero dispari di giochi: l'ultimo occupa tutta la riga. */
.games .game-card:last-child:nth-child(odd) { grid-column: 1 / -1; min-height: 0; }
.game-card:active { transform: scale(.96); }
.game-card .art { position: absolute; right: -14px; bottom: -14px; width: 86px; height: 86px; opacity: .85; pointer-events: none; }
.game-card .name { font-weight: 900; font-size: 19px; line-height: 1.1; position: relative; }
.game-card .desc { font-size: 13px; font-weight: 600; opacity: .9; position: relative; }
.featured .pill { background: rgba(255,255,255,.22); color: #fff; backdrop-filter: blur(4px); }

/* ===== Gioco: struttura comune ===== */
/* Barra in alto: due riquadri ai lati, informazione principale grande al centro. */
.g-hud { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 4px 0 14px; }
.g-stat {
  justify-self: start; display: flex; flex-direction: column; align-items: center; min-width: 72px; padding: 6px 12px;
  border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  transition: box-shadow .25s, transform .25s;
}
.g-stat.right { justify-self: end; }
.g-stat b { font-size: 22px; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.g-stat small { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); }
.g-stat.good b { color: var(--ok); }
.g-stat.bad b { color: var(--bad); }
.g-stat.on { box-shadow: 0 0 0 3px var(--stat-color, var(--accent)), var(--shadow); transform: scale(1.06); }
.g-stat.bump { animation: bump .4s ease; }
@keyframes bump { 40% { transform: scale(1.18); } }
.g-center { position: relative; text-align: center; min-width: 0; }
.g-big { font-size: 34px; font-weight: 900; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.g-sub { font-size: 12px; font-weight: 800; color: var(--text-2); margin-top: 4px; }
.g-sub.new { color: var(--ok); }
.g-center.pulse .g-big { animation: bump .5s ease; }
/* "Tavolo" nel colore del gioco su cui stanno carte e griglie. */
.g-table {
  padding: 12px; border-radius: 26px;
  background:
    radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--game-color) 30%, transparent), transparent 70%),
    color-mix(in srgb, var(--game-color) 12%, var(--surface-2));
  box-shadow: inset 0 2px 10px rgba(0,0,0,.18), var(--shadow);
  transition: box-shadow .3s;
}
.progress { display: flex; gap: 5px; margin: 6px 0 18px; }
.progress span { flex: 1; height: 7px; border-radius: 4px; background: var(--surface-2); transition: background .25s; }
.progress span.cur { background: var(--text-2); }
.progress span.ok { background: var(--ok); }
.progress span.bad { background: var(--bad); }
.game-hud { display: flex; justify-content: space-between; color: var(--text-2); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.game-hud .rec { font-weight: 800; }
.game-hud .rec.new { color: var(--ok); }
.btn.choice { flex-direction: column; gap: 0; height: 64px; }
.btn.choice small { font-size: 12px; font-weight: 700; opacity: .75; }

/* ===== Bandiere ===== */
.flag-stage { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.flag-box {
  position: relative; overflow: hidden; display: grid; place-items: center; height: 200px; border-radius: 26px;
  background:
    radial-gradient(70% 60% at 50% 45%, rgba(255,255,255,.55), transparent 70%),
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--game-color) 35%, transparent), transparent 70%),
    color-mix(in srgb, var(--game-color) 14%, var(--surface-2));
  box-shadow: inset 0 2px 10px rgba(0,0,0,.15), var(--shadow);
}
/* Meridiani e paralleli stilizzati sullo sfondo. */
.flag-box::before {
  content: ""; position: absolute; inset: -20%; opacity: .14; pointer-events: none;
  background:
    repeating-radial-gradient(circle at 50% 50%, transparent 0 34px, var(--game-color) 34px 36px),
    repeating-linear-gradient(90deg, transparent 0 46px, var(--game-color) 46px 48px);
}
.flag-emoji { position: relative; font-family: var(--emoji); font-size: 128px; line-height: 1; filter: drop-shadow(0 10px 14px rgba(0,0,0,.28)); }
.flag-emoji.in { animation: flag-in .45s cubic-bezier(.3,1.4,.5,1) both; }
@keyframes flag-in { from { opacity: 0; transform: rotateY(70deg) scale(.7); } }
.flag-q { text-align: center; color: var(--text-2); font-weight: 800; }
.hearts { display: flex; gap: 2px; font-size: 20px; line-height: 1.2; }
.hearts span { transition: color .3s, transform .3s; }
.hearts span.off { color: var(--border); transform: scale(.8); }
.option.gone { opacity: .18; transform: scale(.97); }
.options { display: grid; gap: 10px; }
.option {
  min-height: 58px; padding: 8px 12px; border-radius: 16px; text-align: left; font-weight: 800; font-size: 16px;
  background: var(--surface); border: 2px solid var(--border); box-shadow: 0 3px 0 var(--border);
  display: flex; align-items: center; gap: 12px;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .08s;
}
.option .opt-k {
  width: 30px; height: 30px; border-radius: 10px; flex: none; display: grid; place-items: center;
  font-size: 13px; font-weight: 900; color: var(--game-color); background: color-mix(in srgb, var(--game-color) 12%, var(--surface));
}
.option.correct .opt-k { background: var(--ok); color: #fff; }
.option.wrong .opt-k { background: var(--bad); color: #fff; }
.option:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.option.correct { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); box-shadow: 0 3px 0 var(--ok); }
.option.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); box-shadow: 0 3px 0 var(--bad); animation: shake .3s; }
.option.dim { opacity: .45; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ===== Parola del giorno ===== */
.wd-clues { display: grid; gap: 7px; }
.wd-clue {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 16px;
  background: var(--surface); border: 1.5px dashed var(--border); color: var(--text-2);
  font-size: 18px; font-weight: 800; transition: background .2s, border-color .2s;
}
.wd-clue.on { border-style: solid; color: var(--text); box-shadow: var(--shadow); animation: rise .3s ease-out; }
.wd-clue .wd-n {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 12px; background: var(--surface-2); color: var(--text-2);
}
.wd-clue.on .wd-n { background: var(--game-color, var(--accent)); color: #fff; }
.wd-boxes { display: flex; justify-content: center; gap: 5px; margin: 16px 0 8px; flex-wrap: wrap; }
.wd-boxes span {
  width: 32px; height: 38px; border-radius: 9px; border: 2px solid var(--border); background: var(--surface);
  display: grid; place-items: center; font-weight: 900; font-size: 19px;
}
.wd-boxes span.hint { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 18%, var(--surface)); color: var(--gold-ink); animation: pop-box .35s ease both; }
.wd-actions { display: flex; margin-top: 12px; }
.wd-actions .help-btn { width: 100%; }
.wd-actions .help-btn:disabled .price { display: none; }
.help-btn { white-space: nowrap; }
.wd-boxes span.ok { background: var(--ok); border-color: var(--ok); color: #fff; animation: pop-box .35s ease both; }
.wd-boxes span.bad { background: var(--bad); border-color: var(--bad); color: #fff; animation: pop-box .35s ease both; }
@keyframes pop-box { from { transform: scale(.6); opacity: 0; } }
.wd-wrong { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 8px; margin-bottom: 10px; }
.wd-wrong .pill { text-decoration: line-through; }
.wd-form { display: flex; gap: 8px; }
.wd-form .btn { height: 54px; }
.wd-input {
  flex: 1; min-width: 0; height: 54px; padding: 0 16px; border-radius: 16px; font: inherit; font-size: 18px;
  font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  background: var(--surface); color: var(--text); border: 2px solid var(--border);
  user-select: text; -webkit-user-select: text;
}
.wd-input:focus { outline: none; border-color: var(--game-color, var(--accent)); }
.wd-input.shake { animation: shake .3s; border-color: var(--bad); }
.wd-review { display: flex; flex-wrap: wrap; gap: 6px; }

/* ===== Memory ===== */
.mem-stage { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.mem-grid { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.mem-foot, .tris-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.tris-foot { min-height: 44px; }
.mem-grid.peek .mem-card:not(.matched) .mem-inner { transform: rotateY(180deg); }
.mem-card { aspect-ratio: 1 / 1.1; perspective: 700px; }
.mem-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform .32s cubic-bezier(.3,.7,.4,1.2); -webkit-transform-style: preserve-3d; transform-style: preserve-3d;
}
.mem-card.open .mem-inner, .mem-card.matched .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute; inset: 0; border-radius: 14px; display: grid; place-items: center;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
/* Dorso: cornice bianca, trama e un emblema al centro. Le varianti (premi dello scrigno) cambiano solo le variabili. */
.mem-back {
  --b2: var(--game-color, #e0782e);
  --b1: color-mix(in srgb, var(--b2) 80%, white);
  --pat: repeating-linear-gradient(45deg, rgba(255,255,255,.13) 0 6px, transparent 6px 12px);
  background: var(--pat), linear-gradient(150deg, var(--b1), var(--b2));
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.55), 0 4px 0 color-mix(in srgb, var(--b2) 60%, black), 0 10px 16px -10px rgba(0,0,0,.6);
}
.mem-back::after {
  content: var(--emblem, "?"); width: 42%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; font-size: clamp(16px, 5vw, 22px); line-height: 1; color: var(--ink, var(--b2));
  background: rgba(255,255,255,.9); box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
[data-back="stars"] .mem-back { --b1: #4352c4; --b2: #222c74; --emblem: "★"; --ink: #e9a400;
  --pat: radial-gradient(circle, rgba(255,255,255,.45) 1.1px, transparent 1.7px) 0 0 / 11px 11px; }
[data-back="hearts"] .mem-back { --b1: #f0659a; --b2: #cf2f6c; --emblem: "♥";
  --pat: radial-gradient(circle at 50% 50%, rgba(255,255,255,.16) 3px, transparent 3.5px) 0 0 / 14px 14px; }
[data-back="diamonds"] .mem-back { --b1: #22b3c9; --b2: #0b6f82; --emblem: "♦";
  --pat: repeating-linear-gradient(45deg, rgba(255,255,255,.12) 0 2px, transparent 2px 10px), repeating-linear-gradient(-45deg, rgba(255,255,255,.12) 0 2px, transparent 2px 10px); }
[data-back="clubs"] .mem-back { --b1: #4fbf62; --b2: #237a35; --emblem: "♣";
  --pat: repeating-linear-gradient(90deg, rgba(255,255,255,.1) 0 5px, transparent 5px 10px); }
[data-back="moon"] .mem-back { --b1: #8a63f2; --b2: #4b2aa8; --emblem: "☾"; --ink: #4b2aa8;
  --pat: radial-gradient(circle at 30% 25%, rgba(255,255,255,.35) 1px, transparent 1.5px) 0 0 / 13px 17px; }
[data-back="sun"] .mem-back { --b1: #ffc634; --b2: #e2761b; --emblem: "☀";
  --pat: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255,255,255,.16) 0 12deg, transparent 12deg 24deg); }
[data-back="crown"] .mem-back { --b1: #3a3f52; --b2: #15171f; --emblem: "♛"; --ink: #c99700;
  --pat: repeating-linear-gradient(45deg, rgba(233,164,0,.22) 0 1.5px, transparent 1.5px 9px), repeating-linear-gradient(-45deg, rgba(233,164,0,.22) 0 1.5px, transparent 1.5px 9px);
  box-shadow: inset 0 0 0 3px #e9a400, 0 4px 0 #000, 0 10px 16px -10px rgba(0,0,0,.6); }
.mem-card:active:not(.open):not(.matched) .mem-back { filter: brightness(.94); }
/* Fronte: sempre chiaro, come una vera carta. */
.mem-front {
  transform: rotateY(180deg); background: linear-gradient(180deg, #ffffff, #eef0f7);
  box-shadow: 0 4px 0 #c9cde0, 0 10px 16px -10px rgba(10,12,30,.6);
  font-family: var(--emoji); font-size: clamp(30px, 9.5vw, 42px);
}
.mem-card.matched .mem-front { background: linear-gradient(180deg, #ecfdf4, #d4f7e5); box-shadow: 0 0 0 3px var(--ok), 0 4px 0 #8fdcb5; }
.mem-card.matched.bot .mem-front { background: linear-gradient(180deg, #fff1f2, #ffe0e3); box-shadow: 0 0 0 3px var(--bad), 0 4px 0 #f3a3ab; }
/* Niente opacità o filtri su .mem-inner: appiattirebbero il 3D e la carta mostrerebbe il dorso al contrario. */
.mem-grid.wait { cursor: progress; }
.mem-turn { color: var(--ok); }
.mem-turn.bot { color: var(--bad); animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .45; } }
.mem-card.pop .mem-inner { animation: pop .35s ease; }
@keyframes pop { 50% { transform: rotateY(180deg) scale(1.1); } }

/* ===== Tris ===== */
.tris-p, .tris-turn-ic, .tris-board { --tris-x: #ef4f6b; --tris-o: #2d7ff9; }
.tris-p b { width: 30px; height: 30px; display: block; }
.tris-p svg, .tris-turn-ic svg, .tris-mark svg { width: 100%; height: 100%; display: block; overflow: visible; fill: none; stroke-linecap: round; }
.tris-p svg { stroke-width: 15; }
.tris-p.x svg, .tris-turn-ic.x svg { stroke: var(--tris-x); }
.tris-p.o svg, .tris-turn-ic.o svg { stroke: var(--tris-o); }
.tris-turn-ic { width: 40px; height: 40px; }
.tris-turn-ic svg { stroke-width: 14; animation: pop-box .3s ease both; }
.tris-turn { color: var(--ok); }
.tris-turn.bot { color: var(--bad); animation: blink 1.2s ease-in-out infinite; }
.tris-turn.won { color: var(--ok); animation: none; }
.tris-stage { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.tris-board { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tris-cell {
  position: relative; aspect-ratio: 1; border-radius: 20px; display: grid; place-items: center;
  background: linear-gradient(180deg, #ffffff, #eef0f7);
  box-shadow: 0 5px 0 #c9cde0, 0 12px 18px -12px rgba(10,12,30,.6);
  transition: transform .1s, box-shadow .1s, background .3s;
}
.tris-cell.free:active { transform: translateY(3px); box-shadow: 0 2px 0 #c9cde0, 0 6px 10px -8px rgba(10,12,30,.6); }
.tris-cell.nope { animation: shake .3s; }
.tris-mark { width: 70%; height: 70%; display: block; }
.tris-mark svg { stroke-width: 13; }
.tris-mark.x svg { stroke: var(--tris-x); }
.tris-mark.o svg { stroke: var(--tris-o); }
.tris-mark.in svg > * { stroke-dasharray: 1; animation: draw .26s ease-out both; }
.tris-mark.in svg .d2 { animation-delay: .12s; }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.tris-mark.out { animation: mark-out .3s ease-in forwards; }
@keyframes mark-out { to { opacity: 0; transform: scale(.35) rotate(-25deg); } }
/* Il segno che sta per sparire: sbiadito, pulsante, con un bordo tratteggiato. */
.tris-cell.fading .tris-mark { animation: fading 1.4s ease-in-out infinite; }
.tris-cell.fading::after {
  content: ""; position: absolute; inset: 7px; border-radius: 14px; pointer-events: none;
  border: 2.5px dashed color-mix(in srgb, var(--text-2) 55%, transparent);
}
@keyframes fading { 0%, 100% { opacity: .5; } 50% { opacity: .18; } }
.tris-cell.hint { animation: tris-hint 1s ease-in-out infinite; }
@keyframes tris-hint { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--gold) 70%, transparent), 0 5px 0 #c9cde0; } }
.tris-cell.win { background: linear-gradient(180deg, #fffbe8, #ffefb0); }
.tris-cell.win .tris-mark { animation: win-pop .5s .2s ease both; }
@keyframes win-pop { 50% { transform: scale(1.18); } }
.tris-line { position: absolute; inset: 0; pointer-events: none; }
.tris-line svg { width: 100%; height: 100%; overflow: visible; }
.tris-line line { stroke-width: 11; stroke-linecap: round; stroke-dasharray: 1; animation: draw .45s ease-out both; filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
.tris-line line.x { stroke: var(--tris-x); }
.tris-line line.o { stroke: var(--tris-o); }
.tris-tip { min-height: 18px; text-align: center; font-size: 13px; font-weight: 700; color: var(--text-2); }

/* ===== Testa o croce ===== */
.coin-area { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-top: 30px; min-height: 300px; position: relative; z-index: 2; }
.coin-stage { --coin: min(52vw, 200px); position: relative; width: var(--coin); height: calc(var(--coin) + 30px); display: flex; justify-content: center; }
.coin-toss { position: relative; width: var(--coin); height: var(--coin); perspective: 900px; cursor: pointer; }
/* Niente opacità o filtri su .coin-spin: appiattirebbero il 3D. */
.coin-spin { position: relative; width: 100%; height: 100%; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; }
.coin-rim { position: absolute; inset: 0; border-radius: 50%; background: #a87400; }
.coin-rim:nth-child(odd) { background: #cf9a17; }
.coin-face {
  position: absolute; inset: 0; border-radius: 50%; overflow: hidden;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  background: radial-gradient(circle at 34% 28%, #fff6cc 0%, #ffd95e 20%, #f3b81f 50%, #d39a06 78%, #a97600 100%);
  box-shadow: inset 0 0 0 3px #a97600, inset 0 0 0 6px #ffe48f, inset 0 0 0 8px #c48c00, inset 0 -8px 18px rgba(110,70,0,.4);
}
.coin-face svg { position: absolute; inset: 0; width: 100%; height: 100%; font-family: var(--font); }
.coin-face::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.6) 47%, transparent 62%) no-repeat;
  background-size: 260% 100%; background-position: 130% 0; animation: coin-idle 5s ease-in-out 1.5s infinite;
}
.coin-stage.shine .coin-face::after { animation: coin-shine .9s ease-out; }
@keyframes coin-idle { 0%, 72% { background-position: 130% 0; } 100% { background-position: -40% 0; } }
@keyframes coin-shine { from { background-position: 130% 0; } to { background-position: -40% 0; } }
.coin-shadow {
  position: absolute; bottom: 2px; left: 50%; width: calc(var(--coin) * .78); height: 24px; margin-left: calc(var(--coin) * -.39);
  border-radius: 50%; background: radial-gradient(closest-side, rgba(0,0,0,.42), rgba(0,0,0,0));
}
.coin-result { height: 54px; text-align: center; margin-top: 6px; opacity: 0; transition: opacity .2s; }
.coin-result.show { opacity: 1; animation: bounce-in .45s cubic-bezier(.3,1.6,.5,1); }
.coin-result b { display: block; font-size: 28px; font-weight: 900; letter-spacing: .08em; line-height: 1.15; color: var(--gold-ink); }
.coin-result.ok b { color: var(--ok); }
.coin-result.bad b { color: var(--bad); }
.coin-result small { font-size: 13px; font-weight: 800; color: var(--text-2); }
.coin-q { text-align: center; color: var(--text-2); font-weight: 800; margin: 6px 0 12px; }
.coin-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.coin-pick {
  height: 64px; border-radius: 18px; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 900; font-size: 19px; color: #4a3000; background: linear-gradient(180deg, #ffe07a, #f5b301);
  box-shadow: 0 4px 0 #c48f00, 0 10px 18px -8px rgba(197,140,0,.7); transition: transform .08s, box-shadow .08s, opacity .2s;
}
.coin-pick .ic { width: 24px; height: 24px; display: block; }
.coin-pick .ic svg { width: 100%; height: 100%; display: block; }
.coin-pick:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #c48f00; }
.coin-pick:disabled { opacity: .5; }
.coin-pick.chosen:disabled { opacity: 1; box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--gold), 0 4px 0 #c48f00; }
.coin-history { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; margin-top: 14px; min-height: 26px; }
.coin-history.past { justify-content: flex-start; margin: 0; }
.coin-dot {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 900; color: #6b4a00;
  background: radial-gradient(circle at 35% 30%, #fff1b0, #f2b51c 60%, #c48c00);
}
.coin-history:not(.past) .coin-dot:first-child { animation: pop-box .3s ease both; }
.coin-dot.ok { box-shadow: 0 0 0 2px var(--ok); }
.coin-dot.bad { box-shadow: 0 0 0 2px var(--bad); }

/* ===== Rotola ===== */
.roll-stage {
  position: relative; flex: 1; min-height: 380px; margin-top: 2px; border-radius: 22px; overflow: hidden; background: #060a1c;
  touch-action: none; -webkit-user-select: none; user-select: none; box-shadow: 0 0 0 1px var(--border), var(--shadow-lg);
}
.roll-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.roll-flash { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle, rgba(255,90,60,.0) 30%, rgba(255,40,60,.55)); opacity: 0; }
.roll-flash.hit { animation: roll-hit .7s ease-out; }
@keyframes roll-hit { 10% { opacity: 1; } 100% { opacity: 0; } }
.roll-hud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: center; padding: 12px 14px; pointer-events: none; }
.roll-score { display: flex; flex-direction: column; align-items: center; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
.roll-score b { font-size: 38px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.roll-score small { font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: #6ff3e0; }
.roll-gems { position: absolute; left: 14px; top: 14px; display: flex; align-items: center; gap: 6px; color: #fff; font-weight: 900; font-size: 16px; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.roll-gems i { width: 14px; height: 14px; background: #7ff7ff; transform: rotate(45deg); border-radius: 2px; box-shadow: 0 0 10px #7ff7ff; }
.roll-banner {
  position: absolute; left: 50%; top: 74px; transform: translateX(-50%); pointer-events: none; opacity: 0; white-space: nowrap;
  padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 800; letter-spacing: .04em; color: #fff;
  background: rgba(10,12,20,.38); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.roll-banner.show { animation: roll-banner 2.4s ease both; }
@keyframes roll-banner {
  0% { opacity: 0; transform: translate(-50%, -6px); }
  12%, 78% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 0); }
}
.roll-overlay { position: absolute; inset: 0; display: none; place-items: center; padding: 20px; background: rgba(4,6,18,.5); }
.roll-overlay.show { display: grid; animation: fade .2s both; }
.roll-card {
  width: 100%; max-width: 300px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 18px;
  text-align: center; color: #fff; border-radius: 22px; background: rgba(14,16,40,.9); border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 18px 40px rgba(0,0,0,.5); animation: rise .3s both;
}
.roll-card b { font-size: 22px; font-weight: 900; }
.roll-card small { color: rgba(255,255,255,.75); font-weight: 700; font-size: 13.5px; line-height: 1.35; }
.roll-hand { width: 30px; height: 30px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 8px rgba(255,255,255,.22); animation: roll-hand 1.4s ease-in-out infinite; }
@keyframes roll-hand { 0%, 100% { transform: translateX(-34px); } 50% { transform: translateX(34px); } }
.roll-final { display: flex; flex-direction: column; align-items: center; font-size: 48px; font-weight: 900; line-height: 1; }
.roll-card .btn, .roll-continue { width: 100%; }
.roll-continue { justify-content: space-between; color: var(--text); }

/* ===== Sfide a due ===== */
.duo-p b { color: var(--p); }
.duo-win {
  position: fixed; left: 50%; top: 42%; z-index: 15; transform: translate(-50%, -50%); width: min(86vw, 340px);
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 20px 18px; border-radius: 24px; text-align: center;
  background: var(--surface); border: 3px solid var(--p); box-shadow: 0 0 0 6px color-mix(in srgb, var(--p) 25%, transparent), var(--shadow-lg);
  animation: bounce-in .5s cubic-bezier(.3,1.6,.5,1) both;
}
.duo-win b { font-size: 24px; font-weight: 900; color: var(--p); }
.duo-win small { font-size: 30px; font-weight: 900; font-variant-numeric: tabular-nums; }

/* Bandiere a due: schermo diviso, il Giocatore 2 in alto capovolto. */
.duel { flex: 1; display: grid; grid-template-rows: 1fr auto 1fr; gap: 6px; touch-action: manipulation; }
.duel-side {
  display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 20px;
  background: color-mix(in srgb, var(--p) 8%, var(--surface)); border: 2px solid color-mix(in srgb, var(--p) 45%, transparent);
  transition: opacity .2s, box-shadow .2s;
}
.duel-side.p1 { transform: rotate(180deg); }
.duel-side.locked { opacity: .55; }
.duel-side.won { box-shadow: 0 0 0 4px var(--p); }
.duel-head { display: flex; justify-content: space-between; align-items: center; font-weight: 900; color: var(--p); }
.duel-head b { font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
.duel-flag { display: grid; place-items: center; height: clamp(64px, 13vh, 100px); }
.duel-flag .flag-emoji { font-size: clamp(54px, 11vh, 84px); }
.duel-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.duel-opt { min-height: 46px; padding: 6px 8px; font-size: 14px; justify-content: center; text-align: center; }
.duel-opt .opt-t { line-height: 1.15; }
.duel-status { min-height: 18px; text-align: center; font-size: 13px; font-weight: 800; color: var(--text-2); }
.duel-mid { text-align: center; font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }

/* Triplo a due: pulsante "Triplo!" per lato, tavolo in comune che si colora di chi gioca. */
.tri-duel { flex: 1; display: flex; flex-direction: column; gap: 8px; justify-content: center; touch-action: manipulation; }
.duel-bar {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 18px;
  background: color-mix(in srgb, var(--p) 8%, var(--surface)); border: 2px solid color-mix(in srgb, var(--p) 45%, transparent);
}
.duel-bar.p1 { transform: rotate(180deg); }
.duel-bar.active { box-shadow: 0 0 0 3px var(--p); }
.duel-bar.out { opacity: .55; }
.duel-who { flex: 1; display: grid; grid-template-columns: auto auto; align-items: center; column-gap: 10px; color: var(--p); font-weight: 900; }
.duel-who b { font-size: 24px; line-height: 1; justify-self: start; font-variant-numeric: tabular-nums; }
.duel-who small { grid-column: 1 / -1; font-size: 12px; color: var(--text-2); min-height: 15px; }
.duel-buzz {
  flex: none; height: 52px; padding: 0 22px; border-radius: 16px; font-weight: 900; font-size: 18px; color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--p) 80%, white), var(--p));
  box-shadow: 0 4px 0 color-mix(in srgb, var(--p) 60%, black); transition: transform .08s, opacity .2s;
}
.duel-buzz:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--p) 60%, black); }
.duel-buzz:disabled { opacity: .4; }
.duel-timer { position: absolute; left: 0; bottom: 0; height: 4px; width: 0; background: var(--p); transition: width .1s linear; }
.tri-duel-table { transition: box-shadow .2s; }
.tri-duel-table.claimed { box-shadow: 0 0 0 4px var(--p), var(--shadow); }
.tri-duel-table .tri-card:disabled { cursor: default; }

/* Memory a due: coppie blu (Giocatore 1) e rosse (Giocatore 2). */
.mem-grid.duo .mem-card.matched .mem-front { background: linear-gradient(180deg, #eef5ff, #d6e6ff); box-shadow: 0 0 0 3px #2d7ff9, 0 4px 0 #9cc0f7; }
.mem-grid.duo .mem-card.matched.bot .mem-front { background: linear-gradient(180deg, #fff1f2, #ffe0e3); box-shadow: 0 0 0 3px #ef4f6b, 0 4px 0 #f3a3ab; }

/* ===== Triplo ===== */
/* Le carte sono sempre chiare (come vere carte da gioco): colori dei simboli fissi, ben contrastati. */
.tri-card, .tri-mini { --tri-0: #1f74d6; --tri-1: #f08a00; --tri-2: #0d9b6c; }
.tri-clock { font-size: 40px; font-weight: 900; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; transition: color .3s; }
.tri-clock.warn { color: var(--warn); }
.tri-clock.low { color: var(--bad); animation: beat 1s ease-in-out infinite; }
@keyframes beat { 50% { transform: scale(1.08); } }
.tri-delta {
  position: absolute; left: 100%; top: -2px; margin-left: 4px; white-space: nowrap;
  font-size: 18px; font-weight: 900; animation: delta 1s ease-out forwards;
}
.tri-delta.plus { color: var(--ok); }
.tri-delta.minus { color: var(--bad); }
@keyframes delta { 0% { opacity: 0; transform: translateY(6px) scale(.8); } 20% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-14px); } }
.tri-timebar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 12px 0 14px; }
.tri-timebar span {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--ok), color-mix(in srgb, var(--ok) 60%, white));
  transition: width .15s linear, background .4s;
}
.tri-timebar.warn span { background: linear-gradient(90deg, var(--warn), color-mix(in srgb, var(--warn) 60%, white)); }
.tri-timebar.low span { background: linear-gradient(90deg, var(--bad), color-mix(in srgb, var(--bad) 60%, white)); }
.tri-timebar.gain span { animation: gain .6s ease-out; }
@keyframes gain { 40% { filter: brightness(1.5) saturate(1.4); } }

.g-table.low { box-shadow: inset 0 2px 10px rgba(0,0,0,.18), 0 0 0 2px color-mix(in srgb, var(--bad) 60%, transparent), 0 0 24px -4px var(--bad); }
.tri-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tri-card {
  position: relative; aspect-ratio: 1.3; border-radius: 16px; border: 0;
  background: linear-gradient(180deg, #ffffff, #eef0f7);
  display: grid; place-items: center;
  box-shadow: 0 4px 0 #c9cde0, 0 10px 16px -10px rgba(10,12,30,.6);
  transition: transform .12s, box-shadow .12s, background .15s;
}
.tri-card:active { transform: translateY(2px); box-shadow: 0 2px 0 #c9cde0; }
.tri-face { display: flex; gap: 5px; align-items: center; justify-content: center; }
.tri-face svg { width: 26px; height: 26px; overflow: visible; filter: drop-shadow(0 1px 0 rgba(0,0,0,.12)); }
.tri-card.sel {
  transform: translateY(-5px) scale(1.03);
  box-shadow: 0 0 0 3px var(--game-color), 0 9px 0 color-mix(in srgb, var(--game-color) 55%, #000), 0 14px 22px -8px var(--game-color);
}
.tri-card.sel::after {
  content: "✓"; position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 900; color: #fff;
  background: var(--game-color); box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.tri-card.hit { background: linear-gradient(180deg, #ecfdf4, #d4f7e5); box-shadow: 0 0 0 3px var(--ok), 0 4px 0 #8fdcb5; animation: hit .45s ease; }
@keyframes hit { 40% { transform: scale(1.08); } }
.tri-card.miss { background: linear-gradient(180deg, #fff1f2, #ffe0e3); box-shadow: 0 0 0 3px var(--bad), 0 4px 0 #f3a3ab; animation: shake .3s; }
.tri-card.hint:not(.sel) { box-shadow: 0 0 0 3px var(--warn), 0 4px 0 #c9cde0; animation: hint 1.2s ease-in-out infinite; }
@keyframes hint { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--warn) 45%, transparent), 0 4px 0 #c9cde0; } }
.tri-card.deal { animation: deal .4s cubic-bezier(.3,1.4,.5,1); }
@keyframes deal { from { opacity: 0; transform: translateY(-14px) rotate(-6deg) scale(.85); } }
.tri-last { display: flex; align-items: center; gap: 10px; margin-top: 12px; animation: rise .3s both; }
.tri-last[hidden] { display: none; }
.tri-last small { font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); white-space: nowrap; }
.tri-last .tri-slot { flex: 1; }
.tri-actions { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; }
.tri-actions .help-btn { align-self: center; }
.tri-slot { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); min-height: 42px; }
.tri-slot.empty { background: transparent; border: 1.5px dashed var(--border); }
.tri-mini {
  flex: 1; height: 34px; border-radius: 8px; background: linear-gradient(180deg, #ffffff, #eef0f7);
  box-shadow: 0 2px 0 #c9cde0; display: grid; place-items: center;
}
.tri-mini .tri-face { gap: 1px; }
.tri-mini svg { width: 11px; height: 11px; }
.tri-example { display: grid; gap: 4px; }
.tri-example .tri-mini { height: 48px; }
.tri-example .tri-mini .tri-face { gap: 3px; }
.tri-example .tri-mini svg { width: 17px; height: 17px; }

/* ===== Sudoku ===== */
.sdk-board {
  display: grid; grid-template-columns: repeat(9, 1fr); aspect-ratio: 1;
  border: 2px solid var(--text-2); border-radius: 14px; overflow: hidden; background: var(--surface);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--game-color) 35%, var(--border)), 0 12px 24px -12px rgba(0,0,0,.5);
}
.g-table:has(.sdk-board) { padding: 8px; }
.sdk-cell {
  position: relative; display: grid; place-items: center; min-width: 0;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  font-size: clamp(18px, 5.6vw, 24px); font-weight: 700; color: var(--game-color); font-variant-numeric: tabular-nums;
  transition: background .1s;
}
.sdk-cell:nth-child(9n) { border-right: 0; }
.sdk-cell:nth-child(n+73) { border-bottom: 0; }
.sdk-cell.bx-r { border-right: 2px solid var(--text-2); }
.sdk-cell.bx-b { border-bottom: 2px solid var(--text-2); }
.sdk-cell.given { color: var(--text); font-weight: 900; }
.sdk-cell.peer { background: var(--surface-2); }
.sdk-cell.same { background: color-mix(in srgb, var(--game-color) 20%, var(--surface)); }
.sdk-cell.sel { background: color-mix(in srgb, var(--game-color) 36%, var(--surface)); }
.sdk-cell.err { color: var(--bad); }
.sdk-cell.err:not(.sel) { background: var(--bad-soft); }
.sdk-notes {
  position: absolute; inset: 1px; display: grid; grid-template-columns: repeat(3, 1fr);
  font-size: clamp(8px, 2.3vw, 10px); font-weight: 700; color: var(--text-2); line-height: 1;
}
.sdk-notes span { display: grid; place-items: center; }
.sdk-board.won .sdk-cell { animation: won .6s ease both; }
.sdk-board.won .sdk-cell:nth-child(odd) { animation-delay: .08s; }
@keyframes won { 50% { background: var(--ok-soft); } }
.sdk-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0; }
.sdk-tool .price {
  position: absolute; top: 0; left: calc(50% + 10px); padding: 1px 6px 1px 3px; border-radius: 99px; font-size: 11px; gap: 2px;
  background: color-mix(in srgb, var(--gold) 18%, var(--surface-2)); color: var(--gold-ink);
}
.sdk-tool .price .coin-ic, .sdk-tool .price .coin-ic svg { width: 13px; height: 13px; }
.sdk-tool {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0;
  border-radius: 12px; font-size: 12px; font-weight: 800; color: var(--text-2);
}
.sdk-tool svg { width: 22px; height: 22px; }
.sdk-tool span { text-align: center; line-height: 1.15; }
.sdk-tool:active { background: var(--surface-2); }
.sdk-tool.on { color: var(--game-color); background: color-mix(in srgb, var(--game-color) 14%, transparent); }
.sdk-pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
.sdk-key {
  height: 58px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 3px 0 var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  font-size: 24px; font-weight: 800; color: var(--game-color); transition: transform .08s, box-shadow .08s;
}
.sdk-key small { font-size: 10px; font-weight: 700; color: var(--text-2); margin-top: 4px; }
.sdk-key.notes { font-size: 17px; font-style: italic; }
.sdk-key.done { opacity: .3; box-shadow: none; }
.sdk-key:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }

/* ===== Blockslate ===== */
.bk-hud { display: flex; flex-direction: column; align-items: center; margin: auto 0 10px; line-height: 1; }
.bk-score { font-size: 38px; font-weight: 900; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.bk-score.bump { animation: bump .32s ease; }
.bk-rec { margin-top: 5px; font-size: 12px; font-weight: 800; color: var(--text-2); }
.bk-rec.new { color: var(--ok); }
.bk-stage { position: relative; display: flex; justify-content: center; margin-bottom: auto; }
.bk-canvas { display: block; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 20px; box-shadow: 0 14px 28px -14px rgba(0,0,0,.55); }
.bk-over { position: absolute; inset: 0; display: none; place-items: center; padding: 20px; border-radius: 20px; background: rgba(14,14,18,.62); }
.bk-over.show { display: grid; animation: fade .25s both; }
.bk-card { width: 100%; max-width: 280px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 18px; text-align: center; color: #f3ead7; border-radius: 18px; background: #2a2d34; border: 1px solid rgba(255,255,255,.1); box-shadow: 0 18px 40px rgba(0,0,0,.5); animation: rise .3s both; }
.bk-card b { font-size: 22px; font-weight: 900; }
.bk-card small { color: rgba(243,234,215,.72); font-weight: 700; font-size: 13.5px; line-height: 1.35; }
.bk-card .btn, .bk-change { width: 100%; }
.bk-change { justify-content: space-between; color: var(--text); }

/* ===== Solitario ===== */
.so-hud { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: -2px 2px 8px; font-size: 13px; font-weight: 800; color: var(--text-2); font-variant-numeric: tabular-nums; }
.so-hud b { color: var(--text); font-size: 17px; font-weight: 900; }
.so-table { position: relative; isolation: isolate; flex: 1; min-height: 340px; margin: 0 -10px; overflow: hidden; border-radius: 16px; touch-action: none; user-select: none; -webkit-user-select: none; background: #1f4a3c; box-shadow: inset 0 0 0 1px rgba(0,0,0,.35), 0 10px 24px -14px rgba(0,0,0,.6); }
.so-felt { position: absolute; inset: 0; width: 100%; height: 100%; }
.so-slot { position: absolute; left: 0; top: 0; pointer-events: none; }
.so-card { position: absolute; left: 0; top: 0; perspective: 500px; transition: transform .19s cubic-bezier(.25,.8,.3,1); will-change: transform; }
.so-card.held { transition: none; }
.so-card.held .so-face { box-shadow: 0 9px 14px rgba(0,0,0,.45); }
.so-inner { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateY(180deg); transition: transform .24s ease; }
.so-inner.up { transform: rotateY(0); }
.so-face, .so-back { position: absolute; inset: 0; width: 100%; height: 100%; background-size: 100% 100%; border-radius: 8.5% / 6%; box-shadow: 0 1px 2px rgba(0,0,0,.42); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.so-back { transform: rotateY(180deg); }
.so-flash .so-face, .so-flash .so-back, .so-slot.so-flash { animation: so-flash .55s ease 4; }
@keyframes so-flash { 50% { box-shadow: 0 0 0 2px #ffdf8a, 0 0 12px 3px rgba(255,223,138,.8); } }
.so-no { animation: so-no .24s ease; }
@keyframes so-no { 25% { margin-left: -3px; } 75% { margin-left: 3px; } }
.so-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.so-tool { display: flex; align-items: center; justify-content: center; gap: 6px; height: 46px; border-radius: 14px; font-size: 13px; font-weight: 800; background: var(--surface); border: 1px solid var(--border); color: var(--text); min-width: 0; padding: 0 6px; line-height: 1.1; position: relative; }
.so-tool > svg { width: 18px; height: 18px; flex: none; }
.so-tool span { text-align: center; }
@media (max-width: 420px) { .so-tool > svg { display: none; } }
.so-tool:disabled { opacity: .45; }
/* Il prezzo è un bollino sull'angolo, così il nome del tasto ha tutto lo spazio. */
.so-tool .price { position: absolute; top: -8px; right: -4px; padding: 2px 6px 2px 3px; border-radius: 99px; font-size: 11px; white-space: nowrap;
  background: color-mix(in srgb, var(--gold) 22%, var(--surface-2)); color: var(--gold-ink); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.so-tool .price .coin-ic, .so-tool .price .coin-ic svg { width: 13px; height: 13px; }
.so-over { position: absolute; inset: 0; z-index: 400; display: none; place-items: center; padding: 20px; background: rgba(6,16,12,.6); }
.so-over.show { display: grid; animation: fade .25s both; }
.so-card-msg { width: 100%; max-width: 280px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 18px; text-align: center; color: #2b2520; border-radius: 16px; background: #f6efdf; box-shadow: 0 18px 40px rgba(0,0,0,.5); animation: rise .3s both; }
.so-card-msg b { font-size: 20px; font-weight: 900; }
.so-card-msg small { color: #6a5f50; font-weight: 700; font-size: 13.5px; line-height: 1.35; }

/* ===== Mahjong ===== */
.mj-table { position: relative; flex: 1; min-height: 340px; margin: 0 -10px; overflow: hidden; border-radius: 16px; background: #3a2418; box-shadow: inset 0 0 0 1px rgba(0,0,0,.35), 0 10px 24px -14px rgba(0,0,0,.6); }
.mj-canvas { display: block; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.mj-over { position: absolute; inset: 0; z-index: 2; display: none; place-items: center; padding: 20px; background: rgba(20,10,4,.6); }
.mj-over.show { display: grid; animation: fade .25s both; }
.mj-mix { width: 100%; justify-content: space-between; color: var(--text); }
.so-card-msg .btn { width: 100%; }

/* ===== Scala ===== */
.sc-stage { position: relative; flex: 1; min-height: 330px; margin: 0 -10px; border-radius: 16px; overflow: hidden; background: linear-gradient(180deg, var(--surface) 55%, color-mix(in srgb, var(--game-color) 9%, var(--surface))); border: 1px solid var(--border); touch-action: none; user-select: none; -webkit-user-select: none; cursor: ns-resize; }
.sc-stage.shown { cursor: default; }
.sc-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.sc-top { position: absolute; left: 14px; right: 14px; top: 12px; text-align: center; pointer-events: none; }
.sc-caption { font-weight: 800; color: var(--text); line-height: 1.25; }
.sc-hint { margin-top: 4px; font-size: 12.5px; font-weight: 800; color: var(--text-2); transition: opacity .3s; }
.sc-hint.off { opacity: 0; }
.sc-names { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 0; font-weight: 800; font-size: 14px; line-height: 1.25; }
.sc-name { color: var(--text-2); text-align: center; min-width: 0; overflow-wrap: anywhere; }
.sc-name.b { color: var(--game-color); }
.sc-out { min-height: 40px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0 4px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.sc-out .pill { font-size: 15px; padding: 4px 12px; }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.sc-ctrl { display: grid; grid-template-columns: 54px minmax(0, 1fr) 54px; gap: 10px; }
.sc-step { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; height: 54px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: 28px; font-weight: 900; line-height: 1; }
.sc-step:disabled { opacity: .4; }
.sc-step:active:not(:disabled) { transform: translateY(2px); }
.sc-loading { margin: auto; color: var(--text-2); font-weight: 800; }
.an-guess { text-align: center; font-size: 40px; font-weight: 900; line-height: 1.1; margin: 8px 0 0; font-variant-numeric: tabular-nums; color: var(--game-color); }

/* ===== Risultato ===== */
.result-head { text-align: center; margin: 8px 0 18px; }
@keyframes bounce-in { from { transform: scale(.2); opacity: 0; } }
.result-head .score { font-size: 56px; font-weight: 900; letter-spacing: -.03em; line-height: 1; animation: rise .4s .1s both; }
.result-head .label { color: var(--text-2); margin-top: 6px; font-weight: 700; }
.kpis { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; text-align: center; }
.countdown { text-align: center; }
.countdown-t { font-size: 30px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.kpi .v { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.kpi .k { font-size: 12px; font-weight: 700; color: var(--text-2); }
.review { display: grid; gap: 6px; }
.review-row { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.review-row .e { font-family: var(--emoji); font-size: 22px; width: 32px; text-align: center; }

.xp-card { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; animation: rise .45s .15s both; }
.xp-top { display: flex; align-items: center; gap: 12px; }
.xp-top .lvl-badge { width: 44px; height: 44px; border-radius: 14px; font-size: 19px; }
.xp-top .info { flex: 1; }
.xp-top .info b { font-weight: 900; }
.xp-gain { font-size: 24px; font-weight: 900; color: var(--accent); font-variant-numeric: tabular-nums; }
.xp-parts { display: flex; flex-wrap: wrap; gap: 6px; }
.unlock {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px;
  background: color-mix(in srgb, var(--gold) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  animation: rise .45s both;
}
.unlock b { display: block; font-weight: 900; }
.unlock small { color: var(--text-2); font-weight: 700; }
.lvl-up { background: linear-gradient(140deg, var(--accent), var(--accent-2)); color: #fff; border: 0; }
.lvl-up small { color: rgba(255,255,255,.85); }

/* ===== Statistiche e traguardi ===== */
.dist { display: grid; gap: 4px; }
.dist-row { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: center; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dist-bar { height: 22px; border-radius: 7px; background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: flex-end; padding: 0 7px; min-width: 26px; }
.dist-bar.hl { background: var(--accent); color: var(--accent-text); }
.ach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ach {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 12px 6px;
  border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.ach .ic { width: 30px; height: 30px; color: var(--gold); }
.ach .ic svg { display: block; width: 100%; height: 100%; }
.ach b { font-size: 12px; font-weight: 900; line-height: 1.15; }
.ach small { font-size: 10.5px; color: var(--text-2); font-weight: 600; line-height: 1.2; }
.ach.locked .ic { filter: grayscale(1); opacity: .35; }
.ach.locked b { color: var(--text-2); }

/* ===== Impostazioni ===== */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); font-weight: 700; }
.setting:last-child { border-bottom: 0; }
.segmented { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.segmented button { padding: 7px 12px; border-radius: 9px; font-size: 14px; font-weight: 800; color: var(--text-2); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.setting.col { flex-direction: column; align-items: stretch; }
.picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pick { position: relative; display: grid; place-items: center; padding: 6px 0; border-radius: 14px; transition: transform .1s; }
.pick:active { transform: scale(.92); }
.pick.on { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--accent); }
.pick.locked > :first-child { filter: grayscale(.85); opacity: .3; }
.pick .lock { position: absolute; inset: 0; display: grid; place-items: center; }
.pick .lock svg { width: 16px; height: 16px; }
.lang-list { padding-top: 4px; padding-bottom: 4px; }
.lang-item { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 13px 0; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 700; text-align: left; }
.lang-item:last-child { border-bottom: 0; }
.lang-item.on { color: var(--accent); font-weight: 900; }
.lang-check { font-weight: 900; color: var(--accent); }
.lang-first { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; padding-bottom: 48px; }
.lang-first h1 { margin: 0; font-size: 36px; font-weight: 900; letter-spacing: -.01em; }
.lang-first p { margin: 6px 0 20px; font-weight: 700; }
.lang-first .lang-item { justify-content: center; }
a { color: var(--accent); font-weight: 800; }

/* ===== Logo all'apertura: parte dalla schermata di Android (stesso sfondo, logo al centro) ===== */
.intro { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: #16161a; transition: opacity .15s; }
.intro.out { opacity: 0; }
.intro-logo { grid-area: 1 / 1; width: min(21vw, 104px); overflow: visible; animation: intro-up .28s .12s ease-out both; }
.intro-logo g { transform-box: fill-box; transform-origin: center; animation: intro-pop .3s ease-out both; }
.intro-logo g:nth-child(2) { animation-delay: .07s; }
.intro-logo g:nth-child(3) { animation-delay: .14s; }
.intro-logo g:nth-child(4) { animation-delay: .21s; }
.intro-name { grid-area: 1 / 1; margin-top: calc(min(21vw, 104px) + 8px); font-size: 30px; font-weight: 900; letter-spacing: -.01em; color: #fff; animation: intro-name .28s .3s ease-out both; }
@keyframes intro-up { to { transform: translateY(-22px); } }
@keyframes intro-pop { 50% { transform: scale(1.12); } }
@keyframes intro-name { from { opacity: 0; transform: translateY(8px); } }

/* ===== Toast / dialog / effetti ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 28px); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-weight: 800; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); z-index: 30;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(8,10,24,.55); display: grid; place-items: center; padding: 24px; z-index: 10;
  animation: fade .15s ease-out; backdrop-filter: blur(3px);
}
.dialog { width: 100%; max-width: 360px; border-radius: 24px; animation: rise .25s both; }
.dialog h3 { margin: 0 0 6px; font-weight: 900; font-size: 20px; }
.dialog p { margin: 0 0 18px; color: var(--text-2); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; }

/* ===== 4.0: rarità dei premi, dorsi nuovi, stile musica, Sudoku a 3 errori, novità ===== */
:root { --rar-common: #868ca3; --rar-rare: #2f7cf6; --rar-epic: #9b45ee; }
.rar-row { justify-content: center; gap: 6px; flex-wrap: wrap; }
.rar { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 900; letter-spacing: .02em; color: #fff; }
.rar-common { background: var(--rar-common); }
.rar-rare { background: var(--rar-rare); }
.rar-epic { background: linear-gradient(120deg, #7b3fe4, #c13fd0 55%, #e8a317); box-shadow: 0 0 14px -3px var(--rar-epic); }
.rar-dup { background: var(--surface-2); color: var(--text-2); }
.rar-legend { gap: 8px; }
.rar-legend .rar-row { justify-content: flex-start; }
.odds { text-align: center; margin-top: 12px; }
.pick.r-rare::after, .pick.r-epic::after { content: ""; position: absolute; right: 4px; bottom: 3px; width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); }
.pick.r-rare::after { background: var(--rar-rare); }
.pick.r-epic::after { background: linear-gradient(120deg, #7b3fe4, #e8a317); }
.pick.locked::after { opacity: .45; }
.chest-dialog[data-rarity="rare"] .chest-big::before {
  background: repeating-conic-gradient(color-mix(in srgb, var(--rar-rare) 55%, transparent) 0 9deg, transparent 9deg 24deg);
}
.chest-dialog[data-rarity="epic"] .chest-big::before {
  inset: -70px;
  background: repeating-conic-gradient(color-mix(in srgb, var(--rar-epic) 62%, transparent) 0 8deg, color-mix(in srgb, #e8a317 50%, transparent) 8deg 12deg, transparent 12deg 22deg);
}
.setting.col .segmented button { flex: 1; padding: 7px 2px; }

/* Dorsi nuovi */
[data-back="spades"] .mem-back { --b1: #63718f; --b2: #343d55; --emblem: "♠";
  --pat: repeating-linear-gradient(135deg, rgba(255,255,255,.1) 0 3px, transparent 3px 9px); }
[data-back="blossom"] .mem-back { --b1: #ffb27a; --b2: #ea6f3a; --emblem: "✿";
  --pat: radial-gradient(circle, rgba(255,255,255,.28) 2px, transparent 2.6px) 0 0 / 12px 12px, radial-gradient(circle, rgba(255,255,255,.16) 2px, transparent 2.6px) 6px 6px / 12px 12px; }
[data-back="chess"] .mem-back { --b1: #7d8a5c; --b2: #3f4a2c; --emblem: "♞";
  --pat: repeating-conic-gradient(rgba(255,255,255,.15) 0 25%, transparent 0 50%) 0 0 / 14px 14px; }
[data-back="notes"] .mem-back { --b1: #2fb6b0; --b2: #11707a; --emblem: "♪";
  --pat: repeating-linear-gradient(0deg, rgba(255,255,255,.2) 0 1.5px, transparent 1.5px 6px) 0 0 / 100% 30px no-repeat, repeating-linear-gradient(0deg, rgba(255,255,255,.2) 0 1.5px, transparent 1.5px 6px) 0 100% / 100% 30px no-repeat; }
[data-back="infinity"] .mem-back { --b1: #ff8a65; --b2: #c2185b; --emblem: "∞";
  --pat: repeating-radial-gradient(circle at 50% 50%, rgba(255,255,255,.14) 0 2px, transparent 2px 9px); }
[data-back="waves"] .mem-back { --b1: #3d8bfd; --b2: #1546a0; --emblem: "≈";
  --pat: radial-gradient(circle at 50% 100%, transparent 5px, rgba(255,255,255,.2) 5.5px 7.5px, transparent 8px) 0 0 / 16px 9px; }
[data-back="cosmos"] .mem-back { --b1: #3a1c71; --b2: #0d0b2a; --emblem: "✦"; --ink: #7b3fe4;
  --pat: radial-gradient(circle at 22% 28%, rgba(214,90,196,.55), transparent 42%), radial-gradient(circle at 78% 72%, rgba(90,88,224,.6), transparent 48%),
    radial-gradient(circle, rgba(255,255,255,.8) .8px, transparent 1.4px) 0 0 / 9px 11px, radial-gradient(circle, rgba(255,255,255,.5) .6px, transparent 1.1px) 4px 5px / 13px 9px;
  box-shadow: inset 0 0 0 3px #c9b8ff, 0 4px 0 #07061a, 0 10px 16px -10px rgba(0,0,0,.6); }
[data-back="neon"] .mem-back { --b1: #15151f; --b2: #050507; --emblem: "◆";
  --pat: repeating-linear-gradient(90deg, rgba(0,255,214,.13) 0 1px, transparent 1px 8px), repeating-linear-gradient(0deg, rgba(255,47,168,.13) 0 1px, transparent 1px 8px);
  box-shadow: inset 0 0 0 3px #00e6c3, inset 0 0 12px rgba(0,230,195,.55), 0 4px 0 #000, 0 10px 16px -10px rgba(0,0,0,.6); }
[data-back="neon"] .mem-back::after { background: #0b0b12; color: #ff2fa8; box-shadow: 0 0 0 2px #ff2fa8, 0 0 12px #ff2fa8; text-shadow: 0 0 6px #ff2fa8; }
[data-back="rainbow"] .mem-back { --b1: #ff5f6d; --b2: #7a4fd6; --emblem: "★"; --ink: #8a4fe0;
  --pat: linear-gradient(150deg, #ff5f6d, #ffb347 22%, #ffe66d 40%, #6ee7a8 58%, #4facfe 76%, #a66cff); }

/* Sudoku: partita persa al terzo errore */
.sdk-board.lost .sdk-cell { animation: lost .7s ease both; }
.sdk-board.lost .sdk-cell:nth-child(odd) { animation-delay: .08s; }
@keyframes lost { 50% { background: var(--bad-soft); } }

/* Novità dell'aggiornamento (una volta sola) */
.news-dialog { text-align: center; }
.news-kicker { font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.news-art { min-height: 150px; display: grid; place-items: center; margin: 4px 0 6px; }
.news-dialog p { margin: 0 0 6px; }
.news-dots { display: flex; justify-content: center; gap: 6px; margin: 10px 0 14px; }
.news-dots span { width: 7px; height: 7px; border-radius: 4px; background: var(--border); transition: width .2s, background .2s; }
.news-dots span.on { width: 20px; background: var(--accent); }
.eq { display: flex; align-items: flex-end; justify-content: center; gap: 7px; height: 76px; }
.eq i { width: 11px; border-radius: 6px; background: linear-gradient(var(--accent-2), var(--accent)); animation: eq .9s ease-in-out infinite alternate; }
@keyframes eq { from { height: 14px; } to { height: 76px; } }
.news-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 14px; }
.news-chips span { padding: 4px 11px; border-radius: 999px; background: var(--surface-2); font-weight: 800; font-size: 13px; }
.news-prizes { display: flex; align-items: center; gap: 12px; }
.news-prizes .chest-ic { width: 74px; height: 64px; }
.news-sdk { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.news-x { display: flex; gap: 10px; }
.news-x span { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.news-x span.on { background: var(--bad); color: #fff; }
.news-x svg { width: 22px; height: 22px; }


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
