/* ==========================================================================
   POKER TRAINER — Telegram Mini App · Design tokens + core components
   Идентичность: «solver console» — глубокие чернильно-синие поверхности,
   тёплый костяной текст, цвета действий = номиналы покерных фишек.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* ---- Поверхности (чернильно-синие, НЕ чёрные) ---- */
  --ink-900: #0D1120;   /* фон приложения        (tg-theme bg_color)          */
  --ink-800: #141A2C;   /* карточка / секция     (tg-theme secondary_bg_color)*/
  --ink-750: #1A2135;   /* приподнятый элемент (кнопки, чипы)                 */
  --cell-empty: #161C2D;/* клетка вне диапазона — темнее фишки fold           */
  --ink-700: #222B44;   /* hover / нажатое                                    */
  --line:    #2C3654;   /* границы, сетка матрицы                             */
  --line-soft:#212A42;  /* тихий разделитель                                  */

  /* ---- Текст ---- */
  --bone:    #ECE7DC;   /* основной текст, тёплый костяной (tg-theme text)     */
  --bone-dim:#B9B3A6;   /* вторичный                                          */
  --mute:    #7C87A6;   /* подписи, неактивные подписи рук (tg-theme hint)     */
  --mute-deep:#556084;  /* самый тихий                                        */

  /* ---- Действия = номиналы фишек (единственный источник цвета) ---- */
  --raise:   #E5533D;   /* глиняно-красная фишка — bet / raise                */
  --raise-d: #8C2A1D;   /* её тёмный тон (для strata / фонов)                 */
  --call:    #2FBF9B;   /* нефритовая фишка — call / check-call               */
  --call-d:  #17705B;
  --fold:    #5E6CA0;   /* сланцевая фишка — fold / check (светлее клетки!)   */
  --fold-d:  #39436B;
  --gold:    #F2C14E;   /* акцент бренда: CTA, «твоя рука», вердикт           */
  --gold-d:  #8A6A21;

  /* ---- Масти ---- */
  --suit-s:  #ECE7DC;   /* ♠ пики   */
  --suit-h:  #E5533D;   /* ♥ червы  */
  --suit-d:  #5B9DF0;   /* ♦ бубны  */
  --suit-c:  #2FBF9B;   /* ♣ трефы  */

  /* ---- Типографика ---- */
  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body:    'IBM Plex Sans', 'Segoe UI', sans-serif;
  --font-data:    'IBM Plex Mono', 'Consolas', monospace;

  /* ---- Радиусы / тени ---- */
  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow-card: 0 1px 0 rgba(255,255,255,.04) inset, 0 8px 24px rgba(0,0,0,.35);

  /* ---- Сетка ---- */
  --pad: 14px;          /* горизонтальные поля экрана 390px */
  --gap: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink-900);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Телефонный контейнер 390px */
.screen {
  width: min(390px, 100%);
  margin: 0 auto;
  padding: 0 var(--pad) 28px;
  position: relative;
}

/* ---------- Типографические роли ---------- */
.h1 { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1.2; letter-spacing: -.01em; margin: 0; }
.h2 { font-family: var(--font-display); font-weight: 600; font-size: 17px; line-height: 1.25; margin: 0; }
.eyebrow {
  font-family: var(--font-data); font-weight: 600; font-size: 10px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--mute);
}
.body { font-size: 15px; color: var(--bone-dim); margin: 0; }
.data { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.caption { font-size: 12px; color: var(--mute); }

/* ---------- Топбар ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 48px; position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--ink-900) 72%, rgba(13,17,32,0));
}
.topbar .back { color: var(--mute); font-size: 20px; line-height: 1; background: none; border: 0; padding: 4px 8px 4px 0; cursor: pointer; }
.topbar .title { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.pill {
  font-family: var(--font-data); font-size: 11px; font-weight: 600;
  padding: 4px 8px; border-radius: 999px;
  background: var(--ink-750); border: 1px solid var(--line); color: var(--bone-dim);
}
.pill--gold { color: var(--gold); border-color: var(--gold-d); background: rgba(242,193,78,.08); }

/* Прогресс раздачи */
.progress { display: flex; gap: 3px; margin: 2px 0 12px; }
.progress i { flex: 1; height: 3px; border-radius: 2px; background: var(--line-soft); }
.progress i.done { background: var(--call); }
.progress i.miss { background: var(--raise); }
.progress i.now  { background: var(--gold); }

/* ---------- Карточка ---------- */
.card {
  background: var(--ink-800);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 14px;
  box-shadow: var(--shadow-card);
}
.card + .card { margin-top: var(--gap); }

/* ---------- Спот: борд ---------- */
.board { display: flex; gap: 6px; }
.pcard {
  width: 44px; height: 62px; border-radius: 8px;
  background: linear-gradient(180deg, #F7F4EC, #E3DED1);
  color: #16192A;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; line-height: 1;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.pcard .rank { font-size: 20px; }
.pcard .suit { font-size: 16px; margin-top: 2px; }
.pcard[data-suit="s"] { color: #16192A; }
.pcard[data-suit="h"] { color: #C2402C; }
.pcard[data-suit="d"] { color: #2C68B8; }
.pcard[data-suit="c"] { color: #14775F; }
/* Карта героя — темнее, с золотым кантом */
.pcard.hero {
  background: linear-gradient(180deg, #232C46, #192034);
  border: 1px solid var(--gold-d);
  color: var(--bone);
  width: 38px; height: 54px;
}
.pcard.hero .rank { font-size: 17px; }
.pcard.hero[data-suit="h"] { color: var(--suit-h); }
.pcard.hero[data-suit="d"] { color: var(--suit-d); }
.pcard.hero[data-suit="c"] { color: var(--suit-c); }

/* Строка стеков — данные моноширинным */
.stats { display: flex; gap: 0; margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
.stat { flex: 1; }
.stat + .stat { border-left: 1px solid var(--line-soft); padding-left: 10px; }
.stat .k { font-family: var(--font-data); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute-deep); display: block; }
.stat .v { font-family: var(--font-data); font-weight: 600; font-size: 14px; color: var(--bone); }

/* ---------- Кнопки действий ---------- */
.actions { display: grid; gap: 8px; }
.actions.two { grid-template-columns: 1fr 1fr; }
.actions.three { grid-template-columns: 1fr 1fr 1fr; }

.act {
  --c: var(--fold);
  --cd: var(--fold-d);
  appearance: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 13px 14px; min-height: 56px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--ink-750);
  color: var(--bone);
  font-family: var(--font-display); font-weight: 600; font-size: 16px;
  text-align: left;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
  position: relative; overflow: hidden;
}
/* полоска-фишка слева = цвет действия */
.act::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c);
}
.act .sub { font-family: var(--font-data); font-size: 11px; font-weight: 500; color: var(--mute); }
.act[data-act="raise"] { --c: var(--raise); --cd: var(--raise-d); }
.act[data-act="call"]  { --c: var(--call);  --cd: var(--call-d); }
.act[data-act="fold"]  { --c: var(--fold);  --cd: var(--fold-d); }
.act:hover { background: var(--ink-700); }
.act:active { transform: scale(.985); }
.act:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* состояния */
.act.is-selected { background: color-mix(in srgb, var(--c) 18%, var(--ink-750)); border-color: var(--c); }
.act.is-correct  { background: color-mix(in srgb, var(--call) 20%, var(--ink-750)); border-color: var(--call); }
.act.is-wrong    { background: color-mix(in srgb, var(--raise) 16%, var(--ink-750)); border-color: var(--raise); }
.act.is-muted    { opacity: .45; }
.act .badge {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-data); font-size: 11px; font-weight: 600;
  padding: 3px 6px; border-radius: 999px;
}
.act.is-correct .badge { background: var(--call); color: #04241C; }
.act.is-wrong   .badge { background: var(--raise); color: #2A0A05; }

/* Размеры ставки — сегменты */
.sizes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.size {
  cursor: pointer; appearance: none;
  border: 1px solid var(--line); background: var(--ink-750); color: var(--bone);
  border-radius: 10px; padding: 10px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.size .pct { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.size .bb  { font-family: var(--font-data); font-size: 10px; color: var(--mute); }
.size.is-selected { border-color: var(--raise); background: color-mix(in srgb, var(--raise) 18%, var(--ink-750)); }
.size.is-solver   { border-color: var(--gold); }
.size:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- CTA ---------- */
.cta {
  display: block; width: 100%; cursor: pointer;
  padding: 14px; border: 0; border-radius: var(--r-md);
  background: var(--gold); color: #22190B;
  font-family: var(--font-display); font-weight: 700; font-size: 16px;
}
.cta:active { transform: scale(.99); }
.cta.secondary { background: var(--ink-750); color: var(--bone); border: 1px solid var(--line); }
.cta:focus-visible { outline: 2px solid var(--bone); outline-offset: 2px; }

/* ==========================================================================
   МАТРИЦА 13×13 — сигнатурный элемент: клетка = стопка фишек.
   Смешанная стратегия = горизонтальные слои снизу вверх (fold→call→raise),
   высота слоя = частота. Подпись руки ВСЕГДА читаема (bone + тень).
   ========================================================================== */
.matrix {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 1px;
  background: var(--line);          /* сетка = фон, клетки перекрывают */
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1 / 1;
}
.cell {
  position: relative;
  background: var(--cell-empty);    /* «пустая» клетка вне диапазона */
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cell .strata { position: absolute; inset: 0; display: flex; flex-direction: column-reverse; }
.cell .strata span { display: block; width: 100%; }
.cell .strata .s-fold  { background: var(--fold); }
.cell .strata .s-call  { background: var(--call); }
.cell .strata .s-raise { background: var(--raise); }
.cell .lbl {
  position: relative; z-index: 2;
  font-family: var(--font-data); font-weight: 600;
  color: var(--bone);
  text-shadow: 0 1px 2px rgba(0,0,0,.55);
  letter-spacing: -.02em;
  pointer-events: none;
}
/* режим «состав диапазона» (вопрос ещё не отвечен): стратегия не раскрыта */
.cell.is-inrange { background: #2F3A5C; }
.cell.is-inrange .lbl { color: var(--bone); }
/* рука вне диапазона (ничего не делаем) — подпись тихая */
.cell.is-empty .lbl { color: var(--mute-deep); text-shadow: none; font-weight: 500; }
/* диагональ — пары: тонкий кант, чтобы читалась ось */
.cell.is-pair { box-shadow: inset 0 0 0 1px rgba(236,231,220,.14); }
/* текущая рука героя — золотой кант + внешний ореол */
.cell.is-hero {
  box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 2px rgba(242,193,78,.45), 0 0 10px rgba(242,193,78,.35);
  z-index: 4;
}
.cell.is-hero .lbl { color: #fff; font-weight: 600; }
/* выбранная пользователем (режим раскраски) */
.cell.is-picked { box-shadow: inset 0 0 0 2px var(--bone); z-index: 3; }
/* ошибки после проверки */
.cell.is-err-miss  { box-shadow: inset 0 0 0 2px var(--gold); }
.cell.is-err-extra { box-shadow: inset 0 0 0 2px var(--raise); }

/* размеры под контекст */
.matrix--compact { font-size: 9.5px; }
.matrix--compact .cell .lbl { font-size: 9.5px; }
.matrix--full { font-size: 11px; }
.matrix--full .cell .lbl { font-size: 11px; }

/* ---------- Легенда ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 10px; }
.legend .li { display: flex; align-items: center; gap: 6px; font-family: var(--font-data); font-size: 11px; color: var(--bone-dim); }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.35); }
.sw--raise { background: var(--raise); }
.sw--call  { background: var(--call); }
.sw--fold  { background: var(--fold); }
.sw--empty { background: var(--cell-empty); border-color: var(--line); }
.sw--mixed { background: linear-gradient(180deg, var(--raise) 0 45%, var(--call) 45% 75%, var(--fold) 75% 100%); }

/* ---------- Частотная полоса (тот же язык слоёв, горизонтально) ---------- */
.freq { height: 10px; border-radius: 999px; overflow: hidden; display: flex; background: var(--ink-750); }
.freq span { display: block; height: 100%; }
.freq .f-raise { background: var(--raise); }
.freq .f-call  { background: var(--call); }
.freq .f-fold  { background: var(--fold); }
.freq-legend { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--font-data); font-size: 11px; color: var(--mute); }

/* ---------- Вердикт ---------- */
.verdict {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--ink-800);
}
.verdict .mark {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
}
.verdict--ok    { border-color: var(--call-d);  background: color-mix(in srgb, var(--call) 12%, var(--ink-800)); }
.verdict--ok .mark   { background: var(--call); color: #04241C; }
.verdict--bad   { border-color: var(--raise-d); background: color-mix(in srgb, var(--raise) 12%, var(--ink-800)); }
.verdict--bad .mark  { background: var(--raise); color: #2A0A05; }
.verdict .t { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.verdict .s { font-family: var(--font-data); font-size: 11px; color: var(--bone-dim); }
.verdict .ev { margin-left: auto; text-align: right; font-family: var(--font-data); }
.verdict .ev b { display: block; font-size: 15px; }
.verdict .ev i { font-style: normal; font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--mute-deep); }

/* ---------- Нижняя панель ---------- */
.bottom { position: sticky; bottom: 0; padding: 12px 0 6px; background: linear-gradient(rgba(13,17,32,0), var(--ink-900) 30%); }

/* Секционный ярлык (только для демо-страниц макета) */
.state-label {
  margin: 26px 0 10px; padding: 6px 10px;
  border-left: 2px solid var(--gold);
  font-family: var(--font-data); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--gold);
  background: rgba(242,193,78,.06);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
