* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, #f8f9fb, #eff1f5);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: #2d3748;
}

.container {
  width: 100%;
  max-width: 600px;
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header {
  text-align: center;
  margin-bottom: 24px;
}

.icon-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #4791f5);
  box-shadow: 0 0 60px rgba(139, 92, 246, 0.15);
  margin-bottom: 16px;
}

.icon-wrapper svg {
  width: 32px;
  height: 32px;
  color: white;
}

h1 {
  font-size: 28px;
  font-weight: bold;
  background: linear-gradient(135deg, #8b5cf6, #4791f5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.description {
  color: #718096;
  font-size: 14px;
}

.scanner-wrapper {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 60px -20px rgba(139, 92, 246, 0.2);
  border: 2px solid #e2e8f0;
  margin-bottom: 16px;
}

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

/* 扫描线 */
.scan-line {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(71, 145, 245, 0.9),
    transparent
  );
  box-shadow: 0 0 15px rgba(71, 145, 245, 0.8);
  animation: scan 2.5s ease-in-out infinite;
  z-index: 5;
}

@keyframes scan {
  0% {
    top: 0;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

.status {
  text-align: center;
  padding: 16px;
  border-radius: 8px;
  margin-top: 16px;
  font-size: 14px;
  font-weight: 500;
}

.status.waiting {
  background: rgba(59, 130, 246, 0.1);
  color: #4791f5;
}

.status.success {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

.status.error {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.status.loading {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.instructions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.instruction-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(237, 242, 247, 0.5);
  font-size: 14px;
}

.instruction-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #4791f5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.instruction-icon svg {
  width: 16px;
  height: 16px;
  color: white;
}

.instruction-text {
  flex: 1;
  padding-top: 6px;
}

.footer {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  color: #a0aec0;
}

/* 操作按钮 */
.action-buttons {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.action-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
}

.primary-btn {
  background: linear-gradient(135deg, #8b5cf6, #4791f5);
  color: white;
}

.secondary-btn {
  background: rgba(237, 242, 247, 0.8);
  color: #2d3748;
}

.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

/* iframe弹窗样式 - 完全自适应版本 */
.iframe-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  display: flex;
  flex-direction: column;
  z-index: 10000;
  animation: slideInUp 0.3s ease-out;
}

/* 头部样式 */
.iframe-header {
  background: linear-gradient(135deg, #8b5cf6, #4791f5);
  color: white;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  min-height: 60px;
  box-sizing: border-box;
}

.header-title {
  font-weight: 600;
  font-size: clamp(16px, 4vw, 18px);
  line-height: 1.4;
}

.close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.close-btn:hover,
.close-btn:focus {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.close-btn:active {
  transform: scale(0.95);
}

/* iframe容器 */
.iframe-container {
  flex: 1;
  background: white;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.iframe-content {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
  display: block;
}

/* 加载状态 */
.iframe-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f3f4f6;
  border-top: 3px solid #8b5cf6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  margin-top: 1rem;
  color: #6b7280;
  font-size: clamp(14px, 3.5vw, 16px);
  text-align: center;
}

/* 动画效果 */
@keyframes slideInUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideOutDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* 响应式设计 */
@media (max-width: 375px) {
  .iframe-header {
    padding: 0.75rem;
    min-height: 54px;
  }

  .close-btn {
    width: 40px;
    height: 40px;
  }
}

@media (min-width: 768px) {
  .iframe-header {
    padding: 1.25rem;
    min-height: 70px;
  }

  .header-title {
    font-size: 20px;
  }

  .close-btn {
    width: 48px;
    height: 48px;
  }

  .loading-spinner {
    width: 50px;
    height: 50px;
  }

  h1 {
    font-size: 24px;
  }

  .scanner-wrapper {
    padding: 16px;
  }
}

@media (min-width: 1024px) {
  .iframe-overlay {
    max-width: 1200px;
    max-height: 800px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
  }

  .iframe-overlay {
    animation: scaleIn 0.3s ease-out;
  }

  @keyframes scaleIn {
    from {
      transform: translate(-50%, -50%) scale(0.9);
      opacity: 0;
    }
    to {
      transform: translate(-50%, -50%) scale(1);
      opacity: 1;
    }
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .iframe-header {
    padding: 0.5rem 1rem;
    min-height: 50px;
  }

  .header-title {
    font-size: 14px;
  }

  .close-btn {
    width: 36px;
    height: 36px;
  }
}

/* 安全区域适配 */
@supports (padding: max(0px)) {
  .iframe-overlay {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .iframe-header {
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 24px;
  }

  .scanner-wrapper {
    padding: 16px;
  }

  .instruction-item {
    margin-bottom: 12px;
  }

  .footer {
    padding: 12px 16px;
  }

  .action-buttons {
    padding: 0 16px 16px;
  }
}
