:root {
  --bg: #070b12;
  --panel: #0f1622;
  --line: #1f2c40;
  --ink: #e6eefb;
  --dim: #8fa3bf;
  --accent: #7fb4ff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 "Noto Sans Thai", "Leelawadee UI", "Segoe UI", system-ui, sans-serif;
}
.top { text-align: center; padding: 22px 16px 10px; }
.top h1 { margin: 0; font-size: 30px; font-weight: 300; letter-spacing: .04em; }
.top p { margin: 4px 0 0; color: var(--dim); font-size: 14px; }

.wrap { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; max-width: 1280px; margin: 0 auto; padding: 12px 16px 28px; align-items: start; }
.stage-box { min-width: 0; }
.stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3; background: #000; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line);
}
/* ภาพกล้องและภาพ 3D กลับซ้ายขวาแบบกระจก · ป้ายชื่อไม่กลับ (คำนวณตำแหน่งกลับด้านเอง) */
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; transform: scaleX(-1); }
.stage video { object-fit: fill; }
.stage canvas { pointer-events: none; }
#lines, #labels { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#lines line { stroke: rgba(230, 240, 255, .55); stroke-width: 1; }
#lines circle { fill: #fff; }
.lbl {
  position: absolute; white-space: nowrap; font-size: 11.5px; line-height: 1.2; color: #f3f7ff;
  text-shadow: 0 0 4px #000, 0 0 2px #000; transform: translateY(-50%);
}
.lbl.r { transform: translate(-100%, -50%); }
#lens-ring { position: absolute; border: 1px solid rgba(220, 235, 255, .55); border-radius: 50%; pointer-events: none; transform: translate(-50%, -50%); }

.start { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; background: rgba(4, 8, 14, .82); text-align: center; padding: 16px; }
.start button { font: inherit; font-size: 17px; padding: 12px 30px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: #06101f; font-weight: 600; cursor: pointer; }
.start button:disabled { opacity: .6; cursor: progress; }
.start p { margin: 0; color: var(--dim); font-size: 13px; max-width: 420px; }
.status { margin: 8px 2px 0; color: var(--dim); font-size: 13px; min-height: 20px; }
.status.err { color: #ffb0a8; }

.panel { display: grid; gap: 12px; }
.panel section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 9px; }
.panel h2 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--dim); }
.panel label { display: grid; gap: 3px; font-size: 13px; color: var(--ink); }
.panel label.row, .checks label { display: flex; align-items: center; gap: 7px; }
.panel label output { color: var(--dim); font-size: 12px; margin-left: 6px; display: inline; }
.panel input[type="range"], .panel select { width: 100%; min-width: 0; }
.panel select, .panel button { font: inherit; font-size: 13px; background: #131d2c; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; cursor: pointer; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.checks i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button.on { background: var(--accent); color: #06101f; border-color: var(--accent); font-weight: 600; }
.tip, .credit p { margin: 0; color: var(--dim); font-size: 12px; line-height: 1.5; }

@media (max-width: 900px) {
  .wrap { grid-template-columns: 1fr; }
  .top h1 { font-size: 24px; }
}
