/* 레이아웃: 펠트 디오라마 장면이 무대 전체를 채우고, 등불빛 밤 패널이 오른쪽(데스크톱)·아래(휴대폰)에 붙는다.
   밤 마당 하나의 세계라 의도적으로 어두운 테마 하나만 쓴다. */
:root {
  color-scheme: dark;
  --night: #15172e;   /* 짙은 남색 펠트 */
  --dusk: #1f2242;    /* 패널 바탕 */
  --dusk-2: #2a2d55;  /* 패널 안 카드·눌림 */
  --wool: #f3e7d3;    /* 크림 양모 글자 */
  --muted: #b3aed0;   /* 보조 글자 */
  --lamp: #ffc46b;    /* 등불 호박색(강조) */
  --lamp-ink: #2a1c05;
  --ember: #9a4524;   /* 크림 말풍선 위 이름(크림 바탕 대비 5.3:1) */
  --blush: #f29bb0;   /* 인형 볼 분홍(보조 강조) */
  --live: #7cdb9a;    /* 지금 함께 있는 사람(초록 점) */
  --live-paper: #e2f5e7; /* 진짜 사람 이름표 바탕(밝은 풀빛) */
  --live-ink: #173826;   /* 그 위 글자(대비 11:1) */
  --live-deep: #2f9e58;  /* 밝은 바탕 위 초록 점 */
  --line: rgb(243 231 211 / 0.14);
  --veil: rgb(13 14 30 / 0.72);
  --display: "Gowun Batang", "AppleMyungjo", "Nanum Myeongjo", serif;
  --body: "Gowun Dodum", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --header-h: 56px;
  --panel-w: 380px;
  --radius: 14px;
}

html,
body {
  height: 100%;
}

/* hidden 속성은 display를 지정한 요소에서도 늘 숨긴다(단독 배포에서도 같게) */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--night);
  color: var(--wool);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* 한국어는 낱말 중간에서 줄을 바꾸지 않는다('수고했 / 어요' 막기). 너무 긴 낱말만 끊는다 */
  word-break: keep-all;
  overflow-wrap: break-word;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: var(--night);
}

h1,
h2 {
  font-family: var(--display);
  font-weight: 700;
  text-wrap: balance;
  margin: 0;
}

h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 16px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
h2 small { font-family: var(--body); font-weight: 400; font-size: 13px; color: var(--muted); }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--lamp);
  outline-offset: 2px;
}

/* 펠트 아이콘(icons.js의 icon()이 이모지 자리에 넣는 <img class="ico">): 글자 크기를 따라가고,
   가로세로 비율은 그림 그대로, 아래쪽을 글자 기준선 조금 아래에 맞춰 이모지처럼 줄 가운데에 선다. */
.ico {
  display: inline-block;
  height: 1.2em;
  width: auto;
  max-width: none;
  vertical-align: -0.22em;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* 'img 전체' 규칙이 있는 곳(칩·의식 카드·장소 카드·브로치·첫 화면)에서도 아이콘은 글자 크기로 */
:is(.chip, .ritual, .place-card, .brooch, .pick, .brand) img.ico { width: auto; height: 1.2em; flex: none; }

/* 누르는 영역: 보이는 크기는 그대로 두고, 가운데를 기준으로 가로세로 44px 이상인 투명한 판을 덧댄다 */
.icon-btn,
.chip,
.nav a,
.link,
.sw,
.toggle.inline { position: relative; }

.icon-btn::after,
.chip::after,
.nav a::after,
.link::after,
.sw::after,
.toggle.inline::after,
.edge-hint::after,
.follow-chip::after,
.spot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(100%, 44px);
  height: max(100%, 44px);
  transform: translate(-50%, -50%);
}

/* 색 동그라미는 이웃과 붙어 있어 가로는 간격까지만(겹치면 뒤 동그라미가 가로챈다) — 세로 44px.
   ::after의 100%는 테두리 안쪽(26px)이라 테두리 2px×2 + 간격 10px를 더해 30+10 = 40px 칸 */
.sw::after { width: calc(100% + 14px); }

/* ── 머리띠 ───────────────────────────── */
.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--night);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  color: var(--wool);
  text-decoration: none;
  white-space: nowrap;
}

.brand img { height: 28px; filter: drop-shadow(0 0 8px rgb(255 196 107 / 0.6)); }

.nav { display: flex; gap: 4px; margin-left: 8px; }

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.nav a:hover { color: var(--wool); }
.nav a[aria-current="page"] { color: var(--wool); background: var(--dusk-2); }

.chip {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px 3px 4px;
  border-radius: 999px;
  background: var(--dusk-2);
  color: var(--wool);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chip img { height: 28px; }
.chip span { color: var(--lamp); font-weight: 700; }
.chip b { font-weight: 400; color: var(--muted); }

.icon-btn {
  border: 1px solid var(--line);
  background: none;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.icon-btn[aria-pressed="false"] { color: var(--wool); }
.icon-btn[aria-expanded="true"] { color: var(--wool); border-color: var(--lamp); }

/* 지금 함께: 진짜 연결 수(초록 점). 연결 중이면 흐리게 */
/* 좁은 머리띠에서 글이 넘치면 머리띠·페이지가 옆으로 밀리지 않게 줄어들며 끝을 '…'로(점의 빛 고리가 잘리지 않게 안쪽 여백).
   줄어드는 것은 이 글뿐: 로고·이동·칩·소리는 그대로(그림이 눌려 작아지지 않게). main.js가 들어가는 가장 긴 말을 고른다 */
.top > :is(.brand, .nav, .focus-chip, .chip, .icon-btn) { flex: none; }
.live-badge {
  margin-left: auto;
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 6px 0 6px 7px;
  font-size: 12px;
  color: var(--wool);
  white-space: nowrap;
}
.live-badge::before {
  content: "";
  display: inline-block;
  vertical-align: 0;
  margin-right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 3px rgb(124 219 154 / 0.22);
  animation: livepulse 2.4s ease-in-out infinite;
}
.live-badge.wait { color: var(--muted); }
.live-badge.wait::before { background: var(--muted); box-shadow: none; animation: none; }
.live-badge:not([hidden]) + .chip { margin-left: 0; }
@keyframes livepulse { 50% { box-shadow: 0 0 0 6px rgb(124 219 154 / 0.06); } }
/* 누르면 한 줄 설명(단추). 사람 수가 아니라 오늘 밤 연등 수일 때(.lit)는 초록 점 대신 작은 펠트 연등 */
button.live-badge { border: 0; background: none; font-family: inherit; line-height: inherit; text-align: left; cursor: pointer; border-radius: 8px; }
button.live-badge:focus-visible { outline: 2px solid var(--lamp); outline-offset: -2px; }
.live-badge.lit::before {
  width: 14px;
  height: 14px;
  margin-right: 5px;
  vertical-align: -3px;
  border-radius: 0;
  background: url(assets/icon/lantern.webp) center / contain no-repeat;
  box-shadow: none;
  animation: none;
}
.live-more {
  position: fixed;
  top: calc(var(--header-h) + 6px); /* main.js가 단추 바로 아래로 옮긴다 */
  right: max(16px, env(safe-area-inset-right, 0px));
  z-index: 25; /* 장면 위 칩·표지(20~22)보다 위, 알림(30)·창보다 아래 */
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--dusk);
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.4);
  color: var(--wool);
  font-size: 13px;
  line-height: 1.5;
  animation: fade 0.2s ease;
}

/* 집중 중 다른 장면에서: 머리말 '집중 12:34'(누르면 작업실로). 좁은 화면은 '집중' 글자 없이 시계만 */
.focus-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px solid var(--lamp);
  border-radius: 999px;
  color: var(--lamp);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  white-space: nowrap;
}
.focus-chip span { color: var(--wool); }
.focus-chip::after { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%); }

/* 건너뛰기 단추: 평소엔 화면 밖, 키보드 초점이 오면 왼쪽 위에 보인다 */
.skip-link {
  position: fixed;
  left: max(8px, env(safe-area-inset-left, 0px));
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  z-index: 60;
  padding: 10px 16px;
  border: 1px solid var(--lamp);
  border-radius: 12px;
  background: var(--night);
  color: var(--wool);
  font-size: 14px;
  transform: translateY(calc(-100% - 24px));
}
.skip-link:focus { transform: none; }

/* 마음이 조금 쌓이면 칩이 살짝 빛난다(숫자 알림 대신) */
.chip.glow { animation: chipglow 1.6s ease-out; }
@keyframes chipglow {
  0% { box-shadow: 0 0 0 0 rgb(255 196 107 / 0.55); }
  100% { box-shadow: 0 0 0 10px rgb(255 196 107 / 0); }
}
/* 움직임 줄이기용: 퍼지지 않고 그 자리에서 번진 빛만 밝아졌다 사그라든다
   (또렷한 고리는 키보드 초점 테두리와 똑같아 보여 초점이 칩에 간 것처럼 읽힌다 — 흐린 빛으로) */
@keyframes chipglow-still {
  0%, 60% { box-shadow: 0 0 14px 3px rgb(255 196 107 / 0.55); }
  100% { box-shadow: 0 0 14px 3px rgb(255 196 107 / 0); }
}

/* 소리 조절 */
.mixer {
  position: absolute;
  top: calc(100% + 6px);
  right: max(16px, env(safe-area-inset-right, 0px));
  z-index: 40;
  width: min(300px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--dusk);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgb(0 0 0 / 0.45);
}
.slider { display: grid; gap: 4px; font-size: 14px; }
.slider span { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.slider small { font-size: 12px; color: var(--muted); }
.slider input { width: 100%; accent-color: var(--lamp); }

/* ── 장소 배치 ─────────────────────────── */
.place {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  height: calc(100% - var(--header-h));
}

.app { height: 100%; }

.view {
  position: relative;
  overflow: hidden;
  container-type: size;
  min-height: 0;
  background: var(--night);
  /* 장면 안 칩·표지(정시 칩 22·가장자리 표지 20·같이 칩 2000…)의 z-index는 장면 안에서만 — 붙박이 머리띠(5)·겹침 창(20) 위로 올라오지 않게 */
  isolation: isolate;
  /* 패널 동작 뒤 장면을 보여 줄 때(scrollIntoView) 붙박이 머리띠 아래에 장면 윗변이 오게 */
  scroll-margin-top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
}

/* 화면 창. clip이라 포커스 이동 등으로 장면이 저절로 밀리지 않고, 카메라만 장면을 옮긴다. */
.pan {
  position: absolute;
  inset: 0;
  overflow: clip;
}

/* 장면은 16:9 그림. 칸을 덮도록 키우고(남는 쪽은 화면 밖), 카메라(actors.js)가 내 인형을 따라 옮긴다. */
.stage {
  position: absolute;
  left: 0;
  top: 0;
  width: max(100cqw, 177.78cqh);
  height: max(100cqh, 56.25cqw);
  transform: translate3d(var(--cx, 0px), var(--cy, 0px), 0);
  will-change: transform;
  touch-action: pan-y; /* 가로로 끌면 둘러보기, 세로로 밀면 페이지 스크롤 */
}

.view.peeking { cursor: grabbing; }

.pan-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 20;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--veil);
  color: var(--wool);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  animation: hint 5s ease forwards;
}

@keyframes hint {
  0%, 75% { opacity: 1; }
  100% { opacity: 0; }
}

/* 첫 안내 띠가 떠 있는 동안(.view.hinting — main.js가 붙이고 5초 뒤 뗀다) 가장자리 표지는 기다렸다가 나타난다 */
.edge-hint { transition: opacity 0.4s ease, visibility 0s; }

/* 화면 밖 장소 표지 */
.edge-hint {
  position: absolute;
  z-index: 20;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 46%;
  padding: 6px 12px;
  border: 1px solid rgb(255 196 107 / 0.6);
  border-radius: 999px;
  background: var(--veil);
  color: var(--wool);
  font-family: var(--display);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 0 16px rgb(255 196 107 / 0.3);
  animation: fade 0.25s ease;
}

.edge-hint span:last-child { overflow: hidden; text-overflow: ellipsis; }
.edge-hint:hover { background: var(--lamp); color: var(--lamp-ink); }
.edge-hint[data-side="left"] { left: max(8px, env(safe-area-inset-left, 0px)); }
.edge-hint[data-side="right"] { right: max(8px, env(safe-area-inset-right, 0px)); flex-direction: row-reverse; }
.edge-hint[data-side="left"] .arrow::before { content: "←"; }
.edge-hint[data-side="right"] .arrow::before { content: "→"; }
.edge-hint .arrow { color: var(--lamp); font-family: var(--body); }
/* 화면 밖 ★친구 표지('★ 보들 →' — 누르면 카메라가 그쪽을 잠깐 보여 준다): 진짜 사람 이름표와 같은 풀빛 테두리 */
.edge-hint.peer-hint { border-color: var(--live); box-shadow: 0 0 14px rgb(124 219 154 / 0.35); }
.edge-hint.peer-hint .arrow { color: var(--live); }

/* 휴대폰: 패널 위쪽의 '★ 친구 부르기'(같이 가기 링크 — 패널 맨 끝까지 내려가지 않아도 보이게). 데스크톱은 패널 글의 단추로 */
.invite-cta { display: none; }
@media (max-width: 860px) {
  .invite-cta {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-height: 44px;
    padding: 9px 14px;
    border: 1px solid var(--live);
    border-radius: 999px;
    background: var(--live-paper);
    color: var(--live-ink);
    font: 700 14px var(--body);
    cursor: pointer;
  }
  .invite-cta small { font-weight: 400; font-size: 12px; }
}

/* 내 방 ★친구 카드: '★ 다시 만나기'(마지막으로 함께한 같이 가기 방으로) */
.friends li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.meet-btn { padding: 6px 12px; font-size: 13px; }

.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  transition: filter 1.2s ease;
}

.stage.hush .bg,
.stage.hush .occ img { filter: brightness(0.86) saturate(0.9); }

.doll,
.host,
.lamp,
.stick {
  position: absolute;
  left: var(--x);
  top: var(--y);
  height: var(--h);
  transform: translate(-50%, -100%);
}

.doll,
.host {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}

.doll::after,
.host::after {
  content: "";
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: -2%;
  height: 8%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgb(0 0 0 / 0.35), transparent);
  z-index: -1;
}

/* 발밑 판(그림자 아래): 진짜 사람은 은은한 등불 원(마을 인형에는 없다), 내 인형은 들어올 때 잠깐 '나' 고리 */
.doll--peer::before,
.doll--me.spawn::before {
  content: "";
  position: absolute;
  left: -14%;
  right: -14%;
  bottom: -5%;
  height: 14%;
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
}

.doll--peer::before {
  left: -32%;
  right: -32%;
  bottom: -11%;
  height: 26%;
  background: radial-gradient(closest-side, rgb(255 232 172 / 0.75) 35%, rgb(255 214 140 / 0.38) 68%, transparent);
}

/* 내 인형 '나' 고리: 들어오거나 다른 사람과 겹칠 때 main.js가 .spawn을 잠깐(약 2.4초) 붙인다. 끝나면 저절로 사라진다 */
.doll--me.spawn::before {
  border: 2px solid var(--lamp);
  box-shadow: 0 0 12px rgb(255 196 107 / 0.7), inset 0 0 8px rgb(255 196 107 / 0.45);
  animation: me-ring 2.4s ease-out forwards;
}

@keyframes me-ring {
  0% { opacity: 0; transform: scale(0.6); }
  15%, 45% { opacity: 1; transform: scale(1); }
  60% { opacity: 0.6; transform: scale(1.12); }
  75%, 85% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

/* 고리만 밝아졌다 사그라드는 판(움직임 줄이기용) */
@keyframes me-ring-still {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; }
}

/* 잠시 자리 비움(진짜 사람이 다른 창에 가 있음): 인형만 반쯤 비치고 이름표 글자는 또렷하게.
   이름표 옆 '자리 비움'은 main.js가 <span class="afk-note">자리 비움</span>을 이름표 안에 넣는다 */
.doll.afk .doll-body { opacity: 0.45; }
.doll.afk::before { opacity: 0.35; }
.afk-note { display: none; }
.doll.afk .afk-note { display: inline; font-weight: 400; }
.afk-note::before { content: "· "; }

.doll-body,
.host-body {
  position: relative;
  display: block;
  height: 100%;
  width: max-content;
  transform-origin: 50% 100%;
}

.doll-body > img,
.host-body > img {
  display: block;
  height: 100%;
  width: auto;
  /* 응원봉을 든 팔·구운 빛 때문에 앞모습보다 넓은 그림이 많다: 상자 너비로 자르면 가로만 눌려 세로로 길쭉해 보인다 */
  max-width: none;
  user-select: none;
}

/* 표정 프레임(눈 감기·손 들기)은 원본과 같은 자리·크기라 겹쳐 두고 바꿔 보인다. */
.doll-body > .frame,
.host-body > .frame {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
}


/* 인형 자세 그림(뒷모습·옆모습·앉기·응원봉): 앞모습과 같은 배율. 발(아래쪽 몸) 중심(--pa)을 상자 가운데에,
   발바닥을 상자 바닥(--pb)에 맞춘다 — 응원봉 든 팔 때문에 그림이 한쪽으로 넓어도 몸은 제자리.
   응원봉 공 색과 빛은 actors.js가 그림에 구워 넣는다(따로 겹친 색 층 없음). */
.doll-body > .pose {
  position: absolute;
  left: 50%;
  bottom: calc(var(--pb) * 100%);
  height: calc(var(--ph) * 100%);
  width: auto;
  transform: translateX(calc(var(--pa, 0.5) * -100%));
  transform-origin: calc(var(--pa, 0.5) * 100%) 100%;
  opacity: 0;
}

/* 무대를 향해 응원하는 순간 잠깐 환해진다(몸 둘레에 빛을 덧씌우지 않는다 — 빛은 공에만, 그림에 구워 넣었다) */
.doll.shine .doll-body > .on { filter: brightness(1.08); }

/* actors.js가 고른 자세 그림에만 .on — 한 장만 보인다. 처음 그리기 전(.on 없음)엔 앞모습이 보인다. */
.doll-body > img,
.host-body > img { opacity: 0; }
/* 호스트 몸짓은 생성 그림마다 몸 크기가 조금씩 달라 살짝 겹쳐 바꾼다(인형 걸음은 바로 바꿔야 또렷하다) */
.host-body > img { transition: opacity 0.14s linear; }
.doll-body:not(:has(.on)) > .base,
.host-body:not(:has(.on)) > .base,
.doll .doll-body > .on,
.host .host-body > .on { opacity: 1; }

/* 대표 브로치: 그 브로치를 단 채로 생성한 그림에서 오린 조각(같은 자리·같은 픽셀). 가슴이 보이는 자세에서만. */
.pinlayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* 걷다 몸이 기운 그림에선 그 그림의 가슴 자리로(--pox·--poy, actors.js) */
.pinlayer img {
  position: absolute;
  left: calc((var(--x) + var(--pox, 0)) * 100%);
  top: calc((var(--y) + var(--poy, 0)) * 100%);
  width: calc(var(--w) * 100%);
  height: auto;
  opacity: 0;
}

.doll.pin-f .pin-front,
.doll.pin-s .pin-sit { opacity: 1; }

.face-left .pinlayer { transform: scaleX(-1); }

/* 의자에 앉아 뒤돌아 있으면 이름은 머리 위 꼬리표로만(작업실). 머리 위 꼬리표가 없으면(산사 찻상 앞 등)
   발밑 이름표를 그대로 둔다 — 진짜 사람(●)과 마을 인형을 나누는 표시가 사라지지 않게 */
.doll[data-pose="sitback"]:has(> .mini-tag:not([hidden])) .tag { display: none; }

/* 앉아 있는 남의 인형(진짜 사람·마을 인형)은 머리 쪽만 누르는 곳 — 몸을 누르면 그 아래 의자·방석(사물 판)이 눌린다 */
.head-hit { display: none; position: absolute; left: 20%; right: 20%; top: 6%; height: 44%; }
.doll.sitting:not(.doll--me) { pointer-events: none; }
.doll.sitting:not(.doll--me) > :is(.head-hit, .tag, .mini-tag) { pointer-events: auto; }
.doll.sitting:not(.doll--me) > .head-hit { display: block; }
.doll:is(.away, .leaving) > * { pointer-events: none !important; }

.face-left .doll-body > img,
.face-left .host-body > img { transform: scaleX(-1); }
.face-left .doll-body > .pose { transform: translateX(calc(var(--pa, 0.5) * -100%)) scaleX(-1); }

/* 숨쉬기(늘), 걷기(발을 번갈아 내딛는 생성 그림 + 모을 때 살짝 올라가는 몸 --bob), 폴짝(--lift: 포물선, 그림자는 바닥에), 몸짓 */
.doll-body {
  animation: breathe 3.2s ease-in-out var(--d, 0s) infinite;
  translate: 0 calc(var(--bob, 0) * -2.2% + var(--lift, 0) * -34%);
}
.doll::after { scale: calc(1 - var(--lift, 0) * 0.35); opacity: calc(1 - var(--lift, 0) * 0.4); }
.walking .doll-body { animation: none; }
.land .doll-body { animation: land 0.26s ease-out; }
.hop .doll-body,
.hop .host-body { animation: hop 0.6s ease-out; }
.waving .doll-body { animation: wiggle 0.35s ease-in-out 4; }
.bowing .doll-body { animation: bow 1.1s ease-in-out; }
/* 자는 동안: 베개에 고개를 살짝 기울이고(몸은 이불 가림 층 아래), 그림자 없음 */
.sleeping .doll-body { transform: rotate(-7deg); animation: none; }
.sleeping::after { display: none; }
.sleeping .tag { display: none; }
/* 침대에 오르내릴 때 잠깐 사라졌다 나타난다 */
.doll.poof { opacity: 0; transition: opacity 0.25s ease; }
.doll { transition: opacity 0.25s ease; }

/* 가림 층: 장면 그림을 다시 깔고 사물 모양 마스크만 남긴다(의자·이불·앞쪽 소품) */
.occ {
  position: absolute;
  inset: 0;
  pointer-events: none;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.occ img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 1.2s ease;
}

/* 펠트 인형 그림을 가로세로 따로 늘리거나 누르지 않는다(찌그러져 보인다): 몸짓은 위아래로 뜨고 내려앉는 움직임으로만,
   눌림은 숨쉬기 정도(2% 안)로만 */
@keyframes breathe {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.008, 0.988); }
}

@keyframes land {
  0% { transform: translateY(1.5%) scale(1.015, 0.98); }
  100% { transform: none; }
}

@keyframes hop {
  0% { transform: translateY(1%) scale(1.012, 0.985); }
  30% { transform: translateY(-15%); }
  55% { transform: translateY(0); }
  72% { transform: translateY(-4%); }
  88% { transform: translateY(0.8%) scale(1.01, 0.99); }
  100% { transform: none; }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

/* 인사는 생성한 인사 그림(합장하고 고개 숙이기)으로 한다. 그 그림이 없는 자세(응원봉을 쥐었거나 옆모습)만 고개를 살짝 끄덕인다 */
@keyframes bow {
  0%, 100% { transform: none; }
  40%, 60% { transform: rotate(6deg); }
}

/* 호스트: 비질·책 읽기·노래는 생성한 프레임으로(actors.js). 몸은 숨 쉬듯, 부엉이는 가끔 고개를 갸웃 */
.host--cat .host-body { animation: breathe 3s ease-in-out infinite; }
.host--owl .host-body { animation: tilt 5s ease-in-out infinite; }
.host--idol .host-body { animation: breathe 2.4s ease-in-out infinite; }

@keyframes tilt {
  0%, 70%, 100% { transform: rotate(0); }
  80% { transform: rotate(-5deg); }
  90% { transform: rotate(3deg); }
}

/* 노래가 나오면 모두 흔들흔들(두 박에 한 번) */
.dance .doll-body,
.dance .host-body { animation: sway 0.84s ease-in-out infinite alternate; }

@keyframes sway {
  from { transform: rotate(-5deg); }
  to { transform: rotate(5deg) translateY(-3%); }
}

.dance .walking .doll-body { animation: none; }
/* 응원봉을 쥔 인형·리나는 흔드는 그림이 따로 있어 몸은 박자에 맞춰 살짝만 들썩인다 */
.dance .doll[data-stick="1"] .doll-body,
.dance .host--idol .host-body { animation: bounce 0.42s ease-in-out infinite alternate; }

@keyframes bounce {
  from { transform: none; }
  to { transform: translateY(-2.5%); }
}

/* 만질 수 있는 사물: 가운데 깜빡이는 점, 가까이 가거나 올리면 이름표 */
.hot {
  position: absolute;
  left: var(--x0);
  top: var(--y0);
  width: calc(var(--x1) - var(--x0));
  height: calc(var(--y1) - var(--y0));
  border: 0;
  padding: 0;
  background: none;
  border-radius: 18px;
  cursor: pointer;
  z-index: 5;
}

.hot:hover { background: rgb(255 196 107 / 0.07); }

.hot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px;
  border-radius: 50%;
  background: rgb(255 196 107 / 0.9);
  animation: beckon 2.4s ease-out infinite;
}

.hot.near::after { background: var(--lamp); transform: scale(1.4); }
.hot.labeled::after { display: none; }

.hot-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -160%);
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--veil);
  color: var(--wool);
  font-family: var(--display);
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.hot:hover .hot-label,
.hot:focus-visible .hot-label,
.hot.near .hot-label,
.hot.labeled .hot-label,
.stage.reveal .hot-label { opacity: 1; } /* 장면에 들어온 뒤 잠깐(main.js가 4초 붙인다) 모든 사물 이름표 */
.stage.reveal .hot.offview:not(:hover, :focus-visible) .hot-label { opacity: 0; } /* 카메라 밖 사물은 잘린 조각 대신 가장자리 표지로 */

.hot.labeled .hot-label {
  transform: translate(-50%, -50%);
  font-weight: 700;
  font-size: 14px;
  padding: 6px 14px;
  border: 1px solid rgb(255 196 107 / 0.6);
  box-shadow: 0 0 18px rgb(255 196 107 / 0.35);
}

.hot.labeled:hover .hot-label { background: var(--lamp); color: var(--lamp-ink); }

.hot-label kbd {
  display: none;
  margin-left: 6px;
  padding: 0 5px;
  font: 12px var(--body);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.hot.near .hot-label kbd { display: inline-block; }

/* 앉아 있는 동안(집중·차·숨)엔 바로 옆 사물 이름표를 숨겨 인형을 가리지 않는다 */
.stage:has(.doll--me.sitting) .hot.near .hot-label { opacity: 0; }

/* 작업실 의자 판 다섯: 깔개에 선 인형(내 인형 포함)의 머리가 의자에 겹쳐도 의자를 누를 수 있게 인형보다 위(앉은 사람 머리 줄은 비워 두었다 — world.js chairY).
   나머지 의자 넷(가운데 의자 말고)은 깜빡이는 점·처음 4초 이름표 없이(의자마다 점이 다섯 개 뜨지 않게) */
.hot[data-chair] { z-index: 1000; }
.hot.chair-extra::after,
.hot[data-chair].taken::after { display: none; }
/* 휴대폰: 누른 의자에 :hover가 남아 이름표가 앉은 사람 머리 위에 계속 떠 있지 않게(손가락에는 올려 보기가 없다) */
@media (hover: none) { .hot[data-chair]:hover:not(.near, :focus-visible) .hot-label { opacity: 0; } .hot[data-chair]:hover { background: none; } }
.stage.reveal .hot.chair-extra:not(:hover, :focus-visible) .hot-label { opacity: 0; }

/* 예불 중엔 장면 위 가운데 '같이 고개 숙이기'가 있다: 그 자리에 겹치는 하늘(연등 달기) 이름표는 숨긴다.
   정시 의식 띠(#herald)가 장면 위에 떠 있을 때도(.on-top — herald.js가 잰다) 같은 자리라 숨긴다 */
.view:has(#yebul-chip) .hot[data-hot="wish"]:not(:focus-visible) .hot-label,
body:has(#herald.on-top:not([hidden])) .view .hot[data-hot="wish"]:not(:focus-visible) .hot-label { opacity: 0; }

/* 내 방: 자는 동안 '일어나기' 이름표는 베개 위 인형 머리를 비켜 침대 오른쪽 위에, 처음 이름표 '침대에 눕기'는 이불 가림 층 위쪽에.
   '창밖 별 보기'는 창 아래쪽에(장면 위 가장자리·머리띠에 걸리지 않게) */
body[data-route="room"] .hot[data-hot="bed"] .hot-label { top: 22%; }
.stage.sleep .hot[data-hot="bed"] .hot-label { left: 86%; top: 30%; transform: translate(-50%, -50%); }
body[data-route="room"] .hot[data-hot="window"] .hot-label { top: 82%; transform: translate(-50%, -50%); }

@media (hover: none) {
  .hot-label kbd { display: none !important; }
}

@keyframes beckon {
  0% { box-shadow: 0 0 0 0 rgb(255 196 107 / 0.6); }
  70%, 100% { box-shadow: 0 0 0 14px rgb(255 196 107 / 0); }
}

.lamp.float { z-index: 6; }
.ripple-at { z-index: 6; }

canvas.fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.walk-ring {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 44px;
  height: 14px;
  margin: -7px 0 0 -22px;
  border: 2px solid var(--lamp);
  border-radius: 50%;
  z-index: 4;
  pointer-events: none;
  animation: ringout 0.7s ease-out forwards;
}

@keyframes ringout {
  from { transform: scale(0.4); opacity: 1; }
  to { transform: scale(1.4); opacity: 0; }
}

/* 말풍선: 화면 가장자리에서 잘리면 actors.js가 --shift(px)만큼 옆으로 민다. 꼬리는 인형 머리 위에 그대로 남는다.
   가로 자리는 translate로 따로 두어 나타날 때의 rise(transform)와 섞이지 않는다 */
.say {
  position: absolute;
  left: 50%;
  bottom: 108%;
  /* --up: 진짜 사람 인형을 덮으면 그 머리 위로 올린다(actors.js fitSay). 올릴 자리가 없으면 .covered로 숨긴다(패널 말풍선에 같은 말) */
  translate: calc(-50% + var(--shift, 0px)) calc(-1 * var(--up, 0px));
  width: max-content;
  max-width: 220px;
  padding: 7px 11px;
  border-radius: 12px;
  background: var(--wool);
  color: var(--lamp-ink);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.3);
  animation: rise 0.25s ease;
  pointer-events: none;
}

.say.covered { visibility: hidden; }

.say::after {
  content: "";
  position: absolute;
  left: clamp(14px, calc(50% - var(--shift, 0px)), calc(100% - 14px));
  top: 100%;
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: var(--wool);
}

.emote-menu {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -112%);
  translate: var(--shift, 0px) 0; /* 장면 가장자리에서 잘리지 않게 main.js가 민다(나타날 때의 transform과 따로) */
  z-index: 3000;
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 16px;
  background: var(--dusk);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.4);
  animation: rise 0.2s ease;
}

.emote-menu button {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 52px;
  padding: 6px 6px 5px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--dusk-2);
  color: var(--wool);
  cursor: pointer;
  font-size: 20px;
  line-height: 1.1;
}

.emote-menu button:hover { border-color: var(--lamp); }
.emote-menu small { font-size: 12px; color: var(--muted); white-space: nowrap; }
.emote-menu .ico { display: block; height: 30px; }

.stage.lamp-off .bg,
.stage.lamp-off .occ img { filter: brightness(0.55) saturate(0.85); }
.stage.sleep .bg,
.stage.sleep .occ img { filter: brightness(0.5) saturate(0.8); }

/* 인물도 장면 조명을 따른다(방이 어두워지면 인형도 어둡게) */
.doll-body,
.host-body { transition: filter 1.2s ease; }
.stage.hush .doll-body,
.stage.hush .host-body { filter: brightness(0.9); }
.stage.lamp-off .doll-body { filter: brightness(0.62) saturate(0.88); }
.stage.sleep .doll-body { filter: brightness(0.58) saturate(0.85); }

.view { transition: opacity 0.3s ease; }
.view.leaving { opacity: 0; }

.how {
  font-size: 13px;
  color: var(--wool);
  background: rgb(255 196 107 / 0.07);
  border-radius: 10px;
  padding: 8px 10px;
}

.card.flash { animation: flash 1.4s ease; }

@keyframes flash {
  0%, 100% { box-shadow: none; }
  30% { box-shadow: 0 0 0 2px var(--lamp); }
}

.doll:not(.doll--me):hover .tag,
.doll--me:hover .tag { outline: 1px solid var(--lamp); }

.tag {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translate(-50%, 6px);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--veil);
  color: var(--wool);
}

/* 장면 바닥 끝에 서서 발밑 이름표가 장면 밖으로 잘릴 때(.doll.low — actors.js가 자리를 놓을 때 붙인다):
   이름표를 머리 위로 올리고, 그 위에 뜨는 말풍선·반응 그림도 한 칸 올린다 */
.doll.low .tag { top: auto; bottom: 100%; transform: translate(-50%, -4px); }
.doll.low .say { bottom: calc(108% + 24px); }
.doll.low .emote { bottom: calc(104% + 24px); }
.doll.low .mini-tag { transform: translate(-50%, -28px); }

/* 이름표 앞 작은 잎 등: 글자 높이(1em) 그대로 */
.tag .ico { display: block; height: 1em; }
.mini-tag .ico { height: 1em; vertical-align: -0.12em; margin-right: 2px; }

.tag--me { background: var(--lamp); color: var(--lamp-ink); font-weight: 700; }
.tag--host { background: var(--blush); color: var(--lamp-ink); }

.mini-tag {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -4px);
  white-space: nowrap;
  font-size: 12px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--veil);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mini-tag.me { background: var(--lamp); color: var(--lamp-ink); }
.mini-tag.live { color: var(--live-ink); background: var(--live-paper); box-shadow: 0 0 0 1.5px var(--live); }
.mini-tag.npc { color: var(--muted); }

/* 진짜 사람(● 지금 여기)과 마을 인형(🍃)을 이름표로 나눈다:
   진짜 사람은 밝은 풀빛 바탕 + 초록 테두리, 마을 인형은 투명도 대신 흐린 글자색(어두운 바탕, 대비 5:1 이상) */
.tag--live {
  gap: 5px;
  color: var(--live-ink);
  background: var(--live-paper);
  box-shadow: 0 0 0 2px var(--live), 0 0 10px rgb(124 219 154 / 0.45);
}
.tag--live .dot,
.legend-live .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  display: inline-block;
}
.tag--live .dot { background: var(--live-deep); }
.tag--npc { color: var(--muted); }
.tag--npc i { font-style: normal; }
.legend-live { display: inline-flex; align-items: center; gap: 4px; color: var(--wool); }

/* 들어오고 나가는 사람은 천천히 나타나고 사라진다. 비켜 준 마을 인형은 숨는다. */
.doll--peer.arriving { animation: arrive 0.9s ease-out; }
@keyframes arrive { from { opacity: 0; filter: blur(2px); } }
.doll.leaving { opacity: 0; transition: opacity 0.6s ease; pointer-events: none; }
.doll.away { opacity: 0; pointer-events: none; transition: opacity 0.8s ease; }

/* 가까이에서 누가 인사하면 '같이' 단추 */
.follow-chip {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -100%);
  z-index: 2000;
  border: 1px solid var(--lamp);
  background: var(--dusk);
  color: var(--wool);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.35);
  animation: rise 0.3s ease-out, beckon 1.6s ease-out 0.3s 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.follow-chip .ico { height: 1.3em; }

/* 다른 사람이 단 연등이 하늘로 오른다 */
.lamp.rise { animation: lampRise 6s ease-out; }
@keyframes lampRise { from { transform: translate(-50%, -40%) scale(0.6); opacity: 0; } }

/* 저녁 예불·같이 25분 회차 안내 */
.card.yebul { font-size: 14px; line-height: 1.6; }
.card.yebul small { color: var(--muted); font-size: 13px; }
.card.yebul br { display: none; } /* 격자 칸 사이에 빈 줄 한 칸이 더 생기던 것 */
.round { font-size: 15px; color: var(--lamp); text-align: center; min-height: 1.4em; }
.doll-swatches { margin-bottom: 4px; }
.link[data-snap] { display: block; margin-top: 8px; }

.emote {
  position: absolute;
  left: 50%;
  bottom: 104%;
  transform: translateX(-50%);
  font-size: 22px;
  line-height: 1;
  white-space: nowrap;
  animation: pop 1.8s ease forwards;
  pointer-events: none;
}

.emote.reply { left: 80%; }
/* 반응 아이콘(펠트 그림)은 이모지보다 조금 크게 — 작은 그림의 결이 보이게 */
.emote .ico { height: 1.3em; vertical-align: top; filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.35)); }

@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}

/* 등불·응원봉: 크림색 그림 위에 같은 모양 색 층을 얹어 색만 바꾼다. */
.lamp,
.stick {
  isolation: isolate;
  filter: drop-shadow(0 0 12px var(--c));
}

.lamp { aspect-ratio: 376 / 400; }
.stick { aspect-ratio: 244 / 400; }

.lamp img,
.stick img {
  display: block;
  height: 100%;
  width: auto;
}

.lamp i,
.stick i {
  position: absolute;
  inset: 0;
  background: var(--c);
  mix-blend-mode: color;
  opacity: 0.85;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.lamp.float { animation: bob 6s ease-in-out infinite; cursor: help; }
.lamp.float:nth-of-type(2n) { animation-duration: 7.5s; animation-delay: -2s; }
.lamp.float:nth-of-type(3n) { animation-duration: 8.5s; animation-delay: -4s; }
.lamp.mine { filter: drop-shadow(0 0 20px var(--c)) drop-shadow(0 0 6px var(--c)); }

@keyframes bob {
  0%, 100% { transform: translate(-50%, -100%); }
  50% { transform: translate(-50%, -112%); }
}


.spot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  border: 1px solid rgb(255 196 107 / 0.6);
  background: var(--veil);
  color: var(--wool);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 0 18px rgb(255 196 107 / 0.35);
  white-space: nowrap;
}

.spot:hover { background: var(--lamp); color: var(--lamp-ink); }

.ripple-at { position: absolute; left: var(--x); top: var(--y); width: 0; height: 0; }

.ripple {
  position: absolute;
  left: 0;
  top: 0;
  width: 60px;
  height: 60px;
  margin: -30px 0 0 -30px;
  border: 2px solid rgb(255 196 107 / 0.8);
  border-radius: 50%;
  animation: ripple 3.2s ease-out forwards;
  pointer-events: none;
}

@keyframes ripple {
  from { transform: scale(0.4); opacity: 1; }
  to { transform: scale(9); opacity: 0; }
}

/* ── 패널 ──────────────────────────────── */
.panel {
  position: relative; /* 안의 화면 읽기 전용 글(.sr-only, absolute)이 패널 스크롤 밖으로 빠져 문서를 늘리지 않게(데스크톱 무대에서 장면이 머리띠 밑으로 밀리던 것) */
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  overflow-y: auto;
  padding-block: 18px 28px;
  padding-left: 18px;
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background:
    radial-gradient(120% 60% at 100% 0%, rgb(255 196 107 / 0.08), transparent 60%),
    var(--dusk);
  border-left: 1px solid var(--line);
}

.panel-head { display: flex; align-items: center; gap: 12px; }
.panel-head p { color: var(--muted); font-size: 13px; }
.panel-head .count { color: var(--lamp); font-variant-numeric: tabular-nums; }

.avatar {
  width: 54px;
  height: 54px;
  flex: none;
  object-fit: contain;
  border-radius: 50%;
  background: var(--dusk-2);
  padding: 5px;
}

.bubble {
  background: var(--wool);
  color: var(--lamp-ink);
  border-radius: var(--radius);
  border-top-left-radius: 4px;
  padding: 10px 14px;
  font-size: 14px;
}

.bubble b { color: var(--ember); margin-right: 4px; }

.acts { display: grid; gap: 8px; }

.ritual,
.place-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--dusk-2);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}

.ritual:hover:not(:disabled, [aria-disabled="true"]),
.place-card:hover { border-color: var(--lamp); transform: translateY(-1px); }
.ritual:disabled,
.ritual[aria-disabled="true"] { opacity: 0.55; cursor: wait; } /* 범종은 울리는 4초 동안 aria-disabled(초점은 그대로) */

.ritual img,
.place-card img { width: 44px; height: 44px; object-fit: contain; flex: none; }
.ritual span,
.place-card span { display: flex; flex-direction: column; min-width: 0; }
.ritual small,
.place-card small { color: var(--muted); font-size: 13px; }
.ritual b,
.place-card b { font-family: var(--display); font-size: 15px; }

.places { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.place-card em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--lamp); white-space: nowrap; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.level { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.level .lv { font-family: var(--display); font-weight: 700; font-size: 28px; color: var(--lamp); font-variant-numeric: tabular-nums; }
.level b { font-family: var(--display); font-size: 17px; }
.level small { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.bar { height: 8px; border-radius: 999px; background: var(--dusk-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--blush), var(--lamp)); border-radius: inherit; }

.recent { font-size: 13px; color: var(--muted); }
.recent b { color: var(--wool); font-weight: 400; }

.cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.cats li { display: grid; grid-template-columns: 44px 1fr 28px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.cats i { display: block; height: 6px; width: var(--w); min-width: 2px; border-radius: 999px; background: var(--lamp); opacity: 0.8; }
.cats em { font-style: normal; text-align: right; font-variant-numeric: tabular-nums; }

.brooch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.brooch {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 8px 4px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--dusk-2);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
}

.brooch img { height: 42px; width: auto; }
.brooch.on { border-color: var(--lamp); box-shadow: 0 0 0 1px var(--lamp) inset; }
.brooch.locked { cursor: default; color: var(--muted); }
.brooch.locked img { filter: grayscale(1) brightness(0.45); opacity: 0.55; }
.brooch span { font-variant-numeric: tabular-nums; }

.toggle { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.toggle input { margin-top: 4px; accent-color: var(--lamp); width: 16px; height: 16px; }
.toggle small { display: block; color: var(--muted); font-size: 13px; }
.toggle.inline { align-items: center; }
.toggle.inline input { margin-top: 0; }

.btn {
  border: 1px solid var(--line);
  background: var(--dusk-2);
  color: var(--wool);
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
}

.btn:hover { border-color: var(--lamp); }
.btn.primary { background: var(--lamp); color: var(--lamp-ink); border-color: var(--lamp); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.wide { width: 100%; }
.btn small { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }

.link {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  justify-self: center;
}

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.note { font-size: 13px; color: var(--muted); }
.link .ico { height: 1.25em; }

.clock { font-family: var(--display); font-size: 30px; font-variant-numeric: tabular-nums; text-align: center; }
.clock.big { font-size: 44px; color: var(--lamp); line-height: 1.1; }
/* 회차 끝: 큰 '✓ 25분' 아래 작은 설명 한 줄(main.js가 <small>을 넣으면) */
.clock.big small { display: block; margin-top: 4px; font-family: var(--body); font-size: 15px; color: var(--wool); }
.focus { justify-items: center; text-align: center; }
.focus small { color: var(--muted); font-size: 13px; }

/* 색 동그라미: 보이는 크기 30px 그대로, 누르는 판 44px(::after) — 이웃 판과 덜 겹치게 간격 10px */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }

.sw {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--dusk);
  background: var(--c);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}

.sw[aria-checked="true"] { box-shadow: 0 0 0 2px var(--wool), 0 0 14px var(--c); }

.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field small { font-size: 13px; }

.field input,
textarea,
.note-form input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  background: var(--night);
  color: var(--wool);
  border-radius: 10px;
  padding: 9px 12px;
}

textarea { resize: none; }

.songs { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }

.song {
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: var(--display);
}

.song:hover { border-color: var(--line); }
.song.on { background: var(--dusk-2); border-color: var(--lamp); color: var(--lamp); }
.song.on::after { content: " · 재생 중"; font-family: var(--body); font-size: 12px; }

.note-form { display: flex; gap: 8px; }
.note-form input { flex: 1; min-width: 0; }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.notes li { background: var(--dusk-2); border-radius: 10px; padding: 7px 10px; }
.notes li b { color: var(--muted); font-weight: 400; margin-right: 4px; }
.notes li.mine { border: 1px solid var(--lamp); }

/* ── 겹침 창 ───────────────────────────── */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: rgb(10 11 25 / 0.62);
  backdrop-filter: blur(3px);
  animation: fade 0.25s ease;
}

.sheet {
  width: min(420px, 100%);
  max-height: 90%;
  overflow: auto;
  box-sizing: border-box;
  background: var(--dusk);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.45);
}

/* 숨·차 띠(.sheet-wrap.band): 장면을 흐리거나 어둡게 하지 않고, 화면 아래에 작은 띠(구슬/찻주전자·글자·그만하기)만.
   데스크톱은 장면 칸 아래 가운데, 휴대폰은 화면 아래. 띠 밖은 그대로 만질 수 있다. */
.sheet-wrap.band {
  inset: auto 0 0 0;
  display: flex;
  justify-content: center;
  padding-top: 0;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: none;
  backdrop-filter: none;
  pointer-events: none;
  animation: rise 0.3s ease;
}

.sheet-wrap.band .sheet {
  pointer-events: auto;
  width: auto;
  max-width: min(560px, 100%);
  max-height: none;
  overflow: visible;
  padding: 10px 12px 10px 14px;
  border-radius: 24px;
  background: var(--dusk);
  border-color: rgb(255 196 107 / 0.35);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.4);
}

.sheet-wrap.band :is(.breath, .tea) {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  justify-items: start;
  column-gap: 14px;
  row-gap: 0;
  text-align: left;
}

.sheet-wrap.band :is(.orb, .pot) { grid-column: 1; grid-row: 1 / span 2; }
.sheet-wrap.band :is(.breath, .tea) .btn { grid-column: 3; grid-row: 1 / span 2; white-space: nowrap; }
.sheet-wrap.band .breath p { grid-column: 2; grid-row: 1 / span 2; font-size: 15px; }
.sheet-wrap.band .tea .clock { grid-column: 2; grid-row: 1; font-size: 24px; line-height: 1.2; text-align: left; }
.sheet-wrap.band .tea p:not(.clock) { grid-column: 2; grid-row: 2; font-size: 13px; color: var(--muted); }

.sheet-wrap.band .orb {
  width: 68px;
  height: 68px;
  margin: 0;
  font-size: 14px;
  box-shadow: 0 0 22px rgb(255 196 107 / 0.45);
  transform: scale(0.86);
}
.sheet-wrap.band .orb[data-phase="in"],
.sheet-wrap.band .orb[data-phase="hold"] { transform: scale(1.1); }
.sheet-wrap.band .orb[data-phase="out"] { transform: scale(0.86); }

.sheet-wrap.band .pot { width: 58px; }
.sheet-wrap.band .steam { width: 6px; height: 22px; filter: blur(2px); }

/* 띠가 떠 있으면 알림은 띠 위로 */
body:has(.sheet-wrap.band:not(.in-panel)) .toasts { bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }

@media (min-width: 861px) {
  .sheet-wrap.band { right: var(--panel-w); }
}

/* 키가 낮은 화면(가로 휴대폰·200% 확대): 띠를 더 납작하게 해 장면을 덜 가린다 */
@media (max-height: 520px) {
  .sheet-wrap.band { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .sheet-wrap.band .sheet { padding-block: 6px; }
  .sheet-wrap.band .orb { width: 52px; height: 52px; font-size: 13px; }
  .sheet-wrap.band .pot { width: 46px; }
  body:has(.sheet-wrap.band:not(.in-panel)) .toasts { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}

/* 화면 아래 붙박이 띠가 떠 있는 동안(main.js가 띠 높이를 --sheet-band-h로 잰다): Tab 초점이 띠 밑에 머물지 않게 scroll-padding,
   좁은 화면은 패널 끝 단추(처음부터 다시 만들기)도 띠 위로 올릴 수 있게 패널 아래 여백을 띠 높이만큼 */
html:has(body > .sheet-wrap.band:not(.in-panel)) { scroll-padding-bottom: var(--sheet-band-h, 0px); }
@media (max-width: 860px) {
  body:has(> .sheet-wrap.band:not(.in-panel)) .panel { padding-bottom: max(calc(80px + env(safe-area-inset-bottom, 0px)), calc(var(--sheet-band-h, 0px) + 16px)); }
}

/* 처음부터 다시 만들기 확인 창: [지우기]는 창이 열리고 1초 동안 눌리지 않는다 */
.reset-ask .btn:disabled { opacity: 0.55; cursor: wait; }

@keyframes fade { from { opacity: 0; } }

.form { display: grid; gap: 12px; }
.form p { color: var(--muted); font-size: 13px; }

.brooch-new { display: grid; justify-items: center; text-align: center; gap: 8px; }
.brooch-big { height: 120px; width: auto; filter: drop-shadow(0 0 24px rgb(255 196 107 / 0.55)); animation: shine 1.2s ease; }
.brooch-new p { color: var(--muted); }
.eyebrow { font-size: 12px; letter-spacing: 0.12em; color: var(--lamp) !important; }

@keyframes shine {
  from { transform: scale(0.6) rotate(-12deg); opacity: 0; }
  60% { transform: scale(1.08) rotate(3deg); opacity: 1; }
}

.breath,
.tea { display: grid; justify-items: center; gap: 14px; text-align: center; }

.orb {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 20px;
  color: var(--lamp-ink);
  background: radial-gradient(circle at 35% 30%, #fff1d8, var(--lamp) 55%, var(--blush));
  box-shadow: 0 0 40px rgb(255 196 107 / 0.45);
  transform: scale(0.8);
  transition-property: transform;
  transition-timing-function: ease-in-out;
  margin: 18px 0;
}

.orb[data-phase="in"],
.orb[data-phase="hold"] { transform: scale(1.15); }
.orb[data-phase="out"] { transform: scale(0.8); }

.pot { position: relative; width: 170px; }
.pot img { display: block; width: 100%; }

.steam {
  position: absolute;
  left: 46%;
  top: 2%;
  width: 14px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(to top, rgb(255 255 255 / 0.5), transparent);
  filter: blur(4px);
  animation: steam 3s ease-in-out infinite;
}

.steam.s2 { left: 56%; animation-delay: -1.5s; }

@keyframes steam {
  0% { transform: translateY(10px) scaleY(0.6); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: translateY(-34px) scaleY(1.2); opacity: 0; }
}

/* ── 첫 화면 ───────────────────────────── */
.start {
  position: relative;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding-block: 32px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  box-sizing: border-box;
  overflow: hidden;
}

.start-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.55) blur(2px);
  transform: scale(1.04);
}

.start-card {
  position: relative;
  width: min(560px, 100%);
  box-sizing: border-box;
  display: grid;
  gap: 16px;
  padding: 28px;
  border-radius: 24px;
  background: rgb(31 34 66 / 0.9);
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.5);
}

.start-card h1 { font-size: 40px; color: var(--lamp); letter-spacing: 0.02em; }
.start-card .lead { color: var(--wool); }
.fine { font-size: 13px; color: var(--muted); text-align: center; }

.doll-pick { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.doll-pick legend { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.doll-pick legend small { font-size: 12px; }

.pick {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 10px 4px 8px;
  border-radius: 14px;
  background: var(--dusk-2);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}

.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick img { height: 72px; width: auto; transition: transform 0.2s; }
.pick:hover img { transform: translateY(-3px); }
/* 고른 인형은 손을 흔든다 */
.pick-doll { position: relative; display: block; }
.pick-doll .pick-wave { position: absolute; left: 0; top: 0; opacity: 0; }
.pick:hover .pick-wave,
.pick:has(input:checked) .pick-wave { opacity: 1; }
.pick:hover .pick-doll > img:first-child,
.pick:has(input:checked) .pick-doll > img:first-child { opacity: 0; }
.pick:has(input:checked) { border-color: var(--lamp); color: var(--wool); background: rgb(255 196 107 / 0.12); }
.pick:has(input:focus-visible) { outline: 2px solid var(--lamp); outline-offset: 2px; }

/* ── 알림 ──────────────────────────────── */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 30;
  display: grid;
  gap: 6px;
  justify-items: center;
  pointer-events: none;
  width: min(420px, calc(100% - 32px));
}

.toast {
  background: var(--wool);
  color: var(--lamp-ink);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  animation: rise 0.3s ease;
  transition: opacity 0.4s, transform 0.4s;
  text-align: center;
}

.toast .ico { height: 1.3em; vertical-align: -0.28em; }
.toast.level { background: var(--lamp); font-weight: 700; }
.toast.soft { background: var(--dusk-2); color: var(--wool); border: 1px solid var(--line); }
/* 진짜 사람이 들어왔을 때 한 줄(toast(…, "soft live")): 이름표와 같은 초록 점 */
.toast.live::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--live);
  vertical-align: 0.05em;
}
.toast.out { opacity: 0; transform: translateY(6px); }
/* 누를 수 있는 한 줄(같이 가기 '복사했어요 · 링크 보기') */
.toast-act .link { pointer-events: auto; color: var(--lamp); font-size: 14px; padding: 6px 2px; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.noscript { padding: 24px; text-align: center; }

/* ── 첫 방문·접근성·예불(main.js) ───────────── */
/* 화면 읽기 프로그램에만 들리는 글(장소를 옮겼을 때 '산사 마당에 왔어요' 등) */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* 장소를 옮기면 장면에 초점이 온다: 테두리를 장면 안쪽에 */
.view:focus-visible { outline-offset: -3px; }

/* 초점 받은 사물·인형·패널 단추가 붙박이 머리띠에 가리지 않게(200% 확대) */
.hot,
.doll,
.host,
.panel :is(button, a, input, textarea, [tabindex]) { scroll-margin-top: calc(var(--header-h) + 12px); }

/* 머리말 칩: 아직 보지 않은 새 브로치(첫 쉼 전에 조용히 받은 것) */
.chip-new {
  width: 8px;
  height: 8px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--blush);
  box-shadow: 0 0 0 2px var(--dusk-2);
}

/* 가까이 간 사물: 장면 위 가운데 고정 칩('E 범종 울리기'). 사물 위 이름표가 종 몸체·인형 머리를 가리지 않게 그 이름표는 숨긴다 */
.near-chip {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  z-index: 21;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 32px);
  padding: 6px 14px;
  border: 1px solid rgb(255 196 107 / 0.6);
  border-radius: 999px;
  background: var(--veil);
  color: var(--wool);
  font-family: var(--display);
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 0 16px rgb(255 196 107 / 0.3);
  animation: fade 0.2s ease;
}
.near-chip::after { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%); }
.near-chip:hover { background: var(--lamp); color: var(--lamp-ink); }
.near-chip kbd { font: 12px var(--body); padding: 0 5px; border: 1px solid var(--line); border-radius: 4px; }
.view:has(.doll--me.sitting) .near-chip,
body:has(.sheet-wrap:not(.ask)) .near-chip { display: none; } /* 묻기 띠는 걷기·E를 막지 않으니 칩도 그대로 */
/* (휴대폰은 누른 사물에 :hover가 남으므로 hover여도 숨긴다 — 이름은 칩에 있다) */
.view:not(.hinting):has(.near-chip:not([hidden])) .hot.near:not(:focus-visible) .hot-label { opacity: 0; }
@media (hover: none) { .near-chip kbd { display: none; } }

/* 예불: 3분 동안 장면 위 가운데 '같이 고개 숙이기'(카메라와 상관없이 늘 보인다). 가까이 칩 아래 */
.follow-chip.yebul-chip {
  left: 50%;
  top: 56px;
  transform: translateX(-50%);
  z-index: 22;
  padding: 7px 14px;
  font-size: 14px;
  animation: fade 0.3s ease, beckon 1.6s ease-out 0.3s 2; /* rise(transform)는 가운데 맞춤과 섞이므로 밝기만 */
}
.follow-chip.yebul-chip[aria-pressed="true"] { border-color: var(--live); color: var(--wool); }
.card.yebul .btn { justify-self: start; }
.card.yebul h2 { font-size: 15px; }
.yebul-today { font-size: 13px; color: var(--wool); }
.bubble-note { display: block; margin-top: 2px; font-size: 12px; color: var(--ember); }

/* 내 방: 최근 28일 예불 함께한 날(칸마다 새벽·저녁·밤 세 점) */
.yebul-days { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 3px; }
.yebul-days i { display: grid; justify-items: center; gap: 2px; padding: 3px 0; border-radius: 4px; background: var(--dusk-2); }
.yebul-days b { width: 5px; height: 5px; border-radius: 50%; background: rgb(243 231 211 / 0.14); }
.yebul-days b.on { background: var(--lamp); }

/* 내 방: 새로 받은 브로치(첫 쉼 전에 조용히 받은 것) */
.new-brooch { border-color: rgb(255 196 107 / 0.5); }
.new-brooch-row { display: flex; align-items: center; gap: 10px; }
.new-brooch-row img { height: 44px; width: auto; flex: none; }
.new-brooch-row span { display: grid; flex: 1; min-width: 0; font-size: 14px; }
.new-brooch-row small { color: var(--muted); font-size: 13px; }

/* 잠긴 브로치: 이름과 진행을 보이고 초점을 받는다(누르면 받는 법) */
.brooch.locked { cursor: pointer; }
.brooch small { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.brooch-info { justify-items: center; text-align: center; }
.brooch-big.locked { height: 88px; filter: grayscale(1) brightness(0.6); animation: none; }

/* 응원 무대: 최애 이름 리본(이 기기에서만 — 남에게 보내지 않는다) */
.cheer-ribbon {
  position: absolute;
  left: 86%;
  top: 34%;
  max-width: 7em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1.5px solid var(--c, var(--lamp));
  background: rgb(255 246 230 / 0.92);
  color: var(--lamp-ink);
  font-size: 11px;
  line-height: 1.3;
  pointer-events: none;
}
.song small { font-family: var(--body); font-size: 12px; color: var(--muted); }

/* 차 한 잔 띠: 숫자 시계를 숨기면 김과 글만 */
.sheet-wrap.band .tea.noclock p:not(.clock) { grid-row: 1 / span 2; }

/* 예시 기록 띠(머리말 바로 아래). 데스크톱은 장면·패널 높이에서 띠 높이만큼 뺀다 */
.demo-band {
  --band-h: 34px;
  height: var(--band-h);
  box-sizing: border-box;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  font-size: 13px;
  color: var(--lamp-ink);
  background: var(--lamp);
  white-space: nowrap;
}
.demo-band .link { color: var(--lamp-ink); font-size: 13px; font-weight: 700; }
.demo-band + .place { height: calc(100% - var(--header-h) - 34px); }

/* 산사 하늘: 오늘 밤 진짜 연등 수만큼(서버가 센 수) 색 없는 작은 연등 실루엣(펠트 연등 아이콘을 작게·옅게 — 별·반딧불과 구별).
   장면 그림 바로 위, 내 연등·반딧불 아래 */
/* 카메라가 장면을 위로 올리면(--cy < 0 — 휴대폰·200%) 하늘 위쪽이 장면 창 밖이라, 실루엣 띠를 그만큼 내려 늘 보이는 하늘 쪽에 둔다(먼 하늘처럼) */
.tonight-sky { position: absolute; inset: 0; z-index: 2; pointer-events: none; translate: 0 calc(-1 * min(0px, var(--cy, 0px))); }
.tonight-sky i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 1.4%;
  aspect-ratio: 1;
  translate: -50% -50%;
  background: url(assets/icon/lantern.webp) center / contain no-repeat;
  filter: grayscale(0.7) brightness(1.3) drop-shadow(0 0 4px rgb(255 236 200 / 0.6));
  opacity: 0.75;
  animation: twinkle 4.8s ease-in-out var(--d) infinite;
}
@keyframes twinkle { 50% { opacity: 0.45; } }

/* '이뤄졌어요' 연등: 연꽃 색으로 조금 더 환하게(7일) */
.lamp.lotus { filter: drop-shadow(0 0 22px var(--c)) drop-shadow(0 0 8px var(--c)) brightness(1.06); }

/* 작은 등불(등불 달력 칸·연등 일기): 크림색 그림 + 같은 모양 색 층(산사 연등과 같은 방법) */
.mini-lamp { position: relative; display: inline-block; height: 26px; aspect-ratio: 376 / 400; isolation: isolate; flex: none; }
.mini-lamp img { display: block; height: 100%; width: auto; }
.mini-lamp i {
  position: absolute;
  inset: 0;
  background: var(--c);
  mix-blend-mode: color;
  opacity: 0.85;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.mini-lamp.tinted { filter: drop-shadow(0 0 5px var(--c)); }

/* 등불 달력: 7칸 × 4줄(오래된 날 → 오늘). 온 날엔 등불, 쉬어 간 날은 빈 칸. 칸을 고르면 아래 한 줄 */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 1px;
  aspect-ratio: 1 / 1.1;
  min-height: 42px;
  padding: 0 0 2px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--dusk-2);
  cursor: pointer;
}
.cal-day:not(.on) { background: rgb(42 45 85 / 0.45); }
.cal-day .mini-lamp { height: 24px; }
.cal-day small { font-size: 12px; line-height: 1.2; color: var(--wool); opacity: 0.82; font-variant-numeric: tabular-nums; }
.cal-day { position: relative; }
/* 누워 쉰 밤: 칸 오른쪽 위 작은 달 · 예불 함께한 밤: 왼쪽 위 작은 합장(펠트 아이콘) */
.cal-mark { position: absolute; top: 2px; line-height: 0; pointer-events: none; }
.cal-mark.moon { right: 2px; }
.cal-mark.pray { left: 2px; }
.cal-ico { width: 14px; height: 14px; object-fit: contain; }
/* ★친구 카드를 눌렀을 때: 함께하지 않은 밤은 흐리게 */
.cal-day.dim { background: rgb(42 45 85 / 0.45); }
.cal-day.dim :is(.mini-lamp, .cal-mark) { opacity: 0.16; filter: grayscale(1); }
.cal-filter { font-size: 13px; color: var(--lamp); }
.friends .friend-pick { all: unset; display: block; width: 100%; box-sizing: border-box; cursor: pointer; border-radius: 8px; }
.friends .friend-pick:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; }
.friends .friend-pick[aria-pressed="true"] b { color: var(--lamp); }
.friends .friend-pick small { color: var(--muted); }
/* 작업실 이번 주: 한 줄 + 7칸 막대(월~일, 밤 날짜) */
.study-week { display: grid; gap: 4px; margin-top: 6px; width: 100%; box-sizing: border-box; justify-self: stretch; }
#study-week { width: 100%; }
.study-week p { font-size: 13px; color: var(--wool); }
.week-bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; align-items: end; height: 46px; }
.week-bars span { display: grid; grid-template-rows: 1fr auto; height: 100%; justify-items: center; gap: 2px; }
.week-bars i { align-self: end; width: min(70%, 20px); min-height: 2px; height: var(--h); border-radius: 4px 4px 2px 2px; background: var(--lamp); opacity: 0.85; }
.week-bars span.future i { opacity: 0.15; }
.week-bars small { font-size: 12px; color: var(--muted); line-height: 1; }
.week-bars span.today small { color: var(--lamp); }
.cal-day.today small { color: var(--lamp); }
.cal-day[aria-checked="true"] { border-color: var(--lamp); }
.cal-day:hover { border-color: rgb(255 196 107 / 0.5); }
.night-line { font-size: 13px; color: var(--wool); min-height: 1.55em; }

/* 기록 카드 끝: 이 브라우저에만 있다는 안내와 기록 꾸러미 */
/* position: relative — 숨긴 파일 칸(.sr-only, absolute)이 패널 안에 머물게(아니면 페이지 끝에 놓여 세로로 넘친다) */
.keep { position: relative; display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.keep-note { font-size: 13px; color: var(--muted); }
.keep .btn { padding: 8px 14px; font-size: 13px; }
.keep-msg { font-size: 13px; color: var(--blush); }
.pack-ask b { color: var(--wool); font-weight: 400; }

/* 연등 일기(책장) */
.diary-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 52vh; overflow-y: auto; }
.diary-list li { display: flex; align-items: center; gap: 10px; background: var(--dusk-2); border-radius: 10px; padding: 6px 10px; }
.diary-list li > span:last-child { display: grid; min-width: 0; font-size: 14px; }
.diary-list time { font-size: 12px; color: var(--muted); }
.diary-list small { font-size: 12px; color: var(--lamp); }
.diary-list li > span:nth-child(2) { display: grid; min-width: 0; font-size: 14px; flex: 1; }
.diary-list .done-btn { margin-left: auto; flex: none; padding: 5px 10px; font-size: 12px; }
.diary-list li:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; }
.diary-nav:empty { display: none; }
.diary-nav .btn { padding: 7px 12px; font-size: 13px; }

/* 다시 온 날: 보리가 어제 단 연등을 묻는 아래 띠(초점을 가져가지 않는다) */
.wish-ask { display: flex; gap: 12px; align-items: flex-start; }
.wish-ask .avatar { width: 44px; height: 44px; }
.wish-ask > div { display: grid; gap: 6px; min-width: 0; }
.wish-ask b { color: var(--lamp); }
.wish-ask .wish-text { font-family: var(--display); }
.wish-ask .btn { padding: 7px 12px; font-size: 13px; }
/* 묻는 띠가 떠 있을 때 23시 보리 한 줄(알림이 띠를 덮지 않게 띠 안 맨 위에 — rituals.js boriSays) */
.ask-aside { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--lamp); font-size: 13px; animation: fade 0.3s ease; }
.ask-aside .ask-aside-ico { height: 1.2em; width: auto; flex: none; }
/* 데스크톱: 묻기 띠는 패널 맨 위에(장면 속 내 인형·친구를 가리지 않게) */
.sheet-wrap.band.in-panel { position: static; inset: auto; padding: 0; display: block; z-index: auto; pointer-events: auto; flex: none; }
.sheet-wrap.band.in-panel .sheet { width: 100%; max-width: none; box-shadow: none; border-radius: var(--radius); }
/* 답 없이 닫힌 물음: 산사·내 방 패널 말풍선에 한 번(답 단추와 함께) */
.ask-bubble { display: grid; gap: 8px; }
.ask-bubble .moods { flex-wrap: wrap; gap: 6px; }
.ask-bubble .btn { padding: 6px 10px; font-size: 13px; }
.ask-bubble .link { color: var(--ember); }
/* 같은 기기의 다른 탭이 열려 이 탭은 쉰다(저장하지 않음): 화면 위 가운데 띠 */
.tab-band {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
  padding: 8px 10px 8px 16px;
  border: 1px solid rgb(255 196 107 / 0.45);
  border-radius: 999px;
  background: var(--dusk);
  color: var(--wool);
  font-size: 14px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.45);
}
.tab-band .btn { padding: 7px 12px; font-size: 13px; white-space: nowrap; }
.tab-band:has(.tab-run) { border-radius: 18px; }
.tab-band .tab-run { display: block; font-size: 12px; color: var(--lamp); }
body:has(#tab-band) #app { filter: saturate(0.55) brightness(0.75); } /* 쉬는 탭: 화면이 멈춰 있다는 것이 보이게 */

/* ── 밤·산사 정시 의식(rituals.js) ─────────────── */
/* 23시 같이 불 끄기의 '5분 뒤' 예고는 정시 의식 띠(#herald — 끝 'B 구역')가 맡는다(예전 머리말 칩·휴대폰 장면 띠 대신) */
/* 23:00부터 장면 등불(마당 줄 등·산사 석등·내 방 스탠드 — 장면 그림)이 30초에 걸쳐 어두워진다. 늦게 들어오면 곧바로(.lights-now) */
.stage.lights-dim .bg,
.stage.lights-dim .occ img { filter: brightness(0.5) saturate(0.8); transition-duration: 30s; }
.stage.lights-dim :is(.doll-body, .host-body) { filter: brightness(0.86); transition-duration: 30s; }
.stage.lights-dim .mala img { filter: brightness(0.6); }
.stage.lights-now :is(.bg, .occ img, .doll-body, .host-body) { transition-duration: 0s; }
/* 누운 채·불 끄기 중 스탠드를 끄면 한 단계 더 어둡게(위 두 규칙이 .lamp-off를 덮어 스탠드 끄기가 무반응이었다) — 창밖 별빛만 남는 소등 */
.stage:is(.sleep, .lights-dim).lamp-off .bg,
.stage:is(.sleep, .lights-dim).lamp-off .occ img { filter: brightness(0.35) saturate(0.75); transition-duration: 1.2s; }
.stage:is(.sleep, .lights-dim).lamp-off .doll-body { filter: brightness(0.5) saturate(0.8); transition-duration: 1.2s; }
/* 3분 동안 진짜 사람(나 포함) 머리 위 작은 초. 끈 사람은 꺼진 초(빛 없이 흐리게 — 꺼진 초 그림이 따로 없다) */
.head-candle {
  position: absolute;
  left: 50%;
  bottom: 95%; /* 인형 그림 위쪽 빈 자리만큼 내려 머리 바로 위에 */
  height: max(22px, 18%);
  translate: -50% 0;
  z-index: 3;
  pointer-events: none;
}
.head-candle .candle-ico {
  display: block;
  height: 100%;
  width: auto;
  filter: drop-shadow(0 0 5px rgb(255 196 107 / 0.95)) drop-shadow(0 0 12px rgb(255 170 80 / 0.55));
  animation: candle-glow 2.6s ease-in-out infinite alternate;
}
.head-candle.out .candle-ico { filter: grayscale(0.7) brightness(0.72) drop-shadow(0 0 2px rgb(13 14 30 / 0.7)); animation: none; }
@keyframes candle-glow { to { filter: drop-shadow(0 0 3px rgb(255 196 107 / 0.7)) drop-shadow(0 0 8px rgb(255 170 80 / 0.35)); } }
.sleeping .head-candle { display: none; }
.doll:has(.head-candle) .say { bottom: calc(108% + 22px); }
.view:has(#lights-scene-chip) .hot[data-hot="wish"]:not(:focus-visible) .hot-label { opacity: 0; }/* 패널 카드: 같이 불 끄기(22:55~23:13) · 108 염주(산사) */
.lights-card,
.beads-card { font-size: 14px; line-height: 1.6; }
.lights-card { border-color: rgb(255 196 107 / 0.45); }
:is(.lights-card, .beads-card) h2 { font-size: 15px; }
:is(.lights-card, .beads-card) h2 > span { display: inline-flex; align-items: center; gap: 6px; }
:is(.lights-card, .beads-card) .btn { justify-self: start; }
.bead-ico { height: 1.1em; width: auto; }
.lights-count { font-size: 13px; color: var(--lamp); } /* 염주 카드의 서버 수 줄은 #beads-goal(together.js · C 구역) */
/* 작업실: 23시 같이 불 끄기 한 줄(칩·알림 없이 — rituals.js paintStudyLine) */
.lights-study { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--lamp); }
.lights-study .ico { height: 1.2em; width: auto; flex: none; }
/* 등불 달력: 23시 같이 불 끈 밤은 칸 왼쪽 아래 작은 초 */
.cal-mark.lights { top: auto; bottom: 2px; left: 2px; }
/* '잘 자요' 카드(침대에 누우면 · 아래 띠) */
.good-night-band .sheet { padding: 14px 18px; border-radius: 20px; }
body:has(.sheet-wrap.band.good-night-band:not(.in-panel)) .toasts { bottom: calc(250px + env(safe-area-inset-bottom, 0px)); } /* 카드가 띠보다 높다: 알림은 그 위로 */
@media (max-width: 600px) { body:has(.sheet-wrap.band.good-night-band:not(.in-panel)) .toasts { bottom: calc(330px + env(safe-area-inset-bottom, 0px)); } }
.good-night { display: grid; gap: 8px; max-width: 440px; }
.good-night h2 { font-size: 17px; justify-content: flex-start; }
.good-night h2 .ico { margin-right: 4px; }
.good-night p { font-size: 14px; }
.good-night p small { display: block; font-size: 12px; color: var(--muted); }
.good-night .gn-count { color: var(--lamp); }
.good-night .gn-count small { display: inline; margin-left: 4px; }
.good-night :is(.gn-how, .gn-note) { font-size: 12px; color: var(--muted); }
.good-night .gn-note:empty { display: none; }
.good-night .row { display: flex; flex-wrap: wrap; gap: 8px; }
.good-night .btn { padding: 7px 12px; font-size: 13px; }
/* 108 염주 띠: 펠트 염주 한 줄(가운데 알이 엄지 자리) · 몇 알째 · 한 알 넘기기 · 그만하기 */
.beads-band {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 6px;
}
.bead-row {
  position: relative;
  grid-column: 1 / -1;
  justify-self: center;
  width: min(330px, 76vw);
  height: 36px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent);
}
.bead-row::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; background: rgb(166 98 60 / 0.7); }
.bead-row::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  translate: -50% -50%;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgb(255 196 107 / 0.75), 0 0 12px rgb(255 196 107 / 0.45);
}
.bead-track { position: relative; display: flex; justify-content: center; align-items: center; gap: 2px; height: 100%; }
.bead-track img { flex: none; width: 28px; height: 28px; object-fit: contain; user-select: none; }
.bead-track.step { animation: bead-step 0.18s ease-out; }
@keyframes bead-step { from { transform: translateX(30px); } }
.bead-count { font-size: 14px; color: var(--muted); line-height: 1.3; }
.bead-count b { font-size: 22px; color: var(--lamp); font-variant-numeric: tabular-nums; }
.bead-count small { display: block; font-size: 12px; }
.bead-next { justify-self: stretch; }
.bead-next kbd { margin-left: 6px; padding: 0 5px; font: 12px var(--body); border: 1px solid rgb(42 28 5 / 0.35); border-radius: 4px; }
/* 내 방 벽 염주 걸이(스탠드 위 못): 돌린 바퀴 '염주 n바퀴' */
/* 걸이는 스탠드 옆 벽 가운데 높이(창 오른쪽 커튼 밑 · 협탁 왼쪽) — 장면 위쪽은 휴대폰·200%에서 머리띠 밑으로 잘려 걸이·글이 보이지 않았다 */
.mala { position: absolute; left: 55%; top: 41.5%; height: 14%; translate: -50% 0; z-index: 4; pointer-events: none; }
.mala img { display: block; height: 100%; width: auto; max-width: none; filter: drop-shadow(0 3px 4px rgb(0 0 0 / 0.25)); transition: filter 1.2s ease; }
.mala small { position: absolute; left: 50%; top: 100%; translate: -50% 0; margin-top: 2px; padding: 1px 8px; border-radius: 999px; background: var(--veil); color: var(--wool); font-size: 12px; white-space: nowrap; }
.stage:is(.lamp-off, .sleep) .mala img { filter: brightness(0.55); }

/* 오늘의 하늘: 이 기기 시각에 따라 장면 그림 바로 위에 색 막 한 장(인물·사물·이름표 아래라 글자 대비는 그대로).
   새벽 05~07 · 낮 07~17 · 노을 17~19 · 밤 19~23 · 깊은 밤 23~05. 산사 그림은 노을, 마당은 밤, 내 방은 창만 바꾼다.
   깊은 밤에도 산사 석등 자리는 막에 구멍을 내 밝게 둔다(매단 연등·인물은 막 위라 그대로 밝다) */
.sky-veil { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.sky-veil[data-sky="dusk"] { display: none; }
body[data-route="temple"] .sky-veil[data-sky="dawn"] { mix-blend-mode: color; background: linear-gradient(180deg, rgb(140 165 215 / 0.6), rgb(165 180 215 / 0.4) 32%, transparent 52%); }
body[data-route="temple"] .sky-veil[data-sky="day"] { mix-blend-mode: color; background: linear-gradient(180deg, rgb(95 165 235 / 0.8), rgb(110 175 230 / 0.6) 30%, transparent 50%); }
body[data-route="temple"] .sky-veil:is([data-sky="night"], [data-sky="late"]) {
  mix-blend-mode: multiply;
  -webkit-mask-image: radial-gradient(5% 9% at 18.8% 50.5%, transparent 35%, #000 100%);
  mask-image: radial-gradient(5% 9% at 18.8% 50.5%, transparent 35%, #000 100%);
}
body[data-route="temple"] .sky-veil[data-sky="night"] { background: rgb(55 62 140 / 0.55); }
body[data-route="temple"] .sky-veil[data-sky="late"] { background: rgb(22 26 78 / 0.74); }
body[data-route="yard"] .sky-veil[data-sky="dawn"] { mix-blend-mode: screen; background: linear-gradient(180deg, rgb(80 105 160 / 0.8), rgb(60 80 120 / 0.35) 40%, transparent 65%); }
body[data-route="yard"] .sky-veil[data-sky="day"] { mix-blend-mode: screen; background: linear-gradient(180deg, rgb(115 165 230), rgb(100 150 210 / 0.75) 30%, rgb(70 90 110 / 0.25) 60%, transparent 80%); }
body[data-route="yard"] .sky-veil[data-sky="dusk"] { display: block; mix-blend-mode: screen; background: linear-gradient(180deg, rgb(150 70 95 / 0.75), rgb(120 60 70 / 0.35) 40%, transparent 65%); }
body[data-route="yard"] .sky-veil[data-sky="night"] { display: none; }
body[data-route="yard"] .sky-veil[data-sky="late"] { mix-blend-mode: multiply; background: linear-gradient(180deg, transparent 30%, rgb(40 40 95 / 0.5)); }
/* 내 방은 창(유리 칸 38~52% · 5~32%)에만, 가장자리는 흐리게(네모 테두리가 보이지 않게). 창 그림이 원래 밤이라 밤·깊은 밤은 그대로 */
body[data-route="room"] .sky-veil { inset: 5.5% auto auto 38.6%; width: 13.4%; height: 26.5%; filter: blur(6px); }
body[data-route="room"] .sky-veil[data-sky="dawn"] { mix-blend-mode: screen; background: rgb(120 150 205 / 0.6); }
body[data-route="room"] .sky-veil[data-sky="day"] { mix-blend-mode: screen; background: rgb(130 185 240 / 0.85); }
body[data-route="room"] .sky-veil:is([data-sky="night"], [data-sky="late"]) { display: none; }
/* 내 방 창: 노을 시간엔 창만 노을빛(산사 그림처럼 원래 노을인 장면이 아니라서) */
body[data-route="room"] .sky-veil[data-sky="dusk"] { display: block; mix-blend-mode: screen; background: rgb(225 115 100 / 0.55); }

/* ── 휴대폰 ────────────────────────────── */
@media (max-width: 860px) {
  .place {
    display: block;
    height: auto;
  }

  .view { height: 58svh; min-height: 300px; }
  .edge-hint { font-size: 12px; padding: 5px 10px; }
  /* 좁은 장면에선 말풍선을 좁게(줄을 늘려) — 넓으면 가장자리에서 안쪽으로 밀리며 옆 방석에 앉은 내 인형을 덮는다 */
  .say { max-width: 150px; }

  /* 장면과 패널이 위아래로 이어지는 화면: #app이 화면 높이에 묶이면 붙박이 머리띠가 #app 끝에서 반쯤 잘려 올라간다(200% 확대) */
  .app { height: auto; min-height: 100%; }

  /* 첫 안내 띠(위쪽)가 떠 있는 동안 가까이 칩은 기다리고, 예불 단추는 띠 아래로 */
  .view.hinting .near-chip { display: none; }
  .view.hinting .follow-chip.yebul-chip { top: 72px; }

  /* 첫 안내 띠는 장면 위쪽(하늘)에: 아래쪽 가장자리 표지·내 이름표와 겹치지 않게. 좁으면 두 줄로 */
  .pan-hint {
    top: 12px;
    bottom: auto;
    width: max-content;
    max-width: calc(100% - 32px);
    box-sizing: border-box;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
  }

  /* 띠가 떠 있는 동안 표지는 숨었다가, 띠가 걷히면(.hinting을 떼면) 나타난다 */
  .view.hinting .edge-hint { opacity: 0; visibility: hidden; }

  .panel {
    overflow: visible;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }

  .demo-band + .place { height: auto; }
  .nav { margin-left: 0; }
  .nav a { padding: 6px 8px; }
  .chip b { display: none; }
  .brand { font-size: 16px; }
  .spot { font-size: 12px; padding: 4px 10px; }
}

@media (max-width: 420px) {
  .icon-btn { padding: 5px 8px; font-size: 12px; }
  .top { gap: 6px; }
  .focus-chip { padding: 3px 8px; font-size: 12px; }
  .focus-chip span { display: none; }
  .brand { font-size: 0; gap: 0; }
  .doll-pick { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .pick img { height: 56px; }
  .start-card { padding: 20px; }
  .start-card h1 { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .orb { transition-duration: 0.01ms !important; }

  /* 끝 프레임이 '안 보임'인 반응 그림은 길이를 줄이면 생기자마자 사라진다:
     움직임 없이 그대로 보이고, 지우는 일은 JS가 한다(이모트 1.8초·물결 3.2초·걸음 고리 0.7초 뒤 remove) */
  .emote,
  .ripple,
  .walk-ring {
    animation: none !important;
    opacity: 1;
  }
  /* 범종 물결: 퍼지지 않는 고리 하나(세 겹이 같은 자리에 겹친다) */
  .ripple { transform: scale(2.4); border-width: 1.5px; }
  .walk-ring { transform: none; }

  /* 움직임 없이 밝기만 바뀌는 것은 원래 길이로 보였다 사라진다(JS가 지우지 않아도 끝난다) */
  .pan-hint { animation: hint 5s ease forwards !important; }
  .chip.glow { animation: chipglow-still 2.4s ease-out !important; }
  .doll--me.spawn::before { animation: me-ring-still 2.4s ease-out forwards !important; }
  .card.flash { animation-duration: 1.4s !important; }
}

/* ── 응원 무대: 리나 정시 무대 · 노래 · 사진(main.js 리나 정시 무대·사진, stage.js, photo.js) ───────── */
/* 장면 오른쪽 위 카메라 단추(응원 중에도 누를 수 있게 · 내 방에도). 휴대폰은 44px */
.cam-btn {
  position: absolute;
  right: max(10px, env(safe-area-inset-right, 0px));
  top: 10px;
  z-index: 4; /* 장면 위 · 붙박이 머리띠(5)와 겹침 창(20)·가장자리 표지(20) 아래 — 휴대폰에서 장면이 머리띠 밑으로 밀려도 그 위에 뜨지 않게 */
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgb(255 196 107 / 0.55);
  border-radius: 50%;
  background: var(--veil);
  cursor: pointer;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.35);
}
.cam-btn .ico { height: 24px; vertical-align: 0; }
.cam-btn:hover { background: var(--lamp); }
.cam-btn::after { content: ""; position: absolute; inset: -4px; } /* 누르는 판은 48px */
@media (pointer: coarse), (max-width: 860px) {
  .cam-btn { width: 44px; height: 44px; }
  .cam-btn .ico { height: 26px; }
}

/* 무대 막(CSS로 그린 천 — 펠트 막 그림이 생기면 바꾼다): 무대 틀 안쪽(가로 29.5~70%, 위 9%~무대 앞끝 57%).
   리나(z 510)보다 앞, 무대 앞 관객(z 680~)보다 뒤. 시작 1분 전부터 내려와 있고(.shut — 리나 이름표까지 가린다), 시작하면 양옆으로 걷혀 묶인다(.open) */
.curtain {
  position: absolute;
  left: 29.5%;
  width: 40.5%;
  top: 9%;
  height: 48%;
  z-index: 600;
  pointer-events: none;
  transition: opacity 0.8s ease;
}
.curtain i {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 51%;
  transform: scaleX(0);
  background:
    repeating-linear-gradient(90deg, rgb(0 0 0 / 0.18) 0 4%, rgb(255 230 240 / 0.07) 7%, rgb(0 0 0 / 0.18) 10%),
    linear-gradient(180deg, #a2405f, #7c2a49 68%, #5f1f39);
  box-shadow: inset 0 -6px 0 rgb(255 214 160 / 0.35), 0 6px 18px rgb(0 0 0 / 0.35);
  transition: transform 2.6s cubic-bezier(0.55, 0.05, 0.25, 1);
}
/* 천의 결(작은 잡음 무늬) */
.curtain i::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  mix-blend-mode: overlay;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.curtain .l { left: 0; transform-origin: left center; border-radius: 0 0 22% 0 / 0 0 6% 0; }
.curtain .r { right: 0; transform-origin: right center; border-radius: 0 0 0 22% / 0 0 0 6%; }
.curtain.shut i { transform: scaleX(1); }
.curtain.open i { transform: scaleX(0.12); }
.curtain.still i { transition: none; }
.curtain.gone { opacity: 0; }
/* 막이 오르면 리나 쪽에 은은한 조명 */
.curtain::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  top: 6%;
  bottom: -28%;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 45%, rgb(255 238 196 / 0.3), transparent 68%);
  mix-blend-mode: screen;
  transition: opacity 1.6s ease 1s;
}
.curtain.open::after { opacity: 1; }

/* 정시 무대 '같이 흔들기': 장면 위 가운데 맨 위(휴대폰에서 리나 말풍선을 가리지 않게). 무대 동안 가까이 칩('무대를 향해 응원' — 같은 일)은 쉰다.
   마당 장소 카드는 정시 의식 띠가 가리키는 곳이면 5분 전부터 은은히 빛난다(.soon — 무대·산사·작업실 모두, herald.js) */
.follow-chip.show-chip { top: 12px; }
.view:has(#show-chip) .near-chip { display: none; }
.follow-chip.show-chip[aria-pressed="true"] { border-color: var(--live); }
.place-card.soon { border-color: var(--lamp); box-shadow: 0 0 0 1px rgb(255 196 107 / 0.45), 0 0 18px rgb(255 196 107 / 0.22); }

/* 패널 무대 카드 */
.card.show-card { border-color: rgb(255 196 107 / 0.45); font-size: 14px; }
.card.show-card h2 { font-size: 15px; }
#show-state { color: var(--lamp); }
.show-today { font-size: 13px; color: var(--wool); }
.card.show-card > small { color: var(--muted); font-size: 13px; }

/* 노래 목록: 곡 길이 · 누가 튼 노래 */
.song { display: flex; align-items: baseline; gap: 6px; }
.song .dur { order: 2; margin-left: auto; font-family: var(--body); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.song.on::after { order: 1; }
.song-by { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--wool); }
.song-by .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); display: inline-block; flex: none; }

/* 내 방 책장: 리나의 곡 카드(그림 없이 글·아이콘) */
.song-card-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.song-card-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--dusk-2);
  border: 1px solid rgb(255 196 107 / 0.4);
}
.song-card-list li > span { grid-row: span 2; }
.song-card-list li .ico { height: 22px; vertical-align: 0; }
.song-card-list b { font-family: var(--display); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-card-list small { grid-column: 2; font-size: 12px; color: var(--muted); }
.song-card-list li.locked { background: none; border-style: dashed; border-color: var(--line); }
.song-card-list li.locked b { color: var(--muted); font-weight: 400; }
.song-card-list li.locked .ico { filter: grayscale(1) brightness(0.75); }

/* 사진 미리보기 창 */
.sheet-wrap.photo .sheet { width: min(560px, 100%); }
.photo-sheet { display: grid; gap: 12px; }
.photo-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.pick-chip { min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--dusk-2); cursor: pointer; font-size: 14px; }
.pick-chip[aria-checked="true"] { border-color: var(--lamp); color: var(--lamp); }
.photo-frame { display: grid; place-items: center; background: var(--night); border-radius: 12px; padding: 6px; }
.photo-img { display: block; max-width: 100%; max-height: min(56vh, 520px); width: auto; height: auto; border-radius: 8px; }
@media (pointer: coarse) { .pick-chip { min-height: 44px; } }

/* ── A 구역 시작(갈래 A · 내 방: 등불 달력 표시 · 이번 달 줄 · ★친구 통계 · 브로치 함 묶음) ── */
/* 달력 칸 표시 다섯: 위 왼쪽 합장 · 위 가운데 연꽃(이뤄진 밤) · 위 오른쪽 달 · 아래 왼쪽 초 · 아래 오른쪽 음표(리나 무대 함께). 날짜 숫자는 가운데 아래 */
/* .stage는 장면 그림 칸 이름과 같다(크기·위치·transform을 가져온다) — 달력 표시에서는 되돌린다 */
.cal-mark.stage { left: auto; top: auto; bottom: 2px; right: 2px; width: auto; height: auto; transform: none; will-change: auto; touch-action: auto; }
.cal-mark.lotus { left: 50%; transform: translateX(-50%); }
/* 칸 하나에 표시 다섯이라 아이콘 11px — 아래 두 표시가 가운데 날짜 숫자를 덮지 않게(데스크톱 패널도 칸 폭 42px 안팎) */
.cal-day .cal-ico { width: 11px; height: 11px; }
@media (max-width: 480px) {
  .cal-mark.lights { left: 1px; }
  .cal-mark.stage { right: 1px; }
}
/* 달력 아래 '이번 달' 한 줄(쌓인 수 · 연속·끊김 없음) */
.month-line { font-size: 13px; color: var(--wool); }
.month-line small { display: block; font-size: 12px; color: var(--muted); }
/* ★친구 줄 아래 같이 한 것 '★보들과 · 불 끈 밤 3 · …' */
.friends .friend-pick small.friend-stats { display: block; font-size: 12px; margin-top: 2px; }
/* 브로치 함 세 묶음(처음 아홉 · 쌓이는 넷 · 계절): 묶음 머리 h3, 칸은 3열 격자 그대로 */
.brooch-group { display: grid; gap: 8px; }
.brooch-group + .brooch-group { margin-top: 6px; }
.brooch-group h3 { margin: 0; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-family: var(--display); font-size: 14px; font-weight: 700; }
.brooch-group h3 small { font-family: var(--body); font-weight: 400; font-size: 12px; color: var(--muted); }
.brooch-group.sewn h3 small { color: var(--lamp); }
.brooch-thread { align-self: center; line-height: 0; }
.brooch-thread img { height: 20px; width: auto; }
/* 받았지만 이 색에 '브로치를 단 인형' 그림이 아직 없다: 가슴에 달 수 없음(글로만 알림 — 그림을 CSS로 흉내 내지 않는다) */
.brooch.nopin { cursor: default; }
.brooch.nopin small { color: var(--muted); }
.brooch-new .gold-line { color: var(--lamp); }
/* ── A 구역 끝 ── */

/* ── B 구역 시작: 정시 의식 한 자리 띠(#herald — herald.js) ───────── */
/* 머리띠 바로 뒤(#app 첫 자리)의 고정 요소. 자리(top·left)는 herald.js가 1초마다·스크롤·크기 바뀔 때 잰다 — 장면 위 가운데(예불 칩 자리),
   휴대폰에서 장면이 머리띠 밑으로 올라가면 머리띠 바로 아래에 붙는다. 붙박이 머리띠(5)·겹침 창(20) 아래 z 4(장면은 z 0 쌓임이라 그 위).
   떠 있는 것은 언제나 하나: 행동 칩(같이 고개 숙이기·같이 불 끄기·같이 흔들기)이 있으면 띠는 숨는다(herald.js) */
.herald {
  position: fixed;
  left: 50%;
  top: calc(var(--header-h) + 56px);
  transform: translateX(-50%);
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
  margin: 0;
  padding: 6px 14px;
  border: 1px solid rgb(255 196 107 / 0.6);
  border-radius: 999px;
  background: var(--dusk);
  color: var(--wool);
  font: 14px/1.3 var(--body);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.35);
  animation: fade 0.3s ease, beckon 1.6s ease-out 0.3s 2; /* rise(transform)는 가운데 맞춤과 섞이므로 밝기만 */
}
.herald[hidden] { display: none; }
.herald .hd-ico { display: inline-flex; flex: none; }
.herald .hd-ico .ico { height: 1.3em; }
.herald > span:not(.hd-ico) { overflow: hidden; text-overflow: ellipsis; }
.herald .hd-short { display: none; }
button.herald { cursor: pointer; }
button.herald::after { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%); }
button.herald:hover { border-color: var(--lamp); background: var(--dusk-2); }
button.herald:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; }
/* 이미 그 장소: 누르는 것이 아니라 글(누르면 그 밑 장면을 누른다) */
p.herald { cursor: default; pointer-events: none; animation: fade 0.3s ease; }
/* 휴대폰(420px 아래): 가는 곳(' · 산사로') 없이 짧게 — 단추 뜻은 aria-label에 */
@media (max-width: 420px) {
  .herald { font-size: 13px; padding: 5px 12px; }
  .herald .hd-long { display: none; }
  .herald .hd-short { display: inline; }
}
/* 움직임 줄이기: 부르는 빛(beckon) 없이 나타나기만 */
@media (prefers-reduced-motion: reduce) { .herald { animation: fade 0.3s ease !important; } }
/* 마당: 띠가 가리키는 장소의 건물 이름표·가장자리 표지에 작은 등불 점(.soon — 장소 카드는 위 .place-card.soon) */
.hot.soon .hot-label { border-color: var(--lamp); box-shadow: 0 0 0 1px rgb(255 196 107 / 0.5), 0 0 20px rgb(255 196 107 / 0.5); }
.edge-hint.soon { border-color: var(--lamp); }
.hot.soon .hot-label::before,
.edge-hint.soon::before {
  content: "";
  display: inline-block;
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lamp);
  box-shadow: 0 0 8px rgb(255 196 107 / 0.9);
  vertical-align: 1px;
  animation: soon-dot 2.4s ease-in-out infinite alternate;
}
.hot.soon .hot-label::before { margin-right: 6px; }
@keyframes soon-dot { to { opacity: 0.45; } }
/* ── B 구역 끝 ── */

/* ── C 구역 시작(갈래 C · together.js: 차 나눔 · 함께 108바퀴 · 무대 꼬마전구 · 둘이 한 바퀴 · 내 방 선반·매듭) ── */
/* 차를 다 우렸다: 띠를 '그 사람 앞에 따라 두기' 단추로 바꿔 쓴다(단추는 터치 44px) */
.sheet-wrap.band .tea.tea-offer { grid-template-columns: auto minmax(0, 1fr); row-gap: 4px; }
.sheet-wrap.band .tea.tea-offer p.tea-done { grid-column: 2; grid-row: 1; font-size: 15px; color: var(--wool); }
.sheet-wrap.band .tea.tea-offer p.tea-offer-note { grid-column: 2; grid-row: 2; font-size: 12px; color: var(--muted); }
.sheet-wrap.band .tea.tea-offer .tea-give { grid-column: 1 / -1; grid-row: 3; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sheet-wrap.band .tea.tea-offer .tea-give .btn { min-height: 44px; padding: 8px 12px; font-size: 14px; white-space: nowrap; }
/* 찻상 위 찻잔(김 오르는 펠트 잔 — 생성 그림). 받은 잔은 단추(누르는 판 44px), 남의 잔은 그림만 */
.tea-cup { position: absolute; left: var(--x); top: var(--y); width: 2.3%; translate: -50% -100%; padding: 0; border: 0; background: none; pointer-events: none; }
.tea-cup img { display: block; width: 100%; height: auto; filter: drop-shadow(0 2px 2px rgb(0 0 0 / 0.3)); }
.tea-cup.noart img { visibility: hidden; }
.tea-cup.mine { pointer-events: auto; cursor: pointer; }
.tea-cup.mine::after { content: ""; position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; translate: -50% -50%; }
.tea-cup.mine:focus-visible { outline: 2px solid var(--lamp); outline-offset: 4px; border-radius: 8px; }
.tea-tag { position: absolute; left: 50%; bottom: 100%; translate: -50% 0; margin-bottom: 4px; padding: 1px 8px; border-radius: 999px; background: var(--veil); color: var(--wool); font-size: 12px; line-height: 1.5; white-space: nowrap; }
.tea-cup.mine[data-slot="1"] .tea-tag { margin-bottom: 26px; } /* 가운데 칸 꼬리표는 한 줄 위(옆 칸 꼬리표와 겹치지 않게) */
.tea-cup.mine:is(:hover, :focus-visible) { z-index: 1000 !important; }
.tea-cup.cold { opacity: 0; transition: opacity 2.2s ease 0.4s; }
/* 내 방 받은 찻잔 선반(생성 그림 — 선반·마신 잔) */
.cup-shelf { position: absolute; left: var(--x0); width: var(--w); top: var(--y); z-index: 4; padding: 0; border: 0; background: none; cursor: pointer; }
.cup-shelf .shelf { display: block; width: 100%; height: auto; filter: drop-shadow(0 3px 4px rgb(0 0 0 / 0.25)); }
.cup-shelf .cups { position: absolute; left: 7%; right: 7%; bottom: 76%; display: flex; justify-content: space-around; align-items: flex-end; pointer-events: none; }
.cup-shelf .cups img { width: 12.5%; height: auto; }
.cup-shelf small { position: absolute; left: 50%; top: 100%; translate: -50% 0; margin-top: 2px; padding: 1px 8px; border-radius: 999px; background: var(--veil); color: var(--wool); font-size: 12px; white-space: nowrap; }
.cup-shelf.noart :is(.shelf, .cups) { visibility: hidden; }
.cup-shelf:focus-visible { outline: 2px solid var(--lamp); outline-offset: 3px; border-radius: 6px; }
.cup-shelf::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: max(100%, 44px); translate: 0 -50%; } /* 휴대폰에서도 누르는 판 44px */
.stage:is(.lamp-off, .sleep) .cup-shelf img { filter: brightness(0.55); }
.cup-list ul { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; max-height: min(50vh, 420px); overflow: auto; }
.cup-list li { display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.cup-list li span { color: var(--muted); font-size: 13px; }
.cup-list .note { font-size: 12px; color: var(--muted); }
/* 내 방 염주 걸이 아래 둘이 한 바퀴 매듭(최대 5 — 걸이(가로 약 53~57%) 술 왼쪽 벽, 새 매듭이 걸이 쪽. 오른쪽은 협탁이라 비운다) */
.knots { position: absolute; right: 47.4%; top: 50%; height: 5%; z-index: 5; display: flex; gap: 1px; align-items: flex-start; }
.knot { position: relative; height: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.knot img { display: block; height: 100%; width: auto; filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.25)); }
.knot.noart { display: none; }
.knot::after { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 28px); height: max(100%, 44px); translate: -50% -50%; }
.knot:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; border-radius: 6px; }
.stage:is(.lamp-off, .sleep) .knot img { filter: brightness(0.55); }
/* 산사 108 염주 카드: 오늘 밤 이 마당 함께 108바퀴(서버가 센 진짜 수 — 모르면 숨김). 펠트 알 12개(한 알 9바퀴) */
.beads-goal { display: grid; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.beads-goal .goal-line { margin: 0; font-size: 14px; color: var(--lamp); }
.goal-beads { display: flex; flex-wrap: nowrap; gap: 2px; }
.goal-beads img { flex: 0 1 22px; min-width: 0; width: 22px; height: auto; aspect-ratio: 1; object-fit: contain; opacity: 0.3; filter: grayscale(0.7); }
.goal-beads img.on { opacity: 1; filter: none; }
.beads-goal small { font-size: 12px; color: var(--muted); }
.beads-goal .goal-mine { color: var(--wool); }
/* 염주 띠의 '둘이 한 바퀴' 한 줄 */
.beads-band .bead-pair { grid-column: 1 / -1; margin: 0; font-size: 13px; color: var(--lamp); text-align: center; }
/* 다 찬 순간: 오늘 밤 연등 실루엣과 내 연등이 6초 밝아진다 */
.stage.goal-glow :is(.tonight-sky, .lamp.mine) { filter: brightness(1.6) drop-shadow(0 0 14px rgb(255 214 150 / 0.9)); transition: filter 1.2s ease; }
/* 무대 막 위 펠트 꼬마전구(생성 그림에 오늘 밤 색을 구워 넣은 한 장). 정시 무대 동안 켜진 알이 박자 없이 천천히 반짝 */
.garland { position: absolute; left: var(--x0); width: var(--w); top: var(--y); z-index: 605; pointer-events: none; }
.garland-img { position: absolute; display: block; max-width: none; user-select: none; filter: brightness(0.8) saturate(0.85); } /* 꺼진 알은 한 톤 낮게 — 오늘 밤 켜진 색이 도드라지게 */
.garland .bulb { position: absolute; display: block; }
.garland .bulb canvas { display: block; width: 100%; height: 100%; opacity: 0; mix-blend-mode: screen; }
.stage.showtime .garland .bulb.lit canvas { animation: bulb-twinkle 3.4s ease-in-out infinite alternate; animation-delay: inherit; }
@keyframes bulb-twinkle { to { opacity: 0.8; } }
@media (prefers-reduced-motion: reduce) { .stage.showtime .garland .bulb.lit canvas { animation: none; } }
.lit-line { font-size: 13px; color: var(--wool); }
/* ── C 구역 끝 ── */
