/* К-247 — страница «Игры» (games.html, правки 06–07.11, И1). Поверх styles.css: те же токены (графит, бумага, фирменный жёлтый)
   и шрифты сайта. Цели — не меньше 44 × 44, промежутки — не меньше 8 px; на 400 px всё в ширину окна без прокрутки вбок.
   Размер поля canvas задаёт games.js (свойства через CSSOM — под ширину блока и высоту окна). */
/* логотип в шапке страницы игр — цель не меньше 44 px в высоту (общая шапка сайта styles.css .mark — 38 px) */
.topbar .mark { min-height: 44px; justify-content: center; }
.gm { min-height: 70vh; padding: clamp(104px, 15vh, 140px) var(--pad) clamp(40px, 7vh, 88px); }
/* раздел «Игры» кабинета (правки 11.11; games.js — .gm-embed): страница во фрейме кабинета — без шапки и подвала сайта и без
   вступления (заголовок раздела даёт кабинет), отступы меньше */
.gm-embed .topbar, .gm-embed .foot, .gm-embed [data-g-intro] { display: none; }
.gm-embed .gm, .gm-embed .gm--play { min-height: 0; padding: var(--s3) var(--s3) var(--s4); }
/* открыта игра: заголовок страницы скрыт, поле ближе к шапке — на 1366 × 900 поле, кнопки и действия в одном экране */
.gm--play { padding-top: 88px; }
.gm__t { margin-bottom: var(--s3); }
.gm__lead { opacity: 0.8; margin-bottom: var(--s5); max-width: 60ch; }

/* ---------- выбор игры ---------- */
.gm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: var(--s4); max-width: 1240px; }
.gm-card {
  display: grid; grid-template-rows: auto auto 1fr auto; gap: var(--s2); align-content: start;
  min-height: 44px; padding: var(--s4); border-radius: 18px; background: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(46, 45, 43, 0.14);
  transition: box-shadow 240ms var(--e), transform 240ms var(--e);
}
.gm-card:hover { box-shadow: inset 0 0 0 2px var(--ink); transform: translateY(-2px); }
.gm-card:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.gm-card__ic { width: 52px; height: 52px; padding: 8px; border-radius: 14px; background: var(--brand); color: var(--ink); }
.gm-card__t {
  font-family: "Wix Madefor Display", system-ui, sans-serif; font-weight: 500;
  font-size: clamp(20px, 1.8vw, 24px); line-height: 1.1; letter-spacing: -0.02em;
}
.gm-card__d { font-size: 14px; line-height: 1.45; opacity: 0.75; }
.gm-card__rec {
  justify-self: start; margin-top: var(--s2); padding: 3px 12px; border-radius: 999px;
  background: var(--ink); color: var(--paper); font-size: 13px; font-variant-numeric: tabular-nums;
}

/* ---------- игра ---------- */
.gm-stage { max-width: 780px; margin: 0 auto; }
.gm-stage__head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4);
  padding: var(--s3) var(--s4); border-radius: 16px 16px 0 0; background: var(--ink); color: var(--paper);
}
.gm-stage__t { font-size: clamp(22px, 2.6vw, 30px); line-height: 1.1; }
.gm-score { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); max-width: none; font-size: 14.5px; }
.gm-score b { color: var(--brand); font-weight: 600; font-variant-numeric: tabular-nums; }
.gm-stage__box { padding: var(--s3); border-radius: 0 0 16px 16px; background: var(--graphite); }
.gm-screen { position: relative; width: fit-content; max-width: 100%; margin: 0 auto; }
.gm-screen--dom { width: 100%; min-height: 380px; }
.gm-canvas { display: block; max-width: 100%; border-radius: 10px; touch-action: none; user-select: none; -webkit-user-select: none; }
.gm-canvas:focus { outline: none; }
.gm-canvas:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* заставка, пауза и итог — поверх поля */
.gm-over {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s3);
  padding: var(--s4); border-radius: 10px; text-align: center;
  background: rgba(46, 45, 43, 0.86); color: var(--paper);
}
.gm-over__t { font-family: "Wix Madefor Display", system-ui, sans-serif; font-weight: 500; font-size: clamp(22px, 3vw, 32px); line-height: 1.1; letter-spacing: -0.02em; }
.gm-over__d { max-width: 38ch; font-size: 15px; line-height: 1.5; opacity: 0.88; }
.gm-over__r { font-weight: 600; color: var(--brand); }
.gm-over .btn--solid { background: var(--brand); color: var(--ink); }
.gm-over .btn--solid .btn__fill { background: var(--paper); }
.gm-over .btn--solid:hover .btn__label { color: var(--ink); }
.btn:focus-visible { outline: 3px solid currentColor; outline-offset: 3px; }

/* кнопки на экране: в ряд или крестом; фокус остаётся на поле (games.js) */
.gm-pad { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: var(--s3); }
.gm-pad--cross {
  display: grid; grid-template-columns: repeat(3, 64px); grid-template-areas: ". up ." "left down right";
  justify-content: center; gap: 10px;
}
.gm-pad--cross .gm-key--up { grid-area: up; }
.gm-pad--cross .gm-key--left { grid-area: left; }
.gm-pad--cross .gm-key--down { grid-area: down; }
.gm-pad--cross .gm-key--right { grid-area: right; }
.gm-key {
  display: inline-grid; place-items: center; width: 60px; height: 56px; padding: 0;
  border: 0; border-radius: 14px; background: var(--ink); color: var(--brand); cursor: pointer;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: background 160ms var(--e), transform 160ms var(--e);
}
.gm-pad--cross .gm-key { width: 64px; }
.gm-key:hover { background: #000000; }
.gm-key:active { transform: translateY(1px); }
.gm-key:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.gm-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2) var(--s3); margin-top: var(--s4); }
.gm-help { max-width: 64ch; margin: var(--s4) auto 0; font-size: 13.5px; line-height: 1.55; text-align: center; opacity: 0.72; }

/* ---------- викторина ---------- */
.gm-dom { min-height: 380px; padding: clamp(16px, 3vw, 28px); border-radius: 10px; background: var(--paper); color: var(--ink); }
.gm-q__n { font-size: 11.5px; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.6; }
.gm-q__t { margin: var(--s2) 0 var(--s4); font-size: clamp(19px, 2.2vw, 24px); line-height: 1.2; }
.gm-q__opts { display: grid; gap: 10px; }
.gm-opt {
  min-height: 48px; padding: 10px 16px; border: 0; border-radius: 12px;
  background: #FFFFFF; color: var(--ink); box-shadow: inset 0 0 0 1px rgba(46, 45, 43, 0.22);
  font: inherit; font-size: 15px; line-height: 1.35; text-align: left; cursor: pointer;
  transition: box-shadow 160ms var(--e), background 160ms var(--e);
}
.gm-opt:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--ink); }
.gm-opt:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.gm-opt:disabled { cursor: default; opacity: 0.62; }
.gm-opt.is-ok { opacity: 1; background: #DDEFC9; box-shadow: inset 0 0 0 2px #5E9E3A; }
.gm-opt.is-bad { opacity: 1; background: #F6D5CF; box-shadow: inset 0 0 0 2px #D23B2C; }
.gm-q__why { margin-top: var(--s3); max-width: none; font-size: 14.5px; line-height: 1.5; }
.gm-q__next { margin-top: var(--s4); }

@media (max-width: 700px) {
  .gm { padding-top: 96px; }
  .gm-stage__head { padding: 10px var(--s3); }
  .gm-stage__box { padding: var(--s2); }
  .gm-actions .btn { flex: 1 1 100%; }
  .gm-q__next { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .gm-card:hover { transform: none; }
}
