/* 제발 한 번만 — 심플 디자인
   단색 배경 · 얇은 선 · 강조색(금색) 하나. 테마: 기본 다크, data-theme="light" 또는 시스템이 라이트면 라이트 */
:root {
  --bg: #12151f;
  --ink: #eceae4;
  --sub: #8b90a0;
  --line: rgba(255, 255, 255, .09);
  --accent: #e8b931;
  --accent-ink: #12151f;
  --accent-text: #e8b931;
  --surface: #1a1e2b;
  --backdrop: rgba(0, 0, 0, .6);
  --danger: #e5625d;
  --danger-fill: #c23a36;
  --hb-shadow: rgba(0, 0, 0, .28);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f7f5f0; --ink: #23211c; --sub: #736e64; --line: rgba(0, 0, 0, .09);
  --accent: #c99400; --accent-ink: #23211c; --accent-text: #8f6900; --danger: #c23a36; --surface: #ffffff; --backdrop: rgba(0, 0, 0, .35);
  --hb-shadow: rgba(0, 0, 0, .1);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f7f5f0; --ink: #23211c; --sub: #736e64; --line: rgba(0, 0, 0, .09);
    --accent: #c99400; --accent-ink: #23211c; --accent-text: #8f6900; --danger: #c23a36; --surface: #ffffff; --backdrop: rgba(0, 0, 0, .35);
    --hb-shadow: rgba(0, 0, 0, .1);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap {
  position: relative;
  max-width: 420px; min-height: 100vh; min-height: 100dvh; margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; text-align: center;
}

/* 위쪽: 업적(왼쪽) · 설정(오른쪽) */
.ach-btn, .set-btn {
  position: absolute; top: max(14px, env(safe-area-inset-top)); z-index: 2;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; height: 44px; padding: 0 6px;
  border: 0; background: none; color: var(--sub); cursor: pointer; font-size: 14px; font-variant-numeric: tabular-nums;
}
.ach-btn { left: 10px; }
.set-btn { right: 10px; }
.ach-btn svg, .set-btn svg { width: 20px; height: 20px; }
.ach-btn:hover, .set-btn:hover { color: var(--ink); }

/* BEST · TOTAL → 제목 */
.stats { align-self: stretch; display: flex; gap: 16px; justify-content: space-between; margin: 52px 2px 2px; font-size: 11px; letter-spacing: 1.5px; color: var(--sub); }
.stats b { margin-left: 5px; font-size: 14px; font-weight: 600; letter-spacing: 0; color: var(--ink); font-variant-numeric: tabular-nums; }
h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }

/* 카운트다운 */
.count {
  height: 52px; margin: 20px 0 4px; font-size: 40px; font-weight: 300; line-height: 52px;
  color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: 1px;
}

/* 가운데 동그란 버튼: 얇은 원 + 금빛 진행선(--p 0~1) */
.pray {
  position: relative; width: 216px; height: 216px; margin: 6px 0 14px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
.ring, .glow { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.ring {
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 360deg), var(--line) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
}
.glow { display: none; }
.face { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.label { font-size: 14px; font-weight: 500; line-height: 1.4; color: var(--sub); font-variant-numeric: tabular-nums; }
.label small { display: block; font-size: 12px; }
.pray.praying .label { color: var(--ink); }
.pray.cool { cursor: default; }
.pray.cool .char { opacity: .5; filter: grayscale(.6); }

/* 큰절 캐릭터 */
:root { --hb-top: #f2c94c; --hb-skirt: #e2647a; --hb-skirt2: #c24d62; --hb-hair: #2b2530; --hb-skin: #ffdcbd; }
.char { width: 104px; height: 97px; display: block; overflow: visible; }
.c-shadow { fill: var(--hb-shadow); }
.c-skirt { fill: var(--hb-skirt); }
.c-skirt-line { fill: none; stroke: var(--hb-skirt2); stroke-width: 1.4; stroke-linecap: round; }
.c-top { fill: var(--hb-top); }
.c-collar { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
.c-skin { fill: var(--hb-skin); }
.c-hair, .c-bun { fill: var(--hb-hair); }
.c-part { fill: none; stroke: #4a3f52; stroke-width: 1; stroke-linecap: round; }
.c-hairline { fill: none; stroke: rgba(255, 255, 255, .12); stroke-width: 1; }
.c-sleeve { fill: none; stroke: var(--hb-top); stroke-width: 7.5; stroke-linecap: round; }
.c-cuff { stroke: var(--hb-skirt); stroke-width: 7.5; stroke-linecap: butt; }
.c-seam { fill: none; stroke: rgba(0, 0, 0, .12); stroke-width: 1.2; stroke-linecap: round; }
.c-pin { stroke: #f2d27a; stroke-width: 2; stroke-linecap: round; }
.torso, .body, .upper { transform-box: view-box; transform-origin: 60px 86px; }
/* 누를 때마다 왼쪽 위(화면 안쪽)로 큰절 */
.pray.tap .torso { animation: bow .3s ease-in-out; }
.pray.tap .body { animation: bow-body .3s ease-in-out; }
.pray.tap .upper { animation: bow-upper .3s ease-in-out; }
@keyframes bow { 0%, 100% { transform: none; } 45%, 60% { transform: translate(-3px, 0) rotate(-20deg); } }
@keyframes bow-body { 0%, 100% { transform: none; } 45%, 60% { transform: scale(1.08, .72); } }
@keyframes bow-upper { 0%, 100% { transform: none; } 45%, 60% { transform: translate(-6px, 16px) scale(.85); } }
/* 절할 때 작은 빛 */
.sparks { position: absolute; left: 0; right: 0; top: 0; height: 60px; pointer-events: none; }
.sparks i { position: absolute; top: 30px; font-style: normal; font-size: 12px; color: var(--accent); animation: spark .9s ease-out forwards; }
@keyframes spark { from { transform: translate(0, 0) scale(.6); opacity: 0; } 20% { opacity: 1; } to { transform: translate(var(--dx), -42px) scale(1); opacity: 0; } }

/* 상태 안내 → 한마디 → NUMBERS → 번호 */
.msg { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.msg:empty { display: none; }
.msg small { display: block; margin-top: 2px; font-size: 13px; font-weight: 400; color: var(--sub); }
.msg > small:first-child { margin-top: 0; }
.word { margin: 18px 0 0; font-size: 14px; color: var(--sub); }
.word:empty { display: none; }
.num-head {
  align-self: stretch; margin: 22px 0 0; padding: 0 2px 8px; border-bottom: 1px solid var(--line);
  font-size: 11px; font-weight: 600; letter-spacing: 2px; color: var(--sub); text-align: left;
}
.num-head[hidden] { display: none; }
.log { list-style: none; margin: 0; padding: 0; width: 100%; }
.log:empty { display: none; }
.log li {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 2px 12px 18px; border-bottom: 1px solid var(--line);
}
.log li.today .ball { color: var(--accent-text); }
.ball {
  flex: 1; text-align: center; font-size: 19px; font-weight: 500; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ball.drop { animation: drop .5s ease-out both; }
@keyframes drop { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }
.star { position: absolute; left: 0; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--accent-text); }
.lock {
  flex: none; width: 44px; height: 44px; margin: -6px -6px -6px 2px; padding: 0; border: 0; border-radius: 10px;
  background: none; color: var(--sub); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.lock svg { width: 18px; height: 18px; }
.lock[aria-pressed="true"] { color: var(--accent-text); }

.foot { margin-top: auto; padding-top: 36px; font-size: 12px; color: var(--sub); }
.foot p { margin: 0; }

/* 페이지(업적·설정): 화면 전체 */
dialog.page {
  width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0;
  border: 0; border-radius: 0; overflow-y: auto; background: var(--bg); color: var(--ink); text-align: left;
}
dialog.page::backdrop { background: var(--bg); }
.page-in { max-width: 420px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom)); }
.page-head { position: relative; display: flex; align-items: center; justify-content: center; min-height: 44px; }
.page-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.back {
  position: absolute; left: -6px; top: 50%; transform: translateY(-50%);
  border: 0; border-radius: 8px; background: none; color: var(--sub); font-size: 14px; padding: 10px 6px; cursor: pointer;
}
.page-head h2:focus { outline: none; }

/* 업적 */
.ach-note { margin: 4px 0 8px; font-size: 12px; color: var(--sub); text-align: center; }
.ach-list { list-style: none; margin: 0; padding: 0; }
.ach-list li { padding: 9px 2px; border-bottom: 1px solid var(--line); color: var(--sub); }
.ach-list li:not(.got) .ach-tx b { font-size: 14px; font-weight: 400; }
.ach-list li.got { padding: 12px 2px; }
.ach-list li.got { color: var(--ink); }
.ach-list li.ach-sec { border: 0; padding: 24px 2px 6px; font-size: 12px; font-weight: 600; letter-spacing: 0; color: var(--sub); }
.ach-list li.ach-grp { border: 0; padding: 14px 2px 2px; font-size: 12px; color: var(--sub); }
.ach-list li.ach-empty { border: 0; font-size: 13px; }
.ach-top { display: flex; align-items: center; gap: 10px; }
.ach-ic { width: 16px; flex: none; text-align: center; font-size: 13px; }
.ach-list li.got .ach-ic { color: var(--accent-text); }
.ach-tx b { font-size: 15px; font-weight: 500; }
.ach-nums { display: flex; gap: 0; margin: 6px 0 0 26px; }
.ach-nums .ball { flex: none; width: 34px; text-align: left; font-size: 14px; color: var(--sub); }
.star-s { display: none; }

/* 설정 */
.set-sec { padding: 18px 0; border-bottom: 1px solid var(--line); }
.set-sec h3 { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: 0; color: var(--sub); }
.set-sec p { margin: 0 0 12px; font-size: 13px; color: var(--sub); }
.set-sec p.sw-note { margin: 8px 0 0; font-size: 12px; }
.seg3 { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg3 button { flex: 1; padding: 9px 0; border: 0; background: none; cursor: pointer; font-size: 14px; color: var(--sub); }
.seg3 button + button { border-left: 1px solid var(--line); }
.seg3 button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.sw-row { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 8px 0; font-size: 15px; cursor: pointer; }
.sw-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw-row i { position: relative; flex: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line); transition: background .2s; }
.sw-row i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s; }
.sw-row input:checked + i { background: var(--accent); }
.sw-row input:checked + i::after { transform: translateX(18px); }
.sw-row input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.danger {
  width: 100%; padding: 11px; border: 1px solid var(--danger); border-radius: 10px; cursor: pointer;
  background: none; color: var(--danger); font-size: 14px; font-weight: 600;
}
.set-foot { margin-top: 24px; text-align: center; font-size: 11px; color: var(--sub); }

/* 확인 창 */
.confirm {
  width: min(320px, calc(100vw - 48px)); padding: 22px 18px 16px; border: 0; border-radius: 16px;
  background: var(--surface); color: var(--ink); text-align: center;
}
.confirm::backdrop { background: var(--backdrop); }
.confirm h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.confirm p { margin: 0 0 18px; font-size: 13px; color: var(--sub); }
.cf-btns { display: flex; gap: 8px; }
.cf-btns button { flex: 1; width: auto; }
.cf-btns .danger { background: var(--danger-fill); border-color: var(--danger-fill); color: #fff; }
.cf-no { padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: none; cursor: pointer; font-size: 14px; }

@media (max-width: 360px) {
  .wrap { padding-left: 14px; padding-right: 14px; }
  .ball { font-size: 17px; }
  .pray { width: 196px; height: 196px; }
}
@media (prefers-reduced-motion: reduce) {
  .pray.tap .torso, .pray.tap .body, .pray.tap .upper, .sparks i, .ball.drop { animation: none; }
}

/* 검수 반영(2026-11-19): 준비 상태 강조 · 대기 중 카운트다운 흐리게 · 누른 횟수 · 오늘 줄 · 결과 강조 줄 */
.pray.ready .ring { background: conic-gradient(var(--accent) calc(var(--p, 0) * 360deg), color-mix(in srgb, var(--accent) 38%, transparent) 0); }
.pray.ready .label { color: var(--ink); }
.count { color: var(--sub); }
.count.live { color: var(--ink); }
.taps { height: 26px; margin: 0; font-size: 18px; font-weight: 600; line-height: 26px; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.msg small.hl { color: var(--accent-text); font-weight: 600; }
.log li.today { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.today-dot { position: absolute; left: 4px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--accent); }

/* 검수 P3 반영(2026-11-19) */
/* 15: 버튼 라벨은 늘 두 줄 높이 — 상태가 바뀌어도 캐릭터가 들썩이지 않게 */
.label { min-height: calc(2 * 1.4em); display: flex; flex-direction: column; justify-content: center; }
.label small { order: -1; }
/* 18: 잠긴 상태에서 눌렀을 때 안내 줄 깜빡임 */
.msg.nudge { animation: nudge .5s ease-in-out; }
@keyframes nudge { 0%, 100% { opacity: 1; } 30% { opacity: .25; } 60% { opacity: 1; } 80% { opacity: .5; } }
/* 22: 화면 읽기 전용 */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) { .msg.nudge { animation: none; } }
/* 업적 보너스 줄·업적 문구는 오늘 번호가 다 나온 뒤에 나타남(지연은 app.js BONUS_AT) */
.later { animation: later-in .35s ease-out both; }
@keyframes later-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .later { animation: none; } }

/* 통계 버튼(설정 왼쪽)·통계 페이지 */
.stat-btn {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 56px; z-index: 2;
  display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 44px; padding: 0 6px;
  border: 0; background: none; color: var(--sub); cursor: pointer;
}
.stat-btn svg { width: 20px; height: 20px; }
.stat-btn:hover { color: var(--ink); }
.stat-sum { margin: 8px 0 4px; text-align: center; font-size: 13px; color: var(--sub); }
.stat-sum b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-sec { padding: 16px 0; border-bottom: 1px solid var(--line); }
.stat-sec h3 { margin: 0 0 10px; font-size: 12px; font-weight: 600; color: var(--sub); }
.stat-top { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; text-align: center; }
.stat-top b { display: block; font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }
.stat-top small { font-size: 11px; color: var(--sub); }
.stat-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.stat-cell {
  display: flex; flex-direction: column; align-items: center; justify-content: center; aspect-ratio: 1; border-radius: 8px;
  background: color-mix(in srgb, var(--accent) calc(var(--k, 0) * 55%), transparent);
  border: 1px solid var(--line);
}
.stat-cell b { font-size: 14px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-cell small { font-size: 10px; color: color-mix(in srgb, var(--ink) 72%, transparent); line-height: 1.1; font-variant-numeric: tabular-nums; }

/* 2차 검수 반영(2026-11-19) */
/* P2-1: 누를 수 있을 때 링이 가장 또렷 — 준비 = 금색 가득·조금 굵게, 잠금 = 조용한 선 */
.pray.ready .ring {
  background: var(--accent-text);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
}
.pray.locked .ring { background: var(--line); }
/* P3: 쿨타임 남은 초 크게 */
.label .big { font-size: 22px; font-weight: 500; line-height: 1.2; color: var(--ink); }
/* P3: 라이트에서도 보이게 — 오늘 줄 점·포커스 테두리는 글자용 금색 */
.today-dot { background: var(--accent-text); }
:focus-visible { outline-color: var(--accent-text); }
.sw-row input:focus-visible + i { outline-color: var(--accent-text); }
/* P2-2·3: 통계 안내 */
.stat-note { margin: 0 0 4px; text-align: center; font-size: 12px; color: var(--sub); }
.stat-few { margin: 16px 0 0; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; font-size: 13px; color: var(--sub); }
.stat-few[hidden], .stat-sec[hidden] { display: none; }
/* P2-4: 다크 통계 칸은 금색을 옅게(최대 40%), 횟수는 본문색 11px */
.stat-cell small { font-size: 11px; color: var(--ink); }
:root:not([data-theme="light"]) .stat-cell { background: color-mix(in srgb, var(--accent) calc(var(--k, 0) * 40%), transparent); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .stat-cell { background: color-mix(in srgb, var(--accent) calc(var(--k, 0) * 55%), transparent); } }
:root[data-theme="light"] .stat-cell small { color: color-mix(in srgb, var(--ink) 72%, transparent); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .stat-cell small { color: color-mix(in srgb, var(--ink) 72%, transparent); } }
