/* ==========================================================================
   Игра Баше — стили
   Токены взяты из фирменного стиля МШП:
   - цвета и шрифт: informatics.ru (акцент #008cd5, тёмный синий #024f95,
     заголовки #003c5b, шрифт Ubuntu);
   - компоненты (радиусы, линии, фон, кнопки 44px, навигация):
     LMS «МШП Online» (static/css/tokens.css, layout.css, components.css).
   ========================================================================== */

/* Ubuntu (Ubuntu Font Licence 1.0, см. assets/fonts/UFL.txt), локально —
   без обращений к сторонним CDN. */
@font-face {
  font-family: "Ubuntu";
  src: url("assets/fonts/ubuntu-400-cyrillic.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Ubuntu";
  src: url("assets/fonts/ubuntu-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Ubuntu";
  src: url("assets/fonts/ubuntu-700-cyrillic.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Ubuntu";
  src: url("assets/fonts/ubuntu-700-latin.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Цвет */
  --brand: #008cd5;          /* informatics.ru: основной акцент */
  --brand-strong: #0073b3;   /* акцент, затемнённый до AA для текста и кнопок */
  --brand-deep: #024f95;     /* informatics.ru: тёмный синий (hover) */
  --ink: #003c5b;            /* informatics.ru: заголовки */
  --text: #1d2c39;           /* LMS --mshp-text-body */
  --muted: #5c6b7d;          /* LMS --mshp-muted */
  --paper: #ffffff;
  --bg: #f5fbff;             /* LMS --mshp-surface */
  --surface-2: #eef8fd;      /* LMS --mshp-surface-2 */
  --surface-3: #e8f7fe;      /* LMS --mshp-surface-3 */
  --line: #d8e9f4;           /* LMS --mshp-line */
  --line-strong: #b9dbea;    /* LMS --mshp-line-strong */
  --danger: #c2331f;         /* LMS --mshp-danger, затемнён до AA */

  /* Дерево для палочек — материал, а не акцент */
  --wood-light: #f3d5a0;
  --wood: #e2b471;
  --wood-dark: #b98142;

  /* Форма (LMS) */
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;
  --shadow-sm: 0 4px 8px rgba(0, 45, 116, 0.06);
  --focus: 0 0 0 3px rgba(0, 140, 213, 0.25);

  --font: "Ubuntu", "Segoe UI Variable", Arial, system-ui, sans-serif;
  --wrap: 1200px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

main {
  flex: 1 0 auto;
}

img,
svg {
  max-width: 100%;
}

h1,
h2,
h3 {
  color: var(--ink);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.6em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2rem, 1.35rem + 2.6vw, 3rem);
  letter-spacing: -0.015em;
}

h2 {
  font-size: clamp(1.35rem, 1.15rem + 0.8vw, 1.65rem);
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.15rem;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--brand-strong);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--brand-deep);
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.35em;
  font: inherit;
  font-size: 0.85em;
  line-height: 1.5;
  text-align: center;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.skip-link:focus {
  top: 8px;
}

.wrap {
  width: min(var(--wrap), calc(100% - 32px));
  margin-inline: auto;
}

/* ---------- Шапка ---------- */

.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.125rem;
  text-decoration: none;
  flex-shrink: 0;
}

.brand:hover {
  color: var(--brand-strong);
  text-decoration: none;
}

.brand__mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.site-nav ul {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  border-bottom: 2px solid transparent;
}

.site-nav a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.site-nav a[aria-current="page"] {
  background: var(--surface-3);
  border-bottom-color: var(--brand);
}

@media (max-width: 760px) {
  .site-header__inner {
    flex-wrap: wrap;
    padding-top: 8px;
  }

  .site-nav {
    width: calc(100% + 32px);
    margin: 0 -16px;
    overflow-x: auto;
    scrollbar-width: none;
    border-top: 1px solid var(--line);
  }

  .site-nav::-webkit-scrollbar {
    display: none;
  }

  .site-nav ul {
    padding: 4px 12px;
  }

  .site-nav a {
    padding: 8px 10px;
  }
}

/* ---------- Подвал ---------- */

.site-footer {
  margin-top: 64px;
  background: var(--paper);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9375rem;
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 32px;
  padding-block: 20px;
}

.site-footer__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 4px;
  margin-left: -10px;
}

.site-footer__nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  color: var(--ink);
  text-decoration: none;
}

.site-footer__nav a:hover {
  text-decoration: underline;
}

.site-footer__copy {
  margin: 0;
}

/* ---------- Кнопки (LMS: 44px, радиус 12, жирный) ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.2;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.btn:disabled {
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-strong);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-deep);
}

.btn-secondary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-secondary.highlight {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: #fff;
}

.btn-secondary.highlight:hover {
  background: var(--brand-deep);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding-inline: 12px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink);
}

/* ---------- Главная: вступление ---------- */

.page-intro {
  max-width: 46rem;
  padding-block: clamp(20px, 3vw, 36px) clamp(16px, 2vw, 24px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-strong);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-intro h1 {
  margin-bottom: 12px;
}

.lede {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
  line-height: 1.5;
  max-width: 40em;
}

/* ---------- Игра ---------- */

.game {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: clamp(16px, 2.4vw, 32px);
}

.game:focus {
  outline: none;
}

.game__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px 32px;
  padding-bottom: clamp(16px, 2vw, 24px);
  margin-bottom: clamp(16px, 2vw, 24px);
  border-bottom: 1px solid var(--line);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field__label {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
}

.field__hint {
  margin: 0;
  max-width: 34em;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

/* Сегментированный переключатель */
.segmented {
  display: inline-flex;
  max-width: 100%;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.segmented__btn {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 8px 16px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.lbl-short {
  display: none;
}

@media (max-width: 480px) {
  .lbl-long {
    display: none;
  }

  .lbl-short {
    display: inline;
  }
}

.segmented__btn:hover {
  background: rgba(255, 255, 255, 0.7);
}

.segmented__btn.active {
  background: var(--paper);
  border-color: var(--line-strong);
  color: var(--brand-strong);
  box-shadow: 0 1px 2px rgba(0, 45, 116, 0.08);
}

.game__layout {
  display: grid;
  gap: 24px;
}

@media (min-width: 960px) {
  .game__layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 32px;
  }
}

.board-status {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.turn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.125rem, 1rem + 0.6vw, 1.5rem);
  font-weight: 700;
  line-height: 1.2;
}

.turn__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
}

.game[data-turn="2"] .turn__dot {
  background: var(--paper);
  box-shadow: inset 0 0 0 3px var(--ink);
}

.game[data-state="over"] .turn {
  color: var(--muted);
}

.count {
  margin: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

.count__num {
  min-width: 2ch;
  color: var(--ink);
  font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.75rem);
  font-weight: 700;
  line-height: 1;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Стол и палочки */
.board {
  position: relative;
  container-type: inline-size;
  display: grid;
  place-items: center;
  padding: clamp(16px, 3vw, 32px) clamp(12px, 2vw, 32px);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
}

.sticks {
  --stick-w: clamp(9px, 2vw, 24px);
  --stick-h: clamp(108px, min(18vw, 21vh), 230px);
  --stick-gap: clamp(6px, 1.6vw, 20px);
  --stick-w: clamp(9px, 2.55cqi, 26px);
  --stick-h: clamp(108px, min(24cqi, 21vh), 240px);
  --stick-gap: clamp(6px, 2.1cqi, 22px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--stick-gap);
  min-height: calc(var(--stick-h) + 16px);
  padding-top: 16px;
}

.stick {
  position: relative;
  display: block;
  width: var(--stick-w);
  height: var(--stick-h);
  border-radius: calc(var(--stick-w) / 2);
  background:
    linear-gradient(90deg,
      var(--wood-dark) 0%,
      var(--wood) 18%,
      var(--wood-light) 45%,
      var(--wood) 75%,
      var(--wood-dark) 100%);
  box-shadow:
    0 1px 0 rgba(90, 55, 15, 0.25),
    2px 6px 8px -4px rgba(60, 40, 10, 0.35);
  transition: transform 200ms ease, opacity 300ms ease, box-shadow 200ms ease;
  animation: stick-in 360ms ease both;
  animation-delay: calc(var(--i, 0) * 30ms);
}

/* Волокна дерева */
.stick::before {
  content: "";
  position: absolute;
  left: 38%;
  top: 12%;
  bottom: 18%;
  width: 1px;
  background: rgba(140, 90, 35, 0.28);
  border-radius: 1px;
}

/* Группы по пять — так проще считать с последней парты */
.stick:nth-child(5n):not(:last-child) {
  margin-right: calc(var(--stick-gap) * 0.9);
}

.stick.is-pickable {
  cursor: pointer;
}

.stick.is-selected {
  transform: translateY(-10%);
  box-shadow:
    0 0 0 3px var(--paper),
    0 0 0 6px var(--brand),
    2px 14px 14px -6px rgba(60, 40, 10, 0.35);
}

.stick.taken {
  opacity: 0;
  transform: translateY(-35%) rotate(10deg);
  pointer-events: none;
}

@keyframes stick-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.game-result {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 4px;
  padding: 24px;
  text-align: center;
  animation: result-in 320ms ease both;
}

.game-result__title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.5rem, 1.1rem + 2vw, 2.5rem);
  font-weight: 700;
  line-height: 1.15;
}

.game-result__title::before {
  content: "";
  display: block;
  width: 48px;
  height: 4px;
  margin: 0 auto 16px;
  border-radius: 2px;
  background: var(--brand);
}

.game-result__text {
  margin: 0 auto;
  max-width: 32em;
  color: var(--muted);
  font-size: clamp(0.9375rem, 0.9rem + 0.3vw, 1.125rem);
}

@keyframes result-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.game-message {
  min-height: 1.6em;
  margin: 14px 0 16px;
  color: var(--muted);
  font-size: 1rem;
}

.game-message.success {
  color: var(--ink);
  font-weight: 700;
}

.game-message.error {
  color: var(--danger);
  font-weight: 700;
}

.game-message.computer-thinking::after {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-left: 8px;
  vertical-align: -0.08em;
  border: 2px solid var(--line-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.take-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.btn-take {
  min-height: clamp(52px, 4.5vw, 68px);
  padding-inline: 8px;
  background: var(--brand-strong);
  color: #fff;
  font-size: clamp(0.9375rem, 0.85rem + 0.4vw, 1.125rem);
}

.btn-take__n {
  font-size: 1.35em;
  font-variant-numeric: tabular-nums;
}

.btn-take:hover:not(:disabled) {
  background: var(--brand-deep);
}

.btn-take:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-take:disabled {
  background: var(--surface-2);
  border-color: var(--line);
  color: #7d8b9a;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.kbd-hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

@media (hover: none) {
  .kbd-hint {
    display: none;
  }
}

/* Боковая колонка */
.game__side {
  display: grid;
  gap: 16px;
  align-content: start;
}

@media (min-width: 600px) and (max-width: 959px) {
  .game__side {
    grid-template-columns: 1fr 1fr;
  }
}

.panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--paper);
}

.panel__title {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.player-info {
  display: grid;
  gap: 8px;
}

.player {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 8px 14px 8px 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  transition: border-color 150ms ease, background-color 150ms ease;
}

.player::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--brand);
}

.player--2::before {
  background: var(--paper);
  box-shadow: inset 0 0 0 2.5px var(--ink);
}

.player.active {
  border-color: var(--brand);
  background: var(--surface-3);
  box-shadow: inset 3px 0 0 var(--brand);
}

.game[data-state="over"] .player.active:not(.winner) {
  border-color: var(--line);
  background: transparent;
  box-shadow: none;
}

.player-name {
  font-weight: 700;
}

.player-score {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.history-head,
.history-item {
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr) 3.4em 4.6em;
  gap: 8px;
  align-items: center;
}

.history-head {
  padding: 0 4px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.history-head span:nth-child(n+3),
.history-item__took,
.history-item__left {
  text-align: right;
}

.history-list {
  max-height: 264px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  font-variant-numeric: tabular-nums;
}

.history-item {
  padding: 7px 4px;
  border-bottom: 1px solid var(--surface-2);
  font-size: 0.9375rem;
}

.history-item:last-child {
  border-bottom: 0;
}

.history-item__n {
  color: var(--muted);
  font-size: 0.8125rem;
}

.history-item__who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item--p1 .history-item__who {
  color: var(--brand-strong);
  font-weight: 700;
}

.history-item--p2 .history-item__who {
  color: var(--ink);
}

.history-item__left {
  color: var(--ink);
  font-weight: 700;
}

.history-empty {
  margin: 10px 0 0;
  padding: 4px;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* Текст под игрой */
.home-info {
  display: grid;
  gap: 24px 48px;
  margin-top: clamp(32px, 5vw, 56px);
}

@media (min-width: 900px) {
  .home-info {
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  }
}

.home-info section {
  max-width: 65ch;
}

.home-info h2 {
  font-size: 1.375rem;
}

.home-info ul {
  margin: 0;
  padding-left: 1.2em;
}

.home-info li + li {
  margin-top: 6px;
}

.intro-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 0;
}

.intro-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 700;
}

.intro-links a::after {
  content: "→";
  margin-left: 6px;
  text-decoration: none;
}

/* ---------- Контентные страницы ---------- */

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin: 0;
  padding: 24px 0 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.875rem;
}

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: 8px;
  color: var(--line-strong);
}

.breadcrumbs a {
  color: var(--ink);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.prose {
  max-width: 68ch;
  padding-top: clamp(16px, 3vw, 32px);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
}

.prose h1 {
  margin-bottom: 0.5em;
}

.prose > h1 + p {
  color: var(--text);
  font-size: 1.1em;
  line-height: 1.55;
}

.prose h2 {
  margin-top: 2.2em;
  padding-top: 0.2em;
}

.prose h3 {
  margin-top: 1.8em;
  margin-bottom: 0.4em;
}

.prose ul,
.prose ol {
  margin: 0 0 1.2em;
  padding-left: 1.4em;
}

.prose li {
  margin-bottom: 0.5em;
  padding-left: 0.2em;
}

.prose li::marker {
  color: var(--brand-strong);
  font-weight: 700;
}

.prose strong {
  color: var(--ink);
}

.prose em {
  font-style: italic;
}

.prose table {
  width: 100%;
  margin: 1.5em 0 2em;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--paper);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

.prose th,
.prose td {
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.prose th {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.875rem;
}

.prose tbody tr:last-child td {
  border-bottom: 0;
}

.prose tr:has(td.lose) td {
  background: var(--surface-3);
}

.prose td.win,
.prose td.lose {
  font-weight: 700;
}

.prose td.win {
  color: var(--brand-strong);
}

.prose td.lose {
  color: var(--ink);
}

.prose td.lose::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--ink);
  vertical-align: 0.05em;
}

.table-scroll {
  overflow-x: auto;
  margin: 1.5em 0 2em;
}

.table-scroll table {
  margin: 0;
}

.callout {
  margin: 1.5em 0 2em;
  padding: 18px 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-md);
}

.callout__title {
  margin: 0 0 8px;
  color: var(--ink);
  font-weight: 700;
}

.callout > :last-child,
.callout ul {
  margin-bottom: 0;
}

.cta {
  margin-top: 2.5em;
}

.cta .btn {
  color: #fff;
  text-decoration: none;
  padding-inline: 22px;
}

/* Оглавление длинных страниц */
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
}

.toc {
  display: none;
}

@media (min-width: 1100px) {
  .article-layout {
    grid-template-columns: minmax(0, 68ch) minmax(220px, 280px);
    justify-content: space-between;
    gap: 64px;
  }

  .toc {
    display: block;
    position: sticky;
    top: 24px;
    align-self: start;
    margin-top: clamp(16px, 3vw, 32px);
    padding: 16px 18px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    font-size: 0.9375rem;
  }

  .toc__title {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .toc ol {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .toc a {
    display: block;
    padding: 6px 0;
    color: var(--ink);
    text-decoration: none;
    line-height: 1.35;
  }

  .toc a:hover {
    color: var(--brand-strong);
    text-decoration: underline;
  }
}

.prose h2[id],
.prose h3[id] {
  scroll-margin-top: 16px;
}

.contact-email {
  font-size: 1.25rem;
  font-weight: 700;
}

@media (max-width: 480px) {
  .prose th,
  .prose td {
    padding: 8px 10px;
  }
}

/* Незаполненные данные владельца — заметны, чтобы не уйти в прод */
mark.placeholder {
  padding: 0 4px;
  background: #fff4cc;
  color: #6b4e00;
  border: 1px dashed #c99a00;
  border-radius: 4px;
}

/* Код в статьях */
.prose code {
  padding: 0.1em 0.35em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875em;
  color: var(--ink);
  background: var(--surface-2);
  border-radius: 6px;
}

.prose pre {
  margin: 0 0 1.2em;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  line-height: 1.5;
}

.prose pre code {
  padding: 0;
  font-size: 0.8125rem;
  background: transparent;
}

/* ---------- Встраиваемая версия (embed.html) ---------- */

body.page-embed {
  min-height: 0;
  display: block;
  background: transparent;
}

.embed {
  padding: 1px;               /* чтобы рамка карточки не обрезалась краем iframe */
}

.page-embed .game {
  margin-inline: 0;           /* на главной на узких экранах карточка выходит за поля */
  box-shadow: none;
}

/* Компактнее, чем на главной: фрейм в LMS не должен быть высоким */
.page-embed .game {
  padding: clamp(12px, 2.4vw, 24px);
}

.page-embed .game__toolbar {
  gap: 12px 24px;
  padding-bottom: 14px;
  margin-bottom: 14px;
}

.page-embed .field__hint,
.page-embed .kbd-hint {
  display: none;
}

.page-embed .lbl-long {
  display: none;
}

.page-embed .lbl-short {
  display: inline;
}

.page-embed .game__layout {
  gap: 16px;
}

/* Высота палочек не зависит от высоты окна (vh): иначе автоподстройка
   высоты iframe растягивала бы палочки и снова меняла высоту */
.page-embed .sticks {
  --stick-h: clamp(96px, 20cqi, 170px);
}

.page-embed .board {
  padding: clamp(12px, 2vw, 20px) clamp(10px, 2vw, 24px);
}

.page-embed .panel {
  padding: 12px 14px;
}

.page-embed .panel__title {
  margin-bottom: 8px;
}

.page-embed .player {
  min-height: 44px;
}

.page-embed .history-list {
  max-height: 136px;
}

.game.is-locked .game__toolbar {
  display: none;
}

.embed-setup {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
}

.embed-credit {
  margin: 6px 4px 0;
  text-align: right;
  font-size: 0.75rem;
  line-height: 1.4;
}

.embed-credit a {
  color: var(--muted);
  text-decoration: none;
}

.embed-credit a:hover {
  color: var(--brand-strong);
  text-decoration: underline;
}

/* ---------- Кнопка и диалог «Встроить на сайт» ---------- */

.embed-cta {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.btn-quiet {
  min-height: 44px;
  padding: 8px 12px;
  gap: 8px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-weight: 700;
}

.btn-quiet:hover {
  color: var(--brand-strong);
  background: var(--surface-2);
}

.btn-quiet svg {
  flex: none;
}

.dialog {
  width: min(960px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  padding: 0;
  color: var(--text);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(0, 45, 116, 0.18);
}

.dialog::backdrop {
  background: rgba(0, 40, 70, 0.45);
}

.dialog__head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.dialog__head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.dialog__close {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.dialog__close:hover {
  background: var(--surface-2);
}

.dialog__body {
  display: grid;
  gap: 20px;
  padding: 20px;
}

@media (max-width: 859px) {
  .embed-preview {
    order: 1;                 /* на узком экране код — сразу под настройками */
  }
}

@media (min-width: 860px) {
  .dialog__body {
    grid-template-columns: 300px minmax(0, 1fr);
    align-items: start;
  }
}

.embed-options {
  display: grid;
  gap: 16px;
  margin: 0;
}

.embed-options fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.embed-options legend {
  padding: 0;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
}

/* Радиокнопки в виде сегментированного переключателя */
.segmented--radio {
  display: flex;
}

.segmented--radio input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented--radio label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.segmented--radio input:checked + label {
  background: var(--paper);
  border-color: var(--line-strong);
  color: var(--brand-strong);
  box-shadow: 0 1px 2px rgba(0, 45, 116, 0.08);
}

.segmented--radio input:focus-visible + label {
  outline: 3px solid var(--brand);
  outline-offset: 1px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding-top: 10px;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--brand);
}

.check small {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.embed-preview {
  margin: 0;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
}

.embed-preview iframe {
  display: block;
  width: 100%;
  height: 560px;
  border: 0;
  background: #fff;
  border-radius: var(--radius-md);
}

.embed-preview figcaption {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
}

.embed-code {
  display: grid;
  gap: 8px;
  grid-column: 1 / -1;
}

.embed-code label {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
}

.embed-code textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 92px;
  padding: 10px 12px;
  font: 0.8125rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  resize: vertical;
  word-break: break-all;
}

.embed-code__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.embed-code__status {
  margin: 0;
  color: var(--brand-strong);
  font-weight: 700;
  font-size: 0.9375rem;
}

/* ---------- Уведомление об обработке данных ---------- */

.pd-notice {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  max-width: 880px;
  margin-inline: auto;
  padding: 14px 18px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  box-shadow: 0 14px 30px rgba(0, 45, 116, 0.12);
  font-size: 0.9375rem;
}

.pd-notice__text {
  flex: 1 1 320px;
  margin: 0;
  line-height: 1.45;
}

.pd-notice__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body.has-pd-notice {
  padding-bottom: 140px;
}

@media (max-width: 480px) {
  .pd-notice {
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 12px 14px;
  }

  .pd-notice {
    gap: 8px;
    font-size: 0.875rem;
  }

  .pd-notice__actions {
    width: 100%;
    flex-wrap: nowrap;
  }

  .pd-notice__actions .btn {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 12px;
  }
}

@media print {
  .pd-notice {
    display: none;
  }
}

/* ---------- Мобильные ---------- */

@media (max-width: 480px) {
  .game {
    border-radius: var(--radius-md);
    margin-inline: -4px;
  }

  .game__toolbar .field,
  .segmented {
    width: 100%;
  }

  .segmented__btn {
    padding-inline: 8px;
    font-size: 0.875rem;
  }

  .game-actions .btn {
    flex: 1 1 auto;
  }
}

/* ---------- Проектор / большие экраны ---------- */

@media (min-width: 1600px) {
  :root {
    --wrap: 1440px;
  }

  html {
    font-size: 18px;
  }

  .game__layout {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
}

/* ---------- Уменьшение движения ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .game-message.computer-thinking::after {
    display: none;
  }
}

@media print {
  .site-header,
  .site-footer,
  .game {
    display: none;
  }
}
