/* Тактическая доска: сначала телефон; светлая и тёмная тема по настройке системы. */
:root {
  color-scheme: light dark;
  --bg: #f2f3f5;
  --card: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --line: #e3e5e8;
  --accent: #2563eb;
  --danger: #dc2626;
  --court: #2f7a55;
  --court-out: #276547;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #1a1d23;
    --fg: #f1f3f5;
    --muted: #9aa1ab;
    --line: #2b2f37;
    --accent: #6ea8fe;
    --danger: #f87171;
    --court: #2a6b4b;
    --court-out: #1f5139;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  overscroll-behavior: none;
}

body {
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app { height: 100vh; height: 100dvh; }

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.bar {
  padding: 12px 12px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

/* Длинное название категории — в несколько строк, без многоточия; слово длиннее строки — переносится */
.bar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: break-word;
  word-break: break-word;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  min-height: 44px;
  min-width: 44px;
  padding: 0 10px;
  border-radius: 10px;
  touch-action: manipulation;
  cursor: pointer;
}

button:disabled { opacity: 0.35; cursor: default; }

.link { color: var(--accent); }
.strong { font-weight: 600; }
.icon { font-size: 24px; line-height: 1; }
.tool { color: var(--accent); white-space: nowrap; }
.primary { background: var(--accent); color: #fff; min-width: 56px; font-size: 20px; } /* 360 px: «30 / 30», «Поделиться», «Изменить», ▶ — в строку */
.danger { color: var(--danger); }

.scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
}

.list li + li { border-top: 1px solid var(--line); }

.row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  border-radius: 0;
  padding: 12px 14px;
  min-height: 52px;
}

.row-title { flex: 1; }
.row-meta { color: var(--muted); font-size: 14px; }
.chevron { color: var(--muted); font-size: 22px; line-height: 1; }

/* Главное действие экрана (новая категория, новая комбинация) — под заголовком, на всю ширину */
.big-button {
  width: 100%;
  min-height: 50px;
  margin-bottom: 12px;
  background: #2563eb; /* синяя в обеих темах: на светлом акценте тёмной темы белый текст не читается */
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  border-radius: 12px;
}

.category-actions { display: flex; justify-content: space-between; gap: 8px; margin: -6px 0 8px; }
.name-form { margin-bottom: 12px; }
.name-row { display: flex; align-items: center; gap: 6px; }

/* Категории — квадратные плитки по две в ряд: число комбинаций крупно, под ним название (до 3 строк) */
.tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tile {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-rows: 1fr 1fr; /* число — над серединой, название — под ней: у соседних плиток числа на одной высоте */
  justify-items: center;
  row-gap: 8px;
  padding: 12px;
  background: var(--card);
  border-radius: 16px;
  text-align: center;
}

.tile-count { align-self: end; font-size: 52px; font-weight: 700; line-height: 1; }

.tile-name {
  align-self: start;
  max-width: 100%;
  font-weight: 600;
  overflow-wrap: break-word;
  word-break: break-word; /* слово длиннее плитки — переносится, не вылезает */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.empty { color: var(--muted); text-align: center; margin: 40px 16px; }

/* Языки — в панели снизу главного экрана, вне прокрутки (решение пользователя 2026-11-30) */
.languages { display: flex; justify-content: center; gap: 6px; padding: 4px 0 2px; }
.language { color: var(--muted); border: 1px solid var(--line); min-width: 52px; font-size: 15px; }
.language.active { color: #fff; background: var(--accent); border-color: var(--accent); font-weight: 600; }

.board {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 4px;
}

.court {
  flex: 1;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.court-out { fill: var(--court-out); }
.court-field { fill: var(--court); }
.court-lines { fill: none; stroke: rgba(255, 255, 255, 0.85); stroke-width: 0.12; }
.court-spot { fill: rgba(255, 255, 255, 0.85); }
.goal { fill: rgba(255, 255, 255, 0.25); stroke: rgba(255, 255, 255, 0.85); stroke-width: 0.1; }

.piece circle { stroke: #fff; stroke-width: 0.12; }
/* Мяч — белый с чёрными пятиугольниками и швами (court.js, drawBall) */
.piece .ball-body { fill: #fff; stroke: none; }
.ball-patches { fill: #111827; }
.ball-seams { fill: none; stroke: #111827; stroke-width: 0.018; }
.piece .ball-rim { fill: none; stroke: #111827; stroke-width: 0.03; }

.piece text {
  fill: #fff;
  font: 700 0.68px -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  text-anchor: middle; /* по вертикали — dy в court.js */
  pointer-events: none;
}

/* Скамейки половины поля — вне площадки: цветом команды, без зелёного */
.bench { stroke-width: 0.08; }
.bench-own { fill: rgba(29, 78, 216, 0.16); stroke: rgba(29, 78, 216, 0.55); }
.bench-rival { fill: rgba(220, 38, 38, 0.16); stroke: rgba(220, 38, 38, 0.55); }

.ghost { opacity: 0.3; }
.trail { fill: none; stroke-width: 0.15; stroke-linecap: round; stroke-dasharray: 0.5 0.35; }
.trail.pass { stroke-dasharray: none; }
/* Ручка изгиба — жёлтая, как кольцо выделения: «тянуть», не путать с мячом */
.handle { fill: rgba(250, 204, 21, 0.45); stroke: #facc15; stroke-width: 0.1; pointer-events: none; }
.selection { fill: none; stroke: #facc15; stroke-width: 0.22; pointer-events: none; }

.panel {
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 2px 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.step-label { color: var(--muted); font-size: 14px; white-space: nowrap; }
/* Название комбинации в просмотре — под кнопками, по центру (решение пользователя 2026-11-30) */
.title-line {
  margin: 0;
  padding: 0 4px 4px;
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Просмотры — только админу (решения пользователя 2026-12-01): в списке справа от строки комбинации «👁 8» — отдельная
   кнопка (касание — кто смотрел); строка — как у всех. Экран «кто смотрел» — итог и список */
.list li.with-views { display: flex; }
.list li.with-views .row { flex: 1; min-width: 0; }
.views-button {
  flex: none;
  border-left: 1px solid var(--line);
  border-radius: 0;
  padding: 0 12px;
  color: var(--muted);
  font-size: 15px;
  white-space: nowrap;
}
.views-total { margin: 0 4px 10px; color: var(--muted); }
.row-sub { color: var(--muted); }

/* «Поделиться» — значок в строке кнопок просмотра */
.share { min-width: 40px; padding: 0; color: var(--accent); }
.share svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.controls, .tools { display: flex; align-items: center; justify-content: space-between; gap: 2px; }
.actions { display: flex; align-items: center; gap: 4px; }
.stepper { display: flex; align-items: center; gap: 2px; }

.fields { display: flex; gap: 6px; padding-top: 4px; }

.field {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px; /* меньше 16px — iPhone увеличивает страницу при вводе */
  padding: 8px 10px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--fg);
}

.message { margin: 0; color: var(--danger); font-size: 14px; }
.message:empty { display: none; }

/* Путь одного игрока (просмотр): остальные фишки бледнее следов пути (.ghost — 0.3), чтобы с ними не путались */
.piece.dimmed { opacity: 0.15; }
