:root {
  --bg: #f4f1ea;
  --card: #fffdf8;
  --ink: #2b2a26;
  --muted: #7a756a;
  --line: #ddd6c8;
  --accent: #2f6f5e;
  --accent-ink: #fff;
  --gold: #b8862b;
  --err: #b3402f;
  --shadow: 0 4px 18px rgba(40, 35, 25, .16);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1d1f; --card: #24272a; --ink: #ece8df; --muted: #9c978c;
    --line: #3a3d40; --accent: #5fb39a; --accent-ink: #10201b; --gold: #e0b45a;
    --shadow: 0 4px 18px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--err); min-height: 1.2em; }
h1 { font-size: 24px; margin: 0 0 8px; }
h3 { margin: 14px 0 6px; font-size: 15px; }
button, input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select { width: 100%; margin: 4px 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; }

.screen { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }

#game, #map { position: fixed; inset: 0; }
#map { z-index: 0; }

#hud { position: fixed; top: 8px; left: 8px; right: 8px; z-index: 500; display: flex; gap: 6px;
  flex-wrap: wrap; pointer-events: none; }
.hud-item { pointer-events: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 4px 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 64px; }
.hud-item b { font-size: 15px; }
.hud-item span { font-size: 11px; color: var(--muted); }
.gps.ok b { color: var(--accent); }
.gps.bad b { color: var(--err); }

#map-tools { position: fixed; z-index: 500; right: 12px; top: 80px; display: flex; flex-direction: column; gap: 8px; }
#map-tools button { width: 44px; height: 44px; border-radius: 50%; font-size: 19px; padding: 0; box-shadow: var(--shadow); }
#fog { position: absolute; inset: 0; pointer-events: none; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
#rose { position: fixed; z-index: 2; left: 14px; top: 80px; width: 96px; height: 96px; pointer-events: none; display: none; opacity: .85; }

#toasts { position: fixed; z-index: 600; top: 80px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--card); border-left: 4px solid var(--gold); border-radius: 8px; padding: 8px 12px;
  box-shadow: var(--shadow); animation: fade 6s forwards; }
@keyframes fade { 0%{opacity:0; transform: translateY(-6px)} 8%{opacity:1; transform:none} 85%{opacity:1} 100%{opacity:0} }

#panel { position: fixed; z-index: 500; right: 8px; bottom: 8px; width: 380px; max-height: 60vh;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; }

#tabs button { border: 0; border-radius: 0; background: none; padding: 10px 10px; white-space: nowrap;
  border-bottom: 2px solid transparent; }
#tabs button.active { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
#tab-body { overflow-y: auto; padding: 10px 14px 14px; }
@media (max-width: 640px) {
  #panel { left: 8px; right: 8px; width: auto; max-height: 45vh; }
  #map-tools { top: auto; bottom: calc(45vh + 18px); }
}

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.time { color: var(--muted); font-size: 12px; margin-right: 6px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 4px 0; }
.bar i { display: block; height: 100%; background: var(--accent); }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.bot { color: var(--muted); }

/* ---------- игровые маркеры ---------- */
.gm { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.gm .ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 21px;
  background: radial-gradient(circle at 35% 30%, #fff6c9, #f2b632 60%, #c47f12); border: 3px solid #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,.35), 0 0 0 2px rgba(196,127,18,.4); transition: transform .2s; }
.gm.unknown .ico { background: radial-gradient(circle at 35% 30%, #f3f5f8, #9aa7b6 65%, #66768a); animation: bob 1.6s ease-in-out infinite; }
.gm .lbl { margin-top: 3px; padding: 1px 7px; border-radius: 8px; background: rgba(255,255,255,.92); color: #23303d;
  font-size: 11px; font-weight: 600; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.gm.camp .ico { border-radius: 10px; background: linear-gradient(#9be27a, #4c9a3a); }
.gm.life .ico { width: 32px; height: 32px; font-size: 17px; background: radial-gradient(circle at 35% 30%, #e6f0ff, #7aa7e0); }
.gm.city .ico { width: auto; height: auto; border-radius: 10px; padding: 2px 8px; font-size: 12px; font-weight: 700; color: #23303d;
  background: linear-gradient(#ffffff, #dfe7ef); white-space: nowrap; }
@keyframes bob { 50% { transform: translateY(-5px); } }
#map.far .gm .lbl { display: none; }
#map.far .gm:not(.city) .ico { transform: scale(.65); }
#map.veryfar .gm.place, #map.veryfar .gm.camp, #map.veryfar .gm.life { display: none; }

.player { position: relative; width: 56px; height: 56px; }
.player .ring { position: absolute; inset: 0; border-radius: 50%; background: rgba(42,125,225,.35); animation: pulse 2s ease-out infinite; }
.player .ava { position: absolute; inset: 8px; border-radius: 50%; display: grid; place-items: center; font-size: 22px;
  background: radial-gradient(circle at 35% 30%, #8fc2ff, #2a7de1); border: 3px solid #fff; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
@keyframes pulse { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

.maplibregl-popup-content { color: #23303d; border-radius: 10px; }

/* ночь */
body[data-map="night"] .gm .ico { box-shadow: 0 0 18px 4px rgba(255,196,80,.75); }
body[data-map="night"] .gm.unknown .ico { box-shadow: 0 0 14px 3px rgba(140,180,255,.55); }
body[data-map="night"] .gm .lbl { background: rgba(20,28,40,.88); color: #ffe3a3; }
body[data-map="night"] #vignette { background: radial-gradient(ellipse at center, rgba(0,0,0,0) 50%, rgba(0,5,20,.6) 100%); }
/* атлас */
body[data-map="atlas"] .gm .ico { background: radial-gradient(circle at 35% 30%, #d9534f, #8e1f1b); border-color: #f3e3bf; }
body[data-map="atlas"] .gm.unknown .ico { background: radial-gradient(circle at 35% 30%, #b9a27a, #6e5a3a); }
body[data-map="atlas"] .gm .lbl { background: none; box-shadow: none; color: #4a3520; font: italic 600 13px Georgia, serif; text-shadow: 0 0 3px #f3e3bf; }
body[data-map="atlas"] #map canvas.maplibregl-canvas { filter: sepia(.45) saturate(.8) contrast(1.05); }
body[data-map="atlas"] #rose { display: block; }
body[data-map="atlas"] #vignette {
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(80,50,20,.45) 100%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/><feColorMatrix values='0 0 0 0 .45 0 0 0 0 .32 0 0 0 0 .15 0 0 0 .22 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---------- чат ---------- */
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--err); color: #fff;
  font-size: 11px; line-height: 18px; text-align: center; }
.chat-channels button { font-size: 13px; padding: 6px 8px; }
#chat-list { height: min(34vh, 320px); overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
@media (max-width: 640px) { #chat-list { height: 22vh; } }
.cm { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; max-width: 92%; align-self: flex-start; }
.cm.mine { align-self: flex-end; border-color: var(--accent); }
.cm.system { align-self: center; background: none; border-style: dashed; font-size: 12px; color: var(--muted); }
.cm.hidden-msg { opacity: .55; border-color: var(--err); }
.cm-head { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.cm-head .time { margin-left: auto; }
.cm-text { white-space: pre-wrap; word-break: break-word; }
.cm-quote { font-size: 12px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 6px; margin: 2px 0; }
.cm-flag { font-size: 11px; color: var(--err); }
.cm-acts { display: flex; gap: 4px; justify-content: flex-end; }
.cm-acts button { padding: 0 6px; font-size: 12px; border-radius: 6px; }
.tag.mod { color: var(--accent); border-color: var(--accent); }
.chat-input input { flex: 5; }

/* ---------- гараж ---------- */
.veh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
.veh { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; padding: 8px 4px; }
.veh .vi { font-size: 24px; }
.veh.on { border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); font-weight: 600; }
.veh .bar { width: 80%; }

/* ---------- мини-игры ---------- */
#game-overlay { position: fixed; inset: 0; z-index: 2000; background: #000; touch-action: none; user-select: none; }
#game-overlay canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.go-close { position: absolute; top: 12px; right: 12px; z-index: 2; width: 42px; height: 42px; border-radius: 50%; font-size: 18px; padding: 0; }
.go-ui { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; align-items: center;
  justify-content: space-between; padding: 14px 16px 24px; }
.go-ui > * { pointer-events: auto; }
.go-top { background: rgba(255,255,255,.88); color: #23303d; border-radius: 12px; padding: 6px 14px; text-align: center;
  display: flex; flex-direction: column; max-width: calc(100% - 60px); }
.go-top span { font-size: 12px; color: #5c6670; }
.go-bars { width: min(420px, 100%); background: rgba(0,0,0,.45); color: #fff; border-radius: 12px; padding: 8px 12px; font-size: 13px; }
.go-bars label { display: block; margin: 4px 0; }
.bar.big { display: block; height: 14px; border-radius: 7px; background: rgba(255,255,255,.25); }
.bar.big i { transition: width .08s linear; }
.go-msg { margin-top: auto; margin-bottom: 10px; background: rgba(0,0,0,.55); color: #fff; padding: 8px 14px; border-radius: 12px;
  text-align: center; max-width: 520px; font-size: 15px; }
.go-gear { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 10px; }
.go-gear button { font-size: 13px; padding: 6px 10px; background: rgba(255,255,255,.85); color: #23303d; }
.go-gear button.on { background: var(--accent); color: #fff; }
.go-btn { width: min(320px, 90%); padding: 18px; font-size: 20px; font-weight: 700; border-radius: 16px; border: 0;
  background: #f2b632; color: #2b2a26; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.go-btn:active { transform: scale(.97); }
.atlas { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.atlas-item { display: flex; flex-direction: column; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 6px 2px; }
.atlas-item span { font-size: 24px; }
.atlas-item small { font-size: 11px; }
.atlas-item.no { opacity: .45; }

.gm.fishspot .ico { width: 34px; height: 34px; font-size: 18px; background: radial-gradient(circle at 35% 30%, #d9f1ff, #3d9ad6); }
#map.veryfar .gm.fishspot { display: none; }
.card-in { border: 1px solid var(--accent); border-radius: 10px; padding: 8px 10px; margin: 8px 0; }

.go-msg.hidden { display: none; }
.dh-end { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; background: rgba(0,0,0,.72); color: #fff; text-align: center; padding: 16px; pointer-events: auto; }
.dh-end.hidden { display: none; }
.dh-end h2 { margin: 0; font-family: monospace; }
.dh-score { font: bold 34px monospace; color: #ffe066; margin: 4px 0; }
.dh-end .row { width: min(320px, 100%); }

/* ---------- кемпинг-магнат ---------- */
.camp-head { display: flex; align-items: center; gap: 4px; }
button.link { border: 0; background: none; padding: 2px 4px; }
.stars { color: var(--gold); letter-spacing: 1px; }
.cash { display: flex; align-items: center; gap: 8px; margin: 6px 0 0; }
.fac-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin: 6px 0; }
.fac { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1px dashed var(--line); border-radius: 10px;
  padding: 6px 2px; text-align: center; }
.fac.on { border-style: solid; border-color: var(--accent); }
.fac .fi { font-size: 22px; }
.fac small { font-size: 11px; line-height: 1.2; }
.fac button { padding: 2px 6px; font-size: 12px; margin-top: 2px; }

/* ---------- реальные кемпинги ---------- */
.gm.realcamp .ico { position: relative; background: radial-gradient(circle at 35% 30%, #e6ffe0, #3c9a4a); }
.ok-badge { position: absolute; right: -4px; bottom: -4px; width: 16px; height: 16px; border-radius: 50%; background: #2f8f3a;
  color: #fff; font-size: 10px; line-height: 16px; text-align: center; border: 2px solid #fff; }
.rc-item { cursor: pointer; }
.rc-item:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.stars.big { font-size: 20px; }
.rc-sub { display: grid; grid-template-columns: 110px 1fr 28px; gap: 6px; align-items: center; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.amen { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px; font-size: 13px; margin: 4px 0; }
.amen input { width: auto; margin: 0 4px 0 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 4px; margin: 6px 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.rc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.btn-file { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; cursor: pointer; flex: 1; }
.ok { color: var(--accent); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- дача-ферма ---------- */
.garden { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 6px; margin: 6px 0; }
.plot { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; min-height: 86px; border-radius: 10px;
  background: linear-gradient(#a8784a, #7d5430); color: #fff; border: 2px solid #6a4526; }
.plot.gh { background: linear-gradient(rgba(210,240,255,.9), rgba(150,200,220,.9)), linear-gradient(#a8784a, #7d5430);
  color: #23303d; border-color: #8fc3dc; }
.plot.sel { outline: 3px solid var(--gold); }
.plot .pi { font-size: 26px; line-height: 1.1; }
.plot .pi.ripe { animation: bob 1.4s ease-in-out infinite; }
.plot small { font-size: 11px; line-height: 1.2; }
.plot .bar { width: 80%; background: rgba(255,255,255,.35); }
.plot .muted { color: inherit; opacity: .8; }
.plot.st-созрело { border-color: var(--gold); box-shadow: 0 0 10px rgba(242,182,50,.7); }
.warn { color: #ffd2c8; }
.plot.gh .warn { color: var(--err); }
.crops { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; margin-top: 6px; }
.crops button { display: flex; flex-direction: column; align-items: center; font-size: 13px; padding: 6px 4px; }
.crops small { font-size: 11px; color: var(--muted); }

/* ---------- доска и маршруты ---------- */
.subtabs button { font-size: 13px; padding: 6px 8px; }
.card-in.rec { border-color: #d64b3a; }
.card-in.rec b::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #d64b3a;
  margin-right: 6px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.report p { margin: 6px 0; }
.plan { white-space: pre-wrap; }
.warn-t { color: var(--err); }
.cp { width: 26px; height: 26px; border-radius: 50%; background: #e2552b; color: #fff; font: bold 12px system-ui; display: grid;
  place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.cp.done { background: #2f8f3a; }

.privacy { border-left: 3px solid var(--accent); padding: 4px 8px; margin: 6px 0; }

/* ================= новый интерфейс: нижнее меню, шторка, плитки ================= */
#hud { gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
#hud::-webkit-scrollbar { display: none; }
.hud-item { flex-direction: row; align-items: center; gap: 5px; padding: 6px 10px; min-width: 0; border-radius: 20px; white-space: nowrap; }
.hud-item b { font-size: 15px; }
.hud-item span { font-size: 12px; }
.hud-item .hi { font-size: 15px; }
.gps .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--err); display: inline-block; }
.gps.ok .dot { background: #34a853; }
.gps b { font-size: 12px; }

#nav { position: fixed; z-index: 700; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(40,35,25,.12);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
#nav button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 12px; padding: 6px 2px; border-radius: 12px; position: relative; color: var(--muted); }
#nav button span { font-size: 24px; line-height: 1.1; filter: grayscale(.4); }
#nav button.on { color: var(--accent); font-weight: 700; background: color-mix(in srgb, var(--accent) 10%, transparent); }
#nav button.on span { filter: none; }
#nav .badge { position: absolute; top: 2px; right: calc(50% - 22px); }

#panel { left: auto; right: 12px; bottom: 76px; width: 440px; max-height: calc(100vh - 150px); font-size: 16px; }
#panel.hidden { display: none; }
#sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
#sheet-head b { flex: 1; font-size: 18px; }
#sheet-head button { width: 38px; height: 38px; padding: 0; border-radius: 50%; font-size: 18px; flex-shrink: 0; }
#tab-body { padding: 12px 16px 18px; }
#tab-body h3 { font-size: 17px; margin: 18px 0 8px; }
#tab-body .small { font-size: 13px; }
#tab-body .list li { padding: 10px 0; }
#tab-body button { min-height: 40px; }
.hint { color: var(--muted); margin: 0 0 12px; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 16px 8px; min-height: 120px;
  border-radius: 16px; border: 1px solid var(--line); background: var(--bg); text-align: center; }
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile .ti { font-size: 40px; line-height: 1; }
.tile b { font-size: 16px; }
.tile small { font-size: 12px; color: var(--muted); }

.me-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; background: var(--bg); }
.me-card b { font-size: 18px; }
.me-money { display: flex; gap: 16px; margin-top: 6px; }

#map-tools { top: auto; bottom: 90px; }
body.sheet-open #map-tools { display: none; }
.maplibregl-ctrl-bottom-left { bottom: 70px; }
.maplibregl-ctrl-bottom-right { bottom: 66px; }
#toasts { top: 64px; }

@media (max-width: 640px) {
  #panel { left: 0; right: 0; width: auto; bottom: 64px; max-height: 68vh; border-radius: 18px 18px 0 0; border-bottom: 0; }
  #map-tools { bottom: 84px; }
}

@media (max-width: 640px) { #h-gps-sub, #h-clock { display: none; } }

.shop-money { margin: 0 0 12px; font-size: 16px; }
.big-ico { font-size: 22px; }
#nav button { font-size: 11px; }
#nav button span { font-size: 22px; }

/* ---------- приложение на телефоне ---------- */
#hud { top: calc(8px + env(safe-area-inset-top)); }
.hud-item.rec { color: #d64b3a; font-weight: 700; font-size: 13px; }
.install { margin: 12px 0; }

/* мелкий масштаб: неоткрытые места — маленькие точки, без подписей */
#map.far .gm.unknown .ico { transform: scale(.45); animation: none; opacity: .8; }
#map.far .gm.unknown .lbl { display: none; }
