/* ネオン看板風。システムフォントのみ */
:root {
  --bg: #16101f;
  --panel: #241a33;
  --ink: #f4ecdf;
  --muted: #b3a6c2;
  --pink: #ff4f8b;
  --cyan: #3fe3e8;
  --gold: #ffd23f;
  --red: #ff6b4a;
  --line: #000;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
#app { max-width: 480px; margin: 0 auto; padding: 44px 16px 24px; }
.pill-btn {
  position: fixed; top: 8px; z-index: 15;
  font: inherit; font-size: 13px; font-weight: 700; color: var(--muted);
  background: var(--panel); border: 2px solid var(--line); border-radius: 999px;
  box-shadow: 0 0 0 2px var(--muted); padding: 3px 12px; cursor: pointer;
}
.sound-btn { right: 8px; }
.book-btn { left: 8px; color: var(--cyan); box-shadow: 0 0 0 2px var(--cyan); }
.sound-btn[aria-pressed="true"] { color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 0 10px rgba(255, 210, 63, 0.4); }
[hidden] { display: none !important; }

.logo {
  font-size: 56px; line-height: 1.1; margin: 28px 0 16px; text-align: center;
  color: var(--ink); letter-spacing: 0.05em;
  text-shadow: 0 0 6px var(--pink), 0 0 18px var(--pink);
}
.logo span { color: var(--gold); text-shadow: 0 0 6px var(--gold), 0 0 18px #ff9d00; }
.lead { text-align: center; font-size: 17px; margin: 0 0 12px; }
.sub { color: var(--muted); font-size: 14px; text-align: center; margin: 8px 0 20px; }
.heading { font-size: 28px; margin: 24px 0 4px; color: var(--cyan); text-shadow: 0 0 10px rgba(63, 227, 232, 0.6); }
.note { color: var(--muted); font-size: 13px; min-height: 1.6em; margin: 4px 0 0; }

.btn {
  font: inherit; font-weight: 700; color: var(--ink);
  background: var(--panel); border: 3px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 0 0 2px var(--cyan); padding: 10px 14px; cursor: pointer; flex: 1;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--pink); color: #fff; box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(255, 79, 139, 0.6); }
.btn.big { display: block; width: 100%; font-size: 20px; padding: 14px; margin: 16px 0; }
.btn.ghost { box-shadow: 0 0 0 2px var(--muted); background: transparent; }
.row { display: flex; gap: 10px; margin: 12px 0; }

/* 伝説を選ぶ */
.legend-list { display: grid; gap: 12px; }
.legend-card {
  text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--panel); border: 3px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 0 0 2px var(--pink); padding: 14px;
}
.legend-card .name { font-size: 19px; font-weight: 800; display: block; }
.legend-card .name::before { content: "昔は "; color: var(--muted); font-weight: 400; font-size: 14px; }
.legend-card .strength { color: var(--muted); font-size: 14px; }

/* 余生 */
.hero { display: flex; gap: 14px; align-items: center; margin-top: 4px; }
.portrait-col { flex: none; display: grid; gap: 6px; justify-items: center; }
.portrait {
  width: 120px; height: 150px; border: 3px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 0 0 2px var(--gold); background: #2a1d3d; overflow: hidden;
}
.portrait svg, .end-portrait svg, .look-preview svg { display: block; width: 100%; height: 100%; }
.look-btn { font: inherit; font-size: 12px; color: var(--cyan); background: none; border: 0; text-decoration: underline; cursor: pointer; padding: 0; }
.look-preview { width: 144px; height: 180px; margin: 8px auto; border: 3px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.look-slot { margin: 8px 0; }
.look-slot h3 { font-size: 13px; color: var(--muted); margin: 0 0 4px; font-weight: 400; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 13px; color: var(--ink); background: #1d1529; border: 2px solid var(--line); border-radius: 999px; box-shadow: 0 0 0 1px var(--muted); padding: 3px 10px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--pink); color: #fff; box-shadow: 0 0 0 2px var(--gold); }
.end-portrait { width: 168px; height: 210px; margin: 4px auto 8px; border: 3px solid var(--line); border-radius: var(--radius); box-shadow: 0 0 0 2px var(--gold); overflow: hidden; }
a.btn { text-align: center; text-decoration: none; display: inline-block; }
.share-x { background: #000; }
.card-box { text-align: center; }
.card-img { width: 100%; height: auto; border-radius: 8px; display: block; }
.card-box .row { margin-bottom: 8px; }
.book-parts-slot { margin: 6px 0 10px; }
.book-parts-slot h4 { margin: 0 0 4px; font-size: 13px; color: var(--muted); font-weight: 400; }
.chip.unknown { color: var(--muted); letter-spacing: 0.15em; cursor: default; }
.chip.got { cursor: default; box-shadow: 0 0 0 1px var(--cyan); }
.hero-name { font-size: 22px; font-weight: 800; }
.hero-nick { color: var(--pink); font-weight: 700; }
.hero-age { font-size: 15px; }
.hero-kare { color: var(--muted); font-size: 13px; }
.legend-line { background: var(--panel); border-left: 4px solid var(--gold); padding: 8px 12px; margin: 14px 0; font-size: 15px; border-radius: 4px; }

.scene {
  background: #2e1830; border: 3px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 0 0 2px var(--pink), 0 0 20px rgba(255, 79, 139, 0.45); padding: 12px 14px; margin: 14px 0;
}
.scene-label { display: inline-block; background: var(--pink); color: #fff; font-weight: 800; font-size: 13px; padding: 0 8px; border-radius: 4px; }
.scene-text { margin: 8px 0 0; }

.stats { display: grid; gap: 6px; margin: 14px 0; }
.stat { display: grid; grid-template-columns: 4.5em 1fr 2.5em; align-items: center; gap: 8px; font-size: 14px; }
.stat .bar { height: 12px; background: #0d0915; border: 2px solid var(--line); border-radius: 6px; overflow: hidden; }
.stat .fill { height: 100%; background: var(--cyan); transition: width 0.4s; }
.stat .fill.low { background: var(--red); }
.stat .num { text-align: right; font-variant-numeric: tabular-nums; }

.log-title { font-size: 15px; color: var(--muted); margin: 18px 0 6px; }
.log { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.log li { background: var(--panel); border-radius: 6px; padding: 8px 10px; font-size: 14px; }
.log li.new { box-shadow: 0 0 0 2px var(--cyan); }
.log .when { color: var(--muted); font-size: 12px; margin-right: 6px; }
.log .delta { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.log li.k-bare { border-left: 4px solid var(--red); }
.log li.k-unlock, .log li.k-flag { border-left: 4px solid var(--gold); color: var(--gold); }
.log li.k-scene { border-left: 4px solid var(--pink); }
.log li.k-result { border-left: 4px solid var(--pink); }
.log li.k-end { border-left: 4px solid var(--muted); }
.up { color: var(--cyan); }
.down { color: var(--red); }

/* 最期 */
.end-text { font-size: 17px; margin: 32px 0 16px; }
.end-card {
  background: var(--panel); border: 3px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 0 0 2px var(--gold), 0 0 24px rgba(255, 210, 63, 0.35); padding: 16px;
}
.end-label { color: var(--muted); font-size: 13px; }
.end-title { font-size: 32px; font-weight: 900; color: var(--gold); text-shadow: 0 0 10px rgba(255, 157, 0, 0.7); }
.end-desc { margin: 4px 0 12px; }
.end-legend { color: var(--muted); font-size: 14px; }
.end-card h4 { margin: 12px 0 4px; color: var(--pink); }
.end-feats { margin: 0; padding-left: 1.4em; }
.end-meta { display: grid; grid-template-columns: 4em 1fr; margin: 12px 0 0; }
.end-meta dt { color: var(--muted); }
.end-meta dd { margin: 0; font-weight: 700; }
.end-who { font-size: 15px; margin: 2px 0 4px; }
.end-who b { color: var(--pink); }
.end-news { background: var(--panel); border-radius: var(--radius); box-shadow: 0 0 0 2px var(--cyan); padding: 10px 14px; margin: 16px 0 0; animation-delay: 1.6s; }
.end-news h4 { margin: 0 0 4px; color: var(--cyan); }
.end-news ul { margin: 0; padding-left: 1.2em; font-size: 14px; }
/* 最期の文を読んでから、カードが出てくる */
.reveal { animation: reveal 0.8s ease-out 0.9s both; }
@keyframes reveal { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .reveal { animation: none; } }

/* 伝説図鑑 */
.book-sum { text-align: left; margin: 4px 0 8px; }
.book-h { font-size: 17px; color: var(--pink); margin: 20px 0 8px; }
.book-n { color: var(--muted); font-size: 14px; font-weight: 400; }
.book-lives { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.book-lives li { background: var(--panel); border-radius: 6px; padding: 8px 10px; font-size: 14px; border-left: 4px solid var(--gold); }
.book-lives .gen { color: var(--muted); font-size: 12px; margin-right: 6px; }
.book-lives .ttl { color: var(--gold); font-weight: 800; }
.book-lives .meta { display: block; color: var(--muted); font-size: 12px; }
.book-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.book-grid li { background: var(--panel); border-radius: 6px; padding: 8px 10px; font-size: 14px; }
.book-grid li b { display: block; }
.book-grid li small { color: var(--muted); }
.book-grid li.unknown { color: var(--muted); background: #1d1529; letter-spacing: 0.2em; }
.book-empty { color: var(--muted); font-size: 14px; }

/* おかえりレポート */
.overlay { position: fixed; inset: 0; background: rgba(8, 4, 14, 0.82); display: grid; place-items: center; padding: 16px; z-index: 10; }
.report-box {
  width: 100%; max-width: 440px; max-height: 92vh; overflow: auto; background: var(--panel);
  border: 3px solid var(--line); border-radius: var(--radius); box-shadow: 0 0 0 2px var(--cyan), 0 0 24px rgba(63, 227, 232, 0.4); padding: 16px;
}
.report-box h2 { margin: 0; color: var(--cyan); }
.report-span { margin: 4px 0 10px; color: var(--muted); }
.report-list { padding-left: 1.2em; margin: 0 0 10px; font-size: 14px; }
.report-list li { margin-bottom: 6px; }
.report-delta { font-size: 14px; margin: 0 0 6px; }
.report-extra { font-size: 14px; color: var(--gold); margin: 0 0 10px; }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 16px 16px 120px; }
.footer p { margin: 2px 0; }
.footer a { color: var(--muted); }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin: 8px 0; font-size: 13px; }

/* 投げ銭 */
.tip { text-align: center; margin: 24px 0 8px; }
.tip-btn {
  display: inline-block; font-weight: 800; color: #1a1210; text-decoration: none;
  background: var(--gold); border: 3px solid var(--line); border-radius: 999px;
  box-shadow: 0 0 0 2px var(--pink); padding: 8px 20px;
}
.tip .note { margin-top: 6px; }

/* about・privacy・404 */
body.page .page-body { max-width: 640px; margin: 0 auto; padding: 16px 16px 8px; }
.page-back { margin: 0 0 8px; font-size: 14px; }
.page-title { font-size: 26px; color: var(--cyan); margin: 8px 0 4px; text-shadow: 0 0 10px rgba(63, 227, 232, 0.5); }
.page-updated, .page-note { color: var(--muted); font-size: 13px; }
.page-body h2 { font-size: 18px; color: var(--pink); margin: 24px 0 6px; }
.page-body li { margin-bottom: 6px; }
.page-body a { color: var(--cyan); }
.page-body a.btn, .page-body a.tip-btn { color: inherit; }
.page-body a.btn.primary { color: #fff; }
.page-body a.tip-btn { color: #1a1210; }
body.page .footer { padding-bottom: 32px; }

/* 開発用 */
.dev {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #000c; border-top: 2px solid var(--gold);
  font-size: 12px; padding: 6px 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
}
.dev button, .dev select, .dev input { font: inherit; font-size: 12px; padding: 3px 6px; }
.dev input { width: 7em; }
.dev .info { width: 100%; color: var(--muted); font-family: ui-monospace, monospace; }
