/* «Хнефатафл» — оформление страницы игры. Цвета — токены сайта из style.css.
   Общая часть (выбор соперника, чипы, панель, правила, итог) повторяет «Мельницу»,
   чтобы игры витрины выглядели одной семьёй; своё — доска и подсветки. */

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

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

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

.tf-opcii { display: flex; flex-wrap: wrap; gap: 14px 28px; margin-top: 22px; }
.tf-gruppa { border: 0; padding: 0; margin: 0; min-width: 0; }
.tf-gruppa[hidden] { display: none; }
.tf-gruppa legend { font-size: .74rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; padding: 0; }
.tf-stavki { display: flex; flex-wrap: wrap; gap: 8px; }
.tf-chip { position: relative; display: inline-block; margin: 0 6px 6px 0; cursor: pointer; }
.tf-stavki .tf-chip { margin: 0; }
.tf-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;
}
.tf-chip:hover span { background: var(--surface-2); }
.tf-chip input:checked + span { border-color: var(--gold); color: #1a1206; background: linear-gradient(135deg, var(--gold-2), var(--gold)); font-weight: 600; }
.tf-chip input:focus-visible + span { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.tf-chip input:disabled + span { opacity: .38; cursor: not-allowed; }
.tf-prim { color: var(--text-2); font-size: .88rem; line-height: 1.5; margin-top: 8px; max-width: 62ch; }
.tf-prim:empty, .tf-prim[hidden] { display: none; }
.tf-start { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 22px; }
.tf-koshel { color: var(--text-2); font-size: .9rem; }
.tf-koshel[hidden] { display: none; }
.tf-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);
}

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

.tf-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);
}


/* Итог партии — поверх доски, но свернуть можно: посмотреть, чем кончилось */
.tf-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; }
.tf-itog[hidden] { display: none; }
.tf-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);
}
.tf-itog-in h2 { font-size: 2rem; color: var(--gold-2); }
.tf-itog-t { color: var(--text-2); margin-top: 8px; }
.tf-itog-m { margin-top: 10px; font-weight: 600; color: var(--text); }
.tf-itog-m[hidden] { display: none; }
.tf-itog-k { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.tf-itog.is-svernut { background: transparent; backdrop-filter: none; place-items: end center; pointer-events: none; }
.tf-itog.is-svernut .tf-itog-in { pointer-events: auto; padding: 12px 16px; }
.tf-itog.is-svernut .tf-itog-t, .tf-itog.is-svernut .tf-itog-m { display: none; }
.tf-itog.is-svernut h2 { font-size: 1.2rem; }
.tf-itog.is-svernut .tf-itog-k { margin-top: 8px; }

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

@media (max-width: 900px) {
  .tf-panel { padding: 16px; gap: 10px; }
  .tf-portret { width: 64px; height: 64px; }
}
@media (max-width: 420px) {
  .tf-stol { padding: 8px; gap: 8px; border-radius: var(--radius-sm); }
}

/* ---------- Правила ---------- */
.tf-pravila { margin-top: 28px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.tf-pravila[open] { border-color: var(--border-strong); }
.tf-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;
}
.tf-pravila summary::-webkit-details-marker { display: none; }
.tf-pravila summary svg { width: 20px; height: 20px; color: var(--text-3); transition: transform .25s; }
.tf-pravila[open] summary svg { transform: rotate(180deg); color: var(--gold); }
.tf-pravila summary:focus-visible { outline: 2px solid var(--gold-2); outline-offset: -2px; border-radius: var(--radius-sm); }
.tf-pravila-in { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 28px; padding: 0 22px 24px; }
@media (max-width: 760px) { .tf-pravila-in { grid-template-columns: 1fr; } }
.tf-skhema { margin: 0; }
.tf-skhema img { width: 100%; height: auto; border-radius: var(--radius-sm); }
.tf-skhema figcaption { color: var(--text-3); font-size: .85rem; margin-top: 8px; line-height: 1.5; }
.tf-pravila-t h3 { font-family: var(--font-display); color: var(--gold-2); font-size: 1.08rem; margin: 16px 0 4px; }
.tf-pravila-t h3:first-child { margin-top: 0; }
.tf-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); }


/* ---------- Доска тафла ---------- */
.tf-doska { width: min(100%, 640px, calc(100vh - var(--nav-h) - 130px)); min-width: min(100%, 300px); aspect-ratio: 1; }
.tf-svg { width: 100%; height: 100%; display: block; overflow: visible; touch-action: manipulation; -webkit-tap-highlight-color: transparent; border-radius: 10px; }
.tf-svg:focus { outline: none; }
.tf-svg:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 4px; }
.tf-podpisi text { font: 600 26px var(--font-body); fill: rgba(239,230,216,.5); text-anchor: middle; }
.tf-hit { fill: transparent; cursor: pointer; }
.tf-fokus { fill: none; stroke: var(--gold-2); stroke-width: 5; stroke-dasharray: 10 8; pointer-events: none; opacity: 0; }
.tf-svg.is-klav:focus .tf-fokus { opacity: 1; }

.tf-f { transition: transform .28s cubic-bezier(.3,.7,.2,1), opacity .35s; pointer-events: none; }
.tf-f image { filter: drop-shadow(0 5px 4px rgba(0,0,0,.5)); }
.tf-f.is-gone { opacity: 0; }

/* Плашки сторон над и под доской */
.tf-plashka {
  display: flex; align-items: center; gap: 10px; width: min(100%, 640px); 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;
}
.tf-plashka.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); }
.tf-plashka img { width: 22px; height: 22px; flex: none; }
.tf-pl-imya { font-weight: 600; white-space: nowrap; }
.tf-pl-inf { color: var(--text-2); margin-left: auto; white-space: nowrap; }

/* Подсветки */
.tf-sled-otkuda { fill: none; stroke: rgba(154,157,212,.75); stroke-width: 4; stroke-dasharray: 8 7; }
.tf-sled-kuda { fill: rgba(95,212,196,.12); stroke: #5fd4c4; stroke-width: 5; }
.tf-sled-strelka { stroke: rgba(95,212,196,.55); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 2 12; }
.tf-sled-vzyat { stroke: rgba(240,143,176,.8); stroke-width: 7; stroke-linecap: round; fill: none; }
.tf-liniya { fill: rgba(95,212,196,.55); stroke: none; animation: tfMigat 1.2s ease-in-out infinite alternate; }
.tf-ugroza { fill: none; stroke: var(--rose); stroke-width: 6; stroke-dasharray: 12 8; animation: tfKrug 3s linear infinite; }
.tf-ugroza.is-korol { stroke-width: 9; stroke: #ff6f8f; }
.tf-vybrano { fill: rgba(240,180,111,.22); stroke: var(--gold-2); stroke-width: 6; }
.tf-cel { fill: var(--gold-2); opacity: .9; stroke: #1a1206; stroke-width: 3; pointer-events: none; }
.tf-cel-beret { fill: none; stroke: var(--gold); stroke-width: 5; pointer-events: none; }
.tf-nelzya { fill: none; stroke: rgba(240,143,176,.85); stroke-width: 5; animation: tfNelzya .4s ease-out both; transform-box: fill-box; transform-origin: center; pointer-events: none; }
@keyframes tfMigat { from { opacity: .45; } to { opacity: 1; } }
@keyframes tfKrug { to { stroke-dashoffset: -80; } }
@keyframes tfNelzya { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }

.tf-itog-p { color: var(--text-3); font-size: .8rem; margin-top: 12px; }
.tf-itog.is-svernut .tf-itog-p { display: none; }

/* Запись партии */
.tf-zapis summary { cursor: pointer; color: var(--text-2); font-size: .9rem; }
.tf-zapis summary span { color: var(--text-3); }
.tf-zapis ol { margin: 8px 0 0; padding-left: 2.4em; max-height: 180px; overflow: auto; font: 500 .85rem/1.6 var(--font-body); color: var(--text-2); font-variant-numeric: tabular-nums; white-space: pre; }

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

@media (max-width: 420px) {
  .tf-stol { padding: 6px; gap: 6px; border-radius: var(--radius-sm); }
  .tf-plashka { padding: 4px 10px; gap: 8px; font-size: .8rem; min-height: 30px; }
  .tf-plashka img { width: 18px; height: 18px; }
  .tf-pl-inf { font-size: .76rem; }
  .tf-podpisi text { font-size: 30px; }
}
/* На телефоне доска 11×11 — почти во всю ширину экрана: каждая клетка на счету пальца. */
@media (max-width: 560px) {
  .tf-stol { margin-inline: -10px; padding: 6px 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .tf-f, .tf-plashka, .tf-karta-in { transition: none; }
  .tf-liniya, .tf-ugroza, .tf-nelzya, .tf-rech.is-new { animation: none; }
}
.tf-panel [data-koshel], .tf-start [data-koshel] { align-self: flex-start; }
