/* Модуль «Задачи» — стили. Дизайн-система innochess (Geologica, brand #5451e7). */

:root {
  --brand: #5451e7;
  --brand-dark: #3d3ab0;
  --brand-mid: #6f6df0;
  --orange: #FF6B2B;
  --orange-light: #FFF0E8;
  --orange-mid: #FFD4BB;
  --green: #36b26b;
  --green-light: #e9f9ef;
  --red: #e0455a;
  --red-light: #fdedf0;
  --white: #ffffff;
  --bg: #f7f8ff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: rgba(84, 81, 231, 0.13);
  --card-bg: #ffffff;
  --shadow: 0 10px 30px rgba(84, 81, 231, 0.09);
}

/* двойной тап (ход кликом-кликом, кнопки) не должен зумить страницу; pinch-зум остаётся */
html, body { touch-action: manipulation; }
button, a, input, textarea, .chip, .block-card, .dots .d, .refl-cell { touch-action: manipulation; }
main { width: 100%; max-width: 1080px; min-width: 0; margin: 0 auto; padding: 28px 4% 80px; }
.screen { display: none; }
.screen.on { display: block; animation: rise 0.35s ease both; }
#scr-solve.on { animation: none; }  /* transform из анимации ломает position:fixed бара */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.page-title { font-size: clamp(1.6rem, 4vw, 2.3rem); font-weight: 900; letter-spacing: -0.02em; margin-bottom: 6px; }
.page-sub { color: var(--muted); font-size: 0.95rem; margin-bottom: 26px; }

.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px; box-shadow: var(--shadow);
}

/* ── вход ── */
.gate { text-align: center; padding: 60px 24px; }
.gate .pawn { font-size: 3rem; display: block; margin-bottom: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 26px; border-radius: 12px; border: none; cursor: pointer;
  font-family: inherit; font-size: 0.95rem; font-weight: 700; text-decoration: none;
  background: var(--brand); color: var(--white); transition: background 0.2s, transform 0.15s;
  min-height: 48px;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: scale(0.97); }
.btn.ghost { background: var(--white); color: var(--brand); border: 1.5px solid var(--brand); }
.btn.ghost:hover { background: var(--bg); }
.btn.warn { background: var(--white); color: var(--red); border: 1.5px solid var(--red); }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ── кто решает ── */
.who { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.who-label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.chip {
  padding: 9px 18px; border-radius: 40px; border: 1.5px solid var(--border);
  background: var(--white); cursor: pointer; font-family: inherit;
  font-size: 0.9rem; font-weight: 600; color: var(--text); transition: all 0.18s;
  min-height: 42px;
}
.chip:hover { border-color: var(--brand-mid); }
.chip.sel { background: var(--brand); border-color: var(--brand); color: var(--white); }

/* ── блоки ── */
.blocks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.block-card {
  background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 16px;
  padding: 18px; cursor: pointer; transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  text-align: left; font-family: inherit;
}
.block-card:hover { border-color: var(--brand-mid); transform: translateY(-2px); box-shadow: var(--shadow); }
.block-card .b-title { font-weight: 800; font-size: 1rem; margin-bottom: 4px; }
.block-card .b-meta { color: var(--muted); font-size: 0.8rem; margin-bottom: 12px; }
.block-card .b-bar { height: 8px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.block-card .b-bar i { display: block; height: 100%; background: var(--green); border-radius: 6px; }
.block-card.done { border-color: rgba(54, 178, 107, 0.4); background: linear-gradient(0deg, var(--green-light), var(--white) 60%); }
.block-card.active-b { border-color: var(--orange); }
.b-badge { display: inline-block; font-size: 0.72rem; font-weight: 800; padding: 3px 10px; border-radius: 20px; margin-bottom: 8px; }
.b-badge.new { background: var(--bg); color: var(--brand); }
.b-badge.act { background: var(--orange-light); color: var(--orange); }
.b-badge.fin { background: var(--green-light); color: var(--green); }

/* ── решение ── */
.solve-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: start; gap: 10px 16px; margin-bottom: 14px;
}
.solve-info { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.solve-status { display: flex; align-items: center; justify-content: flex-end; gap: 10px; white-space: nowrap; }
.solve-num { font-size: 1.25rem; font-weight: 900; }
.solve-theme { color: var(--muted); font-size: 0.88rem; font-weight: 600; }
.solve-source { color: var(--brand); font-size: 0.72rem; font-weight: 700; line-height: 1.35; margin-top: 2px; max-width: min(82vw, 620px); }
.turn-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px; border-radius: 30px;
  font-size: 0.82rem; font-weight: 800; border: 1.5px solid var(--border); background: var(--white);
}
.turn-badge .dot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid #555; }
.turn-badge .dot.w { background: #fff; }
.turn-badge .dot.b { background: #333; }

.dots { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 6px; }
.block-points { font-size: 0.82rem; font-weight: 700; color: var(--muted); margin-bottom: 14px; }
.dots .d {
  width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 800; color: var(--muted); background: var(--white);
}
.dots .d.cur { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 3px rgba(84,81,231,0.15); }
.dots .d.ok { background: var(--green); border-color: var(--green); color: #fff; }
.dots .d.score-75 { background: #f4c542; border-color: #dcae20; color: #4b3900; }
.dots .d.score-50 { background: var(--orange); border-color: #dc4f12; color: #fff; }
.dots .d.bad { background: var(--red); border-color: var(--red); color: #fff; }

.live-comp {
  display: grid; grid-template-columns: minmax(150px, 1.1fr) auto auto minmax(240px, 1.6fr);
  align-items: center; gap: 20px; position: relative; overflow: hidden;
  background: var(--white); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 13px 18px 16px; margin-bottom: 18px;
}
.live-comp-title { display: flex; flex-direction: column; min-width: 0; }
.live-comp-title > span { font-size: 0.78rem; font-weight: 900; color: var(--brand); text-transform: uppercase; }
.live-comp-title small { color: var(--muted); font-size: 0.72rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-comp-metric { display: flex; flex-direction: column; min-width: 78px; }
.live-comp-metric strong { color: var(--text); font-size: 1.08rem; font-weight: 900; line-height: 1.15; }
.live-comp-metric span { color: var(--muted); font-size: 0.68rem; font-weight: 650; }
.live-comp-goal { color: var(--brand-dark); font-size: 0.86rem; font-weight: 800; line-height: 1.35; }
.live-comp-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--bg); }
.live-comp-progress i { display: block; width: 0; height: 100%; background: var(--green); transition: width 0.4s ease; }

.solve-grid { display: grid; grid-template-columns: minmax(280px, 560px) minmax(240px, 1fr); gap: 22px; align-items: start; }
@media (max-width: 760px) {
  .live-comp { grid-template-columns: 1fr auto auto; gap: 10px 14px; padding: 11px 13px 14px; }
  .live-comp-goal { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 9px; }
  .live-comp-metric { min-width: 60px; }
  .solve-grid { grid-template-columns: 1fr; gap: 14px; }
  /* панель действий прижата к низу экрана — «Сдать» всегда под пальцем */
  #scr-solve.on .solve-btns {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
    background: rgba(255,255,255,0.97); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    display: grid; grid-template-columns: auto 1fr; gap: 8px;
    padding: 10px 4% calc(10px + env(safe-area-inset-bottom));
  }
  #scr-solve.on .solve-btns .btn { min-height: 46px; padding: 10px 14px; }
  #scr-solve.on .solve-btns .report-link { grid-column: 1 / -1; }
  #scr-solve.on #btn-back-blocks { display: none; }
  #scr-solve.on #btn-reset { font-size: 0.82rem; }
  #scr-solve.on .attempt-note { grid-column: 1 / -1; margin: 0; }
  #scr-solve.on { padding-bottom: 130px; }   /* контент не прячется за фикс-баром */
  .moves-list { min-height: 52px; }
}

.board-wrap { border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); touch-action: none;
  width: 100%; max-width: min(100%, 560px); }
.board-wrap > div { max-width: 100% !important; }  /* контейнер cm-chessboard не шире обёртки */

.moves-panel { display: flex; flex-direction: column; gap: 14px; }
.moves-list {
  min-height: 74px; background: var(--bg); border-radius: 12px; padding: 12px 14px;
  font-size: 0.95rem; font-weight: 600; line-height: 1.9; letter-spacing: 0.01em;
}
.moves-list .mnum { color: var(--muted); font-weight: 500; margin-right: 2px; }
.moves-list .mv { display: inline-block; padding: 0 6px; border-radius: 6px; margin-right: 2px; }
.moves-list .mv.last { background: rgba(84,81,231,0.12); color: var(--brand-dark); }
.moves-list .hint-empty { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.solve-btns { display: flex; flex-direction: column; gap: 10px; }
.attempt-note { color: var(--muted); font-size: 0.78rem; text-align: center; }
.incomplete-note { background: #eef5ff; border-left: 4px solid var(--brand); border-radius: 7px; color: var(--brand-dark); font-size: 0.88rem; font-weight: 750; margin-top: 12px; padding: 11px 13px; }
.report-link { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.78rem; text-decoration: underline; cursor: pointer; padding: 4px; }
.report-link:hover { color: var(--red); }
.report-link:disabled { color: var(--green); cursor: default; text-decoration: none; }

/* ── ввод «в уме» ── */
.mental-premoves { background: var(--orange-light); border: 1px solid var(--orange-mid); border-radius: 12px; padding: 12px 16px; font-weight: 700; margin-bottom: 12px; }
.mental-premoves .lbl { display: block; font-size: 0.72rem; color: var(--orange); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.mental-input { width: 100%; border: 1.5px solid var(--border); border-radius: 12px; padding: 12px 14px; font-family: inherit; font-size: 1rem; min-height: 52px; }
.mental-input:focus { outline: none; border-color: var(--brand); }
.mental-parsed { font-size: 0.85rem; margin-top: 8px; min-height: 22px; }
.mental-parsed .okp { color: var(--green); font-weight: 700; }
.mental-parsed .badp { color: var(--red); font-weight: 700; }
.mental-hint { font-size: 0.78rem; color: var(--muted); margin-bottom: 10px; line-height: 1.4; }
.mental-cells { display: flex; flex-direction: column; gap: 8px; }
.mrow { display: flex; align-items: center; gap: 8px; }
.mnum { min-width: 34px; text-align: right; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.mcell { width: 88px; border: 1.5px solid var(--border); border-radius: 10px; padding: 9px 10px; font-family: inherit; font-size: 1rem; text-align: center; }
.mcell:focus { outline: none; border-color: var(--brand); }
.mcell.ok { border-color: var(--green); background: var(--green-light); }
.mcell.bad { border-color: var(--red); background: var(--red-light); }

/* ── результат ── */
.result-card { border-radius: 16px; padding: 20px; margin-top: 16px; animation: rise 0.3s ease both; }
.result-card.ok { background: var(--green-light); border: 1.5px solid rgba(54,178,107,0.35); }
.result-card.bad { background: var(--red-light); border: 1.5px solid rgba(224,69,90,0.3); }
.result-title { font-size: 1.15rem; font-weight: 900; margin-bottom: 6px; }
.result-card.ok .result-title { color: var(--green); }
.result-card.bad .result-title { color: var(--red); }
.result-meta { font-size: 0.85rem; color: var(--muted); margin-bottom: 10px; }
.competition-result { background: rgba(255,255,255,0.78); border-left: 4px solid var(--brand); border-radius: 8px; padding: 10px 12px; margin: 10px 0; color: var(--brand-dark); font-size: 0.86rem; font-weight: 800; }
.competition-result.up { border-left-color: var(--orange); color: #b84112; }
.result-sol { background: rgba(255,255,255,0.75); border-radius: 10px; padding: 10px 14px; font-weight: 700; font-size: 0.95rem; line-height: 1.8; }
.result-sol .lbl { display: block; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 2px; font-weight: 700; }
.result-refut { margin-top: 8px; font-size: 0.85rem; color: var(--muted); line-height: 1.7; }
.result-btns { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ── рефлексия ── */
.refl-q { text-align: center; margin-bottom: 20px; }
.refl-q .q-emoji { font-size: 2.2rem; display: block; margin-bottom: 6px; }
.refl-q .q-text { font-size: 1.2rem; font-weight: 800; }
.refl-q .q-hint { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.refl-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.refl-cell {
  border: 2px solid var(--border); border-radius: 12px; padding: 8px; background: var(--white);
  min-width: 0; cursor: pointer; transition: border-color 0.15s, transform 0.15s;
  position: relative; font-family: inherit;
}
.refl-cell:hover { border-color: var(--brand-mid); transform: translateY(-2px); }
.refl-cell.sel { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(84,81,231,0.18); }
.refl-cell .rc-num { font-size: 0.78rem; font-weight: 800; margin-top: 6px; text-align: center; }
.refl-cell .rc-badges { position: absolute; top: -10px; right: -6px; font-size: 1.1rem; }
.refl-nav { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.refl-comment { width: 100%; border: 1.5px solid var(--border); border-radius: 12px; padding: 12px 14px; font-family: inherit; font-size: 0.95rem; min-height: 80px; margin-bottom: 14px; }
.mini-board { width: 100%; pointer-events: none; }

@media (max-width: 820px) {
  .refl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .refl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

/* ── итоги ── */
.summary-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.summary-table th { text-align: left; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.summary-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); font-weight: 600; }
.st-ok { color: var(--green); } .st-bad { color: var(--red); } .st-skip { color: var(--muted); }

/* ── сообщение о некорректной задаче ── */
.report-dialog { width: min(92vw, 500px); border: 0; border-radius: 8px; padding: 0; box-shadow: 0 24px 70px rgba(24,25,48,0.24); }
.report-dialog::backdrop { background: rgba(24,25,48,0.48); }
.report-dialog form { padding: 24px; display: grid; gap: 16px; }
.report-dialog h2 { font-size: 1.2rem; }
.report-dialog p { color: var(--muted); font-size: 0.85rem; }
.report-dialog label { display: grid; gap: 6px; font-size: 0.82rem; font-weight: 750; }
.report-dialog select, .report-dialog textarea { width: 100%; border: 1.5px solid var(--border); border-radius: 7px; background: #fff; color: var(--text); font: inherit; padding: 10px 12px; }
.report-dialog textarea { min-height: 96px; resize: vertical; }
.report-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ── статистика ── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 18px 0; }
.stat-tile { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 16px; text-align: center; }
.stat-tile .v { font-size: 1.35rem; font-weight: 900; color: var(--brand); }
.stat-tile .l { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.section-h { font-size: 1.1rem; font-weight: 800; margin: 30px 0 14px; }

/* ── рейтинг ── */
.rating-section { width: 100%; max-width: 100%; min-width: 0; margin: 34px 0; }
.rating-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.rating-head .section-h { margin: 0 0 2px; }
.rating-scope { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.rating-mine { display: flex; gap: 18px; align-items: center; text-align: right; }
.rating-mine-item .v { font-size: 1.05rem; font-weight: 900; color: var(--brand); line-height: 1.2; }
.rating-mine-item .l { color: var(--muted); font-size: 0.7rem; font-weight: 600; }
.rating-tabs { margin: 0 0 12px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
.rating-tabs .chip { white-space: nowrap; }
.rating-table-wrap {
  width: 100%; max-width: 100%; max-height: 520px; overflow: auto; background: var(--white);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.rating-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.rating-table th {
  position: sticky; top: 0; z-index: 1; background: var(--white); text-align: left;
  color: var(--muted); font-size: 0.72rem; text-transform: uppercase;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
}
.rating-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 650; }
.rating-table tr:last-child td { border-bottom: 0; }
.rating-table tr.mine td { background: rgba(84,81,231,0.07); color: var(--brand-dark); }
.rating-place { width: 72px; font-weight: 900; color: var(--brand); }
.rating-player { min-width: 150px; }
.rating-player small { display: block; color: var(--brand); font-size: 0.68rem; font-weight: 800; }
.rating-progress { display: grid; grid-template-columns: minmax(90px, 1fr) 42px; align-items: center; gap: 10px; min-width: 160px; }
.rating-progress-bar { height: 7px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.rating-progress-bar i { display: block; height: 100%; border-radius: 6px; background: var(--green); }
.rating-progress span { color: var(--muted); font-size: 0.78rem; text-align: right; }
.rating-empty { color: var(--muted); text-align: center; padding: 24px !important; }

@media (max-width: 620px) {
  .rating-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .rating-mine { width: 100%; justify-content: flex-start; text-align: left; }
  .rating-table { table-layout: fixed; }
  .rating-table th, .rating-table td { padding: 10px 7px; }
  .rating-table th:nth-child(1) { width: 54px; }
  .rating-table th:nth-child(2) { width: 32%; }
  .rating-table th:nth-child(3) { width: 28%; }
  .rating-place { width: auto; }
  .rating-player { min-width: 0; }
  .rating-progress { display: block; min-width: 0; }
  .rating-progress-bar { display: none; }
  .rating-progress span { display: block; text-align: left; }
}

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 22px; border-radius: 12px;
  font-size: 0.9rem; font-weight: 600; z-index: 400; opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.toast.show { opacity: 1; }

.dots .d { cursor: pointer; }
.dots .d:hover { border-color: var(--brand); }
