/* Дизайн-система «Игры вживую»: токены и примитивы.
   Тема тёмная всегда — графит, а не чёрный. Цвета Telegram (--tg-theme-*)
   сознательно НЕ используются: у приложения свой игровой вид, а хром Telegram
   подгоняется под него через setHeaderColor/setBackgroundColor (nardy.js).
   Объём даём тенью и внутренним бликом, а не рамками. */

:root {
  --bg: #0f1115;
  --bg-soft: #12151b;      /* подложка липких полос, чтобы контент не просвечивал */
  --surface-1: #171a21;    /* карточки */
  --surface-2: #1e222b;    /* приподнятое и нажатое, инпуты */
  --surface-3: #272c37;    /* чипсы, иконочные кнопки */
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);

  --text: #edeff3;
  --text-2: #9aa3b2;
  --text-3: #6b7382;

  /* латунь — владелец (11.10): «синий цвет кнопок не нравится»; тон взят
     с уголков доски на обложке, чтобы кнопки и фото были из одного мира */
  --accent: #d6a756;
  --accent-rgb: 214, 167, 86;
  --accent-ink: #1c1306;
  --accent-2: #7c5cff;     /* второй акцент — только мотив «голос/видео» */
  --ok: #3dd68c;
  --danger: #ff5c5c;
  --warn: #f5b544;

  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-full: 999px;

  --sh-1: 0 8px 24px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .05);
  --sh-2: 0 14px 36px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06);

  --pad: 16px;             /* горизонтальные поля страницы */
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;   /* жест по доске не должен «оттягивать» страницу */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

/* --- утилиты --- */

.hidden { display: none !important; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ic { width: 20px; height: 20px; flex: none; }
.big-ic { width: 26px; height: 26px; }
.big-icon { font-size: 56px; line-height: 1; }

h1, h2, h3 { margin: 0; font-weight: 700; }
h2 { font-size: 20px; letter-spacing: -.2px; }
h3 { font-size: 17px; }

/* --- экраны-заглушки (загрузка, ошибка) --- */

.screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

/* прокручиваемый экран приложения: свои отступы и safe-area (--sa-* ставит nardy.js) */
.page {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: calc(10px + var(--sa-top, 0px)) var(--pad)
           calc(28px + var(--sa-bottom, 0px));
}

/* --- кнопки --- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease, background .12s ease;
}
.btn:active { transform: scale(.975); opacity: .85; }
.btn:disabled { opacity: .45; transform: none; cursor: default; }

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 6px 18px rgba(var(--accent-rgb), .22);
}
.btn.ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text-2);
  font-weight: 500;
}
.btn.danger { color: var(--danger); }
.btn.mini {
  width: auto;
  min-height: 44px;   /* палец промахивается мимо всего, что ниже */
  padding: 0 14px;
  font-size: 14px;
  border-radius: var(--r-sm);
}
.btn.block { width: 100%; }

.btn-row { display: flex; gap: 8px; width: 100%; }
.btn-row .btn { flex: 1; width: auto; }

/* круглая иконочная кнопка (шестерёнка в шапке) */
.round {
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.round:active { opacity: .7; }

/* --- поверхности --- */

.card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card.row { flex-direction: row; align-items: center; gap: 12px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.chip .ic { width: 15px; height: 15px; }
.chip.av { color: var(--accent-2); border-color: rgba(124, 92, 255, .28);
           background: rgba(124, 92, 255, .12); }

.sect-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.2px;
}
.sect-title .muted { font-size: 13px; font-weight: 500; }

/* --- поля ввода --- */

.field { display: flex; gap: 8px; width: 100%; }
.field input {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 0 14px;
  font-family: inherit;
  font-size: 16px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}
.field input::placeholder { color: var(--text-3); }
.field input:focus { border-color: var(--accent); }

/* --- аватары --- */

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  background: var(--surface-3);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 64px; height: 64px; font-size: 26px; }
.avatar.xl { width: 76px; height: 76px; font-size: 30px; }
.avatar.ghost {
  background: transparent;
  border: 2px dashed var(--line-strong);
  color: var(--text-3);
}

/* --- приглашения (полоса на главной) --- */

.invites { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.invite-btn { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* --- загрузка --- */

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- модалка и шторка снизу --- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, .72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  z-index: 50;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }

/* по центру — для результата партии */
.modal.center { align-items: center; justify-content: center; padding: 24px; }
.modal.center .modal-box {
  width: 100%;
  max-width: 340px;
  border-radius: var(--r-lg);
  padding: 24px;
  animation: pop .2s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.94); } }

/* шторкой снизу — для профиля */
.modal.sheet { align-items: flex-end; }
.modal.sheet .modal-box {
  width: 100%;
  max-height: 88dvh;
  overflow-y: auto;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 8px var(--pad) calc(20px + var(--sa-bottom, 0px));
  animation: rise .22s ease;
}
@keyframes rise { from { transform: translateY(28px); } }

.modal-box {
  background: var(--surface-1);
  border: 1px solid var(--line);
  box-shadow: var(--sh-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
/* «ручка» шторки */
.sheet-grip {
  width: 38px;
  height: 4px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--line-strong);
  margin: 6px 0 4px;
}

/* --- тост --- */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  box-shadow: var(--sh-2);
  color: var(--text);
  padding: 11px 18px;
  border-radius: var(--r-sm);
  font-size: 14px;
  z-index: 60;
  max-width: 90vw;
  text-align: center;
  /* подсказка, а не кнопка: тапы проходят сквозь неё к тому, что под ней */
  pointer-events: none;
}
/* в партии внизу — полоса «⋯ / чат / видео» и реакции: подсказка над ними */
body.in-game #toast { bottom: calc(118px + env(safe-area-inset-bottom)); }

@media (prefers-reduced-motion: reduce) {
  .invite-btn, .modal, .modal-box { animation: none; }
  .btn:active { transform: none; }
}
