:root {
  --mare: #0b4f6c;
  --mare-2: #136f93;
  --sabbia: #f4efe6;
  --carta: #ffffff;
  --inchiostro: #1d2a33;
  --tenue: #5f6f7a;
  --sole: #ffd23f;
  --ok: #2e9e5b;
  --bordo: #e2dccf;
  --ombra: 0 2px 10px rgba(11, 79, 108, .10);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--sabbia); color: var(--inchiostro);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}
button { font: inherit; cursor: pointer; border: 0; }

.schermo { display: none; min-height: 100%; }
.schermo.attivo { display: block; }
#hub, #lezione { max-width: 640px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }

.testata { margin-bottom: 18px; }
.marchio { display: flex; gap: 12px; align-items: center; }
.marchio img { width: 76px; height: auto; }
.marchio h1 { margin: 0; font-size: 1.5rem; color: var(--mare); letter-spacing: -.01em; }
.marchio p { margin: 0; color: var(--tenue); font-size: .95rem; }

.progresso { margin-bottom: 18px; }
.barra { height: 8px; border-radius: 4px; background: var(--bordo); overflow: hidden; }
.barra span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .4s; }
.progresso p { margin: 6px 0 0; font-size: .85rem; color: var(--tenue); }

.elenco { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.carta-lez {
  width: 100%; text-align: left; background: var(--carta); border-radius: 14px; padding: 14px 16px;
  box-shadow: var(--ombra); display: flex; gap: 14px; align-items: center; color: inherit;
}
.carta-lez:active { transform: scale(.99); }
.carta-lez .num { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: #e7f1f5; color: var(--mare); font-weight: 700; }
.carta-lez.fatta .num { background: var(--ok); color: #fff; }
.carta-lez .info { flex: 1; min-width: 0; }
.carta-lez h3 { margin: 0; font-size: 1.05rem; }
.carta-lez p { margin: 2px 0 0; font-size: .85rem; color: var(--tenue); }
.carta-lez.presto { opacity: .55; cursor: default; }
.carta-lez .tag { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--mare-2); }

.barra-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.indietro { background: var(--carta); width: 42px; height: 42px; border-radius: 50%; font-size: 1.3rem; box-shadow: var(--ombra); color: var(--mare); }
.etichetta { font-size: .8rem; font-weight: 600; color: var(--mare-2); background: #e7f1f5; padding: 4px 10px; border-radius: 99px; }
.scheda h2 { margin: 6px 0 14px; font-size: 1.6rem; line-height: 1.2; color: var(--mare); }
.schema { background: var(--carta); border-radius: 14px; padding: 12px; box-shadow: var(--ombra); margin-bottom: 16px; }
.schema svg { display: block; width: 100%; max-width: 360px; height: auto; margin: 0 auto; }
.schema figcaption { text-align: center; font-size: .8rem; color: var(--tenue); margin-top: 6px; }
.testo p { margin: 0 0 12px; }
.testo ul { margin: 0 0 12px; padding-left: 20px; }
.testo li { margin-bottom: 6px; }
.obiettivo { border-left: 4px solid var(--sole); background: #fff8dc; padding: 10px 14px; border-radius: 0 10px 10px 0; font-size: .95rem; }
.obiettivo:empty { display: none; }
.azioni { position: sticky; bottom: 0; padding: 16px 0 calc(8px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--sabbia) 30%); }
.primario { width: 100%; background: var(--mare); color: #fff; font-weight: 600; padding: 14px; border-radius: 12px; font-size: 1.05rem; }
.primario:active { background: var(--mare-2); }
.secondario { width: 100%; background: transparent; color: var(--mare); font-weight: 600; padding: 12px; border-radius: 12px; margin-top: 6px; }

/* Campo */
#gioco { position: fixed; inset: 0; background: #bfe3f0; overflow: hidden; }
#gioco.attivo { display: block; }
#campo { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud { position: absolute; inset: 0; pointer-events: none; color: #fff; }
.hud-top { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 12px 0; }
.chiudi { pointer-events: auto; width: 40px; height: 40px; border-radius: 50%; background: rgba(11, 79, 108, .75); color: #fff; font-size: 1rem; }
.hud-titolo { flex: 1; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.5); font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contatore { background: rgba(11, 79, 108, .75); padding: 6px 12px; border-radius: 99px; font-weight: 700; font-variant-numeric: tabular-nums; }
.messaggio {
  position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: 1.8rem; font-weight: 800;
  text-shadow: 0 2px 8px rgba(0,0,0,.45); opacity: 0; transform: scale(.9); transition: opacity .2s, transform .2s; padding: 0 16px;
}
.messaggio.vis { opacity: 1; transform: scale(1); }
.messaggio.ok { color: #c9ffd9; }
.messaggio.no { color: #ffd0c4; }
.aiuto { position: absolute; left: 0; right: 0; bottom: calc(185px + env(safe-area-inset-bottom)); display: flex; justify-content: space-between; gap: 10px; padding: 0 12px; font-size: .78rem; transition: opacity .6s; }
.aiuto span { background: rgba(11, 79, 108, .7); padding: 6px 10px; border-radius: 10px; max-width: 48%; }
.aiuto.nascosto { opacity: 0; }
.carta-partita {
  width: 100%; margin-top: 18px; display: flex; gap: 14px; align-items: center; text-align: left;
  background: linear-gradient(135deg, #ff5f8f, #f984a3); color: #fff; border-radius: 16px; padding: 16px 18px;
  box-shadow: 0 6px 18px rgba(255, 95, 143, .35); font-size: 1.05rem;
}
.carta-partita b { font-size: 1.2rem; }
.carta-partita small { opacity: .92; }
.carta-partita .palla-icona { width: 56px; height: auto; flex: none; }
.vista {
  position: absolute; right: 12px; top: calc(64px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 8px;
}
.vista button {
  pointer-events: auto; width: 42px; height: 42px; border-radius: 50%; background: rgba(11, 79, 108, .75);
  color: #fff; font-size: 1.35rem; font-weight: 700; line-height: 1; display: grid; place-items: center;
}
.vista button:active { background: rgba(255, 95, 143, .9); }
/* comandi da telefono: joystick a sinistra (compare dove appoggi il dito), pulsante azione a destra */
.comandi-azione {
  position: absolute; right: 16px; bottom: calc(22px + env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 14px;
}
.comandi-azione[hidden] { display: none; }
.azione {
  pointer-events: auto; width: 96px; height: 96px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8db0, #ff4f86 70%); color: #fff;
  font-weight: 800; font-size: .86rem; letter-spacing: .04em; text-shadow: 0 1px 2px rgba(0,0,0,.35);
  border: 3px solid rgba(255,255,255,.85); box-shadow: 0 6px 18px rgba(0,0,0,.3);
  touch-action: none; user-select: none; -webkit-user-select: none; transition: transform .08s, opacity .2s;
}
.azione.spento { opacity: .55; }
.azione.ora { background: radial-gradient(circle at 35% 30%, #8ff0b5, #2fbf6a 70%); box-shadow: 0 0 0 6px rgba(61, 220, 132, .35), 0 6px 18px rgba(0,0,0,.3); }
.azione.giu { transform: scale(.92); }
.potenza {
  position: relative; width: 28px; height: 150px; border-radius: 14px; overflow: hidden;
  border: 3px solid rgba(255,255,255,.9); box-shadow: 0 4px 12px rgba(0,0,0,.3); background: #c0392b;
}
.potenza[hidden] { display: none; }
.potenza i { position: absolute; inset: 0; }
.potenza span {
  position: absolute; left: -2px; right: -2px; height: 6px; margin-bottom: -3px; bottom: 0;
  background: #fff; box-shadow: 0 0 6px rgba(0,0,0,.6); border-radius: 3px;
}
.potenza.scatto span { background: #ffd23f; }
.potenza em { position: absolute; top: 4px; left: 0; right: 0; text-align: center; font-size: .55rem; font-style: normal; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.testata { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.scarica {
  margin-top: 14px; display: flex; align-items: center; gap: 16px; padding: 14px 16px;
  background: var(--carta); border-radius: 16px; box-shadow: var(--ombra); color: inherit; text-decoration: none;
}
.scarica[hidden] { display: none; }
.scarica-testo b { display: block; font-size: 1.25rem; color: var(--mare); }
.scarica-testo small { display: block; color: var(--tenue); font-size: .88rem; line-height: 1.35; margin-top: 2px; }
.qr { flex: none; width: 132px; height: 132px; background: #fff; border-radius: 10px; display: block; }
.qr svg rect, .qr svg path { shape-rendering: crispEdges; }
.qr svg { display: block; width: 100%; height: 100%; }
.secondario.bordo { border: 2px solid var(--mare); margin: 0 0 8px; background: var(--carta); }
.didascalia {
  position: absolute; left: 12px; right: 12px; bottom: calc(18px + env(safe-area-inset-bottom));
  background: rgba(11, 40, 55, .82); color: #fff; border-radius: 14px; padding: 12px 16px;
  font-size: 1.02rem; line-height: 1.4; font-weight: 600; text-align: center; max-width: 620px; margin: 0 auto;
  animation: entra .35s ease;
}
.didascalia[hidden] { display: none; }
@keyframes entra { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.esito-box h3.blu { color: var(--mare); }
.joy { position: absolute; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%; background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.5); display: none; }
.joy.vis { display: block; }
.pomello { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; background: rgba(255,255,255,.85); }
.esito { position: absolute; inset: 0; background: rgba(11, 40, 55, .55); display: grid; place-items: center; padding: 16px; }
.esito[hidden] { display: none; }
.esito-box { background: var(--carta); color: var(--inchiostro); border-radius: 18px; padding: 22px 20px 16px; width: 100%; max-width: 360px; text-align: center; }
.esito-box h3 { margin: 0 0 6px; color: var(--ok); font-size: 1.4rem; }
.esito-box p { margin: 0 0 16px; color: var(--tenue); }
