:root {
  --sky-top: #3f9be0;
  --sky-bottom: #8fd0f5;
  --card-border: #d8ab5c;
  --card-border-dark: #b98738;
  --gold: #ffd75e;
  --danger: #e0503f;
  --ink: #1c3550;
  --cream: #fff9f1;
  --tile-shadow: rgba(120, 90, 60, .14);
  --tile-glow: rgba(212, 166, 74, .35);
  /* Лоток в стиле скриншотов-примеров: светлая рамка, тёмные слоты */
  --tray-bg: linear-gradient(180deg, #f7f8fb, #e6eaf1);
  --tray-slot: rgba(43, 31, 19, .58);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Nunito', sans-serif;
  background: radial-gradient(ellipse at center, #14273d 0%, #08131f 72%);
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.stage {
  position: relative;
  width: 1704px;
  height: 999px;
  flex-shrink: 0;
  transform-origin: center center;
  overflow: hidden;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 55%, #bfe7fa 100%);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(0, 0, 0, .5);
}

/* Виньетка поверх сцены: глубина картинки (заметнее на больших экранах ПК).
   Игровая зона имеет z-index 5, а шапка/кнопки/оверлеи — 10+,
   поэтому затемняются только края поля, а интерфейс остаётся ярким. */
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(6, 14, 28, .38) 100%);
}

/* Фоновое изображение уровня (тематические/стандартные фоны) */
.level-bg {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  /* немного приглушаем, чтобы плитки оставались читаемыми */
  filter: brightness(.9) saturate(1.02);
}

.cloud-drift {
  position: absolute;
  left: 0;
  pointer-events: none;
  will-change: transform;
  opacity: 0;
}

.cloud {
  position: relative;
  left: 0;
  pointer-events: none;
  object-fit: contain;
  will-change: transform;
}

.header {
  position: relative;
  left: 0;
  top: 0;
  width: 100%;
  flex-shrink: 0;
  z-index: 10;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 16px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.4), transparent);
}

.header > * {
  pointer-events: auto;
}


h1 {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  color: #fff;
  text-align: center;
  font-size: 32px;
  /* Заголовок строго по центру сцены — не зависит от ширины боковых групп */
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  max-width: 46%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  text-shadow: 0 3px 0 rgba(0, 60, 110, .5), 0 6px 18px rgba(0, 0, 0, .35);
  letter-spacing: .02em;
}

.score-panel {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  /* Перекрывает абсолютно позиционированный h1 при тесной портретной раскладке */
  position: relative;
  z-index: 1;
}

/* Иконки-превью счётчиков (в портрете подписи скрываются, остаётся иконка+значение) */
.score-ico {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

/* Инлайн-SVG монета вместо эмодзи 🪙 (U+1FA99): старые системные шрифты
   (Segoe UI Emoji < Windows 10 20H1) не содержат этот глиф, из-за чего
   иконка монеты не отрисовывалась на десктопе. SVG рисуется везде одинаково. */
.coin-ico {
  width: 1.15em;
  height: 1.15em;
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
}

.score-ico .coin-ico {
  display: block;
}

.shop-item-price .coin-ico {
  width: 1em;
  height: 1em;
  margin-right: 4px;
}

.score-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 25, 40, .45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  padding: 4px 12px;
  border-radius: 22px;
  border: 2px solid rgba(255, 255, 255, .5);
}

/* Золотая пилюля монет — акцент как на скриншотах-примерах */
.score-item.score-coins {
  background: linear-gradient(160deg, #ffe08a, #f5c445);
  border-color: rgba(255, 255, 255, .95);
  box-shadow: 0 3px 0 rgba(150, 108, 20, .55), 0 6px 14px rgba(0, 0, 0, .28);
}

.score-item.score-coins .score-label {
  color: rgba(70, 50, 8, .8);
}

.score-item.score-coins .score-value {
  color: #5c4208;
}

/* Очки и рекорд — отдельным рядом у нижних краёв сцены (см. index.html) */
.stats {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  z-index: 11;
  pointer-events: none;
}

.stats .score-item {
  pointer-events: none;
}

.score-label {
  color: rgba(255, 255, 255, .85);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.score-value {
  color: var(--gold);
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 20px;
  min-width: 30px;
  text-align: center;
}

.score-item.combo {
  background: linear-gradient(160deg, #ff6b6b, #ff3838);
  border-color: #fff;
  animation: comboPulse .5s ease;
  display: none;
}

.score-item.combo.show {
  display: flex;
}

.combo-label {
  color: #fff;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 14px;
}

.combo-value {
  color: var(--gold);
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 20px;
}

@keyframes comboPulse {
  0% {
    transform: scale(0.5);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.score-pop {
  position: absolute;
  color: var(--gold);
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 29px;
  pointer-events: none;
  animation: scoreFloat .8s ease forwards;
  z-index: 100;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .5);
}

@keyframes scoreFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-40px) scale(1.3);
  }
}

.game-area {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  z-index: 5;
  /* Верх — под шапкой (в потоке), низ — под контролами;
     боковые «желоба» больше не нужны: кнопки переехали в шапку. */
  padding: 6px 60px calc(16px + max(70px, calc(52px / var(--ui-scale, 1)))) 60px;
}

/* Держатель поля: заполняет остаток game-area, поле (JS) берёт его размеры */
.board-holder {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.tray-wrap {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  z-index: 10;
  /* Эффектам слияния разрешаем выходить за края лотка */
  overflow: visible;
}

.tray {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 820px;
  background: var(--tray-bg);
  border: 3px solid rgba(255, 255, 255, .92);
  border-radius: 18px;
  padding: 10px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .28), inset 0 3px 10px rgba(120, 90, 60, .16);
}

.slot {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  height: auto;
  aspect-ratio: 1;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 58px;
  background: var(--tray-slot);
  border: 2px solid rgba(0, 0, 0, .25);
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, .45);
  overflow: hidden;
  padding: 0;
}

.slot-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
  pointer-events: none;
  user-select: none;
}

/* Появление плитки в лотке */
/* Занятый слот — выглядит как плитка на поле: без тёмной ниши/ободка,
   спрайт занимает 100% слота (было 76% + тёмный фон = «сжатие»). */
.slot.filled {
  background: transparent;
  /* Рамку оставляем в потоке (прозрачной), чтобы flex не пересчитывал
     ширину слота при появлении плитки — иначе ряд «прыгает». */
  border-color: transparent;
  box-shadow:
    0 4px 0 var(--tile-shadow),
    0 10px 18px rgba(120, 90, 60, .18);
  overflow: hidden;
  animation: slotPop .28s cubic-bezier(.2, .9, .3, 1.35);
}
/* Картинка компенсирует прозрачную рамку: выходит под неё (inset -2px),
   поэтому спрайт ровно вровень с габаритом пустого слота. */
.slot.filled .slot-image {
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  margin: -2px;
  max-width: none;
  max-height: none;
}

@keyframes slotPop {
  0% {
    transform: scale(.3);
    opacity: .4;
  }
  60% {
    transform: scale(1.18);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

/* Сборка тройки в комбо: плитка вспыхивает и схлопывается */
.slot.clearing {
  animation: comboCollect var(--combo-duration, .32s) ease forwards;
  z-index: 3;
  pointer-events: none;
}

@keyframes comboCollect {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  45% {
    transform: scale(1.35);
    filter: brightness(2.2) drop-shadow(0 0 16px #fff);
  }
  100% {
    transform: scale(0);
    opacity: 0;
    filter: brightness(2.6) drop-shadow(0 0 24px #ffe27a);
  }
}

/* ============ Мягкое премиум-слияние тройки (merge) ============
   4 фазы: sync-pulse -> lift+glow -> dissolve -> settle.
   Частицы/кольца живут в .tray-wrap (не в .slot), поэтому их
   не обрезает overflow. Только transform/opacity — дёшево для FPS:
   фильтры (brightness/blur) в анимациях убраны — они заставляли
   браузер перерисовывать содержимое слотов каждый кадр. */
.tray.tray-merging {
  animation: traySettle 400ms ease-out;
}
/* Затемнение соседних слотов: opacity вместо filter — композитный слой
   обходится без repaint содержимого (картинки плиток). */
.tray.tray-merging .slot.filled:not(.merging):not(.dissolving) {
  opacity: .72;
  transform: scale(.96);
  transition: opacity 220ms ease, transform 220ms ease;
}
.tray .slot.filled {
  transition: opacity 220ms ease, transform 220ms ease;
}

@keyframes traySettle {
  0% { transform: scale(1); }
  35% { transform: scale(1.018); }
  100% { transform: scale(1); }
}

/* Фаза 1-2: тройка подсвечена, приподнята, пульсирует
   (300мс — стыкуется с dissolveAt=300 в FxManager.mergeTriple) */
.slot.merging {
  z-index: 7;
  overflow: visible;
  animation: mergePulse 300ms ease-in-out forwards;
  border-color: rgba(255, 244, 210, .98);
  /* Тонкий золотой ободок вместо широкого «жёлтого пятна»:
     соседние слоты больше не заливаются оранжевым. */
  box-shadow: 0 0 0 2px rgba(255, 238, 178, .75),
    0 0 12px 2px rgba(255, 214, 110, .45),
    0 8px 14px rgba(120, 70, 20, .3);
}
.slot.merging .slot-image {
  filter: brightness(1.12) saturate(1.12);
}

@keyframes mergePulse {
  0% { transform: scale(1) translateY(0); }
  35% { transform: scale(1.1) translateY(-5px); }
  70% { transform: scale(1.13) translateY(-7px); }
  100% { transform: scale(1.1) translateY(-6px); }
}

/* Фаза 3: мягкое растворение вместо резкого схлопывания
   250мс: старт на 300мс (high-end) => конец ровно к total=560мс;
   на low-end старт 220мс => конец 470мс. В обоих случаях слот очищается
   после завершения анимации (Tray снимает призраков на resolve). */
.slot.dissolving {
  z-index: 7;
  overflow: visible;
  pointer-events: none;
  animation: mergeDissolve 250ms ease-in forwards;
  border-color: rgba(255, 249, 224, .85);
  box-shadow: 0 0 14px 2px rgba(255, 226, 152, .5);
}

/* Без filter в кадрах: brightness/blur на каждом кадре = repaint слота,
   заметный проседание FPS на мобильных. Свечение даёт box-shadow сверху. */
@keyframes mergeDissolve {
  0% { transform: translate(0, -6px) scale(1.1); opacity: 1; }
  35% { transform: translate(calc(var(--mdx, 0px) * .3), calc(var(--mdy, 0px) * .3 - 8px)) scale(.96); opacity: .92; }
  100% { transform: translate(var(--mdx, 0px), var(--mdy, 0px)) scale(.4); opacity: 0; }
}

/* Мягкое кольцо от центра тройки — насыщенное, видно на светлом фоне */
.merge-ring {
  position: absolute;
  left: 0; top: 0;
  width: 70px; height: 70px;
  margin: -35px 0 0 -35px;
  border-radius: 50%;
  border: 3px solid rgba(255, 206, 92, .95);
  box-shadow: 0 0 14px 3px rgba(255, 184, 60, .5), inset 0 0 10px rgba(255, 216, 120, .45);
  pointer-events: none;
  z-index: 60;
  animation: mergeRingSoft 620ms ease-out forwards;
}
.merge-ring.wide {
  animation: mergeRingSoftWide 700ms ease-out forwards;
  border-width: 3px;
  border-color: rgba(255, 220, 130, .9);
}
@keyframes mergeRingSoft {
  0% { transform: scale(.5); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: scale(2.6); opacity: 0; }
}
@keyframes mergeRingSoftWide {
  0% { transform: scale(.7); opacity: 0; }
  20% { opacity: .85; }
  100% { transform: scale(4.2); opacity: 0; }
}

/* Светящиеся пылинки — насыщенное золото с тенью, видно на светлом небе */
.merge-mote {
  position: absolute;
  left: 0; top: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 60;
  background: radial-gradient(circle, #ffffff 0%, #ffc93c 40%, #ff9a2e 62%, rgba(255, 154, 46, 0) 75%);
  box-shadow: 0 0 8px 2px rgba(255, 180, 60, .8);
  animation: moteFloat 750ms ease-out forwards;
}
@keyframes moteFloat {
  0% { transform: translate(-50%, -50%) scale(.5); opacity: 0; }
  18% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--mx)), calc(-50% + var(--my))) scale(1.05); opacity: 0; }
}

/* Тёплое пятно-свечение в центре тройки (вместо screen-flash на весь экран) */
.tray-glow {
  position: absolute;
  left: 0; top: 0;
  width: 224px; height: 124px;
  margin: -62px 0 0 -112px;
  background: radial-gradient(ellipse at center, rgba(255, 252, 238, .72) 0%, rgba(255, 214, 120, .36) 45%, rgba(255, 190, 90, 0) 72%);
  pointer-events: none;
  z-index: 59;
  animation: trayGlow 560ms ease-out forwards;
}
@keyframes trayGlow {
  0% { opacity: 0; transform: scale(.6); }
  30% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.2); }
}

/* Крупный золотистый попап очков — с тёмной обводкой, видно на светлом небе */
.merge-popup {
  position: absolute;
  left: 0; top: 0;
  transform: translate(-50%, -50%);
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 34px;
  color: #fff3c4;
  -webkit-text-stroke: 1px rgba(140, 70, 10, .85);
  text-shadow: 0 0 14px rgba(255, 170, 30, 1), 0 2px 8px rgba(120, 55, 5, .9);
  pointer-events: none;
  white-space: nowrap;
  z-index: 61;
  animation: mergePopUp 700ms cubic-bezier(.2, .7, .3, 1) forwards;
}
@keyframes mergePopUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  22% { opacity: 1; transform: translate(-50%, -60%) scale(1.12); }
  55% { opacity: 1; transform: translate(-50%, -110%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(.95); }
}

/* Стрик-лейбл: подсказка GPU при слиянии */
.streak-label {
  will-change: transform, opacity;
}

@media (prefers-reduced-motion: reduce) {
  .slot.merging, .slot.dissolving, .tray.tray-merging {
    animation: none;
  }
  .merge-ring, .merge-mote, .merge-popup, .tray-glow {
    display: none;
  }
}

/* ------------------ Взрыв комбо над лотком ------------------ */
.combo-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 20;
}

.combo-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  border: 4px solid rgba(255, 214, 110, .9);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: comboRing .45s ease-out forwards;
}

.combo-flash-center {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 255, 255, .95) 0%, rgba(255, 215, 94, .7) 40%, transparent 70%);
  animation: comboFlash .4s ease-out forwards;
}

.combo-particle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffd75e 60%, transparent 100%);
  box-shadow: 0 0 9px #ffd75e;
  animation: comboParticle .5s cubic-bezier(.2, .6, .4, 1) forwards;
}

@keyframes comboRing {
  0% {
    transform: translate(-50%, -50%) scale(.6);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(7);
    opacity: 0;
  }
}

@keyframes comboFlash {
  0% {
    transform: translate(-50%, -50%) scale(.4);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(3);
    opacity: 0;
  }
}

@keyframes comboParticle {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx, 0), var(--dy, 0)) scale(0);
    opacity: 0;
  }
}

@keyframes pop {
  0% {
    transform: scale(.5);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes zap {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    filter: brightness(1.6);
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

.board {
  position: relative;
  width: 1160px;
  height: 745px;
  z-index: 5;
  /* Без тёмной подложки — как на скриншотах плитки лежат прямо на фоне уровня */
  background: transparent;
  border-radius: 22px;
  overflow: hidden;
}

.tile {
  position: absolute;
  /* Размер задаёт JS (--tile-size на #board): плитка масштабируется вместе с сеткой,
     иначе на сжатом поле она перекрывает соседей сильнее порога и почти всё «закрыто» */
  width: var(--tile-size, 124px);
  height: var(--tile-size, 124px);
  border-radius: calc(var(--tile-size, 124px) * .177);
  overflow: hidden;
  /* Прозрачный фон: край плитки задаёт только рамка спрайта — без полупрозрачного ободка */
  background: transparent;
  border: none;
  box-shadow:
    0 4px 0 var(--tile-shadow),
    0 10px 18px rgba(120, 90, 60, .18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--tile-size, 124px) * .532);
  /* transition только transform: box-shadow/filter в transition заставляют
     перекрашивать плитку на каждый hover/refresh — дорого на мобильных */
  transition: transform .15s cubic-bezier(.3, 1.5, .5, 1);
  /* Подсказка композитору + изоляция paint */
  will-change: transform;
  contain: layout paint;
}

.tile-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}

.tile.covered {
  /* opacity вместо filter: brightness вызывает только composite, а не repaint */
  opacity: .82;
}

.tile.top {
  cursor: pointer;
}

.tile.top:hover {
  transform: translateY(-3px) scale(1.05);
}

.tile.top:active {
  transform: translateY(0px) scale(.94);
}

.tile.flying {
  animation: fly .38s ease forwards;
  z-index: 999 !important;
}

@keyframes fly {
  to {
    transform: translateY(-40px) scale(.4);
    opacity: 0;
  }
}

.tile.locked-flash {
  animation: shake .3s;
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-4px);
  }
  40%,
  80% {
    transform: translateX(4px);
  }
}

@keyframes cloudFloat {
  0% {
    transform: translateX(-200vw) scale(var(--cloud-scale, 1));
    opacity: 0;
  }
  15% {
    opacity: var(--cloud-opacity, 0.7);
  }
  85% {
    opacity: var(--cloud-opacity, 0.7);
  }
  100% {
    transform: translateX(200vw) scale(var(--cloud-scale, 1));
    opacity: 0;
  }
}

@keyframes cloudFloatReverse {
  0% {
    transform: translateX(200vw) scale(var(--cloud-scale, 1));
    opacity: 0;
  }
  15% {
    opacity: var(--cloud-opacity, 0.7);
  }
  85% {
    opacity: var(--cloud-opacity, 0.7);
  }
  100% {
    transform: translateX(-200vw) scale(var(--cloud-scale, 1));
    opacity: 0;
  }
}

@keyframes cloudFloatMenu {
  0% {
    transform: translateX(-100vw) scale(var(--cloud-scale, 1));
    opacity: var(--cloud-opacity, 0.7);
  }
  85% {
    opacity: var(--cloud-opacity, 0.7);
  }
  100% {
    transform: translateX(100vw) scale(var(--cloud-scale, 1));
    opacity: 0;
  }
}

@keyframes cloudFloatReverseMenu {
  0% {
    transform: translateX(100vw) scale(var(--cloud-scale, 1));
    opacity: var(--cloud-opacity, 0.7);
  }
  85% {
    opacity: var(--cloud-opacity, 0.7);
  }
  100% {
    transform: translateX(-100vw) scale(var(--cloud-scale, 1));
    opacity: 0;
  }
}

@keyframes cloudBob {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(calc(var(--bob-offset, -15px)));
  }
}

/* Статичные облака для low-q: без анимаций вообще */
.cloud-drift.cloud-static {
  animation: none !important;
  opacity: .4;
}
.cloud-drift.cloud-static .cloud {
  animation: none !important;
  filter: none !important;
}

/* Летящая плитка и шлейф: только композитор, без layout */
.flying-tile {
  will-change: transform;
  contain: layout paint;
}
.trail-dot {
  will-change: transform, opacity;
  contain: layout paint;
}

/* ============================================================
   Режим .low-q (слабые мобильные): вырезаем самые дорогие эффекты.
   backdrop-filter/blur/box-shadow/text-shadow и виньетка — главные
   потребители GPU на Mali/Adreno. Визуал чуть проще, FPS заметно выше.
   ============================================================ */
body.low-q .stage::after {
  display: none;
}
body.low-q .score-panel,
body.low-q .stats {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: rgba(15, 25, 40, .55);
}
body.low-q .tile {
  box-shadow: none;
  will-change: auto;
}
body.low-q .slot {
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .35);
}
body.low-q .slot.filled {
  box-shadow: none;
}
body.low-q h1,
body.low-q .merge-popup,
body.low-q .streak-label {
  text-shadow: 0 2px 0 rgba(0, 60, 110, .5);
}
body.low-q .cloud {
  filter: none !important;
}
body.low-q .level-bg {
  filter: none;
}

.controls {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 14px;
}

/* Группа кнопок слева в шапке: Меню, Настройки, Магазин */
.side-actions {
  position: static;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
  /* Перекрывает абсолютно позиционированный h1 при тесной портретной раскладке */
  z-index: 1;
}

#sideActions.hidden {
  display: none;
}



/* Кнопки бонусов: единый тёмный «круг» со светлой рамкой — как на скриншотах */
.ctrl {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(30, 38, 52, .72);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  border: 3px solid rgba(255, 255, 255, .85);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 29px;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .35);
  transition: transform .12s ease, filter .12s ease;
}

.ctrl:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
}

.ctrl:active {
  transform: scale(.92);
}

.ctrl.wand {
  width: 70px;
  height: 70px;
  background: rgba(30, 38, 52, .72);
  border-color: var(--gold);
  color: #fff;
  font-size: 30px;
  position: relative;
}

.ctrl.item {
  width: 62px;
  height: 62px;
  background: rgba(30, 38, 52, .72);
  border-color: rgba(255, 255, 255, .85);
  color: #fff;
  font-size: 29px;
  position: relative;
}

.ctrl.wand img,
.ctrl.item img {
  width: 72%;
  height: 72%;
  object-fit: contain;
  pointer-events: none;
}

.badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #1c3550;
  color: var(--gold);
  font-size: 14px;
  font-weight: 800;
  border-radius: 50%;
  width: 29px;
  height: 29px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 20, 35, .72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  text-align: center;
}

.overlay.show {
  display: flex;
}

#settingsOverlay {
  z-index: 2001;
}

#shopOverlay {
  z-index: 2002;
}

.overlay-card {
  background: #fff;
  border-radius: 22px;
  padding: 28px 26px;
  width: 80%;
  max-width: 280px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, .4);
}

.overlay-card h2 {
  font-family: 'Baloo 2', sans-serif;
  font-size: 29px;
  margin: 0 0 8px;
  color: var(--ink);
}

.overlay-card p {
  font-size: 14px;
  color: #5a6b7d;
  margin: 0 0 18px;
}

.overlay-card button {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  background: linear-gradient(160deg, #5fd39a, #2fa870);
  color: #fff;
  border: none;
  border-radius: 11px;
  padding: 12px 22px;
  font-size: 19px;
  cursor: pointer;
  box-shadow: 0 4px 0 #1f7a52;
}

.overlay-card button:active {
  transform: translateY(3px);
  box-shadow: none;
}

/* Главное меню (отдельное окно) */
.main-menu {
  position: fixed;
  width: 1920px;
  height: 1080px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: url('Phon/NewPhonMenu.webp') center/cover no-repeat;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  text-align: center;
  overflow: hidden;
  transform-origin: center center;
}

#menuClouds {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

#gameTitle {
  position: relative;
  z-index: 2;
  width: 65%;
  max-width: 900px;
  height: auto;
  margin-bottom: 40px;
  pointer-events: none;
}

.main-menu > #startBtn {
  position: relative;
  z-index: 2;
}

.main-menu.hidden {
  display: none;
}

/* Игровая сцена скрывается, пока открыто главное меню, чтобы она не выглядывала
   по краям адаптивного меню (меню шире-уже вьюпорта на не-16:9 экранах). */
.stage.hidden {
  display: none;
}



/* Стили для стартового окна */
.start-card {
  max-width: 320px;
  padding: 40px 33px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88) 0%, rgba(248, 244, 232, 0.88) 100%), url('../Phon/menu.webp') center/cover no-repeat;
  border: 3px solid var(--card-border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5), 0 0 0 6px rgba(255, 255, 255, .15);
}

.game-title {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 56px;
  color: var(--ink);
  text-align: center;
  margin: 0 0 12px;
  text-shadow: 0 3px 0 rgba(0, 60, 110, .3);
  letter-spacing: .02em;
  animation: titleFloat 3s ease-in-out infinite;
}

@keyframes titleFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}



.start-button {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  background: url('Phon/Play.webp') center/contain no-repeat;
  color: transparent;
  border: none;
  border-radius: 24px;
  padding: 31px 88px;
  font-size: 44px;
  cursor: pointer;
  box-shadow: 0 16px 32px rgba(0, 0, 0, .25);
  transition: transform .15s ease, box-shadow .15s ease;
  text-transform: uppercase;
  letter-spacing: .05em;
  text-shadow: none;
}

/* Кнопка «Играть»: текст зашит в картинку, поэтому при смене языка
   подменяется фон — атрибут lang выставляет js/i18n.js. */
html[lang='en'] .start-button {
  background-image: url('Phon/EN/Play.webp');
}

.start-button:hover {
  transform: translateY(-4px) scale(1.1);
  box-shadow: 0 24px 40px rgba(0, 0, 0, .3), 0 0 40px rgba(255, 0, 0, .8);
  filter: brightness(1.1);
}

.start-button:active {
  transform: translateY(8px) scale(1.0);
  box-shadow: 0 8px 16px rgba(0, 0, 0, .2), 0 0 20px rgba(255, 0, 0, .6);
}


  




/* Кнопка старта для больших экранов */
.main-menu .start-button {
  padding: 40px 110px;
  font-size: 57px;
  border-radius: 35px;
}

/* Адаптивность обеспечивается единым преобразованием масштаба в UiManager.resize():
   и .stage, и .main-menu получают адаптивную ширину базы (от реальных пропорций окна),
   масштабируются через transform:scale и переключают класс .is-portrait на узких
   экранах. Поэтому отдельные медиа-запросы с изменением размеров компонентов
   исключены. */

@media (min-width: 768px) {
  .stage {
    border-radius: 22px;
    /* Рамка и мягкая внешняя тень — «картина» на большом экране ПК */
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, .12),
      0 40px 90px rgba(0, 0, 0, .6);
  }
}

/* ПК (точный указатель): лёгкий медленный «ken-burns» фона уровня —
   глубина сцены без заметной нагрузки на GPU (только transform). */
@media (hover: hover) and (pointer: fine) {
  .level-bg {
    animation: bgDrift 40s ease-in-out infinite alternate;
  }
}

@keyframes bgDrift {
  from { transform: scale(1); }
  to   { transform: scale(1.06); }
}

/* Полноэкранный режим */
:fullscreen .stage,
:-webkit-full-screen .stage,
::-webkit-full-screen .stage {
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;
  max-width: 100dvw;
  max-height: 100vh;
  max-height: 100dvh;
  border-radius: 0;
}

:fullscreen .main-menu,
:-webkit-full-screen .main-menu,
::-webkit-full-screen .main-menu {
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
}

/* Яндекс Игры - поддержка iframe */
@supports (padding: env(safe-area-inset-top)) {
  body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
}

/* Кнопка меню на игровых уровнях */
.level-menu-btn {
  position: relative;
  z-index: 10;
  width: 85px;
  height: 85px;
  background: url('Phon/Kvadrat.webp') center/contain no-repeat;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform .1s ease;
}

.level-menu-btn:hover {
  transform: translateY(-2px);
}

/* Кастомный тултип для кнопки меню */
.level-menu-btn .tooltip {
  position: absolute;
  left: calc(100% + 12px);
  transform: translateY(-50%);
  top: 50%;
  display: none;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}

.level-menu-btn .tooltip img {
  display: block;
  max-width: min(160px, 80vw);
  max-height: min(160px, 60vh);
  width: auto;
  height: auto;
  border-radius: 11px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.level-menu-btn:hover .tooltip {
  display: block;
}

.level-menu-btn:active {
  transform: translateY(2px);
}

.settings-icon-btn {
  border: none;
  padding: 0;
  width: 85px;
  height: 85px;
  background: url('Phon/nastroiki.webp') center/contain no-repeat;
  cursor: pointer;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .35));
  transition: transform .15s ease, filter .15s ease;
}

.settings-icon-btn:hover {
  transform: translateY(-2px) scale(1.05);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45)) brightness(1.1);
}

.settings-icon-btn:active {
  transform: translateY(2px) scale(.97);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .35));
}

/* Кастомный тултип для кнопки настроек */
.settings-icon-btn .tooltip {
  position: absolute;
  left: calc(100% + 12px);
  transform: translateY(-50%);
  top: 50%;
  display: none;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}

.settings-icon-btn .tooltip img {
  display: block;
  max-width: min(160px, 80vw);
  max-height: min(160px, 60vh);
  width: auto;
  height: auto;
  border-radius: 11px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

/* Основная кнопка в меню: тултип сверху */
.main-menu > #settingsMenuBtn .tooltip {
  bottom: calc(100% + 12px);
}

/* Кнопка на уровне: тултип справа */
.level-settings-btn .tooltip {
  left: calc(100% + 12px);
  right: auto;
  top: 50%;
}

.settings-icon-btn:hover .tooltip {
  display: block;
}


.level-settings-btn {
  position: relative;
  z-index: 10;
}

.main-menu > #settingsMenuBtn {
  position: absolute;
  z-index: 2;
  right: 20px;
  bottom: 20px;
  width: 128px;
  height: 128px;
}

/* Окно настроек */
.settings-card {
  max-width: 320px;
  padding: 26px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.settings-card h2 {
  font-family: 'Baloo 2', sans-serif;
  font-size: 29px;
  margin: 0;
  color: var(--ink);
}

.settings-volume {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.settings-label {
  font-weight: 700;
  color: #5a6b7d;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.slider-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-icon {
  font-size: 20px;
  color: #5a6b7d;
  flex-shrink: 0;
}

.volume-value {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  color: var(--ink);
  font-size: 20px;
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #dbe9f5, #c0d9ec);
  border: 2px solid #a8c5dc;
  outline: none;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, .12);
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff, #e5f1fb);
  border: 2px solid #8ab6d8;
  box-shadow: 0 3px 0 #4f7a99, 0 4px 8px rgba(0, 0, 0, .25);
  cursor: pointer;
}

input[type='range']::-moz-range-thumb {
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff, #e5f1fb);
  border: 2px solid #8ab6d8;
  box-shadow: 0 3px 0 #4f7a99, 0 4px 8px rgba(0, 0, 0, .25);
  cursor: pointer;
}

.settings-close-btn {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  background: linear-gradient(160deg, #7aaed8, #4a7ea8);
  color: #fff;
  border: none;
  border-radius: 11px;
  padding: 11px 20px;
  font-size: 19px;
  cursor: pointer;
  box-shadow: 0 4px 0 #2f5a78;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .25);
  transition: transform .12s ease, box-shadow .12s ease;
}

.settings-close-btn:hover {
  filter: brightness(1.08);
}

.settings-close-btn:active {
  transform: translateY(3px);
  box-shadow: none;
}

/* Окно магазина */
.shop-card {
  max-width: 420px;
  width: min(420px, calc(100% - 24px));
  box-sizing: border-box;
  padding: 26px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  max-height: 88vh;
  overflow-y: auto;
}

.shop-card h2 {
  font-family: 'Baloo 2', sans-serif;
  font-size: 29px;
  margin: 0;
  color: var(--ink);
}

.shop-balance {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(160deg, #fff3c4, #ffe08a);
  border: 2px solid #e0b84c;
  border-radius: 12px;
  padding: 7px 16px;
  box-shadow: 0 3px 0 #b8943a;
}

.shop-balance-label {
  font-weight: 800;
  color: #7a5b12;
  font-size: 15px;
}

.shop-balance-value {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  color: #5c4208;
  font-size: 22px;
}

.shop-items {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f4f8fc;
  border: 2px solid #dbe7f2;
  border-radius: 14px;
  padding: 10px 12px;
  min-width: 0;
  overflow: hidden;
}

.shop-item-img {
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 10px;
  background: #e8f1f8;
  font-size: 11px;
  line-height: 1.2;
  color: #6b7c8e;
  overflow: hidden;
}

.shop-item-info {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-align: left;
}

.shop-item-name {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.shop-item-desc {
  font-size: 12px;
  line-height: 1.35;
  color: #6b7c8e;
  margin-top: 2px;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.shop-item-price {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  color: #a87b1a;
  font-size: 16px;
  margin-top: 4px;
}

.shop-buy-btn {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  background: linear-gradient(160deg, #5fd39a, #2fa870);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 3px 0 #1f7a52;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  flex-shrink: 0;
}

.shop-buy-btn:active {
  transform: translateY(3px);
  box-shadow: none;
}

.shop-buy-btn.disabled {
  background: linear-gradient(160deg, #c6d2dc, #9fb2c0);
  box-shadow: 0 3px 0 #75899a;
  cursor: not-allowed;
  filter: grayscale(.4);
}

.shop-item-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
  position: relative;
  z-index: 1;
  background: #f4f8fc;
}

.shop-ad-btn {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  background: linear-gradient(160deg, #5aa7f0, #2f7fd0);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 3px 0 #1f5f9e;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  flex-shrink: 0;
}

.shop-ad-btn:active {
  transform: translateY(3px);
  box-shadow: none;
}

.shop-ad-btn.disabled {
  background: linear-gradient(160deg, #c6d2dc, #9fb2c0);
  box-shadow: 0 3px 0 #75899a;
  cursor: not-allowed;
  filter: grayscale(.4);
}

/* Узкая карточка (телефон, RU-тексты длинные): товар перестраивается в сетку —
   иконка + текст сверху, кнопки на всю ширину снизу в ряд.
   Текст получает всю ширину карточки и уже не уходит под кнопки. */
@media (max-width: 440px) {
  .shop-card {
    width: calc(100% - 20px);
    padding: 20px 14px 18px;
    gap: 14px;
  }

  .shop-item {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-areas:
      'img info'
      'actions actions';
    gap: 10px 12px;
    align-items: start;
  }

  .shop-item-img {
    grid-area: img;
  }

  .shop-item-info {
    grid-area: info;
  }

  .shop-item-name {
    font-size: 17px;
  }

  .shop-item-actions {
    grid-area: actions;
    width: 100%;
    flex-direction: row;
    gap: 8px;
    background: transparent;
  }

  .shop-item-actions .shop-buy-btn,
  .shop-item-actions .shop-ad-btn {
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
    padding: 10px 8px;
  }
}

/* Дебаг-кнопка: добавить монеты для теста магазина (убрать перед релизом) */
.debug-add-coins-btn {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  background: linear-gradient(160deg, #ffd76a, #f0a832);
  color: #5c4208;
  border: 2px solid #d99a1f;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 3px 0 #b98218;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}

.debug-add-coins-btn:active {
  transform: translateY(3px);
  box-shadow: none;
}

/* Кнопка магазина в боковой колонне */
.shop-btn {
  position: relative;
  cursor: pointer;
  width: 85px;
  height: 85px;
  background: transparent;
  border: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .35));
  transition: transform .15s ease, filter .15s ease;
}

.shop-btn > img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.shop-btn:hover {
  transform: translateY(-2px);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45)) brightness(1.1);
}

.shop-btn:active {
  transform: translateY(2px);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .35));
}

/* Тултип кнопки магазина */
.shop-btn .tooltip {
  display: none;
  position: absolute;
  left: calc(100% + 12px);
  transform: translateY(-50%);
  top: 50%;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}

.shop-btn .tooltip img {
  display: block;
  max-width: min(160px, 80vw);
  max-height: min(160px, 60vh);
  width: auto;
  height: auto;
  border-radius: 11px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.shop-btn:hover .tooltip,
.shop-btn:focus-visible .tooltip {
  display: block;
}

/* Полупрозрачный фон для подсказок левой колонки (видно на тёмных фонах) */
.side-actions .tooltip {
  background: rgba(255, 255, 255, 0.55);
  padding: 5px 7px;
  border-radius: 12px;
}

/* ==================== ПРЕМИУМ-ЭФФЕКТЫ (из tile-premium-sound.html) ==================== */

/* --- Эффект ВЫБОРА плитки: пульс + кольцо --- */
.tile.selecting {
  animation: selectPulse 340ms cubic-bezier(.2, .8, .3, 1) forwards;
  z-index: 5;
}
@keyframes selectPulse {
  0% { transform: scale(1); filter: brightness(1); }
  35% { transform: scale(1.18); filter: brightness(1.5) saturate(1.3); box-shadow: 0 0 0 0 rgba(243, 198, 107, .6), 0 10px 20px rgba(0, 0, 0, .5); }
  100% { transform: scale(.3); filter: brightness(2) saturate(0.6); opacity: 0; }
}
.select-ring {
  position: absolute;
  left: 50%; top: 50%;
  width: 70px; height: 70px;
  margin: -35px 0 0 -35px;
  border-radius: 18px;
  border: 3px solid #ffe8a3;
  box-shadow: 0 0 18px rgba(255, 232, 163, .85), inset 0 0 10px rgba(255, 232, 163, .5);
  pointer-events: none;
  animation: selectRing 420ms ease-out forwards;
}
@keyframes selectRing {
  0% { transform: scale(.85); opacity: 1; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* --- Шлейф частиц: плитка «летит» от поля к лотку --- */
.flying-tile {
  position: fixed;
  z-index: 50;
  font-size: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px; height: 100px;
  pointer-events: none;
  filter: drop-shadow(0 0 14px rgba(243, 198, 107, .75));
  background: transparent;
}
.flying-tile-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.trail-dot {
  position: fixed;
  z-index: 49;
  width: 7px; height: 7px;
  border-radius: 50%;
  pointer-events: none;
}

/* --- Приземление в слот лотка --- */
.slot.landed {
  animation: slotLand 260ms cubic-bezier(.3, 1.6, .4, 1);
}
@keyframes slotLand {
  0% { transform: scale(.4); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* --- Усиленное разрушение комбо: схлопывание + лучи/осколки/искры --- */
.slot.destroying {
  animation: comboCollapse 520ms cubic-bezier(.36, .07, .19, .97) forwards;
  z-index: 6;
}
@keyframes comboCollapse {
  0% { transform: scale(1) rotate(0deg); filter: brightness(1) saturate(1); }
  20% { transform: scale(1.4) rotate(-5deg); filter: brightness(2.2) saturate(1.8); box-shadow: 0 0 50px 18px rgba(243, 198, 107, .65); }
  50% { transform: scale(.8) rotate(10deg); filter: brightness(2.6) saturate(2.2); }
  100% { transform: scale(0) rotate(40deg); filter: brightness(3) saturate(0); opacity: 0; }
}
.shard {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 3px;
  left: 50%; top: 50%;
  pointer-events: none;
}
.spark {
  position: absolute;
  left: 50%; top: 50%;
  width: 5px; height: 5px;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 10px 3px currentColor;
}
.ray {
  position: absolute;
  left: 50%; top: 50%;
  width: 2px; height: 70px;
  margin-left: -1px; margin-top: -35px;
  pointer-events: none;
  transform-origin: center;
  opacity: 0;
  animation: rayBurst 460ms ease-out forwards;
}
@keyframes rayBurst {
  0% { opacity: 0; transform: rotate(var(--angle)) scaleY(.3); }
  30% { opacity: .9; transform: rotate(var(--angle)) scaleY(1); }
  100% { opacity: 0; transform: rotate(var(--angle)) scaleY(1.3); }
}
.shockring {
  position: absolute;
  left: 50%; top: 50%;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  border: 2px solid #ffe8a3;
  pointer-events: none;
  animation: ring 540ms ease-out forwards;
}
@keyframes ring {
  0% { width: 10px; height: 10px; margin: -5px 0 0 -5px; opacity: 1; border-width: 3px; }
  100% { width: 150px; height: 150px; margin: -75px 0 0 -75px; opacity: 0; border-width: 1px; }
}
.popup {
  position: absolute;
  left: 50%; top: -8px;
  transform: translate(-50%, 0);
  font-weight: 800; font-size: 15px;
  color: #ffe8a3;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .6);
  pointer-events: none;
  animation: popUp 750ms ease-out forwards;
}
@keyframes popUp {
  0% { opacity: 0; transform: translate(-50%, 4px) scale(.7); }
  25% { opacity: 1; transform: translate(-50%, -4px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -30px) scale(1); }
}

/* --- Вспышка на весь экран при комбо --- */
.screen-flash {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 40;
  background:
    radial-gradient(circle at var(--fx) var(--fy), rgba(255, 244, 214, .55), transparent 18%),
    radial-gradient(circle at var(--fx) var(--fy), rgba(243, 198, 107, .5), transparent 48%);
  opacity: 0;
  animation: flashFade 520ms ease-out forwards;
}

/* ============================================================
   ЗАГРУЗОЧНЫЙ ОВЕРЛЕЙ (показывается до готовности DOM и SDK)
   ============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #08131f;
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 18px;
  letter-spacing: .04em;
  transition: opacity .4s ease;
}
.loading-overlay.done {
  opacity: 0;
  pointer-events: none;
}
.loading-spinner {
  width: 46px;
  height: 46px;
  border: 4px solid rgba(255, 255, 255, .25);
  border-top-color: #ffd75e;
  border-radius: 50%;
  animation: loading-spin .9s linear infinite;
}
@keyframes loading-spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   ЗАПРЕТ ВЫДЕЛЕНИЯ И КОНТЕКСТНОГО МЕНЮ (на десктопе и мобильных)
   Требования Яндекс Игр 1.6.1.8 и  ️.6.2.7: при
   взаимодействии с внутренним полем игры не должно происходить
   выделения элементов интерфейса и открытия контекстного меню
   (ни при перетаскивании курсора, ни по правой кнопке мыши,
   ни при долгом нажатии)。
   ============================================================ */
html,
body,
.stage,
.stage *,
.game-area,
.board,
.tile,
.tile-image,
.tray,
.tray-wrap,
.slot,
.slot-image,
.controls,
.ctrl,
.header,
.score-panel,
.score-item,
.score-label,
.score-value,
.side-actions,
.level-menu-btn,
.settings-icon-btn,
.shop-btn,
.overlay,
.overlay-card,
.main-menu {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-user-drag: none !important;
  -khtml-user-drag: none !important;
}

@keyframes flashFade {
  0% { opacity: 0; }
  15% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- Тряска игровой зоны за комбо-стрик (1..3) --- */
.shake-1 { animation: shake1 300ms ease-in-out; }
.shake-2 { animation: shake2 360ms ease-in-out; }
.shake-3 { animation: shake3 430ms ease-in-out; }
@keyframes shake1 {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-5px, 3px); }
  50% { transform: translate(5px, -3px); }
  75% { transform: translate(-3px, -2px); }
}
@keyframes shake2 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  20% { transform: translate(-8px, 5px) rotate(-0.4deg); }
  40% { transform: translate(8px, -6px) rotate(0.4deg); }
  60% { transform: translate(-7px, -3px) rotate(-0.3deg); }
  80% { transform: translate(6px, 4px) rotate(0.3deg); }
}
@keyframes shake3 {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
  15% { transform: translate(-12px, 7px) rotate(-0.7deg) scale(1.008); }
  30% { transform: translate(12px, -8px) rotate(0.7deg) scale(1.008); }
  45% { transform: translate(-10px, -6px) rotate(-0.5deg) scale(1); }
  60% { transform: translate(10px, 7px) rotate(0.5deg) scale(1); }
  75% { transform: translate(-6px, -3px) rotate(-0.3deg) scale(1); }
}

/* --- Стрик-лейбл --- */
.streak-label {
  position: fixed;
  left: 50%; top: 16%;
  transform: translate(-50%, 0);
  font-size: 38px;
  font-weight: 800;
  letter-spacing: .05em;
  background: linear-gradient(90deg, #f3c66b, #ffe8a3);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 34px rgba(243, 198, 107, .6), 0 6px 24px rgba(0, 0, 0, .6);
  pointer-events: none;
  z-index: 60;
  opacity: 0;
  animation: streakPop 720ms cubic-bezier(.2, .9, .3, 1) forwards;
}
@keyframes streakPop {
  0% { opacity: 0; transform: translate(-50%, 14px) scale(.6) rotate(-4deg); }
  30% { opacity: 1; transform: translate(-50%, -4px) scale(1.15) rotate(1deg); }
  70% { opacity: 1; transform: translate(-50%, -4px) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -20px) scale(1) rotate(0deg); }
}

.win-reward {
  font-size: 19px;
  font-weight: 800;
  color: #b8860b;
  margin: -6px 0 14px;
  font-family: "Baloo 2", sans-serif;
}

/* ============================================================
   КОМПЕНСАЦИЯ МАСШТАБА СЦЕНЫ (переменная --ui-scale)
   UiManager.resize() задаёт .stage переменную --ui-scale = scale
   transform'а. На телефоне scale ≈ 0.45–0.65, и без компенсации
   дизайн-пиксели превращаются в нечитаемый/недосягаемый UI:
   подписи счёта 5–7px, тап-таргеты 27–39px (комфортный минимум — 44px),
   карточки оверлеев внутри сцены 120–180px. Формула
   max(базовое_значение, экранный_минимум / --ui-scale) держит
   минимальный ЭКРАННЫЙ размер; на десктопе (scale ≈ 1) нижний порог
   не срабатывает и всё остаётся в базовых размерах.
   ============================================================ */
.stage .score-label {
  font-size: max(12px, calc(13px / var(--ui-scale, 1)));
}

.stage .score-value {
  font-size: max(20px, calc(19px / var(--ui-scale, 1)));
}

.stage .combo-label {
  font-size: max(14px, calc(15px / var(--ui-scale, 1)));
}

.stage .combo-value {
  font-size: max(20px, calc(19px / var(--ui-scale, 1)));
}

.stage .ctrl,
.stage .ctrl.item {
  width: max(62px, calc(46px / var(--ui-scale, 1)));
  height: max(62px, calc(46px / var(--ui-scale, 1)));
}

.stage .ctrl.wand {
  width: max(70px, calc(52px / var(--ui-scale, 1)));
  height: max(70px, calc(52px / var(--ui-scale, 1)));
}

.stage .level-menu-btn,
.stage .settings-icon-btn,
.stage .shop-btn {
  width: max(85px, calc(46px / var(--ui-scale, 1)));
  height: max(85px, calc(46px / var(--ui-scale, 1)));
}

.stage .badge {
  width: max(29px, calc(24px / var(--ui-scale, 1)));
  height: max(29px, calc(24px / var(--ui-scale, 1)));
  font-size: max(14px, calc(12px / var(--ui-scale, 1)));
}

.stage .overlay-card {
  max-width: max(280px, calc(330px / var(--ui-scale, 1)));
}

.stage .overlay-card h2 {
  font-size: max(29px, calc(31px / var(--ui-scale, 1)));
}

.stage .overlay-card p {
  font-size: max(14px, calc(16px / var(--ui-scale, 1)));
}

.stage .overlay-card button {
  font-size: max(19px, calc(20px / var(--ui-scale, 1)));
  padding: max(12px, calc(14px / var(--ui-scale, 1))) max(22px, calc(26px / var(--ui-scale, 1)));
}

.stage .win-reward {
  font-size: max(19px, calc(20px / var(--ui-scale, 1)));
}

/* ============================================================
   АЛЬБОМНАЯ ОРИЕНТАЦИЯ (ДЕСКТОП И ШИРОКИЕ ЭКРАНЫ)
   Класс .is-portrait не установлен (см. UiManager.resize()):
   лоток переносится в шапку (layoutTray), очки/рекорд — тоже
   в шапку (#statsRow). Правила ниже действуют и на узких
   альбомных экранах (телефон в ландшафте); эталонная десктопная
   раскладка (заголовок/пилюли/кнопки слева, широкий лоток по
   центру шапки, бонусы снизу) задаётся в медиа (min-height: 560px)
   ниже.
   ============================================================ */

/* #statsRow переносится в шапку из UiManager.resize() */
.stage:not(.is-portrait) .header .stats {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  width: auto;
  order: 0;
  justify-content: flex-start;
  gap: 10px;
}

.stage:not(.is-portrait) .score-panel {
  order: 4;
  margin-left: 10px;
}

/* ============================================================
   ДЕСКТОП (мышь/точный указатель): кнопки Меню/Настройки/Магазин —
   В СТОЛБИК. У каждой кнопки своя всплывающая подсказка-картинка;
   в строчку подсказка одной кнопки ложилась на соседнюю и закрывала
   её, поэтому группа раскладывается вертикально: подсказки смотрят
   вбок и мешать друг другу не могут.
   На мобильных (тач) остаётся исходная строчка — см. базу выше.
   ============================================================ */
@media (hover: hover) and (pointer: fine) {
  .side-actions {
    flex-direction: column;
    justify-content: flex-start;
  }

  /* Кнопки столбика не сжимаются контейнером: в альбомной раскладке у
     контейнера фиксированная высота одной кнопки, а нижние кнопки
     свисают ниже шапки. */
  .side-actions > * {
    flex-shrink: 0;
  }

  .stage:not(.is-portrait) .side-actions {
    gap: 12px;
    /* Высота контейнера — ровно ОДНА кнопка. Так шапка остаётся
       компактной, а нижние кнопки столбика свисают вниз, в свободный
       «желоб» игровой зоны справа (там стоят бонусы, поле до края
       не доходит). Если столбик расти в потоке, шапка стала бы выше
       на ~200px, поле потеряло высоту и плитки заметно мельчали.
       Выражение совпадает с размером кнопок группы:
       см. .stage .level-menu-btn / .settings-icon-btn / .shop-btn. */
    height: max(85px, calc(46px / var(--ui-scale, 1)));
  }
}

.stage:not(.is-portrait) .side-actions {
  order: 1;
  /* Кнопки — рядом с надписью «Уровень» слева. */
  margin-left: 12px;
  gap: 12px;
}

/* Только иконка + значение — компактно, как на скриншотах-примерах */
.stage:not(.is-portrait) .score-label {
  display: none;
}

/* Тултипы правой группы кнопок открываются влево, не вылезая за край */
.stage:not(.is-portrait) .side-actions .tooltip {
  left: auto;
  right: calc(100% + 12px);
}

.stage:not(.is-portrait) .header .tray-wrap {
  order: 2;
  width: auto;
  height: auto;
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  padding: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
}
.stage:not(.is-portrait) .header .tray {
  flex-direction: row;
  width: auto;
  max-width: 100%;
  gap: 10px;
  padding: 10px 12px;
}
.stage:not(.is-portrait) .header .slot {
  flex: 0 0 auto;
  width: 62px;
  height: 62px;
  font-size: 30px;
}
.stage:not(.is-portrait) .header .stats {
  order: 3;
}

@media (min-height: 560px) {
/* ============================================================
   АЛЬБОМНАЯ/ДЕСКТОПНАЯ РАСКЛАДКА (по эталонному скриншоту)
   Порядок и позиции:
   - шапка содержит только широкий лоток по центру (position: static,
     поэтому h1/пилюли/кнопки групп позиционируются абсолютом ОТ СЦЕНЫ);
   - h1 «Уровень N» — в левом верхнем углу;
   - очки/рекорд/монеты — столбиком пилюль слева под заголовком
     ( UiManager.resize() переносит .score-panel внутрь #statsRow );
   - Меню/Настройки/Магазин — столбиком у левого края по центру высоты;
   - бонусы — компактным горизонтальным рядом по центру низа.
   Высота лотка и резерв под ряд бонусов подобраны так, чтобы поле
   сохраняло ~крайний размер плитки (~139 против 153 в старой раскладке).
   ============================================================ */
.stage:not(.is-portrait) .header {
  position: static;
  justify-content: center;
}

/* Заголовок — в левом верхнем углу сцены (сверху от него ничего нет) */
.stage:not(.is-portrait) .header h1 {
  position: absolute;
  left: 16px;
  top: 8px;
  transform: none;
  order: 0;
  flex: 0 0 auto;
  margin: 0;
  max-width: 30%;
  text-align: left;
  white-space: nowrap;
  font-size: 30px;
  z-index: 12;
}

/* Лоток по центру шапки: широкий (≈36% ширины сцены), слоты квадратные */
.stage:not(.is-portrait) .header .tray {
  flex-direction: row;
  width: min(36%, 640px);
  max-width: 100%;
  gap: 10px;
  padding: 10px 12px;
}
.stage:not(.is-portrait) .header .slot {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  height: auto;
  aspect-ratio: 1;
  font-size: 34px;
  border-radius: 12px;
}

/* Игровая зона: поле на всю ширину, снизу — резерв под компактный ряд бонусов */
.stage:not(.is-portrait) .game-area {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  padding: 4px 12px calc(12px + max(56px, calc(42px / var(--ui-scale, 1)))) 12px;
}

/* Пилюли счёта — столбиком слева под заголовком: очки, рекорд, монеты */
.stage:not(.is-portrait) .header .stats {
  position: absolute;
  left: 16px;
  top: 64px;
  right: auto;
  bottom: auto;
  width: auto;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
}
.stage:not(.is-portrait) .score-panel {
  order: 0;
  margin-left: 0;
}
/* Подписи счётчиков видны — как на эталоне («ОЧКИ: 0», «РЕКОРД: …», «МОНЕТЫ: …») */
.stage:not(.is-portrait) .score-label {
  display: inline;
}

/* Кнопки Меню/Настройки/Магазин — столбиком у левого края по центру высоты */
.stage:not(.is-portrait) .side-actions {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  order: 0;
  margin-left: 0;
  height: auto;
  flex-direction: column;
  justify-content: flex-start;
  gap: 12px;
  z-index: 12;
}
/* Подсказки открываются вправо: кнопки теперь у левого края сцены */
.stage:not(.is-portrait) .side-actions .tooltip {
  left: calc(100% + 12px);
  right: auto;
}

/* Бонусы — компактным горизонтальным рядом по центру низа */
.stage:not(.is-portrait) .controls {
  left: 0;
  right: 0;
  top: auto;
  bottom: 12px;
  transform: none;
  flex-direction: row;
  justify-content: center;
  gap: 12px;
}
/* Компактные размеры кнопок ряда: чем меньше их высота, тем больше
   остаётся высоты у поля (резерв в .game-area считается от тех же значений) */
.stage:not(.is-portrait) .ctrl,
.stage:not(.is-portrait) .ctrl.item {
  width: max(50px, calc(38px / var(--ui-scale, 1)));
  height: max(50px, calc(38px / var(--ui-scale, 1)));
}
.stage:not(.is-portrait) .ctrl.wand {
  width: max(56px, calc(42px / var(--ui-scale, 1)));
  height: max(56px, calc(42px / var(--ui-scale, 1)));
}
}

/* ============================================================
   ПОРТРЕТНАЯ ОРИЕНТАЦИЯ
   Класс .is-portrait ставится/снимается в UiManager.resize().
   Раскладка по скриншотам-примерам: шапка-строка (кнопки слева,
   заголовок по центру, монеты справа), лоток на всю ширину сразу
   под шапкой, поле ниже, очки/рекорд — у нижних краёв (.stats),
   контролы по центру низа. Геометрия потоковая (header в потоке),
   поэтому здесь — только компактные размеры, без смещений absolute.
   ============================================================ */

.stage.is-portrait .header {
  padding: 8px;
  gap: 8px;
}

/* Компактные кнопки: держат экранный минимум 46px через --ui-scale */
.stage.is-portrait .level-menu-btn,
.stage.is-portrait .settings-icon-btn,
.stage.is-portrait .shop-btn {
  width: max(74px, calc(46px / var(--ui-scale, 1)));
  height: max(74px, calc(46px / var(--ui-scale, 1)));
}

.stage.is-portrait .side-actions {
  gap: 8px;
}

.stage.is-portrait .header h1 {
  font-size: 22px;
  max-width: 30%;
}

/* Подписи счётчиков скрываются — остаются иконка+значение (как на примерах) */
.stage.is-portrait .score-label {
  display: none;
}

.stage.is-portrait .score-panel {
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
}

.stage.is-portrait .score-item {
  padding: 3px 9px;
}

.stage.is-portrait .game-area {
  /* Без левого «желоба» под боковую колонку (кнопки теперь в шапке):
     поле идёт почти в край экрана — как на скриншоте-примере. */
  padding: 10px 4px 112px;
  gap: 10px;
}

/* Лотку возвращаем внутренние поля по бокам: поле расширено до краёв,
   а лоток, как на примере, остаётся с небольшим отступом. */
.stage.is-portrait .tray-wrap {
  padding-inline: 8px;
}

.stage.is-portrait .tray {
  gap: 5px;
  padding: 7px;
  border-radius: 14px;
}



/* Портрет (мобильные): плитки визуально +20% */
.stage.is-portrait .tile {
  width: calc(var(--tile-size, 124px) * 1.2);
  height: calc(var(--tile-size, 124px) * 1.2);
  margin-left: calc(var(--tile-size, 124px) * -0.1);
  margin-top: calc(var(--tile-size, 124px) * -0.1);
  border-radius: calc(var(--tile-size, 124px) * .2124);
  font-size: calc(var(--tile-size, 124px) * .6384);
}

.stage.is-portrait .slot {
  border-radius: 12px;
}

.stage.is-portrait .stats {
  left: 12px;
  right: 12px;
  bottom: 12px;
}

.stage.is-portrait .controls {
  bottom: 12px;
  gap: 10px;
}

/* ============================================================
   СВЕРХШИРОКИЕ ЭКРАНЫ
   Столбик кнопок в альбомной раскладке свисает у правого края.
   На 3:1 и шире высота сцены падает (база упирается в MAX_WIDTH),
   из-за чего бонусы справа поднимаются вверх и могли бы накрыться
   нижними кнопками столбика — там кнопки группы уменьшаются,
   а на 7:2 и шире бонусы переезжают к нижнему краю.
   ============================================================ */
@media (hover: hover) and (pointer: fine) and (min-aspect-ratio: 3/1) {
  .stage:not(.is-portrait) .side-actions {
    gap: 8px;
    /* Столбик позиционируется абсолютом по центру сцены (см. альбомную
       раскладку) — контейнеру нужна только естественная высота кнопок. */
    height: auto;
  }

  .stage:not(.is-portrait) .side-actions .level-menu-btn,
  .stage:not(.is-portrait) .side-actions .settings-icon-btn,
  .stage:not(.is-portrait) .side-actions .shop-btn {
    /* 44px/ui-scale — минимальный тап-таргет на экране */
    width: max(64px, calc(44px / var(--ui-scale, 1)));
    height: max(64px, calc(44px / var(--ui-scale, 1)));
  }
}

@media (hover: hover) and (pointer: fine) and (min-aspect-ratio: 7/2) {
  .stage:not(.is-portrait) .controls {
    top: auto;
    bottom: 12px;
    transform: none;
  }
}

/* ============================================================
   ГЛАВНОЕ МЕНЮ: ПОРТРЕТНАЯ ОРИЕНТАЦИЯ
   Класс .main-menu.is-portrait ставится/снимается в UiManager.resize()
   точно так же, как .stage.is-portrait. На узком (портретном) холсте
   ширина базы меню падает (до MIN_MENU_WIDTH), поэтому логотип,
   старт-кнопка и кнопка настроек получают компактные размеры, чтобы
   всё влезало и выглядело пропорционально.
   ============================================================ */
.main-menu.is-portrait #gameTitle {
  width: 78%;
  margin-bottom: 26px;
}

.main-menu.is-portrait .start-button {
  padding: 22px 58px;
  font-size: 38px;
  border-radius: 26px;
}

.main-menu.is-portrait .start-button:hover {
  transform: translateY(-3px) scale(1.08);
}

.main-menu.is-portrait > #settingsMenuBtn {
  width: 92px;
  height: 92px;
  right: 14px;
  bottom: 14px;
}









/* ============================================================
   ПЕРЕКЛЮЧАТЕЛЬ ЯЗЫКА (п. 2.14 и п. 8.2.3 требований Яндекс Игр)
   1) кнопка в главном меню — быстрый переключатель RU ⇄ EN;
   2) селектор «Русский | English» в настройках (доступен и с уровня).
   Названия языков даны самими этими языками.
   ============================================================ */
.main-menu > #langBtn {
  position: absolute;
  z-index: 2;
  top: 24px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  border: 3px solid rgba(255, 255, 255, .85);
  border-radius: 999px;
  background: linear-gradient(160deg, rgba(28, 53, 80, .92), rgba(14, 30, 50, .92));
  color: #fff;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
  transition: transform .15s ease, filter .15s ease;
}

.main-menu > #langBtn:hover {
  transform: translateY(-3px) scale(1.05);
  filter: brightness(1.12);
}

.main-menu > #langBtn:active {
  transform: translateY(2px) scale(.98);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .3);
}

.lang-btn-ico {
  font-size: 30px;
}

.main-menu.is-portrait > #langBtn {
  top: 14px;
  left: 14px;
  gap: 8px;
  padding: 10px 20px;
  font-size: 24px;
}

/* Строка языка в карточке настроек: подпись слева, две кнопки справа */
.settings-lang {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lang-switch {
  display: flex;
  gap: 8px;
  flex: 0 1 auto;
}

button.lang-option {
  flex: 1 1 0;
  min-width: 0;
  padding: 11px 12px;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  border: 2px solid #a8c5dc;
  border-radius: 12px;
  background: linear-gradient(180deg, #eef6fc, #dcebf7);
  color: #33566f;
  box-shadow: 0 3px 0 rgba(31, 122, 82, .18);
  transition: transform .12s ease, background .12s ease, border-color .12s ease, color .12s ease;
}

button.lang-option:hover {
  transform: translateY(-2px);
  border-color: #6fb7e8;
}

button.lang-option.active {
  background: linear-gradient(160deg, #5fd39a, #2fa870);
  border-color: #1f7a52;
  color: #fff;
  box-shadow: 0 3px 0 #1f7a52;
}

button.lang-option:active {
  transform: translateY(2px);
  box-shadow: none;
}

/* Низкие экраны (телефон в альбомной ориентации, ~390px высоты): карточка
   настроек вместе со строкой выбора языка должна целиком помещаться в кадр,
   поэтому уменьшаем отступы, шрифты и ползунки. overflow — страховка на
   случай, если окно окажется ещё ниже. */
@media (max-height: 440px) {
  .settings-card {
    gap: 8px;
    padding: 12px 18px 14px;
    max-height: calc(100% - 8px);
    overflow-y: auto;
  }

  .settings-card h2 {
    font-size: 20px;
  }

  .settings-card .settings-label {
    font-size: 12px;
  }

  .settings-card .settings-volume {
    gap: 6px;
  }

  .settings-card .volume-value {
    font-size: 15px;
  }

  .settings-card input[type='range']::-webkit-slider-thumb,
  .settings-card input[type='range']::-moz-range-thumb {
    width: 22px;
    height: 22px;
  }

  .settings-card button.lang-option {
    padding: 8px 10px;
    font-size: 14px;
  }

  .settings-card .settings-close-btn {
    padding: 8px 18px;
    font-size: 16px;
  }
}