/* ==========================================================================
   style.css — Полный визуальный движок игры "Браконьер"
   ========================================================================== */

/* 1. ГЛОБАЛЬНЫЕ НАСТРОЙКИ И ЦВЕТОВАЯ ПАЛИТРА (ПЕРЕМЕННЫЕ) */
:root {
  /* Индустриальный гранж: уголь + сталь + ржавчина + золото */
  --ink: #ece5d8;          /* Светлый текст (сталь/пергаментный белый) */
  --paper: #2C2C2C;        /* Сталь — базовый фон панелей/плит */
  --paper-deep: #151515;   /* Древесный уголь — глубина, подложки */
  --blood: #9E1A23;        /* Ржаво-красный (кровавый акцент) */
  --blood-dark: #6b1118;   /* Засохшая кровь */
  --blood-bright: #c22b36; /* Свежая кровь / блик */
  --toxic: #7a9a3f;        /* Болотный зеленый (токсичный) */
  --gold: #E0B24D;         /* Грязный золотой (металл) */
  --gold-deep: #a87f28;    /* Тёмная латунь */
  --violet: #3a2540;       /* Мрачный фиолетовый */
  --sky: #2f6fb0;          /* Стальной синий */
  --hazard: #ff9f43;       /* Опасный оранжевый (КПП) */
  --stencil: 'Russo One', 'Rubik', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --metal-glow: rgba(255, 255, 255, 0.09); /* Блик стали сверху */

  --panel-shadow: 5px 5px 0 rgba(0, 0, 0, 0.6);
  --border-weight: 3px;
  --size: 8;               /* DEPRECATED — used as --cols fallback */
  --cols: 9;               /* Столбцы сетки */
  --rows: 11;              /* Строки сетки */

  /* Match-3 (не используется напрямую — оставлено для совместимости) */
  --m3-frame: #a07840;          /* Светлое дерево рамы */
  --m3-frame-light: #c8a060;    /* Блик рамы (верх/лево) */
  --m3-frame-dark: #7a5830;     /* Тень рамы (низ/право) */
  --m3-tile-a: rgba(255, 255, 255, 0.15);  /* Плитка A — полупрозрачный белый */
  --m3-tile-b: rgba(255, 255, 255, 0.08);  /* Плитка B — ещё прозрачнее */
  --m3-hud-bg: linear-gradient(180deg, #3a3a3a 0%, #2C2C2C 45%, #1a1a1a 100%); /* Сталь HUD */
  --m3-hud-border: #dab850;     /* Золотая окантовка HUD */
  --m3-tools-bg: linear-gradient(180deg, rgba(20,20,20,0.85) 0%, rgba(15,15,15,0.9) 100%); /* Тёмная стальная полка */
}

/* Локальный шрифт Chandler Mountain Thin */
@font-face {
  font-family: 'Chandler Mountain Thin';
  src:
    url('chandler-mountain/ttf/chandler-mountain-chandler-mountain-thin-100.ttf') format('truetype'),
    url('chandler-mountain/otf/chandler-mountain-chandler-mountain-thin-100.otf') format('opentype');
  font-weight: 100;
  font-style: normal;
  font-display: swap;
}

/* Иконки PNG (замена эмодзи) */
.icon-img {
  width: auto;
  height: 1.3em;
  vertical-align: middle;
  display: inline-block;
  pointer-events: none;
}
/* Восстанавливаем размер для img внутри .tile-inner (font-size: 0) */
.tile-inner .icon-img {
  font-size: 24px;
  height: 1.3em;
}

/* Сброс стилей и оптимизация под тач-скрины */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-drag: none;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  font-family: 'Rubik', sans-serif;
  color: var(--paper);
}

body {
  /* Замените 'images/background.webp' на путь к вашему красивому фону */
  background-image: url('images/background.webp'); 
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
}

/* Скрытие неактивных экранов */
.hidden {
  display: none !important;
}

/* Стилизация полосы прокрутки для меню */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--blood-dark);
  border-radius: 10px;
}

/* ==========================================================================
   2. ВЕРХНЯЯ ПАНЕЛЬ ИГРОКА (HUD)
   ========================================================================== */
.global-hud {
  display: flex;
  gap: 6px;
  width: 100%;
  max-width: 440px;
  margin-bottom: 12px;
  z-index: 10;
}
/* Во время match-3 лобби-HUD полностью скрыт + затемнение фона */
body.in-match3 .global-hud {
  display: none !important;
}
body.in-match3 {
  padding: 0 !important;
  /* Затемнение фона убрано по просьбе — комната видна без потемнения */
}
body.in-match3 #screenMatch3 {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  padding: 12px;
  overflow: hidden;
  justify-content: center;
  align-items: center;
  /* зазор header↔поле задаём margin у .match3-header-container (30px) */
  gap: 0;
}

.hud-item {
  flex: 1;
  background: var(--paper);
  color: var(--ink);
  border: var(--border-weight) solid var(--ink);
  border-radius: 12px;
  box-shadow: var(--panel-shadow);
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.2s ease;
}

.hud-icon {
  font-size: 11px;
  margin-bottom: 2px;
}

.hud-val {
  font-family: 'Bangers', cursive;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0.5px;
}

/* Персонализация счетчиков */
.stars-stat .hud-val { color: var(--gold); }
.lives-stat .hud-val { color: var(--blood-dark); }
.cash-stat .hud-val { color: #8a6a1a; }
.rep-stat .hud-val { color: var(--sky); }

/* ==========================================================================
   3. КОРНЕВАЯ СТРУКТУРА ЭКРАНОВ И КНОПОК
   ========================================================================== */
.game-screen {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.location-banner {
  background: var(--blood);
  border: var(--border-weight) solid var(--ink);
  border-radius: 10px;
  width: 100%;
  padding: 8px;
  font-family: 'Bangers', cursive;
  font-size: 20px;
  text-align: center;
  letter-spacing: 1px;
  box-shadow: var(--panel-shadow);
  margin-bottom: 14px;
}

.screen-navigation {
  width: 100%;
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
}

.menu-btn {
  flex: 1;
  font-family: 'Bangers', cursive;
  font-size: 20px;
  padding: 12px;
  border: var(--border-weight) solid var(--ink);
  border-radius: 12px;
  cursor: pointer;
  box-shadow: var(--panel-shadow);
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}

.menu-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.tasks-btn { background: var(--gold); color: var(--ink); }
.story-btn { background: var(--sky); color: var(--paper); }
.hunt-btn { background: var(--blood); color: var(--paper); }
.back-btn { background: var(--paper); color: var(--ink); }

.help-btn {
  background: var(--paper);
  color: var(--ink);
  border: var(--border-weight) solid var(--ink);
  border-radius: 50%;
  width: 36px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  box-shadow: var(--panel-shadow);
  cursor: pointer;
  flex-shrink: 0;
}

/* ==========================================================================
   4. ЭКРАН 1: СТИЛИ УБЕЖИЩА (КВАРТИРЫ)
   ========================================================================== */
.room-container {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.decor-card {
  background: rgba(13, 11, 15, 0.6);
  border: 3px solid var(--paper);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--panel-shadow);
}

.decor-card h3 {
  margin: 0 0 16px 0;
  font-family: 'Bangers', cursive;
  font-size: 24px;
  color: var(--gold);
  text-align: center;
  letter-spacing: 1px;
}

.decor-list {
  list-style: none;
  padding: 0;
  margin: 0;
  text-align: left;
}

.decor-list li {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(232, 225, 208, 0.25);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 10px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.decor-val {
  font-weight: 800;
  color: var(--gold);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
}

/* ==========================================================================
   5. ЭКРАН 2: КАРТА И КПП (ПУТЬ)
   ========================================================================== */
.map-scroll-area {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.camp-path {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  position: relative;
  width: 100%;
}

/* Задняя линия-путь, связывающая уровни */
.camp-path::before {
  content: "";
  position: absolute;
  top: 15px;
  bottom: 15px;
  width: 6px;
  background: var(--paper);
  opacity: 0.2;
}

.map-node {
  background: var(--paper);
  color: var(--ink);
  border: var(--border-weight) solid var(--ink);
  border-radius: 14px;
  padding: 12px 18px;
  width: 90%;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
  z-index: 2;
  transition: transform 0.1s ease, background 0.2s ease;
}

.map-node:active {
  transform: scale(0.97) translate(2px, 2px);
}

/* Активный/доступный уровень */
.map-node.active {
  background: var(--gold);
  box-shadow: 4px 4px 0 var(--toxic);
}

/* Закрытый уровень */
.map-node.locked {
  opacity: 0.45;
  cursor: not-allowed;
  background: #7d7a72;
  box-shadow: none;
}

/* Особый узел — КПП */
.map-node.node-checkpoint {
  background: var(--hazard); 
  border-style: dashed;
}
.map-node.node-checkpoint.active {
  animation: hazardPulse 1.5s infinite ease-in-out;
}

/* Заблокированный КПП должен выглядеть закрытым, а не "горячим":
   без этого правила .node-checkpoint (та же специфичность, но ниже
   по файлу) перебивал серый фон .locked своим оранжевым hazard-цветом */
.map-node.node-checkpoint.locked {
  background: #7d7a72;
  border-style: solid;
}

@keyframes hazardPulse {
  0%, 100% { box-shadow: 0 0 0 0px rgba(255, 159, 67, 0.7); }
  50% { box-shadow: 0 0 0 10px rgba(255, 159, 67, 0); }
}

.node-icon {
  font-size: 26px;
}

.node-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.node-title {
  font-weight: 800;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.node-status {
  font-size: 11px;
  opacity: 0.85;
  font-weight: 600;
}

/* ==========================================================================
   6. ЭКРАН 3: MATCH-3 HUD — Homescapes: парящий деревянный бар
   ========================================================================== */
/* ==========================================================================
   ПАРЯЩИЙ 3-СЛОЙНЫЙ HUD (Homescapes: кожа + прошивка + лунка)
   ========================================================================== */

/* Общий контейнер HUD = [X] + [плашка].
   Крестик и плашка — один flex-ряд: двигаются/поднимаются вместе.
   margin-bottom 30px ≈ 25–35px зазор до игрового поля.
   Размер плашки не раздуваем. */
.match3-header-container {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important; /* X на одной вертикальной оси с плашкой */
  justify-content: flex-start !important;
  width: min(92vw, 420px) !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 auto 30px auto !important; /* зазор header → поле */
  padding: 0 !important;
  box-sizing: border-box !important;
  position: relative !important;
  z-index: 100 !important;
  flex-shrink: 0 !important;
  align-self: center !important;
  gap: 8px !important; /* между крестиком и плашкой */
  transition: width 0.3s ease !important;
}

/* При 2+ целях — HUD шире, но всё ещё в пределах экрана */
.match3-header-container.multi-goal {
  width: min(96vw, 460px) !important;
  max-width: 100% !important;
}

/* --- Кнопка закрытия: часть header-ряда, не «отдельный» absolute --- */
.m3-floating-exit-btn {
  width: 44px !important;
  height: 44px !important;
  border-radius: 50% !important;
  background:
    radial-gradient(circle at 35% 25%, #ffffff 0%, #f4efe0 30%, #dfd9c8 70%, #b8b1a2 100%) !important;
  border: 2px solid #FFF !important;
  color: #4A2E1B !important;
  font-size: 18px !important;
  font-weight: 800 !important;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3) !important;
  cursor: pointer !important;
  flex: 0 0 44px !important;
  flex-shrink: 0 !important;
  align-self: center !important;
  margin: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  transition: transform 0.1s ease, box-shadow 0.1s ease !important;
  z-index: 10 !important;
  position: relative !important; /* не absolute — едет с плашкой */
}
.m3-floating-exit-btn:active {
  transform: scale(0.90) !important;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) !important;
}

/* --- СЛОЙ 1: Базовая плашка (размер как был — не увеличиваем) --- */
.m3-hud-base-plate {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  height: 94px !important;
  border-radius: 18px !important;
  padding: 8px 16px !important;
  flex: 1 1 auto !important;
  min-width: 0 !important; /* сжимается вместе с контейнером, «УРОВЕНЬ» остаётся в кадре */
  margin-left: 0 !important; /* отступ X↔плашка = gap у header */
  box-sizing: border-box !important;
  overflow: hidden !important;
  background:
    repeating-linear-gradient(
      120deg,
      rgba(255,220,170,0.05) 0px, rgba(255,220,170,0.05) 1px,
      transparent 1px, transparent 3px
    ),
    repeating-linear-gradient(
      60deg,
      rgba(0,0,0,0.07) 0px, rgba(0,0,0,0.07) 1px,
      transparent 1px, transparent 3px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(255,200,140,0.04) 0px, rgba(255,200,140,0.04) 2px,
      transparent 2px, transparent 4px
    ),
    linear-gradient(to bottom, #5E3A24, #43271A 50%, #3B2012) !important;
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(255, 200, 150, 0.14),
    inset 0 -1px 2px rgba(0, 0, 0, 0.28) !important;
}

/* --- СЛОЙ 2: Средняя плашка (Светло-бежевая кожа + прошивка) --- */
.m3-hud-middle-plate {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  height: 70px !important;
  border-radius: 14px !important;
  padding: 5px 14px !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  margin-right: 8px !important;
  box-sizing: border-box !important;
  border: none !important;
  outline: none !important;
  background:
    repeating-linear-gradient(
      90deg,
      #C8A97A 0px, #C8A97A 6px, transparent 6px, transparent 10px
    ),
    repeating-linear-gradient(
      90deg,
      #C8A97A 0px, #C8A97A 6px, transparent 6px, transparent 10px
    ),
    repeating-linear-gradient(
      135deg,
      rgba(200,170,120,0.08) 0px, rgba(200,170,120,0.08) 1px,
      transparent 1px, transparent 2.5px
    ),
    repeating-linear-gradient(
      45deg,
      rgba(180,150,100,0.06) 0px, rgba(180,150,100,0.06) 1px,
      transparent 1px, transparent 2.5px
    ),
    linear-gradient(to bottom, #F7EFD9, #EFE2C8 50%, #E8D9BC) !important;
  background-size:
    100% 2px, 100% 2px,
    100% 100%, 100% 100%, 100% 100% !important;
  background-position:
    0 1px, 0 calc(100% - 1px),
    0 0, 0 0, 0 0 !important;
  background-repeat:
    repeat-x, repeat-x,
    repeat, repeat, no-repeat !important;
  box-shadow:
    0 0 0 2px #C8A97A,
    0 0 0 4px rgba(255,255,255,0.65),
    0 0 0 6px #C8A97A,
    inset 0 2px 4px rgba(0,0,0,0.08),
    inset 0 -1px 2px rgba(255,255,255,0.5) !important;
}

/* --- СЛОЙ 3: Верхняя лунка целей --- */
.m3-hud-goal-well {
  background-color: #D6C8B5 !important;
  border-radius: 10px !important;
  height: 50px !important;
  min-width: 52px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3) !important;
  margin-right: 8px !important;
  padding: 0 8px !important;
  flex: 0 1 auto !important;
  box-sizing: border-box !important;
}

/* Вторая лунка — не растягивается, подтягивается к первой */
.m3-hud-goal-well--2 {
  margin-right: 0 !important;
}

/* Скрытие лунки целей (перебивает display:flex !important у base) */
.m3-hud-goal-well.hidden {
  display: none !important;
}

/* Контейнер иконки и бейджа цели */
.m3-hud-goal-wrapper {
  position: relative !important;
  display: inline-block !important;
}

.m3-hud-goal-icon {
  font-size: 32px !important;
  line-height: 1 !important;
}

/* Бейдж — цифра цели */
.m3-hud-goal-badge {
  position: absolute !important;
  bottom: -5px !important;
  right: -3px !important;
  color: #FFF !important;
  font-size: 16px !important;
  font-family: 'Rubik', sans-serif !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  text-shadow:
    -1.5px -1.5px 0 #4A2E1B,
     1.5px -1.5px 0 #4A2E1B,
    -1.5px  1.5px 0 #4A2E1B,
     1.5px  1.5px 0 #4A2E1B !important;
}

/* --- Блок ходов (Стрелочки + Цифра) --- */
.m3-hud-moves-block {
  display: flex !important;
  align-items: center !important;
  margin-left: auto !important;
  cursor: pointer !important;
}

.m3-moves-arrows-stack {
  display: flex !important;
  flex-direction: column !important;
  font-size: 11px !important;
  color: #4A2E1B !important;
  margin-right: 3px !important;
  line-height: 1 !important;
  user-select: none !important;
}

.m3-moves-count {
  font-size: 28px !important;
  font-family: 'Rubik', sans-serif !important;
  font-weight: 900 !important;
  color: #4A2E1B !important;
  line-height: 1 !important;
}

/* Мало ходов — пульс */
.m3-hud-moves-block.moves-low .m3-moves-count {
  color: #c0392b !important;
  animation: movesLowPulse 0.7s ease-in-out infinite alternate;
}
.m3-hud-moves-block.moves-low {
  animation: movesLowPulse 0.9s ease-in-out infinite;
}

/* --- Блок уровня --- */
.m3-hud-level-block {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 auto !important; /* не выталкивается и не сжимается в ноль */
  min-width: 64px !important;
  max-width: 30% !important;
  padding: 0 10px !important;
  gap: 3px !important;
  box-sizing: border-box !important;
}

.m3-hud-level-label {
  font-size: 9px !important;
  font-family: 'Chandler Mountain Thin', 'Rubik', sans-serif !important;
  font-weight: 100 !important;
  color: rgba(255,255,255,0.55) !important;
  letter-spacing: 2px !important;
  text-transform: uppercase !important;
  line-height: 1 !important;
}

.m3-hud-level-num {
  font-size: 22px !important;
  font-family: 'Rubik', sans-serif !important;
  font-weight: 300 !important;
  color: #FFF !important;
  line-height: 1.1 !important;
}

/* --- Подсветка в туториале --- */
.m3-hud-moves-block.tut-moves-glow {
  position: relative !important;
  z-index: 40 !important;
  box-shadow:
    0 0 0 3px #ffd76a,
    0 0 16px rgba(255, 215, 100, 0.9),
    0 0 26px rgba(255, 215, 100, 0.6) !important;
  animation: tutMovesPulse 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
  transform: scale(1.08);
  border-radius: 8px !important;
}
.m3-hud-moves-block.tut-moves-glow::after {
  content: '👆';
  position: absolute;
  left: 50%;
  bottom: -24px;
  transform: translateX(-50%);
  font-size: 18px;
  animation: tutMovesArrow 0.9s ease-in-out infinite;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
  z-index: 41;
}
@keyframes movesLowPulse {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(1.12); opacity: 0.85; }
}

.out-of-moves-card .oom-lead {
  font-size: 13px;
  text-align: center;
  margin: 0 0 16px;
  line-height: 1.45;
  color: var(--ink);
}
.out-of-moves-card .oom-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.out-of-moves-card .oom-buy {
  background: linear-gradient(180deg, #ffd15a, #e6a800);
  color: var(--ink);
}
.out-of-moves-card .oom-hint {
  margin: 14px 0 0;
  font-size: 12px;
  text-align: center;
  opacity: 0.75;
}

#boardWrap {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
  overflow: visible;
  min-height: 0;
  /* Рама перенесена на edge-ячейки — контейнер прозрачен */
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
/* L6 scrollField: окно текущей фазы; размеры клеток задаёт JS (квадрат) */
#boardWrap.scroll-field-mode {
  overflow: hidden !important;
  max-width: 100% !important;
  /* width/height выставляет syncGridDimensions в px — без aspect-ratio, чтобы не коробило */
  aspect-ratio: auto !important;
  flex: 0 0 auto !important;
}
#boardWrap.scroll-field-mode #scrollViewport,
#boardWrap.scroll-field-mode .scroll-viewport {
  overflow: hidden !important;
  position: relative;
  flex: 0 0 auto;
}
#boardWrap.scroll-field-mode #board {
  max-width: none !important;
  aspect-ratio: auto !important;
  /* width/height в px из JS — строгие квадратные клетки */
}

/* Декоративная нижняя плита 1 — большая, образует рамку */
#boardWrap::before {
  content: '';
  position: absolute;
  inset: -48px;
  background: linear-gradient(145deg, #b0b0b0 0%, #8a8a8a 100%);
  border-radius: 34px;
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.3),
    inset 0 1px 3px rgba(255, 255, 255, 0.35),
    inset 0 -2px 4px rgba(0, 0, 0, 0.12);
  z-index: -2;
  pointer-events: none;
}
/* Декоративная нижняя плита 2 — ещё больше, внахлёст с первой */
#boardWrap::after {
  content: '';
  position: absolute;
  inset: -72px;
  background: linear-gradient(155deg, #c8c8c8 0%, #999 100%);
  border-radius: 40px;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.2),
    inset 0 2px 4px rgba(255, 255, 255, 0.3),
    inset 0 -3px 6px rgba(0, 0, 0, 0.08);
  z-index: -3;
  pointer-events: none;
}

#board {
  position: relative;
  width: 100%;
  aspect-ratio: var(--cols) / var(--rows);
  touch-action: none;
  transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.25s ease-out;
  will-change: transform, opacity;
  /* Прозрачный — ячейки формируют плиту, дырки просвечивают комнату */
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.3);
}
#board::before { display: none !important; }
#board::after { display: none !important; }
/* ═══════════════════════════════════════════════════════════════════
   Tutorial dim — БЕЗ filter:brightness на фишках (iOS WebKit залипает
   brightness на уже отрисованных .tile; новые спавны остаются яркими).
   Затемнение = только .m3-tut-mask / spotlight. Фишки всегда с обычной тенью.
   ═══════════════════════════════════════════════════════════════════ */

/* Во время обучения: «лишние» фишки только блокируем кликом.
   НЕ трогаем filter/brightness на .tile — WebKit (Safari/Telegram)
   залипает brightness на уже отрисованных узлах: старые фишки остаются
   тёмными, а новые после каскада яркие. Визуальный dim = только spotlight. */
body.m3-tutorial-dimming #board.tut-dim .tile:not(.tut-highlight) {
  pointer-events: none !important;
}
/* Цель кликабельна; желтая box-shadow подсветка убрана (по просьбе) —
   фокус теперь несёт только spotlight-затемнение вокруг обучаемых клеток */
body.m3-tutorial-dimming #board.tut-dim .tile.tut-highlight {
  z-index: 8 !important;
  pointer-events: auto !important;
  transform: none !important;
}
body.m3-tutorial-dimming #board.tut-dim .tile.tut-highlight::after {
  display: none !important;
  content: none !important;
}

/* Все фишки — обычная тень (и filter, и -webkit-filter — Safari).
   Без !important: анимации (орбита бустеров и т.п.) пишут inline filter. */
#board .tile {
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.22));
  -webkit-filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.22));
}
body:not(.m3-tutorial-dimming) #board .tile.tut-highlight,
body.m3-no-tutorial-dim #board .tile.tut-highlight {
  transform: none !important;
  box-shadow: none !important;
}
body:not(.m3-tutorial-dimming) #board .tile.tut-highlight::after,
body.m3-no-tutorial-dim #board .tile.tut-highlight::after {
  display: none !important;
  content: none !important;
}

/* mask/spotlight только при активном dimming */
body:not(.m3-tutorial-dimming) .m3-tut-mask,
body:not(.m3-tutorial-dimming) .m3-tut-spotlight,
body:not(.m3-tutorial-dimming) #m3TutSpotlight,
body.m3-no-tutorial-dim .m3-tut-mask,
body.m3-no-tutorial-dim .m3-tut-spotlight,
body.m3-no-tutorial-dim #m3TutSpotlight {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  box-shadow: none !important;
}

/* Затемнение плашки HUD (цели + ходы + уровень) во время активного обучения.
   Само затемнение даёт fullscreen-слой .m3-tut-spotlight (fixed, на весь экран);
   здесь остаётся только блокировка кликов по плашке и крестику. */
body.m3-tutorial-dimming .match3-header-container .m3-hud-base-plate,
body.m3-tutorial-dimming .match3-header-container .m3-floating-exit-btn {
  pointer-events: none !important;
}

/* После free — полный kill overlay */
body.m3-no-tutorial-dim #m3Tutorial.m3-tutorial-done,
body.m3-no-tutorial-dim #m3Tutorial.hidden,
body.m3-no-tutorial-dim #m3Tutorial {
  display: none !important;
  pointer-events: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Туториал Homescapes */
.m3-tutorial {
  position: absolute;
  inset: 0;
  /* Выше плашки HUD (z:100): fullscreen-spotlight внутри должен накрывать
     и её, и панель бустеров. Пузырь/рука остаются поверх слоя (32/34 внутри). */
  z-index: 101;
  pointer-events: none;
}
.m3-tutorial.hidden { display: none !important; }
/* Старая radial-маска по центру поля — на мобилке давала «белое окно» мимо цели.
   Затемнение только через .m3-tut-spotlight (привязан к клеткам). */
.m3-tut-mask {
  position: absolute;
  inset: -12%;
  background: rgba(0, 0, 0, 0.62);
  border-radius: 24px;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(
    ellipse 62% 56% at 50% 50%,
    transparent 0%,
    transparent 30%,
    rgba(0, 0, 0, 0.1) 42%,
    rgba(0, 0, 0, 0.3) 55%,
    rgba(0, 0, 0, 0.62) 72%,
    #000 88%
  );
  mask-image: radial-gradient(
    ellipse 62% 56% at 50% 50%,
    transparent 0%,
    transparent 30%,
    rgba(0, 0, 0, 0.1) 42%,
    rgba(0, 0, 0, 0.3) 55%,
    rgba(0, 0, 0, 0.62) 72%,
    #000 88%
  );
}
/* Яркое поле / конец обучения: mask и spotlight полностью выключены
   (не opacity:0 — слой не должен оставаться «живым»). */
.m3-tutorial.tut-bright .m3-tut-mask,
.m3-tutorial.hidden .m3-tut-mask {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
.m3-tutorial.tut-bright .m3-tut-spotlight,
.m3-tutorial.hidden .m3-tut-spotlight {
  display: none !important;
  pointer-events: none !important;
}
/* Spotlight: мягкое «окно» вокруг целевых клеток.
   Старая homescapes-схема: тень на весь экран + тёплое свечение по краю окна. */
.m3-tut-spotlight {
  position: absolute;
  z-index: 7;
  pointer-events: none;
  border-radius: 22px;
  border: none !important;
  background: transparent;
  box-shadow:
    0 0 0 9999px rgba(0, 0, 0, 0.5),
    0 0 32px 20px rgba(255, 255, 255, 0.18),
    0 0 56px 32px rgba(255, 220, 100, 0.15);
  filter: blur(1.5px);
  -webkit-filter: blur(1.5px);
  transition:
    left 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
    top 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
    width 0.22s ease,
    height 0.22s ease,
    opacity 0.18s ease;
}
.m3-tut-spotlight.hidden { display: none !important; }

.m3-tut-speech {
  position: absolute;
  left: 4%;
  top: 2%;
  transform: none;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: min(94%, 360px);
  z-index: 32;
  pointer-events: none;
  animation: tutSpeechIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.m3-tut-speech.tut-speech-free {
  left: 50%;
  top: 6px;
  transform: translateX(-50%);
  animation: none;
}
/* L3 шаг Г: заготовка в верхней части поля — опускаем диалог, чтобы её было видно */
.m3-tut-speech.m3-tut-speech-low {
  top: 64%;
}
@keyframes tutSpeechIn {
  from { 
    opacity: 0; 
    transform: translateY(-12px) scale(0.92); 
  }
  to   { 
    opacity: 1; 
    transform: none; 
  }
}
.m3-tut-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff9e6 0%, #fffcf0 100%);
  border: 3px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow:
    0 0 0 3px #e8d469,
    0 -2px 4px rgba(255, 255, 255, 0.4) inset,
    0 8px 20px rgba(0, 0, 0, 0.3);
}
.m3-tut-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: 
    contrast(1.15)
    saturate(1.25)
    brightness(1.08)
    drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  object-position: center center;
  display: block;
  pointer-events: none;
  user-select: none;
}
.m3-tut-bubble {
  flex: 1;
  background: linear-gradient(135deg, #FFFEF8 0%, #FFFCF0 100%);
  color: #4A2E1B;
  border-radius: 24px;
  padding: 14px 16px 15px;
  border: 1.5px solid #7D533C;
  box-shadow:
    0 -4px 0 rgba(100, 50, 30, 0.08),
    0 6px 16px rgba(50, 30, 10, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -2px 4px rgba(0, 0, 0, 0.06);
  font-family: 'Nunito', 'Rubik', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.48;
  font-weight: 700;
  letter-spacing: 0.005em;
  position: relative;
}
/* Плавный изогнутый хвостик облака (вместо треугольника) */
.m3-tut-bubble::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 26px;
  width: 20px;
  height: 18px;
  background: linear-gradient(135deg, #FFFCF0 0%, #FFFEF8 100%);
  border-radius: 0 18px 18px 2px;
  box-shadow: 
    -2px 2px 8px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transform: rotate(-15deg);
}
.m3-tut-name {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 2px;
  color: #8a4a20;
}
.m3-tut-name.hidden { display: none !important; }
.m3-tut-text {
  color: #c45a1a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
.m3-tut-hand {
  position: absolute;
  z-index: 34;
  transform: translate(-30%, -20%);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3)) brightness(1.08);
  pointer-events: none;
  user-select: none;
}
.tut-hand-img {
  display: block;
  width: auto;
  height: 44px;
  image-rendering: auto;
}
.m3-tut-hand.hidden { display: none !important; }
.m3-tut-hand.swipe-left {
  animation: tutHandSwipeLeft 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}
.m3-tut-hand.swipe-right {
  animation: tutHandSwipeRight 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}
.m3-tut-hand.swipe-down {
  animation: tutHandSwipeDown 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}
.m3-tut-hand.swipe-up {
  animation: tutHandSwipeUp 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}
.m3-tut-hand.tap-pulse {
  animation: tutHandTap 1s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}
@keyframes tutHandSwipeLeft {
  0%   { transform: translate(-8%, -20%) scale(1); opacity: 0.8; }
  45%  { transform: translate(-72%, -20%) scale(0.98); opacity: 1; }
  100% { transform: translate(-8%, -20%) scale(1); opacity: 0.8; }
}
@keyframes tutHandSwipeRight {
  0%   { transform: translate(-52%, -20%) scale(1); opacity: 0.8; }
  45%  { transform: translate(12%, -20%) scale(0.98); opacity: 1; }
  100% { transform: translate(-52%, -20%) scale(1); opacity: 0.8; }
}
@keyframes tutHandSwipeDown {
  0%   { transform: translate(-30%, -42%) scale(1); opacity: 0.8; }
  45%  { transform: translate(-30%, 18%) scale(0.98); opacity: 1; }
  100% { transform: translate(-30%, -42%) scale(1); opacity: 0.8; }
}
@keyframes tutHandSwipeUp {
  0%   { transform: translate(-30%, 12%) scale(1); opacity: 0.8; }
  45%  { transform: translate(-30%, -48%) scale(0.98); opacity: 1; }
  100% { transform: translate(-30%, 12%) scale(1); opacity: 0.8; }
}
@keyframes tutHandTap {
  0%, 100% { transform: translate(-30%, -20%) scale(1); opacity: 0.85; }
  25%      { transform: translate(-30%, -20%) scale(0.85); opacity: 1; }
  50%      { transform: translate(-30%, -20%) scale(1.15); opacity: 0.9; }
}
/* Импульс-волна при клике (новая анимация) */
.m3-tut-hand.tap-pulse::after {
  content: '';
  position: absolute;
  width: 32px;
  height: 32px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  pointer-events: none;
  animation: tutHandImpulse 0.2s ease-out;
}
@keyframes tutHandImpulse {
  0% {
    width: 32px;
    height: 32px;
    opacity: 1;
    border-width: 2px;
  }
  100% {
    width: 68px;
    height: 68px;
    opacity: 0;
    border-width: 1px;
  }
}
/* Полностью спрятаны (L1 — обучения по бустерам ещё нет; не «призраки» с ценами) */
.tut-boosters-hidden,
body.m3-l1-no-boosters #m3BoosterPanel {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: none !important;
}

@keyframes tutMovesPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}
@keyframes tutMovesArrow {
  0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.85; }
  50% { transform: translateX(-50%) translateY(-6px); opacity: 1; }
}

/* Pre-level locked boosters — финальные стили в блоке §10 (золотой замок) */

/* Сейф (бонус монет после победы, L13+) */
.safe-bonus-layer {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(10, 6, 4, 0.45);
}
.safe-bonus-layer.hidden { display: none !important; }
.safe-bonus-card {
  position: relative;
  width: min(280px, 82vw);
  padding: 28px 20px 22px;
  border-radius: 22px;
  background: linear-gradient(165deg, #3a2a18 0%, #1a120c 100%);
  border: 3px solid #e8c070;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5), inset 0 0 24px rgba(232, 192, 112, 0.15);
  text-align: center;
  color: #fff8e7;
  transform: scale(0.7);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.34, 1.5, 0.64, 1), opacity 0.35s ease;
}
.safe-bonus-layer.safe-on .safe-bonus-card {
  transform: scale(1);
  opacity: 1;
}
.safe-bonus-layer.safe-out .safe-bonus-card {
  transform: scale(0.85) translateY(-20px);
  opacity: 0;
}
.safe-bonus-icon {
  font-size: 56px;
  line-height: 1;
  filter: drop-shadow(0 0 12px rgba(255, 200, 80, 0.8));
  animation: safeIconPop 0.7s cubic-bezier(0.34, 1.5, 0.64, 1) both;
}
.safe-bonus-glow {
  position: absolute;
  inset: 20% 15%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 210, 90, 0.35), transparent 70%);
  pointer-events: none;
  animation: safeGlow 1.2s ease-in-out infinite alternate;
}
.safe-bonus-title {
  margin-top: 8px;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffd76a;
}
.safe-bonus-coins {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 800;
  color: #fff8e7;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
@keyframes safeIconPop {
  0% { transform: scale(0.4) rotate(-12deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes safeGlow {
  from { opacity: 0.55; }
  to { opacity: 1; }
}
.results-line.results-safe {
  color: #e8c070;
  font-weight: 700;
}

/* ==========================================================================
   Жалюзи (blinds) — stagger + tilt, без видео
   ========================================================================== */
.m3-loading-curtain {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: all;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: transparent;
}
.m3-loading-curtain.hidden { display: none !important; }

/* 3D-сцена для наклона ламелей по X */
.blinds-container {
  position: absolute;
  inset: 0;
  z-index: 1;
  perspective: 1100px;
  perspective-origin: 50% 18%;
  overflow: hidden;
  pointer-events: none;
  /* лёгкая виньетка за жалюзи */
  background: rgba(18, 10, 6, 0.15);
}
.blind-slat {
  position: absolute;
  left: 0;
  width: 100%;
  /* top/height задаёт JS */
  box-sizing: border-box;
  transform-origin: 50% 50%;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform;
  /* тёмное дерево, вертикальный градиент + лёгкая «древесность» */
  background:
    linear-gradient(90deg,
      rgba(0,0,0,0.18) 0%,
      transparent 8%,
      transparent 92%,
      rgba(0,0,0,0.18) 100%),
    linear-gradient(180deg,
      #4a3426 0%,
      #3a281c 18%,
      #2c1c14 55%,
      #1f140e 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 220, 180, 0.1),
    inset 0 -2px 3px rgba(0, 0, 0, 0.25);
}
/* блик-полоска сверху ламели (объём) */
.blind-slat::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 35%;
  background: linear-gradient(180deg,
    rgba(255, 230, 200, 0.14) 0%,
    rgba(255, 230, 200, 0) 100%);
  pointer-events: none;
}
/* тень снизу — «накладка» на следующую ламель */
.blind-slat::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 5px;
  background: linear-gradient(180deg, rgba(0,0,0,0.35) 0%, transparent 100%);
  pointer-events: none;
}

.m3-loading-center {
  position: relative;
  z-index: 2;
  text-align: center;
  color: #fff8e7;
  text-shadow: 0 2px 10px rgba(0,0,0,0.55);
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.m3-loading-curtain.is-open .m3-loading-center,
.m3-loading-curtain.blinds-opening .m3-loading-center {
  opacity: 0;
}
.m3-loading-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 28px;
  animation: m3LoadHint 1.4s ease-in-out infinite;
}
.m3-loading-hint span { line-height: 1; }
/* Картинка-подсказка уровня (без рамок) */
.loading-hint-img {
  max-width: min(340px, 72vw);
  max-height: 170px;
  width: auto;
  height: auto;
  border-radius: 14px;
}
.m3-loading-label {
  font-family: 'Nunito', 'Rubik', system-ui, sans-serif;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.m3-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255,248,231,0.35);
  border-top-color: #fff8e7;
  border-radius: 50%;
  animation: m3Spin 0.7s linear infinite;
}
@keyframes m3Spin {
  to { transform: rotate(360deg); }
}
@keyframes m3LoadHint {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.06); opacity: 1; }
}

/* prefers-reduced-motion: мгновенное закрытие/открытие */
@media (prefers-reduced-motion: reduce) {
  .blind-slat {
    transition: none !important;
  }
}

/* ==========================================================================
   ЯЧЕЙКИ ПОЛЯ — монолитная плита (без зазоров)
   ==========================================================================
   Ячейки сливаются в единое целое. Контур обводки идёт только по
   внешнему краю фигуры (edge-* классы). Пустые клетки прозрачны. */
.grid-cell {
  position: absolute;
  width: calc(100% / var(--cols));
  height: calc(100% / var(--rows));
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 0 !important;
  /* Радиус скругления углов: контур фигуры и одиночный островок */
  --cell-edge-radius: 16px;
  --cell-island-radius: min(7px, 12%);
  /* Мягкий тёмно-серый квадрат с мягкими краями */
  background: #C8C8C8;
  border: none !important;
  /* Плотно прилегают — без скругления, щелей нет */
  border-radius: 0;
  /* Мягкая внутренняя тень — объём «лунки» */
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.5),
    inset 0 -2px 4px rgba(0, 0, 0, 0.12) !important;
  z-index: 1;
  pointer-events: none;
}

/* ==========================================================================
   3D-ОБВОДКА ПО КОНТУРУ — border на внешних краях
   ==========================================================================
   Каждый внешний край ячейки получает border нужного цвета
   (имитация света сверху-слева). */
.grid-cell.edge-top    { border-top: 4px solid #D2DFEB !important; }
.grid-cell.edge-bottom { border-bottom: 4px solid #8FA2B0 !important; }
.grid-cell.edge-left   { border-left: 4px solid #A9BCCD !important; }
.grid-cell.edge-right  { border-right: 4px solid #95A9BA !important; }

/* Угловые стыки — скругление 16px на внешних углах фигуры */
.grid-cell.edge-top.edge-left     { border-top-left-radius: var(--cell-edge-radius, 16px) !important; }
.grid-cell.edge-top.edge-right    { border-top-right-radius: var(--cell-edge-radius, 16px) !important; }
.grid-cell.edge-bottom.edge-left  { border-bottom-left-radius: var(--cell-edge-radius, 16px) !important; }
.grid-cell.edge-bottom.edge-right { border-bottom-right-radius: var(--cell-edge-radius, 16px) !important; }

/* Одиночная клетка-островок (все четыре края внешние): 16px на каждой
   стороне съедали клетку целиком и она выглядела круглой. Держим её
   аккуратным квадратом: те же мягкие углы, но радиус ограничен долей клетки
   (~5 px на клетке 41 px), а не 16 px. */
.grid-cell.edge-top.edge-bottom.edge-left.edge-right {
  border-radius: var(--cell-island-radius, min(7px, 12%)) !important;
}

/* ==========================================================================
   ПУСТЫЕ КЛЕТКИ (дырки) — прозрачные, комната просвечивает
   ========================================================================== */
.grid-cell.cell-empty {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  z-index: 0;
}

/* 🟥 КОВЁР (Homescapes-стиль, ДИНАМИКА): цельное полотно на #carpetCanvas.
   Канвас (z-index 0) рисует остров: бесшовная текстура-ворс, тёмный кант
   только по внешнему контуру, скруглённые КОНТУРНЫЕ углы, мягкая тень.
   Слои: BACKGROUND → КОВЁР (канвас) → ФИШКИ (.tile) → эффекты.
   Появление/растекание/idle-блеск — ТОЖЕ на канвасе (rAF-цикл в движке):
   клеточный CSS-патч роста убран (раньше дублировал отрисовку). */

/* Canvas underlay — цельное полотно ковра */
#carpetCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Ячейки ковра: прозрачное окно в канвас — ни фона, ни лунки, ни ободков */
.grid-cell.carpet {
  z-index: 1 !important;
  overflow: visible !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

/* Рост ковра рисует канвас (класс .carpet-spread остаётся совместимым:
   внутри него живут VFX-элементы — кольцо и искры) */
.grid-cell.carpet.carpet-spread::after {
  content: none;
}

/* Фишки ВСЕГДА над ковром и плитой */
.tile {
  z-index: 5 !important;
}

/* ==========================================================================
   🌿 КОВЁР VFX: золотой край + искры + финальный блик (Homescapes-растекание)
   Дочерние элементы живут ВНУТРИ маски .carpet-spread → открываются волной
   и при этом остаются ПОД фишкой (z-index клетки ниже .tile).
   ========================================================================== */

/* Светящееся кольцо на фронте распространения (edge glow) */
.carpet-edge-ring {
  position: absolute;
  width: 44%;
  height: 44%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(circle,
    rgba(255, 190, 90, 0) 40%,
    rgba(255, 214, 130, 0.85) 60%,
    rgba(255, 236, 180, 0.95) 68%,
    rgba(255, 190, 90, 0) 80%);
  filter: drop-shadow(0 0 5px rgba(255, 205, 110, 0.85));
  animation: carpetEdgeRing 0.55s cubic-bezier(0.2, 0.7, 0.25, 1) forwards;
}
@keyframes carpetEdgeRing {
  0%   { transform: translate(-50%, -50%) scale(0.15); opacity: 0; }
  12%  { opacity: 0.95; }
  60%  { transform: translate(-50%, -50%) scale(1.05); opacity: 0.6; }
  100% { transform: translate(-50%, -50%) scale(1.9); opacity: 0; }
}

/* Золотая искра, рассыпается у фронта распространения */
.carpet-spark {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(circle, #fff 0%, #ffd66b 40%, rgba(255, 190, 80, 0) 75%);
  box-shadow: 0 0 5px rgba(255, 210, 110, 0.9);
  animation: carpetSparkle 0.5s ease-out forwards;
}
@keyframes carpetSparkle {
  0%   { opacity: 0; transform: scale(0.2); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.7) translateY(-8px); }
}

/* Финальный блик по ковру — отключён */
.carpet-shine {
  display: none !important;
}

/* Фишки — пухлые, с мягкой тенью вниз; z-index выше ковра (::after на клетке) */
.tile {
  position: absolute;
  /* Чуть меньше ячейки — фишка с отступом от краёв */
  width: calc(100% / var(--cols) * 0.93);
  height: calc(100% / var(--rows) * 0.93);
  /* По умолчанию — Ease.OutQuad-ish (падение / общее) */
  transition:
    left .30s cubic-bezier(0.33, 0, 0.2, 1),
    top .30s cubic-bezier(0.33, 0, 0.2, 1);
  cursor: pointer;
  z-index: 5;
  will-change: left, top;
  /* Мягкая тень строго вниз — визуально приподнята над коврои/плиткой */
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.22));
}

/* Свайп: EaseInOut — плавный разгон и торможение */
#board.board-mode-swap:not(.no-tile-anim) .tile {
  transition:
    left 0.26s cubic-bezier(0.42, 0, 0.58, 1),
    top 0.26s cubic-bezier(0.42, 0, 0.58, 1) !important;
}

/* Откат свапа: EaseOutBack — упругий перелёт */
#board.board-mode-swapback:not(.no-tile-anim) .tile {
  transition:
    left 0.20s cubic-bezier(0.34, 1.56, 0.64, 1),
    top 0.20s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

/* Каскад падения: Ease.OutQuad + per-tile delay (inline).
   Длительность синхронизирована с FALL_MS (135) в match3.js */
#board.board-mode-cascade:not(.no-tile-anim) .tile {
  transition:
    left 0.135s cubic-bezier(0.33, 0, 0.2, 1),
    top 0.135s cubic-bezier(0.33, 0, 0.2, 1) !important;
}

/* Во время гравитации/snap — БЕЗ transition (иначе «летят вверх» из-за гонок CSS) */
#board.no-tile-anim .tile {
  transition: none !important;
  transition-delay: 0ms !important;
}

.tile-inner {
  position: absolute;
  inset: 0; /* Растягиваем фишку на все 100% ячейки */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0 !important; /* Полностью скрываем старый текст эмодзи */
  background: transparent; /* Убираем серую бумагу, чтобы PNG были прозрачными */
  border: none; /* Убираем черную рамку */
  transition: transform .18s ease, opacity .18s ease, box-shadow .18s ease;
  will-change: transform, opacity;
}

/* Глянцевый блик — яркая белая дуга сверху фишки */
.tile-inner::before {
  content: '';
  position: absolute;
  top: 8%;
  left: 18%;
  right: 18%;
  height: 30%;
  border-radius: 50%;
  background: radial-gradient(ellipse 100% 80% at 50% 30%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.2) 40%, transparent 70%);
  pointer-events: none;
  z-index: 8;
}

/* Ракета «лопает» фишку при пролёте: вспухание → схлопывание с прозрачностью */
.tile.tile-pop .tile-inner {
  animation: tileRocketPop 0.24s ease-in forwards;
  pointer-events: none;
}
@keyframes tileRocketPop {
  0%   { transform: scale(1);    opacity: 1; }
  35%  { transform: scale(1.28); opacity: 1; }
  100% { transform: scale(0.08); opacity: 0; }
}

/*
 * Мягкое приземление с лёгким пружиниванием:
 *  squash 0.055s → scale(1.06, 0.94)
 *  stretch 0.075s → scale(0.97, 1.03)
 *  stabilize 0.07s → 1.0
 *  total ≈ 0.20s
 */
@keyframes tileLandBounce {
  0%   { transform: scale(1, 1); }
  28%  { transform: scale(1.06, 0.94); }   /* мягкое сплющивание */
  65%  { transform: scale(0.97, 1.03); }   /* лёгкое растяжение */
  100% { transform: scale(1, 1); }
}
.tile-inner.tile-land-bounce {
  animation: tileLandBounce 0.20s cubic-bezier(0.25, 0.1, 0.2, 1) both;
  transform-origin: 50% 92%;
}

/* Мягкая волна затухания вверх по столбцу (--wobble-amp 1→0) */
@keyframes tileNeighborWobble {
  0%   { transform: translateY(0) scale(1, 1); }
  30%  {
    transform:
      translateY(calc(-3.5px * var(--wobble-amp, 1)))
      scale(calc(1 + 0.03 * var(--wobble-amp, 1)), calc(1 - 0.04 * var(--wobble-amp, 1)));
  }
  65%  {
    transform:
      translateY(calc(1.2px * var(--wobble-amp, 1)))
      scale(calc(1 - 0.015 * var(--wobble-amp, 1)), calc(1 + 0.02 * var(--wobble-amp, 1)));
  }
  100% { transform: translateY(0) scale(1, 1); }
}
.tile-inner.tile-neighbor-wobble {
  animation: tileNeighborWobble 0.32s cubic-bezier(0.22, 0.8, 0.3, 1) both;
  animation-delay: var(--wobble-delay, 0ms);
  transform-origin: 50% 85%;
}

/* Hit-stop: микро-пауза «тяжести» взрыва */
#board.m3-hit-stop {
  filter: brightness(1.18) contrast(1.05);
}
#board.m3-hit-stop .tile {
  animation-play-state: paused !important;
}

/* Screen Shake — на #boardWrap, НЕ на #board.
   #board.transforms = scroll offset (translateX) + transition;
   shake на #board сбивал скролл и «коробил» поле при залпе самолётов. */
#boardWrap.shake-mild,
#boardWrap.shake-rocket,
#boardWrap.shake-intense,
#boardWrap.shake-bomb,
#boardWrap.shake-rainbow {
  /* не интерполировать transform transition'ом во время keyframes */
  transition: none !important;
}
#boardWrap.shake-mild {
  animation: boardShakeMild 0.15s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
#boardWrap.shake-rocket {
  animation: boardShakeRocket 0.14s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
#boardWrap.shake-intense,
#boardWrap.shake-bomb {
  animation: boardShakeRadial 0.16s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
#boardWrap.shake-rainbow {
  animation: boardShakeBuzz 0.20s linear both;
}
@keyframes boardShakeMild {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2px, 1px); }
  40% { transform: translate(2px, -1px); }
  60% { transform: translate(-1px, -2px); }
  80% { transform: translate(1px, 1px); }
}
@keyframes boardShakeRocket {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(0, -3px); }
  50% { transform: translate(0, 2px); }
  75% { transform: translate(0, -1px); }
}
@keyframes boardShakeRadial {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  15% { transform: translate(-4px, 2px) rotate(-0.4deg); }
  30% { transform: translate(4px, -3px) rotate(0.5deg); }
  45% { transform: translate(-3px, -2px) rotate(-0.3deg); }
  60% { transform: translate(3px, 3px) rotate(0.3deg); }
  75% { transform: translate(-2px, 1px) rotate(-0.15deg); }
  90% { transform: translate(1px, -1px) rotate(0.1deg); }
}
@keyframes boardShakeBuzz {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-2px, 0); }
  20% { transform: translate(2px, 1px); }
  30% { transform: translate(-1px, -1px); }
  40% { transform: translate(2px, 0); }
  50% { transform: translate(-2px, 1px); }
  60% { transform: translate(1px, -1px); }
  70% { transform: translate(-1px, 0); }
  80% { transform: translate(2px, -1px); }
  90% { transform: translate(-1px, 1px); }
}

@media(min-width:460px){ .tile-inner { font-size: 26px; } }
/* Препятствия и бустеры: только PNG, без цветных подложек/рамок/inset-теней.
   (Инжект в match3.js раньше рисовал градиенты — они торчали сквозь alpha PNG.) */
.tile.box .tile-inner,
.tile.vase .tile-inner,
.tile.cookie .tile-inner,
.tile.nut .tile-inner,
.tile.plaid .tile-inner,
.tile.stone .tile-inner,
.tile.surprise-box .tile-inner,
.tile.carpet-roll .tile-inner,
.tile.purple-foam .tile-inner,
.tile.foam .tile-inner,
.tile.ring-case .tile-inner,
.tile.ribbon .tile-inner,
.tile.oven .tile-inner,
.tile.phone .tile-inner,
.tile.ivy .tile-inner,
.tile.bomb .tile-inner,
.tile.plane .tile-inner,
.tile.rocket-row .tile-inner,
.tile.rocket-col .tile-inner,
.tile.rainbow .tile-inner,
.tile.donut .tile-inner {
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
}

/* Желе на поле: отдельная форма, ягода и число оставшихся слоёв. */
.grid-cell.jelly {
  --jelly-art: url('images/jelly_1.webp?v=18');
  --jelly-fruit-art: url('images/jelly_fruit_1.webp?v=18');
  position: absolute;
  background: var(--jelly-art) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
  overflow: hidden;
  z-index: 0;
}
.grid-cell.jelly.jelly-2 {
  --jelly-art: url('images/jelly_2.webp?v=18');
  --jelly-fruit-art: url('images/jelly_fruit_2.webp?v=18');
}
.grid-cell.jelly.jelly-opaque {
  --jelly-art: url('images/jelly_3.webp?v=18');
  --jelly-fruit-art: url('images/jelly_fruit_3.webp?v=18');
}
.grid-cell.jelly.jelly-fruit-visible { background-image: var(--jelly-fruit-art) !important; }
.grid-cell.jelly::before {
  content: attr(data-jelly-layers);
  position: absolute;
  right: 5%;
  bottom: 5%;
  width: 33%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(214, 237, 255, .75);
  border-radius: 50%;
  background: #203455;
  color: #f6f8ff;
  font: 800 clamp(9px, 2.3vw, 14px)/1 system-ui, sans-serif;
  z-index: 2;
  pointer-events: none;
}
/* Лёгкий отклик на удар — только opacity, без scale */
.grid-cell.jelly.jelly-hit {
  animation: jellyHit 0.22s ease-out;
}
@keyframes jellyHit {
  0%   { opacity: 1; }
  40%  { opacity: 0.72; }
  100% { opacity: 1; }
}
.fly-cherry {
  position: fixed;
  font-size: 18px;
  z-index: 220;
  pointer-events: none;
  transform: translate(-50%, -50%);
  opacity: 0.9;
}
/* 🧊 СТИЛИ МОРОЗНОГО ЛЬДА */
.tile.frozen {
  cursor: not-allowed;
}

/* Полупрозрачный голубой купол льда с эффектом размытия */
/* Сложные преграды: Лёд и Цепи (ИСПРАВЛЕНО — С ПОЗИЦИОНИРОВАНИЕМ) */
.tile.frozen .tile-inner::after { 
  content: "" !important; 
  position: absolute;
  inset: 0;
  background-size: 100% 100% !important; 
  background-repeat: no-repeat;
  background-position: center;
  backdrop-filter: none; 
  z-index: 6;
}
.tile.frozen-2 .tile-inner::after { background-image: url('images/ice_2.webp') !important; }
.tile.frozen-1 .tile-inner::after { background-image: url('images/ice_1.webp') !important; }

.tile.chained .tile-inner::after { 
  content: "" !important; 
  position: absolute;
  inset: 0; /* Растягиваем цепи на весь размер фишки */
  background-size: 100% 100% !important; 
  background-repeat: no-repeat;
  background-position: center;
  z-index: 7; /* Отображаем строго поверх фишки */
}
.tile.chain-2 .tile-inner::after { background-image: url('images/chain_2.webp') !important; }
.tile.chain-1 .tile-inner::after { background-image: url('images/chain_1.webp') !important; }

@keyframes iceShimmer {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}

/* Металлический блик на цепях: диагональный sweep-градиент */
.tile.chained::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 8;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 0%,
    transparent 35%,
    rgba(255, 255, 255, 0.25) 42%,
    rgba(200, 220, 255, 0.35) 45%,
    rgba(255, 255, 255, 0.25) 48%,
    transparent 55%,
    transparent 100%
  );
  background-size: 250% 100%;
  animation: chainMetalSheen 3s ease-in-out infinite;
}
@keyframes chainMetalSheen {
  0%   { background-position: 150% 0; }
  100% { background-position: -50% 0; }
}

/* Снятие/раскалывание льда */
.tile.frozen.ice-cracked .tile-inner::after {
  animation: iceCrack 0.25s ease-out forwards;
}

@keyframes iceCrack {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(1.3) rotate(10deg); opacity: 0; }
}

.tile.selected .tile-inner {
  transform: scale(1.12) rotate(-4deg);
  filter: drop-shadow(0 0 3px var(--gold)) drop-shadow(0 0 7px var(--gold));
  z-index: 2;
}

/* ДОБАВЛЕНО: Визуальная обратная связь при перетаскивании фишки пальцем/мышкой (свайп) */
.tile.dragging {
  z-index: 25;
}
.tile.dragging .tile-inner {
  transform: scale(1.1);
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.30)) drop-shadow(0 0 6px rgba(255, 220, 120, 0.25));
}

/* Swap elevation: фишка приподнимается при обмене — объёмный эффект */
.tile.swapping {
  z-index: 10;
}
.tile.swapping .tile-inner {
  transform: scale(1.12);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.30)) drop-shadow(0 0 8px rgba(255, 220, 120, 0.3));
}

.tile.shake .tile-inner { animation: shake .25s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-3.5px); }
  75% { transform: translateX(3.5px); }
}

/* ДОБАВЛЕНО: подсветка контура фишки во время авто-подсказки хода (раньше класс
   .match-hint навешивался в JS, но для него нигде не было CSS — подсказка была
   полностью невидима на экране) */
.tile.match-hint .tile-inner {
  animation: hintPulse 0.6s ease-in-out infinite alternate;
}
@keyframes hintPulse {
  from {
    transform: scale(1);
    filter: drop-shadow(0 0 2px rgba(255,214,90,0.5));
  }
  to {
    transform: scale(1.08);
    filter: drop-shadow(0 0 10px rgba(255,214,90,0.95)) drop-shadow(0 0 18px rgba(255,214,90,0.5));
  }
}

/* Уничтожение: scale → 0 (синхрон с CLEAR_MS ≈ 95ms в match3.js) */
.tile.clearing .tile-inner {
  transform: scale(0) rotate(12deg);
  opacity: 0;
  transition: transform 0.095s cubic-bezier(0.4, 0, 1, 1), opacity 0.08s ease-out !important;
}

/* вспышка убрана — для обычных фишек вместо неё шарики */

/* VFX частицы / debris */
.m3-spark {
  position: absolute;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  border-radius: 50% 40% 50% 40%;
  pointer-events: none;
  z-index: 130;
  will-change: transform, opacity;
}
.m3-vfx-flash {
  position: absolute;
  width: calc(140% / var(--cols));
  height: calc(140% / var(--rows));
  margin: 0;
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 125;
  /* ТЗ: scale → 2.0, исчезновение ~0.1s */
  transition: transform 0.10s cubic-bezier(0.15, 0.9, 0.3, 1), opacity 0.10s ease-out;
}
.m3-vfx-flash.m3-vfx-flash-on {
  transform: translate(-50%, -50%) scale(2.0);
  opacity: 0.95;
}
/* шлейф за летящими в цель */
.m3-goal-trail {
  position: fixed;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  margin-top: -5px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.55;
  transition: opacity 0.28s ease-out, transform 0.28s ease-out;
  will-change: opacity, transform;
}
.fly-apple {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  font-size: 22px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
  will-change: left, top, transform, opacity;
}
.fly-chip-goal {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.45));
  will-change: left, top, transform;
  transform-origin: center center;
}
.fly-chip-goal .icon-img {
  width: 100% !important;
  height: 100% !important;
  display: block;
  object-fit: contain;
}
.m3-collapse-ball {
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  z-index: 9999;
  will-change: transform, opacity;
}
.m3-box-chip,
.m3-box-chunk {
  position: absolute;
  width: 7px;
  height: 5px;
  margin-left: -3px;
  margin-top: -2px;
  background: linear-gradient(135deg, #d4a574, #8b5a2b);
  border-radius: 1px;
  pointer-events: none;
  z-index: 128;
  transition: transform 0.38s cubic-bezier(0.25, 0.6, 0.35, 1), opacity 0.38s ease-out;
  will-change: transform, opacity;
}
.m3-box-chunk {
  width: 11px;
  height: 8px;
  background: linear-gradient(135deg, #e0b888, #6b3f1a);
  transition-duration: 0.5s;
}
.m3-box-dust {
  position: absolute;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(180,140,90,0.55) 0%, transparent 70%);
  pointer-events: none;
  z-index: 127;
  transition: transform 0.4s ease-out, opacity 0.4s ease-out;
}
.m3-chain-frag {
  position: absolute;
  margin-left: -50%;
  margin-top: -50%;
  border: 2px solid #8a939e;
  border-radius: 40% 60% 55% 45% / 50% 40% 60% 50%;
  box-shadow: inset 0 0 0 1px #bcc5ce, 0 1px 2px rgba(0,0,0,0.25);
  pointer-events: none;
  z-index: 129;
  will-change: transform, opacity;
  opacity: 1;
}

.tile.box-hit-flash .tile-inner {
  animation: boxHitFlash 0.22s ease-out;
}
@keyframes boxHitFlash {
  0% { filter: brightness(1.5); transform: scale(1.06); }
  100% { filter: brightness(1); transform: scale(1); }
}
.m3-plane-trail {
  position: absolute;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  border-radius: 50%;
  /* Реактивная струя: бело-жёлтое ядро → оранжевый → красный → прозрачный */
  background: radial-gradient(circle,
    rgba(255, 255, 210, 0.95) 0%,
    rgba(255, 200, 80, 0.75) 30%,
    rgba(255, 130, 40, 0.5) 55%,
    rgba(230, 60, 20, 0.25) 75%,
    transparent 100%);
  pointer-events: none;
  z-index: 109;
  opacity: 0.95;
  transform: scale(1);
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}
.m3-plane-trail.m3-plane-trail-fade {
  opacity: 0;
  transform: scale(0.15);
}
/* Пламя реактивного самолётика: мерцающая струя за хвостом */
.m3-plane-jet {
  position: absolute;
  width: 26px;
  height: 14px;
  margin-left: -13px;
  margin-top: -7px;
  pointer-events: none;
  z-index: 108;
  border-radius: 60% 60% 50% 50% / 90% 90% 10% 10%;
  background: radial-gradient(ellipse at center,
    rgba(255, 240, 160, 0.95) 0%,
    rgba(255, 170, 60, 0.8) 40%,
    rgba(255, 90, 20, 0.5) 70%,
    transparent 100%);
  animation: planeJetFlicker 90ms infinite alternate ease-in-out;
  transform-origin: 0% 50%;
}
@keyframes planeJetFlicker {
  0%   { transform: scaleX(1)   scaleY(0.85); opacity: 0.9; }
  100% { transform: scaleX(1.25) scaleY(1.15); opacity: 1; }
}

/* Бустеры: без цветных подложек, БЕЗ свечения и мигания — только чистая PNG */
.tile.bomb .tile-inner {
  background-color: transparent !important;
}

.tile.rocket-row .tile-inner {
  background-color: transparent !important;
}
.tile.rocket-row.selected .tile-inner {
  transform: scale(1.12);
}

.tile.rocket-col .tile-inner {
  background-color: transparent !important;
}

.tile.plane .tile-inner {
  background-color: transparent !important;
}

/* Радуга idle: чистая PNG, без свечения и вращения */
.tile.rainbow .tile-inner {
  background-color: transparent !important;
}

/* Активация: фиксация; статичный спрайт прячем — сверху GIF */
.tile.rainbow.rainbow-activate {
  z-index: 80 !important;
}
.tile.rainbow.rainbow-activate .tile-inner {
  animation: rainbowActivateSpin 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) infinite !important;
}
.tile.rainbow.rainbow-igniting .tile-inner {
  /* GIF поверх — webp не мигает под ним */
  opacity: 0 !important;
  animation: none !important;
}
.tile.rainbow-target-vibrate .tile-inner {
  animation: rainbowTargetShake 0.1s ease-in-out infinite !important;
}
@keyframes rainbowTargetShake {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(2px, -1.5px) rotate(-2deg); }
  50% { transform: translate(-2px, 1.5px) rotate(2deg); }
  75% { transform: translate(1.5px, 1.5px) rotate(-1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}
/* legacy straight laser (kept for safety if old class still used) */
.rainbow-laser.rainbow-laser-bolt {
  height: 3px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.7) 0%,
    #7CFF6B 35%,
    #C77DFF 75%,
    transparent 100%
  );
  box-shadow:
    0 0 6px rgba(124, 255, 107, 0.7),
    0 0 12px rgba(199, 125, 255, 0.55);
  filter: saturate(1.2) brightness(1.05);
  opacity: 0.9;
}

@keyframes rainbowActivateSpin {
  0% {
    transform: scale(1.08);
    filter:
      drop-shadow(0 0 8px rgba(255, 255, 255, 0.9))
      drop-shadow(0 0 14px rgba(255, 90, 110, 0.7))
      drop-shadow(0 0 22px rgba(90, 182, 255, 0.5));
  }
  50% {
    transform: scale(1.3);
    filter:
      drop-shadow(0 0 16px rgba(255, 255, 255, 1))
      drop-shadow(0 0 28px rgba(255, 209, 90, 0.9))
      drop-shadow(0 0 40px rgba(185, 133, 255, 0.7))
      brightness(1.25);
  }
  100% {
    transform: scale(1.08);
    filter:
      drop-shadow(0 0 8px rgba(255, 255, 255, 0.9))
      drop-shadow(0 0 16px rgba(126, 224, 140, 0.6))
      drop-shadow(0 0 24px rgba(255, 90, 110, 0.5));
  }
}

/* Целевые фишки, в которые бьют щупальца — пульсирующая подсветка */
.tile.rainbow-target-glow {
  z-index: 70 !important;
}
.tile.rainbow-target-glow .tile-inner {
  animation: rainbowTargetPulse 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) infinite alternate !important;
  filter:
    brightness(1.25)
    drop-shadow(0 0 10px rgba(255, 255, 255, 0.75))
    drop-shadow(0 0 16px rgba(124, 255, 107, 0.65))
    drop-shadow(0 0 24px rgba(199, 125, 255, 0.5)) !important;
}
@keyframes rainbowTargetPulse {
  from {
    transform: scale(1.0);
    filter: brightness(1.12)
      drop-shadow(0 0 8px rgba(124, 255, 107, 0.75)) !important;
  }
  to {
    transform: scale(1.16);
    filter: brightness(1.35)
      drop-shadow(0 0 20px rgba(199, 125, 255, 0.85)) !important;
  }
}

.match3-footer {
  margin-top: 12px;
  font-size: 11px;
  opacity: 0.55;
  text-align: center;
}

/* ==========================================================================
   8. ВСПЛЫВАЮЩИЕ ИНТЕРФЕЙСНЫЕ ОКНА (ОВЕРЛЕИ)
   ========================================================================== */
.ui-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 11, 15, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.ui-card {
  background: var(--paper);
  color: var(--ink);
  border: var(--border-weight) solid var(--ink);
  border-radius: 16px;
  box-shadow: 8px 8px 0 var(--blood);
  padding: 24px;
  max-width: 380px;
  width: 100%;
}

.ui-card h2 {
  font-family: 'Bangers', cursive;
  font-size: 28px;
  color: var(--blood-dark);
  margin: 0 0 16px 0;
  text-align: center;
  letter-spacing: 1px;
}

.action-btn {
  font-family: 'Bangers', cursive;
  font-size: 20px;
  padding: 10px 24px;
  border: var(--border-weight) solid var(--ink);
  border-radius: 12px;
  cursor: pointer;
  width: 100%;
  margin-top: 12px;
  letter-spacing: 0.5px;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}

.action-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.start-btn { background: var(--toxic); color: var(--paper); }
.cancel-btn { background: #9c9891; color: var(--ink); }
.next-btn { background: var(--blood); color: var(--paper); }

/* ==========================================================================
   9. ОКНО ДИАЛОГОВ И СЦЕН (НОВЕЛЛА: КЛУБ РОМАНТИКИ)
   ========================================================================== */
.dialogue-window {
  background: var(--paper);
  color: var(--ink);
  border: var(--border-weight) solid var(--ink);
  border-radius: 14px;
  box-shadow: 6px 6px 0 var(--blood);
  padding: 18px;
  width: 100%;
  max-width: 420px;
  position: absolute;
  bottom: 20px;
  cursor: pointer;
  z-index: 150;
  animation: dialogueSlideIn 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes dialogueSlideIn {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.speaker-name {
  font-family: 'Bangers', cursive;
  font-size: 24px;
  color: var(--blood-dark);
  margin-bottom: 8px;
  text-align: left;
  letter-spacing: 1px;
}

.dialogue-text-container {
  min-height: 52px;
  text-align: left;
}

.dialogue-text {
  font-size: 14px;
  line-height: 1.45;
  margin: 0 0 12px 0;
}

/* Контейнер интерактивных выборов */
.choices-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  width: 100%;
}

.choice-btn {
  background: var(--violet);
  color: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: bold;
  text-align: left;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.05s ease, background 0.2s ease;
}

/* Премиальная обводка для платных выборов или по репутации */
.choice-btn.premium {
  border-color: var(--gold);
  box-shadow: 0 0 6px rgba(209, 161, 63, 0.8), 3px 3px 0 var(--ink);
}

.choice-btn:hover {
  background: var(--blood);
}

.choice-btn:active {
  transform: translate(1.5px, 1.5px);
  box-shadow: 1.5px 1.5px 0 var(--ink);
}

.dialogue-hint {
  font-size: 9px;
  text-align: right;
  opacity: 0.65;
  text-transform: uppercase;
  margin-top: 8px;
  font-weight: bold;
}

/* ==========================================================================
   ПОДСКАЗКИ ПОД ВЫБОРОМ И ЗАГОЛОВОК ГЛАВЫ (сюжет «Без памяти»)
   Подсказка — короткая простая фраза: что значит этот выбор.
   ========================================================================== */

.choice-btn .choice-text {
  display: block;
}

.choice-btn .choice-hint {
  display: block;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px dashed rgba(255, 255, 255, 0.28);
  font-size: 10.5px;
  font-weight: normal;
  line-height: 1.35;
  opacity: 0.88;
}

.scene-title {
  align-self: flex-start;
  margin-bottom: 8px;
  padding: 4px 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--gold);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  box-shadow: 2px 2px 0 var(--ink);
}

/* Плашка концовки — красная, чтобы финал было видно сразу */
.scene-title.scene-title-ending {
  background: #b4362f;
  color: #fff3e6;
  border-color: #4a100c;
  box-shadow: 2px 2px 0 #4a100c;
}

/* Строчка про закрытый выбор: чего не хватает, чтобы он стал доступен */
.choice-btn .choice-req {
  display: block;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px dashed rgba(255, 255, 255, 0.22);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  opacity: 0.72;
}

.choice-btn.choice-locked .choice-req {
  opacity: 0.9;
}

/* ==========================================================================
   10. PRE-LEVEL HOMESCAPES — state skins, goal well, danglers, curtains
   Z-order: 0 blur bg | 1 curtains | 2 shadow | 3 plate | 4 content | 5 danglers | 6 close
   ========================================================================== */

#overlayPreLevel.ui-overlay {
  /* L0: прозрачный фон — видна комната, слегка заблюрена (шторы убраны) */
  background: rgba(8, 6, 6, 0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pre-stage {
  position: relative;
  width: min(100vw, 420px);
  min-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 8px 16px;
  box-sizing: border-box;
}

/* ---------- L1: боковые бархатные шторы ---------- */
.pre-curtains {
  display: none !important;
}
.pre-curtain {
  position: absolute;
  top: -4%;
  bottom: -4%;
  width: 22%;
  max-width: 92px;
  background:
    linear-gradient(90deg,
      rgba(0,0,0,0.25) 0%,
      transparent 18%,
      transparent 82%,
      rgba(0,0,0,0.22) 100%),
    linear-gradient(180deg, #9c1e3a 0%, #7a1230 40%, #5a0c24 100%);
  box-shadow: 0 0 28px rgba(40, 10, 20, 0.45);
  animation: preCurtainSway 4.5s ease-in-out infinite;
}
.pre-curtain-left {
  left: 0;
  border-radius: 0 60% 50% 0 / 0 20% 12% 0;
  transform-origin: top left;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.2) 0%, transparent 30%),
    linear-gradient(180deg, #a8223e 0%, #7e1530 45%, #4e0c20 100%);
}
.pre-curtain-right {
  right: 0;
  border-radius: 60% 0 0 50% / 20% 0 0 12%;
  transform-origin: top right;
  animation-delay: -1.1s;
  background:
    linear-gradient(270deg, rgba(0,0,0,0.2) 0%, transparent 30%),
    linear-gradient(180deg, #a8223e 0%, #7e1530 45%, #4e0c20 100%);
}
@keyframes preCurtainSway {
  0%, 100% { transform: scaleX(1) skewY(0deg); }
  50% { transform: scaleX(1.03) skewY(0.4deg); }
}
/* шторы под скины */
.pre-stage.skin-normal .pre-curtain-left,
.pre-stage.skin-normal .pre-curtain-right {
  background:
    linear-gradient(90deg, rgba(0,0,0,0.15) 0%, transparent 28%),
    linear-gradient(180deg, #b03a4a 0%, #8a2035 50%, #5c1424 100%);
}
.pre-stage.skin-hard .pre-curtain-left,
.pre-stage.skin-hard .pre-curtain-right {
  background:
    linear-gradient(90deg, rgba(0,0,0,0.2) 0%, transparent 28%),
    linear-gradient(180deg, #6b1a55 0%, #4a0f3a 50%, #2e0824 100%);
}
.pre-stage.skin-superhard .pre-curtain-left,
.pre-stage.skin-superhard .pre-curtain-right {
  background:
    linear-gradient(90deg, rgba(0,0,0,0.18) 0%, transparent 28%),
    linear-gradient(180deg, #e61a6b 0%, #b01052 45%, #6e0a36 100%);
}

/* ---------- обёртка планшета (тень + danglers) ---------- */
.pre-level-card-wrap {
  position: relative;
  z-index: 2;
  width: min(92vw, 340px);
  filter: drop-shadow(0 22px 40px rgba(20, 10, 6, 0.5));
}

/* ---------- L5: left reward dangler ---------- */
.pre-reward-dangler {
  display: none !important;
}
.pre-dangler-ring {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid #e8c050;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.25),
    inset 0 1px 0 rgba(255,255,255,0.45);
  background: radial-gradient(circle at 35% 30%, #fff3c0, #d4a020 70%);
  margin-bottom: -4px;
  z-index: 1;
}
.pre-dangler-badge {
  width: 64px;
  min-height: 64px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 8px 4px 6px;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.45) 0%, transparent 40%),
    linear-gradient(165deg, #5eb0ff 0%, #2f7fe0 45%, #1a5cb8 100%);
  box-shadow:
    0 6px 14px rgba(20, 50, 100, 0.4),
    inset 0 2px 0 rgba(255,255,255,0.4),
    inset 0 -3px 6px rgba(0,40,90,0.3);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  line-height: 1.05;
}
.pre-dangler-coin { font-size: 18px; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.25)); }
.pre-dangler-amt { font-size: 15px; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.pre-dangler-star { font-size: 12px; margin-top: 2px; opacity: 0.95; }
.pre-dangler-stars { font-size: 11px; opacity: 0.95; }

/* ---------- L5: event bracket ---------- */
.pre-event-bracket {
  position: absolute;
  right: -28px;
  top: -36px;
  z-index: 5;
  width: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.pre-event-bracket.hidden { display: none !important; }
.pre-event-rope {
  width: 3px;
  height: 36px;
  background: linear-gradient(180deg, transparent 0%, #c4a060 20%, #a07830 100%);
  border-radius: 2px;
  box-shadow: 1px 0 0 rgba(255,255,255,0.2);
}
.pre-event-bubble {
  width: 84px;
  min-height: 84px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.55) 0%, transparent 42%),
    linear-gradient(165deg, #fff8e8 0%, #f0dcc0 55%, #e0c8a0 100%);
  border: 3px solid #fff;
  box-shadow:
    0 8px 18px rgba(40, 25, 10, 0.35),
    inset 0 -4px 8px rgba(120, 80, 40, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px 10px;
  text-align: center;
}
.pre-event-char { font-size: 32px; line-height: 1; filter: drop-shadow(0 3px 4px rgba(60,40,20,0.3)); }
.pre-event-meta {
  font-family: 'Nunito', sans-serif;
  font-size: 10px;
  font-weight: 800;
  color: #5a3a28;
  margin-top: 2px;
  line-height: 1.2;
}

/* ---------- L3: main plate ---------- */
.pre-level-card {
  --pre-ink: #3E271E;
  --pre-ink-soft: #5c4030;
  --pre-header: #E6A13C;
  --pre-header-text: #3E271E;
  --pre-plate: #FDF5E6;
  --pre-plate-deep: #f5e6c8;
  --pre-stitch: rgba(255, 255, 255, 0.85);
  --pre-title: #3E271E;
  --pre-booster-title: #6b3a28;
  --pre-well-bg: #fffaf0;
  position: relative;
  z-index: 3;
  color: var(--pre-ink);
  font-family: 'Nunito', 'Rubik', system-ui, sans-serif;
  background: linear-gradient(180deg, var(--pre-plate) 0%, var(--pre-plate-deep) 100%);
  border: none;
  border-radius: 26px;
  box-shadow:
    0 4px 0 rgba(255, 255, 255, 0.35) inset,
    0 -3px 0 rgba(0, 0, 0, 0.06) inset;
  padding: 0 18px 18px;
  width: 100%;
  text-align: center;
  overflow: visible;
}
/* белый пунктирный шов 2px, шаг ~4px, inset 8px */
.pre-level-card::before {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 20px;
  border: 2px dashed var(--pre-stitch);
  pointer-events: none;
  z-index: 1;
  opacity: 0.9;
}
/* L4 content above stitch */
.pre-level-card > * { position: relative; z-index: 4; }
.pre-level-card > .pre-close-btn { z-index: 6; }

/* --- skins --- */
.pre-level-card.diff-normal,
.pre-level-card.diff-normal {
  --pre-plate: #FDF5E6;
  --pre-plate-deep: #f3e4c4;
  --pre-header: #E6A13C;
  --pre-header-text: #3E271E;
  --pre-title: #3E271E;
  --pre-booster-title: #8a4a2a;
  --pre-well-bg: #fff9ee;
  --pre-stitch: rgba(255, 255, 255, 0.88);
}
.pre-level-card.diff-hard,
.pre-level-card.diff-medium {
  --pre-plate: #822A63;
  --pre-plate-deep: #6a1f50;
  --pre-header: #51113B;
  --pre-header-text: #FFFFFF;
  --pre-title: #FFFFFF;
  --pre-ink: #fff8f0;
  --pre-ink-soft: #f0d8e8;
  --pre-booster-title: #f5d0ea;
  --pre-well-bg: #f8eef5;
  --pre-stitch: rgba(255, 255, 255, 0.55);
}
.pre-level-card.diff-superhard,
.pre-level-card.diff-hard-level,
.pre-level-card.diff-extreme,
.pre-level-card.diff-challenge {
  --pre-plate: #E61A6B;
  --pre-plate-deep: #c41258;
  --pre-header: #9C0842;
  --pre-header-text: #FFFFFF;
  --pre-title: #FFFFFF;
  --pre-ink: #fff8f5;
  --pre-ink-soft: #ffe0ec;
  --pre-booster-title: #ffe8f0;
  --pre-well-bg: #fff5f8;
  --pre-stitch: rgba(255, 255, 255, 0.5);
}
/* hard class conflict: game uses diff-hard for "very hard" — map via JS to superhard.
   Keep .diff-hard as purple if we use medium→hard purple and hard→superhard */

.pre-level-card.diff-hard {
  --pre-plate: #E61A6B;
  --pre-plate-deep: #c41258;
  --pre-header: #9C0842;
  --pre-header-text: #FFFFFF;
  --pre-title: #FFFFFF;
  --pre-ink: #fff8f5;
  --pre-ink-soft: #ffe0ec;
  --pre-booster-title: #ffe8f0;
  --pre-well-bg: #fff5f8;
  --pre-stitch: rgba(255, 255, 255, 0.5);
}
.pre-level-card.diff-medium {
  --pre-plate: #822A63;
  --pre-plate-deep: #6a1f50;
  --pre-header: #51113B;
  --pre-header-text: #FFFFFF;
  --pre-title: #FFFFFF;
  --pre-ink: #fff8f0;
  --pre-ink-soft: #f0d8e8;
  --pre-booster-title: #f5d0ea;
  --pre-well-bg: #f8eef5;
  --pre-stitch: rgba(255, 255, 255, 0.55);
}

/* ---------- header tab ---------- */
.pre-level-header {
  margin: 0 -18px 14px;
  padding: 14px 36px 12px;
  border-radius: 26px 26px 18px 18px;
  background: linear-gradient(180deg,
    var(--pre-header) 0%,
    var(--pre-header) 70%,
    rgba(0, 0, 0, 0.12) 100%);
  box-shadow:
    0 4px 0 rgba(0,0,0,0.12),
    inset 0 2px 0 rgba(255,255,255,0.28);
}
.pre-level-card.diff-normal .pre-level-header {
  background: linear-gradient(180deg, #f0b84a 0%, #E6A13C 55%, #c88828 100%);
}
.pre-level-card.diff-medium .pre-level-header {
  background: linear-gradient(180deg, #6a1a4e 0%, #51113B 55%, #3a0c2a 100%);
}
.pre-level-card.diff-hard .pre-level-header,
.pre-level-card.diff-extreme .pre-level-header,
.pre-level-card.diff-challenge .pre-level-header {
  background: linear-gradient(180deg, #b81052 0%, #9C0842 55%, #700630 100%);
}
.pre-level-card h2 {
  font-family: 'Nunito', sans-serif !important;
  font-size: 26px;
  font-weight: 900 !important;
  margin: 0;
  letter-spacing: 0.02em !important;
  color: var(--pre-header-text) !important;
  -webkit-text-stroke: 0 !important;
  text-shadow: 0 1px 0 rgba(255,255,255,0.2);
}
.diff-badge {
  display: inline-block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--pre-header-text);
  opacity: 0.92;
  background: transparent;
  padding: 0;
  box-shadow: none;
  text-shadow: none;
}

/* ---------- L6 close ---------- */
.pre-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.25);
  background:
    radial-gradient(circle at 30% 24%, rgba(255,255,255,0.75) 0%, rgba(255,255,255,0.1) 30%, transparent 45%),
    linear-gradient(165deg, #ff7a8a 0%, #e03050 50%, #b01830 100%);
  box-shadow:
    0 5px 12px rgba(140, 20, 40, 0.4),
    inset 0 2px 0 rgba(255,255,255,0.4),
    inset 0 -2px 4px rgba(80,0,10,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 1px;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.pre-close-btn::before {
  content: '';
  position: absolute;
  left: 16%;
  top: 12%;
  width: 36%;
  height: 26%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), transparent);
  pointer-events: none;
}
.pre-close-btn:hover { filter: brightness(1.06); }
.pre-close-btn:active { transform: scale(0.92); }

/* ---------- Goal Well (inset) ---------- */
.pre-goal-well {
  margin: 0 4px 12px;
  padding: 16px 12px 14px;
  border-radius: 16px;
  background: var(--pre-well-bg);
  box-shadow:
    inset 0 3px 8px rgba(40, 25, 15, 0.18),
    inset 0 -1px 0 rgba(255,255,255,0.6),
    0 1px 0 rgba(255,255,255,0.25);
}
.pre-goals-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 18px 28px;
  min-height: 64px;
}
.pre-goal-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 56px;
}
.pre-goal-icon {
  font-size: 40px;
  line-height: 1;
  filter: drop-shadow(0 4px 5px rgba(40, 25, 15, 0.28));
}
.pre-goal-num {
  font-family: 'Nunito', sans-serif;
  font-size: 28px;
  font-weight: 900;
  color: #3E271E;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.pre-level-tip,
.pre-cat-gift,
.pre-meta-row { display: none !important; }
.pre-level-tip.hidden,
.pre-cat-gift.hidden { display: none !important; }

/* ---------- Boosters ---------- */
.pre-boosters-selection {
  margin: 4px 0 12px;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: none !important;
}
.pre-booster-title {
  display: block !important;
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 800;
  color: var(--pre-booster-title);
  margin: 0 0 12px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.12);
}
.pre-boosters-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}
.pre-booster-btn {
  position: relative;
  width: 68px;
  height: 68px;
  border: none !important;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: transparent !important;
  box-shadow: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.pre-booster-btn .b-orb {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.35) 18%, transparent 42%),
    radial-gradient(circle at 50% 120%, rgba(90, 140, 220, 0.3) 0%, transparent 55%),
    radial-gradient(circle at 50% 40%, #eef6ff 0%, #b8d4f0 48%, #7aa8d8 100%);
  box-shadow:
    inset 0 -6px 14px rgba(40, 70, 120, 0.22),
    inset 0 3px 6px rgba(255, 255, 255, 0.65),
    0 8px 16px rgba(30, 25, 20, 0.28),
    0 2px 0 rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
.pre-booster-btn .b-orb::before {
  content: '';
  position: absolute;
  left: 14%;
  right: 14%;
  top: 10%;
  height: 28%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.88) 0%, transparent 100%);
  pointer-events: none;
}
.pre-booster-btn .b-icon {
  position: relative;
  z-index: 1;
  font-size: 32px;
  line-height: 1;
  filter:
    drop-shadow(0 3px 5px rgba(30, 50, 90, 0.35))
    drop-shadow(0 1px 0 rgba(255,255,255,0.3));
  transform: translateY(-1px);
}
.pre-booster-btn .b-lock {
  display: none;
  position: absolute;
  z-index: 3;
  right: -2px;
  bottom: -2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  background:
    radial-gradient(circle at 35% 30%, #fff6c8 0%, #f0d060 40%, #c49220 100%);
  box-shadow:
    0 2px 5px rgba(80, 50, 10, 0.4),
    inset 0 1px 0 rgba(255,255,255,0.55);
  filter: none;
}
.pre-booster-btn .b-tag {
  position: absolute;
  z-index: 2;
  bottom: -2px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  border: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Nunito', sans-serif;
  font-size: 11px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(180deg, #ff8eb5 0%, #f04a7a 55%, #d63060 100%);
  box-shadow:
    0 3px 6px rgba(180, 40, 80, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}
.pre-booster-btn.selected { transform: scale(1.1); }
.pre-booster-btn.selected .b-orb {
  box-shadow:
    inset 0 -6px 14px rgba(40, 70, 120, 0.22),
    inset 0 3px 6px rgba(255,255,255,0.65),
    0 0 0 3px rgba(255, 210, 90, 0.9),
    0 0 16px rgba(255, 200, 80, 0.5),
    0 8px 16px rgba(30, 25, 20, 0.25);
}
.pre-booster-btn.is-locked {
  cursor: not-allowed;
  opacity: 1;
  filter: none;
}
.pre-booster-btn.is-locked .b-orb {
  opacity: 0.42;
  filter: grayscale(0.35);
}
.pre-booster-btn.is-locked .b-icon {
  opacity: 0.55;
  filter: grayscale(0.4) drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}
.pre-booster-btn.is-locked .b-tag { display: none !important; }
.pre-booster-btn.is-locked .b-lock { display: flex !important; }
.pre-boosters-selection.pre-boosters-locked .pre-booster-btn,
.pre-boosters-selection.pre-boosters-partial .pre-booster-btn:not(.is-locked) {
  /* reset old overrides */
  background: transparent !important;
  box-shadow: none !important;
}

/* ---------- rewards shelf ---------- */
.pre-level-rewards {
  display: none !important;
}
.reward-shelf {
  margin: 0 auto;
  width: 100%;
  padding: 8px 10px;
  border-radius: 16px;
  background: radial-gradient(ellipse at 50% 40%,
    rgba(255, 245, 200, 0.95) 0%,
    rgba(255, 220, 140, 0.88) 50%,
    rgba(230, 180, 80, 0.75) 100%);
  box-shadow:
    0 4px 12px rgba(100, 70, 20, 0.18),
    inset 0 1px 0 rgba(255,255,255,0.7);
}
.reward-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.reward-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.75);
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 800;
  color: #3E271E;
  box-shadow: 0 2px 6px rgba(80, 50, 20, 0.12);
}
.reward-pill .rp-icon {
  font-size: 16px;
  filter: drop-shadow(0 2px 2px rgba(80,50,20,0.25));
}

/* ---------- Play button ---------- */
.pre-level-card .pre-play-btn,
.pre-level-card .start-btn {
  position: relative;
  overflow: hidden;
  font-family: 'Nunito', sans-serif !important;
  font-size: 22px !important;
  font-weight: 900 !important;
  letter-spacing: 0.03em !important;
  color: #fff !important;
  border: none !important;
  border-radius: 999px !important;
  padding: 14px 28px !important;
  margin-top: 2px !important;
  width: 100%;
  background: linear-gradient(180deg, #32CD32 0%, #28b828 40%, #228B22 100%) !important;
  box-shadow:
    0 5px 8px rgba(20, 60, 20, 0.35),
    0 2px 0 #1a6b1a,
    inset 0 2px 0 rgba(255,255,255,0.4) !important;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.12s ease !important;
}
.pre-level-card .pre-play-btn::before,
.pre-level-card .start-btn::before {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: 2px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}
.pre-level-card .pre-play-label {
  position: relative;
  z-index: 1;
  display: inline-block;
  color: #fff;
  /* outline approx via stacked shadows + green drop */
  text-shadow:
    -1px -1px 0 #145a14,
     1px -1px 0 #145a14,
    -1px  1px 0 #145a14,
     1px  1px 0 #145a14,
     0  2px 0 #0f4a0f,
     1px 3px 3px rgba(10, 50, 15, 0.35);
}
.pre-level-card .pre-play-btn:hover,
.pre-level-card .start-btn:hover { filter: brightness(1.05); }
.pre-level-card .pre-play-btn:active,
.pre-level-card .start-btn:active {
  transform: translateY(3px) !important;
  box-shadow:
    0 2px 4px rgba(20, 60, 20, 0.3),
    0 1px 0 #1a6b1a,
    inset 0 1px 0 rgba(255,255,255,0.3) !important;
}

/* open animation for stage */
#overlayPreLevel:not(.hidden) .pre-stage {
  animation: preStageIn 0.38s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}
@keyframes preStageIn {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ==========================================================================
   11. ОКНО ДЕЛ И СПИСКА ЗАДАЧ (МЕНЮ)
   ========================================================================== */
.tasks-scroll-list {
  max-height: 250px;
  overflow-y: auto;
  margin-bottom: 18px;
  padding-right: 4px;
}

.task-item {
  background: rgba(255,255,255,0.45);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.task-info {
  text-align: left;
}

.task-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}

.task-btn {
  background: var(--toxic);
  color: var(--paper);
  font-family: 'Bangers', cursive;
  font-size: 15px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  white-space: nowrap;
  letter-spacing: 0.5px;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}

.task-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink);
}

/* ==========================================================================
   12. ДЕКОРАТИВНЫЕ СНАРЯДЫ И ЧИСТЫЕ ЭФФЕКТЫ (МЯГКИЙ И ПЛАВНЫЙ ВАРИАНТ)
   ========================================================================== */

/* Движущийся снаряд (ракета / самолёт / бомба) — PNG-спрайты */
.m3-projectile {
  position: absolute;
  width: calc(100% / var(--cols));
  height: calc(100% / var(--rows));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0; /* без emoji */
  z-index: 99;
  pointer-events: none;
  transition: left 0.45s cubic-bezier(0.25, 1, 0.5, 1), top 0.45s cubic-bezier(0.25, 1, 0.5, 1), transform 0.45s ease-out;
  will-change: left, top, transform;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
}
.m3-projectile.m3-sprite {
  font-size: 0 !important;
}
.m3-projectile.m3-plane-fly {
  width: calc(95% / var(--cols));
  height: calc(95% / var(--rows));
  z-index: 110;
}
.m3-projectile.m3-rocket-fly,
.m3-projectile.m3-rocket-charge {
  width: calc(110% / var(--cols));
  height: calc(110% / var(--rows));
  z-index: 120;
}
.m3-projectile.m3-rocket-fly {
  transition: none !important;
  opacity: 1 !important;
  visibility: visible !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
}

/* ─── Rocket flyer: <img> + trail + sparks (без mix-blend — он прятал спрайт) ─── */
.m3-rocket-flyer {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 220 !important;
  will-change: left, top, transform;
  transition: none !important;
  opacity: 1 !important;
  overflow: visible !important;
}
.m3-rocket-img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  object-position: center;
  z-index: 3;
  display: block !important;
  opacity: 1 !important;
  filter:
    drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4))
    drop-shadow(0 0 6px rgba(255, 200, 80, 0.75))
    drop-shadow(0 0 14px rgba(255, 140, 30, 0.4));
  -webkit-user-drag: none;
  user-select: none;
}
/* 🔥 Огненный шлейф ракеты — 3 слоя: ядро + основной след + внешнее свечение */
.m3-rocket-trail {
  position: absolute;
  right: 55%;
  top: 50%;
  height: 38%;
  width: 12px;
  transform: translateY(-50%);
  transform-origin: right center;
  z-index: 1;
  pointer-events: none;
  border-radius: 40% 20% 20% 40% / 50%;
  /* Основной градиент: красный → оранжевый → жёлтый → белый (tail → nose) */
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(180, 30, 10, 0.18) 8%,
    rgba(220, 60, 20, 0.5) 22%,
    rgba(255, 120, 30, 0.72) 40%,
    rgba(255, 180, 60, 0.88) 58%,
    rgba(255, 220, 120, 0.96) 78%,
    rgba(255, 250, 230, 1) 92%,
    rgba(255, 255, 255, 1) 100%
  );
  box-shadow:
    0 0 6px rgba(255, 180, 60, 0.7),
    0 0 14px rgba(255, 120, 30, 0.4),
    0 0 28px rgba(200, 50, 15, 0.18);
  filter: blur(0.8px);
  opacity: 0.88;
}
/* Внутреннее ядро — резкий бело-жёлтый стержень */
.m3-rocket-trail::before {
  content: '';
  position: absolute;
  top: 25%;
  bottom: 25%;
  left: 15%;
  right: 0;
  border-radius: 40%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 200, 100, 0.35) 25%,
    rgba(255, 240, 180, 0.75) 55%,
    rgba(255, 255, 245, 0.95) 85%,
    rgba(255, 255, 255, 1) 100%
  );
  filter: blur(0.2px);
}
/* Внешнее свечение — широкий размытый красно-оранжевый ореол */
.m3-rocket-glow {
  position: absolute;
  right: 50%;
  top: 50%;
  height: 100%;
  width: 18px;
  transform: translateY(-50%);
  transform-origin: right center;
  z-index: 0;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at 80% 50%,
    rgba(255, 200, 80, 0.45) 0%,
    rgba(255, 140, 40, 0.28) 30%,
    rgba(220, 70, 20, 0.12) 60%,
    transparent 100%
  );
  filter: blur(5px);
  opacity: 0.7;
}
/* Искры по следу — яркие бело-жёлтые */
.m3-rocket-spark {
  position: absolute;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 218;
  background: radial-gradient(
    circle,
    #fff 0%,
    #ffe566 35%,
    #ffb020 65%,
    transparent 100%
  );
  box-shadow: 0 0 5px rgba(255, 220, 80, 0.95), 0 0 10px rgba(255, 160, 40, 0.5);
  animation: m3RocketSpark 0.28s ease-out forwards;
}
@keyframes m3RocketSpark {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  60%  { opacity: 0.8; }
  100% {
    transform: translate(var(--spark-dx, 8px), var(--spark-dy, -6px)) scale(0.1);
    opacity: 0;
  }
}

/* Тихая центровая вспышка для combo ракета+бомба (без «лап») */
@keyframes m3CenterFlash {
  0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  50%  { transform: translate(-50%, -50%) scale(2.5); opacity: 0.9; filter: brightness(1.6); }
  100% { transform: translate(-50%, -50%) scale(3.5); opacity: 0; }
}

.m3-projectile.m3-bomb-inflate {
  width: calc(115% / var(--cols));
  height: calc(115% / var(--rows));
  z-index: 120;
}

/* Ударная волна Бомбы 5х5 — Замедлена для тяжелого взрыва */
.bomb-shockwave {
  position: absolute;
  width: calc(100% / var(--cols));
  height: calc(100% / var(--rows));
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 168, 0.85) 0%, rgba(209, 121, 63, 0.45) 50%, rgba(0,0,0,0) 70%);
  border: 2.5px solid #ffdca8;
  pointer-events: none;
  z-index: 98;
  transform: scale(1);
  opacity: 1;
  /* Замедлен взрыв до 0.35s для Homescapes-эффекта */
  transition: transform 0.35s cubic-bezier(0.1, 0.8, 0.3, 1), opacity 0.35s ease-out;
  will-change: transform, opacity;
}

/* Препятствие: Коробка/Ящик в стиле Homescapes */
.tile.box .tile-inner {
  z-index: 5;
}
.tile.box.clearing .tile-inner {
  transform: scale(0) rotate(-20deg);
  opacity: 0;
  transition: transform 0.15s cubic-bezier(0.4, 0, 1, 1), opacity 0.12s ease-out !important;
}

/* Анимации прокрутки и перекатки камеры */
/* Портрет: секции уезжают вверх / въезжают снизу (L6 multi-zone) */
#board.scroll-out {
  transform: translate3d(0, -120%, 0) scale(0.92);
  opacity: 0;
  transition: transform 0.32s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.28s ease-out;
}

#board.scroll-in {
  transform: translate3d(0, 120%, 0) scale(0.92);
  opacity: 0;
  transition: none !important;
}

/* Горизонтальный скролл для L6 (scrollField) — сдвиг по фазам через inline transform */
#board.scroll-h-out {
  /* legacy class; основной перекат — translateX по __viewColOffset */
  opacity: 0.92;
  transition: transform 0.55s cubic-bezier(0.25, 0.9, 0.3, 1), opacity 0.28s ease-out;
}

#board.scroll-h-in {
  opacity: 1;
  transition: none !important;
}

/* ==========================================================================
   13. ОБВОЛАКИВАЮЩИЙ ДЫМ РАДУЖНОГО ШАРА 🌈
   Мягкие зелёные / фиолетовые облака, поочерёдно обнимают цели.
   ========================================================================== */
.rainbow-laser {
  position: absolute;
  height: 3px;
  border-radius: 8px;
  transform-origin: left center;
  z-index: 99;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255,255,255,0.5) 0%, #7CFF6B 40%, #C77DFF 100%);
  opacity: 0.7;
}

/* SVG-лента дыма */
.rainbow-smoke {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible !important;
  pointer-events: none;
  z-index: 99;
}
.rainbow-smoke path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rainbow-smoke .rainbow-smoke-haze {
  filter: blur(9px);
  opacity: 0;
}
.rainbow-smoke .rainbow-smoke-mid {
  filter: blur(4.5px);
  opacity: 0;
}
.rainbow-smoke .rainbow-smoke-soft {
  filter: blur(1.8px);
  opacity: 0;
}
/* зелёный дым */
.rainbow-smoke-green .rainbow-smoke-haze { stroke: rgba(90, 220, 120, 0.28); }
.rainbow-smoke-green .rainbow-smoke-mid  { stroke: rgba(130, 255, 150, 0.40); }
.rainbow-smoke-green .rainbow-smoke-soft { stroke: rgba(200, 255, 210, 0.55); }
/* фиолетовый дым */
.rainbow-smoke-violet .rainbow-smoke-haze { stroke: rgba(160, 90, 255, 0.28); }
.rainbow-smoke-violet .rainbow-smoke-mid  { stroke: rgba(200, 140, 255, 0.40); }
.rainbow-smoke-violet .rainbow-smoke-soft { stroke: rgba(235, 200, 255, 0.55); }

/* Летающие облачка-пуфы */
.rainbow-smoke-puff {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 100;
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
  will-change: transform, opacity, left, top;
  filter: blur(5px);
  mix-blend-mode: screen;
}
.rainbow-smoke-puff-green {
  background:
    radial-gradient(circle at 38% 36%,
      rgba(255, 255, 255, 0.55) 0%,
      rgba(150, 255, 160, 0.42) 28%,
      rgba(70, 190, 100, 0.18) 58%,
      transparent 76%);
}
.rainbow-smoke-puff-violet {
  background:
    radial-gradient(circle at 38% 36%,
      rgba(255, 255, 255, 0.55) 0%,
      rgba(210, 150, 255, 0.42) 28%,
      rgba(120, 60, 200, 0.18) 58%,
      transparent 76%);
}
/* Туман, обволакивающий цель */
.rainbow-smoke-wrap {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 101;
  transform: translate(-50%, -50%) scale(0.15);
  opacity: 0;
  filter: blur(7px);
  mix-blend-mode: screen;
  will-change: transform, opacity;
}
.rainbow-smoke-wrap-green {
  background:
    radial-gradient(circle,
      rgba(255, 255, 255, 0.35) 0%,
      rgba(140, 255, 155, 0.38) 28%,
      rgba(70, 200, 100, 0.16) 52%,
      transparent 72%);
  box-shadow:
    0 0 18px rgba(120, 255, 140, 0.35),
    0 0 36px rgba(80, 200, 110, 0.2);
}
.rainbow-smoke-wrap-violet {
  background:
    radial-gradient(circle,
      rgba(255, 255, 255, 0.35) 0%,
      rgba(205, 145, 255, 0.38) 28%,
      rgba(130, 70, 210, 0.16) 52%,
      transparent 72%);
  box-shadow:
    0 0 18px rgba(190, 120, 255, 0.35),
    0 0 36px rgba(140, 70, 220, 0.2);
}
.rainbow-smoke-wrap.wrap-on {
  animation: rainbowSmokeWrapIn 0.48s cubic-bezier(0.2, 0.85, 0.25, 1) forwards;
}
.rainbow-smoke-wrap.wrap-fade {
  animation: rainbowSmokeWrapOut 0.32s ease-out forwards;
}
@keyframes rainbowSmokeWrapIn {
  0%   { transform: translate(-50%, -50%) scale(0.2);  opacity: 0; }
  35%  { transform: translate(-50%, -50%) scale(1.05); opacity: 0.95; }
  70%  { transform: translate(-50%, -50%) scale(1.22); opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(1.12); opacity: 0.75; }
}
@keyframes rainbowSmokeWrapOut {
  to { transform: translate(-50%, -50%) scale(1.45); opacity: 0; }
}

/* Тонкие «усики» дыма вокруг цели */
.rainbow-smoke-wisp {
  position: absolute;
  width: 42%;
  height: 18%;
  max-width: 48px;
  max-height: 18px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 102;
  transform: translate(-50%, -50%) rotate(var(--wisp-rot, 0deg)) scaleX(0.2);
  opacity: 0;
  filter: blur(4px);
  mix-blend-mode: screen;
  transform-origin: center center;
}
.rainbow-smoke-wisp-green {
  background: radial-gradient(ellipse at center,
    rgba(180, 255, 190, 0.55) 0%,
    rgba(90, 210, 120, 0.2) 55%,
    transparent 78%);
}
.rainbow-smoke-wisp-violet {
  background: radial-gradient(ellipse at center,
    rgba(230, 190, 255, 0.55) 0%,
    rgba(150, 90, 220, 0.2) 55%,
    transparent 78%);
}
.rainbow-smoke-wisp.wisp-on {
  animation: rainbowWispIn 0.5s cubic-bezier(0.25, 0.9, 0.3, 1) forwards;
  animation-delay: var(--wisp-delay, 0ms);
}
.rainbow-smoke-wisp.wisp-fade {
  animation: rainbowWispOut 0.28s ease-out forwards;
}
@keyframes rainbowWispIn {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(var(--wisp-rot, 0deg)) scaleX(0.15) scaleY(0.6); }
  55%  { opacity: 0.9; transform: translate(-50%, -50%) rotate(calc(var(--wisp-rot, 0deg) + 18deg)) scaleX(1.15) scaleY(1); }
  100% { opacity: 0.7; transform: translate(-50%, -50%) rotate(calc(var(--wisp-rot, 0deg) + 32deg)) scaleX(1.05) scaleY(0.95); }
}
@keyframes rainbowWispOut {
  to { opacity: 0; transform: translate(-50%, -50%) rotate(calc(var(--wisp-rot, 0deg) + 50deg)) scaleX(1.3) scaleY(0.7); }
}

/* GIF активации — исходная анимация + дым по краям (Homescapes-style rim) */
.m3-projectile.m3-rainbow-ignite {
  width: calc(165% / var(--cols));
  height: calc(165% / var(--rows));
  z-index: 128;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  animation: rainbowIgnitePulse 0.45s ease-in-out infinite alternate;
}
.m3-projectile.m3-rainbow-ignite .rainbow-ignite-core {
  position: relative;
  z-index: 4;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  background: transparent !important;
  /* яркий ободок по силуэту, как белый rim в HS — у нас бело/зелено/фиолет */
  filter:
    drop-shadow(0 0 3px rgba(255, 255, 255, 0.95))
    drop-shadow(0 0 7px rgba(200, 255, 210, 0.75))
    drop-shadow(0 0 12px rgba(190, 150, 255, 0.55))
    drop-shadow(0 0 18px rgba(140, 255, 170, 0.35));
}
/* размытая копия гифки — дым/свечение строго по контуру шара */
.m3-projectile.m3-rainbow-ignite .rainbow-rim-ghost {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 118%;
  height: 118%;
  transform: translate(-50%, -50%);
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
  opacity: 0.85;
  filter:
    blur(7px)
    brightness(1.55)
    saturate(1.25);
  mix-blend-mode: screen;
  animation: rainbowRimGhostPulse 0.55s ease-in-out infinite alternate;
}
@keyframes rainbowRimGhostPulse {
  from { opacity: 0.7;  transform: translate(-50%, -50%) scale(1.05); }
  to   { opacity: 0.95; transform: translate(-50%, -50%) scale(1.14); }
}
/* плотное кольцо дыма на краю (тонкий «обод») */
.m3-projectile.m3-rainbow-ignite .rainbow-rim-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 108%;
  height: 108%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle,
    transparent 52%,
    rgba(255, 255, 255, 0.55) 58%,
    rgba(160, 255, 180, 0.5) 64%,
    rgba(200, 150, 255, 0.45) 70%,
    rgba(140, 255, 170, 0.2) 78%,
    transparent 88%);
  filter: blur(3.5px);
  mix-blend-mode: screen;
  animation: rainbowRimRingPulse 0.5s ease-in-out infinite alternate;
}
@keyframes rainbowRimRingPulse {
  from { opacity: 0.75; transform: translate(-50%, -50%) scale(0.98); }
  to   { opacity: 1;    transform: translate(-50%, -50%) scale(1.06); }
}
/* внешний мягкий ореол */
.m3-projectile.m3-rainbow-ignite .rainbow-rim-outer {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 145%;
  height: 145%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle,
    transparent 40%,
    rgba(200, 255, 210, 0.22) 55%,
    rgba(190, 150, 255, 0.28) 65%,
    rgba(255, 255, 255, 0.12) 75%,
    transparent 88%);
  filter: blur(8px);
  mix-blend-mode: screen;
  animation: rainbowRimOuterPulse 0.65s ease-in-out infinite alternate;
}
@keyframes rainbowRimOuterPulse {
  from { opacity: 0.65; transform: translate(-50%, -50%) scale(0.96); }
  to   { opacity: 0.95; transform: translate(-50%, -50%) scale(1.08); }
}
@keyframes rainbowIgnitePulse {
  from { transform: translate(-50%, -50%) scale(1.05); }
  to   { transform: translate(-50%, -50%) scale(1.12); }
}
/* финал: шар схлопывается в точку */
.m3-projectile.m3-rainbow-ignite.rainbow-collapse {
  animation: rainbowIgniteCollapse 0.3s cubic-bezier(0.55, 0.05, 0.9, 0.35) forwards !important;
}
.m3-projectile.m3-rainbow-ignite.rainbow-collapse .rainbow-rim-ghost,
.m3-projectile.m3-rainbow-ignite.rainbow-collapse .rainbow-rim-ring,
.m3-projectile.m3-rainbow-ignite.rainbow-collapse .rainbow-rim-outer {
  animation: rainbowRimCollapse 0.28s cubic-bezier(0.55, 0.05, 0.9, 0.35) forwards !important;
}
@keyframes rainbowRimCollapse {
  to { opacity: 0; transform: translate(-50%, -50%) scale(0.15); filter: blur(2px); }
}
@keyframes rainbowIgniteCollapse {
  0%   { transform: translate(-50%, -50%) scale(1.12); opacity: 1; }
  55%  { transform: translate(-50%, -50%) scale(0.55); opacity: 0.95; }
  100% { transform: translate(-50%, -50%) scale(0);    opacity: 0; }
}

/* Кокон-туман: мягкое кольцо, обволакивает шар */
.rainbow-cocoon {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 121;
  transform: translate(-50%, -50%) scale(0.25);
  opacity: 0;
  mix-blend-mode: screen;
  background:
    radial-gradient(circle,
      transparent 32%,
      rgba(255, 255, 255, 0.2) 40%,
      rgba(180, 255, 200, 0.35) 48%,
      rgba(200, 150, 255, 0.38) 56%,
      rgba(150, 255, 170, 0.2) 66%,
      transparent 78%);
  filter: blur(5px);
  box-shadow:
    0 0 18px rgba(160, 255, 180, 0.3),
    0 0 28px rgba(190, 140, 255, 0.28);
  will-change: transform, opacity;
}
.rainbow-cocoon.cocoon-on {
  animation:
    rainbowCocoonIn 0.45s cubic-bezier(0.2, 0.85, 0.25, 1) forwards,
    rainbowCocoonPulse 0.7s ease-in-out 0.45s infinite alternate;
}
.rainbow-cocoon.cocoon-collapse {
  animation: rainbowCocoonCollapse 0.32s cubic-bezier(0.55, 0.05, 0.9, 0.35) forwards !important;
}
@keyframes rainbowCocoonIn {
  0%   { opacity: 0;    transform: translate(-50%, -50%) scale(0.2); }
  100% { opacity: 0.95; transform: translate(-50%, -50%) scale(1); }
}
@keyframes rainbowCocoonPulse {
  from { transform: translate(-50%, -50%) scale(0.98); filter: blur(5px) brightness(1); }
  to   { transform: translate(-50%, -50%) scale(1.08); filter: blur(6px) brightness(1.15); }
}
@keyframes rainbowCocoonCollapse {
  0%   { opacity: 0.9;  transform: translate(-50%, -50%) scale(1.05); }
  40%  { opacity: 1;    transform: translate(-50%, -50%) scale(0.7); filter: blur(4px) brightness(1.3); }
  100% { opacity: 0;   transform: translate(-50%, -50%) scale(0.05); filter: blur(2px) brightness(1.6); }
}

/* Орбитальный дым — кружит вокруг шара */
.rainbow-orbit-smoke {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 122;
  opacity: 0;
  filter: blur(6px);
  mix-blend-mode: screen;
  will-change: transform, opacity;
  /* orbit: rotate around center via translateY(-r) */
  --orbit-r: 24px;
  --orbit-a0: 0deg;
  --orbit-dur: 1.2s;
}
.rainbow-orbit-green {
  background: radial-gradient(circle at 40% 35%,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(140, 255, 160, 0.45) 30%,
    rgba(60, 190, 100, 0.15) 58%,
    transparent 75%);
}
.rainbow-orbit-violet {
  background: radial-gradient(circle at 40% 35%,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(210, 150, 255, 0.45) 30%,
    rgba(120, 60, 200, 0.15) 58%,
    transparent 75%);
}
.rainbow-orbit-smoke.orbit-on {
  animation: rainbowOrbitSpin var(--orbit-dur) linear infinite;
  opacity: 0.85;
}
.rainbow-orbit-smoke.orbit-collapse {
  animation: rainbowOrbitCollapse 0.3s cubic-bezier(0.55, 0.05, 0.9, 0.35) forwards !important;
}
@keyframes rainbowOrbitSpin {
  0% {
    opacity: 0.75;
    transform:
      translate(-50%, -50%)
      rotate(var(--orbit-a0))
      translateY(calc(-1 * var(--orbit-r)))
      scale(0.9);
  }
  50% {
    opacity: 0.95;
    transform:
      translate(-50%, -50%)
      rotate(calc(var(--orbit-a0) + 180deg))
      translateY(calc(-1 * var(--orbit-r)))
      scale(1.15);
  }
  100% {
    opacity: 0.75;
    transform:
      translate(-50%, -50%)
      rotate(calc(var(--orbit-a0) + 360deg))
      translateY(calc(-1 * var(--orbit-r)))
      scale(0.9);
  }
}
@keyframes rainbowOrbitCollapse {
  0% {
    opacity: 0.85;
    transform:
      translate(-50%, -50%)
      rotate(var(--orbit-a0))
      translateY(calc(-1 * var(--orbit-r)))
      scale(1);
  }
  100% {
    opacity: 0;
    transform:
      translate(-50%, -50%)
      rotate(calc(var(--orbit-a0) + 90deg))
      translateY(0)
      scale(0.15);
  }
}
/* legacy static orb (если где-то остался) */
.m3-projectile.m3-rainbow-spin {
  width: calc(140% / var(--cols));
  height: calc(140% / var(--rows));
  z-index: 125;
  filter:
    drop-shadow(0 0 10px rgba(255, 255, 255, 0.85))
    drop-shadow(0 0 18px rgba(124, 255, 107, 0.7))
    drop-shadow(0 0 28px rgba(199, 125, 255, 0.55)) !important;
}

/* legacy spark (на всякий) */
.rainbow-target-spark {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 126;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
}
.rainbow-target-spark.spark-on { opacity: 1; transform: translate(-50%, -50%) scale(2); }
.rainbow-target-spark.spark-pop { opacity: 0; transform: translate(-50%, -50%) scale(3.5); }

/* Подсветка цели под дымом */
.tile.rainbow-target-green .tile-inner {
  filter:
    drop-shadow(0 0 8px rgba(124, 255, 107, 0.95))
    drop-shadow(0 0 18px rgba(60, 200, 90, 0.55)) !important;
}
.tile.rainbow-target-violet .tile-inner {
  filter:
    drop-shadow(0 0 8px rgba(199, 125, 255, 0.95))
    drop-shadow(0 0 18px rgba(140, 70, 220, 0.55)) !important;
}

/* ==========================================================================
   14. ПАНЕЛЬ БУСТЕРОВ — парящая стеклянная полка
   ========================================================================== */
.booster-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 340px;
  padding: 12px 22px 18px;
  flex-shrink: 0;
  /* Стеклянная полка: полупрозрачный фарфор с глубокой тенью */
  background: linear-gradient(180deg, rgba(255,255,255,0.82) 0%, rgba(245,240,230,0.72) 50%, rgba(235,228,215,0.62) 100%);
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 22px;
  box-shadow:
    /* Глубокая тень под полкой — парит над комнатой */
    0 10px 30px rgba(0, 0, 0, 0.22),
    0 3px 8px rgba(0, 0, 0, 0.12),
    /* Глянцевый блик сверху */
    inset 0 2px 4px rgba(255, 255, 255, 0.75),
    /* Мягкая тень снизу */
    inset 0 -2px 3px rgba(160, 140, 110, 0.10);
}

/* Кнопка бустера — объёмная молочная сфера с ярким точечным бликом */
.booster-btn {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50% !important;
  /* Молочная сфера: яркий блик-точка сверху-слева → крем → тёмный низ */
  background: radial-gradient(circle at 32% 24%, #ffffff 0%, #fdfaf5 8%, #f0e8dc 20%, #dcc8b0 40%, #c4a888 60%, #a88868 80%, #907058 100%) !important;
  border: 2px solid rgba(140, 110, 70, 0.35) !important;
  box-shadow:
    0 6px 14px rgba(60, 40, 20, 0.30),
    0 2px 4px rgba(60, 40, 20, 0.15),
    inset 0 4px 10px rgba(255, 255, 255, 0.80),
    inset 0 -4px 10px rgba(80, 50, 25, 0.18),
    inset 4px 0 8px rgba(255, 255, 255, 0.40),
    inset -3px -3px 8px rgba(60, 40, 15, 0.12) !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0 !important;
  padding: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.2s;
  background-size: 28px 28px;
  background-repeat: no-repeat;
  background-position: center;
}

/* Иконки инструментов — поверх молочного шарика (фон-градиент с !important
   перебивал background-image, поэтому рисуем иконку псевдоэлементом) */
#btnHammer::before,
#btnGlove::before,
#btnBroom::before,
#btnWeight::before,
#btnFan::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 30px 30px;
  z-index: 1;
  pointer-events: none;
}
#btnHammer::before { background-image: url('images/hammer.webp'); }
#btnGlove::before { background-image: url('images/glove.webp'); }
#btnBroom::before { background-image: url('images/broom.webp'); }
#btnWeight::before { background-image: url('images/weight.webp'); }
#btnFan::before { background-image: url('images/fan.webp'); }

/* Круглый счётчик бустеров — розовый объёмный бэдж с белой обводкой */
.booster-btn .b-count {
  position: absolute;
  top: -5px;
  right: -5px;
  /* Розовый объёмный шарик с ярким бликом */
  background: radial-gradient(circle at 38% 28%, #ffd0e0 0%, #ff80a0 25%, #f05070 50%, #d03058 75%, #b01840 100%);
  color: #fff;
  font-size: 10px;
  font-family: 'Rubik', sans-serif;
  font-weight: 800;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid #fff;
  box-shadow:
    0 2px 6px rgba(160, 20, 50, 0.4),
    inset 0 1px 2px rgba(255, 220, 230, 0.6),
    inset 0 -1px 2px rgba(120, 10, 30, 0.15);
  z-index: 5;
}

/* Ценник бустера — строго под кнопкой, по центру */
.booster-btn .cost {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: #3a2210;
  font-size: 8px;
  font-family: 'Rubik', sans-serif;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 8px;
  border: 1.5px solid #3a2210;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 5;
}

/* ДОБАВЛЕНО: короткий отклик-"бамп" при нажатии на круглую кнопку инструмента */
.booster-btn.tapped {
  animation: boosterTap 0.26s cubic-bezier(.34,1.56,.64,1);
}
@keyframes boosterTap {
  0%   { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255,214,90,0)); }
  40%  { transform: scale(1.28); filter: drop-shadow(0 0 10px rgba(255,214,90,0.9)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255,214,90,0)); }
}

/* Стиль при наведении/активации бустера */
/* L9: туториал молота — только hammer, FREE */
.booster-panel.tut-hammer-only .booster-btn:not(#btnHammer) {
  opacity: 0.25;
  pointer-events: none;
  filter: grayscale(0.8);
}
#btnHammer.tut-hammer-glow {
  box-shadow: 0 0 0 3px #ffd76a, 0 0 16px rgba(255, 215, 100, 0.85), 3px 3px 0 var(--ink) !important;
  animation: tutHammerPulse 1s ease-in-out infinite;
  z-index: 20;
}
#btnHammer.tut-hammer-free .b-free-tag {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #2ecc71;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  z-index: 6;
  letter-spacing: 0.04em;
}
/* L27: туториал перчатки — только glove, FREE */
.booster-panel.tut-glove-only .booster-btn:not(#btnGlove) {
  opacity: 0.25;
  pointer-events: none;
  filter: grayscale(0.8);
}
#btnGlove.tut-glove-glow {
  box-shadow: 0 0 0 3px #ffd76a, 0 0 16px rgba(255, 215, 100, 0.85), 3px 3px 0 var(--ink) !important;
  animation: tutHammerPulse 1s ease-in-out infinite;
  z-index: 20;
}
#btnGlove.tut-glove-free .b-free-tag {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #2ecc71;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  z-index: 6;
  letter-spacing: 0.04em;
}
@keyframes tutHammerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.booster-btn.active {
  background: radial-gradient(circle at 35% 28%, #fffde0 0%, #ffe060 18%, #f0c020 40%, #d8a818 65%, #c09010 100%) !important;
  border-color: rgba(160, 120, 30, 0.6) !important;
  box-shadow:
    0 0 18px rgba(255, 210, 60, 0.6),
    0 6px 16px rgba(80, 50, 20, 0.3),
    inset 0 3px 8px rgba(255, 255, 240, 0.7),
    inset 0 -3px 6px rgba(120, 80, 20, 0.15);
  transform: scale(1.08);
}
/* ==========================================================================
   15. ОФОРМЛЕНИЕ ВСПЛЫВАЮЩИХ УВЕДОМЛЕНИЙ (TOAST)
   ========================================================================== */
.toast-notification {
  position: fixed;
  bottom: 25%;
  left: 50%;
  transform: translate(-50%, 0);
  background: rgba(13, 11, 15, 0.95);
  color: var(--gold);
  border: 2px solid var(--gold);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: bold;
  text-align: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-notification.show {
  opacity: 1;
  transform: translate(-50%, -10px);
}
/* ==========================================================================
   16. КИНЕМАТОГРАФИЧЕСКИЕ ЭФФЕКТЫ БОНУСОВ HOMESCAPES
   ========================================================================== */

/* Движущийся снаряд (Ракета или Самолетик) */
.m3-projectile {
  position: absolute;
  width: calc(100% / var(--cols));
  height: calc(100% / var(--rows));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  z-index: 99;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: left 0.4s cubic-bezier(0.25, 1, 0.5, 1), top 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: left, top, transform;
}

/* Расширяющаяся ударная волна Бомбы */
.bomb-shockwave {
  position: absolute;
  width: calc(100% / var(--cols));
  height: calc(100% / var(--rows));
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 168, 0.8) 0%, rgba(209, 121, 63, 0.3) 60%, rgba(0,0,0,0) 80%);
  border: 3px solid #ffdca8;
  pointer-events: none;
  z-index: 98;
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  transition: transform 0.35s cubic-bezier(0.1, 0.8, 0.3, 1), opacity 0.35s ease-out;
  will-change: transform, opacity;
}
/* Фоновое изображение сцены новеллы */
.dialogue-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: background-image 0.5s ease-in-out;
  z-index: 101;
}

/* Затемняющий градиент поверх фона, чтобы текст читался лучше */
.dialogue-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(13, 11, 15, 0.95) 15%, rgba(13, 11, 15, 0.4) 60%, rgba(13, 11, 15, 0.8) 100%);
}

/* Контейнер спрайтов персонажей */
.dialogue-sprite-container {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 440px;
  height: 60%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  z-index: 102;
  overflow: hidden;
}

/* Спрайт персонажа */
.dialogue-sprite {
  max-height: 100%;
  max-width: 90%;
  object-fit: contain;
  transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.25s ease;
  transform: translateY(40px) scale(0.95);
  opacity: 0;
}

/* Активное состояние спрайта на экране */
.dialogue-sprite.active {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Обновленный диалоговый бокс поверх спрайта */
.dialogue-window {
  z-index: 103 !important;
  bottom: 20px;
}
/* ==========================================================================
   ИНТЕРАКТИВНЫЙ ИГРОВОЙ ХАБ (УБЕЖИЩЕ)
   ========================================================================== */
/* Настройки полноэкранного вьюпорта квартиры */
.hideout-viewport {
  position: relative;
  width: 100%;
  flex: 1; /* Заполняем всё доступное пространство по высоте под баннером */
  overflow: hidden;
  background: #110f14;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* Широкий контейнер комнаты для эффекта панорамирования */
.room-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 1250px; /* Ширина панорамы для прокрутки */
  height: 100%;
  will-change: left;
}

.room-background {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 1;
}

#hotspotsContainer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

/* Делаем так, чтобы по кнопкам улучшений можно было кликать поверх прозрачного слоя */
.hotspot {
  pointer-events: auto !important;
}

/* Стили хотспотов (точек на экране) */
.hotspot {
  position: absolute;
  z-index: 5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

/* Хотспот-пульсар для улучшений */
.hotspot.type-upgrade::before {
  content: "🛠️";
  font-size: 18px;
  padding: 6px;
  background: var(--gold);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--gold);
  animation: hotspotPulse 1.6s infinite ease-in-out;
}

/* Визуальные тиры мебели (после ремонта) */
.hotspot.type-upgrade.decor-tier-1::before {
  content: "🔧";
  background: #c4a35a;
  box-shadow: 0 0 10px #c4a35a;
}
.hotspot.type-upgrade.decor-tier-2::before {
  content: "✨";
  background: var(--sky);
  box-shadow: 0 0 12px var(--sky);
  animation: none;
}
.hotspot.type-upgrade.decor-tier-3::before {
  content: "👑";
  background: var(--toxic);
  box-shadow: 0 0 14px var(--toxic);
  animation: none;
}
.decor-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 9px;
  font-weight: 800;
  background: var(--ink);
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 1px 3px;
  pointer-events: none;
  z-index: 6;
}
.decor-hold-hint {
  position: absolute;
  top: 2px;
  left: 2px;
  font-size: 8px;
  font-weight: 800;
  background: rgba(255,255,255,0.9);
  color: #5d4037;
  border-radius: 4px;
  padding: 1px 3px;
  pointer-events: none;
  z-index: 6;
  opacity: 0.85;
}
/* Удержание: кольцо прогресса */
.hotspot.type-upgrade.decor-holding::before {
  animation: none !important;
  box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.9), 0 0 16px rgba(255, 193, 7, 0.6);
  transform: scale(1.08);
}
.hotspot.type-upgrade.decor-hold-done::before {
  box-shadow: 0 0 0 4px #43a047, 0 0 18px #81c784;
}
.upgrade-hint {
  font-size: 11px;
  text-align: center;
  margin: -6px 0 12px;
  color: var(--ink);
  line-height: 1.35;
  opacity: 0.9;
}
.upgrade-pos-note {
  font-size: 11px;
  text-align: center;
  margin: 10px 0 0;
  font-weight: 700;
  color: #bf360c;
}
.opt-active-mark {
  color: var(--toxic);
  font-weight: 800;
  font-size: 11px;
}

/* Хотспот-портал для переходов в другие комнаты */
.hotspot.type-portal::before {
  content: "🚪";
  font-size: 20px;
  padding: 6px;
  background: var(--sky);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--sky);
  animation: hotspotPulse 2s infinite ease-in-out;
}

/* Хотспот скрытых предметов */
.hotspot.type-collectible {
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px dashed var(--gold);
  border-radius: 4px;
}
.hotspot.type-collectible::after {
  content: "🔍";
  font-size: 12px;
  opacity: 0.1;
  transition: opacity 0.2s;
}
.hotspot.type-collectible:hover::after {
  opacity: 1;
}

@keyframes hotspotPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 4px cubic-bezier(0.25, 1, 0.5, 1); }
  50% { transform: scale(1.15); box-shadow: 0 0 15px cubic-bezier(0.25, 1, 0.5, 1); }
}

/* Панель инвентаря находок */
.inventory-panel {
  width: 100%;
  background: rgba(13, 11, 15, 0.7);
  border: 2px solid var(--paper);
  border-radius: 12px;
  padding: 10px;
  margin: 12px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.inv-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--gold);
  text-transform: uppercase;
}

.inventory-slots {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.inventory-item {
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
  animation: itemPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes itemPop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Опции выбора мебели (карточки) */
.upgrade-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-option-card {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.upgrade-option-card:hover {
  background: #fbf8f0;
}

.upgrade-option-card.active-decor {
  border-color: var(--toxic);
  background: rgba(122, 154, 63, 0.15);
  cursor: default;
}

.opt-info {
  text-align: left;
}

.opt-name {
  font-size: 13px;
  font-weight: bold;
}

.opt-desc {
  font-size: 10px;
  opacity: 0.75;
}

.opt-btn {
  background: var(--toxic);
  color: var(--paper);
  font-family: 'Bangers', cursive;
  font-size: 14px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  padding: 4px 10px;
  box-shadow: 2px 2px 0 var(--ink);
}
/* ==========================================================================
   ПОДКЛЮЧЕНИЕ ГРАФИЧЕСКОГО ПАКЕТА ФИШЕК (ТОЧНЫЕ СЕРВЕРНЫЕ ИМЕНА)
   ========================================================================== */
/* Цветные фишки — PNG-картинки */
.tile-heart .tile-inner { background-image: url('images/heart.webp'); background-size: 100% 100%; background-repeat: no-repeat; }
.tile-bullet .tile-inner { background-image: url('images/bullet.webp'); background-size: 100% 100%; background-repeat: no-repeat; }
.tile-garlic .tile-inner { background-image: url('images/garlic.webp'); background-size: 100% 100%; background-repeat: no-repeat; }
.tile-stake .tile-inner { background-image: url('images/stake.webp'); background-size: 100% 100%; background-repeat: no-repeat; }
.tile-vial .tile-inner { background-image: url('images/vial.webp'); background-size: 100% 100%; background-repeat: no-repeat; }
.tile-coin .tile-inner { background-image: url('images/coin.webp'); background-size: 100% 100%; background-repeat: no-repeat; }
.tile-holy_water .tile-inner {
  background-image: url('images/vial.webp');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.tile-donut .tile-inner { background-image: url('images/donut.webp'); background-size: 100% 100%; background-repeat: no-repeat; }

/* Препятствия: PNG contain + прозрачный фон (без растянутых «квадратов») */
.tile.box.layer-3 .tile-inner,
.tile.box.layer-2 .tile-inner,
.tile.box.layer-1 .tile-inner,
.tile.vase.layer-2 .tile-inner,
.tile.vase.layer-1 .tile-inner,
.tile.nut.layer-3 .tile-inner,
.tile.nut.layer-2 .tile-inner,
.tile.nut.layer-1 .tile-inner,
.tile.cookie.layer-3 .tile-inner,
.tile.cookie.layer-2 .tile-inner,
.tile.cookie.layer-1 .tile-inner,
.tile.plaid.layer-4 .tile-inner,
.tile.plaid.layer-3 .tile-inner,
.tile.plaid.layer-2 .tile-inner,
.tile.plaid.layer-1 .tile-inner,
.tile.stone.layer-3 .tile-inner,
.tile.stone.layer-2 .tile-inner,
.tile.stone.layer-1 .tile-inner,
.tile.surprise-box.layer-5 .tile-inner,
.tile.surprise-box.layer-4 .tile-inner,
.tile.surprise-box.layer-3 .tile-inner,
.tile.surprise-box.layer-2 .tile-inner,
.tile.surprise-box.layer-1 .tile-inner,
.tile.carpet-roll .tile-inner,
.tile.ribbon .tile-inner,
.tile.ivy .tile-inner,
.tile.foam .tile-inner,
.tile.purple-foam .tile-inner {
  background-color: transparent !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  border: none !important;
  box-shadow: none !important;
}

/* Препятствия: Деревянные Ящики ( box_1, box_2, box_3 ) */
.tile.box.layer-3 .tile-inner { background-image: url('images/box_3.webp') !important; }
.tile.box.layer-2 .tile-inner { background-image: url('images/box_2.webp') !important; }
.tile.box.layer-1 .tile-inner { background-image: url('images/box_1.webp') !important; }

/* Препятствия: Глиняные Вазы ( vase_1, vase_2 ) */
.tile.vase.layer-2 .tile-inner { background-image: url('images/vase_2.webp') !important; }
.tile.vase.layer-1 .tile-inner { background-image: url('images/vase_1.webp') !important; }

/* Препятствия: Орехи ( nut_1, nut_2, nut_3 ) */
.tile.nut.layer-3 .tile-inner { background-image: url('images/nut_3.webp') !important; }
.tile.nut.layer-2 .tile-inner { background-image: url('images/nut_2.webp') !important; }
.tile.nut.layer-1 .tile-inner { background-image: url('images/nut_1.webp') !important; }

/* Препятствия: Печенье ( cookie_1, cookie_2, cookie_3 ) */
.tile.cookie.layer-3 .tile-inner { background-image: url('images/cookie_3.webp') !important; }
.tile.cookie.layer-2 .tile-inner { background-image: url('images/cookie_2.webp') !important; }
.tile.cookie.layer-1 .tile-inner { background-image: url('images/cookie_1.webp') !important; }

/* Препятствия: Пледы ( plaid_1, plaid_2, plaid_3, plaid_4 ) */
.tile.plaid.layer-4 .tile-inner { background-image: url('images/plaid_4.webp') !important; }
.tile.plaid.layer-3 .tile-inner { background-image: url('images/plaid_3.webp') !important; }
.tile.plaid.layer-2 .tile-inner { background-image: url('images/plaid_2.webp') !important; }
.tile.plaid.layer-1 .tile-inner { background-image: url('images/plaid_1.webp') !important; }

/* Футляры: art через <img.ring-case-art> (JS ставит src:
   closed=ringCase_1, empty=ringCase_2, ring=ringCase_3).
   CSS background у .tile-inner ОТКЛЮЧЁН — чтобы не конфликтовать. */
.tile.ring-case .tile-inner,
.tile.tile-ringCase .tile-inner {
  background: none !important;
  background-image: none !important;
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-size: 0 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  overflow: visible;
}
.tile.ring-case .ring-case-art,
.tile.tile-ringCase .ring-case-art {
  width: 92%;
  height: 92%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
/* Короткий «открылся» */
.tile.ring-case.ring-case-opening .ring-case-art {
  animation: ringCaseOpenPop 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
@keyframes ringCaseOpenPop {
  0%   { transform: scale(0.86) rotate(-4deg); filter: brightness(1.15); }
  60%  { transform: scale(1.08) rotate(2deg); }
  100% { transform: scale(1) rotate(0deg); filter: brightness(1); }
}
.tile.ring-case.ring-case-score .ring-case-art {
  filter: drop-shadow(0 0 8px rgba(255, 215, 80, 0.95));
}
.tile.ring-case.ring-case-score {
  z-index: 8;
}

/* Препятствия: Каменные Фигурки ( stone_1, stone_2, stone_3 ) */
.tile.stone.layer-3 .tile-inner { background-image: url('images/stone_3.webp') !important; }
.tile.stone.layer-2 .tile-inner { background-image: url('images/stone_2.webp') !important; }
.tile.stone.layer-1 .tile-inner { background-image: url('images/stone_1.webp') !important; }

/* Особые Угрозы: Рулон ковра, лента с бантами, плющ, мыло */
.tile.carpet-roll .tile-inner { background-image: url('images/carpetRoll_6.webp') !important; }
.tile.ribbon .tile-inner { background-image: url('images/ribbon.webp') !important; }
.tile.ivy .tile-inner { background-image: url('images/ivy.webp') !important; }
.tile.foam .tile-inner { background-image: url('images/foam.webp') !important; }
.tile.purple-foam .tile-inner { background-image: url('images/purpleFoam.webp') !important; }

/* Многослойные коробки сюрпризы ( surpriseBox_1 - surpriseBox_5 ) */
.tile.surprise-box.layer-5 .tile-inner { background-image: url('images/surpriseBox_5.webp') !important; }
.tile.surprise-box.layer-4 .tile-inner { background-image: url('images/surpriseBox_4.webp') !important; }
.tile.surprise-box.layer-3 .tile-inner { background-image: url('images/surpriseBox_3.webp') !important; }
.tile.surprise-box.layer-2 .tile-inner { background-image: url('images/surpriseBox_2.webp') !important; }
.tile.surprise-box.layer-1 .tile-inner { background-image: url('images/surpriseBox_1.webp') !important; }

/* Преграды поверх фишек: Лёд ( ice_1, ice_2 ) и Цепи ( chain_1, chain_2 ) */
.tile.frozen .tile-inner::after { 
  content: "" !important; 
  position: absolute;
  inset: 0;
  background-size: 100% 100% !important; 
  background-repeat: no-repeat;
  background-position: center;
  backdrop-filter: none; 
  z-index: 6;
}
.tile.frozen-2 .tile-inner::after { background-image: url('images/ice_2.webp') !important; }
.tile.frozen-1 .tile-inner::after { background-image: url('images/ice_1.webp') !important; }

.tile.chained .tile-inner::after { 
  content: "" !important; 
  position: absolute;
  inset: 0;
  background-size: 100% 100% !important; 
  background-repeat: no-repeat;
  background-position: center;
  z-index: 7;
}
.tile.chain-2 .tile-inner::after { background-image: url('images/chain_2.webp') !important; }
.tile.chain-1 .tile-inner::after { background-image: url('images/chain_1.webp') !important; }

/* Бустеры: Ракеты, Бомба, Радуга, Самолетик */
.tile.bomb .tile-inner,
.tile.plane .tile-inner,
.tile.rainbow .tile-inner,
.tile.rocket-row .tile-inner,
.tile.rocket-col .tile-inner {
  background-color: transparent !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  border: none !important;
  box-shadow: none !important;
}
.tile.bomb .tile-inner { background-image: url('images/bomb.webp?v=9') !important; }
.tile.plane .tile-inner { background-image: url('images/plane.webp?v=9') !important; }
.tile.rainbow .tile-inner { background-image: url('images/rainbow.webp?v=9') !important; }
.tile.rocket-row .tile-inner { background-image: url('images/rocketRow.webp') !important; transform: none !important; }
.tile.rocket-col .tile-inner { background-image: url('images/rocketCol.webp') !important; }

/* tile-pop должен перебивать бесконечный rocketGlow при активации ракеты */
.tile.rocket-row.tile-pop .tile-inner,
.tile.rocket-col.tile-pop .tile-inner {
  animation: tileRocketPop 0.24s ease-in forwards !important;
}

/* tile-pop при пролёте ракеты: перебивает specialGlow у bomb/plane/rainbow */
.tile.bomb.tile-pop .tile-inner,
.tile.plane.tile-pop .tile-inner,
.tile.rainbow.tile-pop .tile-inner {
  animation: tileRocketPop 0.24s ease-in forwards !important;
}
/* ==========================================================================
   ЗАМЕНА ВСЕХ СЛОЖНЫХ ШРИФТОВ НА ЧИТАЕМЫЙ ШРИФТ RUBIK (ДЛЯ КИРИЛЛИЦЫ)
   ========================================================================== */
.hud-val, 
.location-banner, 
.menu-btn, 
.decor-card h3, 
.ui-card h2, 
.action-btn, 
.speaker-name, 
.task-btn {
  font-family: 'Rubik', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
  letter-spacing: 0px !important; /* Убираем лишний разброс букв для лучшей читаемости */
  font-weight: 800 !important;   /* Делаем заголовки сочными и четкими */
}
/* Pre-level Homescapes: округлый Nunito, не Bangers/Rubik-угол */
.pre-level-card,
.pre-level-card h2,
.pre-level-card .pre-play-btn,
.pre-level-card .start-btn,
.pre-level-card .pre-goal-num,
.pre-level-card .pre-moves-num,
.pre-level-card .reward-pill,
.pre-level-card .b-tag {
  font-family: 'Nunito', 'Rubik', system-ui, sans-serif !important;
  letter-spacing: 0.01em !important;
  -webkit-text-stroke: 0 !important;
}
/* Фиксация меню навигации Убежища на экране (ИСПРАВЛЕНО) */
#screenHideout {
  height: 100%;
  overflow: hidden; /* Запрещаем общий скролл экрана, чтобы кнопки не улетали вниз */
  display: flex;
  flex-direction: column;
}
/* ==========================================================================
   НАСТРОЙКА ПАРЯЩЕГО ИНТЕРФЕЙСА (HUD) ДЛЯ УБЕЖИЩА
   ========================================================================== */
#screenHideout {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* 1. Квартира уходит на самый задний план и занимает 100% экрана */
#screenHideout .hideout-viewport {
  position: absolute;
  inset: 0;
  z-index: 1; /* Задний слой */
  width: 100%;
  height: 100%;
}

/* 2. Парящая плашка комнаты сверху */
#screenHideout .location-banner {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  width: calc(100% - 20px) !important;
  z-index: 10; /* Поверх квартиры */
  margin-bottom: 0;
}

/* Название локации сверху скрыто (по просьбе Настюли) */
#screenHideout .location-banner {
  display: none !important;
}

/* 3. Парящий инвентарь над кнопками */
#screenHideout .inventory-panel {
  position: absolute;
  bottom: 92px; /* Чуть выше кнопок */
  left: 10px;
  right: 10px;
  width: calc(100% - 20px) !important;
  z-index: 10;
  background: rgba(13, 11, 15, 0.85); /* Полупрозрачный темный фон */
  border: 2px solid var(--paper);
  box-sizing: border-box;
}

/* Инвентарь свёрнут по умолчанию — открывается по значку рюкзака 🎒 */
#screenHideout .inventory-panel:not(.inventory-open) {
  display: none !important;
}
#screenHideout .inventory-panel.inventory-open {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}

/* 4. Парящие кнопки Сюжет и Охота у самого низа */
#screenHideout .screen-navigation {
  position: absolute;
  bottom: 20px;
  left: 10px;
  right: 10px;
  width: calc(100% - 20px) !important;
  z-index: 10;
  background: transparent;
  padding-top: 0;
  pointer-events: none; /* Пропускаем клики сквозь пустые места */
}

#screenHideout .screen-navigation .menu-btn {
  pointer-events: auto; /* Но сами кнопки остаются кликабельными */
}
/* ==========================================================================
   ИДЕАЛЬНОЕ ВЫРАВНИВАНИЕ И СТРОГИЙ КВАДРАТ 1:1 ИГРОВОГО ПОЛЯ (REDESIGN)
   ========================================================================== */
#boardWrap {
  width: 100% !important;
  max-width: 480px !important;
  margin: 0 auto !important;
  box-sizing: border-box !important;
}

/* Высокие поля (вертикальные раскладки, например 8×11) на невысоких экранах:
   ширина доски зажата так, чтобы по высоте поместились шапка и бустеры.
   Для обычных полей результат больше доступной ширины — правило не срабатывает. */
@media (max-height: 760px) {
  #boardWrap {
    max-width: min(480px, calc((100dvh - 220px) * var(--cols) / var(--rows))) !important;
  }
}

#boardWrap.scroll-field-mode {
  overflow: hidden !important;
  /* размеры окна — из JS (px), не percent+aspect */
}

#board {
  aspect-ratio: var(--cols) / var(--rows);
  width: 100% !important;
  height: auto !important;
}
#boardWrap.scroll-field-mode #board {
  /* width/height в px из syncGridDimensions — не перебивать percent'ами */
  max-width: none !important;
  aspect-ratio: auto !important;
}
/* ==========================================================================
   КОРРЕКЦИЯ ПРОПОРЦИЙ ФИШЕК (СТРОГО 1 К 1 БЕЗ ИСКАЖЕНИЯ)
   ========================================================================== */
.tile .tile-inner,
.tile.box .tile-inner,
.tile.vase .tile-inner,
.tile.nut .tile-inner,
.tile.cookie .tile-inner,
.tile.plaid .tile-inner,
.tile.ring-case .tile-inner,
.tile.stone .tile-inner,
.tile.surprise-box .tile-inner,
.tile.carpet-roll .tile-inner {
  background-size: contain !important; /* Вписываем картинку идеально 1:1 */
  background-position: center !important; /* Центрируем её в ячейке */
  background-repeat: no-repeat !important;
}
/* ==========================================================================
   ШАХМАТНЫЙ УЗОР — УДАЛЁН (ячейки уже единый полупрозрачный слой)
   ========================================================================== */

/* ============================================================
   Убрано название-баннер на главном экране (Убежище).
   Скрываем только #hideoutRoomTitle — баннеры на карте
   ("Охотничьи угодья") и в бою остаются на месте.
   ============================================================ */
/* Показываем название локации — важно для большого мира */
#hideoutRoomTitle {
  display: block !important;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  padding: 6px 10px;
  margin-bottom: 6px;
  background: rgba(13, 11, 15, 0.75);
  border: 2px solid var(--paper);
  border-radius: 10px;
  color: var(--paper);
}

/* Поиск / дверь / крепости */
.hotspot.type-search::before {
  content: "🔍";
  font-size: 16px;
  padding: 5px;
  background: var(--hazard);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--hazard);
  animation: hotspotPulse 1.8s infinite ease-in-out;
}
.hotspot.type-gated_door::before {
  content: none;
}
.hotspot.type-gated_door.door-locked {
  outline: 2px dashed var(--blood);
}
.hotspot.type-gated_door.door-ready {
  outline: 2px solid var(--toxic);
  box-shadow: 0 0 12px var(--toxic);
}
/* Двери прихожей: маленькая белая точка (закрытая дверь — замок) */
.hotspot.hotspot-door {
  background: none;
  border: none;
  box-shadow: none;
}
.hotspot.hotspot-door:hover {
  transform: none;
}
/* Полностью нейтрализуем старый пульсар-кружок порталов для дверей прихожей:
   обнуляем ВСЕ свойства старого .hotspot.type-portal::before (рамка, паддинг, пульсация) */
.hotspot.type-portal.hotspot-door::before,
.hotspot.hotspot-door::before {
  content: "";
  width: 13px;
  height: 13px;
  padding: 0;
  font-size: 16px;
  border: none;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.9), 0 0 10px rgba(255, 255, 255, 0.4);
  animation: none;
}
/* Закрытая входная дверь — замок вместо точки */
.hotspot.hotspot-door.door-locked::before {
  content: "🔒";
  width: auto;
  height: auto;
  background: none;
  border-radius: 0;
  font-size: 13px;
  line-height: 1;
  animation: none;
  box-shadow: 0 0 10px rgba(191, 54, 12, 0.4);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.hotspot.hotspot-door .hotspot-label {
  display: none;
}
.hotspot.hotspot-door.door-locked,
.hotspot.hotspot-door.door-ready {
  outline: none;
  box-shadow: none;
}
.hotspot.type-fortress_gate {
  outline: 2px solid var(--gold);
}
.hotspot-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 800;
  color: var(--paper);
  text-shadow: 0 1px 2px #000, 0 0 6px #000;
  white-space: nowrap;
  pointer-events: none;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.location-danger-badge {
  width: 100%;
  max-width: 440px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
  border: 2px solid var(--ink);
}
.location-danger-badge.danger-safe { background: var(--toxic); color: var(--ink); }
.location-danger-badge.danger-mid { background: var(--hazard); color: var(--ink); }
.location-danger-badge.danger-high { background: var(--blood); color: var(--paper); }
.hunt-here-btn {
  background: var(--hazard) !important;
  color: var(--ink) !important;
  font-size: 12px !important;
}

/* ==========================================================================
   КНОПКА «ИГРАТЬ» + ПИРАТСКАЯ КАРТА
   ========================================================================== */
.nav-with-play {
  display: flex !important;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

.nav-with-play .menu-btn {
  flex: 1;
  min-height: 48px;
  font-size: 12px;
}

.menu-btn.play-btn {
  flex: 1.45 !important;
  background: linear-gradient(180deg, #e8b84a 0%, var(--gold) 45%, #a67c1a 100%) !important;
  color: var(--ink) !important;
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  padding: 6px 10px !important;
}

.menu-btn.play-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.play-icon {
  font-size: 18px;
  line-height: 1;
}

.play-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.play-label {
  font-family: 'Bangers', cursive;
  font-size: 18px;
  letter-spacing: 1px;
}

.play-level {
  font-size: 11px;
  font-weight: 800;
  opacity: 0.85;
}

.menu-btn.story-btn {
  background: var(--sky) !important;
  color: var(--paper) !important;
}

.menu-btn.hunt-btn {
  background: var(--blood) !important;
  color: var(--paper) !important;
}

/* --- Пиратская карта --- */
.pirate-map-banner {
  display: flex !important;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
}

.map-hint-mini {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.75;
}

.pirate-map-viewport {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 360px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: var(--panel-shadow);
  background: #2a2118;
  touch-action: none;
  cursor: grab;
  -webkit-overflow-scrolling: touch;
}

.pirate-map-viewport:active {
  cursor: grabbing;
}

.pirate-map-surface {
  position: relative;
  /* parchment look */
  background:
    radial-gradient(ellipse at 20% 30%, rgba(255, 230, 170, 0.35), transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(120, 80, 40, 0.25), transparent 45%),
    linear-gradient(145deg, #d4b896 0%, #c4a574 40%, #b8956a 70%, #a8845c 100%);
  box-shadow: inset 0 0 80px rgba(60, 35, 15, 0.35);
}

.pirate-map-surface::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(80,50,20,0.08) 3px, rgba(80,50,20,0.08) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(80,50,20,0.06) 3px, rgba(80,50,20,0.06) 4px);
}

.pirate-map-paths {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 1;
}

.pirate-map-paths .path-open {
  stroke: #5c3a1e;
  stroke-width: 3;
  stroke-dasharray: 10 8;
  opacity: 0.75;
}

.pirate-map-paths .path-fog {
  stroke: #7a6a55;
  stroke-width: 2;
  stroke-dasharray: 4 10;
  opacity: 0.35;
}

.pirate-map-pins {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.pirate-zone-stamp {
  position: absolute;
  transform: translate(-50%, -50%) rotate(-6deg);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0.55;
  z-index: 1;
}

.pirate-zone-stamp.is-fog {
  opacity: 0.22;
  filter: grayscale(0.6);
}

.zs-icon { font-size: 22px; }
.zs-name {
  font-family: 'Bangers', cursive;
  font-size: 13px;
  color: #4a3018;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 0 rgba(255,240,200,0.5);
  white-space: nowrap;
}

.pirate-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  z-index: 3;
  max-width: 110px;
}

.pirate-pin .pin-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: #f0e2c4;
  border: 2.5px solid #3a2412;
  box-shadow: 2px 2px 0 rgba(30, 15, 5, 0.45);
  transition: transform 0.12s ease;
}

.pirate-pin:active .pin-dot {
  transform: scale(0.92);
}

.pirate-pin .pin-label {
  font-size: 9px;
  font-weight: 800;
  color: #2a180c;
  background: rgba(240, 226, 196, 0.9);
  border: 1px solid #3a2412;
  border-radius: 4px;
  padding: 1px 4px;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.pirate-pin.is-here .pin-dot {
  background: var(--toxic);
  box-shadow: 0 0 0 4px rgba(122, 154, 63, 0.35), 2px 2px 0 #1a1008;
  animation: pinPulse 1.4s infinite ease-in-out;
}

.pirate-pin.is-locked .pin-dot {
  opacity: 0.55;
  background: #9a8f7c;
}

.pirate-pin.is-unknown .pin-dot {
  background: #6b5e4e;
  color: #eee;
}

.pirate-pin.is-danger .pin-dot {
  border-color: var(--blood);
  box-shadow: 0 0 8px rgba(200, 29, 63, 0.45);
}

.pirate-pin.can-hunt.is-open .pin-dot {
  outline: 2px dashed var(--hazard);
}

@keyframes pinPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.pirate-map-compass {
  position: absolute;
  right: 40px;
  top: 40px;
  font-size: 42px;
  opacity: 0.5;
  pointer-events: none;
  z-index: 1;
  filter: drop-shadow(1px 1px 0 #3a2412);
}

.pirate-map-title-stamp {
  position: absolute;
  left: 80px;
  top: 60px;
  font-family: 'Bangers', cursive;
  font-size: 28px;
  color: rgba(90, 40, 20, 0.35);
  transform: rotate(-8deg);
  pointer-events: none;
  z-index: 1;
  line-height: 1.05;
  text-align: center;
  border: 3px solid rgba(90, 40, 20, 0.25);
  padding: 8px 14px;
  border-radius: 8px;
}

.pirate-map-title-stamp small {
  font-family: 'Rubik', sans-serif;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.pirate-map-legend {
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: 3px 3px 0 var(--ink);
  line-height: 1.3;
}

#screenMap {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 70px);
}

#screenMap.hidden {
  display: none !important;
}

/* ==========================================================================
   VICTORY TRANSITION
   ========================================================================== */
.victory-fx-layer {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  overflow: hidden;
}
.victory-fx-layer.hidden {
  display: none !important;
}

.victory-fly-coin {
  position: fixed;
  font-size: 22px;
  z-index: 210;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.35));
  will-change: left, top, transform, opacity;
}

.hud-cash-pulse {
  animation: hudCashPulse 0.4s cubic-bezier(0.34, 1.4, 0.64, 1);
}
@keyframes hudCashPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); filter: drop-shadow(0 0 8px #ffd15a); }
  100% { transform: scale(1); }
}

.victory-banner {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) scale(0.55);
  opacity: 0;
  text-align: center;
  pointer-events: none;
  transition:
    transform 0.55s cubic-bezier(0.34, 1.45, 0.64, 1),
    opacity 0.35s ease-out;
}
.victory-banner.victory-banner-on {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.victory-banner.victory-banner-out {
  opacity: 0;
  transform: translate(-50%, -55%) scale(1.08);
  transition: transform 0.3s ease-in, opacity 0.3s ease-in;
}
.victory-title {
  font-family: 'Bangers', cursive;
  font-size: clamp(42px, 12vw, 64px);
  letter-spacing: 2px;
  color: #ffd15a;
  text-shadow:
    0 0 12px rgba(255, 209, 90, 0.9),
    0 0 28px rgba(255, 160, 40, 0.65),
    3px 3px 0 #3a2208;
  margin-top: 8px;
}
.victory-sub {
  margin-top: 8px;
  font-family: 'Rubik', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: #fff8e7;
  text-shadow: 0 2px 6px rgba(0,0,0,0.55);
}
.victory-star-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.victory-star {
  font-size: 72px;
  line-height: 1;
  animation: victoryStarPop 0.7s cubic-bezier(0.34, 1.5, 0.64, 1) both;
  filter: drop-shadow(0 0 10px #ffd15a) drop-shadow(0 0 22px #ff9f1a);
  z-index: 2;
}
.victory-star-glow {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,209,90,0.75) 0%, rgba(255,160,40,0.25) 45%, transparent 70%);
  animation: victoryStarGlow 1.2s ease-in-out infinite alternate;
  z-index: 1;
}
@keyframes victoryStarPop {
  0%   { transform: scale(0.2) rotate(-20deg); opacity: 0; }
  55%  { transform: scale(1.25) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes victoryStarGlow {
  from { transform: scale(0.9); opacity: 0.7; }
  to   { transform: scale(1.2); opacity: 1; }
}
.victory-gold-spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffd15a 50%, transparent 70%);
  box-shadow: 0 0 6px #ffd15a;
  animation: victorySparkFly 0.7s cubic-bezier(0.2, 0.8, 0.3, 1) both;
  animation-delay: inherit;
  pointer-events: none;
}
@keyframes victorySparkFly {
  0%   { transform: translate(0,0) scale(0.4); opacity: 1; }
  100% { transform: translate(var(--sx), var(--sy)) scale(0); opacity: 0; }
}

.tile.victory-booster-spawn .tile-inner {
  animation: victoryBoosterSpawn 0.45s cubic-bezier(0.34, 1.5, 0.64, 1) both;
}
@keyframes victoryBoosterSpawn {
  0%   { transform: scale(0.2) rotate(-30deg); filter: brightness(2); }
  60%  { transform: scale(1.2) rotate(8deg); filter: brightness(1.3); }
  100% { transform: scale(1) rotate(0deg); filter: brightness(1); }
}
.tile.victory-booster-fire .tile-inner {
  animation: victoryBoosterFire 0.35s ease-out;
  filter: drop-shadow(0 0 12px #fff) drop-shadow(0 0 18px #ffd15a);
}
@keyframes victoryBoosterFire {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.results-win-block {
  text-align: center;
  font-family: 'Rubik', sans-serif;
  line-height: 1.55;
}
.results-stars {
  font-size: 28px;
  margin-bottom: 8px;
  letter-spacing: 4px;
  animation: resultsStarsIn 0.5s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
@keyframes resultsStarsIn {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.results-line { font-size: 14px; }
.results-total {
  margin-top: 10px;
  font-size: 18px;
  font-weight: 800;
  color: var(--blood-dark, #8b1e2d);
}
.ui-overlay.overlay-win .ui-card {
  box-shadow: 0 0 0 3px rgba(255, 209, 90, 0.55), 8px 8px 0 var(--blood);
  animation: winCardIn 0.45s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}
@keyframes winCardIn {
  from { transform: scale(0.85) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* FieldLayer: масло */
.grid-cell.oil {
  background-image: radial-gradient(ellipse at 40% 40%, rgba(40,30,20,0.55), rgba(20,12,8,0.75));
  box-shadow: inset 0 0 12px rgba(0,0,0,0.45);
}
.grid-cell.oil.oil-spread {
  animation: oilSpread 0.48s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.grid-cell.oil-clear {
  animation: oilClear 0.4s ease-out both;
}
@keyframes oilSpread {
  from { opacity: 0; transform: scale(0.6); filter: blur(2px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}
@keyframes oilClear {
  from { opacity: 1; filter: brightness(1.4); }
  to { opacity: 0; filter: brightness(2); }
}

/* Керамика */
.grid-cell.ceramic-intact {
  background-image: linear-gradient(145deg, #e8eef5 0%, #b8c4d4 50%, #9aabbf 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6), inset 0 -2px 6px rgba(0,0,0,0.12);
}
.grid-cell.ceramic-cracked {
  background-image:
    linear-gradient(145deg, rgba(232,238,245,0.85), rgba(154,171,191,0.9)),
    repeating-linear-gradient(60deg, transparent, transparent 6px, rgba(40,40,50,0.25) 6px, rgba(40,40,50,0.25) 7px),
    repeating-linear-gradient(-40deg, transparent, transparent 8px, rgba(40,40,50,0.18) 8px, rgba(40,40,50,0.18) 9px);
  box-shadow: inset 0 0 8px rgba(0,0,0,0.2);
}

/* Блюдо 2×2 */
.tile.apple-dish {
  z-index: 4;
}
.tile.apple-dish .tile-inner {
  font-size: 13px !important;
  line-height: 1.05;
  text-align: center;
  background: radial-gradient(circle at 50% 60%, #f5e6c8 0%, #d4a574 70%, #8b5a2b 100%) !important;
  border-radius: 18%;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.2);
}
.tile.apple-dish .apple-cross {
  display: inline-block;
  filter: drop-shadow(0 0 4px gold);
  animation: appleCrossPulse 0.9s ease-in-out infinite alternate;
}
@keyframes appleCrossPulse {
  from { transform: scale(1); }
  to { transform: scale(1.12); }
}
.tile.apple-dish-part .tile-inner {
  background: transparent !important;
  pointer-events: none;
}
.fly-apple {
  position: fixed;
  font-size: 22px;
  z-index: 220;
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.35));
}

/* Walls (L71): edges between cells — block swap, not matches */
.grid-wall {
  position: absolute;
  z-index: 8;
  pointer-events: none;
  box-shadow: 0 0 4px rgba(40, 30, 20, 0.55);
}
.grid-wall-h {
  height: 5px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, #6d4c41, #a1887f 40%, #5d4037 100%);
  border-radius: 2px;
}
.grid-wall-v {
  width: 5px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #6d4c41, #a1887f 40%, #5d4037 100%);
  border-radius: 2px;
}

/* Portals (L41) — неоновое свечение входа и выхода */
.grid-portal {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 10px;
  line-height: 1;
  z-index: 3;
  pointer-events: none;
  opacity: 0.85;
}
.grid-portal-in {
  left: 2px;
  right: auto;
  animation: portalEntryGlow 2s ease-in-out infinite;
}
.grid-portal-out {
  animation: portalExitGlow 2s ease-in-out infinite;
}
.grid-portal.portal-blocked { opacity: 0.45; }

/* Вход портала — мягкое голубое пульсирующее свечение */
@keyframes portalEntryGlow {
  0%, 100% {
    filter: drop-shadow(0 0 3px rgba(80, 180, 255, 0.4)) drop-shadow(0 0 8px rgba(60, 140, 255, 0.2));
  }
  50% {
    filter: drop-shadow(0 0 6px rgba(100, 200, 255, 0.8)) drop-shadow(0 0 14px rgba(60, 140, 255, 0.5));
  }
}

/* Выход портала — фиолетовое пульсирующее свечение */
@keyframes portalExitGlow {
  0%, 100% {
    filter: drop-shadow(0 0 3px rgba(180, 100, 255, 0.4)) drop-shadow(0 0 8px rgba(140, 60, 255, 0.2));
  }
  50% {
    filter: drop-shadow(0 0 6px rgba(200, 130, 255, 0.8)) drop-shadow(0 0 14px rgba(140, 60, 255, 0.5));
  }
}

/* Gravitation (L25): статичная подпись, без мерцания всего поля */
#board.gravitation-active::after,
.board.gravitation-active::after {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(20, 24, 40, 0.45);
  padding: 2px 8px;
  border-radius: 10px;
  z-index: 13;
  pointer-events: none;
  opacity: 0.9;
}
#board.grav-up.gravitation-active::after { content: '↑'; }
#board.grav-left.gravitation-active::after { content: '←'; }
#board.grav-right.gravitation-active::after { content: '→'; }
#board.grav-down.gravitation-active::after { content: none; }

#board.grav-split::before,
#board.grav-split::after {
  display: grid !important;
  position: absolute;
  top: 3px;
  width: 1.2em;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid #b2c6db;
  border-radius: 50%;
  background: #283449;
  color: #fff;
  font: 800 clamp(12px, 3vw, 16px)/1 system-ui, sans-serif;
  z-index: 13;
  pointer-events: none;
}
#board.grav-split::before { content: '↓'; left: 23%; }
#board.grav-split::after { content: '↑'; right: 23%; }


/* Element generator (L111) */
.tile.element-gen .tile-inner {
  font-size: 20px !important;
  background: linear-gradient(160deg, #eceff1, #90a4ae 55%, #546e7a) !important;
  border-radius: 18%;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.15), 0 0 0 2px rgba(255,255,255,0.2);
}
.tile.element-gen .gen-label {
  display: inline-block;
  font-size: 16px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.35));
}

/* Жалюзи — спокойные полосы на клетке */
.grid-cell.blind {
  background:
    repeating-linear-gradient(
      180deg,
      #5c6b7a 0px,
      #5c6b7a 4px,
      #3d4a56 4px,
      #3d4a56 7px
    ) !important;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
  z-index: 1;
}
.grid-cell.blind::after {
  content: none !important;
}

/* Печка */
.tile.oven .tile-inner {
  font-size: 26px !important;
  background: linear-gradient(180deg, #ff8a65, #bf360c) !important;
  border-radius: 16%;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.2);
}
.tile.oven.oven-bake .tile-inner {
  animation: ovenBake 0.4s ease-out;
}
@keyframes ovenBake {
  0% { transform: scale(1); filter: brightness(1); }
  40% { transform: scale(1.08); filter: brightness(1.25); }
  100% { transform: scale(1); }
}

/* Телефон */
.tile.phone .tile-inner {
  font-size: 24px !important;
  background: linear-gradient(180deg, #90a4ae, #455a64) !important;
  border-radius: 18%;
}
.tile.phone.phone-ringing .tile-inner {
  background: linear-gradient(180deg, #81c784, #2e7d32) !important;
  animation: phoneRing 0.35s ease-in-out infinite alternate;
}
@keyframes phoneRing {
  from { transform: rotate(-6deg); }
  to { transform: rotate(6deg); }
}

/* Генератор пены */
.tile.soap-foamer .tile-inner {
  font-size: 28px !important;
  background: linear-gradient(180deg, #e3f2fd, #90caf9) !important;
  border-radius: 20%;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.1);
}
.tile.soap-foamer.foamer-stunned .tile-inner {
  filter: saturate(0.5) brightness(1.15);
  animation: foamerStun 0.6s ease-in-out infinite alternate;
}
@keyframes foamerStun {
  from { transform: scale(0.92); }
  to { transform: scale(1); }
}
.tile.soap-foamer.foamer-spit .tile-inner {
  animation: foamerSpit 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
}
@keyframes foamerSpit {
  0% { transform: scale(1); }
  40% { transform: scale(1.2); filter: brightness(1.3); }
  100% { transform: scale(1); }
}

/* Жизни HUD */
.lives-stat {
  cursor: pointer;
  user-select: none;
}
.lives-stat:active { transform: scale(0.96); }
.lives-stat.lives-unlimited {
  box-shadow: 0 0 10px rgba(255, 200, 80, 0.55);
}
.lives-stat.lives-unlimited .hud-icon::after {
  content: "∞";
  font-size: 10px;
  margin-left: 2px;
}
.lives-stat.lives-empty {
  animation: livesEmptyPulse 1s ease-in-out infinite alternate;
}
@keyframes livesEmptyPulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.25) saturate(1.3); }
}
.lives-card .lives-lead {
  text-align: center;
  font-size: 13px;
  line-height: 1.35;
  opacity: 0.9;
  margin: 0 0 10px;
}
.lives-card .lives-status {
  text-align: center;
  font-family: 'Bangers', cursive;
  font-size: 28px;
  margin: 0 0 6px;
}
.lives-card .lives-regen {
  text-align: center;
  font-size: 13px;
  margin: 0 0 14px;
  opacity: 0.85;
}
.lives-card .lives-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lives-card .lives-actions .action-btn:disabled {
  opacity: 0.55;
  pointer-events: none;
}

/* Планшет дома — левый нижний угол экрана убежища */
.house-tablet-btn {
  position: absolute;
  left: 10px;
  bottom: 78px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 56px;
  padding: 8px 4px 6px;
  border: 2px solid var(--ink, #2a1f18);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffe082, #ffb74d);
  box-shadow: 0 4px 0 rgba(0,0,0,0.2);
  font-size: 22px;
  cursor: pointer;
  line-height: 1.1;
}
.house-tablet-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.2); }
.house-tablet-label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #3e2723;
}
#screenHideout:not(.active):not(.game-screen) .house-tablet-btn,
.game-screen:not(#screenHideout) .house-tablet-btn { /* keep visible only on hideout via parent */ }
#screenHideout.hidden .house-tablet-btn,
body:not(:has(#screenHideout:not(.hidden))) .house-tablet-btn {
  /* fallback: button is inside screenHideout so hides with screen */
}

.house-tablet-card {
  max-width: 420px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.house-tablet-stars {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 4px;
}
.house-tablet-summary {
  text-align: center;
  font-weight: 700;
  margin: 0 0 6px;
}
.house-tablet-lead {
  font-size: 12px;
  line-height: 1.35;
  opacity: 0.9;
  margin: 0 0 10px;
  text-align: center;
}
.house-tablet-list {
  overflow-y: auto;
  max-height: 50vh;
  margin-bottom: 12px;
  text-align: left;
}
.house-room-block {
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(255,255,255,0.45);
}
.house-room-block.is-active {
  border-color: #f9a825;
  box-shadow: 0 0 0 1px rgba(249,168,37,0.35);
}
.house-room-block.is-restored {
  opacity: 0.85;
  background: rgba(200, 230, 201, 0.5);
}
.house-room-block.is-locked {
  opacity: 0.55;
}
.house-room-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}
.house-room-title { font-weight: 800; font-size: 14px; }
.house-room-status { font-size: 11px; opacity: 0.9; text-align: right; }
.house-room-bar {
  height: 6px;
  border-radius: 4px;
  background: rgba(0,0,0,0.1);
  overflow: hidden;
  margin-bottom: 6px;
}
.house-room-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #81c784, #43a047);
  border-radius: 4px;
}
.house-room-hint {
  font-size: 11px;
  opacity: 0.75;
}
.house-tasks { display: flex; flex-direction: column; gap: 6px; }
.house-task {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.55);
}
.house-task.done { opacity: 0.7; }
.house-task.locked { opacity: 0.45; }
.house-task-name { flex: 1 1 auto; min-width: 120px; }
.house-task-cost { font-weight: 700; white-space: nowrap; }
.house-task-btn {
  border: none;
  border-radius: 8px;
  padding: 4px 10px;
  font-weight: 800;
  font-size: 11px;
  background: #ffd54f;
  color: #3e2723;
  cursor: pointer;
}
.house-task-btn:active { transform: scale(0.97); }
.house-job-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  font-weight: 800;
  margin: 8px 0 4px;
  padding: 4px 2px;
  border-bottom: 1px dashed rgba(0,0,0,0.12);
}
.house-job-head.done { opacity: 0.7; }
.house-job-prog { font-weight: 600; opacity: 0.8; font-size: 11px; }

.choice-btn.choice-locked {
  opacity: 0.45;
  filter: grayscale(0.3);
  cursor: not-allowed;
}

.hotspot.portal-locked {
  opacity: 0.55;
  filter: grayscale(0.4);
  cursor: not-allowed;
}
.portal-lock-label {
  font-size: 10px;
  font-weight: 700;
  background: rgba(0,0,0,0.45);
  color: #fff;
  padding: 2px 4px;
  border-radius: 4px;
}

/* Выход с match-3 — стили перенесены в основной блок HUD */

/* ==========================================================================
   ИНДУСТРИАЛЬНЫЙ ГРАНЖ С КРОВАВЫМ АКЦЕНТОМ (OVERLAY)
   Палитра: уголь #151515 · сталь #2C2C2C · ржавчина #9E1A23 · золото #E0B24D
   ВАЖНО: игровое поле match-3 (#board, .tile, .grid-cell) НЕ затрагивается.
   ========================================================================== */

/* ---------- 0. Глобальная база ---------- */
html { background: #151515 !important; }

body {
  color: var(--ink) !important;
  background-color: #151515;
  background-image: url('images/background.webp'), linear-gradient(180deg, #202020 0%, #101010 100%);
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

/* Полоса прокрутки — ржавая сталь */
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--blood) 0%, var(--blood-dark) 100%);
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.35);
}

/* ---------- 1. Лобби-HUD (верхняя панель) ---------- */
.hud-item {
  background:
    radial-gradient(circle 2.5px at 50% 9px, #6a6a6a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    linear-gradient(180deg, #3a3a3a 0%, #2C2C2C 50%, #191919 100%) !important;
  color: var(--ink) !important;
  border: 2px solid #151515 !important;
  box-shadow:
    0 0 0 1.5px #4a4a4a,
    3px 3px 0 rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
  border-radius: 12px !important;
}

.hud-icon { filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.55)); }

.hud-val {
  font-family: var(--stencil) !important;
  font-weight: 400 !important;
  color: #f0ead8 !important;
  letter-spacing: 1px !important;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* Счётчики: звёзды/жизни/деньги */
.stars-stat .hud-val {
  color: var(--gold) !important;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55), 0 0 10px rgba(224, 178, 77, 0.3);
}
.lives-stat .hud-val { color: #ff9a9a !important; }
.cash-stat .hud-val { color: var(--gold) !important; }
.rep-stat .hud-val { color: #8ec5f0 !important; }
.stars-stat .hud-icon {
  filter: sepia(0.45) saturate(2.4) hue-rotate(-8deg)
    drop-shadow(0 1px 0 rgba(0, 0, 0, 0.55));
}

/* ---------- 2. Баннер локации ---------- */
.location-banner {
  font-family: var(--stencil) !important;
  font-weight: 400 !important;
  color: #f5efe2 !important;
  background:
    linear-gradient(90deg, transparent 0%, rgba(158, 26, 35, 0.5) 18%, rgba(158, 26, 35, 0.28) 26%, transparent 32%),
    linear-gradient(180deg, #3a3a3a 0%, #262626 55%, #161616 100%) !important;
  border: 3px solid #151515 !important;
  box-shadow:
    0 0 0 2px #4a4a4a,
    4px 4px 0 rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
  border-radius: 10px !important;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.65);
  letter-spacing: 2px !important;
}

/* ---------- 3. Кнопки меню ---------- */
.menu-btn {
  background:
    linear-gradient(180deg, #3d3d3d 0%, #2C2C2C 50%, #191919 100%) !important;
  color: var(--ink) !important;
  border: 3px solid #151515 !important;
  box-shadow:
    0 3px 0 #0d0d0d,
    4px 4px 0 rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.14) !important;
  border-radius: 12px !important;
}
.menu-btn:active {
  transform: translate(2px, 2px) !important;
  box-shadow: 0 1px 0 #0d0d0d, 2px 2px 0 rgba(0, 0, 0, 0.45) !important;
}

/* Кнопка «Играть» на карте — золотая сталь */
.menu-btn.play-btn {
  background:
    linear-gradient(105deg, transparent 0%, rgba(158, 26, 35, 0.28) 42%, transparent 50%),
    linear-gradient(180deg, #f0c45c 0%, var(--gold) 45%, #a87f28 100%) !important;
  color: #3a2a08 !important;
  border: 3px solid #151515 !important;
  box-shadow:
    0 3px 0 #0d0d0d,
    4px 4px 0 rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
}
.play-text { text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35); }

/* ---------- 3b. НАВИГАЦИЯ ГЛАВНОГО ЭКРАНА: КРУГЛЫЕ ИКОНКИ + КРАСНАЯ «ИГРАТЬ» ---------- */
/* Ряд иконок: 4 круглые кнопки-значка + большая круглая «Играть» */
#screenHideout .nav-with-play.nav-icons {
  justify-content: center;
  align-items: center;
  gap: 8px;
}

/* Круглые иконки-значки (Сюжет 📖 / Инвентарь 🎒 / Карта 🗺 / Задания 📒) */
#screenHideout .nav-with-play .menu-btn.icon-btn {
  position: relative;
  flex: 0 0 auto !important;
  width: 48px;
  height: 48px;
  min-height: 48px;
  border-radius: 50% !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  padding: 0 !important;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.18), transparent 45%),
    linear-gradient(180deg, #454545 0%, #2C2C2C 50%, #1a1a1a 100%) !important;
  border: 3px solid #151515 !important;
  box-shadow:
    0 0 0 2px #4a4a4a,
    0 0 0 3px #151515,
    0 4px 8px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
  color: var(--ink) !important;
}

/* Убираем старые цветные фоны story/hunt/tasks — теперь все иконки стальные */
#screenHideout .menu-btn.story-btn,
#screenHideout .menu-btn.hunt-btn,
#screenHideout .menu-btn.tasks-btn {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.18), transparent 45%),
    linear-gradient(180deg, #454545 0%, #2C2C2C 50%, #1a1a1a 100%) !important;
  color: var(--ink) !important;
}

/* «Играть» — большая круглая кнопка: стальное кольцо + красная середина */
#screenHideout .nav-with-play .menu-btn.play-btn {
  flex: 0 0 auto !important;
  width: 70px;
  height: 70px;
  min-height: 70px;
  border-radius: 50% !important;
  display: inline-flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 !important;
  background:
    radial-gradient(circle at 50% 14%, #ff8a80 0%, #c22b36 45%, #7a0f16 100%),
    radial-gradient(circle at 50% 86%, #ff8a80 0%, #c22b36 45%, #7a0f16 100%),
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.25), transparent 45%),
    linear-gradient(180deg, #a31d26 0%, #8a141c 50%, #5c0a10 100%) !important;
  color: #fff !important;
  border: 5px solid #454545 !important;
  box-shadow:
    0 0 0 2px #151515,
    0 0 0 5px #3d3d3d,
    0 0 0 7px #151515,
    0 6px 14px rgba(0, 0, 0, 0.55),
    inset 0 2px 6px rgba(0, 0, 0, 0.45),
    inset 0 -1px 3px rgba(255, 255, 255, 0.2) !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
#screenHideout .nav-with-play .menu-btn.play-btn:active {
  transform: scale(1.14) translateY(-4px) !important;
  z-index: 5;
  background:
    radial-gradient(circle at 50% 14%, #ffc4bb 0%, #e04450 45%, #96121a 100%),
    radial-gradient(circle at 50% 86%, #ffc4bb 0%, #e04450 45%, #96121a 100%),
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.4), transparent 50%),
    linear-gradient(180deg, #c9303c 0%, #a31d26 50%, #6b1118 100%) !important;
  box-shadow:
    0 0 0 2px #151515,
    0 0 0 5px #3d3d3d,
    0 0 0 7px #151515,
    0 0 26px rgba(194, 43, 54, 1),
    0 0 44px rgba(224, 178, 77, 0.6),
    0 9px 20px rgba(0, 0, 0, 0.65),
    inset 0 2px 6px rgba(0, 0, 0, 0.25),
    inset 0 -2px 4px rgba(255, 255, 255, 0.35) !important;
}

/* «Играть» на главном экране — только стрелка ▶ */
#screenHideout .nav-with-play .play-icon {
  font-size: 32px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  padding-left: 4px; /* оптическая центровка асимметричной стрелки */
}

/* ---------- 3c. НАЖАТИЕ: КНОПКИ ВЫПИРАЮТ ВПЕРЁД И ПОДСВЕЧИВАЮТСЯ ---------- */
#screenHideout .nav-with-play .menu-btn.icon-btn,
#screenHideout .nav-with-play .menu-btn.play-btn {
  transition: transform 0.12s cubic-bezier(0.34, 1.4, 0.64, 1),
              box-shadow 0.12s ease-out,
              background 0.12s ease-out;
  will-change: transform;
}

/* Иконки: hover — слегка приподнимаются и светятся золотом */
#screenHideout .nav-with-play .menu-btn.icon-btn:hover {
  transform: translateY(-2px) !important;
  box-shadow:
    0 0 0 2px #6a6a6a,
    0 0 0 3px #151515,
    0 0 14px rgba(224, 178, 77, 0.6),
    0 5px 12px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
}

/* Иконки: нажатие — выпирают вперёд и вспыхивают золотом */
#screenHideout .nav-with-play .menu-btn.icon-btn:active {
  transform: scale(1.18) translateY(-3px) !important;
  z-index: 5;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.4), transparent 50%),
    linear-gradient(180deg, #636363 0%, #424242 55%, #282828 100%) !important;
  box-shadow:
    0 0 0 2px #8a8a8a,
    0 0 0 3px #151515,
    0 0 20px rgba(224, 178, 77, 0.95),
    0 7px 16px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
}

/* «Играть»: hover — приподнимается и загорается красным */
#screenHideout .nav-with-play .menu-btn.play-btn:hover {
  transform: translateY(-2px) !important;
  box-shadow:
    0 0 0 2px #151515,
    0 0 0 5px #3d3d3d,
    0 0 0 7px #151515,
    0 0 18px rgba(194, 43, 54, 0.75),
    0 6px 14px rgba(0, 0, 0, 0.55),
    inset 0 2px 6px rgba(0, 0, 0, 0.4) !important;
}

/* ---------- 4. HUD матч-3 ---------- */
/* Кнопка выхода — металлическое кольцо + красная середина */
.m3-floating-exit-btn {
  background:
    radial-gradient(circle 2px at 50% 32%, #ff6a6a 0%, #c22b36 40%, #8a1010 100%) !important;
  border: 4px solid #3d3d3d !important;
  box-shadow:
    0 0 0 2px #151515,
    0 0 0 4px #5a5a5a,
    0 5px 12px rgba(0, 0, 0, 0.55),
    inset 0 2px 5px rgba(0, 0, 0, 0.45),
    inset 0 -1px 2px rgba(255, 255, 255, 0.15) !important;
  color: #fff !important;
  font-weight: 900 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Базовая плашка — чёрный металл, заклёпки по углам, кровавый мазок */
.m3-hud-base-plate {
  background:
    radial-gradient(circle 3px at 20px 14px, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at calc(100% - 20px) 14px, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at 20px calc(100% - 14px), #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at calc(100% - 20px) calc(100% - 14px), #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    linear-gradient(105deg, transparent 0 62%, rgba(158, 26, 35, 0.30) 62% 66%, rgba(158, 26, 35, 0.12) 66% 71%, transparent 71%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #3a3a3a 0%, #2C2C2C 48%, #171717 100%) !important;
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.55),
    inset 0 2px 3px rgba(255, 255, 255, 0.13),
    inset 0 -2px 4px rgba(0, 0, 0, 0.5) !important;
}

/* Средняя плашка — сталь со швом-бликом */
.m3-hud-middle-plate {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 4px, transparent 4px 9px),
    linear-gradient(180deg, #4a4a4a 0%, #3a3a3a 45%, #2C2C2C 100%) !important;
  box-shadow:
    0 0 0 2px #1a1a1a,
    0 0 0 4px rgba(255, 255, 255, 0.10),
    0 0 0 5px #151515,
    inset 0 1px 2px rgba(255, 255, 255, 0.16),
    inset 0 -2px 4px rgba(0, 0, 0, 0.4) !important;
}

/* Лунки целей — вдавленный уголь с кровавой кромкой */
.m3-hud-goal-well {
  background-color: #141414 !important;
  box-shadow:
    inset 0 3px 7px rgba(0, 0, 0, 0.75),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06),
    inset 0 0 0 2px rgba(158, 26, 35, 0.4),
    0 0 0 1px #4a4a4a !important;
}

.m3-hud-goal-badge {
  color: #f5efe2 !important;
  text-shadow:
    -1.5px -1.5px 0 #151515,
     1.5px -1.5px 0 #151515,
    -1.5px  1.5px 0 #151515,
     1.5px  1.5px 0 #151515,
     0 2px 3px rgba(0, 0, 0, 0.6) !important;
}

/* Ходы */
.m3-moves-arrows-stack { color: #cfc8bb !important; }
.m3-moves-count {
  color: #f5efe2 !important;
  font-weight: 800 !important;
  text-shadow: 0 2px 0 #0d0d0d, 0 3px 5px rgba(0, 0, 0, 0.6);
}
.m3-hud-moves-block.moves-low .m3-moves-count { color: #ff6a6a !important; }

/* Блок уровня */
.m3-hud-level-label {
  font-family: 'Rubik', sans-serif !important;
  font-weight: 800 !important;
  color: var(--gold) !important;
  letter-spacing: 3px !important;
}
.m3-hud-level-num {
  font-family: var(--stencil) !important;
  font-weight: 400 !important;
  color: #f5efe2 !important;
  text-shadow: 0 2px 0 #0d0d0d, 0 3px 6px rgba(0, 0, 0, 0.55);
}

/* ---------- 5. Панель бустеров ---------- */
.booster-panel {
  background:
    radial-gradient(circle 2.5px at 16px 50%, #6a6a6a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 2.5px at calc(100% - 16px) 50%, #6a6a6a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    linear-gradient(105deg, transparent 0 55%, rgba(158, 26, 35, 0.18) 55% 62%, transparent 62%),
    linear-gradient(180deg, rgba(45, 45, 45, 0.97) 0%, rgba(28, 28, 28, 0.98) 60%, rgba(15, 15, 15, 0.98) 100%) !important;
  border: 2px solid #3a3a3a !important;
  border-radius: 18px !important;
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.5),
    0 3px 8px rgba(0, 0, 0, 0.4),
    0 0 0 2px #151515,
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -2px 6px rgba(0, 0, 0, 0.55) !important;
}

/* Плашка супербустеров опущена ниже на 20% своей высоты (--booster-drop) */
.booster-panel {
  --booster-drop: 20%;
  transform: translateY(var(--booster-drop));
}

/* Кнопка бустера: толстое металлическое кольцо + красная вдавленная середина + заклёпки */
.booster-btn {
  background:
    radial-gradient(circle 2.5px at 50% 8px, #9a9a9a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 2.5px at 50% calc(100% - 8px), #9a9a9a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 2.5px at 8px 50%, #9a9a9a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 2.5px at calc(100% - 8px) 50%, #9a9a9a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle at 50% 40%, #ff4653 0%, #c22b36 30%, #9E1A23 58%, #6b1118 82%, #43080d 100%) !important;
  border: 4px solid #3d3d3d !important;
  box-shadow:
    0 0 0 2px #151515,
    0 0 0 4px #5a5a5a,
    0 6px 14px rgba(0, 0, 0, 0.55),
    inset 0 3px 6px rgba(0, 0, 0, 0.5),
    inset 0 -2px 4px rgba(255, 255, 255, 0.14) !important;
}

/* Иконки инструментов — поднять над красной серединой */
#btnHammer::before,
#btnGlove::before,
#btnBroom::before,
#btnWeight::before,
#btnFan::before {
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.65)) brightness(1.12);
}

/* Счётчик бустеров — ржавый шарик */
.booster-btn .b-count {
  background: radial-gradient(circle at 38% 28%, #ffd0d0 0%, #ff6a6a 25%, #d03030 55%, #8a1010 85%) !important;
  border: 2.5px solid #ece5d8 !important;
  box-shadow:
    0 2px 6px rgba(120, 10, 20, 0.5),
    inset 0 1px 2px rgba(255, 230, 230, 0.7),
    inset 0 -1px 2px rgba(60, 0, 8, 0.35);
}

/* Ценник — золотая плашка */
.booster-btn .cost {
  background: linear-gradient(180deg, #f0c45c, #E0B24D 55%, #a87f28) !important;
  color: #3a2a08 !important;
  border: 1.5px solid #151515 !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* ---------- 6. Карточки и оверлеи (ui-card) ---------- */
.ui-card {
  background:
    radial-gradient(circle 3px at 16px 14px, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at calc(100% - 16px) 14px, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at 16px calc(100% - 14px), #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at calc(100% - 16px) calc(100% - 14px), #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    linear-gradient(105deg, transparent 0 70%, rgba(158, 26, 35, 0.14) 70% 74%, transparent 74%),
    linear-gradient(180deg, #343434 0%, #262626 50%, #171717 100%) !important;
  color: var(--ink) !important;
  border: 3px solid #151515 !important;
  box-shadow:
    0 0 0 2px #4a4a4a,
    8px 8px 0 rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.10) !important;
  border-radius: 16px !important;
}

/* Заголовки карточек — трафаретный красный с обводкой */
.ui-card h2,
.decor-card h3,
.speaker-name {
  font-family: var(--stencil) !important;
  font-weight: 400 !important;
  color: var(--blood-bright) !important;
  -webkit-text-stroke: 1.5px #151515 !important;
  text-shadow: 0 2px 0 #43080d, 0 3px 6px rgba(0, 0, 0, 0.6);
  letter-spacing: 1px !important;
  text-transform: uppercase;
}

/* Кнопки действий */
.action-btn {
  background:
    linear-gradient(180deg, #3d3d3d 0%, #2C2C2C 50%, #191919 100%) !important;
  color: var(--ink) !important;
  border: 3px solid #151515 !important;
  border-radius: 10px !important;
  box-shadow:
    0 4px 0 #0d0d0d,
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    4px 4px 0 rgba(0, 0, 0, 0.5) !important;
}
.action-btn:active {
  transform: translate(2px, 2px) !important;
  box-shadow: 0 1px 0 #0d0d0d, 2px 2px 0 rgba(0, 0, 0, 0.5) !important;
}
.start-btn,
.next-btn {
  background:
    linear-gradient(180deg, #c22b36 0%, #9E1A23 50%, #6b1118 100%) !important;
  color: #fff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.cancel-btn {
  background: linear-gradient(180deg, #4a4a4a 0%, #2C2C2C 55%, #1a1a1a) !important;
  color: #cfc9bd !important;
}

/* ---------- 7. Окно диалогов ---------- */
.dialogue-window {
  background:
    radial-gradient(circle 3px at 14px 14px, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at calc(100% - 14px) 14px, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at 14px calc(100% - 14px), #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at calc(100% - 14px) calc(100% - 14px), #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    linear-gradient(105deg, transparent 0 62%, rgba(158, 26, 35, 0.18) 62% 67%, transparent 67%),
    linear-gradient(180deg, #343434 0%, #262626 50%, #171717 100%) !important;
  color: var(--ink) !important;
  border: 3px solid #151515 !important;
  box-shadow:
    0 0 0 2px #4a4a4a,
    6px 6px 0 rgba(0, 0, 0, 0.55),
    0 12px 28px rgba(0, 0, 0, 0.6) !important;
}

.dialogue-text { color: #e6dfd2 !important; }

.choice-btn {
  background: linear-gradient(180deg, #3d3d3d 0%, #2C2C2C 55%, #191919) !important;
  color: var(--ink) !important;
  border: 2px solid #151515 !important;
  box-shadow:
    3px 3px 0 rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
}
.choice-btn.premium {
  border-color: var(--gold) !important;
  box-shadow: 0 0 8px rgba(224, 178, 77, 0.55), 3px 3px 0 rgba(0, 0, 0, 0.5) !important;
}

/* ---------- 8. Пре-уровневый экран ---------- */
/* Плита-подложка прозрачная: только сам планшет на фоне комнаты */
.pre-stage {
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* Переопределяем палитру планшета для ВСЕХ сложностей */
.pre-level-card,
.pre-level-card.diff-normal,
.pre-level-card.diff-medium,
.pre-level-card.diff-hard,
.pre-level-card.diff-superhard,
.pre-level-card.diff-extreme,
.pre-level-card.diff-challenge {
  --pre-ink: #ece5d8;
  --pre-ink-soft: #c9c2b4;
  --pre-header: #9E1A23;
  --pre-header-text: #f5efe2;
  --pre-plate: #2C2C2C;
  --pre-plate-deep: #1c1c1c;
  --pre-stitch: rgba(140, 140, 140, 0.30);
  --pre-title: #c22b36;
  --pre-booster-title: #E0B24D;
  --pre-well-bg: #151515;
  /* Стальная плита: заклёпки по углам + кровавый мазок + щётка стали */
  background:
    radial-gradient(circle 3px at 18px 18px, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at calc(100% - 18px) 18px, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at 18px calc(100% - 18px), #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at calc(100% - 18px) calc(100% - 18px), #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    linear-gradient(100deg, transparent 0 64%, rgba(158, 26, 35, 0.20) 64% 69%, rgba(158, 26, 35, 0.08) 69% 74%, transparent 74%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #343434 0%, #262626 45%, #171717 100%) !important;
  box-shadow:
    0 0 0 3px #4a4a4a,
    0 24px 48px rgba(0, 0, 0, 0.6),
    inset 0 2px 0 rgba(255, 255, 255, 0.12) !important;
}

/* Внутренняя окантовка — металлическая кромка с заклёпками */
.pre-level-card::before {
  inset: 8px !important;
  border: 2px solid rgba(140, 140, 140, 0.28) !important;
  border-radius: 20px !important;
  background:
    radial-gradient(circle 2.5px at 12px 12px, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 2.5px at calc(100% - 12px) 12px, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 2.5px at 12px calc(100% - 12px), #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 2.5px at calc(100% - 12px) calc(100% - 12px), #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px);
}

/* Шапка — сталь с кровавой нижней кромкой */
.pre-level-card .pre-level-header {
  background:
    radial-gradient(circle 3px at 20px 50%, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at calc(100% - 20px) 50%, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    linear-gradient(180deg, #3d3d3d 0%, #2C2C2C 55%, #1a1a1a 100%) !important;
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    inset 0 -4px 0 rgba(158, 26, 35, 0.65) !important;
}

/* Заголовок уровня — трафаретный красный с обводкой */
.pre-level-card h2 {
  font-family: var(--stencil) !important;
  font-size: 24px !important;
  font-weight: 400 !important;
  color: var(--blood-bright) !important;
  -webkit-text-stroke: 1.5px #151515 !important;
  text-shadow: 0 2px 0 #43080d, 0 3px 6px rgba(0, 0, 0, 0.55) !important;
  letter-spacing: 1.5px !important;
  text-transform: uppercase;
}
.diff-badge {
  color: var(--gold) !important;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

/* Кнопка закрытия — металлическое кольцо + красная середина */
.pre-close-btn {
  background:
    radial-gradient(circle at 50% 40%, #ff4653 0%, #c22b36 40%, #8a1010 100%) !important;
  border: 3px solid #3d3d3d !important;
  box-shadow:
    0 0 0 1.5px #151515,
    0 0 0 3px #5a5a5a,
    0 4px 10px rgba(0, 0, 0, 0.5),
    inset 0 2px 4px rgba(0, 0, 0, 0.4),
    inset 0 -1px 2px rgba(255, 255, 255, 0.18) !important;
}

/* Лунка целей — уголь с кровавой кромкой */
.pre-goal-well {
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.65),
    inset 0 0 0 2px rgba(158, 26, 35, 0.4),
    0 0 0 1px #4a4a4a !important;
}
.pre-goal-icon { filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.45)); }
.pre-goal-num,
.pre-moves-num {
  color: #f0ead8 !important;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.55) !important;
}

/* Подпись бустеров */
.pre-booster-title {
  font-family: var(--stencil) !important;
  font-weight: 400 !important;
  color: var(--gold) !important;
  letter-spacing: 1.5px !important;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* Сферы бустеров — тёмный металл */
.pre-booster-btn .b-orb {
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.08) 18%, transparent 42%),
    radial-gradient(circle at 50% 40%, #4a4a4a 0%, #2C2C2C 55%, #151515 100%);
  box-shadow:
    inset 0 -6px 12px rgba(0, 0, 0, 0.6),
    inset 0 2px 4px rgba(255, 255, 255, 0.2),
    0 0 0 2px #151515,
    0 0 0 3px #4a4a4a,
    0 8px 16px rgba(0, 0, 0, 0.5);
}
.pre-booster-btn .b-orb::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent);
}
.pre-booster-btn .b-icon {
  filter:
    drop-shadow(0 3px 5px rgba(0, 0, 0, 0.5))
    drop-shadow(0 1px 0 rgba(255, 255, 255, 0.25));
}
.pre-booster-btn.selected .b-orb {
  box-shadow:
    inset 0 -6px 12px rgba(0, 0, 0, 0.5),
    inset 0 2px 4px rgba(255, 255, 255, 0.2),
    0 0 0 3px rgba(224, 178, 77, 0.9),
    0 0 16px rgba(224, 178, 77, 0.45),
    0 8px 16px rgba(0, 0, 0, 0.45);
}
.pre-booster-btn .b-tag {
  background: linear-gradient(180deg, #ff5a5a 0%, #c22b36 55%, #8a1010 100%) !important;
  color: #fff !important;
  border: 2px solid #ece5d8 !important;
}

/* Полка наград — тёмная сталь с золотой кромкой */
.reward-shelf {
  background:
    radial-gradient(ellipse at 50% 40%, rgba(224, 178, 77, 0.16) 0%, transparent 60%),
    linear-gradient(180deg, #2e2e2e 0%, #1d1d1d 100%) !important;
  box-shadow:
    0 0 0 2px #4a4a4a,
    inset 0 2px 0 rgba(255, 255, 255, 0.10),
    inset 0 -2px 0 rgba(158, 26, 35, 0.35) !important;
}

/* Пилюли наград — стальные плашки */
.reward-pill {
  background: linear-gradient(180deg, #3d3d3d 0%, #2C2C2C 50%, #191919) !important;
  color: #f0ead8 !important;
  border: 2px solid #151515 !important;
  box-shadow: 0 0 0 1px #4a4a4a, 0 3px 6px rgba(0, 0, 0, 0.4) !important;
}
.reward-pill .rp-icon { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5)); }
.rp-icon.rp-star {
  filter: sepia(0.5) saturate(2.5) hue-rotate(-8deg)
    drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}

/* Кнопка «Играть» — стальной кожух с красной краской */
.pre-level-card .pre-play-btn,
.pre-level-card .start-btn {
  background:
    radial-gradient(circle 3px at 20px 50%, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 3px at calc(100% - 20px) 50%, #8a8a8a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    linear-gradient(180deg, #c22b36 0%, #9E1A23 45%, #6b1118 100%) !important;
  border: 4px solid #3d3d3d !important;
  border-radius: 16px !important;
  box-shadow:
    0 0 0 2px #151515,
    0 0 0 4px #5a5a5a,
    0 5px 10px rgba(0, 0, 0, 0.5),
    inset 0 3px 6px rgba(0, 0, 0, 0.45),
    inset 0 -2px 4px rgba(255, 255, 255, 0.15) !important;
  color: #fff !important;
  font-family: var(--stencil) !important;
  font-weight: 400 !important;
  letter-spacing: 2px !important;
  text-transform: uppercase !important;
  -webkit-text-stroke: 1px #4a0a10 !important;
  text-shadow: 0 2px 0 #43080d, 0 3px 6px rgba(0, 0, 0, 0.5);
}
.pre-level-card .pre-play-btn::before,
.pre-level-card .start-btn::before {
  left: 6%;
  right: 6%;
  top: 2px;
  height: 42%;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.20), transparent);
}
.pre-level-card .pre-play-label {
  color: #fff;
  text-shadow:
    -1px -1px 0 #4a0a10,
     1px -1px 0 #4a0a10,
    -1px  1px 0 #4a0a10,
     1px  1px 0 #4a0a10,
     0  2px 0 #43080d,
     1px 3px 3px rgba(0, 0, 0, 0.45);
}
.pre-level-card .pre-play-btn:active,
.pre-level-card .start-btn:active {
  transform: translateY(3px) !important;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.4),
    0 0 0 2px #151515,
    0 0 0 4px #5a5a5a,
    inset 0 3px 6px rgba(0, 0, 0, 0.5) !important;
}

/* ---------- 9. Карта (путь) и пиратская карта ---------- */
/* Узлы пути — стальные плашки */
.map-node {
  background:
    radial-gradient(circle 2.5px at 14px 50%, #6a6a6a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    radial-gradient(circle 2.5px at calc(100% - 14px) 50%, #6a6a6a 0 1px, #0d0d0d 1.5px 2.5px, transparent 3px),
    linear-gradient(180deg, #3a3a3a 0%, #2C2C2C 50%, #1a1a1a 100%) !important;
  color: var(--ink) !important;
  border: 3px solid #151515 !important;
  box-shadow:
    0 0 0 1.5px #4a4a4a,
    4px 4px 0 rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.10) !important;
}
.map-node.active {
  background:
    linear-gradient(105deg, transparent 0 55%, rgba(255, 255, 255, 0.10) 55% 62%, transparent 62%),
    linear-gradient(180deg, #c22b36 0%, #9E1A23 50%, #6b1118 100%) !important;
  color: #fff !important;
  box-shadow:
    0 0 0 1.5px #c22b36,
    0 0 16px rgba(158, 26, 35, 0.5),
    4px 4px 0 rgba(0, 0, 0, 0.45) !important;
}
.map-node.locked {
  background: #1c1c1c !important;
  color: #777 !important;
  border-color: #0d0d0d !important;
  box-shadow: none !important;
}
.map-node.node-checkpoint {
  background:
    linear-gradient(180deg, #f0c45c 0%, #E0B24D 45%, #a87f28 100%) !important;
  color: #3a2a08 !important;
  border-style: dashed !important;
}
.map-node.node-checkpoint.locked {
  background: #1c1c1c !important;
  color: #777 !important;
  border-style: solid !important;
}
.camp-path::before { background: #4a4a4a !important; }

/* Окно пиратской карты — стальная рама */
.pirate-map-viewport {
  border: 3px solid #151515 !important;
  box-shadow: 0 0 0 2px #4a4a4a, 8px 8px 0 rgba(0, 0, 0, 0.45) !important;
  background: #1a1a1a !important;
}
/* Поверхность — графит с кровавыми пятнами */
.pirate-map-surface {
  background:
    radial-gradient(ellipse at 18% 22%, rgba(158, 26, 35, 0.22), transparent 45%),
    radial-gradient(ellipse at 82% 74%, rgba(158, 26, 35, 0.14), transparent 42%),
    radial-gradient(ellipse at 60% 30%, rgba(224, 178, 77, 0.07), transparent 40%),
    linear-gradient(145deg, #2e2e2e 0%, #242424 45%, #161616 100%) !important;
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.7) !important;
}
.pirate-map-surface::before {
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(158, 26, 35, 0.06) 3px, rgba(158, 26, 35, 0.06) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(255, 255, 255, 0.04) 3px, rgba(255, 255, 255, 0.04) 4px) !important;
  opacity: 0.5 !important;
}
.pirate-map-paths .path-open {
  stroke: #c22b36 !important;
  opacity: 0.8 !important;
}
.pirate-map-paths .path-fog {
  stroke: #5a5a5a !important;
  opacity: 0.35 !important;
}
/* Штамп карты — трафаретная красная печать */
.pirate-map-title-stamp {
  font-family: var(--stencil) !important;
  font-weight: 400 !important;
  color: rgba(224, 178, 77, 0.55) !important;
  border: 3px solid rgba(224, 178, 77, 0.4) !important;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
  text-transform: uppercase;
}
.pirate-map-title-stamp small { color: rgba(236, 229, 216, 0.5) !important; }
.pirate-map-legend {
  background: linear-gradient(180deg, #343434 0%, #222 100%) !important;
  color: var(--ink) !important;
  border: 2px solid #151515 !important;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5) !important;
}
/* Булавки — стальные диски */
.pirate-pin .pin-dot {
  background: linear-gradient(180deg, #4a4a4a 0%, #2C2C2C 55%, #151515 100%) !important;
  border: 2.5px solid #0d0d0d !important;
  box-shadow:
    0 0 0 1.5px #5a5a5a,
    2px 2px 0 rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.18) !important;
}
.pirate-pin .pin-label {
  background: rgba(20, 20, 20, 0.92) !important;
  color: #ece5d8 !important;
  border-color: #0d0d0d !important;
}
.pirate-pin.is-here .pin-dot {
  background: linear-gradient(180deg, #f0c45c 0%, #E0B24D 50%, #a87f28 100%) !important;
  box-shadow: 0 0 0 4px rgba(224, 178, 77, 0.35), 0 0 14px rgba(224, 178, 77, 0.45), 2px 2px 0 #1a1008 !important;
}
.pirate-pin.is-locked .pin-dot {
  background: #1c1c1c !important;
  box-shadow: 0 0 0 1.5px #3a3a3a !important;
}
.pirate-pin.is-unknown .pin-dot {
  background: #2e2e2e !important;
  color: #ddd !important;
}
.pirate-pin.is-danger .pin-dot {
  border-color: #c22b36 !important;
  box-shadow: 0 0 10px rgba(158, 26, 35, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.18) !important;
}
.pirate-pin.can-hunt.is-open .pin-dot {
  outline: 2px dashed rgba(255, 159, 67, 0.85) !important;
}
.pirate-zone-stamp .zs-name {
  color: #cfc8bb !important;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}
.pirate-map-compass {
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.6)) sepia(0.3);
}
.map-hint-mini { color: #b8b1a4 !important; }
.pirate-map-banner { color: var(--ink) !important; }

/* ---------- 10. Убежище, инвентарь, декор, дом ---------- */
#screenHideout .inventory-panel {
  background: rgba(15, 15, 15, 0.9) !important;
  border: 2px solid #3a3a3a !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5) !important;
}
.inventory-item {
  background: #2C2C2C !important;
  color: #ece5d8 !important;
  border-color: #151515 !important;
  box-shadow: 0 0 0 1px #4a4a4a;
}
.inv-title { color: var(--gold) !important; }

.decor-card {
  background: rgba(15, 15, 15, 0.88) !important;
  border-color: #3a3a3a !important;
  box-shadow: 0 0 0 2px #151515, 5px 5px 0 rgba(0, 0, 0, 0.5) !important;
}
.decor-list li {
  background: rgba(0, 0, 0, 0.5);
  border-color: rgba(236, 229, 216, 0.14);
}
.decor-val { color: var(--gold) !important; }

.upgrade-option-card {
  background: #2C2C2C !important;
  border-color: #151515 !important;
  color: #ece5d8 !important;
  box-shadow: 0 0 0 1px #4a4a4a, 3px 3px 0 rgba(0, 0, 0, 0.4) !important;
}
.upgrade-option-card:hover { background: #3a3a3a !important; }
.upgrade-option-card.active-decor {
  border-color: var(--gold) !important;
  background: rgba(224, 178, 77, 0.14) !important;
}

.task-item {
  background: rgba(30, 30, 30, 0.85) !important;
  border-color: #3a3a3a !important;
}
.task-title { color: #ece5d8 !important; }

.house-room-block {
  background: rgba(20, 20, 20, 0.85) !important;
  border-color: rgba(236, 229, 216, 0.12) !important;
}
.house-room-block.is-active {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 1px rgba(224, 178, 77, 0.4) !important;
}
.house-room-block.is-restored {
  background: rgba(60, 90, 50, 0.4) !important;
}
.house-tablet-summary { color: #ece5d8 !important; }
.house-tablet-lead { color: #cfc8bb !important; }
.house-task-cost {
  color: var(--gold) !important;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.6));
}
.house-job-head { border-bottom-color: rgba(236, 229, 216, 0.18); }

/* ---------- 11. Звёзды — объёмный грязно-жёлтый металл ---------- */
.results-stars,
.house-tablet-stars,
.victory-star,
.pre-dangler-star,
.pre-dangler-stars {
  filter:
    sepia(0.5) saturate(2.5) hue-rotate(-8deg) brightness(0.98) contrast(1.05)
    drop-shadow(0 2px 1px rgba(0, 0, 0, 0.7))
    drop-shadow(0 5px 4px rgba(0, 0, 0, 0.4)) !important;
  text-shadow: 0 -1px 0 rgba(70, 45, 0, 0.9), 0 1px 0 rgba(70, 45, 0, 0.7);
}
.results-stars {
  font-size: 32px !important;
  letter-spacing: 5px !important;
}
.results-total { color: var(--gold) !important; }
.results-line { color: #e6dfd2; }

/* ---------- 12. Мелкие фиксы ---------- */
/* Оверлей без ходов — тёмная сталь */
.out-of-moves-card .oom-lead { color: var(--ink) !important; }
.out-of-moves-card .oom-buy {
  background: linear-gradient(180deg, #f0c45c 0%, #E0B24D 50%, #a87f28 100%) !important;
  color: #3a2a08 !important;
  border: 3px solid #151515 !important;
  box-shadow: 0 4px 0 #0d0d0d, inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
}
.out-of-moves-card .oom-hint { color: #b8b1a4 !important; }

/* Story-карточка (синяя рамка из inline-стиля остаётся) */
#overlayStory .ui-card { border-color: #2f6fb0 !important; }

/* Навигационные кнопки лобби */
.story-btn { color: #fff !important; }
.hunt-btn { color: #fff !important; }
.tasks-btn { color: #3a2a08 !important; }

/* Бейдж-звёздочка на хотспотах */
.decor-badge {
  background: #151515 !important;
  color: var(--gold) !important;
}

/* Пузырь события пре-уровня — тёмная сталь */
.pre-event-bubble {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.15), transparent 45%),
    linear-gradient(165deg, #3a3a3a 0%, #262626 55%, #151515 100%) !important;
  border: 2px solid #4a4a4a !important;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.5),
    inset 0 2px 4px rgba(255, 255, 255, 0.12) !important;
}
.pre-event-meta { color: #e0c88a !important; }
.pre-event-rope {
  background: linear-gradient(180deg, transparent, #7a6a55 30%, #5c4a38 100%) !important;
}

/* === HUD responsive (viewport fit only, no board redesign) === */
/* Только верхняя плашка: отступы/типографика на узких экранах.
   Поле, фишки, бустеры, фон — без изменений. */
@media (max-width: 420px) {
  .match3-header-container {
    width: min(calc(100vw - 20px), 100%) !important;
    max-width: 100% !important;
    margin: 0 auto 28px auto !important; /* 25–35px до поля, X+плашка вместе */
    gap: 6px !important;
    align-items: center !important;
  }
  .match3-header-container.multi-goal {
    width: min(calc(100vw - 16px), 100%) !important;
  }
  .m3-floating-exit-btn {
    width: 40px !important;
    height: 40px !important;
    flex: 0 0 40px !important;
    flex-shrink: 0 !important;
    align-self: center !important;
    margin: 0 !important;
    position: relative !important;
  }
  .m3-hud-base-plate {
    height: 80px !important; /* не раздуваем */
    padding: 6px 10px !important;
    margin-left: 0 !important;
    border-radius: 16px !important;
  }
  .m3-hud-middle-plate {
    height: 60px !important;
    padding: 4px 8px !important;
    margin-right: 6px !important;
    gap: 4px !important;
  }
  .m3-hud-goal-well {
    height: 44px !important;
    min-width: 48px !important;
    padding: 0 6px !important;
    margin-right: 6px !important;
  }
  .m3-hud-goal-icon { font-size: 26px !important; }
  .m3-hud-goal-badge { font-size: 14px !important; }
  .m3-moves-count { font-size: 22px !important; }
  .m3-hud-level-block {
    min-width: 52px !important;
    max-width: 28% !important;
    padding: 0 6px !important;
  }
  .m3-hud-level-num { font-size: 18px !important; }
  .m3-hud-level-label {
    font-size: 8px !important;
    letter-spacing: 1.5px !important;
  }
}

@media (max-width: 340px) {
  .match3-header-container {
    width: min(calc(100vw - 12px), 100%) !important;
    margin: 0 auto 26px auto !important; /* ~25–30px до поля */
  }
  .m3-hud-base-plate {
    height: 72px !important;
    padding: 4px 8px !important;
    margin-left: 0 !important;
  }
  .m3-hud-middle-plate {
    height: 54px !important;
    padding: 3px 6px !important;
  }
  .m3-hud-goal-well {
    height: 40px !important;
    min-width: 44px !important;
  }
  .m3-hud-level-block {
    min-width: 48px !important;
    padding: 0 4px !important;
  }
  .m3-hud-level-num { font-size: 16px !important; }
  .m3-moves-count { font-size: 18px !important; }
}

/* ==========================================================================
   СЮЖЕТ «БЕЗ ПАМЯТИ» v2: сцены на локациях
   1) человек в локации (хотспот npc) — тап запускает разговор;
   2) указатель, куда идти, если история ждёт в другом месте;
   3) крестик в окне диалога — уйти и вернуться позже.
   ========================================================================== */
.hotspot.type-npc {
  border: none;
  background: none;
  box-shadow: none;
}

.hotspot.type-npc::before {
  content: "🧍";
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 224, 150, 0.9);
  background: rgba(13, 11, 15, 0.55);
  box-shadow: 0 0 12px rgba(255, 200, 90, 0.4);
  animation: npcBreath 3.2s infinite ease-in-out;
}

.hotspot.type-npc:hover::before {
  border-color: #ffe6a8;
  background: rgba(45, 32, 12, 0.75);
}

.hotspot.type-npc .hotspot-label {
  top: calc(50% + 22px);
  bottom: auto;
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 226, 154, 0.6);
  background: rgba(13, 11, 15, 0.82);
  color: #ffe6a8;
  font-size: 11px;
}

@keyframes npcBreath {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 200, 90, 0.26); }
  50% { box-shadow: 0 0 18px rgba(255, 214, 120, 0.5); }
}

.story-goal-chip {
  position: relative;
  z-index: 30;
  align-self: center;
  margin: 0 auto 6px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 800;
  color: #2a1a08;
  background: linear-gradient(180deg, #f3d27c, #d9a63c);
  border: 2px solid #2a1a08;
  border-radius: 999px;
  box-shadow: 2px 2px 0 #2a1a08;
  cursor: pointer;
}

.story-goal-chip:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #2a1a08;
}

.dialogue-close-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.dialogue-close-btn:hover {
  background: var(--blood);
  color: var(--paper);
}

#dialogueBox .speaker-name {
  padding-right: 30px;
}

/* ==========================================================================
   ГЛАВНОЕ МЕНЮ (ЭКРАН ПРЕВЬЮ ИГРЫ)
   ========================================================================== */
body.in-menu {
  padding: 0 !important;
  background: #0b0909;
}

body.in-menu .global-hud {
  display: none !important;
}

.menu-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  scrollbar-width: none;
}

.menu-screen::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.menu-bg {
  position: absolute;
  inset: 0;
  background: url('images/bg_wastelands_night.webp') center / cover no-repeat;
  filter: saturate(0.85) brightness(0.62) contrast(1.05);
}

.menu-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 85% at 50% 18%, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.35) 55%, rgba(5, 4, 4, 0.88) 100%),
    linear-gradient(180deg, rgba(6, 5, 5, 0.55) 0%, rgba(6, 5, 5, 0.08) 35%, rgba(6, 5, 5, 0.92) 100%);
}

.menu-inner {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 460px;
  min-height: 100%;
  height: auto;
  display: flex;
  flex-direction: column;
  padding: calc(14px + env(safe-area-inset-top)) 18px calc(14px + env(safe-area-inset-bottom));
}

.menu-topline {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 20px;
}

.menu-build {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(236, 229, 216, 0.55);
}

.menu-logo {
  margin-top: clamp(26px, 7vh, 64px);
  text-align: center;
  animation: menuRise 0.5s ease-out both;
}

.menu-kicker {
  display: block;
  font-family: var(--stencil);
  font-size: 11px;
  letter-spacing: 0.32em;
  color: var(--gold);
  text-transform: uppercase;
  opacity: 0.92;
}

.menu-title {
  margin: 6px 0 4px;
  font-family: 'Bangers', cursive;
  font-size: clamp(46px, 14vw, 66px);
  line-height: 0.94;
  letter-spacing: 0.045em;
  color: var(--ink);
  text-shadow:
    0 3px 0 #1a0f0f,
    0 6px 18px rgba(0, 0, 0, 0.75),
    0 0 26px rgba(158, 26, 35, 0.35);
}

.menu-tagline {
  margin: 10px auto 0;
  max-width: 330px;
  font-size: 12.5px;
  line-height: 1.45;
  font-weight: 600;
  color: rgba(236, 229, 216, 0.78);
}

.menu-tags {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.menu-tags span {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(236, 229, 216, 0.8);
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(236, 229, 216, 0.22);
  background: rgba(13, 11, 15, 0.5);
}

.menu-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: auto;
  padding-top: 18px;
  animation: menuRise 0.55s 0.08s ease-out both;
}

.menu-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 7px;
  border-radius: 12px;
  border: 2px solid rgba(236, 229, 216, 0.16);
  background: linear-gradient(180deg, rgba(32, 28, 26, 0.88), rgba(16, 13, 12, 0.9));
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

.menu-stat-ico {
  font-size: 13px;
  line-height: 1;
}

.menu-stat-val {
  font-family: 'Bangers', cursive;
  font-size: 18px;
  line-height: 1;
  color: var(--gold);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.menu-stat-cap {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(236, 229, 216, 0.5);
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 12px;
  animation: menuRise 0.6s 0.16s ease-out both;
}

.menu-play-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  border: 3px solid #1a0f0f;
  border-radius: 14px;
  background: linear-gradient(180deg, #c22b36 0%, #9E1A23 55%, #6b1118 100%);
  box-shadow:
    0 4px 0 #1a0f0f,
    0 10px 26px rgba(158, 26, 35, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  color: #fff3e6;
  cursor: pointer;
  text-align: left;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}

.menu-play-btn:hover {
  filter: brightness(1.06);
}

.menu-play-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #1a0f0f, 0 4px 14px rgba(158, 26, 35, 0.3);
}

.menu-play-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.22);
  border: 2px solid rgba(255, 243, 230, 0.35);
  font-size: 17px;
}

.menu-play-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.menu-play-label {
  font-family: 'Bangers', cursive;
  font-size: 25px;
  line-height: 1;
  letter-spacing: 0.05em;
}

.menu-play-sub {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 243, 230, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-secondary-btn {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid rgba(236, 229, 216, 0.22);
  background: rgba(13, 11, 15, 0.55);
  color: rgba(236, 229, 216, 0.88);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.menu-secondary-btn:hover {
  background: rgba(30, 25, 22, 0.8);
  border-color: rgba(224, 178, 77, 0.5);
}

.menu-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(236, 229, 216, 0.38);
}

@keyframes menuRise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Настройки */
.menu-settings-card {
  max-width: 380px;
  width: calc(100% - 32px);
}

.menu-set-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(236, 229, 216, 0.12);
}

.menu-set-row:last-of-type {
  border-bottom: none;
}

.menu-set-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-set-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.menu-set-hint {
  font-size: 10.5px;
  line-height: 1.3;
  color: rgba(236, 229, 216, 0.55);
}

.menu-switch {
  flex: 0 0 auto;
  min-width: 74px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 2px solid rgba(236, 229, 216, 0.2);
  background: rgba(0, 0, 0, 0.35);
  color: rgba(236, 229, 216, 0.7);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}

.menu-switch[aria-pressed="true"] {
  border-color: rgba(122, 154, 63, 0.7);
  background: rgba(122, 154, 63, 0.22);
  color: #cfe3a3;
}

.menu-reset-btn {
  flex: 0 0 auto;
  padding: 7px 11px;
  border-radius: 9px;
  border: 2px solid rgba(158, 26, 35, 0.7);
  background: rgba(158, 26, 35, 0.16);
  color: #f0b9b9;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.menu-reset-btn.armed {
  background: linear-gradient(180deg, #c22b36, #9E1A23);
  color: #fff3e6;
  border-color: #1a0f0f;
}

.menu-build-line {
  margin: 12px 0 10px;
  text-align: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(236, 229, 216, 0.4);
}

/* ==========================================================================
   ОБУЧЕНИЕ ПЕРЕД ПЕРВОЙ ГЛАВОЙ
   ========================================================================== */
.intro-overlay {
  z-index: 120;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(158, 26, 35, 0.26), rgba(8, 6, 6, 0.95) 68%),
    rgba(8, 6, 6, 0.9);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
}

.intro-card {
  position: relative;
  max-width: 360px;
  width: 100%;
  max-height: 100%;
  padding: 26px 20px 16px;
  overflow-y: auto;
  text-align: center;
  animation: menuRise 0.32s ease-out both;
}

.intro-counter {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: rgba(236, 229, 216, 0.38);
}

.intro-icon {
  display: block;
  margin: 0 auto 10px;
  font-size: 38px;
  line-height: 1;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
}

.intro-card h2 {
  margin-bottom: 10px;
  font-size: 22px;
}

.intro-text {
  margin: 0 auto 16px;
  max-width: 302px;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 600;
  color: rgba(236, 229, 216, 0.82);
}

.intro-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
}

.intro-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(236, 229, 216, 0.22);
  transition: background 0.2s ease, transform 0.2s ease;
}

.intro-dot.active {
  background: var(--gold);
  transform: scale(1.15);
}

.intro-next {
  width: 100%;
  padding: 11px 16px;
  font-size: 18px;
}

.intro-skip {
  width: 100%;
  margin-top: 8px;
  padding: 6px;
  border: none;
  background: none;
  color: rgba(236, 229, 216, 0.45);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.intro-skip:hover {
  color: rgba(236, 229, 216, 0.8);
}

/* Жест «сдвинь комнату» в обучении: рука едет влево-вправо */
.intro-swipe {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 18px;
  max-width: 240px;
  margin: 0 auto 14px;
  padding: 6px 14px;
  border: 2px dashed rgba(236, 229, 216, 0.24);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  color: rgba(236, 229, 216, 0.45);
  font-size: 12px;
  font-weight: 900;
  overflow: hidden;
}

.intro-swipe.show {
  display: flex;
}

.intro-swipe .intro-hand {
  display: inline-block;
  font-size: 22px;
  line-height: 1;
  animation: introSwipeHand 1.8s ease-in-out infinite;
}

@keyframes introSwipeHand {
  0%, 100% { transform: translateX(-16px); }
  50% { transform: translateX(16px); }
}
/* ==========================================================================
   12. ПОСТАПОКАЛИПСИС — «БУНКЕРНАЯ СТЕНГАЗЕТА»
   Старая бумага + ржавая краска + уголь/зола + токсичная зелень.
   Игровое поле матч-3 (сетка и фишки) не трогаем — только плашки вокруг.
   Порядок и приоритет: блок идёт ПОСЛЕ старых правил и дублирует их
   !important, иначе старый индустриальный слой перекрывает фон.
   ========================================================================== */

:root {
  --p-paper: #d9c8a3;        /* старая бумага */
  --p-paper-hi: #ece1c5;     /* выцветший белый */
  --p-paper-2: #c7b58d;      /* тень бумаги */
  --p-ink: #211a12;          /* коричнево-чёрный текст */
  --p-ink-2: #5a4b37;        /* приглушённый текст */
  --p-rust: #a32c1e;         /* ржавый красный */
  --p-rust-hi: #c7412c;
  --p-rust-deep: #671810;
  --p-coal: #1b1917;         /* уголь */
  --p-ash: #6f6a5d;          /* зола/серый */
  --p-toxic: #7f9c2e;        /* токсичная зелень */
  --p-toxic-hi: #a6c53f;
  --p-toxic-ink: #3f5210;    /* зелёный, читаемый на бумаге */
  --p-white: #fff6ec;

  /* зерно бумаги / грязи */
  --p-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");

  --p-sheet: linear-gradient(163deg, #e2d3b1 0%, #d6c59f 45%, #c4b189 100%);
  --p-sheet-2: linear-gradient(163deg, #cdba92 0%, #bda87e 100%);
  --p-coal-sheet: linear-gradient(163deg, #2b2823 0%, #1d1b17 55%, #141311 100%);
  --p-rust-sheet: linear-gradient(180deg, #b23527 0%, #8e2317 55%, #6d1a10 100%);
  --p-toxic-sheet: linear-gradient(180deg, #8fb034 0%, #6f8a26 60%, #5a741c 100%);

  --p-brush: polygon(0% 6%, 7% 0%, 18% 4%, 31% 1%, 45% 5%, 58% 0%, 71% 4%, 84% 1%, 94% 5%, 100% 3%, 99% 17%, 100% 33%, 98% 51%, 100% 69%, 99% 85%, 100% 96%, 91% 100%, 77% 97%, 63% 100%, 49% 97%, 34% 100%, 21% 97%, 9% 100%, 0% 96%, 2% 81%, 0% 62%, 2% 43%, 0% 24%);
  --p-stroke: polygon(1% 30%, 12% 12%, 34% 7%, 66% 9%, 87% 4%, 99% 20%, 97% 52%, 100% 74%, 95% 96%, 72% 91%, 44% 95%, 19% 98%, 3% 86%);

  /* Глобальные токены игры — под тему */
  --ink: #211a12;
  --paper: #d9c8a3;
  --paper-deep: #b7a37b;
  --blood: #a32c1e;
  --blood-bright: #c7412c;
  --blood-dark: #671810;
  --gold: #a32c1e;
  --toxic: #7f9c2e;
  --steel: #7f7a70;
  --steel-hi: #a5a099;
}

/* фон-картинку (images/background.webp) не трогаем — она снова видна */
html,
body {
  color: var(--p-paper) !important;
}
body.in-menu {
  background-color: #14120e !important;
}

/* ==========================================================================
   13. МЕНЮ — синяя лента превращается в ржавую клеймёную полосу
   ========================================================================== */

.menu-bg {
  filter: saturate(0.62) sepia(0.35) brightness(0.44) contrast(1.12) !important;
}

.menu-vignette {
  background:
    radial-gradient(ellipse at 50% 46%, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.34) 58%, rgba(0, 0, 0, 0.78) 100%),
    linear-gradient(180deg, rgba(8, 13, 6, 0.6), rgba(6, 9, 5, 0.78)),
    var(--p-grain) !important;
  background-size: auto, auto, 160px !important;
}

.menu-build {
  color: rgba(236, 225, 197, 0.5) !important;
}

.menu-kicker {
  color: var(--p-toxic-hi) !important;
  letter-spacing: 0.36em !important;
  font-weight: 800 !important;
}

.menu-title {
  font-family: var(--stencil) !important;
  color: var(--p-paper-hi) !important;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.9), 0 10px 24px rgba(0, 0, 0, 0.75) !important;
}

.menu-title::after {
  background: var(--p-rust) !important;
  clip-path: var(--p-stroke) !important;
}

.menu-tagline {
  color: rgba(236, 225, 197, 0.78) !important;
}

.menu-tags span {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  color: var(--p-ink) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5) !important;
}

.menu-stat {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5) !important;
}

.menu-stat-val {
  font-family: var(--stencil) !important;
  color: var(--p-rust) !important;
}

.menu-stat-cap {
  color: var(--p-ink-2) !important;
}

.menu-play-btn,
.menu-secondary-btn {
  clip-path: var(--p-brush) !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  justify-content: center;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
}

.menu-play-btn {
  background: var(--p-grain) 0 0 / 160px, var(--p-rust-sheet) !important;
  background-blend-mode: multiply, normal !important;
  color: var(--p-white) !important;
  font-size: 20px !important;
}

.menu-play-btn:hover {
  background: var(--p-grain) 0 0 / 160px, linear-gradient(180deg, #c7412c, #8e2317) !important;
  background-blend-mode: multiply, normal !important;
}

.menu-secondary-btn {
  background: var(--p-grain) 0 0 / 160px, var(--p-coal-sheet) !important;
  background-blend-mode: multiply, normal !important;
  color: var(--p-paper) !important;
  font-size: 14px !important;
  padding: 12px 16px !important;
}

.menu-play-arrow {
  background: rgba(0, 0, 0, 0.35) !important;
  border: 2px solid rgba(255, 246, 236, 0.6) !important;
  border-radius: 3px !important;
}

.menu-play-label {
  font-family: var(--rubik) !important;
  font-weight: 900 !important;
  letter-spacing: 0.1em !important;
}

.menu-play-sub {
  color: rgba(255, 246, 236, 0.9) !important;
}

.menu-footer {
  color: rgba(236, 225, 197, 0.45) !important;
}

/* --- Настройки в меню: бумага + красные ползунки ------------------------- */

.ui-overlay .ui-card.menu-settings-card {
  border-color: var(--p-rust) !important;
}

.menu-set-row {
  border-bottom: 1px dashed rgba(33, 26, 18, 0.32) !important;
}

.menu-set-row:last-of-type {
  border-bottom: none !important;
}

.menu-set-title {
  color: var(--p-ink) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.08em !important;
  font-size: 12px !important;
  font-weight: 800 !important;
}

.menu-set-hint {
  color: var(--p-ink-2) !important;
  font-size: 11px !important;
}

.menu-switch {
  background: var(--p-paper-hi) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  color: var(--p-ink-2) !important;
  min-width: 86px !important;
  font-weight: 700 !important;
}

.menu-switch[aria-pressed="true"] {
  background: var(--p-toxic-sheet) !important;
  border-color: var(--p-toxic-ink) !important;
  color: #121b05 !important;
}

.menu-reset-btn {
  background: transparent !important;
  border: 2px solid var(--p-rust) !important;
  border-radius: 3px !important;
  color: var(--p-rust) !important;
}

.menu-reset-btn.armed,
.menu-reset-btn:hover {
  background: var(--p-rust-sheet) !important;
  color: var(--p-white) !important;
  border-color: var(--p-rust-deep) !important;
}

.menu-build-line {
  color: var(--p-ink-2) !important;
}

/* ==========================================================================
   14. HUD, ЛОКАЦИЯ, НАВИГАЦИЯ — бумажные плашки с чёрной рамкой
   ========================================================================== */

.hud-item {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  color: var(--p-ink) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.45) !important;
}

.hud-val {
  color: var(--p-ink) !important;
  font-family: var(--rubik) !important;
  font-weight: 800 !important;
  letter-spacing: 0.02em !important;
}

.lives-stat .hud-val,
.stars-stat .hud-val,
.cash-stat .hud-val {
  color: var(--p-rust) !important;
}

.rep-stat .hud-val {
  color: var(--p-toxic-ink) !important;
}

.location-banner {
  background: var(--p-grain) 0 0 / 160px, var(--p-rust-sheet) !important;
  background-blend-mode: multiply, normal !important;
  clip-path: var(--p-brush) !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  color: var(--p-white) !important;
  font-family: var(--rubik) !important;
  font-weight: 800 !important;
  letter-spacing: 0.16em !important;
  text-transform: uppercase !important;
  font-size: 15px !important;
}

.menu-btn {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  color: var(--p-ink) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.45) !important;
}

.menu-btn:active {
  transform: translate(2px, 2px) !important;
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.45) !important;
}

.menu-btn.story-btn,
.menu-btn.hunt-btn,
#screenHideout .menu-btn.tasks-btn {
  background: var(--p-coal-sheet) !important;
  color: var(--p-paper) !important;
  border-color: var(--p-coal) !important;
}

.menu-btn.play-btn,
#screenHideout .nav-with-play .menu-btn.play-btn {
  background: var(--p-grain) 0 0 / 160px, var(--p-rust-sheet) !important;
  background-blend-mode: multiply, normal !important;
  color: var(--p-white) !important;
  border: 4px solid var(--p-paper-hi) !important;
  border-radius: 6px !important;
  box-shadow: 4px 5px 0 rgba(0, 0, 0, 0.55) !important;
}

#screenHideout .nav-with-play .menu-btn.play-btn:hover,
#screenHideout .nav-with-play .menu-btn.play-btn:active {
  background: var(--p-rust-sheet) !important;
}

.menu-btn.subtle-btn {
  background: var(--p-coal-sheet) !important;
  color: var(--p-paper) !important;
  border-color: var(--p-coal) !important;
  font-size: 13px !important;
}

.icon-btn,
#screenHideout .nav-with-play .menu-btn.icon-btn {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.45) !important;
}

#screenHideout .nav-with-play .menu-btn.icon-btn:hover,
#screenHideout .nav-with-play .menu-btn.icon-btn:active,
.icon-btn:active {
  background: var(--p-rust-sheet) !important;
  transform: translate(2px, 2px) !important;
}

.hunt-here-btn {
  background: var(--p-rust-sheet) !important;
  color: var(--p-white) !important;
  border: 2px solid var(--p-rust-deep) !important;
  border-radius: 3px !important;
}
/* ==========================================================================
   15. ОВЕРЛЕИ, КАРТОЧКИ, КНОПКИ, ДИАЛОГ
   ========================================================================== */

.ui-overlay {
  background: rgba(14, 13, 10, 0.93) !important;
}

.ui-card,
.ui-overlay.overlay-win .ui-card {
  position: relative;
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  color: var(--p-ink) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  box-shadow: 6px 7px 0 rgba(0, 0, 0, 0.55) !important;
}

.ui-overlay.overlay-win .ui-card {
  box-shadow: 0 0 0 2px var(--p-rust), 6px 7px 0 rgba(0, 0, 0, 0.55) !important;
}

/* кусок изоленты в углу карточки */
.ui-card:not(.intro-card)::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 24px;
  width: 84px;
  height: 21px;
  background: linear-gradient(180deg, #3c392f 0%, #25231d 100%) !important;
  transform: rotate(-3.5deg);
  border-radius: 1px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5) !important;
  opacity: 0.94;
  pointer-events: none;
  z-index: 4;
}

.ui-card h2,
.decor-card h3 {
  font-family: var(--rubik) !important;
  color: var(--p-rust) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.12em !important;
  -webkit-text-stroke: 0 !important;
  text-shadow: none !important;
}

.ui-card h2::after {
  content: "";
  display: block;
  width: 68px;
  height: 7px;
  margin: 9px auto 0;
  background: var(--p-rust) !important;
  clip-path: var(--p-stroke) !important;
}

.speaker-name {
  color: var(--p-rust) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.08em !important;
}

.action-btn,
.start-btn {
  background: var(--p-grain) 0 0 / 160px, var(--p-rust-sheet) !important;
  background-blend-mode: multiply, normal !important;
  color: var(--p-white) !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  clip-path: var(--p-brush) !important;
  font-family: var(--rubik) !important;
  font-weight: 800 !important;
  font-size: 17px !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase !important;
}

.action-btn:active,
.start-btn:active {
  background: var(--p-rust-sheet) !important;
  transform: scale(0.97) !important;
}

.next-btn {
  background: var(--p-toxic-sheet) !important;
  color: #121b05 !important;
}

.cancel-btn,
.ghost-btn {
  background: var(--p-coal-sheet) !important;
  color: var(--p-paper) !important;
  box-shadow: inset 0 0 0 2px rgba(217, 200, 163, 0.5) !important;
}

/* --- диалог ------------------------------------------------------------- */

.dialogue-window {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  color: var(--p-ink) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  box-shadow: 6px 7px 0 rgba(0, 0, 0, 0.55), 0 14px 30px rgba(0, 0, 0, 0.5) !important;
}

.dialogue-text {
  color: var(--p-ink) !important;
}

.dialogue-hint,
.scene-title {
  color: var(--p-ink-2) !important;
}

.dialogue-close-btn {
  background: var(--p-paper-hi) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  color: var(--p-ink) !important;
}

.dialogue-close-btn:hover {
  background: var(--p-rust-sheet) !important;
  color: var(--p-white) !important;
}

/* выборы — угольные плашки на бумаге, наведение — ржавчина */
.choice-btn {
  background: var(--p-coal-sheet) !important;
  border: 2px solid var(--p-coal) !important;
  border-radius: 3px !important;
  color: var(--p-paper) !important;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.35) !important;
}

.choice-btn:hover,
.choice-btn:active {
  background: var(--p-rust-sheet) !important;
  border-color: var(--p-rust-deep) !important;
  color: var(--p-white) !important;
}

.choice-btn.premium {
  border-color: var(--p-rust-hi) !important;
}

.choice-btn.premium:hover {
  background: var(--p-rust-sheet) !important;
}

.choice-hint {
  color: rgba(236, 225, 197, 0.7) !important;
}

.choice-req {
  color: #e2907f !important;
}

.choice-btn:disabled,
.choice-btn.is-locked {
  opacity: 0.55;
}

/* --- пролог / интро ------------------------------------------------------ */

.intro-card {
  border-color: var(--p-ink) !important;
}

.intro-text {
  color: var(--p-ink) !important;
}

.intro-counter {
  color: var(--p-ink-2) !important;
}

.intro-dots .intro-dot {
  background: rgba(33, 26, 18, 0.25) !important;
}

.intro-dots .intro-dot.active {
  background: var(--p-rust) !important;
}

.intro-skip {
  color: var(--p-ink-2) !important;
}

.intro-swipe {
  background: rgba(33, 26, 18, 0.07) !important;
  border: 2px dashed rgba(33, 26, 18, 0.4) !important;
  border-radius: 3px !important;
  color: var(--p-ink-2) !important;
}

/* --- задачи, тосты, бонусы ---------------------------------------------- */

.results-line {
  color: var(--p-ink) !important;
}

.results-total {
  color: var(--p-rust) !important;
}

.results-win-block {
  border: 2px dashed rgba(33, 26, 18, 0.45) !important;
  border-radius: 3px !important;
}

.task-item {
  background: rgba(255, 255, 255, 0.32) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
}

.task-title {
  color: var(--p-ink) !important;
}

.task-btn {
  background: var(--p-toxic-sheet) !important;
  border: 2px solid var(--p-toxic-ink) !important;
  border-radius: 3px !important;
  color: #121b05 !important;
  font-family: var(--rubik) !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
}

.toast-notification {
  background: var(--p-coal-sheet) !important;
  color: var(--p-paper) !important;
  border: 2px solid var(--p-rust) !important;
  border-radius: 3px !important;
}

.upgrade-option-card {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
}

.upgrade-option-card:hover {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet-2) !important;
  background-blend-mode: multiply, normal !important;
}

.house-task-btn {
  background: var(--p-sheet-2) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  color: var(--p-ink) !important;
}

.decor-card {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  color: var(--p-ink) !important;
}

.decor-val {
  color: var(--p-rust) !important;
}
/* ==========================================================================
   16. ПРЕ-УРОВЕНЬ — карточка как выцветший бланк
   ========================================================================== */

.pre-stage {
  background: rgba(14, 13, 10, 0.93) !important;
}

.pre-level-card,
.pre-level-card[class*="diff-"],
.pre-level-card.diff-normal,
.pre-level-card.diff-med,
.pre-level-card.diff-hard,
.pre-level-card.diff-challenge {
  --pre-ink: #211a12;
  --pre-ink-soft: #5a4b37;
  --pre-header: #a32c1e;
  --pre-header-text: #fff6ec;
  --pre-stitch: rgba(33, 26, 18, 0.35);
  --pre-title: #fff6ec;
  --pre-booster-title: #a32c1e;
  --pre-well-bg: #c9b68e;
  --pre-plate: #c7b58d;
  --pre-plate-deep: #b7a37b;
  --pre-diff-ink: #fff6ec;
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  color: var(--p-ink) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 4px !important;
  box-shadow: 6px 7px 0 rgba(0, 0, 0, 0.55) !important;
}

.pre-level-card::before {
  inset: 8px;
  background: none !important;
  border: 2px dashed rgba(33, 26, 18, 0.32) !important;
  border-radius: 3px !important;
  box-shadow: none !important;
  opacity: 1 !important;
}

.pre-level-header,
.pre-level-card .pre-level-header,
.pre-level-header.pre-header-walk,
.pre-level-header.pre-header-fix,
.pre-level-header.pre-header-ambush {
  background: var(--p-grain) 0 0 / 160px, var(--p-rust-sheet) !important;
  background-blend-mode: multiply, normal !important;
  border-radius: 3px 3px 0 0 !important;
  color: var(--p-white) !important;
}

.pre-level-card h2,
.pre-level-card .pre-level-header h2,
.pre-level-header h2 {
  color: var(--p-white) !important;
  font-family: var(--rubik) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.1em !important;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5) !important;
}

.diff-badge {
  background: rgba(0, 0, 0, 0.4) !important;
  border: 1.5px solid rgba(255, 246, 236, 0.55) !important;
  color: var(--p-white) !important;
}

.pre-close-btn {
  background: var(--p-paper-hi) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  color: var(--p-ink) !important;
}

.pre-close-btn:hover {
  background: var(--p-rust-sheet) !important;
  color: var(--p-white) !important;
}

.pre-goal-well {
  background: var(--pre-well-bg) !important;
  border: 2px solid rgba(33, 26, 18, 0.4) !important;
  border-radius: 3px !important;
}

.pre-goal-num,
.pre-moves-num,
.pre-goal-label {
  color: var(--p-ink) !important;
}

.pre-moves-num.no-moves {
  color: var(--p-rust) !important;
}

.pre-boosters-selection {
  background: rgba(33, 26, 18, 0.06) !important;
  border: 2px dashed rgba(33, 26, 18, 0.35) !important;
  border-radius: 3px !important;
  color: var(--p-ink) !important;
}

.pre-boosters-selection.pre-boosters-partial .pre-booster-btn:not(.is-locked) {
  background: var(--p-paper-hi) !important;
}

.pre-booster-title {
  color: var(--p-rust) !important;
  font-family: var(--rubik) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.1em !important;
}

.pre-booster-btn,
.pre-boosters-selection .pre-booster-btn {
  background: var(--p-paper-hi) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  color: var(--p-ink) !important;
}

.pre-booster-btn .b-orb {
  background: var(--p-coal-sheet) !important;
  border: 1.5px solid var(--p-ink) !important;
  color: var(--p-paper) !important;
}

.pre-booster-btn .b-tag,
.pre-boosters-selection .pre-booster-btn .b-tag {
  background: var(--p-ink) !important;
  color: var(--p-paper) !important;
}

.pre-booster-btn.is-on {
  background: var(--p-toxic-sheet) !important;
}

.reward-shelf {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet-2) !important;
  background-blend-mode: multiply, normal !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
}

.reward-pill {
  background: var(--p-paper-hi) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  color: var(--p-ink) !important;
}

.pre-dangler-badge {
  background: var(--p-paper-hi) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 3px !important;
  color: var(--p-ink) !important;
}

.pre-level-card .start-btn,
.pre-level-card .start-btn:active {
  background: var(--p-grain) 0 0 / 160px, var(--p-rust-sheet) !important;
  background-blend-mode: multiply, normal !important;
  color: var(--p-white) !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  clip-path: var(--p-brush) !important;
}

/* ==========================================================================
   17. МАТЧ-3 — ТОЛЬКО ПЛАШКИ (сетка, клетки и фишки не тронуты)
   ========================================================================== */

.match3-header-container {
  background: transparent !important;
}

.m3-floating-exit-btn,
.m3-floating-exit-btn:active {
  background: var(--p-rust-sheet) !important;
  border: 2px solid var(--p-paper-hi) !important;
  border-radius: 5px !important;
  color: var(--p-white) !important;
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.5) !important;
}

.m3-hud-base-plate {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 6px !important;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.45) !important;
  filter: none !important;
}

.m3-hud-middle-plate {
  background: var(--p-grain) 0 0 / 160px, linear-gradient(180deg, #cdba92 0%, #b7a37b 100%) !important;
  background-blend-mode: multiply, normal !important;
  border: 2px solid rgba(33, 26, 18, 0.55) !important;
  border-radius: 4px !important;
}

.m3-hud-goal-well {
  background: linear-gradient(180deg, #c2ae85, #ab9669) !important;
  border: 2px solid var(--p-rust) !important;
  border-radius: 3px !important;
}

.m3-hud-level-block {
  background: transparent !important;
}

.m3-hud-level-label,
.m3-hud-level-num,
.m3-hud-level-num .lvl-num,
.m3-moves-count,
.m3-moves-count .m3-moves-digits,
.m3-hud-moves-block.moves-low .m3-moves-count {
  color: var(--p-ink) !important;
  text-shadow: none !important;
}

.m3-hud-level-label {
  color: var(--p-rust) !important;
}

.m3-moves-arrows-stack {
  color: var(--p-ink-2) !important;
}

.m3-hud-goal-badge {
  color: var(--p-ink) !important;
  text-shadow: 0 0 3px rgba(236, 225, 197, 0.95), 0 1px 2px rgba(236, 225, 197, 0.9) !important;
}

.m3-hud-moves-block.tut-moves-glow {
  background: transparent !important;
}

.booster-panel {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 6px !important;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.45) !important;
}

body.m3-l1-no-boosters #m3BoosterPanel {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
}

.booster-btn,
.booster-btn:active,
.booster-btn.active {
  background: var(--p-grain) 0 0 / 160px, var(--p-rust-sheet) !important;
  background-blend-mode: multiply, normal !important;
  border: 2px solid var(--p-paper-hi) !important;
  border-radius: 5px !important;
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.5) !important;
  filter: none !important;
}

.booster-btn .b-count {
  background: var(--p-ink) !important;
  border: 2px solid var(--p-paper-hi) !important;
  color: var(--p-paper) !important;
}

.booster-btn .cost {
  background: var(--p-paper-hi) !important;
  border: 1.5px solid var(--p-ink) !important;
  border-radius: 3px !important;
  color: var(--p-ink) !important;
}

.m3-tut-bubble {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 4px !important;
  box-shadow: 5px 6px 0 rgba(0, 0, 0, 0.5) !important;
  color: var(--p-ink) !important;
}

.m3-tut-text {
  color: var(--p-ink) !important;
}

.m3-tut-name {
  color: var(--p-rust) !important;
}

.m3-tut-arrow {
  filter: none !important;
}

/* держатели поля: тёмный ржавый металл вместо светлого пластика */
#boardWrap::before {
  background: linear-gradient(145deg, #3a352c 0%, #241f19 100%) !important;
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.5),
    inset 0 0 0 3px rgba(163, 44, 30, 0.55),
    inset 0 1px 3px rgba(255, 255, 255, 0.12),
    inset 0 -2px 6px rgba(0, 0, 0, 0.6) !important;
}

#boardWrap::after {
  background: linear-gradient(155deg, #2b2721 0%, #16130f 100%) !important;
  box-shadow:
    0 20px 44px rgba(0, 0, 0, 0.55),
    inset 0 0 0 2px rgba(127, 156, 46, 0.35),
    inset 0 2px 4px rgba(255, 255, 255, 0.08),
    inset 0 -3px 6px rgba(0, 0, 0, 0.5) !important;
}

/* ==========================================================================
   18. УБЫЛИЩЕ, КАРТА, ЛАВКА — бумага и уголь
   ========================================================================== */

#screenHideout .inventory-panel {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 4px !important;
}

.inv-title {
  color: var(--p-rust) !important;
}

.inventory-item {
  background: var(--p-paper-hi) !important;
  border: 1.5px solid var(--p-ink) !important;
  border-radius: 3px !important;
  color: var(--p-ink) !important;
}

.pirate-map-surface,
.pirate-map-surface::before {
  filter: sepia(0.35) saturate(0.85) brightness(0.98) !important;
}

.pirate-map-legend {
  background: var(--p-grain) 0 0 / 160px, var(--p-sheet) !important;
  background-blend-mode: multiply, normal !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 4px !important;
  color: var(--p-ink) !important;
  box-shadow: 5px 6px 0 rgba(0, 0, 0, 0.45) !important;
}

.pirate-map-banner {
  color: var(--p-white) !important;
}

.pirate-map-title-stamp {
  color: rgba(33, 26, 18, 0.75) !important;
  border-color: rgba(33, 26, 18, 0.5) !important;
}

.pirate-map-title-stamp small {
  color: rgba(33, 26, 18, 0.6) !important;
}

.pirate-zone-stamp .zs-name {
  color: var(--p-rust) !important;
}

.map-hint-mini {
  background: var(--p-coal-sheet) !important;
  color: var(--p-paper) !important;
  border: 2px solid var(--p-coal) !important;
  border-radius: 3px !important;
}

.map-node {
  background: var(--p-paper-hi) !important;
  border: 2px solid var(--p-ink) !important;
  border-radius: 50% !important;
  color: var(--p-ink) !important;
}

.map-node.active {
  background: var(--p-rust-sheet) !important;
  color: var(--p-white) !important;
}

.map-node.locked {
  background: var(--p-coal-sheet) !important;
  color: var(--p-paper) !important;
}

.map-node.node-checkpoint {
  background: var(--p-toxic-sheet) !important;
  color: #121b05 !important;
}

.pirate-pin .pin-dot {
  border-color: var(--p-ink) !important;
  box-shadow: 0 0 0 2px var(--p-paper-hi), 2px 3px 0 rgba(0, 0, 0, 0.5) !important;
}

.pirate-pin .pin-label {
  color: var(--p-ink) !important;
  background: var(--p-paper-hi) !important;
  border: 1px solid var(--p-ink) !important;
}

.pirate-pin.is-here .pin-dot {
  background: var(--p-rust-sheet) !important;
  border-color: var(--p-rust-deep) !important;
}

.pirate-pin.is-locked .pin-dot,
.pirate-pin.is-unknown .pin-dot {
  background: var(--p-coal-sheet) !important;
  box-shadow: 0 0 0 2px rgba(217, 200, 163, 0.55) !important;
  opacity: 1 !important;
}

.pirate-pin.is-danger .pin-dot {
  background: var(--p-rust-sheet) !important;
}

.story-goal-chip {
  background: var(--p-rust-sheet) !important;
  border: 2px solid var(--p-rust-deep) !important;
  border-radius: 3px !important;
  color: var(--p-white) !important;
}

/* --- лавка Жоры: свои правила перекрываем повышением specificity ---------- */
.ui-card .sm-section-title {
  color: var(--p-rust) !important;
  opacity: 1 !important;
  border-bottom: 1px dashed rgba(33, 26, 18, 0.35) !important;
  padding-bottom: 5px !important;
}

.ui-card .sm-row {
  background: rgba(33, 26, 18, 0.07) !important;
  border: 1.5px solid rgba(33, 26, 18, 0.35) !important;
  border-radius: 3px !important;
  color: var(--p-ink) !important;
}

.ui-card .sm-row .sm-hint {
  color: var(--p-ink-2) !important;
  opacity: 1 !important;
}

.ui-card .sm-btn {
  background: var(--p-rust-sheet) !important;
  border: 2px solid var(--p-rust-deep) !important;
  border-radius: 3px !important;
  color: var(--p-white) !important;
}

.ui-card .sm-btn.gold {
  background: var(--p-toxic-sheet) !important;
  border-color: var(--p-toxic-ink) !important;
  color: #121b05 !important;
}

.ui-card .sm-btn.ghost {
  background: var(--p-coal-sheet) !important;
  border-color: #000 !important;
  color: var(--p-paper) !important;
}

.ui-card .sm-entry {
  background: rgba(33, 26, 18, 0.07) !important;
  border: 1.5px solid rgba(33, 26, 18, 0.35) !important;
  border-radius: 3px !important;
}

.ui-card .sm-chip {
  background: rgba(33, 26, 18, 0.08) !important;
  border: 1px solid rgba(33, 26, 18, 0.35) !important;
  color: var(--p-ink) !important;
  border-radius: 3px !important;
}

.ui-card .sm-chip.good {
  border-color: var(--p-toxic-ink) !important;
  color: var(--p-toxic-ink) !important;
}

.ui-card .sm-chip.bad {
  border-color: var(--p-rust) !important;
  color: var(--p-rust) !important;
}

.ui-card .sm-progress,
.ui-card .sm-social-strip {
  color: var(--p-ink) !important;
  opacity: 1 !important;
}


/* ---------- Картинки предметов: инвентарь и награды в развилках ---------- */
.inventory-item { display: inline-flex; align-items: center; gap: 5px; }
.inventory-item .inv-icon { width: 18px; height: 18px; object-fit: contain; flex: 0 0 auto; }
.inventory-item .inv-emoji { font-size: 13px; line-height: 1; }
.choice-btn .choice-reward { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
    margin-top: 6px; padding-top: 5px; border-top: 1px dashed rgba(255, 255, 255, .22);
    font-size: 10.5px; font-weight: normal; }
.choice-btn .choice-reward .reward-icon { width: 22px; height: 22px; object-fit: contain; flex: 0 0 auto; }
.choice-btn .choice-reward .reward-emoji { font-size: 14px; line-height: 1; }
.choice-btn .choice-reward .reward-name { opacity: .9; }

/* ---------- Экран рюкзака: крупные картинки, количество, описание ---------- */
.inv-screen {
  z-index: 60;
}
.inv-screen-card {
  width: min(680px, calc(100vw - 28px)) !important;
  max-width: 680px !important;
  max-height: min(84vh, 760px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow: hidden;
}
.inv-screen-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.inv-screen-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.02em;
}
.inv-screen-sub {
  margin: 4px 0 0;
  font-size: 12px;
  opacity: 0.65;
}
.inv-screen-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid var(--p-ink, #211a12);
  background: var(--p-paper-hi, #ece1c5);
  color: var(--p-ink, #211a12);
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}
.inv-screen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  overflow-y: auto;
  padding: 4px 2px 6px;
  align-content: start;
}
.inv-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--p-paper-hi, #ece1c5);
  border: 2px solid var(--p-ink, #211a12);
  border-radius: 6px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.35);
  color: var(--p-ink, #211a12);
}
.inv-card-pic {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 92px;
  background: rgba(33, 26, 18, 0.08);
  border-radius: 4px;
}
.inv-card-img {
  width: 84px;
  height: 84px;
  object-fit: contain;
}
.inv-card-emoji {
  font-size: 44px;
  line-height: 1;
}
.inv-card-count {
  position: absolute;
  right: 4px;
  bottom: 4px;
  min-width: 22px;
  padding: 1px 6px;
  background: var(--p-rust, #a32c1e);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}
.inv-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.inv-card-name {
  margin: 0;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.25;
}
.inv-card-desc {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--p-ink-2, #5a4b37);
}
.inv-screen-empty {
  margin: 0;
  padding: 18px 4px;
  text-align: center;
  font-size: 12px;
  font-style: italic;
  opacity: 0.6;
}
.inventory-item .inv-count {
  font-size: 10px;
  font-weight: 800;
  opacity: 0.75;
}

/* ---------- Рюкзак: поиск и фильтры по типам ---------- */
.inv-screen-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.inv-search {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  font: inherit;
  font-size: 12.5px;
  color: var(--p-ink, #211a12);
  background: var(--p-paper-hi, #ece1c5);
  border: 2px solid var(--p-ink, #211a12);
  border-radius: 6px;
}
.inv-search::placeholder {
  color: var(--p-ink-2, #5a4b37);
  opacity: 0.65;
}
.inv-search:focus {
  outline: 2px solid var(--p-rust, #a32c1e);
  outline-offset: 1px;
}
.inv-chip-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 1px 1px 3px;
  scrollbar-width: thin;
}
.inv-chip {
  flex: 0 0 auto;
  padding: 5px 10px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--p-ink, #211a12);
  background: transparent;
  border: 2px solid var(--p-ink, #211a12);
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.inv-chip:hover {
  background: rgba(33, 26, 18, 0.08);
}
.inv-chip.active {
  background: var(--p-ink, #211a12);
  color: var(--p-paper-hi, #ece1c5);
}
.inv-chip .inv-chip-count {
  margin-left: 4px;
  font-weight: 600;
  opacity: 0.7;
}

/* Тайники лежат под фишками, метка остаётся на месте при падении. */
.supply-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  min-width: 1.25em;
  height: 1.25em;
  padding: 0 2px;
  border: 1px solid #fff0a0;
  border-radius: 4px;
  background: #c97b11;
  color: #241408;
  font: 800 clamp(10px, 2.45vw, 15px)/1 system-ui, sans-serif;
  box-shadow: 0 1px 3px #1e140d;
  pointer-events: none;
  z-index: 15;
}
.grid-portal.paired-portal::after {
  content: attr(data-pair);
  position: absolute;
  right: 0;
  bottom: 0;
  color: #fff;
  background: #343249;
  border-radius: 50%;
  padding: 0 3px;
  font: 800 9px/1.25 system-ui, sans-serif;
}

.tile-fuse .tile-inner, .tile-grate .tile-inner {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
}
.tile-fuse .tile-inner > img, .tile-grate .tile-inner > img {
  width: 100% !important;
  height: 100% !important;
}
.tile-fuse .fuse-color {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 48%;
  height: 48%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(11, 18, 28, .72);
  pointer-events: none;
}
.tile-fuse .fuse-color img { width: 94% !important; height: 94% !important; }

.tile.phone.service-phone:not(.phone-ringing) .tile-inner { filter: brightness(.66) saturate(.72); }
.tile.phone.service-phone.phone-ringing .tile-inner { filter: drop-shadow(0 0 5px #ffd572); }

#board.service-oil-board .grid-cell.oil:not(.jelly):not(.carpet) {
  background-image: none;
}
#board.service-oil-board .grid-cell.oil::after {
  content: '';
  position: absolute;
  inset: 4%;
  border-radius: 32% 22% 35% 20%;
  background: url('images/oil.webp') center / 100% 100% no-repeat;
  opacity: .83;
}
#board.service-oil-board .grid-cell.oil:is(.jelly, .carpet)::after {
  inset: auto 8% 8%;
  height: 33%;
}


/* Проходы в локации. Маркер стоит на видимой точке фона. */
#screenHideout .room-actions {
  position: relative;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 0 10px 6px;
}
#screenHideout .room-actions .story-goal-chip {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-control, .room-passages summary, .room-passage-list button {
  border: 1px solid #827451;
  border-radius: 7px;
  background: #22251d;
  color: #f1e8cc;
  padding: 7px 9px;
  font: 600 11px/1.3 system-ui, sans-serif;
  cursor: pointer;
}
.room-passages { position: relative; }
.room-passages summary { list-style: none; }
.room-passages summary::-webkit-details-marker { display: none; }
.room-passages summary::after { content: ' ▾'; }
.room-passages[open] summary::after { content: ' ▴'; }
.room-passage-list {
  position: absolute;
  top: calc(100% + 5px);
  right: -78px;
  width: min(255px, 81vw);
  display: grid;
  gap: 5px;
  padding: 7px;
  border: 1px solid #8b7952;
  border-radius: 9px;
  background: #1a1e17;
  box-shadow: 0 10px 25px #000b;
  max-height: min(50vh, 400px);
  overflow-y: auto;
}
.room-passage-list button { text-align: left; min-height: 34px; }
html body #hotspotsContainer .world-passage {
  z-index: 8 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  min-width: 42px;
  min-height: 42px;
  width: 42px;
  height: 42px;
  padding: 0;
  transform: translate(-50%, -50%);
  font: 600 12px/1.2 system-ui, sans-serif;
}
html body #hotspotsContainer .world-passage::before,
html body #hotspotsContainer .world-passage::after { content: none !important; }
.passage-sign {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid #e4c681;
  box-shadow: 0 2px 8px #000c;
  background: #24251ce8;
  color: #ffe4aa;
  font-size: 20px;
}
.passage-edge .passage-sign { border-radius: 6px; }
html body #hotspotsContainer .world-passage .hotspot-label {
  position: absolute !important;
  top: calc(100% - 3px);
  left: 50%;
  transform: translateX(-50%);
  max-width: 94px;
  width: max-content;
  white-space: normal;
  text-align: center;
  color: #f6efda !important;
  background: #22231c !important;
  border: 1px solid #8b7952 !important;
  border-radius: 5px;
  padding: 3px 5px !important;
  text-shadow: none !important;
  font: 600 10px/1.2 system-ui, sans-serif !important;
  pointer-events: none;
}
#hotspotsContainer .passage-highlight {
  outline: 2px solid #f7d177;
  outline-offset: 4px;
  border-radius: 8px;
}
html body #hotspotsContainer .world-passage:focus-visible .passage-sign,
html body #hotspotsContainer .world-passage:hover .passage-sign { background: #625134; }

.passage-sign[data-direction]::before {
  content: '';
  width: 8px;
  height: 8px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: translateY(2px) rotate(-45deg);
}
.passage-sign[data-direction='left']::before { transform: translateX(2px) rotate(-135deg); }
.passage-sign[data-direction='right']::before { transform: translateX(-2px) rotate(45deg); }
html body #hotspotsContainer .world-passage.passage-highlight {
  outline: 2px solid #f7d177 !important;
}

/* Пока открыта карточка перед уровнем, поле и HUD за ней скрыты:
   иначе «1 уровень / цели» просвечивали из-под карточки. */
body.pre-level-open #screenMatch3 { visibility: hidden !important; }

/* ===== Telegram Mini App: безопасные зоны (tg_app.js) ===== */
html { --tg-safe-top: 0px; --tg-safe-bottom: 0px; --tg-vh: 100dvh; }
html.tg-app .global-hud { padding-top: calc(var(--tg-safe-top) + 6px); }

/* ===== Предупреждение для теста беты на главном экране ===== */
.menu-note {
  margin: 10px 0 4px;
  padding: 10px 12px;
  border: 1px solid rgba(196, 160, 90, 0.45);
  border-radius: 4px;
  background: rgba(14, 16, 13, 0.72);
  color: #cfc7b4;
  font-size: 11.5px;
  line-height: 1.35;
}
.menu-note p { margin: 0 0 6px; }
.menu-note-title {
  color: #e8c98a;
  font-weight: 800;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}
.menu-note-close {
  display: block;
  margin: 2px auto 0;
  padding: 6px 18px;
  background: transparent;
  border: 1px solid rgba(196, 160, 90, 0.6);
  border-radius: 3px;
  color: #e8c98a;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.menu-note.hidden { display: none; }
