/* Themes follow the Global Regression stage: the interface itself regresses.
   garage (cozy kraft) -> corporate (toy office) -> soft -> pastel -> storybook.
   Everything is chunky and toy-like: ink outlines, offset shadows, buttons that press down. */

:root {
  --gut: 12px;
  --t: 500ms;
  --lip: rgba(43, 35, 64, .32);
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (max-width: 899px) { :root { --gut: 16px; } }

body[data-theme="garage"], body:not([data-theme]) {
  --bg: #f3e2c3; --pattern: radial-gradient(rgba(90, 60, 30, .11) 1.3px, transparent 1.6px); --pattern-size: 18px 18px;
  --panel: #fffaf0; --panel2: #f8ecd6; --hud: #fff4e0; --ink: #3b2a20; --muted: #8a6f58; --line: #3b2a20;
  --accent: #f26b3a; --accent-ink: #fff; --accent2: #2fa58f; --accent3: #8a63d9; --buy: #2fae6b;
  --good: #23a05f; --warn: #e89a1c; --bad: #e5484d; --bar-bg: #ecdcc0;
  --bw: 2.5px; --radius: 18px; --btn-radius: 14px; --fs: 15px;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif; --font-head: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --shadow: 0 4px 0 rgba(59, 42, 32, .16);
}
body[data-theme="corporate"] {
  --bg: #e6edf9; --pattern: linear-gradient(rgba(59, 124, 246, .08) 1px, transparent 1px), linear-gradient(90deg, rgba(59, 124, 246, .08) 1px, transparent 1px);
  --pattern-size: 22px 22px;
  --panel: #ffffff; --panel2: #f0f4fc; --hud: #ffffff; --ink: #1d2b4f; --muted: #66749a; --line: #1d2b4f;
  --accent: #3b7cf6; --accent-ink: #fff; --accent2: #ff9f1c; --accent3: #8a63d9; --buy: #22b07d;
  --good: #1a9c68; --warn: #e8960c; --bad: #ef4b5a; --bar-bg: #dfe6f5;
  --bw: 2.5px; --radius: 14px; --btn-radius: 12px; --fs: 15px;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif; --font-head: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --shadow: 0 4px 0 rgba(29, 43, 79, .13);
}
body[data-theme="soft"] {
  --bg: #efe9fb; --pattern: radial-gradient(rgba(138, 111, 224, .14) 2px, transparent 2.4px); --pattern-size: 26px 26px;
  --panel: #fdfbff; --panel2: #f4effc; --hud: #fbf8ff; --ink: #3a3350; --muted: #7d7596; --line: #4a4166;
  --accent: #8a6fe0; --accent-ink: #fff; --accent2: #3fb3c4; --accent3: #e573a8; --buy: #3faf82;
  --good: #3a9f78; --warn: #d9962a; --bad: #e26a6a; --bar-bg: #e6def5;
  --bw: 2px; --radius: 22px; --btn-radius: 16px; --fs: 15px;
  --font: 'Nunito', system-ui, sans-serif; --font-head: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --shadow: 0 5px 0 rgba(90, 70, 150, .14);
}
body[data-theme="pastel"] {
  --bg: #ffe9f4; --pattern: radial-gradient(rgba(255, 126, 185, .2) 3px, transparent 3.5px); --pattern-size: 30px 30px;
  --panel: #fffafd; --panel2: #fff0f7; --hud: #fff6fb; --ink: #5a3a5e; --muted: #9a7aa0; --line: #6a3f6e;
  --accent: #ff6fae; --accent-ink: #fff; --accent2: #4fb9ec; --accent3: #a37be8; --buy: #36b98a;
  --good: #2fa883; --warn: #e9a43a; --bad: #f2557a; --bar-bg: #ffdcec;
  --bw: 2.5px; --radius: 24px; --btn-radius: 999px; --fs: 15.5px;
  --font: 'Nunito', system-ui, sans-serif; --font-head: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --shadow: 0 5px 0 rgba(255, 110, 175, .22);
}
body[data-theme="storybook"] {
  --bg: #fff3d6; --pattern: radial-gradient(rgba(61, 42, 26, .07) 1px, transparent 1.4px); --pattern-size: 14px 14px;
  --panel: #fffdf4; --panel2: #fff4d6; --hud: #fffaea; --ink: #3d2a1a; --muted: #8a6d50; --line: #3d2a1a;
  --accent: #ff6f4f; --accent-ink: #fff; --accent2: #4fa3ff; --accent3: #a35bd9; --buy: #3ea85a;
  --good: #3a9a52; --warn: #e0a000; --bad: #e8463a; --bar-bg: #ffe8b0;
  --bw: 3px; --radius: 255px 18px 225px 18px / 18px 225px 18px 255px; --btn-radius: 18px 255px 18px 225px / 225px 18px 255px 18px; --fs: 17px;
  --font: 'Patrick Hand', 'Comic Sans MS', 'Chalkboard SE', cursive; --font-head: var(--font);
  --shadow: 3px 5px 0 rgba(61, 42, 26, .2);
}
/* The original green-screen look, kept as an option in Settings. */
body[data-theme="terminal"] {
  --bg: #040a05; --pattern: repeating-linear-gradient(0deg, rgba(77, 255, 122, .035) 0 1px, transparent 1px 3px); --pattern-size: auto;
  --panel: #07130a; --panel2: #0b1c0f; --hud: #07130a; --ink: #4dff7a; --muted: #2f9e4c; --line: #1c5a2b;
  --accent: #123f1f; --accent-ink: #b6ff4d; --accent2: #1c5a2b; --accent3: #1c5a2b; --buy: #1f6a33;
  --good: #4dff7a; --warn: #ffd84d; --bad: #ff5a4d; --bar-bg: #0e2a15; --lip: rgba(0, 0, 0, .6);
  --bw: 1px; --radius: 0px; --btn-radius: 0px; --fs: 14px;
  --font: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace; --font-head: var(--font);
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background-color: var(--bg); background-image: var(--pattern); background-size: var(--pattern-size);
  color: var(--ink); font-family: var(--font); font-size: var(--fs); line-height: 1.4;
  transition: background-color var(--t), color var(--t); min-height: 100vh; -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 1440px; margin: 0 auto;
  padding: 0 max(var(--gut), env(safe-area-inset-right, 0px)) calc(var(--dock-h, 0px) + 20px + var(--safe-b)) max(var(--gut), env(safe-area-inset-left, 0px));
}
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0 0 8px; line-height: 1.2; font-weight: 600; }
h2 { font-size: 1.5em; }
h3 { font-size: 1.15em; }
h4 { font-size: .9em; color: var(--muted); margin: 14px 0 8px; display: flex; align-items: center; gap: 6px; }
p { margin: 0 0 10px; }
small, .muted { color: var(--muted); }
.flavor { color: var(--muted); font-style: italic; font-size: .9em; }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.intro { font-size: .9em; }
.hint { color: var(--muted); font-size: .82em; margin: 6px 2px 0; }

.panel {
  background: var(--panel); border: var(--bw) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 14px; transition: background var(--t), border-color var(--t);
}
.section-head { display: flex; align-items: center; gap: 8px 10px; margin-bottom: 8px; flex-wrap: wrap; }
.section-head h3 { margin: 0; display: flex; align-items: center; gap: 8px; margin-right: auto; }

/* ---------- art ---------- */
.art { display: block; overflow: visible; }
.sticker { display: inline-block; filter: drop-shadow(1.5px 0 0 #fff) drop-shadow(-1.5px 0 0 #fff) drop-shadow(0 1.5px 0 #fff) drop-shadow(0 -1.5px 0 #fff)
  drop-shadow(0 2px 1.5px rgba(43, 35, 64, .28)); }
.sticker .art { width: 100%; height: 100%; }
.h-ic { width: 30px; height: 30px; flex: 0 0 auto; }
.h4-ic { width: 22px; height: 22px; }
body[data-theme="storybook"] .art { filter: url(#crayon); }
/* Handwriting everywhere, except the numbers you watch: those stay round and crisp. */
body[data-theme="storybook"] :is(.s-v, .hud-pct, .pl-num b, .sl-name small) { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; }
body[data-theme="terminal"] .art { filter: saturate(.7); }
body[data-theme="terminal"] .sticker { filter: none; }
body[data-theme="terminal"] .nanny-name b { color: var(--ink); }
.nanny-light { animation: blink 2.4s ease-in-out infinite; transform-origin: 50px 9px; }
.twinkle { animation: twinkle 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes bob { 50% { transform: translateY(-3px); } }
@keyframes blink { 0%, 60%, 100% { opacity: 1; } 75% { opacity: .35; } }
@keyframes twinkle { 50% { opacity: .35; transform: scale(.7); } }

/* ---------- buttons ---------- */
button {
  font: inherit; font-weight: 800; color: var(--accent-ink); background: var(--accent);
  border: var(--bw) solid var(--line); border-radius: var(--btn-radius); padding: 8px 14px; cursor: pointer;
  box-shadow: 0 4px 0 var(--lip); position: relative; touch-action: manipulation;
  transition: transform .08s, box-shadow .08s, filter .12s, background var(--t);
}
@media (hover: hover) { button:hover:not(:disabled) { filter: brightness(1.06); } }
button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--lip); }
button:disabled { cursor: not-allowed; opacity: .55; filter: saturate(.6); }
button.ghost { background: var(--panel); color: var(--ink); box-shadow: 0 3px 0 rgba(43, 35, 64, .15); }
button.small { padding: 4px 12px; min-height: 40px; font-size: .84em; box-shadow: 0 3px 0 var(--lip); }
button.small.ghost { box-shadow: 0 2px 0 rgba(43, 35, 64, .15); }
button.danger { background: var(--bad); color: #fff; }
button.wide { width: 100%; padding: 12px; font-size: 1.05em; }
button:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
/* Something you're saving toward: the button fills up as the money comes in. */
button:disabled[style*="--p"] {
  opacity: 1; filter: none; color: var(--muted); box-shadow: 0 3px 0 rgba(43, 35, 64, .12);
  background: linear-gradient(90deg, color-mix(in srgb, var(--buy) 32%, var(--panel2)) calc(var(--p, 0) * 100%), var(--panel2) 0);
}
body[data-theme="terminal"] button { box-shadow: none; }

/* ---------- HUD ---------- */
#hud {
  position: sticky; top: 0; z-index: 40;
  margin: 0 calc(-1 * max(var(--gut), env(safe-area-inset-right, 0px))) 14px calc(-1 * max(var(--gut), env(safe-area-inset-left, 0px)));
  padding: max(8px, env(safe-area-inset-top, 0px)) max(var(--gut), env(safe-area-inset-right, 0px)) 8px max(var(--gut), env(safe-area-inset-left, 0px));
  background: var(--hud); border-bottom: var(--bw) solid var(--line); box-shadow: 0 4px 0 rgba(43, 35, 64, .08);
  transition: background var(--t);
}
.hud-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stage-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; min-width: 0; min-height: 40px; max-width: 52%;
  background: var(--accent); color: var(--accent-ink); font-family: var(--font-head); font-weight: 600; font-size: .9em; box-shadow: 0 3px 0 var(--lip);
}
.stage-chip b { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; background: var(--panel); color: var(--ink); display: grid; place-items: center; font-size: .85em; }
.stage-chip > span { overflow: hidden; } .stage-chip span { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.1; text-align: left; }
.stage-chip i, .stage-chip small { font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* The next goal under the stage name ("146M to Soft Power"). */
.stage-chip small { font: 800 .72em/1.15 var(--font); color: inherit; opacity: .9; font-variant-numeric: tabular-nums; max-width: 100%; }
/* Small HUD controls get a bigger invisible hit area (44 px). */
.icon-btn::after { content: ""; position: absolute; inset: -2px; }
.hud-meter { flex: 1 1 auto; display: flex; align-items: center; gap: 6px; min-width: 70px; min-height: 44px; padding: 0; background: none; border: 0; box-shadow: none; color: var(--ink); }
.hud-meter:active:not(:disabled) { transform: none; box-shadow: none; }
.hud-meter .bar { flex: 1; height: 14px; min-width: 40px; }
.hud-pct { font-family: var(--font-head); font-weight: 600; font-size: .8em; white-space: nowrap; }
.hud-spacer { flex: 0 0 0; }
.icon-btn { flex: 0 0 auto; position: relative; width: 40px; height: 40px; padding: 0; display: grid; place-items: center; font-size: 1em; background: var(--panel); color: var(--ink); box-shadow: 0 3px 0 rgba(43, 35, 64, .15); border-radius: 12px; }
.hud-stats { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.stat {
  display: flex; align-items: center; gap: 6px; min-width: 0; padding: 4px 6px; text-align: left;
  background: var(--panel); color: var(--ink); border-radius: 12px; box-shadow: 0 3px 0 rgba(43, 35, 64, .14);
}
.s-ic { flex: 0 0 26px; width: 26px; height: 26px; }
.s-ic .art { width: 100%; height: 100%; }
.s-v { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.s-v b { font-family: var(--font-head); font-weight: 600; font-size: 1.08em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-v small { font-size: .72em; font-weight: 800; color: var(--good); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

@media (min-width: 900px) {
  #hud { display: grid; grid-template-columns: auto minmax(120px, 1fr) auto auto auto; align-items: center; column-gap: 10px; }
  .hud-top { display: contents; }
  .hud-spacer { display: none; }
  .stage-chip, .hud-meter, #mute, #gear, #res { grid-row: 1; }
  .stage-chip { max-width: 260px; }
  #res { grid-column: 3; margin-top: 0; grid-template-columns: repeat(var(--n, 3), minmax(130px, 170px)); }
  #mute { grid-column: 4; } #gear { grid-column: 5; }
  #status { grid-column: 1 / -1; }
}
/* The status rail: timers and warnings, one swipeable row. */
.rail { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 3px; }
.rail::-webkit-scrollbar { display: none; }
.rail.more { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
.chip {
  flex: 0 0 auto; display: inline-flex; flex-direction: column; gap: 3px; padding: 4px 10px; font-size: .78em; font-weight: 800; text-align: left; white-space: nowrap;
  background: var(--panel2); color: var(--ink); border: 2px solid var(--line); border-radius: 999px; box-shadow: none; max-width: 80vw;
}
.chip > span:first-child { overflow: hidden; text-overflow: ellipsis; }
button.chip:active:not(:disabled) { transform: scale(.97); box-shadow: none; }
.chip.bad { background: color-mix(in srgb, var(--bad) 18%, var(--panel)); border-color: var(--bad); color: var(--bad); animation: alertpulse 1.6s ease-in-out infinite; }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, var(--panel)); border-color: var(--warn); }
.chip.good { background: color-mix(in srgb, var(--good) 15%, var(--panel)); border-color: var(--good); }
.chip-bar { display: block; height: 3px; background: var(--bar-bg); border-radius: 2px; overflow: hidden; }
.chip-bar span { display: block; height: 100%; background: var(--accent); }
.chip.bad .chip-bar span { background: var(--bad); }
.chip.good .chip-bar span { background: var(--good); }
.chip.warn .chip-bar span { background: var(--warn); }
@keyframes alertpulse { 50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 30%, transparent); } }

/* ---------- bars ---------- */
.bar { display: block; height: 10px; background: var(--bar-bg); border-radius: 999px; overflow: hidden; position: relative; border: 2px solid var(--line); }
.bar.thin { height: 8px; border-width: 1.5px; }
.bar.big { height: 18px; }
.bar .fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear, background var(--t); border-radius: inherit; }
.bar .fill.warn { background: var(--warn); } .bar .fill.bad { background: var(--bad); } .bar .fill.good { background: var(--good); }
.hud-meter .bar .fill, .bar.big .fill { background: repeating-linear-gradient(45deg, var(--accent) 0 10px, color-mix(in srgb, var(--accent) 75%, #fff) 10px 20px); }
body[data-theme="terminal"] .bar { border-width: 1px; }

/* ---------- layout ---------- */
#cols { display: block; }
#tabs { display: none; }
@media (max-width: 899px) {
  #side { display: contents; }
  body.view-tab #home { display: none; }
  body.view-home #main { display: none; }
}
@media (min-width: 900px) {
  #cols { display: grid; grid-template-columns: minmax(340px, 410px) minmax(0, 1fr); gap: 16px; align-items: start; }
  #side { position: sticky; top: calc(var(--hud-h, 130px) + 14px); max-height: calc(100vh - var(--hud-h, 130px) - 24px); overflow-y: auto;
    scrollbar-width: thin; padding: 2px 4px 8px 2px; margin: -2px -4px 0 -2px; }
  #tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
  #bnav { display: none !important; }
  #main.no-tabs #tabs, #main.no-tabs #tab-body { display: none; }
}

/* ---------- tab bars ---------- */
.nav-b { display: flex; align-items: center; gap: 6px; padding: 5px 12px 5px 6px; background: var(--panel); color: var(--ink); font-family: var(--font-head); font-weight: 600; box-shadow: 0 3px 0 rgba(43, 35, 64, .15); }
.nav-b[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 var(--lip); }
.nav-ic { position: relative; width: 26px; height: 26px; flex: 0 0 auto; }
.nav-ic .art { width: 100%; height: 100%; }
.dot { position: absolute; top: -3px; right: -4px; width: 11px; height: 11px; border-radius: 50%; background: var(--bad); border: 2px solid var(--panel); }
#bnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px;
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + var(--safe-b)) max(8px, env(safe-area-inset-left, 0px));
  background: var(--hud); border-top: var(--bw) solid var(--line); box-shadow: 0 -4px 0 rgba(43, 35, 64, .06);
}
#bnav .nav-b { flex-direction: column; gap: 1px; padding: 4px 2px 3px; min-width: 0; border: 0; box-shadow: none; background: none; border-radius: 14px; font-size: .72em; }
#bnav .nav-ic { width: 30px; height: 30px; transition: transform .15s; }
#bnav .nav-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#bnav .nav-b[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--ink); }
#bnav .nav-b[aria-selected="true"] .nav-ic { transform: translateY(-2px) scale(1.12); }
#bnav .nav-b:active { transform: scale(.94); }
.more-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 6px; }
.more-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 4px 10px; background: var(--panel2); color: var(--ink); font-family: var(--font-head); font-weight: 600; font-size: .85em; }
.more-tile.on { background: color-mix(in srgb, var(--accent) 20%, var(--panel)); }
.more-tile .sticker { width: 40px; height: 40px; }
.more-tile .dot { top: 6px; right: 10px; }
.dot.new { width: auto; height: auto; top: -8px; right: -16px; border-radius: 999px; padding: 1px 5px; font: 800 9px/1.3 var(--font); font-style: normal;
  color: #fff; background: var(--accent2); letter-spacing: .04em; animation: newbadge 2.4s ease-in-out infinite; }
.more-tile .dot.new { top: 4px; right: 6px; }
@keyframes newbadge { 0%, 70%, 100% { transform: none; } 80% { transform: translateY(-3px) rotate(-6deg); } 90% { transform: translateY(0) rotate(4deg); } }

/* ---------- NANNY: card on wide screens, dock above the tab bar on phones ---------- */
#nanny { display: flex; gap: 10px; align-items: flex-start; }
.nanny-av { flex: 0 0 auto; position: relative; width: 64px; height: 64px; padding: 4px; background: var(--panel2); color: var(--ink); border-radius: 50%; box-shadow: 0 3px 0 rgba(43, 35, 64, .15); }
#nanny-portrait { display: block; width: 100%; height: 100%; }
#nanny-portrait .art { width: 100%; height: 100%; animation: bob 3.2s ease-in-out infinite; }
.nanny-dot { display: none; }
/* She has something to say: a speech-bubble badge on her portrait (phones). */
#nanny.note .nanny-dot { display: grid; place-items: center; position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); border: 2px solid var(--line); font: 900 13px/1 var(--font); animation: bob 1.4s ease-in-out infinite; }
#nanny.note .nanny-dot::before { content: "…"; margin-top: -5px; }
.nanny-bubble { flex: 1; min-width: 0; position: relative; background: var(--panel); border: var(--bw) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; }
.nanny-bubble::before { content: ""; position: absolute; left: -9px; top: 22px; width: 14px; height: 14px; background: var(--panel); border-left: var(--bw) solid var(--line); border-bottom: var(--bw) solid var(--line); transform: rotate(45deg); }
.nanny-name { display: flex; align-items: baseline; gap: 6px; font-family: var(--font-head); margin-bottom: 2px; }
.nanny-name b { color: var(--accent); font-weight: 600; }
.nanny-x { display: none; margin: -12px -10px -12px auto; min-width: 44px; min-height: 44px; padding: 0; font-size: 1em; background: none; border: 0; box-shadow: none; color: var(--muted); }
#nanny-text { margin: 0; font-size: .95em; }
/* A story beat is coming: NANNY rings for a moment first. */
#nanny.calling .nanny-av { animation: ringing 1s ease-in-out infinite; }
#nanny.calling .nanny-av::after { content: "💬"; position: absolute; right: -6px; top: -8px; font-size: 20px; animation: bob .8s ease-in-out infinite; }
@keyframes ringing { 0%, 50%, 100% { transform: none; } 10%, 30% { transform: rotate(-9deg) scale(1.06); } 20%, 40% { transform: rotate(9deg) scale(1.06); } }
#nanny-extra:empty { display: none; }
#nanny-extra { margin-top: 8px; display: grid; gap: 6px; }
@media (min-width: 900px) { #nanny { margin-bottom: 14px; } .nanny-av { pointer-events: none; } }
@media (max-width: 899px) {
  #nanny { position: fixed; z-index: 45; right: max(10px, env(safe-area-inset-right, 0px)); left: auto; bottom: calc(14px + var(--safe-b)); }
  body.has-bnav #nanny { bottom: calc(var(--nav-h) + 8px + var(--safe-b)); }
  #nanny .nanny-bubble { display: none; }
  #nanny .nanny-av { width: 54px; height: 54px; border: var(--bw) solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
  #nanny.open { left: max(10px, env(safe-area-inset-left, 0px)); align-items: flex-end; flex-direction: row-reverse; }
  #nanny.open .nanny-bubble { display: block; max-height: 42vh; overflow-y: auto; box-shadow: 0 6px 18px rgba(43, 35, 64, .22); }
  #nanny.open .nanny-bubble::before { top: auto; bottom: 18px; left: auto; right: -9px; transform: rotate(-135deg); }
  #nanny.open .nanny-x { display: inline-block; }
}

/* ---------- onboarding ---------- */
.tut-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#nanny-extra .tut-skip { margin-left: auto; background: none; box-shadow: none; color: var(--muted); padding: 4px 6px; text-decoration: underline; }
.tut-do { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 12px; line-height: 1.25;
  background: color-mix(in srgb, var(--accent2) 16%, var(--panel2)); border: 2px solid var(--accent2); }
.tut-arrow { animation: nudge 1.2s ease-in-out infinite; display: inline-block; }
.tut-do.fresh { animation: tutfresh 1s ease-out; }
@keyframes tutfresh { 0% { transform: scale(.96); box-shadow: 0 0 0 6px color-mix(in srgb, var(--good) 45%, transparent); } 60% { transform: none; } 100% { box-shadow: 0 0 0 0 transparent; } }
.tut-prog { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--accent2); }
.tut-hint { margin: 0; font-size: .85em; font-weight: 700; color: var(--accent2); }
.tut-hint:empty { display: none; }
/* Phones: the tutorial card is one line to do; the "why" opens on request. */
.tut-why { display: none; }
@media (max-width: 899px) {
  #nanny.tut .tut-why { display: inline-flex; align-items: center; }
  #nanny.tut:not(.why) #nanny-text { display: none; }
  #nanny.tut.why .tut-why { background: var(--accent2); color: #fff; }
  #nanny.tut #nanny-extra { margin-top: 4px; }
  #nanny.tut .tut-do { font-size: .92em; padding: 6px 10px; }
  #nanny.tut .tut-skip { font-size: .78em; padding: 4px 2px; }
}
@keyframes nudge { 50% { transform: translateX(4px); } }
.tut-target { z-index: 1; animation: tutpulse 1.4s ease-in-out infinite; }
@keyframes tutpulse {
  0%, 100% { outline: 3px solid transparent; outline-offset: 2px; }
  50% { outline: 4px solid var(--accent2); outline-offset: 4px; }
}

/* ---------- home: the garage scene ---------- */
#ticker {
  display: flex; gap: 8px; align-items: center; overflow: hidden; white-space: nowrap; padding: 6px 10px; margin-bottom: 12px; font-size: .84em;
  border: 2px solid var(--line); border-radius: 999px; background: var(--panel);
}
.ticker-tag { background: var(--bad); color: #fff; font-weight: 900; padding: 0 7px; border-radius: 999px; font-size: .8em; flex: 0 0 auto; }
#ticker-text { display: inline-block; animation: slidein .6s ease-out; overflow: hidden; text-overflow: ellipsis; }
@keyframes slidein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#desk { margin-bottom: 14px; }
.scene { position: relative; aspect-ratio: 360 / 200; border: var(--bw) solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: #e9c99a; }
.sc-art, .sc-art > .art { display: block; width: 100%; height: 100%; }
.sc-art .g-cut, .sc-art .g-cloth, .sc-art .g-stitch, .sc-art .g-pins { transition: opacity .25s; }
.sc-art.s0 .g-cloth, .sc-art.s0 .g-stitch, .sc-art.s0 .g-pins, .sc-art.s1 .g-stitch, .sc-art.s1 .g-pins, .sc-art.s2 .g-pins { opacity: 0; }
.sc-art:not(.s0) .g-cut { opacity: 0; }
.sc-art.made .g-cloth { animation: madeflash .5s ease-out; }
@keyframes madeflash { 0%, 40% { filter: brightness(1.25) drop-shadow(0 0 3px #fff6a8); } }
.g-slot { transform-box: fill-box; transform-origin: center bottom; }
.g-slot.new { animation: slotpop .35s ease-out; }
@keyframes slotpop { from { transform: scale(.2); } 60% { transform: scale(1.25); } to { transform: none; } }
.scene.sewing .g-needle { animation: needle .28s ease-in-out; }
.scene.m-press.sewing .g-needle { animation: stamp .4s ease-in-out; }
@keyframes stamp { 45% { transform: translateY(7px); } }
.scene.m-press.sewing .g-bulb { animation: bulb .4s steps(2) 2; }
@keyframes bulb { 50% { opacity: .25; } }
/* Idle life in the garage: the lamp and mobile sway, the cloud drifts, wheels turn when you work. */
.g-wheel, .g-roll { transform-box: fill-box; transform-origin: center; }
.scene.sewing .g-wheel, .scene.sewing .g-roll { animation: spin .45s ease-out; }
@keyframes spin { to { transform: rotate(360deg); } }
.g-lamp { transform-box: view-box; transform-origin: 150px 0; animation: sway 5s ease-in-out infinite; }
.g-mobile { transform-box: view-box; transform-origin: 207px 0; animation: sway 6.5s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
.g-cloud { animation: drift 16s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translateX(20px); } }
@keyframes needle { 50% { transform: translateY(5px); } }
.sc-nanny { position: absolute; left: 35.6%; bottom: 15.5%; width: 12.6%; aspect-ratio: 1; cursor: pointer; }
.sc-nanny.booped .art { animation: boop .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes boop { 0% { transform: scale(1); } 30% { transform: scale(1.25, .8) translateY(8%); } 60% { transform: scale(.9, 1.15) translateY(-12%); } 100% { transform: none; } }
.g-lamp { cursor: pointer; }
.g-lamp.flick circle { animation: flick .6s steps(1) 1; }
@keyframes flick { 0%, 40%, 80% { fill: #6a6a6a; } 20%, 60%, 100% { fill: #fff3a0; } }
.sc-nanny .art { width: 100%; height: 100%; animation: bob 3.2s ease-in-out infinite; }
.sc-step, .sc-stock { position: absolute; font: 600 .72em/1 var(--font-head); padding: 3px 7px; border-radius: 999px; background: var(--panel); color: var(--ink); border: 2px solid var(--line); pointer-events: none; }
.sc-step { left: 2%; bottom: 4%; }
.sc-stock { left: 50%; bottom: 31%; }
.sc-stock:empty { display: none; }
.sc-stock.empty { color: var(--bad); }
/* The doorway clips its people: customers walk in from behind the left post and waddle off out the right. */
.sc-doorway { position: absolute; left: 68.3%; width: 28.9%; top: 13%; bottom: 0; overflow: hidden; pointer-events: none; }
.sc-door { position: absolute; left: 9.2%; bottom: 19.5%; width: 79.6%; aspect-ratio: 2 / 3; }
.visitor, .leaver { position: absolute; inset: 0; }
.visitor .art, .leaver .art { width: 100%; height: 100%; }
.visitor .art { transform-origin: 50% 96%; animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.012, .985); } }
.visitor.arrive { animation: arrive .8s cubic-bezier(.3, .7, .4, 1) .9s backwards; }
.visitor.react { animation: react .4s ease-out; }
@keyframes arrive { from { transform: translateX(-115%); } 75% { transform: translateX(3%); } to { transform: none; } }
@keyframes react { 0% { transform: scale(.96, 1.04); } 55% { transform: scale(1.03, .97); } }
.leaver { opacity: 0; }
.leaver.leave { animation: waddleoff 2.5s cubic-bezier(.4, 0, .8, 1) forwards; }
.leaver.leave .art { transform-origin: 50% 96%; animation: waddle .42s ease-in-out .45s infinite; }
@keyframes waddleoff { 0% { opacity: 1; transform: none; } 9% { transform: translateY(-7%); } 18% { transform: none; } 100% { opacity: 1; transform: translate(118%, -2%) scale(.94); } }
@keyframes waddle { 0%, 100% { transform: rotate(-7deg); } 25% { transform: translateY(-3%); } 50% { transform: rotate(7deg); } 75% { transform: translateY(-3%); } }
/* Open eyes blink now and then. */
.visitor .eyes, .story-portrait .eyes, .event-portrait .eyes { transform-box: fill-box; transform-origin: center; animation: blinky 4.6s infinite; }
@keyframes blinky { 0%, 93%, 100% { transform: none; } 96% { transform: scaleY(.08); } }
.sc-say {
  position: absolute; right: 25%; top: 4%; max-width: 40%; padding: 4px 9px; font-size: .72em; line-height: 1.25;
  background: #fffdf6; color: #2b2340; border: 2px solid #2b2340; border-radius: 14px; box-shadow: 0 3px 0 rgba(43, 35, 64, .2);
}
.sc-say::after { content: ""; position: absolute; right: -8px; top: 22px; width: 12px; height: 12px; background: #fffdf6; border-top: 2px solid #2b2340; border-right: 2px solid #2b2340; transform: rotate(45deg); }
.sc-say b { font-family: var(--font-head); font-weight: 600; }
.sc-say span { font-style: italic; }
.sc-say.done { background: #e9fbe9; border-color: #23a05f; }
.sc-say.done span { font-style: normal; font-weight: 800; color: #1b7f4a; }
.sc-stress { position: absolute; left: 74.5%; width: 16%; bottom: 13%; }
.sc-stress .bar { height: 8px; border-width: 1.5px; border-color: #2b2340; background: #fff; }
.sc-title, .sc-closed { display: none; }
.desk-actions { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; margin-top: 12px; }
.act { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px 9px; min-height: 92px; overflow: hidden; }
.act[data-id="pitch"] { background: var(--accent2); }
body[data-theme="pastel"] .act { border-radius: 28px; }
.act[data-id="doodle"] { background: var(--accent3); }
.act-ic { width: 36px; height: 36px; }
.act-t { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.act b { font-family: var(--font-head); font-weight: 600; font-size: 1.12em; line-height: 1.1; }
.act small { color: inherit; opacity: .92; font-size: .74em; font-weight: 700; line-height: 1.2; text-align: center;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.act.waiting { opacity: .7; }
.act.cooling::after { content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: currentColor; opacity: .5; animation: sweep var(--cd, .4s) linear forwards; }
@keyframes sweep { from { width: 100%; } to { width: 0; } }
.desk-hint { text-align: center; }

/* ---------- supply at a glance ---------- */
.supply { display: grid; gap: 6px; }
.sline {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) minmax(60px, 34%) auto; gap: 8px; align-items: center; text-align: left; width: 100%;
  padding: 5px 8px 5px 5px; background: var(--panel2); color: var(--ink); border-width: 2px; border-radius: 12px; box-shadow: 0 2px 0 rgba(43, 35, 64, .12); font-weight: 700;
}
.sline .picon { width: 30px; height: 30px; }
.sl-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; font-size: .9em; }
.sl-name small { font-size: .78em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { font-weight: 900; font-size: .68em; padding: 2px 8px; border-radius: 999px; white-space: nowrap; border: 2px solid var(--line); }
.status:empty { display: none; }
.status.ok { background: color-mix(in srgb, var(--good) 22%, var(--panel)); color: var(--ink); border-color: var(--good); }
.status.short { background: var(--bad); color: #fff; }
.status.glut { background: var(--warn); color: #2b2340; }
.bottleneck { margin: 10px 0 0; padding: 8px 10px; border-radius: 12px; background: var(--panel2); font-size: .86em; border-left: 5px solid var(--good); }
.bottleneck.bad { border-left-color: var(--bad); }
.bottleneck.warn { border-left-color: var(--warn); }
.clickable { cursor: pointer; }
.quick-row button { flex: 1 1 160px; }

/* ---------- building rows ---------- */
.brows { display: grid; gap: 8px; }
@media (min-width: 1100px) { .brows { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.brow, .pline {
  display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; grid-template-areas: "ic mid buy" "up up up"; gap: 2px 10px; align-items: center;
  padding: 8px; background: var(--panel2); border: 2px solid var(--line); border-radius: 16px;
}
.brow.locked { opacity: .5; }
.b-ic { grid-area: ic; position: relative; width: 58px; height: 58px; padding: 5px; background: var(--panel); color: var(--ink); border-width: 2px; border-radius: 14px; box-shadow: 0 3px 0 rgba(43, 35, 64, .15); }
span.b-ic { display: block; border: 2px solid var(--line); }
.b-ic .sticker { width: 100%; height: 100%; }
.b-n { position: absolute; right: -8px; bottom: -8px; min-width: 24px; padding: 0 6px; background: var(--ink); color: var(--panel); border-radius: 999px;
  font: 600 .78em/20px var(--font-head); border: 2px solid var(--panel); font-variant-numeric: tabular-nums; }
.b-n:empty { display: none; }
.b-mid { grid-area: mid; display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.b-name { font-family: var(--font-head); font-weight: 600; font-size: 1em; line-height: 1.15; }
.b-rate { color: var(--good); font-weight: 900; font-size: .84em; font-variant-numeric: tabular-nums; }
.b-rate:empty { display: none; }
.b-flavor { color: var(--muted); font-size: .76em; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.b-build { color: var(--warn); font-weight: 800; font-size: .76em; }
.b-build:empty { display: none; }
.buy { grid-area: buy; min-width: 96px; display: flex; flex-direction: column; align-items: center; line-height: 1.1; padding: 6px 10px; background: var(--buy); color: #fff; }
.buy small { font-size: .72em; font-weight: 800; color: inherit; opacity: .92; white-space: nowrap; }
.buy b { font-family: var(--font-head); font-weight: 600; font-size: 1.05em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.upstar {
  grid-area: up; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; margin-top: 8px; padding: 5px 10px; text-align: left;
  background: #ffd84a; color: #3b2a20; font-size: .85em;
}
.upstar .star { font-size: 1.3em; animation: wobble 2s ease-in-out infinite; }
.upstar span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; }
.upstar span b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upstar small { color: inherit; opacity: .8; font-weight: 700; }
.upstar .upc { font-family: var(--font-head); font-weight: 600; white-space: nowrap; }
button.upstar:disabled[style*="--p"] { background: linear-gradient(90deg, #ffe58a calc(var(--p, 0) * 100%), var(--panel) 0); color: var(--muted); }
.qty { display: inline-flex; gap: 0; border: 2px solid var(--line); border-radius: 999px; background: var(--panel); }
.qty button { position: relative; min-width: 46px; min-height: 36px; padding: 3px 9px; font-size: .84em; background: none; color: var(--ink); border: 0; border-radius: 0; box-shadow: none; }
.qty button::after { content: ""; position: absolute; inset: -5px 0; }
.qty button:first-child { border-radius: 999px 0 0 999px; }
.qty button:last-child { border-radius: 0 999px 999px 0; }
.qty button + button { border-left: 2px solid var(--line); }
.qty button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.qty button:active:not(:disabled) { transform: none; box-shadow: none; }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; margin: 4px 0 10px; }
.seg button { border: 0; border-radius: 0; box-shadow: none; min-height: 44px; padding: 4px 14px; font-size: .84em; background: var(--panel); color: var(--ink); }
.seg button + button { border-left: 2px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* ---------- product lines ---------- */
.pline { grid-template-areas: "head head head" "flow flow flow" "bar bar bar" "note note note" "price price price" "up up up"; grid-template-columns: 1fr; margin-bottom: 8px; }
.pl-head { grid-area: head; display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; grid-template-areas: "ic mid buy"; gap: 10px; align-items: center; }
.pl-head .b-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pl-flow { grid-area: flow; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.pl-num { display: flex; flex-direction: column; background: var(--panel); border-radius: 10px; padding: 3px 7px; min-width: 0; }
.pl-num small { font-size: .7em; font-weight: 800; }
.pl-num b { font-family: var(--font-head); font-weight: 600; font-size: .9em; line-height: 1.15; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.pline > .bar { grid-area: bar; margin-top: 6px; }
.pl-note { grid-area: note; font-size: .76em; }
.pl-note:empty { display: none; }
details.price { grid-area: price; margin-top: 6px; font-size: .86em; }
details.price summary { cursor: pointer; color: var(--muted); font-weight: 700; }
.price-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 6px; }
.price-row input[type="range"] { flex: 1 1 140px; min-width: 120px; accent-color: var(--accent); }
.price-note { flex-basis: 100%; }
.tierpips { display: inline-flex; gap: 2px; vertical-align: middle; margin-left: 4px; }
.tierpips i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--line); }
.tierpips i.on { background: var(--accent); }
.sd-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 8px; font-size: .86em; }
.sd-tan { display: inline-flex; align-items: center; gap: 6px; flex: 1 1 120px; }
.sd-tan .bar { flex: 1; min-width: 60px; }

/* ---------- cards (research, shops) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.card { border: 2px solid var(--line); border-radius: 16px; padding: 10px; background: var(--panel2); display: flex; flex-direction: column; gap: 5px; }
.card .name { font-family: var(--font-head); font-weight: 600; }
.card .desc { font-size: .88em; }
.card button { margin-top: auto; }
.card.done { opacity: .6; }
.card.ready { border-color: var(--good); box-shadow: 0 0 0 2px color-mix(in srgb, var(--good) 35%, transparent); }
.card .bar { height: 8px; border-width: 1.5px; }
.tag { display: inline-block; align-self: flex-start; font-size: .72em; font-weight: 800; padding: 1px 8px; border-radius: 999px; background: var(--panel); border: 1.5px solid var(--line); color: var(--muted); }
.tag.good { color: var(--good); border-color: var(--good); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .92em; margin: 0 0 8px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.tiers { display: grid; gap: 2px; font-size: .88em; margin-bottom: 10px; }

/* ---------- research ---------- */
.rp-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0; }
.rp-big { font-family: var(--font-head); font-size: 1.5em; font-weight: 600; font-variant-numeric: tabular-nums; }
.benches { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; margin: 6px 0; }
.bench { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; background: var(--panel2); border: 2px dashed var(--line); border-radius: 14px; min-width: 0; font-size: .9em; line-height: 1.25; }
.bench.busy { border-style: solid; border-color: var(--warn); }
.bench b { overflow-wrap: anywhere; font-size: .92em; }
.bench .bar { height: 8px; border-width: 1.5px; }
.rqueue ol { margin: 4px 0 8px; padding-left: 22px; }
.rqueue li { margin: 3px 0; }
.rqueue li button { padding: 0 6px; }
.fork { border-color: var(--accent2); background: color-mix(in srgb, var(--accent2) 8%, var(--panel)); }
.fork-nanny { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0 10px; }
.fork-av { width: 40px; height: 40px; flex: 0 0 auto; }
.fork-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.view-toggle { display: inline-flex; }
details.tree { border-top: 2px dashed var(--bar-bg); padding: 6px 0; }
details.tree summary { cursor: pointer; padding: 4px 0; display: flex; align-items: center; gap: 6px; list-style: none; }
details.tree summary::before { content: "▸"; color: var(--muted); }
details.tree[open] summary::before { content: "▾"; }
.tnode { display: grid; grid-template-columns: 1.6em 1fr auto; gap: 8px; align-items: center; padding: 6px 8px;
  margin: 4px 0 4px calc(var(--d, 0) * 16px); border-left: 4px solid var(--bar-bg); border-radius: 0 12px 12px 0; background: var(--panel2); }
.tnode .tname { display: flex; flex-direction: column; min-width: 0; }
.tnode.done { border-left-color: var(--good); opacity: .75; }
.tnode.done .ticon { color: var(--good); }
.tnode.ready { border-left-color: var(--accent); }
.tnode.busy { border-left-color: var(--warn); }
.tnode.locked { opacity: .55; }
.tnode.closed { opacity: .4; border-left-style: dashed; }
.tnode.closed .tname b { text-decoration: line-through; }
@media (max-width: 600px) { .tnode { margin-left: calc(var(--d, 0) * 8px); } }
.tgroup { margin: 10px 0 2px; font-weight: 800; font-size: .9em; color: var(--muted); }

/* ---------- diaper catalog ---------- */
.crow { display: grid; grid-template-columns: 7.5em 1fr; gap: 8px; align-items: start; padding: 8px 0; border-bottom: 2px dashed var(--bar-bg); }
.crow:last-child { border-bottom: none; }
.crow-name { font-weight: 800; color: var(--muted); font-size: .85em; padding-top: 6px; }
.ctrack { display: flex; gap: 6px; align-items: stretch; overflow-x: auto; padding: 2px 2px 6px; scroll-snap-type: x proximity; }
.carrow { align-self: center; color: var(--muted); font-weight: 900; }
.cstyle { flex: 0 0 168px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 4px; padding: 8px; font-size: .84em;
  border: 2px solid var(--line); border-radius: 14px; background: var(--panel2); }
.cstyle b { font-family: var(--font-head); font-weight: 600; }
.cs-art { width: 60px; height: 60px; align-self: center; margin: -2px 0 -4px; }
.rc-art { float: right; width: 54px; height: 54px; margin: -4px -4px 0 6px; }
.rc-art .art { width: 100%; height: 100%; }
.cs-art .art { width: 100%; height: 100%; }
.cstyle.locked .cs-art { filter: grayscale(.7); }
.cstyle.owned { border-color: var(--good); }
.cstyle.avail { border-color: var(--accent); }
.cstyle.tooling { border-color: var(--warn); }
.cstyle.locked { opacity: .5; }
.cstyle button, .cstyle .tag, .cstyle .bar { margin-top: auto; }
.buy-s { background: var(--buy); color: #fff; }
@media (max-width: 600px) { .crow { grid-template-columns: 1fr; } .crow-name { padding-top: 0; } }

/* ---------- world ---------- */
.tilemap { display: grid; gap: 6px; margin-bottom: 10px; grid-template-columns: repeat(6, 1fr); grid-template-areas: "na na . eu ea ea" "latam . mena sa sea ." "latam . ssa . . oc"; }
.rtile { position: relative; overflow: hidden; min-height: 64px; padding: 6px 8px; display: flex; flex-direction: column; justify-content: space-between;
  border: 2px dashed var(--line); border-radius: 14px; background: var(--panel2); opacity: .55; }
.rtile.open { border-style: solid; opacity: 1; }
.rfill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--accent); opacity: .35; transition: height .6s ease-out; }
.rname, .rpct { position: relative; font-size: .78em; font-weight: 700; }
.rpct { font-family: var(--font-head); font-variant-numeric: tabular-nums; }
@media (max-width: 899px) { .tilemap { grid-template-columns: repeat(3, 1fr); grid-template-areas: "na eu ea" "latam mena sa" "ssa sea oc"; } }
.regions { display: grid; gap: 8px; }
.region { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; background: var(--panel2); border: 2px solid var(--line); border-radius: 14px; }
.region-bar { height: 8px; margin: 4px 0 2px; border-width: 1.5px; }

/* ---------- sheets and modals ---------- */
#modal {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(43, 35, 64, .5);
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, var(--safe-b)) max(16px, env(safe-area-inset-left, 0px));
}
.modal-card {
  background: var(--panel); color: var(--ink); border: var(--bw) solid var(--line); border-radius: var(--radius); max-width: 560px; width: 100%;
  padding: 20px; box-shadow: 0 8px 0 rgba(43, 35, 64, .25), 0 24px 60px rgba(0, 0, 0, .3); max-height: 88vh; overflow-y: auto; animation: popin .45s cubic-bezier(.2, .9, .3, 1.08);
}
/* Pop-ups ease in over a dimming backdrop and fade back out. */
#modal:not([hidden]) { animation: dimin .35s ease-out; }
#modal.closing { animation: dimout .24s ease-in forwards; pointer-events: none; }
#modal.closing .modal-card { animation: popout .24s ease-in forwards; }
@keyframes dimin { from { background: rgba(43, 35, 64, 0); } }
@keyframes dimout { to { background: rgba(43, 35, 64, 0); } }
@keyframes popout { to { opacity: 0; transform: translateY(14px) scale(.98); } }
.modal-card { --pad-b: 20px; }
/* The button stays in reach at the bottom of a long card. */
.modal-card > .btn-row:not(:empty) { margin-top: 14px; justify-content: flex-end; position: sticky; z-index: 2; bottom: calc(-1 * var(--pad-b));
  margin-bottom: calc(-1 * var(--pad-b)); padding: 12px 0 var(--pad-b); background: linear-gradient(to bottom, transparent, var(--panel) 12px); }
@keyframes popin { from { opacity: 0; transform: scale(.94) translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 899px) {
  #modal { align-items: flex-end; padding: max(24px, env(safe-area-inset-top, 0px)) 0 0; }
  .modal-card { --pad-b: calc(18px + var(--safe-b)); max-width: none; border-radius: 26px 26px 0 0; border-bottom: 0; max-height: 86vh; padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(18px + var(--safe-b)) max(16px, env(safe-area-inset-left, 0px));
    animation: sheetup .5s cubic-bezier(.22, 1, .36, 1); }
  .modal-card::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 99px; background: var(--bar-bg); margin: -8px auto 12px; }
  .modal-card > .btn-row button { flex: 1; }
}
@keyframes sheetup { from { transform: translateY(70%); opacity: 0; } 40% { opacity: 1; } to { transform: none; opacity: 1; } }
@media (max-width: 899px) { #modal.closing .modal-card { animation: sheetdown .24s ease-in forwards; } }
@keyframes sheetdown { to { transform: translateY(40%); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.sheet-ic { width: 56px; height: 56px; flex: 0 0 auto; }
.sheet-head > div { display: flex; flex-direction: column; min-width: 0; }
.sheet-head small { font-weight: 800; }
.sheet-head b { font-family: var(--font-head); font-size: 1.7em; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sheet-head span { font-weight: 900; }
.spark-box { display: block; height: 30px; margin: 4px 0; }
.spark { width: 100%; height: 30px; display: block; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.shares { display: grid; gap: 6px; margin-bottom: 10px; }
.share { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(50px, 1fr) auto; gap: 8px; align-items: center; font-size: .88em; }
.share-n { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.share .picon { width: 24px; height: 24px; flex: 0 0 auto; }
.share b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stages { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; }
.stages li { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 12px; background: var(--panel2); opacity: .6; }
.stages li > b { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); background: var(--panel); font-family: var(--font-head); }
.stages li span { display: flex; flex-direction: column; }
.stages li small { font-size: .8em; }
.stages li.done { opacity: .85; }
.stages li.done > b { background: var(--good); color: #fff; }
.stages li.now { opacity: 1; outline: 3px solid var(--accent); }
.stages li.now > b { background: var(--accent); color: var(--accent-ink); }
.miles { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 10px; }
.mile { font: 600 .78em/1 var(--font-head); padding: 4px 8px; border-radius: 999px; border: 2px solid var(--line); background: var(--panel2); opacity: .55; }
.mile.ready { opacity: 1; background: #ffd84a; color: #3b2a20; }
.mile.got { opacity: 1; background: var(--good); color: #fff; }
.welcome { text-align: center; }
.welcome > .art { width: 80px; height: 80px; margin: 0 auto 6px; }
.welcome .kv { text-align: left; max-width: 260px; margin: 0 auto; }
.form-err { margin: 8px 0 0; color: var(--bad); font-weight: 800; }
textarea { width: 100%; min-height: 120px; font-family: ui-monospace, monospace; font-size: 12px; background: var(--panel2); color: var(--ink); border: 2px solid var(--line); border-radius: 10px; padding: 8px; }
.ending p { opacity: 0; animation: fadein 1.2s forwards; }
@keyframes fadein { to { opacity: 1; } }

/* ---------- events ---------- */
#event { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--panel)); }
.event-card h3 { color: var(--ink); }
.choice { display: block; width: 100%; text-align: left; margin-top: 8px; background: var(--panel2); color: var(--ink); box-shadow: 0 3px 0 rgba(43, 35, 64, .15); }
.choice small { display: block; color: var(--muted); font-weight: 700; }
.event-pop { text-align: center; display: grid; gap: 8px; }
.event-pop h2 { margin: 0; }
.event-pop .choice { text-align: left; }
.event-icon { font-size: 3em; line-height: 1; animation: wobble 1.6s ease-in-out infinite; }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.event-portrait { width: 84px; height: 84px; margin: 0 auto; }
.event-portrait .art { width: 84px; height: 84px; animation: jitter .2s linear infinite; }

/* ---------- story ---------- */
.story { display: grid; gap: 4px; }
.story h2 { margin: 0 0 8px; text-align: center; }
.story > small { text-align: center; font-weight: 800; }
.story p { opacity: 0; animation: fadein .9s ease-out forwards; display: flex; gap: 8px; align-items: flex-start; }
.story .narr { font-style: italic; color: var(--muted); display: block; }
.story p .who { flex: 0 0 30px; height: 30px; }
.story p .who .art { width: 30px; height: 30px; }
.story .rival { color: color-mix(in srgb, #b5452f 70%, var(--ink)); font-weight: 700; }
.story-portrait { position: relative; width: 92px; height: 92px; margin: 0 auto; animation: popin .4s ease-out; }
.story-portrait .art { width: 92px; height: 92px; }
.story-portrait.rival .art { animation: jitter .18s linear infinite; }
.story-badge { position: absolute; right: -8px; bottom: -2px; font-size: 1.5em; }
.story-list { display: flex; flex-wrap: wrap; gap: 6px; }
.story-choices { opacity: 0; animation: fadein .8s forwards; margin-top: 4px; }
.choice-done { padding: 6px 10px; margin-top: 6px; border: 2px dashed var(--line); border-radius: 12px; opacity: .6; }
.choice-done.picked { opacity: 1; border-style: solid; border-color: var(--accent); }
.choice-done small { display: block; color: var(--muted); }
@keyframes jitter { 25% { transform: translate(.6px, -.4px); } 50% { transform: translate(-.5px, .5px); } 75% { transform: translate(.4px, .6px); } }

/* ---------- achievements, log ---------- */
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; margin-top: 10px; }
.ach div { padding: 6px 9px; border: 2px dashed var(--line); border-radius: 12px; font-size: .84em; display: flex; flex-direction: column; }
.ach div.got { border-style: solid; background: color-mix(in srgb, var(--warn) 14%, var(--panel)); }
.ach div:not(.got) { opacity: .5; }
.log { list-style: none; padding: 0; margin: 0; max-height: 300px; overflow-y: auto; font-size: .86em; }
.log li { padding: 4px 0; border-bottom: 1px dashed var(--bar-bg); }
.log .t { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
label.toggle { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
label.vol { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
label.vol input { flex: 1; max-width: 240px; accent-color: var(--accent); }

/* ---------- feedback ---------- */
.float {
  position: fixed; z-index: 80; pointer-events: none; transform: translateX(-50%); font-family: var(--font-head); font-weight: 600; font-size: 1.05em;
  color: var(--ink); text-shadow: 0 2px 0 var(--panel), 0 0 6px var(--panel), 0 -1px 0 var(--panel); animation: floatup 1.05s ease-out forwards; white-space: nowrap;
}
.float.good { color: var(--good); }
/* Money drips out under the cash tile instead of covering the number. */
.float.money { color: var(--good); font-size: .82em; animation-name: floatdown; }
@keyframes floatdown { from { opacity: 0; transform: translate(-50%, -4px) scale(.9); } 20% { opacity: 1; transform: translate(-50%, 2px) scale(1.05); } to { opacity: 0; transform: translate(-50%, 16px) scale(1); } }
/* Juice: coins fly to the wallet, reaction stickers slap on, big buttons squash, bought rows flash gold. */
.coin { position: fixed; z-index: 85; width: 18px; height: 18px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #fff6b0 0 18%, #ffd23f 22% 60%, #e8a20c 64%); border: 2px solid #8a5a00; }
.coin::after { content: "$"; position: absolute; inset: 0; display: grid; place-items: center; font: 900 10px/1 var(--font); color: #8a5a00; }
.coin.giggle { background: radial-gradient(circle at 35% 30%, #fff 0 18%, #ff9fc8 22% 60%, #ff6fae 64%); border-color: #a3336b; }
.coin.giggle::after { content: "♥"; color: #a3336b; }
.react-sticker { position: fixed; z-index: 84; pointer-events: none; transform: translate(-50%, 0) rotate(var(--rot, -6deg)); padding: 4px 12px;
  font: 700 1em/1.2 var(--font-head); color: #3b2a20; background: #fff27a; border: 2.5px solid #3b2a20; border-radius: 999px; white-space: nowrap;
  filter: drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff) drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff) drop-shadow(0 3px 2px rgba(43, 35, 64, .3));
  animation: slap 1.8s cubic-bezier(.3, 1.6, .5, 1) forwards; }
.react-sticker:nth-of-type(3n) { background: #ffc2dd; } .react-sticker:nth-of-type(3n+1) { background: #9fe8d0; }
@keyframes slap { 0% { opacity: 0; transform: translate(-50%, 0) rotate(var(--rot)) scale(2.2); } 14% { opacity: 1; transform: translate(-50%, 0) rotate(var(--rot)) scale(.92); }
  22% { transform: translate(-50%, 0) rotate(var(--rot)) scale(1.05); } 30%, 80% { opacity: 1; transform: translate(-50%, 0) rotate(var(--rot)) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -14px) rotate(var(--rot)) scale(.96); } }
.squish { animation: squish .32s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes squish { 0% { transform: scale(1); } 30% { transform: scale(1.07, .9); } 65% { transform: scale(.96, 1.05); } 100% { transform: none; } }
.bought { animation: bought .7s ease-out; }
.bought .b-n { animation: countbounce .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bought { 0% { box-shadow: 0 0 0 0 #ffd84a; background-color: #fff3b0; } 40% { box-shadow: 0 0 0 5px #ffd84a; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes countbounce { 40% { transform: scale(1.45) translateY(-3px); } }
@keyframes floatup { from { opacity: 1; transform: translate(-50%, 0) scale(.9); } 20% { transform: translate(-50%, -8px) scale(1.12); } to { opacity: 0; transform: translate(-50%, -46px) scale(1); } }
.pop { animation: pop .22s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.05); } 100% { transform: scale(1); } }
.reveal { animation: reveal .7s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 4px var(--accent2), 0 0 24px 4px var(--accent2); } 100% { box-shadow: 0 0 0 0 transparent; } }
#toasts {
  position: fixed; z-index: 55; display: flex; flex-direction: column-reverse; gap: 6px; pointer-events: none;
  bottom: calc(var(--dock-h, 0px) + 12px + var(--safe-b)); right: max(12px, env(safe-area-inset-right, 0px)); width: min(340px, calc(100vw - 24px));
}
.toast {
  pointer-events: auto; background: var(--panel); color: var(--ink); border: 2px solid var(--accent); border-radius: 14px;
  box-shadow: 0 4px 0 rgba(43, 35, 64, .18), 0 10px 24px rgba(0, 0, 0, .18); padding: 9px 12px; font-size: .88em; font-weight: 700;
  animation: toastin .3s ease-out; transition: opacity .4s, transform .4s;
}
.toast.good { border-color: var(--good); }
.toast.alert { border-color: var(--bad); }
.toast.out { opacity: 0; transform: translateX(16px); }
/* Phones: toasts drop in under the HUD, clear of the buttons you're tapping. */
@media (max-width: 899px) {
  #toasts { bottom: auto; top: calc(var(--hud-h, 120px) + 8px); left: 50%; right: auto; transform: translateX(-50%); flex-direction: column; }
  .toast { padding: 7px 12px; font-size: .84em; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
  .toast.out { transform: translateY(-12px); }
}
@keyframes toastin { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
#tab-body.tab-enter { animation: tabin .28s ease-out; }
@keyframes tabin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- stage splash ---------- */
.modal-card.splash-card { max-width: 620px; overflow-x: hidden; position: relative; }
.splash { text-align: center; display: grid; gap: 6px; }
.splash-art { border-radius: 16px; overflow: hidden; border: var(--bw) solid var(--line); animation: popin .5s ease-out; }
.splash-art > .art { width: 100%; height: auto; }
.splash-kicker { text-transform: uppercase; letter-spacing: .12em; color: var(--accent); font-weight: 900; margin-top: 6px; }
.splash h2 { font-size: 1.8em; margin: 0; animation: popin .5s .15s ease-out both; }
.splash-nanny { display: flex; gap: 10px; align-items: center; text-align: left; background: var(--panel2); border-radius: 16px; padding: 8px 10px; }
.splash-nanny .art { flex: 0 0 56px; width: 56px; height: 56px; }
.splash-nanny p { margin: 0; }
.confetti { position: absolute; top: -40px; width: 24px; height: 24px; z-index: 2; pointer-events: none; animation: fall 3s ease-in forwards; }
.confetti .art { width: 100%; height: 100%; }
@keyframes fall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 85% { opacity: 1; } 100% { transform: translateY(560px) rotate(540deg); opacity: 0; } }
.stage-banner { position: fixed; left: 50%; top: max(12px, env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 80; display: flex; gap: 10px;
  align-items: center; padding: 6px 14px 6px 6px; background: var(--panel); color: var(--ink); border: var(--bw) solid var(--line);
  border-radius: 18px; box-shadow: 0 6px 0 rgba(43, 35, 64, .2); animation: dropin .4s ease-out; transition: opacity .5s, transform .5s; }
.stage-banner.out { opacity: 0; transform: translate(-50%, -20px); }
.stage-banner .sb-art { width: 96px; height: 54px; border-radius: 10px; overflow: hidden; }
.stage-banner .sb-art > .art { width: 96px; height: 54px; }
.stage-banner small { display: block; color: var(--muted); }
@keyframes dropin { from { opacity: 0; transform: translate(-50%, -24px); } to { opacity: 1; transform: translateX(-50%); } }

/* ---------- NANNY looks after the CEO ---------- */
/* Something left waiting asks for attention, more like a baby toy the later it gets:
   1 a soft glow, 2 a little wiggle every few seconds, 3 a bounce with a pointing hand. */
.nudge { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent2) 70%, transparent), 0 0 18px 4px color-mix(in srgb, var(--accent2) 45%, transparent) !important; z-index: 2; }
.nudge-1 { animation: nudgeglow 2.4s ease-in-out infinite; }
.nudge-2 { animation: nudgewiggle 2.8s ease-in-out infinite; }
.nudge-3 { animation: nudgebounce 2.2s ease-in-out infinite; }
.nudge-3::after { content: "👆"; position: absolute; right: -6px; bottom: -22px; font-size: 22px; pointer-events: none; animation: bob .7s ease-in-out infinite; z-index: 3; }
@keyframes nudgeglow { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent2) 40%, transparent), 0 0 26px 8px color-mix(in srgb, var(--accent2) 30%, transparent); } }
@keyframes nudgewiggle { 0%, 70%, 100% { transform: none; } 76% { transform: rotate(-4deg) scale(1.04); } 82% { transform: rotate(4deg) scale(1.04); } 88% { transform: rotate(-2deg); } 94% { transform: rotate(1deg); } }
@keyframes nudgebounce { 0%, 60%, 100% { transform: none; } 70% { transform: translateY(-6px) scale(1.06, .96); } 80% { transform: translateY(0) scale(.97, 1.04); } 88% { transform: translateY(-3px); } }
/* NANNY's cheers: a speech bubble that floats up from whatever you just did. */
.float.praise {
  font-size: .95em; color: var(--ink); background: var(--panel); border: 2px solid var(--accent3); border-radius: 14px; padding: 3px 10px;
  text-shadow: none; box-shadow: 0 3px 0 rgba(43, 35, 64, .15); animation: praiseup 2.3s ease-out forwards; max-width: calc(100vw - 24px); white-space: normal; text-align: center;
}
.float.praise::before { content: "💬 "; }
@keyframes praiseup { 0% { opacity: 0; transform: translate(-50%, 6px) scale(.7); } 12% { opacity: 1; transform: translate(-50%, -10px) scale(1.08); }
  20% { transform: translate(-50%, -12px) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -40px); } }
/* Later stages: toasts bounce in like a pop-up book, bars turn into rainbows, tab icons sit on ABC blocks. */
body[data-theme="pastel"] .toast, body[data-theme="storybook"] .toast { animation: toastbounce .55s cubic-bezier(.3, 1.6, .5, 1); border-width: 3px; }
@keyframes toastbounce { from { opacity: 0; transform: translateY(-14px) scale(.8); } 60% { opacity: 1; transform: translateY(2px) scale(1.04); } to { transform: none; } }
body[data-theme="storybook"] .bar .fill:not(.bad):not(.warn) { background: linear-gradient(90deg, #ff8f8f, #ffcf6b, #fff27a, #9be89b, #8fd0ff, #c9a6ff); }
body[data-theme="storybook"] #bnav .nav-ic, body[data-theme="storybook"] #tabs .nav-ic { border: 2px solid var(--line); border-radius: 8px; padding: 2px; background: #ffd94d; box-shadow: 2px 2px 0 rgba(61, 42, 26, .25); }
body[data-theme="storybook"] .nav-b:nth-child(4n+2) .nav-ic { background: #8fd0ff; }
body[data-theme="storybook"] .nav-b:nth-child(4n+3) .nav-ic { background: #ff9fb8; }
body[data-theme="storybook"] .nav-b:nth-child(4n+4) .nav-ic { background: #9be89b; }
body[data-theme="pastel"] .modal-card .btn-row button, body[data-theme="storybook"] .modal-card .btn-row button { animation: popin .45s .2s cubic-bezier(.3, 1.6, .5, 1) both; }
.welcome.peek .art { animation: peekaboo 1.6s ease-in-out .2s both; }
@keyframes peekaboo { 0% { transform: scale(.6) rotate(-8deg); opacity: 0; } 30% { transform: scale(1.1); opacity: 1; } 45% { transform: scale(.95) rotate(3deg); } 60%, 100% { transform: none; } }

/* ---------- title screen ---------- */
.boot { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; overflow-y: auto;
  padding: max(18px, env(safe-area-inset-top, 0px)) 16px max(18px, var(--safe-b));
  background: radial-gradient(ellipse at 50% 30%, rgba(255, 244, 222, .95) 0, rgba(255, 244, 222, 0) 60%), var(--pattern), var(--bg); background-size: auto, var(--pattern-size), auto;
  color: var(--ink); font-family: var(--font); transition: opacity .45s ease, transform .45s ease; }
.boot.out { opacity: 0; transform: scale(1.03); pointer-events: none; }
.boot-card { width: min(440px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; }
/* The garage, framed like it is on the home screen. */
.boot-scene { width: 100%; aspect-ratio: 360 / 200; border: 3px solid var(--line); border-radius: 22px; overflow: hidden; background: #e9c99a;
  box-shadow: 0 6px 0 rgba(59, 42, 32, .22); }
.boot-scene > .art { display: block; width: 100%; height: 100%; animation: bootin .6s ease-out both; }
.boot-scene:empty { background: linear-gradient(100deg, #e9c99a 30%, #f3dbb4 50%, #e9c99a 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }
@keyframes bootin { from { opacity: 0; } }
/* The logo: a sticker-style plate that overlaps the bottom of the picture. */
.boot-logo { position: relative; margin: -26px 0 0; padding: 10px 26px 12px; background: var(--accent); border: 3px solid var(--line); border-radius: 20px;
  transform: rotate(-2deg); box-shadow: 0 6px 0 rgba(59, 42, 32, .25); font-family: var(--font-head); font-weight: 700; line-height: .95; color: #fff;
  -webkit-text-stroke: 1.5px var(--line); paint-order: stroke fill; text-shadow: 0 3px 0 rgba(59, 42, 32, .35); }
.boot-logo span { display: block; }
.boot-logo .l1 { font-size: clamp(1.9rem, 9.5vw, 2.7rem); letter-spacing: .01em; }
.boot-logo .l2 { font-size: clamp(1.45rem, 7.2vw, 2.05rem); color: #fff3c4; }
.boot-logo .inc { position: absolute; right: -14px; bottom: -12px; padding: 3px 10px; font-size: 1rem; background: #ffd23f; color: var(--line);
  -webkit-text-stroke: 0; text-shadow: none; border: 2.5px solid var(--line); border-radius: 999px; transform: rotate(8deg); }
.boot-tag { margin: 22px 0 0; font-weight: 800; color: var(--muted); text-wrap: balance; }
.boot-go { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; margin-top: 16px; min-width: 230px; min-height: 60px;
  padding: 8px 34px; border-radius: 999px; background: var(--buy); color: #fff; border: 3px solid var(--line); box-shadow: 0 5px 0 var(--lip); cursor: pointer;
  font-family: var(--font-head); transition: background .3s, transform .1s; }
.boot-go b { font-size: 1.35rem; font-weight: 700; }
.boot-go small { font-family: var(--font); font-size: .78rem; font-weight: 800; color: #fff; opacity: .95; }
.boot-go:focus { outline: none; }
.boot-go:focus-visible { outline: 3px solid var(--line); outline-offset: 4px; }
.boot-go small:empty { display: none; }
.boot-go:not(:disabled) { animation: bootpulse 1.8s ease-in-out .4s infinite; }
.boot-go:disabled { background: #b9a990; cursor: default; box-shadow: 0 5px 0 rgba(59, 42, 32, .18); }
.boot-go:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--lip); animation: none; }
@keyframes bootpulse { 50% { transform: scale(1.035); } }
.boot-small { margin: 14px 0 0; font-size: .78em; color: var(--muted); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* Naptime advice: what the next run gains. */
.nap-advice { margin: 6px 0 0; padding: 8px 12px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 12%, var(--panel)); font-weight: 700; font-size: .9em; }
.nap-advice:empty { display: none; }
/* Pep (Viral Pitch Deck): taps spend it, rest refills it. */
.pep { display: flex; align-items: center; gap: 8px; margin: 6px 2px 0; font-size: .8em; font-weight: 800; }
.pep .bar { flex: 1; }
.pep small { white-space: nowrap; }
.pep-l { color: var(--good); }

/* ---------- charts: the numbers board (home) and the Charts tab ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.kpi { display: grid; grid-template-rows: auto auto auto 1fr; gap: 1px; min-width: 0; min-height: 96px; padding: 8px 10px 6px; text-align: left;
  background: var(--panel2); color: var(--ink); border-radius: 14px; box-shadow: 0 3px 0 rgba(43, 35, 64, .12); }
.kpi small { color: var(--muted); font-weight: 800; font-size: .74em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi b { font-family: var(--font-head); font-weight: 600; font-size: 1.2em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi em, .ch-head em { font-style: normal; font-weight: 800; font-size: .74em; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi em:empty::before { content: "\00a0"; }
.kpi-sp { position: relative; display: block; height: 30px; margin-top: 3px; }
.kpi-spark { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.kpi-dot { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--panel2); }
@media (min-width: 560px) and (max-width: 899px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ch-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ch-area { fill: var(--accent); opacity: .1; stroke: none; }
.ch-ghost { fill: none; stroke: var(--muted); stroke-width: 1.5; opacity: .55; stroke-linejoin: round; }
.ch-grid { stroke: color-mix(in srgb, var(--muted) 22%, transparent); stroke-width: 1; }
.ch-stage { stroke: color-mix(in srgb, var(--muted) 45%, transparent); stroke-width: 1; }
.ch-ax { fill: var(--muted); font: 700 10px var(--font); font-variant-numeric: tabular-nums; }
.ch-st { fill: var(--muted); font: 800 10px var(--font); }
.ch-dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.ch-seg { display: inline-flex; gap: 2px; margin: 0 0 10px; padding: 3px; background: var(--panel); border: 2px solid var(--line); border-radius: 999px; }
.ch-seg button, .ch-seg button.ghost { min-height: 40px; padding: 4px 16px; border: 0; border-radius: 999px; box-shadow: none; background: transparent; color: var(--ink); font-weight: 800; }
.ch-seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.chart-card { padding-bottom: 8px; }
.ch-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; margin-bottom: 4px; }
.ch-head small { display: block; color: var(--muted); font-weight: 800; font-size: .8em; }
.ch-head b { font-family: var(--font-head); font-weight: 600; font-size: 1.35em; font-variant-numeric: tabular-nums; }
.ch-legend { display: flex; gap: 14px; font-size: .78em; font-weight: 800; color: var(--muted); margin-bottom: 2px; }
.ch-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lk { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--accent); border-radius: 2px; }
.lk.ghost { border-top: 1.5px solid var(--muted); opacity: .7; }
.chart { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.ch-svg { display: block; }
.ch-cross { position: absolute; top: 16px; bottom: 22px; width: 1px; background: var(--ink); opacity: .45; pointer-events: none; }
.ch-tip { position: absolute; top: 0; display: grid; gap: 1px; padding: 5px 9px; border-radius: 10px; background: var(--panel); border: 2px solid var(--line);
  box-shadow: var(--shadow); pointer-events: none; font-size: .8em; white-space: nowrap; z-index: 2; }
.ch-tip b { font-family: var(--font-head); font-weight: 600; font-size: 1.15em; color: var(--ink); font-variant-numeric: tabular-nums; }
.ch-tip small { color: var(--muted); font-weight: 700; }
.tbl-wrap { overflow-x: auto; }
.tbl { border-collapse: collapse; width: 100%; font-size: .82em; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; color: var(--muted); font-weight: 800; padding: 4px 8px 4px 0; white-space: nowrap; border-bottom: 1px solid color-mix(in srgb, var(--muted) 35%, transparent); }
.tbl td { padding: 4px 8px 4px 0; white-space: nowrap; border-bottom: 1px solid color-mix(in srgb, var(--muted) 15%, transparent); }
.tbl tr.now td { font-weight: 800; }
.charts-grid { display: grid; gap: inherit; }
@media (min-width: 1200px) { .charts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; } .charts-grid .panel { margin-bottom: 0; } }

/* ---------- contracts board ---------- */
.job-ic { width: 44px; height: 44px; flex: 0 0 auto; }
.job { position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 10px 10px 14px; border: 2px solid var(--good); border-radius: 14px;
  background: color-mix(in srgb, var(--good) 8%, var(--panel2)); overflow: hidden; }
.job-mid { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.job-who { color: var(--muted); font-weight: 800; }
.job-goal { font-family: var(--font-head); font-weight: 600; line-height: 1.2; }
.job-num { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; font-variant-numeric: tabular-nums; }
.job-how { color: var(--muted); }
.job-rw { font-weight: 800; }
.job .job-x { flex: 0 0 auto; min-width: 44px; min-height: 44px; padding: 0; margin: -6px -6px 0 0; border: 0; box-shadow: none; background: none; color: var(--muted); }
/* How long is left: a strip along the bottom that runs down, warm when it's nearly out. */
.job-clock { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--bar-bg); }
.job-clock span { display: block; height: 100%; background: var(--good); transition: width .3s linear; }
.job-clock.late span { background: var(--warn); }
.job-last { margin: 0 0 10px; padding: 8px 10px; border-radius: 12px; background: var(--panel2); font-size: .88em; border-left: 5px solid var(--good); animation: pop .4s ease-out; }
.job-last.warn { border-left-color: var(--warn); color: var(--ink); }
.jtrack { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -2px; scroll-snap-type: x proximity; }
.job-card { position: relative; flex: 0 0 min(232px, 78%); scroll-snap-align: start; display: flex; flex-direction: column; gap: 6px; padding: 12px 10px 10px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--panel2); overflow: hidden; font-size: .9em; }
.job-card .flavor { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.job-card button { margin-top: auto; }
.job-top { display: flex; align-items: center; gap: 8px; }
.job-top b { font-family: var(--font-head); font-weight: 600; line-height: 1.15; }
.job-top .job-ic { width: 36px; height: 36px; }
/* How long the offer stays on the board. */
.job-stay { position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--bar-bg); }
.job-stay span { display: block; height: 100%; background: var(--accent); }
