:root {
  --ink: #2c1a0e;
  --wood: #3a2414;
  --wood-2: #5a371d;
  --paper: #f8efe0;
  --card: #fffaf1;
  --line: #e4d3b8;
  --muted: #7d6650;
  --red: #c8412a;
  --red-d: #a53220;
  --teal: #2f8577;
  --gold: #c58a2b;
  --radius: 14px;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "AppleMyungjo", "Batang", serif;
  --sans: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
h2, h3, h4 { font-family: var(--serif); margin: 0; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); font-size: .9rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* 상단 */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--wood); color: #f6e7cf;
  border-bottom: 3px solid var(--teal);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--red); color: #ffe9c2; font-size: 1.1rem;
}
.brand strong { display: block; font-family: var(--serif); font-size: 1.1rem; line-height: 1.2; }
.brand small { display: block; font-size: .72rem; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; align-items: center; gap: 4px; flex: none; }
.nav a { color: inherit; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: .95rem; }
.nav a:hover { background: rgba(255,255,255,.1); }
.chip {
  border: 1px solid rgba(255,255,255,.35); background: transparent; color: inherit;
  border-radius: 999px; padding: 6px 12px; font-size: .85rem; cursor: pointer;
  max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip::before { content: "🙏 "; }

/* 법당 */
.hall { background: var(--wood); }
.scene {
  position: relative; overflow: hidden;
  max-width: 1400px; margin: 0 auto;
  aspect-ratio: 1671 / 941;
  transform-origin: 50% 100%;
}
.scene img { display: block; width: 100%; height: 100%; object-fit: cover; transition: filter .8s, transform 1.1s ease-in-out; }

.glow {
  position: absolute; top: 52.3%; width: 16%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255,214,120,.95) 0%, rgba(255,170,60,.45) 22%, rgba(255,150,40,0) 62%);
  mix-blend-mode: screen; opacity: 0; transition: opacity 1.2s; pointer-events: none;
}
.glow-l { left: 44.8%; }
.glow-r { left: 58.8%; }
.scene.lit .glow { opacity: 1; animation: flicker 2.4s infinite ease-in-out; }
.scene.lit .glow-r { animation-delay: -.9s; }
@keyframes flicker {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  35% { transform: translate(-50%, -51%) scale(1.08); }
  60% { transform: translate(-50%, -50%) scale(.94); }
}

.smoke { position: absolute; left: 51.8%; top: 60.5%; width: 0; height: 0; pointer-events: none; }
.smoke i {
  position: absolute; left: 0; bottom: 0; width: 2.2vw; max-width: 30px; aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.75), rgba(255,255,255,0) 68%);
  filter: blur(3px); opacity: 0;
  animation: rise 5s ease-out forwards;
}
@keyframes rise {
  0% { transform: translate(-50%, 0) scale(.4); opacity: 0; }
  15% { opacity: .85; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), -26vw) scale(3.2); opacity: 0; }
}

.bow-veil {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(20, 10, 4, 0); pointer-events: none; transition: background 1s ease-in-out;
}
.bow-veil span {
  font-family: var(--serif); color: #ffe9c2; font-size: clamp(1.4rem, 5vw, 3rem);
  letter-spacing: .3em; opacity: 0; transition: opacity .6s; text-shadow: 0 2px 12px #000;
}
.scene.bowing img { transform: scale(1.12) translateY(4%); filter: brightness(.55); }
.scene.bowing .bow-veil { background: rgba(20, 10, 4, .45); }
.scene.bowing .bow-veil span { opacity: 1; }

.presence {
  position: absolute; left: 50%; bottom: 3%; transform: translateX(-50%);
  background: rgba(40, 22, 10, .72); color: #fbeed8; backdrop-filter: blur(4px);
  padding: 6px 14px; border-radius: 999px; font-size: clamp(.7rem, 2.4vw, .9rem); white-space: nowrap;
}
.presence b { color: #ffd27a; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #7be0a0; margin-right: 6px; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.offer-bar {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
  max-width: 1000px; margin: 0 auto; padding: 12px;
}
.offer-bar button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px; border-radius: var(--radius); cursor: pointer;
  background: linear-gradient(#6b4324, #55331a); color: #f8e8cf;
  border: 1px solid #8a5c33; transition: transform .1s, filter .2s;
  min-width: 0;
}
.offer-bar button:hover { filter: brightness(1.12); }
.offer-bar button:active { transform: scale(.96); }
.offer-bar .ico {
  font-family: var(--serif); font-size: 1.25rem; line-height: 1;
  width: 2.1em; height: 2.1em; display: grid; place-items: center;
  border-radius: 50%; background: var(--red); color: #ffe9c2; margin-bottom: 4px;
}
.offer-bar .lbl { font-weight: 600; font-size: .92rem; white-space: nowrap; }
.offer-bar .cnt { font-size: .72rem; opacity: .75; white-space: nowrap; }
.offer-bar .cnt b { color: #ffd27a; }

/* 패널 */
.panel { max-width: 1000px; margin: 0 auto; padding: 40px 16px 8px; scroll-margin-top: 60px; }
.panel-head { margin-bottom: 16px; }
.panel-head h2 { font-size: 1.6rem; display: flex; align-items: center; gap: 10px; }
.panel-head h2::before { content: ""; width: 6px; height: 1.1em; background: var(--red); border-radius: 3px; }
.panel-head p { color: var(--muted); margin-top: 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 0 rgba(90, 55, 29, .06); }

.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 9px 16px; cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--red); border-color: var(--red-d); color: #fff; }
.btn.primary:hover { background: var(--red-d); }
.btn:disabled { opacity: .55; cursor: default; }

/* 법회 */
.service-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: #e7f2ef; color: var(--teal); margin-bottom: 8px; }
.badge.live { background: var(--red); color: #fff; animation: pulse 2s infinite; }
.next h3 { font-size: 1.35rem; }
.when { margin-top: 10px; font-weight: 600; }
.countdown { font-family: var(--serif); font-size: 1.5rem; color: var(--red-d); margin: 2px 0 14px; font-variant-numeric: tabular-nums; }
.video { aspect-ratio: 16 / 9; margin-bottom: 14px; border-radius: 10px; overflow: hidden; background: #000; }
.video iframe { width: 100%; height: 100%; border: 0; display: block; }
.next h4 { margin: 22px 0 8px; font-size: 1rem; color: var(--wood-2); }
.schedule { list-style: none; margin: 0; padding: 0; }
.schedule li { display: flex; gap: 12px; padding: 9px 0; border-top: 1px dashed var(--line); }
.schedule time { flex: none; width: 7.2em; font-weight: 600; color: var(--teal); }
.schedule small { display: block; color: var(--muted); }

.room h3 { font-size: 1.1rem; margin-bottom: 10px; }
.room h3 small { font-family: var(--sans); font-weight: 400; }
.chat {
  list-style: none; margin: 0; padding: 10px; height: 340px; overflow-y: auto;
  background: #fbf3e4; border: 1px solid var(--line); border-radius: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.chat li { font-size: .95rem; }
.chat li b { color: var(--wood-2); margin-right: 6px; }
.chat li time { color: var(--muted); font-size: .72rem; margin-left: 6px; }
.chat li.sys { color: var(--teal); font-size: .85rem; text-align: center; }
.chat .empty { color: var(--muted); text-align: center; margin: auto; }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input { flex: 1; min-width: 0; }
input, textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff; width: 100%;
}
textarea { resize: vertical; display: block; }

/* 기도 */
.kinds { border: 0; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.kinds label { cursor: pointer; }
.kinds input { position: absolute; opacity: 0; width: 0; }
.kinds span { display: inline-block; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: .9rem; }
.kinds input:checked + span { background: var(--wood); border-color: var(--wood); color: #ffe9c2; }
.kinds input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
.form-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.form-msg { color: var(--red-d); font-size: .9rem; min-height: 0; }
.form-msg:not(:empty) { margin-top: 8px; }

.lanterns { list-style: none; margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 22px 14px; }
.lantern {
  --c: var(--red);
  position: relative; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius); padding: 14px 14px 12px; margin-top: 30px;
}
.lantern::before {
  content: ""; position: absolute; left: -1px; right: -1px; top: -30px; height: 30px;
  border-radius: 40px 40px 0 0;
  background:
    radial-gradient(ellipse at 50% 120%, rgba(255, 230, 150, .85), rgba(255, 230, 150, 0) 60%),
    repeating-linear-gradient(90deg, rgba(0,0,0,.09) 0 1px, transparent 1px 22px),
    var(--c);
}
.lantern::after {
  content: ""; position: absolute; left: 50%; top: -38px; width: 26px; height: 8px;
  transform: translateX(-50%); background: var(--wood); border-radius: 3px;
}
.lantern.health { --c: #2f8577; }
.lantern.memorial { --c: #d9c9ae; }
.lantern.exam { --c: #7fb0d9; }
.lantern.thanks { --c: #e0902c; }
.lantern.fresh { animation: drop .7s ease-out; }
@keyframes drop { from { opacity: 0; transform: translateY(-18px); } }
.lantern .kind { font-size: .75rem; font-weight: 700; color: var(--muted); }
.lantern .text { font-family: var(--serif); margin: 6px 0 12px; white-space: pre-wrap; flex: 1; }
.lantern .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); }
.lantern .meta span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.join {
  flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 4px 10px; cursor: pointer; font-size: .82rem; color: var(--ink);
}
.join:hover { border-color: var(--gold); }
.join.done { background: #fdf0d4; border-color: var(--gold); }
.more { text-align: center; margin-top: 18px; }
.empty-lanterns { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 24px 0; }

.foot { text-align: center; padding: 48px 16px calc(40px + env(safe-area-inset-bottom)); font-family: var(--serif); }
.foot .muted { font-family: var(--sans); margin-top: 4px; }

dialog { border: 0; border-radius: var(--radius); padding: 22px; width: min(92vw, 380px); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(30, 15, 5, .6); }
dialog h3 { margin-bottom: 6px; }
dialog input { margin: 14px 0; }
.dlg-foot { text-align: right; }

@media (max-width: 760px) {
  .service-grid { grid-template-columns: 1fr; }
  .brand small { display: none; }
  .offer-bar { gap: 6px; padding: 10px 8px; }
  .offer-bar .lbl { font-size: .74rem; }
  .offer-bar .cnt { font-size: .64rem; }
  .offer-bar .ico { font-size: 1.05rem; }
  .chat { height: 280px; }
}
@media (max-width: 380px) {
  .offer-bar .cnt { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .scene.bowing img { transform: none; }
}
