/* Фирменный шрифт студии: Comfortaa, SIL OFL (см. fonts/OFL.txt).
   Подключается локально — внешние запросы на Яндекс Играх запрещены. */
@font-face {
  font-family: 'Comfortaa';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../fonts/comfortaa-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Comfortaa';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../fonts/comfortaa-latin.woff2) format('woff2');
  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: 'Comfortaa';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(../fonts/comfortaa300-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Comfortaa';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(../fonts/comfortaa300-latin.woff2) format('woff2');
  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 {
  --banner-h: 0px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;            /* на iOS убирает «резинку» и прыжки адресной строки */
  inset: 0;
  -webkit-touch-callout: none;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* Замер системной безопасной зоны снизу (полоска Home на iPhone). */
.seo-copy {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#safe-probe {
  position: fixed;
  left: 0; bottom: 0;
  width: 0;
  height: env(safe-area-inset-bottom, 0px);
  pointer-events: none;
}

#board {
  display: block;
  position: absolute;
  inset: 0;
  touch-action: none;         /* поле не скроллим и не зумим — только игровые тапы */
}

/* ------------------------------------------------------------- верхняя панель */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  padding-top: max(6px, env(safe-area-inset-top));
  z-index: 12;                    /* выше оверлея: профиль доступен в меню и паузе */
}

#turn-label {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}
#turn-label .dot {
  width: 14px; height: 14px; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.16) inset, 0 1px 2px rgba(120,105,80,.25);
  flex: none;
}
#turn-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
#turn-label em {
  font-style: normal;
  font-weight: 500;
  color: var(--text-soft);
  opacity: .85;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#turn-label em::before { content: '· '; }

.icon-btn {
  width: 38px; height: 38px;
  flex: none;
  border: none;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s ease, opacity .12s ease;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.muted { opacity: .5; }
.icon-btn.muted #wave { display: none; }
.icon-btn[hidden] { display: none; }

.chat-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
#btn-chat { position: relative; }

#chat-panel {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(10px + var(--safe-b) + var(--banner-h, 0px));
  width: min(420px, calc(100% - 20px));
  z-index: 11;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 10px 10px 8px;
}
#chat-panel[hidden] { display: none; }
.chat-feed {
  max-height: 88px;
  overflow-y: auto;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text);
}
.chat-line { margin-bottom: 4px; line-height: 1.35; }
.chat-line b { font-weight: 700; margin-right: 4px; }
.chat-empty { color: var(--text-soft); text-align: center; padding: 6px 0; }
.chat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.chat-grid button {
  border: none;
  border-radius: 12px;
  min-height: 44px;
  padding: 8px 6px;
  background: #F1EBDF;
  color: var(--text);
  font: 600 13px inherit;
  cursor: pointer;
}
.chat-grid button:active { transform: scale(.96); }
.chat-mute {
  display: block;
  width: 100%;
  margin-top: 8px;
  border: none;
  background: transparent;
  color: var(--text-soft);
  font: 600 13px inherit;
  min-height: 36px;
  cursor: pointer;
}

@media (orientation: landscape) and (max-height: 500px) {
  #chat-panel {
    left: auto;
    right: max(10px, var(--safe-r));
    transform: none;
    width: min(340px, 46vw);
    bottom: calc(8px + var(--safe-b));
  }
  .chat-grid button { min-height: 38px; font-size: 12px; padding: 6px 4px; }
}

/* ------------------------------------------------------------- модальные окна */
#overlay {
  position: absolute; inset: 0;
  padding-bottom: calc(16px + var(--banner-h, 0px));
  background: rgba(246, 242, 234, 0.82);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  z-index: 10;
  animation: fade .18s ease;
}
#overlay.hidden { display: none; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.97) } to { opacity: 1; transform: none } }

#modal {
  width: min(500px, 100%);
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 20px 18px;
  animation: pop .2s ease;
}

#modal h2 {
  margin: 0 0 14px;
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  letter-spacing: .2px;
}

#modal-body { font-size: 15px; line-height: 1.5; color: var(--text-soft); }
#modal-body ul { padding-left: 18px; margin: 6px 0; }
#modal-body li { margin-bottom: 7px; }

#modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  position: sticky;          /* главная кнопка не уезжает за нижний край */
  bottom: 0;
  padding-bottom: 4px;
  background: linear-gradient(to bottom, rgba(255, 253, 247, 0), var(--panel) 26%);
}

#modal-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  position: sticky;
  margin: 14px -8px 0;
  padding: 7px 4px 5px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  z-index: 2;
}
#modal-nav[hidden] { display: none; }

#modal-language {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: sticky;
  bottom: 0;
  margin: 0 -8px -8px;
  padding: 3px 8px calc(3px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--panel);
  z-index: 3;
}
#modal-language[hidden] { display: none; }
#modal-language button {
  min-width: 44px;
  min-height: 44px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  font: 600 10px/1.1 inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
}
#modal-language button.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
#modal-language span { font-size: 19px; line-height: 1; }
#modal-language b { display: none; }

#modal-nav button {
  min-width: 0;
  min-height: 52px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  font: 600 10px/1.1 inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
#modal-nav button.on { color: var(--accent-strong); background: var(--accent-soft); }
#modal-nav span, #modal-nav svg { display: block; width: 21px; height: 21px; }
#modal-nav b { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

body.menu-screen #topbar { visibility: hidden; pointer-events: none; }
body.menu-screen #overlay { background: rgba(243, 241, 236, .94); }
body.menu-screen #modal { max-height: calc(100% - 12px); }

.page-intro {
  margin: 0 0 16px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.5;
}
.home-page, .mode-picker { display: grid; gap: 10px; }
.menu-card {
  width: 100%;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 38px 1fr 14px;
  align-items: center;
  gap: 12px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.menu-card.primary { border-color: var(--accent); background: var(--accent-soft); }
.menu-card-icon {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--surface);
  color: var(--accent-strong);
}
.menu-card-icon svg { width: 22px; height: 22px; }
.menu-card b, .menu-card small { display: block; }
.menu-card b { font-size: 16px; margin-bottom: 3px; }
.menu-card small { color: var(--text-soft); font-size: 12px; font-weight: 500; line-height: 1.35; }
.menu-card > i { font-style: normal; font-size: 25px; color: var(--text-soft); }
.progress-peek {
  width: 100%;
  margin-top: 4px;
  min-height: 58px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  display: grid;
  grid-template-columns: 1fr auto 12px;
  align-items: center;
  gap: 14px;
  text-align: left;
  font: inherit;
}
.progress-peek span:nth-child(2) { text-align: right; }
.progress-peek small, .progress-peek b { display: block; }
.progress-peek small { color: var(--text-soft); font-size: 11px; }
.progress-peek b { font-size: 13px; margin-top: 2px; }
.progress-peek i { font-style: normal; font-size: 21px; color: var(--text-soft); }
.settings-note { margin: 4px 0 0; color: var(--text-soft); font-size: 12px; text-align: center; }

.btn {
  border: none;
  border-radius: 16px;
  padding: 15px 22px;
  min-height: 52px;
  width: 100%;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  background: #F1EBDF;
  color: var(--text);
  cursor: pointer;
  transition: transform .12s ease, background .15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-ico {
  width: 22px; height: 22px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-ico svg { width: 22px; height: 22px; display: block; }
.btn-lab { line-height: 1.2; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(232,162,79,.35); }
.btn.ghost { background: transparent; color: var(--text-soft); }
.btn:disabled {
  opacity: .42;
  cursor: default;
  pointer-events: none;
  box-shadow: none;
  transform: none;
  filter: none;
}

/* ------------------------------------------------------------- настройки партии */
.row { margin-bottom: 14px; }
.row-label { font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 12px 10px;
  min-height: 46px;
  background: #F1EBDF;
  color: var(--text-soft);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .1s ease;
}
.seg button:active { transform: scale(.96); }
.seg button.on { background: var(--accent); color: #fff; }
.seg:has(button:nth-child(3)) button { font-size: 13px; padding: 11px 6px; }

.match-rating-hint {
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  margin: -4px 0 12px;
}
.match-lobby { margin-top: 2px; }
.match-seats { display: flex; flex-direction: column; gap: 8px; }
.match-seat {
  display: flex; align-items: center; gap: 10px;
  background: #F7F3EA;
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 48px;
  opacity: .55;
}
.match-seat.on { opacity: 1; }
.match-seat .dot { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.match-who { display: flex; flex-direction: column; min-width: 0; }
.match-who b { color: var(--text); font-size: 15px; font-weight: 700; }
.match-who em { font-style: normal; font-size: 12px; color: var(--text-soft); }
.match-note {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-soft);
}

.rating-card {
  background: #F7F3EA;
  border-radius: 14px;
  padding: 14px 12px 12px;
  text-align: center;
  margin-bottom: 12px;
}
.rating-num {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
  color: var(--text);
}
.rating-label { font-size: 12px; font-weight: 700; color: var(--text-soft); margin-top: 4px; }
.rating-meta { font-size: 12px; color: var(--text-soft); margin-top: 6px; }

.score-delta { margin-left: 8px; font-weight: 700; }
.score-delta.up { color: #6A8F5A; }
.score-delta.down { color: #C45C48; }

.bot-names { margin-top: 2px; }
.bot-names .opt { font-weight: 400; font-size: 12px; opacity: .65; }
.bot-name-row { display: flex; gap: 6px; }
.bot-name-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: #F7F3EA;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  min-height: 40px;
  font: 600 13px inherit;
  text-align: center;
}
.bot-name-row input::placeholder { color: var(--text-soft); font-weight: 500; opacity: .7; }
.bot-name-row input:focus { outline: 2px solid rgba(232, 162, 79, .45); outline-offset: 1px; }

.result-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.result-row {
  display: flex; align-items: center; gap: 10px;
  background: #F7F3EA;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 15px;
  color: var(--text);
}
.result-row .dot { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.result-row .place { font-weight: 700; width: 22px; }
.result-row .score { margin-left: auto; color: var(--text-soft); font-size: 13px; }

/* ------------------------------------------------------------- загрузчик */
#loader {
  position: absolute; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  z-index: 20;
  transition: opacity .3s ease;
}
#loader.hide { opacity: 0; pointer-events: none; }
.loader-title { font-size: 22px; font-weight: 700; letter-spacing: 1px; color: var(--text-soft); }
.spinner {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ------------------------------------------------------------- всплывашка */
#toast {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  background: rgba(90, 83, 70, .92);
  color: #fff;
  padding: 9px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  z-index: 8;
  pointer-events: none;
  animation: pop .18s ease;
}

/* ------------------------------------------------------------- брендирование */
.brand-lockup {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-bottom: 14px;
}
.brand-lockup .brand-text { text-align: center; font-size: 30px; }
.brand-game {
  font-family: var(--font-brand);
  font-weight: 700;
  color: var(--text);
  line-height: 1.05;
  letter-spacing: .01em;
  font-size: 1em;
}

.brand-lockup.lg .brand-text { font-size: 40px; }
.brand-lockup.sm .brand-text { font-size: 22px; }

.brand-footer {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 16px;
  opacity: .9;
}
.brand-footer i {
  height: 1px; width: 26px; flex: none;
  background: linear-gradient(90deg, transparent, var(--line));
}
.brand-footer i:last-child { background: linear-gradient(90deg, var(--line), transparent); }
.brand-footer span {
  font-family: var(--font-brand);
  font-weight: 300;
  font-size: 11.5px;
  letter-spacing: .26em;
  text-indent: .26em;
  color: var(--brand-soft);
  white-space: nowrap;
}


#modal h2.brand-title {
  font-family: var(--font-brand);
  letter-spacing: .01em;
}

/* ------------------------------------------------------------- личный кабинет */
.profile { font-size: 14px; }

.prof-head {
  display: flex; align-items: center; gap: 10px;
  background: #F7F3EA;
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.prof-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: #EADFC8 center/cover no-repeat;
  color: var(--brand);
  font-family: var(--font-brand); font-weight: 700; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.prof-who { flex: 1; min-width: 0; }
.prof-name { font-weight: 700; color: var(--text); font-size: 15px; }
.prof-sync { font-size: 12px; color: var(--text-soft); }
.btn.small { padding: 10px 14px; font-size: 14px; border-radius: 12px; flex: none; min-height: 44px; width: auto; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button {
  flex: 1; border: none; border-radius: 12px; padding: 10px 4px;
  min-height: 44px;
  background: #F1EBDF; color: var(--text-soft);
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.tabs button.on { background: var(--accent); color: #fff; }

.tab-content { min-height: 180px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tile { background: #F7F3EA; border-radius: 12px; padding: 10px 8px; text-align: center; }
.tile-value {
  font-family: var(--font-brand); font-weight: 700;
  font-size: 19px; color: var(--text); line-height: 1.15;
}
.tile-label { font-size: 11px; color: var(--text-soft); margin-top: 3px; line-height: 1.25; }

.bars { margin-bottom: 14px; }
.bars-title { font-size: 12px; font-weight: 700; color: var(--text-soft); margin-bottom: 6px; }
.bars-note { font-size: 11px; color: var(--text-soft); opacity: .8; margin-top: 4px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.bar-key { width: 16px; font-size: 12px; color: var(--text-soft); text-align: center; flex: none; }
.die-ico, .die-num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 1px 2px rgba(120, 105, 80, 0.22));
}
.die-ico svg { display: block; }
.die-num {
  background: #FFFDF7;
  border: 1.35px solid #E3DCCF;
  border-radius: 6px;
  color: #C45C48;
  font-family: var(--font-brand);
  font-weight: 700;
  line-height: 1;
  box-sizing: border-box;
}
.bar-track {
  position: relative; flex: 1; height: 14px;
  background: #F1EBDF; border-radius: 7px; overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 7px; transition: width .4s ease; }
.bar-mark {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: rgba(90,83,70,.35);
}
.bar-val { width: 34px; text-align: right; font-size: 12px; color: var(--text-soft); flex: none; }

.kv-list, .rec-list { display: flex; flex-direction: column; gap: 6px; }
.kv-row, .rec-list div {
  display: flex; justify-content: space-between; align-items: center;
  background: #F7F3EA; border-radius: 10px; padding: 8px 12px;
  font-size: 14px; color: var(--text-soft);
}
.kv-row b, .rec-list b { color: var(--text); font-family: var(--font-brand); }

.hist-list { display: flex; flex-direction: column; gap: 6px; }
.hist-row {
  display: flex; align-items: center; gap: 10px;
  background: #F7F3EA; border-radius: 12px; padding: 8px 10px;
}
.hist-place {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-style: normal; font-weight: 700; color: #fff; font-size: 13px;
}
.hist-main { flex: 1; min-width: 0; }
.hist-title {
  font-size: 13px; color: var(--text); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hist-sub { font-size: 11px; color: var(--text-soft); }
.hist-num { font-size: 13px; color: var(--text-soft); font-family: var(--font-brand); }

.empty { text-align: center; color: var(--text-soft); font-size: 14px; padding: 26px 10px; }

.login-hint { font-size: 13px; color: var(--text-soft); text-align: center; margin: 4px 0 2px; }

.ach-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ach-card {
  background: #F7F3EA;
  border-radius: 14px;
  padding: 10px 10px 11px;
  opacity: .42;
}
.ach-card.on { opacity: 1; background: #F3E6C8; }
.ach-card b {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 3px;
}
.ach-card span { font-size: 11px; color: var(--text-soft); line-height: 1.35; }
.ach-new {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 10px 0 4px;
}
.ach-chip {
  background: #F3E6C8;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
}

.tabs { flex-wrap: wrap; }
.tabs button { flex: 1 1 22%; min-width: 0; }

/* ------------------------------------------------------ интерактивные правила */
.rules-guide { display: grid; gap: 8px; }
.rules-guide { user-select: text; -webkit-user-select: text; }
.rule-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: clip;
}
.rule-section summary {
  min-height: 52px;
  padding: 10px 12px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  cursor: pointer;
}
.rule-section summary::-webkit-details-marker { display: none; }
.rule-section summary > span {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--text-soft);
  font: 700 12px var(--font-brand);
}
.rule-section summary::after { content: '+'; margin-left: auto; color: var(--text-soft); font-size: 20px; }
.rule-section[open] summary::after { content: '−'; }
.rule-content { padding: 0 12px 13px 48px; }
.rule-content p { margin: 8px 0 0; font-size: 13px; line-height: 1.5; color: var(--text-soft); }
.rule-diagram {
  min-height: 48px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--text-soft);
}
.rule-diagram em, .rule-diagram i {
  width: 25px; height: 25px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid #cf665f; background: #f6d9d7; font-style: normal; font-weight: 700;
}
.rule-diagram i { border-radius: 7px; background: var(--panel); border-color: var(--line); color: var(--text); }
.rule-diagram strong { color: var(--accent-strong); font-size: 13px; }
.rule-diagram.barrier em + em { margin-left: -17px; }
.rule-diagram.barrier b { width: 32px; border-top: 2px dashed var(--text-soft); }
.rule-diagram.capture i { border-color: #6fa5d8; background: #e0ebf7; }
.rule-diagram.finish span, .rule-diagram.route span { font-size: 28px; color: var(--accent); }

button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(148, 93, 19, .42);
  outline-offset: 2px;
}

/* --------------------------------------------------- мобильные уточнения */

/* На пальце цель должна быть не меньше 44 px — рекомендация iOS и Android. */
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; border-radius: 13px; }
  #topbar { height: 52px; }
  .btn { min-height: 54px; padding: 16px 24px; font-size: 17px; }
  .seg button { min-height: 48px; padding: 14px 10px; }
  .tabs button { min-height: 46px; padding: 12px 4px; }
  .bot-name-row input { min-height: 44px; }
  #turn-label { font-size: 14px; }
}

/* Узкие телефоны: чуть компактнее модалки, цели пальца не ужимаем. */
@media (max-width: 360px), (max-height: 640px) {
  #modal { padding: 16px 14px 14px; border-radius: 18px; }
  #modal h2 { font-size: 20px; margin-bottom: 10px; }
  .brand-lockup.lg .brand-text { font-size: 32px; }
  .row { margin-bottom: 10px; }
  .btn { min-height: 50px; padding: 14px 18px; font-size: 16px; }
  #modal-actions { gap: 8px; margin-top: 12px; }
  .tiles { gap: 6px; }
  .tile-value { font-size: 17px; }
}

/* Планшеты: модалка чуть шире, полям дышать. */
@media (min-width: 720px) {
  #modal { width: min(480px, 100%); padding: 26px 24px 22px; }
  #modal h2 { font-size: 26px; }
  .brand-lockup.lg .brand-text { font-size: 44px; }
  .btn { min-height: 54px; padding: 16px 24px; font-size: 17px; }
}

/* Десктоп: курсор-ховер, модалка не растягивается на всю ширину. */
@media (min-width: 1100px) {
  #modal { width: min(480px, 92%); }
  .icon-btn:hover { filter: brightness(0.97); }
  .btn:hover:not(:disabled) { filter: brightness(0.97); }
}

/* Уважение к системной настройке «меньше движения». */
@media (prefers-reduced-motion: reduce) {
  #overlay, #modal, #toast { animation: none !important; }
  .spinner { animation-duration: 2.4s; }
  .bar-fill { transition: none; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* ------------------------------------- низкие экраны: ландшафт телефона */
/* Главное меню должно помещаться целиком: кнопка «Играть» не уезжает за край. */
@media (max-height: 460px) {
  #modal { padding: 12px 14px 0; border-radius: 16px; }
  #modal h2 { font-size: 19px; margin-bottom: 8px; }
  .brand-lockup { margin-bottom: 8px; }
  .brand-lockup.lg .brand-game { font-size: 26px; }
  .brand-lockup.lg .brand-studio { font-size: 11px; }
  .row { margin-bottom: 8px; }
  .row-label { font-size: 11px; margin-bottom: 4px; }
  .seg { gap: 5px; }
  .seg button { padding: 9px 4px; font-size: 13px; }
  .btn { padding: 10px 14px; font-size: 15px; }
  #modal-body { font-size: 13px; }
  .brand-footer { display: none; }
  /* панель действий всегда на виду, даже если содержимое прокручивается */
  #modal-actions {
    position: sticky;
    bottom: 0;
    gap: 6px;
    margin-top: 8px;
    padding: 8px 0 10px;
    background: linear-gradient(to bottom, rgba(255, 253, 247, 0), var(--panel) 30%);
  }
}

/* Ландшафт телефона: настройки в две колонки — по высоте влезает без прокрутки. */
@media (max-height: 460px) and (orientation: landscape) {
  #modal { width: min(560px, 100%); }
  .menu-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 14px;
    align-items: start;
  }
  .menu-body .brand-lockup { grid-column: 1 / -1; }
}
