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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a1a;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

@media (pointer: coarse) {
  canvas { cursor: none; }
}

/* ─── Setup Screen ─── */
.setup {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a1a;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 0;
}

.setup-card {
  text-align: center;
  color: #fff;
  max-width: 420px;
  padding: 48px 32px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.setup-icon {
  font-size: 72px;
  margin-bottom: 8px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.setup-card h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  background: linear-gradient(135deg, #FF6B6B, #4ECDC4, #45B7D1, #FFEAA7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.setup-tagline {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 32px;
}

.setup-tip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  text-align: left;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.75);
}

.setup-tip strong {
  color: #fff;
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.setup-tip .tip-step {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 4px;
}

.setup-tip .tip-num {
  color: #4ECDC4;
  font-weight: 700;
  flex-shrink: 0;
}

/* ─── Photo Upload Section ─── */
.photo-section {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  text-align: left;
}

.photo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.photo-header strong {
  color: #fff;
  font-size: 15px;
}

.photo-count {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.4);
}

.photo-desc {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.4;
  margin-bottom: 14px;
}

.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.photo-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: visible;
}

.photo-thumb img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.photo-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ff4444;
  color: #fff;
  border: 2px solid #0a0a1a;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.photo-add-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.6);
  padding: 12px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.photo-add-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.setup-start {
  width: 100%;
  background: #fff;
  color: #0a0a1a;
  border: none;
  padding: 18px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, opacity 0.15s;
}

.setup-start:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.setup-launcher {
  margin-top: 16px;
}

.setup-launcher-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
  margin-bottom: 8px;
}

.setup-launcher-btn {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
  padding: 10px 24px;
  border-radius: 10px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.setup-launcher-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.setup-exit-hint {
  margin-top: 24px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.2);
}

/* ─── Splash ─── */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 26, 0.95);
  backdrop-filter: blur(12px);
}

.splash-card {
  text-align: center;
  color: #fff;
  max-width: 360px;
  padding: 40px 32px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.splash-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.splash-card h2 {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
}

.splash-card p {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 24px;
}

#splash-dismiss {
  background: #fff;
  color: #0a0a1a;
  border: none;
  padding: 14px 48px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ─── PIN Overlay ─── */
.pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 26, 0.97);
  backdrop-filter: blur(20px);
}

.pin-card {
  text-align: center;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.pin-card h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  color: rgba(255, 255, 255, 0.9);
}

.pin-dots {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 32px;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: all 0.15s ease;
}

.pin-dot.filled {
  background: #fff;
  border-color: #fff;
}

.pin-dot.error {
  border-color: #ff4444;
  background: #ff4444;
  animation: shake 0.4s ease;
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.pin-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 28px;
  font-weight: 400;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  cursor: pointer;
  transition: background 0.15s;
}

.pin-btn:active {
  background: rgba(255, 255, 255, 0.15);
}

.pin-btn-empty {
  visibility: hidden;
}

.pin-btn-back {
  font-size: 22px;
}

.pin-error {
  color: #ff4444;
  font-size: 14px;
  margin-bottom: 12px;
  animation: shake 0.4s ease;
}

.pin-cancel {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 14px;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  padding: 8px 16px;
}

/* ─── Long-press indicator ─── */
.press-indicator {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 64px;
  height: 64px;
  z-index: 50;
}

.press-ring {
  width: 100%;
  height: 100%;
}

.press-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 4;
}

.press-ring-fill {
  fill: none;
  stroke: #fff;
  stroke-width: 4;
  stroke-dasharray: 283;
  stroke-dashoffset: 283;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 0.1s linear;
}

.press-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
}

/* ─── Fullscreen recovery banner ─── */
.fs-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: rgba(255, 77, 77, 0.9);
  color: #fff;
  text-align: center;
  padding: 10px;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-weight: 600;
  cursor: pointer;
  animation: pulse-banner 1.5s ease infinite;
}

@keyframes pulse-banner {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; }
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* Install section (collapsible) */
.install-section {
  margin-top: 28px;
  padding: 14px 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  text-align: left;
}
.install-section summary {
  cursor: pointer;
  font-size: 14px;
  color: #b9b9d4;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.install-section summary::-webkit-details-marker { display: none; }
.install-arrow { transition: transform 0.2s ease; opacity: 0.6; }
.install-section[open] .install-arrow { transform: rotate(180deg); }
.install-body { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.05); }
.install-intro { font-size: 12px; color: #8e8eaa; margin: 0 0 14px; line-height: 1.45; }
.install-platform { margin-bottom: 12px; }
.install-platform-label { font-size: 11px; color: #a0a0c0; margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.install-cmd-row { display: flex; gap: 6px; align-items: stretch; }
.install-cmd-row code {
  flex: 1;
  background: #0e0e1a;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: #c5c5e2;
  overflow-x: auto;
  white-space: nowrap;
}
.install-copy {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: #d0d0e8;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.install-copy:hover { background: rgba(255,255,255,0.12); }
.install-copy.copied { background: #4ade80; color: #052e10; border-color: #4ade80; }
.install-after { font-size: 11px; color: #7e7e98; margin: 10px 0 0; line-height: 1.45; }
.install-after code { background: rgba(255,255,255,0.06); padding: 1px 5px; border-radius: 3px; font-size: 10px; }

.install-other-link { margin: 6px 0 0; }
.install-other-link a {
  color: #6b6b8e;
  font-size: 11px;
  text-decoration: none;
  border-bottom: 1px dotted #6b6b8e;
}
.install-other-link a:hover { color: #b9b9d4; border-bottom-color: #b9b9d4; }
.install-other-msg { font-size: 12px; color: #8e8eaa; margin: 0; line-height: 1.45; }

/* Photo upload status + crop method badges */
.photo-status {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  border: 1px solid transparent;
  animation: photoStatusFade 0.3s ease;
}
.photo-status-info { background: rgba(120, 140, 220, 0.12); border-color: rgba(120, 140, 220, 0.3); color: #b9c2e8; }
.photo-status-success { background: rgba(74, 222, 128, 0.12); border-color: rgba(74, 222, 128, 0.4); color: #86efac; }
.photo-status-warn { background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.4); color: #fde68a; }
@keyframes photoStatusFade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.photo-thumb { position: relative; }
.photo-badge {
  position: absolute;
  top: 4px; left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 11px;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: help;
  z-index: 2;
}
.photo-badge-face { background: rgba(74, 222, 128, 0.85); }
.photo-badge-fallback { background: rgba(251, 191, 36, 0.85); }

/* Toggle (drone setting) */
.setup-toggle-row { margin: 14px 0 8px; display: flex; justify-content: center; }
.setup-toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; padding: 10px 14px; border-radius: 10px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); transition: background 0.15s ease; max-width: 100%; }
.setup-toggle:hover { background: rgba(255,255,255,0.06); }
.setup-toggle input { display: none; }
.setup-toggle-track { width: 38px; height: 22px; background: rgba(255,255,255,0.12); border-radius: 999px; position: relative; transition: background 0.2s ease; flex-shrink: 0; }
.setup-toggle-knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s ease; }
.setup-toggle input:checked + .setup-toggle-track { background: #4ecdc4; }
.setup-toggle input:checked + .setup-toggle-track .setup-toggle-knob { transform: translateX(16px); }
.setup-toggle-label { font-size: 13px; color: #d0d0e8; line-height: 1.3; }
.setup-toggle-hint { display: block; font-size: 10.5px; color: #7e7e98; margin-top: 2px; }
