/*
 * Колбы — вид игры. Общий игровой язык (фон, кнопки, меню, окно) — в kit/kit.css;
 * здесь своё: синяя лаборатория, шкаф с полками, инструменты, звёзды итога.
 * Сами колбы и жидкость рисуются на холсте (art.js).
 */

/* ---------- Оттенок игры: глубокий синий ---------- */
/* Верх фона (--bg-top) повторён в <meta name="theme-color">. */
:root {
  --bg-top: #2a5fe6;
  --bg-mid: #1b3fb8;
  --bg-bottom: #0b1a66;
  --glow-a: rgba(96, 230, 255, 0.5);
  --glow-b: rgba(160, 96, 255, 0.46);
  --frame: #3a6ff0;
  --frame-lip: #081a63;
  --pit: #0b1d6e;
  --shade-rgb: 3, 10, 58;
  --deep-rgb: 7, 20, 84;
  --title-hi: #d6e8ff;
  --gear-h: 56px;
}

/* ---------- Фон: пузырьки и соты ---------- */

.sky i {
  background: none;
  box-shadow: none;
  opacity: 0.55;
}

.sky .bub {
  border-radius: 50%;
  background:
    radial-gradient(circle at 31% 27%, rgba(255, 255, 255, 0.85) 0, rgba(255, 255, 255, 0.85) 8%, rgba(255, 255, 255, 0) 12%),
    radial-gradient(circle at 66% 72%, rgba(255, 255, 255, 0.3) 0, rgba(255, 255, 255, 0) 16%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0) 54%, rgba(170, 215, 255, 0.3) 80%, rgba(255, 255, 255, 0.55) 97%, rgba(255, 255, 255, 0) 100%);
}

.sky .hex {
  border-radius: 0;
  opacity: 0.22;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.9), rgba(140, 200, 255, 0.5));
  -webkit-clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
}

/* ---------- Меню ---------- */

/* Значок: три настоящие колбы на холсте, одна переливается в другую. */
.logo.lab-logo {
  position: relative;
  display: block;
  width: 220px;
  height: 204px;
  transform: none;
  animation: lab-bob 3.2s ease-in-out infinite alternate;
}

.lab-logo canvas {
  position: absolute;
  left: 50%;
  top: 0;
  width: 340px;
  height: 100%;
  margin-left: -170px;
}

@media (min-height: 780px) {
  .logo.lab-logo {
    width: 250px;
    height: 240px;
  }
}

@keyframes lab-bob {
  from { transform: translateY(-3px); }
  to { transform: translateY(4px); }
}

.menu .title {
  margin-top: 14px;
}

.menu-best {
  gap: 14px;
}

.best-part {
  display: flex;
  align-items: center;
  gap: 6px;
}

.menu-actions {
  margin-top: 26px;
  gap: 16px;
}

.menu-actions .toggle {
  margin-top: 2px;
}

@media (max-height: 620px) {
  .logo.lab-logo {
    width: 190px;
    height: 170px;
  }

  .menu .title {
    margin-top: 8px;
  }

  .menu-best {
    margin-top: 10px;
    height: 30px;
  }

  .menu-actions {
    margin-top: 16px;
    gap: 12px;
  }

  .menu-actions .btn-big {
    height: 58px;
  }

  .menu-actions .btn-two {
    height: 54px;
  }
}

/* Живая картинка в правилах. */
.card .demo {
  display: block;
  width: 280px;
  max-width: 100%;
  height: 180px;
  margin-bottom: 10px;
}

/* Правила: три короткие строки со значками-фишками. */
.card .rules {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.rules li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 700;
  line-height: 20px;
  color: #fff;
}

.rules .chip {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 13px;
  color: #fff;
}

.rules .chip .ico {
  width: 22px;
  height: 22px;
  stroke-width: 2.8;
}

.rules .r-tap {
  background: linear-gradient(180deg, #62d4ff 0%, #1f9ef6 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55), 0 3px 0 #0c62b8;
}

.rules .r-pour {
  background: linear-gradient(180deg, #ff8f9b 0%, #f2334c 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 3px 0 #9c1830;
}

.rules .r-star {
  background: linear-gradient(180deg, #ffe066 0%, #ffbf1f 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.65), 0 3px 0 #c97b00;
  color: #7a4300;
}

@media (max-height: 620px) {
  .card .demo {
    height: 140px;
    margin-bottom: 4px;
  }

  .card .rules {
    gap: 8px;
    margin-top: 10px;
  }

  .rules li {
    font-size: 15px;
  }

  .rules .chip {
    width: 32px;
    height: 32px;
  }

  .over-full .card.help {
    padding-top: 14px;
    padding-bottom: 18px;
  }
}

/* ---------- Уровень и ходы ---------- */

.lvl {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  height: 56px;
}

.lvl-word {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #d6e8ff;
  text-shadow: 0 3px 0 rgba(var(--deep-rgb), 0.6);
}

.lvl .score {
  min-width: 0.6em;
}

/* Пятизначный номер уровня пишется мельче, чтобы строка не вылезла. */
.lvl .score.long {
  font-size: 34px;
}

.sub {
  gap: 7px;
}

.tag {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 26px;
  padding: 0 11px;
  border-radius: 13px;
  font-size: 13.5px;
  font-weight: 800;
  line-height: 26px;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.tag-goal .ico {
  width: 15px;
  height: 15px;
  color: var(--c4);
  filter: drop-shadow(0 1px 0 rgba(120, 70, 0, 0.7));
}

.tag-goal .ico.off {
  color: rgba(255, 255, 255, 0.22);
  filter: none;
}

.tag-goal .ico.lost {
  animation: star-lost 0.34s ease-out;
}

@keyframes star-lost {
  0% { transform: scale(1); color: var(--c4); }
  45% { transform: scale(1.45); color: #ff8a5c; }
  100% { transform: scale(1); }
}

.tag-goal b {
  margin-left: 4px;
  font-weight: 800;
}

.tag.is-dead {
  background: linear-gradient(180deg, #ff9a3d, #ff4d5e);
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.45), 0 2px 0 #b3202f;
}

@media (max-height: 620px) {
  .lvl {
    height: 44px;
    gap: 8px;
  }

  .lvl-word {
    font-size: 17px;
  }

  .sub {
    height: 24px;
    margin-top: 0;
  }

  .tag {
    height: 24px;
    line-height: 24px;
  }
}

/* ---------- Шкаф: рамка, полки, гнёзда ---------- */

.well {
  background:
    linear-gradient(118deg, rgba(255, 255, 255, 0) 18%, rgba(255, 255, 255, 0.055) 19%, rgba(255, 255, 255, 0.055) 30%, rgba(255, 255, 255, 0) 31%, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0.035) 39%, rgba(255, 255, 255, 0.035) 43%, rgba(255, 255, 255, 0) 44%),
    radial-gradient(120% 70% at 50% 0%, rgba(74, 128, 255, 0.5) 0%, rgba(74, 128, 255, 0) 62%),
    linear-gradient(180deg, #102a8a 0%, var(--pit) 55%, #081656 100%);
}

.board {
  width: var(--fit-w, 300px);
  height: var(--fit-h, 300px);
}

.rack,
.slots {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.rack {
  pointer-events: none;
}

/* Свет из-за полки: мягкая полоса за каждым рядом колб. */
.rack .beam {
  position: absolute;
  background: radial-gradient(50% 100% at 50% 100%, rgba(120, 175, 255, 0.32) 0%, rgba(96, 150, 255, 0.12) 55%, rgba(96, 150, 255, 0) 100%);
}

/* Полка: толстая доска, видимая чуть сверху — светлая верхняя плоскость (--plane) и тёмный торец. */
.rack .shelf {
  position: absolute;
  border-radius: 9px 9px 11px 11px;
  background: linear-gradient(
    180deg,
    #b9d6ff 0,
    #8dbcff 2px,
    #6ea4ff calc(var(--plane, 8px) - 1px),
    #dcebff calc(var(--plane, 8px) - 1px),
    #dcebff var(--plane, 8px),
    #3468e6 var(--plane, 8px),
    #1f47bd 100%
  );
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, 0.7),
    inset 0 -2px 0 rgba(6, 24, 104, 0.45),
    0 4px 0 #0a2488,
    0 10px 12px rgba(var(--shade-rgb), 0.6);
}

/* Гнездо под колбу: лунка, утопленная в верхнюю плоскость полки, с тенью под ближним краем. */
.rack .cup {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 20%, #030c40 0%, #0a2488 70%, #2450c4 100%);
  box-shadow:
    inset 0 3px 4px rgba(0, 4, 40, 0.85),
    inset 0 -1px 0 rgba(170, 205, 255, 0.35),
    0 1px 0 rgba(255, 255, 255, 0.55);
}

.scene {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

.slots {
  z-index: 3;
}

.slot {
  position: absolute;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: none;
  touch-action: none;
}

.slot:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -3px;
}

/* Надпись, вылетающая из собранной колбы. */
.well .gain {
  font-size: 24px;
  color: #ffe37a;
}

/* ---------- Инструменты: назад, подсказка, запасная колба ---------- */

.gear {
  flex: none;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  max-width: var(--col, 460px);
  height: var(--gear-h);
  padding-top: 6px;
}

.tool {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  height: 46px;
  padding: 0 7px;
  border: 0;
  border-radius: 17px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 0.06s ease-out, box-shadow 0.06s ease-out, filter 0.15s ease-out;
}

.tool .ico {
  width: 21px;
  height: 21px;
  stroke-width: 2.6;
}

@media (max-width: 380px) {
  .gear {
    gap: 8px;
  }

  .tool {
    font-size: 13.5px;
  }
}

.tool > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool:active {
  transform: translateY(4px);
}

.tool-undo {
  background: linear-gradient(180deg, #62d4ff 0%, #1f9ef6 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55), 0 4px 0 #0c62b8, 0 8px 12px rgba(var(--shade-rgb), 0.4);
  text-shadow: 0 1px 0 rgba(8, 60, 130, 0.6);
}

.tool-undo:active {
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55), 0 0 0 #0c62b8;
}

.tool-hint {
  background: linear-gradient(180deg, #ffe066 0%, #ffbf1f 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.65), 0 4px 0 #c97b00, 0 8px 12px rgba(var(--shade-rgb), 0.4);
  color: #5a3100;
}

.tool-hint:active {
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.65), 0 0 0 #c97b00;
}

.tool-tube {
  background: linear-gradient(180deg, #7bef8f 0%, #26bd5c 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55), 0 4px 0 #0f7d3b, 0 8px 12px rgba(var(--shade-rgb), 0.4);
  text-shadow: 0 1px 0 rgba(8, 90, 40, 0.6);
}

.tool-tube:active {
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55), 0 0 0 #0f7d3b;
}

.tool:disabled {
  filter: saturate(0.25) brightness(0.82);
  opacity: 0.62;
}

.tool:disabled:active {
  transform: none;
}

/* Сколько осталось: красная фишка на углу кнопки. */
.badge {
  position: absolute;
  top: -7px;
  right: -4px;
  min-width: 23px;
  height: 23px;
  padding: 0 6px;
  border-radius: 12px;
  background: linear-gradient(180deg, #ff7f86 0%, #f2334c 100%);
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.55), 0 2px 0 #9c1830, 0 3px 5px rgba(var(--shade-rgb), 0.4);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 23px;
  text-align: center;
  text-shadow: 0 1px 0 rgba(120, 10, 30, 0.6);
  font-variant-numeric: tabular-nums;
}

.tool:disabled .badge {
  display: none;
}

/* Кнопка просит внимания: «верните ход». */
.tool.nudge {
  animation: tool-nudge 0.9s ease-in-out infinite;
}

@keyframes tool-nudge {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-4px) scale(1.05); }
  60% { transform: translateY(0) scale(1); }
}

.foot {
  height: 24px;
  font-size: 14.5px;
  font-weight: 700;
  color: #dbe8ff;
  text-shadow: 0 1px 0 rgba(var(--shade-rgb), 0.5);
  white-space: nowrap;
}

/* Сообщение игроку подпрыгивает: say() в app.js. */
.foot.pop {
  color: #fff;
  animation: foot-pop 0.36s cubic-bezier(0.3, 1.7, 0.5, 1);
}

@keyframes foot-pop {
  0% { transform: translateY(8px) scale(0.86); opacity: 0.2; }
  100% { transform: none; opacity: 1; }
}

/* ---------- Тупик: плашка с выходами ---------- */

.stuck {
  position: absolute;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 6;
  width: min(var(--col, 460px), calc(100% - 24px));
  padding: 9px 10px 12px;
  border-radius: 22px;
  background: linear-gradient(180deg, #17349c 0%, var(--pit) 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.18),
    0 0 0 3px #ff9a3d,
    0 6px 0 3px #b3501a,
    0 16px 24px rgba(var(--shade-rgb), 0.6);
  transform: translateX(-50%);
  animation: stuck-in 0.36s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}

.stuck[hidden] {
  display: none;
}

@keyframes stuck-in {
  from { transform: translateX(-50%) translateY(40px) scale(0.92); opacity: 0; }
}

.stuck-title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 900;
  line-height: 22px;
  text-align: center;
  color: #ffd9a3;
  text-shadow: 0 2px 0 rgba(var(--shade-rgb), 0.6);
}

.stuck-actions {
  display: flex;
  gap: 8px;
}

.stuck .tool {
  flex: 1 1 0;
}

.stuck .tool[hidden] {
  display: none;
}

.tool-again {
  background: linear-gradient(180deg, #8f9dff 0%, #5a63e8 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 4px 0 #2f35a8, 0 8px 12px rgba(var(--shade-rgb), 0.4);
  text-shadow: 0 1px 0 rgba(30, 30, 120, 0.6);
}

.tool-again:active {
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 0 0 #2f35a8;
}

/* Под плашкой обычные инструменты не видны и не нажимаются. */
.is-stuck .gear,
.is-stuck .foot {
  visibility: hidden;
}

/* ---------- Цели касания не меньше 44 px ---------- */
/* Классы набора; в сам набор передано как недочёт. */

.card .btn-ghost {
  min-width: 64px;
  height: 44px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.13));
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.28), 0 3px 0 rgba(3, 10, 58, 0.6);
}

.card .btn-ghost:active {
  transform: translateY(3px);
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.28), 0 0 0 rgba(3, 10, 58, 0.6);
}

.lang-btn {
  min-height: 44px;
}

@media (max-height: 620px) {
  :root {
    --gear-h: 52px;
  }

  .tool {
    height: 44px;
    border-radius: 15px;
  }

  .gear {
    padding-top: 4px;
  }

  .foot {
    height: 20px;
    font-size: 13px;
    line-height: 15px;
  }
}

/* ---------- Итог уровня: звёзды ---------- */

.stars-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  height: 78px;
  margin-bottom: 10px;
}

.star {
  position: relative;
  width: 62px;
  height: 62px;
}

.star:nth-child(2) {
  width: 78px;
  height: 78px;
}

.star:nth-child(1) {
  transform: rotate(-12deg);
}

.star:nth-child(3) {
  transform: rotate(12deg);
}

.star svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.star .on {
  transform-origin: 50% 55%;
  transform: scale(0);
  opacity: 0;
}

.star.lit .on {
  animation: star-pop 0.5s cubic-bezier(0.3, 1.8, 0.5, 1) both;
  animation-delay: var(--d, 0ms);
}

@keyframes star-pop {
  0% { transform: scale(0) rotate(-50deg); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.card.result .over-title {
  font-size: 21px;
}

.card.result .over-note {
  height: auto;
  min-height: 28px;
  margin-top: 8px;
  padding: 4px 14px;
  line-height: 20px;
  white-space: normal;
  text-wrap: balance;
}

@media (max-height: 620px) {
  .stars-row {
    height: 62px;
    margin-bottom: 6px;
  }

  .star {
    width: 50px;
    height: 50px;
  }

  .star:nth-child(2) {
    width: 62px;
    height: 62px;
  }

  .over-full .card.result {
    padding-top: 16px;
    padding-bottom: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .star .on {
    transform: none;
    opacity: 1;
  }

  .tool.nudge,
  .foot.pop,
  .stuck,
  .tag-goal .ico.lost,
  .logo.lab-logo {
    animation: none !important;
  }
}
