/* PieceTracker - 퍼즐 매트의 짙은 초록을 기본색으로, 색은 진행도 지도에 양보하고 나머지는 조용하게 */
:root {
  --ink: #1E2421;       /* 글자 */
  --sub: #5B635E;       /* 보조 글자 */
  --mat: #2F4A3F;       /* 퍼즐 매트 초록: 상단 막대, 주 버튼 */
  --mat-ink: #F3F5F1;   /* 초록 위 글자 */
  --paper: #FAFAF7;     /* 바탕 */
  --line: #D9DDD8;      /* 선 */
  --signal: #C73E2C;    /* 찾은 자리 표시 */
  --ok-bg: #E3EFE6; --ok-ink: #24543B;
  --warn-bg: #F6EBD3; --warn-ink: #7A5410;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* 숨긴 요소는 다른 스타일(display:block 등)보다 우선해서 숨김 */
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body {
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 16px; line-height: 1.55;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bar {
  position: sticky; top: 0; z-index: 5;
  background: var(--mat); color: var(--mat-ink);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 12px; min-height: 48px;
}
.brand { font-weight: 700; letter-spacing: -0.01em; }
.back { background: none; border: 0; color: var(--mat-ink); font-size: 16px; padding: 4px 0; cursor: pointer; }
main { max-width: 540px; margin: 0 auto; padding: 20px 16px 40px; }
h1 { font-size: 26px; line-height: 1.3; margin: 4px 0 12px; letter-spacing: -0.02em; }
.lead { color: var(--sub); margin: 0 0 16px; }
.sub { color: var(--sub); font-size: 15px; margin: 0 0 8px; }
.hint { color: var(--sub); font-size: 14px; margin: 6px 0 16px; }
.warn { color: var(--warn-ink); font-size: 14px; margin: 4px 0; }
.field { display: block; font-size: 14px; color: var(--sub); margin-bottom: 14px; }
.field input {
  display: block; width: 100%; margin-top: 6px; font-size: 17px; padding: 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.notice { border-left: 3px solid var(--mat); padding: 2px 0 2px 12px; margin: 8px 0 18px; font-size: 14px; color: var(--sub); }
.notice p { margin: 0 0 6px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 15px; margin-top: 10px; }
.check input { width: 20px; height: 20px; }
button { font: inherit; cursor: pointer; }
.primary, .ghost {
  display: block; width: 100%; font-size: 17px; font-weight: 600; padding: 15px; border-radius: 12px; margin-top: 10px;
}
.primary { background: var(--mat); color: var(--mat-ink); border: 0; }
.ghost { background: #fff; color: var(--ink); border: 1px solid #B9BFBA; }
.small { font-size: 14px; padding: 10px 6px; border-radius: 10px; background: #fff; border: 1px solid var(--line); color: var(--ink); }
.link { display: block; margin: 18px auto 0; background: none; border: 0; color: var(--sub); text-decoration: underline; font-size: 14px; }
button:disabled { opacity: .35; cursor: default; }
button:focus-visible, input:focus-visible { outline: 3px solid #8FB3A3; outline-offset: 2px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 14px; }
.meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter div { height: 100%; width: 0; background: var(--mat); }
img.map { display: block; width: 100%; border-radius: 6px; margin: 14px 0 4px; background: #eee; }

/* 퍼즐 목록: 한 줄에 퍼즐 하나 */
.pz { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; color: var(--ink); }
.pz b { display: block; font-size: 17px; }
.pz span { color: var(--sub); font-size: 14px; }
.pz .meter { margin-top: 10px; }
.empty { color: var(--sub); padding: 18px 0; }

/* 결과 */
.chip { display: inline-block; font-size: 14px; font-weight: 600; padding: 3px 12px; border-radius: 99px; }
.chip.ok { background: var(--ok-bg); color: var(--ok-ink); }
.chip.maybe { background: var(--warn-bg); color: var(--warn-ink); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.pane { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; }
.pane img { display: block; width: 100%; border-radius: 6px; }
.pane p { margin: 6px 0 2px; font-size: 14px; }
.issues { padding-left: 20px; margin: 10px 0; }
.issues li { margin-bottom: 6px; }

/* 실시간 카메라 */
.cam { position: relative; border-radius: 10px; overflow: hidden; background: #111; aspect-ratio: 3 / 4; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame { position: absolute; left: 50%; top: 50%; width: 62%; aspect-ratio: 1; transform: translate(-50%, -50%);
  border: 3px dashed rgba(255, 255, 255, .9); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }

/* 등록: 귀퉁이 맞추기 */
#cv { display: block; width: 100%; touch-action: none; border-radius: 6px; background: #eee; }

#loading { position: fixed; inset: 0; z-index: 20; background: rgba(250, 250, 247, .94);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; }
#loading[hidden] { display: none; }
#loading p { margin: 4px 0; }
.spin { width: 40px; height: 40px; border: 4px solid var(--line); border-top-color: var(--mat); border-radius: 50%;
  animation: s 1s linear infinite; margin-bottom: 14px; }
@keyframes s { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }

/* 퍼즐 등록: 나눠 찍는 예시 */
.example { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; }
.example summary { font-size: 15px; font-weight: 600; cursor: pointer; padding: 4px 0; }
.example svg { display: block; width: 100%; max-width: 360px; margin: 8px auto 4px; }
.example ul { margin: 6px 0 4px; padding-left: 20px; font-size: 14px; color: var(--sub); }
.example li { margin-bottom: 4px; }
.example b { color: var(--ink); }

/* (v5.4) 확신 못할 때 다시 찍기 안내 */
.advice { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 14px; margin: 12px 0; }
.advice b { display: block; font-size: 16px; }
.advice p { margin: 4px 0 0; font-size: 15px; color: var(--ink); }
.advice .primary { margin-top: 12px; }
