html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #efe7d6;
  overscroll-behavior: none; /* 引っぱり時のバウンスだけ止める（拡大などの操作は止めない） */
}
/* 遊ぶ画面。スマホでは全画面、横長の画面では中央の額縁 */
#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #e6dcc5;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;          /* 庭の上だけ、スクロール・ダブルタップ拡大をしない */
  -webkit-touch-callout: none;
  cursor: pointer;
}
@media (min-aspect-ratio: 4/5) and (min-width: 700px) {
  body {
    background:
      radial-gradient(ellipse at 50% 40%, rgba(255, 250, 238, 0.55), rgba(255, 250, 238, 0) 70%),
      #ddd0b8;
  }
  #stage {
    top: 2.5vh;
    bottom: 2.5vh;
    left: 50%;
    right: auto;
    width: min(94vw, 74vh);
    transform: translateX(-50%);
    border-radius: 22px;
    box-shadow: 0 0 0 1px rgba(120, 95, 70, 0.18), 0 18px 50px rgba(80, 60, 40, 0.22);
  }
}
.cam-btn {
  position: absolute;
  right: calc(env(safe-area-inset-right, 0px) + 14px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 250, 240, 0.78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(90, 70, 50, 0.16);
  color: #6b5745;
  cursor: pointer;
  touch-action: manipulation;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.cam-btn.show { opacity: 1; }
.cam-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: none;
}
.cam-btn[data-mode="follow"] .i-wide,
.cam-btn[data-mode="overview"] .i-near { display: block; }
.cam-btn:focus-visible { outline: 2px solid #b0846a; outline-offset: 2px; }
.title {
  position: absolute;
  z-index: 1;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  color: #5b4636;
  opacity: 0;
  animation: fadeIn 2.6s ease 0.6s forwards;
}
.title h1 {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  font-weight: 600;
  font-size: clamp(24px, 7vw, 34px);
  letter-spacing: 0.2em;
  margin: 0;
  padding-left: 0.2em;
  text-shadow: 0 0 14px rgba(255, 250, 238, 0.95), 0 0 4px rgba(255, 250, 238, 0.9);
}
.title h1,
.title p {
  transition: opacity 1.2s ease;
}
.title-away .title h1,
.title-away .title p { opacity: 0; }
.title p {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: clamp(12px, 3.4vw, 14px);
  letter-spacing: 0.16em;
  margin: 0.5em 0 0;
  color: #6e5a48;
  text-shadow: 0 0 10px rgba(255, 250, 238, 0.95);
}
.hint {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  transform: translateX(-50%);
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.74);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 12px rgba(90, 70, 50, 0.12);
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #6b5745;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  animation: fadeIn 1.6s ease 2.4s forwards;
  transition: opacity 0.8s ease;
}
.hint.hide { animation: none; opacity: 0; }
#veil {
  position: absolute;
  inset: 0;
  background: #f4eddc;
  pointer-events: none;
  animation: fadeOut 1.8s ease 0.15s forwards;
}
#fps {
  position: absolute;
  right: 6px;
  top: 6px;
  font: 11px/1 monospace;
  color: #333;
  pointer-events: none;
}
.pray-btn {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  transform: translate(-50%, 6px);
  min-width: 128px;
  height: 46px;
  padding: 0 26px;
  border: 1px solid rgba(176, 132, 106, 0.35);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 3px 14px rgba(90, 70, 50, 0.16);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  font-size: 17px;
  letter-spacing: 0.24em;
  padding-left: calc(26px + 0.24em);
  color: #5b4636;
  cursor: pointer;
  touch-action: manipulation;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.pray-btn.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.pray-btn:active { background: rgba(250, 238, 222, 0.95); }
.pray-btn:focus-visible { outline: 2px solid #b0846a; outline-offset: 2px; }
.pray-msg {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 136px); /* 「お参り」「本堂に入る」の上 */
  margin: 0;
  text-align: center;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  font-size: clamp(15px, 4.2vw, 18px);
  letter-spacing: 0.12em;
  line-height: 1.7;
  color: #5b4636;
  text-shadow: 0 0 12px rgba(255, 250, 238, 0.98), 0 0 4px rgba(255, 250, 238, 0.95);
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.6s ease;
}
.pray-msg.show { opacity: 1; transition-duration: 1.4s; }
/* 桜・お地蔵さまのひとこと：その場所の少し上に出す（位置は JS で決める） */
.touch-msg {
  bottom: auto;
  top: 0;
  left: 50%;
  right: auto;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 4px 16px;
  border-radius: 999px;
  /* 枝・花びら・葉・雪に重なっても読めるよう、ふちのぼけた淡い背景（季節によらず同じ） */
  background: radial-gradient(ellipse at center, rgba(255, 250, 238, 0.72) 40%, rgba(255, 250, 238, 0) 72%);
  transform: translate(-50%, -100%);
}
.enter-btn { bottom: calc(env(safe-area-inset-bottom, 0px) + 78px); }
.back-btn {
  position: absolute;
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  height: 36px;
  padding: 0 14px 0 12px;
  border: 1px solid rgba(255, 236, 200, 0.28);
  border-radius: 999px;
  background: rgba(40, 26, 18, 0.42);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #f6ead2;
  cursor: pointer;
  touch-action: manipulation;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}
.back-btn::before { content: "‹ "; }
.back-btn.show { opacity: 0.85; pointer-events: auto; }
.back-btn:focus-visible { outline: 2px solid #e2c08f; outline-offset: 2px; }
.view-hint {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 82px);
  margin: 0;
  text-align: center;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #f6ead2;
  text-shadow: 0 0 8px rgba(40, 24, 14, 0.9), 0 0 3px rgba(40, 24, 14, 0.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.view-hint.show { opacity: 0.92; }
/* 静坐 */
.zazen-row {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  display: flex;
  justify-content: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}
.zazen-row.show { opacity: 1; pointer-events: auto; }
.view-close .zazen-row { bottom: calc(env(safe-area-inset-bottom, 0px) + 78px); }
.z-btn {
  height: 44px;
  padding: 0 20px;
  border: 1px solid rgba(176, 132, 106, 0.35);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 3px 14px rgba(60, 40, 24, 0.18);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  font-size: 15px;
  letter-spacing: 0.14em;
  color: #5b4636;
  cursor: pointer;
  touch-action: manipulation;
}
.z-btn:active { background: rgba(250, 238, 222, 0.95); }
.z-btn:focus-visible { outline: 2px solid #b0846a; outline-offset: 2px; }
.zazen-panel {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  transform: translate(-50%, 6px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.zazen-panel.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.zazen-left {
  margin: 0 0 10px;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  font-size: 15px;
  letter-spacing: 0.16em;
  color: #fbf1dc;
  text-shadow: 0 0 8px rgba(40, 24, 14, 0.95), 0 0 3px rgba(40, 24, 14, 0.9);
}
.zazen-ops { display: flex; gap: 12px; justify-content: center; white-space: nowrap; }
.end-card {
  position: absolute;
  left: 50%;
  top: 58%; /* 本堂の全景：前机と小坊主さんのあいだの床（上の蓮が須弥壇にかからない高さ） */
  transform: translate(-50%, -50%);
  max-width: calc(100% - 48px);
  box-sizing: border-box;
  margin: 0;
  padding: 14px 24px;
  border-radius: 18px;
  background: rgba(255, 249, 238, 0.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(60, 40, 24, 0.18);
  text-align: center;
  white-space: nowrap;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  color: #5b4636;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.end-card.show { opacity: 1; transition-duration: 1.1s; }
.zazen-msg { transition-duration: 0.45s; } /* 消えるのは少し早く、すぐ次のひとことへ */
.hitokoto.show { transition-duration: 0.8s; }
/* 近くから見るときは、顔と体にかからない上のほう（障子の前）。蓮はその上に */
.view-close .end-card { top: calc(env(safe-area-inset-top, 0px) + 150px); transform: translate(-50%, 0); }
.zazen-msg { font-size: clamp(15px, 4.2vw, 18px); letter-spacing: 0.12em; line-height: 1.8; }
.hk-label {
  margin: 0 0 6px;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: #c4876f;
}
.hk-text { margin: 0; font-size: clamp(17px, 4.8vw, 20px); letter-spacing: 0.12em; }
.hk-sign {
  margin: 8px 0 0;
  font-size: 10px;
  letter-spacing: 0.3em;
  color: #a58b6f;
}
#stage:not(.in-hondo) .end-card,
#stage:not(.in-hondo) .lotus { visibility: hidden; } /* 念のため：庭では出さない */
.lotus {
  position: absolute;
  inset: auto; /* 全体の canvas 指定（全画面）を打ち消す */
  left: 50%;
  top: 0; /* 位置は JS で「今日のひとこと」のカードの真上に合わせる */
  width: 132px;
  height: 100px;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
}
/* 音のスイッチ */
.sound-btn {
  position: absolute;
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 250, 240, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #6b5745;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.8s ease;
}
.sound-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sound-btn .spk { fill: currentColor; }
.sound-btn[data-on="1"] .mute,
.sound-btn[data-on="0"] .wave { display: none; }
.sound-btn:focus-visible { outline: 2px solid #b0846a; outline-offset: 2px; }
.in-hondo .sound-btn { background: rgba(40, 26, 18, 0.42); color: #f6ead2; }
/* 静坐中は、触れたときだけ操作を出す */
.zazen:not(.zz-open) .sound-btn { opacity: 0; pointer-events: none; }
/* 場面の切りかえ：あたたかい暗さへ、ゆっくり */
#fade {
  position: absolute;
  inset: 0;
  z-index: 50; /* タイトル（z-index:1）・ボタンも含め、画面全体をおおう */
  background: #24170f;
  opacity: 0;
  pointer-events: none;
  transition-property: opacity;
  transition-timing-function: ease-in-out;
}
/* 本堂の中では、庭のための表示を隠す */
.in-hondo .title,
.in-hondo .hint,
.in-hondo .cam-btn,
.in-hondo .pray-msg { visibility: hidden; }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }

/* ---- これまでの足あと ---- */
.ashiato-btn {
  position: absolute;
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 250, 240, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #6b5745;
  cursor: pointer;
  touch-action: manipulation;
}
.ashiato-btn svg { width: 22px; height: 22px; fill: currentColor; opacity: 0.85; }
.ashiato-btn:focus-visible, .as-nav:focus-visible, .as-close:focus-visible { outline: 2px solid #b0846a; outline-offset: 2px; }
.in-hondo .ashiato-btn, .in-hondo .ashiato:not(.sheet) { display: none; }
#stage:not(.in-hondo) .sheet, #stage:not(.in-hondo) .share-link { display: none; } /* シェアは本堂の中だけ */
.ashiato {
  position: absolute;
  inset: 0;
  z-index: 40; /* 暗転（#fade）よりは下 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: rgba(60, 45, 30, 0.22);
  opacity: 0;
  transition: opacity 0.5s ease;
}
.ashiato.show { opacity: 1; }
.ashiato[hidden] { display: none; }
.as-card {
  width: min(100%, 360px);
  max-height: 100%;
  overflow-y: auto;
  padding: 18px 16px 16px;
  border-radius: 18px;
  background: rgba(253, 248, 238, 0.97);
  box-shadow: 0 10px 34px rgba(70, 50, 30, 0.22);
  color: #5b4636;
  text-align: center;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
}
.as-sub { margin: 0; font-size: 12px; letter-spacing: 0.24em; color: #8a7461; }
.as-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 10px; }
.as-head h2 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: 0.16em; padding-left: 0.16em; }
.as-nav {
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: #8a6f58; font-size: 24px; line-height: 1;
  cursor: pointer; touch-action: manipulation;
}
.as-nav:disabled { opacity: 0.18; cursor: default; }
.as-week, .as-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.as-week span { font-size: 11px; color: #9a8572; padding-bottom: 4px; }
.as-week span:first-child { color: #b57a6e; }
.as-day {
  position: relative;
  height: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 3px;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
}
.as-day .n { font-size: 10.5px; color: #8f7a66; line-height: 1.2; }
.as-day .dot { font-size: 16px; line-height: 20px; color: #bba996; }
.as-day.future .n { color: #d6c8b8; }
.as-day.today::before {
  content: "";
  position: absolute;
  inset: 1px 3px;
  border: 1px solid rgba(196, 146, 100, 0.55);
  border-radius: 10px;
}
.mk { width: 20px; height: 20px; margin-top: 1px; fill: #efa3bb; }
.mk .c { fill: #f6d27c; }
.mk.leaf { fill: #8db86a; }
.mk.leaf .v { fill: none; stroke: #f3f6e6; stroke-width: 1; stroke-linecap: round; }
.as-legend { margin: 10px 0 0; font-size: 12px; color: #7d6754; display: flex; justify-content: center; gap: 16px; font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif; }
.as-legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: -1px; border-radius: 50%; }
.as-legend .lg-z::before { background: #efa3bb; box-shadow: inset 0 0 0 3.5px #efa3bb, inset 0 0 0 6px #f6d27c; }
.as-legend .lg-v::before { background: #8db86a; border-radius: 0 50% 0 50%; }
.as-msg { margin: 14px 0 0; font-size: 14px; line-height: 1.9; letter-spacing: 0.08em; }
.as-close {
  margin-top: 14px;
  min-width: 112px;
  height: 40px;
  padding: 0 22px;
  border: 1px solid rgba(176, 132, 106, 0.35);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.9);
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.2em;
  padding-left: calc(22px + 0.2em);
  color: #5b4636;
  cursor: pointer;
  touch-action: manipulation;
}
@media (prefers-reduced-motion: reduce) { .ashiato { transition: none; } }

/* ---- 今日のひとことをシェア ---- */
.share-link {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 74px); /* 「3分だけ／5分ゆっくり」の上 */
  transform: translateX(-50%);
  height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: #5b4636;
  cursor: pointer;
  touch-action: manipulation;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}
.share-link.show { opacity: 1; pointer-events: auto; }
.share-link:focus-visible, .sh-btn:focus-visible { outline: 2px solid #b0846a; outline-offset: 2px; }
.view-close .share-link { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 12px); } /* 近くからでは小坊主さんにかからないよう上へ */
.sh-title { margin: 4px 0 12px; font-size: 18px; font-weight: 600; letter-spacing: 0.16em; padding-left: 0.16em; }
.sh-text {
  margin: 0 0 14px;
  padding: 14px 12px;
  border-radius: 12px;
  background: rgba(244, 234, 216, 0.6);
  white-space: pre-line;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.8;
  letter-spacing: 0.06em;
}
.sh-ops { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.sh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  border: 1px solid rgba(176, 132, 106, 0.35);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.95);
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.14em;
  color: #5b4636;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.sh-btn[hidden] { display: none; }
.sh-note { margin: 12px 0 0; font-size: 12px; color: #8a7461; letter-spacing: 0.08em; }

/* ---- 絵馬を書くカード ---- */
.ema-box {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start; /* キーボードが出ても隠れないよう、画面の上の方に置く */
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 48px) 16px 16px;
  background: rgba(60, 45, 30, 0.22);
  opacity: 0;
  transition: opacity 0.5s ease;
}
.ema-box.show { opacity: 1; }
.ema-box[hidden] { display: none; }
.in-hondo .ema-box { display: none; }
.ema-card {
  position: relative;
  width: min(100%, 340px);
  padding: 46px 20px 16px;
  background: linear-gradient(170deg, #f3dcb4, #e7c792 70%, #dfba80);
  clip-path: polygon(0 52px, 50% 0, 100% 52px, 100% 100%, 0 100%); /* 絵馬の形 */
  border-radius: 0 0 14px 14px;
  box-shadow: 0 10px 34px rgba(70, 50, 30, 0.22);
  color: #5b4030;
  text-align: center;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  outline: none;
}
.ema-card::before { /* ひもを通す穴と赤いひも */
  content: "";
  position: absolute;
  left: 50%;
  top: 20px;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: #7a5034;
  box-shadow: 0 -10px 0 -2px #c4473a;
}
.ema-card .as-sub { color: #7d5d44; }
.ema-title { margin: 2px 0 12px; font-size: 18px; font-weight: 600; letter-spacing: 0.16em; padding-left: 0.16em; }
.ema-text {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid rgba(120, 80, 50, 0.3);
  border-radius: 10px;
  background: rgba(255, 251, 242, 0.92);
  font-family: inherit;
  font-size: 17px; /* 16px 以上：iPhone で入力時に拡大しない */
  line-height: 1.6;
  color: #4a3326;
  resize: none;
}
.ema-text:focus { outline: 2px solid #b0846a; outline-offset: 1px; }
.ema-text:disabled { opacity: 0.5; }
.ema-count { margin: 4px 2px 0; text-align: right; font-size: 12px; color: #8a6b52; font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif; }
.ema-count.over { color: #b5482f; }
.ema-warn { margin: 6px 0 0; font-size: 12.5px; line-height: 1.6; color: #a1452f; }
.ema-ops { display: flex; gap: 10px; margin-top: 12px; }
.ema-ops .sh-btn { flex: 1; }
.ema-hang { background: #fffaf0; font-weight: 600; }
.ema-hang:disabled { opacity: 0.45; cursor: default; }
.ema-note { margin: 12px 0 0; font-size: 11.5px; line-height: 1.7; color: #7d5d44; letter-spacing: 0.04em; }
@media (prefers-reduced-motion: reduce) { .ema-box { transition: none; } }

/* ---- 絵馬を見る・外す ---- */
.ema-list-card { max-height: calc(100% - 8px); display: flex; flex-direction: column; }
.ema-list {
  list-style: none;
  margin: 0;
  padding: 0 2px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 52vh;
  text-align: left;
}
.ema-item {
  padding: 12px 12px 10px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: linear-gradient(170deg, #f6e4c3, #ecd2a3);
  color: #4a3326;
}
.ema-item.asking { box-shadow: inset 0 0 0 1.5px rgba(181, 72, 47, 0.45); }
.ema-wish { margin: 0; font-size: 15px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.ema-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: #8a6b52;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
}
.ema-meta > span:first-child { margin-right: auto; }
.ema-ask { flex-basis: 100%; order: -1; text-align: right; color: #a1452f; } /* 確かめる文は 1 行目、ボタンは 2 行目 */
.ema-mini {
  height: 32px;
  padding: 0 14px;
  border: 1px solid rgba(120, 80, 50, 0.3);
  border-radius: 999px;
  background: rgba(255, 251, 242, 0.95);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: #5b4030;
  cursor: pointer;
  touch-action: manipulation;
}
.ema-mini.yes { border-color: rgba(181, 72, 47, 0.5); color: #a1452f; font-weight: 600; }
.ema-mini:focus-visible { outline: 2px solid #b0846a; outline-offset: 2px; }
.ema-mini[hidden] { display: none; }
.ema-tolist { margin-top: 8px; }
.ema-empty { padding: 18px 0; text-align: center; font-size: 14px; color: #8a7461; }
.ema-status { min-height: 1.4em; margin: 6px 0 0; font-size: 12.5px; color: #6b5745; text-align: center; }

/* ---- 記録の引き継ぎ（V1.0B） ---- */
.as-sync { margin-top: 10px; }
.as-sync[hidden] { display: none; }
.as-sync-state { margin: 0 0 2px; font-size: 12px; line-height: 1.6; color: #7d6754; letter-spacing: 0.04em; }
.as-sync-state[hidden] { display: none; }
.as-sync-state.s-pending, .as-sync-state.s-error, .as-sync-state.s-lost { color: #9a5a3e; }
.as-link {
  padding: 6px 10px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: #8a6f58;
  text-decoration: underline;
  text-decoration-color: rgba(138, 111, 88, 0.4);
  text-underline-offset: 4px;
  cursor: pointer;
  touch-action: manipulation;
}
.as-link:focus-visible { outline: 2px solid #b0846a; outline-offset: 2px; border-radius: 6px; }
.sync-box { align-items: flex-start; padding-top: calc(env(safe-area-inset-top, 0px) + 48px); } /* キーボードが出ても隠れないよう上の方に */
.sync-card { padding-bottom: 18px; }
.sy-pane[hidden], .sy-ask[hidden], .sync-card .as-close[hidden], .sync-card .sh-btn[hidden] { display: none; }
.sy-text { margin: 0 0 14px; font-size: 14.5px; line-height: 1.9; letter-spacing: 0.06em; }
.sy-ops { display: flex; flex-direction: column; gap: 8px; }
.sy-ops .sh-btn:disabled, .ema-ops .sh-btn:disabled { opacity: 0.45; cursor: default; }
.sy-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  height: 48px;
  padding: 0 12px;
  border: 1px solid rgba(120, 80, 50, 0.3);
  border-radius: 10px;
  background: rgba(255, 251, 242, 0.95);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 18px; /* 16px 以上：iPhone で入力時に拡大しない */
  letter-spacing: 0.08em;
  text-align: center;
  color: #4a3326;
}
.sy-input:focus { outline: 2px solid #b0846a; outline-offset: 1px; }
.sy-code {
  margin: 0 0 10px;
  padding: 12px 6px;
  border-radius: 10px;
  background: rgba(240, 229, 212, 0.6);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 21px;
  letter-spacing: 0.08em;
  color: #3f2c20;
  -webkit-user-select: all;
  user-select: all;
  word-break: break-all;
}
.sy-warn { margin: 14px 0 0; font-size: 12.5px; line-height: 1.8; color: #8a4a30; letter-spacing: 0.03em; text-align: left; }
.sy-ask { margin-top: 4px; }
.sy-ask .sy-warn { margin: 0 0 12px; white-space: pre-line; }
.sy-ops[hidden] { display: none; }
.sy-erase { margin-top: 4px; font-size: 12.5px; color: #9a5a3e; text-decoration-color: rgba(154, 90, 62, 0.4); }
.sy-danger { border-color: rgba(181, 72, 47, 0.5); color: #a1452f; font-weight: 600; }
.sy-foot { margin: 10px 0 0; }
.sy-foot .as-link { font-size: 12px; }
.ema-local { margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: rgba(176, 132, 106, 0.14); font-size: 11px; color: #7d5d44; }

/* ---- みんなのお寺（V1.1A3）：モードの札・カード・本堂のひとこと ---- */
.mode-badge {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  margin: 10px auto 0;
  padding: 0 12px 0 10px;
  border: 1px solid rgba(176, 132, 106, 0.35);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  font-size: 12.5px;
  letter-spacing: 0.14em;
  color: #6b5745;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 1.2s ease;
}
.mode-badge[hidden] { display: none; }
.mode-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #c9b28f; }
.mode-badge.together { background: rgba(236, 243, 224, 0.85); border-color: rgba(122, 150, 96, 0.45); color: #4f6340; }
.mode-badge.together::before { background: #8fae74; }
.mode-badge.new { animation: badgeGlow 2.6s ease-in-out 1s 3; } /* 初めての人にだけ、ほんの少し光る（3 回で止まる） */
@keyframes badgeGlow { 50% { box-shadow: 0 0 0 3px rgba(255, 244, 214, 0.8), 0 0 14px rgba(232, 200, 140, 0.75); } }
.mode-badge:disabled { opacity: 0.45; cursor: default; }
.mode-badge:focus-visible { outline: 2px solid #b0846a; outline-offset: 2px; }
.title-away .title .mode-badge { opacity: 0; pointer-events: none; }
.mode-badge.in-hall {
  position: absolute;
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  top: calc(env(safe-area-inset-top, 0px) + 54px);
  margin: 0;
  border-color: rgba(255, 236, 200, 0.28);
  background: rgba(40, 26, 18, 0.42);
  color: #f6ead2;
}
.mode-badge.in-hall.together { background: rgba(66, 88, 50, 0.55); color: #eef5df; }
.mode-badge.in-hall:focus-visible { outline-color: #e2c08f; }
#stage:not(.in-hondo) .mode-badge.in-hall,
.view-close .mode-badge.in-hall { display: none; }
.zazen .mode-badge.in-hall { opacity: 0; pointer-events: none; }
.tg-msg {
  position: absolute;
  left: 16px;
  right: 16px;
  top: calc(env(safe-area-inset-top, 0px) + 96px); /* 札の下・天井のあたり（座布団や小坊主さんにかからない） */
  margin: 0;
  text-align: center;
  white-space: pre-line;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  font-size: 14px;
  letter-spacing: 0.1em;
  line-height: 1.8;
  color: #f6ead2;
  text-shadow: 0 0 8px rgba(40, 24, 14, 0.9), 0 0 3px rgba(40, 24, 14, 0.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.tg-msg.show { opacity: 0.94; }
#stage:not(.in-hondo) .tg-msg { display: none; }
.in-hondo .mode-box:not([hidden]) { display: flex; } /* 本堂の中でも開ける */
.mode-card { padding: 14px 18px 14px; }
.mode-face { position: relative; inset: auto; display: block; width: 72px; height: 64px; margin: 0 auto 2px; } /* 全体の canvas 指定（全画面）を打ち消す */
.mode-title { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: 0.14em; padding-left: 0.14em; }
.mode-lead { margin: 6px 0 14px; font-size: 13px; color: #7d6450; letter-spacing: 0.08em; }
.mode-ops { display: flex; flex-direction: column; gap: 10px; }
.mode-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 13px 12px;
  border: 1px solid rgba(176, 132, 106, 0.35);
  border-radius: 14px;
  background: #fffaf0;
  font-family: inherit;
  color: #5b4636;
  cursor: pointer;
  touch-action: manipulation;
}
.mode-opt.together { background: #f1f6e8; border-color: rgba(122, 150, 96, 0.42); color: #4a5c3c; }
.mode-opt[aria-pressed="true"] { border-width: 2px; padding: 12px 11px; border-color: #b0846a; }
.mode-opt.together[aria-pressed="true"] { border-color: #7f9d65; }
.mode-opt:focus-visible { outline: 2px solid #b0846a; outline-offset: 2px; }
.mo-name { font-size: 16px; font-weight: 600; letter-spacing: 0.16em; padding-left: 0.16em; }
.mo-sub { font-size: 12.5px; letter-spacing: 0.06em; color: #7d6450; }
.mode-opt.together .mo-sub { color: #627552; }
.mode-note { margin: 14px 0 0; font-size: 12.5px; color: #7d6450; letter-spacing: 0.06em; }
@media (prefers-reduced-motion: reduce) { .mode-badge.new { animation: none; } }
