:root {
  --vetro: rgba(20, 29, 39, .84);
  --vetro-chiaro: rgba(255, 255, 255, .08);
  --linea: rgba(255, 255, 255, .14);
  --testo: #f3f5f7;
  --tenue: #a9b6c2;
  --accento: #f5b82e;
  --accento-scuro: #2a1d00;
  --giusto: #3ccf7a;
  --errore: #ff6b5e;
  --ombra: 0 10px 30px rgba(0, 0, 0, .28);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: #18222d;
  color: var(--testo);
  font: 16px/1.35 "Barlow", "Arial Narrow", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.impianto { position: relative; width: 100vw; height: 100vh; height: 100dvh; }
#scena { position: absolute; inset: 0; }
#scena canvas { display: block; touch-action: none; }
.caricamento {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-items: center;
  background: #18222d; color: var(--tenue); font-size: 18px;
  transition: opacity .6s;
}
body.pronto .caricamento { opacity: 0; pointer-events: none; }

/* elementi sopra la scena: vetro scuro */
.testata, .viste, .dock, #stato {
  position: absolute; z-index: 2;
  background: var(--vetro);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--linea);
  box-shadow: var(--ombra);
}
.testata { top: 14px; left: 14px; padding: 8px 14px 9px; border-radius: 14px; }
.sopratitolo { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--accento); text-decoration: none; }
a.sopratitolo:hover { text-decoration: underline; }
h1 { margin: 0; font-size: 20px; line-height: 1.15; }
.riga-titolo { display: flex; align-items: center; gap: 8px; }
.freccia {
  width: 26px; height: 26px; padding: 0; border: 1px solid var(--linea); border-radius: 50%;
  background: var(--vetro-chiaro); color: var(--testo); font: 600 18px/1 inherit; cursor: pointer;
  display: grid; place-items: center; touch-action: manipulation;
}
.freccia:not(:disabled):hover { background: rgba(255, 255, 255, .16); }
.freccia:disabled { opacity: .3; cursor: default; }
body.singolo .freccia { display: none; }
body.singolo a.sopratitolo { pointer-events: none; }

.viste { top: 14px; right: 14px; display: flex; padding: 4px; border-radius: 999px; }
.viste button {
  font: inherit; color: var(--tenue); background: none; border: 0;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
}
.viste button.scelto { background: var(--testo); color: #18222d; font-weight: 600; }

#stato {
  top: 14px; left: 50%; transform: translate(-50%, 0);
  max-width: min(520px, calc(100vw - 420px));
  padding: 9px 16px; border-radius: 12px; font-size: 14.5px; text-align: center;
  transition: opacity .3s, transform .3s;
}
#stato:empty { opacity: 0; transform: translate(-50%, -8px); pointer-events: none; }
#stato.giusto { border-color: var(--giusto); box-shadow: 0 0 0 1px var(--giusto), var(--ombra); }
#stato.errore { border-color: var(--errore); box-shadow: 0 0 0 1px var(--errore), var(--ombra); }
#stato.giusto::before { content: "✓ "; color: var(--giusto); font-weight: 700; }
/* didascalie della spiegazione */
#stato.spiega { max-width: min(640px, calc(100vw - 420px)); text-align: left; font-size: 15.5px; line-height: 1.4; border-color: var(--accento); }
#stato.spiega .passo {
  display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: 999px;
  background: var(--accento); color: var(--accento-scuro); font-size: 12px; font-weight: 800; vertical-align: 1px;
}
#stato.errore::before { content: "✕ "; color: var(--errore); font-weight: 700; }

.aiuto {
  position: absolute; z-index: 1; left: 14px; bottom: 112px; margin: 0;
  padding: 6px 10px; border-radius: 8px;
  background: rgba(20, 29, 39, .6); color: var(--tenue); font-size: 12.5px;
  pointer-events: none; transition: opacity .8s;
}
.aiuto.nascosto { opacity: 0; }

/* la barra dei comandi */
.dock {
  left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px;
  padding: 10px 14px 10px 16px; border-radius: 22px;
}
.etichetta { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--tenue); margin-bottom: 5px; }
.scelte { display: flex; gap: 8px; }
.dock button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
.dock button:disabled { opacity: .38; cursor: default; }

/* le auto come carte */
.carta {
  position: relative; width: 58px; height: 62px; padding: 0;
  border-radius: 12px; border: 1px solid var(--linea);
  background: var(--vetro-chiaro); overflow: hidden;
  display: grid; place-items: center; transition: transform .15s, background .15s;
}
.carta i { position: absolute; left: 0; right: 0; top: 0; height: 7px; }
.carta b { font-size: 24px; font-weight: 800; margin-top: 4px; }
.carta:not(:disabled):hover { transform: translateY(-2px); background: rgba(255, 255, 255, .14); }
.carta.scelto { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .5); }
.carta[data-posto]:not([data-posto=""])::after {
  content: attr(data-posto);
  position: absolute; right: 4px; bottom: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accento); color: var(--accento-scuro); font-size: 12px; font-weight: 800;
}

/* il pulsante principale */
.prova {
  width: 76px; height: 76px; border-radius: 50%; flex: none;
  border: 0; background: var(--accento); color: var(--accento-scuro);
  display: grid; place-items: center; align-content: center; gap: 0;
  box-shadow: 0 6px 18px rgba(245, 184, 46, .35);
  transition: transform .15s;
}
.prova svg { width: 30px; height: 30px; fill: currentColor; margin-left: 3px; }
.prova span { font-size: 12px; font-weight: 700; margin-top: -2px; }
.prova:not(:disabled):hover { transform: scale(1.05); }
.prova:disabled { background: #5b6672; color: #c4ccd4; box-shadow: none; }

.strumenti { display: flex; gap: 4px; }
.strumenti button {
  min-width: 70px; padding: 6px 6px 5px; border: 0; border-radius: 12px; background: none;
  display: grid; justify-items: center; gap: 3px; color: var(--testo);
}
.strumenti button:not(:disabled):hover { background: var(--vetro-chiaro); }
.strumenti svg { width: 22px; height: 22px; fill: currentColor; }
.strumenti span { font-size: 11.5px; color: var(--tenue); }
#pausa .riprendi { display: none; }
#pausa.in-pausa .pausa { display: none; }
#pausa.in-pausa .riprendi { display: inline; }

.crediti {
  position: absolute; z-index: 1; right: 10px; bottom: 4px; margin: 0;
  font-size: 10px; color: rgba(255, 255, 255, .75); text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

/* telefono in verticale: barra a tutta larghezza su due righe */
@media (max-width: 760px) {
  .testata { top: 10px; left: 10px; padding: 6px 11px 7px; border-radius: 12px; }
  h1 { font-size: 17px; }
  .sopratitolo { font-size: 10px; max-width: calc(100vw - 200px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .viste { top: 10px; right: 10px; }
  .viste button { padding: 6px 11px; font-size: 13.5px; }
  #stato { top: 64px; max-width: calc(100vw - 20px); width: max-content; font-size: 13.5px; }
  #stato.spiega { max-width: calc(100vw - 20px); font-size: 14px; }
  .dock {
    left: 8px; right: 8px; bottom: calc(18px + env(safe-area-inset-bottom)); transform: none;
    display: grid; grid-template-columns: 1fr auto; grid-template-areas: "ordine prova" "strumenti strumenti";
    gap: 8px 12px; padding: 10px 12px 6px; border-radius: 20px;
  }
  .ordine { grid-area: ordine; }
  .scelte { gap: 7px; }
  .carta { flex: 1; width: auto; height: 56px; }
  .prova { grid-area: prova; width: 68px; height: 68px; align-self: end; }
  .strumenti { grid-area: strumenti; justify-content: space-between; border-top: 1px solid var(--linea); padding-top: 4px; }
  .strumenti button { min-width: 0; flex: 1; }
  .aiuto { bottom: 200px; left: 10px; right: 10px; text-align: center; font-size: 12px; }
  .crediti { left: 0; right: 0; bottom: calc(3px + env(safe-area-inset-bottom)); text-align: center; font-size: 9px; }
}
/* telefono in orizzontale: barra compatta su una riga */
@media (max-height: 500px) and (orientation: landscape) {
  .testata { top: 8px; left: 8px; padding: 5px 10px; }
  h1 { font-size: 15px; }
  .sopratitolo { display: none; }
  .viste { top: 8px; right: 8px; }
  .viste button { padding: 5px 10px; font-size: 13px; }
  #stato { top: 8px; font-size: 13px; padding: 6px 12px; max-width: calc(100vw - 360px); }
  #stato.spiega { max-width: calc(100vw - 360px); font-size: 13px; }
  .dock { bottom: 8px; gap: 10px; padding: 6px 10px; border-radius: 18px; }
  .etichetta { display: none; }
  .carta { width: 48px; height: 46px; }
  .carta b { font-size: 20px; }
  .prova { width: 56px; height: 56px; }
  .prova span { display: none; }
  .strumenti button { min-width: 54px; padding: 4px; }
  .strumenti span { font-size: 10.5px; }
  .aiuto { display: none; }
}
