/* Архіпелаг — інтерфейс гри. Темні напівпрозорі панелі над яскравим містом; акцент #8b7bff лише на головних діях. */
:root {
  --s1: rgba(16,20,30,.92); --s2: rgba(255,255,255,.07); --s3: rgba(255,255,255,.13); --line: rgba(255,255,255,.11);
  --tx: #eef1f6; --mu: #9aa3b5; --ac: #8b7bff; --ok: #4fbf5a; --bad: #e8584a; --warn: #f2b632;
  --top-h: 60px; --nav-h: 64px; --mobtool-h: 0px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; max-width: 100vw; overflow: hidden; background: #1f6c9e; font-family: Nunito, system-ui, sans-serif; color: var(--tx); -webkit-tap-highlight-color: transparent; user-select: none; }
#cv { position: fixed; inset: 0; display: block; touch-action: none; }
button { font: inherit; color: inherit; }
.btn { border: 0; background: var(--s2); color: var(--tx); font-weight: 800; font-size: 14px; padding: 0 12px; min-height: 40px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: var(--s3); }
.btn.pri { background: var(--ac); }
.btn.on { background: rgba(139,123,255,.35); box-shadow: inset 0 0 0 1px var(--ac); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.sm { min-height: 32px; font-size: 13px; padding: 0 9px; border-radius: 8px; }
.btn.xs { min-height: 26px; font-size: 12px; padding: 0 7px; border-radius: 7px; font-weight: 800; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); }
.btn.danger-soft { background: rgba(232,88,74,.16); color: #ffb4aa; box-shadow: inset 0 0 0 1px rgba(232,88,74,.36); }
.btn.danger-soft:hover { background: rgba(232,88,74,.28); }
.btn.act-buy { background: rgba(139,123,255,.26); box-shadow: inset 0 0 0 1px rgba(139,123,255,.55); }
.btn.act-buy:hover:not(:disabled) { background: rgba(139,123,255,.4); }
.btn.act-sell { background: rgba(79,191,90,.2); color: #d8f8dc; box-shadow: inset 0 0 0 1px rgba(79,191,90,.45); }
.btn.act-sell:hover:not(:disabled) { background: rgba(79,191,90,.32); }

/* верхня смуга */
.top { position: fixed; left: 0; right: 0; top: 0; min-height: 60px; display: flex; align-items: center; gap: 8px; padding: max(6px, env(safe-area-inset-top)) 12px 6px; background: var(--s1); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); z-index: 10; }
.brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; margin-right: 4px; flex-shrink: 1; }
.brand b { font-size: 15.5px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 195px; cursor: pointer; }
.brand span { font-size: 11.5px; color: var(--mu); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.chips { display: flex; gap: 6px; align-items: center; min-width: 0; flex-wrap: nowrap; }
.chip { display: flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 10px; background: var(--s2); font-weight: 800; font-size: 13.5px; white-space: nowrap; cursor: default; min-width: 0; font-variant-numeric: tabular-nums; }
.chip small { color: var(--mu); font-weight: 700; font-size: 11.5px; }
.chip small.net { font-weight: 800; color: #b7c2d6; }
.chip small.net.pos { color: #8ee09a; }
.chip small.net.neg { color: #ff9a8a; }
.chip svg { width: 15px; height: 15px; flex: none; }
.chip-act { cursor: pointer; transition: background .15s, box-shadow .15s; }
.chip-act:hover { background: var(--s3); }
.chip.layer-on { background: rgba(139,123,255,.32); box-shadow: inset 0 0 0 1px var(--ac); }
.chip.bad { box-shadow: inset 0 0 0 1px var(--bad); background: rgba(232,88,74,.14); }
.chip.bad.layer-on { box-shadow: inset 0 0 0 1.5px var(--bad), 0 0 0 1px var(--ac); }
.dem { display: flex; gap: 3px; align-items: center; height: 20px; }
.dem i { width: 6px; height: 20px; border-radius: 2px; display: block; background: rgba(255,255,255,.08); position: relative; overflow: hidden; }
.dem i b { position: absolute; left: 0; right: 0; bottom: 50%; display: block; min-height: 2px; }
.dem i::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(255,255,255,.25); }
.sp { flex: 1; min-width: 4px; }
.tools { display: flex; gap: 5px; align-items: center; flex: none; }
.tools .btn svg { width: 15px; height: 15px; flex: none; }
#clock { font-weight: 900; font-variant-numeric: tabular-nums; color: var(--mu); min-width: 42px; text-align: center; font-size: 13px; }

/* панель шарів */
.layers-bar { position: fixed; z-index: 11; top: calc(var(--top-h, 60px) + 8px); left: 50%; transform: translateX(-50%); width: max-content; max-width: min(740px, calc(100vw - 24px)); display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; background: var(--s1); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; box-shadow: 0 8px 24px rgba(0,0,0,.32); }

/* ліва панель будування */
.build { position: fixed; left: 0; top: var(--top-h, 60px); bottom: 0; width: 280px; background: var(--s1); backdrop-filter: blur(10px); border-right: 1px solid var(--line); z-index: 9; display: flex; flex-direction: column; }
.cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 10px; border-bottom: 1px solid var(--line); }
.cat { border: 0; background: var(--s2); border-radius: 10px; min-height: 54px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 800; color: var(--mu); padding: 4px 2px; text-align: center; line-height: 1.15; }
.cat svg { width: 20px; height: 20px; flex: none; }
.cat.on { background: rgba(139,123,255,.28); color: var(--tx); box-shadow: inset 0 0 0 1px var(--ac); }
.cat .cat-short { display: none; }
.list { flex: 1; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.tool { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: var(--s2); cursor: pointer; border: 0; text-align: left; width: 100%; }
.tool:hover { background: var(--s3); }
.tool.on { background: rgba(139,123,255,.28); box-shadow: inset 0 0 0 1px var(--ac); }
.tool.lock { opacity: .62; }
.tool img, .tool .ic { width: 52px; height: 52px; flex: none; border-radius: 10px; background: rgba(255,255,255,.05); object-fit: contain; display: flex; align-items: center; justify-content: center; }
.tool .ic svg { width: 28px; height: 28px; }
.tool .tt { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.tool .tn { font-weight: 900; font-size: 14px; }
.tool .td { font-size: 12px; color: var(--mu); font-weight: 700; margin-top: 2px; line-height: 1.3; }
.tool .tc { font-size: 12px; font-weight: 900; color: #ffd34d; margin-top: 3px; }
.dens { display: flex; gap: 6px; padding: 0 10px 10px; }
.dens .btn { flex: 1; }
.hintbar { padding: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--mu); font-weight: 700; line-height: 1.4; }
.exp-jump { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 11px; border: 1px dashed rgba(56,189,248,.4); background: rgba(56,189,248,.09); color: #bfeaff; font-size: 12.5px; font-weight: 800; cursor: pointer; text-align: left; width: 100%; margin-top: 2px; }
.exp-jump:hover { background: rgba(56,189,248,.16); }

/* права панель */
.side { position: fixed; right: 0; top: var(--top-h, 60px); bottom: 0; width: 368px; background: var(--s1); backdrop-filter: blur(10px); border-left: 1px solid var(--line); z-index: 9; display: flex; flex-direction: column; }
.tabs { display: flex; gap: 4px; padding: 10px; border-bottom: 1px solid var(--line); }
.tabs .btn { flex: 1; min-width: 0; }
.pane { flex: 1; overflow: auto; padding: 12px 14px; }
.h2 { font-size: 18px; font-weight: 900; margin: 0 0 4px; }
.sub { color: var(--mu); font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sub i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
dl.kv { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 6px 12px; margin: 12px 0; font-size: 14px; }
dl.kv dt { color: var(--mu); font-weight: 700; }
dl.kv dd { margin: 0; font-weight: 800; min-width: 0; word-break: break-word; }
.note { border-radius: 10px; padding: 9px 11px; font-size: 13px; font-weight: 800; margin: 10px 0; line-height: 1.35; }
.note.bad { background: rgba(232,88,74,.16); color: #ffb4aa; }
.note.ok { background: rgba(79,191,90,.16); color: #b8f0bd; }
.note.info { background: var(--s2); color: var(--mu); }
.bar { height: 8px; border-radius: 5px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar b { display: block; height: 100%; border-radius: 5px; background: var(--ok); }
.meter { display: grid; grid-template-columns: 110px 1fr 44px; gap: 8px; align-items: center; font-size: 13px; font-weight: 700; margin: 6px 0; }
.meter span:last-child { text-align: right; font-weight: 900; }

/* картка розширення острова */
.exp-card { background: linear-gradient(135deg, rgba(56,189,248,.11), rgba(139,123,255,.11)); border: 1px solid rgba(56,189,248,.32); border-radius: 12px; padding: 10px 11px; margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.exp-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.exp-top b { font-size: 14px; font-weight: 900; }
.exp-badge { font-size: 11px; font-weight: 900; padding: 2px 7px; border-radius: 999px; background: rgba(56,189,248,.22); color: #9ee4ff; white-space: nowrap; }
.exp-meta { font-size: 12.5px; color: var(--mu); font-weight: 700; line-height: 1.38; }
.exp-meta b { color: var(--tx); }
.exp-cost { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12.5px; font-weight: 800; }
.exp-act { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.exp-act .btn { flex: 1; min-width: 140px; }

.goods { display: flex; flex-direction: column; gap: 6px; }
.good { background: var(--s2); border: 1px solid rgba(255,255,255,.04); border-radius: 12px; padding: 9px 10px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.good .gr { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; min-width: 0; }
.good .gn { font-weight: 900; font-size: 14px; flex: 1; min-width: 0; }
.good .ga { font-weight: 900; font-variant-numeric: tabular-nums; }
.good .ga small { color: var(--mu); font-weight: 700; font-size: 11.5px; }
.good .gx { font-size: 12px; color: var(--mu); font-weight: 700; margin: 4px 0; }
.good .gb { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.good .gk { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; margin-top: 1px; padding-top: 5px; border-top: 1px solid rgba(255,255,255,.06); font-size: 12px; color: var(--mu); font-weight: 700; }
.good input { width: 64px; min-height: 32px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,.25); color: var(--tx); font: 800 13px Nunito, sans-serif; padding: 0 8px; }
.good .gk input { width: 72px; min-height: 26px; font-size: 12px; padding: 0 6px; }
.log { display: flex; flex-direction: column; gap: 6px; }
.log div { background: var(--s2); border-radius: 10px; padding: 8px 10px; font-size: 13px; font-weight: 700; line-height: 1.35; }
.log time { color: var(--mu); font-size: 11px; display: block; }

/* підказки */
#tip { position: fixed; z-index: 30; background: rgba(16,20,30,.95); border: 1px solid var(--line); padding: 6px 10px; border-radius: 8px; font-size: 13px; font-weight: 800; pointer-events: none; max-width: 280px; line-height: 1.35; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; background: rgba(16,20,30,.95); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-weight: 800; font-size: 14px; pointer-events: none; transition: opacity .25s; width: max-content; max-width: min(460px, calc(100vw - 24px)); text-align: center; }
#toast.bad { box-shadow: inset 0 0 0 1px var(--bad); }
.legend { position: fixed; z-index: 8; background: var(--s1); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 12px; font-weight: 800; display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; left: 294px; bottom: 14px; max-width: calc(100vw - 680px); }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -2px; }

/* старт */
.start { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(8,14,26,.55); backdrop-filter: blur(4px); padding: 16px; }
.start .box { background: var(--s1); border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: min(860px, 100%); max-height: 100%; overflow: auto; }
.start-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.start h1 { margin: 0; font-size: 26px; font-weight: 900; }
.start p { color: var(--mu); font-weight: 700; margin: 0 0 16px; line-height: 1.45; }
.isles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.isle { background: var(--s2); border: 0; border-radius: 14px; padding: 14px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.isle.on { box-shadow: inset 0 0 0 2px var(--ac); background: rgba(139,123,255,.18); }
.isle b { font-size: 17px; font-weight: 900; }
.isle span { color: var(--mu); font-weight: 700; font-size: 13px; line-height: 1.35; }
.isle canvas { width: 100%; height: 120px; border-radius: 10px; background: #2a86b8; }
.start .row { display: flex; gap: 10px; margin-top: 16px; align-items: center; flex-wrap: wrap; }
.start input { flex: 1; min-width: 180px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.25); color: var(--tx); font: 800 16px Nunito, sans-serif; padding: 0 12px; }
.start .err { color: #ffb4aa; font-weight: 800; margin-top: 10px; }

/* нижня навігація та активний інструмент (телефон) */
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h, 64px) + env(safe-area-inset-bottom)); display: none; background: var(--s1); backdrop-filter: blur(10px); border-top: 1px solid var(--line); z-index: 12; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); gap: 4px; }
.nav button { flex: 1; min-width: 0; border: 0; background: transparent; border-radius: 10px; color: var(--mu); font-weight: 800; font-size: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px; }
.nav button svg { width: 21px; height: 21px; }
.nav button.on { color: var(--tx); background: var(--s2); }
.fab { position: fixed; right: 12px; z-index: 11; display: none; flex-direction: column; gap: 6px; bottom: calc(var(--nav-h, 64px) + var(--mobtool-h, 0px) + 12px + env(safe-area-inset-bottom)); }
.fab .btn { width: 44px; height: 44px; padding: 0; border-radius: 12px; background: var(--s1); border: 1px solid var(--line); }
.mobtool { display: none; }

/* склад і біржа */
.st-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
.st-stat { background: var(--s2); border-radius: 10px; padding: 6px 8px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.st-stat small { font-size: 11px; color: var(--mu); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-stat b { font-size: 13px; font-weight: 900; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.st-flt { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0; }
.ord-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; }
.ord-card { background: rgba(139,123,255,.1); border: 1px solid rgba(139,123,255,.26); border-radius: 11px; padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; }
.ord-top { display: flex; align-items: center; gap: 4px 8px; justify-content: space-between; flex-wrap: wrap; font-size: 13px; font-weight: 800; min-width: 0; }
.ord-sub { display: flex; align-items: center; justify-content: space-between; gap: 4px 8px; flex-wrap: wrap; font-size: 11.5px; color: var(--mu); font-weight: 700; min-width: 0; }
.rate { font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rate.pos { background: rgba(79,191,90,.18); color: #9ce8a5; }
.rate.neg { background: rgba(232,88,74,.18); color: #ffaba0; }
.inc-tag { font-style: normal; font-size: 11px; color: #c8beff; background: rgba(139,123,255,.22); padding: 1px 5px; border-radius: 5px; margin-left: 3px; }
.st-qty { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.st-qty .qty-in { width: 66px; min-height: 28px; border-radius: 7px; border: 1px solid var(--line); background: rgba(0,0,0,.3); color: var(--tx); font: 800 13px Nunito, sans-serif; padding: 0 7px; font-variant-numeric: tabular-nums; }
.st-acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.st-acts .btn { width: 100%; min-width: 0; justify-content: space-between; padding: 3px 8px; font-size: 12.5px; min-height: 33px; gap: 4px; }
.st-acts .btn small { font-weight: 800; opacity: .9; font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.link-ex { color: #c4baff; background: rgba(139,123,255,.15); }
.ex-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px 8px; flex-wrap: wrap; margin-bottom: 4px; }
.gchips { display: flex; gap: 5px; flex-wrap: wrap; margin: 6px 0 8px; }
.gchips .btn { min-height: 29px; padding: 0 8px; font-size: 12px; gap: 4px; }
.gchip-b { background: rgba(139,123,255,.32); color: #e2dcff; border-radius: 6px; padding: 0 5px; font-size: 10.5px; font-weight: 900; }
.gchip-st { color: var(--mu); font-size: 11px; font-weight: 700; }
.book { background: var(--s2); border-radius: 12px; padding: 6px 8px; margin: 6px 0 8px; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.book .bh { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px; color: var(--mu); font-size: 11px; padding: 2px 6px 5px; border-bottom: 1px solid var(--line); }
.book-sec { font-size: 11px; color: var(--mu); font-weight: 700; padding: 4px 6px 2px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px; }
.book-row { width: 100%; border: 0; background: transparent; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 4px 6px; border-radius: 6px; cursor: pointer; font: 800 13px Nunito, sans-serif; font-variant-numeric: tabular-nums; text-align: left; color: var(--tx); min-width: 0; }
.book-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-row:hover { background: rgba(255,255,255,.09); }
.book-row.best { background: rgba(255,255,255,.04); }
.book-row.ask span:first-child { color: #ff9a8a; } .book-row.bid span:first-child { color: #8ee09a; }
.book-row .bk-act { font-size: 11px; color: var(--mu); font-weight: 700; }
.book-empty { padding: 5px 6px; font-size: 12px; color: var(--mu); font-weight: 700; }
.book .mid { color: var(--mu); font-size: 11.5px; text-align: center; display: block; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); margin: 4px 0; padding: 4px 0; }
.exform { background: var(--s2); border: 1px solid rgba(255,255,255,.05); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.exform .seg2 { display: flex; gap: 6px; } .exform .seg2 .btn { flex: 1; min-width: 0; }
.exform label { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; font-size: 13px; font-weight: 700; color: var(--mu); min-width: 0; }
.exform input { flex: 1; min-width: 84px; max-width: 100%; min-height: 34px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,.28); color: var(--tx); font: 800 14px Nunito, sans-serif; padding: 0 10px; font-variant-numeric: tabular-nums; }
.qchips { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.ex-totbox { background: rgba(0,0,0,.22); border-radius: 9px; padding: 7px 9px; font-size: 12px; font-weight: 700; line-height: 1.42; color: var(--tx); }
.ex-totbox .good-cmp { color: #8ee09a; } .ex-totbox .bad-cmp { color: #ffb4aa; }
.myo { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; background: var(--s2); border-radius: 10px; padding: 7px 10px; font-size: 13px; font-weight: 700; margin-top: 6px; min-width: 0; }
.myo span { flex: 1; min-width: 0; word-break: break-word; }
.myo-card { background: var(--s2); border: 1px solid rgba(255,255,255,.09); border-radius: 11px; padding: 8px 10px; margin-top: 6px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.myo-top { display: flex; align-items: center; gap: 4px 8px; justify-content: space-between; flex-wrap: wrap; font-size: 13px; font-weight: 800; min-width: 0; }
.myo-top span { min-width: 0; word-break: break-word; }
.myo-sub { display: flex; align-items: center; justify-content: space-between; gap: 4px 8px; flex-wrap: wrap; font-size: 11.5px; color: var(--mu); font-weight: 700; min-width: 0; }
.side-tag { font-size: 10.5px; font-weight: 900; padding: 1px 6px; border-radius: 5px; text-transform: uppercase; letter-spacing: .02em; }
.side-tag.sell { background: rgba(242,182,50,.22); color: #ffd97d; }
.side-tag.buy { background: rgba(79,191,90,.22); color: #9ce8a5; }
.cnt.ok-cnt { background: var(--ac); }
.reset-box { background: rgba(232,88,74,.12); border: 1px solid rgba(232,88,74,.35); border-radius: 12px; padding: 10px 11px; margin-top: 12px; font-size: 13px; font-weight: 700; line-height: 1.4; }

/* мапа моря */
.sea { position: fixed; inset: 0; z-index: 45; background: #0b2440; }
.sea canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.seahead { position: absolute; left: 12px; right: 12px; top: max(12px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; background: var(--s1); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.seahead b { font-size: 17px; font-weight: 900; }
.seahead span { flex: 1; min-width: 160px; color: var(--mu); font-weight: 700; font-size: 13px; }
.seacard { position: absolute; right: 12px; bottom: 12px; width: min(340px, calc(100% - 24px)); max-height: 70vh; overflow: auto; background: var(--s1); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }

.pane .gx { font-size: 12px; color: var(--mu); font-weight: 700; margin: 4px 0; line-height: 1.4; }

/* етап 3: контракти, літаки, клани */
.exseg { display: flex; gap: 5px; margin: 6px 0 4px; flex-wrap: wrap; }
.exseg .btn { flex: 1 1 auto; min-width: 0; padding: 0 6px; font-size: 12.5px; white-space: nowrap; gap: 4px; }
.cnt { font-style: normal; background: var(--bad, #e84a4a); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 3px; }
.dot { position: relative; } .dot::after { content: attr(data-n); position: absolute; top: 2px; right: 4px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--bad, #e84a4a); color: #fff; font: 900 10px/16px Nunito, sans-serif; text-align: center; }
.exform select { flex: 1; min-height: 36px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,.25); color: var(--tx); font: 800 14px Nunito, sans-serif; padding: 0 8px; min-width: 90px; max-width: 100%; }
.exform select option { background: #1c2333; color: #e8ecf4; }
.exform label.chk { gap: 8px; cursor: pointer; flex-wrap: nowrap; } .exform label.chk input { flex: none; min-width: 18px; width: 18px; min-height: 18px; accent-color: var(--ac); }
.ct { background: var(--s2); border-radius: 12px; padding: 9px 11px; margin-top: 6px; font-size: 13px; font-weight: 700; line-height: 1.4; }
.ct.in { border: 1px solid rgba(139,123,255,.55); box-shadow: 0 0 0 1px rgba(139,123,255,.15) inset; }
.ct .gb { display: flex; gap: 6px; margin-top: 6px; } .ct .gb .btn { flex: 1; }
.myo.ally { border-left: 3px solid #6ee68c; }
.badtx { color: #ff9a8a; }
.pane .btn svg { width: 16px; height: 16px; flex: none; }
.pane [data-act=sea] { white-space: nowrap; }

/* адаптація для середніх ПК-екранів (900–1359px) */
@media (min-width: 900px) and (max-width: 1359px) {
  .top { gap: 6px; padding: 6px 10px; }
  .brand b { max-width: 145px; font-size: 14.5px; }
  .brand span { max-width: 155px; font-size: 11px; }
  .chip { padding: 4px 7px; font-size: 12.5px; gap: 4px; }
  .chip .dsk-full { display: none; }
  .tools .btn.sm { padding: 0 7px; font-size: 12.5px; }
}
@media (min-width: 900px) and (max-width: 1179px) {
  .tools .dsk-wide { display: none; }
  .build { width: 248px; }
  .side { width: 326px; }
  .legend { left: 260px; max-width: calc(100vw - 600px); }
}
@media (min-width: 900px) and (max-width: 1059px) {
  .top { flex-wrap: wrap; row-gap: 5px; }
  .chips { flex-wrap: wrap; }
}

/* мобільний інтерфейс (<= 899px) */
@media (max-width: 899px) {
  .top { height: auto; min-height: 0; flex-wrap: wrap; padding: max(6px, env(safe-area-inset-top)) 8px 6px; gap: 5px 6px; }
  .brand { order: 1; flex: 1 1 auto; min-width: 0; margin-right: 0; }
  .brand b { font-size: 14px; max-width: 100%; }
  .brand span { font-size: 11px; max-width: 100%; }
  .sp { display: none; }
  .tools { order: 2; flex: none; gap: 4px; }
  .tools .dsk, .tools .dsk-wide { display: none; }
  .tools .btn.sm { min-height: 32px; min-width: 34px; padding: 0 7px; font-size: 13px; }
  #b-day { order: 1; }
  #zfit { order: 2; }
  #b-sea { order: 3; }

  .chips { order: 3; flex: 1 0 100%; width: 100%; display: grid; grid-template-columns: minmax(0, 0.96fr) minmax(0, 1.32fr) minmax(0, 0.72fr); gap: 4px; overflow: visible; }
  .chip { padding: 3px 5px; font-size: 12px; gap: 3px; border-radius: 8px; justify-content: center; overflow: hidden; }
  .chip svg { width: 13px; height: 13px; }
  .chip .val { overflow: hidden; text-overflow: ellipsis; }
  .chip .dsk-full { display: none; }
  .chip small { font-size: 10.5px; }
  .dem { height: 16px; gap: 2px; }
  .dem i { width: 5.5px; height: 16px; }

  .layers-bar { top: auto; left: 8px; right: 8px; bottom: calc(var(--nav-h, 64px) + 8px + env(safe-area-inset-bottom)); width: auto; max-width: none; transform: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 10px; }
  .layers-bar .btn { min-width: 0; min-height: 36px; padding: 4px 6px; font-size: 12px; line-height: 1.15; white-space: normal; text-align: center; }

  .build, .side { top: auto; bottom: calc(var(--nav-h, 64px) + env(safe-area-inset-bottom)); left: 0; right: 0; width: auto; border: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; max-height: min(64vh, calc(100dvh - var(--top-h, 96px) - var(--nav-h, 64px) - env(safe-area-inset-bottom) - 8px)); }
  .build { max-height: min(62vh, calc(100dvh - var(--top-h, 96px) - var(--nav-h, 64px) - env(safe-area-inset-bottom) - 8px)); }
  .cats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 8px 8px 8px 24px; }
  .cat { min-height: 44px; font-size: 10.5px; gap: 2px; padding: 4px 2px; }
  .cat svg { width: 18px; height: 18px; }
  .cat .cat-full { display: none; }
  .cat .cat-short { display: inline; }
  .build .list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 8px 8px 8px 24px; overflow-y: auto; overflow-x: hidden; align-content: start; max-height: 56vh; }
  .build .tool { display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: auto auto auto; column-gap: 7px; row-gap: 3px; align-items: start; padding: 8px; width: 100%; min-width: 0; }
  .build .tool img, .build .tool .ic { grid-column: 1; grid-row: 1 / 3; width: 44px; height: 44px; }
  .build .tool .ic svg { width: 24px; height: 24px; }
  .build .tool .tt { display: contents; }
  .build .tool .tn { grid-column: 2; grid-row: 1; font-size: 12.5px; line-height: 1.2; word-break: break-word; }
  .build .tool .tc { grid-column: 2; grid-row: 2; font-size: 11.5px; margin-top: 0; }
  .build .tool .td { grid-column: 1 / 3; grid-row: 3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 11px; line-height: 1.3; margin-top: 2px; }
  .build .tool.lock .td { color: #ffb4aa; }
  .build .exp-jump { grid-column: 1 / -1; }
  .dens { padding: 0 8px 8px 24px; }
  .hintbar { display: none; }

  .side .tabs { padding: 8px 8px 8px 24px; flex-wrap: wrap; }
  .side .tabs .btn { padding: 0 6px; font-size: 12.5px; }
  .side .pane { padding: 10px 12px 10px 24px; }
  .meter { grid-template-columns: minmax(82px, 102px) 1fr 40px; gap: 6px; font-size: 12.5px; }

  .mobtool { display: flex; flex-direction: column; gap: 6px; position: fixed; left: 8px; right: 8px; bottom: calc(var(--nav-h, 64px) + 8px + env(safe-area-inset-bottom)); z-index: 11; background: var(--s1); backdrop-filter: blur(10px); border: 1px solid rgba(139,123,255,.45); border-radius: 14px; padding: 8px 10px; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
  .mt-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .mt-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
  .mt-info b { font-size: 13.5px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mt-info span { font-size: 11.5px; color: var(--mu); font-weight: 700; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .mt-info span.badtx { color: #ff9a8a; }
  .mt-x { min-width: 34px; min-height: 34px; padding: 0; flex: none; }
  .mt-dens { display: flex; gap: 5px; }
  .mt-dens .btn { flex: 1; min-width: 0; min-height: 30px; font-size: 12px; padding: 0 6px; }
  body.has-mobtool #cancel { display: none; }

  .nav { display: flex; }
  .fab { display: flex; }
  .legend { left: 8px; right: 64px; bottom: calc(var(--nav-h, 64px) + var(--mobtool-h, 0px) + 10px + env(safe-area-inset-bottom)); max-width: none; padding: 6px 10px; gap: 5px 10px; }
  #toast { bottom: calc(var(--nav-h, 64px) + var(--mobtool-h, 0px) + 12px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); padding: 9px 13px; font-size: 13px; }

  .seahead { left: 8px; right: 8px; top: max(8px, env(safe-area-inset-top)); padding: 8px 10px; gap: 4px 8px; }
  .seahead b { font-size: 15px; }
  .seahead span { order: 3; flex: 1 0 100%; font-size: 12px; }
  .seahead #seaclose { margin-left: auto; }
  .seacard { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); width: auto; max-height: 52vh; overflow: auto; padding: 12px; }

  .start { padding: 10px; }
  .start .box { padding: 16px; border-radius: 14px; }
  .start h1 { font-size: 22px; }
  .isles { grid-template-columns: 1fr; }
  .isle canvas { height: 90px; }
  .start input { min-width: 0; width: 100%; }
}

@media (min-width: 580px) and (max-width: 899px) {
  .chips { display: flex; flex-wrap: nowrap; gap: 5px; }
  .chip { flex: 1 1 auto; }
}

@media (max-width: 379px) {
  .chip .dem-lbl { display: none; }
  .st-acts { grid-template-columns: 1fr; }
  .st-stat { padding: 5px 6px; }
  .st-stat b { font-size: 12px; }
  .exseg .btn { font-size: 11.5px; padding: 0 5px; }
}
