/* Parenthesia の見た目（スマホ縦がメイン、PC は真ん中に縦の列） */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bg: #14131c; --panel: #1f1d2b; --panel2: #282536; --line: #3a3650; --text: #ece8f4; --dim: #a39fb5;
  --gold: #e8c35a; --red: #ef6461; --green: #6fd08c;
  --c-mul: #e8c35a; --c-pct: #f0904a; --c-int: #5fc8e8; --c-tgt: #f07ab8; --c-stat: #7fd67a;
}
@supports (-webkit-touch-callout: none) { :root { --safe-top: max(env(safe-area-inset-top, 0px), 34px); } }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(16px + var(--safe-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
h2 { font-size: 20px; margin: 14px 0 8px; }
h3 { font-size: 14px; color: var(--dim); margin: 16px 0 6px; }
h4 { font-size: 12px; color: var(--dim); margin: 10px 0 4px; font-weight: normal; }
ul { list-style: none; margin: 0; padding: 0; }
.page { padding: 8px 14px; }
.note { color: var(--dim); font-size: 14px; line-height: 1.6; }
.hint { color: var(--dim); font-size: 12px; line-height: 1.6; }

/* ボタン */
.btn { display: block; width: 100%; padding: 13px 14px; margin: 8px 0; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); font-size: 16px; }
.btn.main { background: linear-gradient(180deg, #6a52c9, #4a389a); border-color: #7b65dc; font-weight: bold; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: #7a3b3b; color: #ffb0b0; }
.btn.small { width: auto; display: inline-block; padding: 8px 12px; margin: 4px; font-size: 14px; }
.row { display: flex; gap: 8px; } .row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; }

/* 上の帯 */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-top) + 8px) 12px 8px; background: rgba(20, 19, 28, .94); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.top .icon { background: none; border: 1px solid var(--line); border-radius: 8px; width: 38px; height: 34px; font-size: 18px; }
.top .stat { font-size: 14px; }
.top .hp { color: #ffb4b4; } .top .gold { color: var(--gold); margin-left: auto; }

/* タイトル */
.title { text-align: center; padding: calc(var(--safe-top) + 36px) 22px 20px; }
.title h1 { font-size: 38px; margin: 0; letter-spacing: .02em; font-family: Georgia, "Times New Roman", serif; }
.title .br { color: var(--gold); padding: 0 4px; }
.title .sub { color: var(--dim); margin: 8px 0 18px; }
.hero-art { background: radial-gradient(40% 50% at 50% 50%, #5a5a8c55 0%, transparent 70%); }
.hero-art .art { height: 260px; width: auto; max-width: 80%; object-fit: contain; filter: drop-shadow(0 8px 10px #000a); }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 22px; font-size: 13px; }
.links a { color: var(--dim); }
.ver { width: 100%; color: #6e6a80; font-size: 12px; margin-top: 6px; }

/* カッコ */
.slot { display: inline-block; min-width: 2.4em; padding: 3px 7px; margin: 2px 1px; border-radius: 7px; border: 1.5px solid currentColor; background: rgba(255, 255, 255, .04); font-size: 14px; font-weight: bold; line-height: 1.3; vertical-align: baseline; transition: transform .1s; }
.slot.t-mul { color: var(--c-mul); } .slot.t-pct { color: var(--c-pct); } .slot.t-int { color: var(--c-int); } .slot.t-tgt { color: var(--c-tgt); } .slot.t-stat { color: var(--c-stat); }
.slot.sel { background: currentColor; } .slot.sel { color: #111 !important; box-shadow: 0 0 0 3px #fff8; }
.slot.t-mul.sel { background: var(--c-mul); } .slot.t-pct.sel { background: var(--c-pct); } .slot.t-int.sel { background: var(--c-int); } .slot.t-tgt.sel { background: var(--c-tgt); } .slot.t-stat.sel { background: var(--c-stat); }
.slot.can { animation: can 1s infinite; }
@keyframes can { 50% { transform: scale(1.08); box-shadow: 0 0 10px currentColor; } }

/* 地図 */
.path { display: flex; gap: 6px; justify-content: center; margin: 8px 0 2px; }
.path i { width: 22px; height: 8px; border-radius: 4px; background: var(--line); }
.path i.done { background: #6a52c9; } .path i.now { background: var(--gold); } .path i.boss { width: 30px; }
.nodes { display: grid; gap: 10px; }
.node { text-align: left; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); }
.node b { display: block; font-size: 18px; margin-bottom: 4px; } .node small { color: var(--dim); }
.node.n-elite { border-color: #a0603a; } .node.n-boss { border-color: var(--gold); } .node.n-shop { border-color: #3a7aa0; } .node.n-rest { border-color: #3aa06a; } .node.n-treasure { border-color: #a09a3a; }

/* 構築 */
.build { margin-top: 14px; padding: 4px 12px 12px; background: var(--panel); border-radius: 14px; border: 1px solid var(--line); }
.rule, .act, .skill { padding: 8px 10px; margin: 6px 0; background: var(--panel2); border-radius: 10px; font-size: 14px; line-height: 1.9; }
.skill b { margin-right: 6px; }
.cost { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: #4a389a; font-size: 12px; font-weight: bold; margin-right: 6px; vertical-align: middle; }
.bag { min-height: 34px; }

/* 戦闘 */
.foe, .me { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-top: 8px; }
/* 戦闘の舞台：左に主人公（右向き）、右に敵 */
.stage { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; margin-top: 8px; padding: 10px 12px 10px; border-radius: 14px; border: 1px solid var(--line);
  background: radial-gradient(120% 70% at 50% 100%, #2c2a44 0%, #1a1826 60%, #121019 100%); }
.stage::after { content: ''; position: absolute; left: 0; right: 0; bottom: 92px; height: 1px; background: linear-gradient(90deg, transparent, #4a4566, transparent); pointer-events: none; }
.side { position: relative; text-align: center; min-width: 0; }
.side .art-wrap { height: 170px; display: flex; align-items: flex-end; justify-content: center; }
/* 暗い服が背景に沈まないよう、後ろに淡い光 */
.me-side .art-wrap { background: radial-gradient(55% 60% at 50% 55%, #5a5a8c66 0%, transparent 70%); }
.foe-side .art-wrap { background: radial-gradient(55% 50% at 50% 65%, #8c5a5a44 0%, transparent 70%); }
.me-side .art { height: 170px; width: auto; max-width: 100%; object-fit: contain; filter: drop-shadow(0 6px 6px #0008); }
.foe-side .art { height: 130px; width: 100%; max-width: 150px; }
.side .name { font-size: 14px; }
.intent { grid-column: 1 / -1; text-align: center; }
.name { font-weight: bold; font-size: 17px; }
.tag { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: #a0603a; vertical-align: middle; } .tag.boss { background: #a08a3a; }
.bar { position: relative; height: 18px; border-radius: 9px; background: #0006; overflow: hidden; margin: 6px 0 4px; }
.bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #d94d4d, #f08a5d); transition: width .3s; }
.bar.php i { background: linear-gradient(90deg, #3fa06a, #6fd08c); }
.bar span { position: relative; display: block; text-align: center; font-size: 12px; line-height: 18px; font-weight: bold; text-shadow: 0 1px 2px #000; }
.stats { font-size: 13px; color: var(--dim); }
.chip { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--line); margin-left: 4px; color: var(--text); }
.chip.poison { background: #4f7a2c; }
.intent { margin-top: 4px; font-size: 13px; color: #ffcf8a; }
.act.next { outline: 1.5px solid #ffcf8a; }
.act em { font-style: normal; font-size: 11px; background: #ffcf8a; color: #222; border-radius: 4px; padding: 0 5px; margin-right: 6px; }
.log { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; background: #0b0a10; font-size: 12px; color: var(--dim); line-height: 1.6; max-height: 92px; overflow: hidden; cursor: pointer; }
.log.open { max-height: 50dvh; overflow-y: auto; }
.energy { margin: 8px 0 2px; font-size: 14px; }
.energy b { font-size: 20px; color: var(--c-int); margin: 0 4px; }
.rw { float: right; font-size: 13px; color: var(--gold); } .rw.used { color: #6e6a80; }
.skill .use { display: inline-flex; align-items: center; padding: 5px 10px 5px 5px; margin-right: 6px; border-radius: 9px; border: 1px solid #7b65dc; background: #2f2850; font-weight: bold; }
.skill.off .use { border-color: var(--line); background: transparent; }
.skill .txt { font-size: 13.5px; }
.me .build { margin-top: 8px; background: transparent; border: none; padding: 0; }
.btn.end { position: sticky; bottom: calc(8px + var(--safe-bottom)); margin-top: 12px; box-shadow: 0 6px 18px #000a; z-index: 5; }
.over { position: sticky; bottom: calc(10px + var(--safe-bottom)); margin-top: 12px; padding: 14px; border-radius: 14px; text-align: center; background: rgba(30, 28, 44, .97); border: 1px solid var(--gold); }
.over b { font-size: 22px; } .over.lose { border-color: var(--red); }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.glow { animation: glow .8s; }
@keyframes glow { 30% { box-shadow: 0 0 0 3px var(--gold), 0 0 30px var(--gold); } }
.pop { position: absolute; top: 20px; font-size: 24px; font-weight: 900; pointer-events: none; animation: pop .9s forwards; text-shadow: 0 2px 4px #000; color: #ff8a7a; }
.pop.heal { color: var(--green); }
@keyframes pop { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-40px); opacity: 0; } }

/* ごほうび・店 */
.opts { display: grid; gap: 10px; margin: 10px 0; }
.opt { position: relative; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.opt b { display: block; font-size: 16px; margin-bottom: 4px; } .opt small { color: var(--dim); font-size: 13px; line-height: 1.5; }
.opt.k-token { border-color: #8a7a3a; } .opt.k-skill { border-color: #5a4aa0; } .opt.k-rule { border-color: #3a8a7a; }
.price { position: absolute; right: 12px; top: 12px; color: var(--gold); font-weight: bold; }
.result { text-align: center; padding-top: calc(var(--safe-top) + 40px); }

/* 窓（閉じるボタンは下に固定） */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; max-height: 86dvh; display: flex; flex-direction: column; background: var(--panel); border-radius: 18px 18px 0 0; border: 1px solid var(--line); padding: 6px 16px calc(12px + var(--safe-bottom)); }
.sheet-body { overflow-y: auto; flex: 1; line-height: 1.7; font-size: 14px; }
.sheet-body ul { list-style: disc; padding-left: 20px; }
.sheet-body .small { font-size: 12px; }
.sheet-close { flex: none; }
.news { padding: 8px 0; border-bottom: 1px solid var(--line); } .news .nd { font-size: 12px; color: var(--dim); } .news p { margin: 4px 0; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 18px; max-height: 80dvh; } }

.toast { position: fixed; left: 50%; top: calc(var(--safe-top) + 56px); transform: translateX(-50%); z-index: 99; max-width: 90vw; padding: 10px 16px; border-radius: 10px; background: #000d; border: 1px solid var(--line); font-size: 14px; transition: opacity .4s; }
.toast.out { opacity: 0; }

/* PC：少し広く */
@media (min-width: 1100px) { #app { max-width: 560px; } }
