/* Occhi Laser: stile UI del gioco */

:root {
  --cyan: #35e0ff;
  --magenta: #ff4fd8;
  --yellow: #ffd93b;
  --bg-deep: #060a1a;
  --panel: rgba(10, 16, 38, 0.88);
  --text: #eaf6ff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none; /* niente scroll o zoom di sistema durante il gioco */
  overscroll-behavior: none;
}

.hidden { display: none !important; }

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* La webcam vera resta fuori schermo: serve solo a MediaPipe */
#webcam {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 2px;
  height: 2px;
  opacity: 0;
  pointer-events: none;
}

/* Anteprima webcam in basso a sinistra */
#cam-pip {
  position: fixed;
  left: calc(14px + env(safe-area-inset-left));
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: 180px;
  border: 2px solid rgba(53, 224, 255, 0.5);
  border-radius: 10px;
  overflow: hidden;
  z-index: 30;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  background: #000;
}
#cam-pip canvas { display: block; width: 100%; }

/* Schermate a tutto schermo */
.screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background:
    radial-gradient(1200px 700px at 50% 20%, rgba(40, 70, 160, 0.35), transparent 60%),
    linear-gradient(180deg, #050816 0%, #0a1030 55%, #131a3f 100%);
  text-align: center;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
/* Il menu può essere più alto dello schermo del telefono: si scorre */
.screen-scroll {
  justify-content: flex-start;
  overflow-y: auto;
  touch-action: pan-y;
  gap: 14px;
}
/* In una colonna flex i figli si comprimono se manca spazio: senza questo un
   testo su due righe viene schiacciato e finisce sotto l'elemento seguente */
.screen > * { flex-shrink: 0; }
.screen-transparent {
  background: rgba(4, 7, 20, 0.72);
  backdrop-filter: blur(3px);
}

.title {
  font-size: clamp(44px, 8vw, 96px);
  letter-spacing: 4px;
  color: var(--text);
  text-shadow: 0 0 24px rgba(53, 224, 255, 0.8), 0 4px 0 rgba(0,0,0,0.4);
}
.title span { color: var(--cyan); }
.title-compact { font-size: clamp(36px, 7vw, 72px); margin-top: 4px; }

.subtitle {
  font-size: clamp(16px, 2.4vw, 24px);
  opacity: 0.9;
  margin-top: -10px;
}

.menu-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

.btn {
  font-size: 20px;
  font-weight: 700;
  padding: 14px 30px;
  border-radius: 14px;
  border: 2px solid rgba(53, 224, 255, 0.55);
  background: rgba(12, 22, 52, 0.9);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 22px rgba(53, 224, 255, 0.35);
  background: rgba(20, 34, 74, 0.95);
}
.btn-primary {
  background: linear-gradient(135deg, #0da9c9, #0b6fd6);
  border-color: rgba(255, 255, 255, 0.5);
}
.btn-small { font-size: 16px; padding: 10px 20px; }
/* Bottone secondario: presente ma che non compete con "Gioca" */
.btn-ghost {
  border-color: rgba(53, 224, 255, 0.25);
  background: rgba(12, 22, 52, 0.5);
  opacity: 0.85;
}

/* Schermata della storia: tre battute, poi si gioca */
#intro-box {
  max-width: 620px;
  background: var(--panel);
  border: 2px solid rgba(53, 224, 255, 0.35);
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
}
#intro-emoji { font-size: 62px; line-height: 1; margin-bottom: 12px; }
#intro-testo {
  font-size: clamp(18px, 2.6vw, 24px);
  line-height: 1.45;
  font-weight: 600;
  margin: 0 0 18px;
  min-height: 3.2em;
}
#intro-punti { display: flex; gap: 8px; justify-content: center; }
#intro-punti i {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(53, 224, 255, 0.3);
  transition: background 0.2s ease;
}
#intro-punti i.attivo { background: var(--cyan); }
.intro-bottoni {
  display: flex; gap: 12px; align-items: center;
  margin-top: 20px; flex-wrap: wrap; justify-content: center;
}

.instructions {
  max-width: 560px;
  background: var(--panel);
  border: 1px solid rgba(53, 224, 255, 0.25);
  border-radius: 16px;
  padding: 18px 24px;
  text-align: left;
}
.instructions h3 { margin-bottom: 10px; color: var(--cyan); }
.instructions ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.instructions li { font-size: 16px; line-height: 1.35; }
.privacy-note { margin-top: 12px; font-size: 13px; opacity: 0.65; }
.instructions-kb-title { margin-top: 14px; font-size: 15px; color: var(--cyan); }
.instructions-kb { font-size: 14px; opacity: 0.85; line-height: 1.5; }

.best-score { font-size: 18px; color: var(--yellow); }

/* Classifica nel menu */
#lb-box {
  width: min(560px, 92vw);
  background: var(--panel);
  border: 1px solid rgba(255, 217, 59, 0.35);
  border-radius: 16px;
  padding: 14px 18px;
}
#lb-claim { font-size: 17px; margin-bottom: 10px; }
#lb-claim strong { color: var(--yellow); }
/* Al massimo cinque righe visibili: con tanti giocatori la classifica non
   deve spingere fuori schermo la scelta del personaggio e il tasto Gioca.
   Il resto si scorre dentro il riquadro. */
#lb-list {
  position: relative;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  max-height: calc(5 * 40px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(53, 224, 255, 0.5) transparent;
  padding-right: 4px;
}
/* Trattenere lo scorrimento ha senso solo quando la lista scorre davvero:
   altrimenti il riquadro diventa una zona morta e il menu non si muove più */
#lb-list.scrollabile {
  overscroll-behavior: contain;
  touch-action: pan-y;
}
/* Il primo posto resta sempre in vista: è il punteggio da battere.
   Sfondo pieno, altrimenti le righe gli scorrerebbero attraverso. */
/* Specificità alta di proposito: deve battere la regola del primo posto più
   sotto, altrimenti lo sfondo resta trasparente e le righe ci passano sopra */
#lb-list.scrollabile li:first-child:not(.lb-empty) {
  position: sticky;
  top: 0;
  z-index: 1;
  background-color: #111b3f;
  background-image: linear-gradient(90deg, rgba(255, 217, 59, 0.2), transparent 65%);
  box-shadow: 0 7px 10px -7px rgba(0, 0, 0, 0.95);
}
#lb-list::-webkit-scrollbar { width: 6px; }
#lb-list::-webkit-scrollbar-thumb {
  background: rgba(53, 224, 255, 0.5);
  border-radius: 3px;
}
#lb-list::-webkit-scrollbar-track { background: transparent; }

/* La riga del giocatore: si riconosce mentre si scorre */
#lb-list li.lb-mine {
  background: rgba(53, 224, 255, 0.16);
  outline: 1px solid rgba(53, 224, 255, 0.55);
}
#lb-list li.lb-mine .lb-name { font-weight: 800; }
#lb-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  padding: 3px 6px;
  border-radius: 8px;
}
#lb-list li:first-child:not(.lb-empty) {
  background: rgba(255, 217, 59, 0.12);
  font-weight: 800;
}
#lb-list .lb-pos { width: 26px; text-align: right; opacity: 0.8; }
#lb-list .lb-char {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  /* Inquadratura sul volto: le thumb sono a figura intera */
  object-position: center 12%;
  background: #223;
  border: 2px solid var(--char-color, rgba(255, 255, 255, 0.35));
  box-shadow: 0 0 8px color-mix(in srgb, var(--char-color, transparent) 45%, transparent);
  flex-shrink: 0;
}
#lb-list .lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lb-list .lb-score { font-weight: 700; color: var(--cyan); }
#lb-list .lb-empty { opacity: 0.7; justify-content: center; }

/* Scheletro di caricamento: stessa altezza esatta delle righe vere, così la
   classifica che arriva non sposta di 200px i bottoni sotto il dito.
   Le righe vere sono `display:flex` con padding 3px 6px e altezza guidata
   dall'avatar: lo scheletro le imita con blocchi grigi. */
#lb-list .lb-skel {
  gap: 8px;
  pointer-events: none;
  animation: skel-pulse 1.4s ease-in-out infinite;
}
#lb-list .lb-skel span {
  background: rgba(234, 246, 255, 0.13);
  border-radius: 6px;
  height: 30px;
}
/* 30px come l'avatar vero (.lb-char): e' lui a dettare l'altezza della riga,
   36px in tutto col padding. Se le due misure divergono torna il salto. */
#lb-list .lb-skel span:nth-child(1) { width: 30px; flex: 0 0 30px; border-radius: 50%; }
#lb-list .lb-skel span:nth-child(2) { flex: 1; max-width: 160px; height: 14px; }
#lb-list .lb-skel span:nth-child(3) { width: 56px; margin-left: auto; height: 14px; }
#lb-list .lb-skel:nth-child(2) span:nth-child(2) { max-width: 120px; }
#lb-list .lb-skel:nth-child(3) span:nth-child(2) { max-width: 145px; }
#lb-list .lb-skel:nth-child(4) span:nth-child(2) { max-width: 105px; }
#lb-list .lb-skel:nth-child(5) span:nth-child(2) { max-width: 135px; }
@keyframes skel-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
/* Chi ha chiesto meno movimento non deve vedere nemmeno questa pulsazione */
@media (prefers-reduced-motion: reduce) {
  #lb-list .lb-skel { animation: none; }
}
/* Durante il caricamento lo scorrimento non serve e il primo posto non va
   evidenziato: sono blocchi vuoti */
#lb-list.in-caricamento { overflow-y: hidden; }
#lb-list.in-caricamento li:first-child { background: none; }
#lb-me { margin-top: 8px; font-size: 14px; color: var(--yellow); }

/* Nome utente */
#username-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: min(560px, 92vw);
  justify-content: center;
}
#username-input { min-width: 0; }
#username-row label { font-size: 16px; opacity: 0.9; white-space: nowrap; }
#username-input {
  flex: 1;
  max-width: 260px;
  font-size: 18px;
  font-weight: 700;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(53, 224, 255, 0.45);
  background: rgba(6, 12, 32, 0.9);
  color: var(--text);
  text-align: center;
}
#username-input:focus { outline: 2px solid var(--cyan); }
#btn-dice {
  font-size: 20px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(53, 224, 255, 0.35);
  background: rgba(12, 22, 52, 0.9);
  cursor: pointer;
}
.username-msg { font-size: 14px; color: #ff7b93; max-width: min(560px, 92vw); }

/* Selezione personaggio */
#char-select {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.char-card {
  width: 118px;
  padding: 10px 8px 8px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 16, 38, 0.85);
  /* È un <button>: senza colore esplicito eredita il nero di sistema */
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.char-card img {
  width: 86px;
  height: 106px;
  object-fit: cover;
  object-position: top;
  border-radius: 10px;
  background: #d8dde6;
}
.char-card .char-name { font-size: 14px; font-weight: 800; margin-top: 6px; color: var(--text); }
.char-card .char-desc { font-size: 11.5px; color: #c3d3e8; line-height: 1.3; margin-top: 2px; }
.char-card:hover { transform: translateY(-2px); }
.char-card.selected {
  border-color: var(--card-color, var(--cyan));
  box-shadow: 0 0 16px color-mix(in srgb, var(--card-color, var(--cyan)) 55%, transparent);
}
.char-card.selected .char-name { color: var(--card-color, var(--cyan)); }

/* Bottone super (touch e mouse) */
#btn-super {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(140px + env(safe-area-inset-bottom));
  z-index: 35;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid var(--yellow);
  background: radial-gradient(circle at 35% 30%, #4a3d10, #16120a);
  color: var(--yellow);
  font-size: 24px;
  line-height: 1.1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: superglow 0.7s ease-in-out infinite alternate;
}
#btn-super span { font-size: 10px; font-weight: 900; letter-spacing: 1px; }

.loader {
  width: 46px;
  height: 46px;
  border: 4px solid rgba(53, 224, 255, 0.25);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Calibrazione */
#calib-video-wrap {
  width: min(560px, 80vw, 60vh);
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid rgba(53, 224, 255, 0.5);
  background: #000;
  flex-shrink: 0;
}
#calib-canvas { display: block; width: 100%; }
#calib-progress-wrap {
  width: min(560px, 80vw);
  height: 14px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
#calib-progress {
  height: 100%;
  width: 0%;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  transition: width 0.15s linear;
}
#calib-status { font-size: 17px; min-height: 24px; }

/* Conto alla rovescia */
#countdown-number {
  font-size: clamp(120px, 25vw, 260px);
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 40px rgba(53, 224, 255, 0.9);
  animation: pop 0.9s ease infinite;
}
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0.2; }
  30% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 0.9; }
}

/* HUD */
#hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(16px + env(safe-area-inset-top))
           calc(20px + env(safe-area-inset-right))
           16px
           calc(20px + env(safe-area-inset-left));
}
#hud-left { display: flex; flex-direction: column; gap: 10px; }
#hearts { font-size: 30px; letter-spacing: 4px; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6)); }

#super-bar-wrap {
  position: relative;
  width: 190px;
  height: 20px;
  border-radius: 10px;
  border: 1px solid rgba(255, 217, 59, 0.6);
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
#super-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffb63b, var(--yellow));
  transition: width 0.2s ease;
}
#super-bar-wrap.full { animation: superglow 0.7s ease-in-out infinite alternate; }
@keyframes superglow {
  from { box-shadow: 0 0 6px rgba(255, 217, 59, 0.5); }
  to { box-shadow: 0 0 20px rgba(255, 217, 59, 1); }
}
#super-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #ffffff;
  /* Contorno scuro: leggibile anche sopra la barra gialla piena */
  text-shadow: 0 1px 3px rgba(0,0,0,0.95), 0 0 2px rgba(0,0,0,0.9), 0 -1px 2px rgba(0,0,0,0.7);
}

#hud-right { text-align: right; }
#score {
  font-size: 38px;
  font-weight: 900;
  color: var(--text);
  text-shadow: 0 0 14px rgba(53, 224, 255, 0.7);
}
#combo {
  font-size: 22px;
  font-weight: 800;
  color: var(--yellow);
  text-shadow: 0 0 10px rgba(255, 217, 59, 0.8);
}

#hud-center { flex: 1; display: flex; flex-direction: column; align-items: center; }

/* Barra vita del boss */
#boss-bar-wrap {
  margin-top: 6px;
  width: min(420px, 74vw);
  text-align: center;
  animation: bossin 0.4s ease;
}
@keyframes bossin { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#boss-name {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #ff6b8f;
  text-shadow: 0 0 10px rgba(255, 59, 107, 0.9);
  margin-bottom: 4px;
}
#boss-bar-track {
  height: 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 79, 216, 0.7);
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
  box-shadow: 0 0 14px rgba(255, 59, 107, 0.5);
}
#boss-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff9f1c, #ff3b6b, #ff4fd8);
  transition: width 0.15s ease;
}
#wave-banner {
  margin-top: 8vh;
  font-size: clamp(30px, 5vw, 54px);
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--magenta);
  text-shadow: 0 0 22px rgba(255, 79, 216, 0.8);
  animation: wavein 0.5s ease;
}
@keyframes wavein {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Game over */
.gameover-title {
  font-size: clamp(50px, 9vw, 110px);
  color: var(--magenta);
  text-shadow: 0 0 30px rgba(255, 79, 216, 0.8);
  letter-spacing: 6px;
}
.final-score {
  font-size: clamp(40px, 6vw, 70px);
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 20px rgba(53, 224, 255, 0.8);
}
.final-detail { font-size: 18px; opacity: 0.85; }

/* La battuta del personaggio a fine partita: nel flusso della schermata, non
   in un fumetto che coprirebbe i bottoni */
.gameover-quote {
  max-width: min(560px, 92vw);
  font-size: 17px;
  font-style: italic;
  line-height: 1.35;
  color: #dbe9ff;
  opacity: 0.9;
  margin-top: -4px;
}
.gameover-quote::before { content: '“'; }
.gameover-quote::after { content: '”'; }

.hands-hint { font-size: 16px; opacity: 0.8; }
.hands-hint.attivo { color: var(--yellow); opacity: 1; }

.final-rank {
  font-size: 20px;
  font-weight: 700;
  color: var(--yellow);
  min-height: 26px;
  max-width: min(560px, 92vw);
  line-height: 1.3;
  text-wrap: balance;
}

.instructions summary {
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: var(--cyan);
  text-align: center;
  list-style-position: inside;
}
.instructions h3 { margin-top: 10px; }

/* Schermi piccoli: HUD e anteprima webcam compatti */
@media (max-width: 640px) {
  #username-row label { width: 100%; }
  #username-input { max-width: 200px; }
  #hearts { font-size: 24px; letter-spacing: 2px; }
  #score { font-size: 28px; }
  #combo { font-size: 17px; }
  #super-bar-wrap { width: 140px; height: 17px; }
  #cam-pip { width: 110px; left: 10px; bottom: 10px; }
  #hud { padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }
  .char-card { width: 100px; }
  .char-card img { width: 74px; height: 92px; }
  #wave-banner { margin-top: 12vh; }
}

/* Toast messaggi rapidi (sopra ogni schermata: serve anche nel game over) */
#toast {
  position: fixed;
  left: 50%;
  bottom: 26vh;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--panel);
  border: 1px solid rgba(53, 224, 255, 0.4);
  padding: 10px 22px;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 700;
  pointer-events: none;
  animation: toastin 0.25s ease;
}
@keyframes toastin {
  from { transform: translateX(-50%) translateY(14px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* Tasto "Fine": termina la partita in qualsiasi momento */
/* Pausa e audio affiancati, non impilati: da telefono una colonna di tasti
   mangiava spazio verticale e copriva il campo di gioco (segnalato con uno
   screenshot il 27/07). Il punteggio resta sotto, sulla sua riga. */
#hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
#hud-comandi { display: flex; align-items: center; gap: 6px; }
/* Interruttore delle sole voci: discreto, accanto a Fine */
#btn-voci-hud {
  pointer-events: auto;
  font-size: 14px;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid rgba(53, 224, 255, 0.4);
  background: rgba(10, 20, 34, 0.7);
  color: #d0f2ff;
  cursor: pointer;
}
#btn-end {
  pointer-events: auto;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 79, 216, 0.55);
  background: rgba(20, 10, 30, 0.7);
  color: #ffd0f2;
  cursor: pointer;
  margin-bottom: 2px;
  -webkit-tap-highlight-color: transparent;
}
#btn-end:hover { background: rgba(60, 20, 55, 0.85); }
#btn-end:active { transform: scale(0.95); }

/* Barre degli effetti temporanei */
#effects-hud {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 2px;
}
.effect-row { width: 190px; }
.effect-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.effect-track {
  height: 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.25);
  overflow: hidden;
}
.effect-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.12s linear;
}

/* Fumetto delle frasi del personaggio */
#speech-bubble {
  position: fixed;
  z-index: 60;
  transform: translateX(-50%);
  max-width: min(320px, 72vw);
  background: #ffffff;
  color: #14203c;
  border-radius: 16px;
  padding: 10px 16px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
#speech-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 12px solid #ffffff;
}
#speech-bubble.pop { animation: bubblein 0.22s ease; }
@keyframes bubblein {
  from { transform: translateX(-50%) scale(0.6); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* Schizzi di cacca (easter egg) */
.poop-splat {
  position: fixed;
  z-index: 45;
  pointer-events: none;
  opacity: 1;
  transition: transform 2s ease-out, opacity 2s ease-out;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

/* Scheda salvataggio nel game over */
#save-box {
  width: min(560px, 92vw);
  background: var(--panel);
  border: 1px solid rgba(53, 224, 255, 0.3);
  border-radius: 16px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.save-title { font-size: 17px; font-weight: 800; color: var(--cyan); }
.save-hint { font-size: 13px; opacity: 0.8; line-height: 1.4; }
.save-linked { font-size: 14px; font-weight: 700; color: #7dff5a; }
.save-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.save-row input {
  flex: 1;
  min-width: 0;
  max-width: 260px;
  font-size: 16px;
  font-weight: 700;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(53, 224, 255, 0.45);
  background: rgba(6, 12, 32, 0.9);
  color: var(--text);
  text-align: center;
}
.save-row input:focus { outline: 2px solid var(--cyan); }
.username-msg.msg-ok { color: #7dff5a; }

/* Crediti a fondo pagina */
.made-by {
  max-width: min(560px, 92vw);
  margin-top: 10px;
  padding: 14px 16px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  text-align: center;
  font-size: 12.5px;
  line-height: 1.5;
  color: rgba(234, 246, 255, 0.62);
}
.made-by p { margin: 4px 0; }
.made-by-line { font-size: 15px; font-weight: 800; color: rgba(234, 246, 255, 0.9); }
.made-by-line s { color: var(--magenta); text-decoration-thickness: 2px; }
.made-by a { color: var(--cyan); font-weight: 700; text-decoration: none; }
.made-by a:hover { text-decoration: underline; }

/* Bestiario nelle istruzioni: i tre archetipi con la loro forma */
.bestiario { margin-bottom: 10px; }
.bestiario strong { color: var(--cyan); }
.bestiario em { opacity: 0.9; }

/* Pausa: stato della partita salvata e blocco email */
.paused-stato {
  font-size: 17px;
  color: var(--yellow);
  font-weight: 700;
}
#paused-save {
  width: min(460px, 92vw);
  background: var(--panel);
  border: 1px solid rgba(53, 224, 255, 0.3);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: center;
}

/* Tasto pausa nell'HUD: stessa famiglia di "Fine", ma non allarmante */
#btn-pausa {
  pointer-events: auto;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(53, 224, 255, 0.55);
  background: rgba(10, 20, 34, 0.7);
  color: #d0f2ff;
  cursor: pointer;
}

/* Su touch i tasti dell'HUD vanno presi col dito, non col mouse: la pausa
   nasce proprio per il mobile, e 29px di altezza sono troppo pochi.
   Le linee guida Apple parlano di 44px come minimo. */
@media (pointer: coarse) {
  #btn-pausa {
    font-size: 15px;
    padding: 11px 16px;
    min-height: 44px;
  }
  #btn-voci-hud {
    font-size: 18px;
    padding: 10px 14px;
    min-height: 44px;
  }
  #hud-right { gap: 8px; }
}
