/* Вид измерительного прибора: тёмный фон, тонкие линии, два смысловых цвета. */
@font-face {
  font-family: "Source Sans 3";
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/SourceSans3.woff2") format("woff2");
}

:root {
  --bg: #0b0c0e;
  --panel: rgba(14, 16, 19, 0.94);
  --white: #f4f4f0;
  --muted: rgba(244, 244, 240, 0.66);
  --faint: rgba(244, 244, 240, 0.4);
  --line: rgba(244, 244, 240, 0.2);
  --line-strong: rgba(244, 244, 240, 0.5);
  --uv: #bda4ff;
  --food: #f5c56a;
  --warn: #ff8f7a;
  --font: "Source Sans 3", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--white);
  font: 400 16px/1.45 var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.lbl, .eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.note { font-size: 14px; color: var(--muted); }
.c-uv { color: var(--uv); font-style: normal; }
.c-food { color: var(--food); font-style: normal; }

/* ---------- экраны ---------- */
.screen, .overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background: rgba(6, 7, 9, 0.72);
}
.overlay { background: rgba(6, 7, 9, 0.78); }
.panel {
  width: 100%;
  max-width: 1040px;
  margin: auto;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.panel.narrow { max-width: 760px; }
.panel.center { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 360px; }
.start { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 36px; }
.col { min-width: 0; display: flex; flex-direction: column; gap: 16px; }

h1 { font-size: clamp(38px, 6vw, 60px); font-weight: 300; line-height: 1.02; letter-spacing: -0.01em; }
h2 { font-size: 28px; font-weight: 400; line-height: 1.15; }
.lead { font-size: 19px; color: var(--muted); max-width: 34em; }
.foot { margin: 14px auto 0; max-width: 1040px; font-size: 13px; color: var(--faint); text-align: center; }
.foot a { color: var(--muted); }

.maps { display: flex; gap: 10px; flex-wrap: wrap; }
.map {
  padding: 9px 14px;
  border: 1px solid var(--line);
  font-size: 15px;
  color: var(--faint);
}
.map b { display: block; font-weight: 600; color: inherit; }
.map.on { border-color: var(--white); color: var(--white); }
.map small { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; }

.who { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border: 1px solid var(--line); }
.who-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.who-row b { font-size: 22px; font-weight: 600; }
.vk { display: flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; }
.vk input { width: 18px; height: 18px; accent-color: var(--food); }

.primary {
  padding: 14px 28px;
  background: var(--white);
  color: #0b0c0e;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  align-self: flex-start;
  transition: background 0.15s;
}
.primary:hover { background: #fff; }
.primary:active { transform: translateY(1px); }
.ghost {
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
}
.ghost:hover { border-color: var(--white); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.keys { font-size: 14px; color: var(--muted); }
.keys-touch { display: none; }

.tools { list-style: none; counter-reset: t; display: flex; flex-direction: column; gap: 7px; font-size: 15px; color: var(--muted); }
.tools li { counter-increment: t; padding-left: 28px; position: relative; }
.tools li::before {
  content: counter(t);
  position: absolute; left: 0; top: 2px;
  width: 19px; height: 19px;
  border: 1px solid var(--line-strong); border-radius: 50%;
  font-size: 11px; font-weight: 700; line-height: 17px; text-align: center; color: var(--white);
}
.tools b { color: var(--white); font-weight: 600; }

/* ---------- таблица результатов ---------- */
.board { border-left: 1px solid var(--line); padding-left: 32px; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); }
.tabs button { padding: 8px 14px 9px; font-size: 14px; font-weight: 600; color: var(--faint); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--white); border-bottom-color: var(--white); }
.table { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; min-height: 120px; }
.trow { display: grid; grid-template-columns: 30px minmax(0, 1fr) 62px 52px 36px; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid rgba(244, 244, 240, 0.08); font-size: 15px; }
.trow.head { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.trow span:nth-child(n+3) { text-align: right; }
.trow .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .pl { color: var(--faint); }
.trow.me { color: var(--food); }
.trow.me .pl { color: var(--food); }
.trow.gap { border-bottom: 0; color: var(--faint); padding: 0; }
.empty { padding: 18px 0; color: var(--muted); font-size: 15px; }

/* ---------- итог ---------- */
.big { display: flex; align-items: baseline; gap: 12px; }
.big b { font-size: clamp(56px, 10vw, 92px); font-weight: 300; line-height: 0.95; font-variant-numeric: tabular-nums; }
.big span { font-size: 18px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.stats div { background: #0e1013; padding: 10px 12px; }
.stats b { display: block; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats span { font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { padding: 3px 10px; border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.chips span b { color: var(--white); font-weight: 600; }
.chips .cap { border: 0; padding-left: 0; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; font-size: 11px; }
.facts { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.facts ul { list-style: none; display: flex; flex-direction: column; gap: 5px; font-size: 15px; color: var(--muted); }
.facts li { padding-left: 14px; position: relative; }
.facts li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 6px; height: 1px; background: var(--line-strong); }

/* ---------- выбор улучшения ---------- */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 18px 0 12px; }
.card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px; min-height: 172px; text-align: left;
  border: 1px solid var(--line-strong);
  transition: border-color 0.12s, background 0.12s;
}
.card:hover, .card:focus-visible { border-color: var(--white); background: rgba(244, 244, 240, 0.06); }
.card .k { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.card .k kbd { font: inherit; color: var(--white); border: 1px solid var(--line-strong); padding: 0 6px; }
.card b { font-size: 20px; font-weight: 600; line-height: 1.15; }
.card p { font-size: 15px; color: var(--muted); flex: 1; }
.pips { display: flex; gap: 4px; }
.pips i { width: 16px; height: 3px; background: var(--line); }
.pips i.on { background: var(--white); }

/* ---------- приборная панель ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud-top {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: stretch; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
}
.grow { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; }
.box {
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  min-width: 78px; padding: 6px 12px 7px;
  background: rgba(11, 12, 14, 0.93); border: 1px solid var(--line);
}
.box b { font-size: 26px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.box .lbl { font-size: 10.5px; white-space: nowrap; }
.box .lbl em { font-style: normal; color: var(--food); letter-spacing: 0; }
.box-lvl { min-width: 132px; gap: 7px; }
.bar { height: 4px; background: var(--line); }
.bar i { display: block; height: 100%; width: 0; background: var(--white); transition: width 0.2s; }
.box-score { align-items: flex-end; min-width: 104px; }
.rush .box-score b, .rush #h-time { color: var(--food); }
.icon-btn {
  pointer-events: auto; width: 46px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  background: rgba(11, 12, 14, 0.93); border: 1px solid var(--line);
}
.icon-btn i { width: 4px; height: 16px; background: var(--white); }

.banner {
  position: absolute; left: 50%; top: calc(var(--sy0, 70px) + 40px); transform: translateX(-50%);
  max-width: min(560px, calc(100% - 24px)); width: max-content;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 18px 10px; text-align: center;
  background: rgba(11, 12, 14, 0.9); border: 1px solid var(--line-strong);
  animation: drop 0.25s ease-out;
}
.banner b { font-size: 19px; font-weight: 600; }
.banner span { font-size: 15px; color: var(--muted); }
.banner.food { border-color: var(--food); }
.banner.food b { color: var(--food); }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -8px); } }

/* подсказка первых секунд: в свободном месте верхней строки, ленту не закрывает */
.hint {
  max-width: 100%; padding: 6px 14px; text-align: center; font-size: 15px; line-height: 1.25;
  background: rgba(11, 12, 14, 0.86); border: 1px solid var(--line);
}
.status { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); white-space: nowrap; }

.mini { position: absolute; left: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 3px; padding: 8px; background: rgba(11, 12, 14, 0.93); border: 1px solid var(--line); }
.mini canvas { width: 176px; height: 124px; display: block; }
.mini span { font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

.abil { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; align-items: flex-end; pointer-events: auto; }
.abil button {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-width: 86px; height: 62px; padding: 6px 10px;
  background: rgba(11, 12, 14, 0.93); border: 1px solid var(--line-strong);
  touch-action: none;
}
.abil button span { font-size: 13px; font-weight: 600; position: relative; z-index: 1; }
.abil kbd { font: 600 11px var(--font); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); padding: 0 6px; position: relative; z-index: 1; }
.abil button.uv { border-color: var(--uv); }
.abil button.uv span { color: var(--uv); }
.abil button.main { border-color: var(--white); min-width: 104px; }
.abil button::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--cd, 0) * 100%); background: rgba(244, 244, 240, 0.16); }
.abil button.wait span, .abil button.wait kbd { opacity: 0.45; }
.abil button:active { background: rgba(244, 244, 240, 0.14); }

#stick { position: fixed; width: 112px; height: 112px; margin: -56px 0 0 -56px; border: 1px solid var(--line-strong); border-radius: 50%; pointer-events: none; z-index: 11; }
#stick i { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(244, 244, 240, 0.3); border: 1px solid var(--white); }

/* ---------- шкалы: время, силы, здоровье ---------- */
.c-warn { color: var(--warn); font-style: normal; }
.ghost.small { padding: 6px 12px; font-size: 14px; }
.rules { list-style: none; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); font-size: 15px; color: var(--muted); }
.rules b { color: var(--white); font-weight: 600; }
.box-time { min-width: 92px; gap: 3px; }
.box-time .bar { margin-top: 3px; }
.box-vit { min-width: 190px; gap: 7px; }
.vrow { display: grid; grid-template-columns: 66px minmax(0, 1fr) 28px; gap: 7px; align-items: center; }
.vrow b { font-size: 14px; font-weight: 600; text-align: right; }
.vrow .bar { height: 5px; }
.bar i { max-width: 100%; }
.box-time.low b, .vrow.low b { color: var(--warn); }
.box-time.low .bar i, .vrow.low .bar i { background: var(--warn); }
button.box-lvl { pointer-events: auto; text-align: left; align-items: stretch; }
button.box-lvl:hover { border-color: var(--line-strong); }

/* ---------- умения, которые пришли сами ---------- */
.granted { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 16px; padding: 12px 14px; border: 1px solid var(--food); }
.granted .lbl { color: var(--food); }
.granted b { display: block; font-size: 18px; font-weight: 600; }
.granted p { font-size: 15px; color: var(--muted); }

/* ---------- дерево умений ---------- */
.panel.wide { max-width: 1180px; }
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 10px; }
.track { display: flex; flex-wrap: wrap; margin: 16px 0; border: 1px solid var(--line); border-right: 0; }
.track button { flex: 1 1 130px; display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; text-align: left; border-right: 1px solid var(--line); color: var(--faint); }
.track small { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.track b { font-size: 15px; font-weight: 600; }
.track button.have { color: var(--white); }
.track button.have small { color: var(--food); }
.track button.sel { background: rgba(244, 244, 240, 0.08); }
.tree-body { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 20px; align-items: start; }
.branches { display: grid; grid-template-columns: repeat(auto-fill, minmax(214px, 1fr)); gap: 16px; }
.branch { display: flex; flex-direction: column; gap: 6px; }
.branch > .lbl { padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.node { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 7px 10px; text-align: left; border: 1px solid var(--line); color: var(--faint); }
.node.d1 { margin-left: 18px; }
.node.d2 { margin-left: 36px; }
.node.d3 { margin-left: 54px; }
.node.d1::before, .node.d2::before, .node.d3::before {
  content: ""; position: absolute; left: -11px; top: -7px; width: 10px; height: calc(50% + 7px);
  border-left: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong);
}
.node b { font-size: 15px; font-weight: 600; line-height: 1.2; }
.node small { font-size: 12px; line-height: 1.25; }
.node .fx { font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--food); }
.node.open { color: var(--muted); border-color: var(--line-strong); }
.node.open b, .node.have b { color: var(--white); }
.node.have { color: var(--muted); border-color: var(--white); }
.node.full { border-color: var(--food); }
.node.sel { background: rgba(244, 244, 240, 0.09); }
.skill-info { position: sticky; top: 0; display: flex; flex-direction: column; gap: 9px; padding: 14px 16px; border: 1px solid var(--line-strong); min-height: 220px; }
.skill-info h3 { font-size: 21px; font-weight: 600; line-height: 1.15; }
.skill-info .st { font-size: 14px; font-weight: 600; color: var(--food); }
.skill-info ol { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 14.5px; color: var(--muted); }
.skill-info li { display: grid; grid-template-columns: 22px minmax(0, 1fr); }
.skill-info li span { color: var(--faint); font-weight: 700; }
.skill-info li.got { color: var(--white); }
.skill-info li.got span { color: var(--food); }
.skill-info p { font-size: 14px; color: var(--muted); }
.skill-info p b { color: var(--white); font-weight: 600; }

/* ---------- память голубя ---------- */
.atlas-body { display: grid; grid-template-columns: minmax(0, 330px) minmax(0, 1fr); gap: 20px; margin-top: 14px; align-items: start; }
.atlas-list { display: flex; flex-direction: column; gap: 4px; max-height: 62vh; overflow-y: auto; padding-right: 4px; }
.atlas-list .lbl { margin: 8px 0 2px; }
.arow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; padding: 7px 10px; border: 1px solid var(--line); text-align: left; }
.arow b { font-size: 15px; font-weight: 600; }
.arow span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.arow .bar { grid-column: 1 / -1; height: 3px; }
.arow.food .bar i { background: var(--food); }
.arow.danger .bar i { background: var(--warn); }
.arow.sel { border-color: var(--white); }
.atlas-detail { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border: 1px solid var(--line-strong); min-height: 240px; }
.atlas-detail h3 { font-size: 21px; font-weight: 600; }
.atlas-detail p { font-size: 14px; color: var(--muted); }
.atlas-detail canvas { display: block; width: 100%; }

/* ---------- телефон и узкий экран ---------- */
@media (max-width: 820px) {
  .panel { padding: 20px 18px; }
  .start { grid-template-columns: 1fr; gap: 24px; }
  .board { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 18px; }
  .cards { grid-template-columns: 1fr; }
  .card { min-height: 0; }
  .lead { font-size: 17px; }
  .box { min-width: 0; padding: 5px 9px 6px; }
  .box b { font-size: 21px; }
  .box-lvl { min-width: 86px; }
  .hud-top { gap: 5px; }
  .banner b { font-size: 16px; }
  .banner span { font-size: 13px; }
}
@media (pointer: coarse) {
  .keys-desk { display: none; }
  .keys-touch { display: block; }
  .status { display: none; }
  .mini { left: 10px; top: 62px; bottom: auto; padding: 5px; }
  .mini canvas { width: 104px; height: 74px; }
  .mini span { display: none; }
  .abil { right: max(14px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); gap: 12px; }
  .abil kbd { display: none; }
  .abil button { min-width: 0; width: 68px; height: 68px; border-radius: 50%; }
  .abil button.main { width: 92px; height: 92px; min-width: 0; }
  .abil button span { font-size: 12px; }
  .abil button.main span { font-size: 15px; }
  .hint { font-size: 13px; padding: 4px 10px; }
  .abil button { background: rgba(11, 12, 14, 0.62); }
}
@media (max-height: 520px) {
  .banner { padding: 5px 14px 6px; }
}
/* телефон вертикально: лента сверху, схема площади под ней */
@media (pointer: coarse) and (orientation: portrait) {
  .mini { top: calc(var(--sy1, 50vh) + 30px); }
  .mini canvas { width: 132px; height: 94px; }
  .hint { position: absolute; left: 12px; right: 12px; top: calc(var(--sy1, 50vh) + 158px); font-size: 14px; padding: 6px 12px; }
}
/* ---------- вторая версия: шкалы и новые экраны на узком экране ---------- */
@media (max-width: 820px), (pointer: coarse) {
  /* телефон в любом положении: приборы сжаты, чтобы подсказке хватило места */
  .box { min-width: 0; padding: 5px 9px 6px; }
  .box b { font-size: 21px; }
  .box-lvl { min-width: 86px; }
  .hud-top { gap: 5px; }
  .box-time { min-width: 0; }
  .box-vit { min-width: 104px; gap: 4px; }
  .vrow { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 4px; }
  .vrow .lbl { font-size: 9px; }
  .vrow b { font-size: 12px; grid-row: 1; grid-column: 2; }
  .vrow .bar { grid-column: 1 / -1; height: 4px; }
}
@media (pointer: coarse) and (orientation: landscape) {
  .mini { top: calc(var(--sy0, 54px) + 8px); }
  .hint { font-size: 12.5px; line-height: 1.2; padding: 3px 9px; }
}
@media (max-width: 820px) {
  .tree-body, .atlas-body { grid-template-columns: 1fr; }
  .skill-info { position: static; order: -1; min-height: 0; }
  .atlas-list { max-height: 34vh; }
  .head-row h2 { font-size: 22px; }
}
@media (max-width: 560px) {
  .box-food { display: none; }
  .box-lvl { min-width: 74px; }
  .box-score { min-width: 0; }
  .icon-btn { width: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .banner { animation: none; }
  .bar i { transition: none; }
}
