/* ===== Весы-уравнение — стили ===== */

:root {
  --accent: #FF7A59;
  --accent2: #4EC5F1;
  --ok: #3BC97D;
  --bad: #FF5A6E;
  --ink: #2E2A4F;
  --wood: #C98A55;
  --wood-dark: #A2673A;
  --card: rgba(255, 255, 255, .82);
  --wsize: clamp(42px, 9.5vw, 62px);   /* размер гирьки */
  --ropeH: clamp(34px, 7vh, 56px);
  --tilt: 0deg;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Naukino Emoji", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  color: var(--ink);
  background: #F7E3C6;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 12px 26px;
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }

/* ---------- Верхняя панель ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: clamp(17px, 4.4vw, 24px);
  color: #7A4B2A;
}

.brand-ico { font-size: 1.4em; }

.tools { display: flex; gap: 8px; }

.icon-btn {
  font-size: 22px;
  line-height: 1;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .10);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s;
}

.icon-btn:hover { background: #fff; transform: translateY(-2px); }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .12); }
.icon-btn.off { opacity: .5; }

:focus-visible {
  outline: 4px solid #4EC5F1;
  outline-offset: 3px;
}

/* ---------- Совёнок Наум ---------- */
.hero-art {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 10px;
}

.hero-emoji {
  font-size: clamp(38px, 9vw, 54px);
  line-height: 1;
  flex: 0 0 auto;
  transform-origin: 50% 90%;
}

.hero-emoji.happy { animation: hop .5s ease 2; }
.hero-emoji.sad { animation: wobble .5s ease 2; }

@keyframes hop {
  0%, 100% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-16px) scale(1.08); }
  70% { transform: translateY(0) scale(.96); }
}

@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-9deg); }
  75% { transform: rotate(9deg); }
}

.bubble {
  position: relative;
  background: var(--card);
  border-radius: 20px;
  padding: 10px 14px;
  font-size: clamp(15px, 3.7vw, 19px);
  font-weight: 600;
  line-height: 1.3;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
  min-height: 44px;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
}

.bubble::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 50%;
  margin-top: -8px;
  border: 9px solid transparent;
  border-right-color: var(--card);
  border-left: 0;
}

.bubble.ok { background: #E4FBEE; box-shadow: 0 4px 14px rgba(59, 201, 125, .28); }
.bubble.ok::before { border-right-color: #E4FBEE; }
.bubble.hint { background: #FFF0D6; box-shadow: 0 4px 14px rgba(255, 122, 89, .25); }
.bubble.hint::before { border-right-color: #FFF0D6; }

/* ---------- Экраны ---------- */
.screen {
  background: var(--card);
  border-radius: 26px;
  padding: clamp(14px, 3vw, 24px);
  box-shadow: 0 10px 30px rgba(90, 60, 40, .10);
}

.title {
  margin: 4px 0 10px;
  text-align: center;
  font-size: clamp(26px, 7vw, 40px);
  color: var(--accent);
  text-shadow: 0 2px 0 #fff;
}

.rule {
  margin: 0 auto 14px;
  max-width: 620px;
  text-align: center;
  font-size: clamp(16px, 4vw, 20px);
  line-height: 1.45;
}

.pick-label, .bank-label {
  text-align: center;
  font-weight: 700;
  margin: 10px 0 8px;
  font-size: clamp(16px, 4vw, 20px);
}

.levels {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.lvl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 104px;
  padding: 12px 16px;
  border: 4px solid transparent;
  border-radius: 22px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: clamp(16px, 4vw, 19px);
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .10);
  transition: transform .12s ease, border-color .12s, background .12s;
}

.lvl-btn small { font-weight: 600; opacity: .65; font-size: 14px; }
.lvl-ico { font-size: 26px; }
.lvl-btn:hover { transform: translateY(-3px); }
.lvl-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .12); }
.lvl-btn.sel { border-color: var(--accent); background: #FFF1EC; }

.big-btn {
  display: block;
  margin: 0 auto;
  padding: 14px 34px;
  border: none;
  border-radius: 22px;
  background: linear-gradient(180deg, #FF9878, var(--accent));
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: clamp(19px, 4.6vw, 24px);
  cursor: pointer;
  box-shadow: 0 6px 0 #D95B3D;
  transition: transform .12s ease, box-shadow .12s ease;
}

.big-btn:hover { transform: translateY(-2px); }
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #D95B3D; }
.big-btn.ghost {
  background: linear-gradient(180deg, #7FD8F6, var(--accent2));
  box-shadow: 0 6px 0 #2E9BC4;
}
.big-btn.ghost:active { box-shadow: 0 2px 0 #2E9BC4; }

.best {
  text-align: center;
  margin: 14px 0 0;
  font-weight: 700;
  opacity: .75;
  font-size: 16px;
}

/* ---------- Прогресс ---------- */
.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.progress-text { font-weight: 800; white-space: nowrap; font-size: clamp(15px, 3.6vw, 18px); }

.bar {
  flex: 1 1 auto;
  height: 14px;
  background: #F0E2D6;
  border-radius: 999px;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #FFC26B, var(--accent));
  transition: width .35s ease;
}

/* ---------- Уравнение ---------- */
.equation {
  text-align: center;
  font-size: clamp(28px, 7vw, 40px);
  font-weight: 900;
  letter-spacing: .5px;
  margin: 6px 0 4px;
  min-height: 1.3em;
}

.equation .num {
  border-radius: 10px;
  padding: 0 4px;
}
.equation .q { color: var(--accent); animation: pulse 1.4s ease-in-out infinite; display: inline-block; }
.equation .q.filled { color: var(--ok); animation: none; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.22); }
}

/* ---------- Весы ---------- */
.scale-area {
  position: relative;
  height: clamp(230px, 39vh, 330px);
  margin: 4px 0 6px;
  touch-action: none;
}

.base {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(58%, 280px);
  height: 22px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--wood), var(--wood-dark));
  border-radius: 12px 12px 14px 14px;
  box-shadow: 0 6px 12px rgba(90, 60, 40, .22);
}

.post {
  position: absolute;
  left: 50%;
  top: 16px;
  bottom: 16px;
  width: 20px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #DDA36C, var(--wood) 45%, var(--wood-dark));
  border-radius: 10px;
}

.beam {
  position: absolute;
  top: 12px;
  left: 50%;
  width: min(96%, 620px);
  height: 16px;
  border-radius: 10px;
  background: linear-gradient(180deg, #FFB36B, #F2913C);
  box-shadow: 0 3px 0 rgba(150, 90, 30, .35);
  transform: translateX(-50%) rotate(var(--tilt));
  transform-origin: 50% 50%;
  transition: transform .7s cubic-bezier(.34, 1.3, .5, 1);
}

.pivot {
  position: absolute;
  left: 50%;
  top: -12px;
  width: 30px;
  height: 30px;
  margin-left: -15px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #FFD08A 60%, #E39B3F);
  box-shadow: 0 2px 6px rgba(120, 70, 20, .35);
}

.arm {
  position: absolute;
  top: 100%;
  width: 0;
  height: 0;
  transform: rotate(calc(-1 * var(--tilt)));
  transform-origin: 50% 0;
  transition: transform .7s cubic-bezier(.34, 1.3, .5, 1);
}

.arm-left { left: 22%; }
.arm-right { left: 78%; }

.rope {
  position: absolute;
  left: 50%;
  top: 0;
  width: 5px;
  height: var(--ropeH);
  margin-left: -2.5px;
  background: var(--wood-dark);
  border-radius: 3px;
}

.pan {
  position: absolute;
  left: 50%;
  top: var(--ropeH);
  transform: translateX(-50%);
  width: max-content;
  min-width: min(150px, 40vw);
  max-width: min(46vw, 300px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Подвес кончается ровно на кромке чаши: при высоте «вся чаша минус 6px»
   его концы уходили ниже кромки и торчали из-под чаши двумя палками —
   верёвка будто протыкала её насквозь. 18px — высота самой чаши. */
.hanger {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: calc(100% - 18px);
  z-index: 0;
  pointer-events: none;
}

.pan-items {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 3px 2px;
  max-width: 100%;
  min-height: calc(var(--wsize) * .92);
  padding: 0;
}

.bowl {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 18px;
  background: linear-gradient(180deg, #7FD8F6, #3FA9D6);
  clip-path: polygon(0 0, 100% 0, 88% 100%, 12% 100%);
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .18));
}

.pan.balanced .bowl { background: linear-gradient(180deg, #8CF0BC, #2FB56E); }

/* «знак + гирька» одним блоком — не разрывается при переносе */
.term {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  flex: 0 0 auto;
}

/* знаки + − внутри чаши */
.sign {
  font-size: calc(var(--wsize) * .5);
  font-weight: 900;
  color: #7A4B2A;
  padding: 0 1px;
  align-self: center;
}

/* ---------- Гирьки ---------- */
.weight {
  position: relative;
  width: var(--wsize);
  height: calc(var(--wsize) * .92);
  padding: 0;
  border: none;
  background: none;
  cursor: grab;
  touch-action: none;
  flex: 0 0 auto;
  transition: transform .12s ease, filter .12s ease;
}

.weight svg { width: 100%; height: 100%; display: block; overflow: visible; }
.weight:hover { transform: translateY(-4px) scale(1.05); }
.weight:active { cursor: grabbing; transform: scale(1.02); }
.weight.dragging-src { opacity: .35; }
.weight.wrong { animation: shake .45s ease; }
.weight.drop-in { animation: drop .4s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px) rotate(-6deg); }
  45% { transform: translateX(9px) rotate(6deg); }
  70% { transform: translateX(-6px) rotate(-4deg); }
}

@keyframes drop {
  0% { transform: translateY(-40px) scale(1.15); }
  70% { transform: translateY(3px) scale(.97); }
  100% { transform: translateY(0) scale(1); }
}

/* пустое место на чаше */
.slot {
  width: var(--wsize);
  height: calc(var(--wsize) * .92);
  border: 4px dashed var(--accent);
  border-radius: 16px;
  background: rgba(255, 255, 255, .88);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--wsize) * .5);
  font-weight: 900;
  color: var(--accent);
  flex: 0 0 auto;
  transition: transform .15s, background .15s, border-color .15s;
}

.slot.over {
  transform: scale(1.12);
  background: #FFF0D6;
  border-color: var(--ok);
}

.slot.wrong { animation: shake .45s ease; border-color: var(--bad); background: #FFE6E9; }

/* ---------- Склад гирек ---------- */
.bank {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(6px, 2vw, 14px);
  min-height: calc(var(--wsize) * 1.05);
  padding: 10px;
  background: rgba(255, 255, 255, .55);
  border-radius: 22px;
  border: 3px dashed #F0C9A8;
}

.bank .weight.used { visibility: hidden; }

/* призрак при перетаскивании */
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--wsize);
  height: calc(var(--wsize) * .92);
  z-index: 999;
  pointer-events: none;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .3));
  transform-origin: 50% 50%;
}

.drag-ghost svg { width: 100%; height: 100%; display: block; overflow: visible; }

/* ---------- Результаты ---------- */
.stars {
  text-align: center;
  font-size: clamp(44px, 12vw, 72px);
  line-height: 1.1;
  margin: 6px 0;
}

.stars span {
  display: inline-block;
  opacity: .18;
  filter: grayscale(1);
  transform: scale(.7);
}

.stars span.on {
  opacity: 1;
  filter: none;
  animation: pop .55s cubic-bezier(.3, 1.6, .5, 1) forwards;
}

@keyframes pop {
  0% { transform: scale(.2) rotate(-30deg); }
  60% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}

.score {
  text-align: center;
  font-size: clamp(20px, 5vw, 26px);
  font-weight: 800;
  margin: 6px 0;
}

.result-btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 16px 0 6px;
}

.parents {
  margin-top: 16px;
  background: #fff;
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 16px;
}

.parents summary {
  cursor: pointer;
  font-weight: 800;
  padding: 6px 2px;
}

.parents ul { margin: 8px 0; padding-left: 20px; }
.parents li { margin-bottom: 8px; line-height: 1.4; }
.parents .child-ans { color: var(--bad); font-weight: 700; }
.parents .right-ans { color: var(--ok); font-weight: 700; }

/* ---------- Конфетти ---------- */
.fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 500;
}

.confetti {
  position: absolute;
  top: -8vh;
  font-size: 26px;
  animation: fall linear forwards;
}

@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(115vh) rotate(540deg); opacity: .9; }
}

/* ---------- Крупные экраны: совёнок в углу ---------- */
@media (min-width: 1000px) {
  .hero-art {
    position: fixed;
    left: 16px;
    bottom: 16px;
    width: 300px;
    z-index: 400;
    align-items: flex-end;
  }
  .app { padding-bottom: 40px; }
}

/* ---------- Узкие экраны ---------- */
@media (max-width: 400px) {
  body { font-size: 17px; }
  .app { padding: 8px 8px 20px; }
  .screen { padding: 12px 8px; border-radius: 20px; }
  .icon-btn { width: 42px; height: 42px; font-size: 19px; }
  .brand-name { font-size: 16px; }
  :root { --wsize: clamp(38px, 12vw, 52px); }
  .pan { min-width: 42vw; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================
   ===============  ИНТЕРЬЕР МАГАЗИНА (фон)  ==================
   ============================================================ */

.shop-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.app { position: relative; z-index: 1; }
.fx  { z-index: 500; }

/* --- стена с обоями --- */
.shop-wall {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg,
      var(--sh-stripe) 0 10px,
      rgba(255, 255, 255, 0) 10px 30px),
    linear-gradient(180deg, var(--sh-wall-a) 0%, var(--sh-wall-b) 55%, var(--sh-wall-c) 100%);
}

/* тёплое пятно света в центре */
.shop-wall::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 55% at 50% 22%,
    var(--sh-glow), rgba(255, 220, 170, 0) 70%);
}

/* --- пол --- */
.shop-floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 20vh;
  background:
    repeating-linear-gradient(90deg,
      var(--sh-floor-line) 0 2px,
      rgba(0, 0, 0, 0) 2px 54px),
    repeating-linear-gradient(180deg,
      rgba(255, 255, 255, .10) 0 1px,
      rgba(0, 0, 0, 0) 1px 26px),
    linear-gradient(180deg, var(--sh-floor-a), var(--sh-floor-b) 60%, var(--sh-floor-c));
  box-shadow: inset 0 10px 18px rgba(90, 55, 25, .22);
}

.shop-floor::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  height: 12px;
  background: linear-gradient(180deg, var(--sh-floor-c), var(--sh-floor-b));
  border-radius: 4px 4px 0 0;
}

/* --- стеллажи с товаром --- */
.rack {
  position: absolute;
  bottom: 20vh;
  width: clamp(90px, 20vw, 210px);
  display: flex;
  flex-direction: column;
  padding: 8px 6px 0;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, var(--sh-rack-a), var(--sh-rack-b));
  box-shadow:
    inset 0 0 0 4px var(--sh-rack-edge),
    0 10px 26px rgba(90, 60, 40, .18);
}

.rack-l { left: 0; }
.rack-r { right: 0; }

.rack-shelf {
  position: relative;
  height: clamp(52px, 8.6vh, 84px);
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  padding: 0 4px 11px;
  font-size: clamp(19px, 2.9vw, 32px);
  line-height: 1;
  filter: drop-shadow(0 3px 3px rgba(90, 60, 40, .22));
}

.rack-shelf::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: 0;
  height: 9px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--sh-shelf-a), var(--sh-shelf-b));
  box-shadow: 0 4px 8px rgba(90, 60, 40, .28);
}

/* --- лампы под потолком --- */
.shop-lamp {
  position: absolute;
  top: 0;
  width: 74px;
  height: 92px;
}

.lamp-l { left: 6vw; }
.lamp-r { right: 6vw; }

.shop-lamp::before {           /* шнур */
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 3px;
  height: 26px;
  margin-left: -1.5px;
  background: var(--sh-shelf-b);
}

.shop-lamp::after {            /* плафон + свет */
  content: "";
  position: absolute;
  left: 0;
  top: 24px;
  width: 74px;
  height: 34px;
  border-radius: 6px 6px 40px 40px;
  background: linear-gradient(180deg, var(--sh-lamp-a), var(--sh-lamp-b));
  box-shadow:
    0 6px 10px rgba(120, 70, 20, .25),
    0 26px 46px 16px var(--sh-lamp-glow);
}

/* --- мелкий реквизит --- */
.shop-cart, .shop-crate {
  position: absolute;
  bottom: 3vh;
  font-size: clamp(34px, 6vw, 62px);
  line-height: 1;
  opacity: .5;
  filter: drop-shadow(0 6px 6px rgba(90, 60, 40, .3));
}

.shop-cart  { right: clamp(90px, 20vw, 210px); margin-right: -14px; }
.shop-crate { right: clamp(90px, 20vw, 210px); margin-right: 52px; opacity: .42; font-size: clamp(26px, 4.4vw, 46px); }

/* карточки экранов — «стеклянные», чтобы магазин просвечивал */
.screen {
  background: rgba(255, 255, 255, .84);
  -webkit-backdrop-filter: blur(9px) saturate(1.12);
  backdrop-filter: blur(9px) saturate(1.12);
}

/* ============================================================
   ==========  ВИТРИНА ПОЗАДИ ВЕСОВ + ПРИЛАВОК  ===============
   ============================================================ */

.shop-scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 20px;
  overflow: hidden;
}

/* весы, стойка и коромысло — поверх витрины */
.base, .post, .beam { z-index: 1; }

.ss-wall {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg,
      var(--sh-stripe) 0 9px,
      rgba(0, 0, 0, 0) 9px 26px),
    linear-gradient(180deg, var(--sh-wall-a), var(--sh-wall-b) 70%, var(--sh-wall-c));
}

.ss-wall::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 60% at 50% 15%,
    var(--sh-glow), rgba(255, 235, 195, 0) 72%);
}

/* маленькие полочки по краям витрины */
.ss-rack {
  position: absolute;
  top: 36px;
  width: 13%;
  min-width: 66px;
}

.ss-rack-l { left: 6px; }
.ss-rack-r { right: 6px; }

.ss-shelf {
  position: relative;
  height: 40px;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  padding: 0 3px 8px;
  font-size: clamp(14px, 3.2vw, 22px);
  line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(90, 60, 40, .2));
}

.ss-shelf::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--sh-shelf-a), var(--sh-shelf-b));
  box-shadow: 0 3px 6px rgba(90, 60, 40, .25);
}

/* прилавок, на котором стоят весы */
.ss-counter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 36px;
  background:
    repeating-linear-gradient(90deg,
      rgba(60, 35, 10, .12) 0 2px,
      rgba(0, 0, 0, 0) 2px 40px),
    linear-gradient(180deg, var(--sh-counter-a), var(--sh-counter-b));
}

.ss-counter::before {           /* столешница */
  content: "";
  position: absolute;
  left: -2%;
  right: -2%;
  top: -12px;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(180deg, var(--sh-top-a), var(--sh-top-b) 60%, var(--sh-top-c));
  box-shadow: 0 5px 10px rgba(90, 60, 40, .3);
}

.ss-counter::after {            /* тень под весами на столешнице */
  content: "";
  position: absolute;
  left: 50%;
  top: -4px;
  width: 46%;
  height: 10px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(60, 35, 10, .28);
  filter: blur(4px);
}

/* товар, расставленный на прилавке рядом с весами */
.ss-goods {
  position: absolute;
  bottom: 44px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  font-size: clamp(17px, 3.6vw, 26px);
  line-height: 1;
  filter: drop-shadow(0 3px 2px rgba(90, 60, 40, .28));
}

.ss-goods-l { left: 8px; }
.ss-goods-r { right: 8px; }

/* весы приподняты — стоят на столешнице прилавка */
.base { bottom: 46px; }
.post { bottom: 56px; }

/* ---------- Магазин на узких экранах ---------- */
@media (max-width: 720px) {
  .shop-lamp { display: none; }
  .rack { width: clamp(72px, 17vw, 120px); }
  .rack-shelf { font-size: clamp(15px, 3.6vw, 22px); height: clamp(44px, 7vh, 64px); }
  .shop-cart, .shop-crate { display: none; }
  .ss-rack { display: none; }
}

@media (max-width: 400px) {
  .ss-counter { height: 30px; }
  .ss-goods { bottom: 38px; }
  .base { bottom: 40px; }
  .post { bottom: 50px; }
}

/* ============================================================
   ===============  ТЕМЫ МАГАЗИНА  ============================
   ============================================================ */

/* по умолчанию — продуктовый магазин */
:root,
body[data-shop="grocery"] {
  --sh-wall-a: #FFF3DE;  --sh-wall-b: #FBE6C9;  --sh-wall-c: #F2D6B2;
  --sh-stripe: rgba(255, 255, 255, .55);
  --sh-glow: rgba(255, 240, 200, .85);
  --sh-shelf-a: #E0AC77; --sh-shelf-b: #A2673A;
  --sh-rack-a: #EFD8B8;  --sh-rack-b: #E3C49F;  --sh-rack-edge: rgba(162, 103, 58, .38);
  --sh-floor-a: #D3A275; --sh-floor-b: #B07E4E; --sh-floor-c: #8E6238;
  --sh-floor-line: rgba(90, 55, 25, .16);
  --sh-counter-a: #B5763F; --sh-counter-b: #8E5A2C;
  --sh-top-a: #F0CCA2;   --sh-top-b: #D19A63;   --sh-top-c: #B5763F;
  --sh-lamp-a: #FFD98C;  --sh-lamp-b: #F2A93C;  --sh-lamp-glow: rgba(255, 216, 140, .45);
  --sh-plate: #7A4B2A;
}

body[data-shop="fruit"] {
  --sh-wall-a: #F6FCE8;  --sh-wall-b: #E7F5CC;  --sh-wall-c: #D3EAAE;
  --sh-stripe: rgba(255, 255, 255, .6);
  --sh-glow: rgba(240, 255, 210, .85);
  --sh-shelf-a: #A9CE74; --sh-shelf-b: #5F8B34;
  --sh-rack-a: #E4F3C6;  --sh-rack-b: #D3E7AC;  --sh-rack-edge: rgba(95, 139, 52, .35);
  --sh-floor-a: #C2DC96; --sh-floor-b: #9CBB6A; --sh-floor-c: #7C9A4E;
  --sh-floor-line: rgba(60, 90, 30, .16);
  --sh-counter-a: #8CB35A; --sh-counter-b: #5F8B34;
  --sh-top-a: #DDF0B6;   --sh-top-b: #B4D482;   --sh-top-c: #8CB35A;
  --sh-lamp-a: #F0FFC4;  --sh-lamp-b: #B7DE6B;  --sh-lamp-glow: rgba(200, 240, 140, .45);
  --sh-plate: #4E7328;
}

body[data-shop="sweets"] {
  --sh-wall-a: #FFF3F8;  --sh-wall-b: #FFE3EF;  --sh-wall-c: #FFCFE2;
  --sh-stripe: rgba(255, 255, 255, .62);
  --sh-glow: rgba(255, 235, 245, .9);
  --sh-shelf-a: #F5AECA; --sh-shelf-b: #C4638B;
  --sh-rack-a: #FFE6F1;  --sh-rack-b: #FFD3E5;  --sh-rack-edge: rgba(196, 99, 139, .32);
  --sh-floor-a: #F3C6DB; --sh-floor-b: #DDA0BF; --sh-floor-c: #BE7EA0;
  --sh-floor-line: rgba(130, 60, 95, .14);
  --sh-counter-a: #DE8FB2; --sh-counter-b: #B4628A;
  --sh-top-a: #FFDFEC;   --sh-top-b: #F2AECB;   --sh-top-c: #DE8FB2;
  --sh-lamp-a: #FFE9F3;  --sh-lamp-b: #FF9DC4;  --sh-lamp-glow: rgba(255, 170, 205, .45);
  --sh-plate: #A64B75;
}

body[data-shop="toys"] {
  --sh-wall-a: #F2F7FF;  --sh-wall-b: #E0EAFF;  --sh-wall-c: #C9D9FB;
  --sh-stripe: rgba(255, 255, 255, .6);
  --sh-glow: rgba(230, 242, 255, .9);
  --sh-shelf-a: #9CBCEC; --sh-shelf-b: #4E6FB0;
  --sh-rack-a: #E4ECFF;  --sh-rack-b: #D0DEFB;  --sh-rack-edge: rgba(78, 111, 176, .32);
  --sh-floor-a: #C3D2F1; --sh-floor-b: #9DB0DA; --sh-floor-c: #7C90BE;
  --sh-floor-line: rgba(45, 65, 115, .14);
  --sh-counter-a: #7E9CD6; --sh-counter-b: #5A79B6;
  --sh-top-a: #DEE8FF;   --sh-top-b: #A9C0EE;   --sh-top-c: #7E9CD6;
  --sh-lamp-a: #EAF2FF;  --sh-lamp-b: #8FB4E8;  --sh-lamp-glow: rgba(160, 200, 255, .45);
  --sh-plate: #3D5B96;
}

body[data-shop="pets"] {
  --sh-wall-a: #EEFBF6;  --sh-wall-b: #D9F3E9;  --sh-wall-c: #C0E7D8;
  --sh-stripe: rgba(255, 255, 255, .6);
  --sh-glow: rgba(226, 252, 242, .9);
  --sh-shelf-a: #8ED4BA; --sh-shelf-b: #3F8E75;
  --sh-rack-a: #DFF6EE;  --sh-rack-b: #C9EDE0;  --sh-rack-edge: rgba(63, 142, 117, .32);
  --sh-floor-a: #AEDDCB; --sh-floor-b: #86BCA6; --sh-floor-c: #689C88;
  --sh-floor-line: rgba(25, 90, 70, .14);
  --sh-counter-a: #66B396; --sh-counter-b: #47907A;
  --sh-top-a: #D3F1E5;   --sh-top-b: #96D2BB;   --sh-top-c: #66B396;
  --sh-lamp-a: #E6FCF4;  --sh-lamp-b: #85DFC1;  --sh-lamp-glow: rgba(150, 235, 205, .45);
  --sh-plate: #2F7A62;
}

body[data-shop="flowers"] {
  --sh-wall-a: #F9F3FF;  --sh-wall-b: #EFE3FC;  --sh-wall-c: #E0CFF4;
  --sh-stripe: rgba(255, 255, 255, .6);
  --sh-glow: rgba(246, 236, 255, .9);
  --sh-shelf-a: #C2A6E4; --sh-shelf-b: #7A5AA8;
  --sh-rack-a: #EFE6FC;  --sh-rack-b: #DFCFF4;  --sh-rack-edge: rgba(122, 90, 168, .3);
  --sh-floor-a: #D0BEE8; --sh-floor-b: #AA92CE; --sh-floor-c: #8B74B0;
  --sh-floor-line: rgba(70, 45, 115, .14);
  --sh-counter-a: #9E82CC; --sh-counter-b: #7A5AA8;
  --sh-top-a: #E9DEF9;   --sh-top-b: #BEA5E2;   --sh-top-c: #9E82CC;
  --sh-lamp-a: #F3EAFF;  --sh-lamp-b: #B99BE6;  --sh-lamp-glow: rgba(200, 175, 245, .45);
  --sh-plate: #614291;
}

body[data-shop="bakery"] {
  --sh-wall-a: #FFF6E8;  --sh-wall-b: #FBE8CE;  --sh-wall-c: #F0D5B0;
  --sh-stripe: rgba(255, 255, 255, .58);
  --sh-glow: rgba(255, 242, 214, .88);
  --sh-shelf-a: #E3B37C; --sh-shelf-b: #9E6733;
  --sh-rack-a: #F5E2C6;  --sh-rack-b: #EACFAA;  --sh-rack-edge: rgba(158, 103, 51, .34);
  --sh-floor-a: #DEB98C; --sh-floor-b: #BB9159; --sh-floor-c: #976E3C;
  --sh-floor-line: rgba(95, 60, 25, .16);
  --sh-counter-a: #C08A4E; --sh-counter-b: #97682F;
  --sh-top-a: #F6D9B2;   --sh-top-b: #DAA96E;   --sh-top-c: #C08A4E;
  --sh-lamp-a: #FFE7BC;  --sh-lamp-b: #F0B457;  --sh-lamp-glow: rgba(255, 220, 150, .45);
  --sh-plate: #7C4E22;
}

body[data-shop="veggies"] {
  --sh-wall-a: #F2FBEC;  --sh-wall-b: #DFF2D2;  --sh-wall-c: #C7E6B4;
  --sh-stripe: rgba(255, 255, 255, .6);
  --sh-glow: rgba(232, 250, 220, .88);
  --sh-shelf-a: #97C777; --sh-shelf-b: #4F7F38;
  --sh-rack-a: #E2F3D6;  --sh-rack-b: #CDE7BB;  --sh-rack-edge: rgba(79, 127, 56, .34);
  --sh-floor-a: #B9D8A2; --sh-floor-b: #93B87A; --sh-floor-c: #74975C;
  --sh-floor-line: rgba(45, 80, 30, .16);
  --sh-counter-a: #82AE64; --sh-counter-b: #5C8842;
  --sh-top-a: #DCEECD;   --sh-top-b: #A9CD8D;   --sh-top-c: #82AE64;
  --sh-lamp-a: #EDFBDF;  --sh-lamp-b: #A6D97F;  --sh-lamp-glow: rgba(185, 235, 150, .45);
  --sh-plate: #3F6B2A;
}

body[data-shop="fish"] {
  --sh-wall-a: #EEF9FF;  --sh-wall-b: #D8EEFA;  --sh-wall-c: #BCDFF2;
  --sh-stripe: rgba(255, 255, 255, .62);
  --sh-glow: rgba(226, 246, 255, .9);
  --sh-shelf-a: #85C2DE; --sh-shelf-b: #2F7396;
  --sh-rack-a: #DCF0FA;  --sh-rack-b: #C4E4F3;  --sh-rack-edge: rgba(47, 115, 150, .32);
  --sh-floor-a: #A9CFE2; --sh-floor-b: #83AEC4; --sh-floor-c: #648EA4;
  --sh-floor-line: rgba(20, 70, 95, .15);
  --sh-counter-a: #5E9DBC; --sh-counter-b: #3E7897;
  --sh-top-a: #CDE9F6;   --sh-top-b: #92C4DE;   --sh-top-c: #5E9DBC;
  --sh-lamp-a: #E4F6FF;  --sh-lamp-b: #7EC6E8;  --sh-lamp-glow: rgba(150, 215, 245, .45);
  --sh-plate: #245D7C;
}

body[data-shop="nuts"] {
  --sh-wall-a: #FBF4E6;  --sh-wall-b: #F0E2C8;  --sh-wall-c: #E0CDA9;
  --sh-stripe: rgba(255, 255, 255, .55);
  --sh-glow: rgba(250, 240, 220, .85);
  --sh-shelf-a: #C9A06B; --sh-shelf-b: #855C2E;
  --sh-rack-a: #EEDFC2;  --sh-rack-b: #DFCBA6;  --sh-rack-edge: rgba(133, 92, 46, .34);
  --sh-floor-a: #CBAF87; --sh-floor-b: #A78A61; --sh-floor-c: #866C48;
  --sh-floor-line: rgba(80, 55, 25, .16);
  --sh-counter-a: #AC8451; --sh-counter-b: #86622F;
  --sh-top-a: #E9D6B4;   --sh-top-b: #C6A473;   --sh-top-c: #AC8451;
  --sh-lamp-a: #FBEBCC;  --sh-lamp-b: #DDB068;  --sh-lamp-glow: rgba(245, 215, 160, .45);
  --sh-plate: #6B4A1E;
}

body[data-shop="cheese"] {
  --sh-wall-a: #FFFAE8;  --sh-wall-b: #FCF0C9;  --sh-wall-c: #F5E0A4;
  --sh-stripe: rgba(255, 255, 255, .6);
  --sh-glow: rgba(255, 250, 220, .9);
  --sh-shelf-a: #E7C766; --sh-shelf-b: #A88526;
  --sh-rack-a: #FBEEC4;  --sh-rack-b: #F2E0A8;  --sh-rack-edge: rgba(168, 133, 38, .32);
  --sh-floor-a: #E1CC8E; --sh-floor-b: #BDA76A; --sh-floor-c: #99854E;
  --sh-floor-line: rgba(90, 75, 20, .15);
  --sh-counter-a: #C7A94E; --sh-counter-b: #9C8130;
  --sh-top-a: #F5E7B0;   --sh-top-b: #DCC578;   --sh-top-c: #C7A94E;
  --sh-lamp-a: #FFF6D2;  --sh-lamp-b: #EDCB6A;  --sh-lamp-glow: rgba(255, 235, 165, .45);
  --sh-plate: #7C6518;
}

body[data-shop="tea"] {
  --sh-wall-a: #F1FAF3;  --sh-wall-b: #DCF0E2;  --sh-wall-c: #C1E2CD;
  --sh-stripe: rgba(255, 255, 255, .6);
  --sh-glow: rgba(228, 248, 236, .9);
  --sh-shelf-a: #8FC7A4; --sh-shelf-b: #427E5A;
  --sh-rack-a: #DEF2E4;  --sh-rack-b: #C7E6D2;  --sh-rack-edge: rgba(66, 126, 90, .32);
  --sh-floor-a: #AFD5BC; --sh-floor-b: #89B398; --sh-floor-c: #6A9179;
  --sh-floor-line: rgba(25, 80, 50, .15);
  --sh-counter-a: #6EAA85; --sh-counter-b: #4B8362;
  --sh-top-a: #D5EEDD;   --sh-top-b: #9BCCAE;   --sh-top-c: #6EAA85;
  --sh-lamp-a: #E7F9EE;  --sh-lamp-b: #8AD3A6;  --sh-lamp-glow: rgba(160, 230, 190, .45);
  --sh-plate: #34694A;
}

/* вывеска магазина на прилавке */
.ss-plate {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  max-width: 84%;
  padding: 2px 10px 3px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .78);
  color: var(--sh-plate);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .18);
}

/* плавная смена оформления */
.shop-bg, .shop-scene { transition: opacity .4s ease; }
body.shop-swap .shop-bg,
body.shop-swap .shop-scene { opacity: 0; }

@media (max-width: 400px) {
  .ss-plate { bottom: 4px; font-size: 10px; padding: 1px 8px 2px; }
}

/* ---------- кнопка возврата на страницу игры ---------- */
/* Игра открыта в рамке сайта (docs/09-games.md), и эта кнопка — её выход:
   она просит страницу закрыть окно игры. Открытая отдельной вкладкой игра
   кнопку убирает — возвращаться неоткуда. */
/* Место, которое кнопка занимает в левом верхнем углу. Игры, у которых там
   своя строка (счёт, прогресс), сдвигают её на эти величины: на широком
   экране вбок, на телефоне вниз — рядом с кнопкой строке уже не хватило бы
   ширины и она полезла бы под кнопки звука справа. */
:root{ --exit-space:124px; --exit-drop:0px; }
@media (max-width:640px){ :root{ --exit-space:0px; --exit-drop:54px; } }

.exit-btn{
  display:inline-flex; align-items:center; gap:6px;
  height:46px; padding:0 16px; flex:none;
  border:none; border-radius:16px;
  background:#fff; color:#3D3455;
  font:inherit; font-size:16px; font-weight:800; line-height:1;
  white-space:nowrap; cursor:pointer;
  box-shadow:0 3px 0 rgba(61,52,85,.12);
}
.exit-btn:hover{ background:#F2EFFF; }
.exit-btn:active{ transform:translateY(2px); box-shadow:0 1px 0 rgba(61,52,85,.12); }
/* Вариант для игр без собственной верхней панели: тот же левый верхний угол,
   только сам по себе. Ниже модальных окон игры (у них z-index от 80). */
.exit-btn--float{ position:fixed; top:10px; left:10px; z-index:60; }
@media (max-width:480px){
  .exit-btn{ height:40px; padding:0 12px; font-size:14px; }
  .exit-btn--float{ top:6px; left:6px; }
}
