/* ================================================================
 * Jump Master — стили mini-app. Современный тёмный неон-стиль.
 * ================================================================ */

:root {
  --bg: #0f1226;
  --bg-soft: #171b3a;
  --card: #1c2147;
  --card-2: #232a55;
  --line: #2b3164;
  --text: #eef1ff;
  --muted: #9aa3d0;
  --primary: #5b8def;
  --primary-2: #6d7cff;
  --accent: #fbbf24;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 18px;
  --nav-h: 78px;
  --top-h: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ---------------- ВЕРХНЯЯ ПАНЕЛЬ ---------------- */
#topbar {
  height: calc(var(--top-h) + var(--safe-t));
  padding-top: var(--safe-t);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(180deg, var(--bg-soft), transparent);
  z-index: 5;
}
.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  backdrop-filter: blur(8px);
}
.stat-icon { font-size: 15px; }
.stat-best { color: var(--accent); }

/* ---------------- ОБЛАСТЬ ЭКРАНА ---------------- */
#screen {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px calc(var(--nav-h) + var(--safe-b) + 16px);
  -webkit-overflow-scrolling: touch;
}
#screen.full {
  padding: 0;
  overflow: hidden;
}

.screen { animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.screen-h { font-size: 22px; margin: 6px 0 4px; }
.screen-desc { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin: 0 0 16px; }

/* ---------------- КНОПКИ ---------------- */
.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s;
  font-family: inherit;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: linear-gradient(135deg, var(--primary-2), var(--primary)); }
.btn-buy { background: linear-gradient(135deg, #f59e0b, #f97316); }
.btn-stars { background: linear-gradient(135deg, #3b82f6, #2563eb); width: 100%; }
.btn-ghost { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); }
.btn-danger { background: linear-gradient(135deg, #f87171, var(--danger)); width: 100%; }
.btn-big { padding: 15px 22px; font-size: 16px; border-radius: 14px; }

/* ---------------- НИЖНЯЯ НАВИГАЦИЯ ---------------- */
#navbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(23, 27, 58, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
  z-index: 10;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s;
}
.nav-icon { font-size: 21px; line-height: 1; }
.nav-label { font-size: 10.5px; font-weight: 600; }
.nav-btn.active { color: var(--text); }
.nav-btn.active .nav-icon { transform: translateY(-1px); filter: drop-shadow(0 4px 8px rgba(91, 141, 239, 0.6)); }

/* центральная круглая кнопка «Играть» */
.nav-play {
  flex: 0 0 auto;
  position: relative;
  margin-top: -28px;
}
.nav-play-inner {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #fff;
  box-shadow: 0 10px 26px rgba(91, 141, 239, 0.55), inset 0 1px 2px rgba(255,255,255,0.4);
  border: 4px solid var(--bg);
  transition: transform 0.15s;
}
.nav-play.active .nav-play-inner,
.nav-play:active .nav-play-inner { transform: scale(1.06); }

/* ---------------- ЭКРАН ИГРЫ ---------------- */
.screen-play { position: relative; width: 100%; height: 100%; }
.game-canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(91,141,239,0.18), transparent 60%), rgba(15,18,38,0.86);
  backdrop-filter: blur(3px);
  transition: opacity 0.3s;
  padding: 20px;
}
.play-overlay.hidden { opacity: 0; pointer-events: none; }
.play-card { text-align: center; max-width: 320px; }
.play-logo { font-size: 64px; animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.play-title {
  font-size: 34px; margin: 6px 0 8px;
  background: linear-gradient(135deg, #8fb3ff, #c4b5fd);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.play-sub { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 16px; }
.play-best {
  display: inline-block; background: rgba(255,255,255,0.07);
  border: 1px solid var(--line); padding: 8px 16px; border-radius: 999px;
  font-weight: 700; margin-bottom: 18px;
}
.play-best b { color: var(--accent); }
.play-tip { color: var(--muted); font-size: 12px; margin-top: 16px; line-height: 1.5; }
#start-game { width: 100%; }

/* ---------------- МОДАЛКА (game over) ---------------- */
.modal-backdrop {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 10, 24, 0.7); backdrop-filter: blur(5px);
  animation: fade 0.2s ease; padding: 24px;
}
.modal {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 26px 22px; text-align: center;
  width: 100%; max-width: 340px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  animation: pop 0.28s cubic-bezier(.2,1.2,.4,1);
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-emoji { font-size: 52px; }
.modal h2 { margin: 6px 0 18px; font-size: 22px; }
.result-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.result-item {
  display: flex; justify-content: space-between;
  background: rgba(255,255,255,0.05); padding: 11px 14px; border-radius: 12px;
}
.result-item span { color: var(--muted); }
.result-item b { color: var(--text); }
.ach-unlocked {
  background: rgba(251,191,36,0.12); border: 1px solid rgba(251,191,36,0.4);
  color: var(--accent); padding: 10px; border-radius: 12px; font-size: 13px;
  font-weight: 700; margin-bottom: 16px;
}
.modal-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---------------- ИНВЕНТАРЬ (скины) ---------------- */
.card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.skin-card {
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 14px; text-align: center;
  transition: border-color 0.15s, transform 0.12s;
}
.skin-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,141,239,0.18); }
.skin-preview {
  position: relative; height: 78px; border-radius: 14px;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--c) 30%, transparent), transparent 70%);
  display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
}
.skin-blob {
  width: 44px; height: 44px; border-radius: 14px;
  background: linear-gradient(145deg, var(--t), var(--c));
  box-shadow: 0 8px 18px color-mix(in srgb, var(--c) 50%, transparent);
}
.skin-badge {
  position: absolute; top: 6px; right: 6px; font-size: 8.5px; font-weight: 800;
  background: var(--accent); color: #5a3a00; padding: 3px 6px; border-radius: 6px; letter-spacing: 0.5px;
}
.skin-name { font-weight: 700; font-size: 15px; }
.skin-desc { color: var(--muted); font-size: 11.5px; margin: 3px 0 10px; min-height: 28px; }
.skin-card .btn { width: 100%; }

/* ---------------- ПРОКАЧКА ---------------- */
.upgrade-list { display: flex; flex-direction: column; gap: 12px; }
.upgrade-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.up-icon {
  font-size: 26px; width: 48px; height: 48px; flex: 0 0 auto;
  background: rgba(255,255,255,0.06); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}
.up-main { flex: 1; min-width: 0; }
.up-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.up-lvl { font-size: 11px; color: var(--muted); font-weight: 600; }
.up-desc { color: var(--muted); font-size: 12px; margin: 3px 0 7px; line-height: 1.4; }
.up-dots { display: flex; gap: 4px; }
.dot { width: 100%; max-width: 22px; height: 5px; border-radius: 3px; background: var(--line); flex: 1; }
.dot.on { background: linear-gradient(90deg, var(--primary-2), var(--primary)); }
.up-btn { flex: 0 0 auto; min-width: 76px; }

/* ---------------- МАГАЗИН ---------------- */
.shop-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.shop-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 12px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.shop-icon { font-size: 34px; margin-bottom: 4px; }
.shop-title { font-weight: 700; font-size: 14px; }
.shop-sub { color: var(--muted); font-size: 11.5px; margin-bottom: 10px; min-height: 26px; }
.shop-card .btn { margin-top: auto; }
.shop-note { color: var(--muted); font-size: 11.5px; text-align: center; margin-top: 16px; line-height: 1.5; }

/* ---------------- ПРОЧЕЕ ---------------- */
.tabs { display: flex; gap: 6px; background: var(--bg-soft); padding: 5px; border-radius: 14px; margin-bottom: 16px; }
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 9px 4px; border-radius: 10px; font-size: 12.5px; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.tab.active { background: var(--card-2); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,0.25); }

.lead-list { display: flex; flex-direction: column; gap: 8px; }
.lead-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  padding: 12px 14px; border-radius: 12px;
}
.lead-row.me { border-color: var(--primary); background: rgba(91,141,239,0.12); }
.lead-rank { font-size: 16px; font-weight: 800; width: 28px; text-align: center; }
.lead-name { flex: 1; font-weight: 600; }
.lead-score { font-weight: 800; color: var(--accent); }

.ach-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ach-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 12px; text-align: center; opacity: 0.55;
}
.ach-card.got { opacity: 1; border-color: rgba(251,191,36,0.4); }
.ach-icon { font-size: 32px; }
.ach-name { font-weight: 700; font-size: 13.5px; margin-top: 6px; }
.ach-desc { color: var(--muted); font-size: 11px; margin-top: 3px; line-height: 1.4; }

.stats-list { display: flex; flex-direction: column; gap: 8px; }
.stats-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border: 1px solid var(--line);
  padding: 13px 16px; border-radius: 12px; font-size: 14px;
}
.stats-row span { color: var(--muted); }
.stats-row b { font-size: 16px; }

.settings-list { display: flex; flex-direction: column; gap: 12px; }
.switch-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border: 1px solid var(--line);
  padding: 14px 16px; border-radius: 12px; font-weight: 600; cursor: pointer;
}
.switch-row input { width: 46px; height: 26px; appearance: none; background: var(--line); border-radius: 999px; position: relative; cursor: pointer; transition: background 0.2s; }
.switch-row input:checked { background: var(--primary); }
.switch-row input::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform 0.2s;
}
.switch-row input:checked::after { transform: translateX(20px); }
