:root {
  --bg: #05060A;
  --bg2: #0B0D14;
  --card: #111522;
  --card2: #171B2A;
  --border: rgba(255, 255, 255, 0.07);
  --blue: #2563EB;
  --violet: #5B2EFF;
  --purple: #8B5CF6;
  --text: #FFFFFF;
  --muted: #8A93A8;
  --gold: #F5B93C;
  --radius: 20px;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 500px at 50% -200px, rgba(37, 99, 235, 0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 20%, rgba(91, 46, 255, 0.08), transparent 60%),
    var(--bg);
}

#app {
  max-width: 480px; margin: 0 auto;
  padding: calc(16px + var(--safe-top, 0px)) 16px 92px;
}

.screen { display: none; animation: fadeUp 0.28s ease both; }
.screen.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.hidden { display: none !important; }

.ic { width: 22px; height: 22px; color: var(--text); flex: none; }
.ic.muted { color: var(--muted); }
.ic.tiny { width: 14px; height: 14px; vertical-align: -2px; }
.ic.star { color: var(--gold); }
.ic.prem { color: var(--purple); width: 18px; height: 18px; }
.pill-lbl { color: var(--muted); font-weight: 600; font-size: 13px; }
.lstar { width: 20px; height: 20px; display: inline-block; flex: none; vertical-align: -4px; overflow: hidden; }
.lstar.tiny { width: 15px; height: 15px; vertical-align: -3px; }
.lstar.big { width: 32px; height: 32px; }
.lstar.prem { width: 22px; height: 22px; }
.lstar svg { display: block; width: 100%; height: 100%; }
.value-unit { color: var(--muted); font-size: 15px; font-weight: 700; align-self: flex-end; margin-bottom: 5px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--card2); border: 1px solid var(--border);
  color: var(--muted); display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-btn .ic { width: 19px; height: 19px; }
.avatar-badge { border: none; padding: 0; cursor: pointer; }

/* ---------- top bar ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px; font-weight: 600;
}
.avatar-badge {
  width: 42px; height: 42px; border-radius: 50%; overflow: hidden;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: flex; align-items: center; justify-content: center;
}
.avatar-badge img { width: 100%; height: 100%; object-fit: cover; }
.avatar-badge.big { width: 56px; height: 56px; }

.h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.h2 { font-size: 22px; font-weight: 800; margin-bottom: 14px; letter-spacing: -0.02em; }
.sub { color: var(--muted); margin: 6px 0 18px; font-size: 15px; }
.center { text-align: center; }

/* ---------- banner ---------- */
.banner {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(120deg, #1D4ED8, #3B82F6 60%, #5B2EFF);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(37, 99, 235, 0.35);
}
.banner-title { font-weight: 700; font-size: 16px; }
.banner-sub { font-size: 13px; opacity: 0.85; margin-top: 3px; }
.banner-ic { width: 44px; height: 44px; color: #fff; opacity: 0.9; }

/* ---------- inputs ---------- */
.input-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 999px; padding: 14px 16px; margin-bottom: 10px;
}
.input-row.inner { border-radius: 14px; }
.input-row input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 16px; min-width: 0;
}
.input-row input::placeholder { color: var(--muted); }
.chip-btn {
  background: var(--blue); color: #fff; border: none; border-radius: 999px;
  padding: 7px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.hint { color: var(--muted); font-size: 13px; margin: 4px 2px 14px; }

/* ---------- buttons ---------- */
.primary-btn {
  width: 100%; padding: 16px; border: none; border-radius: 16px;
  background: linear-gradient(120deg, var(--blue), #3B82F6);
  color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 28px rgba(37, 99, 235, 0.4);
  transition: transform 0.12s ease, opacity 0.2s;
  margin-bottom: 8px;
}
.primary-btn:active { transform: scale(0.97); }
.primary-btn:disabled { opacity: 0.5; }
.ghost-btn {
  width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: 16px;
  background: var(--card2); color: var(--text); font-size: 15px; font-weight: 600;
  cursor: pointer; margin-bottom: 8px;
}

/* ---------- cards ---------- */
.glass {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.008)), var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
}
.card { padding: 16px; margin-bottom: 12px; }
.card-title { font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.card-title .count { color: var(--muted); font-weight: 600; }

/* ---------- segmented ---------- */
.seg { display: flex; gap: 6px; background: var(--card); border-radius: 999px; padding: 4px; margin-bottom: 14px; border: 1px solid var(--border); }
.seg-btn {
  flex: 1; border: none; background: none; color: var(--muted);
  padding: 9px 4px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.seg-btn.active { background: var(--blue); color: #fff; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 16px; padding: 13px 14px;
}
.list-item .rank { width: 26px; height: 26px; border-radius: 50%; background: var(--card); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--muted); flex: none; }
.list-item .rank.r1 { background: linear-gradient(135deg, #F5B93C, #B8860B); color: #fff; }
.list-item .rank.r2 { background: linear-gradient(135deg, #C0C6D4, #8A93A8); color: #fff; }
.list-item .rank.r3 { background: linear-gradient(135deg, #C77B4A, #8B4513); color: #fff; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.list-item .li-val { font-weight: 700; display: flex; align-items: center; gap: 5px; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 24px 0; }

/* ---------- scanning ---------- */
#screen-scan { padding-top: 40px; }
.radar {
  position: relative; width: 160px; height: 160px; margin: 26px auto 4px;
}
.radar-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(37, 99, 235, 0.45);
  animation: radar-pulse 2.4s ease-out infinite;
}
.radar-ring.r2 { animation-delay: 0.8s; }
.radar-ring.r3 { animation-delay: 1.6s; }
@keyframes radar-pulse {
  0% { transform: scale(0.35); opacity: 0.9; }
  100% { transform: scale(1.15); opacity: 0; }
}
.radar-core {
  position: absolute; inset: 50px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 40px rgba(91, 46, 255, 0.5);
}
.radar-core svg { width: 26px; height: 26px; color: #fff; }
.radar-sweep {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(37, 99, 235, 0.35), transparent 90deg);
  animation: radar-spin 2s linear infinite;
  -webkit-mask: radial-gradient(circle, transparent 38%, #000 39%, #000 70%, transparent 71%);
  mask: radial-gradient(circle, transparent 38%, #000 39%, #000 70%, transparent 71%);
}
@keyframes radar-spin { to { transform: rotate(360deg); } }
.stages { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.stage {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 14px 16px; opacity: 0.45; transition: all 0.3s;
}
.stage.on { opacity: 1; border-color: rgba(37, 99, 235, 0.5); box-shadow: 0 0 24px rgba(37, 99, 235, 0.15); }
.stage.done { opacity: 1; }
.stage .st-ic { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); flex: none; display: flex; align-items: center; justify-content: center; }
.stage.on .st-ic { border-color: var(--blue); animation: pulse 1s infinite; }
.stage.done .st-ic { border-color: transparent; background: linear-gradient(135deg, var(--blue), var(--purple)); }
.stage.done .st-ic svg { width: 13px; height: 13px; color: #fff; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(37,99,235,0.5);} 50% { box-shadow: 0 0 0 6px rgba(37,99,235,0);} }

/* ---------- result ---------- */
.result-head { text-align: center; padding: 8px 0 16px; position: relative; }
.result-head.has-backdrop {
  border-radius: var(--radius); padding: 20px 12px 18px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 14px;
}
.coll-users { display: flex; flex-direction: column; gap: 8px; }
.coll-user {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card2); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px; cursor: pointer;
}
.cu-name { font-weight: 700; font-size: 15px; letter-spacing: 0.2px; }
.cu-badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  padding: 3px 8px; border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff;
}
.g-media.g-backdrop { position: relative; }
.g-media .g-main { position: relative; width: 72%; height: 72%; margin: auto; z-index: 1; }
.g-media .g-main svg, .g-media .g-main video, .g-media .g-main img { width: 100%; height: 100%; object-fit: contain; }
.result-status { position: absolute; inset: 0; pointer-events: none; }
.pattern-emoji { position: absolute; opacity: 0.35; }
.pattern-emoji svg, .pattern-emoji video, .pattern-emoji img { width: 100%; height: 100%; object-fit: contain; }
.status-inline { width: 22px; height: 22px; display: inline-flex; flex: none; }
.status-inline svg, .status-inline video, .status-inline img { width: 100%; height: 100%; object-fit: contain; }
.result-avatar {
  width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 12px; overflow: hidden;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  box-shadow: 0 0 48px rgba(91, 46, 255, 0.4);
  display: flex; align-items: center; justify-content: center;
}
.result-avatar img { width: 100%; height: 100%; object-fit: cover; }
.result-name-row { display: flex; align-items: center; justify-content: center; gap: 6px; }
.result-name { font-size: 19px; font-weight: 800; }
.result-username { color: var(--muted); font-size: 14px; margin-top: 2px; }
.level-badge {
  display: inline-block; margin-top: 10px; padding: 6px 14px; border-radius: 999px;
  background: linear-gradient(120deg, rgba(37,99,235,0.25), rgba(139,92,246,0.25));
  border: 1px solid rgba(139, 92, 246, 0.4); font-size: 13px; font-weight: 700;
}
.score-card { padding: 22px; text-align: center; margin-bottom: 14px; }
.big-score { font-size: 56px; font-weight: 800; letter-spacing: -0.03em; }
.big-score .of10 { font-size: 22px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.progress { height: 8px; border-radius: 99px; background: var(--card2); margin: 14px 0 10px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--blue), var(--purple)); transition: width 1.2s cubic-bezier(0.2, 0.8, 0.2, 1); }
.rarity-line { color: var(--muted); font-size: 13px; }

.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.cat {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 13px 14px;
}
.cat .c-name { color: var(--muted); font-size: 12.5px; }
.cat .c-val { font-size: 20px; font-weight: 800; margin-top: 3px; }
.cat .c-val small { color: var(--muted); font-size: 12px; font-weight: 600; }
.cat .c-na { color: var(--muted); font-size: 14px; font-weight: 600; margin-top: 5px; }

.comment { font-size: 14px; line-height: 1.5; color: #C6CCDA; }

.gifts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gift {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)), var(--card2);
  border: 1px solid var(--border); border-radius: 22px; padding: 8px 8px 12px;
  backdrop-filter: blur(10px);
}
.gift .g-title { font-weight: 700; font-size: 13.5px; display: flex; gap: 6px; align-items: center; padding: 0 4px; }
.gift .g-title svg { width: 15px; height: 15px; color: var(--purple); }
.gift .g-meta { color: var(--muted); font-size: 11.5px; margin-top: 4px; line-height: 1.5; padding: 0 4px; }
.gift .g-media {
  width: 100%; aspect-ratio: 1 / 1; height: auto; margin: 0 auto 10px; display: flex;
  align-items: center; justify-content: center; overflow: hidden; border-radius: 16px;
  background: radial-gradient(circle at 50% 40%, rgba(139,92,246,0.16), rgba(17,21,34,0.6) 80%);
}
.gift .g-media svg, .gift .g-media video, .gift .g-media img { width: 100%; height: 100%; object-fit: contain; }
.gift .g-media .g-ph { width: 34px; height: 34px; color: var(--purple); opacity: 0.6; }
.gift.g-linked { cursor: pointer; }
.gift.g-linked:active { border-color: rgba(139, 92, 246, 0.5); }
.g-more {
  grid-column: 1 / -1; background: var(--card2); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px; color: var(--text); font-size: 13.5px; font-weight: 600;
}

/* ---------- not found ---------- */
#screen-notfound { padding-top: 70px; text-align: center; }
.nf-icon {
  width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.nf-icon svg { width: 36px; height: 36px; color: var(--muted); }

/* ---------- stats ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stat { padding: 14px; }
.stat-val { font-size: 22px; font-weight: 800; }
.stat-lbl { color: var(--muted); font-size: 12px; margin-top: 3px; }

.me-card { display: flex; align-items: center; gap: 14px; }

.sub-btns { display: flex; gap: 8px; }
.sub-btns button {
  flex: 1; border: 1px solid var(--border); background: var(--card2); color: var(--text);
  border-radius: 12px; padding: 10px 4px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}

/* ---------- admin form ---------- */
.form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.form label { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; }
.form input[type="number"] {
  width: 110px; background: var(--card2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); padding: 8px 10px; font-size: 14px; outline: none;
}
.form input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--blue); }

/* ---------- bottom nav (floating pill) ---------- */
.bottomnav {
  position: fixed; z-index: 50;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  width: auto; min-width: 260px; max-width: 456px;
  display: flex; justify-content: space-around; gap: 4px;
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.03)),
    rgba(20, 24, 38, 0.55);
  backdrop-filter: blur(34px) saturate(170%);
  -webkit-backdrop-filter: blur(34px) saturate(170%);
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 999px;
  padding: 8px 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.12);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: rgba(235, 240, 255, 0.55); cursor: pointer;
  font-size: 10.5px; font-weight: 600; padding: 8px 16px; border-radius: 999px;
  transition: color 0.15s, background 0.15s;
}
.nav-btn.active {
  color: #fff;
  background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.06));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}
.nav-btn .ic { width: 21px; height: 21px; color: inherit; }

/* ---------- value card ---------- */
.value-card { padding: 18px; margin-bottom: 12px; text-align: center; }
.value-main {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 4px;
}
.value-main .ic { width: 26px; height: 26px; }
.value-stars { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }
.value-rub { color: var(--muted); font-size: 14px; margin-top: 2px; font-weight: 600; }
.value-break { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.vb-row {
  display: flex; justify-content: space-between; font-size: 13px;
  color: var(--muted); background: var(--card2); border: 1px solid var(--border);
  border-radius: 12px; padding: 9px 12px;
}
.vb-row b { color: var(--text); display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.vb-row .lstar { overflow: hidden; }
