/* 塗りの画面（ux B） */
/* 上の帯 44px。左の 52px は「作った話と感想」の席 */
#hud-top { position: relative; height: 44px; flex: none; display: flex; align-items: center; gap: 4px; padding: 0 4px 0 0; }
.hud-fb { width: 56px; flex: none; }
#hud-center { flex: 1; min-width: 0; height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px; background: none; color: var(--paper); box-shadow: none; padding: 0 0 0 40px; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#seeker-face { width: 34px; height: 34px; flex: none; display: grid; place-items: center; }
#seeker-face:empty { width: 0; }
#seeker-face > svg { width: 100%; height: 100%; }
#hud-sound, #hud-lang { flex: none; height: 44px; background: none; color: var(--paper); box-shadow: none; padding: 0 4px; font-size: 12px; outline: 0; }
#hud-sound:focus-visible, #hud-lang:focus-visible { outline: 3px solid #FFD27A; outline-offset: -3px; }
#hud-sound svg { width: 24px; height: 24px; display: block; margin: 0 auto; }
#hud-lang { min-width: 52px; }
#hud-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--paper); opacity: .75; transform-origin: left; transform: scaleX(0); }

/* 下の道具 2段で 112px */
#hud-bottom { height: 112px; flex: none; display: flex; flex-direction: column; justify-content: center; gap: 7px; padding: 0 6px; }
#hud-bottom .row { display: flex; align-items: center; gap: 6px; height: 48px; }
.row > .grow { flex: 1; min-width: 0; }
#hud-bottom button { height: 48px; flex: none; font-size: 13px; line-height: 1.2; }
#hud-bottom button.tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 46px; padding: 0 3px; font-size: 10px; white-space: nowrap; }
#hud-bottom button.tool svg { width: 24px; height: 24px; flex: none; }
#hud-bottom button[data-act^="pose-"] { min-width: 52px; }
#hud-bottom button[data-act^="pose-"] svg { width: 20px; height: 31px; }
#hud-bottom button.toggle { width: 84px; min-width: 76px; font-size: 11px; } /* 寄りと全体で幅を変えない（隣の位置がずれない） */
#hud-bottom button.toggle span { white-space: normal; line-height: 1.1; }
#hud-bottom button.main { position: relative; min-width: 86px; padding: 0 8px; font-size: 14px; }
#hud-bottom button.main small { position: absolute; left: 50%; top: -9px; transform: translateX(-50%); white-space: nowrap; background: var(--paper); color: var(--ink); border-radius: 999px; padding: 0 8px; font-size: 10px; line-height: 15px; box-shadow: 0 1px 0 #1c1410; }
#hud-bottom button.dim { opacity: .45; }
.rooms { display: flex; gap: 4px; min-width: 0; }
#hud-bottom button.room { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; min-width: 56px; max-width: 74px; padding: 0 4px; white-space: normal; }
#hud-bottom button.room svg { width: 14px; height: 14px; }
#hud-bottom button.locked { opacity: .55; }
.chip { display: inline-block; width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--paper); box-shadow: 0 0 0 2px #1c1410; flex: none; margin: 0 2px; }
.chip.empty { background-image: linear-gradient(135deg, #fff 45%, #b9a48d 46%, #b9a48d 54%, #fff 55%); }
.chip.unpicked { border-style: dashed; }
.chip-hint { position: relative; flex: none; padding-left: 10px; white-space: pre; font-size: 11px; line-height: 1.35; font-weight: 700; color: #FFD27A; }
.chip-hint::before { content: ''; position: absolute; left: 0; top: 50%; margin-top: -5px; border: 5px solid transparent; border-right-color: currentColor; border-left: 0; }
.recents { display: flex; flex: none; }
#hud-bottom button.recent { min-width: 34px; width: 34px; height: 44px; padding: 0; background: none; box-shadow: none; outline: 0; }
button.recent i { display: block; width: 28px; height: 28px; margin: 0 auto; border-radius: 50%; border: 2px solid var(--paper); box-shadow: 0 0 0 1px #1c1410; }
.chip.bump { animation: pop .12s ease-out; }
.bump:not(.chip) { animation: swell .5s ease-in-out; }
.shake { animation: shake .24s linear; }
@keyframes swell { 50% { transform: scale(1.07); } }
@keyframes pop { 50% { transform: scale(1.16); } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* 部屋の上端の1行と札 */
#guide { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 16px); text-align: center; text-wrap: balance; word-break: auto-phrase; font-size: 13px; line-height: 1.4; padding: 4px 12px; border-radius: 14px; background: #35271Fe6; color: var(--paper); pointer-events: none; z-index: 2; }
#guide:empty { display: none; }
#stage:has(#compose-tag:not([hidden])) #guide { top: 56px; }
#compose-tag { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); white-space: nowrap; font-size: 12px; padding: 0 14px; z-index: 2; }
/* 「⋯」と確かめの小さな紙の札 */
#sheet { position: absolute; inset: 0; z-index: 4; display: flex; align-items: flex-end; justify-content: center; padding: 8px; background: #1c141055; }
#sheet .card { width: min(100%, 320px); display: flex; flex-direction: column; gap: 8px; background: var(--paper); color: var(--ink); border-radius: 12px; padding: 12px; box-shadow: 0 2px 0 #1c1410; font-size: 14px; text-align: center; }
#sheet .card button { border: 2px solid #35271F44; box-shadow: none; }
#sheet .card button.main { border-color: transparent; }
#sheet .row { display: flex; gap: 8px; }
#sheet .row button { flex: 1; }

/* PC: 同じ縦の列を中央に置く。左右は机の色紙の地（飾りは base.css） */
@media (min-width: 560px) {
  #app { max-width: min(480px, calc((100dvh - 156px) * .5634 + 40px)); min-width: 400px; box-shadow: 0 0 0 1px #F1E7D233, 0 0 40px #0006; }
}
@media (prefers-reduced-motion: reduce) { .chip.bump, .bump:not(.chip), .shake { animation: none; } }

/* 横向きの電話: 部屋を左いっぱいに置き、帯と道具を右の列へ（隠れる間と見回しの間。結果の札が出る時は縦の列のまま） */
@media (orientation: landscape) and (max-height: 500px) {
  #app:has(> #panel[hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) 372px; grid-template-rows: 44px minmax(0, 1fr); max-width: none; min-width: 0; }
  #app:has(> #panel[hidden]) > #stage { grid-column: 1; grid-row: 1 / 3; }
  #app:has(> #panel[hidden]) > #hud-top { grid-column: 2; grid-row: 1; }
  #app:has(> #panel[hidden]) > #hud-bottom { grid-column: 2; grid-row: 2; align-self: end; margin-bottom: 8px; }
}

/* 数え。止まっている間は2段（秒と理由）と点線の棒。動き出しに1回光る */
#hud-count[data-state] { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
#hud-count b { font-weight: 700; }
#hud-count small { font-size: 10px; font-weight: 700; }
#hud-count[data-state="wait"] b { opacity: .75; }
#hud-count[data-state="wait"] small { color: #FFD27A; }
#hud-bar[data-state="wait"] { opacity: .6; background: repeating-linear-gradient(90deg, var(--paper) 0 6px, #0000 6px 10px); }
#hud-count.go { animation: go .9s ease-out; }
@keyframes go { 25% { transform: scale(1.3); color: #FFD27A; } 60% { color: #FFD27A; } }
@media (prefers-reduced-motion: reduce) { #hud-count.go { animation: none; } }

/* 人形を動かした時の「寄って塗る」。ふつうの手ほどきより大きく1回 */
#hud-bottom button.nudge { animation: nudge .8s ease-in-out; transform-origin: 70% 100%; z-index: 1; }
@keyframes nudge { 40% { transform: scale(1.2); box-shadow: 0 0 0 4px #FFD27A; } 75% { box-shadow: 0 0 0 4px #FFD27A; } }
@media (prefers-reduced-motion: reduce) { #hud-bottom button.nudge { animation: none; outline: 4px solid #FFD27A; } }

/* じっくり: 入り切りのつまみで「今のモード」と「押すと替わる」を両方見せる */
#compose-tag.switch, #sheet .card button.switch { display: flex; align-items: center; justify-content: center; gap: 8px; }
.switch::before { content: ''; flex: none; width: 34px; height: 20px; border-radius: 999px; background: radial-gradient(circle at 10px 10px, #fff 0 7px, #0000 7.5px), #9C8B78; }
.switch[aria-pressed="true"]::before { background: radial-gradient(circle at 24px 10px, #fff 0 7px, #0000 7.5px), #2F6B63; }
#compose-tag.switch[aria-pressed="true"], #sheet .card button.switch[aria-pressed="true"] { background: #CFE6DC; outline: 3px solid #2F6B63; outline-offset: -1px; font-weight: 700; }
#hud-count[data-state="slow"] { background: #2F6B63; color: #fff; border-radius: 999px; padding: 3px 12px; box-shadow: 0 0 0 2px #CFE6DC; }

/* 幅の狭い電話: 寄りの下の段（戻す・のぞく・ほか・全体・「リンクを作る」）がはみ出さないように詰める */
@media (max-width: 374px) { #hud-bottom { padding: 0 4px; } #hud-bottom .row { gap: 4px; } #hud-bottom button.main { padding: 0 5px; font-size: 13px; } }

/* 画面が切り替わった直後は、部屋と道具が押しを受けない（hud.js の guardSwitch。見た目は変えない） */
#app[data-arming] :is(#stage, #hud-bottom), #app[data-arming] :is(#stage, #hud-bottom) * { pointer-events: none !important; }

/* 使った場所の印（全体の画面。床の手前の札と帯）。押しは下の #fx に通す */
#spots { position: absolute; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.spot-band { position: absolute; height: 5px; border-radius: 3px; background: var(--paper); box-shadow: 0 0 0 1.5px var(--ink); }
.spot-mark { position: absolute; transform: translate(-50%, -50%); width: 36px; height: 30px; display: grid; place-items: center; background: var(--paper); border: 2px solid var(--ink); border-radius: 9px; box-shadow: 0 2px 0 #1c1410; }
.spot-mark .spot-face { width: 32px; height: 23px; }
.spot-face { display: block; overflow: visible; filter: drop-shadow(0 0 .6px #35271F) drop-shadow(0 0 .6px #35271F); }
.spot-mark.shake-mark { animation: shake-mark .36s linear; }
@keyframes shake-mark { 20%, 60% { translate: -4px 0; } 40%, 80% { translate: 4px 0; } }
@media (prefers-reduced-motion: reduce) { .spot-mark.shake-mark { animation: none; } }

/* 使った場所に立っている間の「隠れた！」: 色を落として鍵を付ける（押すと理由の合図が返る） */
#hud-bottom button.main.blocked { background: #6E5F55; color: #D9CCBB; box-shadow: none; }
#hud-bottom button.main i.lock { position: absolute; right: -3px; top: -8px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--paper); color: var(--ink); box-shadow: 0 1px 0 #1c1410; }
#hud-bottom button.main i.lock svg { width: 15px; height: 15px; }

/* 引いている間の場所の名前（人形の頭の上） */
#spot-label { position: absolute; transform: translateX(-50%); z-index: 2; pointer-events: none; display: flex; align-items: center; gap: 5px; white-space: nowrap; padding: 4px 12px; border-radius: 999px; background: var(--paper); color: var(--ink); box-shadow: 0 0 0 2px var(--ink); font-size: 14px; }
#spot-label > svg { width: 16px; height: 16px; }
#spot-label.used { background: #CDBFAA; }
#spot-label.used b { opacity: .55; }
#spot-label .faces, .spot-list .faces { display: flex; gap: 2px; }
#spot-label .faces:empty { display: none; }
#spot-label .spot-face { width: 22px; height: 16px; }

/* 「ほか」の中の場所の記録 */
#sheet .card { max-height: 100%; overflow-y: auto; }
#sheet .card > * { flex: none; }
.spot-list h2 { font-size: 12px; margin-bottom: 3px; }
.spot-list ul { list-style: none; }
.spot-list li { display: flex; align-items: center; gap: 6px; min-height: 23px; font-size: 12px; border-top: 1px solid #35271F22; text-align: left; }
.spot-list .name { display: flex; align-items: center; gap: 3px; flex: 1; min-width: 0; }
.spot-list li.used .name { opacity: .6; }
.spot-list .name svg { width: 13px; height: 13px; }
.spot-list .spot-face { width: 21px; height: 15px; }
.spot-list .best { flex: none; min-width: 118px; text-align: right; font-variant-numeric: tabular-nums; }
.spot-list .best b { font-size: 13px; }
.spot-list .mult, #spot-label .mult { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.spot-list .mult { min-width: 32px; text-align: right; color: #8A3A18; }
#spot-label .mult { color: #8A3A18; }
.spot-list p { font-size: 11px; line-height: 1.4; text-align: left; margin-bottom: 4px; white-space: pre-line; text-wrap: balance; word-break: auto-phrase; }

/* 全体へ戻り切った時の流し見（paint-glance.js）。帯の小さな顔の上に同じ絵を重ねる */
#seeker-face { position: relative; }
#seeker-glance { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 1; }
#seeker-glance > svg { width: 100%; height: 100%; overflow: visible; }
#hud-center[data-glance] #seeker-face > svg { visibility: hidden; }

/* 今の色の丸の名前（初めての人に、何の丸かを伝える） */
.chip { position: relative; }
.chip::after { content: attr(data-label); position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); white-space: nowrap; padding: 0 5px; border-radius: 999px; background: var(--paper); color: var(--ink); box-shadow: 0 0 0 1px #1c1410; font-size: 9px; line-height: 13px; font-weight: 700; }
