/* Step 03 · Why it works */
#s3 .s3-deriv { margin-block: 18px 26px; }
#s3 .s3-deriv-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
#s3 .s3-kicker { font-family: var(--f-mono); font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0; }
#s3 .s3-dots { display: flex; gap: 5px; flex-wrap: wrap; }
#s3 .s3-dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--rule); background: var(--bg); }
#s3 .s3-dot.on { background: var(--tint); border-color: var(--accent); }
#s3 .s3-dot.cur { background: var(--source); border-color: var(--source); }
#s3 .s3-lines { list-style: none; margin: 0 0 12px; padding: 0; counter-reset: ln; display: grid; gap: 8px; }
#s3 .s3-line { counter-increment: ln; position: relative; padding: 8px 12px 4px 44px; border-radius: 10px; border: 1px solid transparent; margin: 0; }
#s3 .s3-line::before { content: counter(ln); position: absolute; left: 10px; top: 10px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--f-mono); font-size: 0.76rem; border: 1px solid var(--rule); color: var(--muted); background: var(--bg); }
#s3 .s3-line.s3-cur { border-color: var(--source); background: color-mix(in srgb, var(--source) 5%, var(--surface)); }
#s3 .s3-line.s3-cur::before { background: var(--source); border-color: var(--source); color: var(--surface); }
#s3 .s3-line.s3-future { display: none; }
#s3 .s3-line .formula { margin: 6px 0 8px; background: var(--bg); }
#s3 .s3-why { margin: 0; font-size: 0.98rem; }
#s3 .s3-catch .s3-why b:first-child { color: var(--bad); }
#s3 .s3-final .formula { border-color: var(--accent); }
#s3 .s3-line.s3-in { animation: s3-in 0.45s ease-out; }
@keyframes s3-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #s3 .s3-line.s3-in { animation: none; } }
#s3 .s3-nav { justify-content: flex-start; }

/* sign game */
#s3 .s3-mats { display: grid; gap: 6px; }
#s3 .s3-mrow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
#s3 .s3-eq { white-space: nowrap; }
#s3 .readout b.bad, #s3 .readout .bad { color: var(--bad); }
#s3 .readout b.good, #s3 .readout .good { color: var(--good); }
#s3 .s3-bars { margin: 14px 0 4px; display: grid; gap: 8px; }
#s3 .s3-bar-row { display: grid; grid-template-columns: 4.6rem minmax(0, 1fr) 4.6rem; gap: 10px; align-items: center; font-family: var(--f-mono); font-size: 0.86rem; font-variant-numeric: tabular-nums; }
#s3 .s3-bl { color: var(--muted); }
#s3 .s3-bv { text-align: right; font-weight: 600; }
#s3 .s3-bv.bad { color: var(--bad); }
#s3 .s3-track { position: relative; height: 18px; border-radius: 4px; background: var(--bg); border: 1px solid var(--rule); overflow: hidden; }
#s3 .s3-track::after { content: ""; position: absolute; left: 50%; top: -1px; bottom: -1px; width: 2px; margin-left: -1px; background: var(--ink); opacity: 0.55; }
#s3 .s3-fill { position: absolute; top: 2px; bottom: 2px; border-radius: 3px; transition: width 0.25s ease, left 0.25s ease; }
#s3 .s3-fill.pos { left: 50%; background: var(--accent); }
#s3 .s3-fill.neg { right: 50%; background: var(--bad); }
#s3 .s3-track-total::after { display: none; }
#s3 .s3-max { position: absolute; left: 0; top: 2px; bottom: 2px; border-radius: 3px; border: 1.5px dashed var(--muted); opacity: 0.6; }
#s3 .s3-fill.tot { left: 0; }
#s3 .s3-fill.tot.rot { background: var(--good); }
#s3 .s3-fill.tot.refl { background: var(--bad); }
#s3 .s3-total { padding-top: 6px; border-top: 1px dashed var(--rule); }
#s3 .s3-barnote { font-size: 0.82rem; color: var(--muted); margin: 2px 0 0; }
@media (prefers-reduced-motion: reduce) { #s3 .s3-fill { transition: none; } }
#s3 .s3-tbl { margin: 12px 0 0; }
#s3 .s3-tbl table { font-size: 0.86rem; }
#s3 .s3-tbl th.s3-num { text-align: right; }
#s3 .s3-tbl td.s3-pat { font-family: var(--f-mono); white-space: nowrap; }
#s3 .s3-tbl td.num.bad { color: var(--bad); } #s3 .s3-tbl td.num.good { color: var(--good); }
#s3 .s3-tbl tbody tr { cursor: pointer; }
#s3 .s3-tbl tbody tr:hover td { background: color-mix(in srgb, var(--tint) 60%, transparent); }
#s3 .s3-tbl tbody tr.cur td { background: color-mix(in srgb, var(--source) 13%, var(--surface)); }
#s3 .s3-tbl tbody tr.cur td:first-child { box-shadow: inset 3px 0 0 var(--source); }
#s3 .s3-tag { display: inline-block; font-family: var(--f-mono); font-size: 0.68rem; letter-spacing: 0.04em; padding: 0 6px; margin-left: 6px; border-radius: 999px; border: 1px solid var(--rule); color: var(--muted); white-space: nowrap; }
#s3 .s3-tag.good { border-color: var(--good); color: var(--good); }
#s3 .s3-ctitle { font-family: var(--f-display); font-weight: 700; font-size: 1.15rem; margin: 0; }
#s3 .s3-signs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
#s3 .s3-sign { display: grid; gap: 2px; justify-items: center; padding: 8px 4px; font-family: var(--f-mono); font-size: 0.95rem; }
#s3 .s3-sign small { font-size: 0.68rem; font-weight: 400; color: var(--muted); }
#s3 .s3-sign.neg { border-color: var(--bad); color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
#s3 .s3-score { display: grid; gap: 3px; }
#s3 .s3-rr { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
#s3 .s3-rmat { justify-content: flex-start; margin-top: 4px; overflow-x: auto; }
#s3 .s3-badmat table.mat { border-color: var(--bad); color: var(--bad); }
#s3 .s3-verdict { font-size: 0.93rem; margin: 0; min-height: 3em; }
#s3 .s3-verdict .bad { color: var(--bad); } #s3 .s3-verdict .good { color: var(--good); }
#s3 #s3-game > .try { margin-top: 14px; }
@media (max-width: 520px) {
  #s3 .s3-line { padding: 8px 8px 4px 8px; }
  #s3 .s3-line::before { position: static; float: left; margin: 1px 8px 0 0; }
  #s3 .s3-line .formula { clear: both; padding: 6px 8px; }
  #s3 .s3-deriv { padding: 10px 6px; }
}
/* phones: interleave controls with the bars so the sign buttons sit next to what they change */
@media (max-width: 899px) {
  #s3 #s3-game .stage, #s3 #s3-game .controls { display: contents; }
  #s3 #s3-mats { order: 1; }
  #s3 .s3-ctitle { order: 2; margin-top: 4px; }
  #s3 #s3-signs { order: 3; }
  #s3 #s3-bars { order: 4; margin: 0; }
  #s3 #s3-verdict { order: 5; min-height: 0; }
  #s3 #s3-score { order: 6; }
  #s3 #s3-btns { order: 7; }
  #s3 .s3-tbl { order: 8; margin: 0; }
}
