/* 색·글자 토큰. 시안은 body[data-theme]로 바꾼다(a 밝은 유리 · b 어두운 먹색 · c 따뜻한 종이). */
:root {
  --bg: linear-gradient(160deg, #eef3fb 0%, #dfe9f7 55%, #e9f0fa 100%);
  --ink: #16202e; --ink-soft: #55637a;
  --card: rgba(255, 255, 255, 0.62); --card-line: rgba(255, 255, 255, 0.9); --card-shadow: 0 18px 50px rgba(40, 70, 120, 0.16);
  --field: rgba(255, 255, 255, 0.8); --field-line: rgba(22, 32, 46, 0.14);
  --accent: #2563eb; --accent-ink: #ffffff;
  --warn: #c2410c; --warn-soft: rgba(194, 65, 12, 0.1);
  --blur: 18px; --radius: 22px;
  --font: "Pretendard Variable", Pretendard, "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  /* 멀리서 보는 화면: 정상 · 교정 · 경고 */
  --far-ok: #0b6b47; --far-fix: #c97800; --far-warn: #b3201c; --far-ink: #ffffff;
}
body[data-theme="b"] {
  --bg: #0f1216; --ink: #eef1f4; --ink-soft: #98a2b0;
  --card: #181d24; --card-line: #262d37; --card-shadow: none;
  --field: #10141a; --field-line: #2c3440;
  --accent: #b6f24a; --accent-ink: #10140a; --warn: #ff8a5c; --warn-soft: rgba(255, 138, 92, 0.12);
  --blur: 0px; --radius: 14px;
  --far-ok: #0f1216; --far-fix: #7a4a00; --far-warn: #8e1512; --far-ink: #f4f7f9;
}
body[data-theme="c"] {
  --bg: #f5efe4; --ink: #24201a; --ink-soft: #6f6557;
  --card: #fffaf0; --card-line: #e6dcc8; --card-shadow: 0 2px 0 #e6dcc8;
  --field: #ffffff; --field-line: #d8ccb4;
  --accent: #b4532a; --accent-ink: #fffaf0; --warn: #a3271f; --warn-soft: rgba(163, 39, 31, 0.08);
  --blur: 0px; --radius: 10px;
  --far-ok: #2f5d50; --far-fix: #b8862b; --far-warn: #a3271f; --far-ink: #fffaf0;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); background-attachment: fixed; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

/* ── 가까이 보는 화면 */
.screen.near { min-height: 100%; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.screen.overlay { position: fixed; inset: 0; overflow: auto; background: var(--bg); z-index: 5; }
.card { width: min(100%, 560px); background: var(--card); border: 1px solid var(--card-line); border-radius: var(--radius);
  box-shadow: var(--card-shadow); backdrop-filter: blur(var(--blur)) saturate(1.3); -webkit-backdrop-filter: blur(var(--blur)) saturate(1.3); padding: 26px 22px; }
h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 22px; margin: 0 0 14px; letter-spacing: -0.01em; }
.lead { margin: 0 0 20px; color: var(--ink-soft); line-height: 1.6; text-wrap: pretty; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.field { flex: 1 1 130px; display: grid; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.field input, .field select { font: inherit; font-size: 18px; color: var(--ink); background: var(--field); border: 1px solid var(--field-line); border-radius: 12px; padding: 12px; width: 100%; min-height: 50px; }
button { font: inherit; cursor: pointer; border-radius: 14px; min-height: 54px; padding: 12px 18px; font-size: 18px; font-weight: 650; border: 1px solid transparent; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.ghost { background: transparent; color: var(--ink); border-color: var(--field-line); }
.warn-btn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.link { background: none; min-height: 44px; font-size: 14px; font-weight: 500; color: var(--ink-soft); text-decoration: underline; padding: 8px; }
#start { margin-top: 6px; }
#setupCancel { margin-top: 14px; }
.notice { font-size: 14px; line-height: 1.55; padding: 12px 14px; border-radius: 12px; background: var(--field); border: 1px solid var(--field-line); margin: 12px 0 0; }
.notice.warn { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.fine { font-size: 13px; line-height: 1.55; color: var(--ink-soft); margin: 12px 0 0; }
.big-msg { font-size: 22px; font-weight: 650; line-height: 1.4; margin: 14px 0 4px; text-wrap: balance; }
.stage { position: relative; aspect-ratio: 16 / 9; background: #0b0e12; border-radius: 14px; overflow: hidden; }
.stage video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.list { list-style: none; margin: 12px 0 4px; padding: 0; display: grid; gap: 6px; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--field); border: 1px solid var(--field-line); font-size: 15px; font-variant-numeric: tabular-nums; }
.list li.sub { background: none; border-style: dashed; color: var(--ink-soft); font-size: 14px; }
.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.buttons .primary { grid-column: 1 / -1; }

.hidden-video { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: 0.01; pointer-events: none; }
.list.attempts li { font-size: 13px; padding: 7px 10px; }
.list.attempts li.bad { border-color: var(--warn); color: var(--warn); }
.diag { width: 100%; height: 120px; margin-top: 8px; font: 12px/1.4 ui-monospace, monospace; }

/* ── 운동 중 화면: 카메라 영상 + 뼈대, 큰 숫자, 테두리·아래 띠 색으로 상태 표시 */
.screen.far { position: fixed; inset: 0; background: #000; color: #fff; user-select: none; -webkit-user-select: none; cursor: pointer; overflow: hidden; }
.screen.far canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.screen.far::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 max(10px, 1.6vmin) var(--far-ok); transition: box-shadow 0.15s; }
.screen.far[data-level="fix"]::after { box-shadow: inset 0 0 0 max(14px, 2.4vmin) var(--far-fix); }
.screen.far[data-level="warn"]::after { box-shadow: inset 0 0 0 max(18px, 3.2vmin) var(--far-warn); }
.far-number { position: absolute; top: 2vmin; right: 5vmin; font-size: min(34vw, 40vh); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.75); }
.far-label { position: absolute; top: 4vmin; left: 5vmin; font-size: clamp(16px, 4vmin, 34px); font-weight: 650; background: rgba(0, 0, 0, 0.55); padding: 0.3em 0.7em; border-radius: 999px; }
.far-msg { position: absolute; left: 0; right: 0; bottom: 0; padding: 0.5em 1em calc(0.5em + env(safe-area-inset-bottom)); font-size: clamp(20px, 6vmin, 56px); font-weight: 750; text-align: center; text-wrap: balance; background: rgba(0, 0, 0, 0.6); min-height: 2em; }
.screen.far[data-level="fix"] .far-msg { background: var(--far-fix); }
.screen.far[data-level="warn"] .far-msg { background: var(--far-warn); }
.far-gauge { position: absolute; left: 3vmin; top: 22%; bottom: 22%; width: max(14px, 2.6vmin); border-radius: 999px; background: rgba(255, 255, 255, 0.25); overflow: hidden; display: flex; align-items: flex-end; }
.far-gauge > div { width: 100%; height: 0%; background: #ffffff; }
.far-gauge > div.reached { background: #34d399; }

@media (prefers-reduced-motion: reduce) { .screen.far::after { transition: none; } }
