:root {
  --bg: #0b0a0d;
  --glass: rgba(18, 16, 15, 0.55);
  --line: rgba(255, 240, 220, 0.16);
  --text: #f1e9de;
  --dim: rgba(241, 233, 222, 0.6);
  --warm: #ffd7a0;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased; touch-action: none; user-select: none; -webkit-user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; cursor: grab; }
#c:active { cursor: grabbing; }

.pill { position: fixed; z-index: 5; display: flex; align-items: center; gap: 4px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 999px;
  -webkit-backdrop-filter: blur(14px) saturate(1.1); backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.35); }
.pill.tl { top: calc(20px + var(--safe-t)); left: 74px; padding: 10px 18px 10px 16px; gap: 9px; font-size: 15px; }
.pill.tl b { font-weight: 650; letter-spacing: 0.02em; }
.pill.tl .sep { width: 1px; height: 13px; background: var(--line); }
.pill.tr { top: calc(20px + var(--safe-t)); right: 20px; padding: 5px 8px; }
.pill button { background: none; border: 0; color: var(--text); font: inherit; display: flex; align-items: center; gap: 7px;
  padding: 8px 11px; border-radius: 999px; cursor: pointer; font-size: 14px; }
.pill button:hover { background: rgba(255, 255, 255, 0.06); }
.pill button:focus-visible { outline: 1px solid var(--warm); }
.dim { color: var(--dim); font-size: 13px; }
.small { font-size: 12px; line-height: 1.6; }

.ico { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ico.big { width: 23px; height: 23px; }
#sound .off-ico { display: none; }
#sound.muted .on-ico { display: none; }
#sound.muted .off-ico { display: block; }
#count { font-weight: 600; min-width: 1ch; }

.pill.bottom { left: 50%; transform: translateX(-50%); bottom: calc(22px + var(--safe-b)); padding: 7px 14px; gap: 10px; }
.pill.bottom button { flex-direction: column; gap: 5px; padding: 9px 22px 7px; font-size: 12.5px; color: var(--dim); white-space: nowrap; }
.pill.bottom button.on { color: var(--warm); }
.pill.bottom button:active { transform: scale(0.96); }

.panel { position: fixed; z-index: 6; top: calc(78px + var(--safe-t)); right: 20px; width: 264px; padding: 16px 18px;
  background: rgba(16, 14, 13, 0.82); border: 1px solid var(--line); border-radius: 18px;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); font-size: 13.5px; }
.panel h3 { margin: 4px 0 10px; font-size: 12px; font-weight: 600; color: var(--dim); letter-spacing: 0.08em; }
.panel h3 + label, .panel label + label { margin-top: 8px; }
.panel label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.panel input[type=range] { width: 140px; accent-color: #d9a868; }
.panel select { background: #1d1a18; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font: inherit; }
.panel p { margin: 6px 0; }
.panel .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip { background: #1d1a18; color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.chip.on { border-color: var(--warm); color: var(--warm); }
[hidden] { display: none !important; }

#toast { position: fixed; z-index: 7; left: 50%; top: calc(110px + var(--safe-t)); transform: translate(-50%, -6px);
  max-width: min(520px, calc(100vw - 40px)); padding: 13px 22px; border-radius: 999px; text-align: center;
  background: rgba(18, 16, 15, 0.7); border: 1px solid var(--line); font-size: 14px; line-height: 1.5;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  opacity: 0; pointer-events: none; transition: opacity 0.5s, transform 0.5s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#hint { position: fixed; z-index: 4; left: 50%; bottom: calc(108px + var(--safe-b)); transform: translateX(-50%);
  font-size: 13px; color: var(--dim); white-space: nowrap; transition: opacity 1.2s; text-shadow: 0 1px 8px #000; }
#hint.gone { opacity: 0; pointer-events: none; }
#prayText { position: fixed; z-index: 4; left: 50%; bottom: calc(112px + var(--safe-b)); transform: translateX(-50%); font-size: 14px; letter-spacing: 0.3em;
  color: rgba(255, 228, 190, 0.75); opacity: 0; transition: opacity 2.5s; pointer-events: none; text-shadow: 0 0 18px rgba(0,0,0,0.9); }
#prayText.show { opacity: 1; }

#loading { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: #070607; transition: opacity 1.4s; }
#loading.done { opacity: 0; pointer-events: none; }
.loading-inner { text-align: center; color: var(--dim); font-size: 14px; letter-spacing: 0.25em; }
.loading-inner .flame { width: 10px; height: 22px; margin: 0 auto 22px; border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%;
  background: radial-gradient(ellipse at 50% 70%, #fff6dc 0%, #ffc56a 45%, rgba(255, 120, 20, 0) 75%);
  box-shadow: 0 0 30px 8px rgba(255, 170, 70, 0.25); animation: flick 1.6s ease-in-out infinite; }
@keyframes flick { 0%,100% { transform: scale(1, 1); } 40% { transform: scale(0.92, 1.08); } 70% { transform: scale(1.05, 0.95); } }
#guide { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px;
  background: rgba(6, 5, 6, 0.55); }
#guide[hidden] { display: none; }
.guide-card { width: min(420px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 26px 26px 18px;
  background: rgba(18, 16, 15, 0.88); border: 1px solid var(--line); border-radius: 22px; text-align: center;
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.guide-card h2 { margin: 0 0 6px; font-size: 19px; font-weight: 650; color: var(--warm); letter-spacing: 0.04em; }
.guide-card ol { list-style: none; margin: 18px 0 20px; padding: 0; text-align: left; display: grid; gap: 10px; }
.guide-card li { display: grid; grid-template-columns: 72px 1fr; gap: 10px; font-size: 13.5px; line-height: 1.5; }
.guide-card li b { color: var(--text); font-weight: 600; }
.guide-card li span { color: var(--dim); }
#guideClose { width: 100%; padding: 12px; border-radius: 999px; border: 1px solid rgba(255, 215, 160, 0.4);
  background: rgba(255, 215, 160, 0.14); color: var(--warm); font: inherit; font-size: 15px; cursor: pointer; }
#guideClose:hover { background: rgba(255, 215, 160, 0.22); }
.guide-card .small { margin: 12px 0 0; font-size: 12px; }
.roundbtn { position: fixed; z-index: 5; top: calc(20px + var(--safe-t)); left: 20px; width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--line); border-radius: 50%; color: var(--text); cursor: pointer;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.roundbtn:hover { background: rgba(255, 255, 255, 0.08); }
#bye { position: fixed; inset: 0; z-index: 12; display: grid; place-items: center; padding: 16px; background: rgba(6, 5, 6, 0.78);
  animation: byeIn 1.2s ease; }
#bye[hidden] { display: none; }
#bye .guide-card p { margin: 10px 0; }
#byeBack { width: 100%; margin-top: 14px; padding: 12px; border-radius: 999px; border: 1px solid rgba(255, 215, 160, 0.4);
  background: rgba(255, 215, 160, 0.14); color: var(--warm); font: inherit; font-size: 15px; cursor: pointer; }
@keyframes byeIn { from { opacity: 0; } to { opacity: 1; } }
.nojs { position: fixed; inset: 0; display: grid; place-items: center; }

/* 함께 있는 사람 목록 */
#peopleList { list-style: none; margin: 8px 0; padding: 0; max-height: 220px; overflow-y: auto; display: grid; gap: 4px; }
#peopleList li { font-size: 13px; color: var(--text); display: flex; justify-content: space-between; gap: 8px; }
#peopleList li .dim { font-size: 11.5px; }

/* 왼쪽 위: 기도 안내 + 남들의 소식 */
#feed { position: fixed; z-index: 4; top: calc(76px + var(--safe-t)); left: 20px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  max-width: min(360px, calc(100vw - 40px)); pointer-events: none; }
#prayerBar { padding: 7px 13px; border-radius: 999px; font-size: 12.5px; color: var(--dim);
  background: rgba(18, 16, 15, 0.5); border: 1px solid var(--line); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
#prayerBar.live { color: var(--warm); border-color: rgba(255, 215, 160, 0.35); }
#notice { padding: 6px 13px; border-radius: 999px; font-size: 12.5px; color: rgba(241, 233, 222, 0.82);
  background: rgba(18, 16, 15, 0.42); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  opacity: 0; transform: translateY(-4px); transition: opacity 0.9s, transform 0.9s; }
#notice.show { opacity: 1; transform: none; }

/* 묵주 */
#rosary { position: fixed; inset: 0; z-index: 15; background: radial-gradient(ellipse at 50% 45%, rgba(40, 28, 20, 0.86), rgba(6, 5, 6, 0.95) 70%);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); touch-action: none; }
#rosary canvas { position: absolute; inset: 0; display: block; cursor: grab; }
.rosary-close { position: absolute; top: calc(20px + var(--safe-t)); right: 20px; width: 44px; height: 44px; border-radius: 999px; display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--line); color: var(--text); cursor: pointer; }
.rosary-info { position: absolute; left: 50%; bottom: calc(70px + var(--safe-b)); transform: translateX(-50%); text-align: center; display: grid; gap: 4px; pointer-events: none; }
.rosary-info b { font-size: 20px; font-weight: 600; letter-spacing: 0.06em; color: var(--warm); font-variant-numeric: tabular-nums; }
.rosary-info span { font-size: 13px; color: var(--dim); transition: color 0.6s; }
.rosary-info span.glow { color: var(--warm); }
.rosary-hint { position: absolute; left: 0; right: 0; bottom: calc(28px + var(--safe-b)); margin: 0; text-align: center; font-size: 12px; color: rgba(241, 233, 222, 0.4); pointer-events: none; }

@media (max-width: 600px) {
  .roundbtn { top: calc(14px + var(--safe-t)); left: 14px; width: 40px; height: 40px; }
  .pill.tl { top: calc(14px + var(--safe-t)); left: 62px; padding: 8px 14px; font-size: 14px; }
  .pill.tl #sub, .pill.tl .sep { display: none; }
  .pill.tr { top: calc(14px + var(--safe-t)); right: 14px; padding: 3px 4px; }
  .pill.tr button { padding: 7px 8px; }
  .panel { top: calc(66px + var(--safe-t)); right: 14px; left: 14px; width: auto; }
  .pill.bottom { bottom: calc(18px + var(--safe-b)); padding: 5px 8px; gap: 4px; }
  .pill.bottom button { padding: 8px 18px 6px; }
  #hint { white-space: normal; width: calc(100vw - 48px); text-align: center; bottom: calc(100px + var(--safe-b)); }
  #toast { top: calc(120px + var(--safe-t)); border-radius: 18px; }
  #feed { top: calc(64px + var(--safe-t)); left: 14px; max-width: calc(100vw - 28px); }
  .pill.bottom button { padding: 8px 14px 6px; }
  .rosary-close { top: calc(14px + var(--safe-t)); right: 14px; }
}

/* 아주 좁은 휴대폰(≤430px): 성당 이름이 오른쪽 버튼에 가리지 않게 */
@media (max-width: 430px) {
  .pill.tl { padding: 8px 12px; gap: 6px; font-size: 13px; }
  .pill.tr { padding: 2px 3px; gap: 0; }
  .pill.tr button { padding: 7px 6px; gap: 4px; }
}

/* 봉헌 초 클로즈업 동안 화면 장식을 잠시 걷는다 */
body.closeup header.pill, body.closeup nav.pill, body.closeup #feed, body.closeup #hint, body.closeup #toast { opacity: 0; pointer-events: none; transition: opacity 0.8s; }
header.pill, nav.pill { transition: opacity 0.8s; }

/* 방 고르기 — 방마다 인원, 눌러서 옮겨 간다 */
.rooms { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.rooms button { display: grid; gap: 2px; justify-items: center; padding: 7px 0 6px; border-radius: 12px; }
.rooms button b { font-size: 13px; font-weight: 600; }
.rooms button span { font-size: 11px; color: var(--dim); }
.rooms button.on span { color: var(--warm); }
.rooms button:disabled { opacity: 0.45; cursor: default; }
