/* 夜の画面。白い大きな面は作らない。文字は #cfd8ea（最大でも 90% の白）。
   配置（390×844 を基準）: 左上=感想（feedback-widget）、右上=言語（待ち画面と結果だけ）・夜の印・⚙、左下=歩くパッド、右下=手に持ったスマホ（ライト）、
   擬音は上から 90px 以下、下の中央は PC のキーの手がかり。 */
:root { --bg: #05070d; --ink: #cfd8ea; --dim: #8795b5; --moon: #2a3550; --light: #eef4ff; --line: rgba(120,145,205,.35); --warm: #ffd9a0; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; overscroll-behavior: none;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; transition: filter .9s; }
body[data-phase="done"] #view { filter: blur(5px) brightness(.42); }
.hidden { display: none !important; }

/* 画面全体の暗さ（ビネット）と、フィルムのざらつき。重ねるだけで、物の見え方は変えない */
#vignette { position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, transparent 52%, rgba(0,0,0,.5) 100%); }
#vignette::after { content: ""; position: absolute; inset: 0; opacity: .035; mix-blend-mode: overlay;
  background-image: var(--grain-img, none); }

/* 読み込み: 暗闇に月明かりの線が伸びる */
#boot { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; transition: opacity .6s; z-index: 9; }
#boot.hidden { display: block !important; opacity: 0; pointer-events: none; }
.moon-line { width: 2px; height: 0; background: linear-gradient(#6f86c4, transparent); animation: grow 1.2s ease-out forwards; }
@keyframes grow { to { height: 40vh; } }

/* 題名と目的の 1 行。最初の 1 タッチで 1 秒かけて消える */
#intro { position: fixed; left: 50%; top: 27%; width: min(90vw, 520px); transform: translateX(-50%); text-align: center; padding: 20px 22px 18px; border-radius: 18px; background: radial-gradient(ellipse at center, rgba(5,7,13,.86) 0%, rgba(5,7,13,.74) 65%, rgba(5,7,13,0) 100%); pointer-events: none; z-index: 3; transition: opacity 1s; }
#intro h1 { margin: 0 0 .5em; font: 600 28px/1.3 "Hiragino Mincho ProN", "Noto Serif JP", "Yu Mincho", serif; color: #e4ebfa; letter-spacing: .08em; text-shadow: 0 0 10px #000, 0 0 2px #000; opacity: 0; animation: rise 1.4s .5s forwards; }
#intro p { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.55; text-wrap: balance; color: #e4ebfa; text-shadow: 0 0 8px #000, 0 0 2px #000; opacity: 0; animation: rise 1.2s 1.3s forwards; }
@keyframes rise { to { opacity: 1; } }
#intro.gone { opacity: 0; }

/* 上の隅 */
#top { position: fixed; top: max(8px, env(safe-area-inset-top)); right: 10px; z-index: 6; display: flex; gap: 8px; align-items: center; }
#top button { height: 44px; min-width: 44px; padding: 0 11px; justify-content: center; background: rgba(5,7,13,.55); border: 1px solid var(--moon); border-radius: 22px; color: var(--ink); font-size: 14px; display: inline-flex; align-items: center; gap: 5px; backdrop-filter: blur(2px); }
#top button:active { background: rgba(40,55,95,.6); }
#night-btn .moon { font-size: 15px; }
body[data-phase="play"] #lang-btn, body[data-phase="ending"] #lang-btn { display: none; }
body[data-phase="ending"] #top, body[data-phase="ending"] #pad-ring, body[data-phase="ending"] #phone, body[data-phase="ending"] #light-btn, body[data-phase="ending"] #keys { opacity: 0; pointer-events: none; transition: opacity .5s; }
#night-btn.pulse { animation: beat 1.2s ease-in-out infinite; border-color: #9fb3e8; }
@keyframes beat { 50% { box-shadow: 0 0 14px rgba(159,179,232,.7); } }

/* 歩くパッド（左下。触れた点が中心になる浮くパッド）。ふだんは 25% の明るさで、足あとが上へ流れる */
#pad-zone { position: fixed; left: 37px; bottom: 91px; width: 176px; height: 176px; border-radius: 50%; z-index: 4; touch-action: none; }   /* 円（中心 125, 底から 179）の外へ 18px 広げた押せる範囲。外は見回しの面 */
#pad-ring { position: fixed; z-index: 4; left: 125px; bottom: 109px; width: 140px; height: 140px; margin: -70px 0 0 -70px; border-radius: 50%; border: 2px solid rgba(160,185,235,.5); background: rgba(20,28,48,.18); pointer-events: none; transition: opacity .2s, border-color .2s; opacity: .3; overflow: hidden; }
#pad-ring.active { opacity: .7; border-color: rgba(190,210,255,.8); }
#pad-ring.pulse:not(.active) { animation: padpulse 1.6s ease-in-out infinite; }
@keyframes padpulse { 50% { opacity: .65; box-shadow: 0 0 18px rgba(160,185,235,.4); } }
#pad-ring .steps { position: absolute; left: 50%; top: 14%; width: 44px; height: 72%; margin-left: -22px; background: var(--steps-img, none) repeat-y center top; -webkit-mask-image: linear-gradient(transparent, #000 25%, #000 75%, transparent); mask-image: linear-gradient(transparent, #000 25%, #000 75%, transparent); animation: steps var(--flow, 1.8s) linear infinite; }
@keyframes steps { from { background-position: center 0; } to { background-position: center -88px; } }
#pad-ring .knob { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px; border-radius: 50%; background: rgba(210,225,255,.5); box-shadow: 0 0 12px rgba(190,210,255,.5); opacity: 0; transform: translate(var(--kx, 0), var(--ky, 0)); transition: opacity .15s; }
#pad-ring.active .knob { opacity: 1; }

/* ライト（右下。手に持ったスマホ）。ボタンは直径 88px の円のまま、スマホの画面の中にある */
#phone { position: fixed; z-index: 4; right: 4px; bottom: calc(-20px + max(0px, env(safe-area-inset-bottom) * 0)); width: 120px; height: 220px; pointer-events: none; opacity: .72; transition: transform .08s, opacity .2s; }
#phone svg { display: block; }
#phone .ph-led, #phone .ph-ring, #phone .ph-rays { opacity: .4; transition: opacity .08s; }
#phone.pulse .ph-led, #phone.pulse .ph-ring, #phone.pulse .ph-rays { animation: ledbeat 1.3s ease-in-out infinite; }
@keyframes ledbeat { 50% { opacity: 1; } }
#phone.active { transform: translateY(3px); opacity: .95; }
#phone.active .ph-led, #phone.active .ph-ring, #phone.active .ph-rays { opacity: 1; }
#phone.active .ph-hand path:nth-child(2) { fill: #c58a6c; opacity: .7; }
#light-btn { position: fixed; right: 20px; bottom: 44px; width: 88px; height: 88px; border-radius: 50%; z-index: 5; border: 0; background: transparent; touch-action: none; padding: 0; }
#light-btn::before { content: ""; position: absolute; inset: -34px -24px -30px -70px; }   /* 触れる範囲を広げる（見えない） */
#light-btn .glow { display: none; }

/* PC の手がかり（指で触れない機器だけ）。使った操作から順に消える */
#keys { position: fixed; z-index: 4; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 14px; opacity: .45; pointer-events: none; font-size: 12px; color: var(--ink); white-space: nowrap; }
#keys span { display: inline-flex; align-items: center; gap: 5px; transition: opacity .8s; }
#keys span.used { opacity: 0; }
#keys kbd { font: inherit; border: 1px solid rgba(180,200,240,.55); border-radius: 4px; padding: 1px 6px; background: rgba(20,28,48,.5); }

/* 擬音の字幕（実際に鳴った音だけ。上から 90px 以下） */
#subs { position: fixed; left: 0; right: 0; top: 0; height: 100%; pointer-events: none; z-index: 4; }
.sub { position: absolute; font: 400 16px/1.2 "Hiragino Mincho ProN", "Noto Serif JP", "Yu Mincho", serif; color: rgba(190,210,255,.78); text-shadow: 0 0 8px #000; white-space: nowrap; animation: subfade 1.5s ease-out forwards; }
.sub.l { left: 14px; } .sub.r { right: 14px; } .sub.c { left: 50%; transform: translateX(-50%); }
@keyframes subfade { 0% { opacity: 0; } 12% { opacity: 1; } 70% { opacity: .8; } 100% { opacity: 0; } }

/* 設定、夜の選択 */
#settings, #night-pick { position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; background: rgba(5,7,13,.72); }
.panel { width: min(320px, 86vw); background: rgba(14,19,32,.96); border: 1px solid var(--moon); border-radius: 14px; padding: 18px 18px 16px; box-shadow: 0 8px 40px rgba(0,0,0,.6); }
.panel h2 { margin: 0 0 14px; font: 400 18px/1.3 "Hiragino Mincho ProN", "Noto Serif JP", serif; letter-spacing: .06em; color: #b9c6e4; }
.panel .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0; font-size: 14px; }
.seg { display: inline-flex; border: 1px solid var(--moon); border-radius: 16px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 6px 12px; font-size: 13px; color: var(--dim); }
.seg button.on { background: rgba(60,80,130,.5); color: var(--ink); }
.toggle { min-width: 64px; padding: 6px 12px; border: 1px solid var(--moon); border-radius: 16px; background: transparent; font-size: 13px; color: var(--dim); }
.toggle.on { background: rgba(60,80,130,.5); color: var(--ink); border-color: #6f86c4; }
.link { background: none; border: 0; padding: 4px 0; color: var(--dim); text-decoration: underline; font-size: 13px; }
.primary, .buttons button { min-height: 52px; border-radius: 12px; border: 1px solid var(--moon); background: rgba(20,28,48,.8); color: var(--ink); font-size: 15px; padding: 0 16px; }
.primary { width: 100%; margin-top: 8px; }
#night-list { display: grid; gap: 8px; }
#night-list button { min-height: 48px; border-radius: 10px; border: 1px solid var(--moon); background: rgba(20,28,48,.8); font-size: 15px; }
#night-list button[disabled] { opacity: .35; }
#night-list button.cur { border-color: #9fb3e8; }

/* 間取りのマップ（F28）。暗い所で見る紙の図。図の外を押すと閉じる */
#map { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(5,7,13,.78); padding: 56px 4px 16px; }
#map-plan { width: min(100%, 760px); max-height: 100%; padding: 6px; background: #121826; border: 1px solid #3a4666; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.65), inset 0 0 40px rgba(0,0,0,.35); }
#map-plan svg { display: block; width: 100%; height: auto; max-height: calc(100vh - 195px); font-family: system-ui, "Hiragino Sans", "Noto Sans JP", sans-serif; }
#map-btn { padding: 0 9px; }
#map-btn.on { background: rgba(60,80,130,.6); border-color: #9fb3e8; }
#map-btn.first { animation: beat 1.2s 2.6s 2 ease-in-out; }
body[data-phase="done"] #map-btn, body[data-phase="ending"] #map-btn { display: none; }

/* 終わりの場面 */
#veil { position: fixed; inset: 0; z-index: 5; pointer-events: none; background: #000; opacity: 0; transition: opacity 1s; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 28vh; }
#veil.dim { opacity: .45; }
#veil.dark { opacity: .78; }
#ending-line { margin: 0; font: 400 20px/1.4 "Hiragino Mincho ProN", "Noto Serif JP", serif; color: #d4dcee; letter-spacing: .06em; opacity: 0; transition: opacity .5s; text-shadow: 0 0 10px #000; }
#ending-line.show { opacity: .92; }

/* 結果の画面 */
#result { position: fixed; inset: 0; z-index: 7; display: flex; flex-direction: column; justify-content: space-between; padding: max(64px, env(safe-area-inset-top) + 54px) 22px max(24px, env(safe-area-inset-bottom)); background: linear-gradient(rgba(5,7,13,.2), rgba(5,7,13,.65)); }
#result .card { max-width: 440px; width: 100%; margin: 0 auto; }
#res-title { margin: 0 0 6px; font: 400 22px/1.35 "Hiragino Mincho ProN", "Noto Serif JP", serif; letter-spacing: .05em; color: #dce4f6; }
#res-meta { margin: 0 0 14px; font-size: 15px; color: #aab7d6; letter-spacing: .04em; }
#res-meta .stars { color: #ffd9a0; letter-spacing: .15em; margin-left: 6px; }
#res-meta .best { margin-left: 8px; font-size: 12px; padding: 2px 8px; border: 1px solid #ffd9a0; color: #ffd9a0; border-radius: 10px; }
#res-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 15px; line-height: 1.5; color: #cfd8ea; }
#res-lines li { padding-left: 10px; border-left: 2px solid rgba(120,145,205,.4); }
#res-note { margin-top: 10px; }
.note { font-size: 13px; color: var(--dim); }
#result .buttons { display: flex; gap: 10px; max-width: 440px; width: 100%; margin: 0 auto; }
#result .buttons button { flex: 1; }
#result .buttons button.main { border-color: #9fb3e8; background: rgba(60,80,130,.55); }

#pause { position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; background: rgba(5,7,13,.78); text-align: center; line-height: 2; }
#nowebgl { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: var(--bg); text-align: center; padding: 24px; }
#nowebgl img { max-width: 80vw; height: auto; border-radius: 8px; margin-top: 12px; opacity: .8; }

/* PC（広い画面）: スマホ縦の配置のまま、パッドとスマホの大きさを少し大きくする */
@media (min-width: 900px) {
  #pad-ring { left: 170px; bottom: 150px; width: 160px; height: 160px; margin: -80px 0 0 -80px; }
  #pad-zone { left: 70px; bottom: 130px; width: 200px; height: 200px; }
  #phone { right: 28px; bottom: -10px; }
  #light-btn { right: 44px; bottom: 54px; }
  #intro h1 { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) { #pad-ring .steps, .sub { animation-duration: 3s; } }

/* 結果の画面では、操作の手がかりを隠す */
body[data-phase="done"] #pad-ring, body[data-phase="done"] #phone, body[data-phase="done"] #light-btn, body[data-phase="done"] #keys { display: none; }
body[data-phase="done"] #pad-zone { pointer-events: none; }


/* 手の届く叩ける物（冷蔵庫、プリン、扉）の上の手の印。叩くと開く */
.reach-mark { position: fixed; z-index: 4; width: 64px; height: 64px; margin: -32px 0 0 -32px; display: none; align-items: center; justify-content: center; border-radius: 50%; border: 2px solid rgba(225,235,255,.85); background: rgba(40,56,96,.4); box-shadow: 0 0 18px rgba(190,210,255,.6); animation: reachpulse 1.2s ease-in-out infinite; touch-action: manipulation; }
.reach-mark svg { width: 34px; height: 34px; }
.reach-mark { display: flex; }
.reach-mark .rl { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 4px; padding: 2px 9px; border-radius: 11px; background: rgba(5,7,13,.8); color: #e8f0ff; font-size: 13px; font-weight: 600; white-space: nowrap; pointer-events: none; animation: none; }
@keyframes reachpulse { 50% { transform: scale(1.12); box-shadow: 0 0 26px rgba(210,225,255,.85); } }
body[data-phase="ending"] #reach-marks, body[data-phase="done"] #reach-marks, body[data-phase="wait"] #reach-marks { display: none; }

/* 終わりの場面と結果には、手ほどきの文字と字幕を重ねない（夜1 の失敗の結果に「真夜中のつまみ食い」が重なった） */
body[data-phase="ending"] #intro, body[data-phase="done"] #intro, body[data-phase="done"] #subs { display: none; }

/* 短いタップの後: 「押さえ続ける」絵。指が押さえ、輪が満ちていく（文なし）。押している間だけライトがつく */
#phone.hold .ph-ring { opacity: 1; stroke-dasharray: 151; animation: ringfill 1.2s ease-in-out infinite; }
#phone.hold .ph-led, #phone.hold .ph-rays { opacity: .8; }
#phone.hold .ph-hand { animation: handpress 1.2s ease-in-out infinite; }
@keyframes ringfill { 0% { stroke-dashoffset: 151; } 70%, 100% { stroke-dashoffset: 0; } }
@keyframes handpress { 0%, 20% { transform: translateY(0); } 40%, 85% { transform: translateY(5px); } 100% { transform: translateY(0); } }

/* 上の帯: 押し間違えない大きさ（44px 以上）と間隔（8px）。夜の札は幅を固定して、「夜1 → 2」に変わっても隣の位置が動かない */
#night-btn { width: 108px; padding: 0 8px; white-space: nowrap; }
#gear-btn { width: 44px; padding: 0; }
#map-btn { width: 44px; padding: 0; }
#night-btn.next { border-color: #cfe0ff; color: #fff; background: rgba(60,80,130,.6); animation: nextflash 1.1s ease-out 1, beat 1.6s 1.1s ease-in-out infinite; }
@keyframes nextflash { 0% { box-shadow: 0 0 0 0 rgba(207,224,255,.95); transform: scale(1.08); } 100% { box-shadow: 0 0 0 16px rgba(207,224,255,0); transform: scale(1); } }

/* 今の目的（始まった後、上の帯の下に小さな 1 行）。薄く、ライトの輪や字幕と重ならない（字幕は 92px 以下） */
#goal-box { position: fixed; z-index: 3; left: 130px; top: calc(max(8px, env(safe-area-inset-top)) + 50px); max-width: calc(100vw - 142px); display: flex; flex-direction: column; align-items: flex-start; gap: 4px; pointer-events: none; }
#next-note { padding: 3px 12px; border-radius: 12px; background: rgba(60,80,130,.78); border: 1px solid #cfe0ff; color: #fff; font-size: 12.5px; line-height: 1.3; letter-spacing: .04em; text-shadow: 0 0 6px #000; }
#next-note::before { content: "▸ "; }
#goal-line { position: static; padding: 3px 12px; border-radius: 12px; background: rgba(5,7,13,.42); font-size: 12.5px; line-height: 1.3; letter-spacing: .04em; color: rgba(214,224,244,.78); text-shadow: 0 0 6px #000; white-space: nowrap; pointer-events: none; transition: opacity .6s; }
#goal-line::before { content: "◎ "; opacity: .7; }
body[data-phase="ending"] #goal-box, body[data-phase="done"] #goal-box, body[data-phase="wait"] #goal-box { display: none; }

/* 見回しの合図: 指と左右の矢印（< ○ >）。始めてすぐ、最初に見回すまで。壁に 3 秒以上向かって押した時にもう一度 */
#look-hint { position: fixed; z-index: 3; left: 50%; top: 46%; width: 210px; height: 56px; margin: -28px 0 0 -105px; pointer-events: none; opacity: 0; transition: opacity .5s; border-radius: 28px; background: rgba(5,7,13,.35); }
#look-hint.show { opacity: .95; }
#look-hint i { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px; border-radius: 50%; background: rgba(210,225,255,.4); border: 2px solid rgba(230,240,255,.95); box-shadow: 0 0 14px rgba(190,210,255,.7); animation: lookdrag 1.6s ease-in-out infinite; }
#look-hint::before, #look-hint::after { content: ""; position: absolute; top: 50%; width: 16px; height: 16px; margin-top: -8px; border: solid rgba(220,235,255,.95); border-width: 0 0 3px 3px; }
#look-hint::before { left: 10px; transform: rotate(45deg); }
#look-hint::after { right: 10px; transform: rotate(-135deg); }
@keyframes lookdrag { 0%, 100% { transform: translate(-64px, 0); } 50% { transform: translate(64px, 0); } }
body[data-phase="done"] #look-hint, body[data-phase="ending"] #look-hint, body[data-phase="wait"] #look-hint { display: none; }

/* 歩くパッドの印（絵だけ）: 上は前向きの矢印、左右は回る矢印（↺ ↻）、下は小さな後ろ向きの矢印。最初の数秒と、円に触れている間 */
#pad-ring .arr { position: absolute; width: 26px; height: 26px; color: rgba(225,236,255,.95); opacity: .55; transition: opacity .3s; }
#pad-ring .arr.u { left: 50%; top: 9px; margin-left: -13px; }
#pad-ring .arr.l { left: 7px; top: 50%; margin-top: -13px; }
#pad-ring .arr.r { right: 7px; top: 50%; margin-top: -13px; }
#pad-ring .arr.d { left: 50%; bottom: 12px; width: 18px; height: 18px; margin-left: -9px; }
#pad-ring.marks .arr, #pad-ring.active .arr { opacity: .95; }
#pad-ring.marks .arr.d, #pad-ring.active .arr.d { opacity: .7; }
#pad-ring.marks:not(.active) .arr.u { animation: arrup 1.6s ease-in-out infinite; }
#pad-ring.marks:not(.active) .arr.l { animation: spinl 2.2s ease-in-out infinite; }
#pad-ring.marks:not(.active) .arr.r { animation: spinr 2.2s ease-in-out infinite; }
@keyframes arrup { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes spinl { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-24deg); } }
@keyframes spinr { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(24deg); } }
#pad-ring.marks:not(.active) { opacity: .75; }

/* ライトの合図: 指で押さえる絵と満ちていく輪。最初に 0.5 秒以上押さえるまで。短いタップの後は、大きく明るくなる */
#hold-hint { position: fixed; z-index: 5; right: 20px; bottom: 44px; width: 88px; height: 88px; pointer-events: none; opacity: 0; transition: opacity .4s; }
#hold-hint.show { opacity: 1; }
#hold-hint svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#hold-hint .hh-fill { stroke-dasharray: 189; stroke-dashoffset: 189; animation: ringfill2 1.5s ease-in-out infinite; }
#hold-hint .hh-finger { inset: auto; left: 50%; top: 50%; width: 38px; height: 38px; margin: -6px 0 0 -12px; animation: fingerpress 1.5s ease-in-out infinite; filter: drop-shadow(0 0 4px #000); }
#hold-hint.strong { filter: drop-shadow(0 0 10px rgba(207,224,255,.9)); transform: scale(1.18); transform-origin: 50% 50%; }
#hold-hint.strong .hh-track { stroke: rgba(207,224,255,.6); stroke-width: 6; }
@keyframes ringfill2 { 0%, 15% { stroke-dashoffset: 189; } 80%, 100% { stroke-dashoffset: 0; } }
@keyframes fingerpress { 0%, 15% { transform: translate(8px, -10px); } 35%, 85% { transform: translate(0, 0); } 100% { transform: translate(8px, -10px); } }
body[data-phase="ending"] #hold-hint, body[data-phase="done"] #hold-hint { display: none; }
@media (min-width: 900px) { #hold-hint { right: 44px; bottom: 54px; } }

/* 家族の反応の印: 反応した人の方向の画面の端に、ふとんの絵と名前。字幕と一緒に出る（眠りの値は出さない） */
#react-marks { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
.rmark { position: absolute; left: 0; top: 180px; max-width: calc(50vw - 12px); box-sizing: border-box; display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px 5px 8px; border-radius: 16px; background: rgba(14,19,32,.82); border: 1px solid rgba(255,217,160,.7); color: #ffe3b8; font-size: 13.5px; line-height: 1.2; white-space: normal; animation: subfade 3s ease-out forwards; }
.rmark svg { width: 22px; height: 16px; }
.sub.hit { color: #ffe3b8; text-shadow: 0 0 8px #000, 0 0 3px #000; }

/* マップを開いている間は、夜の時計が止まっている */
#map-paused { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 6px; font-size: 13px; color: #aab7d6; }
#map-paused svg { width: 14px; height: 14px; }
#map-plan { position: relative; }

/* 小さな間取り図: 左上、感想のボタンの下。半透明（暗い画面のじゃまにならない）。押すと大きなマップ */
#mini-map { position: fixed; z-index: 4; left: 10px; top: calc(max(8px, env(safe-area-inset-top)) + 46px); width: 110px; height: 86px; padding: 3px; border-radius: 8px; border: 1px solid rgba(120,145,205,.35); background: rgba(5,7,13,.5); opacity: .78; }
#mini-map svg { display: block; width: 100%; height: 100%; }
body[data-phase="ending"] #mini-map, body[data-phase="done"] #mini-map { display: none; }
/* 目的の 1 行は小さな図の右、字幕の左側の列は図を避ける */
#goal-line { white-space: normal; }
.sub.l { left: 126px; }
@media (min-width: 900px) { #mini-map { width: 150px; height: 118px; } #goal-box { left: 170px; max-width: 60vw; } .sub.l { left: 166px; } }

/* 初めての夜の短い一言（絵に添える。使ったら消える） */
.hint-label { position: absolute; padding: 3px 10px; border-radius: 12px; background: rgba(5,7,13,.72); color: #e8f0ff; font-size: 13px; font-weight: 600; line-height: 1.3; letter-spacing: .03em; white-space: nowrap; text-shadow: 0 0 4px #000; pointer-events: none; }
#hold-hint .hint-label { right: -12px; bottom: calc(100% + 83px); }
#look-hint .hint-label { left: 50%; top: calc(100% + 8px); transform: translateX(-50%); }
#walk-hint { position: fixed; z-index: 4; left: 125px; bottom: 255px; transform: translateX(-50%); opacity: 0; transition: opacity .4s; }
#walk-hint.show { opacity: 1; }
body[data-phase="ending"] #walk-hint, body[data-phase="done"] #walk-hint { display: none; }
#goal-line.note { color: #fff; background: rgba(60,80,130,.7); border: 1px solid #cfe0ff; }
#goal-line.note::before { content: "▸ "; }
@media (min-width: 900px) { #walk-hint { left: 170px; bottom: 315px; } }

/* 結果: 原因の見出しの下に並べる。PC の大きな画面では文字を大きくする */
#res-lines li.head { border-left: 0; padding-left: 0; margin-top: 4px; color: #aab7d6; font-size: 13px; letter-spacing: .06em; }
#res-lines li.sub { margin-left: 10px; }
@media (min-width: 900px) { #result .card { max-width: 640px; } #res-title { font-size: 30px; } #res-meta { font-size: 19px; } #res-lines { font-size: 20px; gap: 10px; } #res-lines li.head { font-size: 16px; } .note { font-size: 15px; } #result .buttons { max-width: 640px; } #result .buttons button { min-height: 60px; font-size: 18px; } }

/* 大きなマップの凡例（小さな間取りには付けない）: オレンジの丸＝寝ている家族、矢印と扇形＝いまの自分、冷蔵庫の印 */
#map-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 6px; font-size: 12px; line-height: 1.3; color: #cfd8ea; }
#map-legend span { display: inline-flex; align-items: center; gap: 5px; }
#map-legend svg { width: 16px; height: 16px; flex: none; }

/* 取ったプリン: 画面の下の左、歩くパッドの左（円の外）。持っている間だけ出し続ける。取った瞬間に小さく弾む。押せない */
#pudding-held { position: fixed; z-index: 4; left: 6px; bottom: 24px; width: 46px; height: 50px; pointer-events: none; filter: drop-shadow(0 0 6px rgba(255,230,160,.45)); }
#pudding-held svg { display: block; width: 100%; height: 100%; }
#pudding-held.pop { animation: puddingpop .65s cubic-bezier(.3,1.6,.5,1); }
@keyframes puddingpop { 0% { transform: translateY(14px) scale(.4); opacity: 0; } 55% { transform: translateY(-10px) scale(1.25); opacity: 1; } 100% { transform: none; opacity: 1; } }
body[data-phase="ending"] #pudding-held, body[data-phase="done"] #pudding-held, body[data-phase="wait"] #pudding-held { display: none; }
@media (min-width: 900px) { #pudding-held { left: 22px; bottom: 40px; width: 56px; height: 61px; } }
@media (prefers-reduced-motion: reduce) { #pudding-held.pop { animation: none; } }

/* ux 周回2: マップの行き先の光（やわらかく脈打つ） */
.goal-glow { animation: goalglow 2.2s ease-in-out infinite; }
@keyframes goalglow { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .goal-glow { animation: none; } }

/* ux 周回2: 結果（原因の行は .cause-row。字幕の .sub と名前が重なって消えていた）、星の基準、夜のやり直しの確認、「次の夜へ」の行 */
#res-lines li.trigger { border-left-color: #ffd9a0; color: #fff3d6; font-size: 18px; line-height: 1.4; font-weight: 600; margin-top: 4px; }
#res-lines li.cause-row { margin-left: 10px; }
#res-stars { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12.5px; line-height: 1.4; color: #8b97b6; letter-spacing: .02em; }
#res-stars span.on { color: #ffd9a0; }
@media (max-height: 700px) { #result { padding-top: max(52px, env(safe-area-inset-top) + 46px); } #res-lines { gap: 4px; font-size: 13.5px; line-height: 1.35; } #res-lines li.trigger { font-size: 15.5px; } #res-meta { margin-bottom: 8px; } #res-title { font-size: 19px; } #res-stars { margin-top: 6px; font-size: 11.5px; } }
@media (min-width: 900px) { #res-lines li.trigger { font-size: 26px; } #res-stars { font-size: 16px; } }
#night-pick.confirming #night-list, #night-pick.confirming h2 { display: none; }
#night-confirm { display: grid; gap: 14px; justify-items: center; padding: 4px 0; text-align: center; }
#night-confirm p { margin: 0; font-size: 16px; line-height: 1.5; color: #e4ebfa; }
#night-confirm .row { display: flex; gap: 10px; width: 100%; }
#night-confirm button { flex: 1; min-height: 48px; border-radius: 10px; border: 1px solid var(--moon); background: rgba(20,28,48,.8); font-size: 15px; }
#night-confirm button.yes { border-color: #9fb3e8; background: rgba(60,80,130,.6); }
#next-note { pointer-events: auto; cursor: pointer; }
.reach-line { position: fixed; z-index: 3; height: 0; border-top: 2px solid rgba(225,235,255,.75); transform-origin: 0 0; pointer-events: none; display: none; }

/* ux 周回2: 見回しの合図は、画面の真ん中ではなく上の帯の下に小さく出す */
#look-hint { top: calc(max(8px, env(safe-area-inset-top)) + 98px); margin: 0 0 0 -105px; transform: scale(.72); transform-origin: 50% 0; }
body[data-phase="done"] #react-marks, body[data-phase="done"] #subs { display: none; }
