/* 온라인 법당 — 지도는 전체 화면 캔버스, 조작판은 반투명 */
:root {
  --accent: #f0b878;
  --accent-ink: #1a1006;
  --text: #f4f1ea;
  --muted: rgba(244, 241, 234, .68);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #1b1f2a; color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all; overflow-wrap: anywhere;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.en-sub { display: block; font-size: .72em; color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); }

#stage { position: fixed; inset: 0; display: block; touch-action: none; }

.glassy, .bar .b, .pill, .dock, .join-card, .pop, .toast {
  background: rgba(14, 16, 24, .55);
  border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
}

.bar {
  position: fixed; z-index: 5; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .4), transparent);
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.bar h1 { flex: 1; min-width: 0; margin: 0; font-size: 16px; font-weight: 600; text-shadow: 0 1px 6px rgba(0, 0, 0, .55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar h1 .en-sub { display: inline; margin-left: 6px; }
.bar .b {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  height: 38px; min-width: 38px; padding: 0 11px; border-radius: 12px;
  color: var(--text); text-decoration: none; font-size: 14px; justify-content: center;
}
.pill {
  display: inline-flex; align-items: center; min-height: 30px; padding: 4px 12px; border-radius: 999px;
  font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.pill:empty { display: none; }
#status[data-kind="solo"] { border-color: rgba(240, 184, 120, .6); }
#status[data-kind="online"] { border-color: rgba(140, 220, 160, .55); }

/* 입장 */
.join {
  position: fixed; inset: 0; z-index: 6; overflow: auto;
  display: grid; place-items: center;
  padding: calc(64px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 40%, rgba(10, 12, 20, .35), rgba(10, 12, 20, .75));
}
.join-card {
  width: min(560px, 100%);
  display: grid; gap: 14px; justify-items: center; text-align: center;
  padding: 22px 18px; border-radius: 20px;
}
.eyebrow { margin: 0; font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--muted); }
.join-card h2 { margin: 0; font-size: clamp(19px, 4.6vw, 24px); font-weight: 600; }
.join-card h2 .en-sub { margin-top: 4px; font-size: .62em; }
.lead { margin: 0; font-size: 14px; line-height: 1.7; }
.lead .en-sub { margin-top: 4px; }
.chars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
@media (min-width: 520px) { .chars { grid-template-columns: repeat(6, 1fr); } }
.char {
  display: grid; justify-items: center; gap: 2px; padding: 6px 4px 8px;
  border-radius: 14px; border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .06); font-size: 13px;
}
.char canvas { width: 64px; height: 72px; }
.char[aria-pressed="true"] { border-color: var(--accent); background: rgba(240, 184, 120, .18); box-shadow: 0 0 0 3px rgba(240, 184, 120, .18); }
.name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.name-row .en-sub { display: inline; }
.name-row strong { font-size: 17px; }
.fine { margin: 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.fine .en-sub { margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 42px; padding: 8px 14px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .1);
  color: var(--text); font-size: 14px; text-decoration: none;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.btn:hover { background: rgba(255, 255, 255, .16); }
.btn .en-sub { display: inline; margin-left: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary .en-sub { color: rgba(26, 16, 6, .7); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: 13px; }
.btn.wide { width: min(100%, 320px); }
.btn[aria-pressed="true"] { border-color: var(--accent); background: rgba(240, 184, 120, .28); }
.btn.ctx { border-color: rgba(240, 184, 120, .7); background: rgba(240, 184, 120, .2); }
.btn:focus-visible, .char:focus-visible, .bar .b:focus-visible, .pop-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 조작판 */
.hud { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-left {
  position: fixed; top: calc(60px + env(safe-area-inset-top)); left: 12px;
  display: grid; gap: 6px; justify-items: start; max-width: calc(100% - 24px);
}
.pill-btn { color: var(--text); cursor: pointer; font: inherit; font-size: 13px; }
.pill-btn:hover { background: rgba(30, 34, 46, .7); }
.pill.music { max-width: min(320px, 70vw); overflow: hidden; text-overflow: ellipsis; display: block; line-height: 22px; }
.dock {
  position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(600px, calc(100% - 24px));
  display: grid; gap: 8px; justify-items: center;
  padding: 10px 12px; border-radius: 18px;
}
.row, .ctx-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ctx-row:empty { display: none; }
.pop {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  width: min(420px, calc(100vw - 24px));
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  padding: 10px; border-radius: 16px;
}
.pop-item {
  min-height: 44px; padding: 6px 10px; border-radius: 10px; text-align: left;
  border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .07); font-size: 14px;
}
.pop-item:hover { background: rgba(255, 255, 255, .14); }
.lantern-pop { grid-template-columns: repeat(6, 1fr); }
.lantern-item { display: grid; justify-items: center; gap: 2px; padding: 4px 2px; text-align: center; font-size: 12px; }
.lantern-item canvas { width: 36px; height: 44px; }
.toast {
  position: fixed; left: 50%; top: calc(108px + env(safe-area-inset-top));
  width: min(520px, calc(100% - 32px));
  padding: 10px 16px; border-radius: 14px; text-align: center; font-size: 14px; line-height: 1.55;
  transform: translate(-50%, -6px); opacity: 0; pointer-events: none !important;
  transition: opacity .6s, transform .6s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .en-sub { margin-top: 2px; }
.keys-hint {
  position: fixed; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); margin: 0;
  font-size: 11px; color: rgba(255, 255, 255, .7); text-shadow: 0 1px 4px rgba(0, 0, 0, .7);
  max-width: 220px; text-align: right; pointer-events: none !important;
}
@media (pointer: coarse), (max-width: 900px) { .keys-hint { display: none; } }

@media (max-width: 560px) {
  .hide-xs { display: none; }
  .dock { padding: 10px 8px; }
  .dock .row { gap: 6px; flex-wrap: nowrap; }
  .dock .row .btn { padding: 8px 10px; }
  .bar h1 .en-sub { display: none; }
  .btn .en-sub { display: none; }
  .bar h1 { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- 예불 순서 (주보) ---------- */
.yebul {
  position: fixed; z-index: 5; left: 50%; top: calc(60px + env(safe-area-inset-top));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px)); max-height: calc(100% - 250px); overflow: auto;
  padding: 12px 16px 14px; border-radius: 18px;
  background: rgba(24, 20, 16, .78); border: 1px solid rgba(240, 184, 120, .35);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
body.yebul-open .hud-left { display: none; }
body.yebul-open .toast { top: auto; bottom: calc(150px + env(safe-area-inset-bottom)); }
.y-head { display: flex; align-items: center; gap: 10px; }
.y-kicker { font-size: 12px; letter-spacing: .06em; color: var(--accent); white-space: nowrap; }
.y-dots { display: flex; gap: 4px; flex: 1; }
.y-dots span { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .18); }
.y-dots span.past { background: rgba(240, 184, 120, .55); }
.y-dots span.now { background: var(--accent); box-shadow: 0 0 0 3px rgba(240, 184, 120, .2); }
.y-close { border: 0; background: rgba(255, 255, 255, .08); color: var(--text); width: 30px; height: 30px; border-radius: 8px; }
.y-title { margin: 8px 0 4px; font-size: 19px; }
.y-title .hanja { font-weight: 400; color: var(--muted); font-size: .8em; }
.y-title .en-sub { display: inline; margin-left: 6px; font-size: .62em; }
.y-desc { margin: 0 0 8px; font-size: 14px; line-height: 1.65; }
.y-desc .en-sub { margin-top: 2px; }
.y-ok { margin: 6px 0; color: #a6dcb4; font-size: 14px; }
.y-lines { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 6px; }
.y-lines li { padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, .05); border: 1px solid transparent; transition: background .4s, border-color .4s; }
.y-lines li.now { background: rgba(240, 184, 120, .16); border-color: rgba(240, 184, 120, .55); }
.y-lines .chant { display: block; font-size: 17px; font-weight: 600; letter-spacing: .04em; }
.y-lines .hanja { font-weight: 400; color: var(--muted); font-size: .78em; }
.y-lines .mean { display: block; font-size: 14px; margin-top: 2px; }
.y-talk-title { margin: 4px 0 6px; font-size: 16px; }
.y-talk-title .en-sub { display: inline; margin-left: 6px; }
.y-talk p { margin: 0 0 6px; font-size: 14.5px; line-height: 1.7; padding: 2px 6px; border-radius: 6px; transition: background .4s; }
.y-talk p.now { background: rgba(240, 184, 120, .16); }
.y-timer { margin: 4px 0; font-size: 34px; font-variant-numeric: tabular-nums; text-align: center; letter-spacing: .06em; }
.y-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.chip { padding: 7px 11px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .06); color: var(--text); font-size: 13px; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: rgba(240, 184, 120, .25); }
.yebul textarea, .vow-form textarea {
  width: 100%; resize: vertical; min-height: 54px; padding: 8px 10px; border-radius: 10px;
  background: rgba(0, 0, 0, .3); border: 1px solid rgba(255, 255, 255, .18); color: #fff;
  font: inherit; font-size: 16px;
}
.yebul textarea:focus, .vow-form textarea:focus { outline: none; border-color: var(--accent); }
.y-actions { margin-top: 8px; }
.y-actions:empty { display: none; }
.y-nav { margin-top: 8px; justify-content: space-between; }
.btn.primary-soft { border-color: rgba(240, 184, 120, .7); background: rgba(240, 184, 120, .22); }

/* ---------- 창(시트) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 7; background: rgba(6, 8, 14, .45); }
.sheet {
  position: fixed; z-index: 8; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px)); max-height: min(78vh, calc(100% - 80px)); overflow: auto;
  padding: 14px 16px 16px; border-radius: 20px;
  background: rgba(22, 24, 34, .92); border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
  display: grid; gap: 12px;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-head h2 .en-sub { display: inline; margin-left: 6px; }
.sheet .x { border: 0; background: rgba(255, 255, 255, .08); color: var(--text); min-width: 32px; height: 32px; border-radius: 9px; font-size: 15px; }
.sheet-lead { margin: 0; font-size: 14px; line-height: 1.65; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile {
  display: grid; gap: 2px; text-align: left; padding: 12px; border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .06); color: var(--text);
}
.tile:hover { background: rgba(255, 255, 255, .11); }
.tile .ic { font-size: 22px; }
.tile strong { font-size: 15px; }
.tile small { color: var(--muted); font-size: 12px; }
.med-wrap { display: grid; place-items: center; padding: 10px 0; }
.med-circle {
  width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle, rgba(255, 236, 200, .9), rgba(240, 184, 120, .35) 60%, rgba(240, 184, 120, .05));
  color: #2a1c0c; font-weight: 600; font-size: 14px;
  transform: scale(.72); transition: transform 4s ease-in-out;
}
.med-circle.in { transform: scale(1); transition-duration: 4s; }
.med-circle.out { transform: scale(.72); transition-duration: 6s; }
.med-time { margin: 0; text-align: center; font-size: 28px; font-variant-numeric: tabular-nums; }
.verse { padding: 14px; border-radius: 14px; background: rgba(240, 184, 120, .1); border: 1px solid rgba(240, 184, 120, .3); }
.verse-ref { margin: 0 0 6px; font-size: 12px; color: var(--accent); }
.verse-text { margin: 0 0 8px; font-size: 16px; line-height: 1.75; }
.verse-reflect { margin: 0; font-size: 14px; color: var(--muted); }
.vow-form { display: grid; gap: 8px; }
.vow-list, .tasks-list, .guide-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.vow-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, .06); }
.vow-list li span { flex: 1; min-width: 0; }
.vow-list li small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tasks-list li { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); font-size: 15px; }
.tasks-list li .en-sub { margin-top: 1px; }
.tasks-list li.done { background: rgba(120, 200, 140, .14); }
.tasks-list .tick { width: 22px; text-align: center; color: #a6dcb4; font-weight: 700; }
.guide-list li { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); font-size: 14px; line-height: 1.6; display: grid; gap: 2px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, .07); }
.set-row strong { display: block; font-size: 15px; }
.set-row small { display: block; color: var(--muted); font-size: 12px; }
.set-row input[type="range"] { width: min(200px, 45%); accent-color: var(--accent); }
.set-now { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); min-height: 34px; }
.btn.toggle[aria-pressed="true"] { border-color: var(--accent); background: rgba(240, 184, 120, .28); }
@media (max-width: 560px) {
  .menu-grid { grid-template-columns: 1fr 1fr; }
  .tile small { display: none; }
  .yebul { max-height: calc(100% - 230px); }
}

/* ---------- 2단계: 공양·공양간·법당 고르기·오늘의 흔적 ---------- */
.four-pop { grid-template-columns: repeat(4, 1fr); }
.four-pop .lantern-item canvas { width: 44px; height: 44px; }
.big-emoji { font-size: 28px; line-height: 44px; }
#status.pill-btn { height: 38px; }
.rooms-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: 1fr 1fr; }
.room {
  position: relative; overflow: hidden; width: 100%;
  display: grid; gap: 2px; text-align: left; padding: 10px 12px 12px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .06); color: var(--text);
}
.room:hover:not(:disabled) { background: rgba(255, 255, 255, .11); }
.room:disabled { opacity: .5; cursor: default; }
.room.here { border-color: var(--accent); background: rgba(240, 184, 120, .16); }
.room strong { font-size: 15px; }
.room span { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.room .fill { position: absolute; left: 0; bottom: 0; height: 3px; background: rgba(140, 220, 160, .7); }
.room.here .fill { background: var(--accent); }
.traces-stats { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.traces-stats li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); }
.traces-stats .ic { font-size: 18px; width: 24px; text-align: center; }
.traces-stats .lb { flex: 1; min-width: 0; font-size: 14px; }
.traces-stats strong { font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.sheet-sub { margin: 4px 0 0; font-size: 15px; }
.sheet-sub .en-sub { display: inline; margin-left: 6px; font-weight: 400; }
#traces-count { color: var(--accent); }
.names { display: flex; flex-wrap: wrap; gap: 6px; max-height: 28vh; overflow: auto; font-size: 13px; color: var(--muted); }
.name-chip { padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .08); color: var(--text); white-space: nowrap; }
.name-chip.me { background: rgba(240, 184, 120, .9); color: var(--accent-ink); font-weight: 600; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.check .en-sub { display: inline; }
