/* Общий вид. В — синий, П — оранжевый: пара различима и при дальтонизме, и на проекторе.
   Буквы В/П в клетках дублируют цвет. */
:root {
  --win: #2563eb;
  --win-soft: #dbe7ff;
  --lose: #ea580c;
  --lose-soft: #ffe4d2;
  --ink: #111827;
  --muted: #5b6474;
  --line: #d6dbe3;
  --bg: #ffffff;
  --panel: #f5f7fa;
  --ok: #15803d;
  --bad: #b91c1c;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
html { font-size: 17px; }
html.big { font-size: 22px; }
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.45; }
a { color: var(--win); }
h1 { font-size: 1.9rem; margin: 0.6rem 0 0.2rem; line-height: 1.2; }
h2 { font-size: 1.3rem; margin: 1.6rem 0 0.5rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 0.4rem; }
.lead { color: var(--muted); margin: 0 0 1rem; font-size: 1.05rem; }
.num { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%; background: var(--ink); color: #fff; font-size: 0.8em; vertical-align: 0.1em; }

/* Шапка и навигация */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 0.8rem; padding: 0.45rem 1rem; background: #fff; border-bottom: 1px solid var(--line); }
.logo { font-weight: 700; text-decoration: none; color: var(--ink); white-space: nowrap; }
.logo::first-letter { color: var(--lose); }
.nav { display: flex; gap: 0.25rem; overflow-x: auto; flex: 1; scrollbar-width: thin; }
.nav a { white-space: nowrap; text-decoration: none; color: var(--ink); padding: 0.35rem 0.6rem; border-radius: 999px; font-size: 0.92rem; }
.nav a b { color: var(--muted); font-weight: 600; }
.nav a:hover { background: var(--panel); }
.nav a[aria-current="page"] { background: var(--ink); color: #fff; }
.nav a[aria-current="page"] b { color: #c9d1dc; }
.big-toggle { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 0.3rem 0.5rem; font: inherit; font-weight: 700; cursor: pointer; }
.big-toggle[aria-pressed="true"] { background: var(--ink); color: #fff; }

.page { max-width: 1200px; margin: 0 auto; padding: 0.5rem 1rem 2rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager a { text-decoration: none; font-weight: 600; }
.foot { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; justify-content: center; padding: 1rem; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); }
.foot a, .linklike { color: var(--muted); }
.linklike { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }

/* Кнопки и элементы управления */
.btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: var(--radius); padding: 0.5rem 0.9rem; cursor: pointer; min-height: 44px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.good { outline: 3px solid var(--ok); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 1rem; }
label { font-weight: 600; }
input[type="range"] { accent-color: var(--ink); }
input[type="number"], input[type="text"], select, textarea { font: inherit; padding: 0.4rem 0.5rem; border: 1px solid var(--line); border-radius: 8px; }
.error { color: var(--bad); font-weight: 600; }
.muted { color: var(--muted); }
.big-number { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }

/* Подробности по клику */
details { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 0.8rem; margin: 0.8rem 0; background: #fff; }
details > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
details > summary::before { content: '▸'; margin-right: 0.45em; transition: transform 0.15s; }
details[open] > summary::before { transform: rotate(90deg); }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 0.4rem; }
code, pre { font-family: var(--mono); font-size: 0.9em; }
pre { background: var(--panel); padding: 0.8rem; border-radius: 8px; overflow-x: auto; }

/* Выбор ходов */
.rules { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; }
.rules-label { font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: #fff; font: inherit; font-weight: 700; cursor: pointer; transition: background 0.15s, color 0.15s; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.presets { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.preset { font: inherit; font-size: 0.9rem; border: 1px dashed var(--muted); background: #fff; border-radius: 999px; padding: 0.3rem 0.7rem; cursor: pointer; min-height: 36px; }
.preset:hover { background: var(--panel); }

/* Лента позиций В/П */
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); gap: 4px; }
.strip.by-cols { grid-template-columns: repeat(var(--cols), minmax(2.6rem, 3.4rem)); justify-content: start; overflow-x: auto; }
.cell { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 2.9rem; border: 0; border-radius: 7px; font: inherit; color: #fff; background: #c8ced8; transition: background-color 0.35s ease var(--d, 0ms), transform 0.35s ease var(--d, 0ms); padding: 0; cursor: default; }
button.cell:not([tabindex="-1"]) { cursor: pointer; }
.cell .cn { font-size: 0.72rem; opacity: 0.9; line-height: 1; }
.cell .cl { font-weight: 800; font-size: 1.05rem; line-height: 1.1; }
.cell.win { background: var(--win); }
.cell.lose { background: var(--lose); }
.cell.unk { background: #c8ced8; color: #39404b; }
.cell.dim { opacity: 0.35; }
.cell.ring { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); z-index: 1; }

/* Легенда В/П */
.legend { display: flex; flex-wrap: wrap; gap: 0.8rem; font-size: 0.9rem; color: var(--muted); }
.legend i { display: inline-block; width: 0.9em; height: 0.9em; border-radius: 3px; vertical-align: -0.1em; margin-right: 0.3em; }
.legend .w { background: var(--win); }
.legend .l { background: var(--lose); }

/* Диалог обратной связи */
dialog { border: 1px solid var(--line); border-radius: var(--radius); max-width: 28rem; width: calc(100% - 2rem); }
.feedback-form { display: grid; gap: 0.6rem; }

@media (max-width: 640px) {
  html { font-size: 16px; }
  html.big { font-size: 19px; }
  h1 { font-size: 1.5rem; }
  .top { padding: 0.4rem 0.6rem; gap: 0.5rem; }
  .nav a { font-size: 0.85rem; padding: 0.3rem 0.5rem; }
  .strip { grid-template-columns: repeat(auto-fill, minmax(2.3rem, 1fr)); }
  .cell { height: 2.6rem; }
  .big-number { font-size: 1.9rem; }
}
@media (prefers-reduced-motion: reduce) {
  .cell { transition: none; }
}
