/* =================================================================
   style.css — доска-хитмэп «ОБОРОНА» (Telegram Mini App)
   Цвета темы Telegram через var(--tg-theme-*) + фолбэки для браузера.
   Mobile-first. Светлая/тёмная тема подхватывается из Telegram.
   ================================================================= */

:root {
  --bg:        var(--tg-theme-bg-color, #ffffff);
  --text:      var(--tg-theme-text-color, #1c1c1e);
  --hint:      var(--tg-theme-hint-color, #8e8e93);
  --link:      var(--tg-theme-link-color, #2481cc);
  --button:    var(--tg-theme-button-color, #2481cc);
  --button-tx: var(--tg-theme-button-text-color, #ffffff);
  --secbg:     var(--tg-theme-secondary-bg-color, #f2f2f7);

  /* Светофор половин клетки. Насыщенные, читаемые на свете и в темноте. */
  --green:  #2ea043;
  --yellow: #d9a200;
  --red:    #e0443e;
  --gray:   #9aa0a6;

  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.screen { padding: 12px 14px 28px; max-width: 720px; margin: 0 auto; }
.hidden { display: none; }

/* ---------- Верхняя панель ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 14px;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 {
  font-size: 19px;
  margin: 0;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.asof { font-size: 12px; color: var(--hint); }

.btn-add, .btn-back {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.btn-add { background: var(--button); color: var(--button-tx); }
.btn-back { background: var(--secbg); color: var(--link); padding: 8px 10px; }

.conv-badge { font-size: 18px; }

.status { color: var(--hint); font-size: 14px; padding: 18px 4px; }
.status.error { color: var(--red); }

/* ---------- Сетка клеток ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.cell {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  min-height: 92px;
  border: 1px solid rgba(127,127,127,.18);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  transition: transform .06s ease;
}
.cell:active { transform: scale(.975); }

/* Две половины-фона: левая = техника, правая = сила тезиса. */
.cell-halves {
  position: absolute;
  inset: 0;
  display: flex;
}
.half { flex: 1; }
.half-left  { /* техника */ }
.half-right { /* сила тезиса — тонкая разделительная линия по центру */
  border-left: 2px solid rgba(255,255,255,.35);
}

.bg-green  { background: var(--green); }
.bg-yellow { background: var(--yellow); }
.bg-red    { background: var(--red); }
.bg-gray   { background: var(--gray); }

/* Контент поверх половин */
.cell-content {
  position: relative;
  z-index: 1;
  padding: 10px 10px 8px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
}
.cell-ticker {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cell-conv { font-size: 14px; }
.cell-foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 11px;
  font-weight: 600;
  opacity: .95;
}
.cell-foot .lhalf, .cell-foot .rhalf { display: flex; align-items: center; gap: 3px; }
.cell-emoji { font-size: 13px; text-shadow: none; }

/* Маркер kill-technical-hit — красная угловая метка */
.cell-kill {
  position: absolute;
  top: 0; right: 0;
  z-index: 2;
  background: #b11;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-bottom-left-radius: 8px;
  letter-spacing: .03em;
}

/* ---------- Легенда ---------- */
.legend {
  margin-top: 22px;
  padding: 14px;
  background: var(--secbg);
  border-radius: var(--radius);
  font-size: 13px;
}
.legend-cols { margin-bottom: 10px; }
.legend-cell { display: flex; align-items: center; gap: 0; }
.legend-cell .swatch-demo {
  display: inline-block;
  width: 22px; height: 22px;
}
.legend-cell .half-left.swatch-demo  { background: var(--green); border-radius: 6px 0 0 6px; }
.legend-cell .half-right.swatch-demo { background: var(--yellow); border-radius: 0 6px 6px 0; border-left: 2px solid rgba(255,255,255,.5); }
.legend-label { margin-left: 10px; color: var(--hint); }

.legend-rows { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.lg { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-red { background: var(--red); }

.legend-note { color: var(--hint); line-height: 1.45; }
.legend-note b { color: var(--text); }
.draft-badge {
  display: inline-block;
  margin-left: 2px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(217,162,0,.18);
  color: var(--yellow);
  border: 1px dashed var(--yellow);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Экран погружения ---------- */
.detail-title h1 { font-size: 22px; }

.dsection {
  background: var(--secbg);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.dsection-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.dsection-head .icon { font-size: 18px; }
.dsection-head h2 { font-size: 15px; margin: 0; }
.dsection-head .draft-badge { margin-left: auto; }

.statusline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
  font-size: 14px;
}
.sl-green  { background: rgba(46,160,67,.16);  color: var(--green); }
.sl-yellow { background: rgba(217,162,0,.16);  color: var(--yellow); }
.sl-red    { background: rgba(224,68,62,.16);  color: var(--red); }
.sl-gray   { background: rgba(154,160,166,.16); color: var(--gray); }

/* Таблица чисел техники */
.nums { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; }
.nums .k { color: var(--hint); font-size: 13px; }
.nums .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.v.pos { color: var(--green); }
.v.neg { color: var(--red); }
.v.muted { color: var(--hint); font-weight: 400; }

/* Текстовые блоки тезиса */
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field .flabel {
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--hint);
  margin-bottom: 3px;
}
.field .fval { font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.field .fval.empty { color: var(--hint); font-style: italic; }

/* Kill-флаги */
.killflags { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px; }
.killflag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 10px;
}
.killflag.hit  { background: rgba(224,68,62,.14); color: var(--red); font-weight: 600; }
.killflag.ok   { background: rgba(46,160,67,.12); color: var(--green); }
.killflag .kf-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--hint);
}

.note { font-size: 13px; color: var(--hint); margin-top: 6px; font-style: italic; }
