/* Onest (SIL OFL 1.1), переменный вес 400–800; файлы лежат рядом с игрой */
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("/fonts/onest-cyrillic-ext.woff2") format("woff2"); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("/fonts/onest-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("/fonts/onest-symbols.woff2") format("woff2"); unicode-range: U+0001-000C, U+000E-001F, U+007F-009F, U+20DD-20E0, U+20E2-20E4, U+2150-218F, U+2190, U+2192, U+2194-2199, U+21AF, U+21E6-21F0, U+21F3, U+2218-2219, U+2299, U+22C4-22C6, U+2300-243F, U+2440-244A, U+2460-24FF, U+25A0-27BF, U+2800-28FF, U+2921-2922, U+2981, U+29BF, U+29EB, U+2B00-2BFF, U+4DC0-4DFF, U+FFF9-FFFB, U+10140-1018E, U+10190-1019C, U+101A0, U+101D0-101FD, U+102E0-102FB, U+10E60-10E7E, U+1D2C0-1D2D3, U+1D2E0-1D37F, U+1F000-1F0FF, U+1F100-1F1AE, U+1F1E6-1F1FF, U+1F30D-1F30F, U+1F315, U+1F31C, U+1F31E, U+1F320-1F32C, U+1F336, U+1F378, U+1F37D, U+1F382, U+1F393-1F39F, U+1F3A7-1F3A8, U+1F3AC-1F3AF, U+1F3C2, U+1F3C4-1F3C6, U+1F3CA-1F3CE, U+1F3D4-1F3E0, U+1F3ED, U+1F3F1-1F3F3, U+1F3F5-1F3F7, U+1F408, U+1F415, U+1F41F, U+1F426, U+1F43F, U+1F441-1F442, U+1F444, U+1F446-1F449, U+1F44C-1F44E, U+1F453, U+1F46A, U+1F47D, U+1F4A3, U+1F4B0, U+1F4B3, U+1F4B9, U+1F4BB, U+1F4BF, U+1F4C8-1F4CB, U+1F4D6, U+1F4DA, U+1F4DF, U+1F4E3-1F4E6, U+1F4EA-1F4ED, U+1F4F7, U+1F4F9-1F4FB, U+1F4FD-1F4FE, U+1F503, U+1F507-1F50B, U+1F50D, U+1F512-1F513, U+1F53E-1F54A, U+1F54F-1F5FA, U+1F610, U+1F650-1F67F, U+1F687, U+1F68D, U+1F691, U+1F694, U+1F698, U+1F6AD, U+1F6B2, U+1F6B9-1F6BA, U+1F6BC, U+1F6C6-1F6CF, U+1F6D3-1F6D7, U+1F6E0-1F6EA, U+1F6F0-1F6F3, U+1F6F7-1F6FC, U+1F700-1F80B, U+1F810-1F847, U+1F850-1F859, U+1F860-1F887, U+1F890-1F8AD, U+1F8B0-1F8BB, U+1F8C0-1F8C1, U+1F8D0-1F8D8, U+1F900-1F90B, U+1F93B, U+1F946, U+1F984, U+1F996, U+1F9E9, U+1FA00-1FA6F, U+1FA70-1FA7C, U+1FA80-1FAC6, U+1FAC8, U+1FACC-1FADD, U+1FADF-1FAEB, U+1FAEF-1FAFA, U+1FB00-1FBFF; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("/fonts/onest-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("/fonts/onest-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }


:root {
  --bg: #0e1319;
  --bg2: #141b24;
  --panel: #1a222d;
  --panel2: #232e3c;
  --line: #34414f;
  --text: #e9eef4;
  --muted: #8f9eaf;
  --grass: #5fb23a;
  --grass-hi: #7ed957;
  --grass-lo: #3d7a24;
  --dirt: #866043;
  --danger: #e5534b;
  --radius: 6px;
  --shadow: 0 6px 0 rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background:
    linear-gradient(180deg, #16263d 0%, #0e1319 55%),
    var(--bg);
  color: var(--text);
  font: 16px/1.45 "Segoe UI", system-ui, -apple-system, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
button, input { font: inherit; color: inherit; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 .4em; margin: 0 .1em;
  border: 1px solid #4a5a6b; border-bottom-width: 3px; border-radius: 4px;
  background: #2a3645; font: 600 .78em/1.6 var(--font); text-align: center;
}

.screen { min-height: 100%; }

/* ---------- логотип ---------- */
.logo {
  margin: 0; display: flex; flex-direction: column; align-items: center; line-height: .95;
  font: 900 clamp(40px, 8vw, 72px)/.95 "Arial Black", Impact, system-ui, sans-serif;
  text-transform: uppercase; letter-spacing: 2px;
}
.logo-top, .logo-bottom {
  text-shadow:
    0 1px 0 var(--grass-lo), 0 2px 0 var(--grass-lo), 0 3px 0 var(--grass-lo),
    0 4px 0 #2b5a19, 0 5px 0 #2b5a19, 0 6px 0 #1f4112, 0 8px 12px rgba(0, 0, 0, .5);
}
.logo-top { color: var(--grass-hi); }
.logo-bottom { color: #c9955f; text-shadow:
    0 1px 0 #7a5233, 0 2px 0 #7a5233, 0 3px 0 #6a4429,
    0 4px 0 #5a381f, 0 5px 0 #4a2d18, 0 6px 0 #3a2312, 0 8px 12px rgba(0, 0, 0, .5); }
.tagline { text-align: center; color: var(--muted); margin: 20px 0 28px; }

/* ---------- кнопки / поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border: 2px solid #4c5c6e; border-bottom-width: 4px;
  background: #2c3947; color: var(--text); border-radius: var(--radius);
  cursor: pointer; font-weight: 600; transition: transform .06s, background .15s, filter .15s;
  text-decoration: none; user-select: none;
}
.btn:hover { background: #374657; }
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--grass); border-color: var(--grass-hi) var(--grass-lo) var(--grass-lo) var(--grass-hi); color: #0b1a05; border-bottom-color: #2f6119; }
.btn.primary:hover { background: #6cc545; }
.btn.ghost { background: transparent; border-color: #3b4959; }
.btn.ghost:hover { background: rgba(255, 255, 255, .06); }
.btn.danger { background: #5a2623; border-color: #8a3a35; color: #ffd9d6; }
.btn.danger:hover { background: #73302c; }
.btn.big { padding: 12px 20px; font-size: 1.05rem; }
.btn.small { padding: 5px 10px; font-size: .88rem; border-bottom-width: 3px; }

.panel {
  background: var(--panel); border: 2px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow);
}

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 5px; font-weight: 600; font-size: .92rem; }
.field small { font-weight: 400; color: var(--muted); }
input {
  width: 100%; padding: 10px 12px; background: #0f151c; border: 2px solid #3a4858;
  border-radius: var(--radius); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--grass); box-shadow: 0 0 0 3px rgba(95, 178, 58, .25); }
input::placeholder { color: #5f6e7e; }
form .btn.big { width: 100%; }
.form-error { min-height: 1.4em; margin: 0 0 10px; color: #ff8a82; font-size: .92rem; }

/* ---------- экран входа ---------- */
#screen-auth { display: grid; place-items: center; padding: 32px 16px; }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card { padding: 22px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 20px; background: #10161d; padding: 5px; border-radius: 8px; }
.tab { padding: 8px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel2); color: var(--text); box-shadow: inset 0 -3px 0 var(--grass); }

/* ---------- меню ---------- */
.topbar { position: sticky; top: 0; z-index: 5; background: rgba(14, 19, 25, .88); backdrop-filter: blur(8px); border-bottom: 2px solid var(--line); }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo-small { display: flex; align-items: center; gap: 10px; font: 900 1.2rem/1 "Arial Black", system-ui, sans-serif; letter-spacing: .5px; color: var(--grass-hi); image-rendering: pixelated; }
.logo-small img { image-rendering: pixelated; }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-pill { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; min-width: 0; }
.user-pill b { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pill span { color: var(--muted); font-size: .8rem; }

.container { max-width: 1120px; margin: 0 auto; padding: 24px 16px 60px; }
.container section + section { margin-top: 36px; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 1.35rem; }
.counter { padding: 1px 9px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); font-size: .85rem; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.my-grid { grid-template-columns: repeat(3, 1fr); }
.pop-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
@media (max-width: 820px) { .my-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); } }

.card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 2px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); transition: transform .12s, border-color .12s;
}
.card:hover { transform: translateY(-3px); border-color: var(--grass); }
.card-link { color: inherit; text-decoration: none; display: block; }
.cover {
  position: relative; aspect-ratio: 16 / 9; background-size: cover; background-position: center;
  background-color: #6aa0e8; image-rendering: auto; border-bottom: 2px solid var(--line);
}
.cover.empty {
  background:
    linear-gradient(180deg, transparent 58%, #5da034 58%, #5da034 64%, #866043 64%),
    linear-gradient(180deg, #78a7ff, #c4dbff 58%);
}
.cover.empty::after {
  content: "нет обложки"; position: absolute; left: 10px; bottom: 6px; font-size: .72rem; color: rgba(255, 255, 255, .7);
}
.rank {
  position: absolute; left: 8px; top: 8px; padding: 1px 8px; border-radius: 4px;
  background: rgba(10, 14, 20, .78); font-weight: 800; font-size: .85rem; color: #ffd86b;
}
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.world-name { margin: 0; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.by { color: var(--muted); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.by b { color: var(--text); font-weight: 600; }
.stats { display: flex; gap: 14px; margin-top: 4px; font-size: .88rem; color: #c3cdd8; }
.stat { display: inline-flex; align-items: center; gap: 5px; }
.stat svg { width: 16px; height: 16px; fill: currentColor; opacity: .85; }
.stat.live { color: var(--grass-hi); }
.stat.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grass-hi); box-shadow: 0 0 0 3px rgba(126, 217, 87, .2); }
.stat.live.zero { color: var(--muted); }
.stat.live.zero .dot { background: #566474; box-shadow: none; }
.card-actions { display: flex; gap: 8px; padding: 0 12px 12px; }
.card-actions .btn { flex: 1; }
.card-actions .btn.small { flex: 0 0 auto; }

.card.empty-slot {
  align-items: center; justify-content: center; min-height: 230px; gap: 8px; cursor: pointer;
  background: transparent; border-style: dashed; color: var(--muted); box-shadow: none; font: inherit;
}
.card.empty-slot:hover { color: var(--grass-hi); }
.card.empty-slot .plus { font-size: 2.6rem; line-height: 1; font-weight: 300; }
.empty-note { grid-column: 1 / -1; padding: 28px; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: 10px; }

/* ---------- модальное окно / тост ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 8, 12, .7); backdrop-filter: blur(3px);
}
.modal { width: 100%; max-width: 400px; padding: 20px; }
.modal h3 { margin: 0 0 12px; font-size: 1.2rem; }
.modal p { margin: 0 0 14px; color: #c3cdd8; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
#toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 60; transform: translate(-50%, 20px);
  max-width: 90vw; padding: 10px 18px; border-radius: 8px; background: #2c3947; border: 2px solid #4c5c6e;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { border-color: #a2453f; background: #4a2320; }

/* ============================ ИГРА ============================ */
#screen-game { position: fixed; inset: 0; z-index: 10; background: #000; overflow: hidden; user-select: none; cursor: default; }
#gl-container { position: absolute; inset: 0; }
#gl-container canvas { display: block; outline: none; image-rendering: auto; }

#crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; display: none; pointer-events: none; mix-blend-mode: difference; }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: #fff; }
#crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; }
#crosshair::after { top: 10px; left: 0; height: 2px; width: 22px; }
#screen-game[data-mode="play"] #crosshair { display: block; }
#screen-game[data-mode="play"] { cursor: none; }

.hud-corner { position: absolute; left: 12px; top: 10px; color: #fff; text-shadow: 1px 1px 0 #000, 0 0 6px rgba(0, 0, 0, .6); pointer-events: none; font-weight: 600; }
#hud-online { font-size: .85rem; opacity: .85; font-weight: 500; }
#hud-goal { margin-top: 8px; width: min(300px, 62vw); padding: 7px 10px; background: rgba(12, 16, 22, .62); border: 1px solid rgba(255, 255, 255, .22); border-radius: 8px; display: flex; flex-direction: column; gap: 3px; font-size: .85rem; font-weight: 500; }
#hud-goal.hidden { display: none; }
#hud-goal b { font-size: .92rem; }
#hud-goal .goal-bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .18); overflow: hidden; }
#hud-goal .goal-bar i { display: block; height: 100%; background: #5fc46a; transition: width .4s; }
#hud-goal.done b { color: #8ef09a; }
.goal-banner { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); padding: 14px 26px; background: rgba(20, 70, 30, .88); border: 2px solid #8ef09a; border-radius: 10px; color: #fff; font-weight: 700; font-size: 1.3rem; text-shadow: 1px 1px 0 #000; pointer-events: none; z-index: 30; animation: goal-pop .45s ease-out; }
@keyframes goal-pop { from { transform: translateX(-50%) scale(.7); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
#hud-debug { margin: 6px 0 0; font: 12px/1.35 var(--font); }

#tablist { position: absolute; left: 50%; top: 40px; transform: translateX(-50%); min-width: 220px; max-width: 80vw; padding: 10px 16px; background: rgba(12, 16, 22, .78); border: 2px solid rgba(255, 255, 255, .2); border-radius: 8px; }
#tablist-count { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
#tablist ul { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 24px; }
#tablist li { padding: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tablist li.me { color: var(--grass-hi); }

.chat-wrap { position: absolute; left: 10px; bottom: 76px; width: min(560px, calc(100vw - 20px)); pointer-events: none; display: flex; flex-direction: column; gap: 6px; }
#chat-log { max-height: 38vh; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
#chat-log.open { overflow-y: auto; pointer-events: auto; background: rgba(0, 0, 0, .25); }
.chat-line { padding: 2px 8px; background: rgba(0, 0, 0, .42); color: #fff; text-shadow: 1px 1px 0 #000; word-break: break-word; font-size: .95rem; transition: opacity .6s; }
.chat-line.sys { color: #ffe27a; }
.chat-line .nick { color: #9fd3ff; font-weight: 600; }
.chat-line .nick.me { color: var(--grass-hi); }
.chat-line.faded { opacity: 0; }
#chat-log.open .chat-line.faded { opacity: 1; }
#chat-form { pointer-events: auto; }
#chat-form input { background: rgba(0, 0, 0, .7); border-color: rgba(255, 255, 255, .35); color: #fff; }

#hotbar, .slots.hot { display: flex; }
#hotbar { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); padding: 4px; background: rgba(15, 20, 27, .72); border: 3px solid #0b0f14; border-radius: 4px; pointer-events: none; }
#item-name { position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%); color: #fff; text-shadow: 1px 1px 0 #000, 0 0 5px #000; opacity: 0; transition: opacity .4s; pointer-events: none; font-weight: 600; }
#item-name.show { opacity: 1; transition: none; }

.slot {
  position: relative; width: 48px; height: 48px; margin: 0 1px; display: grid; place-items: center;
  background: rgba(60, 72, 88, .55); border: 3px solid #2a3441; border-top-color: #1b222b; border-left-color: #1b222b; border-right-color: #3d4a5a; border-bottom-color: #3d4a5a;
}
.slot img { width: 36px; height: 36px; image-rendering: pixelated; pointer-events: none; }
.slot .count { position: absolute; right: 2px; bottom: 0; font: 700 14px/1.1 var(--font); color: #fff; text-shadow: 1px 1px 0 #000; pointer-events: none; }
#hotbar .slot.selected { border: 3px solid #fff; background: rgba(120, 140, 165, .55); margin: -2px; width: 52px; height: 52px; z-index: 1; }
.inv-box .slot { cursor: pointer; }
.inv-box .slot:hover { background: rgba(120, 140, 165, .55); }
.slot.picked { border-color: var(--grass-hi) !important; box-shadow: 0 0 0 2px rgba(126, 217, 87, .4); }

#inv-panel { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .45); }
.inv-box { padding: 16px 18px 14px; background: #c6c6c6; border: 4px solid #000; border-top-color: #fff; border-left-color: #fff; border-right-color: #555; border-bottom-color: #555; color: #333; max-width: 100vw; }
.inv-box h3 { margin: 0 0 8px; font-size: 1rem; color: #333; }
.inv-box .muted { color: #555; font-size: .8rem; margin: 10px 0 0; }
.inv-box kbd { background: #e0e0e0; border-color: #888; color: #222; }
.slots { display: grid; grid-template-columns: repeat(9, 48px); gap: 2px; }
.slots.hot { margin-top: 10px; }
.inv-box .slot { background: #8b8b8b; border-color: #373737 #fff #fff #373737; }
.inv-box .slot:hover { background: #a9a9a9; }
@media (max-width: 560px) {
  .slots { grid-template-columns: repeat(9, 36px); }
  .slot { width: 36px; height: 36px; border-width: 2px; }
  .slot img { width: 28px; height: 28px; }
  #hotbar .slot.selected { width: 40px; height: 40px; }
}

.overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: rgba(6, 9, 13, .62); backdrop-filter: blur(3px); cursor: default; overflow: auto; }
.pause-box { width: 100%; max-width: 380px; padding: 20px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.pause-box h2 { margin: 0 0 6px; }
.pause-box p { margin: 0 0 6px; color: #c3cdd8; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 10px; font-size: .95em; }
.setting-row select { width: auto; min-width: 140px; padding: 6px 10px; }
.controls-help { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; text-align: left; font-size: .8rem; color: var(--muted); }

.loader { text-align: center; color: #cfd8e3; }
.cube { width: 44px; height: 44px; margin: 0 auto 16px; background: var(--grass); border: 4px solid var(--grass-lo); box-shadow: inset 0 -12px 0 var(--dirt); animation: spin 1.1s infinite steps(8); }
@keyframes spin { to { transform: rotate(360deg); } }
#game-loading { background: #0e1319; backdrop-filter: none; z-index: 8; }
#game-error { z-index: 9; }

/* Management and narrow-screen controls */
#hud-health { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); color: #ff7272; text-shadow: 1px 1px #000; white-space: nowrap; font-weight: 700; pointer-events: none; }
#damage-vignette { position: absolute; inset: 0; z-index: 25; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 35%, rgba(170, 0, 0, .48) 100%); transition: opacity .16s ease-out; }
#damage-vignette.hurt { opacity: 1; transition-duration: .035s; }
#hud-food { position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); display: flex; gap: 3px; pointer-events: none; }
#hud-food i { width: 14px; height: 14px; border-radius: 50% 50% 50% 8%; background: rgba(0,0,0,.45); box-shadow: inset 0 0 0 2px rgba(0,0,0,.6); }
#hud-food i.on { background: #d9902f; box-shadow: inset 0 0 0 2px #6b3f10; }
#hud-food i.half { background: linear-gradient(90deg, #d9902f 50%, rgba(0,0,0,.45) 50%); box-shadow: inset 0 0 0 2px #6b3f10; }
#hud-food.starving { animation: hunger-pulse 1s infinite alternate; }
@keyframes hunger-pulse { from { opacity: 1; } to { opacity: .45; } }
#chest-section { margin-bottom: 10px; }
#chest-section .slots { max-height: 45dvh; overflow-y: auto; }
#hud-health.hurt { color: #fff1e9; filter: drop-shadow(0 0 5px #ff2828); }
@media (prefers-reduced-motion: reduce) { #damage-vignette { transition-duration: .1s; } #damage-vignette.hurt { background: radial-gradient(ellipse at center, transparent 60%, rgba(120, 0, 0, .28) 100%); } }
#creative-tabs { display: flex; flex-wrap: wrap; gap: 4px; max-width: 450px; margin-bottom: 6px; }
#creative-tabs button { font: inherit; font-size: .8rem; padding: 3px 8px; background: #bbb; color: #222; border: 2px solid #555; cursor: pointer; }
#creative-tabs button.active { background: #ffd34d; }
#creative-palette button[hidden] { display: none; }
#creative-palette { display: flex; flex-wrap: wrap; gap: 6px; max-width: 450px; margin-bottom: 10px; }
#creative-palette button { display: flex; align-items: center; gap: 4px; font: inherit; font-size: .8rem; background: #ddd; color: #222; border: 2px solid #555; cursor: pointer; }
#creative-palette img { width: 26px; height: 26px; image-rendering: pixelated; }
select { width: 100%; padding: 10px 12px; font: inherit; color: var(--text); background: #0f151c; border: 2px solid #3a4858; border-radius: var(--radius); }
.check-field { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.check-field input { width: 20px; height: 20px; }
.card-actions, .player-actions { flex-wrap: wrap; }
.player-actions { display: flex; gap: 8px; margin-top: 10px; }
.management-modal { max-width: 640px; }
.global-admin-modal { max-width: 1100px; width: min(1100px, 96vw); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 12px 0; }
.admin-table th, .admin-table td { padding: 8px; text-align: left; border-bottom: 1px solid #415163; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-table input { width: 100%; min-width: 100px; }
#craft-panel { border-top: 1px solid #415163; margin-top: 14px; padding-top: 8px; }
#craft-recipes { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
.craft-recipe { display: flex; flex-direction: column; gap: 4px; padding: 9px; text-align: left; color: #f0f4fb; background: #293847; border: 1px solid #53697b; border-radius: 5px; cursor: pointer; }
.craft-recipe:hover:not(:disabled) { background: #395267; border-color: #91bdc8; }
.craft-recipe:disabled { opacity: .45; cursor: not-allowed; }
.craft-recipe small { font-size: 11px; line-height: 1.4; color: #d0dae4; }
.inv-box { max-height: calc(100dvh - 24px); overflow-y: auto; }
#underwater-overlay { position: absolute; inset: 0; background: #086c8752; box-shadow: inset 0 0 90px #003e6380; pointer-events: none; z-index: 3; }
#action-status { position: absolute; left: 50%; top: calc(50% + 28px); transform: translateX(-50%); padding: 5px 10px; border-radius: 6px; color: #e8f2ff; background: #142435b8; pointer-events: none; font-size: 12px; }
.modal { max-height: calc(100dvh - 32px); overflow-y: auto; }
.player-row { display: flex; flex-direction: column; gap: 8px; padding: 14px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.player-row .field { margin-bottom: 0; }
@media (max-width: 420px) {
  .topbar-inner { flex-wrap: wrap; }
  .user { width: 100%; justify-content: space-between; }
  .user-pill { align-items: flex-start; }
  .section-head { flex-wrap: wrap; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .modal { padding: 14px; }
  .modal-actions { flex-wrap: wrap; }
  .slots { grid-template-columns: repeat(9, 28px); gap: 1px; }
  .slot { width: 28px; height: 30px; margin: 0; }
  .slot img { width: 23px; height: 23px; }
  #hotbar .slot.selected { width: 32px; height: 34px; }
  .inv-box { padding: 10px; }
}

#hud-fatigue { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); display: flex; gap: 3px; pointer-events: none; }
#hud-fatigue i { width: 12px; height: 12px; border-radius: 50%; background: rgba(0,0,0,.45); box-shadow: inset 0 0 0 2px rgba(0,0,0,.6); }
#hud-fatigue i.on { background: #6f7fd6; box-shadow: inset 0 0 0 2px #283069; }
#hud-fatigue i.half { background: linear-gradient(90deg, #6f7fd6 50%, rgba(0,0,0,.45) 50%); box-shadow: inset 0 0 0 2px #283069; }
#hud-fatigue.exhausted { animation: hunger-pulse 1s infinite alternate; }
#sleep-screen { position: absolute; inset: 0; z-index: 7; background: #02030a; color: #cfd6ea; overflow: hidden; display: grid; place-items: center; text-align: center; transition: opacity .8s; }
#sleep-screen.hidden { display: none; }
#sleep-screen .dream-stage { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 2.5s; }
#sleep-screen.dreaming .dream-stage { opacity: 1; }
#sleep-screen .dream-video, #sleep-screen .dream-edit { position: absolute; left: 50%; top: 50%; width: min(92vw, 160vh * 1.0); max-height: 84%; transform: translate(-50%, -50%); object-fit: contain; opacity: .62; filter: blur(2.2px) saturate(.85) brightness(.9);
  -webkit-mask-image: radial-gradient(ellipse 62% 62% at 50% 50%, #000 38%, transparent 100%); mask-image: radial-gradient(ellipse 62% 62% at 50% 50%, #000 38%, transparent 100%); }
#sleep-screen .dream-edit { width: min(92vw, 150vh); aspect-ratio: 16 / 9; height: auto; }
#sleep-screen .dream-caption { position: absolute; left: 50%; bottom: 24%; transform: translateX(-50%); max-width: 70%; color: rgba(255,255,255,.7); text-shadow: 0 0 8px #000; font-style: italic; filter: blur(.4px); }
#sleep-screen .dream-info { position: relative; z-index: 1; padding: 16px; align-self: end; margin-bottom: 7vh; text-shadow: 0 0 6px #000; }
#sleep-screen .dream-title { font-size: 1.25rem; letter-spacing: .12em; text-transform: uppercase; opacity: .85; }
#sleep-screen .dream-sub { margin-top: 6px; opacity: .75; }
#sleep-screen .dream-hint { margin-top: 6px; font-size: .85rem; opacity: .5; }
#sleep-screen[data-kind="micro"] { background: #000; animation: dozing 1.2s ease-out; }
@keyframes dozing { from { opacity: 0; } to { opacity: 1; } }
.dream-row .dream-actions { display: flex; gap: 6px; }
.dream-note { font-size: .78rem; margin: -4px 0 10px; }

.cheat-box { max-width: 460px; }
.cheat-box h4 { margin: 12px 0 6px; opacity: .8; }
.cheat-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cheat-row select, .cheat-row input { width: auto; padding: 6px 8px; font: inherit; }
.cheat-row input { width: 64px; background: #0f151c; color: var(--text); border: 2px solid #3a4858; border-radius: var(--radius); }
.btn.danger { background: #7a2a2a; border-color: #a2453f; }
#btn-unwear { margin-top: 10px; }

#inv-trash { display: block; margin: 8px 0; font: inherit; font-size: .85rem; padding: 6px 10px; background: #c9b0b0; color: #3a1010; border: 2px solid #6b2a2a; cursor: pointer; }
#inv-trash:hover, #inv-trash.hint { background: #e8a0a0; }

/* ---------- окно Telegram ---------- */
.tg-back { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(6, 9, 13, .7); backdrop-filter: blur(3px); }
.tg-box { position: relative; width: 100%; max-width: 400px; padding: 24px 20px 20px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.tg-box h2 { margin: 0 0 2px; }
.tg-box p { margin: 0 0 6px; color: #c3cdd8; }
.tg-box a.btn { display: block; text-decoration: none; }
.tg-x { position: absolute; top: 6px; right: 8px; width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.tg-x:hover { color: var(--text); }

.tg-link { text-decoration: none; display: inline-block; }
@media (max-width: 560px) { .user { flex-wrap: wrap; justify-content: flex-end; } }

/* ---------- чертежи, B-Hub, окна устройств ---------- */
.inv-tabs { display: flex; gap: 4px; margin: 0 0 8px; }
.inv-tabs button { font: inherit; font-size: .85rem; padding: 4px 12px; background: #bbb; color: #222; border: 2px solid #555; cursor: pointer; }
.inv-tabs button.active { background: #e4e4e4; border-color: #222; font-weight: 700; }
#bp-main { width: min(620px, 92vw); max-height: 70dvh; overflow-y: auto; color: #222; }
.bp-head, .bp-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.bp-head input[type=search], .bp-head input[type=text], #bp-main input[type=text] { flex: 1; min-width: 160px; padding: 5px 8px; font: inherit; border: 2px solid #555; background: #eee; color: #111; }
#bp-main select { padding: 4px; font: inherit; background: #eee; color: #111; border: 2px solid #555; }
.bp-btn { font: inherit; font-size: .85rem; padding: 4px 10px; background: #d8d8d8; color: #1a1a1a; border: 2px solid #555; border-radius: 0; cursor: pointer; }
.bp-btn:hover { background: #ececec; } .bp-btn:disabled { opacity: .5; cursor: default; }
.bp-btn.primary { background: #7ed957; border-color: #2f6119; } .bp-btn.danger { background: #f0b4ae; border-color: #8c2a22; }
.bp-list { display: flex; flex-direction: column; gap: 6px; }
.bp-card { padding: 8px 10px; background: #dcdcdc; border: 2px solid #8b8b8b; }
.bp-title { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.bp-kind { font-size: .72rem; padding: 1px 6px; border: 1px solid #555; background: #e9e9e9; }
.bp-kind.device { background: #cfe8ff; } .bp-kind.building { background: #ffe6bf; }
.bp-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.bp-tag { font: inherit; font-size: .75rem; padding: 2px 8px; border: 1px solid #666; background: #e9e9e9; color: #222; cursor: pointer; border-radius: 10px; }
.bp-tags.small .bp-tag { cursor: default; font-size: .7rem; }
.bp-tag.on { background: #7ed957; border-color: #2f6119; }
.bp-msg.bad { color: #a01d14; }
#bp-main h4 { margin: 4px 0; }
/* окна поверх игры: стол сборки, редактор, монитор */
#win-root { position: absolute; inset: 0; pointer-events: none; z-index: 8; }
#win-root > * { pointer-events: auto; }
.win { position: absolute; inset: 0; display: flex; flex-direction: column; background: rgba(10, 14, 20, .94); color: var(--text); }
.win-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.win-bar h2 { margin: 0 12px 0 0; font-size: 1.05rem; }
.win-body { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 12px; overflow: auto; }
.win .btn { padding: 6px 12px; font-size: .9rem; }
.win input[type=text], .win input[type=number], .win select { padding: 5px 8px; background: #0e1319; color: var(--text); border: 1px solid var(--line); border-radius: 4px; font: inherit; }
.win .muted { color: var(--muted); }
.win .ok { color: #7ed957; } .win .bad { color: #ff8a80; }
.asm-board { display: grid; gap: 2px; padding: 6px; background: #0c3d22; border: 3px solid #135c34; border-radius: 6px; user-select: none; position: relative; }
.asm-cell { width: 46px; height: 46px; background: #146b3a; border: 1px solid #1f8a4e; position: relative; }
.asm-part { position: absolute; z-index: 2; border: 2px solid rgba(0,0,0,.55); border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; color: #fff; text-shadow: 1px 1px 0 #000; text-align: center; overflow: hidden; cursor: pointer; box-sizing: border-box; }
.asm-part.sel { outline: 3px solid #fff; z-index: 3; }
.asm-ghost { position: absolute; z-index: 4; border: 2px dashed #fff; opacity: .65; pointer-events: none; box-sizing: border-box; }
.asm-ghost.bad { border-color: #ff5a4a; background: rgba(255, 60, 40, .35); }
.asm-palette { display: flex; flex-direction: column; gap: 4px; min-width: 230px; max-height: 100%; overflow-y: auto; }
.asm-item { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: var(--panel2); border: 2px solid var(--line); border-radius: 4px; cursor: pointer; color: var(--text); font: inherit; text-align: left; }
.asm-item.on { border-color: var(--grass-hi); background: #2d4a2a; } .asm-item[disabled] { opacity: .45; cursor: default; }
.asm-item img { width: 30px; height: 30px; image-rendering: pixelated; }
.asm-item small { margin-left: auto; color: var(--muted); }
.asm-side { display: flex; flex-direction: column; gap: 8px; min-width: 260px; max-width: 340px; }
.prog-stack { display: flex; flex-direction: column; gap: 4px; min-width: 300px; }
.blk { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 5px 8px; border-radius: 8px; color: #fff; font-size: .86rem; border: 1px solid rgba(0,0,0,.45); }
.blk.set, .blk.change { background: #e0852b; } .blk.motor, .blk.led, .blk.cam { background: #4a8fd6; } .blk.if, .blk.repeat { background: #d9a31e; color: #1a1a1a; }
.blk-c { margin: 2px 0 2px 16px; padding-left: 8px; border-left: 4px solid rgba(255,255,255,.3); display: flex; flex-direction: column; gap: 4px; }
.ex { display: inline-flex; align-items: center; gap: 3px; padding: 1px 5px; border-radius: 10px; background: rgba(0,0,0,.28); }
.ex select, .ex input { padding: 1px 3px !important; font-size: .82rem; max-width: 130px; }
.ex input[type=number] { width: 64px; }
.mini { padding: 0 6px; font: inherit; font-size: .8rem; background: rgba(0,0,0,.35); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 4px; cursor: pointer; }
.fpv-hud { position: absolute; inset: 0; pointer-events: none; z-index: 7; color: #bff7c8; font: 600 14px/1.3 var(--font); text-shadow: 1px 1px 0 #000; }
.fpv-hud .frame { position: absolute; inset: 10px; border: 3px solid rgba(190,255,200,.5); border-radius: 14px; }
.fpv-hud .top { position: absolute; left: 24px; top: 20px; } .fpv-hud .bottom { position: absolute; left: 24px; bottom: 20px; }
.fpv-hud .stick { position: absolute; bottom: 24px; width: 90px; height: 90px; border: 2px solid rgba(190,255,200,.6); border-radius: 50%; }
.fpv-hud .stick i { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px; border-radius: 50%; background: rgba(190,255,200,.85); }
.fpv-hud .nosig { position: absolute; inset: 0; display: grid; place-items: center; font-size: 28px; color: #ff8a80; background: repeating-linear-gradient(0deg, rgba(0,0,0,.55) 0 3px, rgba(60,60,60,.65) 3px 6px); }
.sel-hud { position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%); z-index: 6; padding: 10px 14px; background: rgba(15,20,27,.88); border: 1px solid var(--line); border-radius: 8px; color: var(--text); display: flex; flex-direction: column; gap: 6px; max-width: 92vw; }
.sel-hud .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sel-hud .btn.on { outline: 2px solid var(--grass-hi); }
.drone-panel { position: absolute; right: 16px; top: 80px; z-index: 6; width: 250px; padding: 12px; background: rgba(15,20,27,.92); border: 1px solid var(--line); border-radius: 8px; color: var(--text); display: flex; flex-direction: column; gap: 6px; }

.blk input[type=text] { width: 96px; }
.blk input[type=number] { width: 70px; }
.win .asm-part b { line-height: 1.05; }
.ex select { max-width: 112px; }

/* редактор блочной программы (в стиле Scratch) */
.sc { display: flex; flex-direction: column; gap: 8px; height: calc(100vh - 150px); max-height: 940px; min-height: 380px; width: 100%; outline: none; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; }
.sc-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sc-bar .btn, .sc-bar select { width: auto !important; flex: 0 0 auto; margin: 0; padding: 6px 12px; }
.sc-bar select { max-width: 240px; }
.sc-status { margin-left: auto; font-size: .85rem; } .sc-status.ok { color: #9aa7b5; } .sc-status.bad { color: #ff7b72; }
.sc-body { flex: 1; min-height: 0; display: flex; border: 1px solid #d9d9d9; border-radius: 6px; overflow: hidden; background: #f9f9f9; color: #575e75; user-select: none; -webkit-user-select: none; }
.sc-cats { width: 84px; flex: 0 0 84px; background: #fff; border-right: 1px solid #d9d9d9; display: flex; flex-direction: column; padding-top: 6px; overflow-y: auto; }
.sc-cat { background: none; border: 0; border-radius: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px 7px; cursor: pointer; color: #575e75; font-size: 11px; font-weight: 600; line-height: 1.1; text-align: center; width: 100%; box-sizing: border-box; overflow-wrap: anywhere; }
.sc-cat i { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(0,0,0,.15); display: block; }
.sc-cat.on, .sc-cat:hover { background: #e9eef2; }
.sc-fly { width: 330px; flex: 0 0 330px; overflow-y: auto; overflow-x: hidden; background: #f9f9f9; border-right: 1px solid #d9d9d9; padding: 8px 6px 20px 12px; font-size: 13px; }
.sc-sec-t { font-weight: 700; font-size: 15px; color: #575e75; margin: 4px 0 10px; }
.pal-item { margin: 0 0 12px; }
.sc-wrap { position: relative; flex: 1; min-width: 0; }
.sc-ws { position: absolute; inset: 0; overflow: auto; font-size: 13px; background-color: #f9f9f9; background-image: radial-gradient(#d3d8de 1px, transparent 1.2px); background-size: 24px 24px; padding: 28px 30px 200px; }
.sc.dragging, .sc.dragging * { cursor: grabbing !important; }
.sc-scripts { display: grid; grid-auto-flow: column; grid-auto-columns: max-content; gap: 80px; align-items: start; }
.sc-script { display: flex; flex-direction: column; min-width: 16em; }
.sc-zoom { position: absolute; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.sc-zoom-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid #c9ced6; background: #fff; color: #575e75; font-size: 20px; line-height: 1; padding: 0; cursor: pointer; }
.sc-zoom-btn:hover { background: #eef1f5; }
.sc-newvar { display: flex; gap: 6px; } .sc-new { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid #c9ced6; border-radius: 6px; background: #fff !important; color: #575e75 !important; user-select: text; }
.sc-newvar .btn { width: auto; margin: 0; padding: 4px 10px; } .sc-new-msg { color: #d9534f; font-size: 12px; margin-top: 4px; }
/* блоки */
.cb { position: relative; display: block; width: max-content; color: #fff; font-weight: 600; line-height: 1; font-size: 1em; filter: drop-shadow(0 .09em 0 rgba(0,0,0,.28)); }
.cb .lb { white-space: nowrap; }
.cb .row { position: relative; z-index: 1; display: flex; align-items: center; gap: .5em; padding: .5em .85em; min-height: 3em; white-space: nowrap; }
.cb .bg { position: absolute; inset: 0 0 -.38em 0; background: var(--c); border-radius: .45em; }
.cb.flat > .bg { clip-path: polygon(0 0, 1.3em 0, 1.62em .38em, 2.78em .38em, 3.1em 0, 100% 0, 100% calc(100% - .38em), 3.1em calc(100% - .38em), 2.78em 100%, 1.62em 100%, 1.3em calc(100% - .38em), 0 calc(100% - .38em)); }
.cb.hat > .bg { border-radius: 2.4em 2.4em .45em .45em / 1.5em 1.5em .45em .45em; clip-path: polygon(0 0, 100% 0, 100% calc(100% - .38em), 3.1em calc(100% - .38em), 2.78em 100%, 1.62em 100%, 1.3em calc(100% - .38em), 0 calc(100% - .38em)); }
.cb.hat > .row { padding-top: 1.35em; min-height: 3.6em; }
.cb.hat { min-width: 14em; }
/* блок-«С»: заголовок, рукав, низ */
.cb.c { display: block; }
.cb.c > .head { position: relative; }
.cb.c > .head > .bg { clip-path: polygon(0 0, 1.3em 0, 1.62em .38em, 2.78em .38em, 3.1em 0, 100% 0, 100% calc(100% - .38em), 4.2em calc(100% - .38em), 3.88em 100%, 2.72em 100%, 2.4em calc(100% - .38em), 0 calc(100% - .38em)); }
.cb.c > .mouth { position: relative; margin-left: 1.1em; min-height: 1.6em; }
.cb.c > .mouth::before { content: ''; position: absolute; left: -1.1em; top: 0; bottom: -.001em; width: 1.1em; background: var(--c); }
.cb.c > .mid { position: relative; }
.cb.c > .mid > .bg { clip-path: polygon(0 0, 2.4em 0, 2.72em .38em, 3.88em .38em, 4.2em 0, 100% 0, 100% calc(100% - .38em), 4.2em calc(100% - .38em), 3.88em 100%, 2.72em 100%, 2.4em calc(100% - .38em), 0 calc(100% - .38em)); border-radius: 0; }
.cb.c > .mid > .row { min-height: 2.4em; }
.cb.c > .foot { position: relative; height: 2em; }
.cb.c > .foot > .bg { inset: 0 0 -.38em 0; clip-path: polygon(0 0, 2.4em 0, 2.72em .38em, 3.88em .38em, 4.2em 0, 100% 0, 100% calc(100% - .38em), 3.1em calc(100% - .38em), 2.78em 100%, 1.62em 100%, 1.3em calc(100% - .38em), 0 calc(100% - .38em)); border-radius: 0 0 .45em .45em; }
.cb.c > .mouth > .stack { min-width: 9em; min-height: 1.4em; }
.stack { display: flex; flex-direction: column; min-width: 9em; }
.zone { position: relative; height: 0; z-index: 6; }
.zone::before { content: ''; position: absolute; left: 0; right: 0; top: -.32em; height: .64em; border-radius: .3em; pointer-events: none; }
.zone.over::before { background: rgba(110,118,135,.6); box-shadow: 0 0 0 2px rgba(255,255,255,.85); }
.stack .zone:last-child.over::before { top: -.2em; }
.lifted { opacity: .35; }
/* вставки */
.rp { --c: #999; display: inline-flex; align-items: center; gap: .45em; background: var(--c); color: #fff; font-weight: 600; padding: .3em .75em; min-height: 2em; border-radius: 2em; vertical-align: middle; white-space: nowrap; box-shadow: inset 0 0 0 .09em rgba(0,0,0,.2); }
.rp .rp { box-shadow: inset 0 0 0 .07em rgba(255,255,255,.4); }
.rp.bool { border-radius: 0; padding: .3em 1.25em; box-shadow: none; clip-path: polygon(1em 0, calc(100% - 1em) 0, 100% 50%, calc(100% - 1em) 100%, 1em 100%, 0 50%); min-height: 2.1em; }
.sl { display: inline-flex; align-items: center; vertical-align: middle; }
.sl.num.lit { background: #fff; border-radius: 2em; min-width: 2.7em; height: 2em; padding: 0 .25em; box-shadow: inset 0 0 0 .09em rgba(0,0,0,.18); }
.sl.num.lit input { width: 3.1em; border: 0; outline: 0; background: transparent; text-align: center; font: inherit; font-weight: 600; color: #575e75; padding: 0; margin: 0; user-select: text; min-width: 0; }
.sl.bool.empty { width: 3em; height: 2.1em; background: rgba(0,0,0,.28); clip-path: polygon(1em 0, calc(100% - 1em) 0, 100% 50%, calc(100% - 1em) 100%, 1em 100%, 0 50%); }
.sl.num.has, .sl.bool.has { display: inline-flex; }
.sl.hl { filter: drop-shadow(0 0 .3em #fff) drop-shadow(0 0 .25em #fff); }
.sl.hl.num.lit, .sl.hl.bool.empty { background: #fff7c2; }
.cb select.dd, .rp select.dd { appearance: none; -webkit-appearance: none; border: 0; border-radius: 2em; background-color: rgba(0,0,0,.2); color: #fff; font: inherit; font-weight: 600; padding: .35em 1.5em .35em .7em; height: 2em; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='white' stroke-width='1.6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .6em center; }
.cb select.dd option, .rp select.dd option { color: #333; background: #fff; }
.pal-item .cb, .pal-item .rp { cursor: grab; }
.sc-ghost { position: fixed; left: 0; top: 0; z-index: 400; pointer-events: none; opacity: .93; filter: drop-shadow(0 .5em .55em rgba(0,0,0,.35)); }
.sc-ghost.del { opacity: .45; }
.ghost-stack { display: flex; flex-direction: column; }
.sc-menu { position: fixed; z-index: 500; background: #fff; border: 1px solid #c9ced6; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); padding: 4px; display: flex; flex-direction: column; min-width: 150px; }
.sc-menu button { background: none; border: 0; border-radius: 6px; text-align: left; padding: 7px 10px; color: #333; cursor: pointer; }
.sc-menu button:hover { background: #eef1f5; }
@media (max-width: 900px) { .sc-fly { width: 240px; flex-basis: 240px; } }


/* =====================================================================
   Оформление: шрифт Onest, единая тёмная «грифельная» система окон, движение
   ===================================================================== */
:root {
  --font: "Onest", system-ui, -apple-system, "Segoe UI", "Noto Sans", sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.45, .5, 1);
  --edge: #0a0e13;                         /* жёсткая тень-«грань» вместо размытых свечений */
  --hi: rgba(255, 255, 255, .07);
  --ink-dim: #aab6c4;
}
html { font-family: var(--font); }
body, button, input, select, textarea { font-family: var(--font); }
body { font-size: 16px; line-height: 1.45; font-feature-settings: "tnum" 0, "kern"; letter-spacing: .005em; }
h1, h2, h3, h4 { letter-spacing: -.005em; }
b, strong { font-weight: 700; }
.logo, .logo-small { font-family: var(--font); font-weight: 800; }
.logo { letter-spacing: .01em; }
.logo-small { font-size: 1.25rem; letter-spacing: .01em; }
.slot .count, #hud-debug, .fpv-hud, kbd { font-family: var(--font); font-variant-numeric: tabular-nums; }
.slot .count { font-weight: 800; letter-spacing: 0; }
#hud-debug { font-weight: 500; font-size: 12px; }

/* ---------- кнопки, поля: чуть больше воздуха, живой отклик ---------- */
.btn { transition: transform .12s var(--ease), background-color .15s, border-color .15s, filter .15s, box-shadow .15s; letter-spacing: .01em; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(2px); transition-duration: .04s; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
input, select { transition: border-color .15s, box-shadow .15s, background-color .15s; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238f9eaf' stroke-width='1.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
select:hover { border-color: #4b5d70; }
select:focus-visible, input:focus-visible { border-color: var(--grass); box-shadow: 0 0 0 3px rgba(95, 178, 58, .25); outline: none; }
:focus-visible { outline: 2px solid var(--grass-hi); outline-offset: 2px; }
.setting-row select { background-position: right 10px center; }

/* ---------- меню миров ---------- */
.topbar { box-shadow: 0 4px 0 rgba(0, 0, 0, .18); }
.section-head h2 { font-weight: 750; font-size: 1.4rem; }
.card { transition: transform .18s var(--ease), border-color .18s, box-shadow .18s; }
.card:hover { transform: translateY(-4px); box-shadow: 0 10px 0 rgba(0, 0, 0, .35); }
.card:active { transform: translateY(-1px); }
.world-name { font-weight: 700; }
.card.empty-slot { transition: color .15s, border-color .15s, background-color .15s, transform .18s var(--ease); }
.card.empty-slot:hover { border-color: var(--grass); background: rgba(95, 178, 58, .06); transform: translateY(-2px); box-shadow: none; }
.card.empty-slot .plus { transition: transform .25s var(--spring); }
.card.empty-slot:hover .plus { transform: rotate(90deg) scale(1.15); }
.tab { transition: color .15s, background-color .15s, box-shadow .2s var(--ease); }

/* ---------- единая система окон внутри игры ---------- */
#inv-panel { background: rgba(5, 8, 12, .55); backdrop-filter: blur(2px); }
.inv-box { background: var(--panel); color: var(--text); border: 2px solid var(--line); border-radius: 10px;
  box-shadow: inset 0 1px 0 var(--hi), 0 8px 0 var(--edge); padding: 18px 20px 16px; }
.inv-box h3 { color: var(--text); font-size: 1.05rem; font-weight: 750; margin: 0 0 10px; }
.inv-box .muted { color: var(--muted); font-size: .8rem; line-height: 1.5; }
.inv-box kbd { background: #2a3645; border-color: #4a5a6b; color: var(--text); }
.inv-box .slot, .slot { background: #10161d; border: 2px solid #05080c; border-top-color: #05080c; border-left-color: #05080c; border-right-color: #2a3644; border-bottom-color: #2a3644; border-radius: 3px; width: 48px; height: 48px; margin: 0; transition: background-color .12s, transform .12s var(--ease), box-shadow .12s; }
.inv-box .slot:hover { background: #1c2733; transform: translateY(-2px); box-shadow: 0 4px 0 var(--edge); z-index: 2; }
.inv-box .slot:active { transform: translateY(0); }
.slot.picked { border-color: var(--grass-hi) !important; box-shadow: 0 0 0 2px rgba(126, 217, 87, .35); }
.slots { gap: 3px; }
#hotbar { background: rgba(10, 14, 19, .78); border: 2px solid #05080c; border-radius: 8px; padding: 4px; box-shadow: 0 4px 0 rgba(0, 0, 0, .35); }
#hotbar .slot { background: rgba(26, 34, 45, .75); margin: 0 1px; }
#hotbar .slot.selected { border: 2px solid #fff; background: rgba(70, 86, 106, .8); margin: -2px; width: 52px; height: 52px; border-radius: 4px; animation: slot-pop .22s var(--spring); }
#item-name { font-weight: 650; letter-spacing: .01em; }

/* вкладки инвентаря и креатива: плоские «папки» с зелёной кромкой */
.inv-tabs { gap: 2px; margin: 0 0 12px; border-bottom: 2px solid var(--line); }
.inv-tabs button { position: relative; background: transparent; color: var(--muted); border: 0; border-radius: 6px 6px 0 0; padding: 8px 16px; font-size: .92rem; font-weight: 600; cursor: pointer; transition: color .15s, background-color .15s; }
.inv-tabs button:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.inv-tabs button.active { color: var(--text); background: var(--panel2); font-weight: 700; }
.inv-tabs button::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -2px; height: 3px; background: var(--grass); transform: scaleX(0); transform-origin: left; transition: transform .22s var(--ease); }
.inv-tabs button.active::after { transform: scaleX(1); }
#creative-tabs { gap: 6px; margin-bottom: 8px; }
#creative-tabs button, #creative-palette button, #inv-trash { background: #232e3c; color: var(--text); border: 2px solid #3a4858; border-radius: 6px; padding: 5px 10px; font-size: .84rem; font-weight: 600; transition: background-color .15s, border-color .15s, transform .12s var(--ease); }
#creative-tabs button:hover, #creative-palette button:hover { background: #2e3c4d; border-color: #52667c; transform: translateY(-1px); }
#creative-tabs button.active { background: #3d6b25; border-color: var(--grass); color: #fff; }
#creative-palette { gap: 6px; max-width: 520px; }
#creative-palette button { padding: 3px 10px 3px 4px; }
#inv-trash { margin: 10px 0; background: #3a2323; border-color: #6b3330; color: #ffd0cc; }
#inv-trash:hover, #inv-trash.hint { background: #54302d; border-color: #a2453f; }
#craft-panel { border-top: 2px solid var(--line); margin-top: 16px; padding-top: 12px; }
#craft-panel h3 { margin-bottom: 8px; }
#craft-recipes { gap: 8px; }
.craft-recipe { background: #1e2834; border: 2px solid #34414f; border-radius: 8px; padding: 10px 12px; color: var(--text); transition: background-color .15s, border-color .15s, transform .15s var(--ease), box-shadow .15s; }
.craft-recipe b { font-weight: 700; }
.craft-recipe small { color: var(--ink-dim); }
.craft-recipe:hover:not(:disabled) { background: #26364a; border-color: var(--grass); transform: translateY(-2px); box-shadow: 0 4px 0 var(--edge); }

/* чертежи и B-Hub */
#bp-main { color: var(--text); width: min(680px, 92vw); max-height: 68dvh; padding-right: 4px; }
#bp-main h4 { margin: 8px 0 6px; font-size: .95rem; font-weight: 700; }
.bp-head, .bp-actions { gap: 8px; margin: 8px 0; }
.bp-head input[type=search], .bp-head input[type=text], #bp-main input[type=text], #bp-main input[type=search] { background: #0f151c; color: var(--text); border: 2px solid #3a4858; border-radius: 6px; padding: 8px 12px; }
#bp-main select { background-color: #0f151c; color: var(--text); border: 2px solid #3a4858; border-radius: 6px; padding: 8px 32px 8px 12px; width: auto; }
.bp-btn { background: #2c3947; color: var(--text); border: 2px solid #4c5c6e; border-bottom-width: 4px; border-radius: 6px; padding: 5px 12px; font-weight: 600; transition: transform .12s var(--ease), background-color .15s, border-color .15s; }
.bp-btn:hover:not(:disabled) { background: #374657; transform: translateY(-1px); }
.bp-btn:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
.bp-btn.primary { background: var(--grass); border-color: var(--grass-hi) var(--grass-lo) #2f6119 var(--grass-hi); color: #0b1a05; }
.bp-btn.primary:hover:not(:disabled) { background: #6cc545; }
.bp-btn.danger { background: #5a2623; border-color: #8a3a35; color: #ffd9d6; }
.bp-list { gap: 10px; }
.bp-card { background: #1e2834; border: 2px solid #34414f; border-radius: 8px; padding: 12px 14px; color: var(--text); transition: border-color .15s, transform .18s var(--ease), box-shadow .18s; }
.bp-card:hover { border-color: #52667c; transform: translateY(-2px); box-shadow: 0 4px 0 var(--edge); }
.bp-card .muted, .bp-card small { color: var(--ink-dim); }
.bp-title { align-items: center; font-weight: 700; }
.bp-kind { font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 2px 8px; border: 0; border-radius: 4px; background: #2e3c4d; color: var(--ink-dim); }
.bp-kind.device { background: #1f4468; color: #bfe0ff; } .bp-kind.building { background: #5b4217; color: #ffe2a8; }
.bp-tags { gap: 5px; }
.bp-tag { background: #26323f; color: var(--text); border: 1px solid #3f4f61; border-radius: 4px; padding: 2px 9px; font-size: .78rem; font-weight: 550; transition: background-color .15s, border-color .15s, transform .12s var(--ease); }
.bp-tags:not(.small) .bp-tag:hover { background: #324356; border-color: #5a7087; transform: translateY(-1px); }
.bp-tag.on { background: #3d6b25; border-color: var(--grass); color: #fff; }
.bp-tags.small .bp-tag { background: #1b2430; border-color: #2f3d4d; color: var(--ink-dim); }
.bp-msg.bad { color: #ff8a82; }

/* окна поверх игры: стол сборки, редактор чертежей, монитор */
.win { background: rgba(9, 13, 18, .95); backdrop-filter: blur(3px); font-family: var(--font); }
.win-bar { background: var(--panel); border-bottom: 2px solid var(--line); box-shadow: 0 4px 0 rgba(0, 0, 0, .22); gap: 8px; padding: 10px 14px; position: relative; z-index: 2; }
.win-bar h2 { font-size: 1.1rem; font-weight: 750; margin-right: 14px; }
.win .btn { font-size: .9rem; }
.win input[type=text], .win input[type=number], .win select { background-color: #0e1319; border: 2px solid #34414f; border-radius: 6px; padding: 7px 10px; color: var(--text); }
.win select { padding-right: 32px; }
.win-body { padding: 16px; gap: 16px; }
.asm-board { background: #0b3a21; border: 3px solid #135c34; border-radius: 8px; box-shadow: 0 6px 0 rgba(0, 0, 0, .35), inset 0 0 0 2px rgba(255, 255, 255, .04); }
.asm-cell { background: #146b3a; border: 1px solid #1d874b; transition: background-color .12s; }
.asm-cell:hover { background: #1a8147; }
.asm-part { border-radius: 5px; animation: part-in .26s var(--spring); transition: filter .12s; }
.asm-part:hover { filter: brightness(1.12); }
.asm-ghost { animation: ghost-pulse 1s ease-in-out infinite alternate; }
.asm-item { border-radius: 6px; padding: 6px 10px; transition: background-color .15s, border-color .15s, transform .15s var(--ease); font-weight: 550; }
.asm-item:hover:not([disabled]) { background: #2d3b4c; border-color: #52667c; transform: translateX(3px); }
.asm-item.on { border-color: var(--grass-hi); background: #2d4a2a; }
.asm-item img { transition: transform .2s var(--spring); }
.asm-item:hover:not([disabled]) img { transform: scale(1.15) rotate(-6deg); }
.asm-side { font-size: .95rem; }
.sel-hud, .drone-panel { border: 2px solid var(--line); border-radius: 10px; box-shadow: 0 6px 0 rgba(0, 0, 0, .35); animation: rise-in .22s var(--ease); }
.drone-panel { animation-name: slide-left; }
.pause-box, .modal, .tg-box { border-radius: 12px; box-shadow: inset 0 1px 0 var(--hi), 0 8px 0 var(--edge); }
.pause-box h2, .modal h3 { font-weight: 750; }
#toast { border-radius: 8px; box-shadow: 0 4px 0 rgba(0, 0, 0, .3); font-weight: 550; transition: opacity .2s, transform .28s var(--spring); }
.chat-line { animation: chat-in .22s var(--ease); }
.chat-line .nick { font-weight: 700; }
#tablist { border-radius: 10px; animation: rise-in .16s var(--ease); }

/* блочный редактор: шрифт и мелочи */
.sc { font-family: var(--font); }
.sc-cat { transition: background-color .15s; }
.sc-cat i { transition: transform .22s var(--spring); }
.sc-cat:hover i, .sc-cat.on i { transform: scale(1.14); }
.sc-zoom-btn { transition: background-color .15s, transform .15s var(--spring); } .sc-zoom-btn:hover { transform: scale(1.08); } .sc-zoom-btn:active { transform: scale(.94); }
.sc-status.bad { animation: shake .3s; }
.pal-item .cb { transition: transform .14s var(--ease), filter .14s; }
.pal-item .cb:hover { transform: translateX(3px); }
.pal-item .rp { transition: transform .14s var(--ease); } .pal-item .rp:hover { transform: translateX(3px); }
/* блок встал на место: сжатие и «пружина»; в стопке — каскадом */
.cb.in, .rp.in { animation: snap-in .34s var(--spring) both; animation-delay: calc(var(--i, 0) * 45ms); transform-origin: left top; }
.sl.num.lit { transition: box-shadow .12s; } .sl.num.lit:focus-within { box-shadow: inset 0 0 0 .13em #4C97FF; }
.sc-ghost > .ghost-stack > .cb, .sc-ghost > .rp { transform: rotate(-1.2deg); transform-origin: 12px 12px; animation: lift .18s var(--spring); }
.sc-ghost.del { transition: opacity .15s; }
.zone.over::before { animation: zone-grow .14s var(--ease); }
.sc-menu { animation: pop-menu .14s var(--ease); transform-origin: top left; border-radius: 10px; }
.sc-menu button { font-family: var(--font); font-weight: 550; }

/* ---------- движение ---------- */
.overlay, .modal-back, .tg-back { animation: fade-in .18s ease-out; }
.pause-box, .modal, .tg-box, .inv-box { animation: pop-in .26s var(--spring); }
#inv-panel { animation: fade-in .16s ease-out; }
.win { animation: win-in .22s var(--ease); }
.grid > .card { animation: rise-in .38s var(--ease) both; }
.grid > .card:nth-child(2) { animation-delay: .05s; } .grid > .card:nth-child(3) { animation-delay: .1s; } .grid > .card:nth-child(4) { animation-delay: .15s; } .grid > .card:nth-child(n+5) { animation-delay: .2s; }
#bp-main > * { animation: rise-in .26s var(--ease) both; }
.bp-list > .bp-card { animation: rise-in .3s var(--ease) both; }
.bp-list > .bp-card:nth-child(2) { animation-delay: .04s; } .bp-list > .bp-card:nth-child(3) { animation-delay: .08s; } .bp-list > .bp-card:nth-child(4) { animation-delay: .12s; } .bp-list > .bp-card:nth-child(n+5) { animation-delay: .16s; }
.auth-card { animation: rise-in .4s var(--ease) both; }
.logo { animation: rise-in .5s var(--ease) both; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(.965); } to { opacity: 1; transform: none; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slide-left { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes win-in { from { opacity: 0; transform: scale(1.015); } to { opacity: 1; transform: none; } }
@keyframes chat-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes slot-pop { 0% { transform: scale(.88); } 100% { transform: none; } }
@keyframes part-in { 0% { transform: scale(.6); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes ghost-pulse { from { opacity: .5; } to { opacity: .85; } }
@keyframes snap-in { 0% { transform: translateY(-.7em) scale(.94, .86); opacity: 0; } 55% { transform: translateY(.12em) scale(1.015, 1.04); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes lift { from { transform: rotate(0) scale(.97); } to { transform: rotate(-1.2deg) scale(1); } }
@keyframes zone-grow { from { transform: scaleX(.3); } to { transform: none; } }
@keyframes pop-menu { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes shake { 20% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 80% { transform: translateX(-2px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* окно сборки: шапка в одну-две строки, панели как у остальных окон */
.win-bar input[type=text] { width: 260px; flex: 0 1 260px; }
.win-bar select { width: auto; max-width: 340px; flex: 0 1 auto; }
.win-bar { align-items: center; }
.asm-palette, .asm-side { padding: 10px; background: var(--panel); border: 2px solid var(--line); border-radius: 10px; box-shadow: 0 5px 0 rgba(0, 0, 0, .28); align-self: flex-start; }
.asm-palette { max-height: calc(100% - 4px); }
.asm-board { align-self: flex-start; }
.bp-head input[type=search], .bp-head input[type=text] { flex: 2 1 240px; }

.goal-tag { margin: 4px 0 0; font-size: .8rem; color: var(--grass-hi); font-weight: 600; }
.goal-tag.done { color: #8ef09a; }

/* =====================================================================
   Лобби: вход, меню миров, модальные окна и окно Telegram.
   Отдельный слой поверх игрового оформления; в игре не действует,
   кроме модальных окон (#modal-root) и окна Telegram.
   ===================================================================== */
:root {
  --lb-deep: #0a0d12;
  --lb-bg: #0e1218;
  --lb-card: #141a22;
  --lb-raised: #1c2430;
  --lb-raised-2: #253040;
  --lb-line: rgba(233, 238, 244, .08);
  --lb-line-2: rgba(233, 238, 244, .14);
  --lb-text: #eaeef3;
  --lb-text-2: #a9b4c1;
  --lb-muted: #7f8b9a;
  --lb-grass: #6cc33f;
  --lb-grass-hi: #7ed957;
  --lb-grass-ink: #0b1a05;
  --lb-ease: cubic-bezier(.22, 1, .36, 1);
}

/* ---------- общий фон лобби ---------- */
body:has(#screen-game.hidden) { background: var(--lb-bg); }

#screen-auth .btn, #screen-menu .btn, #modal-root .btn, #tg-popup .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border: 1px solid var(--lb-line-2); border-radius: 8px;
  background: var(--lb-raised); color: var(--lb-text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  font: 500 14px/1 var(--font); text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color .15s var(--lb-ease), border-color .15s var(--lb-ease), color .15s var(--lb-ease), transform .12s var(--lb-ease);
}
#screen-auth .btn:hover, #screen-menu .btn:hover, #modal-root .btn:hover, #tg-popup .btn:hover { background: var(--lb-raised-2); }
#screen-auth .btn:active, #screen-menu .btn:active, #modal-root .btn:active, #tg-popup .btn:active { transform: scale(.98); border-bottom-width: 1px; }
#screen-auth .btn:disabled, #screen-menu .btn:disabled, #modal-root .btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
#screen-auth .btn.primary, #screen-menu .btn.primary, #modal-root .btn.primary, #tg-popup .btn.primary {
  background: var(--lb-grass); border-color: transparent; color: var(--lb-grass-ink); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .22);
}
#screen-auth .btn.primary:hover, #screen-menu .btn.primary:hover, #modal-root .btn.primary:hover, #tg-popup .btn.primary:hover { background: var(--lb-grass-hi); }
#screen-menu .btn.ghost, #modal-root .btn.ghost, #tg-popup .btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--lb-text-2); }
#screen-menu .btn.ghost:hover, #modal-root .btn.ghost:hover, #tg-popup .btn.ghost:hover { background: var(--lb-raised); color: var(--lb-text); }
#screen-menu .btn.danger, #modal-root .btn.danger { background: transparent; border-color: transparent; box-shadow: none; color: #f0868a; }
#screen-menu .btn.danger:hover, #modal-root .btn.danger:hover { background: rgba(229, 72, 77, .12); }
#modal-root .modal-actions .btn.danger { border-color: rgba(229, 72, 77, .4); }
#screen-auth .btn.big, #modal-root .btn.big, #tg-popup .btn.big { height: 44px; font-size: 15px; }
#screen-menu .btn.small, #modal-root .btn.small { height: 32px; padding: 0 10px; font-size: 13px; }
#screen-auth :focus-visible, #screen-menu :focus-visible, #modal-root :focus-visible, #tg-popup :focus-visible { outline: 2px solid var(--lb-grass-hi); outline-offset: 2px; }

#screen-auth input, #modal-root input:not([type=checkbox]):not([type=range]):not([type=file]), #modal-root select, #modal-root textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--lb-line-2); border-radius: 8px;
  background: var(--lb-deep); color: var(--lb-text); font: 400 15px/1.4 var(--font); box-shadow: none;
  transition: border-color .15s var(--lb-ease);
}
#modal-root textarea { height: auto; min-height: 88px; padding: 8px 12px; }
#modal-root select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237f8b9a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
#screen-auth input:focus, #modal-root input:focus, #modal-root select:focus, #modal-root textarea:focus { outline: none; border-color: var(--lb-grass); box-shadow: none; }
#screen-auth .field, #modal-root .field { margin-bottom: 16px; }
#screen-auth .field > span, #modal-root .field > span { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; color: var(--lb-text-2); }
#screen-auth .field small, #modal-root .field small { font-weight: 400; color: var(--lb-muted); margin-left: 4px; }
#screen-auth .form-error, #modal-root .form-error { min-height: 0; margin: 0 0 12px; font-size: 13px; color: #f0868a; }
#screen-auth .form-error:empty, #modal-root .form-error:empty { display: none; }

/* ---------- вход ---------- */
#screen-auth { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(400px, 1fr); place-items: stretch; min-height: 100vh; padding: 0; }
.auth-scene { position: relative; overflow: hidden; background: #78a7ff; }
.auth-scene img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 40% 60%; }
.auth-scene { border-right: 1px solid var(--lb-line-2); }
#screen-auth .auth-wrap { align-self: center; justify-self: center; width: 100%; max-width: 420px; padding: 48px 32px; }
#screen-auth .logo { display: flex; flex-direction: row; align-items: center; gap: 12px; margin: 0; font: 600 28px/1 var(--font); letter-spacing: -.01em; text-transform: none; text-shadow: none; animation: none; }
#screen-auth .logo-mark { width: 40px; height: 40px; image-rendering: pixelated; border-radius: 4px; }
#screen-auth .logo-top, #screen-auth .logo-bottom { display: inline; font: inherit; text-shadow: none; transform: none; }
#screen-auth .logo-top { color: var(--lb-text); }
#screen-auth .logo-bottom { color: var(--lb-grass-hi); margin-left: -4px; }
#screen-auth .tagline { margin: 16px 0 32px; text-align: left; font-size: 16px; line-height: 24px; color: var(--lb-text-2); }
#screen-auth .auth-card { padding: 24px; background: var(--lb-card); border: 1px solid var(--lb-line-2); border-top: 3px solid var(--lb-grass); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, .35); animation: none; }
#screen-auth .tabs { gap: 4px; margin-bottom: 24px; padding: 4px; background: var(--lb-deep); border: 1px solid var(--lb-line); border-radius: 10px; }
#screen-auth .tab { height: 32px; padding: 0; border-radius: 6px; font: 500 14px/32px var(--font); color: var(--lb-text-2); box-shadow: none; transition: background-color .15s var(--lb-ease), color .15s var(--lb-ease); }
#screen-auth .tab.active { background: var(--lb-raised-2); color: var(--lb-text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06); }
#screen-auth form .btn.big { width: 100%; margin-top: 8px; }
.auth-foot { margin: 20px 0 0; font-size: 13px; }
.auth-foot a { color: var(--lb-text-2); text-decoration: none; }
.auth-foot a:hover { color: var(--lb-text); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 860px) {
  #screen-auth { grid-template-columns: 1fr; grid-template-rows: 200px auto; }
  #screen-auth .auth-wrap { padding: 32px 20px 48px; align-self: start; }
  #screen-auth .tagline { margin-bottom: 24px; }
}

/* ---------- меню ---------- */
#screen-menu .topbar { background: rgba(10, 13, 18, .92); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--lb-line); box-shadow: none; }
#screen-menu .topbar-inner { max-width: 1200px; height: 60px; padding: 0 24px; }
#screen-menu .logo-small { gap: 10px; font: 600 17px/1 var(--font); letter-spacing: 0; color: var(--lb-text); }
#screen-menu .logo-small img { width: 24px; height: 24px; border-radius: 3px; }
#screen-menu .user { gap: 4px; }
#screen-menu .tg-link { background: transparent; border-color: transparent; box-shadow: none; color: var(--lb-text-2); height: 32px; padding: 0 10px; font-size: 14px; }
#screen-menu .tg-link:hover { background: var(--lb-raised); color: var(--lb-text); }
#screen-menu #btn-global-admin { margin-right: 4px; }
#screen-menu .user-pill { margin: 0 8px 0 12px; padding-left: 16px; border-left: 1px solid var(--lb-line); }
#screen-menu .user-pill b { font-weight: 500; font-size: 14px; }
#screen-menu .user-pill span { font-size: 12px; color: var(--lb-muted); }
#screen-menu #btn-logout { height: 32px; padding: 0 12px; font-size: 13px; border-color: var(--lb-line-2); background: var(--lb-raised); color: var(--lb-text); }

#screen-menu .container { max-width: 1200px; padding: 40px 24px 80px; }
#screen-menu .container section + section { margin-top: 56px; }
#screen-menu .section-head { align-items: baseline; gap: 12px; margin-bottom: 16px; }
#screen-menu .section-head h2 { font: 500 22px/28px var(--font); letter-spacing: -.01em; }
#screen-menu .section-head .muted { font-size: 13px; color: var(--lb-muted); }
#screen-menu .counter { padding: 0; border: 0; background: none; font: 400 13px/20px var(--font); color: var(--lb-muted); font-variant-numeric: tabular-nums; }

#screen-menu .grid { gap: 16px; }
#screen-menu .pop-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
#screen-menu .card {
  background: var(--lb-card); border: 1px solid var(--lb-line); border-radius: 12px; box-shadow: none;
  transition: border-color .15s var(--lb-ease), background-color .15s var(--lb-ease); animation: none;
}
#screen-menu .card:hover { transform: none; box-shadow: none; border-color: var(--lb-line-2); background: #18202a; }
#screen-menu .card:active { transform: none; }
#screen-menu .cover { aspect-ratio: 16 / 10; border-bottom: 3px solid var(--lb-grass); background-color: #78a7ff; }
#screen-menu .cover.empty { background: linear-gradient(180deg, #78a7ff, #b9d2ff 62%, #6cb33f 62%, #6cb33f 70%, #866043 70%); }
#screen-menu .cover.empty::after { content: "Обложки пока нет"; left: 12px; bottom: 8px; font: 400 12px/16px var(--font); color: rgba(255, 255, 255, .8); }
#screen-menu .rank { left: 10px; top: 10px; padding: 2px 8px; border-radius: 6px; background: rgba(10, 13, 18, .8); font: 500 12px/16px var(--font); color: var(--lb-text); font-variant-numeric: tabular-nums; }
#screen-menu .card-body { padding: 14px 16px 16px; gap: 4px; }
#screen-menu .world-name { font: 500 16px/24px var(--font); }
#screen-menu .by { font-size: 13px; color: var(--lb-muted); }
#screen-menu .by b { font-weight: 500; color: var(--lb-text-2); }
#screen-menu .goal-tag { font-size: 13px; color: var(--lb-text-2); }
#screen-menu .stats { gap: 16px; margin-top: 8px; font-size: 13px; color: var(--lb-text-2); font-variant-numeric: tabular-nums; }
#screen-menu .stat svg { width: 16px; height: 16px; opacity: .7; }
#screen-menu .stat.live { color: var(--lb-grass-hi); }
#screen-menu .stat.live .dot { width: 6px; height: 6px; box-shadow: none; }
#screen-menu .stat.live.zero { color: var(--lb-muted); }
#screen-menu .stat.live.zero .dot { background: var(--lb-muted); }
#screen-menu .card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 12px 16px 16px; margin-top: auto; border-top: 1px solid var(--lb-line); }
#screen-menu .card-actions .btn { flex: 0 0 auto; }
#screen-menu .card-actions .btn.primary { padding: 0 16px; margin-right: 4px; }
#screen-menu .card-actions .btn.small { padding: 0 8px; }
#screen-menu .card-actions .btn.danger { margin-left: auto; }
#screen-menu .card-actions .btn.small:not(.danger) { background: transparent; border-color: transparent; box-shadow: none; color: var(--lb-text-2); }
#screen-menu .card-actions .btn.small:not(.danger):hover { background: var(--lb-raised); color: var(--lb-text); }

#screen-menu .card.empty-slot { min-height: 0; gap: 12px; border: 1px dashed var(--lb-line-2); background: transparent; color: var(--lb-text-2); font: 500 14px/20px var(--font); }
#screen-menu .card.empty-slot:hover { border-color: var(--lb-grass); color: var(--lb-text); background: rgba(108, 195, 63, .04); transform: none; }
#screen-menu .card.empty-slot .plus { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--lb-raised); font: 400 24px/1 var(--font); color: var(--lb-text); transition: background-color .15s var(--lb-ease), color .15s var(--lb-ease); }
#screen-menu .card.empty-slot:hover .plus { transform: none; background: var(--lb-grass); color: var(--lb-grass-ink); }
#screen-menu .empty-note { padding: 32px; border: 1px dashed var(--lb-line-2); border-radius: 12px; font-size: 14px; color: var(--lb-text-2); }
#screen-menu:not(.settled) .grid > .card { animation: lb-rise .5s var(--lb-ease) both; }
#screen-menu .grid > .card:nth-child(2) { animation-delay: .06s; } #screen-menu .grid > .card:nth-child(3) { animation-delay: .12s; } #screen-menu .grid > .card:nth-child(4) { animation-delay: .18s; } #screen-menu .grid > .card:nth-child(n+5) { animation-delay: .24s; }
@keyframes lb-rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
  #screen-menu .topbar-inner { height: auto; padding: 10px 16px; flex-wrap: wrap; }
  #screen-menu .user-pill { margin-left: 4px; padding-left: 8px; }
  #screen-menu .container { padding: 24px 16px 64px; }
  #screen-menu .section-head h2 { font-size: 20px; }
}

/* ---------- модальные окна ---------- */
#modal-root .modal-back { background: rgba(5, 7, 10, .72); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: lb-fade .16s var(--lb-ease); }
#modal-root .modal { max-width: 440px; padding: 24px; background: var(--lb-card); border: 1px solid var(--lb-line-2); border-radius: 14px; box-shadow: 0 24px 64px rgba(0, 0, 0, .5); animation: lb-pop .22s var(--lb-ease); color: var(--lb-text); }
#modal-root .modal h3 { margin: 0 0 16px; font: 500 18px/24px var(--font); }
#modal-root .modal p { font-size: 14px; line-height: 20px; color: var(--lb-text-2); }
#modal-root .modal p.muted { margin-top: -8px; font-size: 13px; color: var(--lb-muted); }
#modal-root .modal-actions { gap: 8px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--lb-line); }
#modal-root .check-field { display: flex; align-items: center; gap: 8px; margin: 4px 0 16px; font-size: 14px; color: var(--lb-text); }
#modal-root input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--lb-grass); }
@keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lb-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- окно Telegram ---------- */
#tg-popup.tg-back { background: rgba(5, 7, 10, .72); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: lb-fade .16s var(--lb-ease); }
#tg-popup .tg-box { max-width: 400px; padding: 28px 24px 20px; gap: 8px; text-align: left; background: var(--lb-card); border: 1px solid var(--lb-line-2); border-top: 3px solid var(--lb-grass); border-radius: 14px; box-shadow: 0 24px 64px rgba(0, 0, 0, .5); animation: lb-pop .22s var(--lb-ease); }
#tg-popup .tg-box h2 { margin: 0; font: 500 20px/28px var(--font); }
#tg-popup .tg-box p { margin: 0 0 12px; font-size: 14px; line-height: 20px; color: var(--lb-text-2); }
#tg-popup .tg-box a.btn { display: flex; width: 100%; }
#tg-popup .tg-x { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--lb-muted); cursor: pointer; font-size: 0; line-height: 0; }
#tg-popup .tg-x svg { width: 16px; height: 16px; }
#tg-popup .tg-x:hover { background: var(--lb-raised); color: var(--lb-text); }
#tg-popup #tg-later { margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
  #screen-menu .grid > .card, #modal-root .modal-back, #modal-root .modal, #tg-popup.tg-back, #tg-popup .tg-box { animation: none; }
}

/* =====================================================================
   Лобби: анимации
   ===================================================================== */
/* вход: кадр медленно «дышит», по небу плывут блочные облака */
#screen-auth .auth-scene img { animation: lb-scene-in 1.4s var(--lb-ease) both, lb-drift 38s ease-in-out 1.4s infinite alternate; transform-origin: 40% 60%; }
@keyframes lb-scene-in { from { opacity: 0; transform: scale(1.08); } to { opacity: 1; transform: none; } }
@keyframes lb-drift { from { transform: none; } to { transform: scale(1.06) translate(-1.2%, -.8%); } }
.auth-scene::before, .auth-scene::after {
  content: ""; position: absolute; z-index: 1; width: 16px; height: 16px; background: rgba(255, 255, 255, .92); pointer-events: none; image-rendering: pixelated;
  box-shadow: 16px 0 rgba(255,255,255,.92), 32px 0 rgba(255,255,255,.92), 48px 0 rgba(255,255,255,.92), 16px -16px rgba(255,255,255,.92), 32px -16px rgba(255,255,255,.92), 64px 0 rgba(255,255,255,.92), 48px -16px rgba(255,255,255,.85);
}
.auth-scene::before { top: 9%; left: -90px; animation: lb-cloud 70s linear infinite; }
.auth-scene::after { top: 19%; left: -90px; transform: scale(.7); opacity: .85; animation: lb-cloud 95s linear -40s infinite; }
@keyframes lb-cloud { from { translate: 0 0; } to { translate: calc(62vw + 180px) 0; } }
#screen-auth .logo-mark { animation: lb-drop .8s var(--lb-ease) .15s both; }
@keyframes lb-drop { 0% { opacity: 0; transform: translateY(-28px); } 55% { opacity: 1; transform: translateY(2px); } 75% { transform: translateY(-3px); } 100% { transform: none; } }
#screen-auth .logo-top, #screen-auth .logo-bottom { animation: lb-rise .6s var(--lb-ease) both; }
#screen-auth .logo-top { animation-delay: .3s; } #screen-auth .logo-bottom { animation-delay: .38s; }
#screen-auth .tagline { animation: lb-rise .6s var(--lb-ease) .45s both; }
#screen-auth .auth-card { animation: lb-rise .7s var(--lb-ease) .55s both; }
#screen-auth .auth-foot { animation: lb-fade .6s var(--lb-ease) .8s both; }
#screen-auth .form:not(.hidden) { animation: lb-switch .3s var(--lb-ease) both; }
@keyframes lb-switch { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
#screen-auth .btn.primary.big { position: relative; overflow: hidden; }
#screen-auth .btn.primary.big:hover { transform: translateY(-1px); }

/* меню */
#screen-menu .topbar { animation: lb-down .45s var(--lb-ease) both; }
@keyframes lb-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
#screen-menu .section-head { animation: lb-rise .5s var(--lb-ease) both; }
#screen-menu .logo-small img { transition: transform .4s var(--lb-ease); }
#screen-menu .logo-small:hover img { transform: rotate(-12deg) scale(1.1); }
#screen-menu .cover { overflow: hidden; }
#screen-menu .cover::before { content: ""; position: absolute; inset: 0; background: inherit; background-size: cover; background-position: center; transition: transform .7s var(--lb-ease); }
#screen-menu .card:hover .cover::before { transform: scale(1.06); }
#screen-menu .cover .rank { z-index: 1; }
#screen-menu .card { transition: border-color .15s var(--lb-ease), background-color .15s var(--lb-ease), transform .25s var(--lb-ease); }
#screen-menu .card:hover:not(.empty-slot) { transform: translateY(-3px); }
#screen-menu .world-name { transition: color .15s var(--lb-ease); }
#screen-menu .card:hover .world-name { color: #fff; }
#screen-menu .stat.live:not(.zero) .dot { animation: lb-ping 2s ease-out infinite; }
@keyframes lb-ping { 0% { box-shadow: 0 0 0 0 rgba(126, 217, 87, .6); } 100% { box-shadow: 0 0 0 8px rgba(126, 217, 87, 0); } }
#screen-menu .card.empty-slot .plus { transition: transform .4s var(--lb-ease), background-color .15s var(--lb-ease), color .15s var(--lb-ease); }
#screen-menu .card.empty-slot:hover .plus { transform: rotate(90deg); }
#screen-menu .card-actions .btn.primary:hover { transform: translateY(-1px); }

/* окна */
#modal-root .modal .field, #modal-root .modal > p, #modal-root .modal .check-field { animation: lb-rise .35s var(--lb-ease) both; }
#modal-root .modal .field:nth-of-type(2) { animation-delay: .03s; } #modal-root .modal .field:nth-of-type(3) { animation-delay: .06s; } #modal-root .modal .field:nth-of-type(n+4) { animation-delay: .09s; }
#tg-popup .tg-box > *:not(.tg-x) { animation: lb-rise .4s var(--lb-ease) both; }
#tg-popup .tg-x { z-index: 2; }
#tg-popup .tg-box > *:nth-child(3) { animation-delay: .05s; } #tg-popup .tg-box > *:nth-child(4) { animation-delay: .1s; } #tg-popup .tg-box > *:nth-child(5) { animation-delay: .15s; } #tg-popup .tg-box > *:nth-child(6) { animation-delay: .2s; }
#tg-popup .tg-x svg { transition: transform .3s var(--lb-ease); }
#tg-popup .tg-x:hover svg { transform: rotate(90deg); }
#tg-popup .tg-x:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
  #screen-auth .auth-scene img, .auth-scene::before, .auth-scene::after, #screen-auth .logo-mark, #screen-auth .logo-top, #screen-auth .logo-bottom, #screen-auth .tagline, #screen-auth .auth-card, #screen-auth .auth-foot, #screen-auth .form:not(.hidden),
  #screen-menu .topbar, #screen-menu .section-head, #screen-menu .stat.live .dot, #modal-root .modal *, #tg-popup .tg-box > * { animation: none !important; }
  #screen-menu .card:hover, #screen-menu .card:hover .cover::before { transform: none; }
}
