:root {
  --verde: #1E4E3A;
  --verde-chiaro: #2E7A5A;
  --arancio: #C15517;
  --crema: #FFF7EA;
  --testo: #1B2B24;
  --bianco: #fff;
  --fuoco: #FFD21F;
  --titoli: 'Fredoka', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --corpo: 'Atkinson Hyperlegible', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d3b4a; color: var(--testo); font-family: var(--corpo); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
#tela { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
[hidden] { display: none !important; }

button { font-family: var(--titoli); font-weight: 600; font-size: clamp(18px, 2.4vmin, 26px); border: none; border-radius: 999px; padding: 0.8em 1.6em; cursor: pointer; min-height: 56px; transition: transform .1s, box-shadow .1s; }
button:active { transform: scale(0.96); }
button:focus-visible { outline: 5px solid var(--fuoco); outline-offset: 3px; }
.primario { background: var(--arancio); color: var(--bianco); box-shadow: 0 5px 0 #8a3a0e; }
.secondario { background: var(--crema); color: var(--verde); box-shadow: 0 5px 0 #c9bba3; }
button:disabled { opacity: .35; cursor: default; }

/* ---------- schermate ---------- */
.schermo { position: fixed; inset: 0; overflow-y: auto; padding: max(24px, env(safe-area-inset-top)) 16px 120px; background: linear-gradient(160deg, #2a8fa0 0%, #1E4E3A 100%); color: var(--bianco); text-align: center; touch-action: pan-y; }
.schermo.velo, .velo { background: rgba(10, 40, 35, .72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.velo:not(.schermo) { position: fixed; inset: 0; display: grid; place-items: center; z-index: 30; color: var(--bianco); text-align: center; }
h1 { font-family: var(--titoli); font-size: clamp(44px, 9vmin, 96px); margin: 4vh 0 0; letter-spacing: .02em; text-shadow: 0 5px 0 rgba(0,0,0,.2); }
h2 { font-family: var(--titoli); font-size: clamp(32px, 6vmin, 60px); margin: 3vh 0 1vh; }
.sottotitolo { font-size: clamp(18px, 3vmin, 28px); margin: .4em auto 1.4em; max-width: 40em; }
.aiuto { font-size: clamp(16px, 2.2vmin, 21px); opacity: .92; max-width: 46em; margin: 0 auto 1.2em; }
.grande { font-family: var(--titoli); font-size: clamp(24px, 4vmin, 40px); max-width: 22em; }
.colonna { display: flex; flex-direction: column; gap: 18px; align-items: center; margin-top: 3vh; }
.colonna button { min-width: min(80vw, 380px); }
.riquadro { max-width: 640px; padding: 24px; }

.griglia-mondi { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; margin-top: 3vh; }
.mondo { width: min(86vw, 380px); min-height: 220px; border-radius: 32px; padding: 26px; display: flex; flex-direction: column; justify-content: flex-end; text-align: left; color: var(--bianco); box-shadow: 0 8px 0 rgba(0,0,0,.25); }
.mondo strong { font-family: var(--titoli); font-size: clamp(28px, 4.5vmin, 40px); display: block; }
.mondo span { font-family: var(--corpo); font-weight: 400; font-size: 18px; display: block; margin-top: 6px; }
.mondo.piscina { background: radial-gradient(circle at 30% 20%, #8ff0f0 0, #2bb3c6 40%, #136f88 100%); }
.mondo.parco { background: radial-gradient(circle at 30% 20%, #d9f59a 0, #66b84a 45%, #2f7a35 100%); }

/* ---------- schede giocatori ---------- */
#schede-giocatori { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; }
.scheda { background: var(--crema); color: var(--testo); border-radius: 26px; padding: 16px 18px 18px; width: min(94vw, 420px); text-align: left; border-top: 14px solid var(--colore); box-shadow: 0 6px 0 rgba(0,0,0,.2); }
.scheda h3 { font-family: var(--titoli); margin: 0 0 8px; font-size: 24px; display: flex; justify-content: space-between; align-items: center; }
.scheda h3 button { font-size: 16px; min-height: 40px; padding: .4em 1em; }
.scheda .riga { margin: 10px 0 4px; font-weight: 700; font-size: 17px; }
.scelte { display: flex; flex-wrap: wrap; gap: 8px; }
.scelte button { font-size: 18px; padding: .5em .9em; min-height: 52px; background: #fff; color: var(--testo); box-shadow: 0 3px 0 #d9ceb9; border: 3px solid transparent; }
.scelte button[aria-pressed="true"] { border-color: var(--verde); background: #e3f4ea; box-shadow: 0 3px 0 var(--verde); }
.scelte .pallino { display: inline-block; width: 18px; height: 18px; border-radius: 50%; vertical-align: -3px; margin-right: 6px; border: 2px solid rgba(0,0,0,.25); }
.descr-livello { font-size: 16px; margin: 8px 0 0; color: #3a4a44; min-height: 2.6em; }
.tasti { font-size: 17px; margin: 6px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tasti kbd { font-family: var(--corpo); background: #fff; border: 2px solid #ccc; border-bottom-width: 4px; border-radius: 8px; padding: 2px 8px; }
.tasti button { font-size: 15px; min-height: 40px; padding: .35em .9em; }
.spunta { display: flex; gap: 10px; align-items: center; font-size: 17px; margin: 6px 0; }
.spunta input { width: 26px; height: 26px; accent-color: var(--verde); }
details { margin-top: 8px; font-size: 16px; }
summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
select { font-size: 17px; padding: 6px 10px; border-radius: 10px; }
.azioni-basso { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 16px max(14px, env(safe-area-inset-bottom)); display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; background: linear-gradient(transparent, rgba(0,0,0,.35)); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.barra-squadra { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(60vw, 560px); height: 44px; border-radius: 999px; background: rgba(255,255,255,.85); border: 4px solid var(--bianco); overflow: hidden; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.riempimento { position: absolute; inset: 0; width: 0%; background: linear-gradient(90deg, #3fd0e0, #2a8fd8 60%, #7b5cff); transition: width .5s ease-out; }
.barra-squadra .etichetta { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--titoli); font-weight: 600; font-size: 20px; color: var(--verde); text-shadow: 0 0 6px #fff, 0 0 2px #fff; }
#chip-giocatori { position: absolute; top: calc(max(12px, env(safe-area-inset-top)) + 54px); left: 50%; transform: translateX(-50%); display: flex; gap: 10px; }
.chip { background: var(--colore); color: #1b1b1b; font-family: var(--titoli); font-weight: 600; font-size: 17px; border-radius: 999px; padding: 4px 14px; border: 3px solid #fff; }
#btn-pausa { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 14px; pointer-events: auto; width: 60px; height: 60px; padding: 0; background: rgba(255,255,255,.9); color: var(--verde); font-size: 20px; }
#volanti { position: fixed; inset: 0; pointer-events: none; z-index: 11; }
.volante { position: absolute; transform: translate(-50%, -50%); font-family: var(--titoli); font-weight: 700; font-size: clamp(26px, 4.5vmin, 44px); color: var(--c); -webkit-text-stroke: 2px #1b1b1b; paint-order: stroke fill; animation: sali 1.2s ease-out forwards; white-space: nowrap; }
@keyframes sali { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -220%) scale(1); } }

/* ---------- comandi a schermo ---------- */
#comandi { position: fixed; inset: 0; pointer-events: none; z-index: 12; }
.zona-comandi { position: absolute; display: flex; gap: 14px; align-items: center; pointer-events: none; }
.zona-comandi .pad { pointer-events: auto; touch-action: none; }
.lato-sx { left: max(16px, env(safe-area-inset-left)); top: 50%; transform: translateY(-50%); }
.lato-dx { right: max(16px, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%); }
.pad { display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--colore) 85%, transparent); border: 6px solid #fff; color: #1b1b1b; font-family: var(--titoli); font-weight: 700; box-shadow: 0 6px 0 rgba(0,0,0,.3); }
.pad.premuto { transform: scale(.93); box-shadow: 0 2px 0 rgba(0,0,0,.3); filter: brightness(1.15); }
.pad-grande { width: clamp(120px, 24vmin, 220px); height: clamp(120px, 24vmin, 220px); font-size: clamp(20px, 3.4vmin, 30px); }
.pad-freccia { width: clamp(92px, 16vmin, 150px); height: clamp(92px, 16vmin, 150px); font-size: clamp(36px, 6vmin, 60px); }
.pad-salto { width: clamp(84px, 14vmin, 130px); height: clamp(84px, 14vmin, 130px); font-size: clamp(18px, 2.8vmin, 24px); }
.pad-joystick { width: clamp(120px, 22vmin, 200px); height: clamp(120px, 22vmin, 200px); background: rgba(255,255,255,.35); position: relative; }
.pad-joystick .pomo { width: 46%; height: 46%; border-radius: 50%; background: var(--colore); border: 5px solid #fff; transition: transform .05s; }

@media (prefers-reduced-motion: reduce) { .volante { animation-duration: .01s; } .riempimento { transition: none; } }

/* la festa deve vedersi dietro */
#schermo-fine { background: linear-gradient(rgba(10,40,35,.55), rgba(10,40,35,.15) 55%, transparent); backdrop-filter: none; -webkit-backdrop-filter: none; text-shadow: 0 3px 8px rgba(0,0,0,.45); }

.avviso-tv { background: #fff3c4; color: #5a4200; border-radius: 18px; padding: 12px 18px; max-width: 46em; margin: 0 auto 16px; font-size: 18px; }
.nota-comando { font-size: 16px; color: #6a4a00; margin: 4px 0; }

/* logo e riferimenti dell'associazione */
.intestazione { display: flex; align-items: center; justify-content: center; gap: clamp(12px, 3vmin, 32px); margin-top: 1vh; }
.logo-tarta { height: clamp(130px, 24vmin, 230px); filter: drop-shadow(0 6px 6px rgba(0,0,0,.25)); }
.scritta-tarta { width: min(30vw, 230px); background: rgba(255,255,255,.92); border-radius: 18px; padding: 6px 12px; box-shadow: 0 6px 0 rgba(0,0,0,.18); }
#schermo-titolo h1 { margin-top: 2vh; }
#schermo-titolo { padding-bottom: 24px; display: flex; flex-direction: column; }
.piede { margin-top: auto; padding: 22px 12px 8px; font-size: clamp(14px, 1.9vmin, 18px); line-height: 1.5; opacity: .95; display: flex; flex-direction: column; align-items: center; }
.piede strong { font-family: var(--titoli); font-size: 1.15em; }
.logo-gioco { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 12px; height: clamp(56px, 10vmin, 90px); filter: drop-shadow(0 3px 4px rgba(0,0,0,.35)); }
@media (max-width: 600px) { .intestazione { flex-direction: column; } .scritta-tarta { width: 56vw; } }

.installa { margin: 26px auto 0; }
