:root {
  --bg: #050506;
  --card: #131316;
  --card2: #1b1b20;
  --line: #26262c;
  --text: #fff;
  --muted: #8b8b95;
  --accent: #e4ff3a;
  --accent-2: #b6ff00;
  --accent-text: #0a0a0a;
  --danger: #ff5d5d;
  --r: 22px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, "SF Pro Display", "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--card2);
  border: 1px solid var(--line); border-radius: 14px; padding: 13px; margin-top: 6px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin-top: 12px; }
h2 { margin: 24px 0 10px; font-size: 21px; letter-spacing: -.3px; }
h3 { margin: 0 0 8px; font-size: 17px; }
code { background: var(--card2); padding: 2px 6px; border-radius: 6px; font-size: 12px; }
.muted { color: var(--muted); font-size: 14px; }
main { padding: 14px 16px; max-width: 560px; margin: 0 auto; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* splash */
#splash { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; transition: opacity .3s; }
#splash.hide { opacity: 0; pointer-events: none; }
.logo { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; width: 40px; }
.logo i { display: block; height: 18px; background: var(--accent); border-radius: 5px; }
.splash-t { font-size: 22px; font-weight: 700; }
.bar { width: 280px; height: 5px; border-radius: 3px; background: #1a1a1a; overflow: hidden; }
.bar b { display: block; height: 100%; width: 30%; background: var(--accent); border-radius: 3px; animation: load 1.4s ease-in-out infinite; }
@keyframes load { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

/* профиль-карточка */
.profile { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: var(--r); padding: 14px; width: 100%; text-align: left; border: 1px solid var(--line); }
.avatar { width: 50px; height: 50px; border-radius: 50%; background: linear-gradient(135deg, #2fe0b4, #1b8f8a) center/cover; flex: none; display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #04130f; }
.profile .info { flex: 1; min-width: 0; }
.profile .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 800; border-radius: 8px; padding: 3px 9px; margin-top: 5px; }
.badge.off { background: #2c2c33; color: #cfcfd6; }
.chev { color: var(--accent); font-size: 24px; }

/* статистика */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 22px; letter-spacing: -.5px; }
.stat b em { font-style: normal; color: var(--accent); font-size: 13px; margin-left: 2px; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

/* быстрые кнопки */
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.quick button { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 4px 13px; font-size: 11px; font-weight: 800; text-transform: uppercase; display: flex; flex-direction: column; align-items: center; gap: 8px; line-height: 1.2; transition: transform .1s; }
.quick button:active { transform: scale(.96); }
.quick .ic { font-size: 30px; }

/* чипы */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 800; }

/* карточки челленджей */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ccard { position: relative; aspect-ratio: 3/4; border-radius: var(--r); background: var(--card2) center/cover; overflow: hidden; text-align: left; display: flex; align-items: flex-end; transition: transform .12s; border: 1px solid rgba(255,255,255,.06); }
.ccard:active { transform: scale(.97); }
.ccard::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 30%, rgba(0,0,0,.82)); }
.ccard .emo { position: absolute; top: 24px; right: -6px; font-size: 92px; opacity: .22; transform: rotate(-12deg); line-height: 1; }
.ccard .in { position: relative; z-index: 1; padding: 12px; width: 100%; }
.ccard .t { font-weight: 800; text-transform: uppercase; font-size: 15px; line-height: 1.12; letter-spacing: -.2px; }
.ccard .m { display: flex; justify-content: space-between; margin-top: 8px; font-size: 13px; color: #e4e4e8; }
.ccard .lvl { color: var(--accent); font-weight: 800; }
.ccard .tag { position: absolute; z-index: 2; top: 10px; left: 10px; background: rgba(0,0,0,.55); backdrop-filter: blur(6px); border-radius: 9px; padding: 4px 9px; font-size: 12px; }
.ccard .pb { height: 4px; background: rgba(255,255,255,.18); border-radius: 2px; margin-top: 9px; overflow: hidden; }
.ccard .pb b { display: block; height: 100%; background: var(--accent); }

/* панели и кнопки */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-top: 12px; }
.panel.hl { background: linear-gradient(135deg, #1d2606, #131316 70%); border-color: #3a4a0d; }
.btn { display: block; width: 100%; background: var(--accent); color: var(--accent-text); font-weight: 800; border-radius: 16px; padding: 15px; text-align: center; margin-top: 12px; transition: transform .1s; }
.btn:active { transform: scale(.98); }
.btn.sec { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #4a2020; }
.btn:disabled { opacity: .5; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.progress { height: 8px; background: #2a2a31; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress b { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 4px; transition: width .5s; }
.back { color: var(--accent); margin-bottom: 8px; padding: 6px 0; font-size: 15px; }

/* экран челленджа */
.hero { position: relative; height: 210px; border-radius: var(--r); background: var(--card2) center/cover; overflow: hidden; display: flex; align-items: flex-end; margin-bottom: 12px; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 25%, rgba(0,0,0,.85)); }
.hero .emo { position: absolute; right: 8px; top: 6px; font-size: 120px; opacity: .22; transform: rotate(-10deg); line-height: 1; }
.hero .in { position: relative; z-index: 1; padding: 16px; width: 100%; }
.hero h1 { margin: 0; font-size: 26px; text-transform: uppercase; letter-spacing: -.5px; line-height: 1.05; }
.ringwrap { display: flex; align-items: center; gap: 16px; }
.ring { position: relative; width: 118px; height: 118px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .c { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .c b { font-size: 24px; display: block; line-height: 1; }
.ring .c span { font-size: 11px; color: var(--muted); }
.lv { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lv:last-child { border: 0; }
.medal { width: 38px; height: 38px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; font-size: 19px; flex: none; filter: grayscale(1); opacity: .55; }
.lv.done .medal { background: #27300a; filter: none; opacity: 1; box-shadow: 0 0 0 2px var(--accent) inset; }
.lv.next .medal { opacity: 1; box-shadow: 0 0 0 2px #555 inset; }
.lv .km { margin-left: auto; font-weight: 800; }
.lv.done .km { color: var(--accent); }
.lv:not(.done):not(.next) { color: var(--muted); }
.lb { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.lb .n { width: 22px; color: var(--muted); font-weight: 700; }
.lb .av { width: 30px; height: 30px; border-radius: 50%; background: #333 center/cover; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.lb .km { margin-left: auto; font-weight: 800; color: var(--accent); }
.lb.me { background: rgba(228,255,58,.07); border-radius: 12px; padding: 8px; margin: 0 -8px; }
button.lb { width: 100%; text-align: left; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.g4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.g3 label, .g4 label { font-size: 12px; margin-top: 12px; }
.fav { font-size: 28px; padding: 4px 8px; color: var(--muted); }
.fav.on { color: var(--accent); }

/* рейтинг городов */
.citybar { margin: 14px 0; }
.citybar .top { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px; }
.citybar .track { height: 12px; background: #23232a; border-radius: 6px; overflow: hidden; }
.citybar .track b { display: block; height: 100%; background: linear-gradient(90deg, #6b7a1a, var(--accent)); border-radius: 6px; transition: width .6s; }
.citybar.mine .top span:first-child { color: var(--accent); }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin: 12px 0; }
.seg button { flex: 1; padding: 9px; border-radius: 10px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-text); }

.plan { display: flex; justify-content: space-between; align-items: center; background: var(--card2); border: 1px solid var(--line); border-radius: 16px; padding: 15px; margin-top: 10px; width: 100%; text-align: left; }
.plan b { color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.skel { height: 120px; border-radius: var(--r); background: linear-gradient(100deg, var(--card) 40%, var(--card2) 50%, var(--card) 60%); background-size: 200% 100%; animation: sk 1.2s linear infinite; margin-top: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

/* нижнее меню */
#tabs { position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: 536px; margin: 0 auto; display: flex; background: rgba(24,24,28,.92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 30px; padding: 6px; z-index: 20; }
#tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--muted); padding: 8px 0; border-radius: 24px; transition: background .2s; }
#tabs button span { font-size: 20px; filter: grayscale(1); opacity: .8; }
#tabs button.on { color: var(--accent); background: #000; }
#tabs button.on span { filter: none; opacity: 1; }
#tabs button[hidden] { display: none; }

#toast { position: fixed; top: 16px; left: 50%; transform: translate(-50%, -90px); background: #222; border: 1px solid #333; padding: 11px 18px; border-radius: 14px; z-index: 60; transition: transform .25s; max-width: 90%; text-align: center; font-weight: 600; }
#toast.show { transform: translate(-50%, 0); }
