/* ───── Webfonts ───── */
@font-face {
  font-family: 'Titillium';
  src: url('fonts/Titillium-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Titillium';
  src: url('fonts/Titillium-Bold.otf') format('opentype');
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

/* ───── Reset & Base ───── */
:root {
  --footer-h: 98px;
}

*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Titillium', 'Segoe UI', system-ui, sans-serif;
  background: #000;
}

/* ───── Footer globale ───── */
#global-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-h);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.12);
}
#global-footer img {
  height: calc(var(--footer-h) - 14px);
  width: auto;
  max-width: 220px;
  object-fit: contain;
  display: block;
}

/* ───── Top icon (cover + form) ───── */
.top-icon {
  width: auto;
  height: clamp(80px, 30vw, 170px);
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.35));
}

.top-icon--form {
  height: 64px;
  align-self: center;
  filter: none;
  margin-bottom: -0.3rem;
}

/* ───── Screens ───── */
.screen {
  position: fixed;
  inset: 0 0 var(--footer-h) 0;   /* non scende sotto il footer */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 10;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ───── Cover Screen ───── */
#cover-screen {
  flex-direction: column;
  background: #000;
}
.cover-bg {
  position: absolute;
  inset: 0;
  /* Sostituire img/cover.avif con l'immagine cover del prodotto */
  /* background: url('img/cover.avif') center/cover no-repeat, linear-gradient(150deg, #012a4a 0%, #0288D1 60%, #00acc1 100%); */
  filter: brightness(0.7);
  background-image: url('img/bkg.png');
   background-blend-mode: overlay;
   z-index: 1;
}
.cover-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.cover-logo {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: normal;
  color: #fff;
  letter-spacing: 2px;
  line-height: 1.1;
  text-shadow: 0 2px 20px rgba(0,0,0,0.6);
}
.cover-logo span {
  color: #4FC3F7;
}
.cover-sub {
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  color: rgba(255,255,255,0.85);
  max-width: 340px;
  line-height: 1.5;
  text-shadow: 0 1px 8px rgba(0,0,0,0.5);
}
.btn-play {
  margin-top: 1rem;
  padding: 0.85rem 2.8rem;
  background: #fff;
  color: #2b3f7a;
  font-family: 'Titillium', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  letter-spacing: 2px;
  text-transform: uppercase;
  box-shadow: 0 4px 18px rgba(0,0,0,0.22);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-play:active {
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

/* ───── Register Screen ───── */
#register-screen {
  background-image: url('img/bkg.png');
  background-size: cover;
  background-position: center;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
}

/* ── icona superiore register ── */
.register-top-icon {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── arco bianco ── */
.register-box {
  background: #fff;
    border-radius: 220px 220px 0 0;
    padding: 5.5rem 2rem 1.5rem;
    width: 75%;
    max-width: 520px;
    align-self: center;
    max-height: 80%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.15);
}
.register-box h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2b3f7a;
  text-align: center;
}
.register-box p.subtitle {
  font-size: 0.9rem;
  color: #5a6a8a;
  text-align: center;
  margin-top: -0.4rem;
}

/* ── campi form ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-bottom: 30px;
}
.form-group label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #2b3f7a;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding-left: 0.9rem;
}
.form-group input[type="text"],
.form-group input[type="email"] {
  padding: 0.85rem 1.2rem;
  background: #cdd8ee;
  border: none;
  border-radius: 50px;
  font-family: 'Titillium', sans-serif;
  font-size: 1rem;
  color: #2b3f7a;
  outline: none;
  user-select: text;
  box-shadow: inset 0 3px 7px rgba(43,63,122,0.18),
              inset 0 1px 3px rgba(0,0,0,0.10);
  transition: background 0.2s, box-shadow 0.2s;
}
.form-group input:focus {
  background: #b8caeb;
  box-shadow: inset 0 3px 7px rgba(43,63,122,0.22),
              inset 0 1px 3px rgba(0,0,0,0.12),
              0 0 0 3px rgba(43,63,122,0.15);
}
.form-group input.error {
  box-shadow: 0 0 0 3px rgba(229,57,53,0.3);
}

/* ── privacy ── */
.privacy-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: #5a6a8a;
  padding-left: 0.2rem;
}
.privacy-row input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: #2b3f7a;
  cursor: pointer;
  flex-shrink: 0;
}
.privacy-row a {
  color: #2b3f7a;
  text-decoration: underline;
  cursor: pointer;
}

/* ── bottone form ── */
.btn-start {
  padding: 0.5rem 2.5rem;
  background: linear-gradient(135deg, #3a5298, #2b3f7a);
  color: #fff;
  font-family: 'Titillium', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  letter-spacing: 2px;
  text-transform: uppercase;
  display: block;
  margin: 0.4rem auto 0;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 6px 20px rgba(43,63,122,0.4);
}
.btn-start:active { transform: scale(0.97); }

/* ───── Game Screen ───── */
#game-screen {
  display: none;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow: hidden;
  /* inset ereditato da .screen: 0 0 var(--footer-h) 0 */
}
#game-screen.active {
  display: flex;
}

.game-bg {
  position: absolute;
  inset: 0;
  background: url('img/fondo.avif') center/cover no-repeat;
  transition: filter 0.6s ease;
  will-change: filter;
  z-index: 0;
}

/* ── HUD ── */
#hud {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  gap: 0.5rem;
  flex-shrink: 0;
}
#hud-nick {
  font-size: clamp(0.75rem, 2.5vw, 0.95rem);
  font-weight: 700;
  color: #fff;
  max-width: 30%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#hud-score {
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  font-weight: 900;
  color: #4FC3F7;
  text-shadow: 0 0 12px rgba(79, 195, 247, 0.6);
  letter-spacing: 1px;
  flex: 1;
  text-align: center;
}
#hud-timer {
  font-size: clamp(1rem, 3.5vw, 1.3rem);
  font-weight: 800;
  color: #fff;
  background: rgba(255,255,255,0.15);
  padding: 0.25rem 0.7rem;
  border-radius: 20px;
  min-width: 52px;
  text-align: center;
  transition: color 0.3s, background 0.3s;
}
#hud-timer.urgent {
  color: #FF5252;
  background: rgba(255, 82, 82, 0.2);
  animation: pulse 0.6s ease infinite alternate;
}
@keyframes pulse {
  from { transform: scale(1); }
  to   { transform: scale(1.1); }
}

/* Progress bar */
#score-bar-wrap {
  position: relative;
  z-index: 20;
  height: 5px;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}
#score-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4FC3F7, #0288D1);
  transition: width 0.4s ease;
}

/* ── Game Area ── */
#game-area {
  position: relative;
  z-index: 10;
  flex: 1;
  overflow: hidden;
}

/* ── Game Elements (fly / bonus) ── */
.game-el {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: left 0.8s ease-in-out, top 0.8s ease-in-out;
  z-index: 15;
  transform-origin: center;
}
.game-el:active { transform: scale(0.85); }

.el-icon {
  font-size: clamp(2.5rem, 9vw, 3.5rem);
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.5));
  line-height: 1;
  pointer-events: none;
}
.el-icon.fly-icon {
  font-size: clamp(2rem, 7vw, 3rem);
  animation: flyWiggle 0.4s ease infinite alternate;
}
@keyframes flyWiggle {
  from { transform: rotate(-8deg) translateY(0); }
  to   { transform: rotate(8deg) translateY(-4px); }
}

.el-label {
  font-size: 0.65rem;
  font-weight: 800;
  color: #fff;
  background: rgba(0,0,0,0.55);
  border-radius: 6px;
  padding: 1px 5px;
  margin-top: 2px;
  letter-spacing: 0.5px;
  pointer-events: none;
}

/* Fly pulse ring on spawn */
.game-el::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  animation: ringFade 0.5s ease forwards;
}
@keyframes ringFade {
  from { opacity: 1; transform: scale(0.5); }
  to   { opacity: 0; transform: scale(1.5); }
}

/* Bonus element extra glow */
.game-el.bonus {
  filter: drop-shadow(0 0 10px rgba(255,230,0,0.7));
}

/* Timer ring on bonus */
.bonus-timer {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  overflow: hidden;
}
.bonus-timer-bar {
  height: 100%;
  background: #FFD600;
  border-radius: 2px;
  transition: none;
}

/* Score popup */
.score-popup {
  position: absolute;
  z-index: 30;
  font-size: 1.4rem;
  font-weight: 900;
  color: #FFD600;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  pointer-events: none;
  animation: popUp 0.8s ease forwards;
}
.score-popup.fly-pop { color: #ffffff; }
@keyframes popUp {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  70%  { opacity: 1; transform: translateY(-50px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-80px) scale(0.8); }
}

/* ───── Reveal Screen ───── */
#reveal-screen {
  flex-direction: column;
}
.reveal-bg {
  position: absolute;
  inset: 0;
  /* stessa immagine di gioco ma NITIDA */
  background: url('img/fondo.avif') center/cover no-repeat;
  animation: revealIn 1.2s ease forwards;
}
@keyframes revealIn {
  from { filter: blur(18px) brightness(0.6); transform: scale(1.06); }
  to   { filter: blur(0px)  brightness(1);   transform: scale(1); }
}
.reveal-overlay {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  padding: 2rem;
  text-align: center;
}
.reveal-badge {
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 900;
  color: #fff;
  background: rgba(2,136,209,0.85);
  padding: 0.6rem 1.8rem;
  border-radius: 50px;
  letter-spacing: 1px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
}
.reveal-msg {
  font-size: clamp(1rem, 3.5vw, 1.25rem);
  color: #fff;
  font-weight: 600;
  text-shadow: 0 2px 10px rgba(0,0,0,0.7);
  max-width: 380px;
  line-height: 1.4;
}
.reveal-btn {
  opacity: 0;
  animation: fadeBtn 0.5s ease 1.8s forwards;
}
@keyframes fadeBtn {
  to { opacity: 1; }
}

/* ───── End Screen ───── */
#end-screen {
  background-image: url('img/bkg.png');
  background-size: cover;
  background-position: center;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
}

/* ── arco bianco end ── */
.end-box {
  background: #fff;
  border-radius: 230px 230px 0 0;
  padding: 2.5rem 2rem 1.5rem;
  width: 100%;
  max-width: 520px;
  align-self: center;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.15);
}

/* titolo */
.end-box h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #2b3f7a;
  text-align: center;
}

/* punteggio verde */
.end-final-score {
  text-align: center;
  font-size: 3rem;
  font-weight: 900;
  color: #5cb85c;
  line-height: 1;
}
.end-final-score small {
  display: block;
  font-size: 0.82rem;
  color: #5a6a8a;
  font-weight: 400;
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* header classifica */
.end-lb-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1.5px solid #e0e0e0;
  padding-bottom: 0.5rem;
  margin-top: 0.2rem;
}
.end-lb-icon { height: 48px; width: auto; object-fit: contain; display: block; }
.end-lb-head > span:last-child {
  font-size: 0.95rem;
  font-weight: 700;
  color: #2b3f7a;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* righe classifica */
#leaderboard {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.lb-row {
  display: flex;
  align-items: center;
  padding: 0.35rem 0.2rem;
  font-size: 0.92rem;
  border-bottom: 1px solid #f0f0f0;
}
.lb-row.me { background: #f0f6ff; border-radius: 8px; padding: 0.35rem 0.5rem; }
.lb-rank {
  font-weight: 700;
  color: #aaa;
  width: 22px;
  flex-shrink: 0;
  font-size: 0.8rem;
}
.lb-rank.gold   { color: #f5a623; }
.lb-rank.silver { color: #9b9b9b; }
.lb-rank.bronze { color: #a1887f; }
.lb-nick {
  flex: 1;
  font-weight: 600;
  color: #2b3f7a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-pts {
  font-weight: 700;
  color: #2b3f7a;
  flex-shrink: 0;
  font-size: 0.88rem;
}

/* bottone */
.btn-again {
  padding: 1rem 2.5rem;
  background: linear-gradient(135deg, #3a5298, #2b3f7a);
  color: #fff;
  font-family: 'Titillium', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2px;
  display: block;
  margin: 0.4rem auto 0;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 6px 20px rgba(43,63,122,0.4);
}
.btn-again:active { transform: scale(0.97); }

/* ───── Utility ───── */
.hidden { display: none !important; }

.classifica-icon {
  width: auto;
  height: clamp(80px, 30vw, 40px);
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.35));
}