:root {
  --paper: #ECEFE9;
  --card: #F8FAF7;
  --card2: #F0F3EE;
  --ink: #142026;
  --ink2: #48585E;
  --ink3: #627276;
  --rule: #C6D0CB;
  --rule2: #DCE3DF;
  --accent: #8C1D3C;
  --accent-ink: #FFFFFF;
  --accent-soft: #F3E2E7;
  --stamp: #0F6E68;
  --stamp-soft: #DCEDEA;
  --gold: #9C7020;
  --gold-soft: #F5ECD8;
  --good: #2B7A4E;
  --bad: #B0362B;
  --warn: #A8730F;
  --loss: #282B36;
  --grid-lo: #F3E2B3;
  --grid-mid: #7FBF86;
  --grid-hi: #0B5C63;
  --shadow: 0 1px 0 rgba(20, 32, 38, .04), 0 8px 24px -12px rgba(20, 32, 38, .18);
  --f-display: 'Noto Serif TC', 'Noto Serif CJK TC', 'Songti TC', 'PMingLiU', 'MingLiU', Georgia, serif;
  --f-body: 'PingFang TC', 'Noto Sans TC', 'Noto Sans CJK TC', 'Microsoft JhengHei', system-ui, sans-serif;
  --f-mono: 'IBM Plex Mono', 'JetBrains Mono', 'PingFang TC', 'Noto Sans TC', ui-monospace, monospace;
  --tg-land: #CBD5D1;
  --shelf: #C49A6C;
  --shelf2: #9E764C;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0D1316;
    --card: #141D21;
    --card2: #1A2428;
    --ink: #E1E9E6;
    --ink2: #A3B2AF;
    --ink3: #869692;
    --rule: #2A383D;
    --rule2: #1D282C;
    --accent: #E2678A;
    --accent-ink: #1B0910;
    --accent-soft: #3A1C26;
    --stamp: #4CC0AF;
    --stamp-soft: #12302D;
    --gold: #D9AF59;
    --gold-soft: #2C2415;
    --good: #5CC38B;
    --bad: #F07B6B;
    --warn: #E2B04C;
    --loss: #C9CDD8;
    --grid-lo: #25283F;
    --grid-mid: #2A8A80;
    --grid-hi: #B8E8A8;
    --shadow: 0 1px 0 rgba(0,0,0,.35), 0 10px 30px -14px rgba(0,0,0,.65);
    --tg-land: #253237;
    --shelf: #8C6A48;
    --shelf2: #5E4630;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #0D1316;
  --card: #141D21;
  --card2: #1A2428;
  --ink: #E1E9E6;
  --ink2: #A3B2AF;
  --ink3: #869692;
  --rule: #2A383D;
  --rule2: #1D282C;
  --accent: #E2678A;
  --accent-ink: #1B0910;
  --accent-soft: #3A1C26;
  --stamp: #4CC0AF;
  --stamp-soft: #12302D;
  --gold: #D9AF59;
  --gold-soft: #2C2415;
  --good: #5CC38B;
  --bad: #F07B6B;
  --warn: #E2B04C;
  --loss: #C9CDD8;
  --grid-lo: #25283F;
  --grid-mid: #2A8A80;
  --grid-hi: #B8E8A8;
  --shadow: 0 1px 0 rgba(0,0,0,.35), 0 10px 30px -14px rgba(0,0,0,.65);
  --tg-land: #253237;
  --shelf: #8C6A48;
  --shelf2: #5E4630;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body {
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.lbl { font-size: 12px; letter-spacing: .04em; color: var(--ink3); font-weight: 600; }
.wrap { max-width: 1320px; margin: 0 auto; padding-inline: 20px; }
@media (max-width: 520px) { .wrap { padding-inline: 16px; } }

/* Top Language / Homage Bar */
.langsw {
  position: absolute;
  top: 14px;
  right: max(16px, calc((100% - 1320px) / 2 + 20px));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 12px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 999px;
  box-shadow: var(--shadow);
  color: var(--ink2);
  font-size: 13px;
}
.langsw .badge-homage {
  color: var(--stamp);
  font-weight: 600;
  padding-right: 6px;
  border-right: 1px solid var(--rule);
  margin-right: 4px;
}
.langsw a, .langsw button.navpill {
  padding: 6px 11px;
  border-radius: 999px;
  color: var(--ink2);
  text-decoration: none;
  border: 0;
  background: none;
  font-weight: 500;
  line-height: 1;
}
.langsw a:hover, .langsw button.navpill:hover { color: var(--ink); background: var(--rule2); }
.langsw a[aria-current="page"], .langsw button.navpill[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}
.themebtn {
  border: 0;
  background: none;
  color: var(--ink2);
  font-size: 15px;
  line-height: 1;
  padding: 6px 9px;
  border-radius: 999px;
}
.themebtn:hover { color: var(--ink); background: var(--rule2); }

/* Intro Section */
#intro { position: relative; padding-block: 72px 80px; overflow-x: clip; }
@media (max-width: 760px) {
  .langsw { position: static; margin: 12px 16px 0; justify-content: center; flex-wrap: wrap; }
  #intro { padding-top: 24px; }
}
.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; }
}
.heroside { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.kicker { font-family: var(--f-mono); font-size: 12.5px; color: var(--stamp); letter-spacing: .02em; display: flex; flex-wrap: wrap; gap: 6px; }
.kicker .nw { white-space: nowrap; }
.hero h1 {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(54px, 10vw, 136px);
  line-height: .96;
  letter-spacing: -.02em;
  margin: 12px 0 24px;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero h1 small.sub-h1 {
  display: block;
  font-size: clamp(20px, 3vw, 32px);
  color: var(--ink2);
  font-weight: 600;
  margin-top: 10px;
  letter-spacing: .06em;
}
.lede { font-size: 17.5px; color: var(--ink2); max-width: 36em; margin: 0; line-height: 1.68; }
.counter { margin-top: 26px; display: flex; gap: 32px; flex-wrap: wrap; }
.counter div { display: flex; flex-direction: column; }
.counter strong {
  font-family: var(--f-display);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.counter span { font-size: 13px; color: var(--ink3); margin-top: 2px; }

.tg-live { margin-top: 22px; max-width: 36em; padding: 10px 14px; background: var(--card); border-left: 3px solid var(--stamp); border-radius: 0 4px 4px 0; }
.tg-now { margin: 0; display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--ink); }
.tg-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: tgpulse 2.4s ease-out infinite;
}
@keyframes tgpulse {
  0% { box-shadow: 0 0 0 0 rgba(140, 29, 60, .5); }
  70%, 100% { box-shadow: 0 0 0 8px rgba(140, 29, 60, 0); }
}
.tg-feed { margin: 4px 0 0 19px; font-size: 13px; color: var(--stamp); min-height: 1.5em; }

/* Map & Odds in Hero Side */
.tg-bg {
  position: relative;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.tg-bg canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; }
.tg-map-cap {
  display: flex;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 11.5px;
  font-family: var(--f-mono);
  color: var(--ink3);
  border-top: 1px solid var(--rule2);
  background: var(--card2);
}

.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: 19px; margin: 0 0 4px; font-weight: 700; }
.odds p.sub { margin: 0 0 12px; font-size: 13px; color: var(--ink3); }
.orow {
  display: grid;
  grid-template-columns: 9.5em 1fr 3.8em;
  gap: 10px;
  align-items: center;
  font-size: 13.5px;
  padding-block: 3.5px;
}
.orow .nm-o { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.orow .bar { height: 8px; background: var(--rule2); border-radius: 2px; overflow: hidden; }
.orow .bar i { display: block; height: 100%; background: var(--stamp); transition: width .35s ease; }
.orow .bar i.rare { background: var(--accent); }
.orow .v { text-align: right; font-family: var(--f-mono); font-size: 12.5px; color: var(--ink2); }

/* Options Panel */
.opts {
  margin-top: 36px;
  padding-top: 28px;
  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: 8px; }
.optgroup .hint { font-size: 12.5px; color: var(--ink3); max-width: 25em; line-height: 1.5; }
.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: 9px 13px;
  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: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
  min-width: 210px;
}

.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: 15px 32px;
  font-size: 18px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: filter .15s ease, transform .1s ease;
}
.cta:hover { filter: brightness(1.08); }
.cta:active { transform: translateY(1px); }
.cta.sm { padding: 8px 16px; font-size: 14px; }
.ghost {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  border-radius: 4px;
  padding: 10px 16px;
  font-size: 14.5px;
}
.ghost:hover { border-color: var(--ink3); background: var(--card2); }
.ghost.sm { padding: 6px 12px; font-size: 13px; }
.ctarow {
  flex-basis: 100%;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 20px;
  border-top: 1px solid var(--rule2);
}
.ctahint { font-size: 13px; color: var(--ink3); }

/* Memorial & Past Lives */
.community, .pastlives { margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--rule); }
.community h2 { font-family: var(--f-display); font-size: 20px; margin: 0 0 6px; }
.cm-sub { margin: 0 0 14px; font-size: 13.5px; color: var(--ink2); }
.memo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.memo-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow);
}
.memo-card .mh { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.memo-card .mh b { font-family: var(--f-display); font-size: 16.5px; }
.memo-card .mh span { font-size: 12px; color: var(--ink3); font-family: var(--f-mono); }
.memo-card .m-tag { font-size: 12.5px; color: var(--stamp); font-weight: 600; }
.memo-card .m-quote { font-family: var(--f-display); font-size: 14px; color: var(--ink2); margin: 4px 0; quotes: "「" "」"; }
.memo-card .m-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--rule2); font-size: 12.5px; color: var(--ink3); }
.incense-btn {
  border: 1px solid var(--gold);
  color: var(--gold);
  background: transparent;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
}
.incense-btn:hover, .incense-btn[aria-pressed="true"] {
  background: var(--gold-soft);
}

.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-size: 14.5px; margin: 0 0 6px; font-family: var(--f-display); }
.notes p { margin: 0; font-size: 13.5px; color: var(--ink2); line-height: 1.65; }
.fine { margin-top: 16px; font-size: 12.5px; color: var(--ink3); line-height: 1.65; }
.fine a { color: var(--stamp); }

/* Roll & Birth Certificate Section */
#roll { min-height: 85vh; display: grid; place-items: center; padding-block: 48px; }
.roller { text-align: center; min-height: 60vh; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.roller .country {
  font-family: var(--f-display);
  font-size: clamp(42px, 8vw, 96px);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.1;
  min-height: 1.2em;
  margin-top: 8px;
}
.roller .meta { font-family: var(--f-mono); color: var(--stamp); font-size: 14px; margin-top: 10px; }

.cert {
  width: min(740px, 100%);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.cert .band {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 12px 22px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.cert .band b { font-family: var(--f-display); font-size: 18px; font-weight: 600; letter-spacing: .04em; }
.cert .band span { font-family: var(--f-mono); font-size: 12px; opacity: .9; }
.cert .body { padding: 24px; position: relative; }
.cert h2 { font-family: var(--f-display); font-size: clamp(30px, 5vw, 44px); margin: 2px 0 0; line-height: 1.15; font-weight: 700; }
.cert .story { margin: 12px 0 18px; font-size: 16px; color: var(--ink2); line-height: 1.65; }
.fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 18px;
  border-top: 1px dashed var(--rule);
  padding-top: 16px;
}
@media (max-width: 560px) { .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fields div { min-width: 0; }
.fields b { display: block; font-size: 15px; font-weight: 600; margin-top: 2px; }
.cert .odds-line {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--stamp-soft);
  border-left: 3px solid var(--stamp);
  border-radius: 3px;
  font-size: 13.5px;
  color: var(--ink);
}
.certcomps { margin-top: 18px; border-top: 1px dashed var(--rule); padding-top: 14px; }
.certcomps ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.certcomps li { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 4px 0; border-bottom: 1px dotted var(--rule2); }
.cert .foot { padding: 0 24px 24px; display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }

/* Lifeview Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-block: 10px;
  flex-wrap: wrap;
}
.brand { font-family: var(--f-display); font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand em { font-style: normal; color: var(--accent); }
.agebox { display: flex; align-items: baseline; gap: 12px; flex: 1; min-width: 190px; }
.agebox .age { font-family: var(--f-display); font-size: 38px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.agebox .age small { font-size: 17px; font-weight: 500; margin-left: 2px; }
.agebox .yr { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 5px; }
.agebox .yr .t { font-size: 13px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--f-mono); }
.prog { height: 4px; background: var(--rule2); border-radius: 2px; overflow: hidden; }
.prog i { display: block; height: 100%; width: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; transition: transform .1s linear; }

.speed { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.speed button {
  border: 1px solid var(--rule);
  background: var(--card);
  border-radius: 3px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--f-mono);
  min-width: 38px;
}
.speed button:hover { border-color: var(--ink3); }
.speed button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.speed .ff { font-family: var(--f-body); }

/* Main 3-Column Dashboard */
.life {
  display: grid;
  grid-template-columns: 325px minmax(0, 1fr) 345px;
  gap: 20px;
  padding-block: 20px 64px;
  align-items: start;
}
@media (max-width: 1180px) {
  .life { grid-template-columns: 310px minmax(0, 1fr); }
  .col3 { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
}
@media (max-width: 820px) {
  .life { grid-template-columns: 1fr; }
  .col3 { grid-template-columns: 1fr; }
}
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 16px;
  min-width: 0;
  box-shadow: var(--shadow);
}
.panel > h3 {
  margin: 0 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 15px;
  font-family: var(--f-display);
}
.panel > h3 .lbl { font-family: var(--f-body); font-size: 11.5px; font-weight: 500; }

/* ID Card (江湖身契 / 官府戶帖) */
.idcard { position: relative; overflow: hidden; padding: 0; }
.idcard .top {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .04em;
}
.idcard .in {
  position: relative;
  padding: 14px 14px 12px;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 14px;
}
.portrait {
  width: 68px;
  height: 86px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--card2);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.portrait canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.idcard .nm { font-family: var(--f-display); font-size: 22px; font-weight: 700; line-height: 1.2; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.realm-pill {
  font-family: var(--f-body);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--stamp-soft);
  color: var(--stamp);
  border: 1px solid var(--stamp);
}
.idcard dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 3px 10px;
  margin: 8px 0 0;
  font-size: 13px;
}
.idcard dt { color: var(--ink3); font-size: 12px; }
.idcard dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; }
.mrz {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  line-height: 1.38;
  color: var(--ink2);
  padding: 8px 14px 10px;
  border-top: 1px dashed var(--rule);
  background: var(--card2);
  white-space: nowrap;
  overflow: hidden;
}

/* 4 Stat Bars & Money */
.stat {
  display: grid;
  grid-template-columns: 3.4em minmax(0, 1fr) 2.4em;
  gap: 10px;
  align-items: center;
  font-size: 13.5px;
  padding-block: 4px;
}
.stat .bar { height: 10px; background: var(--rule2); border-radius: 2px; overflow: hidden; position: relative; }
.stat .bar i { position: absolute; inset: 0 auto 0 0; transition: width .45s ease; }
.stat .v { text-align: right; font-family: var(--f-mono); font-size: 13px; }
.stathelp { margin: 8px 0 2px; font-size: 12.5px; color: var(--ink2); }
.stathelp summary { cursor: pointer; color: var(--ink3); padding: 4px 0; }
.stathelp ul { margin: 6px 0; padding-left: 0; list-style: none; }
.stathelp li { margin: 4px 0; line-height: 1.5; }
.stathelp li b { color: var(--ink); margin-right: 4px; }

.money {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
  border-top: 1px dashed var(--rule);
  padding-top: 12px;
}
.money b { display: block; font-family: var(--f-display); font-size: 18px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.money small { color: var(--ink3); font-size: 11.5px; display: block; margin-top: 2px; }
.spend { margin-top: 10px; }
.spend .sbar { display: flex; height: 8px; border-radius: 2px; overflow: hidden; background: var(--rule2); }
.spend .sbar i { display: block; height: 100%; }
.spend .keys { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: var(--ink2); margin-top: 6px; }
.spend .keys span::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 1px;
  background: var(--c);
  vertical-align: -1px;
}

/* Family & Sect Bonds */
.fam { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.fam .row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; border-bottom: 1px dotted var(--rule2); }
.fam .row:last-child { border-bottom: 0; }
.fam .row span:first-child { color: var(--ink3); }
.fam .row span:last-child { text-align: right; font-weight: 500; }
.fam .gone { text-decoration: line-through; color: var(--ink3); font-weight: 400; }

/* Scene Canvas & Focus Chips */
.p-scene { padding: 0; overflow: hidden; }
.scene { aspect-ratio: 32 / 10; background: var(--stamp-soft); position: relative; }
.scene canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.scenecap { margin: 0; padding: 10px 16px 12px; font-size: 14px; color: var(--ink2); border-top: 1px solid var(--rule2); }

.status { font-size: 14px; color: var(--ink2); margin-bottom: 10px; }
.status b { color: var(--ink); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--rule);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
  text-align: left;
  transition: background .15s, border-color .15s;
}
.chip:hover { border-color: var(--stamp); }
.chip small { font-size: 11px; color: var(--ink3); margin-top: 1px; }
.chip[aria-pressed="true"] {
  background: var(--stamp);
  border-color: var(--stamp);
  color: var(--paper);
}
.chip[aria-pressed="true"] small { color: inherit; opacity: .85; }

/* Life Feed */
.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 620px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.feed li {
  display: grid;
  grid-template-columns: 3.6em minmax(0, 1fr);
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--rule2);
  font-size: 14.5px;
  cursor: pointer;
  animation: feedIn .4s ease;
}
@keyframes feedIn {
  from { background: var(--stamp-soft); }
  to { background: transparent; }
}
.feed li:hover { background: var(--card2); }
.feed .a { font-family: var(--f-mono); font-size: 12px; color: var(--ink3); padding-top: 2px; }
.feed .x { min-width: 0; line-height: 1.55; }
.feed .f {
  display: block;
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--ink3);
  margin-top: 3px;
  line-height: 1.45;
}
.feed .f::before { content: '資料 '; color: var(--stamp); font-weight: 600; }
.feed li.starred .a::before { content: '★ '; color: var(--gold); font-size: 11px; }
.feed li.big .x { font-weight: 600; }
.feed li.bad .x { color: var(--bad); }
.feed li.loss .x { font-weight: 600; }
.feed li.loss .a::after { content: ' †'; color: var(--bad); }
.feed li.ms .x { color: var(--stamp); font-weight: 600; }
.feed li.hist .x {
  color: var(--ink2);
  font-size: 13.8px;
  border-left: 2.5px solid var(--gold);
  padding-left: 8px;
}
.feed li.hist .a::after { content: ' ◆'; color: var(--gold); font-size: 10px; }
.feed li.dec .x { color: var(--ink2); font-size: 13.5px; }
.feed li.dec .x::before { content: '▸ '; color: var(--accent); font-weight: 700; }
.feed li.note .x { font-family: var(--f-display); font-size: 15px; color: var(--stamp); }
.feed li.death .x { font-family: var(--f-display); font-size: 17px; font-weight: 700; color: var(--accent); }
.feed .fx { display: none; font-family: var(--f-mono); font-size: 11.5px; color: var(--stamp); margin-top: 4px; }
.feed li.open .fx { display: block; }

/* Right Column: Peers, Life Grid, Survival Curve, Region Stats */
.comps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.comps li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--rule2);
  font-size: 13.5px;
}
.comps li:last-child { border-bottom: 0; padding-bottom: 0; }
.comps .cn b { font-weight: 600; }
.comps .cn small { display: block; color: var(--ink3); font-size: 11.5px; }
.comps .cs { font-size: 12.5px; color: var(--ink2); text-align: right; max-width: 14em; }
.comps li.gone .cn b { text-decoration: line-through; color: var(--ink3); }
.comps li.gone .cs { color: var(--ink3); }

.grid10 { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.grid10 .c {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--rule2);
  position: relative;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-family: var(--f-mono);
  color: var(--paper);
  font-weight: 600;
  cursor: default;
}
.grid10 .c.cur { outline: 2px solid var(--accent); outline-offset: -1px; }
.grid10 .c.le { box-shadow: inset 0 0 0 1.5px var(--ink3); }
.grid10 .c.dead { background: var(--loss) !important; color: #fff; }
.gridkey { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink3); margin-top: 8px; gap: 8px; flex-wrap: wrap; }
.gridkey span i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink3); margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 2.5px; vertical-align: middle; margin-right: 4px; }

.stats dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  margin: 0;
  font-size: 13px;
}
.stats dt { color: var(--ink2); }
.stats dd { margin: 0; text-align: right; font-family: var(--f-mono); font-size: 12.5px; font-weight: 500; }
.stats .src { margin-top: 12px; font-size: 11px; color: var(--ink3); line-height: 1.5; border-top: 1px dashed var(--rule2); padding-top: 8px; }

/* Modals (Decisions, Pause Reflection, Shop, Stats) */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 18, 22, .56);
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
}
div.dec {
  width: min(560px, 100%);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.5);
  overflow: hidden;
  animation: pop .22s ease;
}
@keyframes pop {
  from { transform: translateY(8px); opacity: .6; }
  to { transform: none; opacity: 1; }
}
.dec .hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--accent);
  background: var(--card2);
}
.dec .bd { padding: 20px; }
.dec h2 { font-family: var(--f-display); font-size: 24px; line-height: 1.3; margin: 0 0 8px; font-weight: 700; }
.dec p { margin: 0 0 12px; color: var(--ink2); line-height: 1.6; }
.dec .fact {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink2);
  background: var(--stamp-soft);
  border-left: 3px solid var(--stamp);
  padding: 8px 10px;
  margin-bottom: 14px;
  line-height: 1.5;
}
.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: 12px 14px;
  display: grid;
  grid-template-columns: 1.6em minmax(0, 1fr);
  gap: 2px 10px;
  transition: border-color .15s, background .15s;
}
.dec .ch button:hover:not(.lock) { border-color: var(--accent); background: var(--card); }
.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: 15px; }
.dec .ch button small { color: var(--ink3); font-size: 12.5px; }
.dec .ch button.lock { cursor: not-allowed; border-style: dashed; opacity: .6; }
.dec textarea {
  width: 100%;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 12px;
  resize: vertical;
}

.decpeek {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 16px;
  z-index: 45;
  width: min(560px, calc(100% - 24px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  background: var(--card);
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 18px 40px -16px rgba(19,33,42,.5);
}
.decpeek .dp-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.decpeek .dp-t b { font-size: 14px; }
.decpeek .dp-t small { color: var(--ink3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Death Screen & Certificate (#dead) */
#dead { padding-block: 36px 80px; }
.dcert {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.dcert .band {
  background: var(--loss);
  color: #ECE6DA;
  padding: 12px 22px;
  display: flex;
  justify-content: space-between;
  gap: 4px 12px;
  flex-wrap: wrap;
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: .04em;
}
.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(32px, 5.5vw, 52px); line-height: 1.1; margin: 0 0 6px; font-weight: 700; }
.dcert .span { font-family: var(--f-mono); color: var(--ink2); font-size: 14px; }
.dcert .cause { margin-top: 16px; font-size: 18px; }
.dcert .cause b { color: var(--accent); }
.dcert .story { margin: 14px 0 0; font-size: 15.5px; line-height: 1.72; color: var(--ink); }
.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: 16px; font-weight: 600; margin-top: 2px; }
.summary small { display: block; margin-top: 2px; color: var(--ink3); font-size: 12px; line-height: 1.45; }
.summary .wide { grid-column: 1 / -1; }

.lifemap { margin: 0; padding: 12px 24px 20px; border-top: 1px dashed var(--rule); background: var(--card2); }
.lifemap canvas { display: block; width: 100%; max-width: 660px; height: auto; margin: 8px auto 0; border: 1px solid var(--rule); border-radius: 4px; }
.lifemap figcaption { max-width: 660px; margin: 8px auto 0; font-size: 13px; color: var(--ink2); text-align: center; }

.after { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; 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: 22px; font-weight: 700; line-height: 1.1; color: var(--stamp); }
.lives5 li.me .ca { color: var(--accent); }
.lives5 p { margin: 4px 0 0; font-size: 13.5px; color: var(--ink2); }

.homecmp table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.homecmp th { font-weight: 600; font-size: 12px; color: var(--ink3); text-align: right; padding: 0 0 6px 10px; }
.homecmp th:first-child, .homecmp td:first-child { text-align: left; padding-left: 0; }
.homecmp td { text-align: right; padding: 6px 0 6px 10px; border-top: 1px solid var(--rule2); font-variant-numeric: tabular-nums; }
.homecmp td:last-child { color: var(--ink); font-weight: 600; }

/* Cinematic Ending Overlay */
.ending {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #0D1012;
  color: #ECE6DA;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 16px 48px;
  overflow-y: auto;
}
.end-stage { width: min(580px, 100%); margin: auto; text-align: center; }
.end-skip {
  position: fixed;
  top: 16px;
  right: 16px;
  background: none;
  border: 1px solid rgba(255,255,255,.25);
  color: #CFC8BC;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
}
.end-skip:hover { border-color: #fff; color: #fff; }
.end-pic {
  position: relative;
  width: 100%;
  aspect-ratio: 32 / 10;
  border-radius: 4px;
  overflow: hidden;
  background: #181D20;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,.85);
  border: 1px solid rgba(255,255,255,.12);
}
.end-pic canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.end-age { font-family: var(--f-mono); font-size: 13px; letter-spacing: .16em; color: #D9AF59; margin: 20px 0 8px; }
.end-text { font-family: var(--f-display); font-size: clamp(18px, 4.2vw, 22px); line-height: 1.65; margin: 0 auto; max-width: 28em; min-height: 3.2em; }
.end-strip { display: flex; gap: 2px; height: 5px; margin: 24px auto 0; max-width: 420px; }
.end-strip span { flex: 1; background: rgba(255,255,255,.12); border-radius: 1px; transition: background .4s ease; }
.end-strip span.lit { background: #D9AF59; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
}
