/* 戦国の人生シミュレーション（試作）。デザインは Google Stitch の案（jinsei/design/stitch/）のトークンを写した素のCSS。角は丸めない。 */
:root {
  --surface: #fef8f4; --surface-lowest: #ffffff; --surface-low: #f9f2ef; --surface-container: #f3ede9;
  --surface-high: #ede7e3; --surface-highest: #e7e1de;
  --on-surface: #1d1b19; --on-variant: #43474c; --outline: #74777d; --outline-variant: #c3c7cd; --hairline: #ddd7cd;
  --primary: #051c2e; --on-primary: #ffffff; --primary-container: #1c3144;
  --secondary: #a13e33; --on-secondary: #ffffff; --secondary-fixed: #ffdad5;
  --tertiary: #2b4965; --tertiary-fixed: #cfe5ff;
  --stripe: rgba(5, 28, 46, .06);
  --serif: "Noto Serif JP", "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", Meiryo, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #171513; --surface-lowest: #211f1d; --surface-low: #1d1b19; --surface-container: #25221f;
    --surface-high: #2d2a27; --surface-highest: #37332f;
    --on-surface: #ece6e1; --on-variant: #c6c1bb; --outline: #928d86; --outline-variant: #4a4742; --hairline: #3a3733;
    --primary: #b3c9e1; --on-primary: #051c2e; --primary-container: #cfe5fe;
    --secondary: #ffb4a9; --on-secondary: #410001; --secondary-fixed: #4a1f1a;
    --tertiary: #abc9eb; --tertiary-fixed: #1f3245;
    --stripe: rgba(179, 201, 225, .07);
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--surface); color: var(--on-surface); font-family: var(--sans); font-size: 16px; line-height: 1.9; overflow-wrap: anywhere; letter-spacing: .02em; }
a { color: var(--secondary); text-underline-offset: 3px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 900px) { .wrap { padding: 0 40px; } }
.top { border-bottom: 1px solid var(--hairline); background: var(--surface); }
.top-in { display: flex; align-items: center; gap: 12px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.sitename { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; letter-spacing: .06em; }
.protobadge { font-size: 12px; color: var(--on-variant); background: var(--surface-high); padding: 0 8px; line-height: 1.8; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.5; font-weight: 700; letter-spacing: .05em; }
h1 { font-size: 1.9rem; margin: 2.4rem 0 1rem; }
h2 { font-size: 1.4rem; margin: 0; }
h3 { font-size: 1.05rem; margin: 0; }
p { margin: 0 0 .8rem; }
.note { font-size: 13px; color: var(--outline); }
.center { text-align: center; }
.loaderr { color: #ba1a1a; }

/* ボタン */
.btn { display: inline-block; font: inherit; font-family: var(--serif); font-weight: 600; font-size: 1rem; letter-spacing: .1em; padding: 12px 24px; min-height: 48px; border: 1px solid var(--primary); background: var(--surface-lowest); color: var(--primary); cursor: pointer; border-radius: 0; text-align: center; text-decoration: none; line-height: 1.6; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.big { font-size: 1.25rem; padding: 18px 48px; min-height: 64px; min-width: min(100%, 300px); }
.btn:hover { background: var(--primary-container); color: var(--on-primary); }
.btn:focus-visible, .modecard input:focus-visible + .mc { outline: 2px solid var(--secondary); outline-offset: 2px; }

/* はじまり */
.hero { max-width: 44rem; }
.modes { border: 0; margin: 2rem 0 1.4rem; padding: 0; min-width: 0; }
.modes legend { font-family: var(--serif); font-weight: 700; font-size: 1.2rem; padding: 0; margin-bottom: 12px; letter-spacing: .06em; }
.modecards { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 760px) { .modecards { grid-template-columns: repeat(2, 1fr); gap: 20px; } }
.modecard { display: block; position: relative; cursor: pointer; }
.modecard input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mc { display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 20px 20px 22px; background: var(--surface-low); border: 1px solid var(--hairline); }
.modecard:hover .mc { background: var(--surface-container); }
.modecard input:checked + .mc { background: var(--surface-container); border: 2px solid var(--primary); padding: 19px 19px 21px; box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 4px var(--hairline); }
.modecard input:checked + .mc .mc-name::before { content: ""; display: inline-block; width: 10px; height: 10px; background: var(--secondary); margin-right: 10px; vertical-align: .1em; }
.mc-name { font-family: var(--serif); font-weight: 700; font-size: 1.45rem; letter-spacing: .08em; line-height: 1.5; }
.mc-note { font-size: 14px; line-height: 1.85; color: var(--on-variant); }
.bornwrap { text-align: center; margin: 1.8rem 0 .8rem; }

/* 見出し（淡い面のブロック） */
.lifehead { background: var(--surface-low); border: 1px solid var(--hairline); padding: 22px 24px; margin: 24px 0 28px; }
.lifehead h2 { font-size: 1.5rem; }
.lh-meta { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 2px 20px; font-size: 14px; color: var(--on-variant); }
.lh-year { font-family: var(--serif); font-weight: 600; color: var(--on-surface); }
.lh-prob { color: var(--secondary); }
.lifehead a { color: inherit; }

/* 年表と勢力図 */
.layout { display: flex; flex-direction: column; gap: 24px; }
.mapbox { order: -1; background: var(--surface-low); border: 1px solid var(--hairline); padding: 16px; }
@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 40px; align-items: start; }
  .mapbox { order: 0; position: sticky; top: 16px; }
}
.panel-h { font-size: 1.1rem; padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--hairline); }
.mapbox img { display: block; width: 100%; height: auto; aspect-ratio: 1200 / 630; background: var(--surface-high); border: 1px solid var(--hairline); }
.maptable { margin: 12px 0; display: grid; gap: 6px; }
.maptable .mrow { display: flex; justify-content: space-between; gap: 12px; background: var(--surface-container); padding: 6px 12px; font-size: 14px; line-height: 1.7; }
.maptable dt { color: var(--on-variant); flex: none; }
.maptable dd { margin: 0; font-weight: 700; text-align: right; }
.maptable a { color: inherit; }
.mapopen { margin: 0; }
.mapopen .btn { display: block; background: var(--primary); color: var(--on-primary); }
.mapopen .btn:hover { background: var(--primary-container); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 34px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 12px; bottom: 12px; width: 1px; background: var(--outline-variant); }
.row { position: relative; margin: 0 0 14px; animation: fadein .5s ease both; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .row { animation: none; } }
.row .mark { position: absolute; left: -30px; top: 22px; width: 11px; height: 11px; background: var(--surface); border: 2px solid var(--outline); }
.row.self .mark { background: var(--primary); border-color: var(--primary); }
.row.answered .mark, .row.death .mark { background: var(--secondary); border-color: var(--secondary); }
.row.branch .mark { background: var(--tertiary); border-color: var(--tertiary); transform: rotate(45deg); }
.row.death .mark { width: 15px; height: 15px; left: -32px; top: 20px; }
.card { background: var(--surface-lowest); border: 1px solid var(--hairline); padding: 16px 20px 18px; }
.when { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin-bottom: 6px; line-height: 1.6; }
.when .y { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; letter-spacing: .05em; }
.when .age { font-size: 13px; color: var(--on-variant); background: var(--surface-container); padding: 0 8px; }
.tag { font-size: 11px; letter-spacing: .08em; border: 1px solid var(--primary); color: var(--primary); padding: 0 8px; line-height: 1.7; }
.body p { margin: 0; }
.body .t { font-family: var(--serif); font-size: 1.1rem; line-height: 1.95; }
.src { font-size: 12px; color: var(--outline); line-height: 1.7; margin-top: 6px !important; }
.cert { margin-left: .3em; opacity: .9; }
.maplink { font-size: 12px; margin-top: 2px !important; }
.answer { margin-top: 12px !important; padding: 10px 14px; background: var(--surface-high); font-family: var(--serif); font-weight: 600; font-size: 1.02rem; line-height: 1.8; }
.answer small { display: block; font-family: var(--sans); font-weight: 400; font-size: 12px; color: var(--secondary); letter-spacing: .08em; }
.res { margin-top: 10px !important; }
.maj { font-size: 14px; color: var(--on-variant); margin-top: 10px !important; padding: 10px 14px; background: var(--surface-low); line-height: 1.9; }
.deathage { font-family: var(--serif); font-weight: 700; color: var(--secondary); margin-top: 6px !important; }

/* 世の中の出来事: 左に線を引いた淡い行 */
.row.world .card { background: var(--surface-low); border-left: 3px solid var(--outline-variant); padding: 12px 18px 14px; }
.row.world .t { font-family: var(--sans); font-size: .97rem; color: var(--on-variant); }
.row.world .when .y { font-size: 1rem; color: var(--on-variant); font-weight: 600; }
/* 選んだ行: 朱の線 */
.row.answered .card { border-left: 3px solid var(--secondary); box-shadow: 0 1px 0 var(--hairline); }
/* 歴史が分かれた後: 破線の枠 */
.row.alt .card { border-style: dashed; border-color: var(--outline); }
.row.alt.world .card { border-left-style: dashed; }
.row.alt .t { color: var(--on-variant); }
.row.alt.self .t { color: var(--on-surface); }
/* 歴史が分かれた行: 斜線の地と朱の札 */
.row.branch .card { background-color: var(--surface-low); background-image: repeating-linear-gradient(135deg, var(--stripe) 0 2px, transparent 2px 10px); border-style: solid; border-color: var(--hairline); }
.branchmark { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .08em; background: var(--secondary); color: var(--on-secondary); padding: 0 12px; line-height: 1.9; margin-bottom: 8px !important; }
/* 死の行 */
.row.death .card { border: 1px solid var(--secondary); border-left: 4px solid var(--secondary); }
.row.death .t { font-weight: 700; color: var(--secondary); }

.actions { text-align: center; padding: 20px 0 8px; }
.actions .btn { width: 100%; max-width: 420px; }

/* 二択の場面: 大きな問いと2枚のカード */
.row.choosing .card { background: var(--surface-lowest); border: 1px solid var(--outline); border-top: 3px solid var(--primary); padding: 20px 20px 22px; }
.choicebox { margin: 4px 0 0; }
.row .choicebox { margin-top: 18px; }
.cq { font-family: var(--serif); font-weight: 700; font-size: 1.5rem; line-height: 1.7; letter-spacing: .05em; margin: 0 0 14px; text-align: center; }
.copts { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .copts { grid-template-columns: 1fr 1fr; gap: 16px; } }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; width: 100%; font: inherit; text-align: left; min-height: 96px; padding: 16px 18px; background: var(--surface-container); border: 1px solid var(--hairline); color: var(--on-surface); cursor: pointer; border-radius: 0; line-height: 1.75; }
.choice:hover { background: var(--surface-highest); border-color: var(--primary); }
.choice:active { background: var(--primary); color: var(--on-primary); }
.choice:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }
.cnum { font-size: 12px; letter-spacing: .1em; background: var(--surface-lowest); color: var(--on-variant); padding: 0 10px; line-height: 1.8; border: 1px solid var(--hairline); }
.choice:nth-child(2) .cnum { color: var(--secondary); }
.clabel { font-family: var(--serif); font-weight: 700; font-size: 1.12rem; line-height: 1.7; }

/* 結果 */
.result { margin-top: 36px; }
.end-head { background: var(--surface-container); border: 1px solid var(--hairline); border-top: 3px solid var(--secondary); padding: 28px 20px 24px; text-align: center; }
.end-kicker { font-size: 12px; letter-spacing: .2em; color: var(--on-variant); margin: 0 0 4px; }
.bigage { font-family: var(--serif); font-weight: 700; font-size: 2.6rem; letter-spacing: .25em; line-height: 1.4; margin: 0 0 6px; }
.bigage.small { font-size: 1.25rem; letter-spacing: .06em; }
.end-sub { font-family: var(--serif); font-size: 1.05rem; margin: 0 0 18px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; background: var(--surface-lowest); border: 1px solid var(--hairline); text-align: center; }
.stat { padding: 12px 6px; border-left: 1px solid var(--hairline); }
.stat:first-child { border-left: 0; }
.stat-l { font-size: 11px; letter-spacing: .08em; color: var(--on-variant); margin: 0; line-height: 1.6; }
.stat-v { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; margin: 2px 0 0; line-height: 1.5; }
.stat-v.sm { font-size: .88rem; }
.rcard { background: var(--surface-low); border: 1px solid var(--hairline); padding: 20px 22px; margin-top: 20px; }
.rcard h3 { border-bottom: 1px solid var(--hairline); padding-bottom: 8px; margin-bottom: 14px; font-size: 1.1rem; }
.mech { list-style: none; padding: 0; margin: 0; }
.mech li { margin-bottom: 16px; font-size: 14.5px; line-height: 1.9; }
.mech li:last-child { margin-bottom: 0; }
.bar-l { display: flex; justify-content: space-between; gap: 12px; font-family: var(--serif); font-weight: 600; font-size: .95rem; line-height: 1.6; margin-bottom: 4px; }
.bar-l b { color: var(--secondary); white-space: nowrap; }
.bar { height: 6px; background: var(--surface-high); margin-bottom: 6px; }
.bar i { display: block; height: 100%; background: var(--primary); }
.bar.red i { background: var(--secondary); }
.mech li > span { display: block; color: var(--on-variant); }
.hist p { font-size: 15px; }
.trace { list-style: none; margin: 0; padding: 0; }
.trace li { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 4px 12px; margin-bottom: 10px; font-size: 14.5px; line-height: 1.8; }
.trace li::before { content: ""; width: 11px; height: 11px; border: 2px solid var(--primary); margin-top: 7px; }
.trace li.last::before { border-color: var(--secondary); background: var(--secondary); }
.trace .tw { font-family: var(--serif); font-weight: 600; color: var(--on-variant); margin-right: .8em; white-space: nowrap; }
.trace li.last .tw { color: var(--secondary); }
.seed { font-size: 12px; color: var(--outline); text-align: center; margin-top: 18px; }
.end-actions { text-align: center; margin-top: 22px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.end-actions .btn.big { width: 100%; max-width: 420px; }

.foot { margin-top: 3rem; background: var(--surface-low); border-top: 1px solid var(--hairline); padding: 1.4rem 0 2.4rem; font-size: 12.5px; color: var(--on-variant); line-height: 1.8; }
.foot-links { margin: .6rem 0 0; }
.foot-links a { margin-left: 1em; }
@media (max-width: 520px) {
  h1 { font-size: 1.6rem; }
  .card { padding: 14px 14px 16px; }
  .row.choosing .card { padding: 16px 14px 18px; }
  .lifehead { padding: 18px 16px; }
  .bigage { font-size: 2.1rem; }
  .cq { font-size: 1.3rem; }
  .btn.big { padding: 16px 24px; }
}

/* シェアの欄 */
.sharebox { margin-top: 28px; background: var(--surface-low); border: 1px solid var(--hairline); padding: 20px 20px 18px; }
.sharebox h3 { margin-bottom: 10px; }
.sharetext { font-family: var(--serif); font-size: .98rem; line-height: 1.9; padding: 10px 14px; background: var(--surface-lowest); border-left: 3px solid var(--secondary); margin-bottom: 14px; }
.sharebtns { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.sbtn { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-family: var(--serif); font-weight: 600; font-size: .95rem; letter-spacing: .05em; min-height: 44px; padding: 8px 18px; border: 1px solid var(--primary); background: var(--surface-lowest); color: var(--primary); cursor: pointer; border-radius: 0; text-decoration: none; line-height: 1.5; }
.sbtn:hover { background: var(--primary); color: var(--on-primary); }
.sbtn:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }
.sbtn[hidden] { display: none; }
.sharemsg { min-height: 1.9em; margin: 0 0 4px; font-size: 14px; font-weight: 700; color: var(--secondary); }
.sharebox .note { margin: 0; }
@media (max-width: 520px) { .sharebtns .sbtn { flex: 1 1 calc(50% - 10px); padding: 8px 10px; } }

/* 共有された人生の見出し・読み込めなかったときの知らせ */
.sharedbanner { background: var(--surface-container); border: 1px solid var(--hairline); border-top: 3px solid var(--secondary); padding: 22px 20px 18px; margin: 24px 0 0; text-align: center; }
.sharedbanner[hidden], .notice[hidden] { display: none; }
.sb-kicker { font-size: 12px; letter-spacing: .2em; color: var(--on-variant); margin: 0 0 2px; }
.sharedbanner h2 { font-size: 1.6rem; margin-bottom: 8px; }
.sharedbanner p { text-align: left; }
.sharedbanner .sb-kicker { text-align: center; }
.sb-go { text-align: center !important; margin: 14px 0 4px !important; }
.sb-go .btn.big { width: 100%; max-width: 420px; }
.notice { margin: 20px 0 0; padding: 12px 16px; background: var(--secondary-fixed); border-left: 4px solid var(--secondary); font-weight: 600; }


.foot-ver { font-size: 11px; color: var(--outline); margin-top: 6px; }

.row.histnote .card { background: transparent; border-left: 3px dotted var(--outline); }
.row.histnote .t { font-style: italic; color: var(--on-variant); }
.row.histnote .tag { border-style: dotted; }

.stats.s4 { grid-template-columns: repeat(2, 1fr); }
.stats.s4 .stat:nth-child(odd) { border-left: 0; }
.stats.s4 .stat:nth-child(n+3) { border-top: 1px solid var(--hairline); }
@media (min-width: 640px) {
  .stats.s4 { grid-template-columns: repeat(4, 1fr); }
  .stats.s4 .stat:nth-child(odd) { border-left: 1px solid var(--hairline); }
  .stats.s4 .stat:first-child { border-left: 0; }
  .stats.s4 .stat:nth-child(n+3) { border-top: 0; }
}

/* 挿絵（img/illust/）。角は丸めない。読み込み前に高さが崩れないよう aspect-ratio を指定する */
.illust { margin: 12px 0 4px; padding: 0; max-width: 100%; }
.illust img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border: 0; border-radius: 0; background: var(--surface-container); }
.illust-start { margin: 1.6rem 0 0; max-width: 44rem; }
.illust-end { margin: 10px auto 14px; max-width: 320px; }
@media (prefers-color-scheme: dark) { .illust img { filter: brightness(.85); } }
