/* The Nine Heavens — mobile-first xianxia life-sim.
 * A deliberate dark-ink / jade / gold design system: flat ink surfaces,
 * hairline rules, restrained accents — sharp where it counts, never bubbly. */

/* Bundled display faces (latin subset, OFL) — an engraved Cinzel for labels and
 * a literary Cormorant for titles, so the chrome reads carved, not default. */
@font-face { font-family: "Cinzel"; font-style: normal; font-weight: 600; font-display: swap; src: url("assets/fonts/cinzel-600.woff2") format("woff2"); }
@font-face { font-family: "Cinzel Decorative"; font-style: normal; font-weight: 700; font-display: swap; src: url("assets/fonts/cinzel-decorative-700.woff2") format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-style: normal; font-weight: 500; font-display: swap; src: url("assets/fonts/cormorant-500.woff2") format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-style: normal; font-weight: 600; font-display: swap; src: url("assets/fonts/cormorant-600.woff2") format("woff2"); }
/* hand-brushed hanzi, subset to just the masthead glyphs 九重天飞升命 (~3KB) */
@font-face { font-family: "Ma Shan Zheng"; font-style: normal; font-weight: 400; font-display: swap; src: url("assets/fonts/mashanzheng-brush.woff2") format("woff2"); unicode-range: U+4e5d, U+5347, U+547d, U+5929, U+91cd, U+98de; }

:root {
  /* surfaces — deep ink, faint jade-black undertone (deepest → raised) */
  --bg0: #080b12; --bg: #0b0f18; --bg2: #121622;
  --panel: #161b28; --panel2: #1e2332; --panel3: #262d40;
  /* ink */
  --ink: #ece6d6; --ink2: #bcc1cf; --muted: #7f879b;
  /* fixed accents (used where a colour must stay itself, e.g. spirit stones) */
  --gold: #e6c585; --gold2: #b8934a; --gold-dim: #7c6531;
  --jade: #74dcb4; --red: #e0746c; --purple: #b79be8; --blue: #7fb6e8; --pink: #e09bb3;
  --line: #232838; --line2: #323a4f;
  /* ---- karma-reactive accent (overridden by the body.k-* themes below) ----
   * The whole interface's identity colour shifts with merit and sin: jade-gold
   * for the righteous, amethyst and cinnabar for those who walk the demonic dao. */
  --accent: var(--gold); --accent2: var(--gold2); --accent-dim: var(--gold-dim);
  --aura: rgba(230,197,133,.06);
  /* ink-wash mountain ranges behind the app — far/mid/near, retinted per karma */
  --peak-far: #1a2336; --peak-mid: #141b2c; --peak-near: #0e1422;
  --moon: rgba(235,224,196,.20); --moon-halo: rgba(230,197,133,.10);
  /* effects — quieter shadows, almost no neon glow */
  --shadow: 0 10px 30px rgba(0,0,0,.55);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.45);
  --glow-gold: 0 0 0 1px rgba(230,197,133,.18);
  /* sharp jade-tablet geometry — corners are chamfered, never rounded */
  --r: 2px; --r-sm: 2px; --r-lg: 3px;
  --chamfer: 9px; --chamfer-sm: 5px;
  /* type — engraved labels, literary titles, serif body, Songti for hanzi */
  --font-body: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "Noto Serif SC", Georgia, serif;
  --font-display: "Cormorant Garamond", "Songti SC", "Noto Serif SC", Georgia, serif;
  --font-engrave: "Cinzel", "Songti SC", "Noto Serif SC", Georgia, serif;
  --font-drama: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --seal-red: radial-gradient(125% 125% at 30% 18%, #c8584a, #8e231c);
  --seal-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fdeede' stroke-width='1.5'%3E%3Crect x='4.5' y='4.5' width='15' height='15'/%3E%3Cpath d='M8 8h8v8H8z'/%3E%3Cpath d='M12 8v8M8 12h8'/%3E%3C/svg%3E");
  --font-cjk: "Songti SC", "Noto Serif SC", "Source Han Serif SC", serif;
  --font-brush: "Ma Shan Zheng", "Songti SC", "Noto Serif SC", serif;
  /* 回纹 — the Chinese key-fret (meander) ornament, tiled as a gilt band */
  --fret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='14'%3E%3Cg fill='none' stroke='%23b8934a' stroke-width='1.25'%3E%3Cpath d='M0 12.3H15'/%3E%3Cpath d='M2 12.3V3H11.5V12.3'/%3E%3Cpath d='M5 12.3V6H8.3'/%3E%3C/g%3E%3C/svg%3E");
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
/* Karma tiers — set on <body> from JS. Each retunes the accent + aura so the
 * banner, name, headings, buttons and tiers all glow with the soul's nature. */
body.k-saint    { --accent: #f4dca0; --accent2: #d9b35e; --accent-dim: #9a7c3a; --aura: rgba(244,220,160,.16); --peak-far: #232a3c; --peak-mid: #1a2030; --moon: rgba(244,220,160,.26); --moon-halo: rgba(244,220,160,.16); }
body.k-virtuous { --accent: #cfe1a8; --accent2: #a9c178; --accent-dim: #6f8a4a; --aura: rgba(120,200,150,.12); --peak-far: #1b2a30; --peak-mid: #142028; --moon-halo: rgba(160,210,150,.12); }
body.k-neutral  { --accent: var(--gold); --accent2: var(--gold2); --accent-dim: var(--gold-dim); --aura: rgba(230,197,133,.06); }
body.k-tainted  { --accent: #cba6ec; --accent2: #9070c6; --accent-dim: #5f4a86; --aura: rgba(150,110,205,.14); --peak-far: #211b34; --peak-mid: #181428; --moon-halo: rgba(160,120,210,.14); }
body.k-demonic  { --accent: #ed8079; --accent2: #c14040; --accent-dim: #8a2f2f; --aura: rgba(205,70,62,.17); --peak-far: #2a1a22; --peak-mid: #1f131a; --peak-near: #160d14; --moon: rgba(237,140,130,.22); --moon-halo: rgba(205,70,62,.18); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Pinch-zoom stays available (accessibility); this kills the 300ms double-tap
 * delay and accidental double-tap zoom on every control instead. */
button, .listrow, .chip, .attr-tile, .trove-cell, .doll-slot, .kv.tappable,
.section-h.collapsible, .wm-node, .vbar.tappable, .rl-row, .sundry-card { touch-action: manipulation; }
/* one icon family — inherit colour from the holder, align to text, scale via CSS */
.ic { display: inline-block; vertical-align: -0.18em; flex: none; }
.chip-ic { vertical-align: -0.18em; opacity: .9; }
/* Lock the document to the viewport so the *page* never scrolls or rubber-bands
 * on touch — only the event log (#log) scrolls. `position: fixed` + `overflow:
 * hidden` is the reliable cure for iOS Safari's whole-page bounce. */
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  position: fixed; inset: 0;
  background:
    radial-gradient(130% 80% at 50% -15%, #1d2542 0%, rgba(11,14,26,0) 55%),
    radial-gradient(100% 60% at 100% 100%, #15192c 0%, rgba(11,14,26,0) 60%),
    var(--bg0);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px; line-height: 1.5; overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 720px; margin: 0 auto; position: relative; z-index: 1; }

/* ============================ ink-wash atmosphere ===================== */
/* A fixed scene that lives behind everything: a hung moon, slow clouds, three
 * receding mountain ranges dissolving into mist. Pointer-transparent; retints
 * with karma through the --peak-*/--moon vars. */
#sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; transition: opacity .8s ease; }
.sky-peaks { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 80%; opacity: 1; }
.sky-moon {
  position: absolute; top: 11%; right: 16%; width: 116px; height: 116px; border-radius: 50%;
  background: radial-gradient(circle at 38% 38%, var(--moon), transparent 68%);
  box-shadow: 0 0 90px 30px var(--moon-halo);
  transition: background .8s ease, box-shadow .8s ease;
}
/* soft drifting clouds — layered radial puffs, blurred, crawling sideways */
.sky-cloud {
  position: absolute; height: 70px; width: 260px; opacity: .5; filter: blur(7px);
  background:
    radial-gradient(50% 80% at 30% 60%, rgba(180,196,230,.16), transparent 70%),
    radial-gradient(46% 90% at 58% 50%, rgba(180,196,230,.2), transparent 72%),
    radial-gradient(40% 70% at 80% 64%, rgba(180,196,230,.13), transparent 72%);
}
.sky-cloud.sc1 { top: 22%; left: -30%; transform: scale(1.2); animation: drift 95s linear infinite; }
.sky-cloud.sc2 { top: 35%; left: -40%; opacity: .34; animation: drift 140s linear infinite; animation-delay: -40s; }
.sky-cloud.sc3 { top: 14%; left: -50%; opacity: .28; transform: scale(.85); animation: drift 180s linear infinite; animation-delay: -90s; }
@keyframes drift { from { transform: translateX(0) scale(1.1); } to { transform: translateX(220vw) scale(1.1); } }
/* a low ground-mist veil that lifts the near peaks off the tab bar */
.sky-mist { position: absolute; left: 0; right: 0; bottom: 0; height: 20%; background: linear-gradient(180deg, transparent, var(--bg0) 96%); }
@media (prefers-reduced-motion: reduce) { .sky-cloud { animation: none !important; } }

/* ============================ profile header ========================== */
#profile {
  padding: calc(var(--safe-t) + 10px) 14px 9px;
  background:
    radial-gradient(120% 150% at 50% -45%, var(--aura), transparent 70%),
    linear-gradient(180deg, rgba(11,15,24,.94), rgba(11,15,24,.82));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  transition: background .7s ease;
}
.pf-top { display: flex; align-items: center; gap: 12px; }
.pf-avatar {
  width: 48px; height: 48px; flex: none; border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--accent2); display: flex; align-items: center; justify-content: center;
  color: var(--accent); transition: transform .15s ease, border-color .5s ease, color .5s ease;
}
.pf-avatar:active { transform: scale(.94); }
.pf-avatar .av { width: 30px; height: 30px; }
.pf-id { flex: 1; min-width: 0; }
#pf-name { font-weight: 700; color: var(--accent); font-size: 1.1rem; letter-spacing: .005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .5s ease; }
.pf-sub { color: var(--jade); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .88; margin-top: 1px; }
.pf-epithet { color: var(--accent); font-weight: 700; opacity: 1; transition: color .5s ease; }
.pf-more {
  flex: none; width: 44px; height: 44px; border-radius: var(--r-sm);
  background: transparent; border: 1px solid var(--line2); color: var(--ink2);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.pf-more:active { background: var(--panel); color: var(--gold); }
.pf-bars { display: flex; gap: 12px; margin-top: 8px; }
.vbar { flex: 1; }
.vbar .vb-label { display: flex; justify-content: space-between; font-size: .64rem; color: var(--muted); margin-bottom: 4px; letter-spacing: .08em; text-transform: uppercase; }
.vbar .vb-track { height: 5px; border-radius: 3px; background: #0c0f1a; overflow: hidden; }
.vbar .vb-fill { height: 100%; width: 0%; transition: width .45s ease; border-radius: 3px; }
.vb-fill.qi { background: linear-gradient(90deg, #4a78bf, #6fb6ff); }
.vb-fill.health { background: linear-gradient(90deg, #3a8757, #5fd08a); }
.vb-fill.happy { background: linear-gradient(90deg, #c79a44, #f0d27a); }
.vb-fill.hp { background: linear-gradient(90deg, #8a3a44, #e8736b); }

/* the innate-attribute banner — five compact tiered stats, glyph + standing */
.pf-attrs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-top: 7px; }
.attr-tile {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  padding: 4px 2px 3px; border-radius: 6px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line);
  transition: border-color .15s ease, background .15s ease;
}
.attr-tile:active { background: var(--panel2); }
.attr-tile .ic { width: 13px; height: 13px; color: var(--ink2); }
.attr-tile .at-name { font-size: .58rem; font-weight: 700; letter-spacing: .005em; color: var(--ink2); text-align: center; line-height: 1.15; }
.attr-tile .at-num { font-size: .55rem; line-height: 1; color: var(--muted); font-variant-numeric: tabular-nums; }
.attr-tile.tier-lo .ic, .attr-tile.tier-lo .at-name { color: var(--red); }
.attr-tile.tier-mid .ic { color: var(--ink2); }
.attr-tile.tier-hi .ic, .attr-tile.tier-hi .at-name { color: var(--jade); }
.attr-tile.tier-hi { border-color: #275645; }
.attr-tile.tier-top .ic, .attr-tile.tier-top .at-name { color: var(--accent); }
.attr-tile.tier-top { border-color: var(--accent2); background: var(--aura); }

.pf-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .7rem; padding: 3px 9px; border-radius: var(--r-sm); background: var(--panel);
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap; line-height: 1.1;
}
.chip .chip-ic { color: var(--ink2); }
/* the combined deeds chip: three budgets (☯/⚔/❤) side by side */
.deeds-chip { gap: 8px; padding: 4px 10px; }
.deeds-chip .dg { display: inline-flex; align-items: center; gap: 3px; }
.deeds-chip .dp { font-size: .6rem; letter-spacing: .5px; color: var(--jade); }
.deeds-chip.warn .dp { color: var(--accent); }
.chip b { color: var(--ink); font-weight: 700; letter-spacing: .02em; }
.chip.warn { border-color: var(--accent2); color: var(--accent); background: var(--aura); }
.chip.warn .chip-ic { color: var(--accent); }
.chip.good { color: var(--jade); border-color: #275645; background: rgba(111,214,179,.05); }
.chip.good .chip-ic { color: var(--jade); }
.chip.bad { color: var(--red); border-color: #6a3434; background: rgba(224,116,108,.05); }
.chip.bad .chip-ic { color: var(--red); }
.chip.tappable { cursor: pointer; }
.chip.tappable b { border-bottom: 1px dotted var(--accent-dim); }

/* ============================ life feed / log ========================= */
#log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 12px 16px 10px; -webkit-overflow-scrolling: touch; }
.turn { padding: 11px 2px; border-bottom: 1px dashed var(--line); animation: fade .3s ease; }
.turn:last-child { border-bottom: none; }
@keyframes fade { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.line { margin: 3px 0; white-space: pre-wrap; word-wrap: break-word; line-height: 1.55; }
.line.sub { padding-left: 12px; color: var(--muted); font-size: .92rem; border-left: 2px solid var(--line2); }
.line.epic { color: var(--accent); font-weight: 600; }
.line.good { color: var(--jade); }
.line.bad { color: var(--red); }
.line.trib { color: var(--blue); }
.line.demon { color: var(--purple); }
.line.spacer { height: .4rem; }
/* automatic stat-change readout — compact, colour-coded deltas after an action */
.stat-turn { padding: 4px 2px 9px; }
.line.stat { margin: 1px 0; font-size: .8rem; font-weight: 700; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.line.stat.up { color: var(--jade); }
.line.stat.down { color: var(--red); }
.year-tag {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 0; font-weight: 700;
  color: var(--accent); font-size: .7rem; letter-spacing: .22em; text-transform: uppercase; margin: 8px 0 4px;
}
.year-tag::before { content: ""; width: 18px; height: 1px; background: var(--accent2); }
/* full-bleed milestone scene in the feed; framed card variant for overlays */
.scene { position: relative; margin: 6px -16px 12px; border-top: 1px solid var(--line2); border-bottom: 1px solid var(--line2); overflow: hidden; box-shadow: inset 0 0 60px rgba(0,0,0,.45); }
.scene img { display: block; width: 100%; height: auto; }
.scene-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 14px 9px; text-align: center; font-size: .72rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); background: linear-gradient(transparent, rgba(6,9,16,.92)); }
.scene.scene-card { margin: 2px 0 14px; border-radius: var(--r); border: 1px solid var(--line2); box-shadow: var(--shadow-sm), inset 0 0 50px rgba(0,0,0,.4); }
.banner { position: relative; text-align: center; color: var(--accent); font-weight: 700; letter-spacing: .05em; padding: 10px 6px; font-size: .98rem; }
.banner::before, .banner::after { content: ""; position: absolute; top: 50%; width: 16%; height: 1px; background: linear-gradient(90deg, transparent, var(--accent2)); }
.banner::before { left: 5%; } .banner::after { right: 5%; transform: scaleX(-1); }

/* ============================ bottom tab bar ========================== */
#tabbar {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; align-items: end;
  padding: 5px 8px calc(6px + var(--safe-b));
  background: linear-gradient(180deg, rgba(11,15,24,.72), rgba(11,15,24,.95));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 48px; padding: 6px 2px; border-radius: var(--r-sm);
  background: transparent; color: var(--muted); border: 1px solid transparent;
  font-size: .68rem; font-weight: 600; letter-spacing: .02em; cursor: pointer;
  transition: color .15s ease, transform .08s ease;
}
.tab .ico { display: flex; align-items: center; justify-content: center; }
.tab .ico svg { width: 23px; height: 23px; }
.tab:active { color: var(--ink); transform: scale(.95); }
.tab-age {
  background: var(--panel2); color: var(--accent);
  border: 1px solid var(--accent2); min-height: 58px; border-radius: var(--r);
  transform: translateY(-7px); transition: color .5s ease, border-color .5s ease, transform .08s ease;
}
.tab-age .ico svg { width: 25px; height: 25px; color: var(--accent); }
.tab-age:active { transform: translateY(-4px) scale(.97); }
.tab-age.ready { border-color: var(--accent); background: var(--aura); }
.tab-age.spent { border-color: var(--accent); animation: deedpulse 2s ease-in-out infinite; }
/* (deedpulse keyframes live with the jade-tablet rules near the end) */

/* ============================ overlay / panels ======================== */
#overlay { position: fixed; inset: 0; z-index: 50; background: rgba(4,6,12,.72); backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; }
#overlay.hidden { display: none; }
#overlay-card {
  position: relative;
  width: 100%; max-width: 720px; max-height: 92dvh; background: var(--bg2);
  border: 1px solid var(--line2); border-bottom: none; border-radius: var(--r-lg) var(--r-lg) 0 0;
  display: flex; flex-direction: column; animation: slideup .26s cubic-bezier(.2,.8,.2,1); padding-bottom: var(--safe-b);
  box-shadow: 0 -12px 44px rgba(0,0,0,.55);
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
#overlay-card::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line2); margin: 8px auto 0; flex: none; }
#overlay-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px 10px; border-bottom: 1px solid var(--line); }
#overlay-head h2 { margin: 0; font-size: 1.1rem; font-weight: 700; color: var(--accent); letter-spacing: .005em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#overlay-close, #overlay-back { background: transparent; border: 1px solid var(--line2); color: var(--ink2); width: 40px; height: 40px; border-radius: var(--r-sm); cursor: pointer; flex: none; display: flex; align-items: center; justify-content: center; }
#overlay-close:active, #overlay-back:active { background: var(--panel); color: var(--accent); }
#overlay-back { color: var(--accent); }
#overlay-back.hidden { display: none; }
#overlay-body { overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 24px; -webkit-overflow-scrolling: touch; }

/* menu buttons / cards */
.menu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.mbtn {
  display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 13px 15px; min-height: 58px;
  border-radius: var(--r); background: var(--panel); border: 1px solid var(--line2);
  color: var(--ink); font-size: .94rem; font-weight: 700; cursor: pointer; position: relative; overflow: hidden;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.mbtn:active { background: var(--panel2); transform: scale(.98); }
.mbtn .mb-line { display: flex; align-items: center; gap: 8px; }
.mbtn .mb-line .ic { flex: none; color: var(--accent); }
.mbtn small { color: var(--muted); font-weight: 500; font-size: .73rem; letter-spacing: .01em; }
.mbtn.full { grid-column: 1 / -1; }
.mbtn.primary { background: linear-gradient(var(--aura), var(--aura)), var(--panel2); border-color: var(--accent2); color: var(--accent); padding-left: 19px; }
.mbtn.primary::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; background: var(--accent); }
.mbtn.primary small { color: var(--accent); opacity: .82; }
.mbtn.danger { border-color: #6a3434; color: var(--red); background: #241a1d; }
.mbtn:disabled { opacity: .38; cursor: not-allowed; filter: grayscale(.3); }
/* navigation card (opens a sub-menu): icon tile + title + sub + chevron */
.mbtn.nav { flex-direction: row; align-items: center; gap: 12px; padding-right: 30px; }
.mbtn.nav .mb-ico {
  width: 38px; height: 38px; flex: none; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; background: var(--panel2); border: 1px solid var(--line2);
}
.mbtn.nav .mb-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.mbtn.nav .mb-txt b { font-weight: 700; }
.mbtn.nav::after { content: "›"; position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--accent2); font-size: 1.3rem; font-weight: 700; }

.listrow {
  display: flex; align-items: center; gap: 11px; padding: 12px 13px; border-radius: var(--r); margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--line); cursor: pointer;
  transition: background .15s ease, transform .08s ease, border-color .15s ease;
}
.listrow:active { background: var(--panel2); transform: scale(.99); }
.listrow .lr-ava { width: 38px; height: 38px; flex: none; border-radius: var(--r-sm); background: var(--panel2); border: 1px solid var(--line2); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--ink2); }
.listrow .lr-ava .ic { width: 23px; height: 23px; }
/* sentiment tints — colour an avatar/emblem and its frame to carry meaning */
.tint-gold   { color: var(--accent) !important; border-color: var(--accent2) !important; background: var(--aura) !important; }
.tint-jade   { color: var(--jade) !important; border-color: #2c5d49 !important; background: rgba(111,214,179,.06) !important; }
.tint-pink   { color: var(--pink) !important; border-color: #6a3a52 !important; background: rgba(224,155,179,.06) !important; }
.tint-red    { color: var(--red) !important; border-color: #6a3434 !important; background: rgba(224,116,108,.06) !important; }
.tint-purple { color: var(--purple) !important; border-color: #4f3f7a !important; background: rgba(183,155,232,.07) !important; }
.listrow .lr-main { flex: 1; min-width: 0; }
.listrow .lr-title { font-weight: 700; }
.listrow .lr-sub { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.listrow.bound { border-color: var(--accent2); box-shadow: inset 0 0 0 1px var(--aura); }
.listrow.disabled { opacity: .5; }
.affbar { height: 6px; border-radius: 4px; background: #20263f; overflow: hidden; margin-top: 6px; border: 1px solid var(--line); }
.affbar > div { height: 100%; }

/* ============================ sect hierarchy ========================= */
.rankladder { display: flex; flex-direction: column; gap: 3px; margin: 4px 0 6px; }
.rl-row {
  display: flex; align-items: center; gap: 9px; padding: 7px 11px; border-radius: var(--r-sm);
  background: var(--panel); border: 1px solid var(--line); font-size: .84rem;
}
.rl-row .rl-mark { width: 12px; text-align: center; color: var(--muted); flex: none; }
.rl-row .rl-name { flex: 1; min-width: 0; font-weight: 700; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-row .rl-req { color: var(--muted); font-size: .72rem; text-align: right; flex: none; max-width: 52%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-row.current { border-color: var(--accent2); background: var(--aura); }
.rl-row.current .rl-mark, .rl-row.current .rl-name, .rl-row.current .rl-req { color: var(--accent); }
.rl-row.past .rl-mark { color: var(--jade); }
.rl-row.past .rl-name { color: var(--muted); }
.rl-row.future { opacity: .85; }
.loc-person { color: var(--jade); cursor: pointer; border-bottom: 1px dotted var(--jade); }
.loc-person:active { color: var(--accent); }

/* ============================ equipment paperdoll =================== */
.doll-panel {
  position: relative; width: 100%; aspect-ratio: 1 / 0.9; margin: 8px 0 4px;
  background: radial-gradient(ellipse 72% 85% at 50% 38%, #131e34 0%, #0c1422 55%, #080c18 100%);
  border: 1px solid var(--line2); overflow: hidden;
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
  box-shadow: inset 0 0 0 1px var(--line2), inset 0 0 60px rgba(0,0,0,.4);
}
.doll-figure {
  position: absolute; inset: 0; width: 100%; height: 100%;
  color: var(--accent2); opacity: .2;
}
.doll-slot {
  position: absolute; transform: translate(-50%, -50%);
  width: 58px; height: 58px; padding: 3px;
  background: rgba(8,12,24,.88); border: 1.5px solid var(--line2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  cursor: pointer; backdrop-filter: blur(6px);
  transition: border-color .15s, box-shadow .15s;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
}
.doll-slot:active { transform: translate(-50%, -50%) scale(.88); }
.doll-slot.filled {
  border-color: var(--accent2);
  box-shadow: 0 0 14px var(--aura), 0 0 0 1px rgba(182,147,74,.2);
  background: rgba(12,18,32,.92);
}
.ds-icon { font-size: 1.45rem; line-height: 1; }
.ds-cn   { font-size: .56rem; letter-spacing: .06em; color: var(--muted); font-family: var(--font-engrave); text-transform: uppercase; line-height: 1.1; }
.ds-name { font-size: .62rem; font-weight: 700; color: var(--accent); text-align: center; line-height: 1.15; max-width: 54px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* grade badge used in trove cells */
.grade-cn { font-size: .6rem; color: var(--accent); font-weight: 700; font-family: var(--font-engrave); letter-spacing: .02em; }
/* treasure trove grid */
.trove-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 6px 0 2px; }
.trove-cell {
  aspect-ratio: 1; border: 1px solid var(--line2); background: var(--panel);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; transition: border-color .12s, box-shadow .12s;
  position: relative; overflow: hidden; padding: 5px 3px;
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
}
.trove-cell:active { background: var(--panel2); transform: scale(.94); }
.trove-cell.equipped { border-color: var(--accent2); box-shadow: inset 0 0 10px var(--aura); }
.trove-cell.empty { opacity: .28; cursor: default; pointer-events: none; }
.tc-icon { font-size: 1.25rem; line-height: 1; }
.tc-name { font-size: .62rem; color: var(--ink2); text-align: center; line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
/* sundry item cards */
.sundry-card { display: flex; align-items: flex-start; gap: 11px; padding: 9px 0 8px; border-bottom: 1px solid var(--line); }
.sundry-card:last-child { border-bottom: none; }
.sc-icon { font-size: 1.35rem; flex: none; width: 28px; text-align: center; margin-top: 1px; }
.sc-body { flex: 1; min-width: 0; }
.sc-top  { display: flex; align-items: baseline; gap: 8px; }
.sc-name { font-weight: 700; font-size: .84rem; }
.sc-qty  { font-size: .72rem; color: var(--muted); }
.sc-desc { font-size: .76rem; color: var(--muted); margin-top: 3px; line-height: 1.38; }

/* ============================ world map =============================== */
.worldmap {
  position: relative; width: 100%; aspect-ratio: 1 / 0.74; margin: 4px 0 12px;
  border-radius: var(--r); border: 1px solid var(--line2); overflow: hidden;
  background: radial-gradient(118% 118% at 50% 40%, #182842 0%, #101a2c 52%, #0a1020 100%);
}
.wm-roads { position: absolute; inset: 0; width: 100%; height: 100%; }
.wm-roads line { stroke: rgba(170,188,225,.15); stroke-width: .5; stroke-dasharray: 1.6 1.4; }
.wm-node {
  position: absolute; transform: translate(-50%, -50%); width: 25px; height: 25px; padding: 0;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: #131a29; border: 1.5px solid var(--line2); transition: transform .1s ease;
}
.wm-node:active { transform: translate(-50%, -50%) scale(.86); }
/* pins stay visually small but hit like ~45px targets */
.wm-node::before { content: ""; position: absolute; inset: -10px; border-radius: 50%; }
.wm-node .ic { width: 13px; height: 13px; }
.wm-node.here { box-shadow: 0 0 0 2px var(--accent), 0 0 10px rgba(0,0,0,.5); z-index: 3; }
.wm-node.seat { width: 27px; height: 27px; }
.wm-node.abode::after { content: ""; position: absolute; top: -2px; right: -2px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); border: 1px solid #0a1020; }
/* biome tints, safe heartland → deadly marches */
.biome-0 { color: #8fe0b3; border-color: #46795c; }
.biome-1 { color: #86c8e6; border-color: #3f78a0; }
.biome-2 { color: #aab4ec; border-color: #5663a2; }
.biome-3 { color: #cd9be0; border-color: #7f4f96; }
.biome-4 { color: #ec8f88; border-color: #a8453f; }
.listrow .lr-ava.biome-0, .listrow .lr-ava.biome-1, .listrow .lr-ava.biome-2,
.listrow .lr-ava.biome-3, .listrow .lr-ava.biome-4 { background: #131a29; }

.section-h {
  display: flex; align-items: center; gap: 9px; color: var(--accent); font-size: .68rem; text-transform: uppercase;
  letter-spacing: .16em; font-weight: 700; margin: 18px 0 9px;
}
.section-h::before { content: "◈"; color: var(--accent2); font-size: .7rem; }
.section-h::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--accent-dim), transparent); }
.section-h:first-child { margin-top: 4px; }
/* A collapsible section header: tap to fold the group away. */
.section-h.collapsible { cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.section-h.collapsible::before { content: "\25BE"; display: inline-block; transition: transform .2s ease; }
.section-h.collapsible.collapsed::before { transform: rotate(-90deg); }
.section-h.collapsible .sh-count { color: var(--muted); font-weight: 600; letter-spacing: normal; font-size: .82rem; }
.section-h.collapsible:active { color: var(--ink); }
/* Animated fold: grid-rows 1fr→0fr collapses the inner wrapper smoothly, and the
 * content fades in step so it never hard-clips at the folding edge. */
.collapse-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .26s cubic-bezier(.3,.7,.3,1); }
.collapse-body.hidden { grid-template-rows: 0fr; }
.collapse-body > .collapse-inner { overflow: hidden; min-height: 0; opacity: 1; transition: opacity .22s ease .04s; }
.collapse-body.hidden > .collapse-inner { opacity: 0; transition: opacity .18s ease; }
/* Newly-revealed rows settle in with a gentle staggered lift (only on expand). */
.collapse-inner.revealing > * { animation: foldreveal .34s cubic-bezier(.2,.8,.2,1) both; }
.collapse-inner.revealing > *:nth-child(2) { animation-delay: .04s; }
.collapse-inner.revealing > *:nth-child(3) { animation-delay: .08s; }
.collapse-inner.revealing > *:nth-child(n+4) { animation-delay: .11s; }
@keyframes foldreveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* ----- ambient micro-animations (extend the polish everywhere) ----- */
/* The blurred backdrop fades in with the rising overlay card (fresh opens only). */
#overlay:not(.hidden) { animation: scrimin .24s ease; }
@keyframes scrimin { from { opacity: 0; } to { opacity: 1; } }
/* Event & dialogue cards turn in — each new beat feels like a card laid down. */
.event-card { animation: cardin .34s cubic-bezier(.2,.8,.2,1) both; }
@keyframes cardin { from { opacity: 0; transform: translateY(9px) scale(.992); } to { opacity: 1; transform: none; } }
/* A stat change flashes its colour as it lands in the log. */
.line.stat.up { animation: statpop-up .6s ease both; }
.line.stat.down { animation: statpop-down .6s ease both; }
@keyframes statpop-up { 0% { background: rgba(95,208,138,.22); } 12% { background: rgba(95,208,138,.22); } 100% { background: transparent; } }
@keyframes statpop-down { 0% { background: rgba(232,115,107,.20); } 12% { background: rgba(232,115,107,.20); } 100% { background: transparent; } }
/* Milestone log banners (breakthroughs, death, rebirth…) pulse once as they land. */
.banner { animation: milepop .7s ease both; }
@keyframes milepop { 0% { opacity: 0; transform: translateY(7px) scale(.97); } 55% { opacity: 1; transform: scale(1.015); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .collapse-body, .collapse-body > .collapse-inner, .section-h.collapsible::before { transition: none; }
  .collapse-inner.revealing > *, #overlay:not(.hidden), .event-card,
  .line.stat.up, .line.stat.down, .banner { animation: none; }
}
/* Expand / collapse-all control, sitting top-right of a foldable screen. */
.fold-all {
  display: block; margin: 2px 0 6px auto; padding: 4px 11px; font-size: .72rem; letter-spacing: .08em;
  color: var(--accent); background: var(--panel2); border: 1px solid var(--line2); border-radius: 999px; cursor: pointer;
}
.fold-all:active { background: var(--panel); color: var(--ink); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: .9rem; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); } .kv .v { text-align: right; color: var(--ink); font-weight: 600; }
.kv.tappable { cursor: pointer; } .kv.tappable:active { background: rgba(255,255,255,.03); }
.kv .info-i { color: var(--accent2); font-size: .82em; margin-left: 3px; }
.note { color: var(--ink2); font-size: .86rem; margin: 8px 0; line-height: 1.5; }
.note b { color: var(--accent); }

/* labelled progress bar (qi to next, body tempering, sect prestige, beast bond…) */
.pbar { margin: 10px 0; }
.pbar .pb-top { display: flex; justify-content: space-between; gap: 10px; font-size: .74rem; color: var(--muted); margin-bottom: 5px; }
.pbar .pb-top b { color: var(--ink); font-weight: 700; }
.pbar .pb-track { height: 11px; border-radius: 7px; background: #14182a; border: 1px solid var(--line); overflow: hidden; }
.pbar .pb-fill { height: 100%; border-radius: 7px; box-shadow: inset 0 1px 0 rgba(255,255,255,.2); transition: width .4s ease; min-width: 2px; }
.pb-fill.qi { background: linear-gradient(90deg, #3d6db5, #6fb6ff); }
.pb-fill.body { background: linear-gradient(90deg, #b07d2e, #ecca7e); }
.pb-fill.prestige { background: linear-gradient(90deg, #6d5aa8, #b79be8); }
.pb-fill.bond { background: linear-gradient(90deg, #b0476a, #e89bb7); }
.pb-fill.exp { background: linear-gradient(90deg, #2f7a4a, #6fd6b3); }
.pb-fill.rank { background: linear-gradient(90deg, #c79a44, #f0d27a); }
.pb-fill.dao { background: linear-gradient(90deg, #2e8c84, #7fd9c9); }
.pb-ready { color: var(--gold) !important; font-weight: 700; }

/* ============================ event card ============================== */
.event-card {
  position: relative; background: linear-gradient(var(--aura), var(--aura)), var(--panel); border: 1px solid var(--accent2);
  border-radius: var(--r); padding: 22px 18px 18px; margin-bottom: 14px; box-shadow: var(--shadow-sm); overflow: hidden;
}
/* a thin gilt seam top and bottom — a framed omen, not a chat bubble */
.event-card::before, .event-card::after { content: ""; position: absolute; left: 22px; right: 22px; height: 1px; background: linear-gradient(90deg, transparent, var(--accent2), transparent); }
.event-card::before { top: 0; } .event-card::after { bottom: 0; }
.event-card .ev-emblem {
  width: 56px; height: 56px; margin: 0 auto; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--accent); background: radial-gradient(circle at 50% 38%, var(--aura), transparent 70%), var(--panel2);
  border: 1px solid var(--accent2); box-shadow: 0 0 0 4px rgba(0,0,0,.18);
}
.event-card .ev-emblem .ic { width: 30px; height: 30px; }
.event-card .ev-text { margin-top: 13px; font-size: 1.04rem; line-height: 1.6; text-align: center; color: var(--ink); }
/* A speaker line turns an event card into a spoken-dialogue card. */
.event-card.ev-dialogue { border-color: var(--gold2); }
.event-card .ev-speaker { margin-top: 12px; text-align: center; font-family: var(--font-display); font-size: .82rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.event-card .ev-text.ev-quote { margin-top: 6px; font-style: italic; color: var(--ink2); }
.event-card .ev-text.ev-quote::before { content: "\201C"; } .event-card .ev-text.ev-quote::after { content: "\201D"; }

/* ============================ start / death =========================== */
.center-card { text-align: center; }
/* brushwork masthead with a vermillion name-seal (印章) — the title page chop */
.masthead { position: relative; display: inline-block; margin: 14px auto 4px; padding: 0 34px; }
.title-zh { font-family: var(--font-brush); font-size: 2.7rem; color: var(--gold); letter-spacing: .14em; font-weight: 400; line-height: 1.05; }
.masthead .title-zh::after { content: ""; display: block; height: 14px; width: 84%; margin: 8px auto 0; background: var(--fret) repeat-x left center; opacity: .9; -webkit-mask: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent); mask: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent); }
.seal-stamp {
  position: absolute; top: -6px; right: -10px; width: 44px; height: 44px;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  background: linear-gradient(155deg, #c8403420, #97271f), radial-gradient(120% 120% at 30% 20%, #c8584a, #8e231c);
  color: #fdeede; display: flex; align-items: center; justify-content: center; font-size: 1.7rem; line-height: 1;
  font-family: var(--font-brush); transform: rotate(-5deg);
  box-shadow: inset 0 0 0 1.5px rgba(255,236,222,.5), inset 0 0 0 3px rgba(0,0,0,.18);
}
.title-en { color: var(--muted); font-size: .84rem; margin-bottom: 18px; letter-spacing: .02em; }
.txtfield { width: 100%; padding: 13px 15px; border-radius: var(--r-sm); font-size: 1rem; background: var(--panel); border: 1px solid var(--line2); color: var(--ink); margin: 8px 0 14px; }
.txtfield::placeholder { color: var(--muted); }
.txtfield:focus { outline: none; border-color: var(--gold2); }
.seg { display: flex; gap: 8px; margin-bottom: 14px; }
.seg button { flex: 1; padding: 11px; border-radius: var(--r-sm); background: var(--panel); border: 1px solid var(--line2); color: var(--ink2); font-weight: 700; transition: all .12s ease; }
.seg button.on { border-color: var(--gold2); color: var(--gold); background: #2a2417; }
.chron-line { font-size: .85rem; padding: 4px 0; color: var(--muted); border-bottom: 1px solid #20263f; }
.chron-line:last-child { border-bottom: none; }
.chron-line b { color: var(--ink2); }

/* ============================ combat minigame ========================= */
.cbt-unit { background: linear-gradient(180deg, #1f263f, #181d31); border: 1px solid var(--line2); border-radius: var(--r); padding: 11px 13px; margin-bottom: 9px; }
.cbt-unit.you { border-color: var(--gold2); }
.cu-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 7px; }
.cu-name { font-weight: 800; font-size: 1rem; }
.cu-status { font-size: .78rem; color: var(--muted); }
.hpbar, .qibar { position: relative; height: 17px; border-radius: 9px; background: #11152a; border: 1px solid var(--line); overflow: hidden; margin-top: 5px; }
.hpfill { height: 100%; background: linear-gradient(90deg, #8a2f3a, #e8736b); transition: width .3s ease; }
.hpfill.you { background: linear-gradient(90deg, #2f7a4a, #5fd08a); }
.qifill { height: 100%; background: linear-gradient(90deg, #3d6db5, #6fb6ff); transition: width .3s ease; }
.hpbar span, .qibar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .68rem; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.85); }
.cbt-vs { text-align: center; color: var(--gold2); font-size: .72rem; letter-spacing: .12em; margin: 4px 0 8px; text-transform: uppercase; }
.cbt-feed { height: 152px; overflow-y: auto; background: rgba(8,10,20,.55); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; margin-bottom: 11px; font-size: .85rem; }
.cbt-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.cbt-skill {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 11px 12px; min-height: 62px;
  border-radius: var(--r); background: linear-gradient(180deg, #283156, #212845); border: 1px solid var(--line2); color: var(--ink);
  cursor: pointer; justify-content: space-between; transition: transform .08s ease, background .15s ease;
}
.cbt-skill:not(.off):active { transform: scale(.96); background: #2e3766; }
.cbt-skill .cs-name { font-weight: 700; font-size: .9rem; }
.cbt-skill .cs-desc { font-size: .68rem; color: var(--muted); font-weight: 400; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cbt-skill .cs-cost { font-size: .72rem; color: var(--blue); font-weight: 600; }
.cbt-skill.off { opacity: .4; }
.cbt-skill.flee { background: linear-gradient(180deg, #2c2030, #241a26); border-color: #5a3a4a; }
.cbt-skill.flee .cs-cost { color: var(--muted); }

/* ========================= tactical grid combat ====================== */
.gc-roster { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.gc-foe { flex: 1 1 44%; background: rgba(40,18,22,.5); border: 1px solid #4a2b30; border-radius: var(--r-sm); padding: 3px 7px; font-size: .72rem; color: var(--ink2); }
.gc-foe.dead { opacity: .35; filter: grayscale(1); text-decoration: line-through; }
.gc-foe .gc-hp { height: 4px; background: #2a1418; border-radius: 3px; margin-top: 3px; overflow: hidden; }
.gc-foe .gc-hp > div { height: 100%; background: linear-gradient(90deg, var(--red), #b8534a); transition: width .3s ease; }
.gc-grid { display: grid; gap: 3px; margin: 4px 0 10px; touch-action: manipulation; }
.gc-cell { position: relative; aspect-ratio: 1; border-radius: 5px; background: #10141f; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.gc-cell.t-wall { background: repeating-linear-gradient(45deg, #2a2f3e, #2a2f3e 4px, #232838 4px, #232838 8px); border-color: #3a4257; }
.gc-cell.t-rubble { background: #1b1d24; }
.gc-cell.t-flame { background: radial-gradient(circle, rgba(224,116,108,.34), #1a0f12); border-color: #6a3530; }
.gc-cell.t-chasm { background: #05070c; border-color: #0c1018; box-shadow: inset 0 0 8px #000; }
.gc-cell.t-thicket { background: radial-gradient(circle, rgba(116,220,180,.18), #101a16); border-color: #2c5446; }
.gc-cell.t-spring { background: radial-gradient(circle, rgba(127,182,232,.22), #0e1622); border-color: #2f4a66; }
.gc-terr { position: absolute; font-size: .8rem; opacity: .5; color: var(--ink2); pointer-events: none; }
.gc-cell.reach { box-shadow: inset 0 0 0 2px rgba(127,182,232,.55); cursor: pointer; }
.gc-cell.reach::after { content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%; background: rgba(127,182,232,.5); }
.gc-cell.target { box-shadow: inset 0 0 0 2px var(--red); background: rgba(224,116,108,.16); cursor: pointer; }
.gc-token { position: relative; width: 84%; height: 84%; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #0b0f18; z-index: 2; }
.gc-token.side-player { background: radial-gradient(circle at 40% 35%, var(--jade), #2f7a5e); box-shadow: 0 0 7px rgba(116,220,180,.5); }
.gc-token.side-ally { background: radial-gradient(circle at 40% 35%, var(--blue), #2f5a82); }
.gc-token.side-enemy { background: radial-gradient(circle at 40% 35%, var(--red), #7a2f2f); }
.gc-token.active { outline: 2px solid var(--gold); outline-offset: 1px; }
.gc-token > svg { width: 62%; height: 62%; }
.gc-thp { position: absolute; left: 8%; right: 8%; bottom: -2px; height: 3px; background: rgba(0,0,0,.6); border-radius: 2px; overflow: hidden; }
.gc-thp > i { display: block; height: 100%; background: var(--jade); }
.gc-token.side-enemy + .gc-thp, .side-enemy .gc-thp > i { background: var(--red); }
.gc-status { display: flex; align-items: center; gap: 7px; font-size: .74rem; margin-bottom: 7px; }
.gc-status > span { font-weight: 700; color: var(--ink); white-space: nowrap; }
.gc-bar { position: relative; flex: 1; height: 15px; border-radius: 8px; background: #0c1018; border: 1px solid var(--line); overflow: hidden; }
.gc-bar > i { display: block; height: 100%; transition: width .3s ease; }
.gc-bar.hp > i { background: linear-gradient(90deg, #2f7a5e, var(--jade)); }
.gc-bar.qi { flex: 0 0 88px; }
.gc-bar.qi > i { background: linear-gradient(90deg, #2f5a82, var(--blue)); }
.gc-bar > b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .66rem; color: var(--ink); text-shadow: 0 1px 2px #000; }
.gc-feed { height: 96px; margin-bottom: 8px; }
.gc-hint { margin: 2px 0 7px; }
.gc-acts { margin-bottom: 8px; }
.gc-btnrow { display: flex; gap: 7px; }
.gc-btnrow .mbtn { flex: 1; }

/* ============================ alchemy minigame ======================== */
.brew { margin: 12px 0 6px; }
.brew-gauge { position: relative; height: 28px; border-radius: 9px; background: linear-gradient(90deg,#13233a,#3a2417); border: 1px solid var(--line2); overflow: hidden; }
.brew-band { position: absolute; top: 0; bottom: 0; background: rgba(111,214,179,.32); border-left: 2px solid var(--jade); border-right: 2px solid var(--jade); }
.brew-needle { position: absolute; top: -3px; bottom: -3px; width: 4px; margin-left: -2px; background: var(--gold); box-shadow: 0 0 9px var(--gold); border-radius: 2px; transition: left .2s ease; }
.brew-stats { display: flex; justify-content: space-between; font-size: .76rem; color: var(--muted); margin-top: 9px; }

/* ============================ stat hint bubble ======================== */
#tip {
  position: fixed; left: 12px; right: 12px; bottom: calc(90px + var(--safe-b)); z-index: 60; max-width: 696px; margin: 0 auto;
  background: linear-gradient(180deg, #2a3252, #1b2138); border: 1px solid var(--gold2); border-radius: var(--r);
  padding: 13px 15px; color: var(--ink); font-size: .87rem; line-height: 1.5; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
#tip.show { opacity: 1; transform: none; pointer-events: auto; }
#tip b { color: var(--gold); }
#tip .tip-x { margin-top: 8px; font-size: .68rem; color: var(--muted); text-align: right; }

/* ---------- outcome toast: an in-sheet deed's result, floating above ---- */
#toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(16px + var(--safe-b)); z-index: 70; max-width: 696px; margin: 0 auto;
  background: linear-gradient(180deg, #232b48, #171d32); border-radius: var(--r);
  padding: 11px 14px; color: var(--ink); font-size: .86rem; line-height: 1.45; font-family: var(--font-body);
  clip-path: polygon(var(--chamfer-sm) 0, 100% 0, 100% calc(100% - var(--chamfer-sm)), calc(100% - var(--chamfer-sm)) 100%, 0 100%, 0 var(--chamfer-sm));
  box-shadow: inset 0 0 0 1px var(--accent2), 0 8px 26px rgba(0,0,0,.5);
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
#toast.show { opacity: 1; transform: none; pointer-events: auto; }
#toast .toast-more { margin-top: 4px; font-size: .7rem; color: var(--muted); }
/* Docked inside an open sheet: pinned just below the header, clear of the
 * action buttons that live at the bottom of the sheet. */
#toast.in-sheet { position: absolute; top: 76px; left: 10px; right: 10px; bottom: auto; transform: translateY(-8px); }
#toast.in-sheet.show { transform: none; }

/* ---------- in-sheet deed-budget readout -------------------------------- */
.deed-meter {
  display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 10px; font-size: .72rem;
  color: var(--ink2); font-family: var(--font-engrave); letter-spacing: .04em;
}
.deed-meter .dm-cat { display: inline-flex; align-items: center; gap: 5px; }
.deed-meter .dm-cat b { color: var(--jade); letter-spacing: 2px; font-family: var(--font-body); }
.deed-meter .dm-cat.out b { color: var(--red); }
/* category identity colours, shared with the .deed-tag cost tags */
.deed-meter .dm-cult, .deed-tag.dt-cult { color: var(--blue); }
.deed-meter .dm-act, .deed-tag.dt-act { color: var(--gold); }
.deed-meter .dm-social, .deed-tag.dt-social { color: var(--pink); }

/* ---------- deed-cost tag beneath an action ----------------------------- */
.deed-tag {
  display: inline-flex; align-items: center; gap: 3px; vertical-align: baseline;
  font-family: var(--font-engrave); font-size: .62rem; font-weight: 600;
  letter-spacing: .04em; white-space: nowrap; opacity: .95;
}
.deed-tag .dt-ic { flex: none; vertical-align: -0.12em; }

/* ============================ character creator ====================== */
.cr-field { margin: 10px 0; }
.cr-label { font-size: .72rem; color: var(--muted); margin-bottom: 5px; letter-spacing: .05em; text-transform: uppercase; }
.cr-select {
  width: 100%; padding: 12px 36px 12px 13px; border-radius: var(--r-sm);
  background-color: var(--panel); color: var(--ink); border: 1px solid var(--line2);
  font-size: .95rem; -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--gold2) 50%), linear-gradient(135deg, var(--gold2) 50%, transparent 50%);
  background-position: right 16px center, right 11px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.cr-select:focus { outline: none; border-color: var(--gold2); }
.cr-select option { background: #1b2138; color: var(--ink); }
.cr-preview { background: linear-gradient(180deg, #20283f, #1a2036); border: 1px solid var(--gold2); border-radius: var(--r); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.cr-pv-top { font-size: 1.08rem; margin-bottom: 7px; font-weight: 700; }
.cr-pv-top b { color: var(--gold); }
.cr-preview .kv { font-size: .85rem; }

/* scrollbars */
#log::-webkit-scrollbar, #overlay-body::-webkit-scrollbar, .cbt-feed::-webkit-scrollbar { width: 7px; }
#log::-webkit-scrollbar-thumb, #overlay-body::-webkit-scrollbar-thumb, .cbt-feed::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 0; }

/* ==================================================================== *
 *  WOODBLOCK & JADE-TABLET IDENTITY
 *  Chamfered silhouettes + engraved inner rules + carved type, so the
 *  chrome reads as an inked artifact rather than a default app shell.
 * ==================================================================== */

/* --- carved typography ------------------------------------------------ */
#pf-name, #overlay-head h2, .lr-title, .cr-pv-top, .cu-name, .mbtn, .center-card .note b,
.event-card .ev-text { font-family: var(--font-display); }
.mbtn { font-weight: 600; letter-spacing: .01em; }
.mbtn small, .lr-sub, .cs-desc, .note, .chron-line, .kv, #tip { font-family: var(--font-body); }
#pf-name { font-size: 1.22rem; font-weight: 600; letter-spacing: .02em; }
#overlay-head h2 { font-family: var(--font-display); font-size: 1.32rem; font-weight: 600; letter-spacing: .03em; }
.lr-title, .cu-name, .cr-pv-top { font-weight: 600; letter-spacing: .015em; }
.title-zh, .seal-stamp { font-family: var(--font-cjk); }
.title-en { font-family: var(--font-display); font-style: italic; font-size: .96rem; letter-spacing: .02em; }
.event-card .ev-text { font-size: 1.16rem; line-height: 1.5; }
/* engraved small-caps for every label/divider/tab */
.section-h, .year-tag, .banner, .vbar .vb-label, .tab, .tab-age, .cbt-vs, .scene-cap,
.cr-label, .seg button, .cbt-skill .cs-name, .at-name { font-family: var(--font-engrave); }
.section-h, .year-tag, .scene-cap, .cr-label { letter-spacing: .12em; }
.tab, .tab-age { letter-spacing: .04em; font-weight: 600; }
.banner { font-family: var(--font-engrave); letter-spacing: .14em; }

/* --- chamfered tablets: large cut (top-left + bottom-right) ------------ */
.mbtn, .listrow, .rl-row, .cbt-skill, .cbt-unit, .event-card, .cr-preview, #tip {
  border-radius: 0; border-color: transparent !important;
  clip-path: polygon(var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)), calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer));
  box-shadow: inset 0 0 0 1px var(--line2), inset 0 0 11px rgba(4,6,12,.5), inset 0 1px 0 1px rgba(255,255,255,.03);
}
.listrow.bound { box-shadow: inset 0 0 0 1px var(--accent2), inset 0 0 22px var(--aura); }
.mbtn.primary { box-shadow: inset 0 0 0 1px var(--accent2), inset 0 0 26px var(--aura); }
.mbtn.danger  { box-shadow: inset 0 0 0 1px #6a3434, inset 0 0 11px rgba(4,6,12,.5); }
.event-card   { box-shadow: inset 0 0 0 1px var(--accent2), inset 0 0 26px rgba(4,6,12,.55); }
.cr-preview   { box-shadow: inset 0 0 0 1px var(--gold2), inset 0 0 22px rgba(4,6,12,.5); }
.mbtn:disabled { clip-path: polygon(var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)), calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer)); }

/* --- chamfered chips, fields & tiles: small cut ----------------------- */
.chip, .txtfield, .cr-select, .seg button, .pf-avatar, .attr-tile, .listrow .lr-ava,
.mbtn.nav .mb-ico, #overlay-close, #overlay-back:not(.hidden), .pf-more, .lr-ava {
  border-radius: 0 !important; border-color: transparent !important;
  clip-path: polygon(var(--chamfer-sm) 0, 100% 0, 100% calc(100% - var(--chamfer-sm)), calc(100% - var(--chamfer-sm)) 100%, 0 100%, 0 var(--chamfer-sm));
  box-shadow: inset 0 0 0 1px var(--line2);
}
.pf-avatar { box-shadow: inset 0 0 0 1px var(--accent2); }
.attr-tile.tier-top { box-shadow: inset 0 0 0 1px var(--accent2); }
.attr-tile.tier-hi  { box-shadow: inset 0 0 0 1px #275645; }
.chip.warn { box-shadow: inset 0 0 0 1px var(--accent2); }
.chip.good { box-shadow: inset 0 0 0 1px #275645; }
.chip.bad  { box-shadow: inset 0 0 0 1px #6a3434; }
.lr-ava.tint-gold   { box-shadow: inset 0 0 0 1px var(--accent2); }
.lr-ava.tint-jade   { box-shadow: inset 0 0 0 1px #2c5d49; }
.lr-ava.tint-pink   { box-shadow: inset 0 0 0 1px #6a3a52; }
.lr-ava.tint-red    { box-shadow: inset 0 0 0 1px #6a3434; }
.lr-ava.tint-purple { box-shadow: inset 0 0 0 1px #4f3f7a; }

/* --- the age-up tablet: a notched cinnabar/jade seal ------------------ */
.tab-age {
  clip-path: polygon(var(--chamfer-sm) 0, 100% 0, 100% calc(100% - var(--chamfer-sm)), calc(100% - var(--chamfer-sm)) 100%, 0 100%, 0 var(--chamfer-sm));
  box-shadow: inset 0 0 0 1px var(--accent2);
}
.tab-age.ready { box-shadow: inset 0 0 0 1px var(--accent), inset 0 0 16px var(--aura); }
.tab-age.spent { animation: deedpulse 2s ease-in-out infinite; }
@keyframes deedpulse { 0%,100% { box-shadow: inset 0 0 0 1px rgba(230,197,133,.4); } 50% { box-shadow: inset 0 0 0 1px rgba(230,197,133,.95), inset 0 0 18px var(--aura); } }

/* --- the bottom sheet: a tablet with cut top corners + title rule ----- */
#overlay-card {
  border-radius: 0; border: none;
  clip-path: polygon(0 var(--chamfer), var(--chamfer) 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, 0 100%);
  box-shadow: inset 0 0 0 1px var(--line2);
}
#overlay-head { border-bottom: none; position: relative; }
#overlay-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 14px; background: var(--fret) repeat-x left center; opacity: .5; -webkit-mask: linear-gradient(90deg, #000 60%, transparent); mask: linear-gradient(90deg, #000 60%, transparent); }

/* --- a faint pressed-paper grain over the whole artifact -------------- */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 100; pointer-events: none; opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}
@media (prefers-reduced-motion: reduce) { .tab-age.spent { animation: none; } }

/* --- dramatic engraved English wordmark on the title page ------------- */
.wordmark {
  font-family: var(--font-drama); font-weight: 700; font-size: 1.18rem; letter-spacing: .12em;
  color: var(--gold); text-transform: uppercase; line-height: 1.1; margin-bottom: 2px;
  text-shadow: 0 1px 0 rgba(0,0,0,.5);
}

/* --- vermillion corner seal (印) stamped on hero cards ---------------- */
.chop {
  position: absolute; bottom: 11px; right: 11px; width: 30px; height: 30px; z-index: 2; pointer-events: none;
  transform: rotate(-4deg); opacity: .9;
  clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
  background: var(--seal-glyph) center/17px no-repeat, var(--seal-red);
  box-shadow: inset 0 0 0 1.4px rgba(255,236,222,.55), 0 2px 7px rgba(0,0,0,.4);
}
.scene .chop { top: 12px; right: 12px; bottom: auto; }

/* --- milestone scenes as woodblock prints: gilt double-rule + 回纹 band
       + ink-bled edges + a corner chop ----------------------------------- */
.scene-frame {
  position: absolute; inset: 0; pointer-events: none;
  background: var(--fret) repeat-x left top, var(--fret) repeat-x left bottom;
  background-size: auto 12px, auto 12px;
  box-shadow: inset 0 0 0 1px var(--gold2), inset 0 0 0 4px rgba(6,9,16,.55), inset 0 0 0 5px rgba(184,147,74,.4), inset 0 0 40px rgba(6,9,16,.6);
  filter: url(#inkedge);
}
.scene-cap { z-index: 3; }
