:root {
  --primary: #2A9D8F;
  --accent: #F4A261;
  --glass: rgba(20, 30, 40, 0.65);
  --glass-border: rgba(255, 255, 255, 0.15);
  --text: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0; padding: 0; overflow: hidden;
  background: #0f172a; color: var(--text);
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

#app {
  position: relative; width: 100vw; height: 100vh;
  display: flex; justify-content: center; align-items: center;
}

/* 全屏画布 */
canvas.main-canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 1;
}

/* 隐藏原始视频 */
video.input-video { display: none; }

/* 隐私协议弹窗 */
.privacy-modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85); z-index: 9999;
  display: flex; justify-content: center; align-items: center;
  backdrop-filter: blur(8px);
}

.privacy-modal.hidden { display: none; }

.privacy-content {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-radius: 20px; padding: 30px; max-width: 500px;
  width: 90%; max-height: 80vh; overflow-y: auto;
  border: 2px solid var(--glass-border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.privacy-content h2 {
  margin: 0 0 20px; color: var(--accent); font-size: 1.8rem;
  display: flex; align-items: center; gap: 10px;
}

.privacy-content p {
  line-height: 1.8; margin-bottom: 15px; opacity: 0.9;
  font-size: 0.95rem;
}

.privacy-content ul {
  margin: 15px 0; padding-left: 20px; line-height: 1.8;
}

.privacy-content li {
  margin-bottom: 10px; opacity: 0.85;
}

.privacy-highlight {
  background: rgba(42, 157, 143, 0.2);
  padding: 15px; border-radius: 10px;
  border-left: 4px solid var(--primary);
  margin: 20px 0;
}

.privacy-buttons {
  display: flex; gap: 15px; margin-top: 25px;
}

.privacy-btn {
  flex: 1; padding: 14px; border: none; border-radius: 12px;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: all 0.3s;
}

.privacy-btn.accept {
  background: linear-gradient(135deg, var(--primary), #3B82F6);
  color: white;
}

.privacy-btn.accept:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(42, 157, 143, 0.5);
}

.privacy-btn.decline {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444; border: 2px solid #ef4444;
}

.privacy-btn.decline:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* 摄像头切换按钮 */
.camera-switch {
  position: absolute; top: 20px; right: 20px;
  background: var(--glass); backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border); border-radius: 50%;
  width: 50px; height: 50px; display: flex;
  justify-content: center; align-items: center;
  cursor: pointer; transition: all 0.3s;
  pointer-events: auto; z-index: 20;
}

.camera-switch:hover {
  background: rgba(42, 157, 143, 0.3);
  transform: rotate(180deg);
}

.camera-switch i { font-size: 1.3rem; }
.camera-switch.hidden { display: none; }

/* UI 层 */
.ui-layer {
  position: absolute; top: 0; left: 0; width: 100vw; height: 100vh;
  z-index: 10; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 20px;
  max-width: 100vw;
  max-height: 100vh;
}

/* 顶部栏 */
.top-bar {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  z-index: 100;
  pointer-events: auto;
  width: calc(100% - 40px);
  max-width: 1200px;
}

.top-bar.hidden {
  display: none;
}

.status-indicator {
  background: var(--glass);
  backdrop-filter: blur(12px);
  padding: 12px 24px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.status-indicator.idle { color: #94a3b8; }
.status-indicator.loading { color: #fbbf24; }
.status-indicator.active { color: #10b981; }
.status-indicator.error { color: #ef4444; }

.status-indicator .pulse {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.controls-right {
  display: flex;
  gap: 10px;
}

.icon-btn {
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  color: white;
  text-decoration: none;
}

.icon-btn:hover {
  background: rgba(42, 157, 143, 0.4);
  transform: scale(1.1);
}

/* 底部提示区 */
.bottom-hint {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: none;
}

.bottom-hint.hidden {
  display: none;
}

.hint-text {
  background: var(--glass);
  backdrop-filter: blur(12px);
  padding: 16px 32px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

/* 启动按钮覆盖层 */
.start-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
}

.start-btn {
  background: linear-gradient(135deg, #3B82F6, #2A9D8F);
  border: none;
  color: white;
  padding: 20px 48px;
  border-radius: 50px;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(42, 157, 143, 0.5);
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.start-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(42, 157, 143, 0.7);
}

/* 关节/表情小窗 */
.joint-widget {
  position: fixed;
  z-index: 120;
  width: 280px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  box-shadow: 0 15px 45px rgba(0,0,0,0.35);
  backdrop-filter: blur(12px);
  color: #e2e8f0;
  user-select: none;
}

.joint-widget.hidden { display: none; }

.joint-widget .widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: move;
  background: linear-gradient(135deg, rgba(42,157,143,0.3), rgba(59,130,246,0.25));
  border-bottom: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px 14px 0 0;
}

.widget-title { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.widget-title i { color: #22c55e; }

.widget-actions { display: flex; gap: 6px; }
.widget-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  color: #e2e8f0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.widget-btn:hover { background: rgba(255,255,255,0.16); }

.widget-body { padding: 10px 12px 12px; }
.joint-widget canvas { width: 100%; height: auto; border-radius: 10px; background: #0b1224; }
.widget-hint { margin-top: 8px; font-size: 12px; color: #94a3b8; text-align: center; }

.joint-widget.minimized .widget-body { display: none; }

.start-btn:active {
  transform: scale(1.02);
}

/* 彩蛋容器 */
.easter-egg-container,
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 200;
}

.brand {
  background: var(--glass); backdrop-filter: blur(12px);
  padding: 12px 24px; border-radius: 16px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.brand h1 { 
  margin: 0; font-size: 1.4rem; 
  display: flex; align-items: center; gap: 10px; 
}

.brand p { 
  margin: 4px 0 0; font-size: 0.85rem; opacity: 0.8; 
}

/* 底部栏 */
.bottom-bar {
  display: flex; justify-content: center; align-items: flex-end;
  pointer-events: auto; position: relative;
}

.control-panel {
  background: var(--glass); backdrop-filter: blur(16px);
  padding: 18px 24px; border-radius: 20px;
  border: 1px solid var(--glass-border);
  text-align: center; max-width: 90vw;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  transform: translateY(0); transition: transform 0.3s;
}

.control-panel.hidden { transform: translateY(150%); }

.status-text { 
  font-size: 1.1rem; font-weight: 700; 
  margin-bottom: 8px; color: var(--accent); 
}

.hint-text { 
  font-size: 0.9rem; opacity: 0.8; margin-bottom: 16px; 
}

.action-btn {
  background: linear-gradient(135deg, #3B82F6, #2A9D8F);
  border: none; color: white; padding: 14px 32px;
  border-radius: 50px; font-size: 1rem; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 15px rgba(42, 157, 143, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  display: inline-flex; align-items: center; gap: 8px;
}

.action-btn:hover { 
  transform: scale(1.05); 
  box-shadow: 0 6px 20px rgba(42, 157, 143, 0.6); 
}

.action-btn:disabled { 
  filter: grayscale(1); cursor: not-allowed; opacity: 0.7; 
}

.action-btn.stop { background: rgba(239, 68, 68, 0.8); }

/* 悬浮数据 */
.stats-float {
  position: absolute; bottom: 20px; right: 20px;
  background: var(--glass); backdrop-filter: blur(12px);
  padding: 14px 20px; border-radius: 16px;
  border: 1px solid var(--glass-border);
  pointer-events: none;
  max-width: calc(100vw - 40px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.big-num { 
  font-size: 2rem; font-weight: 800; 
  line-height: 1; color: var(--accent); 
}

.label { 
  font-size: 0.85rem; opacity: 0.7; 
  text-transform: uppercase; letter-spacing: 1px; 
  white-space: nowrap; 
}

/* 彩带 */
.confetti { 
  position: fixed; width: 12px; height: 20px; 
  top: -20px; z-index: 999; 
  animation: drop 2s linear forwards; 
}

@keyframes drop { 
  0% { transform: translate3d(0,0,0) rotate(0deg); } 
  100% { transform: translate3d(var(--x), 110vh, 0) rotate(720deg); opacity: 0; } 
}

/* 加载遮罩 */
.loader-mask {
  position: absolute; inset: 0; background: #0f172a; z-index: 20;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  transition: opacity 0.5s;
}

.loader-mask.fade-out { opacity: 0; pointer-events: none; }

.spinner { 
  font-size: 3rem; color: var(--primary); 
  animation: spin 1s linear infinite; margin-bottom: 20px; 
}

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

/* 响应式优化 */
@media (max-width: 768px) {
  .ui-layer { padding: 12px; }
  .brand h1 { font-size: 1.1rem; }
  .brand p { font-size: 0.75rem; }
  .brand { padding: 10px 16px; }
  .control-panel { padding: 14px 18px; }
  .status-text { font-size: 1rem; }
  .hint-text { font-size: 0.8rem; }
  .action-btn { padding: 12px 24px; font-size: 0.9rem; }
  .big-num { font-size: 1.6rem; }
  .stats-float { 
    padding: 10px 16px; 
    bottom: 15px; 
    right: 15px;
    gap: 8px;
  }
  .stat-item {
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .ui-layer { padding: 8px; }
  .brand h1 { font-size: 1rem; }
  .brand p { font-size: 0.7rem; }
  .control-panel { padding: 12px 16px; }
  .big-num { font-size: 1.4rem; }
  .stats-float {
    bottom: 10px;
    right: 10px;
    padding: 8px 12px;
  }
  .label { font-size: 0.75rem; }
}
