:root {
  --panel: rgba(14, 20, 44, 0.78);
  --border: rgba(255, 255, 255, 0.14);
  --text: #f4f7ff;
  --muted: #a9b6d8;
  --accent: #ffd23f;
  --blue: #3fa9f5;
  --green: #4ade80;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #070b1f; color: var(--text);
  font-family: 'Rubik', 'Segoe UI', sans-serif; user-select: none; }
#game, #game canvas { position: fixed; inset: 0; display: block; }
#game canvas { width: 100% !important; height: 100% !important; }   /* при повороте экрана холст не «отстаёт» */
.hidden { display: none !important; }
[hidden] { display: none !important; }

.panel { background: var(--panel); border: 2px solid var(--border); border-radius: 16px;
  backdrop-filter: blur(6px); box-shadow: 0 6px 0 rgba(0,0,0,.25); }

.btn { font: 700 15px 'Rubik', sans-serif; color: #fff; background: #2f7cf6; border: 0; border-radius: 12px;
  padding: 10px 14px; cursor: pointer; box-shadow: 0 4px 0 #1a4fa8; transition: transform .08s; }
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #1a4fa8; }
.btn.big { font-size: 22px; padding: 14px 20px; width: 100%; background: #22c55e; box-shadow: 0 5px 0 #15803d; }
.btn.big:active { box-shadow: 0 2px 0 #15803d; }
.btn:disabled { background: #4b5575; box-shadow: 0 4px 0 #2d3450; cursor: not-allowed; filter: none; }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: var(--green); }
.dot.off { background: #f87171; }

.bar { flex: 1; height: 12px; background: rgba(255,255,255,.12); border-radius: 6px; overflow: hidden; }
.bar > div { height: 100%; width: 0%; border-radius: 6px; transition: width .15s; }

/* ---------- Вход ---------- */
#login { position: fixed; inset: 0; display: flex; padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: radial-gradient(circle at 50% 30%, rgba(40,70,160,.55), rgba(7,11,31,.9)); z-index: 10; }
.login-card { width: min(420px, 100%); margin: auto; background: var(--panel); border: 2px solid var(--border);
  border-radius: 22px; padding: 26px; box-shadow: 0 10px 0 rgba(0,0,0,.3); }
.logo { font-size: 54px; text-align: center; animation: bob 2.4s ease-in-out infinite; }
h1 { margin: 0; text-align: center; font-size: 46px; font-weight: 800; letter-spacing: 4px;
  color: var(--accent); text-shadow: 0 4px 0 #b8860b; }
.sub { text-align: center; margin: 2px 0 14px; color: var(--muted); font-weight: 700; }
.intro { font-size: 14px; line-height: 1.45; color: #d6def5; margin: 0 0 16px; }
.login-card label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 10px 0 6px; }
#nameInput { width: 100%; font: 700 18px 'Rubik', sans-serif; padding: 12px; border-radius: 12px;
  border: 2px solid var(--border); background: rgba(255,255,255,.08); color: #fff; outline: none; }
#nameInput:focus { border-color: var(--blue); }
#nameInput.locked { opacity: .85; cursor: default; }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-inline-start: 6px;
  border-radius: 9px; background: var(--accent); color: #1a1204; font: 800 11px/1 'Rubik', sans-serif; }
body.compact #actions .badge { position: absolute; top: 2px; right: 2px; margin: 0; }
body.compact #actions .btn { position: relative; }
.streak { padding: 12px 14px; border-radius: 14px; background: rgba(255, 210, 63, .1); border: 2px solid rgba(255, 210, 63, .35); }
.streak b { font-size: 18px; color: var(--accent); }
.streak p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.quest { margin-top: 10px; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.06); }
.quest.done { background: rgba(74, 222, 128, .1); }
.quest-top { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }
.quest-top span:last-child { color: var(--accent); white-space: nowrap; }
.quest .bar { margin-top: 8px; height: 10px; }
.quest .bar > div { background: linear-gradient(90deg, #3fa9f5, #4ade80); }
.quest-sub { margin-top: 6px; font-size: 12px; color: var(--muted); }
.quests-foot { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; }
.quests-guest { font-size: 15px; line-height: 1.5; }
.quests-guest a { color: #7fd3ff; font-weight: 700; }
.mode-pill { margin-top: 8px; width: 100%; padding: 6px 8px; border-radius: 10px; border: 2px solid rgba(127, 231, 255, .5);
  background: rgba(127, 231, 255, .1); color: #bff3ff; font: 700 13px 'Rubik', sans-serif; cursor: pointer; text-align: start; }
.mode-pill.radar { border-color: rgba(108, 255, 154, .6); background: rgba(108, 255, 154, .12); color: #c8ffd9; }
body.compact .mode-pill { margin-top: 5px; padding: 4px 6px; font-size: 11px; }
.legal-links { margin: 12px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
.legal-links a { color: var(--muted); }
.account-bar { margin: 8px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.account-bar a { color: #7fd3ff; font-weight: 700; text-decoration: none; }
.account-bar a:hover { text-decoration: underline; }
a.btn { text-decoration: none; text-align: center; }
#colors { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.swatch { width: 40px; height: 40px; border-radius: 10px; cursor: pointer; border: 3px solid transparent;
  box-shadow: 0 3px 0 rgba(0,0,0,.35); }
.swatch.sel { border-color: #fff; transform: scale(1.08); }
@keyframes bob { 50% { transform: translateY(-8px) rotate(6deg); } }

/* ---------- HUD ---------- */
#topLeft { position: fixed; top: 12px; left: 12px; padding: 12px 14px; width: 210px; }
.who { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.stars { font-size: 26px; font-weight: 800; color: var(--accent); margin: 6px 0; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.meter { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 14px; }
#energyFill { background: linear-gradient(90deg, #22c55e, #a3e635); }
#energyFill.low { background: #ef4444; }
#speedFill { background: linear-gradient(90deg, #38bdf8, #818cf8); }

#topCenter { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); padding: 10px 16px;
  width: min(420px, calc(100vw - 480px)); min-width: 240px; text-align: center; }
.progress-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.progress-title b { color: var(--accent); }
.bar.wide { height: 14px; }
.contracts-line { margin-top: 4px; font-size: 12px; color: #ffd98a; line-height: 1.35; }
.upg-note { margin: 0 0 10px; font-size: 13px; color: #c9d4ea; line-height: 1.45; }
.upg-note a { color: #ffd98a; }
#progressFill { background: linear-gradient(90deg, #3fa9f5, #4ade80); }
.expedition { font-size: 12px; color: var(--muted); margin-top: 4px; }

#topRight { position: fixed; top: 12px; right: 12px; padding: 12px 14px; width: 220px; }
.online { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.lb-title { margin-top: 8px; font-size: 13px; color: var(--muted); font-weight: 700; }
#top { margin: 6px 0 0; padding-left: 22px; font-size: 14px; }
#top li { margin: 2px 0; }
#top li span { float: right; color: var(--accent); font-weight: 700; }
#top li.me { color: var(--accent); }

#toasts { position: fixed; top: 110px; left: 50%; transform: translateX(-50%); display: flex;
  flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 5; }
.toast { background: var(--panel); border: 2px solid var(--border); border-radius: 14px; padding: 8px 16px;
  font-weight: 700; box-shadow: 0 4px 0 rgba(0,0,0,.3); animation: pop .25s ease-out, fade .4s ease-in 3.6s forwards; }
.toast.gold { border-color: var(--accent); color: var(--accent); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes fade { to { opacity: 0; transform: translateY(-10px); } }

.floater { position: fixed; font-weight: 800; font-size: 22px; color: var(--accent); pointer-events: none;
  text-shadow: 0 3px 0 rgba(0,0,0,.5); animation: rise 1.1s ease-out forwards; z-index: 6; }
@keyframes rise { to { transform: translateY(-50px); opacity: 0; } }

#target { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex;
  align-items: center; gap: 12px; padding: 10px 18px 10px 12px; min-width: 240px; }
#arrow { width: 44px; height: 44px; display: grid; place-items: center; font-size: 26px; color: var(--accent);
  background: rgba(255,255,255,.08); border-radius: 50%; transition: transform .1s linear; }
#targetName { font-weight: 800; }
#targetDist { font-size: 13px; color: var(--muted); }

#scanHint { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); font-weight: 700;
  background: rgba(0,0,0,.45); padding: 6px 14px; border-radius: 10px; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .5; } }

#help { position: fixed; bottom: 16px; left: 12px; padding: 10px 12px; font-size: 12px; line-height: 1.6; color: #d6def5; }
#help b { color: #fff; }

#actions { position: fixed; bottom: 16px; right: 12px; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
#emotes { display: flex; gap: 6px; justify-content: space-between; }
#emotes .btn { padding: 8px 10px; font-size: 18px; background: #5b5fc7; box-shadow: 0 4px 0 #3a3d8f; }

#card { position: fixed; right: 12px; top: 50%; transform: translateY(-50%); width: 320px; padding: 16px;
  display: flex; gap: 12px; border-color: var(--accent); animation: slide .35s cubic-bezier(.2,1.4,.4,1); cursor: pointer; }
@keyframes slide { from { transform: translate(120%, -50%); } }
.card-emoji { font-size: 52px; line-height: 1; }
.card-tag { font-size: 11px; font-weight: 800; color: var(--accent); letter-spacing: 1px; }
.card-name { font-size: 20px; font-weight: 800; margin: 2px 0 6px; }
.card-fact { font-size: 14px; line-height: 1.45; color: #dbe3fa; }
.card-first { font-size: 12px; color: var(--muted); margin-top: 8px; }

.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); z-index: 8; padding: 16px; }
.modal-box { position: relative; width: min(460px, 100%); max-height: 85vh; overflow: auto; background: #141c3c;
  border: 2px solid var(--border); border-radius: 20px; padding: 20px; box-shadow: 0 8px 0 rgba(0,0,0,.35); }
.modal-box.wide { width: min(760px, 100%); }
.modal-box h2 { margin: 0 0 14px; font-size: 22px; }
.close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 10px; border: 0;
  background: #ef4444; color: #fff; font-weight: 800; cursor: pointer; box-shadow: 0 3px 0 #991b1b; }

.upg { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: rgba(255,255,255,.06); margin-bottom: 10px; }
.upg-icon { font-size: 32px; }
.upg-info { flex: 1; }
.upg-name { font-weight: 800; }
.upg-desc { font-size: 13px; color: var(--muted); }
.pips { display: flex; gap: 4px; margin-top: 6px; }
.pip { width: 18px; height: 8px; border-radius: 3px; background: rgba(255,255,255,.15); }
.pip.on { background: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.album-item { background: rgba(255,255,255,.06); border-radius: 14px; padding: 12px 8px; text-align: center; cursor: pointer; }
.album-item .ae { font-size: 34px; }
.album-item .an { font-size: 13px; font-weight: 700; margin-top: 4px; }
.album-item.locked { opacity: .45; cursor: default; }
.count { color: var(--accent); font-size: 18px; }
.album-item .as { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---------- MKGT ---------- */
.mkgt-mark { font-weight: 800; letter-spacing: 1px; color: #fff; }
.mkgt-mark i { font-style: normal; font-weight: 500; font-size: .62em; letter-spacing: 3px; margin-left: 4px; color: #7fd3ff; }
.mkgt-mark.big { font-size: 30px; }
.powered { display: block; text-align: center; margin: -8px 0 14px; font-size: 13px; color: var(--muted); text-decoration: none; }
.powered:hover .mkgt-mark { color: #7fd3ff; }
#langPick { display: flex; justify-content: center; gap: 6px; margin-bottom: 4px; }
.lang-opt { font: 700 13px 'Rubik', sans-serif; color: #fff; background: rgba(255,255,255,.08); border: 2px solid transparent;
  border-radius: 10px; padding: 5px 10px; cursor: pointer; }
.lang-opt.sel { border-color: #7fd3ff; background: rgba(127,211,255,.15); }
.mkgt-btn { background: #0b1230; box-shadow: 0 4px 0 #000; border: 2px solid #7fd3ff; }
.mkgt-btn:active { box-shadow: 0 1px 0 #000; }
.mkgt-sub { font-style: normal; font-size: 11px; letter-spacing: 2px; color: #7fd3ff; }
#actions { max-height: calc(100vh - 140px); overflow-y: auto; }
.modal-intro { font-size: 14px; line-height: 1.5; color: #d6def5; margin: 0 0 14px; }
#mkgtLinks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.mk-link { display: block; text-decoration: none; color: #fff; background: rgba(255,255,255,.07); border-radius: 14px; padding: 12px;
  border: 2px solid transparent; }
.mk-link:hover { border-color: #7fd3ff; }
.mk-link .mi { font-size: 26px; }
.mk-link .mt { font-weight: 800; margin-top: 4px; }
.mk-link .md { font-size: 12px; color: var(--muted); margin-top: 2px; }
.site-btn { display: block; text-align: center; text-decoration: none; box-sizing: border-box; font-size: 17px !important; }
.card-sub { font-size: 13px; color: #7fd3ff; font-weight: 700; margin: -2px 0 6px; }
.card-link { display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 700; color: #7fd3ff; text-decoration: none; }
.card-link:hover { text-decoration: underline; }
.card-link:empty { display: none; }
[dir="rtl"] .close { right: auto; left: 12px; }
[dir="rtl"] .mkgt-mark i { margin-left: 0; margin-right: 4px; }

/* ---------- Агентства ---------- */
#agencyPick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.agency-opt { font: 700 15px 'Rubik', sans-serif; color: #fff; padding: 10px; border-radius: 12px; cursor: pointer;
  background: rgba(255,255,255,.07); border: 3px solid transparent; text-align: left; }
.agency-opt.sel { border-color: currentColor; background: rgba(255,255,255,.14); }
.ag-row { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 5px; }
.ag-row .ag-name { width: 78px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-row .bar { height: 9px; }
.ag-row .ag-pct { width: 40px; text-align: right; font-weight: 700; }
.ag-row.mine .ag-name { font-weight: 800; }

/* ---------- Мусор ---------- */
#debrisWarn { position: fixed; top: 46%; left: 50%; transform: translate(-50%, -140px); font-weight: 800;
  font-size: 22px; color: #ff5555; text-shadow: 0 3px 0 rgba(0,0,0,.6); animation: blink .4s infinite; pointer-events: none; }
#hitFlash { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(transparent 40%, rgba(255,40,40,.65));
  opacity: 0; transition: opacity .5s; }
#hitFlash.on { opacity: 1; transition: none; }

/* ---------- Ангар ---------- */
#hangar { position: fixed; top: 50%; right: 12px; transform: translateY(-50%); width: 340px; max-height: 86vh;
  overflow: auto; padding: 18px; z-index: 7; }
#hangar h2 { margin: 0 0 12px; }
#hangarTabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tab { font: 700 13px 'Rubik', sans-serif; color: #fff; background: rgba(255,255,255,.08); border: 0; border-radius: 10px;
  padding: 7px 10px; cursor: pointer; }
.tab.sel { background: #2f7cf6; }
#hangarItems { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.part { background: rgba(255,255,255,.07); border: 3px solid transparent; border-radius: 14px; padding: 10px 6px;
  text-align: center; cursor: pointer; font-weight: 700; font-size: 13px; }
.part .pi { font-size: 28px; }
.part .pc { font-size: 12px; color: var(--accent); margin-top: 2px; }
.part.eq { border-color: var(--green); }
.part.locked .pc { color: #fca5a5; }
.hangar-label { font-size: 13px; color: var(--muted); font-weight: 700; margin: 14px 0 6px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches .swatch { width: 32px; height: 32px; }

/* ---------- Сенсорное управление ---------- */
#joy, #scanBtn, #menuBtn, #emoBtn, #emoBar { display: none; }
body.touch #joy { display: block; position: fixed; left: calc(16px + env(safe-area-inset-left)); bottom: calc(16px + env(safe-area-inset-bottom));
  width: 124px; height: 124px; border-radius: 50%; background: rgba(255,255,255,.1); border: 3px solid rgba(255,255,255,.25); touch-action: none; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: rgba(255,255,255,.75); box-shadow: 0 4px 0 rgba(0,0,0,.3); pointer-events: none; }
body.touch #scanBtn { display: grid; place-items: center; position: fixed; right: calc(16px + env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom)); width: 100px; height: 100px; border-radius: 50%; border: 0; font-size: 34px;
  color: #fff; background: #06b6d4; box-shadow: 0 6px 0 #0e7490; touch-action: none; font-family: 'Rubik', sans-serif; line-height: 1; }
#scanBtn small { font-size: 12px; font-weight: 800; }
#scanBtn.on { background: #22d3ee; transform: translateY(4px); box-shadow: 0 2px 0 #0e7490; }

/* ---------- Компактный режим: телефоны и узкие окна (класс ставит game.js) ---------- */
.round-btn { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--border); background: var(--panel);
  color: #fff; font-size: 22px; box-shadow: 0 4px 0 rgba(0,0,0,.35); cursor: pointer; display: grid; place-items: center;
  backdrop-filter: blur(6px); padding: 0; touch-action: manipulation; }
.round-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
body.compact.menu-open #menuBtn, body.compact.emo-open #emoBtn { background: #2f7cf6; }

body.compact #help { display: none; }
body.compact #menuBtn, body.compact #emoBtn { display: grid; position: fixed; z-index: 7;
  right: calc(16px + env(safe-area-inset-right)); }
body.compact #menuBtn { bottom: calc(132px + env(safe-area-inset-bottom)); }
body.compact #emoBtn { bottom: calc(188px + env(safe-area-inset-bottom)); }
body.compact:not(.touch) #menuBtn { bottom: calc(16px + env(safe-area-inset-bottom)); }
body.compact:not(.touch) #emoBtn { bottom: calc(72px + env(safe-area-inset-bottom)); }

/* меню: всплывающая сетка вместо столбца кнопок */
body.compact #actions { display: none; }
body.compact.menu-open #actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; z-index: 7;
  position: fixed; right: calc(72px + env(safe-area-inset-right)); bottom: calc(150px + env(safe-area-inset-bottom));
  width: min(300px, calc(100vw - 100px)); max-height: none; overflow: visible; padding: 10px; border-radius: 18px;
  background: rgba(10,16,38,.94); border: 2px solid var(--border); box-shadow: 0 8px 0 rgba(0,0,0,.35); }
body.compact:not(.touch).menu-open #actions { bottom: calc(16px + env(safe-area-inset-bottom)); }
body.compact #actions #emotes { display: none; }
body.compact #actions .btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px;
  font-size: 20px; min-width: 0; }
body.compact #actions .btn i { display: block; font-style: normal; font-size: 11px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 100%; }
body.compact #actions .mkgt-btn .mkgt-mark { font-size: 15px; }
body.compact #actions .mkgt-btn .mkgt-sub { font-size: 9px; }

/* эмоции: строка рядом с кнопкой 😀 */
body.compact.emo-open #emoBar { display: flex; gap: 6px; position: fixed; z-index: 7;
  right: calc(72px + env(safe-area-inset-right)); bottom: calc(188px + env(safe-area-inset-bottom)); }
body.compact:not(.touch).emo-open #emoBar { bottom: calc(72px + env(safe-area-inset-bottom)); }
#emoBar .round-btn { width: 44px; height: 44px; font-size: 20px; }

/* верхняя строка */
body.compact #topLeft { top: calc(8px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left));
  width: 138px; padding: 6px 9px; border-radius: 12px; }
body.compact .who { font-size: 13px; gap: 5px; white-space: nowrap; overflow: hidden; }
body.compact .who .dot { width: 9px; height: 9px; flex: none; }
body.compact .stars { font-size: 17px; margin: 2px 0; }
body.compact .meter { margin-top: 3px; font-size: 10px; gap: 5px; }
body.compact .meter .bar { height: 6px; }

body.compact #topCenter { top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: auto; min-width: 0; max-width: calc(100vw - 300px); padding: 5px 9px; border-radius: 12px; }
body.compact .progress-title { font-size: 12px; margin-bottom: 4px; white-space: nowrap; }
body.compact .progress-title span { display: none; }
body.compact .progress-title::before { content: '🌍 '; }
body.compact .bar.wide { height: 6px; min-width: 64px; }
body.compact .expedition { display: none; }

body.compact #topRight { top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right));
  width: auto; min-width: 110px; padding: 6px 9px; border-radius: 12px; font-size: 12px; cursor: pointer; }
body.compact #topRight .online::after { content: '▾'; margin-left: auto; padding-left: 6px; color: var(--muted); }
body.compact #topRight.expanded .online::after { content: '▴'; }
body.compact #topRight:not(.expanded) .lb-title,
body.compact #topRight:not(.expanded) #agencies,
body.compact #topRight:not(.expanded) #top { display: none; }
body.compact #topRight.expanded { width: 190px; z-index: 8; background: rgba(10,16,38,.96); }
body.menu-open #scanHint, body.emo-open #scanHint { display: none; }
body.compact.menu-open #toasts, body.compact #topRight.expanded ~ #toasts { visibility: hidden; }
body.compact .ag-row { font-size: 11px; }
body.compact #top { font-size: 12px; }

/* цель и подсказки */
body.compact #target { top: calc(106px + env(safe-area-inset-top)); bottom: auto; min-width: 0; max-width: calc(100vw - 24px);
  padding: 5px 12px 5px 6px; gap: 8px; border-radius: 30px; }
body.compact #arrow { width: 30px; height: 30px; font-size: 17px; flex: none; }
body.compact #targetName { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.compact #targetDist { font-size: 11px; }
body.compact #scanHint { font-size: 12px; padding: 5px 10px; bottom: calc(150px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 170px); text-align: center; }
body.compact #debrisWarn { font-size: 16px; top: 34%; transform: translate(-50%, 0); }

/* уведомления: одно за раз, в одну строку, коротко */
body.compact #toasts { top: calc(150px + env(safe-area-inset-top)); width: min(80vw, 380px); gap: 0; }
body.compact .toast { font-size: 12px; padding: 4px 10px; border-radius: 9px; border-width: 1px; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: none;
  animation: pop .2s ease-out, fade .3s ease-in 2.4s forwards; }

/* карточка открытия: узкая полоска; нажатие раскрывает факт, повторное — закрывает */
body.compact #card { width: auto; left: 50%; right: auto; transform: translateX(-50%); max-width: calc(100vw - 24px);
  top: calc(150px + env(safe-area-inset-top)); bottom: auto; padding: 6px 12px 6px 8px; gap: 8px; align-items: center;
  border-radius: 14px; border-width: 2px; animation: dropIn .25s ease-out; z-index: 6; }
@keyframes dropIn { from { transform: translate(-50%, -16px); opacity: 0; } }
body.compact .card-emoji { font-size: 26px; }
body.compact .card-tag { font-size: 9.5px; }
body.compact .card-name { font-size: 14px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.compact #card:not(.open) .card-sub,
body.compact #card:not(.open) .card-fact,
body.compact #card:not(.open) .card-first,
body.compact #card:not(.open) .card-link { display: none; }
body.compact #card:not(.open) .card-name::after { content: '  ⓘ'; color: #7fd3ff; font-size: 13px; }
body.compact #card.open { width: min(92vw, 440px); align-items: flex-start; max-height: 45vh; overflow-y: auto; }
body.compact #card.open .card-name { white-space: normal; margin-bottom: 3px; }
body.compact .card-sub { font-size: 11px; }
body.compact .card-fact { font-size: 12.5px; line-height: 1.4; }
body.compact .card-link { margin-top: 6px; font-size: 12px; }
/* пока видна карточка, уведомления не показываем — они под ней */
body.compact.card-shown #toasts { visibility: hidden; }

/* экран входа на телефоне */
body.compact .login-card { padding: 18px; }
body.compact .logo { font-size: 40px; }
body.compact h1 { font-size: 36px; }
body.compact .intro { font-size: 13px; margin-bottom: 10px; }
body.compact .swatch { width: 34px; height: 34px; }
body.compact #colors { margin-bottom: 12px; }

/* ангар — нижняя шторка */
body.compact #hangar { left: 10px; right: 10px; width: auto; top: auto; bottom: 10px; transform: none; max-height: 50vh; padding: 14px; }
body.compact #hangar h2 { font-size: 18px; margin-bottom: 8px; }
body.compact .part .pi { font-size: 22px; }
body.compact #hangarItems { grid-template-columns: repeat(4, 1fr); gap: 6px; }
body.compact .part { padding: 6px 3px; font-size: 11px; }

/* окна */
body.compact .modal { padding: 10px; }
body.compact .modal-box { padding: 16px; max-height: 88vh; border-radius: 16px; }
body.compact .modal-box h2 { font-size: 18px; padding-right: 40px; }
body.compact .grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
body.compact .album-item .ae { font-size: 28px; }
body.compact .upg { padding: 9px; gap: 9px; }
body.compact .upg-icon { font-size: 26px; }

/* ---------- Низкий экран: телефон боком ---------- */
body.short #joy { width: 104px; height: 104px; bottom: calc(10px + env(safe-area-inset-bottom)); }
body.short #scanBtn { width: 84px; height: 84px; font-size: 28px; bottom: calc(12px + env(safe-area-inset-bottom)); }
body.short.compact #menuBtn { bottom: calc(106px + env(safe-area-inset-bottom)); }
body.short.compact #emoBtn { bottom: auto; top: calc(62px + env(safe-area-inset-top)); }
body.short.compact.emo-open #emoBar { bottom: auto; top: calc(62px + env(safe-area-inset-top)); flex-direction: column; }
body.short.compact.menu-open #actions { bottom: auto; top: calc(52px + env(safe-area-inset-top)); grid-template-columns: repeat(5, 1fr);
  width: min(400px, calc(100vw - 300px)); }
body.short #topLeft .meter:last-child { display: none; }
body.short #target { top: auto; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: calc(100vw - 280px); }
body.short #toasts { top: calc(56px + env(safe-area-inset-top)); width: min(50vw, 380px); }
body.short #card { top: calc(56px + env(safe-area-inset-top)); max-width: min(56vw, 440px); }
body.short #card.open { width: min(56vw, 440px); max-height: calc(100vh - 140px); }
/* вход боком: две колонки — слева название, справа форма */
body.short .login-card { width: min(760px, 100%); display: flex; gap: 22px; align-items: center; padding: 14px 18px; }
body.short .login-brand { flex: 1; min-width: 0; }
body.short .login-form { flex: 1.1; min-width: 0; }
body.short .logo { font-size: 30px; }
body.short h1 { font-size: 30px; }
body.short .sub { margin-bottom: 8px; }
body.short .powered { margin: 0 0 8px; }
body.short .login-card label { margin: 6px 0 4px; }
body.short #nameInput { padding: 8px 10px; font-size: 16px; }
body.short .agency-opt { padding: 6px 8px; font-size: 13px; }
body.short .btn.big { font-size: 18px; padding: 10px; }
body.short #scanHint { bottom: calc(60px + env(safe-area-inset-bottom)); }
body.short #hangar { left: auto; right: 10px; top: 10px; bottom: 10px; width: min(360px, 48vw); max-height: none; }
body.short .modal-box { max-height: 94vh; }

/* Ремонт после мусора и щит */
.name-err { margin: 6px 0 0; color: #ff9b9b; font-size: 13px; font-weight: 600; }
.shield-pill { border-color: rgba(127, 231, 255, .35); }
.shield-pill.on { border-color: rgba(127, 231, 255, .9); background: rgba(127, 231, 255, .16); color: #dff8ff; }
#repairBanner { position: fixed; top: 46%; left: 50%; transform: translate(-50%, -190px); padding: 8px 16px; border-radius: 12px;
  background: rgba(40, 18, 8, .82); border: 2px solid rgba(255, 170, 80, .8); color: #ffd7a8; font-weight: 800; font-size: 18px;
  pointer-events: none; white-space: nowrap; z-index: 5; }
body.compact #repairBanner { font-size: 14px; top: calc(34% - 44px); transform: translate(-50%, 0); }

/* Достижения */
.ach-head { margin: 0 0 10px; color: #b9c6e4; font-size: 14px; }
.quest.ach .quest-top span:first-child { font-weight: 700; }
.ach-title-btn { border: 1px solid rgba(127, 231, 255, .5); background: none; color: #dff8ff; border-radius: 8px; padding: 3px 8px; font: inherit; font-size: 12px; cursor: pointer; }
.ach-title-btn.on { background: rgba(127, 231, 255, .18); }

/* Комнаты-миры */
.room-pick { width: 100%; padding: 9px 10px; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .15);
  background: rgba(10, 16, 40, .9); color: #fff; font: inherit; font-size: 15px; }
.invite-btn { margin-inline-start: 6px; padding: 0 6px; border: 1px solid rgba(255, 255, 255, .25); border-radius: 8px;
  background: none; color: inherit; cursor: pointer; font-size: 13px; line-height: 20px; }

/* Обучение новичка */
.tutorial { position: fixed; top: 92px; left: 50%; transform: translateX(-50%); width: min(460px, calc(100vw - 24px));
  padding: 12px 14px; z-index: 6; border: 2px solid rgba(255, 210, 90, .7); }
.tutorial .tut-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; color: #ffd75a; }
.tutorial .tut-head button { background: none; border: 0; color: #b9c6e4; cursor: pointer; font: inherit; font-size: 13px; text-decoration: underline; }
.tutorial p { margin: 8px 0 10px; font-size: 15px; line-height: 1.4; color: #fff; }
.tutorial .tut-bar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.tutorial .tut-bar div { height: 100%; background: #ffd75a; transition: width .3s; }
.tutorial #tutNext { margin-top: 10px; width: 100%; justify-content: center; }
body.compact .tutorial { top: auto; bottom: calc(232px + env(safe-area-inset-bottom)); padding: 9px 11px; }
body.compact .tutorial p { font-size: 13px; margin: 6px 0 8px; }

/* Активный ремонт: узлы — над центром экрана, не перекрывают джойстик и кнопку сканера */
#repairNodes { position: fixed; top: 46%; left: 50%; transform: translate(-50%, -128px); z-index: 7; text-align: center;
  padding: 10px 14px 12px; border-radius: 14px; background: rgba(14, 20, 44, .86); border: 2px solid rgba(255, 170, 80, .7); max-width: min(420px, calc(100vw - 24px)); }
#repairHelp { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: #ffd7a8; }
#repairNodes .nodes { display: flex; justify-content: center; gap: 14px; }
#repairNodes button { width: 58px; height: 58px; border-radius: 50%; border: 3px solid rgba(255, 210, 63, .55); background: rgba(255, 210, 63, .12);
  color: #fff; font: 800 22px 'Rubik', sans-serif; cursor: pointer; touch-action: manipulation; }
#repairNodes button.next { border-color: var(--accent); background: rgba(255, 210, 63, .35); box-shadow: 0 0 0 4px rgba(255, 210, 63, .25); }
#repairNodes button.done { border-color: var(--green); background: rgba(74, 222, 128, .3); color: #d6ffe3; cursor: default; }
#repairNodes button.pending { opacity: .7; }
#repairNodes button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
#repairNodes.shake { animation: nodeShake .3s; }
@keyframes nodeShake { 25% { transform: translate(calc(-50% - 6px), -128px); } 75% { transform: translate(calc(-50% + 6px), -128px); } }
body.compact #repairNodes { top: calc(34% + 4px); transform: translate(-50%, 0); }
body.compact #repairNodes.shake { animation: none; }

/* Миссия в карточке цели: кнопки действий (одна текущая цель, без отдельной панели) */
#targetActions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
#targetActions:empty { display: none; }
.tbtn { font: 700 13px 'Rubik', sans-serif; color: #fff; background: rgba(255, 255, 255, .12); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 10px; min-height: 36px; cursor: pointer; touch-action: manipulation; }
.tbtn.go { background: #2f7cf6; border-color: #2f7cf6; }
.tbtn.risk { background: rgba(255, 90, 95, .25); border-color: rgba(255, 90, 95, .8); }
.tbtn.quit { background: transparent; color: var(--muted); }
.tbtn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
#target { pointer-events: auto; }

/* Итоги миссии */
#mxCard { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 20; width: min(400px, calc(100vw - 24px));
  padding: 20px 20px 18px; max-height: calc(100vh - 24px); overflow: auto; }
#mxCard h2 { margin: 0 40px 12px 0; font-size: 20px; }
[dir="rtl"] #mxCard h2 { margin: 0 0 12px 40px; }
#mxRows { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
#mxRows dt { font-size: 12px; color: var(--muted); }
#mxRows dd { margin: 2px 0 0; font-weight: 700; }
#mxFirst { margin: 12px 0 0; color: var(--accent); font-weight: 700; }
#mxNextText { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.mx-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.mx-actions .btn { flex: 1 1 160px; min-height: 44px; }
.mx-actions .btn:not(.primary) { background: rgba(255, 255, 255, .12); }
@media (prefers-reduced-motion: reduce) {
  #repairNodes.shake { animation: none; }
  #arrow { transition: none; }
}
/* Подпись цели миссии длиннее обычной — на телефоне переносится на две строки */
body.compact #targetName { white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }

/* ---------- Локация аркады ---------- */
.loc-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.loc-opt { font: 700 14px 'Rubik', sans-serif; color: #fff; padding: 9px 6px; border-radius: 12px; cursor: pointer;
  background: rgba(255,255,255,.07); border: 3px solid transparent; }
.loc-opt.sel { border-color: #ffd23f; background: rgba(255,255,255,.14); }
body.short .loc-opt { padding: 6px 4px; font-size: 13px; }
