:root {
  /* Day Theme: 葛萊芬多 (Gryffindor) · 獅心緋紅、古堡羊皮紙與璀璨金徽 */
  --house: 'gryffindor';
  --paper: #F8F4EC;
  --card: #FFFDF9;
  --card2: #F2ECE1;
  --ink: #1F1714;
  --ink2: #54473F;
  --ink3: #75675D;
  --rule: #DCD2C1;
  --rule2: #ECE4D4;
  --accent: #8E1F2F;        /* Gryffindor Scarlet */
  --accent-ink: #FFFFFF;
  --accent-soft: #FDECEF;
  --stamp: #8E1F2F;
  --stamp-soft: #F8E6E9;
  --mystic: #6A3249;
  --mystic-ink: #FFFFFF;
  --mystic-soft: #F7EBF0;
  --gold: #896113;          /* Readable bronze-gold on parchment. */
  --gold-ink: #FFFFFF;
  --gold-soft: #FCF4DF;
  --good: #2E7D4E;
  --bad: #AB2626;
  --warn: #896113;
  --loss: #26211E;
  --grid-lo: #F6E2B8;
  --grid-mid: #7CBF8B;
  --grid-hi: #166B72;
  --grid-mid-ink: #1F1714;
  --grid-hi-ink: #FFFFFF;
  --shadow: 0 1px 0 rgba(31,23,20,.05), 0 12px 28px -12px rgba(142,31,47,.16);
  --f-display: 'Noto Serif TC', 'Songti TC', 'PMingLiU', Georgia, serif;
  --f-body: 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', system-ui, -apple-system, sans-serif;
  --f-mono: 'IBM Plex Mono', 'Consolas', ui-monospace, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  /* Night Theme: 史萊哲林 (Slytherin) · 黑湖深潭、地窖青石與翡翠銀輝 */
  --house: 'slytherin';
  --paper: #09120F;         /* Deep Black Lake Dungeon */
  --card: #101B16;          /* Serpent Jade Chamber */
  --card2: #15241E;
  --ink: #E6EFEA;           /* Silver Mist */
  --ink2: #9CB5A7;          /* Sage Silver */
  --ink3: #7C9788;          /* Readable Dungeon Slate */
  --rule: #1E3329;          /* Serpent Carving */
  --rule2: #162720;
  --accent: #2EA675;        /* Slytherin Pure Emerald */
  --accent-ink: #04140D;
  --accent-soft: #113626;
  --stamp: #2EA675;
  --stamp-soft: #0E2A1D;
  --mystic: #68AA90;
  --mystic-ink: #04140D;
  --mystic-soft: #143026;
  --gold: #7EC89F;          /* Silver-Emerald Tint */
  --gold-ink: #04140D;
  --gold-soft: #142E22;
  --good: #38D997;
  --bad: #F87171;
  --warn: #FBBF24;
  --loss: #94A3B8;
  --grid-lo: #182921;
  --grid-mid: #2C8C61;
  --grid-hi: #5EEAD4;
  --grid-mid-ink: #04140D;
  --grid-hi-ink: #04140D;
  --shadow: 0 1px 0 rgba(0,0,0,.6), 0 14px 36px -12px rgba(46,166,117,.18);
  color-scheme: dark;
}

:root[data-theme="hufflepuff"] {
  /* Hufflepuff: warm yellow, black, and the common room's sunlit earth. */
  --house: 'hufflepuff';
  --paper: #FBF5DF;
  --card: #FFFCED;
  --card2: #F3E9C7;
  --ink: #29251C;
  --ink2: #584C32;
  --ink3: #6F603D;
  --rule: #D9CAA2;
  --rule2: #EBDFBD;
  --accent: #806014;
  --accent-ink: #FFFFFF;
  --accent-soft: #F8E6AA;
  --stamp: #806014;
  --stamp-soft: #F7EAC2;
  --mystic: #74602E;
  --mystic-ink: #FFFFFF;
  --mystic-soft: #F5ECCF;
  --gold: #866116;
  --gold-ink: #FFFFFF;
  --gold-soft: #F8EBC0;
  --good: #367041;
  --bad: #A0352A;
  --warn: #866116;
  --loss: #41382B;
  --grid-lo: #EEE0AC;
  --grid-mid: #A5B66C;
  --grid-hi: #54703C;
  --grid-mid-ink: #29251C;
  --grid-hi-ink: #FFFFFF;
  --shadow: 0 1px 0 rgba(41,37,28,.05), 0 12px 28px -12px rgba(128,96,20,.18);
}

:root[data-theme="ravenclaw"] {
  /* Ravenclaw's book colours: blue and bronze. */
  --house: 'ravenclaw';
  --paper: #0E182B;
  --card: #16243C;
  --card2: #1C2D48;
  --ink: #EEECE4;
  --ink2: #BEC9D8;
  --ink3: #91A1BA;
  --rule: #38475C;
  --rule2: #26374E;
  --accent: #CEA572;
  --accent-ink: #18243B;
  --accent-soft: #323040;
  --stamp: #9BC5E6;
  --stamp-soft: #1C3550;
  --mystic: #BBA8D7;
  --mystic-ink: #18243B;
  --mystic-soft: #2B2C46;
  --gold: #CEA572;
  --gold-ink: #18243B;
  --gold-soft: #33313A;
  --good: #89CEAD;
  --bad: #F49A91;
  --warn: #E0BB7D;
  --loss: #B2BFD0;
  --grid-lo: #243249;
  --grid-mid: #4B779C;
  --grid-hi: #D3AF7A;
  --grid-mid-ink: #FFFFFF;
  --grid-hi-ink: #18243B;
  --shadow: 0 1px 0 rgba(0,0,0,.4), 0 14px 36px -12px rgba(80,120,171,.22);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow-x: hidden;
  max-width: 100vw;
}
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input::placeholder, textarea::placeholder { color: var(--ink3); opacity: 1; }
[hidden], .hidden { display: none !important; }

.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.lbl {
  font-size: 11.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink3);
  font-weight: 600;
}
.wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding-inline: 20px;
}
@media (max-width: 560px) { .wrap { padding-inline: 14px; } }

/* Top Nav */
.langsw {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--rule2);
  font-size: 13px;
  color: var(--ink2);
  max-width: 1320px;
  margin: 0 auto;
  flex-wrap: nowrap;
}
.langsw .nav-l { display: flex; align-items: center; gap: 14px; flex-shrink: 1; min-width: 0; }
.langsw .nav-r { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: nowrap; }
.langsw .brand-link {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.langsw .brand-link em { font-style: normal; color: var(--accent); }
.themebtn {
  border: 1.5px solid var(--rule);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.themebtn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
  transform: translateY(-1px);
}
.themebtn.active {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--ink);
}
.donate-pill {
  border: 1.5px solid var(--gold);
  background: var(--gold-soft);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
  box-shadow: 0 1px 3px rgba(184,134,30,.15);
}
.donate-pill:hover {
  background: var(--gold);
  color: var(--gold-ink);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(184,134,30,.28);
}
.langbtn {
  border: 1.5px solid var(--rule);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-family: var(--f-mono);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.langbtn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
  transform: translateY(-1px);
}

/* Intro Section */
#intro { padding-block: 32px 96px; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(0, 1fr);
  gap: 44px;
  align-items: start;
}
@media (max-width: 920px) {
  .hero { grid-template-columns: 1fr; gap: 28px; }
}
.kicker {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--stamp);
  letter-spacing: .04em;
  font-weight: 600;
}
.hero h1 {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(48px, 8.5vw, 112px);
  line-height: .98;
  letter-spacing: -.03em;
  margin: 12px 0 22px;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.lede {
  font-size: 16.5px;
  color: var(--ink2);
  max-width: 38em;
  margin: 0;
  line-height: 1.72;
}
.counter {
  margin-top: 24px;
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  align-items: flex-start;
}
.counter .c-total {
  display: flex;
  flex-direction: column;
}
.counter .c-twin {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}
.counter .c-sub {
  display: flex;
  flex-direction: column;
}
.counter strong {
  font-family: var(--f-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.counter span { font-size: 12.5px; color: var(--ink3); margin-top: 2px; }

.tdband {
  margin: 20px 0 0;
  padding: 10px 14px;
  background: var(--mystic-soft);
  border-left: 3px solid var(--mystic);
  border-radius: 0 4px 4px 0;
  font-size: 13px;
  color: var(--ink2);
  max-width: 40em;
}
.tdband b {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 7px;
  border-radius: 2px;
  background: var(--mystic);
  color: var(--mystic-ink);
  font-family: var(--f-mono);
  font-size: 11px;
}

.heroside { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.tg-bg {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 10px;
  box-shadow: var(--shadow);
}
.tg-bg canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 192 / 60;
  border-radius: 2px;
  image-rendering: pixelated;
}
.tg-cap {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink3);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.odds {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.odds h2 {
  font-family: var(--f-display);
  font-size: 17px;
  margin: 0 0 4px;
  font-weight: 700;
}
.odds p.sub { margin: 0 0 12px; font-size: 12.5px; color: var(--ink3); }
.orow {
  display: grid;
  grid-template-columns: 10.5em 1fr 3.6em;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  padding-block: 3px;
}
.orow .bar { height: 7px; background: var(--rule2); border-radius: 2px; overflow: hidden; }
.orow .bar i { display: block; height: 100%; background: var(--stamp); }
.orow .bar i.blood { background: var(--accent); }
.orow .v { text-align: right; font-family: var(--f-mono); font-size: 12px; color: var(--ink2); }

/* Options Grid */
.opts {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 24px 36px;
  align-items: flex-start;
}
.optgroup { display: flex; flex-direction: column; gap: 7px; }
.birth-options > summary { display: none; }
.optgroup .hint { font-size: 12px; color: var(--ink3); max-width: 24em; }
.pace-controls { display: flex; align-items: stretch; gap: 6px; }
.auto-choice-toggle {
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--card);
  color: var(--ink2);
  padding: 7px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.auto-choice-toggle[aria-pressed="true"] { background: var(--ink); color: var(--paper); font-weight: 600; }
.seg {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  background: var(--card);
  flex-wrap: wrap;
}
.seg button {
  flex: 1 1 auto;
  border: 0;
  background: none;
  padding: 8px 14px;
  font-size: 13.5px;
  color: var(--ink2);
  white-space: nowrap;
}
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}
.sel {
  font-size: 13.5px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 8px 11px;
}
.bday-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.natal-preview {
  margin-top: 4px;
  padding: 8px 12px;
  background: var(--gold-soft);
  border-left: 3px solid var(--gold);
  border-radius: 0 4px 4px 0;
  font-size: 12.5px;
  color: var(--ink);
  max-width: 28em;
}

.ctarow {
  flex-basis: 100%;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
}
.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 4px;
  padding: 14px 26px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: var(--shadow);
}
.cta:hover { filter: brightness(1.08); }
.cta.sm { padding: 7px 14px; font-size: 13px; }
.ghost {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  border-radius: 4px;
  padding: 10px 16px;
  font-size: 14px;
}
.ghost:hover:not(:disabled) { border-color: var(--ink2); background: var(--card2); }
.ghost:disabled { color: var(--ink3); background: var(--card2); border-style: dashed; opacity: 1; cursor: not-allowed; }
.ghost.sm { padding: 6px 12px; font-size: 12.5px; }
.donate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--gold-soft) !important;
  border-color: var(--gold) !important;
  color: var(--ink) !important;
  font-weight: 600;
  text-decoration: none;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.donate-btn:hover {
  background: var(--gold) !important;
  color: var(--gold-ink) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(184,134,30,.25);
}

/* Intro Notes */
.notes {
  margin-top: 40px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  border-top: 1px solid var(--rule);
  padding-top: 24px;
}
@media (max-width: 760px) { .notes { grid-template-columns: 1fr; } }
.notes h3 { font-family: var(--f-display); font-size: 15.5px; margin: 0 0 6px; }
.notes p { margin: 0; font-size: 13.5px; color: var(--ink2); }

/* Panels */
.panel {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.panel h3 {
  margin: 0 0 12px;
  font-size: 14.5px;
  font-family: var(--f-display);
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

/* Roll & Birth Certificate */
#roll { padding-block: 44px 80px; }
.roller {
  max-width: 560px;
  margin: 48px auto;
  text-align: center;
  padding: 40px 24px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
}
.roller .country {
  font-family: var(--f-display);
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 700;
  margin: 12px 0 6px;
  color: var(--accent);
}
.roller .meta { font-size: 14.5px; color: var(--ink2); min-height: 1.6em; }

.cert {
  max-width: 820px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cert .band {
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: .04em;
  word-break: break-word;
}
.cert .body { padding: 26px 24px; position: relative; }
.cert h2 {
  font-family: var(--f-display);
  font-size: clamp(26px, 4.5vw, 40px);
  margin: 2px 0 10px;
  line-height: 1.15;
}
.cert .story { font-size: 16px; color: var(--ink); margin: 0 0 12px; line-height: 1.72; }
.cert .certpace { font-size: 12.5px; color: var(--ink3); margin: 0 0 18px; font-family: var(--f-mono); }
.cert .fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 12px 16px;
  padding: 16px 0;
  border-block: 1px solid var(--rule);
}
.cert .fields div { display: flex; flex-direction: column; gap: 2px; }
.cert .fields b { font-size: 14px; }
.qdots { display: inline-flex; gap: 3px; vertical-align: middle; margin-right: 4px; }
.qdots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--ink2);
  display: inline-block;
}
.qdots i.on { background: var(--gold); border-color: var(--gold); }
.odds-line {
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink2);
  padding: 10px 12px;
  background: var(--stamp-soft);
  border-left: 3px solid var(--stamp);
}
.natal-cert {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--mystic-soft);
  border-left: 3px solid var(--mystic);
  font-size: 13px;
  line-height: 1.65;
}
.natal-cert b { color: var(--mystic); }
.certcomps { margin-top: 18px; }
.certcomps ul { list-style: none; padding: 0; margin: 6px 0 0; }
.certcomps li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule2);
  font-size: 13px;
  flex-wrap: wrap;
}
.cert .foot {
  padding: 16px 24px;
  background: var(--card2);
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Lifeview Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  padding-block: 10px;
}
.topbar .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
}
.topbar .brand {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 18px;
}
.topbar .brand em { font-style: normal; color: var(--accent); }
.agebox {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 auto;
  min-width: 220px;
}
.agebox .age {
  font-family: var(--f-display);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.agebox .age small { font-size: 14px; font-weight: 500; margin-left: 3px; color: var(--ink2); }
.agebox .yr { flex: 1; max-width: 380px; display: flex; flex-direction: column; gap: 5px; }
.agebox .yr .t { font-family: var(--f-mono); font-size: 12px; color: var(--ink2); }
.prog { height: 6px; background: var(--rule2); border-radius: 3px; overflow: hidden; }
.prog i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform .08s linear;
}

.speed { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.speed button {
  border: 1px solid var(--rule);
  background: var(--card);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12.5px;
}
.speed button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  font-weight: 600;
}
.speed button[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.speed .sps { display: inline-flex; }
.speed .sps button { border-radius: 0; margin-left: -1px; font-family: var(--f-mono); }
.speed .sps button:first-child { border-radius: 4px 0 0 4px; margin-left: 0; }
.speed .sps button:last-child { border-radius: 0 4px 4px 0; }

/* 3-Column Life Grid */
.life {
  padding-block: 20px 64px;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr) 310px;
  gap: 18px;
  align-items: start;
}
@media (max-width: 1080px) {
  .life { grid-template-columns: 280px minmax(0, 1fr); }
  .col3 { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
}
@media (max-width: 780px) {
  .life { display: flex; flex-direction: column; gap: 14px; }
  .col, .col3 { display: contents; }
  .p-scene { order: 0; }
  .p-stats { order: 1; }
  .p-focus { order: 2; }
  .p-feed { order: 3; }
  .p-id { order: 4; }
  .p-fam { order: 5; }
  .p-comps { order: 6; }
  .p-grid { order: 7; }
  .p-chart { order: 8; }
  .p-cty { order: 9; }
}
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 780px) {
  .life > .col { display: contents; }
  .life > .col > .panel { width: 100%; min-width: 0; }
}

/* ID Card */
.idcard { position: relative; overflow: hidden; padding: 0; }
.idcard .top {
  background: var(--ink);
  color: var(--paper);
  padding: 7px 14px;
  display: flex;
  justify-content: space-between;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: .04em;
}
.idcard .in {
  padding: 14px;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.portrait {
  width: 76px;
  height: 95px;
  background: var(--card2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.portrait canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.idcard .nm {
  font-family: var(--f-display);
  font-size: 17.5px;
  font-weight: 700;
  line-height: 1.22;
  margin-bottom: 6px;
}
.idcard dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 8px;
  font-size: 12.5px;
}
.idcard dt { color: var(--ink3); white-space: nowrap; }
.idcard dd { margin: 0; font-weight: 500; }
.idcard .mrz {
  background: var(--card2);
  border-top: 1px solid var(--rule2);
  padding: 6px 12px;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--ink3);
  line-height: 1.35;
  overflow: hidden;
}

/* Stat Bars & Money */
.stat {
  display: grid;
  grid-template-columns: 4.6em 1fr 2.2em;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  padding-block: 3px;
}
.stat .bar { height: 7px; background: var(--rule2); border-radius: 2px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; transition: width .25s ease; }
.stat .v { text-align: right; font-family: var(--f-mono); font-size: 12px; color: var(--ink2); }

.money {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}
.money small { display: block; font-size: 11px; color: var(--ink3); }
.money b { display: block; font-family: var(--f-display); font-size: 16.5px; line-height: 1.25; }
.money .flow ul { list-style: none; margin: 4px 0 0; padding: 0; font-size: 12px; }
.money .flow li {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  border-bottom: 1px dotted var(--rule2);
}
.money .flow b.pos { color: var(--good); font-family: var(--f-mono); font-size: 12px; }
.money .flow b.neg { color: var(--bad); font-family: var(--f-mono); font-size: 12px; }
.money .owns { font-size: 12.5px; color: var(--ink2); }

/* Family List */
.fam .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--rule2);
  font-size: 13px;
}
.fam .row:last-child { border-bottom: 0; }
.fam .row span:first-child { color: var(--ink3); flex: none; }
.fam .row span:last-child { text-align: right; }
.fam .gone { color: var(--ink3); text-decoration: line-through; }

/* Scene Canvas */
.p-scene { padding: 0; overflow: hidden; }
.scene { aspect-ratio: 192 / 60; background: var(--stamp-soft); position: relative; }
.scene canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.scenecap {
  margin: 0;
  padding: 9px 14px 11px;
  font-size: 12.5px;
  color: var(--ink2);
  border-top: 1px solid var(--rule2);
  font-family: var(--f-mono);
}

/* Focus Chips */
.status { font-size: 13.5px; color: var(--ink2); margin-bottom: 10px; }
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chips button {
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 56px;
  text-align: left;
  white-space: normal;
}
.chips button small { color: var(--ink3); font-size: 11px; }
.chips button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  font-weight: 600;
}
.chips button[aria-pressed="true"] small { color: var(--rule); }
.focus-hint { grid-column: 1 / -1; margin: 0; font-size: 13px; color: var(--ink2); }
.skill-summary { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--ink2); line-height: 1.7; }
.skill-summary b { color: var(--ink); }
.resonance-option { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 8px; }
.resonance-option input { accent-color: var(--accent); }

/* Feed Log */
.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 540px;
  overflow-y: auto;
}
.feed li {
  display: grid;
  grid-template-columns: 3.4em minmax(0, 1fr);
  gap: 8px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--rule2);
  font-size: 14px;
  animation: feedIn .22s ease-out;
}
@keyframes feedIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.feed li:hover { background: var(--card2); }
.feed li .a { font-family: var(--f-mono); font-size: 11.5px; color: var(--ink3); padding-top: 2px; }
.feed li.big .x { font-weight: 600; color: var(--ink); }
.feed li.warm .a::after { content: ' ·'; color: var(--gold); font-weight: 700; }
.feed li.bad .x { color: var(--bad); }
.feed li.ms .x { color: var(--stamp); font-size: 13px; }
.feed li.comp .x { color: var(--ink2); font-size: 13px; border-left: 2px solid var(--rule); padding-left: 8px; }
.feed li.prophecy .x {
  color: var(--mystic);
  font-weight: 600;
  border-left: 2px solid var(--mystic);
  padding-left: 8px;
}
.feed li .f-fact {
  grid-column: 2;
  margin-top: 5px;
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--ink2);
  background: var(--stamp-soft);
  border-left: 2px solid var(--stamp);
  padding: 5px 8px;
  line-height: 1.48;
}
.feed li .f-lore {
  grid-column: 2;
  margin-top: 5px;
  font-size: 12px;
  color: var(--ink);
  background: var(--gold-soft);
  border-left: 2px solid var(--gold);
  padding: 5px 8px;
  line-height: 1.48;
}

/* Right Column: Companions, Grid10, Survival Chart, Country Stats */
.comps { list-style: none; margin: 0; padding: 0; }
.comps li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule2);
  font-size: 12.5px;
}
.comps li:last-child { border-bottom: 0; }
.comps li.gone { color: var(--ink3); }
.comps li.gone .cs { color: var(--ink3); }
.comps .cn { font-weight: 600; }
.comps .cn small { display: block; font-weight: 400; color: var(--ink3); font-size: 11px; }
.comps .cs { color: var(--ink2); text-align: right; font-size: 11.5px; max-width: 13em; }

.grid10 {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
}
.grid10 .c {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--rule2);
  display: grid;
  place-items: center;
  position: relative;
  font-size: 9px;
  font-family: var(--f-mono);
  color: var(--ink2);
  line-height: 1;
}
.grid10 .c.cur { outline: 2px solid var(--accent); z-index: 1; }
.grid10 .c.le { border: 1.5px dashed var(--ink2); }
.grid10 .c .m { text-shadow: 0 1px 1px rgba(0,0,0,.45); font-weight: 700; }
.gridkey {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 11px;
  color: var(--ink3);
}

.chart svg { display: block; width: 100%; height: auto; }
.chart-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--ink2);
  margin-top: 6px;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 10px; height: 3px; display: inline-block; }

.p-cty dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  font-size: 12.5px;
}
.p-cty dt { color: var(--ink2); border-bottom: 1px dotted var(--rule2); padding-bottom: 3px; }
.p-cty dd { margin: 0; font-family: var(--f-mono); font-weight: 600; text-align: right; border-bottom: 1px dotted var(--rule2); padding-bottom: 3px; }
.p-cty .src { margin-top: 10px; font-size: 11px; color: var(--ink3); line-height: 1.5; }

/* Decision & Sheet Modal */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(12, 15, 19, .62);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: none;
}
.dec {
  width: min(560px, 100%);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: 0 24px 48px -12px rgba(0,0,0,.45);
  overflow: hidden;
  animation: decArm .2s ease-out;
}
@keyframes decArm { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.dec .hd {
  padding: 10px 18px;
  background: var(--card2);
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--ink2);
  letter-spacing: .03em;
}
.dec.pause .hd { color: var(--stamp); font-weight: 600; }
.dec.divin .hd { background: var(--mystic-soft); color: var(--mystic); font-weight: 600; }
.dec .bd { padding: 20px 20px 22px; max-height: 82vh; overflow-y: auto; overscroll-behavior: contain; }
.dec h2 {
  font-family: var(--f-display);
  font-size: 21px;
  margin: 0 0 10px;
  line-height: 1.3;
}
.dec p { margin: 0 0 12px; color: var(--ink2); font-size: 14.5px; line-height: 1.68; }
.auto-decision-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; font-size: 12px; color: var(--ink3); }
.auto-decision-bar button { flex-shrink: 0; padding: 5px 9px; border: 1px solid var(--rule); border-radius: 4px; background: var(--card); color: var(--ink); font-size: 12px; }
.debt-note { border-left: 3px solid var(--warn); background: var(--gold-soft); padding: 9px 11px; font-size: 12px; color: var(--ink2); line-height: 1.7; }
.dec .fact {
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--ink2);
  background: var(--stamp-soft);
  border-left: 3px solid var(--stamp);
  padding: 8px 11px;
  margin-bottom: 10px;
  line-height: 1.52;
}
.dec .lore {
  font-size: 12.5px;
  color: var(--ink);
  background: var(--gold-soft);
  border-left: 3px solid var(--gold);
  padding: 8px 11px;
  margin-bottom: 12px;
  line-height: 1.58;
}
.dec .lore b { color: var(--gold); display: block; margin-bottom: 2px; }
.dec textarea, .dec input[type="text"] {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 9px 12px;
  margin-bottom: 12px;
}
.dec .ch { display: flex; flex-direction: column; gap: 8px; }
.dec .ch button {
  text-align: left;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 4px;
  padding: 11px 14px;
  display: grid;
  grid-template-columns: 1.6em minmax(0, 1fr);
  gap: 2px 8px;
}
.dec .ch button:hover:not(:disabled) { border-color: var(--accent); background: var(--card); }
.dec .ch button.auto-picked:not(:disabled) {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--gold-soft);
}
.dec .ch button.auto-picked .k { color: var(--accent); font-weight: 700; }
.dec .ch button .k {
  grid-row: span 2;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink3);
  padding-top: 2px;
}
.dec .ch button b { font-weight: 600; font-size: 14.5px; }
.dec .ch button small { color: var(--ink3); font-size: 12px; display: block; margin-top: 2px; }
.dec .ch button.lock {
  cursor: not-allowed;
  border-style: dashed;
  background: transparent;
  color: var(--ink3);
  opacity: 1;
}

/* Image Preview & Save Modal */
.img-modal-box {
  width: min(580px, 94%);
  margin: auto;
}
.img-modal-box .bd {
  padding: 14px 16px;
  max-height: 82dvh;
  overflow-y: auto;
  box-sizing: border-box;
}
.img-tip-box {
  background: var(--card2);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  text-align: left;
}
.img-tip-box b {
  color: var(--accent);
}
.img-tip-box ol {
  margin: 4px 0 0;
  padding-left: 20px;
}
.img-tip-box li {
  margin-bottom: 3px;
}
.img-wrap {
  width: 100%;
  max-height: 52dvh;
  overflow-y: auto;
  margin-bottom: 14px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  -webkit-overflow-scrolling: touch;
}
.img-wrap img {
  max-width: 100%;
  height: auto;
  display: block;
  user-select: auto !important;
  -webkit-user-select: auto !important;
  -webkit-touch-callout: default !important;
}
.img-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Ending Overlay & Life Highlights Montage */
.ending-ov {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(9, 11, 15, 0.96);
  color: #EAE4D8;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  text-align: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.ending-ov .e-box {
  margin: auto 0;
  max-width: 620px;
  width: 100%;
  animation: feedIn .45s ease-out;
  padding: 18px;
  border: 1px solid #252B38;
  background: #11151D;
  border-radius: 6px;
  box-shadow: 0 12px 36px rgba(0,0,0,.6);
  box-sizing: border-box;
}
.montage-top {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #202633;
  text-align: left;
}
.montage-top .kicker { flex: 1 1 200px; min-width: 0; color: #8C94A6; font-size: 11px; line-height: 1.5; letter-spacing: .08em; overflow-wrap: anywhere; }
.end-skip {
  flex: 0 0 auto;
  margin-left: auto;
  min-height: 44px;
  white-space: nowrap;
  color: #B0A798;
  border-color: #384050;
  background: transparent;
  padding: 3px 10px;
  font-size: 11.5px;
}
.montage-top .end-skip:hover:not(:disabled) { background: #1F2633; color: #FFF; border-color: #60708D; }

.ending-ov h2 { font-family: var(--f-display); font-size: 26px; margin: 0 0 4px; color: #F3E5C8; }
.ending-ov .e-sub { font-family: var(--f-mono); font-size: 12px; color: #8F877B; margin-bottom: 14px; }

.montage-stage {
  background: #0A0D14;
  border: 1px solid #222938;
  border-radius: 4px;
  padding: 14px 12px;
  margin-bottom: 16px;
}
.montage-stage .e-scene {
  width: 100%;
  max-width: 480px;
  margin: 0 auto 12px;
  border: 1px solid #2C3547;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
}
.montage-stage .e-scene canvas { width: 100%; height: auto; display: block; image-rendering: pixelated; }

.montage-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}
.m-age {
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
}
.m-title {
  font-family: var(--f-display);
  font-size: 16.5px;
  font-weight: 700;
  color: #F0C978;
}
.m-caption {
  font-size: 13.5px;
  line-height: 1.62;
  color: #DFD8CA;
  margin: 0 0 12px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
}

.montage-strip {
  display: flex;
  height: 8px;
  gap: 1px;
  background: #151A24;
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto 12px;
  max-width: 480px;
  border: 1px solid #1E2533;
}
.montage-strip span {
  flex: 1;
  background: #252E3E;
  transition: opacity .2s;
  opacity: .35;
}
.montage-strip span.lit {
  opacity: 1;
}

.montage-ctrls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.montage-ctrls button {
  padding: 4px 10px;
  font-size: 12px;
}
/* The montage has a fixed dark surface in every house. Keep each control
   state paired here so the shared parchment .ghost:hover cannot override it. */
.ending-ov .ghost {
  background: #141924;
  color: #E2DACB;
  border-color: #384257;
}
.ending-ov .ghost:is(:hover, :active):not(:disabled) { background: #222B3D; color: #FFFFFF; border-color: #60708D; }
.ending-ov :is(button, a):focus-visible { outline-color: #F0C978; }
.m-counter { font-size: 11.5px; color: #7E8799; min-width: 50px; }

.montage-footer { margin-top: 10px; }
.ending-ov .e-line { font-size: 14.5px; line-height: 1.65; margin: 6px 0; color: #DFD8CA; }
.ending-ov .e-quote {
  font-family: var(--f-display);
  font-size: 16px;
  color: #F0C978;
  margin: 12px 0 16px;
  padding: 8px 14px;
  border-block: 1px solid rgba(240,201,120,.22);
}

/* Life Highlights Gallery (#dead Moments Panel) · 大畫幅記憶畫廊 */
.continuity-turns { list-style: none; padding: 0; margin: 16px 0 0; }
.continuity-turns li { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid var(--rule2); }
.continuity-age { flex: 0 0 48px; font-family: var(--f-mono); font-size: 12px; color: var(--accent); padding-top: 3px; }
.continuity-turns li > div { min-width: 0; }
.continuity-turns h4 { margin: 0 0 6px; font-family: var(--f-display); font-size: 16px; overflow-wrap: anywhere; }
.continuity-turns p, .continuity-letters p, .continuity-unfinished { margin: 0; font-size: 14px; line-height: 1.75; overflow-wrap: anywhere; }
.continuity-letters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 12px; margin-top: 14px; }
.continuity-letters blockquote { margin: 0; padding: 15px; background: var(--paper); border-left: 2px solid var(--accent); }
.continuity-letters cite { display: block; margin-top: 9px; font-size: 12px; color: var(--ink3); font-style: normal; }
.continuity-unfinished { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--rule); color: var(--ink2); }
.continuity-unfinished b { display: block; margin-bottom: 5px; color: var(--ink); }
.past-storyline { display: block; color: var(--ink3); font-size: 12px; }
.continuity-live { margin-top: 12px; border-top: 1px solid var(--rule2); padding-top: 10px; font-size: 12px; color: var(--ink2); }
.continuity-live summary { cursor: pointer; color: var(--accent); }
.continuity-people, .continuity-plans { list-style: none; margin: 10px 0 0; padding: 0; }
.continuity-people li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; margin-top: 5px; overflow-wrap: anywhere; }
.continuity-people span, .continuity-plans small { color: var(--ink3); }
.continuity-plans li { margin-top: 8px; line-height: 1.6; overflow-wrap: anywhere; }
.continuity-plans small { display: block; }
.continuity-archive { margin: 12px 0 18px; font-size: 13px; color: var(--ink2); }
.continuity-archive summary { cursor: pointer; color: var(--accent); }
.continuity-archive p { white-space: pre-line; line-height: 1.8; overflow-wrap: anywhere; }

.p-moments {
  margin-top: 24px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 24px 28px;
  box-shadow: var(--shadow);
}
.moments-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.moments-header h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.mv-sub {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--ink2);
}
.moments-gallery {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.moment-viewer-card {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 4px 18px rgba(0,0,0,.08);
  overflow: hidden;
}
.moment-viewer-card .scene {
  aspect-ratio: 192 / 60;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  background: #000;
  position: relative;
}
.moment-viewer-card .scene canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.moment-viewer-info {
  text-align: center;
  background: var(--card);
  border-top: 1px solid var(--rule2);
  padding: 18px 24px;
}
.moment-viewer-info .mv-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}
.moment-viewer-info .m-age {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-family: var(--f-mono);
  font-size: 13px;
  font-weight: 700;
  background: var(--accent);
  color: var(--accent-ink);
  letter-spacing: .02em;
}
.moment-viewer-info h4 {
  font-family: var(--f-display);
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  color: var(--accent);
}
.moment-viewer-info p {
  margin: 6px auto 0;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.7;
  max-width: 820px;
}
.thumbs-wrap {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}
.thumbs-lbl {
  margin-bottom: 8px;
  display: block;
}
.moment-thumbs {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 6px 4px 14px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.moment-thumbs::-webkit-scrollbar { height: 7px; }
.moment-thumbs::-webkit-scrollbar-track { background: var(--card2); border-radius: 4px; }
.moment-thumbs::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
.moment-thumbs::-webkit-scrollbar-thumb:hover { background: var(--ink3); }

.m-thumb {
  flex: 0 0 136px;
  width: 136px;
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  background: var(--card);
  padding: 6px;
  text-align: center;
  cursor: pointer;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
  user-select: none;
}
.m-thumb:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.m-thumb.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1.5px var(--accent);
}
.m-thumb canvas {
  width: 100%;
  aspect-ratio: 192 / 60;
  display: block;
  border-radius: 3px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  margin-bottom: 5px;
  border: 1px solid var(--rule2);
  background: #000;
}
.m-thumb span {
  display: block;
  font-size: 11.5px;
  font-family: var(--f-mono);
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-thumb canvas { width: 100%; height: auto; display: block; border-radius: 2px; image-rendering: pixelated; margin-bottom: 4px; }
.m-thumb span { display: block; font-size: 11px; font-family: var(--f-mono); color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Past Lives Archive & Soul Collection (#intro) */
.past-lives { margin-top: 24px; }
.soul-collection {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 16px;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.soul-pill {
  font-family: var(--f-mono);
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid var(--rule);
  color: var(--ink3);
  background: var(--card);
}
.soul-pill.unlocked {
  border-color: var(--stamp);
  color: var(--stamp);
  font-weight: 600;
  background: var(--paper);
}
.past-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.past-item {
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--card);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color .15s;
}
.past-item:hover { background: var(--paper); border-color: var(--ink3); }
.past-info b { font-family: var(--f-display); font-size: 15.5px; display: block; margin-bottom: 2px; }
.past-info span { font-size: 12.5px; color: var(--ink2); }
.past-badge { font-family: var(--f-mono); font-size: 12px; font-weight: 600; color: var(--stamp); }

/* Interactive Grid Tooltip */
.grid-tip {
  --accent: var(--paper);
  --ink3: var(--paper);
  --burgundy: var(--paper);
  position: absolute;
  z-index: 85;
  background: var(--ink);
  color: var(--paper);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
  box-shadow: var(--shadow);
  max-width: 240px;
}
.grid-tip b { color: inherit; display: block; margin-bottom: 2px; }

/* Death Certificate & Soul Reading (#dead) */
#dead { padding-block: 28px 80px; }
.dcert {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.dcert .band {
  background: var(--loss);
  color: var(--paper);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: .04em;
  word-break: break-word;
}
.dcert .body {
  padding: 26px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 28px;
}
@media (max-width: 860px) { .dcert .body { grid-template-columns: 1fr; } }
.dcert h1 {
  font-family: var(--f-display);
  font-size: clamp(28px, 4.8vw, 44px);
  line-height: 1.12;
  margin: 4px 0 6px;
}
.dcert .span { font-family: var(--f-mono); color: var(--ink2); font-size: 13.5px; }
.dcert .story { margin: 14px 0 0; font-size: 15.5px; line-height: 1.72; color: var(--ink); }
.dcert .cause { margin-top: 16px; font-size: 16px; }
.dcert .cause b { color: var(--accent); }
.dcert .ctx { margin-top: 8px; color: var(--ink2); font-size: 13.5px; }

.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  align-content: start;
}
.summary > div { border-top: 1px solid var(--rule); padding-top: 8px; min-width: 0; }
.summary b { display: block; font-size: 14.5px; font-weight: 600; }
.summary small { display: block; margin-top: 2px; color: var(--ink3); font-size: 12px; }
.summary .wide { grid-column: 1 / -1; }

/* Grain of Life (這一生的人生紋理) */
.gr-name {
  margin: 4px 0 2px;
  font-family: var(--f-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--stamp);
}
.gr-near { margin: 0 0 12px; font-size: 12.5px; color: var(--ink3); font-family: var(--f-mono); }
.gr-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.gr-rows li {
  display: grid;
  grid-template-columns: 6em minmax(60px, 1fr) 6em;
  align-items: center;
  gap: 2px 8px;
  font-size: 12.5px;
}
.gr-rows li small {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 11px;
  color: var(--ink3);
}
.gr-w:first-child { text-align: right; }
.gr-t {
  position: relative;
  height: 6px;
  margin: 0 6px;
  border-radius: 3px;
  background: var(--rule);
}
.gr-t::after {
  content: '';
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: var(--ink3);
  opacity: .5;
}
.gr-t i {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--stamp);
  box-shadow: 0 0 0 2px var(--card);
}
.gr-ch { margin: 12px 0 0; font-size: 13px; color: var(--ink); font-weight: 500; }
.gr-foot { margin: 8px 0 0; font-size: 12px; color: var(--ink3); }

/* Divination & Soul Reading Panel */
.soul-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.soul-card {
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
}
.soul-card .sc-k { font-size: 11px; font-family: var(--f-mono); color: var(--mystic); font-weight: 600; letter-spacing: .04em; }
.soul-card h4 { font-family: var(--f-display); font-size: 16.5px; margin: 4px 0 6px; color: var(--ink); }
.soul-card p { margin: 0; font-size: 13px; color: var(--ink2); line-height: 1.62; }

.deadstack { display: flex; flex-direction: column; gap: 18px; margin-top: 20px; }
.after {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 20px;
}
@media (max-width: 860px) { .after { grid-template-columns: 1fr; } }

.lives5 { list-style: none; margin: 0; padding: 0; }
.lives5 li {
  display: grid;
  grid-template-columns: 4.5em minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule2);
}
.lives5 li:last-child { border-bottom: 0; }
.lives5 .ca {
  font-family: var(--f-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--stamp);
}
.lives5 li.me .ca { color: var(--accent); }
.lives5 p { margin: 3px 0 0; font-size: 13px; color: var(--ink2); }

.look-list { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.75; color: var(--ink); }
.look-list li { margin-bottom: 6px; }
.endbtns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.endbtns > button, .endbtns > a { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 48px; padding: 12px 16px; text-align: center; line-height: 1.5; }
@media (min-width: 561px) and (max-width: 1023px) {
  .endbtns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 4px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
}
/* Keep resume notices clear of the highlighted choice in phone bottom sheets. */
@media (max-width: 780px) {
  #modal:not([hidden]) ~ .toast {
    top: max(12px, env(safe-area-inset-top));
    bottom: auto;
    width: max-content;
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
  }
}

/* Stat bar tier colors & Century Grid cell colors */
.stat .bar i[data-k="ok"]  { background: var(--good); }
.stat .bar i[data-k="mid"] { background: var(--gold); }
.stat .bar i[data-k="low"] { background: var(--bad); }

.grid10 .c.ok  { background: var(--grid-hi); color: var(--grid-hi-ink); }
.grid10 .c.mid { background: var(--grid-mid); color: var(--grid-mid-ink); }
.grid10 .c.low { background: var(--grid-lo); color: var(--ink); }

/* Tribute & Homage Footer */
.homage-bar {
  margin-top: 24px;
  padding: 12px 18px;
  background: var(--card2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-size: 13px;
  color: var(--ink2);
  line-height: 1.6;
}
.homage-bar span {
  font-family: var(--f-mono);
  font-weight: 600;
  color: var(--stamp);
}
.homage-bar a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
  transition: opacity .15s ease;
}
.homage-bar a:hover {
  opacity: 1;
  text-decoration-thickness: 2px;
}

/* Beta Feedback & Build Bar */
.betabar {
  margin-top: 24px;
  padding: 12px 16px;
  border: 1px dashed var(--rule);
  border-radius: 6px;
  background: var(--card);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px 18px;
  flex-wrap: wrap;
}
.beta-l {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.beta-badge {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: .04em;
}
.beta-txt {
  font-size: 13.5px;
  color: var(--ink2);
}
.beta-r {
  display: flex;
  gap: 8px;
  align-items: center;
}
.beta-btn {
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
}

/* Hero Hall of Remembrance (.hero-memo) */
.hero-memo {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px dashed var(--rule);
}
.hm-t {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink2);
}
.hm-all {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: underline;
}
.hm-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.hm-card {
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
  overflow: hidden;
}
.hm-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.hm-card .hm-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}
.hm-card .hm-name {
  font-family: var(--f-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.hm-card .hm-age {
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--accent);
}
.hm-card .hm-sub {
  font-size: 12px;
  color: var(--ink3);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hm-card .hm-grain {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink2);
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dotted var(--rule2);
}
.memo-card-item {
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.memo-card-item:active {
  transform: scale(0.985);
  border-color: var(--accent);
}

/* Mobile & Small Screen RWD Enhancements */
@media (max-width: 560px) {
  /* Top Nav Guarantee 1-line on Mobile */
  .langsw {
    padding: 8px 12px;
    gap: 6px;
    justify-content: space-between;
    flex-wrap: nowrap;
  }
  .langsw .nav-l {
    flex-shrink: 1;
    min-width: 0;
    gap: 0;
  }
  .langsw .nav-l > span { display: none; }
  .langsw .brand-link {
    font-size: 14.5px;
    white-space: nowrap;
  }
  .langsw .brand-sub { display: none; }
  .langsw .nav-r {
    flex-shrink: 0;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .themebtn {
    padding: 4px 8px;
    font-size: 11.5px;
    white-space: nowrap;
  }
  .themebtn .theme-mode { display: none; }
  .themebtn .music-text { display: none; }
  .donate-pill {
    padding: 4px 8px;
    font-size: 11.5px;
    white-space: nowrap;
  }
  .langbtn {
    padding: 4px 8px;
    font-size: 11.5px;
    white-space: nowrap;
  }

  /* Intro */
  #intro { padding-block: 18px 64px; }
  .hero h1 { font-size: clamp(34px, 10vw, 52px); margin: 6px 0 12px; }
  .lede { font-size: 14.5px; }
  .counter {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: 6px;
  }
  .counter .c-total strong { font-size: 24px; }
  .counter .c-total span { font-size: 12px; }
  .counter .c-twin {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    padding-top: 10px;
    border-top: 1px dotted var(--rule2);
  }
  .counter .c-sub strong { font-size: 20px; }
  .counter .c-sub span {
    font-size: 11px;
    line-height: 1.35;
    color: var(--ink3);
  }
  .betabar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
  }
  .beta-r {
    width: 100%;
    justify-content: flex-end;
  }
  .hm-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .odds { padding: 12px; }
  .orow { grid-template-columns: 7.2em 1fr 2.8em; gap: 5px; font-size: 11.5px; }
  .opts { margin-top: 20px; padding-top: 16px; gap: 16px; }
  .optgroup { width: 100%; }
  .seg { width: 100%; }
  .seg button { padding: 8px 10px; font-size: 12.5px; }
  .pace-controls .seg { width: auto; flex: 1; flex-wrap: nowrap; min-width: 0; }
  .pace-controls .seg button { padding: 8px 5px; font-size: 11px; }
  .pace-controls .auto-choice-toggle { padding: 7px; font-size: 11px; }
  .ctarow .cta, .ctarow .ghost { width: 100%; justify-content: center; }

  /* Certificates */
  .cert .band, .dcert .band {
    padding: 10px 14px;
    font-size: 10.5px;
    flex-wrap: wrap;
    gap: 4px 10px;
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  .cert .body, .dcert .body { padding: 16px 12px; }
  .cert .fields { grid-template-columns: 1fr 1fr; gap: 10px 8px; }
  .cert .fields div { min-width: 0; }
  .cert .fields b { font-size: 13px; word-break: break-word; overflow-wrap: anywhere; }
  .cert .foot { padding: 12px; flex-direction: column-reverse; align-items: stretch; }
  .cert .foot button { width: 100%; justify-content: center; }

  /* Simulation Topbar */
  .topbar { padding-block: 6px; }
  .topbar .brand { display: none; }
  .topbar .wrap { flex-wrap: wrap; gap: 6px; justify-content: space-between; }
  .agebox { min-width: 0; flex: 1 1 100%; gap: 8px; }
  .agebox .age { font-size: 24px; }
  .agebox .yr { max-width: none; flex: 1; min-width: 0; }
  .speed .sps button { padding: 5px 7px; font-size: 11px; }
  .speed { margin-left: auto; flex-wrap: nowrap; }
  .speed .auto-choice-toggle { padding: 5px 7px; font-size: 11px; }

  /* Panels */
  .panel { padding: 12px; }
  .chips {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }
  .chips button { width: 100%; padding: 9px 10px; font-size: 12.5px; overflow-wrap: anywhere; }
  .feed { max-height: 340px; }
  .feed li { grid-template-columns: 2.8em minmax(0, 1fr); font-size: 13px; gap: 8px; }

  /* Modal Bottom Sheet */
  .scrim {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding: 0;
  }
  .dec {
    width: 100%;
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
    max-height: 94dvh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }
  .dec .hd {
    flex-shrink: 0;
    padding: 12px 16px;
    border-radius: 16px 16px 0 0;
  }
  .dec .bd {
    flex: 1 1 auto;
    padding: 16px 16px 32px;
    max-height: calc(94dvh - 46px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .dec h2 { font-size: 19px; }
  .dec .ch button { padding: 11px; }

  /* Ending & Montage */
  .montage-ctrls { gap: 4px; }
  .montage-ctrls button { padding: 4px 7px; font-size: 11px; }

  /* Death & Gallery */
  .summary { grid-template-columns: 1fr; gap: 10px; }
  .gr-rows li { grid-template-columns: 4.8em minmax(36px, 1fr) 4.8em; font-size: 11px; }
  .p-moments { padding: 14px 10px; }
  .moments-header { gap: 10px; margin-bottom: 12px; }
  .moment-viewer-info { padding: 12px 10px; }
  .moment-viewer-info h4 { font-size: 18px; }
  .moment-viewer-info p { font-size: 13.5px; line-height: 1.6; }
  .m-thumb { flex: 0 0 110px; width: 110px; padding: 4px; }
  .lives5 li { grid-template-columns: 3.8em minmax(0, 1fr); gap: 8px; padding: 10px 0; }
  .lives5 .ca { font-size: 17px; }
  .endbtns {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  .endbtns button, .endbtns a {
    width: 100%;
    justify-content: center;
    padding: 12px;
    box-sizing: border-box;
  }
  .img-modal-box {
    width: 100%;
    border-radius: 14px 14px 0 0;
  }
  .img-wrap {
    max-height: 44dvh;
  }
  .img-actions {
    flex-direction: column;
    width: 100%;
  }
  .img-actions button {
    width: 100%;
    padding: 11px;
  }
}

@media (max-width: 360px) {
  .donate-pill .donate-text { display: none; }
  .langsw { padding: 6px 10px; }
  .themebtn { padding: 4px 6px; font-size: 11px; }
  .donate-pill { padding: 4px 6px; font-size: 11px; }
  .langbtn { padding: 4px 6px; font-size: 11px; }
}
/* Consequences remain readable in the existing four house palettes. */
.stat-feedback { margin-top: 10px; padding: 9px 10px; border-left: 3px solid var(--accent); background: var(--card2); font-size: 12px; line-height: 1.65; white-space: pre-line; overflow-wrap: anywhere; }
.event-delta { margin: 5px 0; color: var(--ink2); font-size: 11px; line-height: 1.7; }
.world-echoes { margin-top: 14px; padding: 12px; border: 1px solid var(--rule2); border-radius: 8px; background: var(--card2); font-size: 12px; line-height: 1.75; overflow-wrap: anywhere; }
.world-echoes p { margin: 7px 0 0; }
.world-echoes small { color: var(--ink2); }
.world-stage { color: var(--accent); font-weight: 600; }
.world-crisis { font-weight: 600; }

/* Phone reading flow: one page scroll, four destinations, no stacked dashboard. */
.mobile-life-nav, .mobile-vitals { display: none; }
@media (max-width: 780px) {
  /* Clip sideways overflow without creating a second vertical scroll container. */
  html, body { overflow-x: clip; }
  .opts { margin-top: 18px; padding-top: 0; border-top: 0; gap: 14px; }
  .opts > .optgroup, .birth-options, .opts .ctarow { width: 100%; }
  .opts .ctarow { margin-top: 0; }
  .opts .cta { width: 100%; }
  .birth-options > summary {
    display: list-item;
    min-height: 44px;
    padding-block: 10px;
    color: var(--ink2);
    font-size: 13px;
    cursor: pointer;
  }
  .birth-options .sel { font-size: 16px; min-height: 44px; max-width: 100%; }
  .resonance-option { min-height: 44px; }
  .pace-controls button { min-height: 44px; }
  .langsw button, .langsw .donate-pill { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .speed .sps button { min-width: 44px; min-height: 44px; }
  .speed .auto-choice-toggle { min-height: 44px; }
  .speed { width: 100%; justify-content: space-between; }
  .topbar .brand { display: none; }
  .topbar .wrap { flex-wrap: wrap; gap: 6px; }
  .agebox { flex: 1 1 100%; }

  .mobile-vitals {
    display: block;
    padding-block: 9px 0;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--ink2);
  }
  .life { padding-top: 10px; padding-bottom: calc(82px + env(safe-area-inset-bottom)); gap: 12px; }
  .life .p-scene { padding: 0; }
  .life .feed { max-height: none; overflow: visible; }
  .life .feed li { font-size: 14px; }
  #roll .cert { overflow: clip; }
  #roll .cert .foot {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(0,0,0,.1);
  }
  #lifeview .life > .col > .panel { display: none; }
  #lifeview[data-mobile-view="story"] .life .p-scene,
  #lifeview[data-mobile-view="story"] .life .p-feed,
  #lifeview[data-mobile-view="status"] .life .p-stats,
  #lifeview[data-mobile-view="status"] .life .p-focus,
  #lifeview[data-mobile-view="people"] .life .p-id,
  #lifeview[data-mobile-view="people"] .life .p-fam,
  #lifeview[data-mobile-view="people"] .life .p-comps,
  #lifeview[data-mobile-view="world"] .life .p-grid,
  #lifeview[data-mobile-view="world"] .life .p-chart,
  #lifeview[data-mobile-view="world"] .life .p-cty { display: block; }
  #lifeview[data-mobile-view="status"] .p-focus { order: 0; }
  .mobile-life-nav {
    position: fixed;
    z-index: 25;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 7px max(12px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: var(--card);
    border-top: 1px solid var(--rule);
    box-shadow: 0 -4px 18px rgba(0,0,0,.08);
  }
  .mobile-life-nav button {
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--ink2);
    font-size: 14px;
  }
  .mobile-life-nav button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--card2); font-weight: 700; }
  .scrim { height: 100dvh; }
  .dec .bd { min-height: 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .dec button, .img-actions button, .montage-ctrls button { min-height: 44px; }
  .ending-ov { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}
/* v0.23: the current story, small arrangements and complete records. */
.playback-context { display: flex; flex: 1 0 100%; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.playback-status { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 12px; line-height: 1.5; color: var(--ink2); }
.speed #nextDecisionBtn { flex: 0 0 auto; min-height: 36px; white-space: nowrap; }
.resume-panel { padding: 16px; border: 1px solid var(--accent); background: var(--card2); margin-bottom: 14px; }
.resume-panel p { font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.life-tools { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.life-tools button { min-height: 44px; }
.life-tools p { flex-basis: 100%; margin: 0; font-size: 13px; line-height: 1.6; }
.life-action-options { display: grid; gap: 10px; }
.life-action-options button { text-align: left; padding: 14px; min-height: 48px; background: var(--card2); color: var(--ink); border: 1px solid var(--rule); border-radius: 7px; }
.life-action-options button small { display: block; margin-top: 6px; color: var(--ink3); line-height: 1.6; }
.life-action-options button:disabled { color: var(--ink3); opacity: 1; border-style: dashed; cursor: not-allowed; }
.life-records details { border-top: 1px solid var(--rule); padding: 12px 0; }
.life-records summary { cursor: pointer; min-height: 36px; line-height: 1.7; }
.life-records p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.record-log small { color: var(--ink3); }
.life-records input { display: block; margin: 8px 0; width: 100%; }
.dec .hd { gap: 10px; flex-wrap: wrap; }
.dec .hd button { margin-left: auto; min-height: 44px; }
@media (max-width: 780px) {
  .life-tools { gap: 7px; padding-top: 8px; padding-bottom: 8px; }
  .life-tools button { flex: 1 1 28%; padding: 8px; font-size: 12px; }
  .speed { flex-wrap: wrap; justify-content: flex-start; }
  .speed #nextDecisionBtn { min-height: 44px; padding: 8px; font-size: 12px; }
  .life-tools #returnDecisionBtn { flex-basis: 100%; }
  .pace-controls, #paceSeg { flex-wrap: wrap; }
  #paceSeg button { min-height: 44px; }
}
