:root {
  --bg: #0f172a; --card: #1e293b; --line: #334155;
  --fg: #e2e8f0; --muted: #94a3b8; --accent: #38bdf8;
  --ok: #22c55e; --bad: #ef4444; --warn: #f59e0b;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--fg); line-height: 1.5;
}
.app { max-width: 560px; margin: 0 auto; padding: 24px 16px 48px; }
header { text-align: center; margin-bottom: 16px; }
header h1 { margin: 0; font-size: 34px; letter-spacing: 2px; color: var(--accent); }
.sub { margin: 4px 0 0; color: var(--muted); }
.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 18px; font-size: 12px; }
.steps li { flex: 1; text-align: center; padding: 8px 4px; border-radius: 8px;
  background: var(--card); color: var(--muted); border: 1px solid var(--line); }
.steps li.active { color: #fff; border-color: var(--accent); background: #0b3b54; }
.steps li.done { color: var(--ok); border-color: var(--ok); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; }
.card h2 { margin: 0 0 8px; font-size: 18px; }
.card p { color: var(--muted); margin: 6px 0; font-size: 14px; }
.hidden { display: none !important; }
input[type=file] { width: 100%; margin: 12px 0; color: var(--muted); }
button { width: 100%; padding: 12px; margin-top: 14px; border: 0; border-radius: 10px;
  background: var(--accent); color: #05222f; font-weight: 700; font-size: 15px; cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }
.row { display: flex; gap: 10px; margin: 12px 0; }
.preview-box { flex: 1; aspect-ratio: 1; background: #0b1220; border: 1px dashed var(--line);
  border-radius: 10px; position: relative; overflow: hidden; display: flex;
  align-items: center; justify-content: center; }
.preview-box img { width: 100%; height: 100%; object-fit: contain; display: none; }
.preview-box img[src] { display: block; }
.preview-box .ph { position: absolute; bottom: 6px; font-size: 11px; color: var(--muted);
  background: rgba(0,0,0,.5); padding: 2px 6px; border-radius: 6px; }
.video-wrap { position: relative; border-radius: 12px; overflow: hidden; background: #000;
  aspect-ratio: 4/3; margin: 12px 0; }
#video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.overlay { position: absolute; inset: 0; border: 3px solid transparent; border-radius: 12px;
  pointer-events: none; transition: border-color .2s; }
.overlay.ok { border-color: var(--ok); }
.overlay.bad { border-color: var(--bad); }
/* vòng tròn tiến trình: nét đứt, mỗi bước đạt -> xanh thêm 1 phần, xong = xanh 100% */
.prog-ring { position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; }
.prog-ring circle { fill: none; stroke-width: 3.5; stroke-linecap: round;
  stroke: rgba(148, 163, 184, .45); transition: stroke .35s ease; }
.prog-ring circle.on { stroke: var(--ok);
  filter: drop-shadow(0 0 5px rgba(34, 197, 94, .85)); }
.prog-ring.full circle { stroke: var(--ok);
  filter: drop-shadow(0 0 7px rgba(34, 197, 94, .95)); }
/* mũi tên hướng quay, đặt giữa vòng tròn */
.guide-arrow-wrap { position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); pointer-events: none; }
.guide-arrow { font-size: 60px; line-height: 1; display: block;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.6)); }
.guide-arrow-wrap.left  .guide-arrow { animation: nudgeL 1s ease-in-out infinite; }
.guide-arrow-wrap.right .guide-arrow { animation: nudgeR 1s ease-in-out infinite; }
.guide-arrow-wrap.front .guide-arrow { animation: nudgeU 1.2s ease-in-out infinite; }
@keyframes nudgeL { 0%,100% { transform: translateX(0); } 50% { transform: translateX(-18px); } }
@keyframes nudgeR { 0%,100% { transform: translateX(0); } 50% { transform: translateX(18px); } }
@keyframes nudgeU { 0%,100% { transform: translateY(0); opacity: .8; } 50% { transform: translateY(-12px); opacity: 1; } }
.guide { font-size: 12.5px; color: var(--muted); background: #0b1220;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.guide b { color: var(--accent); }
.challenge { text-align: center; font-size: 18px; font-weight: 700; padding: 12px;
  background: #0b3b54; border-radius: 10px; min-height: 24px; }
.progress { height: 8px; background: #0b1220; border-radius: 6px; overflow: hidden; margin: 4px 0; }
#progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.msg { text-align: center; min-height: 20px; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--ok); }
.badge { text-align: center; font-size: 22px; font-weight: 800; padding: 18px;
  border-radius: 12px; margin-bottom: 8px; }
.badge.ok { background: rgba(34,197,94,.15); color: var(--ok); border: 1px solid var(--ok); }
.badge.bad { background: rgba(239,68,68,.15); color: var(--bad); border: 1px solid var(--bad); }
footer { text-align: center; color: var(--muted); font-size: 11px; margin-top: 22px; }
