/* РЖАВЫЙ ПЕРИМЕТР — ретро-постапокалиптический полевой терминал */

:root {
  --surface: #17140f;
  --ink: #ece0c9;
  --primary: #d08a3e;
  --on-primary: #17140f;
  --accent: #8f9c74;
  --on-accent: #17140f;
  --danger: #a8452c;
  --dust: #6f6553;
  --panel: #211c14;
  --panel-2: #191510;
  --panel-3: #2a2318;
  --line: #3a3225;
  --line-hot: #5c4a2b;
  --font-display: 'Russo One', 'PT Sans', system-ui, sans-serif;
  --font-body: 'PT Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;
  --radius: 3px;
  --shadow-panel: inset 0 1px 0 rgba(236, 224, 201, 0.06), 0 18px 40px -28px #000;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 620px at 78% -10%, rgba(208, 138, 62, 0.13), transparent 60%),
    radial-gradient(900px 520px at 8% 108%, rgba(143, 156, 116, 0.09), transparent 62%),
    linear-gradient(180deg, #1a1610 0%, #14110c 42%, #100d09 100%);
  background-color: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 0.32;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

/* ── ПРИБОРНАЯ ПАНЕЛЬ ─────────────────────────────────────────── */

.rig {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px clamp(12px, 2.4vw, 28px);
  background: linear-gradient(180deg, #231d14 0%, #1a1610 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px -18px #000;
}

.rig::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 4px;
  background: repeating-linear-gradient(90deg, #3a3225 0 18px, #241f17 18px 36px);
  opacity: 0.7;
}

.rig__brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.rig__mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--primary);
  border: 1px solid var(--line-hot);
  border-radius: 2px;
  background: repeating-linear-gradient(45deg, #241f16 0 6px, #1d1811 6px 12px);
  box-shadow: inset 0 0 0 2px #17130d;
}

.rig__title {
  font-family: var(--font-display);
  font-size: clamp(13px, 1.5vw, 17px);
  letter-spacing: 0.09em;
  line-height: 1.1;
  color: var(--ink);
  white-space: nowrap;
}

.rig__sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--dust);
  text-transform: uppercase;
}

.rig__meters { display: flex; gap: clamp(8px, 2vw, 26px); margin-left: auto; }

.meter { display: flex; flex-direction: column; gap: 1px; min-width: 54px; }
.meter span {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--dust);
}
.meter b {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.rig__inv { white-space: nowrap; }
.rig__inv-label { font-size: 11px; }

.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dust);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 2px;
  background: #1b1610;
}

/* ── КНОПКИ ───────────────────────────────────────────────────── */

.btn {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 10px 14px;
  border: 1px solid var(--line-hot);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #2c2519 0%, #201a12 100%);
  color: var(--ink);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.06s;
  box-shadow: inset 0 1px 0 rgba(236, 224, 201, 0.07);
}
.btn:hover { color: #fff; border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn--primary {
  background: linear-gradient(180deg, #e2a559 0%, #c27b30 62%, #a5651f 100%);
  border-color: #f0c17a;
  color: var(--on-primary);
  text-shadow: 0 1px 0 rgba(255, 226, 180, 0.4);
  box-shadow: inset 0 0 0 1px #6a4a20, 0 8px 22px -10px rgba(208, 138, 62, 0.75);
}
.btn--primary:hover { color: #1b1409; border-color: #ffe0ad; }
.btn--big { padding: 15px 34px; font-size: 14px; letter-spacing: 0.1em; }
.btn--ghost { background: transparent; border-color: var(--line); }
.btn--toggle { flex: 1; background: #1b1610; color: var(--dust); }
.btn--toggle.is-active {
  color: var(--primary);
  border-color: var(--primary);
  background: linear-gradient(180deg, #3a2c18, #2a2013);
  box-shadow: inset 0 0 12px rgba(208, 138, 62, 0.18);
}

/* ── ПАНЕЛИ ───────────────────────────────────────────────────── */

.plate {
  position: relative;
  padding: 16px 16px 18px;
  background: linear-gradient(180deg, #241f17 0%, #1c1811 58%, #191510 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}
.plate::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(circle at 9px 9px, rgba(236,224,201,0.20) 0 1.6px, transparent 2.1px),
    radial-gradient(circle at calc(100% - 9px) 9px, rgba(236,224,201,0.13) 0 1.6px, transparent 2.1px),
    radial-gradient(circle at 9px calc(100% - 9px), rgba(236,224,201,0.13) 0 1.6px, transparent 2.1px),
    radial-gradient(circle at calc(100% - 9px) calc(100% - 9px), rgba(236,224,201,0.2) 0 1.6px, transparent 2.1px);
  opacity: 0.85;
}

.plate__title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--ink);
}
.plate__title i {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  color: var(--primary);
  border: 1px solid var(--line-hot);
  border-radius: 2px;
  background: #16120c;
}
.plate__hint {
  margin: -4px 0 12px;
  font-size: 13px;
  color: var(--dust);
}
.plate__hint b { color: var(--primary); font-family: var(--font-mono); }
.plate__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--primary);
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 12px;
}
.plate__code { font-family: var(--font-mono); font-size: 11px; color: var(--dust); }

/* ── СКРИНЫ ───────────────────────────────────────────────────── */

#app { padding: clamp(12px, 2vw, 22px) clamp(12px, 2.4vw, 28px) 28px; }
.screen { animation: screen-in 0.28s ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── СОЗДАНИЕ ГЕРОЯ ───────────────────────────────────────────── */

.build-grid {
  display: grid;
  grid-template-columns: minmax(290px, 350px) minmax(0, 1fr);
  gap: clamp(12px, 1.6vw, 20px);
  align-items: start;
}

.dossier { position: sticky; top: 76px; }

.plate--dossier { padding-bottom: 14px; }

.figure {
  position: relative;
  display: grid;
  place-items: center;
  padding: 6px 0 2px;
  background:
    radial-gradient(60% 52% at 50% 62%, rgba(208, 138, 62, 0.16), transparent 70%),
    repeating-linear-gradient(0deg, rgba(236,224,201,0.035) 0 1px, transparent 1px 4px);
  border: 1px solid #2c2519;
  border-radius: 2px;
  overflow: hidden;
}
.figure::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 62%, rgba(12, 10, 7, 0.72) 100%);
}
.figure__glow {
  position: absolute;
  width: 170px; height: 170px;
  border-radius: 50%;
  border: 1px dashed rgba(208, 138, 62, 0.22);
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.figure__glow::after {
  content: "";
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  border: 1px solid rgba(143, 156, 116, 0.14);
}
#hero-figure {
  position: relative;
  z-index: 1;
  width: 200px;
  height: 250px;
  max-width: 100%;
  display: block;
}
.figure__tape {
  position: absolute;
  z-index: 2;
  left: 10px; bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--primary);
  background: rgba(15, 12, 8, 0.86);
  border: 1px solid var(--line-hot);
  transform: rotate(-1.4deg);
}
.figure__tape b { font-size: 15px; }
.figure__tape i { font-style: normal; color: var(--dust); }

.figure__caption {
  margin: 10px 0 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-align: center;
  text-transform: uppercase;
}

.plate__stats { display: grid; gap: 6px; margin-bottom: 14px; }

.pstat { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 12px; }
.pstat span { color: var(--dust); min-width: 108px; letter-spacing: 0.04em; }
.pstat b { color: var(--ink); font-size: 14px; min-width: 20px; text-align: right; }
.pstat i {
  flex: 1;
  height: 6px;
  background: #120f0a;
  border: 1px solid #2c2519;
  position: relative;
  overflow: hidden;
}
.pstat i s {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  background: repeating-linear-gradient(90deg, var(--primary) 0 5px, #9a6528 5px 7px);
  text-decoration: none;
}
.pstat--key span { color: var(--accent); }
.pstat--key i s { background: repeating-linear-gradient(90deg, var(--accent) 0 5px, #6b7556 5px 7px); }

.gauge {
  padding: 10px 11px;
  border: 1px solid var(--line-hot);
  border-radius: 2px;
  background: linear-gradient(180deg, #2a2318, #1d1811);
  box-shadow: inset 0 0 18px rgba(208, 138, 62, 0.1);
}
.gauge__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--dust);
  text-transform: uppercase;
}
.gauge__head b { font-size: 15px; color: var(--primary); letter-spacing: 0; }
.gauge__ticks {
  height: 14px;
  margin: 8px 0;
  background-image: repeating-linear-gradient(90deg, var(--line-hot) 0 1px, transparent 1px 9px);
  border-bottom: 1px solid var(--line-hot);
  position: relative;
}
.gauge__ticks::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: calc(var(--fill, 45%) - 6px);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 8px solid var(--primary);
  transition: left 0.25s ease;
}
.gauge__note { font-size: 12px; line-height: 1.35; color: var(--dust); }

/* опции внешности */
.opt-grid { display: grid; gap: 14px; }
.opt-row { display: grid; grid-template-columns: 138px minmax(0, 1fr); gap: 12px; align-items: center; }
.opt-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--dust);
}
.opts { display: flex; flex-wrap: wrap; gap: 6px; }

.opt input, .swatch input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.opt, .swatch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--dust);
  border: 1px solid var(--line);
  border-radius: 2px;
  background: linear-gradient(180deg, #211b13, #191510);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  user-select: none;
}
.opt:hover, .swatch:hover { color: var(--ink); border-color: var(--line-hot); }
.opt input:checked + span, .swatch input:checked + span { color: var(--primary); }
.opt:has(input:checked), .swatch:has(input:checked) {
  border-color: var(--primary);
  background: linear-gradient(180deg, #3a2c18, #241c11);
  box-shadow: inset 0 0 14px rgba(208, 138, 62, 0.18);
}
.opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }

.swatch { padding-left: 8px; }
.swatch::before {
  content: "";
  width: 15px; height: 15px;
  border-radius: 2px;
  background: var(--sw);
  border: 1px solid rgba(0, 0, 0, 0.55);
  box-shadow: inset 0 0 0 1px rgba(236, 224, 201, 0.16);
}
.swatch input:checked + span::after { content: " ✓"; }

/* параметры */
.stat-rows { display: grid; gap: 10px; }
.stat {
  display: grid;
  grid-template-columns: minmax(130px, 190px) 34px minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid #2c2519;
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(42, 35, 24, 0.55), rgba(24, 20, 14, 0.55));
}
.stat--key { border-color: var(--line-hot); background: linear-gradient(180deg, rgba(58, 46, 26, 0.6), rgba(28, 23, 15, 0.7)); }
.stat__name { display: flex; flex-direction: column; gap: 2px; }
.stat__name b {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink);
}
.stat__name span { font-family: var(--font-mono); font-size: 10px; color: var(--dust); line-height: 1.25; }
.stat--key .stat__name b { color: var(--accent); }
.stat__btn {
  width: 34px; height: 30px;
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1;
  border: 1px solid var(--line-hot);
  border-radius: 2px;
  background: #221c14;
  color: var(--ink);
  cursor: pointer;
}
.stat__btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.stat__btn:disabled { opacity: 0.35; cursor: not-allowed; }
.stat__value {
  font-family: var(--font-mono);
  font-size: 19px;
  line-height: 1;
  text-align: center;
  color: var(--primary);
  letter-spacing: 0.02em;
}
.stat__bar { display: flex; gap: 3px; align-items: center; grid-column: 1 / -1; }
.stat__pip { flex: 1; height: 7px; background: #120f0a; border: 1px solid #2c2519; }
.stat__pip.is-on { background: linear-gradient(180deg, #d08a3e, #8f5c22); border-color: #8a5c25; }
.stat--key .stat__pip.is-on { background: linear-gradient(180deg, #9fae82, #66714f); border-color: #66714f; }

/* арсенал */
.weapon-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.wcard {
  position: relative;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: linear-gradient(180deg, #221c14, #181410);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.wcard:hover, .wcard:focus-visible { border-color: var(--line-hot); background: linear-gradient(180deg, #2a2318, #1c1811); }
.wcard.is-selected { border-color: var(--primary); box-shadow: inset 0 0 0 1px rgba(208, 138, 62, 0.35), inset 0 0 22px rgba(208, 138, 62, 0.1); }
.wcard.is-selected::after {
  content: "В РУКАХ";
  position: absolute;
  top: -1px; right: -1px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--on-primary);
  background: var(--primary);
}
.wcard__icon {
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(0deg, rgba(236,224,201,0.04) 0 1px, transparent 1px 4px),
    radial-gradient(60% 60% at 50% 50%, #2e2a22, #17140f);
  border: 1px solid #2c2519;
  border-radius: 2px;
  min-height: 58px;
}
.wcard__icon svg { width: 66px; height: 40px; display: block; }
.wcard__main { display: block; min-width: 0; }
.wcard__name, .wcard__sub { display: block; }
.wcard__name {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink);
  line-height: 1.2;
}
.wcard__sub { font-family: var(--font-mono); font-size: 10px; color: var(--dust); margin-top: 2px; }
.wcard__chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  color: var(--accent);
  border: 1px solid #3b4432;
  border-radius: 2px;
  background: rgba(143, 156, 116, 0.08);
}
.wcard__detail {
  grid-column: 1 / -1;
  display: grid;
  gap: 3px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.22s ease, opacity 0.18s ease, margin 0.22s ease;
}
.wcard:hover .wcard__detail, .wcard:focus-within .wcard__detail, .wcard.is-open .wcard__detail {
  max-height: 120px;
  opacity: 1;
  margin-top: 6px;
}
.wcard__detail div { display: flex; justify-content: space-between; gap: 8px; font-family: var(--font-mono); font-size: 10px; color: var(--dust); }
.wcard__detail b { color: var(--ink); font-weight: 500; }

/* памятка */
.plate--memo .memo { display: grid; gap: 8px; }
.memo li { font-size: 13.5px; color: #cbbfa9; padding-left: 16px; position: relative; }
.memo li::before { content: "▸"; position: absolute; left: 0; color: var(--primary); }
.memo b { color: var(--ink); }
.memo .kbd { min-width: 16px; height: 16px; font-size: 9px; margin-left: 2px; }

.cta-bar {
  position: sticky;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(23, 20, 15, 0.6), #17140f 55%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(4px);
}
.cta-bar__note { font-size: 13px; color: var(--dust); max-width: 640px; }
.cta-bar .btn--big { margin-left: auto; }

/* ── ЗАГРУЗКА ─────────────────────────────────────────────────── */

.screen--loading { display: grid; place-items: center; min-height: calc(100vh - 150px); }
.loader {
  width: min(520px, 100%);
  padding: 28px;
  text-align: center;
  border: 1px solid var(--line-hot);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #241f17, #17140f);
  box-shadow: 0 40px 90px -60px #000;
}
.loader__dial { position: relative; width: 92px; height: 92px; margin: 0 auto 18px; }
.loader__dial i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px dashed rgba(208, 138, 62, 0.4);
  animation: spin 6s linear infinite;
}
.loader__dial i:nth-child(2) { inset: 14px; border-style: solid; border-color: rgba(143, 156, 116, 0.35); animation-duration: 4s; animation-direction: reverse; }
.loader__dial i:nth-child(3) { inset: 30px; border-color: rgba(208, 138, 62, 0.6); animation-duration: 2.4s; }
.loader__dial i:nth-child(3)::after {
  content: "";
  position: absolute;
  top: -3px; left: 50%;
  width: 6px; height: 6px;
  margin-left: -3px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 12px 2px rgba(208, 138, 62, 0.7);
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader__title { font-family: var(--font-display); font-size: clamp(15px, 2.4vw, 20px); letter-spacing: 0.1em; }
.loader__status { margin-top: 8px; font-family: var(--font-mono); font-size: 13px; color: var(--accent); min-height: 20px; }
.loader__bar {
  height: 10px;
  margin: 18px 0 14px;
  background: #120f0a;
  border: 1px solid var(--line);
  position: relative;
}
.loader__bar i {
  position: absolute;
  inset: 1px auto 1px 1px;
  width: 4%;
  background: repeating-linear-gradient(90deg, var(--primary) 0 8px, #9a6528 8px 12px);
  transition: width 0.16s linear;
}
.loader__radio { font-family: var(--font-mono); font-size: 11px; color: var(--dust); letter-spacing: 0.04em; }

/* ── БОЙ ──────────────────────────────────────────────────────── */

.screen--battle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 336px;
  gap: 14px;
  align-items: start;
}

.stage {
  position: relative;
  height: clamp(420px, calc(100vh - 150px), 780px);
  border: 1px solid var(--line-hot);
  border-radius: var(--radius);
  overflow: hidden;
  background: #12100b;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.8), 0 22px 50px -34px #000;
  touch-action: manipulation;
}
.stage__sky { position: absolute; inset: 0; }
.sky { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.62; }
.stage__haze {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(80% 60% at 50% 100%, rgba(23, 20, 15, 0.2), rgba(23, 20, 15, 0.86) 78%),
    linear-gradient(180deg, rgba(23, 20, 15, 0.35), rgba(23, 20, 15, 0.06) 40%, rgba(23, 20, 15, 0.55));
  pointer-events: none;
}
.stage__haze::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  opacity: 0.55;
}
.stage__mount { position: absolute; inset: 0; }
.stage__mount canvas { display: block; width: 100%; height: 100%; }

.stage__tag {
  position: absolute;
  top: 12px; left: 12px;
  max-width: min(58%, 380px);
  padding: 7px 11px 8px;
  background: linear-gradient(180deg, rgba(36, 31, 23, 0.92), rgba(20, 16, 11, 0.92));
  border: 1px solid var(--line-hot);
  border-left: 3px solid var(--primary);
  box-shadow: 0 10px 24px -18px #000;
}
.stage__sector {
  display: block;
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--ink);
}
.stage__tagline {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-style: normal;
  color: var(--dust);
}
.stage__hint {
  position: absolute;
  right: 12px; top: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: rgba(236, 224, 201, 0.55);
  text-transform: uppercase;
  text-align: right;
}

/* латунный угломер — приборная строка */
.aim {
  position: absolute;
  left: 12px; bottom: 12px;
  width: 246px;
  padding: 8px 10px 9px;
  background: linear-gradient(180deg, rgba(45, 37, 24, 0.95), rgba(21, 17, 11, 0.96));
  border: 1px solid #6b542c;
  border-radius: 2px;
  box-shadow: 0 14px 30px -20px #000, inset 0 0 22px rgba(208, 138, 62, 0.12);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.aim::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(208, 138, 62, 0.18);
  border-radius: 1px;
  pointer-events: none;
}
.aim.is-live { border-color: var(--primary); box-shadow: 0 14px 30px -20px #000, inset 0 0 26px rgba(208, 138, 62, 0.24); }
.aim__title {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.18em;
  color: #b08c56;
  margin-bottom: 5px;
}
.aim__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.aim__cell { display: flex; flex-direction: column; gap: 1px; }
.aim__cell span { font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.1em; color: var(--dust); }
.aim__cell b { font-family: var(--font-mono); font-size: 19px; line-height: 1; color: var(--ink); font-weight: 600; }
.aim__cell--pen b { color: var(--danger); }
.aim.is-live .aim__cell b { color: var(--primary); }
.aim.is-live .aim__cell--pen b { color: #e07a58; }
.aim__breakdown {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px dashed rgba(208, 138, 62, 0.25);
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.35;
  color: var(--dust);
}

.crate-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  padding: 6px 9px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink);
  background: rgba(20, 16, 11, 0.95);
  border: 1px solid var(--accent);
  border-radius: 2px;
  transform: translate(-50%, -130%);
  white-space: nowrap;
  box-shadow: 0 8px 20px -12px #000;
}
.crate-tip b { color: var(--accent); }

/* правая колонка боя */
.battle-panel { display: grid; gap: 12px; align-content: start; }

.turn-card {
  padding: 12px;
  border: 1px solid var(--line-hot);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #262015, #191510);
  box-shadow: var(--shadow-panel);
}
.turn-card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.turn-card__label {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.11em;
  color: var(--primary);
}
.turn-card__turn { font-family: var(--font-mono); font-size: 10px; color: var(--dust); }
.turn-card.is-enemy .turn-card__label { color: var(--danger); }

.ap { display: flex; gap: 5px; margin: 9px 0 10px; flex-wrap: wrap; }
.ap i {
  width: 22px; height: 12px;
  background: #16120c;
  border: 1px solid #4a3f2c;
  transform: skewX(-18deg);
}
.ap i.is-on { background: linear-gradient(180deg, #e2a559, #b3732c); border-color: #f0c17a; box-shadow: 0 0 8px rgba(208, 138, 62, 0.4); }

.turn-card__weapon {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #17130d;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dust);
}
.turn-card__weapon b { color: var(--ink); font-size: 11px; display: block; letter-spacing: 0.02em; }
.turn-card__weapon span { color: var(--accent); white-space: nowrap; }
.turn-card__weapon .wc-ammo b { color: var(--primary); }

.turn-card__btns { display: flex; flex-wrap: wrap; gap: 6px; }
.turn-card__btns .btn { flex: 1 1 45%; }
.turn-card__btns #btn-end-turn { flex-basis: 100%; }

.inline-msg {
  min-height: 17px;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--danger);
}
.inline-msg.is-ok { color: var(--accent); }

.plate--stats { padding: 0; overflow: hidden; }
.plate--stats summary {
  padding: 10px 12px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.09em;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  background: linear-gradient(180deg, #262015, #1c1710);
  border-bottom: 1px solid transparent;
}
.plate--stats summary::-webkit-details-marker { display: none; }
.plate--stats summary::after { content: "▾"; float: right; color: var(--primary); }
.plate--stats[open] summary { border-bottom-color: var(--line); }
.plate--stats[open] summary::after { content: "▴"; }
#battle-stats { padding: 10px 12px 12px; }

.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; }
.mini { display: flex; justify-content: space-between; gap: 6px; font-family: var(--font-mono); font-size: 11px; }
.mini span { color: var(--dust); letter-spacing: 0.04em; }
.mini b { color: var(--ink); }
.mini--key span { color: var(--accent); }
.mini--key b { color: var(--accent); }
.mini--hp b { color: #e07a58; }

.plate--log { padding-bottom: 10px; }
.log { display: grid; gap: 4px; max-height: 168px; overflow: auto; padding-right: 2px; }
.log li {
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--dust);
  padding-left: 10px;
  position: relative;
}
.log li::before { content: "·"; position: absolute; left: 0; color: var(--line-hot); }
.log li.is-hit { color: #e0956f; }
.log li.is-good { color: var(--accent); }
.log li.is-hero { color: var(--primary); }

/* ── ИНВЕНТАРЬ ────────────────────────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(10, 8, 5, 0.66);
  backdrop-filter: blur(2px);
}
.inventory {
  position: fixed;
  top: 0; right: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  width: min(380px, 94vw);
  height: 100%;
  background: linear-gradient(180deg, #241f17, #15110c);
  border-left: 1px solid var(--line-hot);
  box-shadow: -30px 0 60px -40px #000;
  transform: translateX(104%);
  transition: transform 0.24s cubic-bezier(0.3, 0.8, 0.3, 1);
}
.inventory[data-inventory-open="true"] { transform: none; }
.inventory__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #1c1811;
}
.inventory__head h2 { font-family: var(--font-display); font-size: 14px; letter-spacing: 0.12em; }
.inventory__body { padding: 14px 16px 24px; overflow: auto; display: grid; gap: 18px; align-content: start; }
.inventory__block h3 {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--dust);
  margin-bottom: 7px;
  padding-bottom: 5px;
  border-bottom: 1px dashed var(--line);
}
.inv-list { display: grid; gap: 6px; }
.inv-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #1b1610;
  font-family: var(--font-mono);
  font-size: 11px;
}
.inv-list li.is-current { border-color: var(--primary); }
.inv-list li b { color: var(--ink); font-weight: 500; }
.inv-list li span { color: var(--accent); }
.inv-list button {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.06em;
  padding: 3px 7px;
  border: 1px solid var(--line-hot);
  background: #241c12;
  color: var(--primary);
  border-radius: 2px;
  cursor: pointer;
}
.inv-list button:disabled { color: var(--dust); border-color: var(--line); cursor: not-allowed; }
.inv-dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-family: var(--font-mono); font-size: 11px; }
.inv-dl dt { color: var(--dust); }
.inv-dl dd { color: var(--ink); text-align: right; }

/* ── ИТОГИ ────────────────────────────────────────────────────── */

.screen--report { display: grid; place-items: center; min-height: calc(100vh - 150px); }
.report {
  width: min(720px, 100%);
  padding: clamp(18px, 3vw, 32px);
  border: 1px solid var(--line-hot);
  border-radius: var(--radius);
  background:
    radial-gradient(80% 60% at 50% 0%, rgba(208, 138, 62, 0.12), transparent 70%),
    linear-gradient(180deg, #251f16, #17140f);
  box-shadow: 0 50px 100px -70px #000, inset 0 0 0 1px rgba(236, 224, 201, 0.04);
  animation: report-in 0.45s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
@keyframes report-in { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
.report__kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--accent);
}
.report__title {
  font-family: var(--font-display);
  font-size: clamp(20px, 4vw, 32px);
  letter-spacing: 0.06em;
  margin: 4px 0 18px;
  color: var(--ink);
}
.report__text { color: #cbbfa9; margin-bottom: 16px; max-width: 52ch; }
.report__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.report--defeat .report__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.report__cell {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #1a1610;
}
.report__cell span { display: block; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.12em; color: var(--dust); }
.report__cell b { font-family: var(--font-mono); font-size: 21px; color: var(--primary); }
.report__section { margin-top: 18px; }
.report__section h3 {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--dust);
  margin-bottom: 8px;
}
.grow-grid { display: grid; gap: 7px; }
.grow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid var(--line-hot);
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(208, 138, 62, 0.12), rgba(26, 22, 16, 0.9));
  animation: grow-in 0.4s ease both;
}
@keyframes grow-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.grow__name { font-family: var(--font-display); font-size: 11px; letter-spacing: 0.08em; }
.grow__vals { font-family: var(--font-mono); font-size: 13px; color: var(--dust); }
.grow__vals b { color: var(--accent); font-size: 17px; }
.grow__bar { grid-column: 1 / -1; height: 6px; background: #120f0a; border: 1px solid #2c2519; position: relative; }
.grow__bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.grow__pick { display: flex; gap: 6px; flex-wrap: wrap; grid-column: 1 / -1; }

.loot-line { display: flex; flex-wrap: wrap; gap: 8px; }
.loot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: rgba(143, 156, 116, 0.1);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
}
.loot b { color: var(--accent); }
.loot svg { width: 40px; height: 24px; }

#btn-next-sector, #btn-retry-sector { margin-top: 22px; width: 100%; }
.report__note { margin-top: 10px; font-family: var(--font-mono); font-size: 10.5px; color: var(--dust); text-align: center; }

/* ── ТОСТЫ ────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: grid;
  gap: 8px;
  width: min(560px, calc(100vw - 24px));
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #33231a, #241811);
  border: 1px solid var(--danger);
  border-left: 4px solid var(--danger);
  border-radius: 2px;
  box-shadow: 0 18px 40px -26px #000;
  animation: toast-in 0.24s ease both;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.toast p { flex: 1; font-size: 13px; color: #f0ddc4; }
.toast button {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 6px 10px;
  border: 1px solid var(--danger);
  background: #3b1f16;
  color: #ffd7c2;
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
}
.toast button:hover { background: #4d271a; }
.toast--info { border-color: var(--accent); border-left-color: var(--accent); background: linear-gradient(180deg, #23301f, #1a2116); }
.toast--info p { color: #dbe6c8; }
.toast--info button { border-color: var(--accent); background: #2b3724; color: #e6f0d6; }

/* ── АДАПТИВ ──────────────────────────────────────────────────── */

@media (max-width: 1080px) {
  .screen--battle { grid-template-columns: minmax(0, 1fr) 300px; }
  .weapon-cards { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  body { font-size: 15px; }

  .rig { flex-wrap: wrap; gap: 8px 12px; padding: 9px 12px; }
  .rig__sub { display: none; }
  .rig__meters { order: 3; width: 100%; margin-left: 0; justify-content: space-between; gap: 6px; }
  .meter { min-width: 0; }
  .meter b { font-size: 13px; }
  .rig__actions { margin-left: auto; }
  .rig__inv-label { display: none; }
  .rig__inv { padding: 8px 10px; }

  #app { padding: 10px 10px 20px; }

  .build-grid { grid-template-columns: 1fr; }
  .dossier { position: static; }
  .figure { padding: 2px 0; }
  #hero-figure { width: 168px; height: 210px; }
  .plate { padding: 13px 13px 15px; }
  .opt-row { grid-template-columns: 1fr; gap: 6px; }
  .opt-label { font-size: 9px; }
  .opts { gap: 5px; }
  .opt, .swatch { padding: 8px 10px; font-size: 9.5px; }
  .stat { grid-template-columns: minmax(92px, 1fr) 32px 34px 32px; gap: 6px; }
  .stat__bar { grid-column: 1 / -1; }
  .stat__name span { font-size: 9px; }
  .weapon-cards { grid-template-columns: 1fr; }

  .cta-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    border-radius: 0;
    border-left: 0; border-right: 0; border-bottom: 0;
    background: linear-gradient(180deg, rgba(23,20,15,0.94), #17140f 60%);
    box-shadow: 0 -18px 40px -26px #000;
  }
  .cta-bar__note { display: none; }
  .cta-bar .btn--big { width: 100%; margin: 0; }
  #screen-hero { padding-bottom: 92px; }

  .screen--battle { grid-template-columns: 1fr; gap: 10px; }
  .stage { height: clamp(300px, 46vh, 460px); }
  .stage__tag { max-width: calc(100% - 96px); padding: 5px 8px; }
  .stage__sector { font-size: 10px; }
  .stage__tagline { font-size: 9px; }
  .stage__hint { display: none; }

  .aim {
    left: 6px; right: 6px; bottom: 6px;
    width: auto;
    padding: 6px 8px 7px;
    background: linear-gradient(180deg, rgba(40, 33, 22, 0.96), rgba(18, 15, 10, 0.97));
  }
  .aim__title { display: none; }
  .aim__cell b { font-size: 17px; }
  .aim__breakdown { font-size: 9px; margin-top: 4px; padding-top: 4px; }

  .battle-panel { order: 2; gap: 10px; }
  .turn-card__btns .btn { flex: 1 1 44%; font-size: 10px; padding: 9px 8px; }
  .plate--stats summary { padding: 9px 11px; }
  .log { max-height: 130px; }

  .report { padding: 16px; }
  .report__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report--defeat .report__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .report__cell b { font-size: 18px; }
  .report__title { margin-bottom: 14px; }

  .inventory {
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%;
    height: 72vh;
    border-left: 0;
    border-top: 1px solid var(--line-hot);
    border-radius: 8px 8px 0 0;
    transform: translateY(104%);
  }
  .inventory[data-inventory-open="true"] { transform: none; }

  .toasts { top: 76px; }
}

@media (max-width: 400px) {
  .stage { height: clamp(280px, 42vh, 380px); }
  .aim__cell b { font-size: 15px; }
  .report__grid { grid-template-columns: 1fr; }
  .report--defeat .report__grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
