:root {
  --bg: #202026;
  --panel: #2d2d34;
  --panel2: #383840;
  --text: #e6e6e6;
  --dim: #96969e;
  --good: #3cb45a;
  --bad: #dc4646;
  --accent: #6eaaeb;
  --light: #f0d9b5;
  --dark: #b58863;
  --src: #3cb45a;
  --dst: #f0c83c;
  --sel: #4a7fbf;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg); color: var(--text);
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  height: 100%;
  overscroll-behavior: none;
}
#app { max-width: 520px; margin: 0 auto; padding: 8px 10px 24px; }
.loading { text-align: center; padding: 40px 0; color: var(--dim); }

/* ---------------------------------------------------------------- панель */
.panel {
  background: var(--panel); border-radius: 10px;
  padding: 8px 10px; margin-bottom: 8px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.panel h2 { font-size: 15px; width: 100%; margin-bottom: 2px; }
.chip {
  background: var(--panel2); color: var(--text);
  border: 1px solid #4a4a55; border-radius: 16px;
  padding: 4px 10px; font-size: 13px; cursor: pointer; user-select: none;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #10202e; font-weight: 600; }
.chip:active { opacity: .7; }
.btn {
  background: var(--panel2); color: var(--text);
  border: 1px solid #4a4a55; border-radius: 8px;
  padding: 6px 14px; font-size: 14px; cursor: pointer; user-select: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #10202e; font-weight: 600; }
.btn.good { background: var(--good); border-color: var(--good); color: #0c1f12; font-weight: 600; }
.btn:active { opacity: .75; }
.btn:disabled { opacity: .4; cursor: default; }

/* ---------------------------------------------------------------- доска */
.board-wrap { position: relative; }
.board-svg { width: 100%; height: auto; display: block; touch-action: manipulation; }
.square { cursor: pointer; }
.square.empty { cursor: default; }
.move-dot { fill: rgba(0,0,0,.16); }
.move-dst { fill: rgba(20,120,60,.35); }
.hint-src { fill: rgba(60,180,90,.45); }
.hint-dst { fill: rgba(240,200,60,.5); }
.last-src { fill: rgba(110,170,235,.4); }
.last-dst { fill: rgba(110,170,235,.28); }

/* ---------------------------------------------------------------- статус/нормы */
.status {
  background: var(--panel); border-radius: 10px;
  padding: 8px 10px; margin-top: 8px; font-size: 13px; color: var(--dim);
}
.status b { color: var(--text); }
.norm-row { display: flex; align-items: center; gap: 6px; margin: 3px 0; font-size: 12px; }
.norm-label { width: 130px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.norm-bar { flex: 1; height: 8px; background: #3a3a42; border-radius: 4px; overflow: hidden; }
.norm-fill { height: 100%; background: var(--good); border-radius: 4px; transition: width .3s; }
.norm-num { width: 86px; text-align: right; flex-shrink: 0; color: var(--dim); }
.norm-row.done .norm-fill { background: var(--accent); }

/* ---------------------------------------------------------------- тост */
#toast {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%);
  background: var(--panel2); color: var(--text);
  border: 1px solid #555; border-radius: 8px; padding: 8px 14px;
  font-size: 14px; z-index: 50; display: none; max-width: 92vw; text-align: center;
}
#toast.good { border-color: var(--good); }
#toast.bad { border-color: var(--bad); }

/* ---------------------------------------------------------------- модалка */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--panel); border-radius: 12px; padding: 16px;
  width: 92%; max-width: 380px; max-height: 84vh; overflow-y: auto;
}
.modal-box h3 { font-size: 16px; margin-bottom: 8px; }
.modal-box textarea {
  width: 100%; min-height: 70px; background: var(--panel2); color: var(--text);
  border: 1px solid #555; border-radius: 8px; padding: 8px; font-size: 14px;
  font-family: inherit; resize: vertical;
}
.modal-box .promo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.modal-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }

/* ---------------------------------------------------------------- гейт (нет доступа) */
.gate h1 { font-size: 20px; margin-bottom: 10px; }
.gate .card {
  background: var(--panel); border-radius: 10px; padding: 12px;
  margin-bottom: 10px; font-size: 14px; line-height: 1.5;
}
.gate .card h3 { font-size: 15px; margin-bottom: 6px; }
.gate .review { border-bottom: 1px solid #3a3a42; padding: 8px 0; }
.gate .review:last-child { border-bottom: none; }
.gate .review .who { color: var(--dim); font-size: 12px; margin-top: 4px; }
.req-list { margin: 6px 0 6px 16px; }

/* ---------------------------------------------------------------- маленькие экраны */
@media (max-width: 400px) {
  .chip { padding: 3px 8px; font-size: 12px; }
  .btn { padding: 5px 10px; font-size: 13px; }
  .norm-label { width: 105px; }
}

/* ---------------------------------------------------------------- игры (Фаза 2) */
.tabs {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px;
  background: var(--panel); border-radius: 10px; padding: 5px;
}
.tab {
  flex: 1; text-align: center; min-width: 84px;
  background: var(--panel2); color: var(--dim);
  border: 1px solid #4a4a55; border-radius: 8px;
  padding: 5px 6px; font-size: 12px; cursor: pointer; user-select: none;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #10202e; font-weight: 600; }
.tab:active { opacity: .7; }

.card {
  background: var(--panel); border-radius: 10px; padding: 12px; margin-bottom: 8px;
}
.card.center { text-align: center; }
.card h2 { font-size: 17px; margin-bottom: 8px; }
.big {
  font-size: 64px; font-weight: 800; color: var(--accent);
  line-height: 1.1; margin: 6px 0; letter-spacing: 2px;
}
.dim { color: var(--dim); font-size: 13px; }

.sq-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px;
  max-width: 400px; margin: 10px auto;
}
.sq-cell {
  aspect-ratio: 1; background: var(--panel2);
  border: 1px solid #4a4a55; border-radius: 6px; cursor: pointer;
}
.sq-cell:active { background: var(--accent); }

.opt-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px auto; max-width: 320px; }
.opt {
  background: var(--panel2); border: 1px solid #4a4a55; border-radius: 10px;
  padding: 12px; font-size: 16px; cursor: pointer; text-align: center; user-select: none;
}
.opt:active { background: var(--accent); color: #10202e; }
.piece-big { display: block; margin: 4px auto; }

.ghead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ghead h2 { margin: 0; }