:root {
  --bg: #14213d; --panel: #1f2f55; --panel2: #283b69; --text: #f4f1e8; --muted: #a9b4d0;
  --accent: #ffb703; --good: #6ee7a8; --bad: #ff8a8a; --know: #8ecae6; --danger: #e5383b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif; line-height: 1.7; }
body { min-height: 100dvh; }
#app { max-width: 520px; margin: 0 auto; padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom)); }
.screen { padding-top: 12px; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.quake { animation: shake .9s ease; }
@keyframes shake { 0%,100% { transform: none; } 10% { transform: translate(-8px, 3px); } 20% { transform: translate(8px,-3px); } 30% { transform: translate(-7px,-2px); } 40% { transform: translate(7px,3px); } 55% { transform: translate(-4px,2px); } 70% { transform: translate(4px,-2px); } }
ruby rt { font-size: .5em; color: var(--muted); }

h1.title { font-size: 1.8rem; margin: 18px 0 0; text-align: center; letter-spacing: .04em; }
h1.title.small { font-size: 1.4rem; }
.sub { text-align: center; color: var(--accent); margin: 4px 0 12px; }
.lead { color: var(--muted); font-size: .95rem; }
.note { color: var(--muted); font-size: .85rem; margin: 6px 0; }
.error { color: var(--bad); font-size: .9rem; margin: 6px 0; }

.form { background: var(--panel); border-radius: 16px; padding: 12px 16px 16px; margin: 14px 0; }
.form h2 { font-size: 1rem; margin: 12px 0 4px; color: var(--accent); }
.form label { display: block; font-size: .85rem; color: var(--muted); margin-top: 8px; }
.form label.check { color: var(--text); margin-top: 14px; }
input[type=text], input:not([type]), input[inputmode] { width: 100%; padding: 10px 12px; margin-top: 4px; border-radius: 10px; border: 2px solid var(--panel2); background: #0f1830; color: var(--text); font-size: 1rem; }
input:focus { outline: none; border-color: var(--accent); }
input[type=checkbox] { width: 20px; height: 20px; vertical-align: middle; margin-right: 6px; }

button { font: inherit; color: inherit; cursor: pointer; }
.primary { display: block; width: 100%; padding: 14px; margin: 14px 0 6px; border: 0; border-radius: 14px; background: var(--accent); color: #2b2100; font-weight: 700; font-size: 1.05rem; }
.primary.danger { background: var(--danger); color: #fff; }
.link { display: block; margin: 8px auto; background: none; border: 0; color: var(--know); text-decoration: underline; font-size: .9rem; padding: 6px; }

.heroes { display: grid; gap: 12px; margin: 14px 0; }
.hero { text-align: left; background: var(--panel); border: 2px solid var(--panel2); border-radius: 16px; padding: 12px 14px; }
.hero:active, .hero:hover { border-color: var(--accent); }
.hero .face { float: left; margin-right: 12px; width: 84px; height: 84px; }
.thumb { position: relative; display: inline-block; width: 28px; height: 28px; vertical-align: middle; border-radius: 8px; overflow: hidden; background: var(--panel2); }
.thumb .emo { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.1rem; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb.face .emo { font-size: 2.4rem; }
.thumb.face { border-radius: 14px; }
.inv { display: inline-flex; align-items: center; gap: 2px; }
.titleart { margin-top: 4px; }
.hero b { font-size: 1.15rem; margin-right: 8px; }
.hero small { color: var(--muted); }
.hero p { margin: 4px 0; font-size: .9rem; clear: none; }

.hud { background: var(--panel); border-radius: 14px; padding: 8px 12px; margin-bottom: 10px; position: sticky; top: 0; z-index: 2; }
.hud .row { display: flex; justify-content: space-between; font-size: 1rem; }
.gauges { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 6px; }
.g { text-align: center; font-size: .9rem; }
.g small { display: block; color: var(--muted); font-size: .7rem; line-height: 1.2; }
.bar { height: 8px; background: #0f1830; border-radius: 6px; overflow: hidden; margin: 2px 0; }
.bar i { display: block; height: 100%; background: var(--good); transition: width .4s; }
.g.low .bar i { background: var(--bad); }
.invbar { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; font-size: .85rem; }
.inv { white-space: nowrap; }

.art { position: relative; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: linear-gradient(135deg, #3a4f86, #1b2a4e); margin-bottom: 12px; }
.art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.art .ph { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.art .ph span { font-size: 3.2rem; }
.art .ph small { color: var(--muted); font-size: .7rem; }
.phoneart { aspect-ratio: 16 / 6; }

.text { background: var(--panel); border-radius: 14px; padding: 14px 16px; margin: 0 0 12px; font-size: 1.05rem; }
.text.result { border-left: 4px solid var(--accent); }
.notice { background: #2a2a2a55; border-radius: 10px; padding: 6px 10px; margin-bottom: 8px; font-size: .85rem; color: var(--muted); }

.choices { display: grid; gap: 10px; }
.choice { position: relative; text-align: left; display: flex; gap: 10px; align-items: flex-start; padding: 14px 14px; border-radius: 14px; border: 2px solid var(--panel2); background: var(--panel); font-size: 1rem; }
.choice:hover, .choice:active { border-color: var(--accent); background: var(--panel2); }
.choice:disabled { opacity: .45; cursor: not-allowed; }
.choice .tag { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #2b2100; font-weight: 700; display: grid; place-items: center; font-size: .85rem; }
.choice .t { flex: 1; }
.choice em { flex: none; font-style: normal; color: var(--accent); font-weight: 700; }
.choice small { position: absolute; right: 12px; bottom: 4px; color: var(--bad); font-size: .7rem; }

.why { background: #123a4a; border-radius: 12px; padding: 8px 14px; margin: 0 0 12px; }
.why b { color: var(--know); font-size: .85rem; }
.why p { margin: 2px 0 4px; font-size: .95rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; background: var(--panel2); margin: 2px 2px; }
.chip.up { color: var(--good); }
.chip.down { color: var(--bad); }
.chip.know { color: var(--know); }

.bignum { text-align: center; font-size: 2rem; letter-spacing: .1em; font-weight: 700; margin: 8px 0 0; color: var(--accent); }
.count { text-align: center; font-size: 2.4rem; margin: 0; }
.entry { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.entry .d { width: 28px; height: 40px; line-height: 40px; text-align: center; border-radius: 8px; background: #0f1830; border: 2px solid var(--panel2); font-size: 1.3rem; font-weight: 700; }
.entry .d.typed { border-color: var(--accent); }
.entry .d.hint { color: var(--know); border-color: var(--know); }
.entry .dash { line-height: 40px; color: var(--muted); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.key { padding: 14px 0; font-size: 1.4rem; border-radius: 12px; border: 0; background: var(--panel2); }
.key:active { background: var(--accent); color: #2b2100; }
.key.ok { background: var(--accent); color: #2b2100; font-weight: 700; font-size: 1.1rem; }
.steps { margin: 0 0 6px; padding-left: 22px; color: var(--muted); font-size: .9rem; }

.summary { background: var(--panel); border-radius: 14px; padding: 6px 16px 10px; margin: 12px 0; }
.summary h2 { font-size: 1rem; color: var(--accent); margin: 10px 0 2px; }
.summary ul { margin: 0; padding-left: 18px; font-size: .95rem; }
.summary li { margin: 3px 0; }

.scenario, .ending { text-align: center; padding: 24px 0 6px; }
.scenario .big, .ending .big { font-size: 4rem; display: block; }
.ending.over .big { filter: grayscale(.3); }
.ending h1 { font-size: 1.5rem; margin: 6px 0 12px; }
.ending .summary { text-align: left; }
.ending .why { text-align: left; }
