/* «Мельница» — оформление страницы игры. Цвета — токены сайта из style.css. */

.ml-igra { position: relative; scroll-margin-top: calc(var(--nav-h) + 8px); }
.ml-h { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 18px; }

/* ---------- Выбор соперника ---------- */
.ml-vybor {
  padding: clamp(18px, 3vw, 32px); border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border-strong);
}
.ml-soperniki { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1000px) { .ml-soperniki { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .ml-soperniki { gap: 8px; } }

.ml-karta { position: relative; display: block; cursor: pointer; }
.ml-karta input, .ml-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.ml-karta-in {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; height: 100%;
  padding: 18px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: rgba(255,255,255,.025); transition: border-color .2s, background .2s, transform .2s;
}
.ml-karta:hover .ml-karta-in { border-color: var(--border-strong); background: var(--surface-2); }
.ml-karta input:checked + .ml-karta-in {
  border-color: var(--gold); background: linear-gradient(180deg, rgba(232,147,76,.12), rgba(232,147,76,.03));
  box-shadow: 0 0 0 1px var(--gold) inset, 0 10px 30px rgba(232,147,76,.12);
}
.ml-karta input:focus-visible + .ml-karta-in { outline: 2px solid var(--gold-2); outline-offset: 3px; }
.ml-karta-portret { width: 72px; height: 72px; border-radius: 50%; }
.ml-karta-dvoe { display: flex; gap: 4px; height: 72px; align-items: center; }
.ml-karta-t { display: flex; flex-direction: column; gap: 4px; }
.ml-karta-t b { font-family: var(--font-display); font-size: 1.12rem; font-weight: 600; }
.ml-karta-ur { color: var(--gold-2); font-size: .86rem; letter-spacing: .02em; }
.ml-karta-o { color: var(--text-2); font-size: .88rem; line-height: 1.45; }
.ml-karta-st { color: var(--text-3); font-size: .8rem; }
/* На телефоне четыре карточки — сеткой 2×2 без описаний: иначе до кнопки
   «Начать» пришлось бы листать три экрана. Описание выбранного — под сеткой. */
@media (max-width: 560px) {
  .ml-karta-in { padding: 12px 8px; gap: 6px; }
  .ml-karta-portret, .ml-karta-dvoe { width: 56px; height: 56px; }
  .ml-karta-dvoe img { width: 28px; height: 28px; }
  .ml-karta-t b { font-size: 1rem; }
  .ml-karta-o { display: none; }
  .ml-karta-ur { font-size: .8rem; }
}
.ml-kto { display: none; color: var(--text-2); font-size: .9rem; line-height: 1.5; margin-top: 10px; }
@media (max-width: 560px) { .ml-kto { display: block; } }

.ml-opcii { display: flex; flex-wrap: wrap; gap: 14px 28px; margin-top: 22px; }
.ml-gruppa { border: 0; padding: 0; margin: 0; min-width: 0; }
.ml-gruppa[hidden] { display: none; }
.ml-gruppa legend { font-size: .74rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; padding: 0; }
.ml-stavki { display: flex; flex-wrap: wrap; gap: 8px; }
.ml-chip { position: relative; display: inline-block; margin: 0 6px 6px 0; cursor: pointer; }
.ml-stavki .ml-chip { margin: 0; }
.ml-chip span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); font-size: .92rem; transition: border-color .2s, background .2s, color .2s;
}
.ml-chip:hover span { background: var(--surface-2); }
.ml-chip input:checked + span { border-color: var(--gold); color: #1a1206; background: linear-gradient(135deg, var(--gold-2), var(--gold)); font-weight: 600; }
.ml-chip input:focus-visible + span { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.ml-chip input:disabled + span { opacity: .38; cursor: not-allowed; }
.ml-prim { color: var(--text-2); font-size: .88rem; line-height: 1.5; margin-top: 8px; max-width: 62ch; }
.ml-prim:empty, .ml-prim[hidden] { display: none; }
.ml-start { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 22px; }
.ml-koshel { color: var(--text-2); font-size: .9rem; }
.ml-koshel[hidden] { display: none; }
.ml-koshel::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe2a8, var(--gold) 60%, #9a5a24);
}

/* ---------- Партия ---------- */
.ml-partiya { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.ml-partiya[hidden], .ml-vybor[hidden] { display: none; }
@media (max-width: 900px) { .ml-partiya { grid-template-columns: 1fr; } }

.ml-stol {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: clamp(10px, 2vw, 22px); border-radius: var(--radius); border: 1px solid var(--border-strong);
  background-color: #120d18; background-size: cover; background-position: center; box-shadow: var(--shadow);
}
.ml-doska { width: min(100%, 620px, calc(100vh - var(--nav-h) - 150px)); min-width: min(100%, 300px); aspect-ratio: 1; }
.ml-svg { width: 100%; height: 100%; display: block; overflow: visible; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.ml-ruka {
  display: flex; align-items: center; gap: 10px; width: min(100%, 620px); min-height: 34px; padding: 6px 12px;
  border-radius: 999px; background: rgba(12,10,19,.62); border: 1px solid var(--border); font-size: .85rem;
  transition: border-color .25s, box-shadow .25s;
}
.ml-ruka.is-hod { border-color: rgba(240,180,111,.6); box-shadow: 0 0 0 1px rgba(240,180,111,.25), 0 0 22px rgba(232,147,76,.18); }
.ml-ruka-imya { font-weight: 600; white-space: nowrap; }
.ml-ruka-ryad { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; min-width: 0; }
.ml-ruka-ryad img { width: 18px; height: 18px; }
.ml-ruka-inf { color: var(--text-2); white-space: nowrap; margin-left: auto; }

/* Слои доски */
.ml-podpisi text { font: 600 26px var(--font-body); fill: rgba(239,230,216,.55); text-anchor: middle; }
.ml-uzel { fill: transparent; cursor: pointer; outline: none; }
.ml-fokus { fill: none; stroke: var(--gold-2); stroke-width: 5; stroke-dasharray: 10 8; pointer-events: none; }

.ml-fishka { transition: transform .32s cubic-bezier(.3,.7,.2,1), opacity .3s; pointer-events: none; }
.ml-fishka image { filter: drop-shadow(0 6px 5px rgba(0,0,0,.45)); }
.ml-fishka.is-new image { animation: mlPostavit .28s cubic-bezier(.3,1.4,.5,1) both; transform-box: fill-box; transform-origin: center; }
.ml-fishka.is-gone { opacity: 0; }
.ml-fishka.is-gone image { animation: mlSnyat .4s ease-in both; transform-box: fill-box; transform-origin: center; }
.ml-fishka.is-pritushena { opacity: .3; }
.ml-vremennaya { opacity: .85; }
@keyframes mlPostavit { from { transform: scale(1.35); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes mlSnyat { to { transform: scale(.4) translateY(-30px); opacity: 0; } }

.ml-mln { stroke-width: 26; stroke-linecap: round; opacity: .55; }
.ml-mln-yadro { stroke-width: 7; stroke-linecap: round; opacity: .9; }
.ml-mln0 { stroke: #f0b46f; }
.ml-mln1 { stroke: #9a9dd4; }
.ml-mln.is-new { animation: mlMelnica 1.2s ease-out both; }
@keyframes mlMelnica { 0% { opacity: 0; stroke-width: 10; } 30% { opacity: 1; stroke-width: 44; } 100% { opacity: .55; stroke-width: 26; } }

.ml-mozhno { fill: none; stroke: rgba(240,180,111,.55); stroke-width: 4; }
.ml-vybrano { fill: rgba(240,180,111,.18); stroke: var(--gold-2); stroke-width: 7; }
.ml-cel { fill: var(--gold-2); opacity: .85; stroke: #1a1206; stroke-width: 3; animation: mlDyshat 1.4s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.ml-snyat { fill: rgba(240,143,176,.16); stroke: var(--rose); stroke-width: 7; stroke-dasharray: 14 9; animation: mlKrug 3s linear infinite; }
.ml-nelzya { fill: none; stroke: rgba(240,143,176,.8); stroke-width: 5; animation: mlNelzya .38s ease-out both; transform-box: fill-box; transform-origin: center; }
@keyframes mlDyshat { from { transform: scale(.8); } to { transform: scale(1.15); } }
@keyframes mlKrug { to { stroke-dashoffset: -92; } }
@keyframes mlNelzya { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }

.ml-sled-otkuda { fill: none; stroke: rgba(154,157,212,.7); stroke-width: 4; stroke-dasharray: 8 8; }
.ml-sled-kuda { fill: none; stroke: #5fd4c4; stroke-width: 6; }
.ml-sled-strelka { stroke: rgba(95,212,196,.75); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 2 12; }
.ml-sled-snyata { stroke: rgba(240,143,176,.75); stroke-width: 8; stroke-linecap: round; fill: none; }

/* Итог партии — поверх доски, но свернуть можно: посмотреть, чем кончилось */
.ml-itog { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; border-radius: inherit; background: rgba(9,7,14,.62); backdrop-filter: blur(2px); cursor: pointer; }
.ml-itog[hidden] { display: none; }
.ml-itog-in {
  cursor: default; width: min(100%, 420px); text-align: center; padding: 26px 22px; border-radius: var(--radius);
  background: linear-gradient(180deg, #1b1528, #120e1c); border: 1px solid rgba(240,180,111,.45); box-shadow: var(--shadow);
}
.ml-itog-in h2 { font-size: 2rem; color: var(--gold-2); }
.ml-itog-t { color: var(--text-2); margin-top: 8px; }
.ml-itog-m { margin-top: 10px; font-weight: 600; color: var(--text); }
.ml-itog-m[hidden] { display: none; }
.ml-itog-k { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.ml-itog.is-svernut { background: transparent; backdrop-filter: none; place-items: end center; pointer-events: none; }
.ml-itog.is-svernut .ml-itog-in { pointer-events: auto; padding: 12px 16px; }
.ml-itog.is-svernut .ml-itog-t, .ml-itog.is-svernut .ml-itog-m { display: none; }
.ml-itog.is-svernut h2 { font-size: 1.2rem; }
.ml-itog.is-svernut .ml-itog-k { margin-top: 8px; }

/* Панель справа */
.ml-panel {
  display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border-strong);
}
.ml-sopernik { display: flex; align-items: center; gap: 14px; }
.ml-portret { width: 84px; height: 84px; border-radius: 50%; flex: none; }
.ml-portret[hidden] { display: none; }
.ml-sop-t { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ml-sop-t b { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; line-height: 1.2; }
.ml-sop-t span { color: var(--text-2); font-size: .85rem; line-height: 1.4; }
.ml-rech {
  position: relative; padding: 12px 14px; border-radius: 14px; background: rgba(240,180,111,.08);
  border: 1px solid rgba(240,180,111,.25); font-style: italic; color: #f3e6cf; line-height: 1.5; font-size: .95rem;
}
.ml-rech[hidden] { display: none; }
.ml-rech.is-new { animation: mlRech .35s ease-out both; }
@keyframes mlRech { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.ml-status { min-height: 3em; line-height: 1.5; color: var(--text); font-size: .98rem; }
.ml-knopki { display: flex; flex-wrap: wrap; gap: 8px; }
.ml-knopki .btn { padding: 9px 14px; font-size: .86rem; }
.ml-knopki .btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.ml-knopki .btn.is-warn { border-color: var(--rose); color: var(--rose); }

@media (max-width: 900px) {
  .ml-panel { padding: 16px; gap: 10px; }
  .ml-portret { width: 64px; height: 64px; }
}
@media (max-width: 420px) {
  .ml-stol { padding: 8px; gap: 8px; border-radius: var(--radius-sm); }
  .ml-ruka { padding: 5px 10px; gap: 8px; font-size: .8rem; }
  .ml-ruka-ryad img { width: 14px; height: 14px; }
  .ml-ruka-inf { font-size: .76rem; }
}

/* ---------- Правила ---------- */
.ml-pravila { margin-top: 28px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.ml-pravila[open] { border-color: var(--border-strong); }
.ml-pravila summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 18px 22px; font-family: var(--font-display); font-weight: 600; font-size: 1.25rem;
}
.ml-pravila summary::-webkit-details-marker { display: none; }
.ml-pravila summary svg { width: 20px; height: 20px; color: var(--text-3); transition: transform .25s; }
.ml-pravila[open] summary svg { transform: rotate(180deg); color: var(--gold); }
.ml-pravila summary:focus-visible { outline: 2px solid var(--gold-2); outline-offset: -2px; border-radius: var(--radius-sm); }
.ml-pravila-in { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 28px; padding: 0 22px 24px; }
@media (max-width: 760px) { .ml-pravila-in { grid-template-columns: 1fr; } }
.ml-skhema { margin: 0; }
.ml-skhema img { width: 100%; height: auto; border-radius: var(--radius-sm); }
.ml-skhema figcaption { color: var(--text-3); font-size: .85rem; margin-top: 8px; line-height: 1.5; }
.ml-pravila-t h3 { font-family: var(--font-display); color: var(--gold-2); font-size: 1.08rem; margin: 16px 0 4px; }
.ml-pravila-t h3:first-child { margin-top: 0; }
.ml-pravila-t p { color: var(--text-2); line-height: 1.6; }
kbd { font: 600 12px/1 var(--font-body); padding: 3px 7px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .ml-fishka, .ml-ruka, .ml-karta-in { transition: none; }
  .ml-cel, .ml-snyat, .ml-mln.is-new, .ml-rech.is-new { animation: none; }
}
.ml-panel [data-koshel], .ml-start [data-koshel] { align-self: flex-start; }

/* Запись партии: по строке на пару ходов, как в шашках и тафле. */
.ml-zapis { border-top: 1px solid var(--border); padding-top: 10px; }
.ml-zapis summary { cursor: pointer; color: var(--text-2); font-size: .9rem; }
.ml-zapis summary:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; border-radius: 6px; }
.ml-zapis-sp { margin: 8px 0 0; padding-left: 2.2em; max-height: 180px; overflow-y: auto; font: 500 .86rem/1.7 var(--font-body); color: var(--text-2); }
.ml-zapis-sp li::marker { color: var(--text-3); }
.ml-zapis-sp span { display: inline-block; min-width: 10em; }
.ml-zapis-sp span + span { color: var(--text); }
