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

body {
  background: #000;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

#ar-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* MindAR рендерит вложенный div + canvas + video — наши div-ы исключаем */
#ar-container > div:not(#loading),
#ar-container canvas,
#ar-container video {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  color: #fff;
  font-family: sans-serif;
  font-size: 16px;
  gap: 16px;
  z-index: 10;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#no-targets-msg {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-family: sans-serif;
  font-size: 15px;
  padding: 10px 20px;
  border-radius: 20px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#no-targets-msg.visible { opacity: 1; }

/* Баннер установки PWA */
#install-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-family: sans-serif;
  font-size: 14px;
  padding: 12px 16px;
  z-index: 20;
  backdrop-filter: blur(4px);
}

#install-btn {
  background: #fff;
  color: #000;
  border: none;
  border-radius: 14px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
}

#install-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

/* Модальное окно */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.modal-content {
  position: relative;
  background: rgba(255,255,255,0.75);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  border-radius: 20px 20px 0 0;
  padding: 0 16px 28px;
  overflow-y: auto;
  overflow-x: hidden;
  animation: slideUp 0.3s ease;
  display: flex;
  flex-direction: column;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-close {
  position: sticky;
  top: 8px;
  align-self: flex-end;
  flex-shrink: 0;
  margin: 8px 0 4px;
  width: 32px;
  height: 32px;
  border: none;
  background: #f0f0f0;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  z-index: 1;
}

#modal-body {
  margin-top: 0;
  font-family: sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #222;
  overflow-wrap: break-word;
  word-break: break-word;
}

#modal-body img  { max-width: 100%; height: auto; border-radius: 8px; margin: 6px 0; }
#modal-body video { max-width: 100%; height: auto; border-radius: 8px; margin: 6px 0; }
#modal-body h1, #modal-body h2, #modal-body h3 { margin: 10px 0 4px; }
#modal-body p { margin-bottom: 6px; }

/* Два столбца в модальном окне */
#modal-body .two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 8px 0;
}

#modal-body .two-col__col,
#modal-body .two-col__left,
#modal-body .two-col__right {
  min-width: 0;
}

.ar-target-wrapper {
  position: fixed;
  left: 0;
  top: 0;
  will-change: transform;
  z-index: 45;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.ar-target-preview {
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  position: relative;
  opacity: 0.75;
}

.ar-target-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ar-target-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.7));
  animation: targetPulse 1.2s ease-in-out infinite;
}

@keyframes targetPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1);    opacity: 0.95; }
  50%       { transform: translate(-50%, -50%) scale(1.3); opacity: 0.6;  }
}

.ar-target-label {
  margin-top: 6px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-family: sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 10px;
  text-align: center;
  backdrop-filter: blur(4px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

#cam-switch-btn {
  position: fixed;
  bottom: 32px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
}

#cam-switch-btn:active { background: rgba(0,0,0,0.85); }
