/* 2300萬分之1 — clean, light, editorial: serif headings (思源宋體 subset) over the phone's own sans-serif text,
   white cards on a pale grey page, ink blue for structure and vermilion for emphasis; the pixel pictures carry the character. */
:root {
  --bg: #F2F3F1; --paper: #FFFFFF; --soft: #EEF1EE; --ink: #1E2328; --muted: #61686F; --line: #D8DDD9; --rule: #E6EAE7;
  --accent: #23395B; --accent-ink: #FFFFFF; --red: #C0392B; --green: #2A7655; --blue: #2D5BA8; --hi: #FFF2BF; --stamp: #C0392B; --red-d: #9E2E22;
  --c1: #2E8B57; --c2: #C08A1E; --c3: #2C7A8C; --c4: #B5476B;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --serif-base: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --serif: var(--serif-base); /* becomes the bundled 思源宋體 once every piece of it has loaded (html.kai) */
  --kai: var(--sans); /* older stylesheets (panels.css, ending.css) use --kai for body text */
  --px: var(--sans);
  --sys: var(--sans);
  --desk: var(--bg);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171A; --paper: #1D2125; --soft: #252A2F; --ink: #E8EAEC; --muted: #9AA1A8; --line: #323940; --rule: #2A3036;
    --accent: #9DB8E6; --accent-ink: #14171A; --red: #EA7467; --green: #6FBF95; --blue: #8FB0EE; --hi: #3D3720; --stamp: #B23A2E; --red-d: #8A2A20;
    --c1: #5DBB86; --c2: #D9A640; --c3: #58AFC2; --c4: #D8789A; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171A; --paper: #1D2125; --soft: #252A2F; --ink: #E8EAEC; --muted: #9AA1A8; --line: #323940; --rule: #2A3036;
  --accent: #9DB8E6; --accent-ink: #14171A; --red: #EA7467; --green: #6FBF95; --blue: #8FB0EE; --hi: #3D3720; --stamp: #B23A2E; --red-d: #8A2A20;
  --c1: #5DBB86; --c2: #D9A640; --c3: #58AFC2; --c4: #D8789A; color-scheme: dark;
}
html.kai { --serif: "TW Serif", var(--serif-base); }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; min-height: 100dvh; font-family: var(--sans); font-size: 16px; line-height: 1.6; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body.noscroll { overflow: hidden; }
#app { max-width: 560px; margin: 0 auto; padding: 12px 16px 120px; }
[hidden] { display: none !important; }
p, dd, li, .ev, .opt > span, .note, .story, .desc { text-wrap: pretty; line-break: strict; }
/* notebook rows and card bodies: words never split (tidyWords), and two-line rows come out even, not 「…回家給／爸媽。」 */
.ev > .x, .sheet .body { text-wrap: balance; }
h1, h2, h3, .ph, .caption, .opt b, .sh-k, .toast, .lead, .hint, .receipt .ln > span:last-child { text-wrap: balance; line-break: strict; }
.nw { white-space: nowrap; }
.caption .cseg { display: inline-block; }
.caption small { color: var(--muted); font-size: 12px; }
button, a, .ev, .check, .opt { touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { font-size: 14px; color: var(--muted); line-height: 1.75; margin: 10px 0 0; }
h1, h2, h3, .ph, .logo, .name, .age, .draw-big { font-family: var(--serif); }
canvas.pixel { display: block; width: 100%; image-rendering: pixelated; image-rendering: crisp-edges; background: #bcdbe6; }

/* buttons */
.btn { display: block; width: 100%; border: 1px solid var(--accent); border-radius: var(--radius); padding: 13px 14px; font-size: 17px; font-weight: 700; background: var(--accent); color: var(--accent-ink); text-align: center; text-decoration: none; }
.btn.ghost { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn.stamp { background: var(--stamp); border-color: var(--stamp); color: #fff; } /* (--stamp, not --red: white on the lighter dark-mode red is under 4.5:1) */
.btn.mini { display: inline-block; width: auto; padding: 7px 14px; font-size: 15px; }
.btn + .btn { margin-top: 10px; }
.btn:active, .opt:active, .check:active, .pill:active { transform: translateY(1px); }
.link { display: block; margin: 10px auto 0; padding: 8px 12px; border: 0; background: none; color: var(--muted); font-size: 15px; text-decoration: underline; text-underline-offset: 4px; }
.pill { flex: none; min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--soft); font-weight: 700; font-size: 15px; white-space: nowrap; }

/* cards */
.panel { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 12px; scroll-margin-top: calc(var(--tbh, 110px) + 70px); }
.ph { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-weight: 700; font-size: 21px; margin-bottom: 10px; }
.ph small { font-family: var(--sans); font-weight: 400; font-size: 13px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 5em 1fr; gap: 6px 12px; margin: 0; font-size: 16px; line-height: 1.6; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.src { font-size: 12px; color: var(--muted); margin: 6px 0 0; line-height: 1.6; }

/* bottom call-to-action (home, birth card) */
.cta { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 18px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--bg) 40%); }
.cta > .btn { max-width: 528px; margin: 0 auto; font-size: 20px; letter-spacing: 4px; }
.cta.two { display: flex; gap: 10px; justify-content: center; }
.cta.two .btn { flex: 1; max-width: 259px; margin: 0; font-size: 17px; }
.btn.resume { padding: 7px 8px; line-height: 1.3; letter-spacing: 0; }
.btn.resume small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.btn.resume span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }

/* home */
.home { padding-top: 2vh; }
.home .crowd { border-radius: var(--radius); margin-bottom: 18px; }
.eyebrow { font-size: 13px; color: var(--green); margin: 0; font-weight: 700; }
.logo { font-size: clamp(44px, 13vw, 60px); font-weight: 700; line-height: 1.08; margin: 6px 0 14px; letter-spacing: -1px; }
.logo .one { color: var(--red); }
.lead { font-size: 17px; line-height: 1.8; margin: 0; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 20px 0 6px; }
.facts div { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 10px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-family: var(--serif); font-size: 24px; font-weight: 700; }
.facts small { font-family: var(--sans); font-size: 12px; font-weight: 400; margin-left: 2px; color: var(--muted); }
.shelf { margin: 22px 0 4px; }
.shelf-h { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.shelf-h b { font-family: var(--serif); font-size: 19px; }
.shelf-h small { color: var(--muted); font-size: 13px; }
.shelf-h a { margin-left: auto; font-size: 14px; color: var(--muted); padding: 8px 2px; }
.shelf-empty { margin: 0; font-size: 14px; color: var(--muted); background: var(--paper); border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; }
.life-card.left { opacity: .75; }
.life-card.left > small { color: var(--muted); }
/* 圖鑑 */
.collect .col-sh { margin-top: 14px; }
.col-h { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.col-h b { font-size: 16px; }
.col-h small { font-size: 12px; color: var(--muted); }
.col-row { display: flex; flex-wrap: wrap; gap: 6px; }
.col-row span { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--soft); color: var(--muted); border: 1px dashed var(--line); }
.col-row span.got { background: var(--paper); color: var(--ink); border: 1px solid var(--accent); }
.shelf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.life-card { cursor: pointer; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-bottom: 10px; }
.life-card canvas, .life-card .no-pic { margin-bottom: 6px; }
.life-card .no-pic { aspect-ratio: 110 / 50; background: var(--soft); }
.life-card > b, .life-card > span, .life-card > small, .life-card > q { padding: 0 10px; }
.life-card > b { font-family: var(--serif); font-size: 17px; }
.life-card > span { font-size: 12px; color: var(--muted); }
.life-card > small { font-size: 13px; color: var(--red); line-height: 1.4; }
.life-card > q { font-size: 12px; color: var(--blue); line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.links { margin-top: 18px; display: flex; gap: 22px; justify-content: center; }
.links a { color: var(--muted); font-size: 15px; display: inline-block; padding: 10px 8px; }

/* birth draw */
.draw { min-height: 72vh; min-height: 72dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.draw-h { font-size: 14px; color: var(--muted); letter-spacing: 4px; }
.draw-big { font-size: clamp(46px, 14vw, 64px); font-weight: 700; margin: 12px 0 8px; }
.draw-big.hit { color: var(--red); animation: pop .45s ease; }
.draw-s { font-size: 16px; color: var(--muted); }
@keyframes pop { 0% { transform: scale(.85); } 60% { transform: scale(1.1); } 100% { transform: none; } }

/* 出生紀錄 */
.bcard { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.bcard-h { display: flex; justify-content: space-between; align-items: center; background: var(--accent); color: var(--accent-ink); padding: 9px 14px; font-weight: 700; font-size: 15px; letter-spacing: 2px; }
.bcard-h .num { font-size: 12px; letter-spacing: 0; font-weight: 400; opacity: .85; }
.bcard-b { padding: 16px 16px 14px; }
.bcard .name { font-size: 40px; font-weight: 700; letter-spacing: 4px; line-height: 1.2; }
.story { font-size: 17px; line-height: 1.8; margin: 8px 0 12px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; margin: 0; border-top: 1px solid var(--line); }
.grid div { padding: 8px 0; border-bottom: 1px solid var(--rule); min-width: 0; }
.grid dt { font-size: 12px; color: var(--muted); }
.grid dd { margin: 2px 0 0; font-size: 16px; font-weight: 700; }
.dots { color: var(--red); letter-spacing: 2px; }
.note { font-size: 14px; color: var(--muted); line-height: 1.75; margin: 12px 0 0; }

/* top bar while living: age line + controls */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.tb-in { max-width: 560px; margin: 0 auto; padding: 8px 16px 10px; }
.tb1 { display: flex; align-items: center; gap: 12px; }
.tb1 .age { font-size: 18px; font-weight: 700; white-space: nowrap; line-height: 1; }
.tb1 .age span { font-size: 40px; margin-right: 2px; letter-spacing: -1px; }
.tb1 .meta { flex: 1; min-width: 0; }
#tb-sub { font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prog { height: 4px; border-radius: 2px; background: var(--rule); margin-top: 6px; overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: var(--red); border-radius: 2px; }
.tb2 { display: flex; gap: 6px; margin-top: 8px; }
.tb2 .play { flex: none; width: 48px; height: 44px; border: 0; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 900; }
.tb2 .play.paused { background: var(--stamp); color: #fff; }
.speed { flex: 1; display: flex; min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.speed button { flex: 1; min-width: 0; height: 42px; border: 0; border-left: 1px solid var(--line); background: transparent; font-size: 14px; padding: 0; color: var(--ink); letter-spacing: -.3px; }
.speed button:first-child { border-left: 0; }
.speed button.on { background: var(--ink); color: var(--bg); }
.next, .more { flex: none; height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); font-size: 15px; white-space: nowrap; }
.more { width: 42px; height: 40px; padding: 0; font-size: 18px; letter-spacing: 1px; }
.next.on { background: var(--stamp); border-color: var(--stamp); color: #fff; }

/* the status bar: four numbers, the year's 重心 and 花錢; sticks under the top bar */
.statbar { position: sticky; top: var(--tbh, 110px); z-index: 9; display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 2px 10px rgba(0, 0, 0, .05); }
.minis { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; min-width: 0; }
.mini { display: grid; min-width: 0; }
.mini > span { font-size: 12px; color: var(--muted); }
.mini b { font-size: 17px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.mini i { display: block; height: 4px; margin-top: 3px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.mini em { display: block; height: 100%; border-radius: 2px; transition: width .4s ease; }
.mini.c1 em { background: var(--c1); } .mini.c2 em { background: var(--c2); } .mini.c3 em { background: var(--c3); } .mini.c4 em { background: var(--c4); }
.focus-btn { padding: 0 14px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(192, 57, 43, .25); } }
.focus-btn.pulse, .pulse { animation: pulse 1s ease 4; }
@media (max-width: 380px) { .statbar { gap: 6px; padding: 8px 10px; } .pill { padding: 0 10px; font-size: 14px; } .mini b { font-size: 15px; } }
@media (max-height: 520px) { .statbar { position: static; } }

/* scene */
.scene-card { padding: 0; overflow: hidden; }
.scene-card canvas { cursor: pointer; }
.caption { display: block; width: 100%; text-align: left; border: 0; background: none; font-size: 17px; line-height: 1.6; padding: 12px 16px 14px; }

/* 人生紀錄 — newest on top; the age on the left */
.feedmoney { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--soft); border-radius: 8px; padding: 8px 10px 8px 14px; margin-bottom: 8px; font-size: 14px; color: var(--muted); }
.feedmoney b { color: var(--ink); }
.feedmoney b.neg { color: var(--red); }
.feedmoney .btn { margin-left: auto; padding: 6px 14px; }
.log:not(.all) .ev.old, .log:not(.all) .yr.old, .log:not(.all) .sec.old { display: none; }
.notebook .link { margin-top: 4px; }
.sec-h { display: flex; align-items: center; gap: 10px; padding: 12px 0 2px; font-size: 13px; color: var(--muted); }
.sec-h::after { content: ''; flex: 1; height: 1px; background: var(--rule); }
.yr { animation: none; }
.yr-a { display: none; } /* rows carry their own age now; kept in the page for the ending */
.yr-b { min-width: 0; }
/* a row: the age on the left, the line on the right, a hairline between rows (like the original) */
.ev { display: grid; grid-template-columns: 3.2em minmax(0, 1fr); column-gap: 8px; margin: 0; padding: 9px 2px; border-bottom: 1px solid var(--rule); font-size: 15px; line-height: 1.7; cursor: pointer; overflow-wrap: anywhere; }
.ev > .a { font-size: 12px; color: var(--muted); padding-top: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ev > .x { min-width: 0; }
.ev.fresh { animation: rowin 1.1s ease-out; }
.ev.fresh.quick { animation-duration: .45s; } /* at 8× and up many rows arrive at once */
@keyframes rowin { 0% { background: var(--hi); transform: translateY(-6px); } 25% { transform: none; } 100% { background: transparent; } }
.ev.star > .a::before { content: '★ '; color: var(--gold, #B8860B); font-size: 10px; }
.ev.ms > .x { color: var(--green); }
.ev.big > .x { font-weight: 700; }
.ev.loss > .x { font-weight: 700; color: var(--red); }
.ev.loss > .a::after { content: ' †'; }
.ev.choice { cursor: default; padding: 6px 2px; }
.ev.choice > .x { color: var(--muted); font-size: 13px; }

.ev.pen > .x, .pen { color: var(--blue); }
.ev.hist > .x { border-left: 2px solid var(--line); padding-left: 8px; color: var(--muted); font-size: 14px; }
.ev.hist > .a::after { content: ' ◆'; font-size: 9px; vertical-align: 2px; }
.ev.comp > .x { color: var(--muted); font-style: italic; }
.ev .fam { display: block; font-size: 12px; line-height: 1.5; color: var(--muted); font-weight: 400; white-space: nowrap; } /* its own line: never pushes the sentence's last words down */
.ev .fxk { font-style: normal; font-size: 12px; color: var(--muted); margin-left: 5px; opacity: .75; vertical-align: 1px; font-weight: 400; }
.ev .rowx { display: none; font-weight: 400; font-style: normal; color: var(--muted); }
.ev.open .rowx { display: block; margin-top: 4px; }
.ev.open .fxk { opacity: 0; }
.ev .rowx .fx, .ev .rowx .f { display: block; font-size: 12.5px; line-height: 1.5; margin-bottom: 4px; }
.ev .rowx .fx { color: var(--accent); }
.ev .rowx .f::before { content: '資料 '; color: var(--green); font-weight: 700; }
.stb { border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; font-size: 12.5px; padding: 4px 10px; min-height: 30px; margin-top: 2px; }
.stb[aria-pressed="true"] { border-color: var(--gold, #B8860B); color: var(--gold, #B8860B); }
/* rows saved by an older version (no age column inside) */
.ev:not(:has(> .a)) { display: block; padding-left: 3.2em; }
.ev:not(:has(> .a)).star { background: var(--hi); }
.fact { font-size: 12px; color: var(--muted); margin: -2px 0 6px; line-height: 1.55; padding-left: 3.2em; }
.fn { border: 0; background: none; color: var(--green); font-size: 12px; font-weight: 700; padding: 2px 6px 2px 0; margin-right: 4px; min-height: 22px; }
.fn::after { content: ' ▸'; font-weight: 400; }
.fn[aria-expanded="true"]::after { content: ' ▾'; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* 今年的重心 */
.desc { font-size: 15px; color: var(--muted); line-height: 1.7; margin: 0 0 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; flex-direction: column; align-items: flex-start; text-align: left; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); padding: 6px 16px 7px; min-height: 44px; justify-content: center; }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check b { font-size: 15px; line-height: 1.3; }
.check small { font-size: 12px; color: var(--muted); line-height: 1.3; }
.check.on small { color: var(--accent-ink); opacity: .85; }

/* peers */
.peers { list-style: none; margin: 0; padding: 0; }
.peers li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.peers li:last-child { border-bottom: 0; }
.peers b { font-size: 17px; }
.peers li div > span { display: block; font-size: 13px; color: var(--muted); }
.peers li > div:last-child { text-align: right; min-width: 0; }
.peers em { font-style: normal; font-weight: 700; font-size: 15px; }
.peers small { display: block; font-size: 13px; color: var(--muted); }
.peers li.gone em { color: var(--muted); font-weight: 400; }

/* life map: one square a year, rows are decades */
.lifemap { display: grid; gap: 3px; }
.mrow { display: grid; grid-template-columns: 24px repeat(10, 1fr); gap: 3px; align-items: center; }
.mrow > span { font-size: 10px; color: var(--muted); text-align: right; padding-right: 3px; }
.mrow i { aspect-ratio: 1; background: var(--soft); border-radius: 2px; }
.mrow i.lived { background: color-mix(in oklab, var(--accent) calc(var(--j) * 1%), var(--paper)); }
.mrow i.le { outline: 2px solid var(--red); outline-offset: -1px; }
.mrow i.cur { background: var(--red); animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* survival curve */
.curve { width: 100%; height: auto; display: block; }
.curve .gl { stroke: var(--rule); stroke-width: 1; fill: none; }
.curve .ln { stroke: var(--accent); stroke-width: 2.5; fill: none; stroke-linejoin: round; }
.curve .dot { fill: var(--red); }
.curve text { font-size: 10px; fill: var(--muted); }
.curve text.hl { font-size: 13px; font-weight: 700; fill: var(--ink); }

/* county stats */
.cgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 0; }
.cgrid dt { font-size: 13px; color: var(--muted); }
.cgrid dd { margin: 2px 0 0; font-size: 19px; font-weight: 700; }

/* dialogs: decisions, menu, notes — a card in the middle of the screen */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(20, 24, 28, .45); display: flex; align-items: center; justify-content: center; padding: 16px; animation: dim .2s ease; }
.sheet { width: 100%; max-width: 528px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 0 18px 18px; box-shadow: 0 12px 40px rgba(0, 0, 0, .18); animation: up .2s ease; }
.sheet > h3:first-child, .sheet > .sh-k:first-child { margin-top: 18px; }
@keyframes up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes dim { from { background: rgba(0, 0, 0, 0); } }
.sh-k { font-size: 14px; font-weight: 700; color: var(--red); }
.sheet h3 { margin: 6px 0 10px; font-size: 26px; line-height: 1.35; }
.sheet .body { color: var(--ink); line-height: 1.75; margin: 0 0 14px; font-size: 17px; }
.exam-h { display: flex; align-items: center; gap: 10px; margin: 0 -18px 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 15px; color: var(--red); }
.exam-h > span:first-child { font-weight: 700; color: var(--red); }
.peek-btn { margin-left: auto; border: 1px solid var(--line); border-radius: 999px; background: var(--soft); color: var(--ink); font-size: 14px; padding: 6px 14px; min-height: 36px; }
.sheet .fact { background: var(--soft); border-left: 4px solid var(--green); border-radius: 0 6px 6px 0; padding: 10px 12px; margin: 0 0 14px; color: var(--ink); font-size: 14px; }
.opt { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--soft); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.opt b { display: block; font-size: 18px; }
.opt > span { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.opt:disabled { opacity: .45; }
.opts .opt { display: grid; grid-template-columns: 30px 1fr; column-gap: 6px; min-height: 64px; align-items: center; }
.opts .opt i { grid-row: 1 / span 2; font-style: normal; font-size: 15px; color: var(--muted); }
.opts .opt > b, .opts .opt > span { grid-column: 2; }
.opts .opt.picked { border-color: var(--accent); background: var(--paper); box-shadow: inset 0 0 0 1px var(--accent); }
.opts .opt.picked i { color: var(--accent); }
.sheet:focus { outline: none; }
.opts .opt.pre { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
/* 「其他選項」 opens the rest of a long list; a locked option is greyed out with its reason and cannot be chosen */
.opts .more { display: grid; grid-template-columns: 30px 1fr; column-gap: 6px; align-items: center; width: 100%; min-height: 64px; margin-bottom: 10px; padding: 12px 14px; text-align: left; border: 1px dashed var(--muted); border-radius: 8px; background: transparent; color: var(--ink); touch-action: manipulation; }
.opts .more i { grid-row: 1 / span 2; font-style: normal; font-size: 15px; color: var(--muted); }
.opts .more > b { grid-column: 2; display: block; font-size: 18px; }
.opts .more > span { grid-column: 2; display: block; font-size: 14px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.opts .more:active { transform: translateY(1px); }
@media (hover: hover) { .opts .more:hover { border-color: var(--accent); } }
.opts .opt.locked { min-height: 0; padding: 10px 14px; border-style: dashed; background: transparent; opacity: 1; cursor: not-allowed; }
.opts .opt.locked i { grid-row: 1 / span 2; align-self: start; }
.opts .opt.locked > b { font-size: 16px; font-weight: 600; color: var(--muted); }
.opts .opt.locked > span { margin-top: 1px; color: var(--muted); }
@media (hover: hover) { .opt:not(:disabled):hover { border-color: var(--accent); } }
#fate, .sheet .link { display: block; margin: 6px auto 0; padding: 10px 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); text-decoration: none; font-size: 15px; }
.countdown { margin-top: 8px; font-size: 13px; color: var(--muted); text-align: center; }
.countdown i { display: block; height: 4px; background: var(--rule); border-radius: 2px; position: relative; overflow: hidden; margin-bottom: 6px; animation-name: none; }
.countdown i::after { content: ''; position: absolute; inset: 0; background: var(--green); transform-origin: left; animation: inherit; animation-name: countdown; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.countdown .link { display: inline-block; margin-top: 4px; }
.peek-bar { display: none; }
.modal.peek { background: transparent; pointer-events: none; align-items: flex-end; }
.modal.peek .sheet { pointer-events: auto; max-height: none; overflow: visible; padding: 10px 14px; }
.modal.peek .sheet > *:not(.peek-bar) { display: none; }
.modal.peek .peek-bar { display: flex; align-items: center; gap: 10px; }
.peek-bar span { font-size: 12px; color: var(--muted); flex: none; }
.peek-bar b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; font-size: 17px; line-height: 1.6; color: var(--blue); background: var(--paper); resize: none; margin: 0 0 12px; }

/* the end (older layout pieces still used by js/ending.js) */
.receipt { background: #FFFDF8; color: #222; border-radius: 4px; padding: 22px 20px; box-shadow: 0 3px 12px rgba(0, 0, 0, .08); }
.receipt h3 { text-align: center; margin: 0 0 4px; font-size: 22px; letter-spacing: 4px; }
.receipt .rsub { text-align: center; font-size: 12px; color: #6B6B6B; margin-bottom: 12px; }
.receipt .ln { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 15px; }
.receipt .ln > span:first-child { color: #6B6B6B; flex: none; }
.receipt .ln > span:last-child { text-align: right; }
.receipt hr { border: 0; border-top: 2px dashed #ccc; margin: 10px 0; }
.receipt .title { text-align: center; font-family: var(--serif); font-size: 21px; font-weight: 700; margin: 6px 0; }
.receipt .one { text-align: center; font-size: 15px; color: #555; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.row2 .btn { margin: 0; padding: 13px 6px; font-size: 16px; }
.end > .btn { margin-top: 14px; }
.imgview { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .88); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; }
.imgview img { max-width: 100%; max-height: 72dvh; }
.imgview p { color: #fff; font-size: 14px; text-align: center; margin: 0; }
.imgview .btn { max-width: 320px; }
.imgview .btn.ghost { color: #fff; border-color: #fff; background: transparent; }
.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 15px; line-height: 1.6; animation: toastIn .2s ease; }
@keyframes toastIn { from { transform: translate(-50%, 16px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

.page { line-height: 1.85; }
.page h2 { margin-top: 20px; }
.page li { margin: 4px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
