:root {
  --bg: #0f1115;
  --panel: #191c22;
  --line: #2a2e37;
  --text: #eef1f6;
  --muted: #97a0af;
  --primary: #ff5a8a;
  --primary-2: #ff85a8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
}
.app { width: 100%; max-width: 480px; padding: 20px 16px 40px; }

.screen { display: none; flex-direction: column; align-items: center; gap: 14px; }
.screen.active { display: flex; }
h2 { margin: 6px 0; font-size: 20px; }

/* 시작 화면 */
#screen-intro { justify-content: center; min-height: 70vh; text-align: center; }
.logo { font-size: 32px; margin: 0 0 4px; }
.intro-desc { color: var(--muted); line-height: 1.6; margin: 4px 0 8px; }

/* 카메라 */
.cam-wrap {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  border-radius: 16px; overflow: hidden; background: #000;
}
#video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); } /* 거울 모드 */
.countdown {
  position: absolute; inset: 0; margin: auto; width: 96px; height: 96px;
  display: grid; place-items: center; font-size: 56px; font-weight: 800;
  color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,.6);
}
.shot-count {
  position: absolute; top: 12px; right: 14px; padding: 4px 10px;
  background: rgba(0,0,0,.55); border-radius: 999px; font-size: 14px;
}
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.on { opacity: .9; transition: opacity .05s; }

/* 버튼 */
.btn {
  width: 100%; padding: 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel); color: var(--text);
  font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:disabled { background: #3a2b31; border-color: #3a2b31; color: var(--muted); cursor: not-allowed; }
.btn.ghost { background: transparent; }
.hint { color: var(--muted); font-size: 13px; text-align: center; }

/* 선택 그리드 */
.thumb-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%; }
.thumb {
  position: relative; padding: 0; border: 3px solid transparent;
  border-radius: 12px; overflow: hidden; background: #000; cursor: pointer; aspect-ratio: 4/3;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.selected { border-color: var(--primary); }
.thumb .badge {
  position: absolute; top: 6px; left: 6px; width: 26px; height: 26px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 14px;
}
.thumb:not(.selected) .badge { display: none; }
.bar { display: flex; align-items: center; gap: 12px; width: 100%; }
.counter { font-weight: 700; min-width: 54px; }

/* 프레임 미리보기 */
.frame-stage { width: 100%; display: flex; justify-content: center; }
.preview { width: 60%; max-width: 240px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.frame-opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.frame-opt {
  padding: 10px 6px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--text); font-size: 13px; cursor: pointer;
}
.frame-opt.active { border-color: var(--primary); color: var(--primary); }

/* 결과 */
.qr { width: 220px; height: 220px; border-radius: 12px; background: #fff; padding: 10px; }