:root {
  --bg: #121417;
  --card: #1c1f24;
  --card-2: #252930;
  --line: #2e333b;
  --text: #eceae4;
  --muted: #8d939e;
  --seeds: #f2c230;      /* акцент: цвет семок */
  --red: #e0483f;
  --blue: #5aa9ff;
  --green: #5ec26a;
  --common: #a5abb5;
  --choice: #5ec26a;
  --rare: #5aa9ff;
  --legend: #f2c230;
  --radius: 14px;
  --tabs-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
[hidden] { display: none !important; }

/* ---------- заставка ---------- */
.splash {
  position: fixed; inset: 0; display: flex; flex-direction: column; gap: 18px;
  align-items: center; justify-content: center; text-align: center; padding: 24px;
  background:
    repeating-linear-gradient(90deg, transparent 0 22px, rgba(255,255,255,.035) 22px 26px),
    var(--bg);
}
.splash-logo {
  font-weight: 900; font-size: 54px; line-height: .95; letter-spacing: 2px;
  color: var(--seeds); text-shadow: 4px 4px 0 #000;
  transform: rotate(-4deg);
}
.splash-text { color: var(--muted); max-width: 280px; }

/* ---------- каркас ---------- */
.game { max-width: 520px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.screen {
  flex: 1; padding: 12px 12px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 18px);
  display: flex; flex-direction: column; gap: 10px;
}

/* ---------- шапка ---------- */
.hud {
  position: sticky; top: 0; z-index: 5; padding: 10px 12px 10px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 7px;
}
.hud-top { display: flex; align-items: center; gap: 10px; }
.hud-level {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 900; font-size: 18px; color: #15171a;
  background: var(--seeds); box-shadow: 0 0 0 3px #000, 0 0 0 4px var(--seeds);
}
.hud-who { flex: 1; min-width: 0; }
.hud-name { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-sub { color: var(--muted); font-size: 12px; }
.hud-money { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.money { display: flex; gap: 5px; align-items: center; font-size: 14px; }
.money b { font-variant-numeric: tabular-nums; }
.hud-bars { display: grid; grid-template-columns: 1.5fr 1fr; gap: 7px; }

.bar {
  position: relative; height: 20px; border-radius: 10px; overflow: hidden;
  background: var(--card-2); border: 1px solid var(--line);
}
.bar i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 10px; transition: width .35s ease; }
.bar span {
  position: relative; display: block; text-align: center; font-size: 11.5px; line-height: 18px;
  font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.8); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bar-authority { height: 14px; }
.bar-authority span { font-size: 10px; line-height: 12px; }
.bar-authority i { background: linear-gradient(90deg, #2f6fb8, var(--blue)); }
.bar-energy i { background: linear-gradient(90deg, #b88a12, var(--seeds)); }
.bar-vigor i { background: linear-gradient(90deg, #9c2a23, var(--red)); }
.bar-hp i { background: linear-gradient(90deg, #9c2a23, var(--red)); }
.bar-me i { background: linear-gradient(90deg, #2f8a3c, var(--green)); }
.bar-mastery { height: 8px; border-radius: 4px; }
.bar-mastery i { background: var(--seeds); border-radius: 4px; }

/* ---------- вкладки ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  max-width: 520px; margin: 0 auto;
  background: rgba(22, 24, 28, .96); border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.tabs button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; font-size: 11px; color: var(--muted); font-weight: 600;
}
.tabs button span { font-size: 21px; filter: grayscale(.8); opacity: .75; transition: transform .15s; }
.tabs button.on { color: var(--seeds); }
.tabs button.on span { filter: none; opacity: 1; transform: translateY(-2px) scale(1.12); }
.tabs em {
  position: absolute; top: 9px; left: calc(50% + 9px); width: 9px; height: 9px; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 0 2px var(--bg);
}

/* ---------- общее ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.card.dim { opacity: .55; }
.title { font-weight: 800; font-size: 15.5px; line-height: 1.25; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.h2 {
  margin: 8px 2px 0; font-size: 12px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 2px 8px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.chip.good { color: var(--green); border-color: rgba(94,194,106,.4); }
.chip.warn { color: var(--red); border-color: rgba(224,72,63,.45); }

.btn {
  flex: none; min-width: 92px; padding: 9px 14px; border-radius: 11px; font-weight: 800; font-size: 14px;
  color: #15171a; background: var(--seeds); box-shadow: 0 3px 0 #8f6f0c; transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #8f6f0c; }
.btn.red { background: var(--red); color: #fff; box-shadow: 0 3px 0 #7d211c; }
.btn.red:active { box-shadow: 0 1px 0 #7d211c; }
.btn.ghost { background: var(--card-2); color: var(--text); box-shadow: 0 3px 0 #0c0d0f; border: 1px solid var(--line); }
.btn.small { min-width: 0; padding: 6px 11px; font-size: 13px; }
.btn.grow { flex: 1; }
.btn[disabled] { opacity: .4; pointer-events: none; }
body.busy .btn { pointer-events: none; }

/* ---------- район ---------- */
.districts { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.districts::-webkit-scrollbar { display: none; }
.district {
  flex: none; padding: 8px 14px; border-radius: 999px; font-weight: 800; font-size: 14px;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
}
.district.on { background: var(--seeds); border-color: var(--seeds); color: #15171a; }
.medals { display: flex; gap: 1px; font-size: 14px; }
.medals span { filter: grayscale(1); opacity: .25; }
.medals span.on { filter: none; opacity: 1; }
.job-foot { display: flex; align-items: center; gap: 10px; }
.job-foot .bar { flex: 1; }
.job-count { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.boss { border-color: rgba(224,72,63,.5); background: linear-gradient(160deg, #2a1c1c, var(--card) 55%); }
.boss-face {
  width: 58px; height: 58px; flex: none; border-radius: 16px; display: grid; place-items: center; font-size: 34px;
  background: #000; border: 1px solid rgba(224,72,63,.5);
}
.boss-log { font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.boss-log .hit { color: var(--seeds); }
.boss-log .got { color: var(--red); }
.shake { animation: shake .3s; }
@keyframes shake {
  20% { transform: translateX(-5px) rotate(-1deg); } 40% { transform: translateX(5px) rotate(1deg); }
  60% { transform: translateX(-3px); } 80% { transform: translateX(3px); }
}

/* ---------- шмот ---------- */
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot {
  aspect-ratio: 1 / 1; border-radius: var(--radius); border: 1px dashed var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 6px; text-align: center;
}
.slot.full { border-style: solid; }
.slot-emoji { font-size: 26px; }
.slot.empty .slot-emoji { filter: grayscale(1); opacity: .3; }
.slot-name { font-size: 11.5px; font-weight: 700; line-height: 1.15; }
.slot-kind { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.r-common { color: var(--common); } .r-choice { color: var(--choice); }
.r-rare { color: var(--rare); } .r-legend { color: var(--legend); }
.slot.full.r-common { border-color: rgba(165,171,181,.5); } .slot.full.r-choice { border-color: rgba(94,194,106,.6); }
.slot.full.r-rare { border-color: rgba(90,169,255,.6); } .slot.full.r-legend { border-color: rgba(242,194,48,.7); }

/* ---------- пацан ---------- */
.stat-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.stat-row b { font-size: 17px; font-variant-numeric: tabular-nums; }
.stat-row small { color: var(--green); font-weight: 700; }
.link-box {
  padding: 8px 10px; border-radius: 10px; background: #000; border: 1px solid var(--line);
  font-size: 12.5px; word-break: break-all; color: var(--muted); user-select: all; -webkit-user-select: all;
}
.switch { width: 46px; height: 27px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); position: relative; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%; background: var(--muted); transition: .15s; }
.switch.on { background: var(--seeds); border-color: var(--seeds); }
.switch.on::after { left: 21px; background: #15171a; }

/* ---------- топ ---------- */
.top-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.top-row.me { border-color: var(--seeds); }
.top-place { width: 30px; text-align: center; font-weight: 900; color: var(--muted); }
.top-row:nth-child(-n+3) .top-place { color: var(--seeds); font-size: 17px; }

/* ---------- сочность: отклик на действие ---------- */
.fly {
  position: fixed; z-index: 20; pointer-events: none; white-space: nowrap;
  font-weight: 900; font-size: 19px; color: var(--seeds);
  text-shadow: 0 2px 0 #000, 0 0 10px rgba(0,0,0,.9);
  transform: translate(-50%, -50%); animation: fly 1.05s ease-out forwards;
}
.fly.blue { color: var(--blue); }
.fly.red { color: #ff6b61; }
.fly.crit { font-size: 30px; }
@keyframes fly {
  0%   { opacity: 0; transform: translate(-50%, -20%) scale(.5); }
  18%  { opacity: 1; transform: translate(-50%, -90%) scale(1.2); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -330%) scale(1); }
}
.money.bump { animation: bump .4s ease-out; }
@keyframes bump { 40% { transform: scale(1.28); } }
.medals span.pop { display: inline-block; animation: medal .8s cubic-bezier(.2, 1.7, .4, 1); }
@keyframes medal {
  0%   { transform: scale(0) rotate(-50deg); }
  55%  { transform: scale(2.1) rotate(12deg); }
  100% { transform: scale(1) rotate(0); }
}
.boss-face.hurt { animation: hurt .38s ease-out; }
@keyframes hurt { 30% { background: #7d211c; transform: scale(.88) rotate(-8deg); } }

.levelup {
  position: fixed; inset: 0; z-index: 19; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: radial-gradient(circle at center, rgba(242,194,48,.35), transparent 60%);
  animation: levelup-veil 1.5s ease-out forwards;
}
.levelup-num {
  width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center;
  font-size: 58px; font-weight: 900; color: #15171a; background: var(--seeds);
  box-shadow: 0 0 0 6px #000, 0 0 0 9px var(--seeds), 0 0 60px rgba(242,194,48,.8);
  animation: levelup-num 1.5s cubic-bezier(.2, 1.5, .4, 1) forwards;
}
.levelup-text { font-weight: 900; letter-spacing: 3px; color: var(--seeds); text-shadow: 0 2px 0 #000; }
@keyframes levelup-veil { 0% { opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
@keyframes levelup-num { 0% { transform: scale(0) rotate(-25deg); } 35% { transform: scale(1.15) rotate(4deg); } 100% { transform: scale(1); } }

/* Кого мутит от движения — тому без полётов и вспышек: итог и так написан в шторке. */
@media (prefers-reduced-motion: reduce) {
  .fly, .levelup { display: none; }
  .bump, .pop, .hurt, .shake { animation: none !important; }
  .bar i { transition: none; }
}

/* ---------- всплывающий итог ---------- */
.sheet {
  position: fixed; left: 10px; right: 10px; z-index: 9; max-width: 500px; margin: 0 auto;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 10px);
  padding: 13px 14px; border-radius: 16px; background: #0b0c0e; border: 1px solid var(--seeds);
  box-shadow: 0 10px 30px rgba(0,0,0,.6); display: flex; flex-direction: column; gap: 8px;
  animation: rise .18s ease-out;
}
.sheet.bad { border-color: var(--red); }
.sheet .big { font-weight: 800; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
