/* Юнармия · учебный тир — оформление.
   Светлая «мастерская»: бумага, тушь, янтарное дерево. Тир остаётся ночным —
   у него собственные цвета в блоке «тир». */

:root {
  /* тёмные токены — нужны блоку тира */
  --bg: #0d1511;
  --bg2: #111d16;
  --panel: #152219;
  --panel2: #1a2a20;
  --line: rgba(233, 220, 184, 0.14);
  --line2: rgba(233, 220, 184, 0.28);
  --cream: #ecdfbe;
  --dim: #97a392;
  --amber: #e0a23c;
  --amber2: #f6cd78;
  --red: #cf5340;
  --green: #7fae74;

  /* светлая тема */
  --paper: #f7f2e6;
  --paper2: #efe7d5;
  --card: #fffdf7;
  --ink: #1b2721;
  --ink2: #5a6a5e;
  --ink3: #8d9a8e;
  --edge: #ded3bd;
  --edge2: #c9bca1;
  --wood: #e8a92c;
  --wood-d: #c17f1f;
  --ok: #2f7d4f;
  --bad: #bf3f2c;

  --font-head: 'Arial Narrow', 'Roboto Condensed', 'PT Sans Narrow', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --safe: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  background: radial-gradient(1200px 520px at 50% -8%, #fffdf6 0%, rgba(255, 253, 246, 0) 70%), var(--paper);
}

body.is-playing {
  overflow: hidden;
}

#app {
  min-height: 100%;
  min-height: 100dvh;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

kbd {
  font-family: var(--font-head);
  font-size: 0.86em;
  border: 1px solid var(--edge2);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  background: #fff;
}

/* ------------------------------------------------------------------ штаб */

.hub {
  min-height: 100dvh;
  padding: 20px clamp(14px, 3vw, 44px) calc(26px + var(--safe));
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

.hub::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(27, 39, 33, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(27, 39, 33, 0.05) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(120% 70% at 50% 0%, #000 30%, transparent 80%);
  pointer-events: none;
}

.hub-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  width: 50px;
  height: 50px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--wood);
  display: grid;
  place-items: center;
  color: var(--wood-d);
  background: #fff8e7;
  box-shadow: 0 6px 16px -10px rgba(193, 127, 31, 0.9);
}

.brand-mark svg {
  width: 26px;
  height: 26px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-text b {
  font-family: var(--font-head);
  font-size: clamp(22px, 2.4vw, 28px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.brand-text span {
  font-size: 11.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink3);
}

.hub-tools {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tool {
  border: 1px solid var(--edge);
  background: var(--card);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 13px;
  color: var(--ink2);
  transition: 0.16s;
  box-shadow: 0 4px 12px -10px rgba(0, 0, 0, 0.6);
}

.tool:hover {
  border-color: var(--edge2);
  color: var(--ink);
}

.tool.on {
  color: var(--ink);
  border-color: var(--wood);
  background: #fff8e7;
}

.hub-lead {
  position: relative;
  color: var(--ink2);
  font-size: clamp(13px, 1.4vw, 15px);
  line-height: 1.55;
  max-width: 78ch;
}

.hub-lead b {
  color: var(--ink);
}

.hub-cards {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 18px;
  align-items: stretch;
}

.card {
  border: 1px solid var(--edge);
  border-radius: 20px;
  background: var(--card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: 0.2s;
  box-shadow: 0 20px 44px -34px rgba(23, 32, 26, 0.9);
}

.card:hover {
  border-color: var(--edge2);
  transform: translateY(-2px);
}

.card-art {
  position: relative;
  height: 132px;
  background: #0f1a14;
  border-bottom: 1px solid var(--edge);
  overflow: hidden;
}

.card-art svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.card-art-ak {
  background: repeating-linear-gradient(135deg, #fbf7ec 0 12px, #f4eddd 12px 24px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-art-ak .art-rifle {
  max-height: 86%;
  max-width: 96%;
  margin: 0;
}

.art-rifle {
  width: auto;
  max-width: 94%;
  max-height: 82%;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(23, 32, 26, 0.18));
}

.card-tag {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 2;
  padding: 4px 10px;
  border-radius: 7px;
  background: rgba(10, 16, 12, 0.62);
  font-family: var(--font-head);
  letter-spacing: 0.2em;
  font-size: 10.5px;
  color: var(--amber2);
  text-transform: uppercase;
}

.card-art-ak .card-tag {
  background: #1b2721;
  color: #f6cd78;
}

.card-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.card-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.card-title h2 {
  margin: 0;
  font-family: var(--font-head);
  font-size: clamp(22px, 2.8vw, 30px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card-title span {
  font-size: 12px;
  color: var(--ink3);
  letter-spacing: 0.1em;
}

.card-desc {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink2);
}

.card-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink2);
  border-left: 3px solid var(--wood);
  padding: 2px 0 2px 9px;
  background: linear-gradient(90deg, rgba(232, 169, 44, 0.09), transparent 70%);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  border: 1px solid var(--edge);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--ink2);
  transition: 0.15s;
  white-space: nowrap;
}

.chip:hover {
  color: var(--ink);
  border-color: var(--edge2);
}

.chip.on {
  color: #241a05;
  background: linear-gradient(180deg, #fbc95f, var(--wood));
  border-color: var(--wood-d);
  font-weight: 700;
}

/* выбор режима: две крупные плитки с иконками */

.mode-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-tile {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 12px 10px 11px;
  border: 2px solid var(--edge);
  border-radius: 16px;
  background: #fff;
  transition: 0.16s;
  text-align: center;
}

.mode-tile:hover {
  border-color: var(--edge2);
  background: #fffdf6;
}

.mode-tile .mode-ico {
  width: 100%;
  max-width: 176px;
  height: 62px;
  display: block;
}

.mode-ico .ico-gun path {
  fill: #6d776c;
}

.mode-ico .ico-mag,
.mode-ico .ico-grip,
.mode-ico .ico-guard {
  fill: #596358;
}

.mode-ico .ico-part rect {
  fill: var(--wood);
  stroke: #9a6512;
  stroke-width: 1.6;
}

.mode-ico .ico-arrow {
  fill: none;
  stroke: var(--ink2);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode-tile b {
  font-family: var(--font-head);
  font-size: 17px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}

.mode-tile i {
  font-style: normal;
  font-size: 11.5px;
  color: var(--ink3);
  line-height: 1.25;
}

.mode-tile.on {
  border-color: var(--wood);
  background: linear-gradient(180deg, #fffaea, #fff5dd);
  box-shadow: inset 0 0 0 2px rgba(232, 169, 44, 0.35);
}

.mode-tile.on b {
  color: var(--wood-d);
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
}

.record-pill {
  font-size: 12px;
  color: var(--ink3);
  border-left: 2px solid var(--edge2);
  padding-left: 10px;
  line-height: 1.35;
}

.record-pill b {
  color: var(--ink);
  font-size: 15px;
  font-family: var(--font-head);
  letter-spacing: 0.04em;
}

.btn {
  border-radius: 13px;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: 0.16s;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn.primary {
  background: linear-gradient(180deg, #fbc95f, var(--wood));
  color: #241a05;
  border-color: var(--wood-d);
  box-shadow: 0 12px 22px -14px rgba(193, 127, 31, 0.95);
}

.btn.primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn.ghost {
  border-color: var(--edge2);
  color: var(--ink2);
  background: #fff;
}

.btn.ghost:hover {
  color: var(--ink);
  background: #fffdf6;
}

.card .btn.primary {
  margin-left: auto;
}

/* зачётная книжка */

.book {
  position: relative;
  border: 1px solid var(--edge);
  border-radius: 20px;
  background: linear-gradient(180deg, #fffdf6, #fdf6e4);
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  box-shadow: 0 22px 40px -34px rgba(23, 32, 26, 0.85);
}

.book-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.book-mark {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  font-size: 21px;
  background: linear-gradient(160deg, #f6c455, var(--wood-d));
  box-shadow: 0 10px 18px -12px rgba(193, 127, 31, 1);
}

.book-ttl h3 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 17px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.book-ttl p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink3);
}

.book-prog {
  margin-left: auto;
  min-width: 168px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.book-prog b {
  font-family: var(--font-head);
  font-size: 20px;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.book-prog b s {
  font-size: 13px;
  color: var(--ink3);
  text-decoration: none;
}

.book-prog i {
  display: block;
  height: 8px;
  border-radius: 99px;
  background: #ece2cc;
  overflow: hidden;
}

.book-prog i s {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #f6c455, var(--wood));
}

.book-stat {
  font-size: 11.5px;
  color: var(--ink3);
  text-align: right;
  line-height: 1.3;
  padding-left: 14px;
  border-left: 1px solid var(--edge);
}

.book-stat b {
  font-family: var(--font-head);
  font-size: 18px;
  color: var(--ink);
}

.medals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 8px;
}

.medal {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px dashed var(--edge2);
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 12px;
  color: var(--ink3);
  background: #fffdf7;
}

.medal i {
  font-style: normal;
  font-size: 17px;
  line-height: 1;
  color: #c8bda6;
}

.medal b {
  font-weight: 600;
  line-height: 1.2;
}

.medal.got {
  border-style: solid;
  border-color: var(--wood);
  color: var(--ink);
  background: linear-gradient(180deg, #fffaea, #fdf1d5);
  box-shadow: 0 10px 18px -16px rgba(193, 127, 31, 0.9);
}

.medal.got i {
  color: var(--wood-d);
}

.hub-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink3);
}

/* ------------------------------------------------------------------ модалки */

.ov {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(24, 32, 26, 0.42);
  backdrop-filter: blur(3px);
  animation: fade 0.16s ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.ov-card {
  width: min(620px, 100%);
  max-height: 92dvh;
  overflow: auto;
  border: 1px solid var(--edge);
  border-radius: 20px;
  background: var(--card);
  padding: 22px 24px 20px;
  box-shadow: 0 40px 80px -40px rgba(20, 28, 22, 0.8);
  animation: pop 0.2s cubic-bezier(0.2, 1.2, 0.4, 1);
}

@keyframes pop {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
}

.ov-kicker {
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--wood-d);
}

.ov-card h2 {
  margin: 6px 0 10px;
  font-family: var(--font-head);
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ov-card p {
  margin: 0 0 10px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink2);
}

.ov-card p.ov-dim {
  color: var(--ink3);
}

.ov-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.ov-actions .btn {
  flex: 1 1 auto;
}

.ov-card.res.fail h2 {
  color: var(--bad);
}

.ov-card.res.fail .res-line {
  color: var(--bad);
}

.res-score {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin: 4px 0 14px;
}

.res-score b {
  font-family: var(--font-head);
  font-size: clamp(34px, 6vw, 52px);
  letter-spacing: 0.02em;
  color: var(--ink);
}

.res-score span {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
}

.res-score i {
  font-style: normal;
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--edge2);
  color: var(--ink2);
}

.res-score i.res-rec {
  background: linear-gradient(180deg, #fbc95f, var(--wood));
  border-color: var(--wood-d);
  color: #241a05;
  font-weight: 700;
}

.res-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.res-grid > div {
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 9px 10px;
  background: #fffdf7;
}

.res-grid span {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 3px;
}

.res-grid b {
  font-family: var(--font-head);
  font-size: 17px;
  color: var(--ink);
}

.res-passport {
  margin-top: 14px;
  border: 1px solid var(--edge);
  border-radius: 14px;
  overflow: hidden;
  background: #fffdf7;
}

.res-passport-head {
  padding: 9px 12px;
  font-family: var(--font-head);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink2);
  border-bottom: 1px solid var(--edge);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.res-passport-head span {
  color: var(--ink3);
}

.res-passport-rifle {
  padding: 12px;
  background: repeating-linear-gradient(135deg, #fbf7ec 0 12px, #f4eddd 12px 24px);
  display: grid;
  place-items: center;
}

.res-passport-rifle {
  position: relative;
  height: 272px;
  overflow: hidden;
}

.ak-whole-scene {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%) scale(0.38);
  transform-origin: top center;
}

.ak-whole-scene img {
  position: absolute;
  left: 0;
  top: 0;
}

.res-list {
  margin: 0;
  padding: 10px 12px 12px;
  list-style: none;
  font-size: 12.5px;
  color: var(--ink2);
  line-height: 1.7;
  max-height: 176px;
  overflow: auto;
  /* Десять шагов сборки в один столбец не влезали в паспорт: нижние пункты
     уезжали под срез, и их никто не листал. Две колонки по пять — влезают. */
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(5, auto);
  grid-auto-columns: 1fr;
  column-gap: 14px;
  align-content: start;
}

/* Разбивка по целям в итогах тира. Стилей не было вовсе: строки шли подряд,
   и «Курица», число и очки слипались в «Курица14140». */
.res-table {
  margin-top: 12px;
  padding: 6px 12px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: #fffdf7;
  display: grid;
  gap: 1px;
  max-height: 190px;
  overflow: auto;
}

.res-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 52px;
  gap: 10px;
  align-items: baseline;
  padding: 3px 0;
  font-size: 12.5px;
  color: var(--ink2);
  border-bottom: 1px dashed rgba(27, 39, 33, 0.08);
}

.res-row:last-child {
  border-bottom: 0;
}

.res-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.res-row b {
  font-family: var(--font-head);
  font-size: 13px;
  color: var(--ink);
}

.res-row em {
  font-style: normal;
  font-weight: 700;
  text-align: right;
  color: var(--wood-d);
}

.res-bonus {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink3);
}

/* Итоги: паспорт сжимается и листается, кнопки всегда внизу карточки */
.ov-card.res {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ov-card.res .res-passport {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ov-card.res .res-passport-rifle {
  flex: none;
  height: clamp(140px, 24vh, 272px);
}

.ov-card.res .res-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.ov-card.res .ov-actions {
  flex: none;
  margin-top: 12px;
}

.res-list li {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.res-list i {
  flex: none;
  width: 18px;
  font-style: normal;
  font-family: var(--font-head);
  font-size: 11px;
  color: var(--wood-d);
  text-align: right;
}

/* ------------------------------------------------------------------ тир */

/* ------------------------------------------------------------------ тир */

.tg {
  position: fixed;
  inset: 0;
  background: #101a15;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: none;
  z-index: 30;
}

.tg-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.tg button,
.tg .tg-overlay {
  cursor: pointer;
}

.tg-overlay {
  cursor: default;
}

.tg-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(6, 10, 8, 0.55) 100%);
}

.tg-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px clamp(10px, 2vw, 22px);
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, rgba(6, 12, 9, 0.7), transparent);
  pointer-events: none;
}

.tg-top > * {
  pointer-events: auto;
}

.tg-chip {
  display: flex;
  flex-direction: column;
  min-width: 78px;
  /* Без своего цвета цифры наследовали тёмный --ink и тонули на ночной плашке. */
  color: var(--cream);
  border: 1px solid rgba(233, 220, 184, 0.16);
  border-radius: 10px;
  padding: 5px 11px;
  background: rgba(10, 18, 13, 0.55);
  backdrop-filter: blur(4px);
}

.tg-chip span {
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.tg-chip b {
  font-family: var(--font-head);
  font-size: 21px;
  line-height: 1.05;
}

.tg-time {
  margin: 0 auto;
  font-family: var(--font-head);
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: 0.06em;
  padding: 2px 16px;
  border-radius: 10px;
  border: 1px solid rgba(233, 220, 184, 0.16);
  background: rgba(10, 18, 13, 0.5);
  color: #ffe9b8;
}

.tg-time.low {
  color: #ff9c86;
  border-color: rgba(207, 83, 64, 0.55);
  animation: pulse 0.9s infinite;
}

@keyframes pulse {
  50% {
    transform: scale(1.05);
  }
}

.tg-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  border: 1px solid rgba(233, 220, 184, 0.16);
  background: rgba(10, 18, 13, 0.55);
  font-size: 13px;
  letter-spacing: 0.1em;
}

.tg-icon:hover {
  background: rgba(224, 162, 60, 0.18);
}

.tg-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 12px clamp(10px, 2vw, 22px);
  padding-bottom: calc(12px + var(--safe));
  background: linear-gradient(0deg, rgba(6, 12, 9, 0.72), transparent);
}

.tg-mag {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  max-width: 46vw;
}

.tg-mag i {
  width: 6px;
  height: 17px;
  border-radius: 2px;
  background: rgba(233, 220, 184, 0.16);
  transition: 0.12s;
}

.tg-mag i.full {
  background: linear-gradient(180deg, #f6cd78, #c99433);
  box-shadow: 0 0 6px rgba(224, 162, 60, 0.5);
}

.tg-reload {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 15px;
  border: 1px solid rgba(233, 220, 184, 0.22);
  border-radius: 11px;
  background: rgba(10, 18, 13, 0.6);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tg-reload:hover {
  background: rgba(224, 162, 60, 0.16);
}

.tg.is-reloading .tg-reload {
  border-color: var(--amber);
  color: var(--amber2);
  animation: pulse 0.5s infinite;
}

.tg-combo {
  min-width: 74px;
  text-align: right;
  opacity: 0;
  transition: 0.15s;
}

.tg-combo b {
  display: block;
  font-family: var(--font-head);
  font-size: 26px;
  color: var(--amber2);
  line-height: 1;
}

.tg-combo span {
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.tg-combo:not(:empty) {
  opacity: 1;
}

.tg-banner {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translate(-50%, -8px);
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(12, 20, 15, 0.82);
  border: 1px solid rgba(233, 220, 184, 0.2);
  font-size: 14px;
  letter-spacing: 0.02em;
  text-align: center;
  max-width: min(680px, 92vw);
  opacity: 0;
  transition: 0.25s;
  pointer-events: none;
  z-index: 20;
}

.tg-banner.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.tg-banner.bonus {
  color: #ffe6a8;
  border-color: rgba(224, 162, 60, 0.6);
  box-shadow: 0 0 30px -8px rgba(224, 162, 60, 0.5);
}

.tg-banner.bad {
  color: #ffb3a4;
  border-color: rgba(207, 83, 64, 0.6);
}

.tg-banner.big {
  font-family: var(--font-head);
  font-size: clamp(30px, 6vw, 52px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 6px 30px;
  background: none;
  border: 0;
  color: var(--amber2);
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.7);
}

.tg-overlay {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: none;
}

.tg-overlay.show {
  display: block;
}


/* ------------------------------------------------------------------ автомат */

.ak {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(900px 420px at 50% 0%, #fffdf6, rgba(255, 253, 246, 0) 70%), var(--paper);
  color: var(--ink);
  touch-action: manipulation;
}

.ak-top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px clamp(10px, 2vw, 20px);
  border-bottom: 1px solid var(--edge);
  background: rgba(255, 253, 247, 0.92);
  backdrop-filter: blur(6px);
}

.ak-back {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: #fff;
  font-size: 19px;
  line-height: 1;
  color: var(--ink2);
  transition: 0.15s;
}

.ak-back:hover {
  color: var(--ink);
  border-color: var(--edge2);
}

.ak-task {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ak-stepno {
  font-family: var(--font-head);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--wood-d);
}

.ak-task b {
  font-family: var(--font-head);
  font-size: clamp(15px, 2vw, 21px);
  letter-spacing: 0.02em;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ak-meters {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex: none;
}

.ak-meter {
  min-width: 74px;
  border: 1px solid var(--edge);
  border-radius: 11px;
  padding: 5px 10px;
  background: #fff;
  text-align: center;
}

.ak-meter span {
  display: block;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink3);
}

.ak-meter b {
  font-family: var(--font-head);
  font-size: 16px;
  color: var(--ink);
  letter-spacing: 0.03em;
}

.ak-meter.low b {
  color: var(--bad);
}

.ak-meter.off {
  opacity: 0.55;
}

.ak-icon {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: #fff;
  color: var(--ink2);
  font-size: 12px;
  letter-spacing: 0.06em;
}

.ak-icon:hover {
  color: var(--ink);
  border-color: var(--edge2);
}

/* сцена */

.ak-stage {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px clamp(8px, 1.6vw, 18px) 0;
}

.ak-board {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
}

/* Фиксированный холст сцены (координаты референса), масштабируется целиком. */
.ak-scene-box {
  position: relative;
  flex: none;
}

.ak-scene {
  position: absolute;
  left: 0;
  top: 0;
  width: 1330px;
  height: 693px;
  transform-origin: 0 0;
}

.ak-static {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.ak-sightblock {
  pointer-events: none;
}

/* Снимаемая деталь: лежит на столе или стоит на автомате. */
.ak-piece {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transform-origin: 50% 50%;
  transition: transform 0.62s cubic-bezier(0.22, 0.9, 0.24, 1), filter 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.ak-piece.hidden {
  display: none;
}

.ak-piece.flying {
  opacity: 0;
}

.ak-piece img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Мелкие детали (затвор, шомпол) на телефоне выходят 30–40 px: добавляем
   невидимые 8 px вокруг, иначе в них трудно попасть пальцем. */
.ak-piece::after {
  content: '';
  position: absolute;
  inset: -8px;
}

/* Поставленная деталь лежит на автомате, а не наклеена поверх: мягкая тень
   под ней убирает ощущение аппликации на стыке. */
.ak-piece.on,
.ak-static {
  filter: drop-shadow(0 2px 3px rgba(26, 32, 24, 0.22));
}

.ak-whole-scene img {
  filter: drop-shadow(0 2px 2px rgba(26, 32, 24, 0.2));
}

.ak-piece:hover {
  filter: drop-shadow(0 6px 9px rgba(24, 26, 20, 0.28));
}

.ak-piece.sel {
  filter: drop-shadow(0 0 5px rgba(232, 169, 44, 0.95)) drop-shadow(0 8px 14px rgba(24, 26, 20, 0.3));
  z-index: 60 !important;
}

.ak-piece.need {
  animation: pieceNeed 1.5s ease-in-out infinite;
}

@keyframes pieceNeed {
  50% {
    filter: drop-shadow(0 0 6px rgba(232, 169, 44, 1)) drop-shadow(0 0 16px rgba(232, 169, 44, 0.55));
  }
}

/* «Новичок»: контур без пульсации — подсказка есть, анимации нет */
.ak-piece.need-soft {
  filter: drop-shadow(0 0 4px rgba(232, 169, 44, 0.95)) drop-shadow(0 0 12px rgba(232, 169, 44, 0.35));
}

.ak-piece.just {
  animation: pieceJust 0.55s ease-out;
}

@keyframes pieceJust {
  0% {
    filter: brightness(1.45) drop-shadow(0 0 10px rgba(47, 125, 79, 0.7));
  }
  100% {
    filter: none;
  }
}

/* Спусковой крючок */
.ak-zone {
  position: absolute;
  border-radius: 12px;
  border: 2px dashed transparent;
  background: transparent;
  transition: 0.18s;
  pointer-events: auto;
  cursor: default;
}

.ak[data-need='trigger'] .ak-zone {
  border-color: var(--wood);
  background: rgba(232, 169, 44, 0.16);
  box-shadow: 0 0 0 6px rgba(232, 169, 44, 0.12);
  animation: zonePulse 1.6s ease-in-out infinite;
  cursor: pointer;
}

@keyframes zonePulse {
  50% {
    box-shadow: 0 0 0 12px rgba(232, 169, 44, 0.05);
  }
}

.ak-zone.just {
  background: rgba(47, 125, 79, 0.22);
  border-color: var(--ok);
}

/* Полёт внутренней детали между разрезом и столом */
.ak-drag-ghost {
  position: fixed;
  z-index: 120;
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 14px 20px rgba(20, 26, 20, 0.35));
}

.ak-piece.dragging {
  opacity: 0.25;
}

.ak-fly {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  transition: left 0.5s cubic-bezier(0.3, 0.9, 0.3, 1), top 0.5s cubic-bezier(0.3, 0.9, 0.3, 1),
    width 0.5s ease, height 0.5s ease, opacity 0.5s ease;
}

/* разрез ствольной коробки */

.ak-cut {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px 3px 10px;
  border: 1px solid var(--edge);
  border-radius: 11px;
  background: #fff;
}

.ak-cut[hidden] {
  display: none;
}

.ak-cut-cap {
  font-family: var(--font-head);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink3);
  white-space: nowrap;
}

.ak-cut-slots {
  display: flex;
  gap: 6px;
}

.ak-slot {
  position: relative;
  width: 62px;
  height: 34px;
  border: 1px dashed var(--edge2);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  background: #fff;
  cursor: default;
  overflow: hidden;
}

.ak-slot img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  opacity: 0.18;
  filter: grayscale(1);
  transition: 0.25s;
  pointer-events: none;
}

.ak-slot.on {
  border-style: solid;
  border-color: var(--wood);
  background: #fffaea;
  cursor: pointer;
}

.ak-slot.on img {
  opacity: 1;
  filter: none;
}

.ak-slot.need {
  animation: slotNeed 1.4s ease-in-out infinite;
}

@keyframes slotNeed {
  50% {
    box-shadow: 0 0 0 5px rgba(232, 169, 44, 0.25);
    border-color: var(--wood);
  }
}

.ak-slot.need-soft {
  border-color: var(--wood);
  box-shadow: 0 0 0 4px rgba(232, 169, 44, 0.22);
}

/* полоса шагов */


.ak-rail {
  flex: none;
  display: flex;
  justify-content: center;
  gap: 5px;
  padding-bottom: 2px;
}

.ak-rail i {
  width: 22px;
  height: 6px;
  border-radius: 99px;
  background: #e2d8c2;
  transition: 0.2s;
}

.ak-rail i.done {
  background: var(--wood);
}

.ak-rail i.now {
  background: var(--ink);
  width: 30px;
}

/* склад */

.ak-tray-wrap {
  flex: 0 0 auto;
  height: min(31vh, 258px);
  min-height: 168px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px clamp(10px, 2vw, 22px) calc(8px + var(--safe));
  border-top: 1px solid var(--edge);
  background: linear-gradient(180deg, #fffdf7, #fbf6e9);
}

.ak-tray-wrap.is-empty {
  height: auto;
  min-height: 0;
}

.ak-tray-wrap.is-empty .ak-field {
  display: none;
}

.ak-tray-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  flex: none;
}

.ak-tray-head b {
  font-family: var(--font-head);
  font-size: 12.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--wood-d);
}

.ak-tray-head em {
  font-style: normal;
  font-size: 12px;
  color: var(--ink3);
}

.ak-poster-btn {
  border: 1px solid var(--edge);
  background: #fff;
  border-radius: 9px;
  padding: 5px 11px;
  font-size: 11.5px;
  color: var(--ink2);
}

.ak-field {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.ak-item {
  position: absolute;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 7px 6px 5px;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, #fdf9ee);
  box-shadow: 0 8px 16px -12px rgba(23, 32, 26, 0.85);
  transition: box-shadow 0.16s, border-color 0.16s, transform 0.16s;
  overflow: hidden;
}

.ak-item:hover {
  border-color: var(--edge2);
  box-shadow: 0 12px 20px -12px rgba(23, 32, 26, 0.7);
  z-index: 2;
}

.ak-pic {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.ak-pic .ak-ico {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.ak-name {
  flex: none;
  width: 100%;
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
  color: var(--ink2);
  max-height: 2.35em;
  overflow: hidden;
  word-break: break-word;
  hyphens: auto;
}

.ak-item.sel {
  border-color: var(--wood);
  box-shadow: 0 0 0 3px rgba(232, 169, 44, 0.35), 0 12px 20px -12px rgba(23, 32, 26, 0.6);
  z-index: 3;
}

.ak-item.used {
  transform: translate(-50%, -50%) scale(0.9);
  opacity: 0;
  pointer-events: none;
}

.ak-item.need {
  border-color: var(--wood);
  box-shadow: 0 0 0 4px rgba(232, 169, 44, 0.4);
  animation: needPulse 1.5s ease-in-out infinite;
  z-index: 2;
}

@keyframes needPulse {
  50% {
    box-shadow: 0 0 0 9px rgba(232, 169, 44, 0.14);
  }
}

.ak-tray-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: 13px;
  color: var(--ink3);
}

/* «курсор» с выбранной деталью */

.ak-float {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 45;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.14s;
}

.ak-float.show {
  opacity: 1;
}

.ak-float-in {
  transform: translate(-50%, -60%);
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
  padding: 8px;
  border-radius: 16px;
  border: 2px solid var(--wood);
  background: rgba(255, 253, 247, 0.96);
  box-shadow: 0 20px 34px -20px rgba(23, 32, 26, 0.85);
}

.ak-float-in .ak-ico {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

.ak-toast {
  position: absolute;
  left: 50%;
  bottom: 46px;
  transform: translate(-50%, 12px);
  z-index: 40;
  max-width: min(560px, 86vw);
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: rgba(255, 253, 247, 0.98);
  box-shadow: 0 18px 30px -22px rgba(20, 28, 22, 0.9);
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
}

.ak-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.ak-toast.bad {
  border-color: #e3b1a6;
  background: #fdf0ec;
  color: #7c2f21;
}

.ak-toast.note {
  border-color: var(--wood);
  background: #fffaea;
}

.ak.shake {
  animation: shake 0.36s;
}

@keyframes shake {
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(5px);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(2px);
  }
}

.ak-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
}

.ak-overlay.show {
  display: block;
}

.poster-ov .ov-card {
  width: min(1000px, 100%);
}

.poster-box {
  position: relative;
  border: 1px solid var(--edge);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  display: grid;
  place-items: center;
}

.poster-box img {
  display: block;
  max-width: 100%;
  max-height: min(58vh, 620px);
  width: auto;
  height: auto;
}

.poster-cap {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--ink2);
}

/* значки деталей: серый металл и чёрный контур, как на референсе */

.ak-ico .m {
  fill: #6f776e;
  stroke: #141a16;
  stroke-width: 2.2;
  stroke-linejoin: round;
}

.ak-ico .ln {
  fill: none;
  stroke: #141a16;
  stroke-width: 2;
  stroke-linecap: round;
}

.ak-ico .spring {
  stroke-width: 2.4;
}

.ak-ico .wood {
  fill: var(--wood);
  stroke: #141a16;
  stroke-width: 2.2;
}

@media (max-width: 900px) and (orientation: portrait) {
  .ak-stage {
    flex: 1 1 0;
  }
  .ak-board {
    flex: 1 1 0;
    height: auto;
  }
  .ak-tray-wrap {
    flex: 0 0 auto;
    height: 30vh;
    min-height: 150px;
  }
  .ak-toast {
    top: auto;
    bottom: 6px;
  }
  .ak-cut-cap {
    display: none;
  }
}

@media (max-width: 720px) {
  .res-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .mode-pick {
    grid-template-columns: 1fr;
  }
  .ak-tray-wrap {
    height: 30vh;
  }
  .ak-meter {
    min-width: 62px;
    padding: 4px 7px;
  }
  .ak-meter b {
    font-size: 14px;
  }
  .ak-cut {
    transform: scale(0.86);
    transform-origin: left bottom;
  }

  /* На узком экране две колонки списка не читаются — снова один столбец.
     Кегль меньше, чтобы все десять шагов влезли без прокрутки. */
  .res-list {
    grid-auto-flow: row;
    grid-template-rows: none;
    grid-template-columns: 1fr;
    font-size: 11.5px;
    line-height: 1.38;
    padding: 6px 10px 8px;
  }

  /* Паспорт автомата: сцена 1330 px в карточку 350 px не влезала — ствол
     и штык уезжали под срез. */
  .ak-whole-scene {
    transform: translateX(-50%) scale(0.32);
  }

  /* На телефоне карточка ниже: рисунок автомата отдаёт высоту списку шагов,
     иначе десятый шаг («Штык-нож») оставался за срезом. */
  .ov-card.res .res-passport-rifle {
    height: clamp(120px, 18vh, 272px);
  }
}

@media (max-width: 460px) {
  .ak-whole-scene {
    transform: translateX(-50%) scale(0.245);
  }
}

/* Телефон: в шапке не помещались сразу «шаг», задание и два счётчика —
   задание обрезалось до «Присоединить г…». Номер шага уводим в полосу шагов,
   подписи счётчиков прячем, задание переносим на две строки. */
@media (max-width: 620px) {
  .ak-top {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    grid-template-areas:
      'back task pause'
      'meters meters meters';
    gap: 8px;
    padding: 8px 10px;
  }

  .ak-back {
    grid-area: back;
  }

  .ak-task {
    grid-area: task;
  }

  .ak-icon {
    grid-area: pause;
  }

  .ak-stepno {
    display: none;
  }

  .ak-task b {
    font-size: 13px;
    line-height: 1.25;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .ak-meters {
    grid-area: meters;
    margin-left: 0;
    gap: 8px;
  }

  .ak-meter {
    flex: 1 1 0;
    min-width: 0;
    padding: 4px 8px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
  }

  .ak-meter b {
    font-size: 15px;
  }

  /* На телефоне склад выше: на «Экзамене» 20 плиток в прежние 260 px
     не влезали и нижний ряд уезжал под срез. */
  .ak-tray-wrap {
    height: min(42vh, 320px);
  }

  /* Названия предметов в плитках 48–54 px не влезают: «Кроссовок» рвётся
     на две строки. На телефоне оставляем картинку — имя есть в aria-label. */
  .ak-name {
    display: none;
  }

  /* «Внутри коробки» без подписи читается как три пустых квадрата. */
  .ak-cut {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
    transform: none;
  }

  .ak-cut-cap {
    display: block;
    font-size: 9px;
    letter-spacing: 0.1em;
  }
}
