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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#container {
  width: 100%;
  height: 100%;
  position: relative;
}

/* 覆盖层 */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  z-index: 20;
  transition: opacity 0.4s ease;
  text-align: center;
  padding: 24px;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay .title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.overlay .subtitle {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

/* 加载动画 */
.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #00d2a0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 20px;
}

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

/* 扫描框 */
.scan-frame {
  width: 220px;
  height: 220px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.scan-frame::before,
.scan-frame::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: #00d2a0;
  border-style: solid;
}

.scan-frame::before {
  top: -2px;
  left: -2px;
  border-width: 3px 0 0 3px;
  border-top-left-radius: 14px;
}

.scan-frame::after {
  bottom: -2px;
  right: -2px;
  border-width: 0 3px 3px 0;
  border-bottom-right-radius: 14px;
}

.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #00d2a0, transparent);
  animation: scan 2s ease-in-out infinite;
}

@keyframes scan {
  0%, 100% {
    top: 0;
    opacity: 0;
  }
  50% {
    top: 100%;
    opacity: 1;
  }
}

/* 状态栏 */
.status-bar {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: opacity 0.3s;
}

.status-bar.hidden {
  opacity: 0;
  pointer-events: none;
}

.status-bar .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00d2a0;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

/* 区域提示 */
.region-tip {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 210, 160, 0.9);
  color: #000;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  z-index: 15;
  transition: opacity 0.3s;
}

.region-tip.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ===== 启动按钮 ===== */
#start-btn {
  margin-top: 32px;
  padding: 16px 48px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #4facfe 0%, #2575fc 100%);
  border: none;
  border-radius: 32px;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(37, 117, 252, 0.4);
  transition: transform 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

#start-btn:active {
  transform: scale(0.96);
}

#start-btn:disabled {
  opacity: 0.6;
}

/* 自由展示按钮（次要按钮） */
.secondary-btn {
  margin-top: 14px;
  padding: 12px 32px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 28px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.secondary-btn:active {
  transform: scale(0.96);
}

.secondary-btn:disabled {
  opacity: 0.6;
}

.env-check {
  margin-top: 16px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.6;
}

/* ===== 屏幕诊断日志 ===== */
#debug {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  max-height: 30%;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.65);
  color: #7CFC00;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  line-height: 1.5;
  padding: 6px 8px;
  border-radius: 6px;
  z-index: 50;
  pointer-events: auto;
  word-break: break-all;
}

#debug.hidden {
  display: none;
}

/* ===== 调试开关 ===== */
.debug-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 60;
  background: rgba(0, 0, 0, 0.6);
  color: #7CFC00;
  border: 1px solid #7CFC00;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.debug-toggle.hidden {
  display: none;
}

/* ===== 扫描层不要遮黑背景 ===== */
#scanning {
  background: transparent !important;
  pointer-events: none;
}

#scanning .scan-frame,
#scanning .title,
#scanning .subtitle {
  pointer-events: auto;
}

#scanning .title,
#scanning .subtitle {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 8px 16px;
  border-radius: 16px;
  margin-top: 8px;
}

/* 视频兜底 */
video {
  object-fit: cover;
}
