:root {
  color-scheme: dark;
  --ink: #0b0908;
  --zhu: #c8161d;
  --gold: #e6b422;
  --gold2: #f3d77a;
  --rice: #fbf1da;
  --gray: #a89f94;
  --wine: #5a0a0e;
  --wine2: #7a0e12;
  --line: rgba(230, 180, 34, .3);
  --field-line: rgba(230, 180, 34, .5);
  --display: 'Cactus Classical Serif', 'Noto Serif TC', 'PMingLiU', serif;
  --ui: 'Chiron GoRound TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --s14: 14px; --s16: 16px; --s20: 20px; --s28: 28px; --s52: 52px;
  --chart-ink: var(--rice);
  --chart-paper: var(--ink);
  --chart-game: var(--gold2);
  --chart-official: var(--zhu);
  --chart-grid: var(--line);
  --meander: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Cpath d='M1 1h8v8H3V3h4v4H5' fill='none' stroke='%23e6b422' stroke-width='1'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ink); color: var(--rice); font: var(--s16)/1.7 var(--ui); }
/* 共用外框：報頭、LED 與跑馬燈；LED 的等義文字在無 WebGL 時直接可讀。 */
.broadcast-frame { margin-bottom: 32px; border: 1px solid var(--gold); }
.frame-hud { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 12px 24px; border-bottom: 1px solid var(--line); }
.frame-bug { display: inline-flex; white-space: nowrap; font-size: var(--s14); font-weight: 900; }
.frame-badge { background: var(--gold); color: var(--ink); padding: 3px 12px; }
.frame-channel { background: var(--rice); color: var(--ink); padding: 3px 12px; font-family: var(--display); }
.frame-hud time { color: var(--gold2); font-variant-numeric: tabular-nums; }
.frame-hud strong { margin-left: auto; white-space: nowrap; }
.frame-family { flex-basis: 100%; color: var(--gray); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.frame-ledbox { position: relative; height: 200px; background: #120b0a; display: grid; place-items: center; }
.frame-ledbox canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.frame-led-text { font-size: var(--s52); color: var(--gold2); font-weight: 900; }
.led-accessible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
[data-mode="studio"] .frame-ledbox { height: 140px; }
[data-mode="event"] .frame-badge { background: var(--zhu); color: var(--rice); }
[data-mode="event"] .frame-badge::before { content: "●"; margin-right: 6px; animation: live-dot 1.4s steps(2) infinite; }
.ticker { display: flex; background: var(--zhu); color: var(--rice); border-top: 2px solid var(--gold); font-weight: 900; }
.ticker-label { display: flex; align-items: center; background: var(--gold); color: var(--ink); padding: 8px 14px; white-space: nowrap; }
.ticker-window { overflow: hidden; min-width: 0; display: flex; align-items: center; }
.ticker-window p { white-space: nowrap; padding-left: 100%; animation: ticker-run 36s linear infinite; }
.ticker:hover p, .ticker:focus-within p { animation-play-state: paused; }
body:has(.broadcast-frame) header { margin-bottom: 24px; }
@keyframes live-dot { 50% { visibility: hidden; } }
@keyframes ticker-run { to { transform: translateX(-100%); } }
@media (max-width: 899px) {
  .frame-hud { display: grid; grid-template-columns: minmax(0,1fr) auto; padding: 8px 12px; gap: 6px 10px; }
  .frame-hud time { display: none; }
  .frame-family { grid-column: 1 / -1; }
  .frame-ledbox { height: 160px; }
  [data-mode="studio"] .frame-ledbox { height: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  .ticker-window p { white-space: normal; padding: 8px 12px; animation: none; }
  [data-mode="event"] .frame-badge::before { animation: none; }
}
/* 沿用既有網格與閱讀順序，套用野台基礎樣式。 */
main {
  width: min(100% - 2rem, 40rem);
  margin: clamp(2rem, 7vw, 5rem) auto;
}

header { margin-bottom: 2rem; }
h1, h2, p { margin: 0; }
h1 { font-size: var(--s14); line-height: 1.15; }
h2 { font-size: var(--s14); }
[hidden] { display: none !important; }
.eyebrow { color: var(--gold2); margin-bottom: .65rem; font-weight: 700; }
.intro { margin-top: .8rem; }

.record {
  border: 1px solid var(--line);

  background: var(--ink);
  padding: clamp(1rem, 4vw, 1.75rem);
}

.record-heading, .record-date {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .35rem 1rem;
  justify-content: space-between;
}

.record-heading { padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.stamp { color: var(--gold2); font-size: var(--s14); font-weight: 700; }
.record-date { justify-content: start; margin-block: 1rem; }
.record-date time { font-size: var(--s14); font-weight: 700; }
.record-date span { color: var(--gold2); font-weight: 700; }

.settings, .controls { display: flex; flex-wrap: wrap; gap: .75rem; }
.settings label { display: grid; flex: 1 1 8rem; gap: .25rem; }
.controls { margin-top: 1rem; }

select, button {
  min-height: 2.75rem;
  border: 1px solid var(--field-line);
  border-radius: .25rem;
  padding: .45rem .75rem;
  color: inherit;
  background: var(--ink);
  font: inherit;
}

button { cursor: pointer; }
#restart, #skip, .primary { background: var(--rice); color: var(--ink); }
button:disabled { cursor: default; background: transparent; color: var(--gray); border-color: var(--line); }
:focus-visible { outline: 3px solid var(--gold2); outline-offset: 3px; }
.note, footer { margin-top: 1rem; color: var(--gray); font-size: var(--s14); }
#debt-notice:empty { margin: 0; }
footer p + p { margin-top: .25rem; }

.ledger { border-top: 1px solid var(--line); margin-top: 1.1rem; padding-top: .75rem; }
.caption { color: var(--gray); font-size: var(--s14); }
.ledger dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin: .5rem 0 0; }
.ledger dt { font-size: var(--s14); color: var(--gray); }
.ledger dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.cohort-report, .life-history { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: .85rem; }
.cohort-report h3, .cohort-metric h4, .life-history h3, .history-rows h4 { margin: 0; font-size: var(--s14); }
.cohort-metric { margin-top: .6rem; padding: .65rem .8rem; border: 1px solid var(--line); background: var(--ink); }
.cohort-metric dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem .6rem; margin: .35rem 0 0; }
.cohort-metric dt { color: var(--gray); font-size: var(--s14); }
.cohort-metric dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cohort-report .caption + .caption { margin-top: .2rem; }
@media (min-width: 32rem) {
  .cohort-metric dl { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.history-rows { margin: .65rem 0 0; padding-inline-start: 1.4rem; }
.history-rows li { padding: .55rem 0; }
.history-rows li + li { border-top: 1px solid var(--line); }
.history-rows li::marker, .history-date { color: var(--gold2); font-size: var(--s14); font-weight: 700; }
.history-rows dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .2rem .65rem; margin: .3rem 0 0; }
.history-rows dt { color: var(--gray); }
.history-rows dd { margin: 0; overflow-wrap: anywhere; }

.scene { margin-top: 1rem;  }
.scene h2 { font-size: var(--s14); }
.scene-summary, .scene details, .scene .caption { margin-top: .75rem; }
.scene .primary { margin-top: .65rem; }
.scene details { border-block-start: 1px solid var(--line); padding-block: .55rem; }
.scene summary { cursor: pointer; font-weight: 700; }
.scene details p { margin-top: .45rem; }
.scene a { color: var(--gold2); }
.scene-art { display: block; width: 100%; height: auto; margin-top: .65rem; }
.scene blockquote { margin: .7rem 0 0; padding-left: .65rem; border-left: 2px solid var(--line); }
.choices { display: grid; gap: .55rem; }
.choice { text-align: start; font-weight: 700; background: var(--ink); padding: .65rem .8rem; }
.choice:hover { background: var(--wine); }
.choice span { display: block; color: var(--gray); font-weight: 400; font-size: var(--s14); }
.result { margin-block: .65rem; padding: .65rem .85rem; background: var(--ink); border-left: 3px solid var(--gold2); }
.result h3 { margin: 0 0 .25rem; font-size: var(--s14); }
.result p:empty { display: none; }
.result p + p:not(:empty) { margin-top: .4rem; }

.family-options { min-inline-size: 0; margin: .8rem 0; padding: .65rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: .6rem; }
.family-options > .caption { grid-column: 1 / -1; }
.family-card { display: block; padding: .65rem; border: 1px solid var(--line); background: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.family-card:has(input:checked) { border: 2px solid var(--gold2); background: var(--ink); }
.family-card:focus-within { outline: 2px solid var(--gold2); outline-offset: 2px; }
.family-card h3 { margin: .35rem 0; font-size: var(--s14); }
.family-card p { font-size: var(--s14); }
.goal-options { min-inline-size: 0; margin: .8rem 0; padding: .65rem; display: grid; gap: .5rem; }
.goal-option { display: block; cursor: pointer; overflow-wrap: anywhere; }
.goal-option strong { margin-inline-start: .35rem; }
.goal-option span { display: block; color: var(--gray); font-size: var(--s14); }
.choice .goal-hint { margin-top: .35rem; color: var(--gold2); font-weight: 700; }
.ending-report { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; margin-top: 1.25rem; }
.ending-report > section { min-width: 0; margin-top: 0; padding-top: .85rem; border-top: 1px solid var(--line); }
.ending-report .cohort-metric dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.goals-report h3, .goal-result h4 { margin: 0; font-size: var(--s14); }
.goal-result { margin-top: .6rem; padding: .65rem .8rem; border: 1px solid var(--line); background: var(--ink); overflow-wrap: anywhere; }
.goal-result p { font-size: var(--s14); margin-top: .35rem; }
@media (min-width: 52rem) { .ending-report { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 報告清單的長家庭名稱與日期在窄螢幕換行。 */
.savings-panel { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.savings-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: .7rem; margin-block: .7rem; }
.savings-inputs > div { min-width: 0; }
.savings-inputs label { display: block; font-weight: 700; }
.savings-inputs input { display: block; box-sizing: border-box; width: 100%; min-width: 0; margin-top: .25rem; padding: .45rem; font: inherit; }
.savings-inputs p, .savings-panel .caption, .savings-report { overflow-wrap: anywhere; }
.savings-report { border-top: 1px solid var(--line); margin-top: .85rem; padding-top: .65rem; }
.savings-report h4 { margin: 0; }
#savings-error:empty { display: none; }

.report-list { list-style: none; padding: 0; }
.report-entry { border-top: 1px solid var(--line, var(--line)); padding: 0.75rem 0; overflow-wrap: anywhere; }
#report-view-date { overflow-wrap: anywhere; }
#cohort-snapshot-label, #cohort-backfilled, #cohort-latest { overflow-wrap: anywhere; }
.branch-lock, .branch-unavailable { color: var(--gold2); font-weight: 700; overflow-wrap: anywhere; }
.comparison-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: .65rem; margin-top: .8rem; }
.comparison-pair article { min-width: 0; padding: .7rem; border: 1px solid var(--line); overflow-wrap: anywhere; }
.comparison-pair h4 { margin: 0 0 .4rem; }
.comparison-pair p { margin-top: .35rem; }
.comparison-changed article { border: 2px solid var(--gold2); background: var(--ink); }
.comparison-difference, .comparison-first { color: var(--gold2); font-weight: 700; }
.comparison-reality-section { border-top: 3px solid var(--zhu); margin-top: 1.5rem; padding-top: .8rem; }
@media (min-width: 40rem) { .comparison-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 圖表共用野台色票，保留既有座標與虛線參考值。 */
.report-chart { margin: .8rem 0; padding: .5rem; background: var(--chart-paper); color: var(--chart-ink); border: 1px solid var(--chart-grid); min-width: 0; container-type: inline-size; }
.report-chart svg { display: block; width: 100%; max-width: 24rem; height: auto; margin: 0 auto; }
.report-chart text { fill: var(--chart-ink); font-family: inherit; }
.report-chart .chart-game { fill: var(--chart-game); }
.report-chart .chart-official { fill: var(--chart-official); }
.report-chart .chart-reference { fill: var(--chart-official); fill-opacity: .25; stroke: var(--chart-official); stroke-width: 1.3; stroke-dasharray: 3 2; }
.report-chart .chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.report-chart .chart-zero { stroke: var(--chart-ink); stroke-width: 1.8; }
.report-chart .chart-line { stroke: var(--chart-game); stroke-width: 2; fill: none; }
.report-chart .caption, .report-chart a { color: var(--chart-ink); overflow-wrap: anywhere; }
.report-chart table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: var(--s14); }
.report-chart th, .report-chart td { padding: .35rem; border-bottom: 1px solid var(--chart-grid); overflow-wrap: anywhere; text-align: left; }
@container (max-width: 24rem) {
  .report-chart .chart-table-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .report-chart tr:not(.chart-table-head) { display: block; padding: .4rem 0; border-bottom: 1px solid var(--chart-grid); }
  .report-chart td { display: block; border: 0; padding: .15rem 0; }
  .report-chart td::before { content: attr(data-label) "："; font-weight: 700; }
}

/* 野台元件的字級、狀態及材質。 */
h1 { font: 400 var(--s52)/1.25 var(--display); }
h2, h3, h4 { font-size: var(--s20); line-height: 1.5; }
a { color: var(--gold2); overflow-wrap: anywhere; text-underline-offset: 3px; }
.eyebrow { color: var(--gold); font-size: var(--s14); font-weight: 900; }
.record { position: relative; }
.record::before { content: ""; position: absolute; inset: 0 0 auto; height: 10px; background: var(--wine) var(--meander); }
.scene h2 { font: 400 var(--s28)/1.5 var(--display); }
.record-date time { font-size: var(--s28); font-weight: 900; }
.yatai-beam { display: grid; place-items: center; position: relative; margin-bottom: 40px; min-height: 72px; }
.yatai-beam::before { content: ""; position: absolute; inset: 24px 0 auto; height: 18px; background: var(--zhu) var(--meander); border-block: 1px solid var(--gold); }
.yatai-beam span { position: relative; background: var(--ink); color: var(--gold2); border: 3px solid var(--gold); outline: 1px solid var(--gold); outline-offset: -8px; padding: 8px 28px; font: 400 var(--s28)/1.6 var(--display); letter-spacing: .3em; text-indent: .3em; }
select, input, button { min-height: 48px; max-width: 100%; border: 1px solid var(--field-line); border-radius: 0; padding: 8px 12px; color: var(--rice); background: var(--ink); font: inherit; }
input[type="radio"], input[type="checkbox"] { min-height: auto; accent-color: var(--zhu); }
button { color: var(--gold2); border-color: var(--gold); background: transparent; overflow-wrap: anywhere; }
#restart, #skip, .primary { min-height: 52px; background: var(--gold); color: var(--ink); font-weight: 900; }
button:disabled, #restart:disabled, #skip:disabled, .primary:disabled { background: transparent; border-color: var(--line); color: var(--gray); }
button:disabled span { color: var(--gray); }
:focus-visible { outline: 3px solid var(--gold2); outline-offset: 3px; }
.choice { color: var(--ink); background: var(--rice); border-color: var(--gold); font-weight: 900; transition: transform .15s ease; }
.choice::before { content: ""; display: block; height: 4px; background: var(--zhu); margin-bottom: 12px; }
.choice:hover:not(:disabled) { background: var(--rice); transform: translateY(-2px); }
.choice span, .choice .goal-hint { color: #4a3e33; font-size: var(--s14); }
.family-card, .goal-option { position: relative; padding: 16px; background: var(--rice); color: var(--ink); border: 1px solid var(--gold); }
.family-card h3, .family-card strong, .goal-option strong { font-family: var(--display); font-weight: 400; }
.family-card h3 { font-size: var(--s20); padding-right: 44px; }
.family-card p, .family-card .caption, .goal-option span { color: #4a3e33; font-size: var(--s14); }
.goal-option strong { display: inline-block; padding-right: 44px; }
.family-card:has(input:checked), .goal-option:has(input:checked) { border: 1px solid var(--gold); background: var(--rice); box-shadow: 0 0 12px rgba(243, 215, 122, .5); }
.family-card:has(input:checked)::after, .goal-option:has(input:checked)::after { content: "已選"; position: absolute; right: 10px; top: 10px; padding: 3px; border: 2px solid var(--zhu); color: var(--zhu); background: var(--rice); font: var(--s14)/1.5 var(--display); transform: rotate(-8deg); }
.ledger dl, .cohort-metric dl { gap: 1px; border: 1px solid var(--line); }
.ledger dl > div, .cohort-metric dl > div { position: relative; min-width: 0; padding: 18px 8px 12px; border: 1px solid var(--line); }
.ledger dl > div::before, .cohort-metric dl > div::before { content: ""; position: absolute; inset: 0 0 auto; height: 6px; background: var(--wine) var(--meander); }
.ledger dd, .cohort-metric dd { font-size: var(--s20); font-weight: 900; overflow-wrap: anywhere; }
#cash, #life-cash { color: var(--gold2); }
.result { border: 1px solid var(--line); border-left: 3px solid var(--zhu); }
.result h3, .goals-report h3, .goal-result h4, .cohort-report h3, .cohort-metric h4, .life-history h3, .history-rows h4 { font-size: var(--s20); }
.scene-art { padding: 8px; background: var(--rice); border: 1px solid var(--gold); }
.report-chart text { font-size: var(--s14); }
.report-chart text[font-size="18"] { font-size: var(--s20); }
.report-chart text[font-size="16"] { font-size: var(--s16); }
.report-chart .chart-reference { stroke: var(--gold2); }
.comparison-reality-section { border-top-color: var(--zhu); }
.settings label, .controls label { min-width: 0; }
@media (max-width: 600px) { :root { --s52: 28px; --s28: 20px; } }
@media (prefers-reduced-motion: reduce) {
  .choice { transition: none; }
  .choice:hover:not(:disabled) { transform: none; }
}

/* 節目單沿用原控制項與回呼，分段按鈕只同步 select。 */
body:has(#opening-layout) main { width: min(100% - 64px, 1320px); margin: 24px auto; }
body:has(#opening-layout) > main > header { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#run-panel { border: 0; padding: 0; }
#run-panel > .record-heading, #run-panel > .record-date, #run-panel > .settings, #run-panel > .settings + .note { display: none; }
.opening-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 32px; align-items: start; }
.opening-step { margin-bottom: 36px; min-width: 0; }
.opening-step h2 { margin-bottom: 20px; }
#run-panel::before { display: none; }
.opening-step > label { display: block; margin-bottom: 32px; color: var(--gold2); font-size: var(--s14); }
.opening-step .seg { margin-top: 8px; }
.seg { display: flex; flex-wrap: wrap; border: 1px solid var(--gold); width: fit-content; gap: 0; }
.seg button { border: 0; border-radius: 0; min-height: 48px; font-size: var(--s16); }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--ink); font-weight: 900; }
.family-options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; padding: 0; border: 0; }
.family-options > legend, .family-options > .caption { grid-column: 1 / -1; }
.family-options > legend { font-size: var(--s14); color: var(--gray); }
.family-card { min-width: 0; margin: 0; padding: 0 16px 18px; }
.family-card > strong { display: block; margin: 0 -16px 12px; padding: 8px 14px; background: var(--zhu); color: var(--rice); font-size: var(--s14); }
.family-card[data-difficulty="地獄"] > strong { background: var(--wine); }
.family-card input { margin-top: 14px; }
.family-card h3 { line-height: 1.45; margin: 12px 0; padding-right: 0; text-wrap: balance; }
.family-card:has(input:checked)::after { content: "已選"; }
.goal-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; border: 0; padding: 0; }
.goal-options > legend, .goal-options > .caption { grid-column: 1 / -1; }
.goal-option { margin: 0; background: var(--ink); color: var(--rice); border: 1px solid var(--field-line); }
.goal-option span { color: var(--gray); }
.goal-option:has(input:checked) { background: var(--rice); color: var(--ink); }
.goal-option:has(input:checked) span { color: var(--ink); }
.goal-option:has(input:checked)::after { content: "目標"; }
.goal-option:has(input:disabled:not(:checked)) { border-color: var(--line); color: var(--gray); }
.family-card:focus-within, .goal-option:focus-within { outline: 3px solid var(--gold2); outline-offset: 3px; }
#opening-side { position: sticky; top: 24px; min-width: 0; }
.opening-bill { padding: 24px; border: 1px solid var(--gold); }
.opening-bill dl { margin: 20px 0; }
.opening-bill dt { margin-top: 16px; font-size: var(--s14); color: var(--gray); }
.opening-bill dd { margin: 4px 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.opening-bill > label { display: block; font-size: var(--s14); color: var(--gold2); }
.opening-bill .seg { width: 100%; margin: 8px 0; }
.opening-bill .seg button { flex: 1; }
.opening-bill > button { width: 100%; margin-top: 16px; }
#speed + .seg { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
#speed + .seg button { padding-inline: 6px; }
#opening-reruns { margin-top: 28px; }
.opening-dock { position: fixed; bottom: 0; left: 0; right: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom,0px)); background: var(--ink); border-top: 1px solid var(--gold); z-index: 30; }
.opening-dock button { width: 100%; min-height: 56px; background: var(--gold); color: var(--ink); font-weight: 900; }
body[data-view="preview"] { padding-bottom: 80px; }
body:not([data-view="preview"]) #opening-main { display: none; }
body:not([data-view="preview"]) .opening-layout { display: block; }
body:not([data-view="preview"]) #opening-side { position: static; }
body:not([data-view="preview"]) #bill-summary, body:not([data-view="preview"]) .opening-bill > .eyebrow, body:not([data-view="preview"]) .opening-bill > h2 { display: none; }
@media (min-width: 900px) { .opening-dock { display: none !important; } }
@media (max-width: 1099px) { .family-options { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 899px) {
  body:has(#opening-layout) main { width: calc(100% - 32px); }
  .opening-layout { grid-template-columns: minmax(0,1fr); }
  #opening-side { position: static; }
}
@media (max-width: 599px) { .family-options, .goal-options { grid-template-columns: minmax(0,1fr); } }

/* 棚內：主數字、進度與提撥共用同一套月結版型。 */
:root { --s36: 36px; }
.studio-layout { display: grid; grid-template-columns: minmax(0,2fr) minmax(280px,1fr); gap: 32px; align-items: start; }
#studio-main, #studio-side { min-width: 0; }
#ledger { margin-top: 0; border: 0; padding-top: 0; }
.ledger dl.figs { display: grid; grid-template-columns: 2fr repeat(3,minmax(0,1fr)); gap: 0; border: 0; border-block: 1px solid var(--line); }
.figs > div { border: 0 !important; border-right: 1px solid var(--line) !important; padding: 18px 12px !important; }
.figs > div::before { display: none; }
.figs dd { margin: 6px 0 0; font-variant-numeric: tabular-nums; overflow-wrap: normal; }
.figs .hero dd:first-of-type { font-size: var(--s36); color: var(--gold2); white-space: nowrap; }
.figs :is(#household-in, #household-out, #monthly-balance, #life-income, #life-expenses) { white-space: nowrap; }
.figs dt { font-size: var(--s14); }
.figs .hero dd.caption { font-size: var(--s14); color: var(--gray); font-weight: 400; }
#meal-budget { grid-column: 1 / -1; }
.notice { border: 1px solid var(--zhu); background: rgba(200,22,29,.1); padding: 12px 14px; margin-top: 16px; font-size: var(--s14); }
#studio-progress { margin: 32px 0; }
.life-track { position: relative; height: 130px; margin-top: 16px; }
.track-rail { position: absolute; left: 0; right: 0; top: 48px; height: 8px; background: var(--line); }
.track-rail::before { content: ""; display: block; width: var(--progress); height: 100%; background: var(--gold); }
.track-now { position: absolute; top: -8px; left: var(--progress); width: 3px; height: 24px; background: var(--rice); box-shadow: 0 0 0 3px var(--zhu); }
.track-start, .track-end { position: absolute; bottom: 0; font-size: var(--s14); color: var(--gray); }
.track-end { right: 0; }
.track-label { position: absolute; max-width: 150px; transform: translateX(-50%); color: var(--gold2); font-size: var(--s14); text-align: center; line-height: 1.4; }
.track-next { top: 4px; left: clamp(56px, var(--next-position), calc(100% - 56px)); white-space: nowrap; padding-inline: 4px; border-bottom: 2px solid var(--zhu); background: var(--ink); }
.track-mark { position: absolute; top: 43px; width: 2px; height: 18px; background: var(--gold2); }
.bill-setting { display: block; margin-top: 4px; color: var(--gray); font-size: var(--s14); }
.difficulty-badge { display: inline-block; margin-top: 8px; padding: 0 8px; background: var(--wine); color: var(--rice); font-size: var(--s14); }
.studio-controls { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.studio-controls #play { min-width: 160px; }
.studio-controls #skip { background: transparent; color: var(--gold2); font-weight: 400; }
.studio-controls .note { flex-basis: 100%; margin-top: 0; }
#studio-speed { margin-bottom: 32px; }
#studio-speed > label { font-size: var(--s14); color: var(--gold2); }
#studio-side { border-left: 1px solid var(--line); padding-left: 24px; }
#studio-records { padding-left: 20px; font-size: var(--s14); }
#studio-records li { padding-block: 12px; border-bottom: 1px solid var(--line); }
.next-event { margin-top: 28px; border: 1px solid var(--gold); border-top: 16px solid var(--zhu); padding: 20px; background: var(--rice); color: var(--ink); }
.next-event .eyebrow { color: #7a5a0a; }
.next-event h3 { font-family: var(--display); margin: 10px 0; }
.next-event p { font-size: var(--s14); }
.savings-inputs { grid-template-columns: repeat(3,minmax(0,1fr)); }
.account-card { border: 1px solid var(--line); padding: 16px; }
.account-card label { font-family: var(--display); font-weight: 400; }
.account-card progress { width: 100%; height: 6px; display: block; margin-top: 16px; accent-color: var(--gold); border: 0; }
#configure-next { margin: 24px 0; }
@media (max-width: 1099px) { .ledger dl.figs { grid-template-columns: repeat(3,minmax(0,1fr)); } .figs .hero { grid-column: 1 / -1; } }
@media (max-width: 899px) {
  :root { --s36: 28px; }
  .studio-layout { grid-template-columns: minmax(0,1fr); }
  #studio-side { border-left: 0; border-top: 1px solid var(--line); padding: 24px 0 0; }
  .figs > div { padding-inline: 6px !important; }
  .figs dd { font-size: var(--s20); }
  .studio-controls { display: grid; grid-template-columns: minmax(0,1fr); }
  .studio-controls button:disabled { order: 3; }
  .savings-inputs { grid-template-columns: minmax(0,1fr); }
  .track-label:not(.track-next) { display: none; }
}

/* 事件轉播，字幕條與場景共用原本可聚焦的標題。 */
.pillar { display: none; }
[data-mode="event"] .proscenium { display: grid; grid-template-columns: 32px minmax(0, 1fr) 32px; }
[data-mode="event"] .pillar { display: block; position: relative; background: linear-gradient(90deg, var(--wine), var(--zhu) 48%, var(--wine)); }
.pillar::before { content: ""; position: absolute; inset: 0 -3px auto; height: 12px; background: var(--gold); }
.event-inside { position: relative; min-width: 0; }
.lower { padding: 16px; animation: event-caption-in .25s ease-out; }
.lower .tag { display: inline-block; padding: 2px 10px; color: var(--rice); background: var(--zhu); font-weight: 900; }
.lower .tag.done { color: var(--ink); background: var(--gold); }
#event-headline h2 { margin: 2px 0; padding: 6px 12px; background: var(--rice); color: var(--ink); border-left: 8px solid var(--zhu); font: 400 var(--s28)/1.25 var(--display); width: fit-content; }
#event-quote { background: var(--ink); color: var(--gold2); font-size: var(--s14); margin: 6px 0 0; }
#event-host .scene { margin: 0 0 28px; }
.event-desk { display: grid; grid-template-columns: minmax(0,5fr) minmax(0,4fr) minmax(0,3fr); gap: 24px; }
.event-desk h3 { margin: 0 0 12px; color: var(--gold2); }
.event-desk > div + div { border-inline-start: 1px solid var(--line); padding-inline-start: 16px; }
.chips { display: flex; flex-wrap: wrap; list-style: none; padding: 0; gap: 6px; margin: 0 0 12px; }
.chips li { border: 1px solid var(--line); padding: 2px 8px; font-size: var(--s14); }
@keyframes event-caption-in { from { transform: translateX(-12px); opacity: 0; } }
@media (min-width: 900px) {
  .lower { position: absolute; bottom: 0; left: 0; width: 44%; }
  [data-mode="event"] .frame-led-text:not(.led-accessible) { margin-left: 32%; }
}
@media (max-width: 899px) {
  [data-mode="event"] .proscenium { grid-template-columns: 8px minmax(0, 1fr) 8px; }
  .event-desk { grid-template-columns: minmax(0,1fr); }
  .event-desk > div + div { border-inline-start: 0; border-top: 1px solid var(--line); padding: 16px 0 0; }
}
@media (prefers-reduced-motion: reduce) { .lower { animation: none; } }

/* 籤身並列在舞台上，選項的長說明留在下方播報台。 */
.event-marquee { position: relative; }
[data-mode="event"] .frame-led-text:not(.led-accessible) { font-family: var(--display); }
.bei-symbols { position: absolute; }
#event-lot-stage { background: linear-gradient(175deg, var(--ink) 30%, var(--wine)); border-bottom: 5px double var(--gold); padding: 24px 12px 20px; }
.lot-group { display: flex; align-items: stretch; justify-content: center; gap: clamp(6px, 2vw, 28px); perspective: 1000px; }
.lot { position: relative; flex: 0 1 190px; min-width: 0; aspect-ratio: 2 / 3; padding: 0; border: 0; background: transparent; box-shadow: none; transform-style: preserve-3d; isolation: isolate; }
.lot:not(:disabled):hover { transform: translateY(-4px); }
.lot[aria-pressed="true"] { transform: translateY(-8px); }
.lot:disabled { opacity: 1; }
.lot { container-type: inline-size; }
.lot-front, .lot-back, .lot-cover { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px solid var(--gold); backface-visibility: hidden; transition: transform .4s ease; }
.lot-front { justify-content: flex-start; background: var(--rice); color: var(--ink); }
.lot-front strong { margin: auto; writing-mode: vertical-rl; font: 400 var(--s28)/1.2 var(--display); letter-spacing: .14em; }
.lot-number { width: 100%; padding-block: 3px; background: var(--zhu); color: var(--rice); font: 400 var(--s20)/1.5 var(--display); }
.lot-cover, .lot-back { gap: 6px; padding: 12px 4px; transform: rotateY(-180deg); }
.lot-back { background: var(--ink); color: var(--gold2); border-block: 6px double var(--gold); }
.lot-back strong { font-size: clamp(14px, 20cqi, 32px); line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lot-back small, .lot-back > span, .lot-cover > span { font-size: var(--s14); }
.lot-cover { background: var(--wine); color: var(--gold2); border: 4px double var(--gold); }
.lot-cover b { font: 400 var(--s28)/1.2 var(--display); }
.lot-cover .chop { min-width: 0; min-height: 0; padding: 2px 6px; background: var(--gray); color: var(--ink); }
.picked .lot-front, .lot[data-blocked] .lot-front, .lot[data-branch-locked] .lot-front { transform: rotateY(180deg); }
.picked .lot[aria-pressed="true"] .lot-back,
.picked .lot[aria-pressed="false"] .lot-cover,
.lot[data-blocked] .lot-cover, .lot[data-branch-locked] .lot-cover { transform: rotateY(0); }
.lot .branch-lock { position: absolute; inset: auto 0 0; background: var(--ink); color: var(--rice); padding: 3px; font-size: var(--s14); }
#lot-detail h4 { margin-block: 6px; }
#lot-detail .goal-hint { margin-block: 12px; color: var(--gold2); }
.bei-pair { display: flex; gap: 8px; margin: 20px 0 12px; }
.bei-pair svg { width: min(44%, 96px); overflow: visible; }
.bei-pair.casting svg { animation: toss-bei 1s ease-in-out; }
.bei-pair.casting svg + svg { animation-direction: reverse; }
@keyframes toss-bei { 0%,100% { transform: none; } 35% { transform: translateY(-24px) rotate(-16deg) scaleY(.5); } 65% { transform: translateY(-12px) rotate(10deg); } }
#event-toss:disabled { background: transparent; color: var(--gray); border-color: rgba(230,180,34,.3); }
#event-seal { display: flex; gap: 8px; align-items: center; width: fit-content; margin: 8px 0 0; background: var(--zhu); color: var(--rice); }
#event-seal i { border: 2px solid var(--gold2); font: 400 var(--s20)/1.2 var(--display); padding: 3px; }
#event-seal-host:not(:empty) { margin-bottom: 8px; }
@media (max-width: 899px) {
  .lot { flex-basis: 26vw; }
  .lot-group { gap: 6px; }
  #event-lot-stage { padding: 16px 6px 12px; }
  #event-dock:not([hidden]) { display: block; }
  body:has(#event-dock:not([hidden])) { padding-bottom: 76px; }
}
@media (prefers-reduced-motion: reduce) {
  .lot-front, .lot-back, .lot-cover { transition: none; }
  .bei-pair.casting svg { animation: none; }
}

/* 特別節目：主欄對照與現金走勢，右欄時間線。 */
.ending-layout { display: grid; grid-template-columns: minmax(0,2fr) minmax(280px,1fr); gap: 32px; align-items: start; }
#ending-main, #ending-side { min-width: 0; }
#life-scene:has(.ending-layout:not([hidden])) { border: 0; padding: 0; }
#life-scene:has(.ending-layout:not([hidden]))::before { display: none; }
#ending-summary h2 { font-family: var(--display); font-size: var(--s28); margin-bottom: 16px; }
#ending-summary .ledger { margin-bottom: 24px; }
#ending-summary .ledger dd small { display: block; font: 400 var(--s14)/1.7 var(--ui); color: var(--gray); }
.mortgage-subtitle p { margin: 0; font-size: var(--s14); }
.ending-context { margin-block: 16px 32px; }
#ending-report { display: block; }
#goals-report, #cohort-report { margin-top: 32px; border: 0; padding: 0; }
#goals-results { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.goal-result { position: relative; min-width: 0; padding: 20px 20px 88px; background: var(--rice); color: var(--ink); border: 0; border-top: 20px solid var(--zhu); }
.goal-result .goal-card-label { position: absolute; top: -20px; left: 16px; font-size: var(--s14); line-height: 20px; color: var(--rice); }
.goal-result h4 { margin: 0 0 12px; font: 400 var(--s28)/1.4 var(--display); }
.goal-result p { font-size: var(--s14); }
.chop { display: inline-flex; align-items: center; justify-content: center; min-width: 60px; min-height: 60px; padding: 8px; font-size: var(--s14); font-weight: 900; border: 3px double currentColor; }
.goal-result .chop { position: absolute; bottom: 16px; right: 16px; transform: rotate(-6deg); }
.chop.achieved { background: var(--zhu); color: var(--rice); }
.chop.partial { background: #7a5a0a; color: var(--rice); }
.chop.unachieved, .chop.insufficient { background: var(--gray); color: var(--ink); }
#cohort-chart { padding: 0; border: 0; }
.cohort-bars { margin-top: 24px; }
.cohort-bars h4 { margin: 0 0 12px; }
.cohort-bar-row { display: grid; grid-template-columns: 150px minmax(0,1fr) 110px; align-items: center; gap: 12px; min-height: 40px; }
.bar-label { font-size: var(--s14); white-space: nowrap; }
.bar-value { grid-column: 3; grid-row: 1; text-align: right; font-size: var(--s14); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { position: relative; height: 16px; background: var(--line); grid-column: 2; grid-row: 1; }
.bar-track i { position: absolute; inset: 0 auto 0 0; background: var(--gold2); }
.official .bar-track i { background: var(--zhu); }
.bar-track u { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--rice); }
.cohort-difference { font-size: var(--s14); margin-top: 12px; color: var(--gold2); }
.cohort-detail { margin-top: 16px; }
.cohort-detail .cohort-metric { border: 0; padding: 12px 0; }
#peer-reference { border: 0; border-top: 1px dashed var(--line); padding: 16px 0 0; margin-top: 24px; font-size: var(--s14); color: var(--gray); }
#peer-reference h4 { font-size: var(--s14); color: var(--rice); }
#ending-trend { margin-top: 36px; }
#ending-trend .report-chart svg { max-width: 24rem; }
#ending-side { border-left: 1px solid var(--line); padding-left: 24px; }
#ending-side .life-history { margin-top: 0; padding-top: 0; border: 0; }
.history-rows { padding-left: 0; list-style: none; }
.history-rows > li { margin: 0; padding: 16px 0; border: 0; border-bottom: 1px solid var(--line); }
.history-rows dd { margin: 0 0 8px; }
.history-rows dl { font-size: var(--s14); }
.branch-disclosure > summary { color: var(--gold2); text-decoration: underline; text-underline-offset: 4px; min-height: 36px; cursor: pointer; font-size: var(--s14); }
.branch-disclosure > p { margin-top: 12px; }
.branch-disclosure button { margin-top: 12px; }
.sealed { display: block; margin-top: 24px; padding: 12px 16px; border-block: 2px solid var(--gold); background: var(--wine); color: var(--rice); font-size: var(--s14); }
body[data-stage="complete"] #configure-next { background: transparent; color: var(--gold2); }
#report-actions { border: 0; padding: 0 0 24px; }
#report-actions::before { display: none; }
@media (max-width: 1099px) { .cohort-bar-row { grid-template-columns: minmax(0,1fr) auto; } .bar-value { grid-column: 2; } .bar-track { grid-column: 1 / -1; grid-row: 2; } }
@media (max-width: 899px) {
  .ending-layout { grid-template-columns: minmax(0,1fr); }
  #ending-side { padding: 24px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .cohort-bar-row { margin-top: 16px; }
  .bar-track { height: 12px; }
}
@media (max-width: 599px) {
  #ending-summary .ledger dl.figs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #ending-summary .figs > div:last-child { grid-column: 1 / -1; }
  #goals-results { grid-template-columns: minmax(0,1fr); }
}
