:root {
  --navy: #0d1b4d; --blu: #2f6bff; --blu-d: #1237a8; --oro: #ffcf1f; --ok: #2fbf6a;
  --titoli: "Segoe UI Black", "Arial Black", "Trebuchet MS", system-ui, sans-serif;
  --testo: "Segoe UI", system-ui, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--testo); color: #fff; background: radial-gradient(120% 90% at 50% 0%, #1b3a9c, var(--navy) 70%); display: flex; flex-direction: column; overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
main { position: relative; flex: 1; min-height: 0; display: flex; }
.schermata { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 12px; text-align: center; overflow: auto; }
.schermata[hidden], .velo[hidden], #barra[hidden], #libero[hidden] { display: none; }
footer { flex: none; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 10px; padding: 4px 8px; font-size: .78rem; color: #b9c7ff; background: rgba(0,0,0,.25); }
#suoni, #schermo { font: 700 .8rem var(--testo); color: #fff; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.4); border-radius: 999px; padding: 6px 14px; min-height: 36px; cursor: pointer; }

.occhiello { margin: 0; font: 800 clamp(.8rem, 1.6vw, 1.1rem) var(--testo); letter-spacing: .14em; text-transform: uppercase; color: #cfdcff; }
h1 { margin: 0; font: 400 clamp(2rem, 7vw, 4.6rem) var(--titoli); text-shadow: 0 3px 0 rgba(0,0,0,.35), 0 8px 14px rgba(0,0,0,.35); }
.regole { margin: 0; max-width: 46em; padding: 8px 16px; font-size: clamp(.95rem, 1.9vw, 1.25rem); line-height: 1.35; border-radius: 16px; background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.25); }
.regole:empty { display: none; }
.scelte { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.grande { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 220px; padding: 16px 22px; font: 400 clamp(1.3rem, 2.8vw, 2rem) var(--titoli); color: var(--navy); background: linear-gradient(180deg, #fff, #eaf1ff); border: 0; border-radius: 22px; cursor: pointer; touch-action: manipulation; box-shadow: 0 1px 0 #fff inset, 0 5px 0 #9aa8d8, 0 12px 14px rgba(0,0,0,.35); }
.grande.piccolo { min-width: 150px; padding: 12px 18px; }
.grande b { font-weight: 400; }
.grande small { font: 700 .5em var(--testo); letter-spacing: .06em; text-transform: uppercase; color: #3d56b3; }
.grande:active { transform: translateY(4px); box-shadow: 0 1px 0 #fff inset, 0 1px 0 #9aa8d8, 0 3px 4px rgba(0,0,0,.3); }
.grande:focus-visible, .chip:focus-visible, .btn:focus-visible { outline: 5px solid var(--oro); outline-offset: 3px; }
.etichetta { margin: 4px 0 0; font: 800 .9rem var(--testo); letter-spacing: .1em; text-transform: uppercase; color: #cfdcff; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { min-width: 64px; min-height: 48px; padding: 8px 16px; font: 800 1.1rem var(--testo); color: #fff; background: rgba(255,255,255,.14); border: 2px solid rgba(255,255,255,.55); border-radius: 999px; cursor: pointer; touch-action: manipulation; }
.chip[aria-pressed="true"] { color: var(--navy); background: #fff; border-color: #fff; }
.home { color: #cfdcff; font-size: .95rem; padding: 10px; }

#barra { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 10px; background: rgba(0,0,0,.25); }
.pill { display: inline-block; padding: 5px 14px; font: 800 clamp(.9rem, 1.8vw, 1.2rem) var(--testo); color: #fff; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.35); border-radius: 999px; }
.pill.oro { color: var(--navy); background: var(--oro); border-color: var(--oro); font-family: var(--titoli); font-weight: 400; }
.pill[hidden] { display: none; }
.pill.btn { min-height: 40px; cursor: pointer; touch-action: manipulation; }
.pill.btn[aria-pressed="true"] { color: var(--navy); background: #fff; }
#barra .btn:first-of-type { margin-left: auto; }

#gioco { padding: 0; gap: 0; overflow: hidden; }
#scena { width: 100%; height: 100%; display: block; touch-action: none; }
.pezzo { cursor: grab; }
.pezzo.preso { cursor: grabbing; filter: drop-shadow(0 8px 8px rgba(0,0,0,.45)); }
.pezzo.fisso { pointer-events: none; cursor: default; }
.pezzo .contorno { fill: none; stroke: rgba(255,255,255,.75); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.pezzo.fisso .contorno { stroke: rgba(0,0,0,.18); stroke-width: 1; }
.cornice { fill: rgba(255,255,255,.06); stroke: rgba(255,255,255,.55); stroke-width: 2; stroke-dasharray: 8 6; }

.velo { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 14px; background: rgba(5, 12, 43, .72); }
.scheda { max-width: 36em; padding: 20px 26px; text-align: center; border-radius: 26px; background: linear-gradient(180deg, #2a55d6, #14297a); border: 3px solid var(--oro); box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.scheda h2 { margin: 0 0 8px; font: 400 clamp(1.6rem, 4vw, 2.6rem) var(--titoli); color: var(--oro); }
.scheda p { margin: 6px 0; font-size: clamp(1rem, 2.2vw, 1.4rem); line-height: 1.35; }
.azioni { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 12px; }
.azioni [hidden] { display: none; }
@media (max-width: 620px) {
  .grande { min-width: 0; width: 100%; } .scelte { width: 100%; }
  #barra { gap: 4px 5px; padding: 4px 6px; }
  .pill { padding: 3px 9px; font-size: .82rem; }
  .pill.btn { min-height: 36px; }
  #tappa { display: none; }
  footer { font-size: .7rem; }
}
@media (max-width: 620px) { footer > span { display: none; } }

/* feste di fine puzzle */
#festa { position: absolute; inset: 0; z-index: 6; overflow: hidden; perspective: 1000px; display: flex; align-items: center; justify-content: center; cursor: pointer; background: radial-gradient(circle at 50% 42%, rgba(255,255,255,.10), rgba(5,12,43,.62)); animation: entra .4s ease-out; }
#festa.esce { opacity: 0; transition: opacity .4s; }
@keyframes entra { from { opacity: 0; } to { opacity: 1; } }
#festa .cad { position: absolute; top: -12%; left: var(--x); font-style: normal; font-size: var(--s); line-height: 1; color: var(--c); text-shadow: 0 0 10px currentColor; animation: cadi var(--d) linear var(--r) both; will-change: top, transform; }
@keyframes cadi { from { top: -12%; transform: translateX(0) rotate(0); } to { top: 108%; transform: translateX(var(--dx)) rotate(var(--rot)); } }
.scritta3d { position: relative; z-index: 2; max-width: 94%; text-align: center; font: 400 clamp(2.4rem, 9.5vw, 7.5rem)/1.08 var(--titoli); transform-style: preserve-3d; animation: scendi 1.8s cubic-bezier(.22, 1.1, .36, 1) both, ondeggia 4s ease-in-out 1.8s infinite alternate; }
.festa-europa .scritta3d { font-size: clamp(2.2rem, 8vw, 6.6rem); }
.scritta3d .parola { display: inline-block; white-space: nowrap; }
.scritta3d .l { display: inline-block; color: var(--cl);
  text-shadow: 1px 1px 0 var(--ex), 2px 2px 0 var(--ex), 3px 3px 0 var(--ex), 4px 4px 0 var(--ex), 5px 5px 0 var(--ex), 6px 6px 0 var(--ex), 7px 7px 0 var(--ex), 8px 8px 0 var(--ex), 9px 9px 0 var(--ex), 10px 12px 18px rgba(0,0,0,.55); }
@keyframes scendi { from { transform: translateY(-110vh) rotateX(70deg) scale(.6); opacity: 0; } 55% { opacity: 1; } to { transform: translateY(0) rotateX(16deg); opacity: 1; } }
@keyframes ondeggia { from { transform: rotateX(16deg) rotateY(-14deg); } to { transform: rotateX(10deg) rotateY(14deg); } }
.cerchio { --R: 420px; position: absolute; left: 50%; top: 50%; width: var(--R); height: var(--R); margin: calc(var(--R) / -2) 0 0 calc(var(--R) / -2); animation: gira 40s linear infinite; opacity: .9; }
.cerchio b { position: absolute; left: 50%; top: 50%; width: 0; height: 0; font-weight: 400; color: #ffdd00; text-shadow: 0 0 12px #ffdd00; font-size: clamp(2rem, 8vmin, 3.6rem); line-height: 0; text-shadow: 0 0 18px #ffdd00, 0 0 4px #fff3a0; transform: rotate(var(--a)) translateY(calc(var(--R) / -2)); }
.cerchio b::before { content: ""; }
@keyframes gira { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .scritta3d { animation: none; transform: rotateX(12deg); } .cerchio { animation: none; } }
.chip.aggiungi { display: inline-flex; align-items: center; border-style: dashed; }
#elimina-mia[hidden], #msg-mie:empty { display: none; }
.stampa { width: 100%; max-width: 640px; color: #fff; text-align: center; }
.stampa summary { cursor: pointer; font: 800 1.05rem var(--testo); padding: 10px; }
.stampa[open] { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#stampa { display: none; }
@media print {
  body.in-stampa > *:not(#stampa) { display: none !important; }
  body.in-stampa { background: #fff !important; }
  #stampa { display: block; }
  #stampa .foglio { page-break-after: always; break-after: page; }
  #stampa svg { display: block; }
}
body.st-aperta #btn-inizia, body.st-aperta .opzioni, body.st-aperta .scelte, body.st-aperta #info-libero { display: none; }
.stampa summary { display: inline-block; list-style: none; min-height: 48px; padding: 12px 24px; font: 800 1.2rem var(--testo); color: var(--navy); background: var(--oro); border-radius: 999px; box-shadow: 0 4px 0 #b8901a, 0 8px 12px rgba(0,0,0,.3); }
.stampa summary::-webkit-details-marker { display: none; }
.stampa summary::before { content: "🖨️ "; }
.stampa[open] summary { background: #fff; box-shadow: none; }
.stampa summary:focus-visible { outline: 5px solid #fff; outline-offset: 3px; }
a.home { display: inline-block; padding: 4px 14px; background: #fff; border-radius: 16px; line-height: 0; box-shadow: 0 4px 0 #9aa8d8; }
a.home img { display: block; }
a.home:focus-visible { outline: 5px solid var(--oro); outline-offset: 3px; }
.scintilla { position: fixed; z-index: 60; pointer-events: none; font-style: normal; font-size: var(--s); line-height: 1; color: var(--c); text-shadow: 0 0 8px currentColor; transform: translate(-50%, -50%); animation: scoppia 1s ease-out forwards; }
@keyframes scoppia { from { opacity: 1; transform: translate(-50%, -50%) scale(.4); } 70% { opacity: 1; } to { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2) rotate(200deg); } }
#messaggio { position: fixed; z-index: 60; top: 16%; left: 50%; transform: translateX(-50%); max-width: 92vw; padding: 8px 22px; font: 400 clamp(1.4rem, 4vw, 2.4rem) var(--titoli); color: var(--navy); background: var(--oro); border-radius: 999px; box-shadow: 0 4px 0 #b8901a, 0 10px 18px rgba(0,0,0,.35); pointer-events: none; text-align: center; animation: sale 1.7s ease-out forwards; }
#messaggio.grande-msg { font-size: clamp(1.8rem, 5.5vw, 3.4rem); background: #fff; }
@keyframes sale { 0% { opacity: 0; transform: translate(-50%, 20px) scale(.7); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 25% { transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -24px) scale(1); } }
.pill.oro.lampo { animation: lampo .6s ease-out; }
@keyframes lampo { 40% { transform: scale(1.3); box-shadow: 0 0 18px 6px #ffd23f; } }
@media (prefers-reduced-motion: reduce) { #messaggio, .pill.oro.lampo { animation-duration: .01s; } }
.chip.leggi { min-height: 40px; padding: 4px 14px; font-size: 1rem; margin-right: 6px; vertical-align: middle; }
/* LIM e schermi tattili */
html, body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#gioco, #scena { touch-action: none; }
@media (pointer: coarse) {
  .chip { min-height: 56px; }
  .pill.btn { min-height: 52px; }
  .chip.leggi { min-height: 52px; }
  .grande.piccolo { min-height: 60px; }
}
@media (min-width: 1500px), (min-height: 1000px) {
  html { font-size: 125%; }
  .chip { min-height: 60px; padding: 10px 22px; }
  .pill.btn { min-height: 56px; }
  footer { font-size: 1rem; }
  footer button { min-height: 48px; font-size: 1rem; }
}
@media (min-width: 2400px) { html { font-size: 170%; } }
.pezzo.preso { filter: drop-shadow(0 14px 12px rgba(0,0,0,.5)) drop-shadow(0 0 6px rgba(255,255,255,.7)); }
.nome { font-family: Arial, Helvetica, sans-serif; font-weight: 700; fill: #000; stroke: #fff; paint-order: stroke; stroke-linejoin: round; pointer-events: none; }
/* menu piu' compatto */
.scelte { gap: 10px; }
.scelte .grande { min-width: 150px; padding: 8px 16px; font-size: clamp(1.05rem, 2vw, 1.4rem); border-radius: 16px; box-shadow: 0 1px 0 #fff inset, 0 4px 0 #9aa8d8, 0 8px 10px rgba(0,0,0,.3); }
.scelte .grande small { font-size: .55em; }
#libero { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#libero[hidden] { display: none; }
.schermata { gap: 8px; }
#libero { width: 100%; max-width: 760px; }
#btn-inizia { align-self: flex-end; }
h1 { font-size: clamp(1.8rem, 5.5vw, 3.6rem); line-height: 1.1; }
/* menu ordinato */
.pannello { max-width: 720px; padding: 12px 16px; background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.18); border-radius: 18px; gap: 10px; align-items: stretch; }
.riga { display: flex; align-items: center; gap: 10px 14px; }
.riga > .etichetta { flex: 0 0 8.5em; margin: 0; text-align: right; }
.riga > .chips { flex: 1; justify-content: flex-start; }
.pannello .regole { align-self: center; }
#info-libero { background: none; padding: 0; font-size: .95rem; }
#msg-mie:empty { display: none; }
.azioni-riga { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.azioni-riga .stampa { width: auto; max-width: none; }
.azioni-riga .stampa[open] { flex: 1 1 100%; }
.opzioni { width: 100%; max-width: 720px; text-align: center; }
.opzioni summary { display: inline-block; list-style: none; cursor: pointer; padding: 8px 20px; font: 800 1rem var(--testo); color: #fff; background: rgba(255,255,255,.14); border: 2px solid rgba(255,255,255,.55); border-radius: 999px; }
.opzioni summary::-webkit-details-marker { display: none; }
.opzioni[open] summary { background: #fff; color: var(--navy); }
.opzioni .chips { margin-top: 10px; }
@media (max-width: 620px) { .riga { flex-direction: column; align-items: stretch; } .riga > .etichetta { text-align: center; flex: none; } .riga > .chips { justify-content: center; } }
#info-libero { border: 0; } .riga { justify-content: center; }
