/* NON PREMERE! — stile. Mobile first, contrasti alti, niente lampeggi. */

@font-face {
  font-family: "NP Display";
  src: url("../assets/fonts/bricolage-grotesque-wght.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --paper: #fff4dc;
  --paper-2: #ffe8b5;
  --card: #fffdf6;
  --ink: #16121f;
  --ink-2: #4b4459;
  --ink-3: #8a8296;
  --hot: #e8253a;
  --hot-2: #ff3b4e;
  --hazard: #ffd12e;
  --ok: #12a86a;
  --ok-2: #19c37d;
  --sky: #2f6bff;
  --violet: #9b5cff;
  --line: 3px;
  --r: 18px;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --font: "NP Display", "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-weight: 500;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(22, 18, 31, .075) 1.3px, transparent 1.6px);
  background-size: 22px 22px;
  line-height: 1.35;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.in-game { overflow: hidden; overscroll-behavior: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
svg { display: block; }

.noscript { padding: 24px; font-size: 18px; text-align: center; }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(12px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ---------- Focus visibile ---------- */
:focus { outline: none; }
:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; border-radius: 12px; }
.gbtn:focus-visible { outline-offset: -2px; outline: 5px solid var(--sky); }

/* ---------- Pulsanti generici ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px;
  padding: 10px 18px;
  border: var(--line) solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-weight: 750;
  font-size: 17px;
  letter-spacing: .01em;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: box-shadow .08s ease, background-color .12s ease;
}
.btn:active { box-shadow: 1px 1px 0 var(--ink); background-color: var(--paper-2); }
.btn-primary { background: var(--hot); color: #fff; }
.btn-primary:active { background: #c91d31; }
.btn-secondary { background: var(--hazard); }
.btn-secondary:active { background: #f2bf12; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; text-underline-offset: 4px; min-height: 48px; }
.btn-ghost:active { background: rgba(22, 18, 31, .06); box-shadow: none; }
.btn-whatsapp { background: #1fae5b; color: #fff; }
.btn-xl { min-height: 64px; font-size: 24px; font-weight: 800; border-radius: 20px; letter-spacing: .02em; }
.btn-small { min-height: 44px; font-size: 15px; padding: 6px 14px; box-shadow: var(--shadow-sm); }
.btn-stack { flex-direction: column; gap: 0; line-height: 1.15; padding: 8px 18px; }
.btn-title { font-weight: 800; }
.btn-sub { font-size: 13px; font-weight: 600; opacity: .8; }
.row { display: flex; gap: 12px; }
.row > .btn { flex: 1; }

.icon-btn {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border: var(--line) solid var(--ink); border-radius: 14px;
  background: var(--card); box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; fill: var(--ink); stroke: var(--ink); stroke-width: 0; }
#btn-quit svg { fill: none; stroke-width: 3; stroke-linecap: round; }
.icon-btn-small { width: 44px; height: 44px; }
.chip-btn {
  min-height: 44px; padding: 6px 14px;
  border: var(--line) solid var(--ink); border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow-sm);
  font-weight: 750; font-size: 15px; cursor: pointer;
}

/* ---------- HOME ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; }
.hero { text-align: center; padding: 6px 0 4px; }
.logo { display: flex; flex-direction: column; align-items: center; line-height: .86; margin-top: 4px; }
.logo-non {
  display: inline-block;
  font-size: clamp(22px, 7vw, 30px); font-weight: 800; letter-spacing: .06em;
  background: var(--hazard); border: var(--line) solid var(--ink); border-radius: 10px;
  padding: 4px 12px 2px; transform: rotate(-4deg); box-shadow: var(--shadow-sm);
  position: relative; z-index: 1; margin-bottom: -4px;
}
.logo-main { font-size: clamp(48px, 16vw, 78px); font-weight: 800; letter-spacing: -.035em; }
.logo-bang { color: var(--hot); display: inline-block; transform: rotate(8deg); }
.hero-button { position: relative; display: flex; justify-content: center; margin: 6px 0 4px; }
.red-button {
  width: clamp(130px, 40vw, 180px); aspect-ratio: 200 / 132;
  border: 0; background: none; padding: 0; cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.red-button .mascot { width: 100%; height: 100%; }
.red-button.squish .m-press { animation: squish .35s ease; transform-origin: 100px 132px; transform-box: view-box; }
@keyframes squish { 0% { transform: scaleY(1); } 35% { transform: scaleY(.72) scaleX(1.06); } 100% { transform: scaleY(1); } }
.speech {
  position: absolute; top: 2px; left: 50%; transform: translateX(18%);
  max-width: 48%;
  background: var(--card); border: var(--line) solid var(--ink); border-radius: 14px;
  padding: 6px 10px; font-size: 14px; font-weight: 700; text-align: left;
  box-shadow: var(--shadow-sm);
}
.tagline { font-size: 17px; font-weight: 650; color: var(--ink-2); max-width: 30ch; margin: 2px auto 0; text-wrap: balance; }

.home-actions { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.home-best { text-align: center; font-weight: 700; margin-top: 14px; }
.home-footer { margin-top: auto; padding-top: 18px; text-align: center; font-size: 13px; color: var(--ink-2); }
.link-btn { background: none; border: 0; padding: 4px 2px; min-height: 32px; font: inherit; font-weight: 750; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.privacy-body { display: flex; flex-direction: column; gap: 10px; font-size: 15px; font-weight: 550; color: var(--ink); }
.privacy-body p { overflow-wrap: anywhere; }

.notice, .challenge-card {
  margin-top: 14px;
  border: var(--line) solid var(--ink); border-radius: var(--r);
  background: var(--card); box-shadow: var(--shadow);
  padding: 14px;
}
.notice { background: #ffe1e4; display: flex; gap: 12px; align-items: center; }
.notice p { flex: 1; font-weight: 600; font-size: 15px; }
.challenge-card { background: var(--hazard); }
.challenge-title { font-size: 22px; font-weight: 800; overflow-wrap: anywhere; }
.challenge-target { font-weight: 700; margin-top: 2px; }
.challenge-note { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.challenge-card .row { margin-top: 12px; align-items: center; }
.challenge-card .row .btn-ghost { flex: 0 0 auto; }

/* ---------- MASCOTTE ---------- */
.mascot .m-base { fill: var(--ink); }
.mascot .m-plate { fill: var(--hazard); stroke: var(--ink); stroke-width: 6; }
.mascot .m-stripes { display: none; }
.mascot .m-dome { fill: var(--hot-2); stroke: var(--ink); stroke-width: 6; }
.mascot .m-shine { fill: none; stroke: rgba(255, 255, 255, .75); stroke-width: 7; stroke-linecap: round; }
.mascot .m-eye { fill: #fff; stroke: var(--ink); stroke-width: 4; }
.mascot .m-pupils { fill: var(--ink); transition: transform .25s ease; }
.mascot .m-lid { fill: none; stroke: var(--ink); stroke-width: 5; stroke-linecap: round; display: none; }
.mascot .m-brows { fill: none; stroke: var(--ink); stroke-width: 5; stroke-linecap: round; }
.mascot .m-mouth { fill: none; stroke: var(--ink); stroke-width: 5; stroke-linecap: round; display: none; }
.mascot .m-grin, .mascot .m-o { fill: var(--ink); stroke-width: 3; }
.mood-idle .m-smirk, .mood-smug .m-smirk, .mood-talk .m-o, .mood-peek .m-smirk { display: inline; }
.mood-idle .m-pupils { animation: look 4s ease-in-out infinite; }
.mood-smug .m-lid { display: inline; }
.mood-smug .m-pupils { transform: translate(4px, 3px); }
.mood-talk .m-pupils { transform: translate(-4px, 0); }
.mood-talk .m-o { animation: talk .3s ease-in-out infinite alternate; transform-origin: 100px 124px; }
.mood-peek .m-pupils { transform: translate(0, 4px); }
.mood-shock .m-o { display: inline; }
.mood-shock .m-brows { transform: translateY(-6px); }
.mood-laugh .m-grin { display: inline; }
.mood-laugh .m-brows { display: none; }
.mood-laugh .m-pupils { transform: translate(0, -2px); }
@keyframes look { 0%, 40% { transform: translate(0, 0); } 50%, 70% { transform: translate(-5px, 1px); } 80%, 100% { transform: translate(3px, 0); } }
@keyframes talk { from { transform: scaleY(.5); } to { transform: scaleY(1.2); } }

/* ---------- PARTITA ---------- */
.screen-game { position: relative; gap: 10px; height: calc(100dvh - 28px - var(--safe-t) - var(--safe-b)); min-height: 0; }
@supports not (height: 100dvh) { .screen-game { height: calc(100vh - 28px); } }
.hud { display: flex; align-items: center; gap: 10px; }
.clock { flex: 1; display: flex; align-items: center; gap: 8px; }
.clock-bar { flex: 1; height: 12px; border: var(--line) solid var(--ink); border-radius: 99px; background: var(--card); overflow: hidden; }
.clock-bar i { display: block; height: 100%; background: var(--ink); transform-origin: left; transform: scaleX(0); }
.clock-num { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 20px; min-width: 4.4ch; text-align: right; }
.clock-num small { font-size: 12px; font-weight: 700; color: var(--ink-3); }
.round-num { font-weight: 800; font-size: 14px; background: var(--ink); color: var(--paper); border-radius: 99px; padding: 6px 10px; white-space: nowrap; }

.instr-card {
  position: relative;
  border: var(--line) solid var(--ink); border-radius: var(--r);
  background: var(--card); box-shadow: var(--shadow);
  padding: 12px 14px 16px;
  min-height: 118px;
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
  overflow: hidden;
}
.tag {
  align-self: flex-start;
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  background: var(--ink); color: var(--paper); border-radius: 6px; padding: 3px 8px;
}
.instr-card[data-type="wait"] .tag { background: var(--hot); color: #fff; }
.instr-card[data-type="color"] .tag, .instr-card[data-type="word"] .tag, .instr-card[data-type="decoy"] .tag { background: var(--hazard); color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.instr {
  font-size: clamp(19px, 5.6vw, 25px); font-weight: 750; line-height: 1.22;
  min-height: 2.5em;
  display: flex; flex-wrap: wrap; align-items: center; column-gap: .3em; row-gap: 4px;
}
.instr.instr-wait { font-size: clamp(22px, 7vw, 30px); font-weight: 800; color: var(--hot); letter-spacing: -.01em; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: var(--line) solid var(--ink); border-radius: 12px;
  background: var(--paper); padding: 2px 10px 2px 6px;
  font-weight: 800; white-space: nowrap; line-height: 1.25;
}
.chip .sym { width: 1.25em; height: 1.25em; fill: var(--ink); }
.chip-color .swatch { width: 1.15em; height: 1.15em; border-radius: 50%; border: var(--line) solid var(--ink); display: inline-block; }
.chip-word { background: var(--card); padding: 2px 10px; }
.round-timer { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; background: rgba(22, 18, 31, .1); }
.round-timer i { display: block; height: 100%; background: var(--ok-2); transform-origin: left; }
#screen-game:has(.board.phase-show) .round-timer i { background: var(--violet); }
#screen-game:has(.board.type-wait) .round-timer i { background: var(--hot-2); }

/* Fascia scena: mascotte, consigli ingannevoli, oggetti da contare */
.stage {
  height: clamp(64px, 12vh, 104px);
  display: flex; align-items: center; gap: 10px;
  position: relative;
}
.stage .mascot { height: 100%; width: auto; flex: 0 0 auto; }
.bubble {
  position: relative;
  border: var(--line) solid var(--ink); border-radius: 16px;
  background: var(--card); padding: 6px 12px;
  font-weight: 750; font-size: clamp(15px, 4.4vw, 19px);
  display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap;
  transform: rotate(-2deg);
  box-shadow: var(--shadow-sm);
}
.bubble::before {
  content: ""; position: absolute; left: -10px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  background: var(--card); border-left: var(--line) solid var(--ink); border-bottom: var(--line) solid var(--ink);
  transform: rotate(45deg);
}
.bubble .sym.inline { width: 1.2em; height: 1.2em; fill: var(--hot); }
.stage-decoy .bubble { background: #ffe1e4; font-size: clamp(17px, 5vw, 22px); }
.stage-decoy .bubble::before { background: #ffe1e4; }
.bubble-quiet { color: var(--ink-3); }
.fake-toast {
  flex: 1; min-width: 0;
  border: var(--line) solid var(--ink); border-radius: 14px;
  background: var(--ink); color: var(--paper);
  padding: 8px 12px; font-size: 14px; font-weight: 700;
  box-shadow: 3px 3px 0 var(--violet);
  animation: toastIn .35s ease both;
}
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.count-items { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 6px 8px; width: 100%; height: 100%; padding: 4px; border: var(--line) dashed var(--ink-3); border-radius: 14px; background: var(--card); }
.count-items .sym { width: clamp(24px, 7vw, 32px); height: clamp(24px, 7vw, 32px); fill: var(--ink); }

/* Griglia dei pulsanti di gioco */
.board { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.grid {
  position: relative; z-index: 1;
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 2), minmax(0, 1fr));
  gap: 12px;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.gbtn {
  position: relative;
  min-width: 0; min-height: 0;
  width: 100%; height: 100%;
  border: var(--line) solid var(--ink); border-radius: 20px;
  background: var(--fill, var(--card));
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6%;
  padding: 6px;
  cursor: pointer;
  container-type: size;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.gbtn.neutral { background: var(--card); }
.gbtn .sym { width: 52cqmin; height: 52cqmin; fill: var(--ink); pointer-events: none; }
.gbtn .tok-shape { width: 44cqmin; height: 44cqmin; }
.gbtn .lbl {
  background: #fff; color: var(--ink);
  border: 2px solid var(--ink); border-radius: 10px;
  padding: 2px 8px; max-width: 100%;
  font-weight: 800; font-size: clamp(12px, 15cqmin, 22px); letter-spacing: .02em; line-height: 1.1;
  text-align: center; overflow-wrap: anywhere; hyphens: auto;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  pointer-events: none;
}
.gbtn .num { font-size: 46cqmin; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; pointer-events: none; }
.gbtn .key {
  position: absolute; top: 5px; left: 7px;
  font-size: 12px; font-weight: 800; color: var(--ink-2);
  background: rgba(255, 255, 255, .85); border-radius: 6px; padding: 0 5px;
  display: none; pointer-events: none;
}
.gbtn .back { display: none; }
@supports not (container-type: size) {
  .gbtn .sym { width: 48px; height: 48px; }
  .gbtn .lbl { font-size: 15px; }
  .gbtn .num { font-size: 40px; }
}
@media (hover: hover) and (pointer: fine) {
  .gbtn .key { display: block; }
  .gbtn:hover { filter: brightness(1.04); }
}
.kbd .gbtn .key { display: block; }
.keys-hint { display: none; text-align: center; font-size: 12px; color: var(--ink-3); }
@media (hover: hover) and (pointer: fine) and (min-height: 700px) { .keys-hint { display: block; } }

/* Nuovo round: comparsa rapida, finisce entro i 150 ms in cui gli input sono ignorati */
.board.phase-arm .gbtn, .board.phase-show .gbtn { animation: pop .12s ease-out both; }
@keyframes pop { from { transform: scale(.9); opacity: .4; } to { transform: none; opacity: 1; } }
.board.phase-show .gbtn { cursor: default; box-shadow: 2px 2px 0 var(--ink); }
.board.phase-show .gbtn .key { visibility: hidden; }

/* Memoria: simboli coperti */
.board.hidden-syms .gbtn .sym { visibility: hidden; }
.board.hidden-syms .gbtn { background: var(--ink); }
.board.hidden-syms .gbtn .back { display: block; position: absolute; inset: 0; display: grid; place-items: center; color: var(--hazard); font-weight: 800; font-size: 40cqmin; pointer-events: none; }
.board.hidden-syms .gbtn .key { color: var(--paper); background: rgba(255, 255, 255, .15); }

/* Feedback */
.gbtn.correct { box-shadow: 0 0 0 5px var(--ok-2), var(--shadow); }
.gbtn.correct::after, .gbtn.wrong::after {
  position: absolute; right: -8px; top: -10px;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  border: var(--line) solid var(--ink);
  font-weight: 800; font-size: 20px; line-height: 1;
}
.gbtn.correct::after { content: "✓"; background: var(--ok-2); color: #fff; }
.gbtn.wrong { box-shadow: 0 0 0 5px var(--hot), var(--shadow); animation: shake .32s ease; }
.gbtn.wrong::after { content: "✕"; background: var(--hot); color: #fff; }
.gbtn.reveal { box-shadow: 0 0 0 5px var(--ok-2), var(--shadow); outline: 4px dashed var(--ok); outline-offset: 5px; }
.gbtn.half { box-shadow: 0 0 0 5px var(--hazard), var(--shadow); }
.gbtn .prog { position: absolute; right: 6px; bottom: 6px; background: var(--ink); color: var(--hazard); font-size: 14px; font-weight: 800; border-radius: 8px; padding: 1px 7px; pointer-events: none; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.board.survived .grid { opacity: .55; transition: opacity .15s; }
.board.ended .gbtn { cursor: default; }
.board.failed.reason-pressed-wait .gbtn:not(.wrong) { opacity: .5; }

/* Distrazioni grafiche: sopra la griglia ma trasparenti al tocco */
.decor { position: absolute; inset: -6px; z-index: 2; pointer-events: none; overflow: hidden; }
.floaty { position: absolute; opacity: .5; transform: rotate(var(--rot)); animation: drift 2.4s ease-in-out var(--delay) infinite alternate; stroke: var(--ink); stroke-width: 6px; }
@keyframes drift { from { transform: rotate(var(--rot)) translateY(0); } to { transform: rotate(calc(var(--rot) * -1)) translateY(-10px); } }

/* Conto alla rovescia e vittoria */
.countdown, .celebrate {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255, 244, 220, .92);
  pointer-events: none;
}
.countdown-label { font-size: 24px; font-weight: 800; color: var(--ink-2); min-height: 1.3em; }
.countdown-num { font-size: clamp(96px, 34vw, 160px); font-weight: 800; line-height: 1; color: var(--hot); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.bump { animation: bump .4s ease-out; }
@keyframes bump { from { transform: scale(1.35); } to { transform: scale(1); } }
.celebrate { background: rgba(255, 209, 46, .9); }
.celebrate span { font-size: clamp(110px, 38vw, 180px); font-weight: 800; color: var(--ok-2); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; animation: bump .5s ease-out; }

/* ---------- FINE PARTITA ---------- */
.screen-end { gap: 14px; padding-top: 8px; }
.end-head { display: flex; align-items: center; gap: 14px; }
.end-mascot { width: clamp(72px, 22vw, 104px); flex: 0 0 auto; }
.end-mascot .mascot { width: 100%; height: auto; }
.end-head > div { min-width: 0; }
.end-title { font-size: clamp(26px, 7.6vw, 40px); font-weight: 800; line-height: 1; letter-spacing: -.02em; overflow-wrap: anywhere; text-wrap: balance; }
.is-lose .end-title { color: var(--hot); }
.is-win .end-title { color: var(--ok); }
.end-phrase { font-size: 17px; font-weight: 650; color: var(--ink-2); margin-top: 6px; text-wrap: balance; }
.result {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border: var(--line) solid var(--ink); border-radius: var(--r);
  background: var(--card); box-shadow: var(--shadow); overflow: hidden;
}
.stat { padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.stat + .stat { border-left: var(--line) solid var(--ink); }
.stat-label { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.stat-value { font-size: clamp(36px, 11vw, 52px); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.result-sub { grid-column: 1 / -1; border-top: var(--line) solid var(--ink); padding: 10px 14px; font-weight: 750; background: var(--hazard); }
/* Vittoria: i round superati sono il dato che distingue i risultati */
.is-win .stat-rounds { background: var(--hazard); }
.is-win .stat-rounds .stat-value { font-size: clamp(48px, 15vw, 68px); }
.is-win .stat-time .stat-value { color: var(--ok); }
.end-why { font-weight: 650; color: var(--ink-2); }
.end-record { font-weight: 750; }
.end-record.is-new { align-self: flex-start; background: var(--ok-2); color: #fff; border: var(--line) solid var(--ink); border-radius: 10px; padding: 4px 10px; box-shadow: var(--shadow-sm); }
.vs { border: var(--line) solid var(--ink); border-radius: var(--r); padding: 12px 14px; background: var(--card); }
.vs-title { font-size: 20px; font-weight: 800; overflow-wrap: anywhere; }
.vs-line { font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.vs-win { background: #d8f6e7; }
.vs-lose { background: #ffe1e4; }
.end-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.end-actions.guard { pointer-events: none; }
.end-note { font-size: 13px; color: var(--ink-2); text-align: center; }

/* ---------- FINESTRE ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(22, 18, 31, .55);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + var(--safe-b));
}
.sheet {
  width: 100%; max-width: 480px; max-height: calc(100dvh - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: 24px;
  box-shadow: 6px 6px 0 var(--ink);
  padding: 20px 18px 16px;
  display: flex; flex-direction: column; gap: 12px;
  animation: sheetIn .22s ease-out;
}
.sheet > * { flex-shrink: 0; }
@media (min-width: 600px) { .modal { align-items: center; } }
@keyframes sheetIn { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.tut-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.tut-steps li { display: flex; gap: 12px; align-items: center; background: var(--card); border: var(--line) solid var(--ink); border-radius: 16px; padding: 10px 12px; }
.tut-steps p { font-weight: 650; font-size: 16px; }
.tut-demo { flex: 0 0 64px; height: 48px; display: flex; gap: 6px; align-items: center; justify-content: center; }
.tut-demo i { width: 26px; height: 26px; border: var(--line) solid var(--ink); border-radius: 8px; background: var(--card); }
.demo-press i:first-child { background: var(--sky); }
.demo-press i.ok { background: var(--hot-2); box-shadow: 0 0 0 4px var(--ok-2); }
.demo-wait i { background: var(--hazard); position: relative; }
.demo-wait::after { content: ""; position: absolute; }
.demo-wait { position: relative; }
.demo-wait::before { content: ""; position: absolute; width: 58px; height: 4px; background: var(--hot); transform: rotate(-20deg); border-radius: 4px; z-index: 1; }
.demo-clock b { font-size: 26px; font-weight: 800; color: var(--hot); border: var(--line) solid var(--ink); border-radius: 50%; width: 48px; height: 48px; display: grid; place-items: center; background: var(--card); }
.tut-tip { font-size: 14px; font-weight: 650; background: var(--hazard); border-radius: 12px; padding: 8px 12px; border: 2px solid var(--ink); }

.set-list { display: flex; flex-direction: column; gap: 8px; }
.switch {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; width: 100%;
  padding: 8px 12px; border: var(--line) solid var(--ink); border-radius: 14px;
  background: var(--card); font-weight: 750; font-size: 17px; text-align: left; cursor: pointer;
}
.switch i { flex: 0 0 auto; width: 52px; height: 30px; border-radius: 99px; border: var(--line) solid var(--ink); background: #e3dccd; position: relative; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform .15s; }
.switch[aria-checked="true"] i { background: var(--ok-2); }
.switch[aria-checked="true"] i::after { transform: translateX(22px); background: #fff; box-shadow: 0 0 0 2px var(--ink); }
.set-hint { font-size: 13px; color: var(--ink-2); margin: -2px 4px 4px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 750; }
.field input {
  min-height: 48px; padding: 8px 12px;
  border: var(--line) solid var(--ink); border-radius: 12px; background: #fff;
  font: inherit; font-size: 17px; font-weight: 600; color: var(--ink);
}
.field small { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.seg { display: flex; border: var(--line) solid var(--ink); border-radius: 12px; overflow: hidden; }
.seg-btn { flex: 1; min-height: 46px; border: 0; background: var(--card); font-weight: 750; cursor: pointer; }
.seg-btn + .seg-btn { border-left: var(--line) solid var(--ink); }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.set-note { font-size: 13px; color: var(--ink-2); }
.set-warn { color: #9a1424; font-weight: 700; }
.set-version { font-size: 12px; color: var(--ink-3); }

.share-preview { width: 100%; max-width: 280px; align-self: center; border: var(--line) solid var(--ink); border-radius: 16px; box-shadow: var(--shadow-sm); }
.share-text { width: 100%; resize: none; border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px; font: inherit; font-size: 14px; background: #fff; color: var(--ink); }
.share-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share-actions .btn { min-height: 50px; font-size: 15px; padding: 8px 10px; text-align: center; }
.share-actions .btn-primary { grid-column: 1 / -1; }
.share-status { min-height: 1.3em; font-weight: 750; text-align: center; color: var(--ok); }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%); z-index: 60;
  max-width: calc(100% - 32px);
  background: var(--ink); color: var(--paper); border-radius: 14px; padding: 10px 16px;
  font-weight: 700; box-shadow: 3px 3px 0 var(--hazard);
  pointer-events: none;
}
.update-banner {
  position: fixed; left: 50%; top: calc(10px + var(--safe-t)); transform: translateX(-50%); z-index: 40;
  width: calc(100% - 32px); max-width: 488px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--hazard); border: var(--line) solid var(--ink); border-radius: 14px; padding: 8px 10px 8px 14px;
  font-weight: 750; box-shadow: var(--shadow-sm);
}

/* ---------- Schermi bassi e desktop ---------- */
@media (max-height: 640px) {
  .instr-card { min-height: 100px; padding: 10px 12px 14px; }
  .stage { height: 56px; }
  .grid { gap: 10px; }
  .logo-main { font-size: clamp(44px, 14vw, 64px); }
  .red-button { width: 112px; }
  .home-actions { margin-top: 12px; gap: 12px; }
}
@media (max-width: 350px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .grid { gap: 9px; }
  .row { flex-direction: column; }
}
@media (min-width: 700px) and (min-height: 760px) {
  .screen-game { max-height: 860px; }
}

/* ---------- Animazioni ridotte ---------- */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
