:root {
  --paper: #f4efe6;
  --card: #fffdf8;
  --ink: #2a2420;
  --ink2: #4a4038;
  --muted: #8d8276;
  --line: #e7ddcf;
  --red: #c8432b;
  --red-soft: #f6e1da;
  --green: #2f8a5b;
  --green-soft: #dcefe3;
  --gold: #b8892e;
  --blue: #3e6b99;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --r: 14px;
  --shadow: 0 10px 30px rgba(60, 40, 20, .12);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 15px/1.6 var(--sans); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; }
input, select { font: inherit; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 11px 20px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-weight: 600; transition: transform .12s, background .2s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #000; }
.btn.ghost { background: transparent; }
.btn.big { min-width: 240px; padding: 14px 26px; font-size: 17px; }
.btn.big small { font-weight: 400; font-size: 12px; opacity: .7; }
.btn.small { padding: 6px 14px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 18px; }
.tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 4px; background: var(--red-soft); color: var(--red); font-size: 11px; font-weight: 600; vertical-align: 2px; }

/* ---------- start ---------- */
#app.start { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: radial-gradient(circle at 50% 30%, #fbf7ef, var(--paper) 70%); }
.hero { text-align: center; max-width: 420px; width: 100%; }
.seal { width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 10px; background: var(--red); color: #fff; font: 700 38px/64px var(--serif); transform: rotate(-4deg); box-shadow: 0 6px 18px rgba(200, 67, 43, .3); }
.hero h1 { margin: 0; font: 700 52px/1.1 var(--serif); letter-spacing: 8px; }
.hero .motto { display: block; margin: 14px 0 34px; color: var(--muted); font-family: var(--serif); font-size: 16px; }
.start-btns { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.custom { margin: 20px auto 0; padding: 18px; display: grid; gap: 10px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.custom[hidden] { display: none; }
.custom label { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 10px; font-size: 14px; color: var(--ink2); }
.custom input, .custom select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.custom .btn { margin-top: 6px; }
.foot { margin-top: 32px; color: var(--muted); font-size: 12px; }

/* ---------- game layout ---------- */
#app.game { height: 100dvh; display: flex; flex-direction: column; max-width: 1180px; margin: 0 auto; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 16px 8px; padding-top: max(12px, env(safe-area-inset-top)); }
.who { flex: 1; min-width: 0; }
.who .name { display: block; font: 700 19px/1.3 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .meta { color: var(--muted); font-size: 12px; }
.age { display: flex; align-items: baseline; gap: 2px; }
.age b { font: 700 34px/1 var(--serif); color: var(--red); }
.age b.tick { animation: tick .6s ease; }
@keyframes tick { 0% { transform: scale(1.5); opacity: .2; } 100% { transform: none; opacity: 1; } }
.age small { color: var(--muted); }
.cash { text-align: right; min-width: 86px; }
.cash small { display: block; color: var(--muted); font-size: 11px; }
.cash b { font-size: 16px; }
.cash b.neg { color: var(--red); }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 0 16px 10px; }
.stat { font-size: 11px; color: var(--ink2); display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 4px; }
.stat span { grid-column: 1; }
.stat em { grid-column: 2; text-align: right; font-style: normal; font-weight: 600; }
.stat i { grid-column: 1 / 3; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.stat i b { display: block; height: 100%; border-radius: 3px; background: var(--ink2); transition: width .5s; }
.stat.health i b { background: var(--green); }
.stat.happy i b { background: var(--gold); }
.stat.smarts i b { background: var(--blue); }
.stat.looks i b { background: #b4588a; }
.stat.grades i b, .stat.perf i b { background: var(--ink); }
.stat.low em { color: var(--red); }

.body { flex: 1; min-height: 0; display: flex; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.feed { flex: 1; overflow-y: auto; padding: 6px 18px 18px; font-family: var(--serif); font-size: 15.5px; line-height: 1.75; scroll-behavior: smooth; }
.yr { display: flex; align-items: baseline; gap: 6px; margin: 18px 0 6px; padding-top: 10px; border-top: 1px dashed var(--line); font-family: var(--sans); }
.yr:first-child { border-top: 0; margin-top: 4px; }
.yr b { font: 700 22px/1 var(--serif); color: var(--red); }
.yr span { color: var(--muted); font-size: 12px; }
.ln { margin: 4px 0; color: var(--ink); }
.ln .h { font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--red); margin-right: 8px; padding: 1px 6px; border-radius: 4px; background: var(--red-soft); vertical-align: 1px; }
.ln em { font-style: normal; font-family: var(--sans); font-size: 12px; color: var(--muted); margin-left: 4px; }
.ln.big { font-weight: 700; }
.ln.good { color: var(--green); }
.ln.bad { color: var(--red); }
.ln.money { font-family: var(--sans); font-size: 12.5px; color: var(--muted); }
.ln.ach { font-family: var(--sans); font-size: 13px; color: var(--gold); font-weight: 600; }
.ln.new { animation: rise .45s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.dock { padding: 10px 14px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); }
.cats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 10px; }
.cat { padding: 10px 0; border-radius: 10px; background: var(--card); border: 1px solid var(--line); font-weight: 600; font-size: 14px; transition: transform .1s; }
.cat:active { transform: scale(.95); }
.cat.dim { color: var(--muted); background: transparent; }
.next { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 17px; font-weight: 700; }
.next:active { transform: scale(.99); }
.next small { font-weight: 400; font-size: 12px; opacity: .8; display: flex; align-items: center; gap: 4px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .6); }
.dot.on { background: #fff; border-color: #fff; }

.side { display: none; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.panel h4 { margin: 0 0 10px; font: 700 15px var(--serif); }
.panel h5 { margin: 14px 0 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.profile dl { display: grid; grid-template-columns: 64px 1fr; gap: 6px 8px; margin: 0; font-size: 13px; }
.profile dt { color: var(--muted); }
.profile dd { margin: 0; }
.row-btns { display: flex; gap: 8px; margin-top: 14px; }
.person { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-radius: 10px; text-align: left; }
.person:hover { background: var(--paper); }
.av { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #e9e2d6; font: 600 14px var(--serif); }
.av.m { background: #dfe7f0; color: #34557a; }
.av.f { background: #f3e1e4; color: #9a4458; }
.pn { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pn b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pn small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rel { flex: none; width: 46px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.rel i { display: block; height: 100%; background: var(--red); }
.person.gone { opacity: .55; }
.empty { color: var(--muted); font-size: 13px; }

.tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: var(--card); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { padding: 10px 0; font-size: 13px; color: var(--muted); }
.tabs button.on { color: var(--ink); font-weight: 700; }

/* mobile tabs */
@media (max-width: 899px) {
  #app[data-tab="people"] .main, #app[data-tab="profile"] .main { display: none; }
  #app[data-tab="people"] .side, #app[data-tab="profile"] .side { display: block; flex: 1; overflow-y: auto; padding: 4px 14px 14px; }
  #app[data-tab="people"] .profile, #app[data-tab="profile"] .people { display: none; }
  .cats { grid-template-columns: repeat(3, 1fr); }
  .stats { gap: 6px; }
  .stat { font-size: 10.5px; }
}
@media (min-width: 900px) {
  body { background: linear-gradient(90deg, #efe8dc, var(--paper) 30%, var(--paper) 70%, #efe8dc); }
  .tabs { display: none; }
  .top { padding: 18px 22px 10px; }
  .stats { padding: 0 22px 14px; gap: 14px; }
  .side { display: flex; flex-direction: column; gap: 12px; width: 320px; flex: none; padding: 0 0 16px 22px; overflow-y: auto; }
  .main { margin: 0 22px 16px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
  .feed { padding: 8px 28px 24px; }
  .dock { background: #faf6ef; }
}

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(42, 36, 32, .38); opacity: 0; transition: opacity .2s; }
.modal.on { opacity: 1; }
.modal .card { width: 100%; max-width: 500px; max-height: calc(100dvh - 36px); overflow-y: auto; background: var(--card); border-radius: 18px; padding: 22px 22px 20px; box-shadow: var(--shadow); transform: translateY(12px); transition: transform .25s; }
.modal.on .card { transform: none; }
.kicker { color: var(--red); font-size: 12px; font-weight: 600; letter-spacing: 1px; }
.card h2 { margin: 4px 0 12px; font: 700 24px/1.3 var(--serif); }
.story { font-family: var(--serif); font-size: 16px; line-height: 1.8; color: var(--ink2); }
.story p { margin: 0 0 8px; }
.story.pre { white-space: pre-line; }
.story.result { color: var(--ink); font-size: 17px; margin-top: 8px; }
.choices { display: grid; gap: 8px; margin-top: 18px; }
.choice { text-align: left; padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 15px; transition: border-color .15s, transform .1s; }
.choice:hover:not(:disabled) { border-color: var(--ink); }
.choice:active:not(:disabled) { transform: scale(.99); }
.choice:disabled { color: var(--muted); background: transparent; }
.choice small { display: block; font-size: 12px; color: var(--red); }
.fx { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.fx span { padding: 3px 9px; border-radius: 999px; background: var(--paper); font-size: 12.5px; }
.fx .up { background: var(--green-soft); color: var(--green); }
.fx .down { background: var(--red-soft); color: var(--red); }
.ach-pop { margin-top: 12px; padding: 10px 14px; border-radius: 10px; background: #fbf1da; color: #7a5a18; font-weight: 700; font-size: 14px; animation: rise .4s; }
.ach-pop small { display: block; font-weight: 400; }
.name-input { display: flex; gap: 8px; margin-top: 14px; }
.name-input input { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.badges span { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--red); color: var(--red); font-size: 12px; }
.modal.birth .card { text-align: left; }

.modal.sheet { align-items: flex-end; padding: 0; }
.modal.sheet .card { max-width: 560px; border-radius: 20px 20px 0 0; padding: 0; max-height: 80dvh; display: flex; flex-direction: column; }
@media (min-width: 900px) { .modal.sheet { align-items: center; padding: 18px; } .modal.sheet .card { border-radius: 18px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 10px; border-bottom: 1px solid var(--line); }
.sheet-head b { font: 700 18px var(--serif); }
.x { font-size: 26px; line-height: 1; color: var(--muted); padding: 0 4px; }
.sheet-body { overflow-y: auto; padding: 10px 14px 18px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.act { width: 100%; display: flex; flex-direction: column; align-items: flex-start; text-align: left; padding: 12px 12px; border-radius: 12px; border-bottom: 1px solid var(--line); }
.act:last-child { border-bottom: 0; }
.act:hover:not(:disabled) { background: var(--paper); }
.act b { font-size: 15px; }
.act small { color: var(--muted); font-size: 12.5px; }
.act:disabled b { color: var(--muted); }
.act:disabled small { color: #b8a99a; }
.pinfo { display: grid; grid-template-columns: 72px 1fr; gap: 6px 10px; margin: 6px 6px 12px; font-size: 14px; }
.pinfo dt { color: var(--muted); }
.pinfo dd { margin: 0; }
.acts { border-top: 1px solid var(--line); padding-top: 6px; }
.achs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ach { padding: 10px 12px; border-radius: 10px; background: var(--paper); color: var(--muted); }
.ach b { display: block; font-size: 14px; }
.ach small { font-size: 12px; }
.ach.got { background: #fbf1da; color: #7a5a18; }
.help p { margin: 0 0 12px; font-size: 14.5px; color: var(--ink2); }

/* ---------- obituary ---------- */
.modal.death { background: rgba(20, 16, 14, .72); }
.modal.death .card { max-width: 460px; background: #fbf8f2; border: 6px double #3a312b; border-radius: 6px; }
.obit { text-align: center; }
.obit-k { font: 700 14px var(--serif); letter-spacing: 10px; color: var(--muted); }
.obit h2 { margin: 10px 0 4px; font-size: 32px; }
.obit .years { margin: 0; color: var(--ink2); font-family: var(--serif); }
.obit .cause { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.obit blockquote { margin: 18px 0; padding: 14px 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font: 600 18px/1.6 var(--serif); color: var(--ink); }
.obit dl { display: grid; grid-template-columns: 80px 1fr; gap: 6px 10px; margin: 0; text-align: left; font-size: 14px; }
.obit dt { color: var(--muted); }
.obit dd { margin: 0; }
.obit-ach { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 16px 0 4px; }
.obit-ach span { padding: 2px 9px; border-radius: 4px; border: 1px solid var(--gold); color: #7a5a18; font-size: 12px; }
.obit-btns { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }

/* ---------- minigames ---------- */
.mg { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 14px; background: rgba(30, 24, 20, .62); opacity: 0; transition: opacity .2s; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.mg.on { opacity: 1; }
.mg-box { width: 100%; max-width: 460px; background: var(--card); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.mg-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 8px; }
.mg-title { font: 700 17px var(--serif); }
.mg-hud { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mg-time { height: 4px; background: var(--line); }
.mg-time i { display: block; height: 100%; background: var(--ink); transform-origin: left; }
.mg-time i.low { background: var(--red); }
.mg-body { padding: 18px; min-height: 340px; display: flex; flex-direction: column; }
.mg-intro { margin: auto 0; text-align: center; }
.mg-intro h3 { margin: 0 0 10px; font: 700 26px var(--serif); }
.mg-intro p { color: var(--ink2); font-size: 15px; }
.mg-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; align-items: center; }
.mg-actions .btn { min-width: 220px; }
.mg-count { margin: auto; text-align: center; }
.mg-count small { display: block; color: var(--muted); }
.mg-count b { display: block; font: 700 80px/1.1 var(--serif); color: var(--red); animation: tick .5s infinite; }
.mg-result { margin: auto 0; text-align: center; }
.stamp { display: inline-flex; align-items: baseline; justify-content: center; width: 128px; height: 128px; padding-top: 30px; border: 4px solid var(--red); border-radius: 50%; color: var(--red); font: 700 52px/1 var(--serif); transform: rotate(-10deg); animation: stamp .35s cubic-bezier(.2, 1.6, .4, 1); }
.stamp small { font-size: 16px; }
@keyframes stamp { from { transform: rotate(-10deg) scale(2.2); opacity: 0; } to { transform: rotate(-10deg) scale(1); opacity: 1; } }
.mg-word { font: 700 20px var(--serif); margin: 16px 0 0; }
.mg-result p { color: var(--ink2); }
.mg-result .btn { min-width: 180px; margin-top: 10px; }

.quiz { flex: 1; display: flex; flex-direction: column; }
.quiz-q { margin: 26px 0 26px; text-align: center; font: 700 38px/1.3 var(--serif); letter-spacing: 2px; min-height: 52px; }
.quiz-q.latin { font-family: Georgia, serif; letter-spacing: 0; font-size: 34px; }
.quiz-opts, .chat-opts, .baby-btns { display: grid; gap: 10px; }
.opt { position: relative; padding: 15px 16px 15px 40px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 17px; text-align: left; transition: transform .08s; }
.opt small { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; }
.opt:active { transform: scale(.98); }
.opt.good { background: var(--green-soft); border-color: var(--green); }
.opt.bad { background: var(--red-soft); border-color: var(--red); animation: shake .3s; }
.quiz-fb { height: 26px; margin-top: 12px; text-align: center; font-weight: 700; }
.quiz-fb.g { color: var(--green); }
.quiz-fb.b { color: var(--red); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.run { flex: 1; display: flex; flex-direction: column; gap: 18px; padding-top: 10px; }
.run-track { position: relative; height: 46px; border-radius: 23px; background: repeating-linear-gradient(90deg, #e9dfcf 0 18px, #efe7da 18px 36px); }
.run-dot { position: absolute; top: 8px; left: 0; width: 30px; height: 30px; margin-left: -4px; border-radius: 50%; background: var(--red); box-shadow: 0 3px 8px rgba(200, 67, 43, .4); }
.run-gauge { position: relative; height: 16px; border-radius: 8px; background: var(--line); }
.run-zone { position: absolute; top: 0; bottom: 0; background: var(--green-soft); border: 2px solid var(--green); border-radius: 6px; }
.run-needle { position: absolute; top: -6px; width: 4px; height: 28px; margin-left: -2px; background: var(--ink); border-radius: 2px; transition: left .05s linear; }
.run-needle.ok { background: var(--green); }
.run-tip { text-align: center; color: var(--ink2); font-weight: 600; min-height: 24px; }
.run-btns { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.leg { padding: 30px 0; border-radius: 16px; background: var(--ink); color: #fff; font-size: 20px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.leg small { font-size: 11px; font-weight: 400; opacity: .6; }
.leg.hit { background: var(--red); transform: scale(.96); }

.chat { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.chat-who { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 10px; background: var(--paper); font-size: 13px; }
.chat-who b { font-size: 15px; }
.chat-who span { color: var(--ink2); }
.chat-log { flex: 1; min-height: 140px; max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 82%; padding: 9px 13px; border-radius: 14px; font-size: 15px; animation: rise .25s; }
.bubble.them { align-self: flex-start; background: #f0e9de; border-bottom-left-radius: 4px; }
.bubble.me { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.bubble.react { align-self: center; background: none; color: var(--muted); font-size: 12.5px; padding: 0; }
.chat-meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.chat-meter i { display: block; height: 100%; width: 50%; background: var(--red); transition: width .4s; }
.chat-opts .opt { font-size: 15px; padding-top: 12px; padding-bottom: 12px; }

.work-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cell { aspect-ratio: 1.15; border-radius: 12px; background: #f0e9de; display: grid; place-items: center; overflow: hidden; }
.cell.oops { background: var(--red-soft); animation: shake .3s; }
.task { width: 88%; height: 78%; border-radius: 10px; background: #fff; border: 2px solid var(--ink); font-weight: 700; font-size: 14px; animation: popin .18s; }
.task.trap { background: #fff4d8; border-color: var(--gold); color: #7a5a18; }
.task.pop { transform: scale(0); transition: transform .12s; }
@keyframes popin { from { transform: scale(.3); } to { transform: none; } }
.work-tip { margin-top: 14px; text-align: center; color: var(--muted); font-size: 13px; }

.stock-price { display: flex; justify-content: space-between; align-items: baseline; }
.stock-price b { font: 700 30px var(--serif); font-variant-numeric: tabular-nums; }
.stock-price span { font-weight: 600; }
.stock-price .up { color: var(--red); }
.stock-price .down { color: var(--green); }
.stock-chart { width: 100%; height: 170px; margin: 10px 0 16px; background: linear-gradient(#fff, #faf6ef); border: 1px solid var(--line); border-radius: 10px; }
.stock-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; }
.stock-btns button { padding: 20px 0; border-radius: 14px; color: #fff; font-size: 19px; font-weight: 700; }
.stock-btns .buy { background: var(--red); }
.stock-btns .sell { background: var(--green); }
.stock-btns button:active { transform: scale(.97); }

.baby { flex: 1; display: flex; flex-direction: column; }
.baby-face { text-align: center; padding: 8px 0 16px; }
.baby-head { position: relative; width: 96px; height: 96px; margin: 0 auto 10px; border-radius: 50%; background: #f7dcc8; }
.baby-head i { position: absolute; top: 38px; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.baby-head i:first-child { left: 26px; }
.baby-head i:nth-child(2) { right: 26px; }
.baby-head b { position: absolute; left: 50%; bottom: 20px; width: 26px; height: 12px; margin-left: -13px; border-radius: 0 0 14px 14px; background: #b34a3a; }
.baby-face.cry .baby-head b { height: 18px; border-radius: 50%; }
.baby-face.cry .baby-head i { height: 4px; border-radius: 2px; top: 42px; }
.baby-face.happy .baby-head { background: #fbe4d2; }
.baby-face.shake .baby-head { animation: shake .3s; }
.baby-need { font: 700 26px var(--serif); color: var(--red); }
.baby-face.happy .baby-need { color: var(--green); }
.baby-hint { color: var(--ink2); min-height: 24px; }
.baby-btns { grid-template-columns: 1fr 1fr; margin-top: auto; }
.baby-btns .opt { text-align: center; padding-left: 16px; }
.baby-btns .opt small { display: none; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- signature: nickname, family group, lineage ---------- */
.who .nick { display: inline-block; margin: 0 0 2px; color: var(--red); font: 600 12px var(--serif); }
.who .nick:empty { display: none; }
.who .meta { display: block; }
.sfx { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink2); font-size: 15px; }
.sfx.off { opacity: .35; text-decoration: line-through; }
.group { margin-top: 14px; border-radius: 12px; background: #ededed; overflow: hidden; font-family: var(--sans); animation: rise .35s; }
.group-h { padding: 8px 12px; background: #f7f7f7; border-bottom: 1px solid #ddd; text-align: center; font-size: 13px; font-weight: 600; color: #333; }
.gl { display: flex; gap: 8px; padding: 6px 10px; }
.gav { flex: none; width: 30px; height: 30px; border-radius: 6px; background: #8fb4d8; color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.gl:nth-child(3n) .gav { background: #d89a8f; }
.gl:nth-child(3n+1) .gav { background: #9bc49b; }
.gl small { display: block; font-size: 11px; color: #888; }
.gl p { margin: 1px 0 0; padding: 6px 10px; border-radius: 6px; background: #fff; font-size: 13.5px; color: #222; display: inline-block; }
.ln.chat { font-family: var(--sans); font-size: 12.5px; color: #5f7d5f; }
.ln.title { font-family: var(--sans); font-size: 13px; color: var(--red); font-weight: 600; }
.lineage { margin-top: 14px; padding: 10px 12px; border-radius: 8px; background: #f3ede2; text-align: left; font-size: 13px; }
.lineage p { margin: 4px 0 0; color: var(--ink2); }
.heirs { margin-top: 14px; padding: 12px; border-radius: 10px; border: 1px dashed var(--gold); display: grid; gap: 8px; text-align: left; }
.heirs small { color: var(--muted); }

.cands { display: grid; gap: 10px; margin-top: 12px; }
.cand { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.cand-h { display: flex; align-items: center; gap: 8px; }
.cand-h b { font: 700 17px var(--serif); }
.cand-tag { padding: 1px 8px; border-radius: 4px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; }
.cand-sub { margin: 4px 0 6px; color: var(--ink2); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.chips span { padding: 1px 7px; border-radius: 4px; background: var(--paper); font-size: 12px; color: var(--ink2); }
.chips.soft span { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.cand-intro { margin: 6px 0 4px; font-family: var(--serif); font-size: 14px; }
.cand-pitch { margin: 0; font-size: 13px; color: var(--ink2); }
.cand-red { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.cand-bad { margin: 4px 0 0; font-size: 12.5px; color: var(--red); font-weight: 600; }

/* ---------- pixel portraits ---------- */
.pav { display: inline-block; flex: none; line-height: 0; }
.pav canvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; border-radius: 10px; background: #efe5d4; }
.pav.av canvas { border-radius: 50%; background: #ece3d3; }
.pav.gav canvas { border-radius: 6px; background: #dfe7ef; }
.me-av { flex: none; }
.me-av canvas { border-radius: 12px; background: #efe5d4; box-shadow: inset 0 0 0 1px var(--line); }
.cand { position: relative; }
.cand-pics { float: right; margin: 0 0 6px 10px; text-align: center; }
.cand-pics small { display: block; font-size: 11px; color: var(--muted); }
.ev-pic { float: right; margin: 0 0 8px 12px; }
.ev-pic.mourn canvas, .obit-av canvas { filter: grayscale(1); }
.p-big { display: flex; justify-content: center; margin: 4px 0 10px; }
.obit-av { display: flex; justify-content: center; margin-top: 8px; }

/* ---------- 命格卡 ---------- */
.fgod { display: flex; justify-content: center; margin: 4px 0 2px; }
.fgod img { width: 72px; height: 72px; image-rendering: pixelated; }
.fcards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.fcard { position: relative; min-height: 196px; padding: 12px 8px 10px; border-radius: 12px; text-align: center; background-color: #fff; background-size: 100% 100%; image-rendering: pixelated; border: 2px solid var(--line); animation: flip .45s ease both; }
.fcards .fcard:nth-child(2) { animation-delay: .08s; }
.fcards .fcard:nth-child(3) { animation-delay: .16s; }
@keyframes flip { from { transform: rotateY(90deg) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.fcard.g-fan { border-color: #b57b45; background-color: #fbf1e4; }
.fcard.g-xian { border-color: #9aa7b8; background-color: #f1f4f8; }
.fcard.g-shen { border-color: #d6a92e; background-color: #fff6d8; box-shadow: 0 0 0 2px rgba(214, 169, 46, .25), 0 6px 18px rgba(214, 169, 46, .35); }
.fc-icon { display: flex; justify-content: center; align-items: center; height: 68px; }
.fc-icon img { width: 64px; height: 64px; image-rendering: pixelated; }
.fc-icon b { font: 700 34px var(--serif); color: var(--red); }
.fc-name { display: block; margin-top: 6px; font: 700 14.5px/1.3 var(--serif); }
.fc-grade { display: block; font-size: 11px; color: var(--muted); }
.fc-desc { margin: 6px 0 0; font-size: 12px; line-height: 1.45; color: var(--ink2); }
.fcards.pick { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.fpick { padding: 0; border-radius: 14px; }
.fpick.on .fcard { outline: 3px solid var(--red); outline-offset: 2px; }
.fate-h { margin-top: 16px !important; }
.fmini { display: flex; flex-wrap: wrap; gap: 6px; }
.fm { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 2px; border-radius: 6px; font-size: 12px; border: 1px solid var(--line); background: #fff; }
.fm img { width: 22px; height: 22px; image-rendering: pixelated; }
.fm.g-shen { border-color: #d6a92e; background: #fff6d8; }
.fm.g-xian { border-color: #9aa7b8; }
.fbond { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.fbond.on { color: #7a5a18; font-weight: 700; }
.opt.hint { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
@media (max-width: 420px) { .fcard { min-height: 188px; padding: 10px 5px; } .fc-desc { font-size: 11px; } }

.fcard.framed { padding: 8px 4px 8px; background: transparent; border: 0; box-shadow: none; min-height: 0; }
.fc-frame { position: relative; width: 100%; max-width: 116px; margin: 0 auto; aspect-ratio: 96 / 128; background-size: 100% 100%; image-rendering: pixelated; }
.fc-img { position: absolute; left: 16.6%; top: 12.5%; width: 66.7%; image-rendering: pixelated; }
.fc-frame .fc-name { position: absolute; left: 12%; right: 12%; top: 68%; height: 20%; display: flex; align-items: center; justify-content: center; margin: 0; font: 700 12px/1.15 var(--serif); color: #3a2c20; }
.fcard.framed.g-shen .fc-frame { filter: drop-shadow(0 4px 10px rgba(214, 169, 46, .45)); }
.fcard.framed .fc-grade { margin-top: 4px; }

.fc-wrap { text-align: center; }
.fc-god { width: 48px; height: 48px; image-rendering: pixelated; margin-bottom: -4px; }

/* ---------- 模式选择 ---------- */
.modes { display: grid; gap: 8px; margin: -14px 0 22px; text-align: left; }
.mode { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.mode b { display: block; font: 700 15px var(--serif); }
.mode small { color: var(--muted); font-size: 12px; }
.mode.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.mode[data-mode="easy"].on { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: #fff8e6; }
.mode[data-mode="hard"].on { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); background: #fdf0ec; }
.stat.luck i b { background: #c8432b; }
.stats { grid-template-columns: repeat(6, 1fr); }
.obit-hard { margin: 12px auto 0; display: inline-block; padding: 3px 12px; border: 2px solid var(--red); color: var(--red); font: 700 14px var(--serif); transform: rotate(-3deg); }

.quiz-tag { align-self: center; margin-top: 6px; padding: 2px 10px; border-radius: 999px; background: var(--paper); color: var(--muted); font-size: 12px; font-weight: 600; }
.quiz-tag.hard { background: var(--red); color: #fff; animation: tick .5s; }
.qian { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 10px; }
.qian-tube { position: relative; width: 90px; height: 170px; border: 4px solid #7a4a22; border-radius: 10px 10px 16px 16px; background: #f3dfb8; overflow: hidden; }
.qian-tube i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: repeating-linear-gradient(90deg, #c8432b 0 6px, #e0a24a 6px 12px); transition: height .1s; }
.qian-tube.wob { animation: shake .18s; }
.qian-tip { color: var(--ink2); margin: 0; }
.qian-btn { width: 100%; }

/* 神颜：闪光边框 */
.pav.ultra { position: relative; }
.pav.ultra canvas { box-shadow: 0 0 0 2px #f2c14e, 0 0 10px 2px rgba(242, 193, 78, .7); animation: glow 2.4s ease-in-out infinite; }
.pav.ultra::after { content: '神颜'; position: absolute; right: -4px; top: -6px; padding: 0 4px; border-radius: 4px; background: #f2c14e; color: #5a3a00; font: 700 9px/14px var(--sans); }
.pav.av.ultra::after, .pav.gav.ultra::after { display: none; }
@keyframes glow { 50% { box-shadow: 0 0 0 2px #ffe08a, 0 0 16px 4px rgba(255, 214, 102, .9); } }
