/* Pixel Wars — «война в клеточку»: тетрадный лист, синяя паста, красные поля. */
@font-face { font-family: "Inter"; src: url("/fonts/inter-400.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/inter-600.woff") format("woff"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/inter-700.woff") format("woff"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/inter-800.woff") format("woff"); font-weight: 800; font-display: swap; }

:root {
  --paper: #F5F8FC;      /* тетрадный лист */
  --grid: #DCE6F2;       /* клетка */
  --grid2: #BFD1E6;
  --ink: #2347A6;        /* синяя паста */
  --ink-d: #19357E;
  --ink-l: #E8EEFA;
  --red: #E0453A;        /* поля тетради, TNT */
  --red-l: #FDECEA;
  --text: #1F2430;
  --mute: #5F6B7E;
  --card: #FFFFFF;
  --ok: #138A4B;
  --r: 10px;
  --top-h: 56px;
  --tk-h: 34px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); overscroll-behavior: none; }
body { display: flex; flex-direction: column; font-size: 15px; line-height: 1.45; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, canvas:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hide { display: none !important; }

/* ---------- шапка ---------- */
.top { height: var(--top-h); flex: none; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--grid2); position: relative; z-index: 3; }
.brand { display: flex; align-items: center; color: var(--ink); text-decoration: none; flex: none; }
.logo { width: 150px; height: auto; fill: currentColor; stroke: none; shape-rendering: crispEdges; }
.logo .cur { fill: var(--red); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.menu { display: flex; gap: 4px; margin-left: 8px; }
.mi { display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px; border: 0; background: none; border-radius: 8px; font-weight: 600; color: var(--text); }
.mi:hover { background: var(--ink-l); color: var(--ink); }
.acct { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.bal { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 10px; border: 1px solid var(--grid2); border-radius: 18px; background: var(--paper); font-variant-numeric: tabular-nums; }
.bal b { font-weight: 700; font-size: 15px; }
.bal:hover { border-color: var(--ink); }
.px { width: 12px; height: 12px; background: var(--ink); box-shadow: 4px 4px 0 -1px var(--red); display: inline-block; margin-right: 3px; }
.me { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--grid2); background: var(--ink-l) center / cover no-repeat; color: var(--ink); font-weight: 700; padding: 0; }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: var(--r); border: 1px solid var(--grid2); background: var(--card); font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn.ink { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ink:hover { background: var(--ink-d); }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.sm { height: 36px; padding: 0 14px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.wide { width: 100%; }
.lnk { border: 0; background: none; color: var(--ink); font-weight: 600; padding: 0; }

/* ---------- бегущая строка ---------- */
.ticker { height: var(--tk-h); flex: none; display: flex; align-items: stretch; background: var(--card); border-bottom: 1px solid var(--grid2); position: relative; z-index: 2; }
.tk-view { flex: 1; overflow: hidden; position: relative; border-left: 2px solid var(--red); margin-left: 44px; }
.tk-view::before { content: ""; position: absolute; left: -48px; top: 0; bottom: 0; width: 1px; }
.tk-run { position: absolute; top: 0; bottom: 0; left: 0; display: flex; align-items: center; white-space: nowrap; will-change: transform; font-size: 14px; }
.tk-run span { padding: 0 22px 0 0; }
.tk-run span::after { content: ""; display: inline-block; width: 6px; height: 6px; background: var(--ink); margin-left: 22px; vertical-align: 2px; }
.tk-run .tk-def { color: var(--mute); }
.tk-add { flex: none; border: 0; border-left: 1px solid var(--grid2); background: var(--paper); padding: 0 14px; font-weight: 600; font-size: 13px; color: var(--ink); }
.tk-add:hover { background: var(--ink-l); }

/* ---------- поле ---------- */
.stage { flex: 1; position: relative; overflow: hidden; touch-action: none;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
#board.grab { cursor: grabbing; }
.loading { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); background: var(--card); padding: 10px 16px; border-radius: var(--r); border: 1px solid var(--grid2); font-weight: 600; }
.zoom { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; border: 1px solid var(--grid2); border-radius: var(--r); overflow: hidden; background: var(--card); }
.zoom button { width: 40px; height: 40px; border: 0; background: none; font-size: 20px; font-weight: 600; display: grid; place-items: center; }
.zoom button + button { border-top: 1px solid var(--grid); }
.zoom button:hover { background: var(--ink-l); color: var(--ink); }
.online { position: absolute; left: 14px; top: 14px; background: var(--card); border: 1px solid var(--grid2); border-radius: 16px; padding: 4px 12px 4px 10px; font-size: 13px; color: var(--mute); display: flex; align-items: center; gap: 7px; }
.online::before { content: ""; width: 8px; height: 8px; background: var(--ok); }
.online:empty { display: none; }

/* ---------- нижняя панель ---------- */
.dock { flex: none; display: flex; align-items: center; gap: 18px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--grid2); position: relative; z-index: 2; }
.cell { min-width: 150px; display: flex; flex-direction: column; font-size: 13px; color: var(--mute); }
.cell b { color: var(--text); font-variant-numeric: tabular-nums; font-size: 14px; }
.cell span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.pal { display: grid; grid-template-columns: repeat(16, 26px); gap: 4px; margin: 0 auto; }
.sw { width: 26px; height: 26px; border: 1px solid rgba(31, 36, 48, .18); border-radius: 4px; padding: 0; }
.sw[aria-checked="true"] { outline: 3px solid var(--ink); outline-offset: 2px; transform: scale(1.05); }
.acts { display: flex; gap: 10px; }
.place { min-width: 156px; font-variant-numeric: tabular-nums; }
.tnt { gap: 10px; color: var(--red); border-color: var(--red); font-weight: 800; letter-spacing: .02em; }
.tnt b { background: var(--red); color: #fff; border-radius: 9px; min-width: 22px; height: 22px; display: grid; place-items: center; font-size: 12px; padding: 0 6px; }
.tnt[aria-pressed="true"] { background: var(--red); color: #fff; }
.tnt[aria-pressed="true"] b { background: #fff; color: var(--red); }

/* ---------- окна ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(23, 31, 52, .38); z-index: 10; }
.sheet { position: fixed; z-index: 11; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 48px)); background: var(--card); border-radius: 14px; display: flex; flex-direction: column; box-shadow: 0 18px 50px rgba(20, 30, 60, .25); }
.sh-head { display: flex; align-items: center; padding: 16px 18px 6px 22px; }
.sh-head h2 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.x { margin-left: auto; width: 38px; height: 38px; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; }
.x:hover { background: var(--ink-l); }
.sh-body { padding: 6px 22px 22px; overflow: auto; }
.sh-body p { margin: 6px 0 12px; }
.lead { color: var(--mute); }
.note { background: var(--paper); border: 1px dashed var(--grid2); border-radius: var(--r); padding: 10px 12px; font-size: 13px; color: var(--mute); margin: 4px 0 16px; }
.note b { color: var(--text); }

.packs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.pack { border: 1px solid var(--grid2); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 2px; background: var(--card); text-align: left; }
.pack:hover { border-color: var(--ink); background: var(--ink-l); }
.pack .q { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; }
.pack .p { color: var(--mute); font-size: 14px; }
.pack.big { grid-column: span 2; flex-direction: row; align-items: center; gap: 14px; }
.pack.big .t { flex: 1; }
.pack.tntp { border-color: #F3B4AE; }
.pack.tntp:hover { border-color: var(--red); background: var(--red-l); }
.tnt-ico { width: 46px; height: 46px; flex: none; background: var(--red); color: #fff; font-weight: 800; font-size: 13px; display: grid; place-items: center; border-radius: 6px; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .15); }
.sec { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--grid); }
.sec h3 { margin: 0 0 4px; font-size: 16px; }
.ta { width: 100%; min-height: 76px; resize: vertical; border: 1px solid var(--grid2); border-radius: var(--r); padding: 10px 12px; font: inherit; }
.row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.row .grow { flex: 1; }
.cnt { color: var(--mute); font-size: 13px; font-variant-numeric: tabular-nums; }
.cnt.bad { color: var(--red); }
.pay { text-align: center; padding: 8px 0 4px; }
.pay .sum { font-size: 40px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0; }

.link { display: flex; gap: 8px; margin: 8px 0 4px; }
.link input { flex: 1; min-width: 0; height: 44px; border: 1px solid var(--grid2); border-radius: var(--r); padding: 0 12px; font: inherit; background: var(--paper); }
.goal { margin: 14px 0; }
.goal .gl { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.goal .gl b { font-variant-numeric: tabular-nums; }
.cells { display: flex; gap: 4px; }
.cells i { flex: 1; height: 14px; border: 1px solid var(--grid2); background: var(--card); }
.cells i.on { background: var(--ink); border-color: var(--ink); }
.cells.red i.on { background: var(--red); border-color: var(--red); }
.steps { margin: 4px 0 0; padding-left: 20px; }
.steps li { margin: 4px 0; }
.boost { display: flex; align-items: center; gap: 12px; border: 1px solid var(--grid2); border-radius: 12px; padding: 12px 14px; margin-top: 14px; }
.boost .t { flex: 1; }

.lb { list-style: none; margin: 0; padding: 0; counter-reset: lb; }
.lb li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--grid); counter-increment: lb; }
.lb li::before { content: counter(lb); width: 22px; color: var(--mute); font-variant-numeric: tabular-nums; font-weight: 600; }
.lb li .n { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.lb li.mine { background: var(--ink-l); margin: 0 -10px; padding: 10px; border-radius: 8px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 10px 0 16px; }
.stats div { background: var(--paper); border: 1px solid var(--grid); border-radius: 10px; padding: 10px 12px; }
.stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stats span { color: var(--mute); font-size: 13px; }
.who { display: flex; align-items: center; gap: 12px; margin: 4px 0 6px; }
.who .me { width: 48px; height: 48px; font-size: 18px; }
.empty { color: var(--mute); padding: 12px 0; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100vw - 32px); text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); }

/* ---------- телефон ---------- */
@media (max-width: 760px) {
  :root { --top-h: 52px; }
  .top { gap: 8px; padding: 0 10px; }
  .logo { width: 104px; }
  .menu { margin-left: 2px; gap: 0; }
  .mi { padding: 0 9px; }
  .mi span { display: none; }
  .bal { padding: 0 10px 0 8px; height: 34px; }
  .tk-view { margin-left: 14px; }
  .tk-add { padding: 0 10px; font-size: 12px; }
  .dock { flex-wrap: wrap; gap: 8px 10px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .cell { order: 1; min-width: 0; flex: 1; }
  .acts { order: 2; }
  .place { min-width: 128px; }
  .pal { order: 3; width: 100%; grid-template-columns: repeat(16, 1fr); gap: 3px; }
  .sw { width: auto; height: 22px; }
  .sheet { left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100%; max-height: 88vh; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .zoom { top: 10px; right: 10px; }
  .online { top: 10px; left: 10px; }
  .toast { bottom: 150px; }
}
@media (max-width: 380px) {
  .logo { width: 88px; }
  .btn.sm { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .logo .cur { animation: none; }
  .toast { transition: none; }
}
