/* Layout: tabla fizică în stânga ca instrument de laborator, panou de comandă în dreapta, tabel comparativ dedesubt */
:root {
  --bg: #e9eeec; --panel: #f6f8f7; --ink: #15201d; --muted: #5a6a66; --line: #cdd7d3;
  --sq-light: #cfdcd5; --sq-dark: #5f8577; --tray: #d9e1dd; --tray-slot: #c5d0cb;
  --accent: #d9821a; --accent-ink: #ffffff; --good: #2f8a57; --warn: #b8571d;
  --pw: #f5f3ec; --pw-ink: #1d2320; --pb: #262d2b; --pb-ink: #efede6; --shadow: rgba(10,25,20,.28); --arrow: #17796b;
  --f-display: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
  --f-body: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0e1412; --panel: #151d1a; --ink: #e3ebe7; --muted: #8d9e98; --line: #27332f;
  --sq-light: #a3b7ad; --sq-dark: #436a5c; --tray: #1b2522; --tray-slot: #26332f;
  --accent: #f0a043; --accent-ink: #1a1208; --good: #5cc28a; --warn: #f08a4b;
  --pw: #f1efe7; --pw-ink: #1d2320; --pb: #1c2321; --pb-ink: #ece9e1; --shadow: rgba(0,0,0,.55); --arrow: #2fae98;
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0e1412; --panel: #151d1a; --ink: #e3ebe7; --muted: #8d9e98; --line: #27332f;
  --sq-light: #a3b7ad; --sq-dark: #436a5c; --tray: #1b2522; --tray-slot: #26332f;
  --accent: #f0a043; --accent-ink: #1a1208; --good: #5cc28a; --warn: #f08a4b;
  --pw: #f1efe7; --pw-ink: #1d2320; --pb: #1c2321; --pb-ink: #ece9e1; --shadow: rgba(0,0,0,.55); --arrow: #2fae98;
  color-scheme: dark; }
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5; }
.wrap { max-width: 1560px; margin: 0 auto; padding-block: 28px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 32px; margin-bottom: 20px; }
h1 { font-family: var(--f-display); font-weight: 700; font-size: clamp(28px, 4.4vw, 44px); line-height: 1; letter-spacing: .01em; margin: 0; text-wrap: balance; }
h1 span { color: var(--accent); }
.lede { color: var(--muted); max-width: 58ch; margin: 8px 0 0; }
.kbd { font-family: var(--f-mono); font-size: 12px; border: 1px solid var(--line); border-bottom-width: 2px; padding: 1px 6px; border-radius: 4px; color: var(--muted); }
.main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 940px) { .main { grid-template-columns: minmax(0, 1fr); } }
.stage { min-width: 0; }
.readout { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 10px; }
.pz-name { font-family: var(--f-display); font-weight: 600; font-size: 22px; }
.pz-desc { color: var(--muted); font-size: 14px; }
.clock { font-family: var(--f-mono); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
canvas { display: block; width: 100%; height: auto; border-radius: 10px; background: var(--panel); touch-action: manipulation; }
.board-row { display: flex; gap: 8px; align-items: stretch; justify-content: center; }
.board-row canvas { flex: 1 1 0; min-width: 0; width: auto; }
.eval { position: relative; flex: 0 0 24px; border-radius: 6px; overflow: hidden; background: #2b2b2b; border: 1px solid var(--line); }
.eval[hidden] { display: none; }
.eval i { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: #f4f4f1; transition: height .35s ease; }
.eval.flip i { top: 0; bottom: auto; }
.eval span { position: absolute; left: 0; right: 0; text-align: center; font: 600 10px var(--f-mono); letter-spacing: -.3px; }
@media (prefers-reduced-motion: reduce) { .eval i { transition: none; } }
.material { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px; margin-top: 8px; font-size: 13.5px; }
.material[hidden] { display: none; }
.mat-side { display: flex; align-items: center; gap: 6px; min-height: 26px; min-width: 0; flex-wrap: wrap; }
.mat-side b { font-weight: 600; }
.mat-side .pcs { display: inline-flex; flex-wrap: wrap; }
.mat-side .pcs img { width: 22px; height: 22px; margin-right: -7px; }
.mat-side .pcs img.gap { margin-left: 8px; }
.mat-side em { font-style: normal; font-family: var(--f-mono); font-weight: 600; color: var(--good); margin-left: 9px; }
.mat-side .none { color: var(--muted); }
.bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 1px; margin-top: 14px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stat { background: var(--panel); padding: 10px 12px; min-width: 0; }
.stat b { display: block; font-family: var(--f-mono); font-weight: 500; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat.ok b { color: var(--good); } .stat.bad b { color: var(--warn); }
.note { margin-top: 10px; font-size: 13px; color: var(--warn); min-height: 1em; }
aside { display: flex; flex-direction: column; gap: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.go { appearance: none; border: 0; cursor: pointer; width: 100%; background: var(--accent); color: var(--accent-ink);
  font-family: var(--f-display); font-weight: 700; font-size: 19px; letter-spacing: .02em; padding: 14px 16px; border-radius: 8px;
  display: flex; justify-content: space-between; align-items: center; transition: transform .12s ease, filter .12s; }
.go:hover { filter: brightness(1.05); } .go:active { transform: translateY(1px); }
.go small { font-family: var(--f-mono); font-weight: 400; font-size: 12px; opacity: .8; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
select { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.algos { display: grid; gap: 6px; }
.algo { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: start; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--bg); }
.algo input { margin: 4px 0 0; accent-color: var(--accent); }
.algo strong { font-weight: 600; font-size: 14px; }
.algo em { grid-column: 2; font-style: normal; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.algo:has(input:checked) { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.tag { font-family: var(--f-mono); font-size: 10.5px; padding: 1px 6px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; vertical-align: 1px; }
.rules { display: grid; gap: 7px; }
.rules label { display: flex; gap: 9px; align-items: center; font-size: 14px; cursor: pointer; }
.rules input { accent-color: var(--accent); }
.row { display: flex; gap: 8px; }
.btn { appearance: none; flex: 1; cursor: pointer; font: 500 13.5px var(--f-body); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; }
.btn:hover { border-color: var(--muted); }
.btn[disabled] { opacity: .45; cursor: default; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=number] { width: 86px; flex: none; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.speed { display: flex; justify-content: space-between; font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
section { margin-top: 40px; }
h2 { font-family: var(--f-display); font-weight: 600; font-size: 24px; margin: 0 0 6px; text-wrap: balance; }
.sub { color: var(--muted); margin: 0 0 14px; max-width: 70ch; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; min-width: 720px; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
td.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; text-align: right; }
th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
td.best { color: var(--good); font-weight: 500; }
.meter { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); vertical-align: middle; margin-right: 8px; opacity: .8; }
.empty { padding: 18px; color: var(--muted); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 28px; }
.cols article { min-width: 0; }
.cols h3 { font-family: var(--f-display); font-size: 17px; margin: 0 0 4px; font-weight: 600; }
.cols p { margin: 0; color: var(--muted); font-size: 14px; max-width: 62ch; }
.rulebox { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; font-size: 14px; color: var(--muted); max-width: 80ch; }
.rulebox b { color: var(--ink); font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.toolbar .btn { flex: 0 1 auto; display: inline-flex; align-items: center; gap: 8px; }
.toolbar .btn .kbd { padding: 0 5px; font-size: 11px; }
.toolbar .spacer { flex: 1 1 auto; }
.toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }
.toggle i { width: 26px; height: 14px; border-radius: 7px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.toggle i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--panel); transition: transform .15s; }
.toggle[aria-pressed="true"] i { background: var(--accent); }
.toggle[aria-pressed="true"] i::after { transform: translateX(12px); }
.game { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 14px 16px; display: grid; gap: 10px; }
.game-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 14px; }
.game-status { font-family: var(--f-display); font-weight: 600; font-size: 18px; }
.game-status.win { color: var(--good); } .game-status.lose { color: var(--warn); }
.moves { font-family: var(--f-mono); font-size: 13.5px; color: var(--muted); min-height: 1.4em; overflow-wrap: anywhere; }
.moves b { color: var(--ink); font-weight: 500; }
.moves .mv { cursor: pointer; border-radius: 3px; padding: 0 2px; }
.moves .mv:hover { color: var(--ink); }
.moves .mv.on { color: var(--ink); background: var(--line); }
.game-nav[hidden], .game-promo[hidden] { display: none; }
.game .game-promo .btn { flex: 1 1 0; }
.game .game-nav .btn { flex: 1 1 0; font-family: var(--f-mono); }
.btn.confirm { border-color: var(--warn); color: var(--warn); }
.game .row { flex-wrap: wrap; }
.game .btn { flex: 0 1 auto; }
canvas.clickable { cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .go { transition: none; } }
canvas.holding { cursor: grabbing; }
#cv.clickable { touch-action: none; }
#cv.dragging { cursor: grabbing; }
.mode-tabs { display: grid; grid-template-columns: repeat(3, auto); gap: 4px; padding: 4px; background: var(--bg); border-radius: 9px; }
.mode-tab { appearance: none; border: 0; background: none; cursor: pointer; font: 600 13.5px var(--f-body); color: var(--muted); padding: 9px 6px; border-radius: 6px; }
.mode-tab.on { background: var(--accent); color: var(--accent-ink); }
.mode-pane { display: grid; gap: inherit; }
.mode-pane[hidden], .toolbar .btn[hidden], .go[hidden] { display: none; }
.progress { display: grid; gap: 7px; }
.progress[hidden] { display: none; }
.progress-head, .progress-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; color: var(--muted); }
.progress-head b { color: var(--ink); font-weight: 600; font-size: 14px; }
.progress-head span { font-family: var(--f-mono); color: var(--ink); }
.progress-bar { height: 10px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; background: var(--good); border-radius: 99px; transition: width .5s ease; }
.link-btn { appearance: none; border: 0; background: none; padding: 0; cursor: pointer; font: inherit; font-size: 12px; color: var(--muted); text-decoration: underline; }
.pz-help { border-left: 3px solid var(--accent); padding: 2px 0 2px 11px; }
.pz-help b { font-weight: 600; font-size: 14px; }
.pz-help p { margin: 4px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.pz-help:not(:has(b:not(:empty))) { display: none; }
.pz-done { font: 600 14px var(--f-body); color: var(--good); white-space: nowrap; }
.pz-done[hidden] { display: none; }
canvas.cheer-canvas { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; max-width: none; pointer-events: none; z-index: 50; background: transparent; border: 0; border-radius: 0; box-shadow: none; margin: 0; }
.cheer-banner { position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%); pointer-events: none; z-index: 51; padding: 16px 30px; border-radius: 14px; background: var(--panel); color: var(--ink); border: 2px solid var(--accent); box-shadow: 0 12px 40px rgba(0,0,0,.28); text-align: center; animation: cheer 3s ease both; max-width: calc(100vw - 32px); }
.cheer-banner b { display: block; font: 700 30px var(--f-display); color: var(--accent); }
.cheer-banner span { display: block; margin-top: 3px; font-size: 14px; color: var(--muted); }
@keyframes cheer { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); } 10% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); } 16% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1); } }
.side-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.side-tab { appearance: none; border: 0; background: none; cursor: pointer; font: 600 13.5px var(--f-body); color: var(--muted); padding: 8px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.side-tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.panel-main { display: grid; gap: inherit; min-width: 0; }
.panel-main[hidden], .panel-sizes[hidden] { display: none; }
.size-row { display: grid; grid-template-columns: 30px 50px minmax(0, 1fr) 72px 12px; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.size-row img { width: 30px; height: 30px; }
.size-row input[type=number] { width: 100%; padding: 6px; }
.size-row i { font-style: normal; color: var(--muted); }
.fill-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 13px; }
.fill-row input[type=color] { width: 44px; height: 28px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); cursor: pointer; }

/* openings: a search, the popular families, a list, and two choices */
.op-search { width: 100%; box-sizing: border-box; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.op-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.op-chip { appearance: none; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 99px; padding: 4px 10px; font: 12.5px var(--f-body); cursor: pointer; }
.op-chip:hover { border-color: var(--accent); }
.op-chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.op-list { height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.op-row { display: block; width: 100%; text-align: left; appearance: none; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); padding: 8px 10px; cursor: pointer; font: 13.5px/1.3 var(--f-body); }
.op-row:hover { background: var(--panel); }
.op-row.on { background: var(--panel); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.op-row small { display: block; color: var(--muted); font: 11.5px var(--f-mono); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; }
.op-row .n { float: right; margin-left: 8px; color: var(--muted); font: 12px var(--f-mono); }
.op-row .ok { color: var(--good); font-weight: 600; }
.op-back { font-weight: 600; color: var(--accent); }
.op-empty { margin: 0; padding: 14px 10px; color: var(--muted); font-size: 13px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--bg); border-radius: 9px; }
.seg button { appearance: none; border: 0; background: none; cursor: pointer; font: 600 14px var(--f-body); color: var(--muted); padding: 8px 6px; border-radius: 6px; }
.seg button.on { background: var(--ink); color: var(--panel); }
.op-pick { border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 12px; background: var(--bg); }
.op-pick b { display: block; font-size: 14px; }
.op-pick small { display: block; margin-top: 4px; color: var(--muted); font: 12px/1.5 var(--f-mono); }
.op-adv { font-size: 13px; color: var(--muted); cursor: pointer; }
#opElo { width: 100%; box-sizing: border-box; }
.ex-setup { display: grid; grid-template-columns: 1fr 110px; gap: 12px; align-items: end; }
.op-pick .lbl { display: block; margin-bottom: 2px; }
.op-follow { border-left-color: var(--good); }
.op-row.sub { padding-left: 24px; font-size: 13px; }
.op-row .fam-open { color: var(--accent); }
.op-div { margin: 0; padding: 7px 10px; font: 600 11px var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--panel); border-bottom: 1px solid var(--line); }
.sys-text { margin: 6px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--ink); }
.sys-list { height: 300px; }
.op-row .tag { display: inline-block; min-width: 14px; margin-right: 6px; font: 600 10px var(--f-mono); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); vertical-align: 1px; }
.op-row .tag.w { background: var(--pw); color: var(--pw-ink); }
.op-row .tag.b { background: var(--pb); color: var(--pb-ink); }
.op-row .known { color: var(--good); font-size: 11px; font-weight: 600; margin-left: 6px; }
.review-box { display: grid; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.review-box textarea { width: 100%; box-sizing: border-box; font: 12.5px/1.45 var(--f-mono); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; resize: vertical; }
.review-box input[type=file] { font-size: 12.5px; color: var(--muted); max-width: 100%; }
.review-box input[type=text] { flex: 1; min-width: 0; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.review-box .row select { flex: 1; min-width: 0; }
.mv .rv { font-family: var(--f-mono); margin-left: 1px; }
.mv .rv1i { color: var(--accent); }
.mv .rv1 { color: var(--warn); }
.mv .rv2 { color: #d23c2c; }
.game-nav.near { display: flex; gap: 8px; margin-top: 10px; }
.game-nav.near[hidden] { display: none; }
.game-nav.near .btn { flex: 1 1 0; font-family: var(--f-mono); padding-block: 8px; }
.game-nav.near .btn.play { flex: 1.4 1 0; font-family: var(--f-body); font-weight: 600; background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.game-nav.near .btn.play[hidden] { display: none; }
.game-nav.near .btn.play:disabled { background: var(--panel); color: var(--muted); border-color: var(--line); }
.perf { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--good); border-radius: 8px; background: var(--bg); }
.perf[hidden] { display: none; }
.perf-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.perf-note { font-size: 12px; color: var(--muted); }
.perf-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.4fr); gap: 12px; align-items: baseline; font-size: 14px; }
.perf-row > b { font: 600 16px var(--f-mono); font-variant-numeric: tabular-nums; }
.perf-wait { font-size: 13px; color: var(--muted); }
.perf .btn { justify-self: start; }
.perf-row small { color: var(--muted); font-size: 12px; }
.perf-row.avg { padding-top: 6px; border-top: 1px solid var(--line); }
