/* Тактическая доска: сначала телефон; светлая и тёмная тема по настройке системы. */
: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 {
  display: grid;
  grid-template-columns: minmax(72px, auto) 1fr minmax(72px, auto);
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  padding-top: max(4px, env(safe-area-inset-top));
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.bar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar > :first-child { justify-self: start; }
.bar > :last-child { justify-self: end; }

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: «Шаг 10 из 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; }

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

.languages { display: flex; justify-content: center; gap: 6px; margin-top: 20px; }
.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.15; }
.piece .ball { stroke: #111827; stroke-width: 0.15; }

.piece text {
  fill: #fff;
  font: 700 1.25px -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.ghost { opacity: 0.3; }
.trail { fill: none; stroke-width: 0.15; stroke-dasharray: 0.5 0.35; }
.trail.pass { stroke-dasharray: none; }
.selection { fill: none; stroke: #facc15; stroke-width: 0.3; 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; }
.title-line {
  margin: 0;
  padding: 4px 4px 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note { margin: 0; padding: 2px 4px 0; font-size: 15px; }
.note:empty { display: none; }
.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; }
.note-row { display: flex; align-items: center; gap: 6px; }

.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; }
