/* 書体：Shippori Mincho（SIL Open Font License 1.1、fonts/OFL.txt）。サイトで使う文字だけに絞って同梱（外部の書体配信へは接続しない） */
@font-face { font-family: "Shippori Mincho"; src: url("../fonts/ShipporiMincho-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Shippori Mincho"; src: url("../fonts/ShipporiMincho-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
:root {
  --safe-left: env(safe-area-inset-left, 0px); --safe-right: env(safe-area-inset-right, 0px); --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  --red: #b3121a; --blood: #d01a10; --gold: #9a7a3a; --ash: #8d877c; --bg: #050303; --fg: #e9e3d5;
  --panel: rgba(8, 6, 6, .95); --line: #3a1510;
  --ui: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif CJK JP", serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg: #050303; --fg: #e9e3d5; } }
:root[data-theme="dark"] { --bg: #050303; --fg: #e9e3d5; }
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: var(--ui); overflow: hidden; -webkit-tap-highlight-color: transparent; }
#stage { position: fixed; inset: 0; touch-action: none; }
canvas { display: block; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

/* ---------- 入口 ---------- */
#intro { position: fixed; inset: 0; z-index: 9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; text-align: center;
  padding: calc(env(safe-area-inset-top, 0px) + 1rem) 1.25rem calc(env(safe-area-inset-bottom, 0px) + 1rem); transition: opacity 1.2s ease;
  background: radial-gradient(ellipse at center, rgba(5,3,3,.35) 0%, rgba(5,3,3,.9) 42%, #050303 70%), url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='80'><polyline points='0,0 30,40 0,80' fill='none' stroke='%236a130e' stroke-width='5'/><polyline points='18,0 48,40 18,80' fill='none' stroke='%238c7c66' stroke-width='3'/><polyline points='36,0 66,40 36,80' fill='none' stroke='%23201614' stroke-width='6'/></svg>"); background-color: #050303; }
#intro.gone { opacity: 0; pointer-events: none; }
/* 背景の石板（js/intro.js が描く）。文字や門はその上に「刻まれた」ように見せる */
#intro-bg { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; }
#intro > :not(#intro-bg) { position: relative; z-index: 1; }
#intro h1 { font-weight: 400; margin: 0; display: flex; flex-direction: column; gap: .45rem; align-items: center; }
/* 刻字：上の縁に影、下の縁に光（石に彫った文字の見え方） */
#intro .en { font-size: .78rem; letter-spacing: .55em; color: #b08c46; padding-left: .55em; text-shadow: 0 -1px 0 rgba(0,0,0,.95), 0 1px 0 rgba(255,226,170,.16); }
#intro .ja { font-size: 1.45rem; letter-spacing: .5em; padding-left: .5em; color: #e2d6bf; text-shadow: 0 -1px 0 rgba(0,0,0,.95), 0 1px 0 rgba(255,232,196,.2), 0 0 18px rgba(0,0,0,.7); }
#intro .lead { margin: 0; color: #ad9f8a; font-size: .8rem; line-height: 2; letter-spacing: .12em; text-shadow: 0 -1px 0 rgba(0,0,0,.9), 0 1px 0 rgba(255,232,196,.1), 0 0 10px rgba(0,0,0,.8); }
#intro .sound { margin: 0; color: #948776; font-size: .72rem; letter-spacing: .3em; text-shadow: 0 -1px 0 rgba(0,0,0,.9), 0 1px 0 rgba(255,232,196,.08); }
/* 門の下の一言：読み込みが終わると、門の点滅に合わせてゆっくり浮かぶ */
#intro .cue { margin: .2rem 0 0; color: #d0a94e; font-size: .86rem; letter-spacing: .32em; padding-left: .32em; cursor: pointer; opacity: 0; transition: opacity 1s ease; text-shadow: 0 -1px 0 rgba(0,0,0,.95), 0 1px 0 rgba(255,226,170,.18), 0 0 12px rgba(0,0,0,.8); }
#enter:not(:disabled) ~ .cue { opacity: 1; animation: cue 2.2s ease-in-out 1s infinite; }
@keyframes cue { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { #enter:not(:disabled) ~ .cue { animation: none; } }
#enter { background: none; border: 0; padding: 0; cursor: pointer; line-height: 0; }
#enter:disabled { cursor: wait; }
/* 門の絵は、石に顔料を埋めた浮き彫りに見せる（下に影、上の縁に光） */
#enter .gate { height: min(44vh, 420px); width: auto; display: block; filter: drop-shadow(0 1.5px 0 rgba(0,0,0,.9)) drop-shadow(0 -1px 0 rgba(255,226,180,.12)) drop-shadow(0 6px 10px rgba(0,0,0,.55)); }
#enter .serp { fill: none; stroke: #7e1a14; stroke-width: 5; stroke-linecap: round; }
#enter .door { fill: #1a0806; animation: breathe 2.4s ease-in-out infinite; }
#enter:not(:disabled) .door { animation: blink 1.1s steps(1) infinite; }
@keyframes breathe { 50% { fill: #2a0c08; } }
@keyframes blink { 0% { fill: #d01a10; filter: drop-shadow(0 0 6px #d01a10); } 50% { fill: #050202; filter: none; } }
/* 読み込みの帯：石に彫った細い溝に、血赤が満ちていく */
#progress { width: min(180px, 50vw); height: 3px; background: #090605; overflow: hidden; transition: opacity .6s; box-shadow: inset 0 1px 1px rgba(0,0,0,.95), 0 1px 0 rgba(255,226,180,.1); }
#progress span { display: block; height: 100%; background: linear-gradient(90deg, #6a130e, #d01a10); transform: scaleX(0); transform-origin: left; transition: transform .3s ease; }
#enter:not(:disabled) ~ #progress { opacity: 0; }

/* ---------- 現在地・ヒント ---------- */
#place { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 56px); left: 50%; transform: translateX(-50%); z-index: 3; font-size: 1.05rem; letter-spacing: .5em; padding-left: .5em; color: var(--fg); opacity: 0; transition: opacity 1s; pointer-events: none; text-shadow: 0 0 12px #000; white-space: nowrap; }
#place.on { opacity: .92; }
#hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); z-index: 3; width: max-content; max-width: calc(100vw - 32px); text-align: center; color: var(--ash); font-size: .76rem; letter-spacing: .08em; line-height: 1.7; pointer-events: none; opacity: 0; transition: opacity .8s; text-shadow: 0 0 8px #000; }
#hint.on { opacity: 1; }

/* ---------- 上部ボタン ---------- */
#langBtn, #listBtn, #snd { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 12px); z-index: 10; font-size: .78rem; letter-spacing: .12em; background: rgba(5,2,2,.72); border: 1px solid var(--line); padding: .45rem .8rem; cursor: pointer; }
#langBtn { left: 12px; }
#listBtn { left: calc(12px + 4.6rem); }
#snd { right: 12px; }
/* パソコンでは、作品パネルを開いている間は音ボタンをパネルの左へずらす（×と重ならないように） */
@media (min-width: 601px) { body.panel-open #snd { right: calc(min(390px, 100%) + 12px); } }
#snd { transition: right .35s ease; }
/* 完成後も四つの操作を重ねない。既存の表示順・文言・音設定は維持。 */
@media (max-width: 480px) {
  #langBtn, #listBtn, #snd { letter-spacing: .04em; padding: .45rem .65rem; min-height: 40px; }
  #listBtn { left: 70px; }
  #crestBtn { left: 12px !important; top: calc(env(safe-area-inset-top, 0px) + 60px) !important; max-width: calc(100vw - 24px); min-height: 40px; }
  #place { top: calc(env(safe-area-inset-top, 0px) + 106px); }
}
#l-experiences { display: flex; flex-wrap: wrap; gap: .6rem; max-width: 1100px; margin: 0 auto 1.4rem; }
#l-experiences button { min-height: 44px; max-width: 100%; padding: .65rem .8rem; border: 1px solid #5a4225; background: #100b09; color: #d0b775; font: inherit; font-size: .8rem; line-height: 1.5; cursor: pointer; text-align: left; }

/* ---------- 作品パネル ---------- */
#panel { position: fixed; right: 0; top: 0; bottom: 0; width: min(390px, 100%); z-index: 6; background: var(--panel); border-left: 1px solid #2a1a14;
  padding: calc(env(safe-area-inset-top, 0px) + 2.2rem) 1.6rem calc(env(safe-area-inset-bottom, 0px) + 2rem); transform: translateX(100%); transition: transform .5s cubic-bezier(.2,.7,.2,1);
  display: flex; flex-direction: column; gap: .9rem; overflow-y: auto; overscroll-behavior: contain; }
#panel.open { transform: none; }
#panel h2 { font-weight: 400; font-size: 1.35rem; line-height: 1.5; margin: 0; letter-spacing: .06em; padding-right: 1.5rem; }
#panel .desc { line-height: 1.9; font-size: .9rem; margin: 0; white-space: pre-line; }
#panel .quote { color: var(--gold); font-size: .92rem; line-height: 1.8; margin: 0; }
#panel .desc:empty, #panel .quote:empty, #panel .note:empty { display: none; }
#panel dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1.2rem; margin: 0; font-size: .86rem; }
#panel dt { color: var(--ash); } #panel dd { margin: 0; } #panel dd.sold { color: var(--blood); }
#panel.is-sold h2::before { content: 'SOLD'; display: block; width: fit-content; margin-bottom: .55rem; padding: .18rem .7rem .14rem; border: 1px solid var(--blood); color: var(--blood); font-size: .74rem; letter-spacing: .4em; text-indent: .2em; }
#p-zoom { align-self: flex-start; background: none; border: 1px solid var(--gold); color: var(--fg); padding: .55rem 1rem; font-size: .85rem; letter-spacing: .12em; cursor: pointer; }
#p-buy { display: block; text-align: center; text-decoration: none; background: var(--red); color: #fff; padding: .85rem; font-size: .95rem; letter-spacing: .12em; }
#p-buy[hidden] { display: none; }
#panel .note { color: var(--ash); font-size: .78rem; line-height: 1.7; margin: 0; }
#panel .p-nav { display: flex; gap: .5rem; margin-top: .2rem; }
#panel .p-nav button { flex: 1; background: none; border: 1px solid var(--line); color: var(--fg); padding: .55rem .4rem; font-size: .8rem; letter-spacing: .08em; cursor: pointer; }
#panel .p-nav button:disabled { opacity: .3; cursor: default; }
#panel .p-nav button[hidden] { display: none; }
#p-close { position: absolute; top: calc(env(safe-area-inset-top, 0px) + .7rem); right: .8rem; background: none; border: 0; font-size: 1.6rem; cursor: pointer; line-height: 1; padding: .2rem .4rem; }
.legal { color: var(--ash); font-size: .74rem; }
@media (max-width: 600px) {
  #panel { top: auto; height: 56%; width: 100%; border-left: 0; border-top: 1px solid #2a1a14; transform: translateY(100%); padding-top: 1.6rem; }
  #panel.open { transform: none; }
  #p-close { top: .5rem; }
}

/* ---------- 一覧 ---------- */
#list { position: fixed; inset: 0; z-index: 8; background: rgba(5,3,3,.97); overflow-y: auto; padding: calc(env(safe-area-inset-top, 0px) + 3.6rem) 1rem calc(env(safe-area-inset-bottom, 0px) + 2rem); }
#list .lhead { display: flex; justify-content: space-between; align-items: center; max-width: 1100px; margin: 0 auto 1rem; }
#list h2 { font-weight: 400; font-size: 1.2rem; letter-spacing: .3em; margin: 0; }
#l-close { background: none; border: 0; font-size: 1.6rem; cursor: pointer; }
#l-note { max-width: 1100px; margin: 0 auto 1rem; color: var(--ash); font-size: .85rem; line-height: 1.7; white-space: pre-line; }
#l-rooms { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; max-width: 1100px; margin: 0 auto 1.4rem; }
#l-rooms[hidden] { display: none; }
#l-rooms .lr-label { color: var(--ash); font-size: .78rem; letter-spacing: .2em; margin-right: .3rem; }
#l-rooms button { background: none; border: 1px solid rgba(154,122,58,.55); color: var(--fg); padding: .5rem .95rem; font: inherit; font-size: .84rem; letter-spacing: .16em; cursor: pointer; transition: border-color .3s, color .3s; }
#l-rooms button:hover, #l-rooms button:focus-visible { border-color: var(--gold); color: #e0c27a; }
#l-rooms button[aria-current] { border-color: var(--gold); color: #e0c27a; }
#l-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 1.2rem; max-width: 1100px; margin: 0 auto; }
.card { display: flex; flex-direction: column; gap: .35rem; }
.card img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #0e0a09; border: 1px solid #2a1a14; cursor: zoom-in; }
.card h3 { font-weight: 400; font-size: .85rem; line-height: 1.5; margin: .2rem 0 0; }
.card .meta { margin: 0; color: var(--ash); font-size: .7rem; letter-spacing: .05em; }
.card .st { margin: 0; font-size: .72rem; color: #c9b89a; } .card .st.sold { color: var(--blood); }
.card .row { display: flex; gap: .4rem; margin-top: .2rem; }
.card .row button, .card .row a { flex: 1; text-align: center; font-size: .72rem; padding: .45rem .3rem; cursor: pointer; text-decoration: none; border: 1px solid var(--line); background: none; color: var(--fg); }
.card .row a { background: var(--red); border-color: var(--red); color: #fff; }
.card { position: relative; }
.card.sold img { opacity: .78; }
.card.sold::before { content: 'SOLD'; position: absolute; z-index: 1; top: .45rem; left: .45rem; pointer-events: none; padding: .16rem .55rem .12rem; background: rgba(110,12,8,.92); border: 1px solid #c9a24a; color: #f2e8d2; font-size: .66rem; letter-spacing: .32em; text-indent: .16em; }
.lfoot { max-width: 1100px; margin: 2rem auto 0; text-align: center; }

/* ---------- 吹き出し ---------- */
#bubble { position: fixed; z-index: 4; transform: translate(-50%, calc(-100% - 12px)); width: max-content; max-width: min(78vw, 310px, calc(100vw - var(--safe-left) - var(--safe-right) - 24px)); background: rgba(14,9,8,.95); color: var(--fg);
  border: 1px solid #8a1a12; border-radius: 14px; padding: .7rem .95rem; font-size: .86rem; line-height: 1.75; cursor: pointer; box-shadow: 0 0 18px rgba(160,20,12,.35); }
#bubble::after { content: ""; position: absolute; left: var(--bubble-arrow, 50%); bottom: -9px; transform: translateX(-50%); border: 9px solid transparent; border-bottom: 0; border-top-color: #8a1a12; }
#b-txt { display: block; }
#bubble.chara { border-radius: 18px; }
#bubble .more { display: block; text-align: right; color: #c9b89a; font-size: .72rem; margin-top: .2rem; }
#b-link { display: block; margin-top: .6rem; text-align: center; background: var(--red); color: #fff; text-decoration: none; padding: .5rem .8rem; border-radius: 8px; font-size: .82rem; letter-spacing: .08em; }
#b-link[hidden] { display: none; }
#b-more { display: contents; }
#bubble .b-link2 { display: block; margin-top: .45rem; text-align: center; background: var(--red); color: #fff; text-decoration: none; padding: .5rem .8rem; border-radius: 8px; font-size: .82rem; letter-spacing: .08em; }
/* 浴の間：3D空間に重ねる上映スクリーンと、その操作ボタン */
#screen3d { position: fixed; left: 0; top: 0; z-index: 1; pointer-events: none; }
#screenUi { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 46px); z-index: 5; display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; width: max-content; max-width: calc(100vw - 32px); }
#screenUi[hidden] { display: none; }
#screenUi button, #screenUi a { background: rgba(8,4,4,.78); border: 1px solid var(--line); color: var(--fg); font-size: .78rem; letter-spacing: .08em; padding: .5rem .9rem; cursor: pointer; text-decoration: none; }
#screenUi a { border-color: #8a1a12; }
#screenUi a[hidden], #screenUi button[hidden] { display: none; }
/* 知の間の石板：映像の縁に内側の影（石に彫り込んだ窓の奥で流れているように見せる）。押す操作は下の映像に通す */
.yt-inset { position: absolute; inset: 0; z-index: 1; pointer-events: none; box-shadow: inset 0 0 46px 14px rgba(8,4,2,.82), inset 0 0 0 5px rgba(18,12,9,.95); }
.yt-fallback { z-index: 2; }
.yt-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 36px; background: rgba(8,4,4,.92); color: #e9e3d5; font-size: 40px; letter-spacing: .08em; text-align: center; padding: 60px; }
.yt-fallback[hidden] { display: none; }
.yt-fallback .yt-play { background: #b3161c; color: #fff; border: 0; border-radius: 14px; padding: 16px 40px; font: inherit; font-size: 30px; letter-spacing: .1em; cursor: pointer; }
.yt-fallback .yt-play[hidden] { display: none; }
#intro[hidden] { display: none; }
.yt-fallback.soft { inset: auto 0 0 0; flex-direction: row; gap: 28px; padding: 20px 28px; font-size: 28px; background: rgba(8,4,4,.82); }
.yt-fallback.soft a { padding: 16px 36px; font-size: 30px; }
.yt-fallback p { margin: 0; line-height: 1.6; }
.yt-fallback a { background: #b3161c; color: #fff; text-decoration: none; padding: 28px 64px; border-radius: 14px; font-size: 44px; letter-spacing: .1em; }
#bubble.linkonly #b-txt, #bubble.linkonly .more { display: none; }
#bubble.linkonly #b-link { margin-top: 0; }
#bubble.linkonly .b-link2 { margin-top: .45rem; }

/* ---------- 拡大ビューア ---------- */
#zoom { position: fixed; inset: 0; z-index: 11; background: #050303; touch-action: none; overflow: hidden; cursor: grab; }
#zoom[hidden] { display: none; }
#z-img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; user-select: none; -webkit-user-drag: none; transition: opacity .3s; }
#z-bar { position: absolute; left: 0; right: 0; bottom: 0; padding: .7rem 1rem calc(env(safe-area-inset-bottom, 0px) + .7rem); display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem 1rem;
  background: linear-gradient(transparent, rgba(5,3,3,.92)); font-size: .78rem; color: var(--ash); pointer-events: none; }
#z-title { color: var(--fg); }
#z-close { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 10px); right: 12px; background: rgba(5,2,2,.75); border: 1px solid var(--line); font-size: 1.4rem; width: 2.6rem; height: 2.6rem; cursor: pointer; line-height: 1; }

/* ---------- 質感と暗転 ---------- */
#grain { position: fixed; inset: 0; pointer-events: none; z-index: 2; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 38%, rgba(0,0,0,.78) 100%); }
#grain::after { content: ""; position: absolute; inset: -50%; opacity: .12; animation: gr .4s steps(4) infinite;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }
@keyframes gr { 0% { transform: translate(0,0); } 25% { transform: translate(-7%,4%); } 50% { transform: translate(5%,-6%); } 75% { transform: translate(-3%,7%); } 100% { transform: translate(0,0); } }
#fade { position: fixed; inset: 0; background: #0a0202; opacity: 0; pointer-events: none; z-index: 7; transition: opacity .6s ease; }
#fade.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  #intro, #panel, #fade { transition: none; } #grain::after { animation: none; }
  #enter .door, #enter:not(:disabled) .door { animation: none; } #enter:not(:disabled) .door { fill: #d01a10; }
}
/* 入口の全体に、細かな石の粒を重ねる（門の絵や文字も同じ石の面に刻まれて見えるように） */
#intro::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: .16;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1.6 -.55'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }
/* 入口：細い画面では字間を詰め、低い画面（横向きのスマホなど）では門を小さくして、全部が石板に収まるように */
@media (max-width: 420px) {
  #intro .lead { font-size: .76rem; letter-spacing: .06em; }
  #intro .en { letter-spacing: .42em; padding-left: .42em; }
  #intro .sound { letter-spacing: .14em; }
  #intro .cue { letter-spacing: .24em; padding-left: .24em; }
}
@media (max-height: 700px) { #intro { gap: .7rem; } #enter .gate { height: min(38vh, 420px); } #intro .lead { line-height: 1.8; } }
@media (max-height: 460px) { #intro { gap: .35rem; } #enter .gate { height: 26vh; } #intro .ja { font-size: 1.2rem; } #intro .lead { line-height: 1.6; font-size: .72rem; } }

/* ---------- 隠し印の記念紋（crest.js） ---------- */
#crestBtn { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 12px); left: calc(12px + 9rem); z-index: 10; font-size: .78rem; letter-spacing: .12em; background: rgba(5,2,2,.72); border: 1px solid #8a6a30; color: #d8b866; padding: .45rem .8rem; cursor: pointer; }
#crestBtn[hidden] { display: none; }
#crestToast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); transform: translate(-50%, 8px); z-index: 12; display: flex; align-items: center; gap: .6rem; max-width: calc(100vw - 32px);
  background: rgba(10,6,5,.94); border: 1px solid #8a6a30; padding: .55rem .6rem .55rem 1rem; box-shadow: 0 6px 24px rgba(0,0,0,.6); opacity: 0; transition: opacity .45s ease, transform .45s ease; }
#crestToast.on { opacity: 1; transform: translate(-50%, 0); }
#crestToast[hidden] { display: none; }
#crestToast p { margin: 0; font-size: .82rem; letter-spacing: .08em; color: #efe6d4; }
#crestToast .ct-view { background: #9a7a3a; color: #0a0605; border: 0; padding: .45rem .8rem; font-size: .8rem; letter-spacing: .1em; cursor: pointer; white-space: nowrap; }
#crestToast .ct-x { background: none; border: 0; color: #8d877c; font-size: 1.1rem; cursor: pointer; padding: .2rem .4rem; }
#crest { position: fixed; inset: 0; z-index: 13; background: rgba(4,2,2,.94); display: flex; align-items: center; justify-content: center; overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(env(safe-area-inset-bottom, 0px) + 12px); }
#crest[hidden] { display: none; }
#crest .c-box { position: relative; width: 100%; max-width: 460px; display: flex; flex-direction: column; align-items: center; gap: .6rem; margin: auto; }
#crest h2 { margin: .2rem 0 0; font-weight: 400; font-size: 1rem; letter-spacing: .3em; padding-left: .3em; color: #d8b866; }
#c-img { display: block; width: auto; max-width: 100%; max-height: min(58vh, 560px); aspect-ratio: 1080 / 1350; border: 1px solid #3a1510; -webkit-touch-callout: default; user-select: none; }
#c-close { position: absolute; top: -4px; right: 0; background: rgba(5,2,2,.75); border: 1px solid var(--line); color: var(--fg); font-size: 1.3rem; width: 2.4rem; height: 2.4rem; cursor: pointer; line-height: 1; z-index: 1; }
.c-orderLabel { margin: 0; font-size: .72rem; color: #8d877c; letter-spacing: .2em; }
#c-order { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem .8rem; width: 100%; }
#c-order li { display: flex; align-items: center; gap: .3rem; font-size: .8rem; color: #efe6d4; }
#c-order canvas { width: 28px; height: 28px; }
#c-order li { min-width: 0; }
#c-order span { overflow-wrap: anywhere; }
@media (max-width: 380px) { #c-order { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
#crest .c-btns { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
#crest .c-btns button, #crest .c-btns a { font: inherit; font-size: .8rem; letter-spacing: .08em; padding: .6rem .9rem; cursor: pointer; text-decoration: none; border: 1px solid var(--line); background: none; color: var(--fg); }
#c-save { background: #9a7a3a !important; border-color: #9a7a3a !important; color: #0a0605 !important; }
#crest .c-note { margin: 0; font-size: .68rem; color: #6e6457; text-align: center; line-height: 1.6; }
.lmark { background: none; border: 0; padding: 4px; cursor: pointer; line-height: 0; opacity: .5; transition: opacity .4s ease, filter .4s ease; }
.lmark canvas { width: 30px; height: 30px; }
.lmark.found { opacity: 1; filter: drop-shadow(0 0 4px rgba(201,162,74,.8)); }
.lmark.hintglow { animation: lmglow 3.2s ease-in-out infinite; }
.lmark.lit { animation: lmlit .9s ease-out; }
@keyframes lmglow { 50% { opacity: .9; filter: drop-shadow(0 0 5px rgba(201,162,74,.7)); } }
@keyframes lmlit { 0% { filter: drop-shadow(0 0 14px #e8c26a) brightness(1.6); } 100% { filter: drop-shadow(0 0 4px rgba(201,162,74,.8)); } }
#l-grid .lmark.lm-grid { align-self: center; justify-self: center; }
#list .lhead .lmark { margin-right: auto; margin-left: .6rem; }
@media (prefers-reduced-motion: reduce) { .lmark.hintglow, .lmark.lit { animation: none; } #crestToast { transition: none; } }

/* 小さな扉から最初の画面へ戻っている間は、記念紋のボタンも隠す（入り直すと戻る） */
body.at-intro #crestBtn { display: none; }
/* WebGL が戻らない時の「読み込み直す」 */
.gl-reload { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 60; min-height: 48px; padding: 12px 22px; font: inherit; font-size: .95rem; letter-spacing: .12em; color: #f1e6cc; background: rgba(20,10,8,.92); border: 1px solid #b08a4a; border-radius: 4px; cursor: pointer; }
.gl-reload:focus-visible { outline: 2px solid #e6c174; outline-offset: 3px; }
/* 横持ちのノッチ：常設ボタンを左右の安全域の内側へ（寸法と並び順はそのまま） */
:root { --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px); }
#langBtn { left: calc(var(--sl) + 12px); }
#listBtn { left: calc(var(--sl) + 12px + 4.6rem); }
#snd { right: calc(var(--sr) + 12px); }
#crestBtn { left: calc(var(--sl) + 12px + 9rem); }
@media (min-width: 601px) { body.panel-open #snd { right: calc(min(390px, 100%) + var(--sr) + 12px); } }
@media (max-width: 480px) {
  #listBtn { left: calc(var(--sl) + 70px); }
  #crestBtn { left: calc(var(--sl) + 12px) !important; max-width: calc(100vw - 24px - var(--sl) - var(--sr)); }
}
/* 拡大表示のキー・タップ操作（＋／－／全体） */
#z-ctl { position: absolute; right: calc(var(--sr, 0px) + 12px); bottom: calc(env(safe-area-inset-bottom, 0px) + 64px); display: flex; flex-direction: column; gap: 8px; z-index: 2; }
#z-ctl button { min-width: 44px; min-height: 44px; font: inherit; font-size: .95rem; color: var(--fg); background: rgba(5,2,2,.72); border: 1px solid var(--line); cursor: pointer; }
#z-ctl button:focus-visible, #z-close:focus-visible { outline: 2px solid #e6c174; outline-offset: 2px; }
/* 最初の画面の言語選び（左上の EN ボタンは、最初の画面が出ている間は隠す） */
#langPick { display: flex; align-items: center; gap: .5rem; margin-top: .2rem; color: #6f6455; font-size: .8rem; }
#langPick button { min-height: 40px; min-width: 64px; padding: .4rem .9rem; font: inherit; font-size: .8rem; letter-spacing: .14em; color: #a8997c; background: rgba(5,2,2,.55); border: 1px solid #3c2b1c; cursor: pointer; }
#langPick button[aria-pressed="true"] { color: #f0d79a; border-color: #b08c46; background: rgba(36,23,14,.85); }
#langPick button:focus-visible { outline: 2px solid #e6c174; outline-offset: 2px; }
#intro:not(.gone):not([hidden]) ~ #langBtn { visibility: hidden; }
/* 入口の言語選択の下に置く公式サイトへの導線 */
#intro { justify-content: safe center; overflow-y: auto; }
#intro-official { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; max-width: 100%; padding: .25rem .5rem; color: #c9b080; font-size: .75rem; line-height: 1.6; letter-spacing: .06em; text-decoration: underline; text-decoration-color: #7d6034; text-underline-offset: .3em; }
#intro-official:hover { color: #f0d79a; text-decoration-color: currentColor; }
#intro-official:focus-visible { outline: 2px solid #e6c174; outline-offset: 3px; }
#intro-official .official-en { display: none; }
html[lang="en"] #intro-official .official-ja { display: none; }
html[lang="en"] #intro-official .official-en { display: inline; }

/* VR モード（対応機器でだけ出る）：最初の画面の「VRで入る」と、入館後の上部の「VR」 */
#vrEnter { min-height: 44px; padding: .5rem 1.4rem; font: inherit; font-size: .84rem; letter-spacing: .2em; color: #f0d79a; background: rgba(36,23,14,.85); border: 1px solid #b08c46; cursor: pointer; }
#vrEnter:focus-visible, #vrBtn:focus-visible { outline: 2px solid #e6c174; outline-offset: 2px; }
/* 「音」ボタンの文字の長さ（日英）に左右されないよう、音ボタンのすぐ下（右上の2段目）に置く */
#vrBtn { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 60px); right: calc(var(--sr, 0px) + 12px); z-index: 10; font-size: .78rem; letter-spacing: .12em; background: rgba(5,2,2,.72); border: 1px solid #8a6a30; color: #d8b866; padding: .45rem .8rem; cursor: pointer; transition: right .35s ease; }
@media (min-width: 601px) { body.panel-open #vrBtn { right: calc(min(390px, 100%) + var(--sr, 0px) + 12px); } }
#vrBtn[hidden], #vrEnter[hidden], #listBtn[hidden] ~ #vrBtn { display: none; }
@media (max-width: 480px) { #vrBtn { min-height: 40px; padding: .45rem .65rem; } }
/* 英語表示では左上のボタンが「日本語」と長くなるので、一覧ボタンをその分右へ（スマホで重ならないように） */
@media (max-width: 480px) { #listBtn { left: calc(var(--sl, 0px) + 12px + 4.4rem); } }
