:root {
  --glass: rgba(150, 130, 255, 0.14);
  --glass-hover: rgba(150, 130, 255, 0.24);
  --glass-border: rgba(255, 255, 255, 0.16);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.7);
  --accent: #ffd54a;
  --accent-dark: #c79a1a;
  --accent-text: #3a2600;
  --star-off: rgba(255, 255, 255, 0.18);
  --font: "Fredoka", "Nunito", ui-rounded, "Segoe UI Rounded", "Segoe UI", system-ui, sans-serif;
  --logo-font: "Fredoka", ui-rounded, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #0b0820;
  color: var(--text);
  font-family: var(--font);
  user-select: none;
  touch-action: manipulation;
}

button {
  font-family: var(--font);
}

#sky {
  position: fixed;
  inset: 0;
  display: block;
}

svg {
  display: block;
}

/* ---------- екрани ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: none;
  flex-direction: column;
}

body[data-screen="menu"] #menuScreen,
body[data-screen="levels"] #levelsScreen,
body[data-screen="game"] #gameScreen,
body[data-screen="lab"] #labScreen,
body[data-screen="daily"] #dailyScreen,
body[data-screen="home"] #homeScreen {
  display: flex;
}

/* у грі кліки по порожньому місцю мають проходити до canvas */
#gameScreen {
  pointer-events: none;
}

#gameScreen > * {
  pointer-events: auto;
}

#gameScreen #stage {
  flex: 1;
  min-height: 0;
  pointer-events: none;
}

/* ---------- загальні елементи ---------- */
.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass);
  backdrop-filter: blur(6px);
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
}

.coin {
  width: 22px;
  height: 22px;
  flex: none;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass);
  backdrop-filter: blur(6px);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.icon-btn:hover {
  background: var(--glass-hover);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn svg,
.tool svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary {
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 18px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--accent-dark);
  transition: transform 0.1s, box-shadow 0.1s;
}

.primary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--accent-dark);
}

.secondary {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  background: var(--glass);
  backdrop-filter: blur(6px);
  color: var(--text);
  font-weight: 600;
  font-size: 18px;
  cursor: pointer;
}

.secondary:hover {
  background: var(--glass-hover);
}

/* зірка: вимкнена — напівпрозора, увімкнена — золота */
.st path,
.win-stars path {
  fill: var(--star-off);
}

.st.on path,
.win-stars .on path {
  fill: var(--accent);
  stroke: var(--accent-dark);
  stroke-width: 1.2;
}

/* ---------- головне меню ---------- */
#menuScreen {
  align-items: center;
  justify-content: space-between;
  padding: max(28px, 6vh) 16px max(20px, env(safe-area-inset-bottom));
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 2vh;
}

.logo-ufo {
  width: 84px;
  height: 52px;
  margin-bottom: -6px;
  animation: ufo-bob 2.6s ease-in-out infinite;
}

@keyframes ufo-bob {
  50% {
    transform: translateY(-8px) rotate(-4deg);
  }
}

.logo-title {
  font-family: var(--logo-font);
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  line-height: 0.88;
  font-weight: 700;
  font-size: clamp(56px, 17vw, 104px);
  letter-spacing: 0.01em;
}

.logo-title span {
  display: flex;
}

/* кожна літера — желейна, гойдається зі своїм зсувом */
.logo-title i {
  display: inline-block;
  font-style: normal;
  -webkit-text-stroke: 0.06em #2a1660;
  paint-order: stroke fill;
  text-shadow: 0 0.07em 0 #2a1660, 0 0.12em 0.18em rgba(0, 0, 0, 0.45);
  animation: wobble 2.4s ease-in-out infinite;
}

.w1 i {
  color: #7be08a;
}

.w2 i {
  color: #ffd54a;
}

.w1 i:nth-child(2) { color: #5fd3ea; animation-delay: -0.3s; }
.w1 i:nth-child(3) { color: #ff79d5; animation-delay: -0.6s; }
.w1 i:nth-child(4) { color: #ffa53a; animation-delay: -0.9s; }
.w1 i:nth-child(5) { color: #a98bff; animation-delay: -1.2s; }
.w2 i:nth-child(2) { color: #ff6b7e; animation-delay: -0.45s; }
.w2 i:nth-child(3) { color: #7be08a; animation-delay: -0.75s; }
.w2 i:nth-child(4) { color: #5fd3ea; animation-delay: -1.05s; }

@keyframes wobble {
  0%,
  100% {
    transform: translateY(0) scale(1, 1);
  }
  25% {
    transform: translateY(-0.04em) scale(0.96, 1.05);
  }
  50% {
    transform: translateY(0) scale(1.05, 0.95);
  }
}

.logo-tag {
  margin-top: 14px;
  padding: 4px 14px;
  border-radius: 12px;
  background: rgba(20, 12, 50, 0.6);
  color: #bff7ee;
  font-weight: 600;
  font-size: clamp(15px, 4.2vw, 20px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(300px, 100%);
}

.primary.big {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 14px 12px;
  font-size: 28px;
  line-height: 1.05;
  animation: breathe 2.2s ease-in-out infinite;
}

.primary.big small {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.75;
}

@keyframes breathe {
  50% {
    transform: scale(1.04);
  }
}

.menu-bottom {
  display: flex;
  gap: 8px;
  margin-bottom: max(130px, 18vh);
}

/* ---------- вибір рівня ---------- */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
}

/* заголовок посередині між кнопками; довгий — зменшується й переноситься рівно, по центру */
.bar h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: clamp(18px, 5.6vw, 24px);
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
}

.bar > .icon-btn,
.bar > .pill {
  flex: none;
}

.level-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 24px;
  -webkit-overflow-scrolling: touch;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
}

.lvl {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  aspect-ratio: 1;
  padding: 6px 4px;
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  background: var(--glass);
  backdrop-filter: blur(6px);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.lvl:hover {
  background: var(--glass-hover);
}

.lvl:active {
  transform: scale(0.94);
}

.lvl .num {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.lvl-stars {
  display: flex;
  gap: 1px;
}

.lvl-stars .st {
  width: 14px;
  height: 14px;
}

.lvl.current {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 213, 74, 0.35), 0 0 18px rgba(255, 213, 74, 0.35);
  animation: breathe 1.8s ease-in-out infinite;
}

.lvl.locked {
  opacity: 0.45;
  cursor: default;
}

.lvl.locked svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ---------- гра ---------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
}

.hud-side {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.hud .pill {
  padding: 0 12px;
}

.hud-stars {
  display: flex;
  gap: 1px;
}

.hud-stars .st {
  width: 16px;
  height: 16px;
  transition: transform 0.3s;
}

.hud-stars .st:not(.on) {
  transform: scale(0.8);
}

.toolbar {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px 16px max(14px, env(safe-area-inset-bottom));
}

.tool {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 72px;
  padding: 8px 4px 6px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  background: var(--glass);
  backdrop-filter: blur(6px);
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.tool svg {
  width: 26px;
  height: 26px;
}

.tool:hover {
  background: var(--glass-hover);
}

.tool:active {
  transform: scale(0.94);
}

.tool:disabled,
.tool.used {
  opacity: 0.4;
}

/* ціна в монетах або значок реклами, якщо монет бракує */
.price {
  position: absolute;
  top: -8px;
  right: -8px;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 22px;
  padding: 0 7px 0 3px;
  border-radius: 11px;
  background: #2a1a5e;
  border: 1px solid rgba(255, 213, 74, 0.6);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.price .coin {
  width: 15px;
  height: 15px;
}

.price.ad {
  justify-content: center;
  width: 22px;
  padding: 0;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 9px;
}

.coach {
  position: relative;
  z-index: 1;
  display: none;
  align-self: center;
  max-width: min(440px, calc(100% - 32px));
  margin: 10px 16px 0;
  padding: 10px 16px;
  border: 1px solid rgba(255, 213, 74, 0.5);
  border-radius: 16px;
  background: rgba(30, 20, 70, 0.85);
  backdrop-filter: blur(6px);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  animation: coach-in 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.coach.show {
  display: block;
}

@keyframes coach-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 104px;
  z-index: 2;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: rgba(10, 6, 30, 0.85);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- вікно перемоги ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 6, 30, 0.45);
  transition: opacity 0.3s;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.card {
  width: 100%;
  max-width: 330px;
  padding: 24px 22px 20px;
  border: 1px solid var(--glass-border);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(90, 58, 154, 0.96), rgba(40, 26, 90, 0.96));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
  transition: transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.overlay.hidden .card {
  transform: scale(0.8);
}

.card h2 {
  margin: 0 0 10px;
  font-size: clamp(21px, 6.4vw, 26px);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
}

.win-stars {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 6px;
  margin-bottom: 8px;
}

.win-stars svg {
  width: 52px;
  height: 52px;
}

/* середня зірка більша й вища */
.win-stars svg:nth-child(2) {
  width: 66px;
  height: 66px;
  margin-bottom: 10px;
}

.overlay:not(.hidden) .win-stars .on {
  animation: star-pop 0.5s cubic-bezier(0.3, 1.8, 0.5, 1) both;
}

.overlay:not(.hidden) .win-stars .on:nth-child(2) { animation-delay: 0.25s; }
.overlay:not(.hidden) .win-stars .on:nth-child(3) { animation-delay: 0.5s; }

@keyframes star-pop {
  from {
    transform: scale(0) rotate(-40deg);
  }
}

.card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 600;
}

.win-coins {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.win-coins .coin {
  width: 30px;
  height: 30px;
}

.double {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 5px 10px 5px 6px;
  border: 1px solid rgba(255, 213, 74, 0.6);
  border-radius: 14px;
  background: rgba(255, 213, 74, 0.12);
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.double .ad {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 9px;
}

.double:disabled {
  opacity: 0.4;
  cursor: default;
}

.win-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.win-row .icon-btn {
  width: 48px;
  height: 48px;
  padding: 11px;
}

/* ---------- налаштування / пауза ---------- */
.settings h2 {
  margin-bottom: 18px;
}

.setting {
  margin-bottom: 18px;
  text-align: left;
}

.setting-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 17px;
}

.setting-head svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.setting-val {
  margin-left: auto;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* слайдер: заповнена частина золота, повзунок — велике кругле «желе» під палець */
.slider {
  --fill: 50%;
  width: 100%;
  height: 32px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.slider::-webkit-slider-runnable-track {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent) var(--fill), rgba(255, 255, 255, 0.15) var(--fill));
}

.slider::-moz-range-track {
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
}

.slider::-moz-range-progress {
  height: 12px;
  border-radius: 6px;
  background: var(--accent);
}

.slider::-webkit-slider-thumb {
  width: 28px;
  height: 28px;
  margin-top: -8px;
  border: 3px solid var(--accent-dark);
  border-radius: 50%;
  background: #fff3c4;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 3px solid var(--accent-dark);
  border-radius: 50%;
  background: #fff3c4;
}

.slider:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 8px;
}

.pause-only {
  display: none;
}

.in-game .pause-only {
  display: block;
}

.in-game .menu-only {
  display: none;
}

.pause-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.pause-row .secondary {
  font-size: 16px;
}

/* ---------- меню: кнопка лабораторії ---------- */
.menu-row {
  display: flex;
  gap: 10px;
}

.lab-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.lab-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* «можна створити новий Pal» */
.badge-dot {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  border: 2px solid #1a1240;
  border-radius: 50%;
  background: #ff5a6e;
  animation: breathe 1.4s ease-in-out infinite;
}

.badge-dot[hidden] {
  display: none;
}

/* ---------- лабораторія ---------- */
.lab-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 28px;
  -webkit-overflow-scrolling: touch;
}

.lab-scroll > * {
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

.lab-panel {
  padding: 10px 0 14px;
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  background: radial-gradient(ellipse at 50% 80%, rgba(120, 220, 255, 0.12), transparent 60%), rgba(30, 20, 70, 0.55);
  backdrop-filter: blur(6px);
  text-align: center;
}

.lab-panel canvas {
  margin: 0 auto;
}

.pal-name {
  font-size: 24px;
  font-weight: 700;
}

.pal-status {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.pick-label {
  margin-top: 14px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pick {
  display: block;
  cursor: pointer;
}

.lab-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.lab-actions .primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 19px;
}

.lab-actions .primary .coin {
  width: 22px;
  height: 22px;
}

/* не вистачає монет — кнопка лишається активною (пояснює, скільки бракує), але тьмяніша */
.lab-actions .primary.short {
  opacity: 0.6;
}

.lab-actions .primary:disabled {
  opacity: 0.55;
  cursor: default;
}

.free-coins {
  flex: none;
  height: 52px;
  margin-left: 0;
}

.free-coins .coin {
  width: 18px;
  height: 18px;
}

.nudge {
  animation: nudge 0.5s;
}

@keyframes nudge {
  25% { transform: translateX(-5px) scale(1.06); }
  75% { transform: translateX(5px) scale(1.06); }
}

.album-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 26px;
  margin-bottom: 8px;
}

.album-head h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.album-count {
  color: var(--accent);
  font-weight: 700;
}

#albumCanvas {
  display: block;
  cursor: pointer;
}

.album-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.lang-select {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 14px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: rgba(20, 12, 50, 0.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffd54a' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 18px;
  color: var(--text);
  font: 600 16px var(--font);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.lang-select option {
  background: #2a1a5e;
  color: #fff;
}

.lang-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Fredoka не має кирилиці — для української весь інтерфейс на Nunito (округлий, з повною кирилицею).
   Лого латиницею лишається у Fredoka. Nunito візуально тонший, тому трохи важча вага. */
:root:lang(uk) {
  --font: "Nunito", ui-rounded, "Segoe UI Rounded", "Segoe UI", system-ui, sans-serif;
}

:lang(uk) body {
  font-weight: 700;
}

:lang(uk) .pill,
:lang(uk) .tool,
:lang(uk) .secondary,
:lang(uk) .coach,
:lang(uk) .toast,
:lang(uk) .setting-head,
:lang(uk) .pal-status,
:lang(uk) .card p {
  font-weight: 800;
}

:lang(uk) .primary,
:lang(uk) h2,
:lang(uk) h3,
:lang(uk) .pal-name,
:lang(uk) .logo-tag {
  font-weight: 900;
}

/* ---------- головоломка дня ---------- */
.daily-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.daily-btn > svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.flame {
  width: 20px;
  height: 20px;
  flex: none;
}

.streak-chip {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px 2px 4px;
  border-radius: 12px;
  background: rgba(255, 138, 61, 0.18);
  color: #ffb27a;
  font-size: 15px;
  font-weight: 700;
}

.streak-chip[hidden] {
  display: none;
}

.daily-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 28px;
}

.daily-scroll > * {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.daily-card {
  padding: 18px 16px;
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 138, 61, 0.18), transparent 60%), rgba(30, 20, 70, 0.55);
  backdrop-filter: blur(6px);
  text-align: center;
}

.daily-date {
  font-size: 20px;
  font-weight: 700;
}

.daily-diff {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.diff-dots {
  letter-spacing: 3px;
  color: var(--accent);
}

.streak-big {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 10px;
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
}

.streak-big .flame {
  width: 52px;
  height: 52px;
}

.streak-sub {
  color: var(--muted);
  font-weight: 600;
}

.rescue {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 90, 110, 0.6);
  border-radius: 18px;
  background: rgba(255, 90, 110, 0.12);
}

.rescue[hidden] {
  display: none;
}

.rescue p {
  flex: 1;
  margin: 0;
  font-weight: 600;
  font-size: 14px;
}

.rescue .double {
  flex: none;
  margin: 0;
}

/* 7-денна шкала нагород */
.track {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin: 18px auto;
}

.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: var(--glass);
  font-size: 11px;
  font-weight: 600;
}

.day .coin,
.day .st {
  width: 20px;
  height: 20px;
}

.day b {
  font-size: 12px;
  color: var(--accent);
}

.day.done {
  border-color: rgba(123, 224, 138, 0.7);
  background: rgba(123, 224, 138, 0.15);
}

.day.today {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 213, 74, 0.35), 0 0 14px rgba(255, 213, 74, 0.35);
}

.day.prize {
  background: linear-gradient(180deg, rgba(255, 213, 74, 0.25), rgba(255, 213, 74, 0.06));
}

.daily-done {
  margin-top: 4px;
  text-align: center;
}

.daily-done[hidden] {
  display: none;
}

.dd-title {
  font-size: 22px;
  font-weight: 700;
}

.dd-stars {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 8px 0;
}

.dd-stars .st {
  width: 34px;
  height: 34px;
}

.dd-count {
  margin-bottom: 14px;
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#btnDailyPlay[hidden] {
  display: none;
}

/* ---------- вікно перемоги: серія і зоряний Pal ---------- */
.win-streak {
  color: #ffb27a !important;
}

.win-streak[hidden],
.win-star[hidden],
.win-coins[hidden] {
  display: none;
}

.win-star {
  margin: -4px 0 12px;
}

.win-star-title {
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
}

.win-star canvas {
  display: block;
  margin: 0 auto;
}

.win-star-name {
  font-weight: 700;
}

/* ---------- HUD: кнопки не стискаються, довгий підпис рівня обрізається трикрапкою ---------- */
.hud .icon-btn,
.hud .pill {
  flex: none;
}

.hud .level-pill {
  flex: 0 1 auto;
  min-width: 0;
}

.hud .level-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level-pill .cal {
  display: none;
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.level-pill.is-daily .cal {
  display: block;
}

.coach,
.toast,
.card p,
.rescue p {
  text-wrap: balance;
}

/* кнопка за замовчуванням рядкова (inline-block) — margin: auto її не центрує на широкому екрані */
.daily-scroll > button,
.daily-done > button,
.lab-scroll > button {
  display: block;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* сьогоднішній день на шкалі — теж запускає головоломку */
.day.today.playable {
  cursor: pointer;
}

.day.today.playable:hover {
  background: rgba(255, 213, 74, 0.2);
}

/* ---------- «Щасливий множник» ---------- */
.lucky {
  margin: -6px 0 16px;
}

.lucky[hidden] {
  display: none;
}

.lucky-bar {
  position: relative;
  display: flex;
  height: 34px;
  margin: 0 4px 10px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  overflow: visible;
}

.lucky-bar span {
  display: grid;
  place-items: center;
  background: #4a3c8f;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-weight: 700;
}

.lucky-bar span:first-child {
  border-radius: 10px 0 0 10px;
}

.lucky-bar span:nth-last-child(2) {
  border-radius: 0 10px 10px 0;
}

.lucky-bar .x3 {
  background: #6b4fc4;
}

.lucky-bar .x5 {
  background: linear-gradient(180deg, #ffe27a, #f0b41c);
  color: var(--accent-text);
  font-size: 16px;
}

/* стрілка — трикутник зверху і риска через шкалу */
.lucky-needle {
  position: absolute;
  top: -10px;
  bottom: -4px;
  width: 4px;
  margin-left: -2px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
  pointer-events: none;
}

.lucky-needle::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: #fff;
  border-bottom: 0;
}

.lucky-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px 8px 8px;
  border: 1px solid rgba(255, 213, 74, 0.7);
  border-radius: 16px;
  background: rgba(255, 213, 74, 0.14);
  color: var(--accent);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.lucky-btn .ad {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 10px;
}

.lucky-btn:disabled {
  cursor: default;
}

.lucky.claimed .lucky-btn {
  border-color: rgba(123, 224, 138, 0.7);
  background: rgba(123, 224, 138, 0.15);
  color: #7be08a;
}

.lucky.claimed .lucky-btn .ad {
  display: none;
}

#winCoins.pop {
  animation: coin-pop 0.7s ease-out;
}

@keyframes coin-pop {
  30% {
    transform: scale(1.35);
  }
}

#winCoins {
  display: inline-block;
}

/* ---------- запас на кнопках ---------- */
.price.stock {
  justify-content: center;
  min-width: 22px;
  padding: 0 6px;
  border-color: rgba(123, 224, 138, 0.8);
  background: #2c7a44;
  color: #fff;
}

/* ---------- предмети на екрані перемоги ---------- */
.win-items {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 14px;
}

.win-items[hidden] {
  display: none;
}

.item-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px 6px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 700;
  font-size: 15px;
  animation: star-pop 0.5s 0.6s cubic-bezier(0.3, 1.8, 0.5, 1) both;
}

.item-chip small {
  opacity: 0.7;
  font-size: 12px;
}

.item-chip svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.item-chip .ic-frag {
  fill: #ffe68a;
  stroke: #c79a1a;
  stroke-width: 1.2;
}

/* ---------- уламки в лабораторії ---------- */
.frag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-weight: 600;
}

.frag-pips {
  display: flex;
  gap: 5px;
}

.frag-pips i {
  width: 16px;
  height: 16px;
  clip-path: polygon(50% 0, 62% 38%, 100% 42%, 70% 64%, 80% 100%, 50% 78%, 20% 100%, 30% 64%, 0 42%, 38% 38%);
  background: rgba(255, 255, 255, 0.18);
}

.frag-pips i.on {
  background: #ffd54a;
}

/* ---------- космічне колесо ---------- */
.daily-row .daily-btn {
  flex: 1;
}

.wheel-btn {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 56px;
  padding: 10px;
}

.wheel-btn svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  animation: wheel-idle 6s linear infinite;
}

@keyframes wheel-idle {
  to {
    transform: rotate(360deg);
  }
}

.wheel-card {
  position: relative;
  padding-top: 18px;
}

.wheel-card h2 {
  margin-bottom: 0;
}

.wheel-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
}

#wheelCanvas {
  display: block;
  margin: 0 auto;
}

.wheel-result {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  margin: 2px 0 10px;
}

.wheel-result .item-chip {
  animation-delay: 0s;
}

.wheel-result .item-chip .coin {
  width: 20px;
  height: 20px;
}

.wheel-star {
  width: 100%;
  color: var(--accent);
  font-weight: 700;
}

#btnSpin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#btnSpin .ad {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-text);
  color: var(--accent);
  font-size: 10px;
}

#btnSpin:disabled {
  opacity: 0.55;
  cursor: default;
}

.wheel-sub {
  min-height: 18px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.wheel-odds {
  margin: 6px 0 0 !important;
  font-size: 12px !important;
}

/* ---------- меню: плитки Рівні / Лабораторія / Дім ---------- */
.menu-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 8px;
  font-size: 13px;
  line-height: 1.15;
}

.tile > svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- домашня планета ---------- */
.home-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#homeCanvas {
  position: absolute;
  inset: 0;
  display: block;
}

.home-panel {
  width: min(440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 0 max(16px, env(safe-area-inset-bottom));
}

.happy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.happy-row .heart {
  width: 22px;
  height: 22px;
  fill: #ff6b9a;
}

.happy-bar {
  flex: 1;
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.happy-bar i {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #ff8fb3, #ff6b9a);
  transition: width 0.6s ease;
}

.happy-bar i.low {
  background: linear-gradient(90deg, #8f9ccc, #6f7a98);
}

.happy-val {
  min-width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.home-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.home-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 17px;
}

.home-actions .coin,
.home-actions .jelly-ic {
  width: 24px;
  height: 24px;
  flex: none;
}

.jelly-count {
  min-width: 24px;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(58, 38, 0, 0.18);
  font-size: 14px;
}

.jelly-count[hidden] {
  display: none;
}

#btnFeed.buy {
  font-size: 15px;
}

#btnFeed.buy .coin {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
}

#btnFeed:disabled,
#btnCollect:disabled {
  opacity: 0.5;
  cursor: default;
}

#btnCollect b {
  color: var(--accent);
}

#btnCollect.full {
  border-color: var(--accent);
  animation: breathe 1.6s ease-in-out infinite;
}

.home-tip {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  text-wrap: balance;
}

.item-chip .jelly-ic {
  width: 20px;
  height: 20px;
}

/* ---------- магазин стилів планет ---------- */
.style-btn {
  position: absolute;
  top: 8px;
  left: 16px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px 0 10px;
  border: 1px solid var(--glass-border);
  border-radius: 19px;
  background: var(--glass);
  backdrop-filter: blur(6px);
  color: var(--text);
  font: 600 14px var(--font);
  cursor: pointer;
}

.style-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.style-btn svg circle {
  fill: currentColor;
  stroke: none;
}

.shop-card {
  position: relative;
  max-width: 460px;
  overflow-x: hidden;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding-top: 18px;
}

.shop-coins {
  display: flex;
  justify-content: center;
  margin: 2px 0 12px;
}

.shop-coins .pill {
  height: 34px;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.theme-card {
  padding: 8px 8px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  background: rgba(10, 6, 30, 0.35);
}

.theme-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 213, 74, 0.3);
}

.theme-card canvas {
  display: block;
  margin: 0 auto 4px;
}

.theme-name {
  margin-bottom: 8px;
  font-weight: 700;
}

.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: var(--glass);
  color: var(--text);
  font: 700 14px var(--font);
  cursor: pointer;
}

.theme-btn.buy {
  border-color: rgba(255, 213, 74, 0.6);
  color: var(--accent);
}

.theme-btn.buy .coin {
  width: 18px;
  height: 18px;
}

.theme-btn.short {
  opacity: 0.6;
}

.theme-btn.active {
  border-color: rgba(123, 224, 138, 0.7);
  background: rgba(123, 224, 138, 0.15);
  color: #7be08a;
  cursor: default;
}

/* ціна без реклами, коли монет не вистачає */
.price.short {
  opacity: 0.55;
}

#btnFreeCoins[hidden] {
  display: none;
}
