
/* ===== Мобильный UX: блокируем свайпы навигации, pull-to-refresh, выделение ===== */
/* Yandex Games требования: п. 1.6.2.7 (без выделения), п. 1.10.2 (без браузерного скролла) */
html, body {
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
  margin: 0;
  padding: 0;
  /* Фиксируем body — pull-to-refresh на iOS не сработает без скролла на body */
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Запрещаем выделение текста и iOS-callout (превью при долгом тапе) */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
body {
  /* На body запрещены все жесты браузера — скролл только во внутренних контейнерах */
  touch-action: none;
}
/* Скроллящиеся области (галерея, категории, палитра) — разрешаем нормальный скролл внутри */
#gallery-grid, #categories-bar, #palette,
.modal, .modal-content,
#screen-gallery, #screen-myworks, #screen-menu, #screen-game {
  touch-action: pan-y pan-x;
  overscroll-behavior: contain;
}
/* Поля ввода (если есть) — разрешаем выделение и взаимодействие */
input, textarea, select, [contenteditable="true"] {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
  touch-action: manipulation;
}
/* Кнопки — мгновенный отклик при тапе */
button, .btn, .cat-chip, .gal-card, .pal-item, .menu-btn, .zoom-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, opacity 0.1s ease, filter 0.1s ease;
}
button:active, .btn:active, .cat-chip:active, .gal-card:active,
.pal-item:active, .menu-btn:active, .zoom-btn:active {
  transform: scale(0.95);
  filter: brightness(0.92);
}
/* Пастельный «пластилиновый» стиль */
:root {
  --bg-wall-1: #b9e3c8;
  --bg-wall-2: #a1d7b4;
  --bg-wood-1: #e8c9a0;
  --bg-wood-2: #d5ac7d;
  --panel: #ffffff;
  --panel-soft: #fff5f8;
  --fg: #3a2a1a;
  --fg-dim: #8a6e57;
  --accent: #ff6fa3;
  --accent-dark: #e04a86;
  --accent-soft: #ffd6e4;
  --accent-2: #ffc08a;
  --ok: #6dd186;
  --err: #ff5577;
  --grid: #d8cfbf;
  --grid-bold: #9c8a6d;
  --paper: #fbf5e5;
  --frame-1: #e0a56a;
  --frame-2: #b57540;
  --shadow-pink: 0 6px 0 rgba(224,74,134,.18), 0 12px 30px rgba(224,74,134,.18);
  --shadow-soft: 0 4px 0 rgba(140,100,70,.15), 0 10px 24px rgba(140,100,70,.15);
  --radius: 22px;
}
.theme-light { }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overscroll-behavior: none; }
body {
  font-family: "Nunito","Comfortaa",-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;
  color: var(--fg);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg-wall-1);
}
/* #app: используем svh (small viewport) — не учитывает динамические браузерные панели и Yandex плашку */
#app {
  position: relative; width: 100vw;
  height: 100vh;       /* fallback для старых браузеров */
  height: 100dvh;      /* динамический — учитывает скрытие баров */
  height: 100svh;      /* малый viewport — БЕЗ браузерных панелей и без YG плашки */
  overflow: hidden;
  /* Учитываем safe-area для iOS notch/home-indicator */
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-sizing: border-box;
}
.hidden { display: none !important; }

#app::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    linear-gradient(180deg, transparent 0%, transparent 72%, var(--bg-wood-1) 72%, var(--bg-wood-2) 100%),
    repeating-linear-gradient(90deg, var(--bg-wall-1) 0 14px, var(--bg-wall-2) 14px 28px);
}
#app::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 28%;
  background: repeating-linear-gradient(90deg, transparent 0 120px, rgba(120,80,40,.18) 120px 122px);
  z-index: 0; pointer-events: none;
}
.screen, .modal, #loader, #toast { position: relative; z-index: 1; }

#loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg-wall-1); z-index: 100;
}
.spinner {
  width: 54px; height: 54px; border-radius: 50%;
  border: 6px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite; margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loader-text { color: var(--fg-dim); font-size: 14px; font-weight: 700; }

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.menu-header { text-align: center; padding: 40px 20px 8px; }
.menu-header .logo { color: var(--accent); margin-bottom: 4px; filter: drop-shadow(0 4px 0 rgba(224,74,134,.2)); }
.menu-header h1 {
  /* Адаптивный: min(5vw, 5vh) — берём меньшую сторону, не растёт безумно в ландшафте */
  font-size: clamp(20px, min(5vw, 5vh), 36px);
  margin: 4px 0 2px; font-weight: 900; letter-spacing: -.5px;
  color: var(--fg); text-shadow: 0 3px 0 rgba(255,255,255,.6);
  padding: 0 16px;
  line-height: 1.15;
}
.menu-header h1 .accent { color: var(--accent); }
.tagline { margin: 0; color: var(--fg-dim); font-size: 15px; font-weight: 700; }
.menu-header::after {
  content: ""; display: block; margin: 12px auto 0;
  width: 180px; height: 10px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 10px, transparent 10px 20px);
  border-radius: 999px; opacity: .6;
}
.menu-buttons {
  flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding: 24px 22px; max-width: 420px; width: 100%; margin: 0 auto;
  justify-content: center;
  box-sizing: border-box;
  /* Запас снизу под Yandex Games плашку контролов (~90px) и safe-area */
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  overflow: visible;
  min-height: 0;
}
.menu-footer { text-align: center; padding: 14px; color: var(--fg); font-size: 14px; font-weight: 700; }
.menu-footer #stats-total::before { content: "🧵 "; }

.btn {
  appearance: none; border: none; cursor: pointer;
  background: var(--panel); color: var(--fg);
  padding: 16px 22px; border-radius: 999px;
  font-size: 17px; font-weight: 800; font-family: inherit;
  transition: transform .1s, box-shadow .2s, background .2s;
  box-shadow: var(--shadow-soft); position: relative;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(140,100,70,.2); }
.btn.primary {
  background: linear-gradient(180deg, #ff8cb6 0%, var(--accent) 100%);
  color: #fff; box-shadow: var(--shadow-pink);
}
.btn.primary:hover { background: linear-gradient(180deg, #ff9bc0 0%, #ff7fac 100%); }
.btn.small {
  font-size: 14px; padding: 11px 16px;
  background: rgba(255,255,255,.6); box-shadow: none; color: var(--fg-dim);
}
.btn.small:hover { background: var(--panel); color: var(--fg); }
.btn-icon {
  width: 48px; height: 48px; border: none; cursor: pointer;
  background: var(--panel); color: var(--accent);
  border-radius: 50%; font-size: 22px; font-weight: 900;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-soft); transition: transform .1s;
}
.btn-icon:hover { transform: translateY(-2px); }
.btn-icon:active { transform: translateY(1px); }

.top-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid rgba(255,255,255,.9);
}
.top-bar h2 { margin: 0; font-size: 20px; font-weight: 900; color: var(--fg); }
.game-bar { background: var(--panel); box-shadow: 0 3px 12px rgba(160,110,80,.15); border-bottom: none; }
.game-bar .game-title {
  flex: 1; text-align: center; font-weight: 800; font-size: 16px;
  color: var(--accent-dark);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.game-header-actions { display: flex; gap: 6px; }

.categories { display: flex; gap: 10px; overflow-x: auto; padding: 14px 16px; scrollbar-width: none; }
.categories::-webkit-scrollbar { display: none; }
.cat-chip {
  appearance: none; border: none; cursor: pointer;
  background: var(--panel); color: var(--fg-dim);
  padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 800; white-space: nowrap;
  box-shadow: var(--shadow-soft); font-family: inherit;
}
.cat-chip.active {
  background: linear-gradient(180deg, #ff8cb6, var(--accent));
  color: #fff; box-shadow: var(--shadow-pink);
}
.gallery-grid {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px; padding: 12px;
  align-items: start;
  align-content: start;
}
.gal-card {
  background: linear-gradient(180deg, var(--frame-1), var(--frame-2));
  border-radius: 18px; padding: 10px; cursor: pointer;
  transition: transform .15s; box-shadow: var(--shadow-soft);
  position: relative;
}
.gal-card::before {
  content: ""; position: absolute; inset: 4px; border-radius: 14px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.3); pointer-events: none;
}
.gal-card:hover { transform: translateY(-3px) rotate(-1deg); }
.gal-card canvas {
  width: 100%; aspect-ratio: 1/1; border-radius: 10px;
  background: var(--paper); image-rendering: pixelated;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.15);
}
.gal-card .gal-name {
  font-size: 14px; margin-top: 8px; font-weight: 800;
  color: #fff; text-align: center; text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.gal-card .gal-meta {
  font-size: 11px; color: rgba(255,255,255,.85);
  text-align: center; font-weight: 700;
}
.gal-card .gal-progress {
  position: absolute; top: 10px; right: 10px;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 800;
  padding: 4px 9px; border-radius: 999px;
  box-shadow: 0 2px 0 rgba(224,74,134,.3);
}
.gal-card .gal-done {
  position: absolute; top: 10px; right: 10px;
  background: var(--ok); color: #fff;
  font-size: 14px; font-weight: 900;
  padding: 2px 8px; border-radius: 999px;
  box-shadow: 0 2px 0 rgba(40,130,70,.3);
}

#canvas-wrap { flex: 1 1 0; min-height: 0; position: relative; overflow: hidden; touch-action: none; padding: 18px; }
#canvas-wrap::before {
  content: ""; position: absolute;
  top: 18px; left: 18px; right: 18px; bottom: 18px;
  border-radius: 18px; padding: 14px;
  background: linear-gradient(135deg, var(--frame-1) 0%, var(--frame-2) 100%);
  box-shadow:
    0 8px 0 rgba(110,70,30,.25),
    0 16px 32px rgba(110,70,30,.25),
    inset 0 2px 4px rgba(255,255,255,.35),
    inset 0 -3px 6px rgba(0,0,0,.15);
  pointer-events: none; z-index: 1;
}
#canvas {
  position: absolute;
  top: 36px; left: 36px; right: 36px; bottom: 36px;
  width: calc(100% - 72px); height: calc(100% - 72px);
  display: block; border-radius: 8px;
  background: var(--paper);
  box-shadow: inset 0 3px 10px rgba(80,50,20,.25);
  z-index: 2;
}
#zoom-controls {
  position: absolute; right: 24px; bottom: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 10;
}
#progress-bar {
  position: absolute; left: 28px; right: 28px; top: 28px;
  height: 10px;
  background: rgba(255,255,255,.5);
  border: 2px solid #fff;
  border-radius: 999px; overflow: hidden; z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
}
#progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffb6d1, var(--accent), var(--accent-dark));
  width: 0; transition: width .25s;
}

#palette {
  display: flex; gap: 10px; overflow-x: auto;
  padding: 14px 12px;
  background: var(--panel);
  scrollbar-width: thin;
  box-shadow: 0 -4px 16px rgba(160,110,80,.15);
  border-top: 3px solid var(--accent-soft);
}
.pal-item {
  flex: 0 0 auto; width: 64px; height: 82px;
  border-radius: 16px; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4px;
  background: transparent;
  border: 3px solid transparent;
  transition: transform .12s, border-color .15s;
  font-family: inherit;
}
.pal-item:active { transform: scale(.94); }
.pal-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-4px);
}
.pal-item.done { opacity: .35; filter: grayscale(.5); }
.pal-item .sw {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 16px;
  color: rgba(0,0,0,.75);
  box-shadow:
    inset 0 -4px 8px rgba(0,0,0,.2),
    inset 0 3px 4px rgba(255,255,255,.35),
    0 3px 6px rgba(0,0,0,.2);
  position: relative;
}
.pal-item .sw::after {
  content: ""; position: absolute; inset: 6px; border-radius: 50%;
  border: 1px dashed rgba(0,0,0,.15);
}
.pal-item .sw.dark { color: rgba(255,255,255,.95); }
.pal-item .num { font-size: 11px; font-weight: 800; margin-top: 4px; color: var(--fg-dim); }
.pal-item .rem {
  position: absolute; top: -2px; right: -2px;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 800;
  padding: 2px 7px; border-radius: 999px;
  min-width: 20px; text-align: center;
  box-shadow: 0 2px 0 rgba(224,74,134,.3);
}
.pal-item.done .rem { background: var(--ok); }

.modal {
  position: fixed; inset: 0;
  background: rgba(58,42,26,.45);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; animation: fadeIn .2s ease;
  /* Padding снизу больше — запас под YG плашку, чтобы кнопки модалки не обрезались */
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px)) 20px;
  overflow-y: auto;
}
.modal-content {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 28px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow-pink), 0 20px 60px rgba(60,30,20,.4);
  /* Используем svh — малый viewport, гарантирует что не уйдём под YG плашку */
  max-height: calc(100svh - 100px);
  overflow-y: auto;
  border: 3px solid #fff;
}
.modal h2 { margin: 0 0 16px; font-size: 24px; font-weight: 900; color: var(--fg); text-align: center; }
.modal .btn { width: 100%; margin-top: 10px; }
.modal label.row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 2px dashed var(--accent-soft);
  font-size: 15px; font-weight: 700;
}
.modal label.row input, .modal label.row select {
  background: var(--panel-soft); color: var(--fg);
  border: 2px solid var(--accent-soft);
  padding: 8px 10px; border-radius: 10px;
  font-size: 14px; font-family: inherit; font-weight: 700;
}
.modal .tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.modal .tab {
  flex: 1; background: var(--panel-soft); color: var(--fg-dim);
  padding: 10px; border-radius: 12px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 800; font-family: inherit;
}
.modal .tab.active { background: linear-gradient(180deg, #ff8cb6, var(--accent)); color: #fff; }
#leaderboard-list .lb-row,
#achievement-list .ach-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 8px;
  border-bottom: 2px dashed var(--accent-soft);
  font-size: 14px;
}
.lb-row .lb-rank { width: 32px; font-weight: 900; color: var(--accent); }
.lb-row .lb-name { flex: 1; font-weight: 700; }
.lb-row .lb-score { font-weight: 900; color: var(--accent-dark); }
.lb-row.me { background: var(--accent-soft); border-radius: 12px; }
.ach-row .ach-icon { font-size: 28px; width: 44px; text-align: center; }
.ach-row .ach-name { flex: 1; font-weight: 800; }
.ach-row .ach-desc { font-size: 12px; color: var(--fg-dim); font-weight: 600; }
.ach-row.locked { opacity: .35; filter: grayscale(1); }
.celebrate #complete-stats { padding: 14px 0; text-align: center; color: var(--fg); font-size: 15px; font-weight: 700; }
.celebrate #complete-stats > div { margin: 6px 0; }
.celebrate h2 { text-align: center; font-size: 34px; color: var(--accent); font-weight: 900; text-shadow: 0 2px 0 rgba(255,255,255,.6); }

.toast {
  position: absolute; bottom: 140px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel); color: var(--fg);
  padding: 12px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 800;
  box-shadow: var(--shadow-soft); z-index: 60;
  animation: fadeIn .2s ease;
  border: 2px solid var(--accent-soft);
}

@media (min-width: 720px) {
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .pal-item { width: 72px; height: 92px; }
  .pal-item .sw { width: 52px; height: 52px; font-size: 18px; }
}

/* ПЛАВАЮЩАЯ КНОПКА ВИДЕО-НАГРАДЫ */
.btn-earn-float {
  position: absolute; right: 16px; bottom: 20px; width: 72px;
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 0; font-family: inherit;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.25));
  transition: transform .15s; z-index: 20;
  animation: earnBob 2.5s ease-in-out infinite;
}
.btn-earn-float:hover { transform: scale(1.08); }
.btn-earn-float:active { transform: scale(.94); animation: none; }
@keyframes earnBob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
.earn-icon {
  width: 64px; height: 64px;
  background: linear-gradient(145deg,#5ecef6 0%,#3aaee0 60%,#2288c4 100%);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center; font-size: 30px;
  box-shadow: 0 6px 0 #1a6fa0, 0 10px 20px rgba(40,120,180,.35), inset 0 2px 4px rgba(255,255,255,.4);
  border: 3px solid rgba(255,255,255,.7);
}
.earn-label {
  background: linear-gradient(90deg,#ff6fa3,#ffaa3c); color:#fff;
  font-size:13px; font-weight:900; padding:4px 12px; border-radius:999px;
  box-shadow:0 3px 0 rgba(200,80,80,.3); white-space:nowrap;
}

/* ===== ПАЛИТРА — ГОРИЗОНТАЛЬНЫЕ КРУЖКИ ===== */
#palette {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 4px 10px 10px;
  background: var(--panel);
  scrollbar-width: none;
  box-shadow: 0 -4px 16px rgba(160,110,80,.15);
  border-top: 3px solid var(--accent-soft);
  flex-shrink: 0;
}
#palette::-webkit-scrollbar { display: none; }
.pal-item {
  flex: 0 0 auto; min-width: 50px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer;
  padding: 4px 3px 5px;
  border-radius: 14px;
  border: 3px solid transparent;
  transition: transform .12s, border-color .15s, background .15s;
  font-family: inherit;
}
.pal-item:active { transform: scale(.92); }
.pal-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-5px);
}
.pal-item.done { opacity: .35; filter: grayscale(.6); }
.pal-badge {
  font-size: 11px; font-weight: 900;
  color: var(--fg-dim); line-height: 1;
  text-align: center; min-width: 28px;
}
.pal-item.active .pal-badge { color: var(--accent-dark); }
.pal-item.done .pal-badge { color: var(--ok); }
.pal-circle {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 19px;
  color: rgba(0,0,0,.72);
  box-shadow:
    inset 0 -4px 8px rgba(0,0,0,.2),
    inset 0 3px 5px rgba(255,255,255,.35),
    0 3px 6px rgba(0,0,0,.18);
}
.pal-circle.dark { color: rgba(255,255,255,.95); }


/* ПЛАСТИЛИНОВАЯ ФАКТУРА КРУЖКОВ ПАЛИТРЫ */
.pal-circle {
  position: relative;
  box-shadow:
    inset 0 -6px 12px rgba(0,0,0,.28),
    inset 0 5px 10px rgba(255,255,255,.55),
    0 5px 10px rgba(0,0,0,.22),
    0 2px 4px rgba(0,0,0,.12) !important;
}
.pal-circle::before {
  content: "";
  position: absolute;
  top: 6px; left: 9px;
  width: 13px; height: 8px;
  background: rgba(255,255,255,.55);
  border-radius: 50%;
  transform: rotate(-35deg);
  filter: blur(2px);
  pointer-events: none;
}
.pal-circle::after {
  content: "";
  position: absolute;
  bottom: 7px; right: 8px;
  width: 7px; height: 5px;
  background: rgba(0,0,0,.12);
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}

/* МОДАЛКА ВЫБОРА РЕЖИМА МЕТОК */
.modal-choice { text-align: center; }
.choice-hint { color: var(--fg-dim); font-size: 15px; font-weight: 700; margin: 0 0 22px; }
.choice-buttons { display: flex; gap: 14px; justify-content: center; }
.btn-choice {
  flex: 1; max-width: 150px;
  background: var(--panel-soft);
  border: 3px solid var(--accent-soft);
  border-radius: 22px;
  padding: 22px 12px 18px;
  cursor: pointer; font-family: inherit;
  transition: transform .15s, border-color .15s, box-shadow .15s;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.btn-choice:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-pink);
}
.btn-choice:active { transform: scale(.94); }
.btn-choice-num .choice-icon { background: #e8f4ff; color: #4a90d9; }
.btn-choice-let .choice-icon { background: var(--accent-soft); color: var(--accent); }
.choice-icon {
  font-size: 24px; font-weight: 900;
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.btn-choice .choice-label { font-size: 15px; font-weight: 900; color: var(--fg); }
.btn-choice .choice-sub { font-size: 12px; color: var(--fg-dim); font-weight: 700; }

/* ===== МОНЕТА-КАРТИНКА ===== */
.coin-img {
  width: 28px; height: 28px;
  vertical-align: middle;
  display: inline-block;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
}
.coin-img-sm {
  width: 22px; height: 22px;
  vertical-align: middle;
  display: inline-block;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.25));
}
/* В хедере галереи — чуть крупнее */
.top-bar .coin-img { width: 32px; height: 32px; }
/* Плавающая кнопка */
.earn-label .coin-img-sm { width: 26px; height: 26px; }

/* ===== МОНЕТА-ИКОНКИ ===== */
.coin-header {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  border: 2px solid rgba(255,210,0,.7);
  box-shadow: 0 2px 6px rgba(180,140,0,.4);
}
.earn-coin-img {
  width: 60px; height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,215,0,.85);
  box-shadow:
    0 0 0 3px rgba(255,180,0,.2),
    0 6px 20px rgba(200,150,0,.4);
}

/* Убрать фон монеты через multiply */
.earn-coin-img {
  mix-blend-mode: multiply;
}
.coin-header {
  mix-blend-mode: multiply;
  background: transparent;
}

/* AD-картинка не круглая — убираем border-radius и обводку только для неё */
.earn-icon img[src*="ad.png"].earn-coin-img {
  border-radius: 14px;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  mix-blend-mode: normal;
}

/* ===== AD-КНОПКА: убрать розовый фон, увеличить картинку на 40% ===== */
.btn-earn-float {
  width: auto;
}
.earn-coin-img {
  width: 84px !important;
  height: 84px !important;
}
.earn-label {
  background: none !important;
  box-shadow: none !important;
  padding: 2px 4px !important;
  color: #fff !important;
  font-size: 20px !important;
  font-weight: 900 !important;
  text-shadow: 0 2px 6px rgba(0,0,0,.7), 0 0 10px rgba(0,0,0,.5);
}

/* Убрать всё лишнее, оставить только большую AD картинку */
.earn-label { display: none !important; }
.earn-coin-img {
  width: 80px !important;
  height: 80px !important;
}
.btn-earn-float {
  width: auto !important;
  right: 20px !important;
  bottom: 24px !important;
}
/* Мобилка: ещё чуть меньше + поднимаем выше пагинации */
@media (max-width: 700px) {
  .earn-coin-img {
    width: 68px !important;
    height: 68px !important;
  }
  .btn-earn-float {
    right: 12px !important;
    bottom: 80px !important;
  }
}
.earn-icon {
  width: auto !important;
  height: auto !important;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}

/* ===== ФОНОВЫЕ ДЕКОРАЦИИ ===== */
body {
  background-image: url('assets/fon_igra.webp?v=1777184667');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
}

/* Боковые узоры (только на широких экранах где есть место) */
@media (min-width: 520px) {
  body::before, body::after {
    content: "";
    position: fixed;
    top: 0; bottom: 0;
    width: 180px;
    pointer-events: none;
    z-index: 0;
    background-repeat: repeat-y;
    background-size: 180px auto;
    background-position: top center;
    opacity: 1;
  }
  body::before {
    left: 0;
    background-image: url('assets/bok-left.png?v=1777104114');
  }
  body::after {
    right: 0;
    background-image: url('assets/bok-right.png?v=1777104115');
  }
}

/* Уголки */
@media (min-width: 720px) {
  #app::before, #app::after {
    content: "";
    position: fixed;
    width: 180px; height: 180px;
    background-image: url('assets/corn.png?v=1777058581');
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 1;
  }
  #app::before { top: 0;    left: 0;  }
  #app::after  { bottom: 0; right: 0; transform: rotate(180deg); }
}

/* Основной контейнер приложения — прозрачный, чтобы фон проглядывал */
#app {
  background: transparent;
}

/* Скрыть уголки — от них одна транспарентная клетчатая каша */
#app::before, #app::after {
  display: none !important;
  content: none !important;
}


/* DECO SCATTER — декорации по обоям, только на десктопе */
@media (min-width: 720px) {
  html::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 1;
    background-image:
      url('assets/deco-corner-flowers.png?v=1777104219'),
      url('assets/deco-scissors.png?v=1777104219'),
      url('assets/deco-yarn-ball.png?v=1777104219'),
      url('assets/deco-button-thread.png?v=1777104219'),
      url('assets/deco-scissors.png?v=1777104219'),
      url('assets/deco-corner-flowers.png?v=1777104219');
    background-position:
      26% 6%,
      72% 8%,
      24% 90%,
      74% 80%,
      28% 50%,
      70% 50%;
    background-repeat: no-repeat;
    background-size: 130px, 100px, 115px, 85px, 80px, 95px;
  }
}
@media (min-width: 1200px) {
  html::before {
    background-position:
      22% 5%,
      76% 7%,
      20% 90%,
      78% 82%,
      24% 45%,
      74% 47%;
    background-size: 160px, 125px, 140px, 100px, 100px, 120px;
  }
}
@media (min-width: 1600px) {
  html::before {
    background-position:
      19% 5%,
      78% 6%,
      18% 88%,
      80% 82%,
      22% 48%,
      77% 45%;
    background-size: 190px, 150px, 170px, 120px, 120px, 145px;
  }
}
/* /DECO */

/* На мобилках боковушек нет */
@media (max-width: 519px) {
  body::before, body::after { display: none !important; }
}

/* На широких — пошире */
@media (min-width: 1200px) {
  body::before, body::after { width: 220px !important; }
}

/* ===== ИГРОВОЙ ЭКРАН: пластилин вместо черноты ===== */
#canvas-wrap {
  position: relative;
  background-image: url('assets/fon_igra.webp?v=1777184667');
  background-size: 500px auto;
  background-repeat: repeat;
  border: 6px solid #c89166;
  border-radius: 14px;
  box-shadow:
    inset 0 0 0 3px #e8b884,
    inset 0 0 24px rgba(0,0,0,.15),
    0 6px 24px rgba(0,0,0,.2);
  margin: 10px;
}

/* Канва поверх фона, но прозрачная — декор просвечивает */
#canvas-wrap > canvas {
  position: relative;
  z-index: 1;
}

/* Пластилиновые уголки по углам */
#canvas-wrap::before, #canvas-wrap::after {
  content: "";
  position: absolute;
  width: 180px; height: 180px;
  background-image: url('assets/corn.png?v=1777058581');
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 0;
  opacity: .9;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.2));
}
#canvas-wrap::before { top: 8px;    left: 8px;  }
#canvas-wrap::after  { bottom: 8px; right: 8px; transform: rotate(180deg); }


/* DECO SCATTER — декорации по обоям, только на десктопе */
@media (min-width: 720px) {
  html::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 1;
    background-image:
      url('assets/deco-corner-flowers.png?v=1777104219'),
      url('assets/deco-scissors.png?v=1777104219'),
      url('assets/deco-yarn-ball.png?v=1777104219'),
      url('assets/deco-button-thread.png?v=1777104219'),
      url('assets/deco-scissors.png?v=1777104219'),
      url('assets/deco-corner-flowers.png?v=1777104219');
    background-position:
      26% 6%,
      72% 8%,
      24% 90%,
      74% 80%,
      28% 50%,
      70% 50%;
    background-repeat: no-repeat;
    background-size: 130px, 100px, 115px, 85px, 80px, 95px;
  }
}
@media (min-width: 1200px) {
  html::before {
    background-position:
      22% 5%,
      76% 7%,
      20% 90%,
      78% 82%,
      24% 45%,
      74% 47%;
    background-size: 160px, 125px, 140px, 100px, 100px, 120px;
  }
}
@media (min-width: 1600px) {
  html::before {
    background-position:
      19% 5%,
      78% 6%,
      18% 88%,
      80% 82%,
      22% 48%,
      77% 45%;
    background-size: 190px, 150px, 170px, 120px, 120px, 145px;
  }
}
/* /DECO */

/* На мобилках — уголки поменьше */
@media (max-width: 600px) {
  #canvas-wrap::before, #canvas-wrap::after {
    width: 90px; height: 90px;
  }
}

/* Зум-кнопки и прогресс-бар должны быть поверх */
#zoom-controls, #progress-bar { z-index: 3; }

/* ===== ИГРОВОЙ ЭКРАН: пластилин вместо черноты ===== */
#canvas-wrap {
  position: relative;
  background-image: url('assets/fon_igra.webp?v=1777184667');
  background-size: 500px auto;
  background-repeat: repeat;
  border: 6px solid #c89166;
  border-radius: 14px;
  box-shadow:
    inset 0 0 0 3px #e8b884,
    inset 0 0 24px rgba(0,0,0,.15),
    0 6px 24px rgba(0,0,0,.2);
  margin: 10px;
}

/* Канва поверх фона, но прозрачная — декор просвечивает */
#canvas-wrap > canvas {
  position: relative;
  z-index: 1;
}

/* Пластилиновые уголки по углам */
#canvas-wrap::before, #canvas-wrap::after {
  content: "";
  position: absolute;
  width: 180px; height: 180px;
  background-image: url('assets/corn.png?v=1777058581');
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 0;
  opacity: .9;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.2));
}
#canvas-wrap::before { top: 8px;    left: 8px;  }
#canvas-wrap::after  { bottom: 8px; right: 8px; transform: rotate(180deg); }


/* DECO SCATTER — декорации по обоям, только на десктопе */
@media (min-width: 720px) {
  html::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 1;
    background-image:
      url('assets/deco-corner-flowers.png?v=1777104219'),
      url('assets/deco-scissors.png?v=1777104219'),
      url('assets/deco-yarn-ball.png?v=1777104219'),
      url('assets/deco-button-thread.png?v=1777104219'),
      url('assets/deco-scissors.png?v=1777104219'),
      url('assets/deco-corner-flowers.png?v=1777104219');
    background-position:
      26% 6%,
      72% 8%,
      24% 90%,
      74% 80%,
      28% 50%,
      70% 50%;
    background-repeat: no-repeat;
    background-size: 130px, 100px, 115px, 85px, 80px, 95px;
  }
}
@media (min-width: 1200px) {
  html::before {
    background-position:
      22% 5%,
      76% 7%,
      20% 90%,
      78% 82%,
      24% 45%,
      74% 47%;
    background-size: 160px, 125px, 140px, 100px, 100px, 120px;
  }
}
@media (min-width: 1600px) {
  html::before {
    background-position:
      19% 5%,
      78% 6%,
      18% 88%,
      80% 82%,
      22% 48%,
      77% 45%;
    background-size: 190px, 150px, 170px, 120px, 120px, 145px;
  }
}
/* /DECO */

/* На мобилках — уголки поменьше */
@media (max-width: 600px) {
  #canvas-wrap::before, #canvas-wrap::after {
    width: 90px; height: 90px;
  }
}

/* Зум-кнопки и прогресс-бар должны быть поверх */
#zoom-controls, #progress-bar { z-index: 3; }

/* ===== УЗКАЯ ИГРОВАЯ ОБЛАСТЬ ПО ЦЕНТРУ ===== */
#canvas-wrap {
  max-width: 760px !important;
  margin: 8px auto !important;
  width: calc(100% - 16px) !important;
  flex: 0 1 auto !important;
  aspect-ratio: 1 / 1;
  max-height: calc(100vh - 200px);

  /* Чистый тёмно-тёплый тон вместо cream, чтобы вышивка не тонула */
  background: rgba(0, 0, 0, 0.12) !important;
  background-image: none !important;

  border: 6px solid #b58863 !important;
  border-radius: 14px !important;
  box-shadow:
    inset 0 0 0 3px #e2b88c,
    inset 0 0 28px rgba(0, 0, 0, .2),
    0 6px 20px rgba(0, 0, 0, .25) !important;
}

/* Убираем уголки — с прозрачными краями они выглядят плохо */
#canvas-wrap::before, #canvas-wrap::after {
  display: none !important;
}

/* Прогрессбар прилипает к верху рамки */
#progress-bar {
  top: 8px !important;
  left: 70px !important;
  right: 70px !important;
  width: auto !important;
}

/* ===== ЗУМ-КНОПКИ: не перекрывают поле ===== */
#zoom-controls {
  position: absolute !important;
  right: -58px !important;
  bottom: 8px !important;
  display: flex !important;
  flex-direction: column;
  gap: 8px;
  z-index: 3;
}
.zoom-btn {
  width: 44px !important;
  height: 44px !important;
  font-size: 18px !important;
  background: var(--card) !important;
  box-shadow: 0 3px 10px rgba(0,0,0,.25) !important;
  border: 2px solid var(--border) !important;
}

/* На узких экранах — вплотную к правому краю рамки, полупрозрачные */
@media (max-width: 900px) {
  #zoom-controls {
    right: 6px !important;
    opacity: 0.7;
    transition: opacity .2s;
  }
  #zoom-controls:active,
  #zoom-controls:hover { opacity: 1; }
  .zoom-btn {
    width: 38px !important;
    height: 38px !important;
  }
}

/* ===== ПАЛИТРА: горизонтальная прокрутка ===== */
#palette {
  overflow-x: auto !important;
  overflow-y: hidden !important;
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 10px !important;
  padding: 10px 14px !important;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
#palette .pal-item {
  flex-shrink: 0 !important;
}
#palette::-webkit-scrollbar {
  height: 8px;
}
#palette::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}
#palette::-webkit-scrollbar-track {
  background: transparent;
}

/* Подсказка: активный цвет авто-скроллит к видимой области */
#palette .pal-item.active {
  scroll-margin: 0 40px;
}

/* Палитра — drag-to-scroll cursor */
#palette { cursor: grab; user-select: none; }
#palette:active { cursor: grabbing; }

/* ===== МОДАЛКА ПРЕДПРОСМОТРА ===== */
.modal-preview-content { text-align: center; max-width: 560px; }
#preview-wrap {
  display: flex;
  justify-content: center;
  padding: 14px;
  background: #f6efe2;
  border-radius: 14px;
  margin: 12px 0;
  border: 4px solid #b58863;
  box-shadow: inset 0 0 0 2px #e2b88c, 0 4px 14px rgba(0,0,0,.15);
}
#preview-wrap canvas {
  display: block;
  image-rendering: pixelated;
  border-radius: 4px;
}
.preview-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--fg);
  margin-bottom: 10px;
}


#game-pattern-name[data-in-canvas] {
  position: absolute !important;
  left: 50% !important;
  top: 4px !important;
  transform: translateX(-50%) !important;
  z-index: 15 !important;
  background: linear-gradient(135deg, #ffa8c8, #f473a6, #e04a86) !important;
  color: #fff !important;
  padding: 6px 14px !important;
  border-radius: 20px !important;
  font-size: 15px !important;
  font-weight: 800 !important;
  box-shadow: 0 3px 8px rgba(180,40,90,0.4), 0 1px 2px rgba(255,255,255,0.6) !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: calc(100% - 56px) !important;
}

#progress-bar.with-title {
  top: 40px !important;
}

#palette {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 100 !important;
  display: flex !important;
  gap: 10px !important;
  overflow-x: auto !important;
  padding: 12px !important;
  background: var(--panel) !important;
  scrollbar-width: thin !important;
  box-shadow: 0 -4px 16px rgba(160,110,80,.15) !important;
  border-top: 3px solid var(--accent-soft) !important;
  max-height: 80px !important;
}

/* Центрируем элементы палитры по вертикали */
#palette {
  align-items: center !important;
  justify-content: flex-start !important;
}

#palette .pal-item {
  margin: 0 !important;
}

/* Исправляем стиль процента в шапке */
.progress-pct {
  font-size: 14px !important;
  font-weight: 800 !important;
  color: var(--accent-dark) !important;
  margin-right: 4px !important;
}

/* Исправляем выравнивание процента в top-bar */
.game-header-actions {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}

.game-header-actions .progress-pct {
  display: flex !important;
  align-items: center !important;
  line-height: 1 !important;
  margin: 0 4px 0 0 !important;
  padding: 0 !important;
}

/* Перестройка top-bar в игре */
.game-bar {
  justify-content: space-between !important;
}

.game-header-actions {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}

/* Процент как круглая кнопка */
.progress-pct {
  width: 48px !important;
  height: 48px !important;
  border-radius: 50% !important;
  background: linear-gradient(180deg, #fff, #f4ebde) !important;
  color: var(--accent-dark) !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 2px solid rgba(80,40,10,.25) !important;
  box-shadow: 0 4px 0 rgba(80,40,10,.25), 0 6px 14px rgba(80,40,10,.2), inset 0 1px 2px rgba(255,255,255,.8) !important;
  transition: transform .15s !important;
}

.progress-pct:hover {
  transform: translateY(-2px) !important;
}


#game-pattern-name[data-in-canvas] {
  position: absolute !important;
  left: 50% !important;
  top: 4px !important;
  transform: translateX(-50%) !important;
  z-index: 15 !important;
  background: linear-gradient(135deg, #ffa8c8, #f473a6, #e04a86) !important;
  color: #fff !important;
  padding: 6px 14px !important;
  border-radius: 20px !important;
  font-size: 15px !important;
  font-weight: 800 !important;
  box-shadow: 0 3px 8px rgba(180,40,90,0.4), 0 1px 2px rgba(255,255,255,0.6) !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: calc(100% - 56px) !important;
}

#progress-bar.with-title {
  top: 40px !important;
}

.progress-pct {
  width: 48px !important;
  height: 48px !important;
  border-radius: 50% !important;
  background: linear-gradient(180deg, #fff, #f4ebde) !important;
  color: var(--accent-dark) !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 2px solid rgba(80,40,10,.25) !important;
  box-shadow: 0 4px 0 rgba(80,40,10,.25), 0 6px 14px rgba(80,40,10,.2), inset 0 1px 2px rgba(255,255,255,.8) !important;
  transition: transform .15s !important;
}

.game-header-actions {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}

#palette {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 100 !important;
  display: flex !important;
  gap: 10px !important;
  overflow-x: auto !important;
  padding: 12px !important;
  background: var(--panel) !important;
  scrollbar-width: thin !important;
  box-shadow: 0 -4px 16px rgba(160,110,80,.15) !important;
  border-top: 3px solid var(--accent-soft) !important;
  max-height: 80px !important;
  align-items: center !important;
  justify-content: flex-start !important;
}

/* ===== МОБИЛКА: zoom-кнопки ПОД деревянной рамкой (на зелёном фоне), подсказка в рамке ===== */
@media (max-width: 768px), (pointer: coarse) {
  /* zoom-controls — выносим ниже #canvas-wrap, на зелёный фон section */
  /* canvas-wrap overflow управляется финальным блоком */
  #zoom-controls {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    bottom: -56px !important;     /* под рамкой, на зелёном фоне */
    top: auto !important;
    flex-direction: row !important;
    justify-content: center !important;
    gap: 12px !important;
    margin: 0 !important;
    width: auto !important;
    opacity: 1 !important;
    z-index: 5 !important;
    transform: none !important;
  }
  #zoom-controls .zoom-btn,
  #zoom-controls button {
    width: 42px !important;
    height: 42px !important;
    font-size: 18px !important;
    position: static !important;
  }
  /* canvas-hints — теперь снаружи рамки, в потоке */
  #canvas-hints {
    position: relative !important;
    left: auto !important;
    transform: none !important;
    bottom: auto !important;
    top: auto !important;
    margin: 4px 0 0 !important;
    white-space: normal !important;
    line-height: 1.35 !important;
    max-width: 100% !important;
    text-align: center !important;
    padding: 5px 10px !important;
    font-size: 11px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  /* Сделаем секцию с игрой выше, чтобы кнопки на -56px не залезли на палитру */
  #screen-game { padding-bottom: 64px; }
}

/* Мобильные подсказки: каждая на своей строке */
#canvas-hints .hint-mobile .hint-line {
  display: block;
  white-space: nowrap;
}

/* ===== МОБИЛКА: яркий отклик при тапе на кнопки меню ===== */
@media (max-width: 700px), (pointer: coarse) {
  .btn:active,
  .btn.primary:active,
  .btn.small:active,
  .btn-icon:active {
    transform: scale(0.92) !important;
    filter: brightness(0.85) !important;
    box-shadow: 0 1px 0 rgba(140,100,70,.15) !important;
    transition: transform 0.05s ease, filter 0.05s ease !important;
  }
  /* Плавное возвращение */
  .btn, .btn-icon {
    transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.2s !important;
  }
}

/* ===== Гарантированный отклик при тапе через JS-класс .tap-flash ===== */
.tap-flash {
  transform: scale(0.90) !important;
  filter: brightness(0.78) !important;
  transition: transform 0.05s ease, filter 0.05s ease !important;
}

/* ===== Пагинация галереи ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 16px 12px 24px;
  user-select: none;
}
.pagination .page-btn {
  appearance: none;
  border: 2px solid var(--border, rgba(140,100,70,.25));
  background: var(--card, #fff);
  color: var(--fg, #4a3a2a);
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(140,100,70,.15);
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pagination .page-btn:hover:not(.disabled):not(.active) {
  transform: translateY(-1px);
  box-shadow: 0 3px 0 rgba(140,100,70,.2);
}
.pagination .page-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(140,100,70,.15);
}
.pagination .page-btn.active {
  background: linear-gradient(180deg, #ff8cb6, var(--accent, #ff5f9e));
  color: #fff;
  border-color: var(--accent-dark, #d83a72);
  cursor: default;
  box-shadow: 0 2px 8px rgba(255,95,158,.4);
}
.pagination .page-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.pagination .page-arrow {
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}
.pagination .page-dots {
  color: var(--fg-dim, #8a7560);
  font-weight: 800;
  padding: 0 4px;
  font-size: 16px;
}
@media (max-width: 700px) {
  .pagination { gap: 4px; padding: 12px 8px 20px; }
  .pagination .page-btn { min-width: 34px; height: 34px; font-size: 13px; }
  .pagination .page-arrow { font-size: 20px; }
}

/* ===== Модалка выбора режима — сетка 2x2 ===== */
.choice-buttons.choice-buttons-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
  flex-wrap: unset;
}
.choice-buttons-grid .btn-choice {
  flex: unset;
  max-width: unset;
  padding: 14px 8px;
}
.choice-buttons-grid .btn-choice .choice-icon { font-size: 22px; }
.choice-buttons-grid .btn-choice .choice-label { font-size: 13px; }
.choice-buttons-grid .btn-choice .choice-sub { font-size: 11px; }
.btn-choice-stitch {
  background: linear-gradient(180deg, #ffd0e1, #ff95b8) !important;
  border-color: #d83a72 !important;
}
.btn-choice-flat {
  background: linear-gradient(180deg, #c9e8ff, #7dc1f0) !important;
  border-color: #2872a8 !important;
}
@media (max-width: 480px) {
  .choice-buttons.choice-buttons-grid { gap: 8px; }
  .choice-buttons-grid .btn-choice { padding: 10px 6px; }
  .choice-buttons-grid .btn-choice .choice-icon { font-size: 18px; }
  .choice-buttons-grid .btn-choice .choice-label { font-size: 11.5px; }
  .choice-buttons-grid .btn-choice .choice-sub { display: none; }
}

/* ===== Переключатель Крестики/Цвет в игре ===== */
.cell-toggle {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 0;
  background: transparent;
  position: fixed;
  /* Высота палитры ~100px + safe-area */
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
  z-index: 50;
  pointer-events: none;
}
.cell-toggle .cell-toggle-btn {
  pointer-events: auto;
}
.cell-toggle-btn {
  appearance: none;
  border: 2px solid rgba(140,100,70,.3);
  background: rgba(255, 248, 235, 0.85);
  color: #6b5234;
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 0 rgba(140,100,70,.15);
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
}
.cell-toggle-btn:hover:not(.active) {
  transform: translateY(-1px);
  background: rgba(255, 248, 235, 1);
}
.cell-toggle-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(140,100,70,.15);
}
.cell-toggle-btn.active {
  background: linear-gradient(180deg, #ff8cb6, #ff5f9e);
  color: #fff;
  border-color: #d83a72;
  box-shadow: 0 2px 6px rgba(255,95,158,.4);
  cursor: default;
}
.cell-toggle-icon {
  font-size: 14px;
  line-height: 1;
}
@media (max-width: 480px) {
  .cell-toggle { padding: 4px 0; gap: 6px; bottom: calc(140px + env(safe-area-inset-bottom, 0px)) !important; }
  .cell-toggle-btn { font-size: 12px; padding: 6px 12px; }
}

/* ========================================================================
   ТЁМНАЯ ТЕМА (тёплая вечерняя)
   Активируется классом .theme-dark на #app
   ======================================================================== */
#app.theme-dark {
  /* Стены/дерево фон — тёмные коричневые тона вечерней комнаты */
  --bg-wall-1: #2b1f15;
  --bg-wall-2: #251a11;
  --bg-wood-1: #3d2c1d;
  --bg-wood-2: #2e2014;

  /* Панели — чуть светлее фона, чтобы выделяться */
  --panel: #3a2c1f;
  --panel-soft: #43342a;

  /* Текст — кремовый, мягкий */
  --fg: #efe1cc;
  --fg-dim: #b89c7a;

  /* Акценты остаются "тёплыми" — розовый чуть приглушаем для глаз */
  --accent: #ff7ba9;
  --accent-dark: #d94d7d;
  --accent-soft: #5a3340;
  --accent-2: #f0a878;

  /* Статусы */
  --ok: #7ad99a;
  --err: #ff6680;

  /* Сетка крестиков */
  --grid: #5a4632;
  --grid-bold: #8a6e4f;

  /* "Бумажный" фон холста — тёмный, чтобы крестики читались */
  --paper: #2f2418;

  /* Рамка картин */
  --frame-1: #6b4a2c;
  --frame-2: #4d3219;

  /* Тени — затемнённые, более выразительные */
  --shadow-pink: 0 6px 0 rgba(217,77,125,.25), 0 12px 30px rgba(0,0,0,.4);
  --shadow-soft: 0 4px 0 rgba(0,0,0,.3), 0 10px 24px rgba(0,0,0,.4);
}

/* Точечные правки для элементов где цвет захардкожен и не идёт через переменные */
#app.theme-dark .modal-content,
#app.theme-dark .modal-content.modal-choice,
#app.theme-dark .modal-content.modal-buy,
#app.theme-dark .modal-content.modal-all-done,
#app.theme-dark .modal-content.modal-preview-content {
  background: var(--panel) !important;
  color: var(--fg);
}

#app.theme-dark .modal-content h2,
#app.theme-dark .modal-content p,
#app.theme-dark .modal-content label,
#app.theme-dark .modal-content .row span {
  color: var(--fg);
}

#app.theme-dark .modal {
  background: rgba(20, 12, 6, 0.7);
}

/* Палитра в темной теме */
#app.theme-dark #palette {
  background: var(--panel);
  border-top-color: var(--accent-soft);
}

/* Категории-чипы */
#app.theme-dark .cat-chip {
  background: var(--panel-soft);
  color: var(--fg);
  border-color: var(--accent-soft);
}
#app.theme-dark .cat-chip.active {
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #fff;
}

/* Карточки галереи — фон тёмно-коричневый */
#app.theme-dark .gallery-grid .card {
  background: var(--panel);
  color: var(--fg);
}

/* Подсказка над canvas */
#app.theme-dark #canvas-hints {
  background: var(--panel);
  color: var(--fg);
  border-color: var(--accent-soft);
}

/* Переключатель Крестики/Цвет */
#app.theme-dark .cell-toggle-btn {
  background: rgba(67, 52, 42, 0.85);
  color: var(--fg);
  border-color: var(--accent-soft);
}
#app.theme-dark .cell-toggle-btn:hover:not(.active) {
  background: var(--panel-soft);
}

/* Пагинация */
#app.theme-dark .pagination .page-btn {
  background: var(--panel);
  color: var(--fg);
  border-color: var(--accent-soft);
}

/* Селекты в настройках */
#app.theme-dark select,
#app.theme-dark input[type="checkbox"] + span,
#app.theme-dark .row {
  color: var(--fg);
}
#app.theme-dark select {
  background: var(--panel-soft);
  border: 2px solid var(--accent-soft);
  color: var(--fg);
}

/* Тексты статусов и подписей в карточках */
#app.theme-dark .card .name,
#app.theme-dark .card .meta,
#app.theme-dark #stats-total,
#app.theme-dark #coins-count {
  color: var(--fg);
}

/* Кнопки меню */
#app.theme-dark .btn:not(.primary) {
  background: var(--panel-soft);
  color: var(--fg);
  border-color: var(--accent-soft);
}

/* Шапка экранов */
#app.theme-dark .top-bar {
  background: rgba(58, 44, 31, 0.85) !important;
  border-bottom-color: rgba(184, 156, 122, 0.3) !important;
}
#app.theme-dark .top-bar h2,
#app.theme-dark .top-bar .game-title {
  color: var(--fg) !important;
}
/* Тёмная тема: яркий розовый градиент для названия "Крестики" в главном меню */
#app.theme-dark .menu-header h1 {
  background: linear-gradient(135deg, #ffb6d8 0%, #ff7eb6 50%, #d83a72 100%) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  color: transparent !important;
  text-shadow: none !important;
  filter: drop-shadow(0 2px 6px rgba(255, 126, 182, 0.4));
}
#app.theme-dark .menu-header h1 .accent {
  -webkit-text-fill-color: #ffd86b !important;
  color: #ffd86b !important;
  background: none !important;
}
#app.theme-dark .menu-header h1 .hero-sub {
  -webkit-text-fill-color: #fff5e0 !important;
  color: #fff5e0 !important;
  background: none !important;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5)) !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) !important;
}
#app.theme-dark .tagline {
  color: #fff5e0 !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) !important;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5)) !important;
}
/* Кнопка-стрелка "назад" — чтобы тоже не сливалась с фоном */
#app.theme-dark .btn-icon {
  background: var(--panel-soft) !important;
  color: var(--fg) !important;
  border-color: var(--accent-soft) !important;
}

#app.theme-dark .menu-footer {
  color: var(--fg-dim);
}

/* В тёмной теме — выключаем multiply на монете, иначе она тонет в тёмном фоне */
#app.theme-dark .coin-header,
#app.theme-dark .coin-img,
#app.theme-dark .coin-img-sm,
#app.theme-dark .earn-coin-img {
  mix-blend-mode: normal !important;
  filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.5));
}

/* Дополнительные элементы в модалках, которые могли остаться с тёмным цветом */
#app.theme-dark .modal-content .buy-name,
#app.theme-dark .modal-content .preview-name,
#app.theme-dark .modal-content h3,
#app.theme-dark .modal-content h4,
#app.theme-dark .modal-content #choice-pattern-name,
#app.theme-dark .modal-content .modal-msg,
#app.theme-dark .modal-content .choice-hint,
#app.theme-dark .modal-content .all-done-msg {
  color: var(--fg) !important;
}
/* Цена картины в модалке покупки — оставляем монету заметной */
#app.theme-dark .modal-content .buy-price {
  color: var(--fg) !important;
}

/* ===== ФИКС: жёсткий размер Ниточки на главном экране ===== */
.menu-header .logo-mascot {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 140px !important;
  height: 140px !important;
  max-width: 140px !important;
  max-height: 140px !important;
  margin: 0 auto 8px !important;
  flex: 0 0 140px !important;
}
.menu-header .logo-mascot .mascot-hello {
  width: 140px !important;
  height: 140px !important;
  max-width: 140px !important;
  max-height: 140px !important;
  object-fit: contain;
  display: block;
  animation: mascotBob 2.6s ease-in-out infinite;
  filter: drop-shadow(0 6px 16px rgba(255, 143, 177, 0.3));
}
@media (max-width: 480px) {
  .menu-header .logo-mascot,
  .menu-header .logo-mascot .mascot-hello {
    width: 110px !important;
    height: 110px !important;
    max-width: 110px !important;
    max-height: 110px !important;
  }
  .menu-header .logo-mascot { flex: 0 0 110px !important; }
}

/* ===== Ниточка в модалке победы ===== */
.mascot-victory {
  display: block;
  width: 160px;
  height: 160px;
  max-width: 160px;
  max-height: 160px;
  margin: 8px auto 12px;
  object-fit: contain;
  animation: mascotJump 1.4s ease-in-out infinite;
  filter: drop-shadow(0 8px 18px rgba(255, 143, 177, 0.45));
}
@keyframes mascotJump {
  0%, 100% { transform: translateY(0) rotate(-3deg) scale(1); }
  25%      { transform: translateY(-14px) rotate(0deg) scale(1.04); }
  50%      { transform: translateY(0) rotate(3deg) scale(1); }
  75%      { transform: translateY(-10px) rotate(0deg) scale(1.03); }
}
@media (max-width: 480px) {
  .mascot-victory { width: 130px; height: 130px; max-width: 130px; max-height: 130px; }
}

/* Скрываем пустой блок статистики если в нём нет содержимого */
#complete-stats:empty {
  display: none;
}

/* ===== Тост с монетами + Ниточка ===== */
#toast.toast.toast-coins {
  position: fixed !important;
  bottom: 60px !important;
  left: 50% !important;
  transform: translateX(-50%);
  z-index: 9999 !important;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px 10px 10px;
  background: linear-gradient(135deg, #fff5d8 0%, #ffd86b 100%);
  color: #6b4a18;
  font-weight: 900;
  font-size: 18px;
  border: 3px solid #f5b83b;
  box-shadow: 0 8px 24px rgba(180, 110, 30, 0.35);
  border-radius: 999px;
}
.toast.toast-coins .toast-mascot {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex-shrink: 0;
  animation: toastBob 0.8s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}
.toast.toast-coins .toast-text {
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(255,255,255,0.6);
}
@keyframes toastBob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-4px) rotate(3deg); }
}
@media (max-width: 480px) {
  .toast.toast-coins { font-size: 15px; padding: 8px 16px 8px 8px; }
  .toast.toast-coins .toast-mascot { width: 44px; height: 44px; }
}

/* ===== Ниточка с пяльцами в модалке выбора режима ===== */
.modal-choice .mascot-modes {
  display: block;
  width: 110px;
  height: 110px;
  max-width: 110px;
  max-height: 110px;
  margin: 4px auto 6px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(255, 143, 177, 0.3));
  animation: mascotFloat 3s ease-in-out infinite;
}
@keyframes mascotFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-5px) rotate(2deg); }
}
@media (max-width: 480px) {
  .modal-choice .mascot-modes {
    width: 80px;
    height: 80px;
    max-width: 80px;
    max-height: 80px;
    margin: 2px auto 4px;
  }
}

/* ===== Ниточка-картина-дня выглядывает справа от кнопки ===== */
.btn-daily-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.btn-daily-wrap .btn {
  width: 100%;
}
.mascot-daily-peek {
  position: absolute;
  top: 50%;
  right: -20px;
  transform: translateY(-50%) rotate(8deg);
  width: 70px;
  height: 70px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 4px 10px rgba(255, 143, 177, 0.4));
  animation: peekBob 2.4s ease-in-out infinite;
  z-index: 2;
}
@keyframes peekBob {
  0%, 100% { transform: translateY(-50%) rotate(6deg); }
  50%      { transform: translateY(-58%) rotate(12deg); }
}
@media (max-width: 480px) {
  .mascot-daily-peek {
    width: 56px;
    height: 56px;
    right: -12px;
  }
}

/* ===== Ниточка-катится в loader ===== */
.mascot-loader {
  width: 140px;
  height: 140px;
  object-fit: contain;
  margin-bottom: 16px;
  filter: drop-shadow(0 6px 14px rgba(255, 143, 177, 0.4));
  animation: mascotRoll 1.2s linear infinite;
}
@keyframes mascotRoll {
  0%   { transform: rotate(0deg) translateX(0); }
  25%  { transform: rotate(-90deg) translateX(-6px); }
  50%  { transform: rotate(-180deg) translateX(0); }
  75%  { transform: rotate(-270deg) translateX(6px); }
  100% { transform: rotate(-360deg) translateX(0); }
}
@media (max-width: 480px) {
  .mascot-loader { width: 110px; height: 110px; }
}

/* ===== Ниточка-медалист в модалке достижений ===== */
#modal-achievements .mascot-medal {
  display: block;
  width: 110px;
  height: 110px;
  max-width: 110px;
  max-height: 110px;
  margin: 4px auto 12px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(255, 215, 0, 0.45));
  animation: medalShine 2.4s ease-in-out infinite;
}
@keyframes medalShine {
  0%, 100% { transform: rotate(-2deg) scale(1); }
  50%      { transform: rotate(2deg) scale(1.04); }
}
@media (max-width: 480px) {
  #modal-achievements .mascot-medal {
    width: 86px;
    height: 86px;
    max-width: 86px;
    max-height: 86px;
  }
}

/* ===== Ниточка-спит в модалке "Все картины дня пройдены" ===== */
.modal-all-done .mascot-sleep {
  display: block;
  width: 130px;
  height: 130px;
  max-width: 130px;
  max-height: 130px;
  margin: 0 auto 12px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(180, 140, 200, 0.35));
  animation: sleepBreath 3.4s ease-in-out infinite;
}
@keyframes sleepBreath {
  0%, 100% { transform: scale(1) rotate(-1deg); }
  50%      { transform: scale(1.04) rotate(1deg); }
}
@media (max-width: 480px) {
  .modal-all-done .mascot-sleep {
    width: 100px;
    height: 100px;
    max-width: 100px;
    max-height: 100px;
  }
}

/* Поддержка \n переносов в сообщении модалки "все пройдены" */
.modal-all-done .all-done-msg {
  white-space: pre-line;
}

/* ===== Empty state с Ниточкой-грустной (лидерборд и т.д.) ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  text-align: center;
}
.empty-state .mascot-empty {
  width: 110px;
  height: 110px;
  max-width: 110px;
  max-height: 110px;
  object-fit: contain;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 10px rgba(140, 130, 200, 0.3));
  animation: emptySway 3s ease-in-out infinite;
}
@keyframes emptySway {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(3deg); }
}
.empty-state .empty-state-text {
  color: var(--fg-dim);
  font-size: 15px;
  font-weight: 600;
  max-width: 240px;
  line-height: 1.4;
}
@media (max-width: 480px) {
  .empty-state .mascot-empty { width: 86px; height: 86px; max-width: 86px; max-height: 86px; }
}

/* Подзаголовок "вышиваем по номерам" в h1 главного меню */
.menu-header h1 .hero-sub {
  display: block;
  font-size: 0.5em;
  font-weight: 700;
  margin-top: 4px;
  background: none !important;
  -webkit-text-fill-color: var(--fg-dim) !important;
  color: var(--fg-dim);
  letter-spacing: 0.5px;
  text-transform: lowercase;
}

/* ===== Кнопки "Скачать" / "Поделиться" в модалке победы ===== */
#modal-complete .share-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 8px 0 14px;
  flex-wrap: wrap;
}
#modal-complete .share-actions .btn {
  flex: 1 1 0;
  min-width: 130px;
  max-width: 180px;
  padding: 12px 16px !important;
  font-size: 15px !important;
  font-weight: 800 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 !important;
}
#modal-complete .btn-share {
  background: linear-gradient(135deg, #ffd86b 0%, #f5b83b 100%) !important;
  color: #6b4a18 !important;
  border: 2px solid #f5b83b !important;
  box-shadow: 0 4px 12px rgba(245, 184, 59, 0.35) !important;
}
#modal-complete .btn-download {
  background: linear-gradient(135deg, #b6e0ff 0%, #7ec3f5 100%) !important;
  color: #1e4060 !important;
  border: 2px solid #7ec3f5 !important;
  box-shadow: 0 4px 12px rgba(126, 195, 245, 0.35) !important;
}
#modal-complete .share-ico {
  font-size: 20px;
  line-height: 1;
}
@media (max-width: 480px) {
  #modal-complete .share-actions .btn { font-size: 14px !important; padding: 10px 12px !important; }
}

/* ===== Экран "Мои работы" — вкладки ===== */
.myworks-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.myworks-tabs::-webkit-scrollbar { display: none; }

.myworks-tab {
  flex: 1 1 auto;
  min-width: 100px;
  padding: 10px 18px;
  border: 2px solid var(--accent-soft);
  background: var(--panel-soft);
  color: var(--fg);
  font-size: 14px;
  font-weight: 800;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.myworks-tab:hover { background: var(--panel); }
.myworks-tab.active {
  background: linear-gradient(135deg, #ff7eb6 0%, #d83a72 100%);
  color: #fff;
  border-color: #d83a72;
  box-shadow: 0 3px 10px rgba(216, 58, 114, 0.3);
}

/* Empty state контейнер */
.myworks-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--fg-dim);
}
.myworks-empty img {
  width: 130px;
  height: 130px;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 10px rgba(140, 130, 200, 0.3));
}

/* ===== Карточки "Мои работы" ===== */
.myworks-card { cursor: pointer; transition: transform 0.15s ease; }
.myworks-card:hover { transform: translateY(-3px); }

.myworks-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 13px;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  border: 2px solid #fff;
}
.myworks-badge-done {
  background: linear-gradient(135deg, #6dd96d 0%, #3aa53a 100%);
  font-size: 16px;
}
.myworks-badge-progress {
  background: linear-gradient(135deg, #ffb96b 0%, #f5832b 100%);
}

.myworks-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.myworks-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffb96b 0%, #f5832b 100%);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* "Готовая" карточка — слегка зелёный отлив */
.myworks-card.is-done .gal-thumb-wrap {
  box-shadow: 0 0 0 2px rgba(58, 165, 58, 0.3);
}

/* ===== Модалка просмотра готовой работы ===== */
.modal-mywork-view-content {
  text-align: center;
  max-width: 380px !important;
}
.modal-mywork-view-content h2 {
  font-size: 22px;
  margin: 0 0 14px;
  color: var(--fg);
}
.modal-mywork-view-content #mywork-view-preview {
  margin: 0 auto 18px;
  padding: 14px;
  background: linear-gradient(135deg, #fff5fa 0%, #ffe7ee 100%);
  border-radius: 18px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6), 0 4px 12px rgba(216, 58, 114, 0.15);
}
.mywork-view-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 0 0 14px;
  flex-wrap: wrap;
}
.mywork-view-actions .btn {
  flex: 1 1 0;
  min-width: 130px;
  max-width: 180px;
  padding: 12px 16px !important;
  font-size: 15px !important;
  font-weight: 800 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 !important;
}
.mywork-view-actions .btn-share {
  background: linear-gradient(135deg, #ffd86b 0%, #f5b83b 100%) !important;
  color: #6b4a18 !important;
  border: 2px solid #f5b83b !important;
}
.mywork-view-actions .btn-download {
  background: linear-gradient(135deg, #b6e0ff 0%, #7ec3f5 100%) !important;
  color: #1e4060 !important;
  border: 2px solid #7ec3f5 !important;
}

/* ===== Меню "Поделиться" ===== */
.share-menu-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 15, 40, 0.65);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}
.share-menu {
  background: linear-gradient(155deg, #fff5fa 0%, #ffe7ee 100%);
  border-radius: 24px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 30px 80px rgba(40, 20, 80, 0.45);
  animation: slideUp 0.3s cubic-bezier(.34, 1.5, .64, 1);
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.share-menu-title {
  margin: 0 0 18px;
  text-align: center;
  font-size: 22px;
  font-weight: 900;
  color: #2a1a14;
}
.share-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.share-menu-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px;
  background: #fff;
  border: 2px solid;
  border-radius: 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: #2a1a14;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.share-menu-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}
.share-menu-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  flex-shrink: 0;
}
.share-menu-name { flex: 1; text-align: left; }
.share-menu-note {
  margin: 0 0 10px;
  font-size: 13px;
  color: #7a5a4a;
  text-align: center;
}
.share-menu-download {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #b6e0ff 0%, #7ec3f5 100%);
  color: #1e4060;
  border: 2px solid #7ec3f5;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  margin-bottom: 10px;
}
.share-menu-download:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(126, 195, 245, 0.4); }
.share-menu-close {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: none;
  color: #7a5a4a;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
@media (max-width: 480px) {
  .share-menu-grid { grid-template-columns: 1fr; }
  .share-menu-btn { padding: 12px; }
}

/* Тёмная тема: счётчик монет в шапке "Мои работы" — светлый */
/* Тёмная тема: счётчик монет везде — золотой и контрастный */
#app.theme-dark .coins-display,
#app.theme-dark .coins-display span,
#app.theme-dark #coins-count,
#app.theme-dark #myworks-coins-count {
  color: #ffd86b !important;
  font-weight: 900 !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6), 0 0 8px rgba(255, 216, 107, 0.3) !important;
}

/* Тёмная тема: контраст текста в карточках выбора режима (.btn-choice) */
#app.theme-dark .btn-choice .choice-label {
  color: #2a1a14 !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
}
#app.theme-dark .btn-choice .choice-sub {
  color: #5a4030 !important;
  font-weight: 800;
}
#app.theme-dark .btn-choice .choice-icon {
  color: #2a1a14 !important;
}

/* Мобильная адаптация главного меню — чтобы все кнопки влезали без обрезки */
@media (max-width: 480px) {
  .menu-header { padding: 16px 16px 4px !important; }
  .menu-header .logo-mascot { width: 90px !important; height: 90px !important; }
  .menu-header h1 { font-size: 36px !important; margin: 2px 0 0 !important; }
  .menu-header h1 .hero-sub { font-size: 0.45em !important; margin-top: 2px !important; }
  .tagline { font-size: 13px !important; margin: 2px 0 !important; }
  .menu-header::after { margin: 8px auto 0 !important; height: 8px !important; width: 140px !important; }
  .menu-buttons { gap: 10px !important; padding: 12px 16px 8px !important; justify-content: flex-start !important; }
  .menu-buttons .btn { padding: 12px 18px !important; font-size: 15px !important; }
  .menu-footer { padding: 8px 14px !important; font-size: 12px !important; }
}
@media (max-width: 480px) and (max-height: 720px) {
  /* Маленькие телефоны — ещё компактнее */
  .menu-header { padding: 8px 16px 2px !important; }
  .menu-header .logo-mascot { width: 70px !important; height: 70px !important; }
  .menu-header h1 { font-size: 30px !important; }
  .menu-header::after { display: none !important; }
  .menu-buttons { gap: 8px !important; padding: 8px 16px !important; }
  .menu-buttons .btn { padding: 10px 16px !important; font-size: 14px !important; }
}

/* Сверх-приоритет для цифры монет в тёмной теме (id selector + !important побеждают всё) */
#app.theme-dark .top-bar .coins-display span,
#app.theme-dark header .coins-display span,
html #app.theme-dark span#myworks-coins-count,
html #app.theme-dark span#coins-count {
  color: #ffd86b !important;
  font-weight: 900 !important;
  font-size: 18px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7), 0 0 6px rgba(255, 216, 107, 0.4) !important;
}

/* Тёмная тема: цифра монет — ярко-золотая с обводкой для контраста */
html body #app.theme-dark #myworks-coins-count,
html body #app.theme-dark #coins-count {
  color: #ffd86b !important;
  font-weight: 900 !important;
  font-size: 18px !important;
  -webkit-text-stroke: 1px #5a3a1a;
  text-shadow:
    -1px -1px 0 #3a2a14,
     1px -1px 0 #3a2a14,
    -1px  1px 0 #3a2a14,
     1px  1px 0 #3a2a14,
     0 0 8px rgba(255, 216, 107, 0.6) !important;
}

/* ============================================================
   FINAL FIX v3: zoom-controls — вертикальный ряд СПРАВА снаружи канваса
   canvas-hints — внутри снизу (не наезжает ни на что)
   ============================================================ */
#canvas-wrap {
  overflow: visible !important;
}
/* Зум-кнопки — вертикально справа, только десктоп */
@media (min-width: 701px) and (pointer: fine) {
  #zoom-controls {
    position: absolute !important;
    top: 50% !important;
    right: -56px !important;
    left: auto !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: auto !important;
    z-index: 50 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    background: transparent !important;
  }
}
/* Подсказку "Колесо мыши" возвращаем вниз внутри канваса — только на десктопе */
@media (min-width: 701px) and (pointer: fine) {
  #canvas-hints {
    position: absolute !important;

    top: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    pointer-events: none !important;
    opacity: 0.65 !important;
  }
}


/* ============================================================
   LANDSCAPE FIX: главное меню в горизонтальной ориентации мобилки
   Используем те же селекторы что и базовые правила, чтобы !important победил
   ============================================================ */
@media (orientation: landscape) and (max-height: 900px) and (max-width: 1024px) {
  /* Шапка — горизонтальный flexbox: маскот слева, текст справа */
  .menu-header {
    padding: 6px 16px 4px !important;
    flex-shrink: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    text-align: left !important;
    max-width: 520px !important;
    margin: 0 auto !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  /* Маскот контейнер — мелкий, не центрируем margin auto */
  .menu-header .logo-mascot {
    width: 60px !important;
    height: 60px !important;
    max-width: 60px !important;
    max-height: 60px !important;
    flex: 0 0 60px !important;
    margin: 0 !important;
  }
  /* Сама картинка маскота — точная специфичность как у базового правила */
  .menu-header .logo-mascot .mascot-hello {
    width: 60px !important;
    height: 60px !important;
    max-width: 60px !important;
    max-height: 60px !important;
  }
  .menu-header h1 {
    font-size: 17px !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: left !important;
    line-height: 1.15 !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    text-shadow: none !important;
  }
  .tagline {
    display: none !important;
  }
  .menu-header::after {
    display: none !important;
  }
  /* Кнопки — компактные, выравниваем сверху чтобы все влезли */
  .menu-buttons {
    padding: 2px 16px !important;
    gap: 4px !important;
    max-width: 520px !important;
    justify-content: flex-start !important;
    overflow-y: auto !important;
    scrollbar-width: none !important;          /* Firefox */
  }
  .menu-buttons::-webkit-scrollbar {
    display: none !important;                  /* Chrome/Safari */
  }
  .menu-buttons .btn {
    padding: 5px 16px !important;
    font-size: 12px !important;
  }
  .menu-buttons .btn.small {
    padding: 5px 12px !important;
    font-size: 11px !important;
  }
  .menu-footer {
    padding: 2px !important;
    font-size: 10px !important;
  }
  .mascot-daily-peek {
    display: none !important;
  }
}

/* ============================================================
   ROTATE OVERLAY: заглушка для телефонов в ландшафте
   Показывается только на узких устройствах в горизонтальной ориентации
   ============================================================ */
#rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: linear-gradient(135deg, #ffe8ee 0%, #fff5f5 50%, #f0fff4 100%);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#rotate-overlay .rotate-content {
  text-align: center;
  max-width: 420px;
}
#rotate-overlay .rotate-icon {
  display: inline-block;
  margin-bottom: 16px;
  animation: rotateHint 2.4s ease-in-out infinite;
}
@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  40% { transform: rotate(-90deg); }
  60% { transform: rotate(-90deg); }
}
#rotate-overlay .rotate-title {
  font-size: 22px;
  font-weight: 900;
  color: #3a2a1a;
  margin: 0 0 6px;
}
#rotate-overlay .rotate-text {
  font-size: 14px;
  color: #8a6e57;
  margin: 0;
  font-weight: 700;
}
/* Показываем только в ландшафте на узких устройствах (телефоны) */
@media (orientation: landscape) and (max-width: 900px) {
  #rotate-overlay {
    display: flex !important;
  }
}

/* Мобилка: cell-toggle чуть выше чтобы не наезжал на подсказку */
@media (max-width: 768px), (pointer: coarse) {
  .cell-toggle {
    bottom: calc(140px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* cell-toggle в потоке ПОСЛЕ палитры */
#cell-style-toggle.cell-toggle {
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  padding: 8px 0 !important;
  background: var(--panel) !important;
  border-top: 2px solid var(--accent-soft) !important;
}

/* Убираем пустое пространство между palette и cell-toggle */
#screen-game {
  justify-content: flex-start !important;
}

/* Ограничиваем высоту canvas-wrap на мобиле */
@media (max-width: 768px), (pointer: coarse) {
  #canvas-wrap {
    max-height: calc(100svh - 280px) !important;
  }
}

/* Мобилка: canvas-wrap не растягивается, занимает только нужное место */
@media (max-width: 768px), (pointer: coarse) {
  #canvas-wrap {
    flex: 1 1 auto !important;
    min-height: 0 !important;
  }
}

/* ФИНАЛЬНЫЙ FIX cell-toggle: fixed на десктопе, relative на мобиле */
#cell-style-toggle.cell-toggle {
  position: fixed !important;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important;
  left: 0 !important;
  right: 0 !important;
  background: transparent !important;
  border-top: none !important;
  padding: 8px 0 !important;
  z-index: 50 !important;
}
@media (max-width: 768px), (pointer: coarse) {
  #cell-style-toggle.cell-toggle {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    background: var(--panel) !important;
    border-top: 2px solid var(--accent-soft) !important;
  }
}

/* === МОБИЛКА ФИНАЛ === */
/* 1. Зум-кнопки под рамкой — теперь снаружи canvas-wrap, в потоке */
@media (max-width: 700px), (pointer: coarse) {
  #zoom-controls {
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    flex-direction: row !important;
    justify-content: center !important;
    gap: 12px !important;
    padding: 8px 0 !important;
    flex: 0 0 auto !important;
    background: var(--bg-wall-1) !important;
  }
  #canvas-wrap {
    overflow: hidden !important;
    margin-bottom: 0 !important;
  }
  /* 2. Канвас больше — на всю ширину рамки */
  #canvas {
    position: absolute !important;
    left: 8px !important;
    top: 50px !important;
    right: auto !important;
    bottom: auto !important;
    width: calc(100% - 16px) !important;
    height: calc(100% - 60px) !important;
    aspect-ratio: auto !important;
    max-height: none !important;
  }
}

/* Мобилка: hints в потоке между Крестики/Цвет и палитрой */
@media (max-width: 700px), (pointer: coarse) {
  #canvas-hints {
    position: relative !important;
    bottom: auto !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    text-align: center !important;
    padding: 6px 8px 3px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    font-size: 11px !important;
  }
}

/* При малой высоте окна убираем декоративную полоску и уменьшаем отступы */
@media (max-height: 800px) {
  .menu-header::after { display: none !important; }
  .menu-header { padding: clamp(4px, 2vh, 20px) 20px 4px !important; }
  .menu-buttons { gap: 8px !important; padding: 8px 22px !important; }
  .menu-buttons .btn { padding: 10px 16px !important; font-size: 15px !important; }
  .menu-footer { padding: 4px 14px !important; }
}


/* screen-game на мобиле: overflow hidden чтобы flex дочерние не вылезали */
@media (max-width: 768px), (pointer: coarse) {
  #screen-game {
    overflow: hidden !important;
    padding-bottom: 84px !important;
  }
}

/* Мобиль: hints не обрезает текст */
@media (max-width: 768px), (pointer: coarse) {
  #canvas-hints {
    overflow: visible !important;
    height: auto !important;
    padding: 6px 10px 8px !important;
    line-height: 1.45 !important;
    white-space: normal !important;
  }
}

/* ===== МОБИЛЬ: компактный UI — максимум места рисунку ===== */
@media (max-width: 768px), (pointer: coarse) {
  /* Шапка компактнее */
  .game-bar { padding: 4px 8px !important; min-height: 0 !important; }
  .game-bar .btn-icon, .game-bar button {
    width: 38px !important; height: 38px !important;
    font-size: 16px !important; padding: 0 !important;
  }
  /* Зум-кнопки меньше и плотнее */
  #zoom-controls { padding: 4px 0 !important; gap: 10px !important; }
  #zoom-controls .zoom-btn, #zoom-controls button {
    width: 36px !important; height: 36px !important; font-size: 15px !important;
  }
  /* Крестики/Цвет компактнее */
  #cell-style-toggle { padding: 4px 0 !important; }
  #cell-style-toggle .cell-toggle-btn {
    padding: 5px 14px !important; font-size: 13px !important;
  }
  /* Подсказки компактнее */
  #canvas-hints {
    font-size: 10.5px !important;
    padding: 4px 8px 5px !important;
    margin: 2px 8px !important;
    line-height: 1.35 !important;
  }
  /* Палитра плотнее */
  #palette { padding: 6px 10px 8px !important; gap: 8px !important; }
  /* Отступ под палитру — чуть меньше после ужатия */
  #screen-game { padding-bottom: 76px !important; }
  /* Рамка: меньше внутренние отступы */
  #canvas-wrap { margin: 6px 6px 0 6px !important; }
}

/* Мобиль: компактные название и прогресс-бар */
@media (max-width: 768px), (pointer: coarse) {
  #game-pattern-name {
    font-size: 13px !important;
    padding: 3px 14px !important;
    top: 3px !important;
  }
  #progress-bar { top: 28px !important; height: 5px !important; }
}


/* Мобиль: прогресс-бар скрыт (процент есть в шапке), канвас выше */
@media (max-width: 768px), (pointer: coarse) {
  #progress-bar { display: none !important; }
}

/* Мобиль: компактное название поверх канваса — перебиваем [data-in-canvas] */
@media (max-width: 768px), (pointer: coarse) {
  #game-pattern-name,
  #game-pattern-name[data-in-canvas] {
    font-size: 12px !important;
    padding: 3px 12px !important;
    top: 2px !important;
    line-height: 1.3 !important;
  }
}
