:root {
  --paper: #f8f6f1;
  --ink: #271a3a;
  --muted: #625572;
  --purple: #5b36ad;
  --lavender: #e7dcfb;
  --border: #ded7e6;
  --white: #fffdfa;
  --green: #2f6048;
  --red: #872e47;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: #eae5ee;
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
button, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus, summary:focus { outline: 2px solid var(--purple); outline-offset: 3px; }
h1[tabindex]:focus { outline: none; }
button:disabled, [aria-disabled="true"] { cursor: default; }
h1, h2, p { margin: 0; }
button:active:not(:disabled):not([aria-disabled="true"]) { transform: scale(.98); }

.shell {
  max-width: 480px;
  min-height: 100vh;
  margin: auto;
  padding: 0 18px 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--paper);
}
.masthead {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; font-weight: 800; font-size: 14px; letter-spacing: .045em; }
.brand-mark {
  display: flex;
  flex-wrap: wrap;
  width: 26px;
  height: 26px;
  justify-content: space-between;
  align-content: space-between;
  margin-right: 8px;
  padding: 5px;
  background: var(--ink);
  border-radius: 9px;
  transform: rotate(-8deg);
}
.brand-mark i { width: 7px; height: 7px; border-radius: 2px; background: #e4d4ff; }
.brand-mark i:nth-child(2) { background: #f8e693; transform: rotate(20deg); }
.brand-mark i:nth-child(3) { background: #c6b2f6; }
.progress { display: flex; align-items: center; color: var(--muted); font-size: 11px; font-weight: 700; }
.view { animation: enter .3s ease both; }
@keyframes enter { from { opacity: .6; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.hero {
  padding: 20px 18px 20px;
  position: relative;
  overflow: hidden;
  min-height: 263px;
  border-radius: 24px;
  background: #e5d9fb;
  background-image: radial-gradient(rgba(102,70,172,.22) 1px, transparent 1px), linear-gradient(145deg, #f0e7ff, #d9c7fc);
  background-size: 16px 16px, 100% 100%;
  border: 1px solid #d9c7f0;
}
.hero-label {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  background: #fff9e8;
  border: 1px solid #443257;
  border-radius: 6px;
  color: #49345c;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: .075em;
}
.hero-label i { width: 5px; height: 5px; background: #754cbd; border-radius: 50%; margin-right: 5px; }
.hero h1 {
  position: relative;
  z-index: 1;
  margin-top: 11px;
  font-size: 36px;
  font-weight: 900;
  line-height: 1.16;
  letter-spacing: -.055em;
}
.hero h1 span { color: #5932a5; font-size: 1.18em; margin-left: 3px; }
.hero p { position: relative; z-index: 1; margin-top: 24px; font-size: 12px; line-height: 1.65; color: #46355e; font-weight: 600; }
.hero canvas { position: absolute; width: 152px; right: -3px; bottom: -1px; pointer-events: none; }

.setup { padding-top: 15px; }
.option-group { min-width: 0; padding: 0; margin: 0 0 12px; border: 0; }
.option-group legend { width: 100%; padding: 0 1px 5px; font-weight: 800; font-size: 14px; }
.option-group legend span { float: right; color: var(--muted); font-size: 11px; font-weight: 600; padding-top: 2px; }
.option-row { display: flex; }
.setup-option {
  flex: 1 1 0;
  min-width: 0;
  min-height: 47px;
  padding: 7px 2px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-weight: 800;
  line-height: 1.2;
  font-size: 14px;
  transition: background .15s, transform .12s;
}
.setup-option + .setup-option { margin-left: 7px; }
.setup-option small { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
.setup-option[aria-pressed="true"] { background: #eae0ff; border-color: #7953c5; color: #462780; box-shadow: inset 0 0 0 1px #7953c5; }

.forecast {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 8px 10px;
  margin-top: 1px;
  border: 1px dashed #d7cce1;
  border-radius: 10px;
  font-size: 11px;
  color: var(--muted);
}
.forecast b { font-size: 13px; color: var(--ink); }
.forecast-warning { flex: 0 0 100%; padding-top: 3px; color: var(--red); font-weight: 700; }

.actions { margin-top: 14px; }
.button {
  display: block;
  width: 100%;
  min-height: 49px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 800;
  transition: transform .12s, background .18s;
}
.button span { margin-left: 3px; }
.primary { background: var(--purple); color: white; box-shadow: 0 4px 0 #3b2379; }
.primary:disabled { color: #5e546e; background: #e7e0ee; box-shadow: none; }
.secondary { background: var(--white); border-color: #d6c8e6; color: #4b3670; }
.text-button { background: transparent; margin-top: 5px; color: #4b3670; }
.note { text-align: center; color: var(--muted); font-size: 11px; margin: 12px 0 0; }

.ledger {
  margin-top: 10px;
  border: 1px solid #e6deed;
  border-radius: 16px;
  background: var(--white);
}
.ledger summary { cursor: pointer; min-height: 44px; padding: 11px 12px; font-size: 14px; font-weight: 800; }
.ledger summary small { float: right; color: var(--muted); font-weight: 600; font-size: 11px; padding-top: 2px; }
.ledger ul, .category-totals { margin: 0; padding: 0; list-style: none; }
.ledger ul { padding: 0 12px 10px; }
.ledger li, .category-totals li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1px 0;
  color: #473852;
  border-bottom: 1px dashed #eae3ed;
  font-size: 12px;
}
.ledger li:last-child, .category-totals li:last-child { border-bottom: 0; }
.ledger li strong { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.ledger .income strong { color: var(--green); }
.ledger .deposit strong { color: var(--purple); }
.ledger li small { margin-left: 2px; padding: 0 3px; border-radius: 4px; color: #583c83; background: #f0e7ff; font-size: 10px; }

.poster { width: 100%; height: auto; display: block; border-radius: 21px; background: var(--ink); box-shadow: 0 5px 14px rgba(51,31,82,.15); }
.share-feedback { text-align: center; color: var(--purple); font-size: 12px; font-weight: 700; }
.share-feedback:not(:empty) { padding: 12px 0 0; }
.result-ledger { margin-top: 15px; background: var(--white); border: 1px solid var(--border); border-radius: 12px; }
.result-ledger summary { padding: 9px 12px; min-height: 44px; font-size: 13px; font-weight: 800; cursor: pointer; }
.takeaway { font-size: 12px; padding: 4px 12px 8px; color: var(--muted); }
.month-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid #eee7f1; padding: 6px 12px; font-size: 12px; }
.category-totals { border-top: 1px solid #eee7f1; padding: 7px 12px; }
.result-note { margin-top: 8px; }

@media (max-width: 360px) {
  .shell { padding-left: 14px; padding-right: 14px; }
  .hero { min-height: 215px; padding: 17px 13px; }
  .hero h1 { font-size: 31px; }
  .hero p { margin-top: 17px; font-size: 11px; }
  .hero canvas { width: 119px; right: -6px; }
}

@media (min-width: 481px) {
  .shell { padding-left: 22px; padding-right: 22px; box-shadow: 0 0 36px rgba(46,28,67,.11); }
  .hero { min-height: 283px; }
  .hero h1 { font-size: 40px; }
  .hero canvas { width: 178px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Older engines keep the base focus outline. */
button:focus:not(:focus-visible), summary:focus:not(:focus-visible) { outline: none; }

.hero h1 { letter-spacing: -.025em; }
.hero p { width: 64%; }
.story-wallet {
  color: #faf4ff;
  background: #29213a;
  border: 1px solid #3e3051;
  border-radius: 17px;
  padding: 10px 12px;
}
.story-wallet.is-negative { background: #492538; border-color: #6f3e54; }
.story-cash, .story-cash > div { display: flex; align-items: center; }
.story-cash { justify-content: space-between; margin-bottom: 7px; }
.story-cash > div span { color: #d7cce4; font-size: 11px; margin-right: 6px; }
.story-cash strong { font-size: 23px; line-height: 1.1; font-weight: 900; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.work-status { align-self: center; font-size: 10px; padding: 2px 7px; border: 1px solid #756587; border-radius: 12px; color: #ede0f9; }
.story-stats { display: flex; }
.story-stat { flex: 1; min-width: 0; font-size: 10px; }
.story-stat + .story-stat { margin-left: 10px; }
.story-stat span { color: #e9dff3; }
.story-stat b { float: right; font-size: 11px; font-variant-numeric: tabular-nums; }
.story-stat i { display: block; height: 3px; background: #554364; margin-top: 4px; border-radius: 5px; overflow: hidden; }
.story-stat em { display: block; height: 100%; border-radius: 5px; background: #eed28b; animation: measure-in .45s ease both; transform-origin: left; }
.story-stat.relation em { background: #d8e8a7; }
.story-stat.work em { background: #d4baf9; }
@keyframes measure-in { from { transform: scaleX(.88); } to { transform: scaleX(1); } }

.story-card {
  position: relative;
  margin-top: 10px;
  min-height: 173px;
  padding: 12px 12px 11px;
  border: 1px solid #dbca9b;
  border-radius: 18px;
  background: #fff1cf;
  background-image: linear-gradient(145deg, #fff8df, #f4e3bb);
}
.story-card.home-scene { background: #edf3d8; background-image: linear-gradient(145deg, #f7f8e5, #dce7bc); border-color: #cad4ac; }
.story-card.work-scene { background: #eae3fa; background-image: linear-gradient(145deg, #f4eeff, #dccbf5); border-color: #d9c8ef; }
.story-kicker { display: flex; align-items: center; color: #5d4f68; font-size: 11px; font-weight: 700; }
.story-kicker i { flex: 0 0 auto; background: #79628d; border-radius: 50%; width: 3px; height: 3px; margin: 0 6px; }
.story-lead { display: flex; align-items: center; justify-content: space-between; min-height: 89px; }
.story-lead > div { flex: 1; min-width: 0; margin-right: 7px; }
.story-lead h1 { font-size: 26px; font-weight: 900; line-height: 1.13; letter-spacing: -.035em; margin-bottom: 6px; }
.story-lead canvas { width: 83px; height: 87px; flex: 0 0 auto; animation: character-in .45s ease both; }
@keyframes character-in { from { opacity: .65; transform: translateY(4px) rotate(2deg); } to { opacity: 1; transform: none; } }
.character b { color: #473557; font-size: 13px; }
.character span { color: #5e506c; font-size: 10px; padding-left: 2px; }
.dialogue {
  margin-top: 5px;
  padding: 7px 9px;
  border-radius: 9px;
  background: rgba(255,255,255,.58);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.46;
  color: #34263f;
}
.memory-line { font-size: 10px; color: #58496b; margin: 6px 1px 0; font-weight: 700; }

.story-options { margin-top: 9px; }
.story-choice {
  position: relative;
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 6px 28px 6px 11px;
  text-align: left;
  border: 1px solid #ded3e7;
  border-radius: 12px;
  background: #fffdfa;
  transition: background-color .16s, transform .12s;
}
.story-choice + .story-choice { margin-top: 5px; }
.story-choice b { display: block; color: #351f51; font-size: 14px; line-height: 1.24; }
.story-choice small { display: block; font-weight: 600; color: #5b4f6a; font-size: 11px; line-height: 1.25; margin-top: 3px; }
.story-choice span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 15px; color: #6b46a4; }
.story-choice:active { background: #ede2fc; }
.story-choice:disabled { background: #ebe6ed; }
.story-choice:disabled b, .story-choice:disabled small { color: #5e5569; }
.story-choice:disabled span { display: none; }

.story-response {
  margin-top: 9px;
  padding: 9px 11px;
  border-radius: 14px;
  border: 1px solid #cdbce6;
  background: #f0e8fb;
}
.story-response h2 { font-size: 14px; color: #472b78; }
.story-response h2[tabindex]:focus { outline: none; }
.story-response p { margin-top: 3px; line-height: 1.45; font-size: 12px; color: #34263f; }
.effects { margin-top: 4px; }
.effects span {
  display: inline-block;
  margin: 3px 4px 0 0;
  padding: 2px 6px;
  border-radius: 6px;
  color: #4b3574;
  background: #e2d5f6;
  font-weight: 700;
  font-size: 10px;
}
.story-actions { display: flex; margin-top: 9px; }
.story-actions .button { min-height: 44px; padding-left: 10px; padding-right: 10px; font-size: 14px; }
.story-actions .secondary { flex: 0 0 auto; width: auto; margin-right: 7px; }
.story-actions .primary { flex: 1; min-width: 0; }
.story-ledger { margin-top: 10px; }
.save-status { color: var(--red); font-size: 11px; }
.save-status:not(:empty) { margin-top: 10px; }

.ending-numbers { display: flex; padding: 9px 10px; margin-top: 8px; border-radius: 13px; background: var(--white); border: 1px solid var(--border); }
.ending-numbers > div { flex: 1; min-width: 0; text-align: center; }
.ending-numbers > div + div { border-left: 1px solid #ebe0f0; }
.ending-numbers span { display: block; font-size: 10px; color: var(--muted); }
.ending-numbers b { display: block; font-size: 15px; color: var(--ink); }
.ending-decisions { margin-top: 17px; }
.ending-decisions h2 { font-size: 15px; font-weight: 800; }
.decision-list { list-style: none; margin: 6px 0 12px; padding: 0; }
.decision-list li { display: flex; align-items: flex-start; padding: 9px 1px; border-bottom: 1px solid #e5dce9; }
.decision-month { flex: 0 0 auto; font-size: 10px; padding: 2px 5px; border-radius: 6px; color: #4a3276; background: #e8defa; margin-right: 7px; }
.decision-list b { display: block; font-size: 13px; line-height: 1.3; }
.decision-list p { margin-top: 2px; color: #584b66; font-size: 11px; }
.decision-list small { display: block; margin-top: 4px; color: #6239a1; font-size: 10px; font-weight: 700; }
.share-preview .poster { width: calc(100% - 16px); margin: 0 8px 8px; border-radius: 10px; }
.replay-head { background: #eee4fb; border: 1px solid #dcccfa; border-radius: 16px; padding: 12px; }
.replay-head h1 { font-size: 22px; }
.replay-head p { color: var(--muted); margin-top: 3px; font-size: 12px; }
.rewind { width: auto; min-height: 40px; margin-top: 6px; padding-left: 9px; padding-right: 9px; font-size: 12px; }

@media (max-width: 360px) {
  .masthead { height: 48px; }
  .story-wallet { padding: 8px 10px; }
  .story-card { margin-top: 8px; min-height: 0; padding: 9px 10px; }
  .story-lead { min-height: 73px; }
  .story-lead h1 { font-size: 23px; }
  .story-lead canvas { width: 70px; height: 74px; }
  .dialogue { padding: 6px 7px; margin-top: 3px; }
  .story-choice { min-height: 44px; }
  .story-choice b { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .story-stat em, .story-lead canvas { animation: none; }
}

.story-kicker { min-height: 23px; }
.story-kicker .story-back {
  width: auto;
  margin-left: auto;
  min-height: 31px;
  padding: 1px 3px 1px 7px;
  background: transparent;
  font-size: 11px;
  color: #513776;
}
.personality-hero { color: #fff9ff; border-radius: 20px; padding: 14px 15px 16px; }
.report-header { display: flex; align-items: center; justify-content: space-between; height: 42px; }
.report-header span { color: var(--report-paper, #fff0d5); font-size: 12px; font-weight: 800; }
.report-header canvas { width: 53px; height: 53px; flex-shrink: 0; margin-right: 1px; }
.personality-hero h1 { color: var(--report-paper, #fff0d5); font-size: 29px; line-height: 1.12; margin-top: 7px; font-weight: 900; letter-spacing: -.045em; overflow-wrap: break-word; }
.quip { font-size: 13px; line-height: 1.5; font-weight: 700; margin-top: 9px; }
.report-basis { margin-top: 9px; color: var(--report-paper, #fff0d5); font-size: 11px; font-weight: 600; }
.ending-epilogue summary small { float: right; font-size: 11px; color: var(--muted); }
.share-line { color: #563289; text-align: center; font-weight: 700; font-size: 12px; margin-top: 12px; }
.period-adjustment { margin-top: 7px; color: #e9dff3; font-size: 10px; }

.inline-receipt { margin-top: 8px; padding: 6px 9px; border-left: 2px solid #b9a4d4; background: #f1ebf6; color: #473855; font-size: 11px; line-height: 1.4; }
.inline-receipt b { color: #5b3a8d; padding-right: 3px; }
.inline-receipt .effects { margin-top: 0; }
.reply-notes { list-style: none; padding: 0; margin: 8px 0 0; }
.reply-notes li { margin-top: 5px; padding: 7px 9px; border-radius: 9px; background: #f2ebfa; color: #423052; font-size: 11px; line-height: 1.45; }
.reply-notes b { color: #5b3a8d; }
.ending-epilogue .reply-notes { margin: 0 9px 9px; }
.ledger-rule { margin: 6px 10px 10px; color: var(--muted); font-size: 11px; }
.episode { margin-top: 13px; padding: 11px 10px 12px; border-radius: 12px; background: rgba(255,255,255,.09); }
.episode-kicker { color: var(--report-paper); font-size: 10px; font-weight: 800; }
.episode h2 { color: var(--report-paper); font-size: 19px; line-height: 1.25; margin-top: 3px; }
.episode .quip { margin-top: 5px; }
.episode-chain { margin-top: 8px; padding: 6px 7px; border-left: 2px solid var(--report-paper); background: rgba(0,0,0,.24); font-size: 12px; font-weight: 700; line-height: 1.55; }
.episode-share { font-size: 12px; line-height: 1.45; margin-top: 7px; }
.result-view > .report-basis { color: var(--muted); text-align: center; }
