:root {
  color-scheme: light dark;
  --background: #f6f5ef;
  --surface: #fffefa;
  --ink: #203d36;
  --muted: #536962;
  --line: #d8e2d9;
  --tint: #e4eee7;
  --diagram: #f4f7ef;
  --curve: #34766b;
  --new-curve: #c05022;
  --marker-text: #fff;
  --hero: #173b34;
  --hero-ink: #f5f8f0;
  --answer: #ffd7a3;
  font: 16px/1.65 system-ui, "Noto Sans SC", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #141e1b;
    --surface: #1d2d28;
    --ink: #e3efe6;
    --muted: #b0c6bc;
    --line: #3c574d;
    --tint: #2a463a;
    --diagram: #172722;
    --curve: #83c4b2;
    --new-curve: #ff9e73;
    --marker-text: #302119;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); }
p, h1, h2, h3 { margin: 0; }
p { overflow-wrap: anywhere; }
a { color: inherit; }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--curve); outline-offset: 3px; }
.shell { width: min(100% - 2rem, 960px); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.header-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1rem; min-height: 62px; }
.back { font-size: .9rem; text-underline-offset: .2em; }
.app-name { color: var(--muted); font-size: .9rem; }
main.shell { padding-block: 2rem 4rem; display: grid; gap: 1.5rem; }
.intro { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1.5rem; padding: clamp(1.25rem, 4vw, 2.5rem); color: var(--hero-ink); background: var(--hero); border-radius: 1.15rem; }
.intro h1 { font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1.2; margin-bottom: .75rem; }
.intro p { max-width: 42rem; }
.answer { display: grid; justify-items: center; line-height: 1.3; min-width: 8rem; padding: .85rem 1.2rem; background: var(--answer); color: #392b20; border-radius: .85rem; }
.answer strong { font-size: clamp(2.1rem, 6vw, 3.2rem); line-height: 1.22; font-variant-numeric: tabular-nums; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; padding: clamp(1rem, 3vw, 1.6rem); }
.experiment-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .85rem 1.25rem; }
h2 { font-size: clamp(1.25rem, 3vw, 1.55rem); }
h3 { font-size: 1.05rem; }
.experiment-header p, .reason p, .diagram-caption p { color: var(--muted); }
.counts { display: flex; flex-wrap: wrap; gap: .35rem; }
.counts button { min-height: 44px; border-radius: .5rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; padding: .35rem .66rem; white-space: nowrap; }
.counts button[aria-pressed="true"] { background: var(--tint); border-color: var(--curve); font-weight: 700; }
.canvas-area { margin-block: 1rem; border-radius: .8rem; background: var(--diagram); overflow: hidden; }
#diagram { display: block; width: 100%; height: clamp(180px, 42vw, 265px); }
.diagram-caption { display: grid; gap: .15rem; }
.diagram-caption strong { color: var(--new-curve); font-size: 1.15rem; }
.reason-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-block: .65rem; }
.reason p { margin-top: .4rem; }
.reason strong { color: var(--ink); }
.rule { margin-top: .9rem; border-left: 3px solid var(--curve); padding-left: 1rem; }
.calculation p { margin-top: .5rem; }
.calculation .equation { margin-top: 1rem; padding: .8rem 1rem; background: var(--tint); border-radius: .6rem; font-size: clamp(1.05rem, 4vw, 1.35rem); font-variant-numeric: tabular-nums; }

@media (max-width: 550px) {
  main.shell { padding-block: 1.2rem 2rem; gap: 1rem; }
  .intro, .reason-grid { grid-template-columns: 1fr; }
  .answer { justify-self: start; grid-auto-flow: column; align-items: baseline; gap: .45rem; }
  .answer strong { font-size: 1.8rem; }
}
