:root {
  --bg: #f6f3ec; --panel: #fffdf8; --ink: #2a2318; --dim: #6c6250; --line: #e4ddcd;
  --accent: #a4622c; --accent2: #2f7d6a; --good: #158a4f; --bad: #c0392b;
  --shadow: 0 1px 2px rgba(42,35,24,0.09), 0 8px 24px rgba(42,35,24,0.06);
}
html[data-theme="dark"] {
  --bg: #14110c; --panel: #1e1a13; --ink: #f0e9dc; --dim: #a79b85; --line: #322c21;
  --accent: #e8a86a; --accent2: #6fd6bb; --good: #5ee39a; --bad: #ff7a86;
  --shadow: 0 1px 2px rgba(0,0,0,0.5), 0 10px 30px rgba(0,0,0,0.35);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
header.top { padding: 18px 20px 0; max-width: 960px; margin: 0 auto; position: relative; }
h1 { margin: 0; font-size: 26px; letter-spacing: -0.01em; }
.sub { margin: 4px 0 12px; color: var(--dim); font-size: 14px; }
nav.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.tab {
  background: none; border: 1px solid transparent; border-bottom: none; color: var(--dim);
  padding: 8px 13px; border-radius: 8px 8px 0 0; cursor: pointer; font: inherit; font-size: 14px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); background: var(--panel); border-color: var(--line); font-weight: 600; }
#themeBtn { position: absolute; top: 18px; right: 20px; }
main { max-width: 960px; margin: 0 auto; padding: 16px 20px 40px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.panel[hidden] { display: none !important; }
.stage { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.stage.two { gap: 12px; flex-wrap: wrap; align-items: flex-start; }
canvas { max-width: 100%; height: auto; min-width: 0; border-radius: 10px; background: var(--panel); display: block; touch-action: none; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0 6px; }
button { font: inherit; border-radius: 8px; cursor: pointer; padding: 8px 14px; border: 1px solid var(--line); }
button.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; color: var(--ink); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
select, input[type="range"] { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
input[type="range"] { padding: 0; min-width: 200px; }
label { color: var(--dim); font-size: 14px; }
output { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 64px; display: inline-block; }
.note { color: var(--dim); font-size: 13.5px; margin: 8px 0 0; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 12px 0 4px; }
.ro { border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; }
.ro .k { display: block; color: var(--dim); font-size: 12px; }
.ro .v { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.prose { line-height: 1.62; }
.prose h2 { font-size: 19px; margin: 22px 0 6px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 15.5px; margin: 16px 0 4px; }
.prose p, .prose li { color: var(--ink); }
.prose .lead { font-size: 16px; }
.prose blockquote { margin: 10px 0; padding: 8px 14px; border-left: 3px solid var(--accent2); color: var(--dim); font-style: italic; }
.tablewrap { overflow-x: auto; margin: 10px 0; }
table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
th, td { text-align: right; padding: 5px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--dim); font-weight: 600; }
.tag { display: inline-block; font-size: 11px; letter-spacing: .04em; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); }
.ok { color: var(--good); } .bad { color: var(--bad); }
footer { max-width: 960px; margin: 0 auto; padding: 0 20px 34px; color: var(--dim); font-size: 13px; }
@media (max-width: 720px) { .stage.two { flex-direction: column; align-items: center; } }

/* --- finger-trap additions --- */
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin: 10px 0; }
.lvl { text-align: left; padding: 9px 11px; line-height: 1.35; }
.lvl[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.lvl .n { display: block; font-size: 14px; }
.lvl .h { display: block; font-size: 12px; color: var(--dim); font-weight: 400; }
.verdict { margin: 12px 0 0; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line); font-size: 14.5px; }
.verdict.win { border-color: var(--good); }
.verdict.hold { border-color: var(--accent2); }
.force { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.force input[type="range"] { flex: 1 1 260px; min-width: 180px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--dim); margin-top: 8px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.eq { display: block; margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 0 8px 8px 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; overflow-x: auto; }
