:root {
  --bg: #07090b;
  --panel: #11161a;
  --panel2: #151c21;
  --line: #222c33;
  --ink: #eef2f4;
  --dim: #8b9aa2;
  --red: #ff3b30;
  --red-deep: #d81f2b;
  --gold: #ffcf4a;
  --ice: #58c9ff;
  --good: #6bd66d;
  --dock-h: 58px;
  --display: "Oswald", "Russo One", system-ui, sans-serif;
  --text: "Inter", "PT Sans", system-ui, sans-serif;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
button { font-family: inherit; }

html,
body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  font-size: 12.5px;
  line-height: 1.42;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 20px; height: 20px; display: block; flex: 0 0 auto; }

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(70% 40% at 50% -10%, rgba(255, 59, 48, .12), transparent 70%),
    var(--bg);
}

/* ---------- HUD ---------- */

.hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
}

.hud-id { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }

.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(145deg, #ff5a4f, var(--red-deep));
  border-radius: 11px;
  box-shadow: 0 8px 20px -10px rgba(255, 59, 48, .9), inset 0 0 0 1px rgba(255, 255, 255, .16);
}

.id-text { min-width: 0; flex: 1 1 auto; }
.brand-mini {
  margin: 0 0 1px;
  font-size: 7.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #6b7b83;
}
.who {
  margin: 0;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sub-row { display: flex; align-items: center; gap: 6px; margin-top: 1px; min-width: 0; }
.rank {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--red);
  border: 1px solid rgba(255, 59, 48, .4);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}
.rep {
  font-size: 9.5px;
  color: #7c8e97;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wallet { flex: 0 0 auto; text-align: right; }
.wallet-label {
  display: block;
  font-size: 7.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #6b7b83;
}
.wallet-sum {
  display: block;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.05;
  color: var(--gold);
  text-shadow: 0 0 16px rgba(255, 207, 74, .3);
  white-space: nowrap;
}
.wallet-sum b { font-weight: 600; font-variant-numeric: tabular-nums; }
.wallet-sum i { font-style: normal; font-size: 11px; margin-left: 2px; color: rgba(255, 207, 74, .7); }
.wallet-goal {
  width: 74px;
  height: 3px;
  margin: 4px 0 0 auto;
  background: #222b31;
  border-radius: 99px;
  overflow: hidden;
}
.wallet-goal span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--red), var(--gold));
  transition: width .4s ease;
}
.wallet small { display: block; font-size: 8px; color: #6b7b83; margin-top: 2px; }

.vitals { flex: 0 0 auto; display: flex; gap: 6px; padding: 0 12px 8px; }
.vi {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  background: #0f1418;
  border: 1px solid #1b242a;
  border-radius: 7px;
}
.vi-name {
  font-size: 7.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #7c8e97;
  white-space: nowrap;
}
.vi-track {
  flex: 1 1 auto;
  min-width: 8px;
  height: 4px;
  background: #212b31;
  border-radius: 99px;
  overflow: hidden;
}
.vi-track i { display: block; height: 100%; width: 0; border-radius: 99px; transition: width .35s ease; }
.vi b {
  font-family: var(--display);
  font-size: 9.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.vi.hp .vi-track i { background: var(--red); box-shadow: 0 0 8px rgba(255, 59, 48, .55); }
.vi.food .vi-track i { background: var(--gold); box-shadow: 0 0 8px rgba(255, 207, 74, .5); }
.vi.energy .vi-track i { background: var(--ice); box-shadow: 0 0 8px rgba(88, 201, 255, .5); }

/* ---------- Stage ---------- */

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 10px calc(var(--dock-h) + env(safe-area-inset-bottom) + 8px);
}

.view { height: 100%; }

.view-map { display: flex; }

.map {
  position: relative;
  flex: 1 1 auto;
  border: 1px solid #1d272e;
  border-radius: 14px;
  overflow: hidden;
  background: #0a0f12;
}
.map::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 70px 18px rgba(0, 0, 0, .55);
  pointer-events: none;
}
.city { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.map-watermark {
  position: absolute;
  left: 9px;
  top: 7px;
  margin: 0;
  font-size: 7px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .3);
  pointer-events: none;
}

.map-tags {
  position: absolute;
  top: 7px;
  right: 7px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.map-chip {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #c3d0d6;
  background: rgba(7, 9, 11, .78);
  border: 1px solid rgba(255, 255, 255, .12);
  padding: 3px 7px;
  border-radius: 3px;
  backdrop-filter: blur(6px);
}
.map-chip.free {
  color: #0a0b0c;
  background: var(--gold);
  border-color: var(--gold);
}

.pins { position: absolute; inset: 0; pointer-events: none; }

.pin {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0;
  background: none;
  border: 0;
  color: #cdd9dd;
  cursor: pointer;
  pointer-events: auto;
}
.pin-dot {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: rgba(15, 20, 24, .92);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 50%;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
  transition: background .18s, box-shadow .18s, transform .18s;
}
.pin-dot .ic { width: 17px; height: 17px; }
.pin-label {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(7, 9, 11, .8);
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, .07);
}
.pin.on .pin-dot {
  background: var(--red);
  border-color: transparent;
  color: #fff;
  transform: scale(1.06);
  box-shadow: 0 0 0 4px rgba(255, 59, 48, .22), 0 8px 22px rgba(255, 59, 48, .5);
}
.pin.on .pin-label { background: var(--red); color: #fff; border-color: transparent; }

/* ---------- Panels ---------- */

.panel {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 2px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: none;
}
.panel::-webkit-scrollbar { display: none; }

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}
.panel-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.panel-head span {
  font-size: 8.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #6f818a;
  text-align: right;
}
.panel-head.sub { margin-top: 4px; }

.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.feed li {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: baseline;
  background: var(--panel);
  border: 1px solid #1c262c;
  border-left: 2px solid #39464d;
  border-radius: 3px 10px 10px 3px;
  padding: 9px 11px;
  font-size: 11.5px;
}
.feed li.good { border-left-color: var(--good); }
.feed li.bad { border-left-color: var(--red); }
.feed .ago { flex: 0 0 auto; font-size: 9px; color: #6f818a; }

.badges { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid #1e282e;
  border-radius: 3px 11px 3px 11px;
  background: var(--panel);
  font-size: 10.5px;
  color: #7e9098;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #2b363d; flex: 0 0 auto; }
.badge.got {
  color: var(--ink);
  border-color: rgba(255, 207, 74, .35);
  background: linear-gradient(140deg, rgba(255, 207, 74, .09), var(--panel));
}
.badge.got .dot { background: var(--gold); box-shadow: 0 0 10px rgba(255, 207, 74, .7); }

.counters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.count {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid #1e282e;
  border-radius: 3px 10px 3px 10px;
  font-size: 10px;
  color: var(--dim);
}
.count b {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.top { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.top li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  background: var(--panel);
  border: 1px solid #1e282e;
  border-radius: 3px 11px 3px 11px;
}
.top .pos {
  flex: 0 0 auto;
  width: 20px;
  text-align: center;
  font-family: var(--display);
  font-size: 14px;
  color: var(--dim);
}
.top li:nth-child(1) .pos { color: var(--gold); }
.top li:nth-child(2) .pos { color: #ccd6da; }
.top li:nth-child(3) .pos { color: #d59a63; }
.top .nm {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top .rk { display: block; font-size: 9px; color: #6f818a; }
.top .sum { flex: 0 0 auto; font-family: var(--display); font-size: 12.5px; color: var(--gold); white-space: nowrap; }
.top li.me { border-color: rgba(255, 59, 48, .5); background: linear-gradient(140deg, rgba(255, 59, 48, .08), var(--panel)); }
.top-empty {
  padding: 12px;
  font-size: 11px;
  color: #6f818a;
  border: 1px dashed #253139;
  border-radius: 3px 11px 3px 11px;
}

/* ---------- Автоответчик ---------- */

.admin-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid #1e282e;
  border-radius: 4px 14px 4px 14px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 25px;
  padding: 0;
  background: #232d33;
  border: 1px solid #2c383f;
  border-radius: 99px;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.switch i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #8b9aa2;
  transition: transform .2s, background .2s;
}
.switch[aria-checked="true"] {
  background: rgba(255, 59, 48, .22);
  border-color: rgba(255, 59, 48, .6);
}
.switch[aria-checked="true"] i { transform: translateX(19px); background: var(--red); }

.admin-hint { margin: 0; font-size: 10px; line-height: 1.45; color: #7c8e97; }

.admin-card textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  padding: 9px 10px;
  background: #0d1216;
  border: 1px solid #243038;
  border-radius: 8px;
  color: var(--ink);
  font-family: var(--text);
  font-size: 12px;
  line-height: 1.4;
}
.admin-card textarea:focus { outline: none; border-color: rgba(255, 59, 48, .55); }

.admin-actions { display: flex; gap: 7px; }
.admin-save {
  flex: 1 1 auto;
  padding: 9px;
  background: var(--red);
  color: #fff;
  border: 0;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  cursor: pointer;
}
.admin-reset {
  flex: 0 0 auto;
  padding: 9px 12px;
  background: #1a2227;
  color: #a7b6bd;
  border: 1px solid #27333a;
  border-radius: 7px;
  font-size: 10px;
  cursor: pointer;
}
.admin-status { margin: 0; font-size: 9.5px; color: #6f818a; }
.admin-status.ok { color: var(--good); }

/* ---------- Sheet ---------- */

.sheet {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 8px);
  z-index: 15;
  max-height: 52%;
  display: flex;
  flex-direction: column;
  background: rgba(13, 17, 20, .97);
  border: 1px solid #2b363d;
  border-radius: 12px;
  box-shadow: 0 -12px 44px rgba(0, 0, 0, .55);
  backdrop-filter: blur(16px);
  overflow: hidden;
  animation: sheetIn .22s ease-out;
}
@keyframes sheetIn {
  from { transform: translateY(14px); opacity: .35; }
  to { transform: none; opacity: 1; }
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px 8px;
  border-bottom: 1px solid #1d262c;
}
.sheet-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.sheet-head p { margin: 1px 0 0; font-size: 9.5px; color: var(--dim); }
.sheet-close {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: #1a2227;
  border: 1px solid #27333a;
  border-radius: 7px;
  color: #a7b6bd;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: none;
}
.sheet-body::-webkit-scrollbar { display: none; }

.act {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px 9px 12px;
  text-align: left;
  background: #141a1f;
  border: 1px solid #232e35;
  border-radius: 9px;
  color: var(--ink);
  cursor: pointer;
  transition: transform .1s, border-color .18s;
}
.act::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--red);
  box-shadow: 0 0 8px rgba(255, 59, 48, .7);
  border-radius: 2px;
}
.act:active { transform: scale(.985); }
.act.off { opacity: .45; filter: saturate(.4); cursor: default; }
.act.off::before { background: #39444b; box-shadow: none; }

.act-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.act-text b { font-size: 11.5px; font-weight: 600; }
.act-text i { font-style: normal; font-size: 9.5px; color: var(--dim); }
.act-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: 0 0 auto; }

.tag {
  font-style: normal;
  font-size: 8.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: #222b31;
  color: #b9c6cc;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tag.cost { color: var(--gold); background: rgba(255, 207, 74, .1); }
.tag.en { color: var(--ice); background: rgba(88, 201, 255, .1); }
.tag.wait { color: #ffb1a8; background: rgba(255, 59, 48, .12); }
.tag.lock { color: #ff9a8f; background: rgba(255, 59, 48, .1); }

/* ---------- Dock ---------- */

.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  height: calc(var(--dock-h) + env(safe-area-inset-bottom));
  padding: 0 6px env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(7, 10, 12, .97);
  border-top: 1px solid #1d272e;
  backdrop-filter: blur(16px);
}
.dock-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  background: none;
  border: 0;
  color: #6b7d85;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
}
.dock-btn .ic { width: 19px; height: 19px; }
.dock-btn.on { color: var(--ink); }
.dock-btn.on .ic { color: var(--red); }
.dock-btn.on::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 2px;
  background: var(--red);
  box-shadow: 0 0 12px rgba(255, 59, 48, .8);
}
.dock.owner { grid-template-columns: repeat(5, 1fr); }
.dock.owner .dock-btn { font-size: 7.5px; letter-spacing: .06em; }

/* ---------- Toast / notice ---------- */

.toast {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 82px;
  z-index: 45;
  pointer-events: none;
  padding: 9px 12px;
  font-size: 11.5px;
  line-height: 1.35;
  background: rgba(20, 26, 31, .97);
  border: 1px solid #2a363d;
  border-left: 3px solid var(--red);
  border-radius: 3px 11px 11px 3px;
  box-shadow: 0 18px 40px -18px #000;
  transform: translateY(-8px);
  opacity: 0;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--red); }

.notice {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 92px;
  z-index: 44;
  padding: 13px 14px;
  background: rgba(16, 22, 26, .98);
  border: 1px solid #26323a;
  border-left: 3px solid var(--red);
  border-radius: 3px 12px 12px 3px;
  font-size: 11.5px;
  line-height: 1.45;
  box-shadow: 0 18px 44px -20px #000;
}
.notice p { margin: 0 0 10px; }
.notice button {
  background: var(--red);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 7px 13px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
}

@media (max-width: 360px) {
  .brand-mini, .vi-name { display: none; }
  .wallet-sum { font-size: 18px; }
  .map-chip { font-size: 8px; }
}