/* Плеер тренажёров Магии турецкого языка.
   Страница открывается во весь экран внутри окна тренажёра на /trainers.html;
   в правом верхнем углу поверх неё лежит кнопка закрытия - угол оставляем пустым. */

:root {
  --pri: #1A9BA1;
  --pri-dark: #147A7F;
  --deep: #0E5C60;
  --ink: #12393B;
  --card: #FFFFFF;
  --pic-bg: #EEF6F5;
  --ring: rgba(255, 255, 255, .55);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: linear-gradient(180deg, var(--pri) 0%, var(--pri-dark) 100%);
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button { font: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
button:disabled { cursor: default; }

.igra {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.ig-wait {
  margin: auto;
  padding: 24px;
  font-size: 1.1rem;
  text-align: center;
}
.ig-fail { max-width: 420px; }

/* ---------- Шапка ---------- */
.ig-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 64px 4px 20px;   /* справа - место под кнопку закрытия окна */
}
.ig-head { min-width: 0; }
.ig-kind {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  opacity: .8;
}
.ig-title {
  margin: 0;
  font-family: 'Lora', Georgia, serif;
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ig-count {
  margin-left: auto;
  flex: none;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  font-weight: 700;
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
}

/* Подпись по правилу IGRY.fitText: строки ломаются по пробелам и выравниваются по длине. */
.ig-fit { max-width: 100%; text-wrap: balance; overflow-wrap: normal; hyphens: manual; }

/* ---------- Нижняя панель - общая для всех тренажёров (IGRY.chrome) ----------
   Слева меню, по центру кнопки шаблона, справа звук и весь экран.
   Размеры и места одни на все шаблоны; цвета шаблон может перекрасить под свой скин. */
.igra { position: relative; }
.ig-bar {
  position: relative;
  margin-top: auto;         /* внизу и тогда, когда поле игры ещё пустое (стартовый экран) */
  z-index: 70;              /* звук и весь экран видны и поверх стартового экрана шаблона */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 20px calc(16px + env(safe-area-inset-bottom));
}
.ig-left { justify-self: start; display: flex; align-items: center; gap: 10px; min-width: 0; }
.ig-main { display: flex; justify-content: center; gap: 10px; }
.ig-side { justify-self: end; display: flex; gap: 10px; }
.ig-bar--idle .ig-menu-btn, .ig-bar--idle .ig-main { visibility: hidden; }
/* «2 из 10» стоит на месте меню, пока игры нет; в игре список тренажёров - пункт меню. */
.ig-bar--idle .ig-menu-btn { display: none; }
.ig-bar:not(.ig-bar--idle) .ig-route-btn { display: none; }
.ig-route-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 16px 0 12px;
  border: 2px solid rgba(255, 255, 255, .55);
  border-radius: 14px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background .15s;
}
.ig-route-btn:hover { background: rgba(255, 255, 255, .28); }
.ig-route-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Список тренажёров списка (кнопка «2 из 10» или пункт меню). */
.ig-route-box { max-height: calc(100% - 40px); max-width: calc(100% - 40px); }
.ig-route-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  min-height: 0;
}
.ig-menu-box .ig-route-list button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  font-size: 1.05rem;
  font-weight: 600;
}
.ig-route-n {
  flex: none;
  width: 1.6em;
  text-align: right;
  opacity: .7;
  font-variant-numeric: tabular-nums;
}
.ig-route-t { flex: 1; min-width: 0; }
.ig-route-m { flex: none; min-width: 1.2em; text-align: center; font-weight: 800; }
.ig-menu-box .ig-route-list .ig-route-cur { background: rgba(255, 255, 255, .16); font-weight: 800; opacity: 1; }

/* Итоговый экран: «Дальше» - главной кнопкой, «Пройти ещё раз» - ссылкой под ней.
   Цвета «Дальше» берёт от кнопки повтора своей игры (те же классы). */
.igra .ig-next {
  display: block;
  max-width: 100%;
  height: auto;
  min-height: 58px;
  margin: 0 auto 10px;
  padding: 12px 32px;
  white-space: normal;
  text-wrap: balance;
  line-height: 1.25;
}
.igra .ig-go.ig-go--alt {
  display: block;
  min-width: 0;
  height: auto;
  margin: 0 auto;
  padding: 8px 16px;
  background: none;
  box-shadow: none;
  color: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  opacity: .85;
}
.igra .ig-go.ig-go--alt:hover { transform: none; opacity: 1; }

.ig-ico {
  flex: none;
  width: 46px;
  height: 46px;
  padding: 8px;
  border: 2px solid rgba(255, 255, 255, .55);
  border-radius: 14px;
  background: rgba(255, 255, 255, .16);
  transition: background .15s;
}
.ig-ico:hover { background: rgba(255, 255, 255, .28); }

/* Крестик «Закрыть тренажёр» (core.js): в правом верхнем углу, на месте,
   которое шапки шаблонов держат свободным под крестик окна страницы. */
.ig-exit {
  display: none;
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 80;
  width: 40px;
  height: 40px;
  padding: 9px;
  border: 2px solid rgba(255, 255, 255, .55);
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  cursor: pointer;
  transition: background .15s;
}
.ig-exit:hover { background: rgba(255, 255, 255, .28); }
.ig-exit svg { display: block; width: 100%; height: 100%; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; }
.ig-solo .ig-exit, html:fullscreen .ig-exit { display: block; }
html:-webkit-full-screen .ig-exit { display: block; }
.ig-ico svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: #fff;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ig-ico svg .ig-solid { fill: #fff; }

.ig-btn {
  min-width: 150px;
  height: 50px;
  padding: 0 22px;
  border: 2px solid var(--ring);
  border-radius: 14px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;      /* «Следующий экран» в одну строку */
  transition: background .15s, opacity .2s;
}
.ig-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .26); }
.ig-btn--main { border-color: #fff; background: #fff; color: var(--pri-dark); font-weight: 800; }
.ig-btn--main:hover:not(:disabled) { background: #F2FBFA; }
.ig-btn:disabled { opacity: .45; }

/* Меню: задание сверху по затемнённому экрану, пункты в панели слева внизу. */
.ig-menu {
  position: absolute;
  inset: 0;
  z-index: 80;
  background: rgba(3, 34, 36, .84);
  animation: ig-fade .2s ease-out;
}
@keyframes ig-fade { from { opacity: 0; } }
.ig-menu-t {
  margin: 0 auto;
  max-width: 780px;
  padding: 96px 24px 0;
  text-align: center;
  font-size: clamp(1.1rem, 2.6vw, 1.7rem);
  font-weight: 700;
  line-height: 1.35;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .45);
}
.ig-menu-t span { display: block; margin-bottom: 6px; font-size: .7em; opacity: .8; }
.ig-menu-box {
  position: absolute;
  left: 20px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  min-width: 280px;
  display: flex;
  flex-direction: column;
  padding: 10px 0;
  border: 2px solid rgba(255, 255, 255, .35);
  border-radius: 18px;
  background: #0E5C60;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .3);
}
.ig-menu-h {
  margin: 4px 18px 6px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(255, 255, 255, .25);
  font-size: .85rem;
  font-weight: 700;
  opacity: .7;
}
.ig-menu-box button {
  padding: 12px 18px;
  border: 0;
  background: none;
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
  text-align: left;
}
.ig-menu-box button:hover, .ig-menu-box button:focus-visible { background: rgba(255, 255, 255, .12); outline: none; }

/* ---------- Экран начала и конца ---------- */
.ig-panel {
  max-width: 620px;
  margin: auto;
  padding: 24px;
  text-align: center;
}
.ig-panel-n {
  margin: 0 0 12px;
  font-family: 'Lora', Georgia, serif;
  font-weight: 600;
  font-size: 1.7rem;
}
.ig-panel-t {
  margin: 0 0 28px;
  font-size: clamp(1.1rem, 2.4vw, 1.45rem);
  line-height: 1.5;
}
.ig-go {
  min-width: 200px;
  height: 58px;
  padding: 0 40px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: var(--pri-dark);
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  transition: transform .15s;
}
.ig-go:hover { transform: translateY(-2px); }
/* Кнопка получает фокус сама при показе экрана (чтобы Enter запускал колоду),
   белая рамка фокуса при этом не нужна: кнопка на экране одна. */
.ig-go:focus, .ig-go:focus-visible { outline: none; }
.ig-keys {
  margin: 20px 0 0;
  font-size: .9rem;
  opacity: .8;
}
/* Личный контекст на экране результата: «ваш первый результат», «ваш лучший
   результат», «лучший результат: 16 из 18 · 1:42», «быстрее на 9 с». Цвет
   наследуется от карточки итога каждой игры. */
.ig-ctx {
  margin: -8px 0 18px;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  opacity: .85;
}

/* ---------- Речевые карточки ---------- */
.kc-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 8px 16px;
}

/* --w - ширина карточки; высота карточки и колоды - 1,27 ширины. */
.kc-table {
  --w: min(430px, 38vw, calc((100dvh - 230px) / 1.27));
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 6vw, 96px);
}

.kc-deck {
  position: relative;
  flex: none;
  width: var(--w);
  height: calc(var(--w) * 1.27);
  padding: 0;
  border: 0;
  background: none;
  transition: transform .15s;
}
.kc-deck:hover { transform: translateY(-3px); }
.kc-back {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  border: 3px solid rgba(255, 255, 255, .35);
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .06) 0 10px, transparent 10px 20px),
    var(--deep);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.kc-back:nth-child(1) { transform: translate(10px, 10px); }
.kc-back:nth-child(2) { transform: translate(5px, 5px); }
.kc-deck--thin .kc-back:nth-child(1),
.kc-deck--thin .kc-back:nth-child(2) { display: none; }
.kc-deck--empty .kc-back {
  background: transparent;
  border-style: dashed;
  box-shadow: none;
}
.kc-left {
  position: absolute;
  inset: auto 0 18px;
  font-weight: 700;
  font-size: 1rem;
  color: rgba(255, 255, 255, .9);
}

.kc-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.kc-slot { touch-action: pan-y; user-select: none; -webkit-user-select: none; }

.kc-card {
  margin: 0;
  width: var(--w);
  height: calc(var(--w) * 1.27);
  display: flex;
  flex-direction: column;
  padding: 14px 14px 6px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .2);
  cursor: pointer;
}
.kc-pic {
  flex: none;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--pic-bg);
}
.kc-pic img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
/* Общее правило обрезки кадров во всех играх: полоса берётся ближе к верху (50% 35%),
   а не по центру. В кадрах голова целиком, и по центру узкая полоса её срезает;
   при 35% лицо попадает в полосу, а предмет внизу кадра ещё виден (проверено 06.10.2026). */
.kc-pic img, .mp-pic img, .vb-pic img, .pr-cardp img, .pr-row-pic, .pr-row-real img,
.sv-pic img, .zp-pic img, .rs-pic img, .rs-row-pic { object-position: 50% 35%; }
.kc-word {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  color: var(--ink);
  font-weight: 800;
  font-size: calc(var(--w) * .155);
  line-height: 1.1;
  text-align: center;
  overflow: hidden;   /* длинное выражение уменьшает шрифт скрипт, а не перенос посреди слова */
}
.kc-card--text { padding: 20px; }
.kc-word--big { font-size: calc(var(--w) * .16); }

.kc-in-next { animation: kc-from-deck .28s ease-out; }
.kc-in-prev { animation: kc-back-in .28s ease-out; }
@keyframes kc-from-deck {
  from { opacity: 0; transform: translateX(-48px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes kc-back-in {
  from { opacity: 0; transform: translateX(48px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.kc-say {
  width: 76px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ring);
  border-radius: 14px;
  background: rgba(255, 255, 255, .16);
  transition: background .15s;
}
/* Значок меняет цвет вместе с фоном: иначе в конце звука белый значок
   на долю секунды сливается с ещё белым фоном. */
.kc-say svg { width: 32px; height: 32px; fill: #fff; transition: fill .15s; }
.kc-say:hover { background: rgba(255, 255, 255, .26); }
.kc-say.on { background: #fff; border-color: #fff; }
.kc-say.on svg { fill: var(--pri-dark); }
.kc-say:disabled { opacity: .35; }

/* Телефон и узкое окно: колода не помещается рядом, остаётся одна карточка. */
@media (max-width: 760px), (orientation: portrait) and (max-width: 1000px) {
  .kc-table { --w: min(420px, 84vw, calc((100dvh - 260px) / 1.27)); }
  .kc-deck { display: none; }
  .ig-title { font-size: 1.1rem; }
}

/* Невысокий экран (телефон боком, низкое окно): шапка и кнопки ужимаются,
   кнопка звука встаёт сбоку от карточки, чтобы карточке досталась вся высота. */
@media (max-height: 560px) and (orientation: landscape) {
  .ig-top { padding: 6px 56px 0 16px; }
  .ig-kind { display: none; }
  .ig-title { font-size: 1.05rem; }
  .ig-count { font-size: .85rem; padding: 2px 10px; }
  .kc-stage { padding: 4px 12px; }
  .kc-table { --w: min(400px, 38vw, calc((100dvh - 118px) / 1.27)); gap: clamp(20px, 4vw, 56px); }
  .kc-side { flex-direction: row; gap: 16px; }
  .kc-card { padding: 8px 8px 4px; border-radius: 14px; }
  .kc-say { width: 56px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .kc-in-next, .kc-in-prev { animation: none; }
  .ig-go, .kc-deck { transition: none; }
}

/* Нижняя панель на узком экране: кнопки шаблона ужимаются между меню и значками. */
@media (max-width: 760px) {
  .ig-bar { gap: 8px; padding: 6px 12px calc(12px + env(safe-area-inset-bottom)); }
  .ig-ico { width: 42px; height: 42px; padding: 7px; }
  .ig-side { gap: 6px; }
  .ig-main { gap: 6px; min-width: 0; }
  .ig-btn { min-width: 0; height: 46px; padding: 0 12px; font-size: 1rem; }
  .ig-menu-box { left: 12px; min-width: 230px; max-width: calc(100% - 24px); bottom: calc(68px + env(safe-area-inset-bottom)); }
  .ig-menu-box button { padding: 10px 16px; font-size: 1.1rem; }
  .ig-menu-h { margin: 2px 16px 4px; }
  .ig-menu-t { padding-top: 70px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .ig-bar { padding: 2px 12px calc(6px + env(safe-area-inset-bottom)); }
  .ig-ico { width: 38px; height: 38px; padding: 6px; }
  .ig-btn { height: 38px; font-size: 1rem; }
}
