/* =====================================================
   app-ui.css — интерфейс приложения «Длинные нарды»
   Подключается только при body.in-app (APK/приложение)
   ===================================================== */

/* ── Токены тем ─────────────────────────────────────── */
body.in-app {
  --a-bg: #0C1220;
  --a-card: #161F2E;
  --a-border: #22304A;
  --a-text: #FFFFFF;
  --a-sub: #93A0B6;
  --a-green: #3DDC84;
  --a-amber: #FFC21A;
  --a-amber-text: #FFC21A;
  --a-btn2: #1C2738;
  --a-btn2-text: #D2DAE8;
  --a-off: #5F6B80;
  --a-panel: #172133;
  --a-danger: #FF7A6B;
  --a-scrim: rgba(4,7,14,.62);
  --a-seg-bg: #1C2738;
  --a-seg-active: #22304A;
  --a-seg-shadow: none;
  --a-icon-bg: rgba(255,255,255,.08);
  --a-icon-color: #93A0B6;
  --a-pri-bg: linear-gradient(180deg, #FFD34D, #FFB800);
  --a-pri-text: #1B1300;
  --a-pri-shadow: 0 6px 16px -6px rgba(255,184,0,.6);
  background: var(--a-bg);
  color: var(--a-text);
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
}
body.in-app[data-theme="light"] {
  --a-bg: #E9EDF3;
  --a-card: #FFFFFF;
  --a-border: #D6DDE8;
  --a-text: #121826;
  --a-sub: #566174;
  --a-green: #11823F;
  --a-amber-text: #8A5A00;
  --a-btn2: #F1F4F8;
  --a-btn2-text: #263042;
  --a-off: #9AA4B4;
  --a-panel: #FFFFFF;
  --a-danger: #C93A2B;
  --a-scrim: rgba(18,24,38,.38);
  --a-seg-bg: #DDE3EC;
  --a-seg-active: #FFFFFF;
  --a-seg-shadow: 0 1px 4px rgba(0,0,0,.2);
  --a-icon-bg: #EEF1F6;
  --a-icon-color: #6B4500;
}

body.in-app #game { position: relative; }

/* ── Экран меню #appMenu ────────────────────────────── */
/* Лобби всех игр скрываем сразу, до JS, если APP_CONFIG уже задан */
body.in-app #lobby { display: none !important; }

/* Сплэш-экран приложения */
#appSplash {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  background: #0C1220;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
}
body.in-app #appSplash { display: flex; }
body.in-app #appSplash.hidden { display: none; }
.spl-logo { height: 36px; width: auto; }
.spl-bar { width: 160px; height: 3px; background: rgba(255,255,255,.12); border-radius: 2px; overflow: hidden; }
.spl-fill {
  height: 100%; width: 40%; background: #FFB800; border-radius: 2px;
  animation: spl-slide 1.2s ease-in-out infinite;
}
@keyframes spl-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

#appMenu {
  background: var(--a-bg);
  color: var(--a-text);
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
/* Шапка */
.am-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(16px + var(--sa-top, 0px)) 14px 0;
  min-width: 0;
}
.am-logo { min-width: 0; flex-shrink: 1; }
.am-header-right { flex-shrink: 0; }
.am-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.am-wordmark {
  height: 24px;
  width: auto;
  display: block;
}
.am-badge {
  font-size: 13px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--a-btn2);
  color: var(--a-amber-text);
}
.am-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.am-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 10px 0 4px;
  border-radius: 999px;
  background: transparent;
  border: none;
  color: var(--a-text);
  font-weight: 800;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.am-pill #amNick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.am-avatar { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--a-amber); background: var(--a-btn2); overflow: visible; position: relative; }
/* ≤ 360 px — скрываем ник, остаётся аватар + шестерёнка (макет 02) */
@media (max-width: 400px) {
  .am-pill #amNick { display: none; }
  .am-pill { padding: 0; }
}
/* ≤ 320 px — убираем плашку «Нарды», лого 20 px (макет 02) */
@media (max-width: 340px) {
  .am-badge { display: none; }
  .am-wordmark { height: 20px; }
}
.am-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--a-btn2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  overflow: hidden;
}
.am-avatar svg, .am-avatar .ico { display: block; }
.am-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--a-card);
  border: 1.5px solid var(--a-border);
  color: var(--a-btn2-text);
  font-family: inherit;
  cursor: pointer;
  flex: none;
}
/* Контент */
.am-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px calc(24px + var(--sa-bottom, 0px));
}
/* Переключатель Длинные / Короткие */
.am-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--a-seg-bg);
}
.am-seg-btn {
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  font-weight: 800;
  font-size: 15px;
  background: transparent;
  color: var(--a-sub);
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.am-seg-btn[aria-pressed="true"] {
  background: var(--a-seg-active);
  color: var(--a-text);
  box-shadow: var(--a-seg-shadow, none);
}
/* Карточка «Продолжить» */
.am-continue-wrap { display: flex; gap: 8px; align-items: stretch; }
.am-continue {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-height: 62px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--a-card);
  border: 1.5px solid var(--a-border);
  cursor: pointer;
  font-family: inherit;
  color: var(--a-text);
  text-align: left;
}
.am-new-game-btn {
  min-width: 72px; border-radius: 16px; border: 1.5px solid var(--a-border);
  background: var(--a-card); color: var(--a-text); font-family: inherit;
  font-size: 14px; font-weight: 700; cursor: pointer; padding: 0 12px;
}
.am-continue-thumb {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--a-btn2);
  flex: none;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--a-sub);
}
.am-continue-info { flex: 1; min-width: 0; }
.am-continue-title { font-size: 15px; font-weight: 800; }
.am-continue-sub { font-size: 12px; color: var(--a-sub); font-weight: 600; margin-top: 2px; }
/* Подзаголовок секции */
.am-section-label {
  margin: 6px 0 -4px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--a-sub);
}
/* Режимы игры */
.am-modes { display: flex; flex-direction: column; gap: 8px; }
.am-mode {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 62px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--a-card);
  border: 1.5px solid var(--a-border);
  color: var(--a-text);
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
  transition: opacity .1s;
}
.am-mode:active { opacity: .8; }
.am-mode-primary {
  background: var(--a-pri-bg);
  border-color: transparent;
  color: var(--a-pri-text);
  box-shadow: var(--a-pri-shadow);
}
.am-mode-icon {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(27,19,0,.12);
  color: var(--a-pri-text);
}
.am-mode:not(.am-mode-primary) .am-mode-icon {
  background: var(--a-icon-bg);
  color: var(--a-icon-color);
}
.am-mode-texts { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.am-mode-title { font-size: 17px; font-weight: 800; }
.am-mode-sub { font-size: 13px; font-weight: 600; color: rgba(27,19,0,.75); margin-top: 2px; }
.am-mode:not(.am-mode-primary) .am-mode-sub { color: var(--a-sub); }
.am-mode-chevron { flex: none; opacity: .6; color: inherit; }
/* Вторичные кнопки */
/* Вкладки по макету 02: иконка сверху, подпись снизу, крупная кнопка */
.am-secondary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.am-sec-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 72px;
  padding: 10px 4px;
  border-radius: 16px;
  background: var(--a-card);
  border: 1.5px solid var(--a-border);
  color: var(--a-text);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  min-width: 0;
  white-space: nowrap;
}
.am-sec-btn svg, .am-sec-btn .ico { flex: none; color: var(--a-amber); width: 24px; height: 24px; }
/* Баннер */
.am-banner {
  height: 50px;
  border: 1.5px dashed var(--a-sub);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--a-sub);
}
/* Нижняя панель выбора уровня */
#amLevelSheet {
  position: fixed;
  inset: 0;
  background: var(--a-scrim);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}
#amLevelSheet .am-sheet-body {
  width: 100%;
  background: var(--a-panel);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px calc(16px + var(--sa-bottom, 0px));
}
.am-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--a-border);
  margin: 0 auto 16px;
}
.am-sheet-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 12px;
  text-align: center;
}
.am-level-btns { display: flex; flex-direction: column; gap: 8px; }
.am-level-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-height: 54px;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--a-card);
  border: 1.5px solid var(--a-border);
  color: var(--a-text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.am-level-btn[aria-pressed="true"],
.am-level-btn.am-level-active {
  border-color: var(--a-amber);
  box-shadow: 0 0 0 1px var(--a-amber);
}
.am-level-main { display: flex; align-items: center; justify-content: space-between; }
.am-level-chip { font-size: 12px; font-weight: 600; background: var(--a-amber); color: #1B1300; padding: 2px 8px; border-radius: 20px; }
.am-level-desc { font-size: 13px; font-weight: 400; color: var(--a-sub); }
.am-level-hint { font-size: 13px; color: var(--a-sub); }
.am-start-btn {
  margin-top: 12px; width: 100%; min-height: 50px; border-radius: 14px; border: none;
  background: var(--a-pri-bg); color: var(--a-pri-text);
  font-family: inherit; font-size: 16px; font-weight: 800; cursor: pointer;
}

/* ── Колонка игры body.in-app ───────────────────────── */
body.in-app #game .bar {
  background: var(--a-card) !important;
  border: 1.5px solid var(--a-border) !important;
  backdrop-filter: none;
  color: var(--a-text);
  border-radius: 14px;
}
body.in-app #game .bar.active {
  border-color: var(--a-amber) !important;
}
body.in-app #game .bar .nick { color: var(--a-text); font-size: 14px; font-weight: 800; }
body.in-app #game .bar .rate { color: var(--a-sub); font-size: 11.5px; }
body.in-app #game .bar .sub { color: var(--a-sub); font-size: 11.5px; }
body.in-app #game .bar::before {
  width: 38px; height: 38px;
  background-color: var(--a-btn2);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2393A0B6'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21a8 8 0 0 1 16 0z'/%3E%3C/svg%3E");
  border-radius: 50%;
  box-shadow: none;
}
body.in-app #game .status {
  background: var(--a-card) !important;
  border: 1.5px solid var(--a-border) !important;
  backdrop-filter: none;
  border-radius: 14px;
  gap: 6px;
  padding: 9px 10px;
}
body.in-app #game .status #dice {
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
}
body.in-app #game .status #dice .die {
  width: 34px;
  height: 34px;
  font-size: 17px;
}
body.in-app #game .status #turnInfo {
  color: var(--a-amber);
  font-weight: 800;
  font-size: 12px;
}
body.in-app #game .status #timer {
  font-size: 20px;
  font-weight: 800;
  color: var(--a-text);
  padding-left: 0;
  background: none;
}
body.in-app #game .actions { background: none !important; border: 0; }
body.in-app #game .actions button {
  min-height: 44px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 15px;
  font-family: inherit;
  background: var(--a-btn2);
  border: 1.5px solid var(--a-border);
  color: var(--a-btn2-text);
  padding: 0 10px;
}
body.in-app #game .actions #btnRoll {
  background: var(--a-pri-bg);
  border-color: transparent;
  color: var(--a-pri-text);
  box-shadow: var(--a-pri-shadow);
  font-size: 15px;
}
body.in-app #game .actions button:disabled {
  opacity: .4;
  cursor: default;
}
/* Кнопка отмены: жёлтая обводка (2с после хода) */
body.in-app #game .actions #btnUndo.undo-timing {
  border-color: var(--a-amber);
  box-shadow: 0 0 0 1px var(--a-amber);
}
/* Бейдж на кнопке отмены */
.undo-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--a-amber);
  color: #1B1300;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
}
/* Иконки на кнопках убраны в app-режиме (не помещаются в 170px) */
body.in-app #game .actions #btnRoll,
body.in-app #game .actions #btnUndo {
  background-image: none;
  padding-left: 10px;
}
body.in-app #game .viewbtn:not(.set) { background-image: none; padding-left: 0; }
/* 3D кнопка в шестерёнке, не на экране */
body.in-app #game #btnView { display: none; }
body.in-app #game #btnSet { display: none; }

/* Нижний ряд колонки: подсказка + шестерёнка */
#appColBottom {
  display: flex;
  gap: 7px;
  grid-area: view;
}
#appColBottom #appBtnHint,
#appColBottom #appBtnGear {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
  font-family: inherit;
  background: var(--a-btn2);
  border: 1.5px solid var(--a-border);
  color: var(--a-btn2-text);
  cursor: pointer;
  gap: 6px;
}
#appColBottom #appBtnHint { flex: 1; }
#appColBottom #appBtnGear { flex: none; width: 52px; }
body.in-app #game .viewbtns { display: none; }

/* ── Шестерёнка #appGear ─────────────────────────────── */
#appGear {
  position: absolute;
  inset: 0;
  background: var(--a-scrim);
  display: flex;
  align-items: flex-end;
  z-index: 15;
}
#appGear .ag-panel {
  width: 100%;
  background: var(--a-panel);
  border-radius: 20px 20px 0 0;
  padding: 12px 16px calc(12px + var(--sa-bottom, 0px));
}
.ag-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--a-border);
  margin: 0 auto 14px;
}
.ag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  gap: 12px;
}
.ag-row-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--a-text);
}
.ag-row-sub { font-size: 13px; color: var(--a-sub); margin-top: 1px; }
.ag-divider { border: 0; border-top: 1px solid var(--a-border); margin: 4px 0; }
.ag-action {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 46px;
  gap: 10px;
  background: transparent;
  border: 0;
  padding: 6px 0;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--a-text);
  cursor: pointer;
  text-align: left;
}
.ag-action.danger { color: var(--a-danger); }
/* Маленький сегментный переключатель 3D/2D */
.ag-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--a-seg-bg);
}
.ag-seg-btn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  font-size: 13px;
  background: transparent;
  color: var(--a-sub);
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.ag-seg-btn[aria-pressed="true"] {
  background: var(--a-seg-active);
  color: var(--a-text);
  box-shadow: var(--a-seg-shadow, none);
}
/* Тема — три кнопки */
.ag-theme-btns {
  display: flex;
  gap: 4px;
}
.ag-theme-btn {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--a-btn2);
  border: 1.5px solid var(--a-border);
  color: var(--a-btn2-text);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.ag-theme-btn[aria-pressed="true"] {
  border-color: var(--a-amber);
  color: var(--a-amber-text);
}
/* Чекбокс-переключатель */
.ag-toggle {
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--a-btn2);
  border: 1.5px solid var(--a-border);
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex: none;
}
.ag-toggle::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--a-off);
  top: 1px;
  left: 1px;
  transition: left .2s, background .2s;
}
.ag-toggle[aria-checked="true"] {
  background: var(--a-amber);
  border-color: var(--a-amber);
}
.ag-toggle[aria-checked="true"]::after {
  background: #1B1300;
  left: 19px;
}

/* ── Экраны настроек / статистики / правил ─────────────────────────── */
body.in-app #appSettings,
body.in-app #appStats,
body.in-app #appRules {
  position: fixed;
  inset: 0;
  background: var(--a-bg);
  color: var(--a-text);
  font-family: 'Manrope', system-ui, sans-serif;
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.in-app #appSettings.hidden,
body.in-app #appStats.hidden,
body.in-app #appRules.hidden { display: none; }

.as-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(50px + var(--sa-top, 0px)) 12px 14px;
  flex: none;
}
.as-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: transparent;
  border: none;
  color: var(--a-text);
  cursor: pointer;
  flex: none;
}
.as-header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  color: var(--a-text);
}
.as-body {
  flex: 1;
  padding: 0 20px 40px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.as-list-card {
  border-radius: 18px;
  background: var(--a-card);
  border: 1.5px solid var(--a-border);
  overflow: hidden;
}
.as-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 10px 16px;
  box-sizing: border-box;
  border: none;
  border-bottom: 1px solid var(--a-border);
  background: transparent;
  color: var(--a-text);
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.as-row:last-child { border-bottom: none; }
.as-row-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--a-btn2);
  color: var(--a-amber-text);
}
.as-row-texts {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.as-row-title { font-size: 16px; font-weight: 700; }
.as-row-sub { font-size: 13px; font-weight: 600; color: var(--a-sub); line-height: 1.4; }
.as-chevron { flex: none; opacity: 0.5; }

/* Toggle switch 50×30 */
.as-toggle {
  position: relative;
  width: 50px;
  height: 30px;
  border-radius: 15px;
  border: none;
  cursor: pointer;
  flex: none;
  transition: background .2s;
  padding: 0;
}
.as-toggle[aria-checked="true"] { background: var(--a-amber); }
.as-toggle[aria-checked="false"] { background: #2E3B52; }
body.in-app[data-theme="light"] .as-toggle[aria-checked="false"] { background: #C5CDD9; }
.as-toggle::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  transition: left .2s;
}
.as-toggle[aria-checked="true"]::after { left: 23px; }
.as-toggle[aria-checked="false"]::after { left: 3px; }

/* Sub-screen rows */
.as-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 10px 16px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--a-border);
}
.as-sub-row:last-child { border-bottom: none; }
.as-sub-row-label { flex: 1; }
.as-sub-row-title { font-size: 16px; font-weight: 700; display: block; }
.as-sub-row-hint { font-size: 12px; font-weight: 600; color: var(--a-sub); display: block; line-height: 1.4; }

/* Speed/view segmented control */
.as-speed-seg {
  display: flex;
  gap: 4px;
  background: var(--a-btn2);
  border-radius: 12px;
  padding: 4px;
  flex: none;
}
.as-speed-btn {
  flex: 1;
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--a-sub);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.as-speed-btn[aria-pressed="true"] { background: var(--a-amber); color: #1B1300; }

/* Action link row */
.as-action-link {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--a-border);
  background: var(--a-btn2);
  color: var(--a-sub);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  flex: none;
}

/* Danger button */
.as-danger-btn {
  width: 100%;
  min-height: 52px;
  border-radius: 16px;
  border: none;
  background: var(--a-btn2);
  color: var(--a-danger);
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}

/* ── Статистика ─────────────────────────────────────────────────────── */
.ast-ring-card {
  background: var(--a-card);
  border: 1.5px solid var(--a-border);
  border-radius: 18px;
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.ast-ring { flex: none; }
.ast-ring-title { font-size: 24px; font-weight: 800; }
.ast-ring-sub { font-size: 13px; font-weight: 600; color: var(--a-sub); margin-top: 2px; }
.ast-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.ast-tile {
  background: var(--a-card);
  border: 1.5px solid var(--a-border);
  border-radius: 16px;
  padding: 14px 16px;
}
.ast-tile-val { font-size: 26px; font-weight: 800; }
.ast-tile-label { font-size: 12px; font-weight: 600; color: var(--a-sub); margin-top: 2px; }
.ast-bar-section {
  background: var(--a-card);
  border: 1.5px solid var(--a-border);
  border-radius: 18px;
  overflow: hidden;
}
.ast-bar-title { font-size: 16px; font-weight: 700; padding: 14px 16px 10px; }
.ast-bar-row { display: flex; align-items: center; gap: 10px; padding: 8px 16px; }
.ast-bar-label { font-size: 14px; font-weight: 600; width: 60px; flex: none; }
.ast-bar-track { flex: 1; height: 8px; border-radius: 4px; background: var(--a-border); overflow: hidden; }
.ast-bar-fill { height: 100%; border-radius: 4px; background: var(--a-amber); transition: width .3s; }
.ast-bar-val { font-size: 13px; font-weight: 700; color: var(--a-sub); width: 50px; text-align: right; flex: none; }
.ast-rating-note { font-size: 13px; font-weight: 600; color: var(--a-sub); line-height: 1.5; padding: 4px; margin: 0; }

/* ── Правила ────────────────────────────────────────────────────────── */
.ar-card {
  background: var(--a-card);
  border: 1.5px solid var(--a-border);
  border-radius: 18px;
  overflow: hidden;
}
.ar-card-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.ar-card-num {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--a-amber); color: #1B1300;
  font-size: 14px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.ar-card-title { font-size: 17px; font-weight: 800; }
.ar-card-text {
  font-size: 14px; font-weight: 600; line-height: 1.55;
  color: var(--a-sub); padding: 0 16px 16px; margin: 0;
}

/* ── Туториал (оверлей поверх доски) ───────────────────────────────── */
#appTutor {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}
#appTutor:not(.hidden) { pointer-events: auto; }
.at-scrim {
  position: absolute;
  inset: 0;
  background: var(--a-scrim);
}
.at-dialog {
  position: absolute;
  width: 300px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--a-panel);
  border: 1px solid var(--a-border);
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
  box-sizing: border-box;
  color: var(--a-text);
  font-family: 'Manrope', system-ui, sans-serif;
}
.at-step-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 8px;
}
.at-step-label { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--a-amber-text); }
.at-dots { display: flex; gap: 4px; }
.at-dot { display: block; height: 6px; border-radius: 3px; }
.at-dot.active { width: 18px; background: var(--a-amber); }
.at-dot.inactive { width: 6px; background: var(--a-border); }
.at-title { margin: 0 0 4px; font-size: 18px; font-weight: 800; color: var(--a-text); }
.at-text { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.45; color: var(--a-sub); }
.at-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.at-skip-btn {
  min-height: 44px; padding: 0 6px; border: none;
  background: transparent; color: var(--a-sub);
  font-family: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
}
.at-next-btn {
  min-height: 44px; padding: 0 22px; border: none; border-radius: 12px;
  background: var(--a-pri-bg); color: var(--a-pri-text);
  font-family: inherit; font-weight: 800; font-size: 15px; cursor: pointer;
}

/* ── Тост ────────────────────────────────────────────── */
.app-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--a-btn2, rgba(30,28,24,.92)); color: var(--a-text, #fff);
  border: 1.5px solid var(--a-border, transparent);
  font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 20px; z-index: 9999;
  pointer-events: none; transition: opacity .25s;
  display: flex; align-items: center; gap: 8px;
}
.app-toast.hidden { opacity: 0; }
.toast-icon {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  background: #4A9EFF; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff; font-style: normal; line-height: 1;
}

/* ── Диалог жребия ───────────────────────────────────── */
.lot-dialog {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--a-card, rgba(20,18,14,.93));
  border: 1.5px solid var(--a-border, transparent);
  color: var(--a-text, #fff); border-radius: 18px;
  padding: 18px 28px; text-align: center;
  pointer-events: none; z-index: 800; min-width: 200px;
  transition: opacity .3s; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.lot-dialog.hidden { opacity: 0; pointer-events: none; }
.lot-dice { font-size: 38px; line-height: 1; }
.lot-msg { font-size: 17px; font-weight: 700; }

/* ── Модальные окна в APP ───────────────────────────── */
body.in-app .modal .card {
  background: var(--a-card);
  border: 1.5px solid var(--a-border);
  position: relative; padding-top: 50px;
}
body.in-app #modalClose {
  background: none; border: none;
  color: var(--a-sub); font-size: 14px; font-weight: 600;
  padding: 6px 0; cursor: pointer; font-family: inherit;
}
body.in-app #modalClose:hover { color: var(--a-text); }
.modal-x {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--a-btn2); border: 1.5px solid var(--a-border);
  color: var(--a-sub); font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.modal-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--a-btn2);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 6px;
}
.modal-icon svg, .modal-icon .ico { width: 26px; height: 26px; }
.modal-icon .ico { color: var(--a-sub, #93A0B6); }

/* Список найденных игр в «Рядом» */
.near-game-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--a-btn2); border: 1.5px solid var(--a-border);
  border-radius: 12px; padding: 12px 14px; cursor: pointer;
  font: inherit; text-align: left; width: 100%; color: var(--a-text);
}
.near-game-item:hover { border-color: var(--a-amber); }
.near-dot-green { width: 8px; height: 8px; border-radius: 50%; background: var(--a-green); flex-shrink: 0; }
.near-wifi { color: var(--a-sub); flex-shrink: 0; }
.near-game-name { flex: 1; font-weight: 600; }

/* Анимация «ждём игрока» */
.near-avatars { display: flex; align-items: center; justify-content: center; gap: 0; margin: 10px 0; }
.near-av { width: 44px; height: 44px; border-radius: 50%; background: var(--a-btn2); border: 1.5px solid var(--a-border); display: flex; align-items: center; justify-content: center; }
.near-av svg, .near-av .ico { width: 22px; height: 22px; }
.near-av .ico { color: var(--a-sub, #93A0B6); }
.near-av-ghost { opacity: .45; }
.near-av-dots { display: flex; gap: 5px; padding: 0 10px; }
.near-av-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--a-border); animation: ndot .9s ease-in-out infinite alternate; }
.near-av-dot:nth-child(2) { animation-delay: .15s; }
.near-av-dot:nth-child(3) { animation-delay: .3s; }
@keyframes ndot { to { background: var(--a-amber); } }

/* ── Экран ожидания в APP ────────────────────────────── */
body.in-app .wait { background: var(--a-scrim); align-items: center; }
.wait-card {
  background: var(--a-card); border: 1.5px solid var(--a-border);
  border-radius: 18px; padding: 20px; width: 90%; max-width: 320px;
  display: flex; flex-direction: column; gap: 12px;
  position: relative; text-align: center;
  box-sizing: border-box;
}
.wait-close-x {
  position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--a-btn2); border: 1.5px solid var(--a-border);
  color: var(--a-sub); font-size: 16px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.wait-label { font-size: 13px; color: var(--a-sub); font-weight: 600; }
.wait-code { font-size: 40px; font-weight: 800; color: var(--a-amber); letter-spacing: 6px; line-height: 1; }
.wait-link-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--a-btn2); border: 1.5px solid var(--a-border);
  border-radius: 10px; padding: 10px 12px;
  cursor: pointer; text-align: left;
}
.wait-link-text { flex: 1; font-size: 13px; color: var(--a-sub); word-break: break-all; }
.wait-link-copy { flex-shrink: 0; color: var(--a-sub); }
.wait-hint { font-size: 12px; color: var(--a-sub); line-height: 1.4; }
body.in-app .wait .waitbtns { display: flex; flex-direction: column; gap: 8px; }
body.in-app .wait .waitbtns button {
  min-height: 44px; border-radius: 12px; font-weight: 800;
  font-size: 15px; font-family: inherit; display: flex;
  align-items: center; justify-content: center; gap: 6px; cursor: pointer;
}
body.in-app .wait .waitbtns .primary {
  background: var(--a-pri-bg); border: none;
  color: var(--a-pri-text); box-shadow: var(--a-pri-shadow);
}
body.in-app .wait .waitbtns .ghost {
  background: var(--a-btn2); border: 1.5px solid var(--a-border); color: var(--a-btn2-text);
}

/* ── Экран результата в APP ──────────────────────────── */
body.in-app .result .card {
  background: var(--a-card);
  border: 1.5px solid var(--a-border);
}
body.in-app .result .card h2 { margin: 0; font-size: 24px; font-weight: 800; }
body.in-app .result .card p { color: var(--a-sub); font-size: 14px; margin: 0; }
body.in-app #btnAgain {
  background: var(--a-pri-bg); border-color: transparent;
  color: var(--a-pri-text); box-shadow: var(--a-pri-shadow);
  font-weight: 800; min-height: 44px;
}
.result-icon { font-size: 52px; line-height: 1; text-align: center; }

/* ── Компактная статистика в конце партии (APP) ─────────────────────── */
body.in-app .dstat.dstat-app {
  margin-top: 10px;
  background: var(--a-card);
  border: 1.5px solid var(--a-border);
  border-radius: 18px;
  padding: 12px 14px 10px;
  border-top: none;
}
.dsa-row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.dsa-player {
  background: var(--a-btn2);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.dsa-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--a-sub);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.dsa-pct {
  font-size: 28px;
  font-weight: 800;
  color: var(--a-amber);
  line-height: 1.1;
}
.dsa-sub {
  font-size: 11px;
  color: var(--a-sub);
  font-weight: 600;
  margin-bottom: 4px;
}
.dsa-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--a-sub);
}
.dsa-row b { color: var(--a-text); font-weight: 700; }
.dsa-verdict {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--a-sub);
  text-align: center;
}
.dsa-verdict.dsa-ok { color: var(--a-green); }

/* Иконки меню, настроек, окон и входа — PNG-маски из icon.png (client/icons/), цвет берут из color темы */
.ico { display: inline-block; flex: none; width: 1em; height: 1em; vertical-align: middle; background-color: currentColor;
  /* раздельными свойствами: var() в сокращённом mask лишает движок отката на -webkit-mask */
  -webkit-mask-image: var(--i); -webkit-mask-size: contain; -webkit-mask-repeat: no-repeat; -webkit-mask-position: center;
  mask-image: var(--i); mask-size: contain; mask-repeat: no-repeat; mask-position: center; }
