@font-face {
  font-family: 'Agenda';
  src: url('../fonts/fonnts.com-Agenda.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: 'Agenda';
  src: url('../fonts/fonnts.com-Agenda_Light.otf') format('opentype');
  font-weight: 300;
  font-style: normal;
}

@font-face {
  font-family: 'Agenda';
  src: url('../fonts/fonnts.com-Agenda_Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
}

@font-face {
  font-family: 'Agenda';
  src: url('../fonts/fonnts.com-Agenda_RegularItalic.otf') format('opentype');
  font-weight: 400;
  font-style: italic;
}

/* Reset e stili base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Agenda', sans-serif !important;
  background-color: #f0f0f0;
  /*overflow: hidden; */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;

  background-image: url('/img/background.jpg');
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover; /* riempie mantenendo proporzioni */
  background-attachment: fixed; /* <-- qui lo rendi "fixed" */
}

.bg-concorso {
  background-image: url('/img/background.webp');
  background-size: cover;
  background-repeat: no-repeat;
}

/* Stili per l'offcanvas del premio */
#prizeOffcanvas {
  --bs-offcanvas-height: 70vh;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
  z-index: 10000; /* Z-index inferiore ai confetti (99999) ma superiore ad altri elementi */
}

#prizeOffcanvas .offcanvas-header {
  background: linear-gradient(135deg, #ffd700, #ffa500);
  border-radius: 20px 20px 0 0;
  border-bottom: none;
  padding: 1.5rem;
}

#prizeOffcanvas .offcanvas-title {
  color: #333;
  font-weight: bold;
  font-size: 1.5rem;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
}

#prizeOffcanvas .offcanvas-body {
  background: linear-gradient(180deg, #fff, #f8f9fa);
  padding: 0.5rem 1rem;
}

.qr-controls .btn-outline-light {
  border-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.9);
  transition: all 0.3s ease;
}

.qr-controls .btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.8);
  color: #fff;
  transform: translateY(-2px);
}

#qr-reader {
  border-radius: 15px;
  overflow: hidden;
  /* box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3); */
}

#qr-reader video {
  border-radius: 15px;
}

#prizeOffcanvas .btn-close {
  background-color: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  padding: 0.5rem;
  opacity: 0.8;
  position: absolute;
  right: 1rem;
  top: 1rem;
}

#prizeOffcanvas .btn-close:hover {
  opacity: 1;
  background-color: rgba(255, 255, 255, 0.9);
}

/* Stili per i contenuti win/lose */
.result-content {
  animation: slideUpFadeIn 0.5s ease-out;
}

#winContent {
  margin: 10px 0;
}

#loseContent {
  margin: 10px 0;
}

.win-animation h2 {
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
  animation: bounce 1s ease-in-out;
}

.lose-animation h2 {
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
  animation: gentle-shake 0.8s ease-in-out;
}

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

@keyframes bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

@keyframes gentle-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

#prizeOffcanvas #prizeImage {
  transition: transform 0.3s ease;
}

#prizeOffcanvas #prizeImage:hover {
  transform: scale(1.05);
}

#prizeOffcanvas .btn-primary {
  background: linear-gradient(135deg, #007bff, #0056b3);
  border: none;
  border-radius: 25px;
  padding: 0.75rem 2rem;
  font-weight: bold;
  box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
  transition: all 0.3s ease;
}

#prizeOffcanvas .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

/* Gestione animazione GIF */
.spesaevinci-gif {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
}

.spesaevinci-gif.loading {
  opacity: 0;
  visibility: hidden;
}

.spesaevinci-gif.ready {
  opacity: 1;
  visibility: visible;
}

/* Container principale */
.container-fluid {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  padding: 0 !important;
  text-align: center;

  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  flex-direction: column;
  /* overflow: hidden; */
}

main {
  display: flex;
  flex: 1;
  flex-direction: column;
  /* min-height: 100vh; */
}

/* Header */
header {
  background-color: #fff;
  padding: 0.5rem 1rem;
  min-height: 9vh; /* Assicura che sia sempre almeno 10vh */
  min-height: 9dvh; /* Dynamic viewport height per iOS */
  height: auto; /* Permette al header di adattarsi al contenuto */
  flex-shrink: 0; /* Impedisce al header di ridursi */
}

.header-side {
  display: flex;
  align-items: center;
}

.header-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Burger Menu */
.burger-menu {
  background: none;
  border: none;
  padding: 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 60px;
  height: 60px;
  transition: all 0.3s ease;
}

.burger-line {
  width: 100%;
  height: 5px;
  background-color: #d4002a;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.burger-menu:hover .burger-line {
  background-color: #a50020;
}

.logo {
  max-height: 80px;
  margin-bottom: 20px;
}

.header-gif {
  max-width: 300px;
  height: auto;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}

h1 {
  color: #d4002a;
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 20px;
  font-size: 0 1rem;
}

/* Stili per centrare il gioco */
.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.game-title {
  color: white;
  font-size: 2.5em;
  font-weight: bold;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#game-container {
  background-image: url(/img/ruota.gif);
  display: flex;
  justify-content: center;
  align-items: center;
  background-size: 150%;
  z-index: 9;
  background-position: center;
}

/* Stili responsivi */
@media (max-width: 600px) {
  .game-title {
    font-size: 1.8em;
    margin-bottom: 15px;
  }
}

/* Footer */
footer {
  z-index: 9;
  width: 100%;
  border-radius: 0.2rem 0.2rem 0 0;
  /* position: fixed;
    bottom: 0; */
  font-size: 0.5rem;
  padding: 0 0.5rem;
  margin-top: auto;
  line-height: 0.5rem;
}

/* Stato disabilitato del pulsante */
.button-spin.disabled {
  cursor: not-allowed;
  pointer-events: none;
}

.button-spin.disabled:hover {
  transform: scale(1);
}

/* Animazione di click per il pulsante */
.button-spin.button-clicked {
  animation: buttonPress 1s ease-in-out;
}

@keyframes buttonPress {
  0% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

canvas {
  background: transparent !important;
  background-color: transparent !important;
}

canvas {
  max-width: 100%;
}

/* Impostazioni specifiche per canvas PDF - alta qualità */
.pdf-page canvas {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  max-width: 100%;
  height: auto;
  display: block;
}

@media (min-width: 1200px) {
  main {
    max-width: 900px !important;
  }

  .game-content {
    max-width: 900px;
  }
}

.indicator {
  position: absolute;
  width: 15%;
  top: 0;
  z-index: 10;
  transform-origin: center top;
  transition: transform 0.15s ease-in-out;
}

.game-content {
  width: 100%;
  height: auto;
  z-index: 5;
  flex: 1;
  max-width: 50vh;
  margin: auto;
}

/* Adatta grandeconcorso allo spazio disponibile */
.grandeconcorso {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.grandeconcorso img {
  max-height: 35vh; /* Ogni immagine massimo 15% del viewport */
  width: auto;
  object-fit: contain;
}

/* Ottimizzazioni per dispositivi mobili */
@media (max-height: 700px) {
  .grandeconcorso {
    max-height: 30vh;
  }

  .grandeconcorso img {
    max-height: 12vh;
  }
}

@media (max-height: 600px) {
  .grandeconcorso {
    max-height: 25vh;
  }

  .grandeconcorso img {
    max-height: 10vh;
  }
}

/* Effetto neve gialla dal basso */
.snow-container {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60%;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.snow-particle {
  position: absolute;
  background-color: #ffd700;
  border-radius: 50%;
  opacity: 0.8;
  animation: snowfall linear infinite;
}

@keyframes snowfall {
  0% {
    transform: translateY(100vh) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 0.8;
  }
  90% {
    opacity: 0.8;
  }
  100% {
    transform: translateY(-10vh) translateX(var(--drift));
    opacity: 0;
  }
}

/* Diverse dimensioni di particelle */
.snow-particle:nth-child(odd) {
  width: 4px;
  height: 4px;
  animation-duration: 8s;
}

.snow-particle:nth-child(even) {
  width: 6px;
  height: 6px;
  animation-duration: 12s;
}

.snow-particle:nth-child(3n) {
  width: 3px;
  height: 3px;
  animation-duration: 10s;
}

.snow-particle:nth-child(4n) {
  width: 5px;
  height: 5px;
  animation-duration: 15s;
}

.spinner-overlay.loaded {
  opacity: 0;
  visibility: hidden;
}

.button-spin {
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
}

.button-spin.loaded {
  opacity: 1;
}

.spinner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background-color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 1;
  visibility: visible;
  transition: all 0.5s ease-in-out;
}

.button-spin {
  position: absolute;
  z-index: 99;
  max-width: 30%;
  cursor: pointer;
}

/* #prizeOffcanvas { */
.offcanvas-bottom {
  /* --bs-offcanvas-height: 90vh; */
  background-image: url(/img/background_premi.webp);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border-radius: 1rem !important;
  box-shadow: none !important;
  z-index: 10000 !important; /* Z-index inferiore ai confetti ma superiore ad altri elementi */
  top: 8vh;
  height: 100% !important;
  /* padding-bottom: 9vh; */
  border: none;
}

#prizeOffcanvas > div {
  background: none !important;
}

.title-price {
  background-color: rgba(255, 255, 255, 0.5);
  padding: 0.5rem 1rem;
  margin: 0 -2rem;
}

.offcanvas-backdrop {
  opacity: 0 !important;
  z-index: 9999; /* Backdrop sotto l'offcanvas ma sopra altri elementi */
}

/* Assicura che i confetti appaiano sopra tutti gli elementi dell'offcanvas */
.confetti-canvas {
  z-index: 99999 !important;
  pointer-events: none;
}

/* Forza tutti i canvas dei confetti ad avere il massimo z-index */
canvas[style*='position: fixed'] {
  z-index: 99999 !important;
  pointer-events: none;
}

/* Fix per iOS Safari - gestione dinamica della viewport */
@supports not (height: 100dvh) {
  /* Fallback per browser che non supportano dvh */
  .container-fluid {
    min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    min-height: calc(var(--vh, 1vh) * 100); /* Usa la variabile CSS custom se disponibile */
  }

  body {
    height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    height: calc(var(--vh, 1vh) * 100); /* Usa la variabile CSS custom se disponibile */
  }

  header {
    min-height: calc(var(--vh, 1vh) * 10); /* 10% dell'altezza viewport reale */
  }
}

/* Media query specifica per dispositivi iOS in viewport ristretta */
@media screen and (max-height: 700px) and (orientation: portrait) {
  .container-fluid {
    min-height: 100vh;
    min-height: 100dvh;
  }

  header {
    min-height: 8vh;
    min-height: 8dvh;
    padding: 0.5rem 1rem;
  }

  .grandeconcorso {
    max-height: 25vh;
  }

  .grandeconcorso img {
    max-height: 8vh;
  }
}

.grande_concorso {
  width: 400px;
  margin-bottom: 1rem;
}

.form-content {
  background-color: #f2f2f2;
  border: 0.5rem solid #fff;
}

.form-control:focus {
  box-shadow: none !important;
  border-color: light-dark(rgb(118, 118, 118), rgb(133, 133, 133)) !important;
}

input::placeholder {
  font-family: 'Agenda', sans-serif;
  font-size: 12px;
  font-style: italic;
  color: #aaa;
}

.footer-canvas {
  position: absolute;
  left: 0;
  bottom: 0;
  background-color: #fff;
}

.footer-qr {
  max-width: 300px;
}

#offcanvasRight .footer-content {
  font-size: 0.5rem;
}

#offcanvasRight .btn-close {
  position: absolute;
  left: 0.5rem;
  top: 1rem;
  background-color: #fff;
}

#offcanvasRight .card-text {
  /* font-size: 0.8rem; */
  line-height: 1.3rem;
}

#offcanvasRight {
  z-index: 99999 !important;
  max-width: 95vw;
}

.btn-gioca {
  max-height: 4rem;
}

#qr-reader {
  border: 0 !important;
}

.offcanvas-body {
  overflow-x: hidden;
}

/* Stili per i nav-tabs nella sidebar */
.offcanvas .nav-tabs {
  border-bottom: 1px solid #dee2e6;
}

.offcanvas .nav-tabs .nav-link {
  max-width: 33%;
  padding: 0.8rem 0.4rem 0.7rem;
  white-space: normal;
  word-wrap: break-word;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  text-transform: uppercase;
  font-weight: bold;
  color: #000;
  font-size: 0.9rem;
}

/* Responsive per schermi molto piccoli */
@media (max-width: 380px) {
  .offcanvas .nav-tabs .nav-link {
    max-width: 100px;
    font-size: 0.75rem;
    padding: 0.4rem 0.3rem;
    min-height: 55px;
  }
}

@media (max-width: 320px) {
  .offcanvas .nav-tabs .nav-link {
    max-width: 90px;
    font-size: 0.7rem;
    padding: 0.3rem 0.2rem;
    min-height: 50px;
  }
}

.nav-tabs .nav-link.active {
  color: var(--bs-nav-tabs-link-active-color);
  background-color: var(--bs-nav-tabs-link-active-bg);
  border-color: #f1862c;
  border-bottom: 2px solid #f1862c !important;
}

/* Stili per QR Scanner Offcanvas */
#offcanvasQRBottom {
  --bs-offcanvas-height: 80vh;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
  background-image: url(/img/fondo_qr.webp);
  color: #f7a92f;
  font-weight: bold;
}

#offcanvasQRBottom .offcanvas-title {
  color: white;
  font-weight: bold;
  font-size: 1.3rem;
}

#offcanvasQRBottom .btn-close {
  position: absolute;
  right: 1rem;
  top: 1rem;
}

#offcanvasQRBottom .offcanvas-body {
  color: #f7a92f;
  font-weight: bold;
  align-items: center;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: end;
}

/* Video QR Scanner */
#qrVideo {
  border-radius: 15px;
  border: 3px solid #007bff;
  background: #000;
  object-fit: cover;
  max-height: 300px;
  width: 15rem;
}

#cameraContainer {
  text-align: center;
}

#cameraContainer .btn {
  margin-top: 10px;
}

/* Input field per inserimento manuale */
#qrInputText {
  border-radius: 0.2rem;
  padding: 0.5rem;
  font-size: 1rem;
  transition: all 0.3s ease;
  text-align: center;
}

#qrInputText:focus {
  border-color: #0056b3;
  box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.25);
}

/* Risultato QR */
#qrResult .alert {
  border-radius: 12px;
  border: none;
  box-shadow: 0 4px 15px rgba(40, 167, 69, 0.2);
}

#qrResult .alert-success {
  background: linear-gradient(135deg, #d4edda, #c3e6cb);
  color: #155724;
  font-weight: 500;
}

/* Responsive per QR Scanner */
@media (max-width: 576px) {
  #offcanvasQRBottom {
    --bs-offcanvas-height: 90vh;
  }

  #qrVideo {
    max-height: 250px;
  }

  #offcanvasQRBottom .offcanvas-body {
    padding: 1.5rem 1rem;
  }
}

/* Stili per il pulsante Partecipa */
#participaBtn {
  transition: opacity 0.3s ease, cursor 0.3s ease;
}

#participaBtn:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  pointer-events: none;
}

#participaBtn:disabled img {
  opacity: 0.6;
  filter: grayscale(0.3);
}

#participaBtn:not(:disabled):hover {
  transform: translateY(-1px);
  transition: transform 0.2s ease;
}

#participaBtn:not(:disabled):active {
  transform: translateY(0);
}

.giocate {
  background-color: #fff;
  border: 0.1rem solid #ccc;
  border-radius: 0.4rem;
  display: flex;
  align-items: center;
  margin: 1rem 0;
  width: 100%;
  justify-content: center;
  padding: 0.6rem;
  position: relative;
}

.giocate > img {
  max-height: 2rem;
  margin: 0.2rem;
}

.giocate > span {
  font-weight: bold;
  font-size: 1rem;
  flex: 1;
  padding-right: 1rem;
  color: #6e6e6e;
  padding-top: 0.3rem;
}

.triangolo {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-top: 5rem solid rgb(247, 169, 47, 0.8);
  border-right: 5rem solid transparent;
  background-color: transparent;
  border-left: 0;
  border-bottom: 0;
}

.text-muted-ccn {
  line-height: 1;
  font-size: 0.8rem;
  margin: 0;
  padding-bottom: 0.5rem;
  font-weight: bold;
  font-style: italic;
}

/* Stili per i checkbox nel form */
.form-check {
  margin-bottom: 1rem !important;
  padding-left: 0 !important;
  display: flex;
}

.form-check-input {
  margin: 0 !important;
  transform: scale(1.1);
  border: 2px solid #dee2e6;
  border-radius: 0.25rem;
  margin-left: 0 !important;
}

.form-check-input:checked {
  background-color: #007bff;
  border-color: #007bff;
}

.form-check-label {
  line-height: 1.2;
  font-size: 0.9rem;
  color: #495057;
  cursor: pointer;
  margin-left: 0.5rem;
}

.form-check-label small {
  display: block;
}

.form-check-label .text-danger {
  font-weight: bold;
}

.form-check-label a {
  text-decoration: underline;
}

.form-check-label a:hover {
  text-decoration: none;
}

.info-carta,
.popover {
  z-index: 99999 !important;
}

.form-control.is-valid,
.was-validated .form-control:valid {
  background-position: right calc(0.375em + 1.1875rem) center !important;
}

.nav-tabs .nav-link.active {
  color: var(--bs-nav-tabs-link-active-color);
  background-color: var(--bs-nav-tabs-link-active-bg);
  border-color: #f1862c;
  border-bottom: 2px solid #f1862c !important;
}

.inforeg a {
  font-weight: bold;
  color: #e30613;
  font-size: 0.9rem;
}

.card-body svg {
  color: #fff;
  background-color: #ffb63d;
  border-radius: 0.2rem;
  padding: 0.2rem;
  width: 0.8rem;
  height: 0.8rem;
  margin-bottom: 0.3rem;
}

.card-body {
  text-align: center;
}

#nav-contact {
  background-color: #f8f8f8;
}

@media (min-width: 1200px) {
  .container-fluid {
    max-width: 900px !important;
  }
}

@media (orientation: landscape) {
  .offcanvas {
    max-width: 900px !important;
    margin: auto;
    top: 20vh;
  }

  /* main {
    min-height: 100vh;
  } */

  #prizeOffcanvas {
    height: 80vh !important;
  }

  .btn-whatsapp {
    max-width: 500px;
  }

  #offcanvasQRBottom .offcanvas-body {
    padding-bottom: 10vh;
  }
}

@media (orientation: portrait) {
  .offcanvas-bottom {
    padding-bottom: 9vh;
  }
}

#nav-tabContent {
  overflow-y: auto;
}

#prizeDescription {
  font-size: 1.2rem;
}

.form-control {
  font-size: 1.1rem !important;
}
