/* ==========================================================================
   Биосфера Земли · открытый 3D-мир
   Оформление поверх css/design-system.css: неоновый брутализм PhilTech.
   Палитра: #ECF1F7 / #F5F0E8 / #0A1224 / #43B5A0 / #FFD23C / #FA448C / #5CE1E6
   ========================================================================== */

:root {
  --bf-ink: #0a1224;
  --bf-paper: #f5f0e8;
  --bf-bg: #ecf1f7;
  --bf-cyan: #5ce1e6;
  --bf-teal: #43b5a0;
  --bf-yellow: #ffd23c;
  --bf-pink: #fa448c;
  --bf-violet: #491d88;
  --bf-line: #0a1224;
  --bf-shadow: 6px 6px 0 #0a1224;
  --bf-shadow-sm: 4px 4px 0 #0a1224;
  --bf-font: "Space Grotesk", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --bf-display: "Archivo Black", "Arial Black", "Segoe UI Black", Impact, sans-serif;
  --bf-mono: "JetBrains Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
}

html,
body.bf-body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #cfeeff;
}

body.bf-body {
  font-family: var(--bf-font);
  color: var(--bf-ink);
  -webkit-user-select: none;
  user-select: none;
}

body.bf-body::before {
  display: none;
}

#c {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

button,
a {
  font-family: var(--bf-font);
}

.bf-kicker {
  display: inline-block;
  font-family: var(--bf-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--bf-violet);
}

/* ──────────────────────────────── Загрузка ─────────────────────────────── */
#load {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 18% 12%, rgba(92, 225, 230, 0.5), transparent 36%),
    radial-gradient(circle at 88% 82%, rgba(250, 68, 140, 0.32), transparent 40%),
    #cfeeff;
  z-index: 9999;
  transition: opacity 0.55s ease;
}

.bf-loader {
  width: min(460px, 94vw);
  max-height: 92vh;
  overflow: auto;
  padding: 26px 28px 22px;
  text-align: center;
  background: var(--bf-paper);
  border: 3px solid var(--bf-ink);
  box-shadow: 10px 10px 0 var(--bf-ink);
}

.bf-loader-globe {
  font-size: clamp(54px, 12vw, 82px);
  line-height: 1;
  animation: bfSpin 6s linear infinite;
  transform-origin: 50% 55%;
}

@keyframes bfSpin {
  0% { transform: rotate(-6deg) translateY(0); }
  50% { transform: rotate(6deg) translateY(-5px); }
  100% { transform: rotate(-6deg) translateY(0); }
}

.bf-loader-title {
  margin: 8px 0 2px;
  font-family: var(--bf-display);
  font-size: clamp(1.6rem, 5vw, 2.3rem);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.bf-loader-sub {
  margin: 0 0 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #33455c;
}

.bf-progress {
  position: relative;
  height: 22px;
  overflow: hidden;
  background: #e6eef7;
  border: 3px solid var(--bf-ink);
  box-shadow: var(--bf-shadow-sm);
}

.bf-progress--lg {
  height: 28px;
}

.bf-progress--sm {
  height: 12px;
  border-width: 2px;
  box-shadow: none;
  margin-top: 8px;
}

.bf-progress-fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(45deg, var(--bf-yellow) 0 10px, #e0b400 10px 20px);
  border-right: 3px solid var(--bf-ink);
  transition: width 0.4s cubic-bezier(0.3, 0.7, 0.3, 1);
}

.bf-progress--sm .bf-progress-fill {
  border-right-width: 2px;
  background: var(--bf-teal);
}

.bf-loader-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-family: var(--bf-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bf-loader-meta #loadPercent {
  font-family: var(--bf-display);
  font-size: 22px;
  letter-spacing: 0;
}

.bf-loader-meta #loadCurrent {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.7;
}

.load-steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 12px;
  margin: 18px 0 0;
  padding: 14px 0 0;
  list-style: none;
  border-top: 2px solid var(--bf-ink);
  text-align: left;
}

.load-step {
  position: relative;
  padding: 4px 0 4px 26px;
  font-family: var(--bf-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.42;
  transition: opacity 0.25s ease;
}

.load-step::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  background: #fff;
  border: 2px solid var(--bf-ink);
}

.load-step.active {
  opacity: 1;
}

.load-step.active::before {
  background: var(--bf-pink);
  animation: bfStepPulse 0.9s ease-in-out infinite;
}

.load-step.done {
  opacity: 1;
}

.load-step.done::before {
  content: "✓";
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bf-yellow);
  font-size: 11px;
  font-weight: 900;
}

@keyframes bfStepPulse {
  0%, 100% { transform: translateY(-50%) scale(1); }
  50% { transform: translateY(-50%) scale(0.6); }
}

.bf-loader-foot {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 2px solid var(--bf-ink);
  font-family: var(--bf-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.6;
}

/* ──────────────────────────────── Верхняя панель ──────────────────────── */
.bf-topbar {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: var(--bf-paper);
  border: 3px solid var(--bf-ink);
  box-shadow: var(--bf-shadow);
  pointer-events: none;
}

.bf-topbar > * {
  pointer-events: auto;
}

.bf-brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding-left: 4px;
}

.bf-brand-kicker {
  font-family: var(--bf-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bf-violet);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bf-brand-title {
  font-family: var(--bf-display);
  font-size: clamp(0.95rem, 2vw, 1.25rem);
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.bf-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.bf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 12px;
  background: #fff;
  color: var(--bf-ink);
  border: 3px solid var(--bf-ink);
  box-shadow: 3px 3px 0 var(--bf-ink);
  font-family: var(--bf-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.bf-btn:hover {
  background: var(--bf-yellow);
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--bf-ink);
}

.bf-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--bf-ink);
}

.bf-btn--back {
  background: var(--bf-cyan);
  flex: none;
}

.bf-btn--accent {
  background: var(--bf-teal);
  color: #fff;
}

/* ──────────────────────────────── Подсказка / HUD ─────────────────────── */
.bf-hint {
  position: fixed;
  top: 92px;
  left: 12px;
  z-index: 90;
  max-width: min(560px, 46vw);
  padding: 8px 12px;
  background: var(--bf-paper);
  border: 2px solid var(--bf-ink);
  box-shadow: 3px 3px 0 var(--bf-ink);
  font-family: var(--bf-mono);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.7;
  color: #24334a;
  pointer-events: none;
}

.bf-hint b {
  background: var(--bf-yellow);
  padding: 0 3px;
  font-weight: 800;
}

.bf-players {
  position: fixed;
  top: 50%;
  left: 12px;
  z-index: 80;
  min-width: 190px;
  padding: 12px 14px;
  transform: translateY(-50%);
  background: var(--bf-paper);
  border: 3px solid var(--bf-ink);
  box-shadow: var(--bf-shadow-sm);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

.player-list-title {
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--bf-ink);
  font-family: var(--bf-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.65;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.player-item.me {
  color: #a01d44;
}

.bf-hud {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 90;
  display: grid;
  grid-template-columns: repeat(6, minmax(78px, auto));
  gap: 8px;
  pointer-events: none;
}

.bf-hud-card {
  min-width: 78px;
  padding: 6px 9px 7px;
  background: var(--bf-paper);
  border: 3px solid var(--bf-ink);
  box-shadow: 3px 3px 0 var(--bf-ink);
  text-align: center;
}

.bf-hud-card span {
  display: block;
  font-family: var(--bf-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.62;
}

.bf-hud-card b {
  display: block;
  margin-top: 1px;
  font-family: var(--bf-display);
  font-size: 15px;
  line-height: 1.2;
}

.bf-hud-card b.coords {
  font-size: 10px;
  letter-spacing: 0.02em;
}

.bf-hud-card--xp {
  background: var(--bf-yellow);
}

.bf-hud-card--species {
  background: var(--bf-cyan);
}

.bf-lesson-links {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 85;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 300px;
  padding: 8px 10px;
  background: var(--bf-paper);
  border: 2px solid var(--bf-ink);
  box-shadow: 3px 3px 0 var(--bf-ink);
  font-family: var(--bf-mono);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.35;
}

.bf-lesson-links > span {
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.55;
}

.bf-lesson-links a {
  color: var(--bf-violet);
  text-decoration: none;
  text-transform: uppercase;
}

.bf-lesson-links a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

body.bf-panel-open .bf-hud,
body.bf-panel-open #ptt-btn,
body.bf-panel-open .bf-players,
body.bf-panel-open .bf-lesson-links,
body.bf-panel-open .bf-hint {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ──────────────────────────────── Панели ──────────────────────────────── */
.bf-panel {
  position: fixed;
  top: 96px;
  left: 50%;
  z-index: 400;
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100dvh - 130px);
  overflow: auto;
  padding: 20px 22px 18px;
  transform: translateX(-50%);
  background: var(--bf-paper);
  border: 3px solid var(--bf-ink);
  box-shadow: 12px 12px 0 var(--bf-ink);
  animation: bfPanelIn 0.16s ease-out;
}

@keyframes bfPanelIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.bf-panel[hidden] {
  display: none;
}

.bf-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--bf-ink);
}

.bf-panel-head h2 {
  margin: 2px 0 0;
  font-family: var(--bf-display);
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  line-height: 1.05;
  text-transform: uppercase;
}

.bf-panel-close {
  flex: none;
  width: 36px;
  height: 36px;
  background: #fff;
  border: 3px solid var(--bf-ink);
  box-shadow: 2px 2px 0 var(--bf-ink);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}

.bf-panel-close:hover {
  background: var(--bf-pink);
  color: #fff;
}

.bf-panel-lead {
  max-width: 68ch;
  margin: 0 0 14px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #33455c;
}

.bf-panel-lead--small {
  font-size: 0.78rem;
}

.bf-panel-lead code {
  padding: 0 4px;
  background: #e6eef7;
  border: 1px solid var(--bf-ink);
  font-family: var(--bf-mono);
  font-size: 0.72rem;
}

.bf-journal-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.bf-journal-block {
  min-width: 0;
  padding: 10px 11px;
  background: #fff;
  border: 2px solid var(--bf-ink);
  box-shadow: 3px 3px 0 var(--bf-ink);
}

.bf-journal-block > span {
  display: block;
  font-family: var(--bf-mono);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.62;
}

.bf-journal-block b {
  display: block;
  margin-top: 2px;
  font-family: var(--bf-display);
  font-size: 1.35rem;
  line-height: 1;
}

.bf-journal-block small {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 700;
  color: var(--bf-violet);
}

.bf-journal-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 34px;
  margin-bottom: 16px;
}

.bf-journal-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #fff;
  border: 2px solid var(--bf-ink);
  font-size: 10.5px;
}

.bf-journal-chip b {
  font-family: var(--bf-mono);
  color: #0b6b5f;
}

.bf-journal-empty {
  margin: 0;
  font-size: 0.8rem;
  color: #52657c;
}

.bf-panel-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 12px;
  border-top: 2px solid var(--bf-ink);
}

.bf-biome-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.bf-biome {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  min-height: 104px;
  padding: 10px 11px;
  background: #fff;
  border: 3px solid var(--bf-ink);
  box-shadow: 3px 3px 0 var(--bf-ink);
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.bf-biome:hover {
  background: var(--bf-yellow);
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--bf-ink);
}

.bf-biome-emoji {
  font-size: 28px;
  line-height: 1;
}

.bf-biome b {
  font-family: var(--bf-display);
  font-size: 0.82rem;
  line-height: 1.1;
  text-transform: uppercase;
}

.bf-biome small {
  font-family: var(--bf-mono);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.62;
}

.bf-quality {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.bf-quality button {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px;
  background: #fff;
  border: 3px solid var(--bf-ink);
  box-shadow: 3px 3px 0 var(--bf-ink);
  font-family: var(--bf-display);
  font-size: 0.9rem;
  text-transform: uppercase;
  cursor: pointer;
}

.bf-quality button small {
  font-family: var(--bf-mono);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  opacity: 0.6;
}

.bf-quality button.is-active {
  background: var(--bf-teal);
  color: #fff;
}

.bf-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #fff;
  border: 2px solid var(--bf-ink);
  font-family: var(--bf-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

/* ──────────────────────────────── Подсказки у земли ───────────────────── */
#landHint {
  position: fixed;
  bottom: 106px;
  left: 50%;
  z-index: 110;
  display: none;
  padding: 8px 20px;
  transform: translateX(-50%);
  background: var(--bf-yellow);
  border: 3px solid var(--bf-ink);
  box-shadow: var(--bf-shadow-sm);
  font-family: var(--bf-mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
  animation: bfPulse 1.6s ease-in-out infinite;
}

#landHint kbd {
  padding: 1px 8px;
  background: var(--bf-ink);
  color: #fff;
  font-family: var(--bf-mono);
  font-size: 12px;
  font-weight: 800;
}

@keyframes bfPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

#animal-action-btn {
  position: fixed;
  z-index: 130;
  display: none;
  padding: 9px 16px;
  transform: translate(-50%, -50%);
  background: var(--bf-paper);
  border: 3px solid var(--bf-ink);
  box-shadow: var(--bf-shadow-sm);
  font-family: var(--bf-mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

#animal-action-btn:hover {
  background: var(--bf-yellow);
}

#ptt-btn {
  position: fixed;
  bottom: 16px;
  left: 50%;
  z-index: 140;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  transform: translateX(-50%);
  background: var(--bf-paper);
  border: 3px solid var(--bf-ink);
  box-shadow: var(--bf-shadow-sm);
  font-family: var(--bf-mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

#ptt-btn.active {
  background: var(--bf-pink);
  color: #fff;
}

#ptt-btn.is-offline {
  opacity: 0.72;
}

#ptt-btn.is-offline:hover {
  background: var(--bf-yellow);
}

.ptt-key {
  padding: 1px 6px;
  background: var(--bf-ink);
  color: #fff;
  font-family: var(--bf-mono);
  font-size: 10px;
}

/* ──────────────────────────────── Тост / факт / XP ───────────────────── */
#factPopup {
  position: fixed;
  bottom: 118px;
  left: 50%;
  z-index: 150;
  max-width: 80vw;
  padding: 8px 16px;
  transform: translateX(-50%) translateY(16px);
  background: var(--bf-ink);
  color: #fff;
  border: 2px solid var(--bf-yellow);
  font-family: var(--bf-mono);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#factPopup.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#bf-xp-toast {
  position: fixed;
  top: 96px;
  left: 50%;
  z-index: 300;
  padding: 7px 16px;
  transform: translate(-50%, -8px);
  background: var(--bf-teal);
  color: #fff;
  border: 3px solid var(--bf-ink);
  box-shadow: 3px 3px 0 var(--bf-ink);
  font-family: var(--bf-mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

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

/* ──────────────────────────────── Модалка ─────────────────────────────── */
#infoModal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(10, 18, 36, 0.74);
}

#infoModal.show {
  display: flex;
}

.modal-content {
  position: relative;
  width: min(760px, 96vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px 28px 20px;
  background: var(--bf-paper);
  border: 3px solid var(--bf-ink);
  box-shadow: 12px 12px 0 var(--bf-ink);
  animation: bfModalIn 0.16s ease-out;
}

@keyframes bfModalIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

#modalClose {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  background: var(--bf-ink);
  color: var(--bf-paper);
  border: 2px solid var(--bf-ink);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}

#modalClose:hover {
  background: var(--bf-pink);
}

.modal-kicker {
  margin-bottom: 8px;
  padding-right: 42px;
  font-family: var(--bf-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.6;
}

.modal-emoji {
  display: block;
  margin-bottom: 8px;
  font-size: 48px;
  line-height: 1;
}

.modal-title {
  margin: 0 0 14px;
  padding-right: 42px;
  font-family: var(--bf-display);
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  line-height: 1.08;
  text-transform: uppercase;
}

.modal-zone-badge {
  display: inline-block;
  margin-bottom: 16px;
  padding: 4px 10px;
  background: var(--bf-yellow);
  border: 2px solid var(--bf-ink);
  box-shadow: 2px 2px 0 var(--bf-ink);
  font-family: var(--bf-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.modal-fact-text {
  margin-bottom: 14px;
  font-size: 0.94rem;
  line-height: 1.6;
  color: #24334a;
}

.bf-modal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 2px solid var(--bf-ink);
}

.bf-modal-links a {
  padding: 6px 10px;
  background: #fff;
  border: 2px solid var(--bf-ink);
  box-shadow: 2px 2px 0 var(--bf-ink);
  font-family: var(--bf-mono);
  font-size: 9.5px;
  font-weight: 700;
  color: var(--bf-ink);
  text-decoration: none;
  text-transform: uppercase;
}

.bf-modal-links a:hover {
  background: var(--bf-cyan);
}

/* ──────────────────────────────── Карточки животных ───────────────────── */
.popup-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  padding-right: 44px;
}

.popup-emoji {
  font-size: 44px;
  line-height: 1;
}

.popup-header-text {
  flex: 1;
  min-width: 0;
}

.popup-kicker {
  margin-bottom: 2px;
  font-family: var(--bf-mono);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.6;
}

.popup-title {
  font-family: var(--bf-display);
  font-size: clamp(1.3rem, 3vw, 1.75rem);
  line-height: 1;
  text-transform: uppercase;
}

.popup-latin {
  margin-top: 3px;
  font-family: var(--bf-mono);
  font-size: 9.5px;
  font-style: italic;
  opacity: 0.7;
}

.popup-zone {
  display: inline-block;
  margin-bottom: 14px;
  padding: 3px 9px;
  background: var(--bf-yellow);
  border: 2px solid var(--bf-ink);
  box-shadow: 2px 2px 0 var(--bf-ink);
  font-family: var(--bf-mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.popup-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.popup-stat {
  padding: 8px 4px 7px;
  background: var(--bf-yellow);
  border: 2px solid var(--bf-ink);
  box-shadow: 3px 3px 0 var(--bf-ink);
  text-align: center;
}

.popup-stat-val {
  display: block;
  font-family: var(--bf-display);
  font-size: 16px;
  line-height: 1;
}

.popup-stat-val small {
  margin-left: 1px;
  font-size: 10px;
}

.popup-stat-lbl {
  display: block;
  margin-top: 4px;
  font-family: var(--bf-mono);
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.15;
  text-transform: uppercase;
  opacity: 0.72;
}

.popup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 14px;
}

.popup-block {
  min-height: 86px;
  padding: 8px 9px;
  background: #fffbe8;
  border: 2px solid var(--bf-ink);
  box-shadow: 2px 2px 0 var(--bf-ink);
}

.popup-block-icon {
  display: block;
  margin-bottom: 3px;
  font-size: 19px;
  line-height: 1;
}

.popup-block-title {
  margin-bottom: 3px;
  font-family: var(--bf-mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1.2;
  text-transform: uppercase;
}

.popup-block-text {
  font-size: 10.5px;
  line-height: 1.45;
  color: #24334a;
}

.popup-block-text b,
.popup-fact b,
.popup-eco-text b {
  background: var(--bf-yellow);
  padding: 0 2px;
  font-weight: 700;
}

.popup-eco {
  margin-bottom: 14px;
  padding: 10px 12px;
  background: #e8f8f5;
  border: 2px solid var(--bf-ink);
  border-left: 8px solid var(--bf-teal);
  box-shadow: 3px 3px 0 var(--bf-ink);
}

.popup-eco-kicker {
  margin-bottom: 3px;
  font-family: var(--bf-mono);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #0b6b5f;
}

.popup-eco-title {
  margin-bottom: 4px;
  font-family: var(--bf-display);
  font-size: 0.95rem;
  line-height: 1.15;
  text-transform: uppercase;
}

.popup-eco-text {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: #24334a;
}

.popup-facts {
  counter-reset: popf;
  margin: 0;
  padding-top: 10px;
  border-top: 2px solid var(--bf-ink);
  list-style: none;
}

.popup-fact {
  counter-increment: popf;
  position: relative;
  margin-bottom: 7px;
  padding-left: 28px;
  font-size: 11px;
  line-height: 1.5;
  color: #24334a;
}

.popup-fact:last-child {
  margin-bottom: 0;
}

.popup-fact::before {
  content: counter(popf);
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--bf-yellow);
  border: 2px solid var(--bf-ink);
  font-family: var(--bf-mono);
  font-size: 9px;
  font-weight: 800;
}

/* ──────────────────────────────── Викторина ───────────────────────────── */
.quiz-opt {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 10px 14px;
  background: var(--bf-paper);
  color: var(--bf-ink);
  border: 2px solid var(--bf-ink);
  box-shadow: 3px 3px 0 var(--bf-ink);
  font-family: var(--bf-font);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.quiz-opt:hover:not(:disabled) {
  background: var(--bf-yellow);
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--bf-ink);
}

.quiz-opt:disabled {
  cursor: default;
}

.quiz-opt.correct {
  background: var(--bf-teal);
  color: #fff;
}

.quiz-opt.wrong {
  background: var(--bf-pink);
  color: #fff;
  text-decoration: line-through;
}

.quiz-result {
  margin-top: 14px;
  padding: 10px 12px;
  border: 2px solid var(--bf-ink);
  box-shadow: 3px 3px 0 var(--bf-ink);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.5;
}

.quiz-result.correct {
  background: #d8f7ea;
}

.quiz-result.wrong {
  background: #ffe1e7;
}

.quiz-why {
  display: block;
  margin-top: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.45;
  opacity: 0.9;
}

/* ──────────────────────────────── Тосты / финал ──────────────────────── */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 390;
  max-width: 90vw;
  padding: 18px 28px;
  transform: translate(-50%, -50%) scale(0.85);
  background: var(--bf-paper);
  border: 3px solid var(--bf-ink);
  box-shadow: 10px 10px 0 var(--bf-ink);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.2, 1.2, 0.4, 1);
}

.toast.on {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.toast-title {
  margin-bottom: 4px;
  font-family: var(--bf-display);
  font-size: 1.5rem;
  line-height: 1.05;
  color: var(--bf-violet);
}

.toast-sub {
  font-family: var(--bf-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#abductionOverlay {
  position: fixed;
  inset: 0;
  z-index: 650;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(10, 18, 36, 0.78);
}

#abductionOverlay .box {
  width: min(500px, 94vw);
  padding: 26px 26px 22px;
  background: var(--bf-paper);
  border: 3px solid var(--bf-ink);
  box-shadow: 12px 12px 0 var(--bf-ink);
  text-align: center;
}

#abductionOverlay .emoji {
  margin-bottom: 8px;
  font-size: 58px;
}

#abductionOverlay h2 {
  margin: 0 0 12px;
  font-family: var(--bf-display);
  font-size: clamp(1.6rem, 5vw, 2.3rem);
  line-height: 1.05;
  color: var(--bf-pink);
  text-transform: uppercase;
}

#abductionOverlay p {
  margin: 0 0 20px;
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.5;
}

#abductionOverlay button {
  padding: 10px 20px;
  background: var(--bf-yellow);
  border: 3px solid var(--bf-ink);
  box-shadow: 4px 4px 0 var(--bf-ink);
  font-family: var(--bf-mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

/* ──────────────────────────────── Адаптив ─────────────────────────────── */
@media (max-width: 1100px) {
  .bf-hint {
    max-width: 42vw;
    font-size: 9px;
  }
  .bf-hud {
    grid-template-columns: repeat(3, minmax(78px, auto));
  }
  .bf-biome-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 820px) {
  .bf-topbar {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 8px;
    padding: 6px 8px;
  }
  .bf-brand-kicker {
    display: none;
  }
  .bf-brand-title {
    font-size: 0.85rem;
  }
  .bf-btn {
    min-height: 34px;
    padding: 5px 8px;
    font-size: 9px;
  }
  .bf-actions .bf-btn:not(.bf-btn--back) {
    min-width: 38px;
    padding: 5px 8px;
  }
  .bf-btn-label {
    display: none;
  }
  .bf-hint {
    top: 76px;
    left: 8px;
    max-width: 54vw;
    padding: 6px 9px;
    font-size: 8.5px;
    line-height: 1.6;
  }
  .bf-players {
    display: none;
  }
  .bf-lesson-links {
    display: none;
  }
  .bf-hud {
    right: 8px;
    bottom: 8px;
    gap: 5px;
    grid-template-columns: repeat(3, minmax(64px, auto));
  }
  .bf-hud-card {
    min-width: 64px;
    padding: 4px 6px 5px;
    border-width: 2px;
    box-shadow: 2px 2px 0 var(--bf-ink);
  }
  .bf-hud-card b {
    font-size: 12px;
  }
  .bf-hud-card b.coords {
    font-size: 8px;
  }
  .bf-panel {
    top: 72px;
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 96px);
    padding: 14px 14px 16px;
    box-shadow: 6px 6px 0 var(--bf-ink);
  }
  .bf-journal-grid {
    grid-template-columns: 1fr 1fr;
  }
  .bf-biome-grid {
    grid-template-columns: 1fr 1fr;
  }
  .bf-biome {
    min-height: 88px;
  }
  .popup-grid {
    grid-template-columns: 1fr 1fr;
  }
  .modal-content {
    padding: 20px 16px 16px;
  }
  #ptt-btn {
    bottom: 116px;
    padding: 6px 12px;
    font-size: 9px;
  }
  #landHint {
    bottom: 158px;
    font-size: 10px;
  }
}

@media (max-width: 520px) {
  .bf-brand-title {
    max-width: 168px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.76rem;
  }
  .bf-actions {
    gap: 5px;
  }
  .bf-actions .bf-btn:not(.bf-btn--back) {
    min-width: 32px;
    min-height: 30px;
  }
  .bf-hud {
    left: 8px;
    right: 8px;
    grid-template-columns: repeat(3, 1fr);
  }
  .bf-hint {
    max-width: calc(100vw - 160px);
    font-size: 8px;
  }
  .bf-progress--lg {
    height: 22px;
  }
  .load-steps {
    grid-template-columns: 1fr;
  }
  .bf-journal-grid,
  .bf-quality,
  .popup-stats {
    grid-template-columns: 1fr 1fr;
  }
  .popup-grid {
    grid-template-columns: 1fr;
  }
  .bf-panel-lead {
    font-size: 0.82rem;
  }
  .toast {
    padding: 14px 16px;
  }
}

@media (min-width: 1600px) {
  .bf-hud-card {
    min-width: 92px;
    padding: 8px 12px;
  }
  .bf-hud-card b {
    font-size: 17px;
  }
  .bf-hint {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bf-loader-globe,
  .load-step.active::before,
  #landHint {
    animation: none;
  }
  .bf-progress-fill {
    transition: none;
  }
}

/* ═══════════ МОБИЛЬНОЕ УПРАВЛЕНИЕ ═══════════ */
.bf-touch {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
  display: none; justify-content: space-between; align-items: flex-end;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}
.bf-touch__pad { display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(2, 58px); gap: 7px; pointer-events: auto; }
.bf-touch__side { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: auto; }
.bf-touch-btn {
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--bf-ink); border-radius: 12px;
  background: rgba(255,255,255,.88); color: var(--bf-ink);
  font-family: var(--bf-display); font-size: 21px; line-height: 1;
  cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent; box-shadow: 3px 3px 0 var(--bf-ink);
  backdrop-filter: blur(4px);
}
.bf-touch-btn.is-on { background: var(--bf-yellow); transform: translate(1px,1px); box-shadow: 2px 2px 0 var(--bf-ink); }
.bf-touch-btn--boost { width: 58px; height: 58px; font-size: 24px; background: var(--bf-cyan); }
.bf-touch-btn--action {
  width: 74px; height: 58px; font: 900 12px/1.15 var(--bf-mono);
  letter-spacing: .05em; text-transform: uppercase; background: var(--bf-pink); color: #fff;
}
.bf-touch-btn--action.is-ready { background: var(--bf-yellow); color: var(--bf-ink); animation: bfTouchPulse 1.2s infinite; }
@keyframes bfTouchPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

@media (hover: none), (pointer: coarse), (max-width: 820px) {
  .bf-touch { display: flex; }
  .bf-hint { display: none; }
  .bf-hud { top: 66px; right: 8px; bottom: auto; left: auto; grid-template-columns: repeat(3, minmax(60px, auto)); gap: 4px; }
  .bf-hud-card { min-width: 60px; padding: 4px 6px; }
  .bf-hud-card b { font-size: 12px; }
  #landHint { bottom: calc(140px + env(safe-area-inset-bottom, 0px)); left: 12px; transform: none; font-size: 9px; }
  #animal-action-btn { top: auto !important; bottom: calc(150px + env(safe-area-inset-bottom, 0px)); left: 50% !important; transform: translateX(-50%); }
  #ptt-btn { bottom: calc(206px + env(safe-area-inset-bottom, 0px)); }
  .bf-panel { top: 66px; max-height: calc(100dvh - 90px); }
}
@media (max-width: 520px) {
  .bf-touch__pad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 52px); gap: 6px; }
  .bf-touch-btn { font-size: 18px; }
  .bf-touch-btn--boost { width: 52px; height: 52px; font-size: 21px; }
  .bf-touch-btn--action { width: 66px; height: 52px; font-size: 10px; }
  #landHint { bottom: calc(132px + env(safe-area-inset-bottom, 0px)); }
  #animal-action-btn { bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }
  #ptt-btn { bottom: calc(194px + env(safe-area-inset-bottom, 0px)); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .bf-touch { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .bf-touch__pad { grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(2, 46px); gap: 5px; }
  .bf-touch-btn { font-size: 16px; border-width: 2px; }
  .bf-touch-btn--boost { width: 46px; height: 46px; font-size: 18px; }
  .bf-touch-btn--action { width: 56px; height: 46px; font-size: 9px; }
  .bf-hud { top: 54px; grid-template-columns: repeat(6, minmax(46px, auto)); gap: 3px; }
  .bf-hud-card { min-width: 46px; padding: 2px 4px; border-width: 2px; box-shadow: 2px 2px 0 var(--bf-ink); }
  .bf-hud-card span { font-size: 6.5px; }
  .bf-hud-card b { font-size: 10px; }
  .bf-hud-card b.coords { font-size: 7px; }
  #landHint { bottom: 116px; font-size: 8px; }
  #animal-action-btn { bottom: 118px; font-size: 9px; padding: 6px 10px; }
  #ptt-btn { bottom: 160px; }
  .bf-panel { top: 52px; max-height: calc(100dvh - 64px); }
}
