:root {
  --bg: #07090f;
  --bg-soft: #101624;
  --ink: #eef3ff;
  --muted: #93a0c0;
  --accent: #6cf0c2;
  --accent-2: #ffb86b;
  --danger: #ff6b8a;
  --card: rgba(14, 18, 32, 0.92);
  --stroke: rgba(255, 255, 255, 0.1);
  --glow: 0 0 28px rgba(108, 240, 194, 0.35);
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 700px at 50% -10%, #1a2440 0%, var(--bg) 55%);
  color: var(--ink);
  font-family: var(--font);
}

body {
  min-height: 100dvh;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 14px 18px;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.logo {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), #3aa0ff);
  color: #041018;
  font-weight: 800;
  box-shadow: var(--glow);
}

.hud {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 6px 12px;
  min-width: 72px;
  text-align: center;
}

.stat .label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.stat strong {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.stage-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
}

.stage {
  position: relative;
  width: min(100%, 920px);
  aspect-ratio: 4 / 3;
  border-radius: 20px;
  overflow: hidden;
  background: #05070d;
  border: 1px solid var(--stroke);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

#video,
#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#video {
  transform: scaleX(-1);
  opacity: 0.88;
  filter: saturate(0.8) contrast(1.08) brightness(0.92);
}

#canvas {
  transform: scaleX(-1);
  pointer-events: none;
}

/* Tracking status chip — always on during play */
.track-chip {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(7, 9, 15, 0.82);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.track-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 10px rgba(255, 107, 138, 0.7);
  flex-shrink: 0;
}

.track-chip.is-hand {
  color: var(--accent-2);
  border-color: rgba(255, 184, 107, 0.35);
}

.track-chip.is-hand .track-dot {
  background: var(--accent-2);
  box-shadow: 0 0 12px rgba(255, 184, 107, 0.8);
}

.track-chip.is-pinch {
  color: var(--accent);
  border-color: rgba(108, 240, 194, 0.45);
  background: rgba(108, 240, 194, 0.12);
}

.track-chip.is-pinch .track-dot {
  background: var(--accent);
  box-shadow: 0 0 14px rgba(108, 240, 194, 0.9);
  animation: pulse-dot 0.8s ease-in-out infinite;
}

.track-chip.is-none .track-dot {
  animation: pulse-dot 1.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.7; }
}

.action-hint {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 12px 22px;
  border-radius: 16px;
  background: rgba(255, 184, 107, 0.95);
  color: #1a1005;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 32px rgba(255, 184, 107, 0.45);
  animation: hint-pulse 0.9s ease-in-out infinite;
  pointer-events: none;
  white-space: nowrap;
}

.action-hint[hidden] {
  display: none !important;
}

@keyframes hint-pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.06); }
}

.celebrate {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: rgba(108, 240, 194, 0.18);
}

.celebrate span {
  font-size: clamp(2.2rem, 8vw, 3.6rem);
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 40px rgba(108, 240, 194, 0.8), 0 4px 0 rgba(0, 0, 0, 0.35);
  animation: celebrate-pop 0.85s ease-out both;
}

.celebrate[hidden] {
  display: none !important;
}

@keyframes celebrate-pop {
  0% { transform: scale(0.4); opacity: 0; }
  35% { transform: scale(1.15); opacity: 1; }
  70% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.05); opacity: 0; }
}

.pinch-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(7, 9, 15, 0.72);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(8px);
  font-size: 0.85rem;
  color: var(--muted);
  z-index: 2;
}

.pinch-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 10px rgba(255, 107, 138, 0.7);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.pinch-hint.is-pinched .pinch-dot {
  background: var(--accent);
  box-shadow: 0 0 12px rgba(108, 240, 194, 0.8);
}

.pinch-hint.is-pinched .pinch-label {
  color: var(--accent);
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 6, 12, 0.78);
  backdrop-filter: blur(10px);
  z-index: 20;
  overflow-y: auto;
}

.overlay.hidden {
  display: none;
}

.card {
  width: min(100%, 440px);
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.card-wide {
  width: min(100%, 520px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 1.75rem;
}

.tagline {
  margin: 0 0 18px;
  color: var(--accent-2);
  font-size: 1.05rem;
  font-weight: 600;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #4ec3ff);
  color: #041018;
  font-weight: 800;
  font-size: 1rem;
}

.step-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.step-body strong {
  font-size: 1rem;
  color: var(--ink);
}

.step-body span {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.35;
}

.demo {
  margin: 0 0 14px;
  padding: 10px 8px 6px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--stroke);
  text-align: center;
}

.demo-svg {
  width: 100%;
  max-width: 340px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.demo-hand {
  animation: demo-move 2.4s ease-in-out infinite;
  transform-origin: 110px 60px;
}

.demo-bead {
  animation: demo-bead 2.4s ease-in-out infinite;
}

.demo-tip {
  animation: demo-glow 2.4s ease-in-out infinite;
}

.demo-pinch-line {
  animation: demo-line 2.4s ease-in-out infinite;
}

.demo-arrow {
  animation: demo-arrow-fade 2.4s ease-in-out infinite;
}

@keyframes demo-move {
  0%, 15% { transform: translateX(0); }
  45%, 70% { transform: translateX(95px); }
  100% { transform: translateX(0); }
}

@keyframes demo-bead {
  0%, 100% { opacity: 1; }
  55% { opacity: 1; }
  70% { opacity: 0.35; }
  85% { opacity: 1; }
}

@keyframes demo-glow {
  0%, 12% { fill: #ffb86b; r: 6; }
  18%, 75% { fill: #6cf0c2; }
  100% { fill: #ffb86b; }
}

@keyframes demo-line {
  0%, 12% { stroke-opacity: 0.15; }
  18%, 75% { stroke-opacity: 1; }
  100% { stroke-opacity: 0.15; }
}

@keyframes demo-arrow-fade {
  0%, 20% { stroke-opacity: 0.9; }
  50% { stroke-opacity: 0.3; }
  100% { stroke-opacity: 0.9; }
}

.demo-caption {
  margin: 4px 0 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.hint {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.85rem;
}

.primary-btn,
.ghost-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font: inherit;
  border-radius: 999px;
  padding: 12px 20px;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.primary-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #4ec3ff);
  color: #041018;
  font-weight: 700;
  box-shadow: var(--glow);
}

.primary-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.ghost-btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--stroke);
}

.ghost-btn:hover {
  border-color: rgba(255, 255, 255, 0.28);
}

.topbar .ghost-btn {
  padding: 8px 12px;
  font-size: 0.8rem;
}

.status {
  min-height: 1.2em;
  margin: 12px 0 0;
  color: var(--accent-2);
  font-size: 0.85rem;
}

.final-score,
.final-meta {
  margin: 0 0 8px;
  color: var(--muted);
}

.final-score strong,
.final-meta strong {
  color: var(--ink);
  font-size: 1.4rem;
  margin-left: 6px;
}

.row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.row .primary-btn,
.row .ghost-btn {
  flex: 1;
  width: auto;
}

@media (max-width: 640px) {
  #app {
    padding: 8px;
  }

  .brand h1 {
    font-size: 1rem;
  }

  .stat {
    min-width: 58px;
    padding: 5px 8px;
  }

  .stage {
    aspect-ratio: 3 / 4;
    border-radius: 16px;
  }

  .card,
  .card-wide {
    padding: 22px 16px;
  }

  .action-hint {
    font-size: 1rem;
    padding: 10px 16px;
  }

  .track-chip {
    font-size: 0.78rem;
    padding: 6px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .primary-btn,
  .ghost-btn,
  .pinch-dot,
  .track-dot,
  .action-hint,
  .demo-hand,
  .demo-bead,
  .demo-tip,
  .demo-pinch-line,
  .demo-arrow,
  .celebrate span {
    animation: none !important;
    transition: none;
  }
}
