:root {
  --ink: #2a241d;
  --paper: #f4efe4;
  --panel: rgba(28, 24, 19, .82);
  --panel-ink: #f3ecdf;
  --accent: #b4552b;
  --line: rgba(243, 236, 223, .22);
  --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #d9dccf; color: var(--ink); font: 400 18px/1.7 var(--sans);
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid #f0b35a; outline-offset: 2px; }

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }

/* 部位ラベル */
#labels { position: fixed; inset: 0; pointer-events: none; }
.tag {
  position: absolute; left: 0; top: 0; pointer-events: auto;
  font-size: 16px; line-height: 1.3; padding: 5px 11px 6px; border-radius: 999px;
  background: var(--panel); color: var(--panel-ink); border: 1px solid var(--line);
  white-space: nowrap; box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
  will-change: transform;
}
.tag::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; width: 2px; height: 7px; margin-left: -1px;
  background: var(--panel-ink); opacity: .7;
}
.tag[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.tag[hidden] { display: none; }

/* 見出し */
.head {
  position: fixed; left: 20px; top: 16px; pointer-events: none;
  padding: 10px 18px 12px; border-radius: 12px; background: rgba(244, 239, 228, .8);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.kicker { margin: 0; font-size: 16px; letter-spacing: .3em; opacity: .8; }
.head h1 { margin: 0; font: 600 56px/1.1 var(--serif); letter-spacing: .12em; }
.read { display: inline-block; margin-left: .7em; font: 400 16px var(--sans); letter-spacing: .2em; vertical-align: .6em; opacity: .8; }
.sub { margin: 6px 0 0; font-size: 16px; opacity: .85; }

/* 見せ方の切替 */
.modes {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 6px; border-radius: 999px; background: var(--panel);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
.modes button {
  font-size: 20px; padding: 9px 22px; border-radius: 999px; border: 0; background: transparent; color: var(--panel-ink);
  white-space: nowrap;
}
.modes button[aria-pressed="true"] { background: var(--paper); color: var(--ink); font-weight: 600; }
.modes .ghost { font-size: 18px; opacity: .85; border-left: 1px solid var(--line); border-radius: 0 999px 999px 0; }
.hint {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); margin: 0;
  font-size: 16px; padding: 4px 14px; border-radius: 8px; background: rgba(244, 239, 228, .82);
  white-space: nowrap; pointer-events: none;
}

/* 解説 */
.info {
  position: fixed; right: 24px; top: 50%; transform: translateY(-50%); width: min(360px, calc(100vw - 48px));
  padding: 22px 24px 18px; border-radius: 14px; background: var(--panel); color: var(--panel-ink);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}
.info h2 { margin: 0 32px 8px 0; font: 600 26px/1.3 var(--serif); letter-spacing: .06em; }
.info p { margin: 0; font-size: 18px; }
.info .est { margin-top: 12px; font-size: 16px; color: #f0c39a; }
.close {
  position: absolute; right: 10px; top: 8px; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; font-size: 26px; line-height: 1;
}

.foot {
  position: fixed; right: 20px; top: 16px; margin: 0; text-align: right; font-size: 16px;
  padding: 8px 16px; border-radius: 12px; background: rgba(244, 239, 228, .8);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.foot p { margin: 0 0 2px; opacity: .85; }
.link { background: none; border: 0; padding: 6px 0; font-size: 16px; text-decoration: underline; text-underline-offset: 3px; }

/* 資料ダイアログ */
dialog {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 14px;
  background: var(--paper); color: var(--ink);
}
dialog::backdrop { background: rgba(20, 16, 12, .5); }
.about-inner { position: relative; padding: 28px 30px 30px; }
.about-inner h2 { margin: 0 40px 12px 0; font: 600 28px/1.3 var(--serif); }
.about-inner h3 { margin: 22px 0 6px; font-size: 19px; }
.about-inner ul { margin: 0; padding-left: 1.3em; }
.about-inner a { color: #7a3a1c; }
.plan-figure { margin: 20px 0 0; }
.plan-figure svg, #fallback-plan svg { width: 100%; height: auto; display: block; border-radius: 8px; }

.fallback { position: fixed; inset: 0; overflow: auto; padding: 24px 16px 40px; background: var(--paper); }
.fallback h2 { font: 600 28px var(--serif); margin: 0 0 8px; }
.fallback dt { margin-top: 14px; font-weight: 600; }
.fallback dd { margin: 2px 0 0; }
.fallback > * { max-width: 820px; margin-left: auto; margin-right: auto; }
.no-webgl .modes, .no-webgl .hint, .no-webgl .head { display: none; }

@media (max-width: 760px) {
  .head { left: 12px; top: 12px; padding: 6px 14px 8px; }
  .head h1 { font-size: 40px; }
  .sub { display: none; }
  .foot { right: 12px; top: 12px; max-width: 46vw; padding: 4px 12px; }
  .foot p { display: none; }
  .modes { left: 12px; right: 12px; transform: none; bottom: max(12px, env(safe-area-inset-bottom)); justify-content: space-between; gap: 2px; }
  .modes button { font-size: 18px; padding: 10px 12px; flex: 1 1 auto; }
  .modes .ghost { font-size: 16px; padding: 10px 8px; }
  .hint { bottom: 84px; white-space: normal; width: calc(100vw - 32px); text-align: center; }
  .info { left: 12px; right: 12px; top: auto; bottom: 138px; transform: none; width: auto; padding: 16px 18px 14px; }
  .info h2 { font-size: 22px; }
}
body.info-open .hint { display: none; }
@media (max-width: 400px) {
  .read { display: none; }
  .head h1 { font-size: 36px; }
  .foot { max-width: 44vw; }
  .link { line-height: 1.4; }
}
@media (max-width: 360px) {
  .modes button { font-size: 16px; padding: 10px 8px; }
  .modes .ghost { font-size: 16px; padding: 10px 6px; }
}
/* 方丈の庵：如庵の情報階層を保持し、名称が長い狭幅を調整 */
.head h1{font-size:52px}.about-inner dd{margin:4px 0 20px}.about-inner dt{font-weight:600}.fallback img{display:block;width:100%}.no-webgl .foot{display:none}
@media(max-width:760px){.head h1{font-size:34px}.head{max-width:64vw}.foot{max-width:31vw}.kicker{letter-spacing:.08em}.foot .link{white-space:nowrap}.about-inner{padding:24px 18px}.plan-figure{overflow:auto}.plan-figure svg,#fallback-plan svg{min-width:500px}}
@media(max-width:360px){.head{left:8px;padding:7px 10px}.head h1{font-size:30px}.foot{right:8px;padding:6px 8px}.modes{left:8px;right:8px}}
@media(max-height:500px) and (min-width:761px){.head h1{font-size:32px}.sub,.foot p{display:none}.modes{bottom:10px}.hint{bottom:70px}.info{max-height:70vh;overflow:auto}}
@media(max-height:500px) and (min-width:761px){.modes{left:auto;right:14px;top:112px;bottom:auto;transform:none;flex-direction:column;border-radius:20px;width:185px}.modes .ghost{border-left:0;border-top:1px solid var(--line);border-radius:0}.hint{bottom:10px}.info{left:16px;right:auto;top:110px;bottom:45px;transform:none;width:230px;font-size:16px}.info p{font-size:16px}}
