/* Đời Việt — phong cách hoạt hình: nền kem ấm, màu pastel, góc bo tròn to, viền mềm, bóng "nổi khối" kiểu đồ chơi.
   Bố cục: một cột kiểu ứng dụng điện thoại; đầu trang cố định, nội dung cuộn, nút +1 tuổi ở đáy. */
:root {
  --bg: #fff8ef;
  --bg-dot: #f6e7d6;
  --surface: #ffffff;
  --surface-2: #fdf3e9;
  --ink: #3a3150;
  --muted: #7a7090;
  --line: #efe3d6;
  --lam: #5a5fd6;          /* tím-xanh oải hương: màu chính */
  --lam-soft: #ecebff;
  --lam-deep: #4146b3;
  --son: #f0647c;          /* hồng san hô: nút chính */
  --son-deep: #c9445c;
  --son-ink: #ffffff;
  --vang: #c98a12;
  --vang-soft: #fff1c7;
  --good: #3fb98a;
  --warn: #f2a93b;
  --bad: #ef6b7b;
  --bubble: #f1eefc;
  --bubble-me: #7b80ec;
  --bubble-me-ink: #ffffff;
  --mint: #d4f1e4;
  --peach: #ffe0cc;
  --pink: #ffd6e0;
  --pink-ink: #a33a50;
  --mint-ink: #1f7a55;
  --vang-ink: #8a5d00;
  --shadow: 0 2px 0 rgba(58, 49, 80, 0.06), 0 10px 24px rgba(120, 90, 60, 0.10);
  --pop: 0 4px 0 var(--line);
  --f-display: 'Baloo 2', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r: 22px;
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1e1b2e; --bg-dot: #26223a; --surface: #2a2640; --surface-2: #322d4b; --ink: #f3eefe; --muted: #b3aacb; --line: #3e3858;
    --lam: #a3a8ff; --lam-soft: #37335a; --lam-deep: #7d83f0; --son: #ff8a9c; --son-deep: #d9637a; --son-ink: #2a1520;
    --vang: #ffd277; --vang-soft: #4a3f2a; --good: #74dcb0; --warn: #ffc56e; --bad: #ff8e9c;
    --bubble: #353054; --bubble-me: #6c71de; --bubble-me-ink: #ffffff; --mint: #2c4a42; --peach: #4b3a35; --pink: #4b3343; --pink-ink: #ffc2cf; --mint-ink: #a8ecd0; --vang-ink: #ffe2a0;
    --shadow: 0 2px 0 rgba(0, 0, 0, 0.25), 0 10px 26px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #1e1b2e; --bg-dot: #26223a; --surface: #2a2640; --surface-2: #322d4b; --ink: #f3eefe; --muted: #b3aacb; --line: #3e3858;
  --lam: #a3a8ff; --lam-soft: #37335a; --lam-deep: #7d83f0; --son: #ff8a9c; --son-deep: #d9637a; --son-ink: #2a1520;
  --vang: #ffd277; --vang-soft: #4a3f2a; --good: #74dcb0; --warn: #ffc56e; --bad: #ff8e9c;
  --bubble: #353054; --bubble-me: #6c71de; --bubble-me-ink: #ffffff; --mint: #2c4a42; --peach: #4b3a35; --pink: #4b3343; --pink-ink: #ffc2cf; --mint-ink: #a8ecd0; --vang-ink: #ffe2a0;
  --shadow: 0 2px 0 rgba(0, 0, 0, 0.25), 0 10px 26px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background-color: var(--bg); background-image: radial-gradient(var(--bg-dot) 2px, transparent 2.5px); background-size: 26px 26px; color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5; font-weight: 500; -webkit-font-smoothing: antialiased; }
* { box-sizing: border-box; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, [role='button']:focus-visible { outline: 3px solid var(--lam); outline-offset: 2px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }

#app { height: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; background: transparent; position: relative; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* dải lượn sóng pastel (thay cho hồi văn) */
.hoivan { height: 12px; background: linear-gradient(90deg, var(--pink), var(--peach), var(--vang-soft), var(--mint), var(--lam-soft), var(--pink));
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12' viewBox='0 0 24 12'%3E%3Cpath d='M0 6q6-6 12 0t12 0v6H0z' fill='black'/%3E%3C/svg%3E") repeat-x left bottom / 24px 12px;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12' viewBox='0 0 24 12'%3E%3Cpath d='M0 6q6-6 12 0t12 0v6H0z' fill='black'/%3E%3C/svg%3E") repeat-x left bottom / 24px 12px; }

/* ---------- nút chung: khối bo tròn, nhấn xuống như đồ chơi ---------- */
.btn { appearance: none; border: 2px solid var(--line); background: var(--surface); padding: 13px 18px; border-radius: 18px; cursor: pointer; font-weight: 800; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 12px; box-shadow: 0 4px 0 var(--line); transition: transform 0.15s var(--bounce), box-shadow 0.15s ease, border-color 0.15s ease; }
.btn:hover:not(:disabled) { border-color: var(--lam); transform: translateY(-2px); box-shadow: 0 6px 0 var(--line); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn small { font-weight: 600; color: var(--muted); }
.btn.primary { background: var(--son); color: var(--son-ink); border-color: var(--son); box-shadow: 0 4px 0 var(--son-deep); }
.btn.primary:hover:not(:disabled) { border-color: var(--son); box-shadow: 0 6px 0 var(--son-deep); }
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--son-deep); }
.btn.primary small { color: inherit; opacity: 0.9; }
.btn.lam { background: var(--lam); color: var(--surface); border-color: var(--lam); box-shadow: 0 4px 0 var(--lam-deep); }
.btn.lam small { color: inherit; opacity: 0.88; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- màn hình bắt đầu ---------- */
#start { overflow-y: auto; }
.start-wrap { padding-block: 36px 32px; display: flex; flex-direction: column; gap: 22px; }
.start-wrap > * { animation: rise 0.5s var(--bounce) both; }
.start-wrap > *:nth-child(2) { animation-delay: 0.05s; }
.start-wrap > *:nth-child(3) { animation-delay: 0.1s; }
.start-wrap > *:nth-child(4) { animation-delay: 0.15s; }
.start-wrap > *:nth-child(5) { animation-delay: 0.2s; }
.brand { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.brand .seal { width: 72px; height: 72px; border-radius: 26px; background: var(--pink); display: grid; place-items: center; font-size: 40px; line-height: 1; box-shadow: 0 5px 0 rgba(240, 100, 124, 0.35); animation: bob 3s ease-in-out infinite; }
.brand h1 { font-family: var(--f-display); font-weight: 800; font-size: clamp(44px, 12vw, 64px); line-height: 1; letter-spacing: -0.01em; color: var(--lam); text-shadow: 0 4px 0 var(--lam-soft); }
.brand p { margin: 0; color: var(--muted); max-width: 34ch; font-size: 16px; }
.qa { display: flex; flex-wrap: wrap; gap: 8px; }
.qa span { font-size: 13px; padding: 5px 12px; border-radius: 999px; font-weight: 700; background: var(--lam-soft); color: var(--lam-deep); }
.qa span:nth-child(4n + 2) { background: var(--pink); color: var(--pink-ink); }
.qa span:nth-child(4n + 3) { background: var(--mint); color: var(--mint-ink); }
.qa span:nth-child(4n + 4) { background: var(--vang-soft); color: var(--vang-ink); }
.start-actions { display: flex; flex-direction: column; gap: 12px; }
.form { display: grid; gap: 12px; background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 700; }
.form input, .form select { font: inherit; color: var(--ink); background: var(--surface-2); border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; min-width: 0; transition: border-color 0.15s ease; }
.form input:focus, .form select:focus { border-color: var(--lam); }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ach-shelf { display: flex; flex-direction: column; gap: 8px; }
.ach-shelf h3 { font-family: var(--f-display); font-size: 16px; color: var(--ink); font-weight: 700; }
.ach-list { display: flex; flex-wrap: wrap; gap: 6px; }
.ach { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 2px dashed var(--line); color: var(--muted); font-weight: 600; }
.ach.on { border-style: solid; border-color: transparent; background: var(--vang-soft); color: var(--vang); font-weight: 800; }
.foot { font-size: 12px; color: var(--muted); }

/* ---------- đầu trang trong game ---------- */
.top { background: var(--surface); border-bottom: 0; border-radius: 0 0 28px 28px; box-shadow: var(--shadow); padding-block: 12px 8px; display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 2; }
.who { display: flex; align-items: center; gap: 12px; }
.avatar { width: 54px; height: 54px; border-radius: 20px; flex: none; background: var(--pink); display: grid; place-items: center; font-size: 32px; line-height: 1; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.06); animation: bob 3.2s ease-in-out infinite; }
.who .meta { min-width: 0; flex: 1; }
.who .nm { font-family: var(--f-display); font-size: 21px; font-weight: 800; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .sub { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.purse { text-align: right; flex: none; background: var(--vang-soft); border-radius: 16px; padding: 6px 12px; }
.purse .v { font-family: var(--f-display); font-weight: 800; font-variant-numeric: tabular-nums; font-size: 17px; line-height: 1.2; color: var(--vang); }
.purse .v::before { content: '🪙 '; }
.purse .v.neg { color: var(--bad); }
.purse .l { font-size: 11px; color: var(--muted); font-weight: 700; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 16px; }
.stat { display: grid; grid-template-columns: 92px 1fr 26px; align-items: center; gap: 8px; font-size: 12.5px; }
.stat .n { color: var(--muted); white-space: nowrap; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.stat .si { font-style: normal; font-size: 13px; }
.stat.vn .n { color: var(--vang); }
.stat .b { height: 10px; border-radius: 99px; background: var(--surface-2); border: 0; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06); }
.stat .b i { display: block; height: 100%; border-radius: inherit; transition: width 0.6s var(--bounce), background-color 0.4s ease; background-image: linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 60%); }
.stat .x { font-variant-numeric: tabular-nums; text-align: right; font-weight: 800; }
.toggle-stats { appearance: none; border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; padding: 0; align-self: flex-start; }

.tabs { display: flex; gap: 6px; background: transparent; border-bottom: 0; padding-block: 10px 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { appearance: none; border: 2px solid transparent; background: var(--surface); padding: 7px 12px; font-size: 13.5px; font-weight: 800; color: var(--muted); cursor: pointer; border-radius: 999px; white-space: nowrap; position: relative; display: inline-flex; align-items: center; gap: 5px; box-shadow: 0 3px 0 var(--line); transition: transform 0.15s var(--bounce), background-color 0.2s ease, color 0.2s ease; }
.tab:hover { transform: translateY(-1px); }
.tab .ti { font-size: 15px; line-height: 1; }
.tab[aria-selected='true'] { color: var(--surface); background: var(--lam); box-shadow: 0 3px 0 var(--lam-deep); }
.tab .dot { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; background: var(--son); color: var(--son-ink); font-size: 11px; margin-left: 2px; animation: pulse 1.6s ease-in-out infinite; }

.pane { flex: 1; min-height: 0; overflow-y: auto; padding-block: 10px 24px; overscroll-behavior: contain; }
.pane > .gutter { animation: fade 0.25s ease-out; }

/* ---------- nhật ký ---------- */
.year { display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 12px 14px 12px 10px; margin-bottom: 10px; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); border: 0; }
.year:last-child { animation: rise 0.45s var(--bounce) both; }
.yr-age { text-align: center; }
.yr-age b { display: grid; place-items: center; margin: 0 auto; width: 44px; height: 44px; border-radius: 50%; background: var(--lam-soft); font-family: var(--f-display); font-size: 21px; font-weight: 800; line-height: 1; color: var(--lam-deep); }
.year:nth-child(4n + 1) .yr-age b { background: var(--pink); color: var(--pink-ink); }
.year:nth-child(4n + 2) .yr-age b { background: var(--mint); color: var(--mint-ink); }
.year:nth-child(4n + 3) .yr-age b { background: var(--vang-soft); color: var(--vang-ink); }
.yr-age span { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.items { display: flex; flex-direction: column; gap: 7px; min-width: 0; justify-content: center; }
.it { font-size: 14.5px; }
.it.q { color: var(--muted); font-size: 13.5px; }
.it .c { display: inline-block; font-weight: 800; color: var(--lam); margin-right: 4px; }
.it.sys { color: var(--muted); }
.it.money { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.it.good { color: var(--good); font-weight: 700; }
.it.bad { color: var(--bad); font-weight: 700; }
.it.rumor { font-style: italic; color: var(--warn); }
.it.ach { font-weight: 800; color: var(--vang); }
.fx { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 4px; vertical-align: 1px; }
.fx span { font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); border: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fx .up { color: var(--mint-ink); background: var(--mint); }
.fx .dn { color: var(--pink-ink); background: var(--pink); }
.empty { color: var(--muted); text-align: center; padding: 32px 12px; font-size: 14px; font-weight: 600; }

/* ---------- hoạt động ---------- */
.card { background: var(--surface); border: 0; border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.status { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0 0 16px; }
.status div { min-width: 0; }
.status dt { font-size: 12px; color: var(--muted); font-weight: 700; }
.status dd { margin: 0; font-weight: 800; font-size: 14px; }
.sec-h { font-family: var(--f-display); font-size: 17px; color: var(--ink); font-weight: 700; margin: 20px 0 8px; display: flex; align-items: center; gap: 8px; }
.sec-h::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--son); box-shadow: 14px 0 0 var(--warn), 28px 0 0 var(--good); margin-right: 30px; flex: none; }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.act { appearance: none; text-align: left; border: 2px solid var(--line); background: var(--surface); border-radius: 18px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; box-shadow: 0 4px 0 var(--line); transition: transform 0.15s var(--bounce), box-shadow 0.15s ease, border-color 0.15s ease; }
.act:hover:not(:disabled) { border-color: var(--lam); transform: translateY(-2px); box-shadow: 0 6px 0 var(--lam-soft); }
.act:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.act:disabled { opacity: 0.45; cursor: not-allowed; }
.act b { font-size: 14.5px; font-weight: 800; }
.act span { font-size: 12.5px; color: var(--muted); }
.act .cost { align-self: flex-start; margin-top: 3px; font-size: 11px; color: var(--lam-deep); background: var(--lam-soft); padding: 1px 8px; border-radius: 99px; font-weight: 800; }

.jobs { display: flex; flex-direction: column; gap: 8px; }
.job { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 12px 14px; border: 2px solid var(--line); border-radius: 18px; background: var(--surface); }
.job .jn { font-weight: 800; font-size: 14.5px; }
.job .jp { font-size: 12px; color: var(--muted); grid-column: 1; }
.job .jw { font-size: 12px; color: var(--bad); font-weight: 700; grid-column: 1; }
.job button { grid-row: 1 / span 4; grid-column: 2; }
.job .jl { font-size: 11px; color: var(--muted); grid-column: 1; }
.status .wide { grid-column: 1 / -1; }
.mini { appearance: none; border: 2px solid var(--lam); color: var(--lam-deep); background: var(--surface); border-radius: 999px; padding: 5px 14px; font-size: 13px; font-weight: 800; cursor: pointer; white-space: nowrap; box-shadow: 0 3px 0 var(--lam-soft); transition: transform 0.15s var(--bounce), box-shadow 0.15s ease; }
.mini:hover:not(:disabled) { transform: translateY(-1px); }
.mini:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--lam-soft); }
.mini:disabled { border-color: var(--line); color: var(--muted); cursor: not-allowed; box-shadow: none; }
.mini.solid { background: var(--lam); color: var(--surface); box-shadow: 0 3px 0 var(--lam-deep); }

/* ---------- quan hệ ---------- */
.people { display: flex; flex-direction: column; gap: 10px; }
.person { background: var(--surface); border: 0; border-radius: 20px; padding: 10px 12px; display: grid; gap: 8px; box-shadow: var(--shadow); transition: transform 0.2s var(--bounce); }
.person:hover { transform: translateY(-1px); }
.person.dead { opacity: 0.6; filter: grayscale(0.6); }
.person .ph { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.person .pa { width: 44px; height: 44px; border-radius: 16px; background: var(--lam-soft); display: grid; place-items: center; font-size: 26px; line-height: 1; flex: none; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.06); }
.person .ph:hover .pa { animation: wiggle 0.5s ease-in-out; }
.person .pm { min-width: 0; flex: 1; }
.person .pr { font-size: 12px; color: var(--muted); font-weight: 600; }
.person .pn { font-weight: 800; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .cl { width: 76px; flex: none; }
.person .cl .b { height: 8px; border-radius: 99px; background: var(--surface-2); border: 0; overflow: hidden; }
.person .cl i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffb3c1, var(--son)); transition: width 0.6s var(--bounce); }
.person .cl span { font-size: 10.5px; color: var(--muted); font-weight: 700; }
.person .cl span::before { content: '💗 '; }
.person .pacts { display: flex; flex-wrap: wrap; gap: 6px; animation: rise 0.3s var(--bounce) both; }

/* ---------- nhóm chat ---------- */
.chat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; background: var(--surface); padding: 10px 12px; border-radius: 20px; box-shadow: var(--shadow); }
.chat-head .ga { width: 44px; height: 44px; border-radius: 16px; background: var(--peach); display: grid; place-items: center; font-size: 24px; }
.chat-head b { display: block; font-family: var(--f-display); font-size: 17px; font-weight: 800; }
.chat-head span { font-size: 12px; color: var(--muted); font-weight: 600; }
.msgs { display: flex; flex-direction: column; gap: 6px; }
.sep { align-self: center; font-size: 11px; color: var(--muted); font-weight: 700; margin: 8px 0 2px; background: var(--surface); padding: 2px 10px; border-radius: 99px; }
.msg { max-width: 82%; display: flex; flex-direction: column; gap: 2px; }
.msg .mn { font-size: 11.5px; color: var(--lam); font-weight: 800; padding-left: 12px; }
.msg .mb { background: var(--surface); padding: 9px 14px; border-radius: 20px 20px 20px 6px; font-size: 14px; overflow-wrap: anywhere; box-shadow: 0 2px 0 var(--line); }
.msg.me { align-self: flex-end; }
.msg.me .mn { display: none; }
.msg.me .mb { background: var(--bubble-me); color: var(--bubble-me-ink); border-radius: 20px 20px 6px 20px; box-shadow: 0 2px 0 var(--lam-deep); }
.msg.sys { align-self: center; max-width: 92%; }
.msg.sys .mb { background: none; border: 2px dashed var(--line); box-shadow: none; color: var(--muted); font-size: 12.5px; text-align: center; }
.msg:last-child { animation: rise 0.35s var(--bounce) both; }
.chat-act { margin-top: 14px; }

/* ---------- miệng đời ---------- */
.board { display: flex; flex-direction: column; gap: 12px; }
.note { background: var(--vang-soft); border: 0; border-radius: 6px 22px 22px 22px; padding: 14px 16px; display: grid; gap: 8px; box-shadow: var(--shadow); position: relative; }
.note:nth-child(even) { background: var(--pink); }
.note:nth-child(3n) { background: var(--mint); }
.note::before { content: '🗨️'; position: absolute; top: -10px; right: 12px; font-size: 20px; }
.note q { font-style: italic; font-size: 15px; font-weight: 700; color: var(--ink); quotes: '“' '”'; }
.note .nr { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); font-weight: 600; }
.lede { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; }

/* ---------- thanh dưới ---------- */
.bar { background: var(--surface); border-top: 0; border-radius: 28px 28px 0 0; box-shadow: 0 -6px 24px rgba(120, 90, 60, 0.10); padding-block: 12px calc(12px + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; gap: 14px; position: relative; z-index: 2; }
.tp { flex: 1; min-width: 0; }
.tp .l { font-size: 12px; color: var(--muted); font-weight: 700; }
.tp .dots { display: flex; gap: 4px; margin-top: 5px; }
.tp .dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--warn); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12); transition: transform 0.25s var(--bounce), background-color 0.2s ease; }
.tp .dots i.off { background: var(--line); box-shadow: none; transform: scale(0.75); }
.age-btn { appearance: none; border: 0; background: var(--son); color: var(--son-ink); font-family: var(--f-display); font-weight: 800; font-size: 21px; padding: 10px 26px 8px; border-radius: 999px; cursor: pointer; box-shadow: 0 5px 0 var(--son-deep), 0 10px 20px rgba(240, 100, 124, 0.3); white-space: nowrap; transition: transform 0.15s var(--bounce), box-shadow 0.15s ease; animation: breathe 2.4s ease-in-out infinite; }
.age-btn::before { content: '🎂 '; }
.age-btn:hover:not(:disabled) { transform: translateY(-2px) scale(1.03); }
.age-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--son-deep); animation: none; }
.age-btn:disabled { opacity: 0.5; cursor: not-allowed; animation: none; }

/* ---------- hộp sự kiện ---------- */
.modal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; background: rgba(58, 49, 80, 0.45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade 0.2s ease-out; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.sheet { width: 100%; max-width: 528px; max-height: 100%; overflow-y: auto; background: var(--surface); border-radius: 30px; box-shadow: 0 8px 0 rgba(0, 0, 0, 0.08), 0 20px 50px rgba(58, 49, 80, 0.3); display: flex; flex-direction: column; animation: pop 0.38s var(--bounce); }
.sheet .hoivan { flex: none; height: 16px; background-color: var(--lam-soft); }
.sheet-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.eyebrow { align-self: flex-start; font-size: 12px; color: var(--son-deep); background: var(--pink); padding: 3px 12px; border-radius: 99px; font-weight: 800; }
.sheet h2 { font-family: var(--f-display); font-size: 22px; line-height: 1.3; font-weight: 700; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice { appearance: none; text-align: left; border: 2px solid var(--line); background: var(--surface); border-radius: 18px; padding: 13px 16px; cursor: pointer; font-weight: 800; font-size: 14.5px; display: flex; justify-content: space-between; gap: 10px; box-shadow: 0 4px 0 var(--line); transition: transform 0.15s var(--bounce), box-shadow 0.15s ease, border-color 0.15s ease, background-color 0.15s ease; animation: rise 0.35s var(--bounce) both; }
.choice:nth-child(2) { animation-delay: 0.05s; }
.choice:nth-child(3) { animation-delay: 0.1s; }
.choice:nth-child(4) { animation-delay: 0.15s; }
.choice:nth-child(n + 5) { animation-delay: 0.2s; }
.choice:hover:not(:disabled) { border-color: var(--lam); background: var(--lam-soft); transform: translateY(-2px); box-shadow: 0 6px 0 var(--lam-soft); }
.choice:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.choice:disabled { opacity: 0.5; cursor: not-allowed; }
.choice small { font-weight: 600; color: var(--muted); white-space: nowrap; }
.result { background: var(--lam-soft); border-radius: 20px; padding: 14px 16px; font-size: 15px; animation: pop 0.4s var(--bounce); }
.result .fx { margin-left: 0; margin-top: 6px; display: flex; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 40; background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 700; max-width: min(92vw, 480px); box-shadow: var(--shadow); animation: toast 0.4s var(--bounce); }

/* ---------- cáo phó ---------- */
#death { overflow-y: auto; }
.death-wrap { padding-block: 24px 32px; display: flex; flex-direction: column; gap: 18px; }
.obit { background: var(--surface); border: 3px dashed var(--line); outline: 0; border-radius: 28px; padding: 24px 20px; text-align: center; display: flex; flex-direction: column; gap: 10px; margin: 0; box-shadow: var(--shadow); animation: pop 0.5s var(--bounce); }
.obit::before { content: '🕊️'; font-size: 40px; line-height: 1; animation: bob 3s ease-in-out infinite; }
.obit .t { font-family: var(--f-display); letter-spacing: 0.25em; font-size: 15px; font-weight: 800; color: var(--muted); }
.obit .nm { font-family: var(--f-display); font-size: 30px; font-weight: 800; line-height: 1.2; color: var(--lam); }
.obit .yrs { color: var(--muted); font-size: 14px; font-weight: 600; }
.obit .verdict { align-self: center; font-family: var(--f-display); font-weight: 700; color: var(--son-deep); background: var(--pink); padding: 4px 16px; border-radius: 99px; font-size: 18px; }
.obit .eu { text-align: left; font-size: 14.5px; display: flex; flex-direction: column; gap: 6px; border-top: 2px dashed var(--line); padding-top: 12px; }
.obit .eu p { margin: 0; }
.scores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.score { background: var(--surface); border: 0; border-radius: 20px; padding: 10px 8px; text-align: center; box-shadow: var(--shadow); }
.score:nth-child(4n + 1) { background: var(--lam-soft); }
.score:nth-child(4n + 2) { background: var(--mint); }
.score:nth-child(4n + 3) { background: var(--vang-soft); }
.score:nth-child(4n + 4) { background: var(--pink); }
.score b { display: block; font-family: var(--f-display); font-size: 26px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--ink); }
.score span { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.lineage { display: flex; flex-direction: column; gap: 6px; }
.lineage li { list-style: none; display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: baseline; font-size: 14px; }
.lineage li span { font-family: var(--f-display); color: var(--lam); font-weight: 800; }
.lineage ul { margin: 0; padding: 0; display: grid; gap: 6px; }
.heirs { display: flex; flex-direction: column; gap: 12px; }

@media (max-width: 420px) {
  .stat { grid-template-columns: 84px 1fr 22px; gap: 6px; font-size: 12px; }
  .stats { gap: 6px 12px; }
  .acts { grid-template-columns: 1fr; }
  .scores { grid-template-columns: repeat(2, 1fr); }
  .form .row2 { grid-template-columns: 1fr; }
}
@media (max-width: 360px) {
  .stat .si { display: none; }
  .stat { grid-template-columns: 66px 1fr 22px; }
}

/* ---------- liên kết đầu trang ---------- */
.top-links { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.top-links .toggle-stats { margin: 0; }
.top-links span { display: flex; gap: 4px; }
.link { appearance: none; border: 0; background: var(--surface-2); color: var(--lam-deep); font-size: 12.5px; font-weight: 800; padding: 5px 12px; cursor: pointer; border-radius: 99px; transition: background-color 0.15s ease; }
.link:hover { background: var(--lam-soft); }
.ach-shelf .mini { align-self: flex-start; }

/* ---------- gia phả ---------- */
.tree { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tree .gen { display: grid; grid-template-columns: 40px 1fr; gap: 12px; position: relative; padding-bottom: 14px; }
.tree .gen:not(:last-child)::before { content: ''; position: absolute; left: 18px; top: 40px; bottom: 0; width: 0; border-left: 4px dotted var(--line); }
.tree .gn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--lam-soft); border: 0; color: var(--lam-deep); font-family: var(--f-display); font-weight: 800; z-index: 1; }
.tree .gen.now .gn { background: var(--son); color: var(--son-ink); box-shadow: 0 3px 0 var(--son-deep); }
.tree .gc { background: var(--surface-2); border: 0; border-radius: 18px; padding: 10px 14px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tree .gname { font-family: var(--f-display); font-size: 18px; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.tree .gname .sp { font-family: var(--f-body); font-size: 13.5px; font-weight: 600; color: var(--muted); }
.tree .gmeta { font-size: 13px; color: var(--muted); }
.tree .gv { font-family: var(--f-display); font-weight: 700; color: var(--son-deep); font-size: 14.5px; }
.tree .kids { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tree .kid { font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 2px solid var(--line); display: inline-flex; gap: 5px; align-items: baseline; }
.tree .kid small { color: var(--muted); font-size: 11px; }
.tree .kid.heir { border-color: transparent; background: var(--vang-soft); color: var(--vang); font-weight: 800; }
.tree .kid.gone { opacity: 0.55; text-decoration: line-through; }

/* ---------- thành tựu ---------- */
.prog { height: 12px; border-radius: 999px; background: var(--surface-2); border: 0; overflow: hidden; }
.prog i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffd36e, var(--warn)); transition: width 0.6s var(--bounce); }
.achs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.achv { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: start; padding: 10px 12px; border: 2px dashed var(--line); border-radius: 18px; color: var(--muted); }
.achv.on { border-style: solid; border-color: transparent; color: var(--ink); background: var(--vang-soft); }
.achv .am { font-size: 24px; line-height: 1.3; text-align: center; }
.achv:not(.on) .am { filter: grayscale(1); opacity: 0.6; }
.achv b { display: block; font-weight: 800; }
.achv span { display: block; font-size: 13.5px; }
.achv small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- ảnh cáo phó ---------- */
.card-prev { background: var(--surface-2); border: 0; border-radius: 20px; padding: 10px; display: grid; place-items: center; min-height: 180px; }
.card-prev img { display: block; width: 100%; max-width: 360px; height: auto; border-radius: 14px; box-shadow: var(--shadow); }
a.btn { text-decoration: none; color: var(--ink); }
a.btn.primary { color: var(--son-ink); }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

/* ---------- hiệu ứng nhẹ ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(30px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-4px) rotate(2deg); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 16px) scale(0.9); } to { opacity: 1; transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
