:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #23211d;
  --muted: #6f6a60;
  --line: #e4dfd4;
  --accent: #b5532f;
  --birth: #3b7d6b;
  --edu: #3a62a8;
  --work: #7a5aa6;
  --move: #a7782a;
  --family: #c0567a;
  --death: #55524b;
  --friend: #2f8a9a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1a18; --card: #24231f; --ink: #ece8df; --muted: #a39d90; --line: #3a3832;
    --accent: #e0805c; --birth: #6dbba5; --edu: #7d9fe0; --work: #b29ad8; --move: #d6ab5e; --family: #e48aa8; --death: #aaa597; --friend: #62c0cf;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1a18; --card: #24231f; --ink: #ece8df; --muted: #a39d90; --line: #3a3832;
  --accent: #e0805c; --birth: #6dbba5; --edu: #7d9fe0; --work: #b29ad8; --move: #d6ab5e; --family: #e48aa8; --death: #aaa597; --friend: #62c0cf;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  line-height: 1.6;
}
main { max-width: 640px; margin: 0 auto; padding: 32px 16px 48px; }

.top h1 { font-size: 1.6rem; margin: 0 0 4px; letter-spacing: .02em; }
.lead { margin: 0 0 24px; color: var(--muted); }
.lead-note { margin: -16px 0 24px; color: var(--muted); font-size: 0.8em; line-height: 1.6; }
.credit { margin: 16px 0 0; font-size: .75rem; color: var(--muted); opacity: .8; text-align: center; }
.credit a { color: inherit; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: clip; }   /* clip, not hidden: keeps the sticky name label working */
.card-head { padding: 20px 20px 14px; border-bottom: 1px solid var(--line); }
.kicker { margin: 0; font-size: .85rem; color: var(--muted); }
.ev-more { margin-top: 4px; }
.ev-more summary { cursor: pointer; color: var(--muted); font-size: .8rem; width: fit-content; }
.ev-more summary:hover { color: var(--accent); }
.ev-more > .note { margin-top: 6px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--ink); }
.switch input { accent-color: var(--accent); }

/* statistics notes inside the timeline are hidden unless switched on or the row is opened */
.card:not(.show-notes) .timeline .ev:not(.open) .note:not(.keep) { display: none; }
.card:not(.show-notes) .timeline .has-note { cursor: pointer; }
.card:not(.show-notes) .timeline .has-note:not(.open) .text::after { content: ' ⓘ'; color: var(--muted); font-size: .75em; }
.headline { font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: .05em; }
.persona { margin: 4px 0 0; font-size: .9rem; }
.sub { margin: 2px 0 0; color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 8px 20px; }
.ev { display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.ev:last-child { border-bottom: 0; }
.age { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; color: var(--kind, var(--ink)); }
.age small { font-weight: 400; font-size: .75em; margin-left: 1px; }
.body { border-left: 3px solid var(--kind, var(--line)); padding-left: 12px; }
.text { margin: 0; }
.note { margin: 2px 0 0; font-size: .8rem; color: var(--muted); }
/* with statistics notes on, made-up wording is dimmed */
.card.show-notes .fl, .card.show-notes .ev.flavor .text { opacity: .45; }
.src { color: var(--muted); text-decoration: none; border-bottom: 1px dotted currentColor; white-space: nowrap; margin-left: .3em; }
.src:hover, .src:focus-visible { color: var(--accent); }
.rare { display: inline-block; margin-left: .4em; padding: 0 .5em; border-radius: 4px; font-size: .72rem; font-weight: 800;
  letter-spacing: .04em; line-height: 1.6; vertical-align: .1em; cursor: help; color: #fff; }
.rare-R { background: #5f7f9f; }
.rare-SR { background: #8a5cc2; }
.rare-SSR { background: linear-gradient(135deg, #c99a2e, #e6c25a 50%, #b9822a); color: #2b1f05; }
.rare.sad { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.details { margin: 8px 0 0; display: grid; gap: 4px; }
.details div { display: grid; grid-template-columns: 5.5em 1fr; gap: 8px; font-size: .9rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.details .note { display: block; margin: 0; }
/* phones: the label on its own small line, the text below at full width */
@media (max-width: 520px) { .details { gap: 8px; } .details div { grid-template-columns: 1fr; gap: 0; } }
.ev-birth { --kind: var(--birth); }
.ev-edu { --kind: var(--edu); }
.ev-work, .ev-money { --kind: var(--work); }
.ev-move { --kind: var(--move); }
.ev-family, .ev-love { --kind: var(--family); }
.ev-death { --kind: var(--death); }
.ev-friend { --kind: var(--friend); }
.ev-hobby { --kind: var(--move); }
.ev-life { --kind: var(--move); }
.ev-health { --kind: var(--death); }
.ev-info .body { border-left-color: var(--line); }

/* after the end the summary (and the もしも comparison) come first, then the timeline under a small heading */
.tl-head { margin: 0; padding: 12px 20px 0; border-top: 1px solid var(--line); font-size: .8rem; font-weight: 600; color: var(--muted); }
.summary[hidden] ~ .tl-head { display: none; }
.life-scroll.fork-only > .summary, .life-scroll.fork-only > .compare, .life-scroll.fork-only > .tl-head { display: none; }
.summary { margin: 0; padding: 14px 20px 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.summary div { min-width: 0; }
/* the place a person moves to, on the row of the move */
.text b.place { font-weight: 700; }
/* the life code (照合): small and faint in the bottom right */
.summary .life-code { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: .4em; font-size: .7rem; color: var(--muted); opacity: .6; font-variant-numeric: tabular-nums; }
.summary .life-code dt { font-size: inherit; }
.summary .life-code dd { margin: 0; letter-spacing: .05em; }
/* the table of all badges in the summary */
.summary .rare-table { grid-column: 1 / -1; }
.summary .rare-table dd { font-weight: 400; }
.summary .rare-table table { width: 100%; border-collapse: collapse; font-size: .82rem; line-height: 1.4; }
.summary .rare-table td { padding: 4px 3px; vertical-align: middle; }
.summary .rare-table tr { cursor: pointer; border-top: 1px dashed var(--line); }
.summary .rare-table tr:hover td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.summary .rare-table .rare { margin: 0; white-space: nowrap; }
.summary .rare-table .rk { font-weight: 700; white-space: nowrap; }
.summary .rare-table .rc { width: 100%; }
.summary .rare-table .rc div { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.summary .rare-table .ra { color: var(--muted); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.summary .rare-table .ro { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; font-size: .78rem; }
.summary .rare-table .rb { width: 56px; min-width: 56px; }
.summary .rare-table .rb span { display: block; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.summary .rare-table .rb i { display: block; height: 100%; border-radius: 3px; }
.summary .rare-table .rb i.rare-SSR { background: #c99a2e; } .summary .rare-table .rb i.rare-SR { background: #8e5ac8; } .summary .rare-table .rb i.rare-R { background: #5c7f9e; }
.ev.flash { animation: evflash 1.6s ease-out; }
@keyframes evflash { from { background: color-mix(in srgb, var(--accent) 25%, transparent); } to { background: transparent; } }
.summary dt { font-size: .75rem; color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.actions { display: flex; flex-direction: column; gap: 10px; margin: 20px 0 8px; }
/* after a life: 「もう一度生まれる」 full width; 「0歳から見なおす」 and 「共有する…」; small links below */
.actions .act-main { width: 100%; padding: 14px 22px; font-size: 1.05rem; }
.actions .act-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .act-links { margin: 2px 0 0; text-align: center; font-size: .85rem; color: var(--muted); }
.actions .act-links .link-btn { color: var(--muted); }
.share-name { margin: 0 0 8px; text-align: left; }
.share-name label { display: inline-flex; gap: 4px; align-items: center; margin-right: 14px; font-size: .9rem; }
/* phones: the four buttons after a life in two rows of two */
@media (max-width: 520px) { .actions { gap: 8px; } .actions .act-row { gap: 8px; } .actions .act-row button { padding: 9px 8px; font-size: .88rem; white-space: nowrap; } .wide-only { display: none; } }
button { font: inherit; border-radius: 999px; padding: 10px 22px; cursor: pointer; }
.primary { background: var(--accent); color: #fff; border: 0; font-weight: 700; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); z-index: 30; max-width: min(90vw, 480px); margin: 0;
  padding: 8px 14px; border-radius: 10px; background: var(--ink); color: var(--card); font-size: .85rem; line-height: 1.5;
  opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.on { opacity: 1; }

.foot { margin-top: 32px; font-size: .75rem; color: var(--muted); }
.foot p { margin: 0 0 6px; }

/* links between related lives */
.view-of { margin: 0 0 6px; font-size: .85rem; }
.view-of a, a.person { color: var(--accent, inherit); text-decoration: underline; text-underline-offset: 2px; }

/* title screen: map of Japan */
.picker { margin: 0 0 8px; }
.pick-lead { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }
.map { max-width: 560px; margin: 0 auto; }
.jp { width: 100%; height: auto; display: block; }
.jp .inset { fill: none; stroke: var(--line); stroke-width: 1; }
.jp .pref { cursor: pointer; outline: none; }
.jp .land { fill: color-mix(in srgb, var(--accent) calc(var(--t) * 45% + 10%), var(--card)); stroke: var(--card); stroke-width: 1.2; stroke-linejoin: round; transition: fill .15s; }
.jp .hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; }
.jp .pref:hover .land, .jp .pref:focus-visible .land { fill: var(--accent); }
.jp .pref.on .land { fill: var(--accent); }
.primary:disabled, .ghost:disabled { opacity: .4; cursor: default; }
.map-wrap { position: relative; max-width: 560px; margin: 0 auto; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.map { max-width: none; }
.jp { touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.jp .land, .jp .hit { vector-effect: non-scaling-stroke; }
.jp .label { fill: var(--ink); font-size: var(--label, 12px); text-anchor: middle; dominant-baseline: middle; pointer-events: none; font-weight: 700;
  paint-order: stroke; stroke: var(--card); stroke-width: .25em; }
.jp.nolabel .label { display: none; }
.map-ctl { position: absolute; right: 8px; bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.map-ctl button { min-width: 40px; padding: 6px 8px; font-size: .85rem; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; }

/* the hidden attribute wins over display rules (e.g. .actions { display: flex }) */
[hidden] { display: none !important; }

/* option: a rarer life */
.rarity-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 8px; font-size: .85rem; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 6px 12px; background: transparent; color: var(--ink); font-size: .85rem; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; font-weight: 700; }

/* title screen: the big button and the options */
.primary.big { display: block; width: auto; min-width: 240px; max-width: 100%; margin: 0 auto 14px; padding: 14px 36px; font-size: 1.05rem; }
.options { max-width: 560px; margin: 0 auto 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--card); }
.options summary { cursor: pointer; font-weight: 700; }
.opt-summary { font-weight: 400; color: var(--muted); font-size: .85rem; margin-left: 6px; }
.opt { margin: 14px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.opt-label { width: 100%; font-size: .85rem; color: var(--muted); }
.opt .map-wrap { width: 100%; }
.chip { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: .9rem; }
.chip-x { padding: 2px 9px; font-size: .8rem; background: transparent; color: var(--muted); border: 1px solid var(--line); }
.ghost.small { padding: 6px 14px; font-size: .85rem; }
.rarity-pick { display: none; }
.pref-select { font: inherit; font-size: .85rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); max-width: 100%; }
#optReset { display: block; margin: 10px auto 4px; }

/* lives so far */
.hist-stats { margin: 10px 0 6px; font-size: .8rem; color: var(--muted); }
.hist-list { list-style: none; margin: 0; padding: 0; }
.hist-list li { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--line); padding: 6px 0; }
.hist-open { flex: 1; color: var(--ink); text-decoration: none; font-size: .9rem; }
.hist-name { font-weight: 700; margin-right: 6px; }
.hist-meta { color: var(--muted); font-size: .8rem; }
.star { padding: 2px 6px; border: 0; background: transparent; color: var(--muted); font-size: 1rem; }
.star.on { color: var(--accent); }
#histClear { display: block; margin: 10px auto 4px; }

/* a life unfolding */
.ev.pending { display: none; }
.ev.appear { animation: appear .35s ease-out; }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }
.ev.appear .rare-SSR { animation: shine 1.2s ease-out; }
@keyframes shine { 0% { box-shadow: 0 0 0 0 rgba(255, 200, 60, .9); } 100% { box-shadow: 0 0 0 14px rgba(255, 200, 60, 0); } }
.age-now { margin: 4px 0 0; font-size: 1.6rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.skip-bar { position: fixed; left: 0; right: 0; bottom: 16px; display: flex; justify-content: center; z-index: 20; pointer-events: none; }
.skip-bar button { pointer-events: auto; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
@media (prefers-reduced-motion: reduce) { .ev.appear, .ev.appear .rare-SSR { animation: none; } }

.rare[title] { cursor: help; }

/* rarity count and the search panel */
.rare-count { font-size: .85rem; }
.opt-hint { font-size: .8rem; color: var(--muted); }
.switch.until { width: 100%; font-size: .85rem; }
.search-panel { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 40; width: min(88vw, 360px);
  padding: 18px 20px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); text-align: center; }
.search-panel p { margin: 0 0 8px; }
.search-best { font-size: .85rem; color: var(--muted); }

/* a life unfolding: a slim name label stays on top and counts the years; the newest year is highlighted */
.card-head.playing { position: sticky; top: 0; z-index: 15; background: var(--card); box-shadow: 0 6px 14px rgba(0, 0, 0, .12);
  padding: 10px 20px; }
.card-head.playing .headline { white-space: nowrap; }
.card-head.playing #viewOf, .card-head.playing .kicker, .card-head.playing .persona { display: none; }
.card-head.playing .headline { font-size: 1.15rem; }
.card-head.playing .age-now { margin: 0; font-size: 1.3rem; }
/* the same slim label after the end (享年 in place of the age); the 「← …の人生に戻る」 link stays */
.card-head.slim { padding: 10px 20px; }
.card-head.slim .kicker, .card-head.slim .persona, .card-head.slim .sub { display: none; }
.card-head.slim .headline { font-size: 1.15rem; white-space: nowrap; }
.card-head.slim .age-now { margin: 0; font-size: 1.3rem; }
.timeline.playing .ev:not(.current) { opacity: .55; transition: opacity .4s; }
/* the state next to the name: nine fixed slots, two columns, five rows; the grid keeps its size */
.card-head { position: relative; }
.stat { margin: 6px 0 0; font-size: .78rem; line-height: 1.55; }
.stat-when { margin: 0; min-height: 1.2em; font-size: .72rem; color: var(--muted); }
.stat-grid { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
/* the name and the three capitals on the left, the state items in one column on the right */
.card-head { display: grid; grid-template-columns: fit-content(46%) minmax(0, 1fr); column-gap: 16px; align-items: start; }
.card-head > * { grid-column: 1; }
.card-head #stat { display: contents; }
.card-head .stat-side { grid-column: 2; grid-row: 1 / span 12; min-width: 0; font-size: .78rem; line-height: 1.55; }
.card-head .cap { grid-column: 1; margin: 6px 0 0; font-size: .78rem; }
.cap-row { display: flex; gap: 6px; align-items: center; cursor: pointer; white-space: nowrap; line-height: 1.6; }
.cap-label { color: var(--muted); }
.cap-help-btn { display: block; margin: 2px 0 0; padding: 0; border: 0; background: none; color: var(--muted); font-size: .72rem; cursor: pointer; border-radius: 0; }
.cap-help-btn:hover { color: var(--accent); }
.card-head .cap-help { grid-column: 1 / -1; grid-row: 13; margin: 8px 0 0; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--line) 45%, transparent); font-size: .74rem; line-height: 1.55; }
.ch-row { display: grid; grid-template-columns: 2.6em 1fr; gap: 4px; margin: 0 0 4px; }
.ch-row b { color: var(--accent); }
.ch-up { color: #2e7d4f; } .ch-down { color: #b23b38; }
.ch-foot { margin: 6px 0 0; color: var(--muted); }
.ch-title { margin: 0 0 6px; font-weight: 600; }
.ch-more { margin: 6px 0 0; }
.ch-more summary { cursor: pointer; color: var(--muted); }
.ch-more p { margin: 4px 0 0; }
.tb-note { margin-top: 2px; font-size: .7rem; opacity: .75; }
.cap-num { min-width: 1.6em; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .72rem; }
.cap-bar { position: relative; flex: none; width: 76px; height: 9px; border-radius: 4px; background: var(--line); overflow: hidden; }
.cap-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; transition: width .4s ease; }
.cap-buf { position: absolute; top: 0; bottom: 0; background: #fff; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 0 4px 4px 0; transition: left .4s ease, width .4s ease; }
.ch-buf { margin: 2px 0 6px; }
.cap-delta { position: absolute; top: 0; bottom: 0; opacity: 0; pointer-events: none; }
.cap-delta.up { background: #3c9a5f; animation: capFlash 1.1s ease-out; }
.cap-delta.down { background: #d0504d; animation: capFlash 1.1s ease-out; }
@keyframes capFlash { 0%, 40% { opacity: 1; } 100% { opacity: 0; } }
.toast .tb { display: grid; grid-template-columns: auto 90px 2em; gap: 8px; align-items: center; }
.toast .mini { height: 6px; border-radius: 3px; background: color-mix(in srgb, currentColor 25%, transparent); overflow: hidden; }
.toast .mini i { display: block; height: 100%; background: currentColor; }
.toast .tb span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.toast .tb span:first-child { white-space: nowrap; }
.cap-mark { display: inline-block; margin-left: .4em; padding: 0 .35em; border-radius: 4px; font-size: .7rem; line-height: 1.5; vertical-align: .1em; white-space: nowrap; }
.cap-mark.up { color: #2e7d4f; background: color-mix(in srgb, #3c9a5f 15%, transparent); }
.cap-mark.down { color: #b23b38; background: color-mix(in srgb, #c0504d 15%, transparent); }
.stat-grid div { display: grid; grid-template-columns: 3.6em 1fr; gap: 4px; min-width: 0; border-radius: 4px; transition: background-color .9s; }
.stat-grid dt { color: var(--muted); }
.stat-grid dd { margin: 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default; }
.stat-grid dd.none { color: var(--muted); opacity: .6; }
.stat-grid .chg { background: color-mix(in srgb, var(--accent) 22%, transparent); transition: none; }
.stat.folded, .card-head #stat.folded { display: none; }
.card-head.playing .stat-when { display: none; }
.stat-fold { position: absolute; top: 8px; right: 12px; background: transparent; border: 0; color: var(--muted); font: inherit; font-size: .85rem; padding: 4px 8px; cursor: pointer; }
.stat-fold:hover { color: var(--accent); }
.timeline.playing .ev.current { opacity: 1; }

.skip-bar { gap: 10px; }
.skip-bar .ghost { pointer-events: auto; background: var(--card); box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }

/* life mode: the page fits the screen; only the timeline box scrolls (the title screen scrolls as a page) */
body.life-mode { overflow: hidden; height: 100dvh; }
body.life-mode main { height: 100dvh; display: flex; flex-direction: column; padding-top: 10px; padding-bottom: 10px; box-sizing: border-box; }
body.life-mode .top, body.life-mode .foot, body.life-mode #picker { display: none; }
body.life-mode .card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
body.life-mode .card-head, body.life-mode .toolbar { flex: none; }
body.life-mode .toolbar .hint { display: none; }
body.life-mode .life-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
body.life-mode .card-head.playing { position: relative; box-shadow: none; }
body.life-mode #lifeActions { flex: none; margin: 10px 0 0; justify-content: center; }
body.life-mode .skip-bar { position: static; flex: none; margin: 10px 0 0; pointer-events: auto; }
body.life-mode .skip-bar button { box-shadow: none; }
.skip-bar { flex-wrap: wrap; }
/* five buttons on one line, even on a 360px phone */
.skip-bar button { padding: 9px 12px; font-size: .88rem; white-space: nowrap; }
body.life-mode .skip-bar { gap: 6px; }
/* the big 次へ at the bottom of the life panel (it stays put; the timeline scrolls above it) */
.next-wrap { flex: none; padding: 8px 12px 12px; border-top: 1px solid var(--line); background: var(--card); }
.next-big { display: block; width: 100%; min-height: 56px; font-size: 1.1rem; border-radius: 14px; }
@media (max-width: 420px) { .skip-bar button { padding: 9px 8px; font-size: .82rem; } body.life-mode .skip-bar { gap: 4px; } .bar-sep { margin: 6px 0; } }
.bar-sep { align-self: stretch; width: 1px; margin: 6px 2px; background: var(--line); }

/* newest first: the timeline list reversed on screen (rows keep their order in the page) */
.timeline.newest-first { display: flex; flex-direction: column-reverse; }
.timeline.reorder { animation: appear .4s ease-out; }
.order-btn { margin-left: auto; padding: 4px 12px; font-size: .8rem; }

/* もしも (if): a small quiet button on turning-point rows, the panel of options, the comparison in the summary */
.fork-btn { display: inline-block; margin-left: .4em; padding: 0 .6em; border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-size: .75rem; font-weight: 700; line-height: 1.6;
  vertical-align: .1em; white-space: nowrap; cursor: pointer; }
.fork-btn:hover, .fork-btn:focus-visible { background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: var(--accent); }
/* 「もしも」 switch */
.timeline.fork-only .ev:not(.ev-birth):not(.ev-death):not(.has-fork) { display: none; }
.fork-btn.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.fork-tag { display: inline-block; margin: 0 .4em 0 .2em; padding: 0 .45em; border-radius: 4px; font-size: .7rem; line-height: 1.5; font-weight: 700;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); vertical-align: .1em; white-space: nowrap; }
.fork-tag.orig { color: var(--muted); background: color-mix(in srgb, var(--line) 70%, transparent); }
.fork-note-head { margin: 0 0 4px; font-size: .78rem; color: var(--muted); }
.card-head.playing .fork-note-head { font-size: .72rem; }
.link-btn { padding: 0; border: 0; border-radius: 0; background: none; color: var(--accent); font: inherit; font-size: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.fork-panel { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, .35); }
.fork-sheet { width: min(100%, 460px); max-height: 85dvh; overflow-y: auto; padding: 16px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .25); }
@media (min-width: 600px) { .fork-panel { align-items: center; } .fork-sheet { border-radius: 16px; } }
/* the life card preview (card.js) */
.card-img { display: block; width: 100%; max-height: 62dvh; object-fit: contain; margin: 8px 0 12px; border-radius: 8px; box-shadow: 0 1px 6px rgba(0,0,0,.15); }
.card-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.fork-title { margin: 0 0 2px; font-weight: 700; font-size: 1.05rem; }
.fork-lead { margin: 0 0 10px; font-size: .8rem; color: var(--muted); }
.fork-sub { margin: 10px 0 4px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.fork-opts { display: grid; gap: 6px; margin: 0 0 12px; }
.fork-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 10px 14px; border-radius: 12px; text-align: left;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); font-size: .92rem; }
.fork-opt:not([disabled]):hover { border-color: var(--accent); }
.fork-opt.cur { background: color-mix(in srgb, var(--accent) 8%, var(--card)); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.fork-opt[disabled] { opacity: 1; cursor: default; }
.fork-label { min-width: 0; overflow-wrap: anywhere; }
.fork-eff { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.fork-eff .cap-mark { margin-left: 0; }
.fork-eff.none { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.fork-res { display: block; margin-top: 2px; font-size: .75rem; color: var(--muted); }
.fork-note { margin: 2px 2px 4px; font-size: .72rem; color: var(--muted); }
#forkClose { display: block; margin: 0 auto; }
.compare { padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.compare.wait { display: none; }
.cmp-title { margin: 0 0 2px; font-weight: 700; }
.cmp-paths { margin: 0 0 8px; font-size: .8rem; color: var(--muted); }
.cmp-sum { margin: 0 0 4px; font-size: .85rem; }
.cmp-fly { color: var(--accent); font-weight: 700; margin-bottom: 8px; }
/* もしも lives: rows that the original life didn't have (a quiet 「新」 under the age) */
.timeline .ev.is-new .age::after { content: '新'; display: block; font-size: .62rem; line-height: 1; margin-top: 2px; color: var(--accent); opacity: .75; font-weight: 400; }
.cmp-grid { display: grid; gap: 2px; margin: 0 0 12px; font-size: .85rem; }
.cmp-row { display: grid; grid-template-columns: 6.5em minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.cmp-row span { min-width: 0; overflow-wrap: anywhere; }
.cmp-k { color: var(--muted); font-size: .78rem; }
.cmp-head { font-size: .75rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.cmp-row.diff span:last-child { font-weight: 700; color: var(--accent); }

/* the start: a reel of prefecture names */
.birth-reel { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: var(--bg); cursor: pointer; }   /* opaque: the new life is already drawn behind it */
.reel-box { text-align: center; padding: 24px 28px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .15); min-width: 240px; }
.reel-lead { margin: 0 0 10px; color: var(--muted); font-size: .9rem; }
.reel-window { height: 56px; overflow: hidden; border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); }
.reel-strip { will-change: transform; }
.reel-item { height: 56px; line-height: 56px; font-size: 1.8rem; font-weight: 700; letter-spacing: .08em; }
.reel-sex { margin: 12px 0 0; min-height: 1.6em; font-size: 1.2rem; font-weight: 700; color: var(--accent); opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s; }
.reel-sex.on { opacity: 1; transform: none; }

/* names chosen by the player: a small pencil next to the name (and next to a pet's name on its first row), an inline form */
.name-edit, .pet-edit { margin-left: .35em; padding: 0 .3em; border: 0; border-radius: 4px; background: none; color: var(--muted); font: inherit; font-size: .8em;
  font-weight: 400; line-height: 1.2; vertical-align: .08em; cursor: pointer; }
.name-edit:hover, .name-edit:focus-visible, .pet-edit:hover, .pet-edit:focus-visible { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.name-note { margin: 2px 0 0; font-size: .72rem; color: var(--muted); }
/* the name form spans the label's width, below the bars (the state grid takes the right column above) */
.card-head .name-form { grid-column: 1 / -1; grid-row: 14; }
.name-form, .pet-form { margin: 8px 0 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-size: .85rem; }
.name-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.name-fields label:last-child { grid-column: 1 / -1; }
.name-fields label, .pet-form label { display: grid; gap: 2px; color: var(--muted); font-size: .75rem; }
.name-form input, .pet-form input { width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); }
.name-form input:focus, .pet-form input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.name-msg { margin: 6px 0; font-size: .72rem; color: var(--muted); }
.name-msg.err { color: #c0504d; }
.name-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.primary.small { padding: 6px 14px; font-size: .85rem; }
.card-head.playing .name-note { font-size: .68rem; }
#shareClose { display: block; margin: 0 auto; }
