:root {
  --bg: var(--tg-theme-bg-color, #f4f5f7);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --surface-2: rgba(120,125,140,.10);
  --text: var(--tg-theme-text-color, #1a1c1e);
  --hint: var(--tg-theme-hint-color, #8b909a);
  --border: rgba(120,125,140,.20);
  --brand: #6c5ce7;
  --brand-press: #5a49d6;
  --brand-soft: rgba(108,92,231,.12);
  --brand-text: #ffffff;
  --like: #22c55e;
  --nope: #ef4444;
  --star: #f5a623;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 3px rgba(20,20,45,.08);
  --shadow-md: 0 8px 26px rgba(20,20,45,.13);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; }

/* ---------- Токен-кнопки ---------- */
.primary-btn {
  background: var(--brand); color: var(--brand-text); border: none;
  border-radius: var(--radius); padding: 14px 18px; font-size: 16px; font-weight: 600;
  cursor: pointer; transition: background .15s, transform .08s, box-shadow .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 4px 14px rgba(108,92,231,.32);
}
.primary-btn:hover { background: var(--brand-press); }
.primary-btn:active { transform: scale(.98); }
.primary-btn:disabled { opacity: .5; box-shadow: none; }

.ghost-btn {
  background: transparent; color: var(--hint); border: none;
  border-radius: var(--radius); padding: 12px 16px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.ghost-btn:hover { color: var(--text); background: var(--surface-2); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; font-weight: 700; font-size: 17px;
}
.brand { display: flex; align-items: center; gap: 6px; }
.icon-btn { background: none; border: none; font-size: 22px; cursor: pointer; line-height: 1; padding: 4px; border-radius: 10px; transition: background .15s; }
.icon-btn:hover { background: var(--surface-2); }
.ver { font-size: 11px; color: var(--hint); font-weight: 400; }

#app { height: calc(100% - 52px); padding: 0 16px 16px; }
.screen { height: 100%; display: flex; flex-direction: column; }

/* ---------- Опрос ---------- */
#survey { justify-content: center; gap: 20px; }
.q-title { font-size: 23px; font-weight: 800; text-align: center; letter-spacing: -.2px; }
.q-options { display: flex; flex-direction: column; gap: 10px; }
.q-options button {
  padding: 16px 18px; font-size: 16px; font-weight: 500; text-align: left;
  border-radius: var(--radius); border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: border-color .15s, background .15s, transform .08s;
}
.q-options button:hover { border-color: var(--brand); background: var(--brand-soft); }
.q-options button:active { transform: scale(.985); }

/* ---------- Стопка карт ---------- */
.cards { position: relative; flex: 1; margin: 4px 0; }
.game-card {
  position: absolute; inset: 0;
  background: var(--surface); border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column;
  will-change: transform; touch-action: none;
}
.game-card.behind { pointer-events: none; }
.game-card.behind1 { transform: scale(.955) translateY(12px); filter: brightness(.99); }
.game-card.behind2 { transform: scale(.91) translateY(24px); filter: brightness(.97); }

.card-img { width: 100%; height: 44%; object-fit: contain; background: var(--surface-2); }
.card-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.card-title { font-size: 20px; font-weight: 800; margin: 0 0 8px; letter-spacing: -.2px; }
.card-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 4px 9px; font-size: 13px; color: var(--text); }
.card-why { margin: 8px 0; padding: 0; list-style: none; font-size: 14px; line-height: 1.55; }
.card-desc { color: var(--hint); font-size: 14px; line-height: 1.5; }
.card-links { display: flex; gap: 8px; margin-top: 12px; }
.card-links a {
  flex: 1; text-align: center; text-decoration: none; padding: 9px; border-radius: 10px;
  background: var(--surface-2); color: var(--text); font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}

.badge {
  position: absolute; top: 18px; font-size: 46px; opacity: 0; z-index: 3;
  pointer-events: none; filter: drop-shadow(0 2px 6px rgba(0,0,0,.35));
}
.badge.like { left: 18px; transform: rotate(-14deg); }
.badge.nope { right: 18px; transform: rotate(14deg); }

.top-badge {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  background: rgba(0,0,0,.62); color: #fff; font-size: 12px; font-weight: 700;
  padding: 5px 10px; border-radius: 999px; backdrop-filter: blur(2px);
}
.relax-banner {
  background: rgba(245,166,35,.16); color: var(--text);
  border-radius: var(--radius); padding: 9px 12px; margin-bottom: 8px;
  font-size: 13px; text-align: center;
}

@keyframes cardHint {
  0%, 100% { transform: translateX(0) rotate(0); }
  15% { transform: translateX(-28px) rotate(-4deg); }
  40% { transform: translateX(24px) rotate(3deg); }
  65% { transform: translateX(-15px) rotate(-2deg); }
  85% { transform: translateX(9px) rotate(1deg); }
}
.game-card.hint { animation: cardHint .8s ease-in-out; }

.actions { display: flex; justify-content: center; gap: 36px; margin: 8px 0 4px; }
.round {
  width: 62px; height: 62px; border-radius: 50%; border: 1.5px solid var(--border);
  font-size: 26px; cursor: pointer; box-shadow: var(--shadow-sm); background: var(--surface);
  transition: transform .08s, border-color .15s; line-height: 1;
}
.round:active { transform: scale(.92); }
.round.like { border-color: rgba(34,197,94,.5); }
.round.nope { border-color: rgba(239,68,68,.5); }
.hint { text-align: center; color: var(--hint); font-size: 12px; margin-top: 8px; }
#stack.done .actions, #stack.done .hint { display: none; }

/* ---------- Карта-финиш ---------- */
.game-card.completion { align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 28px 24px; }
.done-emoji { font-size: 58px; }
.done-title { font-size: 24px; font-weight: 800; }
.done-sub { color: var(--hint); font-size: 15px; margin-bottom: 6px; }
.game-card.completion .primary-btn, .game-card.completion .ghost-btn { width: 84%; }

/* ---------- Полёт в избранное ---------- */
.fly-clone {
  position: fixed; border-radius: var(--radius-lg); background: var(--surface);
  background-size: cover; background-position: center;
  box-shadow: var(--shadow-md); z-index: 30; pointer-events: none;
  transition: transform .5s cubic-bezier(.35,0,.25,1), opacity .5s ease;
}
#favBtn.pulse { animation: starGulp .34s ease; }
@keyframes starGulp { 0% { transform: scale(1); } 40% { transform: scale(1.6); } 70% { transform: scale(.85); } 100% { transform: scale(1); } }

/* ---------- Пусто ---------- */
#empty { justify-content: center; align-items: center; gap: 12px; text-align: center; }
#empty .primary-btn, #empty .ghost-btn { width: 84%; max-width: 340px; }
.empty-emoji { font-size: 54px; }
.empty-text { font-size: 17px; color: var(--hint); }

/* ---------- Избранное ---------- */
.favs-title { font-size: 21px; font-weight: 800; margin: 6px 0 4px; }
.fav-hint { font-size: 12px; color: var(--hint); margin-bottom: 10px; }
.favs-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
#favs .primary-btn { margin-top: 10px; }

.fav-item {
  display: flex; gap: 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; position: relative; touch-action: pan-y;
}
.fav-item img { width: 64px; height: 64px; border-radius: 10px; object-fit: contain; background: var(--surface-2); cursor: pointer; flex: none; }
.fav-info { flex: 1; min-width: 0; }
.fav-name { font-weight: 700; font-size: 15px; cursor: pointer; padding-right: 24px; }
.fav-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.fav-actions a, .fav-actions button {
  font-size: 13px; text-decoration: none; padding: 6px 11px; border-radius: 9px; border: none;
  background: var(--surface-2); color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.fav-actions a:active, .fav-actions button:active { background: var(--border); }
.fav-share { position: absolute; top: 8px; right: 8px; background: none; border: none; color: var(--hint); cursor: pointer; opacity: .85; z-index: 2; padding: 2px; }

.fav-stars { display: flex; gap: 3px; margin: 5px 0; }
.fav-stars .star { color: var(--border); font-size: 18px; cursor: pointer; transition: color .1s; }
.fav-stars .star.on { color: var(--star); }
.fav-stars.big { gap: 6px; margin: 6px 0 14px; }
.fav-stars.big .star { font-size: 30px; }

.fav-group { margin-bottom: 8px; }
.fav-group-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); font-weight: 700; font-size: 14px; cursor: pointer;
}
.fav-group-head .grp-right { display: flex; align-items: center; gap: 12px; color: var(--hint); }
.grp-share { background: none; border: none; color: var(--hint); cursor: pointer; padding: 0; display: inline-flex; }
.fav-group-head .chev { transition: transform .2s; display: inline-flex; }
.fav-group-head.collapsed .chev { transform: rotate(-90deg); }
.fav-group-body { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
.fav-group-body.collapsed { display: none; }

/* ---------- Деталь / оверлей ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10; }
.overlay-card { background: var(--surface); border-radius: var(--radius-lg); padding: 22px; width: 100%; max-width: 360px; text-align: center; }
.detail-card { max-height: 88vh; overflow-y: auto; position: relative; text-align: left; }
.detail-close { position: absolute; top: 10px; right: 12px; background: none; border: none; color: var(--hint); cursor: pointer; z-index: 2; padding: 2px; }
.detail-img { width: 100%; height: 200px; object-fit: contain; background: var(--surface-2); border-radius: var(--radius); margin-bottom: 10px; }
.detail-buy { display: flex; gap: 8px; margin: 14px 0 8px; }
.detail-buy button {
  flex: 1; padding: 12px; border-radius: var(--radius); border: none;
  background: var(--brand); color: var(--brand-text); font-size: 15px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.detail-card .ghost-btn { width: 100%; justify-content: flex-start; margin-top: 4px; }

/* ---------- Экран «тебе советуют» ---------- */
#shared { overflow-y: auto; }
#sharedBody { width: 100%; max-width: 480px; margin: 0 auto; }
.shared-head { font-size: 20px; font-weight: 800; text-align: center; margin: 8px 0 12px; }
#shared .primary-btn, #shared .ghost-btn { width: 100%; margin-top: 8px; }
#favsShare { margin-top: 8px; }

/* ---------- Иконки ---------- */
.ic { width: 18px; height: 18px; display: inline-block; flex: none; vertical-align: -4px; }
.fav-actions .ic { width: 15px; height: 15px; vertical-align: -2px; }
.fav-share .ic { width: 19px; height: 19px; }
.detail-close .ic { width: 20px; height: 20px; }
.grp-share .ic { width: 17px; height: 17px; }
.chev .ic { width: 18px; height: 18px; }
.card-links .ic, .detail-buy .ic { width: 16px; height: 16px; vertical-align: -3px; }

/* ---------- CSAT ---------- */
.csat { margin-top: 16px; width: 84%; border-top: 1px solid var(--border); padding-top: 14px; }
.csat-q { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.csat-opt { color: var(--hint); font-weight: 400; }
.csat-faces { display: flex; justify-content: center; gap: 14px; }
.csat-faces button { font-size: 34px; background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: 12px; transition: transform .1s, background .15s; }
.csat-faces button:hover { background: var(--surface-2); }
.csat-faces button:active { transform: scale(1.2); }
.csat-input { width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius); padding: 10px; font-family: inherit; font-size: 14px; background: var(--surface); color: var(--text); resize: none; margin-bottom: 8px; }
