/* «Расследование партии» (разбор v3, Блок 1). Дизайн-система innochess (Geologica, #5451e7).
   Тон: спортивный разбор + следовательская лексика. Без красного цвета наказания. */

:root {
  --brand: #5451e7; --brand-dark: #3d3ab0; --brand-mid: #6f6df0;
  --orange: #FF6B2B; --orange-light: #FFF0E8;
  --green: #36b26b; --green-light: #e9f9ef;
  --violet: #8b5cf6; --violet-light: #f3eeff;
  --yellow: #b48a06; --yellow-light: #fefce8;
  --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);
}

html, body { touch-action: manipulation; }
[hidden] { display: none !important; }  /* иначе display:flex у .comment-pill перебивает hidden */
button, a, input, textarea { touch-action: manipulation; }
main { max-width: 1080px; margin: 0 auto; padding: 24px 4% 80px; }
.screen { display: none; }
.screen.on { display: block; animation: rise 0.35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.page-title { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 900; letter-spacing: -0.02em; margin-bottom: 6px; }
.page-sub { color: var(--muted); font-size: 0.95rem; margin-bottom: 22px; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; padding: 20px; 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 24px; 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: 46px;
}
.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.big { width: 100%; padding: 16px 24px; font-size: 1.05rem; margin-top: 16px; }
.btn.wide { width: 100%; margin-top: 14px; }
.btn.small { padding: 7px 14px; min-height: 36px; font-size: 0.82rem; border-radius: 9px; }
.btn:disabled { opacity: 0.45; cursor: default; }

.chip { padding: 10px 18px; border-radius: 40px; border: 1.5px solid var(--border); background: var(--white);
  cursor: pointer; font-family: inherit; font-size: 0.92rem; font-weight: 600; color: var(--text); min-height: 44px; }
.chip.sel { background: var(--brand); border-color: var(--brand); color: var(--white); }
.chip.skip { border-style: dashed; color: var(--muted); margin-top: 14px; }

.who { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }

/* ── список партий ── */
.games-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.game-entry { position: relative; min-width: 0; }
.game-card { background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 16px; padding: 16px 18px;
  padding-right: 62px; width: 100%; height: 100%; cursor: pointer; text-align: left; font-family: inherit;
  transition: border-color 0.18s, transform 0.18s; }
.game-card:hover { border-color: var(--brand-mid); transform: translateY(-2px); }
.game-card .g-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.game-card .g-opp { font-weight: 800; font-size: 1rem; }
.game-card .g-res { font-weight: 900; font-size: 1rem; }
.g-res.win { color: var(--green); } .g-res.loss { color: var(--orange); } .g-res.draw { color: var(--muted); }
.game-card .g-meta { color: var(--muted); font-size: 0.78rem; margin: 4px 0 8px; }
.g-badge { display: inline-block; font-size: 0.72rem; font-weight: 800; padding: 3px 10px; border-radius: 20px;
  background: var(--bg); color: var(--brand); }
.game-delete { position: absolute; z-index: 2; right: 12px; bottom: 12px; width: 40px; height: 40px;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--white); cursor: pointer;
  font-size: 1rem; line-height: 1; transition: border-color 0.15s, background 0.15s, transform 0.12s; }
.game-delete:hover { border-color: var(--orange); background: var(--orange-light); }
.game-delete:active { transform: scale(0.94); }
.game-delete:disabled { opacity: 0.45; cursor: wait; }

/* ── новая партия ── */
.add-card { max-width: 560px; margin: 0 auto; }
.add-card textarea { width: 100%; border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 14px;
  font-family: ui-monospace, monospace; font-size: 0.82rem; resize: vertical; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.add-row input { flex: 1; min-width: 140px; border: 1.5px solid var(--border); border-radius: 12px;
  padding: 10px 14px; font-family: inherit; font-size: 0.92rem; }

/* ── обложка дела ── */
.cover-wrap { max-width: 560px; margin: 0 auto; }
.cover-card { text-align: center; }
.cover-meta-opp { font-size: 1.25rem; font-weight: 900; margin-bottom: 2px; }
.cover-meta-sub { color: var(--muted); font-size: 0.88rem; margin-bottom: 14px; }
.cover-note { color: var(--muted); font-size: 0.82rem; margin-top: 10px; }
.board.mini { max-width: 340px; margin: 0 auto; }

/* ── вопрос разведки ── */
.intent-wrap { max-width: 560px; margin: 0 auto; text-align: center; }
.q-title { font-size: 1.3rem; font-weight: 900; letter-spacing: -0.01em; margin-bottom: 18px; }
.intent-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
#intent-text, #comment-text { width: 100%; border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 14px;
  font-family: inherit; font-size: 0.95rem; margin: 12px 0 10px; resize: vertical; }

/* ── рабочий экран ── */
.work-grid { display: grid; grid-template-columns: minmax(0, 58%) minmax(0, 1fr); gap: 22px; align-items: start; }
.board-col { min-width: 0; }
.board { width: 100%; }
.nav-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.nav-btn { flex: 0 0 48px; height: 48px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--white);
  font-size: 1.5rem; font-weight: 700; color: var(--brand); cursor: pointer; }
.nav-btn:active { transform: scale(0.95); }
.notation { flex: 1; display: flex; gap: 2px; overflow-x: auto; white-space: nowrap; padding: 6px 2px;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.nmove { position: relative; padding: 5px 7px; border-radius: 8px; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  color: var(--text); background: transparent; border: none; font-family: inherit; flex: 0 0 auto; }
.nmove.cur { background: var(--brand); color: var(--white); }
.nmove .pin { position: absolute; top: -1px; right: 0; font-size: 0.62rem; line-height: 1; }
.nmove .no { color: var(--muted); font-weight: 500; margin-right: 2px; }
.nmove.cur .no { color: rgba(255,255,255,0.7); }

.side-col { min-width: 0; }
.phase-hint { font-size: 0.92rem; font-weight: 600; color: var(--muted); margin-bottom: 12px; min-height: 1.4em; }
.phase-hint b { color: var(--text); }

.marks-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mark-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; border-radius: 14px;
  border: 1.5px solid var(--border); background: var(--white); cursor: pointer; font-family: inherit; min-height: 68px;
  transition: transform 0.12s, border-color 0.15s, background 0.15s; }
.mark-btn:active { transform: scale(0.95); }
.mark-btn .mi { font-size: 1.3rem; line-height: 1; }
.mark-btn .ml { font-size: 0.82rem; font-weight: 700; }
.mark-btn.on { border-width: 2px; }
.mark-btn[data-kind="strong_decision"].on { border-color: var(--green); background: var(--green-light); }
.mark-btn[data-kind="doubt"].on { border-color: var(--yellow); background: var(--yellow-light); }
.mark-btn[data-kind="punished_opponent"].on { border-color: var(--violet); background: var(--violet-light); }
.mark-btn[data-kind="own_blunder"].on { border-color: var(--orange); background: var(--orange-light); }
.mark-btn[data-kind="opponent_surprise"].on { border-color: var(--violet); background: var(--violet-light); }
.mark-btn[data-kind="opening_uncertainty"].on { border-color: var(--yellow); background: var(--yellow-light); }
.mark-btn:disabled { opacity: 0.4; cursor: default; }

.pin-strong { color: var(--green); }
.pin-doubt { color: var(--yellow); }
.pin-opp { color: var(--violet); }
.pin-blunder { color: var(--orange); }

.comment-pill { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 8px 12px;
  border: 1.5px dashed var(--border); border-radius: 40px; animation: rise 0.25s ease both; }
.cp-label { font-size: 0.85rem; font-weight: 700; }
.cp-btn { border: none; background: var(--bg); border-radius: 50%; width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; }
.cp-btn.rec { background: var(--orange-light); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.cp-skip { font-size: 0.72rem; color: var(--muted); margin-left: auto; }
.comment-edit { margin-top: 10px; }

/* ── мастера ── */
.nav-btn.masters { font-size: 1.05rem; }
.nav-btn.masters.on { background: var(--brand); border-color: var(--brand); }
.nav-btn.masters.pulse { animation: mpulse 1.2s ease-in-out 4; border-color: var(--brand); }
@keyframes mpulse { 50% { transform: scale(1.18); box-shadow: 0 0 0 6px rgba(84,81,231,0.15); } }
.hint-masters { display: block; font-weight: 500; font-size: 0.82rem; margin-top: 2px; }
.opening-line { font-size: 0.82rem; color: var(--muted); margin-top: 4px; font-weight: 600; }
.opening-line b { color: var(--text); }
.masters-panel { margin: 10px 0 12px; padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: 14px; background: var(--card-bg); }
.m-title { font-size: 0.82rem; font-weight: 800; margin-bottom: 8px; }
.m-title .m-src { color: var(--muted); font-weight: 500; font-size: 0.72rem; }
.m-row { display: grid; grid-template-columns: 52px 44px 1fr 56px 26px; gap: 8px; align-items: center;
  padding: 3px 0; font-size: 0.85rem; }
.m-why { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--border);
  background: var(--white); color: var(--brand); font-weight: 800; font-size: 0.8rem;
  cursor: pointer; font-family: inherit; }
.m-why:hover { border-color: var(--brand); }
.m-why:disabled { opacity: 0.5; }
.m-answer { font-size: 0.84rem; line-height: 1.5; padding: 8px 10px; margin: 2px 0 6px;
  background: var(--yellow-light); border-radius: 10px; }
.m-thinking { color: var(--muted); font-style: italic; }
.m-row .m-san { font-weight: 800; }
.m-row .m-pct { font-weight: 600; color: var(--muted); font-size: 0.8rem; }
.m-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; border: 1px solid var(--border); }
.m-bar .w { background: #f6f4ee; }
.m-bar .d { background: #b8b6c9; }
.m-bar .b { background: #4a4864; }
.m-row .m-games { text-align: right; color: var(--muted); font-size: 0.75rem; }
.m-empty { color: var(--muted); font-size: 0.82rem; }

/* ── карта дела ── */
.map-card { max-width: 640px; margin: 0 auto; }
.map-counts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.map-count { font-size: 0.82rem; font-weight: 700; padding: 5px 12px; border-radius: 20px; background: var(--bg); }
.map-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.map-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: 12px; background: var(--white); cursor: pointer; font-family: inherit; text-align: left; }
.map-item .mi { font-size: 1.1rem; }
.map-item .m-ply { font-weight: 800; font-size: 0.9rem; min-width: 52px; }
.map-item .m-comment { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── развязка ── */
.wait-card { text-align: center; padding: 40px 20px; }
.spinner { width: 42px; height: 42px; border: 4px solid var(--border); border-top-color: var(--brand);
  border-radius: 50%; margin: 0 auto 16px; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.v-card { border-radius: 16px; padding: 18px 20px; border: 2px solid var(--border); background: var(--card-bg);
  box-shadow: var(--shadow); animation: rise 0.3s ease both; }
.v-card.confirmed { border-color: var(--green); background: var(--green-light); }
.v-card.answered { border-color: var(--yellow); background: var(--yellow-light); }
.v-card.partial { border-color: var(--brand-mid); background: #eef0ff; }
.v-card.not_confirmed { border-color: var(--violet); background: var(--violet-light); }
.v-card.missed { border-color: var(--orange); background: var(--orange-light); }
.v-kicker { font-size: 0.72rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 6px; }
.v-card.confirmed .v-kicker { color: var(--green); }
.v-card.answered .v-kicker { color: var(--yellow); }
.v-card.partial .v-kicker { color: var(--brand); }
.v-card.not_confirmed .v-kicker { color: var(--violet); }
.v-card.missed .v-kicker { color: var(--orange); }
.v-title { font-size: 1.05rem; font-weight: 900; margin-bottom: 8px; }
.v-body { font-size: 0.9rem; }
.v-body p { margin-bottom: 6px; }
.v-quote { border-left: 3px solid var(--border); padding: 4px 10px; color: var(--muted); font-style: italic;
  font-size: 0.85rem; margin: 8px 0; }
.v-line { display: flex; gap: 8px; align-items: baseline; font-size: 0.88rem; margin: 3px 0; flex-wrap: wrap; }
.v-line .l-move { font-weight: 800; }
.v-line .l-pv { color: var(--muted); font-size: 0.8rem; }
.verdict-nav { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.v-progress { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.v-try { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,0.65);
  font-size: 0.88rem; font-weight: 600; }

/* ── дело закрыто ── */
.done-card { max-width: 560px; margin: 0 auto; text-align: center; }
.done-emoji { font-size: 3rem; margin-bottom: 8px; }
.done-summary-main { font-size: 1.05rem; font-weight: 700; margin-bottom: 14px; }
.done-list { text-align: left; display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.done-item { display: flex; gap: 8px; align-items: baseline; font-size: 0.88rem; }
.done-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: var(--text);
  color: var(--white); padding: 10px 22px; border-radius: 12px; font-size: 0.88rem; font-weight: 600; opacity: 0;
  pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 300; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── мобайл ── */
@media (max-width: 860px) {
  main { padding: 16px 3% 90px; }
  .work-grid { grid-template-columns: 1fr; gap: 14px; }
  .board { max-width: min(94vw, 480px); margin: 0 auto; }
  .marks-panel { position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 10px; z-index: 50; }
  .mark-btn { min-height: 62px; }
  .games-list { grid-template-columns: 1fr; }
}
