@font-face {
  font-family: 'Kenney Mini';
  src: url('assets/fonts/KenneyMini.ttf') format('truetype');
  font-display: swap;
}

.viz-root {
  color-scheme: light;
  --page: #f4f2ec;
  --surface-1: #fcfcfb;
  --surface-2: #efede6;
  --border: #dcd9cf;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --grid: #e6e4dc;
  --series-1: #2a78d6; /* money */
  --series-2: #eb6834; /* price */
  --accent: #b7791f;
  --accent-ink: #ffffff;
  --off: #8a8780;
  --on: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --page: #121211;
    --surface-1: #1a1a19;
    --surface-2: #242422;
    --border: #34332f;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --grid: #2b2b28;
    --series-1: #3987e5;
    --series-2: #d95926;
    --accent: #d69a3c;
    --accent-ink: #121211;
    --off: #8f8e86;
    --on: #3987e5;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page, #f4f2ec); }
.viz-root {
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 12px 28px;
}
a { color: var(--series-1); }
h1, h2 { font-family: 'Kenney Mini', system-ui, sans-serif; font-weight: normal; letter-spacing: 0.02em; }
.big, .stat .v, .day, .badge .n { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-weight: 700; font-variant-numeric: tabular-nums; }
h1 { font-size: 30px; line-height: 1.2; margin: 0 0 8px; }
.page-head p { margin: 0 0 12px; color: var(--text-secondary); }
.jump { display: flex; flex-wrap: wrap; gap: 6px; }
.jump a {
  font-size: 13px; text-decoration: none; color: var(--text-primary);
  border: 1px solid var(--border); background: var(--surface-1); border-radius: 999px; padding: 3px 10px;
}
.jump a:hover { border-color: var(--text-secondary); }
.page-foot { margin-top: 18px; font-size: 12px; color: var(--text-muted); text-align: center; }

/* Card */
.trick {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 18px;
}
.trick-head { display: flex; gap: 12px; align-items: flex-start; }
.badge {
  flex: none; width: 44px; height: 44px; border-radius: 10px; background: var(--accent);
  display: grid; place-items: center; position: relative;
}
.badge .icon { width: 30px; height: 30px; background: var(--accent-ink); }
.badge .n {
  position: absolute; right: -6px; top: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--text-primary); color: var(--surface-1); font-size: 12px; line-height: 20px; text-align: center;
}
.trick h2 { font-size: 24px; margin: 0; line-height: 1.25; }
.trick-head p { margin: 2px 0 0; color: var(--text-secondary); font-size: 14px; }
.trick-head code { font-size: 12.5px; background: var(--surface-2); padding: 0 4px; border-radius: 4px; }

.icon {
  display: inline-block; width: 18px; height: 18px; background: currentColor; vertical-align: -3px;
  -webkit-mask: var(--src) center / contain no-repeat; mask: var(--src) center / contain no-repeat;
}

.tabs { display: flex; gap: 4px; margin: 14px 0 10px; border-bottom: 1px solid var(--border); }
.tabs button {
  font: inherit; font-size: 14px; background: none; border: 0; color: var(--text-secondary);
  padding: 6px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }
.tabs:has(> :only-child) { display: none; }

/* Two sides */
.stage { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.side { min-width: 0; background: var(--surface-2); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; }
.side-head { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.side-head .tag {
  font: 700 10.5px/1 system-ui, sans-serif; text-transform: uppercase; letter-spacing: 0.06em; padding: 4px 6px; border-radius: 4px;
  color: var(--surface-1); background: var(--off);
}
.side.with .side-head .tag { background: var(--on); }
.side-head .what { color: var(--text-secondary); font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 6px; }
.stat { background: var(--surface-1); border-radius: 6px; padding: 4px 6px; min-width: 0; }
.stat .k { font-size: 10.5px; color: var(--text-muted); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v { font-size: 15px; line-height: 1.3; white-space: nowrap; }

.chart-label { font-size: 11.5px; color: var(--text-secondary); margin: 4px 0 0; display: flex; align-items: center; gap: 5px; }
.chart-label .sw { width: 10px; height: 2px; border-radius: 1px; }
canvas { display: block; width: 100%; touch-action: pan-y; }
canvas.line { height: 84px; }
canvas.strip { height: 54px; }

.caption {
  margin-top: 8px; font-size: 13px; line-height: 1.4; min-height: 4.2em; color: var(--text-primary);
}
.caption b { font-weight: 650; }

.controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.btn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border-radius: 8px; padding: 6px 12px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  display: inline-flex; align-items: center; gap: 6px; touch-action: manipulation;
}
.btn:hover:not(:disabled) { border-color: var(--text-secondary); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn:focus-visible, .tabs button:focus-visible, .jump a:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
.progress { flex: 1; height: 4px; background: var(--grid); border-radius: 2px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--text-secondary); }
.day { font-size: 12px; line-height: 1; color: var(--text-secondary); min-width: 74px; text-align: right; }
.takeaway { margin: 10px 0 0; font-size: 13.5px; color: var(--text-secondary); border-left: 3px solid var(--accent); padding-left: 10px; }

/* Play mode */
.play-shared { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.play-shared .hint { font-size: 13px; color: var(--text-secondary); flex: 1 1 200px; }
.wallet { display: flex; align-items: baseline; gap: 6px; margin: 2px 0 6px; }
.wallet .big { font-size: 24px; line-height: 1.1; }
.wallet .sub { font-size: 12px; color: var(--text-secondary); }
.row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; border-bottom: 1px dashed var(--border); }
.row:last-child { border-bottom: 0; }
.row .k { color: var(--text-secondary); }
.row .v { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.side .btn { width: 100%; justify-content: center; margin-top: 6px; font-size: 13px; }
.ledger { font-size: 12.5px; margin: 6px 0 0; padding: 0; list-style: none; font-variant-numeric: tabular-nums; min-height: 6.5em; }
.ledger li { display: flex; justify-content: space-between; color: var(--text-secondary); }
.ledger li.minus .v { color: var(--text-primary); }
.ledger li.day-row { color: var(--text-primary); font-weight: 600; margin-top: 2px; }
.meter { height: 10px; background: var(--surface-1); border-radius: 5px; position: relative; overflow: visible; margin: 8px 0 14px; }
.meter > span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--series-1); border-radius: 5px; transition: width .25s; }
.meter .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text-primary); }
.meter .mark i { position: absolute; top: 16px; transform: translateX(-50%); font-size: 10.5px; font-style: normal; white-space: nowrap; color: var(--text-secondary); }
.goal { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; align-items: center; font-size: 13px; margin-top: 6px; }
.goal .bar { grid-column: 2 / 4; height: 5px; background: var(--surface-1); border-radius: 3px; overflow: hidden; }
.goal .bar span { display: block; height: 100%; background: var(--series-1); transition: width .25s; }
.goal.owned { color: var(--text-muted); }
.goal .btn { width: auto; margin: 0; padding: 2px 8px; font-size: 12px; }
.note { font-size: 12.5px; color: var(--text-secondary); margin-top: 6px; min-height: 2.6em; }
.note.alert { color: var(--text-primary); font-weight: 600; }
.flash { animation: flash .6s; }
@keyframes flash { 0% { background: var(--accent); } 100% { background: transparent; } }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Solo embed */
body.solo .page-head, body.solo .page-foot { display: none; }
body.solo .viz-root { padding: 0; background: transparent; }
body.solo .trick { margin: 0; }
body.solo { background: transparent; }

/* Phone: stack the two sides, without on top */
@media (max-width: 560px) {
  .viz-root { padding: 14px 8px 20px; }
  h1 { font-size: 24px; }
  .trick { padding: 12px; }
  .stage { grid-template-columns: 1fr; gap: 10px; }
  .caption { min-height: 0; }
  .ledger { min-height: 0; }
}

@media (forced-colors: active) {
  .icon { background: CanvasText; }
}
