:root {
  --colore-testo: #3a2b20;
  --colore-bolla-nonna: #fff6e8;
  --colore-bolla-bimbo: #ffd9a0;
  --colore-accento: #c0392b;
  --colore-sfondo-riquadro: rgba(255, 250, 240, 0.92);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
  color: var(--colore-testo);
  background: #f4e4c1 url("../img/nonna-maria.jpg") center/cover no-repeat fixed;
}

.schermata {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.schermata[hidden] {
  display: none;
}

.riquadro {
  background: var(--colore-sfondo-riquadro);
  border-radius: 24px;
  padding: 32px 24px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

h1 {
  font-size: 1.5rem;
  margin-top: 0;
}

form#form-codice {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

input {
  font-size: 20px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid #d8b98a;
  min-height: 48px;
}

button {
  font-size: 20px;
  padding: 14px 16px;
  border-radius: 14px;
  border: none;
  background: var(--colore-accento);
  color: white;
  min-height: 48px;
  cursor: pointer;
}

button:active {
  opacity: 0.85;
}

.messaggio-errore {
  color: var(--colore-accento);
  font-weight: bold;
}

/* --- Chat --- */

.schermata-chat {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  min-height: 100vh;
}

.intestazione-chat {
  background: rgba(58, 43, 32, 0.85);
  color: white;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.1rem;
  font-weight: bold;
}

.lista-messaggi {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(255, 255, 255, 0.55);
}

.bolla {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 18px;
  line-height: 1.3;
}

.bolla-nonna {
  align-self: flex-start;
  background: var(--colore-bolla-nonna);
  border-bottom-left-radius: 4px;
}

.bolla-bimbo {
  align-self: flex-end;
  background: var(--colore-bolla-bimbo);
  border-bottom-right-radius: 4px;
}

.bolla-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 16px;
}

.bolla-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a9895f;
  animation: rimbalzo-puntini 1s infinite ease-in-out;
}

.bolla-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.bolla-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes rimbalzo-puntini {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

.form-domanda {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.85);
}

.form-domanda input {
  flex: 1;
}

.form-domanda button {
  flex-shrink: 0;
  padding: 14px 20px;
}

/* --- Riepilogo --- */

.lista-riepilogo {
  text-align: left;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 55vh;
  overflow-y: auto;
}

.voce-riepilogo .domanda {
  font-weight: bold;
}

.voce-riepilogo .risposta {
  margin: 4px 0 0;
}

.chiusura {
  margin-top: 20px;
  font-size: 1.2rem;
}
