/* Стиль «стикеров»: толстый тёмный контур как у персонажей, плоские цвета, жёсткие тени */
:root {
  --ink: #1d1631;
  --cream: #fff7e6;
  --yellow: #ffd23f;
  --pink: #ff4f9a;
  --teal: #1fc8b0;
  --green: #5ee07a;
  --white: #ffffff;
  --line: 4px;
  --font: "Segoe UI Black", "Arial Black", "Rubik", "Nunito", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--ink); color: var(--ink);
  font-family: var(--font); font-weight: 900;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;   /* без «потянуть, чтобы обновить» на телефоне */
}
#bg, #gl, #game { position: fixed; inset: 0; display: block; }
#bg, #gl { pointer-events: none; }
/* Поднятый мем: выше панели (5) и корзины (6), ниже всплывающих наград (8) и окон; касания проходят сквозь слой */
#drag-layer { position: fixed; inset: 0; display: block; z-index: 7; pointer-events: none; }
.hidden { display: none !important; }
svg { width: 1.15em; height: 1.15em; fill: currentColor; flex-shrink: 0; }

/* ---------- Кнопки ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 10px auto 0; padding: 12px 24px;
  font: inherit; font-size: 19px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ink); background: var(--white);
  border: var(--line) solid var(--ink); border-radius: 18px;
  box-shadow: 0 6px 0 var(--ink);
  cursor: pointer; transition: transform .07s, box-shadow .07s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.btn:disabled { opacity: .45; }
.btn-lg { font-size: 24px; padding: 14px 34px; }
.btn-sm { font-size: 16px; padding: 7px 12px; margin: 0; border-width: 3px; box-shadow: 0 4px 0 var(--ink); border-radius: 14px; }
.btn-icon { width: 48px; height: 48px; padding: 0; margin: 0; border-width: 3px; border-radius: 14px; box-shadow: 0 4px 0 var(--ink); font-size: 22px; }
.btn-wide { width: min(340px, 100%); }
.menu-bottom { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.menu-bottom .btn { margin: 0; }

/* Магазин помощников */
.shop-bal { display: inline-flex; margin: 0 auto 12px; }
#shop-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 2px; }
.shop-item { display: flex; align-items: center; gap: 12px; text-align: left; background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 8px 10px; }
.shop-item > svg { width: 44px; height: 44px; flex-shrink: 0; }
.shop-item .info { flex: 1; min-width: 0; }
.shop-item b { font-size: 16px; text-transform: uppercase; }
.shop-item p { font-size: 12px; font-weight: 700; opacity: .7; line-height: 1.2; }
.shop-item .btn { margin: 0; padding: 8px 12px; font-size: 16px; gap: 4px; flex-shrink: 0; }
.shop-item .btn svg { width: 20px; height: 20px; }
.yellow { background: var(--yellow); }
.green { background: var(--green); }
.pink { background: var(--pink); }
.teal { background: var(--teal); }
.white { background: var(--white); }

/* ---------- Меню ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 45%, rgba(29,22,49,.82) 0%, rgba(29,22,49,.55) 55%, rgba(29,22,49,.2) 100%);
}
.topbar { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.topbar-right { display: flex; gap: 8px; }
.pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 999px;
  padding: 5px 14px 5px 6px; font-size: 20px; box-shadow: 0 4px 0 var(--ink);
}
.pill svg { width: 28px; height: 28px; }
.menu-center { display: flex; flex-direction: column; align-items: center; }

.logo { display: flex; flex-direction: column; align-items: center; margin-bottom: 4px; }
.logo-top {
  display: inline-block; background: var(--pink); color: #fff;
  font-size: clamp(22px, 6vw, 32px); letter-spacing: 3px; text-transform: uppercase;
  padding: 4px 18px; border: var(--line) solid var(--ink); border-radius: 14px;
  box-shadow: 0 5px 0 var(--ink); transform: rotate(-3deg); position: relative; z-index: 1;
}
.logo-main {
  display: inline-block; margin-top: -6px;
  font-size: clamp(72px, 22vw, 136px); line-height: 1; text-transform: uppercase;
  color: var(--yellow);
  text-shadow:
    4px 0 var(--ink), -4px 0 var(--ink), 0 4px var(--ink), 0 -4px var(--ink),
    3px 3px var(--ink), -3px 3px var(--ink), 3px -3px var(--ink), -3px -3px var(--ink),
    0 11px 0 var(--ink), 4px 11px 0 var(--ink), -4px 11px 0 var(--ink);
  animation: wobble 2.6s ease-in-out infinite;
}
@keyframes wobble { 0%, 100% { transform: rotate(-3deg) scale(1); } 50% { transform: rotate(2deg) scale(1.04); } }

.heroes { display: flex; align-items: flex-end; gap: 4px; margin: 6px 0 4px; height: 118px; }
.hero { width: 96px; height: 96px; animation: hop 1.1s ease-in-out infinite; transform-origin: 50% 100%; }
.hero:nth-child(2) { width: 118px; height: 118px; animation-delay: .18s; }
.hero:nth-child(3) { animation-delay: .36s; }
@keyframes hop {
  0%, 100% { transform: translateY(0) scale(1.06, .94); }
  40% { transform: translateY(-16px) scale(.96, 1.05); }
  60% { transform: translateY(-16px) scale(.97, 1.04); }
}

.btn-play { font-size: 30px; padding: 16px 48px; border-radius: 22px; box-shadow: 0 8px 0 var(--ink); animation: pulse 1.6s ease-in-out infinite; }
.btn-play:active { animation: none; transform: translateY(6px); box-shadow: 0 2px 0 var(--ink); }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.level-tag { margin-top: 14px; color: var(--cream); font-size: 17px; text-transform: uppercase; letter-spacing: 1px; }
.level-tag b { color: var(--yellow); }
/* Низкий экран (телефон боком): меню должно помещаться целиком — логотип меньше, без прыгающих героев,
   кнопки компактнее; если и так не влезает — прокрутка, а не обрезанные кнопки */
@media (max-height: 520px) {
  .screen { overflow-y: auto; justify-content: flex-start; gap: 6px; }
  .screen .menu-center { margin: auto 0; }
  .heroes { display: none; }
  .logo-top { font-size: 20px; padding: 2px 14px; }
  .logo-main { font-size: min(64px, 15vh); margin-top: -4px; }
  .btn-play { font-size: 24px; padding: 10px 38px; margin-top: 10px; box-shadow: 0 6px 0 var(--ink); }
  .level-tag { margin-top: 8px; font-size: 15px; }
  .menu-bottom .btn { padding-top: 8px; padding-bottom: 8px; }
}
.count { background: var(--ink); color: var(--cream); border-radius: 10px; padding: 2px 8px; font-size: 15px; margin-left: 4px; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  padding: 8px 10px 10px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--ink);
}
/* содержимое панели не шире игрового поля — на широких экранах стоит по центру над полем */
.hud-in { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 auto; }
.sticker { background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 rgba(0,0,0,.35); }
#target-card { display: flex; align-items: center; gap: 6px; padding: 3px 8px 3px 3px; flex: 0 1 auto; min-width: 0; max-width: 44%; outline: 3px solid var(--yellow); outline-offset: -1px; cursor: pointer; }
.target-frame { width: 52px; height: 52px; background: #e6f4ff; border-radius: 10px; flex-shrink: 0; overflow: hidden; }
#target-img { width: 100%; height: 100%; display: block; animation: bob 1.2s ease-in-out infinite; transform-origin: 50% 90%; }
.target-text { min-width: 0; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; opacity: .7; }
#hud .label { color: var(--cream); }
#target-card .label { color: var(--ink); }
#target-name { font-size: 14px; line-height: 1.05; }
#hud-center { text-align: center; }
#timer {
  display: flex; align-items: center; gap: 5px;
  background: var(--yellow); border: 3px solid var(--cream); border-radius: 999px;
  padding: 2px 12px 2px 8px; font-size: 26px; line-height: 1.1;
}
#timer svg { width: 22px; height: 22px; }
#timer.low { background: var(--pink); color: #fff; animation: beat .5s ease-in-out infinite; }
@keyframes beat { 50% { transform: scale(1.1); } }
#timer.shake { animation: shake .35s; }
@keyframes shake {
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
#hud-right { display: flex; gap: 6px; flex-shrink: 0; }
#btn-hint { white-space: nowrap; height: 44px; padding: 0 9px; gap: 4px; }
#btn-pause, #btn-hud-shop, #btn-hud-menu { width: 44px; height: 44px; }
#btn-hud-shop svg { width: 28px; height: 28px; }
/* до медиазапросов: иначе это правило перебивало уменьшенный значок на узких экранах и панель вылезала за край */
#btn-hint svg { width: 22px; height: 22px; }
@media (max-width: 480px) {
  #hud-right { gap: 4px; }
  #btn-pause, #btn-hud-shop, #btn-hud-menu, #btn-hint { width: 38px; height: 38px; }
  #btn-hud-shop svg, #btn-pause svg, #btn-hud-menu svg { width: 22px; height: 22px; }
  #btn-hint { width: auto; padding: 0 7px; }
  #hud .hud-in { gap: 5px; }
  /* узкий экран: в карточке цели только портрет, имя — на карточке уровня */
  #target-card { flex-shrink: 0; padding: 3px; max-width: none; }
  #target-card .target-text { display: none; }
  #btn-hint { font-size: 13px; padding: 0 6px; gap: 2px; }
  #btn-hint svg { width: 17px; height: 17px; }
  #hud-center .hud-sub { gap: 4px; }
  #hud-center .label, .hud-coins b { font-size: 10px; }
  #timer { font-size: 22px; padding: 2px 8px; }
  /* телефон: панель должна помещаться целиком (три портрета «трио», цена подсказки, пауза и меню) —
     без значка часов и без слова «Уровень» (номер уровня и монеты остаются) */
  #timer svg { display: none; }
  #hud-level [data-i18n] { display: none; }
  #hud-right { gap: 3px; }
  #hud .hud-in { gap: 4px; }
}
#target-name { font-size: 13px; }
@media (max-width: 380px) {
  #hud { gap: 5px; padding-left: 6px; padding-right: 6px; }
  #timer { font-size: 22px; padding: 2px 9px 2px 6px; }
  .target-frame { width: 44px; height: 44px; }
  #timer { padding: 2px 8px; }
  #btn-pause, #btn-hud-shop, #btn-hud-menu { width: 36px; height: 36px; }
  #btn-hint { height: 36px; padding: 0 5px; }
}

/* ---------- Карточки-окна ---------- */
/* Окно прокручивается, если карточка выше экрана (горизонтальный телефон): margin:auto у карточки
   центрирует её, когда места хватает, и даёт прокрутку с самого верха, когда не хватает */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: rgba(29, 22, 49, .6); padding: 34px 16px 20px;
}
.card {
  position: relative; width: 100%; max-width: 360px; flex-shrink: 0;
  background: var(--cream); border: var(--line) solid var(--ink); border-radius: 26px;
  box-shadow: 0 10px 0 var(--ink);
  padding: 44px 22px 26px; text-align: center; margin: auto;
}
/* Низкий экран (телефон боком): компактные карточки */
@media (max-height: 520px) {
  .card { padding: 34px 18px 18px; }
  .ribbon { font-size: 22px; padding: 4px 16px; top: -22px; }
  .portrait-wrap { width: 110px; height: 110px; }
  .big-name { font-size: 20px; }
  .find-label, .intro-meta { margin-top: 6px; margin-bottom: 6px; }
  .tip { margin-top: 6px; font-size: 13px; padding: 6px 10px; }
  .btn-lg { font-size: 20px; padding: 10px 26px; }
  .btn { margin-top: 8px; }
  .diff-chip { font-size: 16px; padding: 2px 12px; margin-bottom: 4px; }
  .boost-row { margin: 6px 0; }
  .boost-row svg { width: 40px; height: 40px; }
}
.intro-left, .intro-right { display: contents; }
/* Экран «Помощники» (первый запуск) на невысоком экране (375×667 и ниже): строки плотнее, «Понятно!» без прокрутки (FRESH-04) */
@media (max-height: 700px) {
  #boost-intro .card { padding-top: 38px; padding-bottom: 18px; }
  #boost-intro .boost-row { margin: 5px 0; gap: 10px; }
  #boost-intro .boost-row svg { width: 38px; height: 38px; padding: 4px; flex-shrink: 0; }
  #boost-intro .boost-row b { font-size: 15px; }
  #boost-intro .boost-row p { font-size: 12px; }
  #boost-intro .boost-foot { margin: 4px 0 0; font-size: 12px; }
}
/* Телефон боком: помощники — в две колонки; окно магнита — список цветов/форм ниже, кнопка «Отмена» на экране */
@media (max-height: 520px) and (orientation: landscape) {
  #boost-intro { padding: 24px 12px 10px; }
  #boost-intro .card { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; max-width: 720px; padding: 24px 16px 10px; }
  #boost-intro .boost-row { margin: 1px 0; }
  #boost-intro .boost-foot { margin: 2px 0 0; font-size: 11px; }
  #boost-intro #btn-boost-ok { padding-top: 8px; padding-bottom: 8px; font-size: 20px; }
  #boost-intro .boost-row svg { width: 32px; height: 32px; padding: 3px; border-width: 2px; border-radius: 10px; }
  #boost-intro .boost-row b { font-size: 13px; }
  #boost-intro .boost-row p { font-size: 11px; }
  #boost-intro .boost-foot, #boost-intro #btn-boost-ok { grid-column: 1 / -1; justify-self: center; }
  #boost-intro #btn-boost-ok { margin-top: 6px; }
  #magnet-pick .card { max-width: 620px; padding-top: 30px; padding-bottom: 12px; }
  #magnet-pick #swatches { max-height: calc(100vh - 190px); grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
  #magnet-pick .tabs { margin-bottom: 4px; }
  #magnet-pick .boost-foot { margin: 2px 0; }
}
/* Телефон боком: карточка уровня и экран победы — в две колонки, чтобы главная кнопка была видна без прокрутки.
   Уровень: портрет (или «трио») слева, всё остальное справа. Победа: награда слева, кнопки справа. */
@media (max-height: 520px) and (orientation: landscape) {
  #intro .card { display: flex; align-items: center; gap: 18px; max-width: 640px; padding-top: 30px; padding-bottom: 14px; }
  #intro .intro-left, #intro .intro-right { display: flex; flex-direction: column; align-items: center; min-width: 0; }
  #intro .intro-left { flex: 0 0 auto; max-width: 46%; }
  #intro .intro-right { flex: 1 1 auto; }
  #intro .boss-tag { font-size: 15px; padding: 2px 12px; margin: 0 0 4px; }
  #intro .diff-chip { font-size: 14px; margin-bottom: 4px; }
  #intro .intro-meta { margin: 0 0 4px; font-size: 11px; }
  #intro .mods { margin: 0 0 6px; gap: 4px; }
  #intro .portrait-wrap { width: min(110px, 26vh); height: min(110px, 26vh); }
  #intro .trio-big { gap: 6px; }
  #intro .trio-big .tf { width: min(64px, 16vh); height: min(64px, 16vh); }
  #intro .find-label { margin-top: 0; margin-bottom: 0; }
  #intro .big-name { font-size: 18px; }
  #intro .tip { margin-top: 4px; font-size: 12px; }
  /* наклейка «Новый мем!» над маленьким портретом, а не поверх него */
  #intro .new-tag { top: -12px; left: -14px; font-size: 10px; padding: 1px 6px; border-width: 2px; white-space: nowrap; }
  #win .card { display: grid; grid-template-columns: 1fr auto; column-gap: 18px; align-items: center; max-width: 600px; padding-top: 38px; }   /* лента сверху не наезжает на сумму */
  #win .card > * { grid-column: 1; }
  #win .card > #btn-double, #win .card > #btn-next { grid-column: 2; }
  #win .card > #btn-double { grid-row: 1 / span 2; align-self: end; }
  #win .card > #btn-next { grid-row: 3 / span 2; align-self: start; }
  #win .reward { font-size: 34px; margin: 0; }
  #win .balance { margin-bottom: 4px; }
}
.card-tall { max-width: 520px; max-height: calc(100% - 40px); display: flex; flex-direction: column; }
.pop { animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.5) rotate(-6deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
.ribbon {
  position: absolute; top: -26px; left: 50%; transform: translateX(-50%);   /* ровно, без наклона */
  white-space: nowrap; font-size: 28px; text-transform: uppercase; letter-spacing: 1px;
  padding: 6px 22px; border: var(--line) solid var(--ink); border-radius: 16px;
  box-shadow: 0 6px 0 var(--ink);
}
.ribbon.pink { color: #fff; }
.corner { position: absolute; top: -20px; right: -12px; z-index: 2; }
.card-tall { padding-top: 48px; }
.reward { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 40px; margin: 4px 0 6px; }
.reward svg { width: 44px; height: 44px; }
.portrait-wrap { width: 170px; height: 170px; margin: 0 auto; background: #e6f4ff; border: var(--line) solid var(--ink); border-radius: 22px; position: relative; }
.portrait-inner { width: 100%; height: 100%; overflow: hidden; border-radius: 18px; }
#intro-img { width: 100%; height: 100%; display: block; animation: bob 1.2s ease-in-out infinite; transform-origin: 50% 90%; }
/* покачивание на месте — не вылезает за рамку */
@keyframes bob { 0%, 100% { transform: rotate(-5deg) scale(1); } 50% { transform: rotate(5deg) scale(1.04, .97); } }
.big-name { font-size: 24px; margin: 0 0 2px; line-height: 1.1; }
.find-label { margin-top: 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; opacity: .6; }
.diff-chip {
  display: inline-block; font-size: 20px; text-transform: uppercase; letter-spacing: 1px;
  padding: 4px 16px; border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 4px 0 var(--ink);
  margin: 0 auto 8px;
}
.diff-chip.small { font-size: 13px; padding: 2px 10px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); margin: 0 0 0 4px; }
.intro-meta { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; opacity: .65; margin-bottom: 12px; }
.new-tag {
  position: absolute; top: 8px; left: -10px; transform: rotate(-10deg);
  background: var(--pink); color: #fff; font-size: 14px; text-transform: uppercase;
  padding: 3px 10px; border: 3px solid var(--ink); border-radius: 10px;
}

.tip {
  margin: 10px auto 0; max-width: 290px; font-size: 14px; line-height: 1.25;
  background: var(--yellow); border: 3px dashed var(--ink); border-radius: 14px; padding: 8px 12px;
}
.next-line { font-size: 14px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; }

#collection { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; overflow-y: auto; padding: 4px 2px 6px; touch-action: pan-y; }
.coll-item { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 4px 4px 6px; font-size: 11px; line-height: 1.1; }
.coll-item canvas { width: 100%; aspect-ratio: 1; display: block; }
.coll-item.locked { background: #d9d3e8; color: #6b6285; }

.mods { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: -4px 0 12px; }
.mod-chip {
  font-size: 13px; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 10px; border: 2px solid var(--ink); border-radius: 999px; box-shadow: 0 2px 0 var(--ink);
}
.balance { font-size: 14px; text-transform: uppercase; letter-spacing: .5px; opacity: .75; margin-bottom: 8px; }
.hud-sub { white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 2px; }
.hud-coins { display: inline-flex; align-items: center; gap: 3px; color: var(--yellow); opacity: 1; }
.hud-coins svg { width: 13px; height: 13px; }
.hud-coins b { font-size: 12px; }
/* Всплывающая подсказка: по центру между отступами 16 px (раньше left:50% + сдвиг давал ей только половину ширины
   экрана — на телефоне она становилась узкой и высокой, FRESH-03); касания проходят сквозь неё к полю,
   а окна (z-index 20) лежат поверх неё (FRESH-02) */
#toast {
  position: fixed; left: 16px; right: 16px; top: 84px; z-index: 18; margin: 0 auto; width: fit-content; pointer-events: none;
  display: flex; align-items: center; gap: 8px; max-width: 560px; text-align: left; line-height: 1.2;
  background: var(--yellow); border: var(--line) solid var(--ink); border-radius: 16px;
  box-shadow: 0 6px 0 var(--ink); padding: 10px 18px; font-size: 18px; text-transform: uppercase;
}
#toast svg { width: 26px; height: 26px; flex-shrink: 0; }
#toast.show { animation: toast-in .4s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes toast-in { from { transform: translateY(40px) scale(.7); opacity: 0; } }
@media (max-width: 480px) { #toast { font-size: 15px; padding: 8px 12px; } }

/* Корзина: сюда выкидывают мемов и завалы. Сквозь неё проходят касания — ловит их canvas */
#bin {
  position: fixed; z-index: 6; width: 64px; height: 64px; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--cream); color: var(--ink);
  border: var(--line) solid var(--ink); border-radius: 18px; box-shadow: 0 5px 0 var(--ink);
  transition: transform .12s, background .12s; opacity: .92;
}
#bin svg { width: 38px; height: 38px; }
#bin.hot { transform: scale(1.3) rotate(-8deg); background: var(--pink); color: #fff; opacity: 1; }
#bin.gulp { animation: gulp .35s; }
/* Награда из корзины — по центру поля */
#reward-pop {
  position: fixed; z-index: 8; pointer-events: none; opacity: 0;
  transform: translate(-50%, -50%) scale(.5);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--yellow); border: var(--line) solid var(--ink); border-radius: 18px;
  box-shadow: 0 6px 0 var(--ink); padding: 8px 18px;
  font: 900 30px var(--font); color: var(--ink); text-transform: uppercase;
}
#reward-pop .rp-row { display: flex; align-items: center; gap: 8px; }
#reward-pop svg { width: 38px; height: 38px; }
#reward-pop small { font-size: 13px; letter-spacing: 1px; opacity: .85; }
#reward-pop.big { background: var(--green); font-size: 38px; }
#reward-pop.big svg { width: 46px; height: 46px; }
#reward-pop.gift { background: var(--pink); color: #fff; font-size: 28px; padding: 12px 24px; }
#reward-pop.gift svg { width: 64px; height: 64px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 6px; }
#reward-pop.show { animation: reward-in 2.2s cubic-bezier(.2, 1.6, .4, 1) forwards; }
#reward-pop.show:not(.gift) { animation-duration: 1.1s; }
/* плашка «Подарок из корзины» тоже с классом .gift: без этого, когда show снимали, срабатывала анимация .gift
   (строка подарка на экране победы) и плашка появлялась второй раз */
#reward-pop:not(.show) { animation: none; }
@keyframes reward-in {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  30% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -60%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(.9); }
}
@keyframes gulp { 30% { transform: scale(1.35, .8); } 60% { transform: scale(.9, 1.15); } }

/* Помощники */
/* 6 помощников: на ПК в один ряд, на телефоне — два ряда по три, чтобы не упереться в корзину */
#boosts { position: fixed; z-index: 6; display: grid; grid-template-columns: repeat(6, 58px); gap: 8px; }
@media (max-width: 640px) {
  #boosts { grid-template-columns: repeat(3, 50px); gap: 7px; }
  .boost { width: 50px; height: 50px; border-radius: 14px; }
  .boost svg { width: 30px; height: 30px; }
}
.boost {
  position: relative; width: 58px; height: 58px; padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink);
  transition: transform .07s;
}
.boost svg { width: 36px; height: 36px; }
.boost:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.boost:disabled { opacity: .4; }
.boost .cnt {
  position: absolute; top: -9px; right: -9px; min-width: 24px; height: 24px; line-height: 20px;
  background: var(--pink); color: #fff; border: 2px solid var(--ink); border-radius: 999px; font-size: 13px; text-align: center;
}
.boost-row { display: flex; align-items: center; gap: 12px; text-align: left; margin: 10px 0; }
.boost-row svg { width: 48px; height: 48px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 5px; }
.boost-row b { font-size: 18px; text-transform: uppercase; }
.boost-row p { font-size: 13px; font-weight: 700; line-height: 1.25; opacity: .8; margin-top: 2px; }
.boost-foot { font-size: 13px; opacity: .7; margin-top: 6px; }
.gift {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin: 2px auto 6px;
  background: #fff; border: 3px dashed var(--pink); border-radius: 14px; padding: 6px 12px; font-size: 16px;
  animation: pop .45s cubic-bezier(.2, 1.6, .4, 1);
}
.gift svg { width: 28px; height: 28px; }
.gift .gift-items { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.gift .gift-row { display: flex; align-items: center; gap: 8px; text-align: left; }
.gift > span:empty { display: none; }
.gift .gift-item { background: var(--cream); border: 2px solid var(--ink); border-radius: 8px; padding: 2px; }
/* окошко «что выпало» поверх экрана победы (окна — z-index 20) */
#reward-pop.gift { z-index: 30; }
#timer.frozen { background: #80deea; }
.tabs { display: flex; gap: 8px; justify-content: center; margin: 0 0 12px; }
.tab {
  font: inherit; font-size: 15px; text-transform: uppercase; cursor: pointer;
  padding: 6px 16px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; color: var(--ink);
}
.tab.on { background: var(--pink); color: #fff; box-shadow: 0 3px 0 var(--ink); }
.swatch.shape i { background: #e6f4ff; position: relative; overflow: hidden; }
.swatch.shape canvas { width: 44px; height: 44px; display: block; }
.swatch.shape i svg { position: absolute; }
#swatches { max-height: 46vh; overflow-y: auto; padding: 2px 2px 8px; }
#swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 12px; margin: 4px 0 8px; }
.swatch {
  display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: none;
  font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; padding: 0;
}
.swatch i {
  width: 52px; height: 52px; border-radius: 50%; border: 4px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  display: flex; align-items: center; justify-content: center; transition: transform .08s;
}
.swatch:active i { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.swatch:disabled { cursor: default; }
.swatch:disabled i { background: #cfd8dc !important; box-shadow: none; }
.swatch i svg { width: 24px; height: 24px; }

#fake-ad { background: #000; z-index: 50; }
#fake-ad .card { max-width: 260px; padding: 26px; }
.ad-ico { width: 64px; height: 64px; }

/* ---------- «Найди троих»: три портрета вместо одного ---------- */
.trio { display: flex; gap: 4px; flex-shrink: 0; }
.trio .tf { position: relative; width: 44px; height: 44px; background: #e6f4ff; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; }
.trio .tf canvas { width: 100%; height: 100%; display: block; animation: bob 1.2s ease-in-out infinite; transform-origin: 50% 90%; }
.trio .tf.done::after {
  content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(94, 224, 122, .78); color: #fff; font-size: 28px; font-weight: 900; text-shadow: 0 2px 0 var(--ink);
}
.trio .tf.done canvas { animation: none; }
.trio-big { justify-content: center; gap: 10px; margin: 0 auto; }
.trio-big .tf { width: 92px; height: 92px; border: var(--line) solid var(--ink); border-radius: 18px; }
/* телефон: три (или два) портрета в верхней панели должны оставлять место паузе и меню */
@media (max-width: 480px) { #trio-row { gap: 3px; } #trio-row .tf { width: 26px; height: 26px; border-radius: 7px; } }
@media (max-width: 380px) { #trio-row .tf { width: 22px; height: 22px; } .trio-big .tf { width: 72px; height: 72px; } }
@media (max-width: 340px) { #trio-row .tf { width: 20px; height: 20px; } #hint-cost svg { display: none; } }
@media (max-height: 520px) { .trio-big .tf { width: 72px; height: 72px; } }

/* ---------- Босс-уровень ---------- */
.boss-tag {
  display: inline-block; margin: 0 6px 8px; padding: 4px 16px; font-size: 20px; text-transform: uppercase; letter-spacing: 2px;
  background: #e53935; color: #fff; border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 4px 0 var(--ink);
  animation: beat 1s ease-in-out infinite;
}
.card.boss { background: #fff3e0; box-shadow: 0 10px 0 var(--ink), 0 0 0 6px #e53935, 0 0 40px 10px rgba(229, 57, 53, .6); }
#hud-level.boss { color: #ff5252 !important; }

/* «Найди лишнего»: на портрете — мем толпы со знаком «не равно» */
.target-frame.odd, .portrait-wrap.odd { position: relative; }
.target-frame.odd::after, .portrait-wrap.odd::after {
  content: "≠"; position: absolute; right: 1px; bottom: 1px; width: 26px; height: 26px; line-height: 24px; text-align: center;
  background: #ef5350; color: #fff; border: 2px solid var(--ink); border-radius: 50%; font-size: 20px; font-weight: 900;
}
.portrait-wrap.odd::after { width: 48px; height: 48px; line-height: 44px; font-size: 36px; right: -12px; bottom: -12px; border-width: 3px; }
#target-card.pop { animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }

/* ---------- Все уровни (только для проверки на своём компьютере) ---------- */
.levels-note { font-size: 12px; opacity: .65; margin: 0 0 8px; }
#levels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; overflow-y: auto; padding: 4px 2px 6px; touch-action: pan-y; }
.lvl-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 70px; padding: 6px 4px;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); cursor: pointer; font: inherit; color: var(--ink);
}
.lvl-btn b { font-size: 22px; line-height: 1; }
.lvl-btn span { font-size: 10px; line-height: 1.1; text-transform: uppercase; border-radius: 6px; padding: 2px 5px; color: #fff; border: 2px solid var(--ink); }
.lvl-btn.boss { background: #fff3e0; border-color: #e53935; }
.lvl-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- Телефон вертикально: помощники и корзина в полосе под полем ---------- */
body.toolbar #boosts { grid-template-columns: repeat(6, 40px); gap: 6px; }
body.toolbar .boost { width: 40px; height: 40px; border-radius: 12px; box-shadow: 0 3px 0 var(--ink); border-width: 2.5px; }
body.toolbar .boost svg { width: 25px; height: 25px; }
body.toolbar .boost .cnt { top: -7px; right: -7px; min-width: 19px; height: 19px; line-height: 15px; font-size: 11px; }
body.toolbar #bin { width: 48px; height: 48px; border-radius: 14px; box-shadow: 0 3px 0 var(--ink); }
body.toolbar #bin svg { width: 30px; height: 30px; }
@media (max-width: 350px) { body.toolbar #boosts { grid-template-columns: repeat(6, 36px); gap: 4px; } body.toolbar .boost { width: 36px; height: 36px; } }

/* Прокрутка списков в окнах (коллекция, магазин) не передаётся странице Яндекса вокруг игры */
.overlay, #collection, #levels-grid, #shop-list { overscroll-behavior: contain; }

/* Совсем узкие телефоны (320 px, iPhone SE 1-го поколения): панель ужимается ещё на ~20 px */
@media (max-width: 340px) {
  #hud { padding-left: 4px; padding-right: 4px; }
  #hud .hud-in { gap: 3px; }
  #hud-right { gap: 3px; }
  #btn-pause, #btn-hud-shop, #btn-hud-menu { width: 32px; height: 32px; }
  #btn-hint { padding: 0 4px; height: 32px; }
  .target-frame { width: 40px; height: 40px; }
  #timer { font-size: 20px; padding: 1px 7px; }
  .hud-coins { display: none; }   /* монеты видны на карточке победы и в магазине */
}

/* ---------- Обучение на учебном уровне ---------- */
.help-btn { font-size: 26px; font-weight: 900; color: var(--ink); line-height: 1; }
#coach { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
/* подсветка: прямоугольник с огромной тенью затемняет всё вокруг себя */
#coach-hole { position: fixed; border-radius: 16px; border: 4px solid var(--yellow);
  box-shadow: 0 0 0 9999px rgba(29, 22, 49, .55); transition: all .25s ease; animation: coach-pulse 1.2s ease-in-out infinite; }
#coach-hole.off { box-shadow: none; border-color: transparent; animation: none; }
@keyframes coach-pulse { 50% { border-color: #fff; } }
#coach-hand { position: fixed; width: 58px; height: 58px; margin: -8px 0 0 -24px; filter: drop-shadow(0 4px 0 rgba(0,0,0,.35)); }
/* второй палец «разведения» — та же рука, повёрнутая кончиком к первой */
/* рука пальцем вниз (шаг «помощники»): кончик пальца — в точке left/top */
#coach-hand.down { margin: -50px 0 0 -34px; transform: rotate(180deg); filter: drop-shadow(0 -4px 0 rgba(0,0,0,.35)); }
#coach-hand2 { position: fixed; width: 58px; height: 58px; margin: -50px 0 0 -34px; transform: rotate(180deg); filter: drop-shadow(0 -4px 0 rgba(0,0,0,.35)); }
/* мышь: колёсико «прокручивается» вверх, над мышью мигает стрелка */
#coach-mouse { position: fixed; width: 64px; height: 96px; margin: -48px 0 0 -32px; filter: drop-shadow(0 4px 0 rgba(0,0,0,.35)); }
#coach-mouse .m-wheel { animation: m-wheel .7s ease-in-out infinite; }
#coach-mouse .m-arrow { animation: m-arrow .7s ease-in-out infinite; }
@keyframes m-wheel { 0% { transform: translateY(4px); } 60% { transform: translateY(-3px); } 100% { transform: translateY(4px); } }
@keyframes m-arrow { 0%, 100% { opacity: .25; transform: translateY(2px); } 50% { opacity: 1; transform: translateY(-2px); } }
#coach-bubble { position: fixed; left: 50%; transform: translateX(-50%); width: min(440px, calc(100vw - 24px));
  padding: 12px 14px; pointer-events: auto; text-align: center; border-width: 4px; box-shadow: 0 6px 0 var(--ink); }
#coach-text { font-size: 17px; font-weight: 800; line-height: 1.25; margin-bottom: 8px; }
.coach-btns { display: flex; flex-direction: column-reverse; align-items: center; gap: 4px; }   /* в разметке «Пропустить» идёт первой — показываем её снизу */
.coach-btns .btn { margin: 0; }
/* «Пропустить обучение» — неприметная ссылка под главной кнопкой «Дальше» */
#btn-coach-skip { background: none; border: 0; box-shadow: none; padding: 2px 6px; font-size: 12px; font-weight: 700; color: var(--ink); opacity: .55; text-decoration: underline; text-transform: none; }
#btn-coach-skip:hover { opacity: .8; }
#btn-coach-next { min-width: 150px; }
/* своя анимация: общая .pop сбивала центрирование облачка (translateX) */
#coach-bubble.bump { animation: coach-bump .3s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes coach-bump { from { transform: translateX(-50%) scale(.85); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
/* телефон боком: облачко обучения шире и ниже, чтобы закрывать меньше поля */
@media (max-height: 520px) and (orientation: landscape) {
  #coach-bubble { width: min(600px, calc(100vw - 24px)); padding: 8px 12px; border-width: 3px; box-shadow: 0 4px 0 var(--ink); }
  #coach-text { font-size: 14px; line-height: 1.2; margin-bottom: 6px; }
  #btn-coach-next { font-size: 13px; padding: 6px 12px; }
}
/* на учебном уровне: подсказка, магазин и помощники только показываются (не тратят монеты и помощников),
   вместо замершего таймера — «∞»: время на обучение не ограничено */
body.tutorial #btn-hint, body.tutorial #btn-hud-shop, body.tutorial .boost { pointer-events: none; }
body.tutorial #timer-num { font-size: 0; }
body.tutorial #timer-num::after { content: '∞'; font-size: 30px; line-height: 1; }

/* Пасхалка «Легенда мемов» */
#legend .card { max-width: 400px; }
.legend-big { font-size: 64px; line-height: 1; margin: 6px 0 4px; }
#legend .tip { margin: 8px auto 14px; }   /* auto — плашка по центру под заголовком */

/* «Рассмотреть мема»: нажали на карточку «Найди:» вверху — мем крупно, чтобы разглядеть оттенок */
#peek .card { max-width: 420px; }
#peek .find-label { margin: 0 0 6px; }
.peek-wrap { width: min(260px, 62vw, 42vh); aspect-ratio: 1; margin: 0 auto 8px; background: #e6f4ff; border: var(--line) solid var(--ink); border-radius: 26px; overflow: hidden; position: relative; }
.peek-wrap.odd { overflow: visible; }
#peek-img { width: 100%; height: 100%; display: block; animation: bob 1.2s ease-in-out infinite; transform-origin: 50% 90%; }
#peek .trio-big { margin: 0 auto 8px; }
#peek .big-name { margin: 0 0 4px; }
#peek .tip { margin: 0 0 10px; }
/* телефон боком: портрет слева, текст и кнопка справа */
@media (max-height: 520px) and (orientation: landscape) {
  #peek .card { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto 1fr; column-gap: 18px; align-items: center; max-width: 620px; padding-top: 24px; padding-bottom: 14px; text-align: left; }
  #peek .find-label { grid-column: 2; grid-row: 1; }
  #peek .peek-wrap, #peek .trio-big { grid-column: 1; grid-row: 1 / 5; width: min(220px, 62vh); margin: 0; }
  #peek .big-name { grid-column: 2; grid-row: 2; }
  #peek .tip { grid-column: 2; grid-row: 3; }
  #peek #btn-peek-go { grid-column: 2; grid-row: 4; justify-self: start; }
}


/* Верхняя панель — в цвет темы уровня (переменные --hud-a/--hud-b ставит game.js): градиент, лёгкие диагональные полоски
   и тёмная кромка снизу, как у доски с полем */
#hud {
  background:
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, .06) 0 14px, rgba(255, 255, 255, 0) 14px 28px),
    linear-gradient(var(--hud-a, var(--ink)), var(--hud-b, var(--ink)));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25);
}
#hud .hud-sub { opacity: 1; color: #fff8e1; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
/* рамка вокруг поля — фон страницы в цвет темы; полоса помощников на ПК оформлена как верхняя панель (зеркально) */
body {
  background:
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, .05) 0 14px, rgba(255, 255, 255, 0) 14px 28px),
    var(--hud-a, var(--ink));
}
body.strip::after {
  content: ''; position: fixed; left: 0; right: 0; bottom: 0; height: 60px; z-index: 1; pointer-events: none;
  background:
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, .06) 0 14px, rgba(255, 255, 255, 0) 14px 28px),
    linear-gradient(var(--hud-b, var(--ink)), var(--hud-a, var(--ink)));
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, .25);
}
