:root {
  --bg: #0a0a0c;
  --bg-2: #141416;
  --accent: #ffffff;
  --accent-2: #c8c8c8;
  --text: #ffffff;
  --muted: #9a9a9a;
  --error: #e0e0e0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Contenitore della scena AR (fotocamera a tutto schermo) */
#ar-root, #ar-root a-scene {
  position: fixed;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

/* Schermate a tutto schermo (iniziale / non supportato) */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  background: #ffffff;
}

/* Transizione di caricamento minimale (nessun riquadro/menu) */
.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.loading-box .small {
  margin: 0;
  color: #6b6b6b;
}

.loading-box .small.error {
  color: #b00020;
  max-width: 300px;
  line-height: 1.5;
}

/* Pulsante "Riprova" (visibile solo in caso di errore, su sfondo bianco) */
.loading-box button#start-btn {
  background: #0a0a0c;
  color: #ffffff;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.12);
  border-top-color: #0a0a0c;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Link per tornare alla home dell'app Hybrid AR */
.home-link {
  margin-top: 26px;
  color: #0a0a0c;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  border-bottom: 1px solid #0a0a0c;
  padding-bottom: 2px;
}

.screen.hidden, .hidden { display: none !important; }

.card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  background: var(--bg);
  border-radius: 28px;
  padding: 40px 30px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.logo {
  display: block;
  width: 110px;
  max-width: 38%;
  height: auto;
  margin: 0 auto 20px;
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: 0.04em;
  line-height: 1.25;
  text-transform: uppercase;
}

.subtitle {
  margin: 0 0 20px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
}

.hint {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 0 24px;
}

button#start-btn {
  width: auto;
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 14px 30px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #000;
  cursor: pointer;
  background: #fff;
  transition: transform 0.12s ease, opacity 0.2s ease;
}
button#start-btn:active { transform: scale(0.98); }
button#start-btn:disabled { opacity: 0.55; cursor: progress; }

.small { margin: 14px 0 0; font-size: 0.8rem; color: var(--muted); }
.small.error, .error { color: var(--error); }

/* Indicatore di scansione */
.scan-hint {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  pointer-events: none;
}
.scan-hint p {
  background: rgba(0,0,0,0.55);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  color: #fff;
}

.scan-frame {
  position: relative;
  width: min(70vw, 320px);
  height: min(45vw, 200px);
}
.scan-frame .c {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 3px solid var(--accent-2);
}
.scan-frame .tl { top: 0; left: 0; border-right: none; border-bottom: none; border-radius: 8px 0 0 0; }
.scan-frame .tr { top: 0; right: 0; border-left: none; border-bottom: none; border-radius: 0 8px 0 0; }
.scan-frame .bl { bottom: 0; left: 0; border-right: none; border-top: none; border-radius: 0 0 0 8px; }
.scan-frame .br { bottom: 0; right: 0; border-left: none; border-top: none; border-radius: 0 0 8px 0; }

/* Pulsante chiudi */
/* "Torna alla Home" durante l'AR: pillola in basso al centro */
.ar-home-btn {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.close-btn {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  z-index: 12;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

/* ===== Pannello di DEBUG temporaneo (slider Kalman) ===== */
.debug-panel {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 14;
  width: min(92vw, 460px);
  padding: 12px 16px 14px;
  background: rgba(0, 0, 0, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  color: #fff;
  backdrop-filter: blur(8px);
  font-family: "Montserrat", sans-serif;
  pointer-events: auto;
}
.debug-panel .dbg-title {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  text-align: center;
}
.debug-panel .dbg-row { margin: 8px 0; }
.debug-panel label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 4px;
}
.debug-panel label b { font-variant-numeric: tabular-nums; }
.debug-panel input[type="range"] {
  width: 100%;
  accent-color: #fff;
  margin: 0;
}
.debug-panel .dbg-hint {
  display: block;
  font-size: 0.66rem;
  color: var(--muted);
  margin-top: 2px;
  text-align: center;
}
