/* 예배당 — 말씀과 빛
   디자이너 시안의 상아·오크·꿀빛·청록, 아치창 모양을 화면 문법으로 쓴다. */
:root {
  --ivory: #f3ecde;
  --paper: #fbf7ef;
  --paper-a: rgba(251, 247, 239, 0.9);
  --oak: #b98a5a;
  --oak-deep: #7a5434;
  --honey: #ad793d;
  --honey-soft: #f1dfc0;
  --teal: #496a64;
  --teal-soft: #dde6e2;
  --ink: #2e2a25;
  --sub: #7a7166;
  --line: rgba(46, 42, 37, 0.12);
  --shadow: 0 10px 30px rgba(60, 42, 24, 0.16);
  --arch: 999px 999px 18px 18px;
  --serif: "Noto Serif KR", "Nanum Myeongjo", serif;
  --sans: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ivory); color: var(--ink); font-family: var(--sans); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

.paper {
  background: var(--paper-a); border: 1px solid rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: var(--shadow);
}

/* ── 머리띠 ── */
.crown {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 8px;
  background: var(--paper-a); border: 1px solid rgba(255, 255, 255, 0.7); border-radius: 16px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: var(--shadow);
  white-space: nowrap;
}
.crown-logo { width: 28px; height: 28px; border-radius: 8px; }
.crown-name { font-family: var(--serif); font-weight: 600; font-size: 16px; letter-spacing: 0.08em; margin: 0 6px 0 2px; }
.crown-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 10px;
  font-size: 13px; color: var(--teal); background: var(--teal-soft);
}
.crown-chip:hover { filter: brightness(0.97); }
.swatch { width: 12px; height: 12px; border-radius: 6px 6px 2px 2px; background: var(--honey); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8); }
.swatch.dawn { background: linear-gradient(180deg, #8ea0cf, #e7d9d2); }
.swatch.day { background: linear-gradient(180deg, #f2cf7a, #fff3d8); }
.swatch.evening { background: linear-gradient(180deg, #c9874a, #f0c98e); }
#peopleCount { font-weight: 700; font-variant-numeric: tabular-nums; }

.light-pop {
  position: absolute; top: calc(max(14px, env(safe-area-inset-top)) + 54px); left: 50%; transform: translateX(-50%);
  z-index: 8; width: min(440px, calc(100vw - 32px)); padding: 16px; border-radius: 20px;
  background: var(--paper); box-shadow: var(--shadow); animation: drop .25s ease;
}
.pop-title { margin: 0 0 12px; font-family: var(--serif); font-size: 15px; }
.light-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.light-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px 12px;
  border-radius: var(--arch); border: 1.5px solid transparent; background: #fff; text-align: center;
}
.light-opt .sky { width: 100%; aspect-ratio: 1 / 1.05; border-radius: var(--arch); }
.light-opt b { font-size: 14px; font-weight: 600; }
.light-opt small { font-size: 11px; color: var(--sub); line-height: 1.4; }
.light-opt[aria-checked="true"] { border-color: var(--teal); background: var(--teal-soft); }
.light-list.compact .light-opt { padding: 8px 6px 10px; }
.light-list.compact .light-opt small { display: none; }
.light-list.compact .sky { aspect-ratio: 1.45; }
.sky.dawn { background: linear-gradient(180deg, #8ea0cf 0%, #c9c6e3 55%, #f3e3d6 100%); }
.sky.day { background: linear-gradient(180deg, #f6e6bf 0%, #fff6e2 60%, #f3ecde 100%); }
.sky.evening { background: linear-gradient(180deg, #c9874a 0%, #e9b878 50%, #f6dfba 100%); }

.ribbon {
  position: absolute; top: calc(max(14px, env(safe-area-inset-top)) + 54px); left: 50%; transform: translateX(-50%); z-index: 4;
  font-size: 12px; color: var(--paper); background: rgba(73, 106, 100, 0.86); padding: 6px 14px; border-radius: 0 0 12px 12px;
  white-space: nowrap;
}
.ribbon-note { display: inline-block; animation: sway 1.6s ease-in-out infinite; }

/* ── 오른쪽 도구 ── */
.rail {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%); z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px;
  background: var(--paper-a); border: 1px solid rgba(255, 255, 255, 0.7); border-radius: 999px 999px 22px 22px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.rail-btn {
  width: 52px; padding: 7px 0 6px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; color: var(--sub);
}
.rail-btn svg { width: 21px; height: 21px; color: var(--ink); }
.rail-btn:first-child { padding-top: 12px; border-radius: 999px 999px 14px 14px; }
.rail-btn:hover { background: rgba(46, 42, 37, 0.05); }
.rail-btn[aria-pressed="true"] { background: var(--teal); color: var(--paper); }
.rail-btn[aria-pressed="true"] svg { color: var(--paper); }
.rail-sep { width: 22px; height: 1px; background: var(--line); margin: 4px 0; }
#icoSound .on { display: none; }
#icoSound.is-on .on { display: inline; }
#icoSound.is-on .off { display: none; }

/* ── 알림 · 안내 ── */
.note {
  position: absolute; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 178px); transform: translate(-50%, 6px);
  z-index: 29; padding: 10px 16px; border-radius: 12px; font-size: 13.5px;
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow); border-left: 3px solid var(--honey);
  max-width: calc(100vw - 32px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; pointer-events: none; transition: opacity .35s, transform .35s;
}
.note.show { opacity: 1; transform: translate(-50%, 0); }

.hint {
  position: absolute; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 124px); transform: translateX(-50%);
  font-size: 12px; color: var(--ink); background: rgba(251, 247, 239, 0.72); padding: 7px 14px; border-radius: 10px;
  white-space: nowrap; pointer-events: none; transition: opacity .8s; z-index: 4;
}
.hint.gone { opacity: 0; }

.seat-btn {
  position: absolute; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 122px); transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 16px; z-index: 6;
  border-radius: 12px; font-size: 14px; font-weight: 600; color: var(--paper); background: var(--teal);
  box-shadow: var(--shadow); animation: rise .25s cubic-bezier(.2,.8,.2,1);
}
/* ── 키보드 안내 ── */
.keys {
  position: absolute; right: 16px; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 5;
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 16px;
  background: var(--paper-a); border: 1px solid rgba(255, 255, 255, 0.7); box-shadow: var(--shadow);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-size: 12px; color: var(--sub);
}
.keys kbd {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px;
  font: 700 11px var(--sans); color: var(--ink); background: #fff; box-shadow: 0 2px 0 var(--line), 0 0 0 1px var(--line);
}
.keycaps { display: grid; grid-template-columns: repeat(3, 24px); gap: 3px; }
.keycaps .w { grid-column: 2; grid-row: 1; }
.keycaps kbd:not(.w) { grid-row: 2; }
.keys-label { margin-right: 4px; }
@media (hover: none), (pointer: coarse) { .keys { display: none; } }

.seat-btn kbd { font: 600 11px var(--sans); color: var(--teal); background: var(--paper); border-radius: 5px; padding: 2px 6px; }
@media (hover: none) { .seat-btn kbd { display: none; } .seat-btn { padding: 0 18px; } }

/* ── 펼친 성경 탭 ── */
.book-tab {
  position: absolute; left: 16px; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: 64px; height: 76px; border-radius: 8px 14px 14px 8px; color: var(--paper);
  background: linear-gradient(90deg, #3c5853 0 7px, var(--teal) 7px);
  box-shadow: var(--shadow), inset -3px 0 0 rgba(255, 255, 255, 0.18);
  font-family: var(--serif); font-size: 13px;
}
.book-tab svg { width: 28px; height: 22px; stroke-width: 1.5; }

/* ── 기도 아치 ── */
.prayer {
  position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 5;
  display: grid; grid-template-columns: 62px 96px 62px; align-items: end; gap: 10px;
}
.pray-side, .pray-main {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--paper-a); border: 1px solid rgba(255, 255, 255, 0.7); box-shadow: var(--shadow);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: transform .15s, background .2s;
}
.pray-side { position: relative; height: 66px; border-radius: var(--arch); font-size: 12px; color: var(--sub); margin-bottom: 4px; }
.pray-side .emo { font-size: 20px; }
.pray-main { position: relative; height: 104px; border-radius: var(--arch); }
.pray-main .emo { font-size: 30px; margin-top: 6px; }
.pray-label { font-family: var(--serif); font-size: 15px; font-weight: 600; }
.pray-main .ring { position: absolute; inset: 4px auto auto 50%; width: 84px; height: 84px; transform: translateX(-50%) rotate(-90deg); }
.pray-side .ring { position: absolute; inset: 3px auto auto 50%; width: 52px; height: 52px; transform: translateX(-50%) rotate(-90deg); }
.ring circle { stroke: var(--honey); stroke-width: 4; stroke-dasharray: 289; stroke-dashoffset: 289; opacity: 0; }
.praying .ring circle { opacity: 1; animation: fill-ring var(--dur, 3.6s) linear forwards; }
.pray-side:active, .pray-main:active { transform: scale(0.96); }
.pray-side.on, .pray-main.on { background: var(--honey-soft); }

/* ── 펼친 성경 ── */
.book-wrap {
  position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(90% 70% at 50% 45%, rgba(46, 34, 22, 0.35), rgba(30, 22, 14, 0.72));
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .35s ease;
  padding: 16px;
}
.book {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; width: min(760px, 100%); aspect-ratio: 1.55;
  max-height: calc(100dvh - 110px); perspective: 1600px;
  filter: drop-shadow(0 24px 40px rgba(20, 12, 4, 0.45));
}
.page {
  position: relative; display: flex; flex-direction: column; padding: clamp(18px, 4vw, 42px) clamp(18px, 3.6vw, 40px) 18px;
  background: var(--paper) url("assets/paper.jpg") center / cover;
}
.page.left { border-radius: 14px 4px 4px 14px; box-shadow: inset -26px 0 30px -22px rgba(80, 55, 30, 0.45); }
.page.right { border-radius: 4px 14px 14px 4px; box-shadow: inset 26px 0 30px -22px rgba(80, 55, 30, 0.45); }
.page-kicker { font-size: 12px; letter-spacing: 0.18em; color: var(--honey); }
.page-ref { margin: auto 0 6px; font-family: var(--serif); font-weight: 600; font-size: clamp(22px, 3.4vw, 32px); line-height: 1.35; word-break: keep-all; }
.page-ver { font-size: 11px; color: var(--sub); margin-bottom: auto; line-height: 1.5; }
.page-text {
  margin: auto 0; font-family: var(--serif); font-size: clamp(16px, 2.2vw, 20px); line-height: 1.9; color: var(--ink); word-break: keep-all;
}
.page-text::first-letter { font-size: 2.1em; color: var(--teal); float: left; line-height: 1; margin: 0.12em 0.12em 0 0; }
.page-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.folio { font-family: var(--serif); font-size: 12px; color: var(--sub); }
.page-link { font-size: 13px; color: var(--sub); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.page-link.strong { color: var(--teal); font-weight: 600; text-decoration-color: var(--teal); }
.only-narrow { display: none; }
.turn {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 50%; transform-origin: left center; border-radius: 4px 14px 14px 4px;
  background: var(--paper) url("assets/paper.jpg") center / cover; opacity: 0; pointer-events: none;
  box-shadow: inset 20px 0 30px -18px rgba(80, 55, 30, 0.5);
}
.turn.go { animation: page-turn .62s cubic-bezier(.45,.05,.3,1) forwards; }
.turn.back { animation: page-back .62s cubic-bezier(.45,.05,.3,1) forwards; }
.book-close {
  height: 40px; padding: 0 20px; border-radius: 12px; font-size: 14px; color: var(--paper);
  border: 1px solid rgba(251, 247, 239, 0.5);
}
.book-close:hover { background: rgba(251, 247, 239, 0.12); }

/* ── 시트 ── */
.sheet-dim { position: absolute; inset: 0; background: rgba(30, 22, 14, 0.28); z-index: 30; animation: fade .25s; }
.sheet {
  position: absolute; z-index: 31; right: 16px; top: max(16px, env(safe-area-inset-top)); max-height: calc(100dvh - 32px);
  width: min(380px, calc(100vw - 32px)); overflow: auto; background: var(--paper);
  border-radius: 22px; padding: 20px 22px 22px; box-shadow: var(--shadow);
  animation: slide .3s cubic-bezier(.2,.8,.2,1);
}
.sheet header { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 600; }
.sheet .x { width: 32px; height: 32px; border-radius: 50%; font-size: 22px; color: var(--sub); }
.sheet .x:hover { background: var(--line); }
.sheet-desc { margin: 8px 0 16px; font-size: 13.5px; color: var(--sub); line-height: 1.6; }
.people-list { list-style: none; margin: 0; padding: 0; }
.people-list li { display: flex; align-items: center; gap: 12px; padding: 10px 2px; font-size: 14px; border-bottom: 1px solid var(--line); }
.people-list .dot-c { width: 26px; height: 30px; border-radius: 13px 13px 5px 5px; flex: none; }
.people-list .st { margin-left: auto; font-size: 12px; color: var(--sub); }
.people-list .me { color: var(--teal); font-weight: 600; }
.field { display: grid; gap: 8px; margin-top: 18px; font-size: 13px; color: var(--sub); }
.name-row { display: flex; gap: 8px; }
.name-row input { flex: 1; min-width: 0; height: 42px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 0 12px; font: inherit; font-size: 15px; color: var(--ink); }
.soft-btn { height: 42px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 14px; }
.seg { display: flex; background: var(--line); padding: 3px; border-radius: 12px; }
.seg button { flex: 1; height: 36px; border-radius: 10px; font-size: 14px; color: var(--sub); }
.seg button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
input[type="range"] { accent-color: var(--teal); }

/* ── 들어가는 문 ── */
.door {
  position: absolute; inset: 0; z-index: 60; overflow-y: auto;
  background: radial-gradient(120% 80% at 30% 20%, #fbf5e9 0%, var(--ivory) 55%, #ece2cf 100%);
}
.door-inner {
  min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: clamp(24px, 5vw, 72px);
  padding: clamp(24px, 6vh, 64px) clamp(20px, 6vw, 88px); max-width: 1180px; margin: 0 auto;
}
.door-arch {
  justify-self: end; width: min(420px, 100%); aspect-ratio: 3 / 4; border-radius: 999px 999px 20px 20px; overflow: hidden;
  border: 10px solid var(--paper); box-shadow: 0 30px 60px rgba(90, 60, 30, 0.22), 0 0 0 1px var(--line);
}
.door-arch img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; display: block; animation: breathe 12s ease-in-out infinite alternate; }
.door-copy { max-width: 440px; }
.door-kicker { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; letter-spacing: 0.24em; color: var(--teal); }
.door-kicker img { width: 26px; height: 26px; border-radius: 7px; }
.door h1 { margin: 10px 0 4px; font-family: var(--serif); font-weight: 600; font-size: clamp(40px, 6vw, 60px); letter-spacing: 0.14em; }
.door-greet { margin: 0 0 22px; font-size: 15px; color: var(--sub); }
.door-verse { margin: 0 0 24px; padding: 14px 0 14px 18px; border-left: 2px solid var(--honey); }
.door-verse blockquote { margin: 0; font-family: var(--serif); font-size: 16px; line-height: 1.8; word-break: keep-all; }
.door-verse figcaption { margin-top: 6px; font-size: 12px; color: var(--sub); }
.door-label { margin: 0 0 10px; font-size: 13px; color: var(--sub); }
.door-name { margin: 18px 0 0; font-size: 14px; color: var(--sub); }
.door-name b { color: var(--ink); }
.enter {
  margin-top: 18px; width: 100%; height: 54px; border-radius: 999px 999px 14px 14px;
  background: var(--teal); color: var(--paper); font-size: 16px; font-weight: 600; letter-spacing: 0.04em;
  box-shadow: 0 12px 26px rgba(73, 106, 100, 0.3);
}
.enter:disabled { background: #a7b6b2; box-shadow: none; cursor: progress; }

.leaves { position: absolute; inset: 0; z-index: 70; pointer-events: none; display: none; }
.leaves.on { display: block; }
.leaf {
  position: absolute; top: 0; bottom: 0; width: 50.5%;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,0.08) 0 2px, transparent 2px 46px),
    linear-gradient(180deg, #a77a4f, var(--oak-deep));
}
.leaf.l { left: 0; border-right: 2px solid #5a3c24; transform: translateX(-100%); }
.leaf.r { right: 0; border-left: 2px solid #5a3c24; transform: translateX(100%); }
.leaf::after { content: ""; position: absolute; top: 50%; width: 10px; height: 64px; border-radius: 5px; background: #d8b46e; transform: translateY(-50%); }
.leaf.l::after { right: 18px; }
.leaf.r::after { left: 18px; }
/* 문짝이 닫혔다가(0~30%) 잠깐 머문 뒤(30~42%) 양옆으로 열린다 */
.leaves.on .leaf.l { animation: leaf-l 1.7s cubic-bezier(.6,0,.3,1) forwards; }
.leaves.on .leaf.r { animation: leaf-r 1.7s cubic-bezier(.6,0,.3,1) forwards; }
@keyframes leaf-l { 0% { transform: translateX(-100%); } 30%, 42% { transform: none; } 100% { transform: translateX(-100%); } }
@keyframes leaf-r { 0% { transform: translateX(100%); } 30%, 42% { transform: none; } 100% { transform: translateX(100%); } }

/* ── 축도 ── */
.bless {
  position: absolute; inset: 0; z-index: 55; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 20px; text-align: center; overflow-y: auto;
  background: radial-gradient(70% 55% at 50% 30%, #fff8e6 0%, var(--ivory) 60%, #e8dcc6 100%); animation: fade .6s ease;
}
.bless-arch {
  width: min(400px, 100%); padding: 72px 30px 30px; border-radius: 999px 999px 22px 22px;
  background: linear-gradient(180deg, rgba(255, 244, 214, 0.9), var(--paper)); box-shadow: 0 0 0 1px var(--line), 0 24px 60px rgba(173, 121, 61, 0.22);
}
.bless .kicker { font-size: 12px; letter-spacing: 0.3em; color: var(--honey); }
.bless-text { margin: 14px 0 12px; font-family: var(--serif); font-size: 16px; line-height: 1.95; word-break: keep-all; }
.bless cite { font-style: normal; font-size: 12px; color: var(--sub); }
.bless .credit { display: block; margin-top: 4px; font-size: 10.5px; color: var(--sub); opacity: 0.8; }
.bless h2 { margin: 26px 0 4px; font-family: var(--serif); font-weight: 600; font-size: 26px; letter-spacing: 0.08em; }
.bless-sub { margin: 0; font-size: 13px; color: var(--sub); }
.bless .enter { width: min(280px, 100%); }

@keyframes fade { from { opacity: 0; } }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -6px); } }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } }
@keyframes sheet-up { from { opacity: 0; transform: translateY(28px); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes sway { 50% { transform: translateY(-2px) rotate(-8deg); } }
@keyframes breathe { to { transform: scale(1.06); } }
@keyframes fill-ring { 0% { stroke-dashoffset: 289; } 100% { stroke-dashoffset: 0; } }
@keyframes page-turn {
  0% { opacity: 1; transform: rotateY(0); }
  100% { opacity: 1; transform: rotateY(-180deg); }
}
@keyframes page-back {
  0% { opacity: 1; transform: rotateY(-180deg); }
  100% { opacity: 1; transform: rotateY(0); }
}

/* ── 좁은 화면 ── */
@media (max-width: 720px) {
  .door-inner { grid-template-columns: 1fr; gap: 18px; padding-top: max(20px, env(safe-area-inset-top)); }
  .door-inner { gap: 14px; padding-bottom: 0; }
  .door-arch { justify-self: center; width: min(196px, 52vw); border-width: 6px; }
  .door-copy { justify-self: center; width: 100%; }
  .door h1 { font-size: 34px; margin-top: 4px; }
  .door-greet { margin-bottom: 12px; }
  .door-verse { margin-bottom: 14px; padding: 8px 0 8px 14px; }
  .door-verse blockquote { font-size: 14.5px; line-height: 1.7; }
  .door-name { margin-top: 12px; }
  .door .enter {
    position: sticky; bottom: 0; margin: 12px 0 0; border-radius: 999px 999px 0 0;
    padding-bottom: env(safe-area-inset-bottom); height: calc(54px + env(safe-area-inset-bottom));
  }

  .book { grid-template-columns: 1fr; aspect-ratio: auto; height: min(560px, calc(100dvh - 110px)); width: min(420px, 100%); }
  .page.left { display: none; }
  .page.right { border-radius: 6px 14px 14px 6px; box-shadow: inset 18px 0 22px -16px rgba(80, 55, 30, 0.5); }
  .only-narrow { display: inline; }
  .page-ref-n { font-family: var(--serif); font-size: 14px; color: var(--sub); }
  .page-credit.only-narrow { display: block; margin-top: 2px; font-size: 10.5px; color: var(--sub); opacity: 0.8; }
  .turn { left: 0; width: 100%; border-radius: 6px 14px 14px 6px; }
}
@media (max-width: 520px) {
  .crown { gap: 4px; padding: 5px 5px 5px 6px; }
  .crown-name { font-size: 15px; margin: 0 2px; }
  .crown-chip { padding: 0 8px; font-size: 12px; }
  .rail { right: 10px; padding: 6px 4px; }
  .rail-btn { width: 46px; }
  .book-tab { width: 54px; height: 66px; left: 12px; font-size: 12px; }
  .prayer { grid-template-columns: 56px 84px 56px; gap: 8px; }
  .pray-main { height: 92px; }
  .pray-main .ring { width: 74px; height: 74px; }
  .hint { white-space: normal; width: calc(100vw - 48px); text-align: center; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 112px); }
  .seat-btn { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 110px); }
  .note { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 182px); }
  /* 휴대폰: 아래에서 올라오는 창, 손가락 크기 칸, 16px 이상 글씨(아이폰 확대 방지) */
  .sheet {
    left: 0; right: 0; top: auto; bottom: 0; width: 100%; max-height: 86dvh;
    border-radius: 22px 22px 0 0; padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
    animation: sheet-up .3s cubic-bezier(.2,.8,.2,1);
  }
  .sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 14px; }
  .sheet h2 { font-size: 20px; }
  .sheet .x { width: 40px; height: 40px; }
  .field { margin-top: 20px; font-size: 14px; }
  .name-row input { height: 50px; font-size: 16px; }
  .soft-btn { height: 50px; font-size: 15px; padding: 0 16px; }
  .seg button { height: 46px; font-size: 15px; }
  input[type="range"] { height: 32px; }
}
