
/* Layout: the tree and the player's money stay on one side, one decision at a time on the other. Colors come from the book cover. */
:root {
  color-scheme: light;
  --forest: #23563f;
  --pine: #233c31;
  --sage: #5c7263;
  --mist: #e4ecdf;
  --paper: #f5f7f0;
  --white: #ffffff;
  --gold: #e9a820;
  --coral: #d9553d;
  --sky: #2b86a8;
  --line: #cfdac9;
  --display: "Lilita One", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --btn: var(--forest);
  --btn-edge: var(--pine);
  --btn-ink: var(--white);
}
/* Under 13: same game in a sunny, playful look. */
:root[data-mode="kid"] {
  --forest: #15784a;
  --pine: #243a66;
  --sage: #52628f;
  --mist: #fff1bd;
  --paper: #d9f2ff;
  --line: #ffd166;
  --btn: #ffb02e;
  --btn-edge: #d9820f;
  --btn-ink: #3b2400;
  --display: "Chewy", "Comic Sans MS", "Arial Rounded MT Bold", sans-serif;
  --body: "Nunito", "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--pine);
  font: 500 17px/1.5 var(--body);
}
h1, h2, h3 { font-family: var(--display); font-weight: 400; color: var(--forest); margin: 0; line-height: 1.12; text-wrap: balance; letter-spacing: .01em; }
h1 { font-size: clamp(2.5rem, 8vw, 4rem); }
h2 { font-size: clamp(1.55rem, 4.5vw, 2.1rem); }
h3 { font-size: 1.2rem; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.shell { max-width: 960px; margin: 0 auto; display: grid; gap: 20px; }
.shell.game { grid-template-columns: 290px minmax(0, 1fr); align-items: start; }
.stack { display: grid; gap: 16px; min-width: 0; }
.eyebrow { font-size: .78rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--sage); }
.muted { color: var(--sage); font-size: .95rem; }
.panel { background: var(--white); border: 2px solid var(--line); border-radius: 14px; padding: 22px; display: grid; gap: 16px; min-width: 0; animation: rise .28s ease-out; }
@keyframes rise { from { transform: translateY(8px); opacity: .4; } to { transform: none; opacity: 1; } }

.btn { background: var(--btn); color: var(--btn-ink); border: 0; border-radius: 10px; padding: 14px 20px; font-weight: 800; box-shadow: 0 4px 0 var(--btn-edge); transition: transform .08s, box-shadow .08s; width: 100%; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-edge); }
.btn:disabled { background: var(--line); color: var(--sage); box-shadow: none; cursor: not-allowed; }
.link { background: none; border: 0; padding: 4px; color: var(--sage); text-decoration: underline; font-size: .9rem; justify-self: center; }

.choice { display: grid; gap: 3px; width: 100%; text-align: left; background: var(--paper); border: 2px solid var(--line); border-radius: 10px; padding: 13px 15px; font-weight: 700; transition: border-color .12s, background .12s; }
.choice small { font-weight: 500; font-size: .88rem; color: var(--sage); }
.choice:hover { border-color: var(--forest); }
.choice.on { border-color: var(--forest); background: var(--mist); }
.choice.right { border-color: var(--forest); background: var(--mist); }
.choice.wrong { border-color: var(--coral); background: #fbeae6; }
.choices { display: grid; gap: 10px; }
.pick3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.scale .choice { text-align: center; font-size: 1.15rem; padding: 12px 4px; }
.ends { display: flex; justify-content: space-between; gap: 12px; }

.home { text-align: center; justify-items: center; max-width: 620px; margin: 0 auto; padding-top: 8px; }
.home svg { width: min(300px, 74vw); height: auto; }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--white); }
.seg button { border: 0; background: none; padding: 8px 16px; font-weight: 700; color: var(--sage); }
.seg button.on { background: var(--forest); color: var(--white); }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; width: 100%; text-align: left; font-size: .94rem; }
.steps b { display: block; color: var(--forest); }

.side { display: grid; gap: 12px; position: sticky; top: calc(12px + env(safe-area-inset-top, 0px)); min-width: 0; }
.treebox { background: var(--mist); border-radius: 14px; padding: 8px; }
.treebox svg { display: block; width: 100%; height: auto; }
.leaf { transform-box: fill-box; transform-origin: center; animation: pop .4s cubic-bezier(.3,1.7,.5,1); }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.wk { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.goalbar { height: 13px; background: var(--mist); border-radius: 7px; overflow: hidden; }
.goalbar i { display: block; height: 100%; background: var(--forest); transition: width .4s; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--white); border: 2px solid var(--line); border-radius: 10px; padding: 7px 10px; min-width: 0; }
.stat span { display: block; font-size: .72rem; font-weight: 700; color: var(--sage); }
.stat b { font: 400 1.25rem/1.2 var(--display); color: var(--forest); font-variant-numeric: tabular-nums; }
.stat b.bad { color: var(--coral); }

.ledger { display: grid; gap: 5px; font-variant-numeric: tabular-nums; }
.ledger div { display: flex; justify-content: space-between; gap: 16px; }
.ledger .tot { border-top: 2px solid var(--pine); padding-top: 5px; font-weight: 800; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.split div { border-radius: 10px; padding: 8px 12px; background: var(--paper); }
.split div:first-child { background: var(--mist); }
.split span { display: block; font-size: .8rem; font-weight: 700; color: var(--sage); }
.split b { font: 400 1.5rem var(--display); color: var(--forest); }
input[type=range] { width: 100%; accent-color: var(--forest); height: 30px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { font-size: .85rem; font-weight: 800; padding: 3px 10px; border-radius: 99px; background: var(--mist); color: var(--forest); }
.chip.down { background: #fbeae6; color: #a93822; }
.lesson { background: var(--mist); border-radius: 10px; padding: 12px 14px; display: grid; gap: 3px; }
.lesson .eyebrow { color: var(--forest); }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }

.scorecard { text-align: center; justify-items: center; }
.bigscore { font: 400 clamp(3.4rem, 12vw, 5rem)/1 var(--display); color: var(--forest); }
.compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
.compare div { background: var(--paper); border-radius: 10px; padding: 10px; }
.compare span { display: block; font-size: .8rem; font-weight: 700; color: var(--sage); }
.compare b { font: 400 1.35rem var(--display); color: var(--forest); }
.progress { font-weight: 700; color: var(--sage); font-size: .9rem; }
.ages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; }
.ages .choice { text-align: center; font-size: 1.2rem; padding: 14px 4px; }

.buddy { display: flex; align-items: center; gap: 10px; text-align: left; }
.buddy img { width: 84px; height: 84px; flex: none; object-fit: contain; animation: bob 2.4s ease-in-out infinite; }
.buddy p { position: relative; background: var(--mist); border-radius: 16px; padding: 9px 14px; font-weight: 800; min-width: 0; }
.buddy p::before { content: ""; position: absolute; left: -7px; top: 50%; width: 14px; height: 14px; margin-top: -7px; background: var(--mist); transform: rotate(45deg); }
@keyframes bob { 50% { transform: translateY(-5px) rotate(3deg); } }

[data-mode="kid"] body { font-weight: 700; background: linear-gradient(#bfe9ff, #e6f8ff 55%, #d8f5c8); background-attachment: fixed; }
[data-mode="kid"] h1 { font-size: clamp(3.2rem, 11vw, 5rem); color: #ff7a2f; }
[data-mode="kid"] h2 { font-size: clamp(1.8rem, 5vw, 2.4rem); }
[data-mode="kid"] .panel { border-width: 4px; border-radius: 28px; box-shadow: 0 7px 0 var(--line); }
[data-mode="kid"] .btn { border-radius: 99px; font-size: 1.15rem; font-weight: 900; }
[data-mode="kid"] .btn:hover:not(:disabled) { animation: wiggle .4s; }
[data-mode="kid"] .btn:disabled { background: var(--white); color: var(--sage); }
[data-mode="kid"] .choice { background: var(--white); border-width: 3px; border-radius: 20px; }
[data-mode="kid"] .choice:hover { transform: scale(1.015); }
[data-mode="kid"] .choice.on, [data-mode="kid"] .choice.right { background: #d8f5c8; border-color: var(--forest); }
[data-mode="kid"] .stat { border-width: 3px; border-radius: 16px; }
[data-mode="kid"] .treebox { border-radius: 24px; background: linear-gradient(#a9e2ff 70%, #9ddc7a 70%); }
[data-mode="kid"] .goalbar { background: var(--white); border: 2px solid var(--line); height: 18px; border-radius: 9px; }
[data-mode="kid"] .goalbar i { background: #ff9d2e; }
[data-mode="kid"] .lesson { border-radius: 20px; }
[data-mode="kid"] .split div, [data-mode="kid"] .compare div { border-radius: 18px; }
[data-mode="kid"] .seg { border-radius: 99px; }
[data-mode="kid"] .steps { display: none; }
[data-mode="kid"] .home svg:not(.buddy svg) { width: min(250px, 62vw); }
@keyframes wiggle { 25% { transform: rotate(-1.2deg); } 75% { transform: rotate(1.2deg); } }

.coin { position: fixed; top: -30px; width: 20px; height: 20px; border-radius: 50%; background: var(--gold); border: 3px solid #bf8712; animation: fall linear forwards; pointer-events: none; z-index: 5; }
@keyframes fall { to { transform: translateY(112vh) rotateY(720deg); } }

@media (max-width: 760px) {
  body { font-size: 16px; }
  .shell.game { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .side { position: static; grid-template-columns: 96px minmax(0, 1fr); gap: 8px 10px; }
  .treebox { grid-row: span 3; padding: 2px; align-self: start; }
  .stats { grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .stat { padding: 4px 6px; }
  .stat span { font-size: .64rem; white-space: nowrap; }
  .stat b { font-size: 1.02rem; }
  .panel { padding: 16px; gap: 13px; }
  .steps, .pick3 { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
