/* 灯火の迷宮 弐（試作） */
:root {
  --bg: #0d0b0a; --panel: #1a1512; --panel2: #241d18; --line: #3a2f26;
  --gold: #d8b46a; --gold2: #f3dca0; --text: #ece3d2; --dim: #9c8f7c;
  --red: #e0604a; --blue: #6ec3ff; --green: #86d99a; --lum: #9dffe0;
  --serif: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: #050404; color: var(--text); overscroll-behavior: none; }
body { font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif; font-size: 14px; line-height: 1.5;
  -webkit-user-select: none; user-select: none; touch-action: manipulation; overflow: hidden; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

#app { position: relative; display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 480px; margin: 0 auto;
  background: var(--bg); padding-bottom: env(safe-area-inset-bottom); overflow: hidden; }

/* ---- 上部 ---- */
#top { display: flex; align-items: center; gap: 7px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px 10px; background: linear-gradient(#1d1713, #130f0d); border-bottom: 1px solid var(--line); flex: none; }
#goalBox { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; }
#goalBox .lbl { flex: none; font-size: 10px; letter-spacing: .1em; color: #1a130c; background: var(--gold); border-radius: 3px; padding: 1px 5px; font-weight: 700; }
#goal { font-family: var(--serif); font-size: 13px; color: var(--gold2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#btnMenu, #btnNote { position: relative; flex: none; height: 34px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; gap: 4px; color: var(--gold2); }
#btnMenu { width: 38px; } #btnNote { padding: 0 10px 0 8px; font-size: 12.5px; }
#noteDot { position: absolute; right: -3px; top: -3px; width: 10px; height: 10px; border-radius: 50%; background: #ffcf5a; box-shadow: 0 0 8px #ffb84a; animation: pulse 1s infinite; }
svg { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#btnMenu svg, #btnNote svg { width: 19px; height: 19px; }

/* ---- 一人称視点 ---- */
#view { position: relative; flex: 100 1 auto; min-height: 220px; max-height: min(132vw, 640px); background: #000; overflow: hidden; touch-action: none; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#vig { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 52%, rgba(0,0,0,0) 46%, rgba(0,0,0,.5) 100%); transition: background .3s, opacity .5s; }
.dark #vig { background: radial-gradient(ellipse at 50% 52%, rgba(4,8,20,0) 30%, rgba(2,4,12,.72) 100%); }
.dead #cv { filter: grayscale(.7) brightness(.35) sepia(.6) hue-rotate(-40deg); transition: filter .6s; }
.chip { position: absolute; pointer-events: none; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: rgba(10,8,7,.66); border: 1px solid rgba(216,180,106,.3); color: var(--gold2); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
#sense { left: 8px; top: 8px; display: flex; align-items: center; gap: 6px; transition: color .3s, border-color .3s; }
#sense i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px currentColor; color: var(--green); }
#sense.s1 { color: #cfe3ff; border-color: rgba(150,190,255,.5); } #sense.s1 i { background: #9cc4ff; color: #9cc4ff; }
#sense.s2 { color: #ffd98a; border-color: rgba(255,200,90,.6); } #sense.s2 i { background: #ffc24a; color: #ffc24a; }
#sense.s3 { color: #ffb0a0; border-color: rgba(255,110,90,.75); } #sense.s3 i { background: var(--red); color: var(--red); animation: pulse .6s infinite; }
#compass { left: 50%; top: 8px; transform: translateX(-50%); font-family: var(--serif); letter-spacing: .2em; padding-left: 12px; }
#mini { position: absolute; right: 8px; top: 8px; width: 108px; height: 108px; border-radius: 10px; background: rgba(10,8,7,.62); border: 1px solid rgba(216,180,106,.4); }
#hint { left: 50%; bottom: 10px; transform: translateX(-50%); font-size: 13px; padding: 5px 14px; color: #fff3d0; border-color: rgba(255,214,130,.65); background: rgba(28,20,10,.78); white-space: nowrap; opacity: 0; transition: opacity .15s; }
#hint.on { opacity: 1; animation: bobhint 1.4s ease-in-out infinite; }
#hint.warn { color: #ffc9bd; border-color: rgba(255,110,90,.8); background: rgba(40,12,8,.82); }
.dark #hint { color: #d9fff3; border-color: rgba(140,255,220,.5); background: rgba(8,20,22,.8); }
.dark #hint.warn { color: #f0ffb0; border-color: rgba(210,255,90,.7); }
#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
#flash.red { background: #c22; animation: flash .45s; } #flash.white { background: #fff3d0; animation: flash .5s; }
#flash.blue { background: #5ac0ff; animation: flash .9s; } #flash.gold { background: #ffd067; animation: flash .9s; }
#banner { position: absolute; left: 0; right: 0; top: 34%; text-align: center; font-family: var(--serif); font-size: 28px; font-weight: 700; letter-spacing: .14em; color: #fff3d0;
  text-shadow: 0 0 18px rgba(255,170,60,.9), 0 2px 4px #000; pointer-events: none; opacity: 0; }
#banner.go { animation: banner 1.9s ease-out; } #banner.danger { color: #ffd0c4; text-shadow: 0 0 18px rgba(255,60,40,.9), 0 2px 4px #000; }
#banner small { display: block; font-size: 13px; letter-spacing: .2em; font-weight: 400; margin-top: 4px; }

/* ---- ログ・状態 ---- */
#log { flex: 1 1 62px; min-height: 62px; display: flex; flex-direction: column; justify-content: flex-end; padding: 5px 12px; overflow: hidden; background: #110d0b; border-top: 1px solid var(--line); font-size: 12.5px; line-height: 1.42; }
#log div { color: #7d7264; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
#log div:last-child { color: var(--text); white-space: normal; } #log div:nth-last-child(2) { color: #b3a792; }
#log .warn:last-child, #log .warn:nth-last-child(2) { color: #ff9c88; } #log .good:last-child, #log .good:nth-last-child(2) { color: #ffe08a; }
#log .note:last-child, #log .note:nth-last-child(2) { color: #a8e6ff; }
#status { flex: none; display: flex; align-items: center; gap: 8px; padding: 5px 10px 6px; background: #110d0b; font-size: 12px; color: var(--dim); }
#status .lampst { flex: none; display: flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); }
#status .lampst i { width: 9px; height: 9px; border-radius: 50%; }
#status .lampst.on { color: #ffe1a0; border-color: #6a5026; } #status .lampst.on i { background: #ffc24a; box-shadow: 0 0 9px #ffb030; }
#status .lampst.off { color: #a9bddc; border-color: #2c3a52; background: #10151f; } #status .lampst.off i { background: #2a3550; box-shadow: inset 0 0 0 1px #5a6c94; }
#status .items { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #cdbf9f; }
#status .dc { flex: none; font-family: var(--serif); color: #c98a7c; }

/* ---- 操作パッド ---- */
#pad { flex: none; padding: 4px 8px 10px; background: #110d0b; display: grid; grid-template-columns: 1fr 1.25fr 1fr; gap: 7px; }
#pad button { height: 58px; border-radius: 13px; background: linear-gradient(#2c231c, #1c1612); border: 1px solid #4a3c30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--gold2); box-shadow: 0 2px 0 #060504; }
#pad button svg { width: 24px; height: 24px; } #pad button span { font-size: 10.5px; color: var(--dim); }
#pad button.main { background: linear-gradient(#5a4322, #33260f); border-color: var(--gold); color: #fff3d0; } #pad button.main svg { width: 28px; height: 28px; stroke-width: 2.6; }
#pad button.sub { background: #171210; color: #cdbf9f; }
#pad button.lamp { background: linear-gradient(#4a3716, #2a1f0c); border-color: #a8843e; color: #ffe1a0; } #pad button.lamp span { color: #d9bf86; }
.dark #pad button.lamp { background: linear-gradient(#16203a, #0c1220); border-color: #5a74b0; color: #bcd0ff; } .dark #pad button.lamp span { color: #9db2e0; }
#pad button:active, #pad button.held { transform: translateY(2px); box-shadow: none; filter: brightness(1.35); }

/* ---- モーダル ---- */
#modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.74); animation: fade .18s; }
#modal.death { background: rgba(26,2,2,.88); }
.card { width: 100%; max-width: 390px; max-height: 94vh; overflow: auto; background: linear-gradient(#241c16, #16110e); border: 1px solid var(--gold); border-radius: 16px; padding: 16px 15px 13px; text-align: center; box-shadow: 0 10px 40px #000, inset 0 0 30px rgba(216,180,106,.06); animation: pop .22s cubic-bezier(.2,1.3,.5,1); }
#modal.death .card { border-color: #8a2a20; background: linear-gradient(#2a1210, #120807); box-shadow: 0 10px 50px #000, inset 0 0 40px rgba(200,40,30,.12); }
.card h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 19px; color: var(--gold2); letter-spacing: .08em; }
.card h4 { margin: 14px 0 5px; font-size: 11.5px; letter-spacing: .14em; color: var(--gold); text-align: left; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.card p { margin: 6px 0; color: #d7ccb8; font-size: 13.5px; } .card p.warn { color: #ff9c88; } .card p.dim { color: #7d7264; font-size: 12.5px; }
.card p.quote { font-family: var(--serif); font-size: 15px; line-height: 1.85; color: #efe4cc; margin: 10px 0; text-align: left; padding: 0 4px; }
.card p.quote.lum { color: var(--lum); text-shadow: 0 0 12px rgba(120,255,214,.55); text-align: center; }
.card p.quote.death { color: #f0c4b8; text-align: center; }
.card p.memo { font-size: 12px; color: #a8e6ff; margin-top: 8px; }
#modal.death p.memo { color: #c9b8a8; }
.deathmark { font-family: var(--serif); font-size: 64px; line-height: 1; color: #d8402e; text-shadow: 0 0 28px rgba(255,50,30,.7); margin: 2px 0 6px; animation: deathin .7s ease-out; }
.card .btns { display: grid; gap: 8px; margin-top: 13px; } .card .btns.two { grid-template-columns: 1fr 1fr; }
.card .btns button { min-height: 46px; border-radius: 11px; background: linear-gradient(#2c231c, #1c1612); border: 1px solid #4a3c30; font-size: 14.5px; padding: 6px 8px; }
.card .btns button.pri { background: linear-gradient(#5a4322, #33260f); border-color: var(--gold); color: #fff3d0; font-weight: 700; }
#modal.death .btns button.pri { background: linear-gradient(#6a2018, #3a0f0a); border-color: #c8553f; }
.card .btns button:disabled { opacity: .4; } .card .btns button small { display: block; font-size: 11px; color: var(--dim); font-weight: 400; }
.chest-img { width: 124px; height: 124px; display: block; margin: -4px auto 2px; filter: drop-shadow(0 0 18px rgba(255,200,90,.3)); }
.chest-img.open { animation: pop .35s cubic-bezier(.2,1.5,.5,1); filter: drop-shadow(0 0 26px rgba(255,210,110,.8)); }
.mural { width: 78%; max-width: 280px; aspect-ratio: 1; display: block; margin: 0 auto 8px; border-radius: 6px; box-shadow: 0 4px 22px #000; }
.mural.lum { background: #05090c; box-shadow: 0 0 26px rgba(120,255,214,.25), 0 4px 22px #000; }
.chestbox { position: relative; width: 132px; height: 132px; margin: -4px auto 2px; }
.chestbox img { position: absolute; inset: 0; width: 100%; height: 100%; }
.chestbox.dark { background: radial-gradient(circle, #0a1018, #020305 70%); border-radius: 12px; } .chestbox.dark img:first-child { filter: brightness(.16) saturate(.4); }
.chestbox .ey { animation: pulse 2.2s ease-in-out infinite; }
#bigmap { width: 100%; aspect-ratio: 1; display: block; background: #0c0908; border-radius: 10px; border: 1px solid var(--line); }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px 11px; font-size: 10.5px; color: var(--dim); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; margin-right: 4px; border-radius: 2px; vertical-align: -1px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 12px 0 4px; text-align: left; }
.stats div { background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; font-size: 11px; color: var(--dim); }
.stats b { display: block; font-size: 17px; color: var(--text); font-family: var(--serif); }
.rank { font-family: var(--serif); font-size: 22px; color: #ffe08a !important; margin: 8px 0 0; text-shadow: 0 0 14px rgba(255,180,60,.6); }
.help, .hl { text-align: left; font-size: 13px; color: #d7ccb8; padding-left: 20px; margin: 6px 0; } .help li, .hl li { margin: 6px 0; }
.nb { text-align: left; } .nb p { font-size: 12.5px; } .nb ol { margin: 4px 0; padding-left: 22px; font-size: 12.5px; color: #c98a7c; }
.nb details { border: 1px solid var(--line); border-radius: 9px; background: rgba(0,0,0,.28); margin: 5px 0; }
.nb summary { padding: 8px 10px; font-size: 13px; color: var(--gold2); cursor: pointer; }
.nb details p { margin: 0; padding: 2px 12px 10px; font-family: var(--serif); font-size: 13.5px; line-height: 1.8; color: #e6dcc6; }

/* ---- タイトル ---- */
#title { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px; text-align: center; background: radial-gradient(circle at 50% 38%, rgba(30,20,10,.74), rgba(6,5,4,.96) 70%); transition: opacity .6s; }
#title.out { opacity: 0; pointer-events: none; }
.t-icon { width: 80px; height: 80px; stroke: none; animation: glow 2.4s ease-in-out infinite; }
#title h1 { margin: 6px 0 0; font-family: var(--serif); font-size: 36px; letter-spacing: .14em; color: #fff0c8; text-shadow: 0 0 24px rgba(255,170,60,.6); }
#title h1 span { color: #9fd2ff; text-shadow: 0 0 22px rgba(90,160,255,.8); margin-left: .1em; }
.t-sub { margin: 4px 0 18px; font-size: 12px; letter-spacing: .22em; color: var(--gold); font-family: var(--serif); }
.t-text { font-family: var(--serif); font-size: 15px; line-height: 2; color: #d9cdb6; margin: 0 0 22px; }
#titleBtns { display: grid; gap: 10px; width: min(280px, 80vw); margin: 0 auto; min-height: 54px; }
#titleBtns button { height: 54px; border-radius: 14px; font-size: 17px; font-family: var(--serif); letter-spacing: .12em; background: linear-gradient(#6a4e24, #3a2a10); border: 1px solid var(--gold); color: #fff3d0; box-shadow: 0 0 24px rgba(255,170,60,.25); }
#titleBtns button.sec { height: 44px; font-size: 14px; background: var(--panel); border-color: var(--line); color: var(--dim); box-shadow: none; }
.loading { height: 54px; display: grid; place-items: center; color: var(--dim); font-size: 13px; letter-spacing: .1em; animation: pulse 1.2s infinite; }
.t-note { margin-top: 18px; font-size: 10.5px; color: #6f6456; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.9); } }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes flash { from { opacity: .55; } to { opacity: 0; } }
@keyframes banner { 0% { opacity: 0; transform: scale(1.4); } 12% { opacity: 1; transform: scale(1); } 76% { opacity: 1; } 100% { opacity: 0; transform: translateY(-12px); } }
@keyframes bobhint { 50% { transform: translateX(-50%) translateY(-3px); } }
@keyframes glow { 50% { filter: brightness(1.25); transform: scale(1.04); } }
@keyframes deathin { from { opacity: 0; transform: scale(2.2); filter: blur(6px); } }

@media (max-height: 640px) {
  #pad button { height: 50px; } #pad button svg { width: 20px; height: 20px; } #pad button.main svg { width: 23px; height: 23px; } #pad button span { font-size: 10px; }
  #log { flex-basis: 44px; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { #hint.on, .t-icon { animation: none; } }
