/* Cashflow. Токены с холста Design: зелёное сукно, кремовое поле, золото на главной кнопке.
 * Шрифт один, Unbounded, веса 400 и 600. Отступы 4/8/12/16/24/32, радиусы 8 и 16. */
:root {
  --felt: #143A2E; --felt-2: #1B4637; --felt-3: #0F2E24; --felt-line: #2C5A48;
  --felt-ink: #F6EFE2; --felt-muted: #B7CBBE;
  --paper: #F6EFE2; --paper-2: #EDE3D1; --paper-3: #FFFDF8; --line: #DCCDB3; --line-2: #E6DAC6;
  --ink: #1F1A14; --ink-2: #5E5546;
  --gold: #E3A82B; --gold-2: #F2C35A; --good: #1F7A4C; --bad: #B23B3B;
  --r-s: 8px; --r-l: 16px;
  --font: 'Unbounded', system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--felt); color: var(--felt-ink); font-family: var(--font); font-size: 14px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: 0.5; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- кнопки ---------- */
.btn { min-height: 48px; padding: 0 16px; border: 0; border-radius: var(--r-l); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-gold { min-height: 56px; background: var(--gold); color: var(--ink); font-size: 16px; }
.btn-gold:not(:disabled):hover { background: var(--gold-2); }
.btn-paper { background: var(--paper-2); color: var(--ink); }
.btn-paper:not(:disabled):hover { background: #E4D7C0; }
.btn-dark { background: var(--felt); color: var(--felt-ink); }
.btn-line { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-felt { background: transparent; border: 1px solid var(--felt-line); color: var(--felt-ink); }
.btn-small { min-height: 44px; padding: 0 12px; border-radius: var(--r-s); font-size: 12px; }
.icon-btn { width: 44px; height: 44px; border-radius: var(--r-s); border: 1px solid var(--felt-line); background: transparent; color: var(--felt-ink); display: inline-flex; align-items: center; justify-content: center; }

/* ---------- старт ---------- */
.setup { max-width: 520px; margin: 0 auto; padding: 24px 16px 32px; display: flex; flex-direction: column; gap: 16px; }
.wordmark { display: flex; align-items: center; gap: 12px; }
.wordmark b { font-size: 28px; font-weight: 600; letter-spacing: 0.08em; }
.wordmark span { padding: 4px 8px; border-radius: var(--r-s); background: var(--gold); color: var(--ink); font-size: 12px; font-weight: 600; }
.panel { background: var(--paper); color: var(--ink); border-radius: var(--r-l); padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .field > .label { font-size: 12px; color: var(--ink-2); }
.input { height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--paper-3); font-size: 16px; color: var(--ink); width: 100%; }
select.input { font-size: 14px; }
.hscroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.prof { flex: 0 0 auto; width: 120px; min-height: 76px; padding: 8px 12px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--paper-3); color: var(--ink); text-align: left; display: flex; flex-direction: column; gap: 4px; }
.prof b { font-size: 12px; font-weight: 600; }
.prof span { font-size: 12px; color: var(--ink-2); }
.prof em { font-style: normal; font-size: 12px; color: var(--good); }
.prof[aria-pressed="true"], .seat[aria-pressed="true"] { border: 2px solid var(--ink); }
.seats { display: flex; flex-direction: column; gap: 8px; }
.seat { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border-radius: var(--r-s); border: 1px solid var(--line); background: transparent; color: var(--ink-2); text-align: left; width: 100%; }
.seat[aria-pressed="true"] { background: var(--paper-3); color: var(--ink); }
.seat .who { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.seat .who b { font-size: 14px; font-weight: 600; color: var(--ink); }
.seat .who span { font-size: 12px; }
.human-row { display: flex; gap: 8px; align-items: center; }
.human-row .input { flex: 1 1 auto; }
.setup-foot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* ---------- фишка-аватар ---------- */
.av { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #FFFFFF; color: #FFFFFF; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.av.light { color: var(--ink); }
.av.big { width: 36px; height: 36px; border-width: 3px; font-size: 14px; }

/* ---------- экран партии ---------- */
.game { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.topbar .mark { font-size: 14px; font-weight: 600; letter-spacing: 0.12em; }
.topbar .round { font-size: 12px; color: var(--felt-muted); }
.layout { flex: 1 1 auto; display: flex; flex-direction: column; }
.left, .right { display: contents; }
.center { order: 2; display: flex; flex-direction: column; flex: 1 1 auto; }

.players { order: 1; display: flex; gap: 8px; padding: 0 16px 12px; overflow-x: auto; scrollbar-width: none; }
.players::-webkit-scrollbar { display: none; }
.pl { flex: 0 0 auto; display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-radius: var(--r-l); background: var(--felt-2); border: 2px solid var(--felt-2); color: var(--felt-ink); text-align: left; }
.pl.now { border-color: var(--gold); }
.pl.out { opacity: 0.45; }
.pl .info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pl .nm { font-size: 12px; font-weight: 600; white-space: nowrap; }
.pl .nm .c { display: none; }
.pl .cash { font-size: 12px; color: var(--felt-muted); white-space: nowrap; }
.pl .cash.ft { color: var(--gold); }
.pl .sub { display: none; font-size: 12px; color: var(--felt-muted); }
.bar { height: 4px; border-radius: 4px; background: var(--felt-line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--gold); }
.pl .bar { width: 64px; }

.boardwrap { order: 2; padding: 0 16px; }
.board { position: relative; width: 100%; max-width: 560px; margin: 0 auto; aspect-ratio: 1 / 1; container-type: inline-size; background: var(--paper); border-radius: var(--r-l); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22); color: var(--ink); }
.board svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.board .cell { cursor: pointer; transition: opacity 0.2s; }
.board .cell.lit { stroke: var(--gold); stroke-width: 9; paint-order: stroke; }
.board .arc-label { font-family: var(--font); }
.tok { transition: transform 0.16s ease-out; }
.tok text { font-family: var(--font); pointer-events: none; }
.tok.active circle { stroke: var(--gold); }
.disc { position: absolute; left: 28%; top: 28%; width: 44%; height: 44%; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.4cqw; text-align: center; pointer-events: none; }
.disc-who { display: flex; flex-direction: column; gap: 0.6cqw; align-items: center; }
.disc-label { font-size: max(10px, 1.8cqw); letter-spacing: 0.14em; color: var(--ink-2); }
.disc-name { font-size: max(14px, 3.8cqw); font-weight: 600; max-width: 36cqw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disc-dice { display: flex; gap: 2cqw; min-height: 10cqw; }
.die { width: 10cqw; height: 10cqw; padding: 1.4cqw; border-radius: 2cqw; background: #FFFFFF; border: 2px solid var(--ink); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); place-items: center; }
.die i { width: 1.7cqw; height: 1.7cqw; border-radius: 50%; background: var(--ink); }
.die b { width: 1.7cqw; height: 1.7cqw; }
.disc-chip { max-width: 36cqw; padding: 1.2cqw 2.4cqw; border-radius: 2cqw; font-size: max(10px, 1.9cqw); line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.lastline { order: 3; margin: 12px 16px 0; padding: 12px 16px; border-radius: var(--r-l); background: var(--felt-2); display: flex; gap: 12px; align-items: flex-start; min-height: 52px; }
.lastline .txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lastline .head { font-size: 12px; font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lastline .say { font-size: 14px; line-height: 1.45; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.lastline .think { font-size: 14px; color: var(--felt-muted); }

.log { display: none; }
.statement-box { display: none; }

.actions { order: 4; position: sticky; bottom: 0; z-index: 5; background: var(--paper); color: var(--ink); border-radius: var(--r-l) var(--r-l) 0 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; margin-top: auto; box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18); }
.center::after { content: ''; display: block; height: 12px; order: 3; }
.actions .btn-gold { min-height: 52px; }
.stat .bar { margin-top: 4px; background: var(--line); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat .k { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.stat .v { font-size: 16px; font-weight: 600; white-space: nowrap; }
.stat .v small { font-size: 12px; font-weight: 400; color: var(--ink-2); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.row3 .btn { min-height: 44px; border-radius: var(--r-s); font-size: 12px; padding: 0 8px; }
.actions .only-desk { display: none; }
@media (max-width: 420px) { .row3 svg { display: none; } }

/* ---------- журнал ---------- */
.entries { display: flex; flex-direction: column; gap: 8px; }
.entry { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.5; }
.entry.neg .t { color: #F2A0A0; }
.sheet .entry.neg .t { color: var(--bad); }
.entry.pos .t { color: var(--gold); }
.entry .dot { flex: 0 0 auto; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; }
.entry .t { min-width: 0; }
.entry .t b { font-weight: 600; }
.entry.r { color: var(--ink-2); font-size: 12px; letter-spacing: 0.12em; padding-top: 8px; }
.bubble { display: flex; gap: 8px; align-items: flex-start; }
.bubble .av { width: 20px; height: 20px; font-size: 10px; border-width: 2px; }
.bubble .b { padding: 8px 12px; border-radius: 0 var(--r-l) var(--r-l) var(--r-l); font-size: 14px; line-height: 1.5; background: var(--paper-2); }
.bubble .b b { display: block; font-weight: 600; margin-bottom: 2px; }

/* ---------- ведомость ---------- */
.st { display: flex; flex-direction: column; gap: 24px; }
.st-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.st-head .t { display: flex; flex-direction: column; gap: 4px; }
.st-head .t b { font-size: 20px; font-weight: 600; }
.st-head .t span { font-size: 12px; color: var(--ink-2); }
.goal { border-radius: var(--r-l); background: var(--felt); color: var(--felt-ink); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.goal .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.goal .k { font-size: 12px; color: var(--felt-muted); }
.goal .big { font-size: 28px; font-weight: 600; color: var(--gold); }
.goal .mid { font-size: 20px; font-weight: 600; }
.goal .bar { height: 8px; border-radius: 8px; }
.goal .g3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.goal .g3 div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.goal .g3 b { font-size: 14px; font-weight: 600; white-space: nowrap; }
.sec { display: flex; flex-direction: column; gap: 4px; }
.sec-t { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; color: var(--ink-2); padding-bottom: 4px; }
.line { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.line:last-child { border-bottom: 0; }
.line.total { font-weight: 600; }
.line .l { flex: 1 1 auto; min-width: 0; }
.line .btn-small { margin-left: 4px; }
.asset { border-radius: var(--r-l); background: var(--paper-3); border: 1px solid var(--line); padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.asset .top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 600; }
.asset .sub { font-size: 12px; color: var(--ink-2); }
.st-foot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.st-foot .btn { font-size: 12px; padding: 0 8px; }
.coach { border-radius: var(--r-l); background: var(--paper-2); padding: 12px 16px; font-size: 14px; line-height: 1.55; white-space: pre-line; }
.empty { font-size: 12px; color: var(--ink-2); padding: 8px 0; }

/* ---------- шторка ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-back { position: absolute; inset: 0; background: rgba(8, 22, 17, 0.62); }
.sheet { position: relative; width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--paper); color: var(--ink); border-radius: var(--r-l) var(--r-l) 0 0; padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; animation: sheet-in 0.22s ease-out; }
.sheet .grip { align-self: center; width: 40px; height: 4px; border-radius: 4px; background: var(--line); flex: 0 0 auto; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-who { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 600; }
.sheet p { margin: 0; font-size: 14px; }

.card { border-radius: var(--r-l); overflow: hidden; background: var(--paper-3); border: 1px solid var(--line); }
.card-head { padding: 12px 16px; color: #FFFFFF; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-head .deck { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; }
.card-head .kind { font-size: 12px; }
.card-head.dark { color: var(--ink); }
.card-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.card-title { font-size: 20px; font-weight: 600; line-height: 1.25; }
.card-sub { font-size: 14px; color: var(--ink-2); margin-top: 4px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kv div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kv .k { font-size: 12px; color: var(--ink-2); }
.kv .v { font-size: 16px; font-weight: 600; }
.kv .v.lg { font-size: 20px; }

.stepper { display: flex; gap: 8px; align-items: center; }
.stepper .btn { width: 48px; min-height: 48px; padding: 0; border-radius: var(--r-s); font-size: 20px; }
.stepper input { flex: 1 1 auto; min-width: 0; height: 48px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--paper-3); text-align: center; font-size: 20px; font-weight: 600; color: var(--ink); }
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.quick .btn { min-height: 44px; border-radius: var(--r-s); font-size: 12px; font-weight: 400; padding: 0 4px; }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: var(--r-s); background: var(--paper-2); }
.seg button { min-height: 40px; border: 0; border-radius: 6px; background: transparent; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--paper-3); color: var(--ink); }
.sum { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.sum .muted { color: var(--ink-2); }
.sum.warn { color: var(--bad); font-weight: 600; }
.pl-head { display: none; }
.link-btn { border: 0; background: transparent; color: var(--felt-muted); font-size: 12px; min-height: 32px; padding: 0 4px; text-decoration: underline; text-underline-offset: 3px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 16px; min-height: 72px; border-radius: var(--r-l); border: 1px solid var(--line); background: var(--paper-3); color: var(--ink); text-align: left; width: 100%; }
.choice b { font-size: 16px; font-weight: 600; }
.choice span { font-size: 12px; color: var(--ink-2); }
.sellrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-l); background: var(--paper-3); border: 1px solid var(--line); }
.sellrow .t { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sellrow .t b { font-size: 14px; font-weight: 600; }
.sellrow .t span { font-size: 12px; color: var(--ink-2); }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.rules { display: flex; flex-direction: column; gap: 12px; font-size: 14px; line-height: 1.55; }
.rules h3 { margin: 8px 0 0; font-size: 14px; font-weight: 600; }
.rules p { margin: 0; }
.standings { display: flex; flex-direction: column; gap: 8px; }
.standings .line { font-size: 14px; }

.toast { position: fixed; left: 50%; top: 16px; z-index: 60; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: var(--r-l); background: var(--ink); color: var(--paper); font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); animation: sheet-in 0.2s ease-out; }

/* ---------- компьютер ---------- */
@media (min-width: 1100px) {
  .game { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
  .topbar { display: none; }
  .layout { display: grid; grid-template-columns: 300px minmax(0, 1fr) 380px; gap: 24px; padding: 24px; min-height: 0; height: 100%; }
  .left { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
  .right { display: flex; flex-direction: column; min-height: 0; }
  .center { order: 0; min-height: 0; align-items: center; gap: 16px; }
  .deskhead { display: flex !important; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
  .deskhead .mark { font-size: 16px; font-weight: 600; letter-spacing: 0.12em; }
  .deskhead .round { font-size: 12px; color: var(--felt-muted); }
  .players { order: 0; flex-direction: column; padding: 0; overflow: visible; }
  .pl { padding: 12px 16px; gap: 12px; width: 100%; }
  .pl .av { width: 36px; height: 36px; border-width: 3px; font-size: 14px; }
  .pl .info { flex: 1 1 auto; }
  .pl .nm { display: flex; justify-content: space-between; font-size: 14px; gap: 8px; }
  .pl .nm .c { display: inline; font-weight: 400; }
  .pl .cash { display: none; }
  .pl .sub { display: block; }
  .pl .bar { width: 100%; }
  .pl-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: -8px; }
  .pl-head .sec-t { color: var(--felt-muted); padding: 0; }
  .players.compact { gap: 4px; }
  .players.compact .pl { padding: 6px 12px; border-radius: var(--r-s); }
  .players.compact .pl .av { width: 28px; height: 28px; border-width: 2px; font-size: 12px; }
  .players.compact .pl .sub, .players.compact .pl .bar { display: none; }
  .players.compact .pl .nm { font-size: 13px; }
  .log { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; min-height: 0; border-radius: var(--r-l); background: var(--felt-3); padding: 16px; color: var(--felt-ink); }
  .log .entry .t { color: #DCE6DF; }
  .log .entry.neg .t { color: #F2A0A0; }
  .log .entry.pos .t { color: var(--gold); }
  .log .sec-t { color: var(--felt-muted); }
  .log .entries { overflow-y: auto; min-height: 0; flex: 1 1 auto; padding-right: 4px; scrollbar-width: thin; }
  .log .bubble .b { background: var(--felt-2); color: var(--felt-ink); }
  .log .entry.r { color: var(--felt-muted); }
  .boardwrap { padding: 0; width: 100%; flex: 1 1 auto; min-height: 0; display: flex; justify-content: center; align-items: center; }
  .board { max-width: none; width: min(100%, calc(100vh - 152px)); width: min(100%, calc(100dvh - 152px)); margin: 0; }
  .lastline { display: none; }
  .actions { position: static; margin: 0; width: 100%; max-width: 760px; border-radius: var(--r-l); box-shadow: none; padding: 12px; flex-direction: row; align-items: center; background: transparent; }
  .actions .stats { display: none; }
  .actions .main { flex: 1 1 auto; }
  .actions .row3 { display: flex; gap: 8px; }
  .actions .row3 .btn { min-height: 56px; border-radius: var(--r-l); padding: 0 24px; background: transparent; border: 1px solid var(--felt-line); color: var(--felt-ink); font-size: 14px; }
  .actions .only-phone { display: none; }
  .actions .only-desk { display: inline-flex; }
  .statement-box { display: block; background: var(--paper); color: var(--ink); border-radius: var(--r-l); padding: 24px; overflow-y: auto; min-height: 0; flex: 1 1 auto; scrollbar-width: thin; }
  .sheet-wrap { align-items: center; }
  .sheet { max-width: 440px; border-radius: var(--r-l); max-height: 88vh; padding: 16px 24px 24px; }
  .sheet .grip { display: none; }
}
.deskhead { display: none; }

@media (prefers-reduced-motion: reduce) {
  .tok { transition: none; }
  .sheet, .toast { animation: none; }
}
