:root {
  /* Цвета берём из темы Telegram, а в обычном браузере — свои */
  --bg: var(--tg-theme-bg-color, #fff8f3);
  --text: var(--tg-theme-text-color, #2a2230);
  --hint: var(--tg-theme-hint-color, #9a8f99);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --accent: var(--tg-theme-button-color, #ff7a9a);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);

  --sky-1: #ffe7dc;
  --sky-2: #fff4ec;
  --night-1: #1b1d42;
  --night-2: #34326a;

  --good: #4cc38a;
  --mid: #f5b83d;
  --bad: #f25c54;
}

@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #17151c;
    --text: #f1eaf2;
    --hint: #8d8494;
    --card: #26222c;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 0 calc(74px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }

button { font: inherit; color: inherit; border: 0; cursor: pointer; background: none; }

/* ---------- сцена с питомцем ---------- */

.stage {
  position: relative;
  touch-action: none;   /* жесты на сцене не должны прокручивать страницу и обрывать расчёсывание */
  height: min(52vh, 440px);
  min-height: 300px;
  background:
    radial-gradient(ellipse at 50% 115%, rgba(255,255,255,.75) 0 30%, transparent 60%),
    linear-gradient(180deg, var(--sky-1), var(--sky-2));
  border-radius: 0 0 28px 28px;
  overflow: hidden;
  transition: background 1s;
}
.stage::before {
  /* звёзды — видны только ночью */
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1s;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 8%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 44% 22%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 63% 12%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 82% 20%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 90% 6%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 7% 34%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 72% 32%, #fff 50%, transparent 51%);
}
.stage::after {
  /* луна */
  content: "";
  position: absolute;
  top: 58px; right: 28px;
  width: 34px; height: 34px;
  border-radius: 50%;
  box-shadow: -9px 4px 0 0 #fff3c4;
  opacity: 0;
  transition: opacity 1s;
}
.stage.night { background: linear-gradient(180deg, var(--night-1), var(--night-2)); }
.stage.night::before, .stage.night::after { opacity: 1; }
.stage.night .top, .stage.night .sub { color: #f1eaf2; }

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
  touch-action: none;
}

.top {
  position: absolute;
  z-index: 2;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.who { text-align: left; padding: 0; }
.name { font-size: 22px; font-weight: 800; letter-spacing: -.2px; }
.sub { color: color-mix(in srgb, var(--text) 55%, transparent); font-size: 13px; }
.badge {
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(8px);
  color: #2a2230;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hint);
}

.bubble {
  position: absolute;
  z-index: 2;
  left: 16px; right: 16px; bottom: 12px;
  margin: 0 auto;
  width: fit-content;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  color: #2a2230;
  border-radius: 16px;
  text-align: center;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
  transition: transform .18s, opacity .3s;
  pointer-events: none;
}
.bubble.pop { transform: scale(1.05); }

/* ---------- шкалы ---------- */

#petPanel, #streetPanel, #foundPanel { padding: 14px 16px 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  gap: 8px;
  margin-bottom: 12px;
}
.stat {
  background: var(--card);
  border-radius: 14px;
  padding: 7px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.stat .ico { font-size: 17px; line-height: 1; }
.stat .bar {
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--hint) 22%, transparent);
  overflow: hidden;
}
.stat .fill { height: 100%; border-radius: 99px; transition: width .6s, background .6s; }
.stat.low .ico { animation: shake .6s infinite; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }

/* ---------- кнопки ---------- */

.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.actions button {
  background: var(--card);
  border-radius: 16px;
  padding: 10px 4px 9px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: transform .1s, opacity .2s;
}
.actions button b { font-weight: 500; }
.actions button span { font-size: 24px; line-height: 1.1; }
.actions button:active { transform: scale(.94); }
.actions button:disabled { opacity: .35; }
.actions button.alert { box-shadow: 0 0 0 2px var(--bad) inset; }

.panel {
  background: var(--card);
  border-radius: 18px;
  padding: 14px;
  text-align: center;
}
.game-title { font-weight: 600; margin-bottom: 10px; }
.game-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game-score { font: 700 22px/1 -apple-system, sans-serif; font-variant-numeric: tabular-nums; }
button.big {
  width: 86px;
  height: 56px;
  border-radius: 16px;
  font-size: 24px;
  background: var(--accent);
  color: var(--accent-text);
}
button.big:active { transform: scale(.94); }
button.big:disabled { opacity: .4; }
button.link { color: var(--hint); margin-top: 8px; padding: 6px 12px; }
button.primary, button.secondary {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 650;
  font-size: 16px;
}
button.primary:active { transform: scale(.98); }
button.primary:disabled { opacity: .5; }
button.secondary { background: color-mix(in srgb, var(--hint) 18%, transparent); color: var(--text); }
.dead-text { margin-bottom: 12px; }

/* ---------- выбор питомца ---------- */

#createPanel { background: none; text-align: left; }
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--card);
  border-radius: 16px;
  margin-bottom: 14px;
}
.seg button {
  padding: 11px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 16px;
  transition: background .2s;
}
.seg button.active { background: var(--accent); color: var(--accent-text); }
.swatch-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.swatches { display: flex; gap: 10px; }
.swatches button {
  width: 40px; height: 40px;
  border-radius: 50%;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.08), 0 0 0 2px var(--bg), 0 0 0 2px color-mix(in srgb, var(--hint) 25%, transparent);
  transition: transform .15s, box-shadow .15s;
}
.swatches button.active { transform: scale(1.1); box-shadow: inset 0 -4px 0 rgba(0,0,0,.08), 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.swatch-name { color: var(--hint); font-size: 14px; }
.name-row { display: flex; gap: 8px; margin-bottom: 12px; }
.name-row input, .sheet input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 17px;
  padding: 13px 14px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: var(--card);
  color: var(--text);
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.name-row input:focus, .sheet input:focus { border-color: var(--accent); }
.dice { width: 52px; border-radius: 14px; background: var(--card); font-size: 22px; }
.dice:active { transform: rotate(40deg); }

/* ---------- списки ---------- */

.view:not(#view-pet) { padding: 14px 16px 0; }
h2 { margin: 6px 0 2px; font-size: 22px; }
.hint { color: var(--hint); font-size: 13px; margin: 0 0 12px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 16px;
  padding: 10px 12px;
}
.row.me { box-shadow: 0 0 0 2px var(--accent) inset; }
.row .rank { width: 22px; font-weight: 700; color: var(--hint); text-align: center; }
.row .ava {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex: none;
}
.row .info { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { color: var(--hint); font-size: 12px; }
.row .right { font-weight: 600; font-size: 13px; white-space: nowrap; }
.empty { color: var(--hint); text-align: center; padding: 30px 0; }

/* ---------- нижние вкладки ---------- */

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 6px 16px calc(6px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid color-mix(in srgb, var(--hint) 18%, transparent);
}
.tabs button {
  flex: 1;
  max-width: 140px;
  font-size: 20px;
  padding: 4px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: .5;
}
.tabs button span { font-size: 11px; }
.tabs button.active { opacity: 1; background: var(--card); }

/* ---------- окно имени ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
}
.sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet input { width: 100%; margin: 10px 0 12px; }
.sheet-title { font-size: 20px; font-weight: 700; }
.sheet-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.error {
  position: fixed;
  left: 16px; right: 16px; top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bad);
  color: #fff;
  text-align: center;
  z-index: 20;
}

@media (max-height: 650px) {
  .stage { height: 44vh; min-height: 250px; }
  .actions button { padding: 7px 4px 6px; }
  .actions button span { font-size: 20px; }
}

/* ---------- улица и профиль ---------- */

.street-hint { margin: 0 2px 14px; }
.story-card {
  background: var(--card);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.story { font-size: 15px; line-height: 1.45; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--hint) 16%, transparent);
}
.chip.hurt { background: color-mix(in srgb, var(--bad) 16%, transparent); color: color-mix(in srgb, var(--bad) 80%, var(--text)); }
.sheet .story { margin: 10px 0; color: color-mix(in srgb, var(--text) 80%, transparent); }
.sheet .chips { margin-bottom: 14px; }
.meter { display: flex; justify-content: space-between; font-size: 14px; margin: 10px 0 5px; }
.meter b { font-weight: 600; }
.bar.wide {
  height: 8px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--hint) 22%, transparent);
  overflow: hidden;
}
.bar.wide .fill { height: 100%; border-radius: 99px; transition: width .6s; }

/* улица: серо и дождь */
.stage.street { background: linear-gradient(180deg, #b4bbc6, #dde1e7); }
.stage.street::before {
  opacity: .55;
  background-image: repeating-linear-gradient(105deg, transparent 0 22px, rgba(255,255,255,.7) 22px 23px, transparent 23px 46px);
  background-size: 230px 230px;
  animation: rain .5s linear infinite;
}
@keyframes rain { to { background-position: -60px 230px; } }

.limit {
  margin-top: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--hint);
}
.limit .dots { letter-spacing: 2px; color: var(--accent); }
.limit .income {
  margin-left: 8px;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--card);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
#coinBadge { cursor: pointer; }
.tiers { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.tier { display: flex; justify-content: space-between; padding: 7px 12px; border-radius: 10px; background: var(--card); font-size: 14px; }
.tier.on { box-shadow: 0 0 0 2px var(--accent) inset; }

/* ---------- шапка: переключатель питомцев и значки ---------- */

.who-wrap { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.badges { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.switch { display: flex; gap: 6px; flex-wrap: wrap; }
.switch button {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.55);
  backdrop-filter: blur(6px);
  color: #2a2230;
}
.switch button.active { background: var(--accent); color: var(--accent-text); }

/* ---------- событие ---------- */

.event {
  position: absolute;
  z-index: 3;
  left: 12px; right: 12px; bottom: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  color: #2a2230;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  animation: drop .35s ease-out;
}
@keyframes drop { from { transform: translateY(-12px); opacity: 0; } }
.event-text { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.event-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.event-buttons button {
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
}
.stage.storm::before {
  opacity: .6;
  background-image: repeating-linear-gradient(100deg, transparent 0 16px, rgba(190,210,255,.7) 16px 17px, transparent 17px 34px);
  background-size: 200px 200px;
  animation: rain .35s linear infinite;
}
.stage.flash { filter: brightness(2.2); }

/* ---------- доп. действия ---------- */

.extras {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 10px -16px 0;
  padding: 2px 16px 4px;
  scrollbar-width: none;
}
.extras::-webkit-scrollbar { display: none; }
.extras button {
  flex: none;
  padding: 9px 13px;
  border-radius: 14px;
  background: var(--card);
  font-size: 13px;
  white-space: nowrap;
}
.extras button:disabled { opacity: .4; }
.extras button:active { transform: scale(.95); }
.mode-hint { color: var(--hint); font-size: 13px; margin: -4px 0 10px; }
#modeBar { margin: 4px 0 6px; }

/* ---------- общий лист ---------- */

.sheet { max-height: 82vh; display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.close { width: 34px; height: 34px; border-radius: 50%; background: var(--card); font-size: 15px; }
.sheet-body { overflow-y: auto; margin: 0 -16px; padding: 0 16px 4px; }
.sheet-body .story { margin: 0 0 10px; }
.sheet-body h4 { margin: 16px 0 8px; font-size: 15px; }
.trait {
  display: flex; gap: 10px; align-items: center;
  background: var(--card); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px;
}
.trait b { display: block; }
.trait span { color: var(--hint); font-size: 13px; }

.rows { display: flex; flex-direction: column; gap: 8px; }
.svc {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 14px; padding: 10px 12px;
}
.svc .ico { font-size: 26px; width: 32px; text-align: center; }
.svc .info { flex: 1; min-width: 0; }
.svc .info b { display: block; font-weight: 600; }
.svc .info span { color: var(--hint); font-size: 12px; }
.svc .bar.wide { margin-top: 6px; height: 6px; }
.svc .btns { display: flex; flex-direction: column; gap: 4px; }
.svc .btns button, .pill-btn {
  padding: 7px 11px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.svc .btns button.ghost, .pill-btn.ghost { background: color-mix(in srgb, var(--hint) 18%, transparent); color: var(--text); }
.svc .btns button:disabled, .pill-btn:disabled { opacity: .45; }

.items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.item {
  background: var(--card);
  border-radius: 14px;
  padding: 10px 6px;
  text-align: center;
  font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.item .swatch { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.item.on { box-shadow: 0 0 0 2px var(--accent) inset; }
.item .price { font-weight: 700; }

.ach { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ach div {
  background: var(--card); border-radius: 12px; padding: 8px 4px; text-align: center; font-size: 10px; line-height: 1.2;
}
.ach div span { display: block; font-size: 24px; margin-bottom: 2px; }
.ach div.off { opacity: .3; filter: grayscale(1); }

/* ---------- альбом ---------- */

.album { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.album figure, .ba figure { margin: 0; background: var(--card); border-radius: 14px; overflow: hidden; }
.album img, .ba img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.album figcaption, .ba figcaption { padding: 6px 8px 8px; font-size: 12px; }
.album figcaption span { display: block; color: var(--hint); font-size: 11px; }
.ba { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.ba-title { font-weight: 700; margin-bottom: 8px; }
.photo-big { width: 100%; border-radius: 14px; margin-bottom: 12px; }

/* ---------- гости, память ---------- */

.visit-info { text-align: center; color: var(--hint); font-size: 13px; margin-bottom: 10px; }
#visitPanel { padding: 14px 16px 0; }
#visitPanel .secondary { margin-top: 10px; }
.sub-title { margin: 20px 0 10px; font-size: 17px; }
.list > .sub-title:first-child { margin-top: 4px; }

/* Ремонт: палитра кружками и полоса «Покрасить» */
.colors {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; margin: 0 -2px 4px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.color {
  flex: 0 0 auto; width: 62px; padding: 6px 2px; border-radius: 14px; background: var(--card);
  display: flex; flex-direction: column; align-items: center; gap: 4px; scroll-snap-align: start;
  font-size: 10px; line-height: 1.15; color: var(--hint); text-align: center;
}
.color span { width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.14); }
.color.on { box-shadow: 0 0 0 2px var(--text) inset; color: var(--text); }
.color.pick { box-shadow: 0 0 0 2px var(--accent) inset; color: var(--text); }
.paint-bar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 8px; border-radius: 14px; background: var(--card); box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.paint-bar > div { flex: 1; display: flex; flex-direction: column; font-size: 14px; }
.paint-bar span { font-size: 12px; color: var(--hint); }
.paint-bar button { padding: 9px 12px; border-radius: 12px; font-size: 13px; }
.row .pill-btn { flex: none; }

.toast {
  position: fixed;
  left: 50%; top: 14px;
  transform: translateX(-50%);
  z-index: 30;
  padding: 10px 16px;
  border-radius: 14px;
  background: #2a2230;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: drop .3s ease-out;
  max-width: calc(100% - 32px);
  text-align: center;
}

/* двор на прогулке */
.stage.park { background: linear-gradient(180deg, #bfe3ff, #eaf7ff); }
.stage.park::before, .stage.park::after { opacity: 0; }

/* ---------- вкладки действий: компактно ---------- */

.groups {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--card);
  border-radius: 14px;
  margin-bottom: 8px;
}
.groups button {
  flex: 1;
  position: relative;
  padding: 7px 2px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  color: color-mix(in srgb, var(--text) 65%, transparent);
}
.groups button.active { background: var(--accent); color: var(--accent-text); }
.groups .dot {
  position: absolute;
  top: 4px; right: 6px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 0 2px var(--card);
}
.tools {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
}
.tools button {
  background: var(--card);
  border-radius: 14px;
  padding: 7px 2px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  transition: transform .1s, opacity .2s;
  min-width: 0;
}
.tools button span { font-size: 21px; line-height: 1.1; }
.tools button b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tools button:active { transform: scale(.94); }
.tools button:disabled { opacity: .35; }
.tools button.alert { box-shadow: 0 0 0 2px var(--bad) inset; }
.stats { margin-bottom: 8px; }
.stats.few { grid-template-columns: repeat(auto-fit, 56px); justify-content: center; }
.stat.hidden { display: none; }

/* обучение: подсказка над кнопками */
.tut {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 10px 12px;
  border-radius: 14px; background: color-mix(in srgb, var(--accent) 16%, var(--card));
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent) inset;
  font-size: 14px; line-height: 1.35; animation: tutIn .35s ease;
}
.tut-text { flex: 1; }
.tut-btn { flex: 0 0 auto; padding: 6px 10px; border-radius: 10px; background: transparent; color: var(--hint); font-size: 12px; }
@keyframes tutIn { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.tools button.tut-pulse { animation: tutPulse 1.2s ease-in-out infinite; box-shadow: 0 0 0 2px var(--accent) inset; }
@keyframes tutPulse { 50% { transform: scale(1.06); } }

/* катсцена поверх апки */
.cutscene { position: fixed; inset: 0; z-index: 100; background: #000; opacity: 0; transition: opacity .45s; touch-action: none; }
.cutscene.show { opacity: 1; }
.cutscene canvas { display: block; width: 100%; height: 100%; }
.cs-bar { position: absolute; left: 0; right: 0; height: 7%; background: #000; pointer-events: none; }
.cs-bar.top { top: 0; } .cs-bar.bottom { bottom: 0; }
.cs-caption { position: absolute; left: 20px; right: 20px; bottom: calc(7% + 74px); text-align: center; color: #fff; font-size: 18px; font-weight: 600; text-shadow: 0 2px 8px rgba(0,0,0,.9); opacity: 0; transition: opacity .8s; pointer-events: none; }
.cs-caption.on { opacity: 1; }
.cs-skip { position: absolute; right: 14px; top: calc(7% + 12px); padding: 7px 13px; border-radius: 10px; background: rgba(255,255,255,.16); color: #fff; font-size: 13px; }
.cs-cta { position: absolute; left: 50%; bottom: calc(7% + 18px); transform: translateX(-50%); padding: 14px 30px; border-radius: 16px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .6s; }
.cs-cta.on { opacity: 1; pointer-events: auto; }
.stage { height: min(56vh, 470px); }

/* ---------- магазин ---------- */

.shop-tabs { margin-bottom: 10px; grid-template-columns: repeat(5, 1fr); }
.shop-tabs button { font-size: 11px; padding: 8px 1px; }
.svc .info .lvl { display: block; color: var(--text); font-size: 12px; margin-top: 3px; }
.pips { display: flex; gap: 4px; margin-top: 6px; }
.pips i { width: 18px; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--hint) 25%, transparent); }
.pips i.on { background: var(--accent); }
.item { position: relative; }
.item .small { color: var(--hint); font-size: 10px; line-height: 1.25; }
.item.rare { box-shadow: 0 0 0 2px #f5b83d inset; }
.item .tag {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  background: #f5b83d; color: #3a2a00; font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 99px; white-space: nowrap;
}
.items .empty { grid-column: 1 / -1; }

/* ---------- кладбище ---------- */

.grave { background: var(--card); border-radius: 16px; padding-bottom: 8px; }
.grave .row { background: none; }
.plaque { margin: -2px 14px 6px 66px; font-style: italic; font-size: 13px; color: color-mix(in srgb, var(--text) 75%, transparent); }
.burning { margin: 0 14px 6px 66px; font-size: 12px; color: #d98a1f; }
.grave-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 12px 0 66px; }
.grave-btns .pill-btn { font-size: 11px; padding: 6px 9px; }

/* приближение камеры */
.zoom {
  position: absolute;
  z-index: 2;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.zoom button {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(6px);
  color: #2a2230;
  font-size: 18px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.zoom button:active { transform: scale(.92); }
.zoom button[data-sound] { font-size: 15px; }
.zoom button[data-sound="music"] { margin-top: 8px; }
.zoom button.off { opacity: .45; filter: grayscale(1); }

/* окошко с описанием показателя */
.stat { cursor: pointer; }
.stat:active { transform: scale(.95); }
.stat-now { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.stat-now .bar.wide { flex: 1; }
.stat-now b { font-size: 18px; min-width: 32px; text-align: right; }
.stat-help { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 14px; }
.stat-help .up { color: color-mix(in srgb, var(--good) 75%, var(--text)); }
.stat-help .down { color: color-mix(in srgb, var(--bad) 75%, var(--text)); }

/* В квартире звёзды и луна — только за окном (в 3D), а не поверх стен */
.stage.home::before, .stage.home::after { opacity: 0 !important; }
.stage.home.night { background: linear-gradient(180deg, #2b2438, #3a3150); }
.stage.home.storm::before { opacity: 0 !important; }

.empty.small { padding: 10px 6px; font-size: 13px; }
.groups:empty, .tools:empty { display: none; }
