
/* ========================
   ДИЗАЙН-СИСТЕМА / ПЕРЕМЕННЫЕ
   ======================== */
:root {
  /* Оригинальные цвета сохранены */
  --bg-color: #fdfaf4;               
  --accent-color: #dbeafe;           
  --accent-hover: #bfdbfe;
  --accent-active: #4f46e5;          
  --text-color: #2d2d2d;
  --card-bg: #ffffff;

  --correct-color: #22c55e;
  --correct-hover: #16a34a;
  --wrong-color: #ef4444;
  --wrong-hover: #dc2626;

  --skip-color: #fbbf24;
  --skip-hover: #f59e0b;
  --skip-text: #1f2937;

  /* Нативные скругления и тени */
  --button-radius: 16px;
  --modal-radius: 24px;
  --input-radius: 14px;
  
  --shadow-app: 0 4px 12px rgba(79, 70, 229, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 20px 40px rgba(0, 0, 0, 0.15);

  /* ЕДИНЫЕ ПОЛЯ ВВОДА */
  --field-bg: #ffffff;
  --field-border: #e5e7eb;
  --field-focus: rgba(79, 70, 229, 0.25);
  --field-text: #111827;
  --field-placeholder: #9ca3af;
  --field-invalid: #ef4444;
  --field-valid: #22c55e;
}

/* ========================
   ГЛОБАЛЬНЫЕ СБРОСЫ И БАЗА
   ======================== */
* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
  /* Убираем синее моргание при тапе на iOS/Android */
  -webkit-tap-highlight-color: transparent; 
}

html, body { height: 100%; }

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Системные шрифты для идеального рендеринга на мобильных */
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: 0 1rem 2rem;
  transition: background-color 0.3s ease;
  justify-content: flex-start;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================
   ШАПКА (HEADER)
   ======================== */
header {
  width: 100%;
  text-align: center;
  /* Увеличиваем padding-top до 4.5rem для обхода кнопок Telegram + 
    добавляем системную переменную iOS/Android для обхода "челки" */
  padding-top: calc(4.5rem + env(safe-area-inset-top, 0px));
  padding-bottom: 1.5rem;
  padding-left: 1rem;
  padding-right: 1rem;
  
  background: linear-gradient(to right, var(--accent-color), var(--card-bg));
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  position: relative;
  z-index: 10;
  margin-bottom: 1.5rem;
}

header h1 {
  font-size: 2.1rem;
  font-weight: 800;
  margin: 0;
  color: var(--accent-active);
  letter-spacing: -0.5px;
  line-height: 1.1;
  /* Добавляем защиту: если на узком экране заголовок 
     не поместится, он аккуратно перенесется */
  word-wrap: break-word; 
  padding: 0 10px;
}

/* ========================
   ГЛАВНОЕ МЕНЮ
   ======================== */
.menu-container {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
}
.menu-container.hidden { display: none; }

.menu-section-title {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8e8e93; /* Системный серый */
  margin: 1rem 0 0.2rem 0.5rem;
  font-size: 0.85rem;
  text-align: left;
}

.menu-divider { display: none; } /* Убрано для чистоты дизайна */

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}
.menu-grid--single {
  grid-template-columns: 1fr;
}

/* ========================
   КНОПКИ (ЕДИНОЕ ПОВЕДЕНИЕ И ФИЗИКА)
   ======================== */
.game-button,
.menu-button,
.start-button,
.back-button,
.correct-button,
.wrong-button,
.skip-button {
  width: 100%;
  padding: 16px 14px;
  font-size: 1.05rem;
  background-color: var(--accent-color);
  color: var(--text-color);
  border: none;
  border-radius: var(--button-radius);
  cursor: pointer;
  box-shadow: var(--shadow-app);
  font-weight: 600;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  /* Плавная кривая анимации для упругости */
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.15s, box-shadow 0.15s;
}

button:focus-visible { outline: none; }

/* Физика нажатия (Native Feel) */
.game-button:active,
.menu-button:active,
.start-button:active,
.back-button:active {
  transform: scale(0.95);
  background-color: var(--accent-hover);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.correct-button { background: var(--correct-color); color: #fff; }
.correct-button:active { transform: scale(0.95); background: var(--correct-hover); }

.wrong-button { background: var(--wrong-color); color: #fff; }
.wrong-button:active { transform: scale(0.95); background: var(--wrong-hover); }

.skip-button { background: var(--skip-color); color: var(--skip-text); }
.skip-button:active { transform: scale(0.95); background: var(--skip-hover); }

.game-button:disabled,
.menu-button:disabled,
.start-button:disabled,
.back-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}

/* ========================
   ПОЛЯ ВВОДА (INPUTS) - НАТИВНЫЙ ВИД
   ======================== */
.field { width: 100%; margin: 0 0 16px; text-align: left; }
.field label { display: block; font-size: 0.95rem; font-weight: 600; margin: 0 0 6px 4px; color: var(--text-color); }
.field-hint { font-size: 0.85rem; color: #8e8e93; margin-top: 6px; margin-left: 4px; }

input[type="text"], input[type="number"], input[type="search"],
input[type="email"], input[type="url"], input[type="tel"],
input[type="password"], textarea, select, .timer-input {
  appearance: none; -webkit-appearance: none;
  width: 100%; 
  font-size: 1.05rem; /* >16px предотвращает зум в iOS */
  line-height: 1.4; 
  padding: 14px 16px;
  border: 1.5px solid var(--field-border); 
  border-radius: var(--input-radius);
  background-color: var(--field-bg); 
  color: var(--field-text);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.01);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input::placeholder, textarea::placeholder { color: var(--field-placeholder); opacity: 1; }

input:focus, textarea:focus, select:focus, .timer-input:focus {
  outline: none; 
  border-color: var(--accent-active);
  box-shadow: 0 0 0 4px var(--field-focus); /* Мягкое кольцо фокуса */
}

.is-invalid { border-color: var(--field-invalid) !important; box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2) !important; }
.is-valid { border-color: var(--field-valid) !important; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2) !important; }

input:disabled, textarea:disabled, select:disabled {
  background-color: #f3f4f6; color: #8e8e93; cursor: not-allowed; opacity: 1;
}

/* ========================
   КАРТОЧКИ СЛОВ И БАЗОВЫЕ КОНТЕЙНЕРЫ
   ======================== */
#game-container { width: 100%; max-width: 420px; text-align: center; margin: 0 auto; }

.card {
  background: var(--card-bg);
  border-radius: var(--modal-radius);
  padding: 2rem 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-app);
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-color);
}

.theme-letter {
  font-size: 1.6rem; font-weight: bold; color: var(--accent-active);
  background: var(--accent-color); padding: 1.2rem 1.5rem; 
  border-radius: var(--button-radius);
  box-shadow: var(--shadow-app); margin: 1.5rem 0;
}
.theme-letter strong { color: var(--text-color); }

/* Таймер */
#alias-timer {
  font-size: 2.5rem;
  text-align: center;
  margin-top: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums; /* Моноширинные цифры, чтобы не прыгали */
  transition: color 0.3s ease, transform 0.2s ease;
}
#alias-timer.time-low {
  color: var(--wrong-color);
  animation: pulseTimer 0.8s ease-in-out infinite;
}
@keyframes pulseTimer {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ========================
   МОДАЛЬНЫЕ ОКНА (ЕДИНЫЙ НАТИВНЫЙ СТИЛЬ)
   ======================== */
.quartet-modal, .kids-modal, .ws-modal, .ws-win { 
  position: fixed; 
  inset: 0; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  padding: 1.5rem; 
  background: rgba(0, 0, 0, 0.3); 
  backdrop-filter: blur(5px); /* Эффект матового стекла iOS */
  -webkit-backdrop-filter: blur(5px);
  z-index: 9999; 
  animation: fadeInModal 0.2s ease-out forwards;
}
.quartet-modal.hidden, .kids-modal.hidden, .ws-modal.hidden, .ws-win.hidden { display: none; }

.quartet-modal-card, .kids-modal-card, .ws-modal-content, .ws-win__card { 
  width: 100%; 
  max-width: 420px; 
  background: var(--card-bg); 
  border-radius: var(--modal-radius); 
  padding: 1.8rem; 
  box-shadow: var(--shadow-modal);
  /* Пружинящая анимация появления */
  animation: popUpModal 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.1) forwards;
  transform: scale(0.9);
  opacity: 0;
}

@keyframes fadeInModal { to { opacity: 1; } }
@keyframes popUpModal { to { transform: scale(1); opacity: 1; } }

/* Специфика модалок */
.quartet-modal-title, .kids-modal-title, .ws-modal-header h3, .ws-win__title { 
  font-weight: 800; 
  font-size: 1.35rem; 
  color: var(--accent-active); 
  margin-bottom: 0.8rem; 
  text-align: center;
}
.quartet-modal-text, .kids-modal-body, .ws-win__text { 
  margin-bottom: 1.2rem; 
  color: var(--text-color); 
  font-size: 1rem;
  line-height: 1.5;
  text-align: center;
}
.ws-win__card { background: rgba(28, 28, 30, 0.98); } /* Темная версия для победы */
.ws-win__title { color: var(--accent-color); }
.ws-win__text { color: #fdfaf4; }

/* ========================
   КВАРТЕТ (QUARTET)
   ======================== */
.quartet-wrap{ width: 100%; max-width: 520px; margin: 0 auto; }
.quartet-header{ width:100%; margin: .5rem 0 1rem; text-align:center; }
.quartet-title{ font-size: 1.5rem; font-weight: 800; color: var(--accent-active); letter-spacing: -0.5px;}
.quartet-subtitle{ font-size: .95rem; color: #8e8e93; margin-top: .2rem; }

.quartet-card{
  width: 100%;
  background: var(--card-bg);
  border-radius: var(--button-radius);
  padding: 1.2rem;
  box-shadow: var(--shadow-app);
  margin-bottom: 1rem;
}
.quartet-grid2{ display:grid; grid-template-columns: 1fr 1fr; gap:.6rem; }
@media (max-width: 420px){ .quartet-grid2{ grid-template-columns: 1fr; } }

.quartet-hint{ font-size: .86rem; color: #8e8e93; margin-top: .4rem; }
.quartet-status{ margin-top: .8rem; font-size: .95rem; padding: .8rem 1rem; border-radius: 12px; background: rgba(79,70,229,.08); color: var(--text-color); font-weight: 500;}
.quartet-status[data-kind="ok"]{ background: rgba(34,197,94,.12); color: #166534; }
.quartet-status[data-kind="err"]{ background: rgba(239,68,68,.12); color: #991b1b; }

.quartet-main.hidden{ display:none; }
.quartet-topbar{ display:flex; align-items:center; justify-content:space-between; gap:.6rem; margin-bottom:1rem; }
.quartet-room{ font-size:.95rem; font-weight: 600; color: #8e8e93; }

.quartet-section-title{ font-weight: 800; color: var(--accent-active); margin-bottom:.6rem; }
.quartet-subsection{ font-weight: 700; color: var(--text-color); margin: .5rem 0; }
.quartet-muted{ color: #8e8e93; font-size: .92rem; }

.quartet-players{ display:flex; flex-direction:column; gap:.6rem; margin-bottom:1rem; }
.q-player{ display:flex; flex-direction:column; gap:.2rem; padding:.8rem 1rem; border-radius: 14px; background: rgba(79,70,229,.05); }
.q-player-name{ font-weight: 700; color: var(--text-color); }
.q-player-meta{ font-size:.9rem; color: #8e8e93; }
.q-badge{ display:inline-flex; align-items:center; justify-content:center; font-size:.75rem; font-weight: 700; padding:.2rem .5rem; border-radius:999px; background: rgba(79,70,229,.15); color: var(--accent-active); margin-left:.4rem; }
.q-badge--turn{ background: rgba(34,197,94,.18); color: #166534; }
.q-badge--host{ background: rgba(251,191,36,.25); color: #92400e; }

.quartet-split{ display:grid; grid-template-columns: 1fr 1fr; gap:.8rem; }
@media (max-width: 520px){ .quartet-split{ grid-template-columns: 1fr; } }

.quartet-hand{ display:flex; flex-direction:column; gap:.6rem; }
.q-qblock{ padding:.8rem 1rem; border-radius: 14px; background: var(--accent-color); }
.q-qname{ font-weight: 800; color: var(--accent-active); margin-bottom:.4rem; }
.q-chips{ display:flex; flex-wrap:wrap; gap:.4rem; }
.q-chip{ display:inline-flex; font-size:.9rem; font-weight: 500; padding:.3rem .6rem; border-radius:999px; background:#fff; box-shadow: 0 2px 4px rgba(0,0,0,.04); }

.quartet-log{ max-height: 200px; overflow:auto; padding:.8rem; border-radius: 14px; background: #f3f4f6; }
.q-log-item{ font-size:.9rem; padding:.3rem 0; border-bottom: 1px solid rgba(0,0,0,.05); }
.q-log-item:last-child{ border-bottom:none; }

/* ========================
   ДЛЯ ДЕТЕЙ (KIDS ARK PAIRS)
   ======================== */
.kids-screen { width: 100%; max-width: 420px; margin: 0 auto; }
.kids-panel { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin: 10px 0 16px; }
.kids-panel .menu-button { width: auto; padding: 14px 20px; font-size: 1rem; margin: 0; }
.kids-switch { display: inline-flex; align-items: center; gap: 10px; user-select: none; }
.kids-switch input { display: none; }
.kids-switch-ui { width: 52px; height: 32px; background: #e5e7eb; border-radius: 999px; position: relative; transition: background-color 0.25s ease; }
.kids-switch-ui::after { content: ""; width: 26px; height: 26px; border-radius: 999px; background: #fff; position: absolute; top: 3px; left: 3px; box-shadow: 0 2px 5px rgba(0,0,0,0.15); transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
.kids-switch input:checked + .kids-switch-ui { background: var(--correct-color); }
.kids-switch input:checked + .kids-switch-ui::after { transform: translateX(20px); }
.kids-switch-text { font-weight: 600; color: var(--text-color); }

.kids-topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.kids-title-small { font-weight: 700; color: var(--accent-active); }
.kids-timer { font-weight: 800; font-size: 1.4rem; padding: 10px 16px; border-radius: var(--button-radius); background: var(--card-bg); box-shadow: var(--shadow-app); font-variant-numeric: tabular-nums; }
.kids-grid { display: grid; grid-template-columns: repeat(var(--kids-grid, 4), 1fr); gap: 12px; width: 100%; }

.kids-card { 
  position: relative; width: 100%; aspect-ratio: 1 / 1; 
  border-radius: 16px; border: none; background: transparent; padding: 0; 
  cursor: pointer; overflow: visible; 
  /* Нативное поведение */
  -webkit-tap-highlight-color: transparent;
}
.kids-card:active { transform: scale(0.95); } /* Физика нажатия для детей */
.kids-card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: var(--shadow-app); border-radius: 16px; }
.kids-card.flipped .kids-card-inner, .kids-card.matched .kids-card-inner { transform: rotateY(180deg); }
.kids-card-face { position: absolute; inset: 0; display: grid; place-items: center; backface-visibility: hidden; font-size: 2rem; border-radius: 16px; }
.kids-card-back { background: var(--accent-color); }
.kids-card-front { transform: rotateY(180deg); background: #ffffff; }

.kids-card.matched .kids-card-inner { box-shadow: 0 0 0 4px var(--correct-color), var(--shadow-app); }
.kids-card.wrong .kids-card-inner { box-shadow: 0 0 0 4px var(--wrong-color), var(--shadow-app); }
.kids-card.shake { animation: kidsShake 0.3s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes kidsShake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* =========================
   WORD SEARCH (ПОИСК СЛОВ)
   ========================= */
.ws-wrap { width: min(480px, 100%); margin: 0 auto; padding: 0; }
.ws-topbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ws-title { text-align: left; flex: 1; }
.ws-title__name { font-weight: 800; letter-spacing: -.2px; font-size: 1.25rem; color: var(--accent-active); }
.ws-stars{ display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: var(--card-bg); color: var(--accent-active); font-weight: 800; box-shadow: var(--shadow-app); font-size: 1rem; }

.ws-panel { background: var(--card-bg); border-radius: var(--button-radius); padding: 14px; margin-bottom: 16px; box-shadow: var(--shadow-app); }
.ws-levelrow{ margin-bottom: 12px; }
.ws-level-btn { background: rgba(79,70,229,.05); border: none; padding: 14px 16px; border-radius: 14px; display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--accent-active); cursor: pointer; transition: transform 0.1s, background 0.1s; }
.ws-level-btn:active { background: rgba(79,70,229,.1); transform: scale(0.97); }
.ws-level-num { color: #8e8e93; font-weight: 600; font-size: 0.95rem; }

.ws-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.ws-progress { font-size: 1rem; font-weight: 600; color: var(--text-color); text-align: center; }

/* Сетка игрового поля */
.ws-board {
  --ws-cols: 6; 
  --ws-rows: 6; 
  display: grid;
  grid-template-columns: repeat(var(--ws-cols), 1fr);
  grid-template-rows: repeat(var(--ws-rows, var(--ws-cols)), 1fr);
  gap: 4px;
  width: 100%;
  margin: 14px auto;
  position: relative;
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

.ws-cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(85vw / var(--ws-cols) * 0.55);
  font-weight: 700;
  color: var(--text-color);
  border-radius: 10px;
  background-color: var(--card-bg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.1s;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 480px) { .ws-cell { font-size: calc(480px / var(--ws-cols) * 0.55); } }

.ws-cell:active { transform: scale(0.9); } /* Физика ячеек */
.ws-cell.ws-cell--sel { background-color: var(--accent-hover); transform: scale(0.92); box-shadow: none; color: var(--accent-active); }
.ws-cell.ws-cell--solved { background-color: #f3f4f6; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05); color: #9ca3af; transform: scale(1); }

.ws-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }

/* Сетка уровней в модалке */
.ws-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; }
.ws-modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #8e8e93; line-height: 1; padding: 4px; }
.ws-levels-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ws-level-item { aspect-ratio: 1; border-radius: 14px; border: none; background: #f3f4f6; display: flex; justify-content: center; align-items: center; font-weight: 700; font-size: 1.1rem; color: #8e8e93; cursor: pointer; transition: transform 0.1s, background 0.1s; }
.ws-level-item:active { transform: scale(0.92); }
.ws-level-item.completed { background: var(--correct-color); color: #fff; }
.ws-level-item.active { background: var(--accent-active); color: #fff; box-shadow: 0 4px 10px rgba(79,70,229,.3); }

/* Тосты (уведомления) */
.ws-toast { 
  position: fixed; left: 50%; bottom: 40px; 
  transform: translateX(-50%) translateY(20px); 
  opacity: 0; padding: 12px 20px; border-radius: 999px; 
  background: rgba(28, 28, 30, 0.95); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  color: #fff; font-weight: 600; font-size: 0.95rem;
  box-shadow: var(--shadow-modal); z-index: 10000; 
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
}
.ws-toast--in { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Адаптация под очень узкие экраны */
@media (max-width: 360px) {
  header h1 { font-size: 1.8rem; }
  .menu-grid { grid-template-columns: 1fr; }
  .game-button { font-size: 1rem; padding: 14px; }
}


/* ========================
   УТИЛИТЫ
   ======================== */
.hidden { display: none !important; }
.fade-in { animation: appFadeIn 0.22s ease-out; }
@keyframes appFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========================
   ДОПОЛНЕНИЯ ДЛЯ КВАРТЕТА
   ======================== */
.quartet-field { width: 100%; text-align: left; margin-bottom: .85rem; }
.quartet-field label { display: block; margin: 0 0 6px 4px; font-size: .95rem; font-weight: 600; color: var(--text-color); }
.q-input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 50px;
  padding: 14px 16px;
  border: 1.5px solid var(--field-border);
  border-radius: var(--input-radius);
  background: var(--field-bg);
  color: var(--field-text);
  font-size: 1.02rem;
  line-height: 1.3;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.q-input:focus {
  outline: none;
  border-color: var(--accent-active);
  box-shadow: 0 0 0 4px var(--field-focus);
}
.quartet-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.quartet-info,
.quartet-ask {
  background: #f8fafc;
  border-radius: 14px;
  padding: .9rem;
  min-height: 72px;
}
.quartet-ask { text-align: left; }
.quartet-start-disabled {
  background: #e5e7eb !important;
  color: #6b7280 !important;
  box-shadow: none !important;
}
.quartet-status {
  word-break: break-word;
  text-align: left;
}
.quartet-log {
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.quartet-log::-webkit-scrollbar { width: 8px; }
.quartet-log::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius: 999px; }
.quartet-card.hidden,
#q_lobby.hidden,
#q_game.hidden { display: none !important; }
@media (max-width: 420px) {
  .quartet-topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .quartet-room,
  .quartet-topbar .back-button {
    width: 100%;
  }
}

/* =========================================================
   TELEGRAM 2026 REFRESH — compact cards, safe areas, SVG menu
   ========================================================= */
:root {
  --app-bg-1: #f6fbff;
  --app-bg-2: #dff4ff;
  --app-bg-3: #dfe8ff;
  --app-ink: #111827;
  --app-muted: #667085;
  --app-primary: #4f46e5;
  --app-primary-2: #0ea5e9;
  --app-card: rgba(255, 255, 255, 0.74);
  --app-card-strong: rgba(255, 255, 255, 0.92);
  --app-border: rgba(99, 102, 241, 0.16);
  --app-shadow: 0 18px 45px rgba(79, 70, 229, 0.12), 0 4px 14px rgba(15, 23, 42, 0.06);
  --app-radius: 28px;
  --tg-top-gap: calc(env(safe-area-inset-top, 0px) + 82px);
}

html {
  background: linear-gradient(165deg, var(--app-bg-1) 0%, var(--app-bg-3) 42%, var(--app-bg-2) 100%);
}

body {
  width: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 4%, rgba(255,255,255,.96), transparent 32%),
    radial-gradient(circle at 86% 18%, rgba(162, 187, 255, .45), transparent 34%),
    radial-gradient(circle at 52% 92%, rgba(125, 211, 252, .34), transparent 42%),
    linear-gradient(165deg, var(--app-bg-1) 0%, var(--app-bg-3) 44%, var(--app-bg-2) 100%);
  color: var(--app-ink);
  padding: 0 14px max(24px, env(safe-area-inset-bottom, 0px));
  justify-content: flex-start;
}

.app-header,
header.app-header {
  width: min(760px, 100%);
  margin: 0 auto 18px;
  padding: var(--tg-top-gap) 8px 8px;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  text-align: center;
}

.app-header h1,
header.app-header h1 {
  margin: 0;
  color: #312e81;
  font-size: clamp(2rem, 8vw, 3rem);
  line-height: .98;
  letter-spacing: -0.05em;
  font-weight: 900;
  text-wrap: balance;
}

.app-kicker,
.app-subtitle {
  margin: 0;
  color: rgba(49, 46, 129, .62);
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: .75rem;
}

.app-subtitle {
  margin-top: 10px;
  letter-spacing: 0;
  text-transform: none;
  font-size: 1rem;
  color: rgba(49, 46, 129, .56);
}

.menu-container,
main.menu-container {
  max-width: 760px;
  width: 100%;
  gap: 18px;
  padding-bottom: 32px;
}

.menu-section {
  display: grid;
  gap: 12px;
}

.menu-section-title {
  margin: 0 0 0 6px;
  font-weight: 900;
  letter-spacing: .13em;
  color: rgba(49, 46, 129, .56);
  font-size: .8rem;
}

.menu-grid,
.menu-grid--single {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.game-card {
  position: relative;
  isolation: isolate;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 164px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  padding: 18px 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 13px;
  background: linear-gradient(145deg, rgba(255,255,255,.64), rgba(191, 219, 254, .46));
  color: var(--app-ink);
  box-shadow: var(--app-shadow), inset 0 1px 0 rgba(255,255,255,.88);
  cursor: pointer;
  text-align: center;
  overflow: hidden;
  transform: translateZ(0);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: calc(var(--app-radius) - 1px);
  background: radial-gradient(circle at 28% 14%, rgba(255,255,255,.86), transparent 40%);
  z-index: -1;
}

.game-card:active {
  transform: scale(.975);
  box-shadow: 0 10px 24px rgba(79,70,229,.12), inset 0 1px 0 rgba(255,255,255,.8);
}

.game-card__icon {
  width: 62px;
  height: 62px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 11px 18px rgba(79, 70, 229, .28));
}

.game-card__svg {
  width: 62px;
  height: 62px;
  display: block;
}

.game-card__icon--image {
  width: 76px;
  height: 76px;
  border-radius: 24px;
  overflow: visible;
  filter: drop-shadow(0 14px 22px rgba(79, 70, 229, .30));
}

.game-card__img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transform: translateZ(0);
}

.game-card__body {
  display: grid;
  gap: 5px;
}

.game-card__title {
  font-size: clamp(1.02rem, 3.9vw, 1.22rem);
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: 1.1;
}

.game-card__desc {
  min-height: 2.2em;
  color: rgba(17, 24, 39, .58);
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.22;
}

.game-card--system,
.game-card--admin {
  min-height: 112px;
  flex-direction: row;
  justify-content: flex-start;
  text-align: left;
  padding: 16px;
}

.game-card--system .game-card__body,
.game-card--admin .game-card__body { gap: 4px; }
.game-card--admin { background: linear-gradient(145deg, rgba(240, 245, 255, .92), rgba(218, 230, 255, .74)); }

.app-loader,
.app-game-loading,
.admin-loading {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(165deg, var(--app-bg-1), var(--app-bg-3) 48%, var(--app-bg-2));
  color: var(--app-ink);
  font-weight: 800;
  gap: 14px;
}

.app-game-loading,
.admin-loading {
  position: relative;
  min-height: 320px;
  inset: auto;
  z-index: 1;
  background: transparent;
}

.app-loader__ring {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(79,70,229,.16);
  border-top-color: var(--app-primary);
  animation: spin .8s linear infinite;
}

.banned-screen {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--tg-top-gap) 14px 32px;
}

.banned-card,
.app-error-card {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: 28px;
  background: var(--app-card-strong);
  box-shadow: var(--app-shadow);
  text-align: center;
}

body[data-mode="game"] header.app-header,
body[data-mode="admin"] header.app-header { display: none; }

body[data-mode="game"] #game-container,
body[data-mode="admin"] #game-container {
  width: min(760px, 100%);
  max-width: 760px !important;
  padding-top: var(--tg-top-gap) !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin: 0 auto !important;
}

body[data-mode="game"] #game-container .alias-title,
body[data-mode="game"] #game-container h2:first-child,
body[data-mode="admin"] #game-container h2:first-child {
  color: #312e81;
  text-align: center;
}

.support-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15,23,42,.38);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: supportIn .18s ease-out both;
}

.support-overlay--closing { animation: supportOut .18s ease-in both; }

.support-box {
  width: min(390px, 100%);
  border-radius: 30px;
  background: rgba(255,255,255,.95);
  box-shadow: 0 24px 70px rgba(15,23,42,.22);
  padding: 24px;
  text-align: center;
}

.support-icon { display: grid; place-items: center; margin-bottom: 8px; }
.support-title { margin: 0 0 8px; color: #312e81; font-size: 1.35rem; font-weight: 900; }
.support-text { margin: 0 0 18px; color: #667085; line-height: 1.5; font-weight: 650; }
.support-actions { display: grid; gap: 10px; }
.support-btn-primary,
.support-btn-secondary {
  border: none;
  border-radius: 18px;
  min-height: 52px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.support-btn-primary { background: linear-gradient(135deg, var(--app-primary), var(--app-primary-2)); color: #fff; }
.support-btn-secondary { background: #f1f5f9; color: #334155; }

.admin-page {
  width: min(760px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.admin-topbar {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  z-index: 30;
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 28px;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--app-shadow);
  border: 1px solid rgba(255,255,255,.6);
}

.admin-back,
.admin-pager button {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 16px;
  background: #eef2ff;
  color: #312e81;
  font-size: 1.35rem;
  font-weight: 900;
  cursor: pointer;
}

.admin-pager button:disabled { opacity: .42; cursor: default; }
.admin-topbar h2 { margin: 0; color: #312e81; font-size: 1.55rem; line-height: 1; font-weight: 950; }
.admin-topbar p { margin: 5px 0 0; color: #667085; font-weight: 750; font-size: .88rem; }

.admin-broadcast,
.admin-tools,
.admin-user,
.admin-empty {
  border: 1px solid rgba(99, 102, 241, .14);
  border-radius: 26px;
  background: rgba(255,255,255,.78);
  box-shadow: var(--app-shadow);
  overflow: hidden;
}

.admin-broadcast summary {
  list-style: none;
  cursor: pointer;
  padding: 17px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 950;
  color: #312e81;
}
.admin-broadcast summary::-webkit-details-marker { display: none; }
.admin-broadcast summary small { color: #667085; font-size: .82rem; font-weight: 750; }
.admin-broadcast__body { padding: 0 16px 16px; display: grid; gap: 10px; }
.admin-broadcast textarea { min-height: 118px; resize: vertical; background: rgba(248,250,252,.9); }
.admin-broadcast button { min-height: 54px; border: none; border-radius: 18px; background: linear-gradient(135deg, var(--app-primary), var(--app-primary-2)); color: #fff; font-weight: 950; font-size: 1rem; }

.admin-tools {
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}
.admin-search { display: grid; gap: 6px; }
.admin-search span { margin-left: 4px; color: #667085; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 900; }
.admin-search input { min-height: 48px; background: rgba(248,250,252,.92); }
.admin-pager { display: flex; align-items: center; gap: 8px; color: #312e81; font-weight: 900; white-space: nowrap; }

.admin-list {
  display: grid;
  gap: 10px;
  max-height: min(58vh, 640px);
  overflow: auto;
  padding: 2px 2px 24px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.admin-user summary {
  min-height: 78px;
  padding: 14px 16px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  list-style: none;
}
.admin-user summary::-webkit-details-marker { display: none; }
.admin-user__main { min-width: 0; display: grid; gap: 5px; }
.admin-user__main b { font-size: 1rem; word-break: break-word; }
.admin-user__main small { color: #667085; font-weight: 740; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-user__status { padding: 8px 10px; border-radius: 999px; font-size: .78rem; font-weight: 950; background: #dcfce7; color: #166534; }
.admin-user.is-banned .admin-user__status { background: #fee2e2; color: #991b1b; }
.admin-user__body { padding: 0 14px 14px; display: grid; gap: 12px; }
.admin-user__topline { display: flex; gap: 10px; }
.admin-chat,
.admin-ban {
  flex: 1;
  min-height: 46px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  text-decoration: none;
  font-weight: 950;
  cursor: pointer;
}
.admin-chat { background: #eff6ff; color: #2563eb; }
.admin-chat--disabled { color: #94a3b8; background: #f1f5f9; }
.admin-ban { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }
.admin-ban--restore { background: #ecfdf5; color: #047857; border-color: #bbf7d0; }

.admin-score-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.admin-score {
  display: grid;
  gap: 7px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(248,250,252,.86);
  border: 1px solid rgba(226,232,240,.86);
}
.admin-score span { color: #667085; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 950; text-align: center; }
.admin-score div { display: grid; grid-template-columns: 1fr 42px; gap: 6px; }
.admin-score input { min-height: 44px; padding: 10px 6px; text-align: center; font-weight: 900; }
.admin-score button { border: none; border-radius: 14px; background: #22c55e; color: #fff; font-size: 1.1rem; font-weight: 950; }
.admin-empty { padding: 24px; text-align: center; color: #667085; font-weight: 900; }

.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 100001;
  transform: translate(-50%, 18px) scale(.98);
  opacity: 0;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .92);
  color: white;
  font-weight: 900;
  box-shadow: 0 14px 32px rgba(15,23,42,.24);
  transition: opacity .18s ease, transform .18s ease;
  white-space: nowrap;
}
.app-toast--visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.app-toast--error { background: rgba(185, 28, 28, .94); }

@keyframes supportIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes supportOut { from { opacity: 1; } to { opacity: 0; } }

@media (max-width: 480px) {
  :root { --tg-top-gap: calc(env(safe-area-inset-top, 0px) + 92px); }
  body { padding-left: 12px; padding-right: 12px; }
  .menu-grid, .menu-grid--single { gap: 12px; }
  .game-card { min-height: 152px; border-radius: 25px; padding: 16px 10px 14px; }
  .game-card__icon, .game-card__svg { width: 58px; height: 58px; }
  .game-card__icon--image { width: 70px; height: 70px; }
  .game-card__desc { display: none; }
  .game-card--system, .game-card--admin { min-height: 92px; }
  .game-card--system .game-card__desc,
  .game-card--admin .game-card__desc { display: block; }
  .admin-tools { grid-template-columns: 1fr; }
  .admin-pager { justify-content: space-between; }
  .admin-score-grid { grid-template-columns: 1fr; }
  .admin-list { max-height: none; overflow: visible; }
}

@media (max-width: 360px) {
  .menu-grid, .menu-grid--single { grid-template-columns: 1fr; }
  .game-card { min-height: 118px; flex-direction: row; text-align: left; justify-content: flex-start; padding: 14px; }
  .game-card__desc { display: block; }
}

/* =========================================================
   TELEGRAM GAME POLISH v14 — bugfix + unified game styling
   ========================================================= */
:root {
  --tg-top-gap: calc(env(safe-area-inset-top, 0px) + 96px);
  --surface: rgba(255,255,255,.74);
  --surface-strong: rgba(255,255,255,.94);
  --surface-soft: rgba(239,246,255,.68);
  --line: rgba(99,102,241,.16);
  --ink: #111827;
  --ink-soft: #667085;
  --primary: #4f46e5;
  --primary-2: #0ea5e9;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius-lg: 28px;
  --radius-md: 22px;
  --shadow-soft: 0 18px 45px rgba(79,70,229,.12), 0 4px 14px rgba(15,23,42,.06);
  --shadow-card: 0 16px 38px rgba(79,70,229,.11), inset 0 1px 0 rgba(255,255,255,.86);
}

html {
  min-height: 100%;
  height: auto !important;
  background: linear-gradient(165deg, #f7fbff 0%, #e7edff 45%, #c9f0ff 100%) fixed !important;
}

body {
  min-height: 100dvh !important;
  height: auto !important;
  background: transparent !important;
  position: relative;
  isolation: isolate;
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(circle at 8% 0%, rgba(255,255,255,.98), transparent 34%),
    radial-gradient(circle at 90% 14%, rgba(156,185,255,.48), transparent 36%),
    radial-gradient(circle at 54% 88%, rgba(125,211,252,.38), transparent 46%),
    linear-gradient(165deg, #f8fcff 0%, #e6edff 46%, #c9f0ff 100%);
  background-repeat: no-repeat;
  background-size: cover;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.26) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.20) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.55), transparent 82%);
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes softPop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes pulseGlow { 0%,100% { box-shadow: 0 0 0 rgba(79,70,229,0); } 50% { box-shadow: 0 0 28px rgba(79,70,229,.18); } }

.app-loader__ring,
.spinner,
.spinner-dark {
  animation: spin .8s linear infinite !important;
  flex: 0 0 auto;
}

.app-loader__ring,
.spinner,
.spinner-dark,
.loading-spinner {
  border-radius: 50% !important;
  border-style: solid !important;
  border-color: rgba(79,70,229,.16) !important;
  border-top-color: var(--primary) !important;
}

/* меню: меньше огромных пустых областей и без обрыва фона */
.app-header,
header.app-header { padding-top: var(--tg-top-gap) !important; }
.menu-container,
main.menu-container { padding-bottom: calc(42px + env(safe-area-inset-bottom, 0px)) !important; }
.game-card { min-height: 150px; }
.game-card__icon { margin-bottom: 2px; }
.game-card__desc { opacity: .82; }

/* общий контейнер всех игр */
body[data-mode="game"] #game-container,
body[data-mode="admin"] #game-container {
  width: min(760px, 100%) !important;
  max-width: 760px !important;
  padding-top: var(--tg-top-gap) !important;
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)) !important;
  display: grid;
  gap: 14px;
  animation: softPop .18s ease-out both;
}

#game-container > h2,
#game-container .alias-title,
#game-container .sw-title,
#game-container .ws-title__name,
#game-container .wow-title {
  color: #312e81 !important;
  font-weight: 950 !important;
  letter-spacing: -.045em;
  line-height: 1.05;
  text-align: center;
}

#game-container > h2,
#game-container .alias-title { font-size: clamp(2rem, 8vw, 3.15rem) !important; margin: 0 0 4px !important; }
#game-container p { color: var(--ink-soft); font-weight: 700; line-height: 1.45; }

.alias-sub,
.hint,
.field-hint,
.sw-subtitle,
.ws-title__meta {
  color: rgba(49,46,129,.58) !important;
  font-weight: 800 !important;
}

/* единые кнопки */
.btn,
.menu-button,
.start-button,
.back-button,
.correct-button,
.wrong-button,
.skip-button,
.chip,
.wow-chip,
.ws-level-btn,
.kids-difficulty-btn,
.kids-mode-btn,
.admin-back,
.admin-pager button {
  appearance: none !important;
  -webkit-appearance: none !important;
  border: 1px solid rgba(255,255,255,.72) !important;
  border-radius: 20px !important;
  min-height: 54px;
  padding: 14px 16px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  background: rgba(255,255,255,.86) !important;
  color: #0f172a !important;
  box-shadow: 0 10px 24px rgba(79,70,229,.09), inset 0 1px 0 rgba(255,255,255,.9) !important;
  font-weight: 900 !important;
  font-size: clamp(1rem, 4vw, 1.12rem) !important;
  line-height: 1.1 !important;
  text-decoration: none !important;
  cursor: pointer !important;
  transition: transform .14s ease, box-shadow .14s ease, opacity .14s ease !important;
}

.btn:active,
.menu-button:active,
.start-button:active,
.back-button:active,
.correct-button:active,
.wrong-button:active,
.skip-button:active,
.chip:active,
.wow-chip:active { transform: scale(.975) !important; }

.btn-primary,
.start-button,
.menu-button,
.correct-button,
#wow-hint,
#wow-reveal,
#wow-levels-open,
#wow-shuffle {
  background: linear-gradient(135deg, var(--primary), var(--primary-2)) !important;
  color: #fff !important;
  border-color: rgba(255,255,255,.32) !important;
  box-shadow: 0 16px 32px rgba(79,70,229,.20), inset 0 1px 0 rgba(255,255,255,.3) !important;
}

.btn-good,
.correct-button { background: linear-gradient(135deg, #22c55e, #10b981) !important; color: #fff !important; }
.btn-bad,
.wrong-button { background: linear-gradient(135deg, #ef4444, #fb7185) !important; color: #fff !important; }
.btn-skip,
.skip-button { background: linear-gradient(135deg, #fbbf24, #f59e0b) !important; color: #422006 !important; }
.btn-ghost,
.back-button,
#wow-menu,
#wow-prev,
#wow-next,
#wow-reset,
#wow-zoom-out,
#wow-zoom-in { background: rgba(255,255,255,.88) !important; color: #2563eb !important; }

button:disabled,
.btn:disabled { opacity: .48 !important; filter: saturate(.7); cursor: not-allowed !important; transform: none !important; }

/* поля */
.input,
.input-lg,
.select,
.number-input,
.timer-input,
input[type="text"],
input[type="number"],
input[type="search"],
textarea,
select {
  min-height: 54px !important;
  border-radius: 18px !important;
  border: 1px solid rgba(99,102,241,.16) !important;
  background: rgba(255,255,255,.88) !important;
  color: #0f172a !important;
  font-weight: 850 !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.92), 0 8px 18px rgba(79,70,229,.05) !important;
}

/* карточки и блоки всех мини-игр */
.card,
.setup-block,
.theme-letter,
.secret-card,
.ws-panel,
.ws-board,
.sw-card,
.sw-keyboard,
.sw-lamp-card,
.wow-board-area,
.wow-controls,
.wow-pill,
.kids-panel,
.kids-board-wrap,
.quartet-card,
.premium-theme-card,
.next-block,
.admin-broadcast,
.admin-tools,
.admin-user,
.admin-empty {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-lg) !important;
  background: linear-gradient(145deg, rgba(255,255,255,.86), rgba(232,241,255,.66)) !important;
  box-shadow: var(--shadow-card) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.card,
.setup-block,
.theme-letter,
.secret-card {
  width: 100%;
  padding: clamp(20px, 5vw, 30px) !important;
  margin: 0 !important;
}

.setup-grid,
.alias-buttons,
.actions,
.row-center,
.premium-actions,
.ws-actions,
.ws-bottom,
.sw-actions {
  display: grid !important;
  gap: 12px !important;
  width: 100%;
}

.row-wrap,
.chips { display: flex !important; flex-wrap: wrap !important; gap: 10px !important; align-items: center !important; justify-content: center !important; }
.row-center.actions-bottom { margin-top: 12px; }

/* Alias */
body[data-current-game="alias"] #game-container { gap: 16px; }
.alias-title { display: flex; align-items: center; justify-content: center; gap: 12px; }
.alias-title-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-weight: 950;
  font-size: 1.35rem;
  box-shadow: 0 14px 28px rgba(79,70,229,.22);
}
.difficulty-dot { width: 24px; height: 24px; border-radius: 50%; display: inline-block; box-shadow: inset 0 2px 4px rgba(255,255,255,.7), 0 4px 10px rgba(15,23,42,.12); }
.difficulty-dot--easy { background: linear-gradient(#4ade80,#16a34a); }
.difficulty-dot--medium { background: linear-gradient(#fde047,#f59e0b); }
.difficulty-dot--hard { background: linear-gradient(#fb7185,#dc2626); }
.round-head { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.timer,
#alias-timer {
  font-size: clamp(2.5rem, 12vw, 4.7rem) !important;
  color: #0f172a !important;
  font-weight: 950 !important;
  letter-spacing: -.07em;
  text-align: left;
}
.round-meta { color: var(--ink-soft); font-weight: 850; text-align: right; }
.word-card,
#alias-word {
  min-height: 150px !important;
  display: grid !important;
  place-items: center !important;
  font-size: clamp(2rem, 9vw, 3.5rem) !important;
  color: #18181b !important;
  background: rgba(255,255,255,.94) !important;
}
.scoreboard { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 6px 0; }
.badge { border-radius: 999px; padding: 8px 12px; background: rgba(255,255,255,.86); color: #312e81; font-weight: 900; border: 1px solid rgba(99,102,241,.14); }
.badge-good { background: #dcfce7 !important; color: #166534 !important; }
.badge-bad { background: #fee2e2 !important; color: #991b1b !important; }
.badge-skip { background: #fef3c7 !important; color: #92400e !important; }
.results-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; font-weight: 780; }
.results-table th { color: var(--ink-soft); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.results-table td { background: rgba(255,255,255,.74); padding: 10px; }
.results-table td:first-child { border-radius: 14px 0 0 14px; }
.results-table td:last-child { border-radius: 0 14px 14px 0; }

/* простые игры */
.theme-letter strong,
.secret-card h3 { color: #111827; font-size: clamp(1.8rem, 9vw, 3.2rem); line-height: 1.05; display: block; margin: 8px 0; }
.theme-letter-big { font-size: clamp(4rem, 22vw, 8rem); line-height: .9; color: var(--primary); display: block; margin: 10px 0; }
.theme-label { color: var(--ink-soft); font-weight: 950; letter-spacing: .1em; text-transform: uppercase; }
.secret-card small { display: block; color: var(--ink-soft); font-weight: 750; line-height: 1.45; }

/* Word Search */
.ws-wrap { display: grid; gap: 14px; }
.ws-topbar,
.sw-topbar,
.wow-top {
  display: grid !important;
  gap: 10px !important;
  align-items: center;
}
.ws-board {
  width: 100% !important;
  max-width: min(94vw, 560px) !important;
  margin: 0 auto !important;
  padding: 10px !important;
  background: rgba(255,255,255,.72) !important;
}
.ws-cell {
  border-radius: 14px !important;
  background: rgba(255,255,255,.92) !important;
  color: #0f172a !important;
  box-shadow: 0 6px 14px rgba(79,70,229,.08) !important;
  font-weight: 950 !important;
}
.ws-cell.ws-cell--sel { background: #dbeafe !important; color: #1d4ed8 !important; }
.ws-cell.ws-cell--solved { background: #dcfce7 !important; color: #166534 !important; }
.ws-progress { color: var(--ink-soft); font-weight: 900; text-align: center; }
.ws-modal { backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.ws-modal-content { border-radius: 28px !important; background: rgba(255,255,255,.96) !important; box-shadow: var(--shadow-soft) !important; }

/* Bible WOW */
.wow-wrap { display: grid; gap: 12px; }
.wow-top { grid-template-columns: 1fr !important; }
.wow-pill { padding: 8px !important; display: flex !important; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.wow-board-area { min-height: 250px; padding: 14px !important; overflow: hidden; }
.wow-grid { filter: drop-shadow(0 16px 22px rgba(79,70,229,.13)); }
.wow-cell,
.wow-letter,
.wow-wheel-letter {
  border-radius: 16px !important;
  background: rgba(255,255,255,.92) !important;
  color: #0f172a !important;
  box-shadow: 0 8px 18px rgba(79,70,229,.10) !important;
  font-weight: 950 !important;
}
.wow-controls { padding: 14px !important; }
.wow-preview { min-height: 48px; border-radius: 18px; background: rgba(255,255,255,.78); display: grid; place-items: center; color: #312e81; font-weight: 950; }

/* Sacred Word */
.sw-wrap { display: grid; gap: 14px; }
.sw-card { padding: 16px !important; }
.sw-grid { display: grid !important; gap: 14px !important; }
.sw-pillrow { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.sw-pill { border-radius: 999px !important; background: rgba(255,255,255,.86) !important; color: #312e81 !important; border: 1px solid rgba(99,102,241,.14); padding: 8px 11px; font-weight: 900; }
.sw-hintbox { border-radius: 20px !important; background: rgba(255,255,255,.80) !important; border: 1px solid rgba(99,102,241,.14); color: #0f172a !important; font-weight: 820; }
.sw-word { gap: 7px !important; justify-content: center; }
.sw-letter { border-radius: 14px !important; background: rgba(255,255,255,.9) !important; color: #111827 !important; box-shadow: 0 8px 16px rgba(79,70,229,.08); }
.sw-letter.revealed { background: #dbeafe !important; color: #1d4ed8 !important; }
.sw-kb-row { display: flex; gap: 7px; justify-content: center; }
.sw-kb-key { border-radius: 14px !important; border: none !important; min-height: 42px; background: rgba(255,255,255,.90) !important; color: #0f172a !important; font-weight: 950 !important; box-shadow: 0 7px 15px rgba(79,70,229,.08) !important; }
.sw-kb-key.good { background: #dcfce7 !important; color: #166534 !important; }
.sw-kb-key.bad { background: #fee2e2 !important; color: #991b1b !important; }

/* Kids pairs */
.kids-wrap { display: grid; gap: 14px; }
.kids-board { gap: 10px !important; }
.kids-card { border-radius: 20px !important; filter: drop-shadow(0 10px 18px rgba(79,70,229,.12)); }
.kids-card-back { background: linear-gradient(135deg, var(--primary), var(--primary-2)) !important; }
.kids-card-front { background: rgba(255,255,255,.94) !important; }
.kids-timer { border-radius: 999px !important; background: rgba(255,255,255,.86) !important; color: #312e81 !important; }

/* Spy */
.secret-card { animation: pulseGlow 2.4s ease-in-out infinite; }

/* Quartet: не ломаем механику, только общий внешний слой */
.quartet-root { padding: 0 !important; color: #0f172a; }
.quartet-root .screen,
.quartet-root .auth-card,
.quartet-root .lobby-card,
.quartet-root .game-panel,
.quartet-root .hand-group,
.quartet-root .action-card,
.quartet-root .players-ring,
.quartet-root .log-card {
  border-radius: 26px !important;
  background: rgba(255,255,255,.78) !important;
  border: 1px solid rgba(99,102,241,.14) !important;
  box-shadow: var(--shadow-card) !important;
}
.quartet-root button { border-radius: 18px !important; }

/* Админка компактнее */
.admin-page { gap: 12px !important; }
.admin-topbar { top: calc(env(safe-area-inset-top, 0px) + 74px) !important; border-radius: 24px !important; }
.admin-list { max-height: none !important; overflow: visible !important; padding-bottom: 18px !important; }
.admin-user summary { min-height: 68px !important; }
.admin-user__body { gap: 10px !important; }
.admin-score-grid { grid-template-columns: repeat(3, minmax(0,1fr)) !important; }
.admin-score { border-radius: 18px !important; }

@media (max-width: 520px) {
  :root { --tg-top-gap: calc(env(safe-area-inset-top, 0px) + 112px); }
  body { padding-left: 12px !important; padding-right: 12px !important; }
  .app-header h1, header.app-header h1 { font-size: clamp(2rem, 10vw, 2.65rem); }
  .game-card { min-height: 146px !important; }
  .round-head { grid-template-columns: 1fr; text-align: center; }
  .timer, #alias-timer { text-align: center !important; }
  .round-meta { text-align: center !important; }
  .alias-buttons .btn, .actions .btn, .row-center .btn { width: 100%; }
  .admin-score-grid { grid-template-columns: 1fr !important; }
  .ws-actions, .ws-bottom { grid-template-columns: 1fr !important; }
}

@media (max-width: 380px) {
  .game-card { min-height: 134px !important; }
  .game-card__icon, .game-card__svg { width: 52px !important; height: 52px !important; }
  .game-card__icon--image { width: 64px !important; height: 64px !important; }
  #game-container > h2, #game-container .alias-title { font-size: clamp(1.75rem, 9vw, 2.2rem) !important; }
}


/* =========================================================
   v15 — компактные словесные игры + полный мобильный редизайн Квартета
   ========================================================= */
body[data-current-game="bible-wordsearch"] #game-container,
body[data-current-game="bible-wow"] #game-container,
body[data-current-game="sacred-word"] #game-container,
body[data-current-game="quartet"] #game-container {
  padding-top: calc(env(safe-area-inset-top, 0px) + 82px) !important;
  gap: 10px !important;
}

/* Поиск библейских слов: вся партия помещается выше, без огромного служебного блока */
body[data-current-game="bible-wordsearch"] .ws-wrap {
  width: min(100%, 620px) !important;
  gap: 10px !important;
}
body[data-current-game="bible-wordsearch"] .ws-topbar {
  display: grid !important;
  grid-template-columns: auto 1fr auto !important;
  gap: 8px !important;
  margin: 0 !important;
  align-items: center !important;
}
body[data-current-game="bible-wordsearch"] .ws-topbar .back-button {
  min-height: 44px !important;
  padding: 10px 12px !important;
  border-radius: 18px !important;
  white-space: nowrap !important;
}
body[data-current-game="bible-wordsearch"] .ws-title__name {
  font-size: clamp(1.45rem, 6vw, 2.1rem) !important;
  text-align: left !important;
}
body[data-current-game="bible-wordsearch"] .ws-stars {
  min-height: 44px !important;
  padding: 9px 12px !important;
  box-shadow: 0 8px 18px rgba(79,70,229,.08) !important;
}
body[data-current-game="bible-wordsearch"] .ws-panel {
  display: grid !important;
  gap: 8px !important;
  padding: 10px !important;
  margin: 0 !important;
  border-radius: 24px !important;
}
body[data-current-game="bible-wordsearch"] .ws-levelrow { margin: 0 !important; }
body[data-current-game="bible-wordsearch"] .ws-level-btn {
  min-height: 48px !important;
  padding: 9px 12px !important;
  border-radius: 18px !important;
  font-size: clamp(.92rem, 3.8vw, 1.05rem) !important;
}
body[data-current-game="bible-wordsearch"] .ws-actions {
  grid-template-columns: 1fr 1fr !important;
  gap: 8px !important;
  margin: 0 !important;
}
body[data-current-game="bible-wordsearch"] .ws-actions .start-button,
body[data-current-game="bible-wordsearch"] .ws-actions .wrong-button,
body[data-current-game="bible-wordsearch"] .ws-bottom .start-button {
  min-height: 46px !important;
  padding: 10px 12px !important;
  border-radius: 18px !important;
  font-size: clamp(.9rem, 3.7vw, 1rem) !important;
}
body[data-current-game="bible-wordsearch"] .ws-progress {
  min-height: 24px !important;
  font-size: clamp(.9rem, 3.5vw, 1rem) !important;
}
body[data-current-game="bible-wordsearch"] .ws-board {
  width: min(calc(100vw - 26px), 560px) !important;
  max-width: min(calc(100vw - 26px), 560px) !important;
  gap: clamp(2px, .8vw, 4px) !important;
  padding: clamp(6px, 1.5vw, 10px) !important;
  margin: 0 auto !important;
  border-radius: 24px !important;
}
body[data-current-game="bible-wordsearch"] .ws-cell {
  border-radius: clamp(9px, 2.4vw, 14px) !important;
  font-size: clamp(1.15rem, calc(46vw / var(--ws-cols)), 1.95rem) !important;
}
body[data-current-game="bible-wordsearch"] .ws-bottom {
  grid-template-columns: 1fr 1fr !important;
  gap: 8px !important;
  margin-top: 0 !important;
}

/* Библейские слова: компактная доска + колесо не раздувает страницу */
body[data-current-game="bible-wow"] .wow-wrap {
  width: min(100%, 640px) !important;
  display: grid !important;
  gap: 10px !important;
  min-height: auto !important;
  height: auto !important;
  padding: 0 0 calc(14px + env(safe-area-inset-bottom,0px)) !important;
}
body[data-current-game="bible-wow"] .wow-top {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 8px !important;
}
body[data-current-game="bible-wow"] .wow-top > .wow-pill {
  min-height: 48px !important;
  padding: 6px !important;
  border-radius: 20px !important;
  margin: 0 !important;
  gap: 6px !important;
}
body[data-current-game="bible-wow"] .wow-top > .wow-pill:nth-child(2) { min-width: 0 !important; }
body[data-current-game="bible-wow"] .wow-title { font-size: clamp(1rem, 4.2vw, 1.25rem) !important; white-space: nowrap !important; }
body[data-current-game="bible-wow"] .wow-rightCol { gap: 4px !important; align-items: center !important; }
body[data-current-game="bible-wow"] .wow-stars { padding: 5px 9px !important; font-size: .86rem !important; }
body[data-current-game="bible-wow"] #wow-bonus-open { min-height: 32px !important; padding: 5px 8px !important; font-size: .78rem !important; }
body[data-current-game="bible-wow"] #wow-levels-open { min-width: 42px !important; }
body[data-current-game="bible-wow"] .wow-board-area {
  min-height: clamp(150px, 28dvh, 245px) !important;
  max-height: 280px !important;
  padding: 10px !important;
  margin: 0 !important;
  border-radius: 24px !important;
}
body[data-current-game="bible-wow"] .wow-cell { width: 34px !important; height: 34px !important; font-size: 18px !important; border-radius: 12px !important; }
body[data-current-game="bible-wow"] .wow-controls {
  padding: 10px !important;
  gap: 9px !important;
  border-radius: 26px !important;
  background: linear-gradient(145deg, rgba(255,255,255,.86), rgba(232,241,255,.66)) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow-card) !important;
}
body[data-current-game="bible-wow"] .wow-preview { height: 32px !important; margin: 0 !important; }
body[data-current-game="bible-wow"] .wow-preview-let { width: 32px !important; height: 32px !important; border-radius: 11px !important; font-size: 16px !important; }
body[data-current-game="bible-wow"] .wow-actions {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  width: 100% !important;
  gap: 8px !important;
  order: 3 !important;
}
body[data-current-game="bible-wow"] .wow-actions .wow-chip {
  min-height: 44px !important;
  padding: 9px 10px !important;
  border-radius: 17px !important;
  font-size: clamp(.84rem, 3.5vw, .98rem) !important;
}
body[data-current-game="bible-wow"] .wow-wheel-wrap { width: 216px !important; height: 216px !important; order: 2 !important; }
body[data-current-game="bible-wow"] .wow-btn-let { width: 44px !important; height: 44px !important; margin-left: -22px !important; margin-top: -22px !important; font-size: 19px !important; }
body[data-current-game="bible-wow"] .wow-wheel-bg { inset: 9px !important; }
body[data-current-game="bible-wow"] .wow-zoom { top: 8px !important; right: 8px !important; }
body[data-current-game="bible-wow"] .wow-zoom .wow-chip { min-height: 34px !important; padding: 5px 9px !important; }

/* Священное слово: компактнее и без пустого вертикального разрыва */
body[data-current-game="sacred-word"] .sw-wrap { width: min(100%, 660px) !important; }
body[data-current-game="sacred-word"] .sw-topbar { margin: 0 !important; }
body[data-current-game="sacred-word"] .sw-card { margin: 0 !important; }
body[data-current-game="sacred-word"] .sw-lamp-card canvas { max-width: 210px !important; }

/* Квартет v15: мобильная игровая панель вместо длинного десктопного стола */
body[data-current-game="quartet"] #game-container { width: min(680px, 100%) !important; max-width: 680px !important; }
body[data-current-game="quartet"] .quartet-root {
  min-height: auto !important;
  background: transparent !important;
  padding: 0 0 calc(16px + env(safe-area-inset-bottom,0px)) !important;
  color: #0f172a !important;
}
body[data-current-game="quartet"] .game-header {
  position: sticky !important;
  top: calc(env(safe-area-inset-top, 0px) + 72px) !important;
  z-index: 80 !important;
  border: 1px solid rgba(255,255,255,.72) !important;
  border-radius: 26px !important;
  padding: 12px 14px !important;
  margin: 0 0 10px !important;
  background: linear-gradient(145deg, rgba(255,255,255,.9), rgba(223,235,255,.72)) !important;
  color: #0f172a !important;
  box-shadow: 0 14px 34px rgba(79,70,229,.13), inset 0 1px 0 rgba(255,255,255,.9) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
}
body[data-current-game="quartet"] .game-title {
  margin: 0 !important;
  font-size: clamp(1.6rem, 7vw, 2.4rem) !important;
  line-height: 1 !important;
  letter-spacing: -.05em !important;
  color: #312e81 !important;
  text-shadow: none !important;
}
body[data-current-game="quartet"] .game-subtitle { color: rgba(49,46,129,.62) !important; font-weight: 850 !important; opacity: 1 !important; }
body[data-current-game="quartet"] .content-wrap { padding: 0 !important; max-width: none !important; }
body[data-current-game="quartet"] .card-3d,
body[data-current-game="quartet"] .room-code-display,
body[data-current-game="quartet"] .game-table,
body[data-current-game="quartet"] .hand-section,
body[data-current-game="quartet"] .log-section,
body[data-current-game="quartet"] .action-panel {
  border-radius: 26px !important;
  border: 1px solid rgba(255,255,255,.7) !important;
  background: linear-gradient(145deg, rgba(255,255,255,.86), rgba(232,241,255,.68)) !important;
  box-shadow: 0 14px 34px rgba(79,70,229,.11), inset 0 1px 0 rgba(255,255,255,.88) !important;
  color: #0f172a !important;
}
body[data-current-game="quartet"] .card-3d { padding: 14px !important; margin-bottom: 12px !important; }
body[data-current-game="quartet"] .input-group { margin-bottom: 10px !important; }
body[data-current-game="quartet"] .room-code-display { padding: 16px !important; margin: 0 0 12px !important; }
body[data-current-game="quartet"] .room-code { font-size: clamp(2rem, 10vw, 3.4rem) !important; color: #312e81 !important; text-shadow: none !important; }
body[data-current-game="quartet"] .lobby-player-row { border-radius: 18px !important; background: rgba(255,255,255,.8) !important; }
body[data-current-game="quartet"] .grid-2 { gap: 10px !important; }
body[data-current-game="quartet"] .btn {
  min-height: 50px !important;
  border-radius: 18px !important;
  margin-bottom: 10px !important;
  padding: 12px 16px !important;
  font-weight: 950 !important;
}
body[data-current-game="quartet"] .btn-primary { background: linear-gradient(135deg, #4f46e5, #0ea5e9) !important; color: #fff !important; box-shadow: 0 16px 30px rgba(79,70,229,.2) !important; }
body[data-current-game="quartet"] .btn-secondary { background: rgba(255,255,255,.86) !important; color: #2563eb !important; border: 1px solid rgba(99,102,241,.18) !important; }
body[data-current-game="quartet"] .btn-icon { width: 46px !important; height: 46px !important; min-height: 46px !important; }
body[data-current-game="quartet"] .game-table {
  min-height: 0 !important;
  margin: 0 0 10px !important;
  padding: 12px !important;
  overflow: hidden !important;
}
body[data-current-game="quartet"] .table-felt { display: none !important; }
body[data-current-game="quartet"] .players-ring {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px !important;
  padding: 0 !important;
}
body[data-current-game="quartet"] .player-avatar {
  display: grid !important;
  grid-template-columns: 42px 1fr !important;
  align-items: center !important;
  gap: 9px !important;
  padding: 9px !important;
  border-radius: 18px !important;
  background: rgba(255,255,255,.76) !important;
  border: 1px solid rgba(99,102,241,.12) !important;
  transform: none !important;
}
body[data-current-game="quartet"] .player-avatar.active { background: rgba(254,243,199,.88) !important; box-shadow: 0 0 0 2px rgba(245,158,11,.25) inset !important; }
body[data-current-game="quartet"] .avatar-circle {
  width: 42px !important; height: 42px !important; font-size: 17px !important;
  border: 0 !important; background: linear-gradient(135deg, #4f46e5, #0ea5e9) !important;
}
body[data-current-game="quartet"] .player-info { color: #0f172a !important; text-align: left !important; text-shadow: none !important; min-width:0 !important; }
body[data-current-game="quartet"] .player-cards-count { background: rgba(79,70,229,.1) !important; color: #312e81 !important; }
body[data-current-game="quartet"] .game-info-wrap { padding: 0 0 8px !important; }
body[data-current-game="quartet"] #turnIndicator {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 44px !important;
  padding: 9px 14px !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,.78) !important;
  box-shadow: 0 8px 18px rgba(79,70,229,.08) !important;
  font-size: clamp(.95rem, 4vw, 1.12rem) !important;
  color: #312e81 !important;
}
body[data-current-game="quartet"] #quartetsDisplay { margin-bottom: 2px !important; }
body[data-current-game="quartet"] .quartet-badge { padding: 7px 11px !important; font-size: .82rem !important; }
body[data-current-game="quartet"] .hand-section { padding: 12px !important; margin: 0 0 10px !important; }
body[data-current-game="quartet"] .section-caption { margin-bottom: 8px !important; color: rgba(49,46,129,.62) !important; }
body[data-current-game="quartet"] .cards-fan { gap: 8px !important; }
body[data-current-game="quartet"] .hand-group { border-radius: 22px !important; }
body[data-current-game="quartet"] .hand-group-head { padding: 11px !important; gap: 9px !important; }
body[data-current-game="quartet"] .card-header-row { flex-basis: 48px !important; }
body[data-current-game="quartet"] .card-icon { width: 38px !important; height: 38px !important; border-radius: 13px !important; }
body[data-current-game="quartet"] .card-title { font-size: 1rem !important; }
body[data-current-game="quartet"] .card-subtitle { font-size: .78rem !important; }
body[data-current-game="quartet"] .mini-cards-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
body[data-current-game="quartet"] .mini-card { min-height: 68px !important; padding: 9px !important; border-radius: 16px !important; }
body[data-current-game="quartet"] .action-panel {
  position: sticky !important;
  bottom: calc(8px + env(safe-area-inset-bottom,0px)) !important;
  margin: 0 0 10px !important;
  padding: 12px !important;
  border-radius: 26px !important;
  z-index: 70 !important;
}
body[data-current-game="quartet"] .action-handle { display: none !important; }
body[data-current-game="quartet"] .action-title { font-size: 1.04rem !important; }
body[data-current-game="quartet"] .action-text { font-size: .9rem !important; }
body[data-current-game="quartet"] .log-section { padding: 12px !important; margin: 0 !important; }
body[data-current-game="quartet"] .game-log { max-height: 132px !important; padding: 10px !important; border-radius: 18px !important; background: rgba(255,255,255,.74) !important; }
body[data-current-game="quartet"] .modal-content,
body[data-current-game="quartet"] .wait-box { border-radius: 26px !important; }
@media (max-width: 520px) {
  body[data-current-game="bible-wordsearch"] #game-container,
  body[data-current-game="bible-wow"] #game-container,
  body[data-current-game="sacred-word"] #game-container,
  body[data-current-game="quartet"] #game-container {
    padding-top: calc(env(safe-area-inset-top, 0px) + 76px) !important;
  }
  body[data-current-game="bible-wow"] .wow-top { grid-template-columns: 1fr !important; }
  body[data-current-game="bible-wow"] .wow-top > .wow-pill { justify-content: center !important; }
  body[data-current-game="bible-wow"] .wow-actions { grid-template-columns: 1fr 1fr !important; }
  body[data-current-game="quartet"] .players-ring { grid-template-columns: 1fr 1fr !important; }
  body[data-current-game="quartet"] .game-header { top: calc(env(safe-area-inset-top, 0px) + 66px) !important; }
}
@media (max-width: 380px) {
  body[data-current-game="bible-wordsearch"] .ws-actions .start-button,
  body[data-current-game="bible-wordsearch"] .ws-actions .wrong-button { font-size: .84rem !important; }
  body[data-current-game="bible-wow"] .wow-actions .wow-chip { font-size: .78rem !important; padding: 8px 7px !important; }
  body[data-current-game="quartet"] .players-ring { grid-template-columns: 1fr !important; }
  body[data-current-game="quartet"] .mini-cards-grid { grid-template-columns: 1fr !important; }
}
body[data-current-game="quartet"] .quartet-play-guide {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0,1fr)) !important;
  gap: 8px !important;
  margin: 0 0 10px !important;
}
body[data-current-game="quartet"] .quartet-play-guide span {
  display: grid !important;
  place-items: center !important;
  min-height: 42px !important;
  padding: 8px !important;
  border-radius: 18px !important;
  background: rgba(255,255,255,.76) !important;
  border: 1px solid rgba(99,102,241,.14) !important;
  color: #312e81 !important;
  font-size: clamp(.72rem, 3vw, .9rem) !important;
  font-weight: 900 !important;
  text-align: center !important;
  line-height: 1.12 !important;
}
@media (max-width: 380px) {
  body[data-current-game="quartet"] .quartet-play-guide { grid-template-columns: 1fr !important; }
}


/* =========================================================
   v16 — точечные правки: Sacred Word, Bible Words, Quartet
   ========================================================= */
body[data-current-game="bible-wow"] #game-container,
body[data-current-game="sacred-word"] #game-container,
body[data-current-game="quartet"] #game-container {
  padding-top: calc(env(safe-area-inset-top, 0px) + 76px) !important;
}

/* Библейские слова: меню + выбор уровня в одной строке, звёзды справа сверху,
   стрелки уровня строго над колесом букв */
body[data-current-game="bible-wow"] .wow-wrap {
  position: relative !important;
  width: min(100%, 640px) !important;
  gap: 9px !important;
}
body[data-current-game="bible-wow"] .wow-head {
  position: relative !important;
  min-height: 52px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 86px 0 0 !important;
}
body[data-current-game="bible-wow"] .wow-head-row {
  width: 100% !important;
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 8px !important;
}
body[data-current-game="bible-wow"] .wow-head-row .wow-chip {
  min-height: 48px !important;
  justify-content: center !important;
  border-radius: 19px !important;
  background: rgba(255,255,255,.90) !important;
  color: #2563eb !important;
  box-shadow: 0 12px 24px rgba(79,70,229,.10) !important;
}
body[data-current-game="bible-wow"] .wow-stars-floating {
  position: absolute !important;
  top: 4px !important;
  right: 0 !important;
  min-width: 76px !important;
  min-height: 42px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 8px 10px !important;
  border-radius: 18px !important;
  background: rgba(255,255,255,.92) !important;
  color: #0f172a !important;
  font-size: 1rem !important;
  font-weight: 950 !important;
  z-index: 3 !important;
}
body[data-current-game="bible-wow"] .wow-level-switch {
  width: 100% !important;
  display: grid !important;
  grid-template-columns: 52px 1fr 52px !important;
  align-items: center !important;
  gap: 8px !important;
  order: 1 !important;
}
body[data-current-game="bible-wow"] .wow-level-switch .wow-chip {
  min-height: 46px !important;
  justify-content: center !important;
  border-radius: 18px !important;
  font-size: 1rem !important;
}
body[data-current-game="bible-wow"] .wow-level-switch .wow-title {
  min-height: 46px !important;
  display: grid !important;
  place-items: center !important;
  border-radius: 18px !important;
  background: rgba(255,255,255,.86) !important;
  border: 1px solid rgba(99,102,241,.13) !important;
  color: #312e81 !important;
}
body[data-current-game="bible-wow"] .wow-preview { order: 2 !important; }
body[data-current-game="bible-wow"] .wow-wheel-wrap { order: 3 !important; }
body[data-current-game="bible-wow"] .wow-actions { order: 4 !important; grid-template-columns: 1fr 1fr !important; }
body[data-current-game="bible-wow"] #wow-reset { grid-column: 1 / -1 !important; }
body[data-current-game="bible-wow"] .wow-board-area { min-height: clamp(168px, 28dvh, 250px) !important; }
@media (max-width: 430px) {
  body[data-current-game="bible-wow"] .wow-head { padding-right: 78px !important; }
  body[data-current-game="bible-wow"] .wow-head-row .wow-chip { font-size: .9rem !important; padding-inline: 8px !important; }
  body[data-current-game="bible-wow"] .wow-stars-floating { min-width: 70px !important; font-size: .92rem !important; }
}

/* Священное слово: эстетичный фон вокруг меноры и более кинематографичный блок */
body[data-current-game="sacred-word"] .sw-wrap { width: min(100%, 690px) !important; }
body[data-current-game="sacred-word"] .sw-card {
  overflow: hidden !important;
  background:
    radial-gradient(circle at 23% 35%, rgba(255,221,122,.35), transparent 30%),
    radial-gradient(circle at 78% 24%, rgba(125,211,252,.32), transparent 32%),
    linear-gradient(145deg, rgba(255,255,255,.86), rgba(226,239,255,.76)) !important;
}
body[data-current-game="sacred-word"] .sw-lamp-card {
  position: relative !important;
  min-height: 222px !important;
  background:
    radial-gradient(circle at 50% 45%, rgba(255,231,155,.56) 0 13%, rgba(255,202,92,.18) 24%, transparent 45%),
    radial-gradient(circle at 50% 120%, rgba(14,165,233,.26), transparent 52%),
    linear-gradient(160deg, rgba(255,255,255,.70), rgba(215,230,255,.54)) !important;
  border: 1px solid rgba(255,255,255,.82) !important;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.95),
    inset 0 -24px 58px rgba(59,130,246,.11),
    0 20px 42px rgba(79,70,229,.13) !important;
}
body[data-current-game="sacred-word"] .sw-lamp-card::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 26px;
  background:
    linear-gradient(90deg, transparent 0 48%, rgba(255,255,255,.26) 50%, transparent 52%),
    linear-gradient(0deg, transparent 0 48%, rgba(255,255,255,.20) 50%, transparent 52%);
  background-size: 42px 42px;
  opacity: .35;
  pointer-events: none;
}
body[data-current-game="sacred-word"] .sw-lamp-card::after {
  content: "";
  position: absolute;
  left: 16%; right: 16%; bottom: 18px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(245,158,11,.25), transparent 72%);
  filter: blur(2px);
  pointer-events: none;
}
body[data-current-game="sacred-word"] .sw-lamp-card canvas {
  position: relative !important;
  z-index: 1 !important;
  max-width: 250px !important;
  filter: drop-shadow(0 22px 26px rgba(80,45,0,.22)) saturate(1.08) contrast(1.04) !important;
}
body[data-current-game="sacred-word"] .sw-info { align-content: center !important; }
body[data-current-game="sacred-word"] .sw-message { color: #312e81 !important; font-weight: 950 !important; }
@media (max-width: 520px) {
  body[data-current-game="sacred-word"] .sw-grid { grid-template-columns: 42% 1fr !important; }
  body[data-current-game="sacred-word"] .sw-lamp-card { min-height: 206px !important; }
  body[data-current-game="sacred-word"] .sw-lamp-card canvas { max-width: 218px !important; }
}
@media (max-width: 390px) {
  body[data-current-game="sacred-word"] .sw-grid { grid-template-columns: 1fr !important; }
  body[data-current-game="sacred-word"] .sw-lamp-card { min-height: 190px !important; }
}

/* Квартет: убрать наложения, сделать тексты читаемыми на светлой палитре */
body[data-current-game="quartet"] #game-container { padding-top: calc(env(safe-area-inset-top,0px) + 84px) !important; }
body[data-current-game="quartet"] .quartet-root { width: 100% !important; }
body[data-current-game="quartet"] .game-header {
  position: relative !important;
  top: auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  margin: 0 0 12px !important;
  z-index: 2 !important;
}
body[data-current-game="quartet"] #authScreen .game-header {
  display: grid !important;
  place-items: center !important;
  text-align: center !important;
  padding: 18px 14px !important;
}
body[data-current-game="quartet"] .content-wrap { display: grid !important; gap: 12px !important; }
body[data-current-game="quartet"] .card-3d,
body[data-current-game="quartet"] .room-code-display {
  margin: 0 !important;
}
body[data-current-game="quartet"] .input-label,
body[data-current-game="quartet"] .room-code-label,
body[data-current-game="quartet"] .guide-title,
body[data-current-game="quartet"] .section-caption {
  color: #64748b !important;
  opacity: 1 !important;
}
body[data-current-game="quartet"] .guide-text,
body[data-current-game="quartet"] .lobby-player-name,
body[data-current-game="quartet"] .lobby-player-meta,
body[data-current-game="quartet"] .empty-note,
body[data-current-game="quartet"] .action-text,
body[data-current-game="quartet"] .game-log,
body[data-current-game="quartet"] .rules-intro,
body[data-current-game="quartet"] .rules-list,
body[data-current-game="quartet"] .rules-section {
  color: #334155 !important;
  opacity: 1 !important;
  text-shadow: none !important;
}
body[data-current-game="quartet"] .guide-text {
  margin-top: 10px !important;
  padding: 12px !important;
  border-radius: 18px !important;
  background: rgba(255,255,255,.72) !important;
  border: 1px solid rgba(99,102,241,.12) !important;
  line-height: 1.42 !important;
  font-weight: 750 !important;
}
body[data-current-game="quartet"] .game-title { overflow-wrap: anywhere !important; }
body[data-current-game="quartet"] #leaveBtn {
  flex: 0 0 48px !important;
  background: rgba(255,255,255,.88) !important;
  color: #2563eb !important;
  border: 1px solid rgba(99,102,241,.16) !important;
  box-shadow: 0 10px 22px rgba(79,70,229,.10) !important;
}
body[data-current-game="quartet"] .room-code-display {
  padding: 14px !important;
  display: grid !important;
  gap: 10px !important;
  text-align: center !important;
}
body[data-current-game="quartet"] .room-code { line-height: 1 !important; }
body[data-current-game="quartet"] .copy-row { display: flex !important; justify-content: center !important; }
body[data-current-game="quartet"] .copy-row .btn { margin-bottom: 0 !important; }
body[data-current-game="quartet"] .lobby-player-row {
  min-height: 62px !important;
  padding: 10px 12px !important;
}
body[data-current-game="quartet"] #startBtn:disabled,
body[data-current-game="quartet"] .btn:disabled {
  opacity: .64 !important;
  color: rgba(49,46,129,.72) !important;
  filter: none !important;
}
body[data-current-game="quartet"] .modal-content,
body[data-current-game="quartet"] .wait-box {
  background: linear-gradient(145deg, rgba(255,255,255,.96), rgba(232,241,255,.92)) !important;
  color: #0f172a !important;
}
body[data-current-game="quartet"] .players-ring { align-items: stretch !important; }
body[data-current-game="quartet"] .player-avatar { min-width: 0 !important; }
body[data-current-game="quartet"] .player-info { overflow: hidden !important; }
body[data-current-game="quartet"] .player-info strong,
body[data-current-game="quartet"] .player-name {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
body[data-current-game="quartet"] .turn-target-selector {
  background: rgba(255,255,255,.82) !important;
  border-color: rgba(99,102,241,.18) !important;
  color: #312e81 !important;
}
body[data-current-game="quartet"] .turn-target-selector > div { color: #312e81 !important; }
body[data-current-game="quartet"] .input-field,
body[data-current-game="quartet"] .compact-select {
  background: rgba(255,255,255,.94) !important;
  color: #0f172a !important;
  border-color: rgba(99,102,241,.22) !important;
}
body[data-current-game="quartet"] .mini-card {
  color: #0f172a !important;
  border: 1px solid rgba(99,102,241,.16) !important;
  background: rgba(255,255,255,.88) !important;
}
body[data-current-game="quartet"] .mini-card.missing { background: rgba(239,246,255,.88) !important; }
body[data-current-game="quartet"] .mini-card-top { color: #64748b !important; opacity: 1 !important; }
body[data-current-game="quartet"] .mini-card-title { color: #0f172a !important; }
body[data-current-game="quartet"] .action-panel { position: relative !important; bottom: auto !important; }
@media (max-width: 430px) {
  body[data-current-game="quartet"] #game-container { padding-top: calc(env(safe-area-inset-top,0px) + 78px) !important; }
  body[data-current-game="quartet"] .game-title { font-size: clamp(1.45rem, 8vw, 2.2rem) !important; }
  body[data-current-game="quartet"] .grid-2 { grid-template-columns: 1fr !important; }
  body[data-current-game="quartet"] .players-ring { grid-template-columns: 1fr !important; }
  body[data-current-game="quartet"] .quartet-play-guide { grid-template-columns: 1fr !important; }
}
