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

html, body {
  height: 100%;
  width: 100%;
  font-family: 'Georgia', serif;
  color: #fff;
  overflow: hidden;
  background: #1a0e08;
  -webkit-tap-highlight-color: transparent;
}

body {
  /* Evita zoom su iOS quando si tocca un button */
  -webkit-text-size-adjust: 100%;
}

#background {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: background-image 0.8s ease-in-out, filter 0.8s ease-in-out;
  z-index: 0;
}

.bg-step-1 { background-image: url('pictures/RacoonsAreWatchingYou.png'); }
.bg-step-2 { background-image: url('pictures/RacoonsAreTakingADecision.png'); }
.bg-step-3 { background-image: url('pictures/RacoonsArePartying.png'); }
.bg-sad    { background-image: url('pictures/RacoonsAreWatchingYou.png'); filter: grayscale(0.8) brightness(0.5); }

#overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.40) 0%, rgba(0,0,0,0.70) 100%);
  z-index: 1;
}

#card {
  position: relative;
  z-index: 2;
  max-width: 760px;
  margin: 0 auto;
  min-height: 100%;
  /* Usa svh dove disponibile per evitare problemi con la barra mobile */
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem max(1.5rem, env(safe-area-inset-bottom));
  text-align: center;
}

#question {
  font-size: clamp(1.25rem, 4.5vw, 2.2rem);
  line-height: 1.45;
  text-shadow: 0 2px 12px rgba(0,0,0,0.85);
  margin-bottom: 2rem;
  white-space: pre-line;
  animation: fadeIn 0.6s ease;
}

#answers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.85rem;
  width: 100%;
  animation: fadeIn 0.9s ease;
}

button {
  font-family: inherit;
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  padding: 0.95rem 1.5rem;
  min-height: 48px;            /* target tap mobile-friendly */
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 999px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  touch-action: manipulation;
}

button:hover {
  background: rgba(255,255,255,0.18);
  border-color: #fff;
  transform: translateY(-2px);
}

button:active {
  transform: scale(0.97);
}

button.primary {
  background: rgba(180, 110, 60, 0.9);
  border-color: rgba(255, 220, 180, 0.9);
}

button.primary:hover {
  background: rgba(210, 130, 70, 0.98);
}

/* Mobile: immagine intera in alto (contained), testo e bottoni in basso */
@media (max-width: 600px) {
  #background {
    inset: auto;
    top: 0;
    left: 0;
    right: 0;
    height: 48svh;
    background-size: contain;
    background-position: center top;
    background-color: #1a0e08;
  }
  #overlay {
    background: linear-gradient(
      180deg,
      rgba(0,0,0,0)   0%,
      rgba(0,0,0,0)   35%,
      rgba(0,0,0,0.6) 50%,
      rgba(0,0,0,0.92) 70%,
      rgba(0,0,0,0.96) 100%
    );
  }
  #card {
    justify-content: flex-end;
    padding: 1rem 1rem max(1.25rem, env(safe-area-inset-bottom));
  }
  #question {
    margin-bottom: 1.5rem;
    font-size: clamp(1.15rem, 4.2vw, 1.6rem);
  }
  #answers {
    flex-direction: column;
    gap: 0.65rem;
  }
  button {
    width: 100%;
    padding: 1.05rem 1.25rem;
  }
}

/* Landscape mobile basso: riduci margini */
@media (max-height: 480px) and (orientation: landscape) {
  #question { margin-bottom: 1.25rem; font-size: clamp(1.05rem, 3vw, 1.5rem); }
  button { padding: 0.7rem 1.2rem; min-height: 40px; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
