/* ============================================================
   1 ใน 14,000,605 — style
   dark theme, mobile-first
   ============================================================ */
:root {
  --bg: #0b0b0f;
  --bg-2: #101016;
  --card: #15151c;
  --card-2: #1b1b24;
  --border: #2a2a35;
  --border-2: #3a3a48;
  --text: #f2f2f5;
  --muted: #9a9aa8;
  --accent: #e8456b;
  --accent-2: #ff6f8e;
  --accent-soft: rgba(232, 69, 107, .14);
  --gold: #f5c542;
  --gold-soft: rgba(245, 197, 66, .12);
  --sel-bg: #e9eeec;
  --sel-text: #0b0b0f;

  --c-health: #4cd28a;
  --c-happy: #ffb347;
  --c-chaos: #a970ff;
  --c-money: #4fb3ff;
  --c-fame: #e8456b;

  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 16px;
  --font: 'Prompt', 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img, canvas { max-width: 100%; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 600; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.accent { color: var(--accent); }
.gold-text { color: var(--gold); }
.h-sm { font-size: 15px; font-weight: 600; }
.h-md { font-size: 20px; }

.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 8px; top: 8px; z-index: 100; background: var(--card); padding: 8px 12px; border-radius: 8px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(11, 11, 15, .86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 54px; }
.brand { color: var(--text); font-weight: 700; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700;
}
.topnav { display: flex; gap: 4px; align-items: center; }
.topnav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: 14px; white-space: nowrap; }
.topnav a:hover { color: var(--text); background: var(--card); text-decoration: none; }
.topnav .topnav-cta { background: var(--accent); color: #fff; font-weight: 600; }
.topnav .topnav-cta:hover { background: var(--accent-2); color: #fff; }
@media (max-width: 380px) {
  .brand { font-size: 13px; }
  .topnav a { padding: 6px 7px; font-size: 13px; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--card-2); color: var(--text);
  font-size: 14px; font-weight: 500; line-height: 1.3;
  text-align: center; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .08s, opacity .15s;
  max-width: 100%;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-outline { background: transparent; border-color: var(--border-2); }
.btn-outline:hover { border-color: var(--muted); background: var(--card); }
.btn-outline-accent { background: transparent; border-color: var(--accent); color: var(--accent-2); border-radius: 999px; }
.btn-outline-accent:hover { background: var(--accent-soft); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--card); }
.btn-gold { background: var(--gold); color: #1a1405; font-weight: 600; }
.btn-gold:hover { filter: brightness(1.08); }
.btn-lg { min-height: 48px; padding: 10px 24px; font-size: 16px; }
.btn-xs { min-height: 30px; padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.music-toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-2); background: var(--accent-soft); }

.btn-born {
  min-width: 132px; min-height: 64px; padding: 12px 32px;
  border: 0; border-radius: 6px;
  background: #e0607f;
  background: linear-gradient(180deg, #ee6d8c, var(--accent));
  color: #2a0a12; font-size: 22px; font-weight: 600; letter-spacing: .5px;
  box-shadow: 0 8px 28px rgba(232, 69, 107, .28);
  transition: transform .1s, filter .15s, box-shadow .15s;
}
.btn-born:hover { filter: brightness(1.06); box-shadow: 0 10px 34px rgba(232, 69, 107, .4); }
.btn-born:active { transform: scale(.98); }
.btn-born[disabled] { opacity: .6; cursor: progress; }
.btn-born-wide { width: 100%; }

/* ---------- segmented (button group like reference) ---------- */
.seg {
  display: inline-flex; flex-wrap: wrap; max-width: 100%;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--bg-2);
}
.seg button {
  border: 0; background: transparent; color: var(--text);
  padding: 9px 14px; font-size: 14px; line-height: 1.3;
  box-shadow: 1px 0 0 var(--border-2), 0 1px 0 var(--border-2);
  transition: background .15s, color .15s;
  flex: 1 1 auto; white-space: nowrap;
}
.seg button:hover { background: var(--card-2); }
.seg button.active { background: var(--sel-bg); color: var(--sel-text); font-weight: 500; }
.seg-sm button { padding: 6px 12px; font-size: 13px; }

/* ---------- tabs ---------- */
.tabs-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); max-width: 100%; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 6px 10px; margin-right: 10px; font-size: 15px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- hero ---------- */
.hero {
  padding: 44px 0 36px;
  background:
    radial-gradient(800px 320px at 15% -10%, rgba(232, 69, 107, .18), transparent 70%),
    radial-gradient(600px 300px at 100% 0%, rgba(245, 197, 66, .07), transparent 70%);
  border-bottom: 1px solid var(--border);
}
.hero-kicker { color: var(--muted); font-size: 13px; letter-spacing: .5px; margin-bottom: 6px; }
.hero-title { font-size: clamp(40px, 11vw, 84px); font-weight: 700; letter-spacing: -1px; line-height: 1.05; }
.hero-sub { margin-top: 12px; font-size: clamp(15px, 3.8vw, 19px); color: #d6d6de; max-width: 640px; }
.hero-stats { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 24px; }
.hero-stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px;
}
.hero-stat-label { color: var(--muted); font-size: 14px; }
.hero-stat-num { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1.1; }
.hero-stat-num.small { font-size: 24px; }
.hero-stat.gold { border-color: rgba(245, 197, 66, .35); background: linear-gradient(180deg, var(--gold-soft), var(--card)); }
.hero-stat.gold .hero-stat-num { color: var(--gold); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
@media (min-width: 720px) {
  .hero { padding: 64px 0 48px; }
  .hero-stats { grid-template-columns: 1.4fr 1fr 1fr; }
  .hero-stat { flex-direction: column; gap: 2px; }
  .hero-stat-num { font-size: 40px; }
  .hero-stat-num.small { font-size: 32px; }
}

/* feed ticker */
.feed { margin-top: 22px; display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 13px; }
.feed-label { flex: none; color: var(--accent-2); font-weight: 500; }
.feed-window { flex: 1; min-width: 0; overflow: hidden; height: 22px; position: relative; }
.feed-track { position: absolute; left: 0; top: 0; width: 100%; transition: transform .5s ease; }
.feed-item { height: 22px; line-height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.feed-item b { color: var(--text); font-weight: 500; }

/* ---------- sections ---------- */
.section { padding: 40px 0; border-bottom: 1px solid var(--border); }
.section-head { margin-bottom: 18px; }
.section-head h2 { font-size: 22px; margin-bottom: 6px; }
.section-foot { margin-top: 18px; }
.section-gold { background: linear-gradient(180deg, rgba(245, 197, 66, .04), transparent 60%); }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 22px 0 16px; }

/* ---------- board ---------- */
.board-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 720px) { .board-grid { grid-template-columns: 1fr 1fr; column-gap: 28px; } }
@media (min-width: 1040px) { .board-grid { grid-template-columns: 1fr 1fr 1fr; } }
.entry {
  border-top: 1px solid var(--border); padding: 16px 0 18px;
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
  animation: fadeUp .35s ease both;
}
.entry-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.entry-rank {
  flex: none; display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: 6px; background: var(--card-2); color: var(--muted); font-size: 13px; font-weight: 600;
  align-self: center;
}
.entry-rank.r1 { background: var(--gold); color: #1a1405; }
.entry-rank.r2 { background: #cfd3dc; color: #111; }
.entry-rank.r3 { background: #c98a54; color: #1a0e05; }
.entry-name { font-weight: 600; font-size: 16px; }
.entry-meta { color: var(--muted); font-size: 13px; }
.entry-title { color: var(--accent-2); font-size: 14px; font-weight: 500; }
.entry-death { color: #cfcfd8; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.entry-caption { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.entry-caption::before { content: '“'; } .entry-caption::after { content: '”'; }
.entry-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.entry-stats b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.entry-stats .votes b { color: var(--accent-2); }
.entry-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.entry-actions .spacer { flex: 1; }
.btn-vote-free { border-radius: 999px; }
.tip { position: relative; }
.tip[data-tip]:hover::after, .tip[data-tip]:focus::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 0;
  background: #000; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 5;
  border: 1px solid var(--border-2);
}
.free-vote-note {
  background: var(--accent-soft); border: 1px solid rgba(232, 69, 107, .4); color: #ffd3dd;
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; font-size: 14px;
}
.empty, .loading, .error-box {
  grid-column: 1 / -1; color: var(--muted); padding: 28px 16px; text-align: center;
  border: 1px dashed var(--border-2); border-radius: var(--radius); font-size: 14px;
}
.error-box { color: #ffb3c2; border-color: rgba(232, 69, 107, .4); }
.loading::after { content: ''; display: inline-block; width: 1em; animation: dots 1.2s steps(4) infinite; text-align: left; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- true story list ---------- */
.ts-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.ts-item {
  background: var(--card); border: 1px solid rgba(245, 197, 66, .22); border-radius: var(--radius);
  padding: 12px 16px; display: grid; gap: 4px; animation: fadeUp .35s ease both; min-width: 0;
}
.ts-item-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.ts-item-name { color: var(--gold); font-weight: 600; }
.ts-item-msg { overflow-wrap: anywhere; }
.ts-item-meta { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }

/* ---------- birth settings ---------- */
.section-birth { border-bottom: 0; }
.settings { display: grid; gap: 26px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .settings { grid-template-columns: 1.3fr 1fr; gap: 36px; } }
.setting { min-width: 0; }
.setting-label { font-size: 14px; font-weight: 500; color: #d6d6de; margin-bottom: 10px; }
.setting-desc { color: var(--muted); font-size: 13px; margin-top: 8px; max-width: 520px; }
.birth-card {
  margin-top: 28px; padding: 18px; border-radius: var(--radius);
  background: linear-gradient(135deg, #17171f, #13131a); border: 1px solid var(--border);
  display: grid; gap: 14px; max-width: 520px;
}
.birth-card-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.birth-parent { display: flex; flex-direction: column; min-width: 70px; }
.birth-parent strong { font-size: 20px; }
.birth-plus { color: var(--accent); font-size: 22px; font-weight: 300; }
.birth-baby { display: flex; flex-direction: column; border-top: 1px solid var(--border); padding-top: 12px; }
.birth-baby strong { font-size: 26px; color: var(--accent-2); }
.birth-card.born .birth-baby strong { animation: pop .6s ease; }
.birth-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); }
.birth-hint { max-width: 220px; }
@media (max-width: 520px) {
  .birth-actions .btn-born { width: 100%; }
  .birth-hint { max-width: none; width: 100%; }
  .birth-actions .btn { flex: 1 1 auto; }
}

.birth-where { border-top: 1px solid var(--border); padding-top: 10px; }

/* ---------- birth certificate (การแจ้งเกิด) ---------- */
.cert-wrap { padding-top: 22px; padding-bottom: 48px; max-width: 760px; }
.cert {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45); animation: certIn .5s cubic-bezier(.2, .8, .2, 1) both; min-width: 0;
}
@keyframes certIn { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }
.cert-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: #e2698b; color: #2a0a12; padding: 14px 18px;
}
.cert-title { font-size: 17px; font-weight: 600; }
.cert-no { font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; font-size: 12.5px; letter-spacing: .5px; overflow-wrap: anywhere; }
.cert-body { padding: 18px 18px 20px; display: grid; gap: 12px; min-width: 0; }
@media (min-width: 640px) { .cert-body { padding: 22px 24px 24px; } .cert-head { padding: 16px 24px; } }
.cert-label { color: var(--muted); font-size: 12.5px; }
.cert-name { font-size: clamp(32px, 9vw, 46px); font-weight: 700; line-height: 1.1; margin-top: -6px; overflow-wrap: anywhere; }
.cert-story { color: #d6d6de; font-size: 15.5px; overflow-wrap: anywhere; }
.cert-note { color: var(--muted); font-size: 12.5px; padding-bottom: 12px; border-bottom: 1px dashed var(--border-2); }
.cert-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 16px; margin: 4px 0 0; }
@media (min-width: 640px) { .cert-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 22px; } }
.cert-grid > div { min-width: 0; }
.cert-grid dt { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.cert-grid dd { margin: 0; font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere; line-height: 1.45; }
.cert-grid .wide { grid-column: 1 / -1; }
@media (min-width: 640px) { .cert-grid .wide { grid-column: auto; } }
.tier-dots { color: var(--accent-2); letter-spacing: 1px; white-space: nowrap; }
.tier-dots .off { color: #4a4a58; }
.cert-odds {
  background: rgba(76, 210, 138, .07); border: 1px solid rgba(76, 210, 138, .22); color: #cfeedd;
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13.5px; overflow-wrap: anywhere;
}
.cert-odds b { color: #fff; }
.cert-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.cert-actions .btn { min-height: 52px; padding: 10px 22px; font-size: 15.5px; }
.cert-start { font-weight: 600; min-width: 150px; background: #e2698b; color: #2a0a12; }
.cert-start:hover { background: #ee7c9b; }
@media (max-width: 520px) { .cert-actions .btn { flex: 1 1 140px; } }

/* ---------- play ---------- */
.play-wrap { padding-top: 16px; padding-bottom: 40px; display: grid; gap: 14px; }
.play-cols { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.play-main, .play-side { display: grid; gap: 14px; min-width: 0; align-content: start; }
@media (min-width: 980px) { .play-cols { grid-template-columns: minmax(0, 1fr) 300px; } }
.reg-card, .side-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; overflow: hidden; }
.side-card { padding: 12px 14px; }
.side-card .h-sm { margin-bottom: 8px; }
.reg-head {
  display: flex; justify-content: space-between; gap: 8px; background: #e2698b; color: #2a0a12;
  padding: 6px 14px; font-size: 12.5px; font-weight: 600;
}
.reg-no { font-family: ui-monospace, Consolas, monospace; font-weight: 400; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reg-card .kv-list { padding: 10px 14px 12px; }
.kv-list { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 13.5px; }
.kv-list dt { color: var(--muted); white-space: nowrap; }
.kv-list dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.kv-list dd small { display: block; color: var(--muted); font-size: 12px; }
.play-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.play-id { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.play-id strong { font-size: 22px; }
.pill {
  display: inline-block; align-self: flex-start; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--border-2); color: var(--muted); font-size: 12.5px;
}
.play-age { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.play-age-num { font-size: 40px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.play-age-num small { font-size: 16px; color: var(--muted); font-weight: 400; }

.stats { display: grid; grid-template-columns: 1fr; gap: 8px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
@media (min-width: 640px) { .stats { grid-template-columns: 1fr 1fr; column-gap: 24px; } }
.stat { display: grid; grid-template-columns: 72px 1fr 34px; align-items: center; gap: 8px; position: relative; min-width: 0; }
.stat-label { font-size: 13px; color: #d6d6de; white-space: nowrap; }
.stat-val { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 99px; background: #23232d; overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 99px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.stat-health .bar-fill { background: var(--c-health); }
.stat-happy .bar-fill { background: var(--c-happy); }
.stat-chaos .bar-fill { background: var(--c-chaos); }
.stat-money .bar-fill { background: var(--c-money); }
.stat-knowledge .bar-fill { background: #2fd3c4; }
.stat-relation .bar-fill { background: #ff8fb1; }
.stat-fame .bar-fill { background: var(--c-fame); }
.stat-delta {
  position: absolute; right: 0; top: -14px; font-size: 11.5px; font-weight: 600; pointer-events: none;
  animation: floatUp 1.4s ease forwards;
}
.stat-delta.up { color: var(--c-health); } .stat-delta.down { color: #ff7a8f; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(6px); } 20% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-8px); } }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.controls #c-skip { flex: 1 1 auto; }
@media (min-width: 640px) { .controls #c-skip { flex: 0 1 auto; } .controls #c-exit { margin-left: auto; } }
#c-pause.paused { border-color: var(--accent); color: var(--accent-2); }

.log-box, .lifemap-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.log-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.log {
  list-style: none; margin: 0; padding: 0 4px 0 0;
  height: 46vh; min-height: 240px; max-height: 520px; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 2px; scroll-behavior: smooth;
  mask-image: linear-gradient(180deg, transparent 0, #000 32px);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 32px);
}
.log-static { height: auto; max-height: 60vh; mask-image: none; -webkit-mask-image: none; }
.log li {
  display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 7px 4px;
  border-bottom: 1px solid rgba(42, 42, 53, .6); font-size: 14.5px; min-width: 0;
}
.log li.anim { animation: logIn .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes logIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.log-age { color: var(--muted); font-size: 12.5px; padding-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.log-body { min-width: 0; overflow-wrap: anywhere; }
.log-deltas { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.chip { font-size: 11.5px; padding: 0 6px; border-radius: 4px; background: #20202a; color: var(--muted); white-space: nowrap; }
.chip.up { color: #7de3a9; } .chip.down { color: #ff8fa2; }
.log li.k-birth .log-body { color: #ffd3dd; }
.log li.k-decision .log-body { color: var(--accent-2); font-weight: 500; }
.log li.k-choice .log-body { color: #f6c7d3; }
.log li.k-choice .log-body::before { content: '→ '; color: var(--accent); }
.log li.k-death { background: rgba(232, 69, 107, .08); }
.log li.k-death .log-body { color: #fff; font-weight: 600; }
.log li.k-note .log-body { color: var(--gold); font-style: italic; }
.log li.k-year .log-body { color: var(--muted); font-size: 12.5px; }

/* life map */
.lifemap { display: grid; grid-template-columns: repeat(auto-fill, minmax(14px, 1fr)); gap: 3px; }
.lm-cell { aspect-ratio: 1; border-radius: 3px; background: #1f1f28; transition: background .3s; }
.lm-cell.decade { box-shadow: inset 0 0 0 1px #3a3a48; }
.lm-cell.past { background: #3a3a48; }
.lm-cell.good, .lifemap-legend .lm-good { background: #2f9e64; }
.lm-cell.bad, .lifemap-legend .lm-bad { background: #b8394f; }
.lm-cell.chaos, .lifemap-legend .lm-chaos { background: #7d4fd0; }
.lm-cell.dec, .lifemap-legend .lm-dec { background: var(--accent); box-shadow: 0 0 0 1px #ffb3c2 inset; }
.lm-cell.note { background: var(--gold); }
.lm-cell.now { animation: pulse 1.2s ease-in-out infinite; background: var(--text); }
.lm-cell.dead { background: #000; box-shadow: 0 0 0 1px var(--accent) inset; }
@keyframes pulse { 50% { opacity: .35; } }
.lifemap-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; color: var(--muted); }
.lifemap-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 4px; }

/* ---------- end ---------- */
.end-wrap { padding-top: 22px; padding-bottom: 48px; display: grid; gap: 18px; max-width: 760px; }
.end-card {
  position: relative; overflow: hidden;
  background: radial-gradient(600px 240px at 0% 0%, rgba(232, 69, 107, .16), transparent 70%), var(--card);
  border: 1px solid var(--border); border-radius: 16px; padding: 22px 18px; display: grid; gap: 12px; min-width: 0;
  animation: fadeUp .5s ease both;
}
@media (min-width: 640px) { .end-card { padding: 30px 30px; } }
.end-brand { color: var(--muted); font-size: 13px; letter-spacing: 1px; }
.end-name { font-size: clamp(30px, 8vw, 44px); font-weight: 700; }
.end-title { color: var(--accent-2); font-size: 18px; font-weight: 500; }
.end-variant { font-size: 13px; }
.end-origin { font-size: 14px; color: #d6d6de; margin-top: -6px; overflow-wrap: anywhere; }
.end-death { display: flex; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); min-width: 0; }
.end-age { flex: none; font-size: 54px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.end-age small { font-size: 16px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.end-cause-box { min-width: 0; }
.end-cause { font-size: 16px; overflow-wrap: anywhere; }
.end-epitaph { margin: 0; padding: 4px 0 4px 14px; border-left: 3px solid var(--accent); color: #e6e6ec; font-style: italic; }
.end-epitaph:empty { display: none; }
.end-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.score { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; display: flex; flex-direction: column; }
.score span { color: var(--muted); font-size: 13px; }
.score strong { font-size: 28px; font-variant-numeric: tabular-nums; }
.score-pity strong { color: #7fb4ff; }
.score-chaos strong { color: var(--c-chaos); }
.highlights { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14.5px; }
.highlights li { overflow-wrap: anywhere; }
.highlights li::marker { color: var(--accent); }
.stats-mini { background: transparent; border: 0; padding: 0; }
.end-status { border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14px; background: var(--card); border: 1px solid var(--border); color: var(--muted); }
.end-status.warn { border-color: rgba(245, 197, 66, .35); color: #f3dc9a; }
.end-actions { display: grid; gap: 18px; }
.end-actions-group { display: grid; gap: 8px; }
.end-log summary { cursor: pointer; color: var(--muted); padding: 8px 0; }
.end-log summary:hover { color: var(--text); }

/* true banner */
.true-banner {
  position: relative; overflow: hidden;
  border-radius: 16px; padding: 22px 18px; display: grid; gap: 10px;
  background: linear-gradient(135deg, rgba(245, 197, 66, .22), rgba(245, 197, 66, .05) 60%), var(--card);
  border: 1px solid rgba(245, 197, 66, .6);
  box-shadow: 0 0 0 1px rgba(245, 197, 66, .15), 0 12px 50px rgba(245, 197, 66, .15);
  animation: fadeUp .6s ease both;
}
.true-banner::after {
  content: ''; position: absolute; inset: -40% -10%; pointer-events: none;
  background: linear-gradient(110deg, transparent 40%, rgba(255, 240, 190, .16) 50%, transparent 60%);
  animation: shine 3.5s ease-in-out infinite;
}
@keyframes shine { from { transform: translateX(-60%); } to { transform: translateX(60%); } }
.true-banner h2 { color: var(--gold); font-size: clamp(22px, 6vw, 30px); font-weight: 700; }
.true-kicker { color: #f3dc9a; font-size: 13px; letter-spacing: 1px; }
.ts-form { display: grid; gap: 12px; margin-top: 8px; position: relative; z-index: 1; }
.field { display: grid; gap: 4px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > span, .field legend { font-size: 13px; color: #e8dcb4; display: flex; justify-content: space-between; gap: 8px; }
.field input[type=text], .field input[type=email], .modal input[type=text], .modal textarea {
  width: 100%; min-width: 0; background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 16px; color: var(--text);
}
.field input:focus, .modal input:focus, .modal textarea:focus { outline: none; border-color: var(--gold); }
.modal input:focus, .modal textarea:focus { border-color: var(--accent); }
.counter { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.over { color: #ff8fa2; }
.radios { display: grid; gap: 6px; }
.radios label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.radios input { accent-color: var(--gold); width: 18px; height: 18px; }
.ts-preview { font-size: 14px; color: #e8dcb4; overflow-wrap: anywhere; }
.ts-preview strong { color: var(--gold); }
#ts-note.err { color: #ff8fa2; }
#ts-note.ok { color: var(--c-health); }

/* ---------- modal ---------- */
.modal-root {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 5, 8, .72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fadeIn .2s ease both; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--border-2); border-radius: 16px;
  padding: 20px 18px; display: grid; gap: 14px; min-width: 0;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  animation: modalIn .28s cubic-bezier(.2, .8, .2, 1) both;
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.modal-title { font-size: 19px; font-weight: 600; overflow-wrap: anywhere; }
.modal-kicker { color: var(--accent-2); font-size: 13px; }
.modal-close { flex: none; border: 0; background: var(--card-2); width: 34px; height: 34px; border-radius: 8px; color: var(--muted); font-size: 18px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { display: grid; gap: 10px; font-size: 14.5px; min-width: 0; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.decision-choices { display: grid; gap: 8px; }
.decision-choices .btn { justify-content: flex-start; text-align: left; min-height: 50px; padding: 10px 16px; font-size: 15px; background: var(--bg-2); border-color: var(--border-2); }
.decision-choices .btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.decision-choices .btn .num { color: var(--accent); font-weight: 700; margin-right: 6px; }
.modal-detail-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.kv { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 13px; }
.kv b { color: var(--text); }

/* ---------- paid votes / amount input ---------- */
.pack-btns { display: contents; }
.vote-modal-body { gap: 14px; }
.pack-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.pack-btn {
  display: grid; gap: 2px; justify-items: start; text-align: left; min-width: 0;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--border-2); color: var(--text);
  transition: border-color .15s, background .15s, transform .08s;
}
.pack-btn b { font-size: 16px; font-weight: 600; }
.pack-btn span { color: var(--accent-2); font-size: 14px; font-variant-numeric: tabular-nums; }
.pack-btn:hover, .pack-btn.is-picked { border-color: var(--accent); background: var(--accent-soft); }
.pack-btn:active { transform: translateY(1px); }
.pack-btn[disabled] { opacity: .5; cursor: progress; }
.custom-amount { display: grid; gap: 8px; padding-top: 14px; border-top: 1px dashed var(--border-2); min-width: 0; }
.custom-head { font-size: 14px; font-weight: 500; }
.custom-go { width: 100%; margin-top: 2px; }
.amount-row { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; min-width: 0; }
.amount-row .amount-box { flex: 1 1 150px; }
.amount-box {
  display: flex; align-items: center; min-width: 0; max-width: 100%;
  background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  transition: border-color .15s;
}
.amount-box:focus-within { border-color: var(--accent); }
.amount-box:has(.amount-input[aria-invalid="true"]) { border-color: #ff8fa2; }
.amount-cur { flex: none; padding: 0 2px 0 12px; color: var(--muted); font-size: 16px; }
.amount-input {
  flex: 1; min-width: 0; width: 100%; background: transparent; border: 0; outline: none;
  padding: 10px 12px 10px 6px; font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield;
}
.amount-input::-webkit-outer-spin-button, .amount-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.amount-input:focus-visible { outline: none; }
.amount-preview { flex: none; font-size: 17px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount-preview.on { color: var(--accent-2); }
.amount-hint { font-size: 12.5px; color: var(--muted); }
.amount-err { font-size: 13px; color: #ff8fa2; }
.amount-err.info { color: #f3dc9a; }

/* ---------- support the game ---------- */
.section-support { border-top: 1px solid var(--border); border-bottom: 0; padding: 28px 0 36px; }
.support-card {
  max-width: 640px; margin: 0 auto; display: grid; gap: 16px; min-width: 0;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 16px;
}
@media (min-width: 640px) { .support-card { padding: 22px 24px; } }
.support-head { display: grid; gap: 4px; }
.support-kicker { color: var(--accent-2); font-size: 12.5px; letter-spacing: .5px; }
.support-title { font-size: 18px; }
.support-desc { color: var(--muted); font-size: 13.5px; }
.support-desc strong { color: var(--text); font-weight: 500; }
.support-form { display: grid; gap: 12px; min-width: 0; }
.support-form .field > span { color: var(--muted); }
.support-label { font-size: 13px; color: var(--muted); }
.amount-slot { display: grid; gap: 6px; min-width: 0; }
.amt-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.amt-chip {
  min-height: 36px; padding: 4px 14px; border-radius: 999px; font-size: 14px; font-variant-numeric: tabular-nums;
  background: transparent; border: 1px solid var(--border-2); color: var(--text);
  transition: border-color .15s, background .15s;
}
.amt-chip:hover { border-color: var(--muted); }
.amt-chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }
.support-form input[type=text] {
  width: 100%; min-width: 0; background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 16px; color: var(--text);
}
.support-form input[type=text]:focus { outline: none; border-color: var(--accent); }
@media (min-width: 520px) { .support-submit { justify-self: start; min-width: 180px; } }

/* ---------- toast ---------- */
.toasts {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 80; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  background: #1e1e28; border: 1px solid var(--border-2); border-left: 4px solid var(--muted);
  color: var(--text); padding: 10px 14px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: toastIn .25s ease both; pointer-events: auto;
  overflow-wrap: anywhere;
}
.toast.ok { border-left-color: var(--c-health); }
.toast.error { border-left-color: var(--accent); }
.toast.gold { border-left-color: var(--gold); }
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--border); padding: 24px 0 32px; color: var(--muted); font-size: 12.5px; }
.footer p + p { margin-top: 6px; }

/* ---------- misc animations ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.8); opacity: .3; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }

.view { animation: fadeIn .25s ease both; }

/* ---------- success page ---------- */
.success-wrap { max-width: 560px; padding-top: 60px; padding-bottom: 60px; }
.success-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 28px 22px; display: grid; gap: 14px; text-align: center; }
.success-icon { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 30px; font-weight: 700; background: var(--card-2); color: var(--muted); }
.success-icon.ok { background: rgba(76, 210, 138, .15); color: var(--c-health); }
.success-icon.fail { background: var(--accent-soft); color: var(--accent-2); }
.success-title { font-size: 22px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}
.section, .hero { scroll-margin-top: 60px; }
.nowrap { white-space: nowrap; }

/* ============================================================
   v2 — หน้าเล่น 3 คอลัมน์ · เงิน · จุดเน้น · ฉาก · หน้าจบ
   ============================================================ */
.mono { font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; }
.neg { color: #ff8fa2; }
.pos { color: #7de3a9; }

/* sprites */
.sprite-slot { display: grid; place-items: center; overflow: hidden; }
.sprite-slot svg { display: block; width: 100%; height: 100%; image-rendering: pixelated; shape-rendering: crispEdges; }
.sprite-ph {
  border: 1px dashed var(--border-2); color: var(--muted); font-size: 12px; text-align: center;
  background: repeating-linear-gradient(45deg, #15151c 0 8px, #181820 8px 16px);
}

/* layout */
.play-wrap { max-width: 1400px; gap: 12px; }
.play-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.play-col { display: grid; gap: 12px; min-width: 0; align-content: start; }
@media (max-width: 759px) {
  .play-col { display: contents; }
  #p-scene-box { order: 1; } #p-stats-card { order: 2; } #p-focus { order: 3; } .play-center .log-box { order: 4; }
  #p-money { order: 5; } #p-reg { order: 6; } #p-fam { order: 7; } #p-peers { order: 8; } .lifemap-box { order: 9; }
  #p-surv { order: 10; } #p-wstats { order: 11; }
}
@media (min-width: 760px) and (max-width: 1139px) {
  .play-grid { grid-template-columns: 290px minmax(0, 1fr); }
  .play-right { grid-column: 1 / -1; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}
@media (min-width: 1140px) {
  .play-grid { grid-template-columns: 290px minmax(0, 1fr) 310px; }
}
.side-card { padding: 12px 14px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head .h-sm { margin: 0; }

/* top bar / controls */
.controls { gap: 6px; }
.controls .btn { min-height: 36px; padding: 6px 12px; font-size: 13.5px; }
.controls #c-skip { flex: 0 1 auto; }
#c-auto.on { border-color: #2fd3c4; color: #7ff0e4; background: rgba(47, 211, 196, .1); }
@media (max-width: 520px) {
  .controls { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .controls #c-pause { grid-column: span 2; }
  .controls #c-speed { grid-column: span 4; display: flex; }
  .controls #c-skip, .controls #c-auto { grid-column: span 3; }
  .controls #c-music { grid-column: span 1; }
  .controls #c-note { grid-column: span 3; }
  .controls #c-exit { grid-column: span 2; }
  .controls .btn { padding: 6px 6px; font-size: 13px; white-space: normal; }
  .controls #c-speed button { padding: 6px 4px; }
}
.true-chip { border-color: rgba(245, 197, 66, .6); color: var(--gold); background: var(--gold-soft); font-weight: 500; }
.true-chip.off { border-color: var(--border-2); color: var(--muted); background: transparent; }
.play-id { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.play-id .pill { align-self: center; }

/* ทะเบียนประวัติ */
.reg-body { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px 12px; padding: 12px 14px 8px; align-items: center; }
.reg-main { display: contents; }
.reg-body .kv-list { grid-column: 1 / -1; }
.reg-portrait { width: 64px; height: 64px; border-radius: 8px; background: #101016; border: 1px solid var(--border); }
.reg-name { font-weight: 600; font-size: 17px; margin-bottom: 4px; overflow-wrap: anywhere; }
.kv-left dd { text-align: right; }
.kv-left { font-size: 13px; gap: 3px 10px; }
.reg-card .kv-list { padding: 0; }
.mrz {
  font-family: ui-monospace, Consolas, monospace; font-size: 11px; letter-spacing: 1.5px; color: #8b8b9b;
  padding: 8px 14px 10px; border-top: 1px dashed var(--border-2); overflow: hidden; line-height: 1.5;
}
.mrz div { white-space: nowrap; overflow: hidden; text-overflow: clip; }

/* stats column */
.stats.stats-col { grid-template-columns: 1fr; background: transparent; border: 0; padding: 0; gap: 7px; }
.stats-col .stat { grid-template-columns: 88px 1fr 30px; }

/* money */
.money-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin: 0; }
.money-grid > div { min-width: 0; }
.money-grid dt { color: var(--muted); font-size: 12px; }
.money-grid dd { margin: 0; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.money-grid dd small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; }
.money-sub { font-size: 12.5px; color: #d6d6de; margin: 12px 0 6px; }
.money-ly { border-top: 1px solid var(--border); margin-top: 10px; }
.money-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 12.5px; }
.money-lines li { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); }
.money-lines b { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-items { border-top: 1px solid var(--border); margin-top: 10px; }
.item-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.item-list li { display: flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.item-ic { flex: none; width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 5px; background: #101016; overflow: hidden; }
.item-ic svg { width: 100%; height: 100%; image-rendering: pixelated; }
.item-ic-ph { border: 1px dashed var(--border-2); }
.item-cash { color: var(--gold); font-size: 12px; font-weight: 600; }
.money-tr { font-size: 13px; margin-top: 6px; }
.btn-money { width: 100%; margin-top: 12px; }
.bd { margin-top: 4px; }
.bd-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: #23232d; }
.bd-bar i { display: block; height: 100%; }
.bd-legend { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; font-size: 11.5px; color: var(--muted); }
.bd-legend li { display: flex; align-items: center; gap: 5px; min-width: 0; }
.bd-legend i { flex: none; width: 8px; height: 8px; border-radius: 2px; }
.bd-legend b { color: var(--text); font-weight: 500; margin-left: auto; }
.bd-how { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.bd-how summary { cursor: pointer; color: var(--accent-2); }
.bd-how p { margin-top: 6px; }

/* ฉาก */
.scene-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.scene { aspect-ratio: 560 / 220; width: 100%; background: #101016; }
.scene.sprite-ph { border: 0; aspect-ratio: auto; height: 72px; }
.death-scene.sprite-ph { aspect-ratio: auto; height: 60px; }
.scene svg { width: 100%; height: 100%; }
.scene-cap { padding: 8px 14px 10px; font-size: 13px; display: grid; gap: 1px; border-top: 1px solid var(--border); }

/* จุดเน้น */
.focus-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.focus-chip {
  display: grid; gap: 1px; text-align: left; padding: 8px 10px; border-radius: var(--radius-sm); min-width: 0;
  background: var(--bg-2); border: 1px solid var(--border-2); color: var(--text); transition: border-color .15s, background .15s;
}
.focus-chip b { font-weight: 500; font-size: 13.5px; }
.focus-chip small { color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.focus-chip:hover { border-color: var(--muted); }
.focus-chip.on { border-color: var(--accent); background: var(--accent-soft); }
.focus-chip.on b { color: var(--accent-2); }
.focus-chip[disabled] { opacity: .45; cursor: not-allowed; }
.focus-baby { grid-column: 1 / -1; }

/* log (ใหม่สุดอยู่บน) */
.log.log-rev {
  mask-image: linear-gradient(0deg, transparent 0, #000 40px); -webkit-mask-image: linear-gradient(0deg, transparent 0, #000 40px);
  height: 52vh; max-height: 640px;
}
.log-fact {
  margin-top: 4px; font-size: 12.5px; color: #9fc9b5; background: rgba(47, 158, 100, .08);
  border-left: 2px solid #2f9e64; padding: 2px 8px; border-radius: 0 4px 4px 0;
}
.log-fact b { color: #4cd28a; font-weight: 600; }
.log li.k-usernote .log-body { color: #f3dc9a; font-style: normal; }
.note-mark { color: var(--gold); }
.log li.t-ok .log-body { color: #e9d27a; font-style: normal; }
.log li.t-ok .log-body::first-letter { color: #4cd28a; }
.log li.t-bad .log-body { color: #ff8fa2; font-style: normal; }

/* คนที่เกิดพร้อมกัน */
.peer-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; }
.peer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.peer-name { font-weight: 500; overflow-wrap: anywhere; }
.peer-stage { color: var(--muted); text-align: right; font-size: 12.5px; }
.peer-death { grid-column: 1 / -1; color: var(--muted); font-size: 11.5px; }
.peer.dead .peer-name { color: var(--muted); }

/* แผนที่ชีวิต */
.lifemap { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.lm-cell { display: grid; place-items: center; font-size: 10px; line-height: 1; color: rgba(255, 255, 255, .92); font-weight: 600; overflow: hidden; }
.lm-cell.past { background: #2c2c38; }
.lm-cell.exp { box-shadow: inset 0 0 0 1.5px var(--gold); }
.lm-cell.now { animation: pulse 1.2s ease-in-out infinite; background: var(--text) !important; color: #000; }
.lm-cell.dead { background: #000 !important; box-shadow: 0 0 0 1px var(--accent) inset; }
.lifemap-legend { display: block; margin-top: 8px; line-height: 1.5; }
.lifemap-legend b { color: var(--text); }
.lm-exp-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; box-shadow: inset 0 0 0 1.5px var(--gold); vertical-align: -1px; }

/* เส้นโค้งการรอดชีวิต */
.surv svg { display: block; margin-top: 6px; }
.sv-grid { stroke: #23232d; stroke-width: 1; }
.sv-tick { fill: #7a7a88; font-size: 9px; font-family: ui-monospace, Consolas, monospace; }
.sv-area { fill: rgba(47, 211, 196, .12); }
.sv-line { fill: none; stroke: #2fd3c4; stroke-width: 2; }
.sv-world { fill: none; stroke: #9a9aa8; stroke-width: 1.3; stroke-dasharray: 4 3; }
.sv-now { stroke: rgba(255, 255, 255, .25); stroke-dasharray: 2 3; }
.sv-dot { fill: #fff; stroke: #2fd3c4; stroke-width: 2; }
.sv-lab { fill: #fff; font-size: 11px; font-weight: 600; font-family: var(--font); }
.sv-legend { font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 4px; }
.sv-legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid #2fd3c4; margin-left: 4px; }
.sv-legend i.sv-k-world { border-top: 2px dashed #9a9aa8; }

/* สถิติประเทศ */
.wstats { margin: 8px 0 6px; display: grid; gap: 0; font-size: 12.5px; }
.wstats > div { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid rgba(42, 42, 53, .6); }
.wstats dt { color: var(--muted); }
.wstats dd { margin: 0; text-align: right; font-family: ui-monospace, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.wstats-src { font-size: 11px; }

/* decision modal */
.decision-modal { max-width: 580px; }
.decision-body { display: grid; gap: 12px; }
.decision-desc { color: #d6d6de; font-size: 15px; }
.fact-bar {
  background: rgba(47, 158, 100, .1); border: 1px solid rgba(76, 210, 138, .28); border-left: 3px solid #4cd28a;
  color: #cfeedd; border-radius: 6px; padding: 8px 12px; font-size: 13px;
}
.fact-bar b { color: #4cd28a; margin-right: 4px; }
.decision-choices .btn .num {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 6px; margin-right: 10px;
  background: var(--card-2); color: var(--accent-2); font-size: 13px;
}
.decision-auto { justify-self: center; border: 1px solid var(--border-2); }

/* money modal */
.money-modal { max-width: 640px; }
.money-body { gap: 14px; }
.money-kv b { font-variant-numeric: tabular-nums; }
.act-group { display: grid; gap: 6px; }
.act-group > .h-sm { color: var(--accent-2); font-size: 14px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.act-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center;
  padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--border);
}
.act-row.off { opacity: .55; }
.act-info { min-width: 0; display: grid; gap: 2px; }
.act-title { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; }
.act-title b { font-weight: 500; }
.act-cost { color: var(--gold); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.act-why { color: #f3dc9a; }
.act-btns { display: flex; flex-direction: column; gap: 4px; }
.act-btns .btn { min-width: 84px; }
@media (max-width: 420px) {
  .act-row { grid-template-columns: 1fr; }
  .act-btns { flex-direction: row; }
  .act-btns .btn { flex: 1; }
}

/* birth card: ชีวิตจริง */
.cert.cert-gold { border-color: rgba(245, 197, 66, .7); box-shadow: 0 0 0 1px rgba(245, 197, 66, .2), 0 20px 60px rgba(245, 197, 66, .15); }
.cert.cert-gold .cert-head { background: var(--gold); color: #1a1405; }
.cert.cert-gold .cert-start { background: var(--gold); color: #1a1405; }
.cert-true {
  position: relative; overflow: hidden; padding: 14px 18px; display: grid; gap: 4px;
  background: linear-gradient(135deg, rgba(245, 197, 66, .22), rgba(245, 197, 66, .05) 70%);
  border-bottom: 1px solid rgba(245, 197, 66, .4);
}
.cert-true::after {
  content: ''; position: absolute; inset: -40% -10%; pointer-events: none;
  background: linear-gradient(110deg, transparent 40%, rgba(255, 240, 190, .16) 50%, transparent 60%);
  animation: shine 3.5s ease-in-out infinite;
}
.cert-true-title { color: var(--gold); font-weight: 600; font-size: 15.5px; overflow-wrap: anywhere; }
.cert-true-hint { color: #f3dc9a; font-size: 13px; }
@media (min-width: 640px) { .cert-true { padding: 14px 24px; } }

/* end: banner ใกล้เคียง */
.true-banner.near {
  background: linear-gradient(135deg, rgba(255, 166, 77, .18), rgba(255, 166, 77, .04) 60%), var(--card);
  border-color: rgba(255, 166, 77, .55); box-shadow: none;
}
.true-banner.near h2 { color: #ffb366; }
.true-banner.near::after { display: none; }

/* end: บันทึกการเสียชีวิต */
.end-wrap { max-width: 820px; }
.death-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; min-width: 0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45); animation: certIn .5s cubic-bezier(.2, .8, .2, 1) both;
}
.death-head {
  display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap;
  background: #e2698b; color: #2a0a12; padding: 12px 18px; font-weight: 600; font-size: 14px;
}
.death-head .reg-no { font-weight: 400; font-size: 12px; }
.death-body { padding: 18px; display: grid; gap: 14px; min-width: 0; }
@media (min-width: 640px) { .death-body { padding: 24px 28px 28px; } .death-head { padding: 14px 28px; } }
.death-id { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 14px; align-items: center; }
.death-portrait { width: 84px; height: 84px; border-radius: 10px; background: #101016; border: 1px solid var(--border); }
.death-id-text { min-width: 0; display: grid; gap: 2px; }
.end-years { color: #d6d6de; font-size: 13.5px; overflow-wrap: anywhere; }
.death-scene { width: 100%; aspect-ratio: 560 / 220; border-radius: 10px; background: #101016; border: 1px solid var(--border); }
.death-narr { font-size: 15.5px; color: #e6e6ec; line-height: 1.75; overflow-wrap: anywhere; }
.death-compare { display: grid; gap: 4px; font-size: 14px; color: #d6d6de; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.death-compare b { color: var(--text); }
.death-table { display: grid; grid-template-columns: minmax(110px, auto) minmax(0, 1fr); gap: 0; margin: 0; font-size: 13.5px; }
.death-table dt, .death-table dd { padding: 7px 0; border-bottom: 1px solid var(--border); margin: 0; }
.death-table dt { color: var(--muted); padding-right: 12px; }
.death-table dd { overflow-wrap: anywhere; }
.death-table dd small { display: block; color: var(--muted); }
.pattern { display: grid; gap: 10px; padding: 14px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--border); }
.pattern-axes { display: grid; gap: 12px; }
.pat-axis { display: grid; gap: 2px; }
.pat-labels { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.pat-labels .on { color: var(--text); font-weight: 600; }
.pat-track { position: relative; height: 30px; }
.pat-beam { position: absolute; left: 4%; right: 4%; top: 12px; height: 6px; border-radius: 99px; background: #2a2a35; transform-origin: 50% 50%; transition: transform .8s cubic-bezier(.2, .8, .2, 1); }
.pat-beam i { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(232, 69, 107, .25); }
.pat-pivot { position: absolute; left: 50%; top: 18px; width: 0; height: 0; margin-left: -6px; border: 6px solid transparent; border-bottom: 8px solid #4a4a58; }
.pat-text { font-size: 12px; color: var(--muted); text-align: center; }
.pattern-name { font-size: 20px; font-weight: 700; color: var(--accent-2); }
.pattern-desc { font-size: 14px; }
.pattern .btn { justify-self: start; }
#e-last { justify-self: start; }
.farewell { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 6px; }
.farewell .field > span { color: #d6d6de; }
.farewell textarea {
  width: 100%; min-width: 0; background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 16px; color: var(--text); resize: vertical;
}
.farewell textarea:focus { outline: none; border-color: var(--accent); }
.modal textarea { resize: vertical; }

/* คำเตือนเรื่องสมมติ */
.section-disclaimer { padding: 24px 0; }
.disclaimer-card {
  border: 2px solid rgba(245, 197, 66, .55); border-radius: var(--radius); background: linear-gradient(135deg, rgba(245, 197, 66, .08), transparent 60%), var(--card);
  padding: 18px 16px; display: grid; gap: 10px; min-width: 0;
}
@media (min-width: 640px) { .disclaimer-card { padding: 22px 26px; } }
.disclaimer-title { font-size: clamp(20px, 5.4vw, 30px); line-height: 1.25; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.disclaimer-ico { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #f5c542; color: #0b0b0f; font-weight: 800; flex: none; }
.disclaimer-lead { font-size: 15px; line-height: 1.7; color: #e6e6ec; overflow-wrap: anywhere; }
.disclaimer-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; color: var(--muted); font-size: 14px; }
.disclaimer-line { color: #d9c27a; }
.footer .disclaimer-line { color: #cdb76f; }

/* สนามประลอง (ดูสดบนหน้าแรก) */
.section-arena { border-bottom: 0; padding: 28px 0 0; }
.arena-card {
  max-width: 980px; margin: 0 auto; display: grid; gap: 12px; min-width: 0;
  background: linear-gradient(135deg, rgba(232, 69, 107, .12), transparent 60%), var(--card);
  border: 1px solid rgba(232, 69, 107, .35); border-radius: var(--radius); padding: 18px 16px;
}
@media (min-width: 640px) { .arena-card { padding: 20px 24px; } }
.arena-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; }
.arena-title { font-size: 18px; }
.arena-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 480px) { .arena-actions { width: 100%; } .arena-actions .btn { flex: 1; } }
.arena-live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: arena-blink 1s infinite; vertical-align: 1px; }
@keyframes arena-blink { 50% { opacity: .25; } }
.arena-embed { min-width: 0; }
.arena-counts { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.arena-counts b { color: var(--text); }
.arena-bottom { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 720px) { .arena-bottom { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }
.arena-feed { margin: 4px 0 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 13px; }
.arena-feed li { border-left: 2px solid var(--accent); padding-left: 8px; overflow-wrap: anywhere; line-height: 1.5; }
.arena-feed li.muted { border: 0; padding: 0; }
.arena-strat-name { display: grid; gap: 4px; margin-top: 10px; }
.arena-strat-name input { width: 100%; min-width: 0; background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: 9px 10px; font-size: 16px; color: var(--text); }
.arena-strat-name .row { display: flex; gap: 6px; }
.arena-strat-name .row input { flex: 1; }
.arena-top { margin: 4px 0 0; padding-left: 20px; display: grid; gap: 2px; font-size: 14px; }
.arena-top li { overflow-wrap: anywhere; }
.arena-top li b { float: right; color: var(--accent-2); font-weight: 600; margin-left: 8px; }
.arena-top li.muted { list-style: none; margin-left: -20px; }
.arena-strats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
@media (max-width: 380px) { .arena-strats { grid-template-columns: 1fr; } }
