/* Bad Piggies: Космос — интерфейс в "деревянно-мультяшном" стиле */
@font-face { font-family: 'Rubik'; font-weight: 700; font-display: swap; src: url('../fonts/rubik-cyrillic-700-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Rubik'; font-weight: 700; font-display: swap; src: url('../fonts/rubik-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Rubik'; font-weight: 800 900; font-display: swap; src: url('../fonts/rubik-cyrillic-900-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Rubik'; font-weight: 800 900; font-display: swap; src: url('../fonts/rubik-latin-900-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Seymour One'; font-display: swap; src: url('../fonts/seymour-one-cyrillic-400-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Seymour One'; font-display: swap; src: url('../fonts/seymour-one-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --ink: #2b1a0e;
  --wood: #d49a55;
  --wood-d: #9b6532;
  --wood-l: #f0c88a;
  --green: #7fd64f;
  --green-d: #3e8a1e;
  --orange: #ffa62b;
  --orange-d: #c86a0a;
  --red: #e8453a;
  --cream: #fff4dc;
  --panel: rgba(255, 244, 220, 0.94);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* страница никогда не прокручивается: на телефоне body закреплён, а прокрутка лент и окон не перетекает на неё */
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: #4fb6ec; }
body { position: fixed; inset: 0; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { font-family: 'Rubik', system-ui, sans-serif; font-weight: 700; color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none; }

#game { position: fixed; inset: 0; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: block; }
.screen > *, .modal, #toasts > * { pointer-events: auto; }
.screen.hud { pointer-events: none; }
.screen.hud > * { pointer-events: auto; }

/* ---------- кнопки ---------- */
.btn {
  font: inherit; font-weight: 900; color: var(--ink); cursor: pointer;
  border: 3px solid var(--ink); border-radius: 14px; padding: 8px 14px;
  background: linear-gradient(#fff6e2, #f0d8a8);
  box-shadow: 0 4px 0 var(--ink), inset 0 2px 0 rgba(255,255,255,.8);
  transition: transform .08s, box-shadow .08s, filter .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:active, .btn.on { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink), inset 0 2px 0 rgba(255,255,255,.6); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.green { background: linear-gradient(#a6ef6c, #59b52c); color: #fff; text-shadow: 0 2px 0 var(--green-d), 0 0 2px var(--ink); }
.btn.orange { background: linear-gradient(#ffd27a, #ff9a1f); color: #fff; text-shadow: 0 2px 0 var(--orange-d), 0 0 2px var(--ink); }
.btn.red { background: linear-gradient(#ff8c7a, #d9342a); color: #fff; text-shadow: 0 2px 0 #7a1410; }
.btn.sq { width: 46px; height: 46px; padding: 0; font-size: 22px; display: inline-flex; align-items: center; justify-content: center; }
.btn.round { width: 58px; height: 58px; border-radius: 50%; padding: 0; font-size: 26px; }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 10px; box-shadow: 0 3px 0 var(--ink); }
.btn.big { font-family: 'Seymour One', 'Rubik', sans-serif; font-weight: 400; font-size: 30px; padding: 16px 34px; border-radius: 22px; border-width: 4px; box-shadow: 0 7px 0 var(--ink), inset 0 3px 0 rgba(255,255,255,.6); display: flex; align-items: center; gap: 12px; letter-spacing: .5px; }
.btn.big:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.btn .ico { font-size: 30px; filter: drop-shadow(0 2px 0 rgba(0,0,0,.3)); }
.btn.ic { display: inline-flex; align-items: center; gap: 6px; }
.btn.attn { animation: attn 1s infinite; }
@keyframes attn { 50% { background: linear-gradient(#fffab0, #ffd23a); } }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }

/* ---------- меню ---------- */
#scr-menu { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 26px; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 40%, rgba(0,20,40,.25)); }
#scr-menu.active { display: flex; }
.logo { display: flex; align-items: center; gap: 4px; filter: drop-shadow(0 6px 0 rgba(43,26,14,.35)); }
.logo-text { text-align: center; }
.logo-top {
  font-family: 'Seymour One', sans-serif; font-size: clamp(38px, 8vw, 86px); line-height: 1;
  color: #8fe05a; letter-spacing: 2px;
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--green-d), 0 8px 0 var(--ink);
  transform: rotate(-3deg);
}
.logo-sub {
  margin-top: 10px; display: inline-block; font-family: 'Seymour One', sans-serif; font-size: clamp(14px, 2.4vw, 24px);
  color: #fff; background: linear-gradient(#5a3cc8, #2a1a7a); padding: 6px 16px; border: 3px solid var(--ink); border-radius: 12px;
  box-shadow: 0 4px 0 var(--ink); transform: rotate(2deg); letter-spacing: 1px;
}
#logo-pig { width: 140px; height: 140px; animation: bob 2.6s ease-in-out infinite; }
#logo-bird { width: 110px; height: 110px; animation: bob 2.2s ease-in-out infinite reverse; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(4deg); } }
.menu-main { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; }
.menu-row { display: flex; gap: 16px; }
.menu-foot { position: absolute; bottom: 12px; font-size: 13px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); opacity: .9; }

/* ---------- песочницы ---------- */
#scr-sandboxes { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 24px; background: rgba(10,20,40,.35); }
#scr-sandboxes.active { display: flex; }
.scr-title { font-family: 'Seymour One', sans-serif; font-weight: 400; font-size: 46px; margin: 0; color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); }
.sb-cards { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; padding: 0 16px; }
.sb-card {
  font: inherit; color: var(--ink); cursor: pointer; text-align: left; width: 330px; padding: 14px;
  border: 4px solid var(--ink); border-radius: 22px; background: linear-gradient(#ffe9bd, #e8b46c);
  box-shadow: 0 7px 0 var(--ink); display: flex; flex-direction: column; gap: 8px; transition: transform .12s;
}
.sb-card:hover { transform: translateY(-4px) rotate(-1deg); }
.sb-card canvas { width: 100%; border-radius: 12px; border: 3px solid var(--ink); }
.sb-name { font-family: 'Seymour One', sans-serif; font-size: 20px; }
.sb-desc { font-size: 14px; opacity: .85; line-height: 1.3; }
.sb-progress { display: flex; gap: 14px; font-size: 18px; font-weight: 900; }
.sb-progress span { display: inline-flex; align-items: center; gap: 4px; }
.sb-progress img { width: 26px; height: 26px; }
.sb-go { align-self: flex-end; background: linear-gradient(#a6ef6c, #59b52c); color: #fff; padding: 6px 16px; border-radius: 12px; border: 3px solid var(--ink); text-shadow: 0 2px 0 var(--green-d); font-weight: 900; }
.sb-card.locked { width: 220px; align-items: center; justify-content: center; background: linear-gradient(#d8d0c0, #a8a090); opacity: .85; }
.sb-lock { font-size: 64px; }
.btn.back { position: absolute; left: 20px; top: 20px; }

/* ---------- верхняя панель ---------- */
.screen .topbar { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.tb-title { font-family: 'Seymour One', sans-serif; font-size: 22px; color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink); margin-left: 6px; }
.tb-right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
/* бонусы — всплывающая панель под кнопкой ⚡ */
.bonus-pop { position: absolute; top: 66px; right: 10px; display: flex; gap: 6px; padding: 6px; background: var(--panel); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink); z-index: 3; }
.bonus-pop.hidden { display: none; }
.btn .badge { position: absolute; right: -6px; top: -6px; min-width: 20px; height: 20px; border-radius: 10px; background: linear-gradient(#e9a6ff, #a54ad6); color: #fff; border: 2px solid var(--ink); font-size: 11px; line-height: 16px; text-align: center; }
.btn .badge.hidden { display: none; }
#b-bonus, #b-eng { position: relative; }
#b-bonus.on { background: linear-gradient(#f3d0ff, #c27ae8); }
#b-eng.on { background: linear-gradient(#bfe8ff, #4aa8e8); }
.pw { font: inherit; font-weight: 800; font-size: 13px; cursor: pointer; padding: 5px 10px; border-radius: 20px; border: 3px solid var(--ink); background: rgba(255,255,255,.75); box-shadow: 0 3px 0 var(--ink); color: var(--ink); opacity: .75; }
.pw.on { background: linear-gradient(#e9a6ff, #a54ad6); color: #fff; opacity: 1; text-shadow: 0 1px 0 #4a1070; }

.part-info { position: absolute; top: 66px; left: 70px; max-width: min(380px, 50vw); background: var(--panel); border: 3px solid var(--ink); border-radius: 14px; padding: 5px 12px; box-shadow: 0 4px 0 var(--ink); font-size: 13px; line-height: 1.3; cursor: pointer; z-index: 2; }
.part-info.full { padding: 8px 12px; }
.pi-name { font-family: 'Seymour One', sans-serif; font-size: 15px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pi-more { font-style: normal; font-family: Rubik, sans-serif; font-size: 14px; opacity: .55; }
.pi-desc { font-weight: 700; opacity: .85; }
.pi-count { margin-top: 4px; opacity: .6; font-size: 12px; }
.warn { margin-top: 5px; color: #c0201a; font-weight: 900; }
.warn.soft { color: #8a5a10; font-weight: 800; }

/* ---------- инструменты (слева) ---------- */
.toolbar { position: absolute; left: 10px; top: 66px; display: flex; flex-direction: column; gap: 6px; padding: 6px; background: var(--panel); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); }
.tb-tool { width: 42px; height: 42px; padding: 0; font-size: 20px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; }
.tb-tool img { width: 32px; height: 32px; pointer-events: none; }
.tb-tool.on { background: linear-gradient(#c6f59c, #7fd64f); transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.tb-sep { display: block; height: 3px; margin: 1px 4px; border-radius: 2px; background: rgba(43, 26, 14, .25); }

/* ---------- блокнот идей ---------- */
.notes-box { max-width: 680px; }
.nt-sub { font-size: 13px; opacity: .75; margin: 0 0 8px; }
textarea.notes {
  display: block; width: min(620px, 82vw); height: min(46vh, 380px); resize: vertical; padding: 4px 12px 4px 40px;
  font: inherit; font-weight: 700; font-size: 16px; line-height: 28px; color: #2b1a0e; border: 3px solid var(--ink); border-radius: 12px;
  background: linear-gradient(90deg, transparent 30px, rgba(220, 70, 60, .45) 30px 32px, transparent 32px), repeating-linear-gradient(#fffdf4 0 27px, #c9dcef 27px 28px);
  background-attachment: local; box-shadow: inset 0 2px 6px rgba(0,0,0,.12); outline: none;
  user-select: text; -webkit-user-select: text; touch-action: auto; -webkit-touch-callout: default;
}
textarea.notes:focus { border-color: #3fa0ff; }
.nt-foot { font-size: 12px; opacity: .6; text-align: right; margin-top: 4px; }
.m-btns.top { margin: 0 0 10px; }

/* ---------- палитра ---------- */
.palette { position: absolute; left: 0; right: 120px; bottom: 0; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 0; }
.cat-tabs { display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; overscroll-behavior: contain; touch-action: pan-x; scrollbar-width: none; padding-top: 4px;
  /* неактивные вкладки сдвинуты вниз на 3px — место под сдвиг, чтобы лента не прокручивалась по вертикали */
  padding-bottom: 3px; margin-bottom: -3px; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  font: inherit; font-weight: 900; font-size: 13px; cursor: pointer; color: var(--ink); white-space: nowrap;
  display: flex; align-items: center; gap: 4px; padding: 4px 10px 6px; border: 3px solid var(--ink); border-bottom: none;
  border-radius: 12px 12px 0 0; background: linear-gradient(#e8c48a, #c99550); opacity: .9; transform: translateY(3px);
}
.cat-tab.sel { background: linear-gradient(#fff4dc, #f2d6a2); opacity: 1; transform: none; }
.cat-ico { width: 24px; height: 24px; }
.cat-tab.shake { animation: shake .5s 2; background: linear-gradient(#ffb0a0, #ff6050); }
@keyframes shake { 25% { transform: translateX(-6px) rotate(-3deg); } 75% { transform: translateX(6px) rotate(3deg); } }
.parts-row {
  display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior: contain; touch-action: pan-x; padding: 10px; border: 3px solid var(--ink); border-radius: 0 16px 16px 16px;
  background: repeating-linear-gradient(90deg, #f2d6a2 0 48px, #ead0a0 48px 96px); box-shadow: 0 5px 0 var(--ink);
  scrollbar-width: thin;
}
.part-btn {
  font: inherit; cursor: pointer; flex: 0 0 auto; width: 88px; padding: 6px 4px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 3px solid var(--ink); border-radius: 14px; background: linear-gradient(#fffaf0, #f0dcb4); box-shadow: 0 4px 0 var(--ink); color: var(--ink);
  transition: transform .08s;
}
.part-btn img { width: 58px; height: 58px; pointer-events: none; }
.part-btn .pname { font-size: 11px; font-weight: 900; line-height: 1.1; text-align: center; min-height: 24px; display: flex; align-items: center; justify-content: center; overflow-wrap: anywhere; hyphens: auto; max-width: 100%; }
.part-btn:hover { transform: translateY(-3px); }
.part-btn.sel { background: linear-gradient(#c6f59c, #7fd64f); transform: translateY(-4px) scale(1.04); box-shadow: 0 6px 0 var(--ink); }

.play-btn {
  position: absolute; right: 16px; bottom: 16px; width: 96px; height: 96px; border-radius: 50%; font-size: 44px; padding: 0 0 0 8px;
  background: radial-gradient(circle at 35% 30%, #c8ff8a, #59b52c 60%, #3e8a1e); color: #fff; border-width: 4px;
  box-shadow: 0 7px 0 var(--ink), 0 0 0 6px rgba(255,255,255,.35); text-shadow: 0 3px 0 var(--green-d);
  animation: pulse 1.6s ease-in-out infinite;
}

/* ---------- игровой HUD ---------- */
.counters { margin-left: auto; display: flex; gap: 8px; }
.counters span { display: inline-flex; align-items: center; gap: 4px; background: var(--panel); border: 3px solid var(--ink); border-radius: 20px; padding: 3px 12px 3px 6px; box-shadow: 0 3px 0 var(--ink); font-weight: 900; font-size: 16px; }
.counters img { width: 26px; height: 26px; }
.counters span.bump { animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.35) rotate(-5deg); background: #fff27a; } }

.telemetry { position: absolute; top: 66px; right: 10px; width: 186px; background: rgba(20, 16, 40, .62); color: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 7px 10px; font-size: 13px; box-shadow: 0 4px 0 rgba(0,0,0,.4); }
.telemetry .zone { font-family: 'Seymour One', sans-serif; font-size: 14px; color: #a6ef6c; margin-bottom: 3px; }
.telemetry .zone.space { color: #c8a0ff; }
.telemetry .row { display: flex; justify-content: space-between; }
.telemetry .row span { opacity: .75; }
.telemetry .orbit { margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(255,255,255,.2); font-size: 12px; color: #bfefff; line-height: 1.35; }
.telemetry .orbit:empty { display: none; }
.telemetry { cursor: pointer; padding-right: 18px; }
.telemetry::after { content: '▾'; position: absolute; right: 6px; top: 2px; font-size: 11px; opacity: .55; }
.telemetry.mini::after { content: '▸'; }
.telemetry.mini .zone, .telemetry.mini .ext, .telemetry.mini .orbit { display: none; }
#slowmo { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); font-family: 'Seymour One', sans-serif; font-size: 16px; color: #bfefff; text-shadow: 0 2px 0 #000; letter-spacing: 3px; pointer-events: none; animation: attn 1.4s infinite; }
#slowmo.hidden { display: none; }
.btn.hidden { display: none; }
#s-gas { background: linear-gradient(#ffe08a, #f2a516); }
.fuel { margin-top: 4px; }
.fuel span { opacity: .75; }
.fuel-bar { height: 10px; border-radius: 6px; background: #222; border: 2px solid #000; overflow: hidden; margin-top: 2px; }
.fuel-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(#7dff9a, #2bbf4f); }

#minimap { position: absolute; right: 10px; bottom: 10px; width: 136px; height: 184px; border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 4px 0 rgba(0,0,0,.4); cursor: zoom-in; }

/* большая карта */
#bigmap { position: fixed; inset: 0; z-index: 25; background: #05051a; touch-action: none; pointer-events: auto; }
#bigmap.hidden { display: none; }
#bm-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.bm-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.bm-top > * { pointer-events: auto; }
.bm-title { font-family: 'Seymour One', sans-serif; font-size: 22px; color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 3px var(--ink); pointer-events: none; }
.bm-tools { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.bm-info { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); max-width: min(560px, calc(100vw - 24px)); background: rgba(20,16,40,.78); color: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 7px 12px; font-size: 13px; text-align: center; pointer-events: none; }
.bm-info b { color: #ffc860; }

.actions { position: absolute; left: 230px; right: 190px; bottom: 14px; display: flex; gap: 10px; flex-wrap: wrap-reverse; justify-content: center; pointer-events: none; }
.actions > * { pointer-events: auto; }
.act {
  position: relative; width: 74px; height: 74px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 4px solid var(--ink); background: radial-gradient(circle at 40% 30%, #fffaf0, #f0d8a8 70%, #d9b070); box-shadow: 0 5px 0 var(--ink);
  transition: transform .08s;
}
.act img { width: 58px; height: 58px; pointer-events: none; }
.act .key { position: absolute; left: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); font-size: 12px; font-weight: 900; display: flex; align-items: center; justify-content: center; }
.act .cnt { position: absolute; right: -6px; bottom: -4px; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 12px; background: var(--orange); border: 2px solid var(--ink); color: #fff; font-size: 13px; font-weight: 900; display: flex; align-items: center; justify-content: center; text-shadow: 0 1px 0 var(--orange-d); }
.act.on { background: radial-gradient(circle at 40% 30%, #eaffd0, #8fe05a 70%, #4f9a24); box-shadow: 0 2px 0 var(--ink), 0 0 18px 4px rgba(160,255,100,.75); transform: translateY(3px); }
.act.disabled { filter: grayscale(1); opacity: .5; }
.act.press { animation: press .25s; }
@keyframes press { 40% { transform: scale(.88); } }

.steer { position: absolute; left: 12px; bottom: 14px; display: flex; gap: 8px; align-items: center; }
#steer-rot { display: flex; gap: 8px; }
.steer .btn.sq { width: 62px; height: 62px; font-size: 30px; border-radius: 50%; }

/* ---------- модальные окна ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 10, 30, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal.hidden { display: none; }
.modal-box {
  position: relative; max-width: 460px; width: 100%; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 18px 22px;
  background: linear-gradient(#fff4dc, #f2d6a2); border: 4px solid var(--ink); border-radius: 24px; box-shadow: 0 8px 0 var(--ink);
  animation: popin .25s cubic-bezier(.2,1.6,.4,1);
}
.modal-box.wide { max-width: 760px; }
@keyframes popin { from { transform: scale(.7); opacity: 0; } }
.modal-box h2 { font-family: 'Seymour One', sans-serif; font-weight: 400; margin: 0 0 10px; font-size: 28px; text-align: center; color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }
.modal-box h2 small { font-size: 18px; }
.m-text { text-align: center; font-size: 15px; }
.m-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.pause .m-btns { flex-direction: column; align-items: stretch; }
.m-pig { display: block; margin: 0 auto; }
.stub { display: flex; gap: 14px; align-items: center; }
.stub-text p { margin: 6px 0; font-size: 15px; line-height: 1.35; }
.help { font-size: 14px; line-height: 1.4; }
.help h3 { font-family: 'Seymour One', sans-serif; font-weight: 400; margin: 10px 0 4px; font-size: 17px; }
.help ul { margin: 0; padding-left: 20px; }
kbd { display: inline-block; padding: 0 6px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; font: inherit; font-size: 12px; box-shadow: 0 2px 0 var(--ink); }
.ach-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.ach { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border: 3px solid var(--ink); border-radius: 12px; background: rgba(0,0,0,.08); opacity: .6; }
.ach.ok { background: linear-gradient(#fff7b0, #ffd23a); opacity: 1; }
.ach .a-ico { font-size: 24px; }
.ach b { display: block; font-size: 14px; }
.ach span { font-size: 12px; opacity: .8; }
.stats { margin-top: 10px; font-size: 13px; text-align: center; }
.settings { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 16px; }
.settings input[type=range] { width: 60%; accent-color: #59b52c; }
.settings select { font: inherit; padding: 4px 8px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; }
.fun-box { border: 3px solid var(--ink); border-radius: 14px; padding: 8px 12px; background: rgba(255,255,255,.45); }
.settings .fun-main span { display: flex; flex-direction: column; }
.fun-main small { font-size: 12px; opacity: .7; }
.fun-box input[type=checkbox] { width: 20px; height: 20px; accent-color: #59b52c; flex: 0 0 auto; }
.fun-list { display: none; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 4px 10px; margin-top: 8px; padding-top: 8px; border-top: 2px dashed rgba(0,0,0,.25); }
.fun-box.on .fun-list { display: grid; }
.settings .fun-list label { justify-content: flex-start; font-size: 13px; gap: 6px; cursor: pointer; }
.bp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.bp-card { font: inherit; color: var(--ink); text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 3px solid var(--ink); border-radius: 14px; background: rgba(255,255,255,.6); box-shadow: 0 4px 0 var(--ink); transition: transform .1s; }
.bp-card:hover { transform: translateY(-3px); }
.bp-card canvas { width: 100%; background: linear-gradient(#9ad8f5, #e2f6ff); border-radius: 10px; border: 2px solid var(--ink); }
.bp-card b { font-size: 15px; }
.bp-card span { font-size: 12px; opacity: .8; }
.bp-actions { display: flex; gap: 6px; justify-content: flex-end; }
.save-row { display: flex; gap: 8px; }
.save-row input { flex: 1; font: inherit; font-size: 16px; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 12px; }

/* ---------- тосты, баннер, вспышка ---------- */
#toasts { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 30; pointer-events: none; }
body[data-screen="play"] #toasts { left: 10px; transform: none; align-items: flex-start; }
.toast { display: flex; gap: 8px; align-items: center; min-width: 240px; max-width: 360px; padding: 5px 12px; background: linear-gradient(#fff7d0, #ffd77a); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 5px 0 var(--ink); animation: tin .4s cubic-bezier(.2,1.5,.4,1); }
.toast.out { animation: tout .5s forwards; }
.toast .t-ico { width: 34px; height: 34px; flex: 0 0 auto; }
.toast .t-ico.e { font-size: 26px; display: flex; align-items: center; justify-content: center; }
.toast .t-body b { display: block; font-family: 'Seymour One', sans-serif; font-weight: 400; font-size: 13px; }
.toast .t-body span { font-size: 12px; line-height: 1.2; display: block; }
@keyframes tin { from { transform: translateX(-60px) scale(.8); opacity: 0; } }
@keyframes tout { to { transform: translateX(-40px); opacity: 0; } }

#banner { position: fixed; top: 22%; left: 0; right: 0; text-align: center; pointer-events: none; z-index: 15; }
#banner.hidden { display: none; }
#banner .b-title { font-family: 'Seymour One', sans-serif; font-size: clamp(26px, 5.5vw, 64px); padding: 0 16px; overflow-wrap: anywhere; line-height: 1.1; color: #ffe04a; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); }
#banner .b-sub { margin-top: 6px; display: inline-block; font-size: 16px; color: #fff; background: rgba(0,0,0,.45); padding: 4px 14px; border-radius: 12px; }
#banner.anim { animation: banner 3s forwards; }
@keyframes banner { 0% { transform: scale(.3); opacity: 0; } 12% { transform: scale(1.12); opacity: 1; } 20% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }

#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 40; }
#flash.go { animation: flash .5s; }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }

/* ---------- выделение, настройки деталей, расчёт ---------- */
.pw.tool { opacity: .9; }
.pw.tool.on { background: linear-gradient(#bfe8ff, #4aa8e8); color: #fff; text-shadow: 0 1px 0 #1a4a70; }
.sel-bar { position: absolute; left: 0; right: 0; margin: 0 auto; width: max-content; top: 112px; display: flex; gap: 6px; align-items: center; background: var(--panel); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 8px; box-shadow: 0 4px 0 var(--ink); max-width: calc(100vw - 20px); flex-wrap: wrap; justify-content: center; }
.sel-bar.hidden { display: none; }
.sel-bar .sb-btn { padding: 0; width: 40px; height: 38px; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.sel-bar .sb-btn .bi { font-size: 18px; }
.sel-bar .sb-btn .bt { display: none; }
.sel-bar .sb-btn:disabled { opacity: .4; filter: grayscale(1); }
.sel-bar .sb-btn.on { background: linear-gradient(#c6f59c, #7fd64f); }
.sb-hint { font-size: 12px; font-weight: 800; opacity: .75; padding: 0 4px; max-width: 150px; line-height: 1.15; }
.set-h { display: flex; align-items: center; justify-content: center; gap: 8px; }
.set-h img { width: 52px; height: 52px; }
.set-list { display: flex; flex-direction: column; gap: 12px; min-width: min(420px, 80vw); }
.set-row { display: flex; flex-direction: column; gap: 6px; }
.set-name { font-weight: 900; display: flex; justify-content: space-between; gap: 10px; }
.set-val { color: #b05a00; }
.set-range { flex: 1; min-width: 0; width: 100%; accent-color: #59b52c; height: 26px; }
.set-line { display: flex; align-items: center; gap: 8px; }
.set-step { font: inherit; font-weight: 900; font-size: 20px; line-height: 1; flex: none; width: 38px; height: 34px; border-radius: 12px; border: 3px solid var(--ink); background: #fff8e8; color: var(--ink); box-shadow: 0 3px 0 var(--ink); cursor: pointer; touch-action: none; user-select: none; }
.set-step:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.set-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-weight: 900; font-size: 14px; cursor: pointer; min-width: 36px; height: 34px; padding: 0 10px; border-radius: 17px; border: 3px solid var(--ink); background: #fff8e8; color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.chip.sel { background: linear-gradient(#c6f59c, #7fd64f); transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.chip.ch { background: var(--ch); padding: 0; width: 34px; }
.chip.ch.sel { outline: 3px solid #fff; outline-offset: -7px; }
.set-hint { font-size: 12px; font-weight: 700; opacity: .75; }
.act.chan { border-color: var(--ch); box-shadow: 0 5px 0 var(--ink), inset 0 0 0 3px var(--ink); }
.act .chn { position: absolute; right: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--ch); border: 2px solid var(--ink); font-size: 12px; font-weight: 900; display: flex; align-items: center; justify-content: center; }
.eng-panel { position: absolute; top: 66px; right: 10px; width: 250px; background: var(--panel); border: 3px solid var(--ink); border-radius: 14px; padding: 7px 11px; box-shadow: 0 4px 0 var(--ink); font-size: 12px; line-height: 1.35; }
.eng-panel.hidden { display: none; }
.eng-h { font-family: 'Seymour One', sans-serif; font-size: 14px; margin-bottom: 3px; }
.eng-h small { font-family: Rubik, sans-serif; font-size: 11px; font-weight: 700; opacity: .6; }
.eng-row { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.eng-row b { text-align: right; }
.eng-row.good b { color: #2f8a10; }
.eng-row.bad b { color: #c0201a; }

/* слои мастерской */
/* справа по центру: слева — панель инструментов */
.layer-bar { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 5px; background: var(--panel); border: 3px solid var(--ink); border-radius: 14px; padding: 5px 6px 6px; box-shadow: 0 4px 0 var(--ink); }
.lb-head { font-weight: 900; font-size: 12px; text-align: center; cursor: pointer; text-transform: uppercase; letter-spacing: .04em; }
.lb-q { display: inline-block; margin-left: 4px; width: 16px; height: 16px; line-height: 14px; border-radius: 50%; border: 2px solid var(--ink); font-size: 10px; opacity: .6; text-transform: none; }
/* свёрнутая панель слоёв: только сами слои; глаза — после тапа по заголовку (или у скрытого слоя) */
.layer-bar:not(.open) .lb-row:not(.off) .lb-eye { display: none; }
.layer-bar:not(.open) .lb-q { display: none; }
.lb-row { display: flex; align-items: center; gap: 3px; }
.lb-row button { font: inherit; cursor: pointer; border: 2px solid var(--ink); color: var(--ink); padding: 0; }
.lb-eye { width: 24px; height: 30px; border-radius: 8px; background: #fff8e8; font-size: 13px; }
.lb-row.on .lb-eye { visibility: hidden; }
.lb-row.off .lb-eye { opacity: .45; text-decoration: line-through; background: #d8cbb0; }
.lb-btn { display: flex; align-items: center; gap: 5px; width: 64px; height: 34px; border-radius: 10px; background: #fff8e8; box-shadow: 0 3px 0 var(--ink); padding: 0 6px !important; }
.lb-btn i { width: 12px; height: 12px; border-radius: 3px; background: var(--lc); border: 2px solid var(--ink); flex: none; }
.lb-btn b { font-size: 16px; font-weight: 900; }
.lb-btn .lb-n { margin-left: auto; font-size: 11px; font-weight: 700; opacity: .6; }
.lb-row.on .lb-btn { background: linear-gradient(#c6f59c, #7fd64f); transform: translateY(2px); box-shadow: 0 1px 0 var(--ink), inset 0 0 0 2px var(--lc); }
.lb-row.off .lb-btn { opacity: .55; }
.lb-mv { width: 26px; height: 30px; border-radius: 8px; background: var(--lc); color: #fff !important; font-weight: 900; font-size: 15px; visibility: hidden; }
.lb-row.mvable .lb-mv { visibility: visible; }
.layer-help p { text-align: left; margin: 0 0 8px; }

/* ---------- маленькие экраны ---------- */
@media (max-width: 760px) {
  .tb-title { display: none; }
  .btn.ic { width: 46px; height: 46px; padding: 0; font-size: 22px; }
  .btn.ic .bt { display: none; }
  .part-info { top: 62px; left: 64px; max-width: calc(100vw - 160px); font-size: 11px; padding: 3px 9px; }
  .pi-name { font-size: 12px; }
  .part-info .warn { font-size: 11px; }
  .toolbar { top: 62px; left: 6px; padding: 4px; gap: 4px; border-radius: 13px; }
  .tb-tool { width: 38px; height: 38px; font-size: 18px; border-radius: 10px; }
  .tb-tool img { width: 28px; height: 28px; }
  .bonus-pop { top: 62px; right: 6px; flex-direction: column; }
  .eng-panel { top: 104px; left: 64px; right: auto; width: 220px; font-size: 11px; }
  .sel-bar { top: 104px; }
  body[data-sel="1"] .eng-panel { top: 156px; }
  .sel-bar .sb-btn .bt { display: none; }
  .pw { font-size: 11px; padding: 4px 7px; }
  .palette { right: 0; }
  .layer-bar { right: 6px; padding: 3px 4px 4px; gap: 3px; border-width: 2px; }
  .lb-head { font-size: 10px; }
  .lb-btn { width: 40px; height: 30px; }
  .lb-btn .lb-n { display: none; }
  .lb-eye, .lb-mv { width: 22px; height: 26px; font-size: 11px; }
  .play-btn { width: 74px; height: 74px; font-size: 34px; bottom: auto; top: 112px; right: 12px; }
  .part-btn { width: 74px; }
  .part-btn img { width: 46px; height: 46px; }
  .telemetry { width: 150px; font-size: 11px; top: 64px; }
  #minimap { width: 92px; height: 124px; border-width: 2px; border-radius: 10px; right: 8px; bottom: 8px; }
  .actions { left: 8px; right: 106px; bottom: 84px; gap: 8px; justify-content: flex-start; }
  .act { width: 60px; height: 60px; }
  .act img { width: 46px; height: 46px; }
  .counters span { font-size: 13px; padding: 2px 8px 2px 4px; }
  .counters img { width: 20px; height: 20px; }
  .topbar .btn.sq { width: 40px; height: 40px; font-size: 18px; }
  .logo canvas { display: none; }
  .btn.big { font-size: 22px; padding: 12px 22px; }
}

/* узкие телефоны: все кнопки мастерской в один ряд, без переноса корзины на вторую строку */
@media (max-width: 460px) {
  .screen .topbar { left: 6px; right: 6px; gap: 5px; }
  .tb-right { flex-wrap: nowrap; gap: 5px; }
  .topbar .btn.sq, .topbar .btn.ic { width: 38px; height: 38px; font-size: 18px; border-radius: 11px; flex: 0 1 38px; min-width: 30px; }
  .part-info { top: 52px; left: 56px; max-width: calc(100vw - 150px); }
  .toolbar { top: 52px; }
  .tb-tool { width: 36px; height: 36px; }
  .bonus-pop { top: 52px; }
  .eng-panel { top: 92px; left: 56px; }
  #scr-play .topbar { flex-wrap: wrap; row-gap: 6px; }
  #scr-play .counters { flex-basis: 100%; margin-left: 0; gap: 5px; }
  #scr-play .telemetry { top: 100px; }
  body[data-screen="play"] #toasts { top: 100px; }
  .bm-title { display: none; }
  .bm-top { left: 6px; right: 6px; gap: 5px; }
  .bm-tools { flex-wrap: nowrap; gap: 5px; }
  .bm-top .btn.sq { width: 38px; height: 38px; font-size: 18px; flex: 0 1 38px; min-width: 30px; }
  .pw .pt { display: none; }
  .act { width: 54px; height: 54px; }
  .act img { width: 42px; height: 42px; }
}

/* низкие экраны (телефон в альбомной ориентации) */
@media (max-height: 520px) {
  .screen .topbar { top: 6px; left: 6px; right: 6px; gap: 6px; }
  .btn.sq, .btn.ic { width: 38px; height: 38px; font-size: 18px; padding: 0; border-radius: 11px; }
  .btn.ic .bt { display: none; }
  .tb-title { font-size: 16px; }
  .part-info { top: 50px; left: 286px; max-width: calc(100vw - 520px); font-size: 11px; padding: 3px 9px; }
  .pi-name { font-size: 12px; }
  .part-info.full .pi-desc { max-height: 30vh; overflow: auto; }
  /* в альбомной ориентации места по высоте мало — инструменты в ряд под верхней панелью */
  .toolbar { top: 50px; left: 6px; padding: 3px; gap: 3px; flex-direction: row; }
  .tb-tool { width: 34px; height: 34px; font-size: 16px; border-radius: 9px; }
  .tb-tool img { width: 24px; height: 24px; }
  .tb-sep { display: none; }
  .bonus-pop { top: 50px; right: 6px; }
  .eng-panel { top: 50px; right: 6px; width: 210px; font-size: 11px; padding: 4px 8px; max-height: calc(100vh - 170px); overflow: auto; }
  .sel-bar { top: 50px; padding: 4px 6px; }
  textarea.notes { height: 38vh; }
  body[data-sel="1"] .eng-panel { top: 100px; }
  .sel-bar .sb-btn .bt { display: none; }
  .pw { font-size: 11px; padding: 3px 8px; box-shadow: 0 2px 0 var(--ink); }
  .palette { padding: 0 6px 6px; right: 86px; }
  .cat-tab { font-size: 11px; padding: 2px 7px 4px; }
  .cat-ico { width: 18px; height: 18px; }
  .parts-row { padding: 5px; gap: 5px; border-width: 2px; }
  .part-btn { width: 60px; padding: 3px 2px 2px; border-radius: 10px; box-shadow: 0 3px 0 var(--ink); }
  .part-btn img { width: 34px; height: 34px; }
  .part-btn .pname { font-size: 9px; min-height: 18px; }
  .play-btn { width: 66px; height: 66px; font-size: 30px; right: 10px; bottom: 10px; top: auto; }
  .layer-bar { right: 6px; padding: 3px 4px 4px; gap: 3px; border-width: 2px; }
  .lb-head { font-size: 10px; }
  .lb-btn { height: 28px; width: 54px; }
  .lb-eye, .lb-mv { height: 26px; }
  .telemetry { top: 50px; width: 148px; font-size: 11px; padding: 4px 8px; }
  .telemetry .zone { font-size: 12px; }
  #minimap { width: 78px; height: 106px; border-width: 2px; border-radius: 10px; right: 8px; bottom: 8px; }
  .bm-title { display: none; }
  .bm-top .btn.sq { width: 38px; height: 38px; font-size: 18px; }
  .actions { bottom: 8px; gap: 6px; left: 130px; right: 100px; }
  .act { width: 52px; height: 52px; border-width: 3px; }
  .act img { width: 40px; height: 40px; }
  .counters span { font-size: 13px; padding: 2px 8px 2px 4px; }
  .counters img { width: 20px; height: 20px; }
  .steer { bottom: 8px; left: 8px; }
  .steer .btn.sq { width: 50px; height: 50px; font-size: 24px; }
  #toasts { top: 50px; }
  .logo canvas { display: none; }
  .logo-top { font-size: 44px; }
  .btn.big { font-size: 20px; padding: 10px 20px; }
  .btn.round { width: 46px; height: 46px; font-size: 20px; }
  #scr-menu { gap: 14px; }
  .modal-box { padding: 12px 16px; }
  .scr-title { font-size: 30px; }
  .sb-card { width: 280px; padding: 10px; }
  .sb-card canvas { display: none; }
}

/* ---------- сенсорный экран: поворот под левым большим пальцем, газ — под правым ---------- */
body.touch .steer { right: 12px; justify-content: space-between; pointer-events: none; }
body.touch .steer > * { pointer-events: auto; }
body.touch #s-rev { margin-left: auto; }
body.touch .steer .btn.sq { width: 64px; height: 64px; }
body.touch #s-gas { width: 78px; height: 78px; font-size: 36px; }
body.touch #steer-rot { gap: 12px; }
body.touch #minimap { top: 66px; left: 10px; right: auto; bottom: auto; }
body.touch .actions { left: 170px; right: 190px; }
@media (max-width: 760px) {
  body.touch #minimap { top: 100px; left: 8px; }
  body.touch .actions { left: 8px; right: 8px; bottom: 92px; justify-content: center; }
}
@media (max-width: 460px) {
  body.touch .steer { left: 8px; right: 8px; bottom: 10px; }
  body.touch .steer .btn.sq { width: 60px; height: 60px; font-size: 28px; }
  body.touch #s-gas { width: 72px; height: 72px; }
}
@media (max-height: 520px) {
  body.touch .steer { left: 8px; right: 8px; bottom: 8px; }
  body.touch .steer .btn.sq { width: 56px; height: 56px; font-size: 26px; }
  body.touch #s-gas { width: 66px; height: 66px; font-size: 30px; }
  body.touch #steer-rot { gap: 10px; }
  body.touch #minimap { top: 50px; left: 6px; }
  body.touch .actions { left: 142px; right: 150px; bottom: 8px; justify-content: center; }
}

/* выбор точки старта */
.spawn-list { display: flex; flex-direction: column; gap: 10px; max-height: 55vh; overflow-y: auto; margin: 8px 0; }
.spawn-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.spawn-h { width: 100%; font-weight: 800; opacity: 0.8; font-size: 14px; }
.spawn-btn { font-size: 14px; padding: 6px 10px; }
