/* ====== Тема (берём цвета Telegram, с запасными значениями) ====== */
:root {
  --bg:        var(--tg-theme-bg-color, #0f1115);
  --card:      var(--tg-theme-secondary-bg-color, #1b1f29);
  --text:      var(--tg-theme-text-color, #e8eaed);
  --hint:      var(--tg-theme-hint-color, #8a8f98);
  --btn:       var(--tg-theme-button-color, #3a7afe);
  --btn-text:  var(--tg-theme-button-text-color, #ffffff);

  /* отступы под «чёлку»/панели — JS подставит реальные значения от Telegram,
     а env(...) — запас для обычного браузера и iOS */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* ВОТ ЭТО не даёт обрезать контент сверху/снизу под «чёлкой» */
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  overscroll-behavior: none;  /* чтобы случайным свайпом не закрыть приложение */
  user-select: none;
}

/* ====== Верхняя панель ====== */
#topbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
}
#turn { font-weight: 600; }
#dice { font-size: 20px; letter-spacing: 2px; }

/* ====== Доска ====== */
#board-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  min-height: 0;
}
#board {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
  background: var(--card);
  border-radius: 12px;
  padding: 6px;
}
.point {
  position: relative;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* треугольники пунктов (как на настоящей доске) */
.point::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.28;
}
.point.top::before    { clip-path: polygon(0 0, 100% 0, 50% 92%); }
.point.bottom::before { clip-path: polygon(50% 8%, 0 100%, 100% 100%); }
.point.dark::before   { background: #6b7280; }
.point.light::before  { background: #9aa3b2; }

/* номер пункта */
.point .num {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 10px;
  color: var(--hint);
}
.point.bottom .num { top: auto; bottom: 2px; }

/* шашка-диск с числом */
.checker {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  z-index: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.checker.white { background: #f3f4f6; color: #111; }
.checker.black { background: #20242c; color: #f3f4f6; border: 2px solid #3a4150; }

#off-line {
  text-align: center;
  color: var(--hint);
  font-size: 14px;
}

/* ====== Нижняя панель ====== */
#controls {
  flex: 0 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#moves {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 26vh;
  overflow-y: auto;
}
button {
  font: inherit;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
button.move {
  background: var(--card);
  color: var(--text);
  border: 1px solid #333a47;
}
button.move:active { background: #2a3140; }
button.primary {
  background: var(--btn);
  color: var(--btn-text);
  font-weight: 600;
  padding: 14px;
}
#status {
  text-align: center;
  font-weight: 600;
  padding: 6px;
}
