/* Светлая тема. Mobile-first. */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #14181f;
  --muted: #6b7480;
  --line: #e4e9f0;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --green: #15a34a;
  --red: #dc2626;
  --gold: #b8860b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;   /* базовый кегль увеличен — всё на rem масштабируется пропорционально */
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 8px 24px;
}

h1 { font-size: 1.6rem; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }

/* Карточки */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 8px;
}
.card h2 { margin-top: 0; }

/* Формы */
label { display: block; font-size: .85rem; color: var(--muted); margin: 12px 0 5px; }
input[type=text], input[type=number] {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 13px 16px;
  font-size: 1rem; font-weight: 600;
  border: none; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  cursor: pointer;
  margin-top: 16px;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #eef2f8; color: var(--ink); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }

/* Прочее */
.divider { text-align: center; color: var(--muted); margin: 18px 0; font-size: .85rem; }
.error { color: var(--red); font-size: .9rem; margin-top: 10px; min-height: 1.1em; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Код игры + QR */
.code-big {
  font-size: 2.2rem; font-weight: 800; letter-spacing: .15em;
  text-align: center; color: var(--accent); margin: 6px 0;
}
.qr { display: block; width: 200px; height: 200px; margin: 12px auto; image-rendering: pixelated;
      border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 8px; }
.join-link { word-break: break-all; text-align: center; font-size: .85rem; color: var(--muted); }

/* Список игроков / стартапов */
.list { list-style: none; padding: 0; margin: 0; }
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; }
.row .startup { color: var(--muted); font-size: .85rem; }
.row.me { background: #f0f6ff; border-radius: 8px; }

.badge {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.badge.mi { background: #fff7e6; color: var(--gold); border: 1px solid #f0e0b8; }
.badge.round { background: #eef2f8; color: var(--muted); }

/* Главный экран игрока */
.hero { background: linear-gradient(160deg,#fff, #f7faff); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.stat { background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.stat .k { font-size: .75rem; color: var(--muted); }
.stat .v { font-size: 1.25rem; font-weight: 700; }
.stat .v.money { color: var(--green); }
.stat .v.val { color: var(--accent); }

.actions { display: grid; gap: 10px; margin-top: 8px; }

.feed { font-size: .9rem; }
.feed .fi { padding: 8px 4px; border-bottom: 1px dashed var(--line); color: var(--ink); }
.feed .fi:last-child { border-bottom: none; }
.empty { color: var(--muted); font-style: italic; padding: 8px 4px; }

.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%);
  background: #14181f; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: .9rem; box-shadow: var(--shadow); z-index: 90; max-width: 90%;  /* выше экрана «Команда» */
}

/* Модалка покупки доли */
.modal-bg {
  position: fixed; inset: 0; background: rgba(16,24,40,.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 56;  /* выше экрана «Команда» (50) */
}
.modal {
  background: #fff; width: 100%; max-width: 640px;
  border-radius: 16px 16px 0 0; padding: 18px 18px 28px;
  max-height: 85vh; overflow: auto; box-shadow: var(--shadow);
}
@media (min-width: 640px) {
  .modal-bg { align-items: center; }
  .modal { border-radius: 16px; }
}
.modal h2 { margin: 0 0 4px; }
.modal .close {
  float: right; border: none; background: #eef2f8; color: var(--ink);
  width: 34px; height: 34px; border-radius: 50%; font-size: 1rem; cursor: pointer;
}
.buy-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 2px; border-bottom: 1px solid var(--line);
}
.buy-row:last-child { border-bottom: none; }
.buy-row .grow { flex: 1; min-width: 0; }
.buy-row .reason { font-size: .75rem; color: var(--red); margin-top: 3px; }
.btn.small { width: auto; padding: 9px 16px; margin: 6px 0 0; font-size: .9rem; }
.btn.small[disabled] { opacity: .4; }

/* Заголовок стартапа и раунд на главном экране (крупнее/жирнее) */
.startup-title { font-size: 2rem; font-weight: 800; line-height: 1.15; margin: .1em 0 .18em; letter-spacing: -.01em; }
.round-hero {
  display: inline-block; font-size: 1.05rem; font-weight: 700; color: var(--accent);
  background: #eef4ff; border: 1px solid #d7e6ff; border-radius: 999px; padding: 5px 16px;
}
.hero-info { margin-top: 14px; font-size: .95rem; color: var(--muted); }
.hero-info div { margin: 3px 0; }

/* Диалоги */
.dialog-text { font-size: 1.05rem; margin: 8px 0 16px; color: var(--ink); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin-top: 0; }

/* Счётчик количества долей в модалке инвестиций */
.buy-action { text-align: right; min-width: 150px; }
.qty { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }
.qty > button {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: #eef2f8; color: var(--ink); font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.qty > button[disabled] { opacity: .4; cursor: not-allowed; }
.qty .n { min-width: 26px; text-align: center; font-weight: 700; font-size: 1.15rem; }
.qty .buy { margin: 0 0 0 4px; }

/* Финал: оверлей победы / уведомление */
.win-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(20, 24, 31, .55);
}
.win-card {
  background: #fff; border-radius: 18px; padding: 28px 24px;
  max-width: 440px; width: 100%; text-align: center; box-shadow: var(--shadow);
}
.win-emoji { font-size: 3rem; line-height: 1; }
.win-title { font-size: 2.3rem; font-weight: 800; margin: .1em 0 .2em; color: var(--green); }
.win-sub { font-size: 1.15rem; color: var(--ink); margin: 0 0 18px; }
.win-card .btn-row { justify-content: center; }
.notice-line { font-size: 1.15rem; margin: 6px 0; color: var(--ink); }
.notice-line.big { font-size: 1.5rem; font-weight: 800; color: var(--green); margin: 12px 0 18px; }
.btn.win { background: var(--green); }
.win-row { color: var(--green); }
.notice-sep { border: none; border-top: 1px solid var(--line); width: 70%; margin: 10px auto; }

/* Кнопка подтверждения покупки — нейтрально-красная с тенью, чтобы выделялась */
.btn.buy-confirm {
  background: #c75b52; color: #fff;
  box-shadow: 0 2px 8px rgba(199, 91, 82, .35);
}

/* Модалка инвестиций: акценты в строке стартапа */
.buy-name { font-weight: 600; color: var(--ink); }
.bought-line { font-weight: 500; color: var(--accent); }
/* «Ваша доля X%» — синим (перебиваем .row .startup, иначе остаётся серым) */
.startup.your-share { color: var(--accent); font-weight: 600; }

/* Кнопка «Инвестировать» внизу блока «Мои инвестиции» */
.invest-bottom { margin-top: 14px; }

/* Кликабельные строки стартапов (открыть описание) */
.row.clickable { cursor: pointer; }
.row.clickable:active { background: #f0f6ff; }
.modal-startup-name { margin: 0 0 2px; font-weight: 800; }

/* Описание стартапа */
.desc-view {
  white-space: pre-wrap; background: #f7f9fc; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: .95rem;
}
.desc-edit { margin-top: 10px; }
.desc-edit textarea {
  width: 100%; padding: 10px 12px; font-size: .95rem; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px; resize: vertical;
}
.desc-edit textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.desc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.desc-foot .btn-row { margin: 0; }
.desc-foot .btn.small { margin: 0; }
.desc-count { font-size: .8rem; color: var(--muted); }

/* Блок «Жетоны раунда» */
.tok-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tok-table-link { border: none; background: none; color: var(--accent); font-size: 1rem; font-weight: 400;
  cursor: pointer; text-decoration: underline; padding: 0; white-space: nowrap; }
.tok-name-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tok-have { color: var(--muted); font-size: .9rem; white-space: nowrap; }
/* строка жетона — в столбик: инфо сверху, управление снизу (не сжимается на узком экране) */
.tok-row { display: flex; flex-direction: column; gap: 10px; padding: 14px 2px; border-bottom: 1px solid var(--line); }
.tok-row:last-child { border-bottom: none; }
.tok-info .buy-name { font-weight: 600; }
.tok-icon { font-size: 1.05rem; }
.tok-ok { color: var(--green); font-weight: 700; }
.tok-action { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tok-action .qty { margin: 0; gap: 6px; }
.tok-action .qty > button { width: 40px; height: 42px; }
.tok-action .qty .n { font-size: 1.15rem; }
.tok-add { flex: 1 1 auto; min-width: 140px; margin: 0; height: 42px; }
/* «бонус» — той же высоты, что и «Купить за…» */
.chip { border: 1px solid var(--line); background: #eef2f8; color: var(--muted); border-radius: 10px;
  height: 42px; padding: 0 16px; display: inline-flex; align-items: center; font-size: .95rem; cursor: pointer; }
.chip.on { background: #e8f5e9; border-color: #bfe3c4; color: var(--green); font-weight: 600; }

/* Шапка героя: «Мой стартап» + таб «Моя команда» */
.hero-toprow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.team-tab {
  border: 1px solid var(--accent); background: #eef4ff; color: var(--accent);
  border-radius: 999px; padding: 6px 16px; font-size: .95rem; font-weight: 600; cursor: pointer;
}
.team-tab:active { transform: translateY(1px); }

/* Карты команды (прототип) */
.team-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.team-card {
  border: 2px solid var(--line); border-radius: 14px; background: #f7f9fc;
  padding: 12px 12px 14px; display: flex; flex-direction: column;
  aspect-ratio: 1 / 1.5;  /* все карты одинакового размера, пропорция ≈1:1.5 */
}
.team-card.leader { border-color: #2b3a4d; }
.tcard-kind { text-align: center; color: var(--muted); font-size: .85rem; }
.tcard-name { text-align: center; font-weight: 800; font-size: 1.25rem; margin: 8px 0 14px; }
.tcard-grants { margin-top: auto; }
.tcard-line { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .9rem; padding: 2px 0; }
.tcard-line b { color: var(--ink); }
.tcard-ability b { color: var(--accent); }

/* Полноэкранный раздел «Команда» + витрина найма */
.team-screen { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; padding: 14px 14px 36px; }
/* зафиксированная шапка: назад, баланс, подпись, табы */
.ts-top { position: sticky; top: 0; background: var(--bg); padding: 4px 0 8px; z-index: 1; }
.ts-back { border: none; background: #eef2f8; color: var(--ink); border-radius: 8px; padding: 8px 14px; font-size: 1rem; cursor: pointer; }
.ts-balance { margin: 10px 0 2px; }
.ts-note { color: var(--muted); font-size: .9rem; margin-bottom: 10px; }
.ts-tabs { display: flex; gap: 8px; }
.ts-tab { flex: 1; border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 10px; padding: 10px; font-size: 1rem; font-weight: 600; cursor: pointer; }
.ts-tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ts-tabbody { margin-top: 14px; }
.ts-hire-note { margin: 0 0 12px; }
.ts-hire-rule { margin: 0 0 12px; }
.team-card.market { aspect-ratio: auto; }   /* витрина: карта растёт по контенту (тиры/остаток) */
.team-card.market.sold-out { opacity: .5; }
.tcard-next { text-align: center; font-size: .72rem; color: var(--accent); margin: -8px 0 8px; }
/* витрина найма: грейды как кнопки (выбор тира + цена) */
.tier-opts { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.tier-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #eef2f8; color: var(--ink);
  font-size: .85rem; cursor: pointer; }
.tier-btn[disabled] { opacity: .45; cursor: not-allowed; }
.tier-btn .tb-lbl { font-weight: 700; min-width: 50px; text-align: left; }
.tier-btn .tb-prim { color: var(--muted); }
.tier-btn .tb-rem { color: var(--muted); margin-left: auto; font-size: .75rem; }
.tier-btn .tb-price { font-weight: 700; min-width: 62px; text-align: right; }
/* счётчик из блока «Действия», переиспользованный в модалах (центрированный, крупнее) */
.qty.qty-modal { justify-content: center; gap: 8px; margin: 4px 0 0; }
.qty.qty-modal > button { width: 44px; height: 44px; font-size: 1.4rem; }
.qty.qty-modal .n { min-width: 40px; font-size: 1.3rem; }
.qty-cap { text-align: center; margin-top: 4px; }
.team-slot { display: flex; flex-direction: column; gap: 8px; }
.fire-btn { background: #fff; border: 1px solid #d9534f; color: #d9534f; }
.fire-btn:hover { background: #d9534f; color: #fff; }
.btn.danger { background: #d9534f; border-color: #d9534f; color: #fff; }
.btn.danger:hover { background: #c9302c; border-color: #c9302c; }
.market-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hire-btn { width: 100%; margin-top: 10px; }
/* кнопка случайного найма — заметная (светло-синяя), но отличается от платного найма */
.ts-random { width: 100%; margin: 0 0 12px; background: #dbe9ff; color: var(--accent); border: 1px solid #b9d3ff; }

/* Модалка «таблица цен жетонов» */
.tt-wrap { margin-top: 8px; }
.tt-round { padding: 8px 0; border-bottom: 1px solid var(--line); }
.tt-round:last-child { border-bottom: none; }
.tt-rname { font-weight: 700; margin-bottom: 4px; }
.tt-cell { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; padding: 2px 0; }
.tt-cell span { color: var(--muted); }
