:root {
  --bg: var(--tg-theme-bg-color, #f3f4f6);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #14181f);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --accent: #ffc531;
  --accent-ink: #1b1400;
  --navy: #0f1b2d;
  --navy-2: #1b2c46;
  --red: #e5484d;
  --green: #2fa36b;
  --blue: #3e8ef7;
  --line: rgba(127, 127, 127, .16);
  --shadow: 0 10px 30px rgba(15, 27, 45, .10);
  --radius: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font-family: Manrope, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.4; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
#app { min-height: 100vh; padding-bottom: calc(86px + var(--safe-b)); }
#screen { padding: 14px 16px 8px; max-width: 560px; margin: 0 auto; }
.fade-in { animation: fadeUp .38s cubic-bezier(.2,.8,.2,1) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- tabs ---------- */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; align-items: flex-end;
  padding: 8px 10px calc(10px + var(--safe-b)); background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); z-index: 20; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--hint); padding: 4px 10px; border-radius: 14px; transition: color .2s, transform .2s; }
.tab .ti { font-size: 21px; filter: grayscale(.6); transition: filter .2s, transform .25s; }
.tab.active { color: var(--text); }
.tab.active .ti { filter: none; transform: translateY(-2px) scale(1.08); }
.tab-center { position: relative; margin-top: -26px; }
.tab-center .ti { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 18px; background: linear-gradient(145deg, #ffd768, #ffb800);
  box-shadow: 0 8px 20px rgba(255, 184, 0, .45); filter: none; font-size: 25px; }
.tab-center.active .ti { transform: translateY(-3px) rotate(-4deg) scale(1.05); }

/* ---------- common ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 10px; }
.h2 { font-size: 18px; font-weight: 800; margin: 22px 2px 10px; letter-spacing: -.01em; }
.muted { color: var(--hint); }
.row { display: flex; gap: 10px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; background: var(--line); }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 15px 18px; border-radius: 16px; font-weight: 800; font-size: 16px;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px rgba(255, 184, 0, .35); transition: transform .12s, filter .2s; }
.btn:active { transform: scale(.97); }
.btn.dark { background: var(--navy); color: #fff; box-shadow: 0 6px 16px rgba(15, 27, 45, .3); }
.btn.ghost { background: var(--line); color: var(--text); box-shadow: none; }
.btn.blue { background: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(62, 142, 247, .35); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.stack > * + * { margin-top: 10px; }
.skeleton { background: linear-gradient(90deg, var(--line) 25%, rgba(127,127,127,.08) 37%, var(--line) 63%); background-size: 400% 100%; animation: sk 1.3s infinite; border-radius: 16px; }
@keyframes sk { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }

/* ---------- avatar ---------- */
.ava { width: 44px; height: 44px; border-radius: 50%; flex: none; background-color: #ccd; background-repeat: no-repeat; box-shadow: 0 0 0 3px var(--card), 0 4px 10px rgba(0,0,0,.18); }

/* ---------- hero ---------- */
.hero { position: relative; border-radius: 26px; overflow: hidden; min-height: 300px; color: #fff; background: var(--navy); box-shadow: 0 16px 40px rgba(15, 27, 45, .28); }
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 22% 46%; transform: scale(1.06); animation: heroZoom 9s ease-out both; }
@keyframes heroZoom { from { transform: scale(1.18); } to { transform: scale(1.04); } }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(15,27,45,0) 30%, rgba(15,27,45,.92) 88%); }
.hero-in { position: relative; z-index: 2; padding: 18px; display: flex; flex-direction: column; justify-content: flex-end; min-height: 300px; }
.hero-badge { position: absolute; top: 14px; left: 14px; z-index: 3; background: rgba(255,255,255,.16); backdrop-filter: blur(10px); padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: 12px; letter-spacing: .02em; }
.bubble { background: #fff; color: #14181f; border-radius: 18px 18px 18px 6px; padding: 12px 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 92%; min-height: 46px; }
.typing span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: #9aa1ab; animation: blink 1.1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s } .typing span:nth-child(3) { animation-delay: .3s }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0) } 40% { opacity: 1; transform: translateY(-3px) } }
.hero-name { font-weight: 800; font-size: 13px; opacity: .85; margin: 10px 0 0 4px; }
.road { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; z-index: 3; background: repeating-linear-gradient(90deg, var(--accent) 0 26px, transparent 26px 46px); animation: road 1.2s linear infinite; opacity: .9; }
@keyframes road { from { background-position: 0 0 } to { background-position: -46px 0 } }

/* ---------- category ---------- */
.cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cat { background: var(--card); border-radius: 16px; padding: 12px 6px; text-align: center; font-weight: 800; box-shadow: var(--shadow); border: 2px solid transparent; transition: transform .15s, border-color .2s; }
.cat .ce { font-size: 26px; display: block; }
.cat small { display: block; color: var(--hint); font-weight: 700; font-size: 11px; }
.cat.on { border-color: var(--accent); transform: translateY(-2px); }

/* ---------- quick stats ---------- */
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 22px; font-weight: 800; }
.stat span { font-size: 12px; color: var(--hint); font-weight: 700; }

/* ---------- catalog carousel ---------- */
.carousel { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 8px 12% 22px; margin: 0 -16px; scrollbar-width: none; }
.carousel::-webkit-scrollbar { display: none; }
.pcard { flex: 0 0 76%; scroll-snap-align: center; border-radius: 26px; overflow: hidden; position: relative; color: #fff; min-height: 380px; display: flex; flex-direction: column;
  box-shadow: 0 14px 34px rgba(15, 27, 45, .28); transform: scale(.9); opacity: .7; transition: transform .35s cubic-bezier(.2,.8,.2,1), opacity .35s; }
.pcard.focus { transform: scale(1); opacity: 1; }
.pcover { height: 210px; position: relative; overflow: hidden; }
.pcover svg { width: 100%; height: 100%; display: block; }
.pbody { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; }
.ptitle { font-size: 21px; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; }
.psub { opacity: .85; font-weight: 600; margin-top: 6px; font-size: 14px; }
.pflag { position: absolute; top: 12px; left: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 12px; padding: 6px 10px; border-radius: 999px; z-index: 2; }
.powned { position: absolute; top: 12px; right: 12px; background: rgba(47, 163, 107, .95); font-weight: 800; font-size: 12px; padding: 6px 10px; border-radius: 999px; z-index: 2; }
.pbody .btn { margin-top: auto; }
.p-city { background: linear-gradient(160deg, #13284a, #0b1526); }
.p-tasks { background: linear-gradient(160deg, #3a2a05, #1f1602); }
.p-winter { background: linear-gradient(160deg, #1d4f7a, #0d2a45); }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: -8px; }
.dots i { width: 7px; height: 7px; border-radius: 99px; background: var(--line); transition: width .3s, background .3s; }
.dots i.on { width: 22px; background: var(--accent); }

/* ---------- quiz ---------- */
.modes { display: flex; gap: 8px; background: var(--line); padding: 4px; border-radius: 14px; }
.modes button { flex: 1; padding: 10px; border-radius: 11px; font-weight: 800; color: var(--hint); transition: background .2s, color .2s; }
.modes button.on { background: var(--card); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.qcard { margin-top: 12px; }
.qhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.scene { border-radius: 18px; overflow: hidden; background: #9cc478; margin: 0 -4px 12px; aspect-ratio: 1 / 1; position: relative; }
.scene svg { width: 100%; height: 100%; display: block; }
.replay { position: absolute; right: 10px; bottom: 10px; background: rgba(15,27,45,.82); color: #fff; font-weight: 800; font-size: 13px; padding: 8px 12px; border-radius: 999px; backdrop-filter: blur(6px); }
.qtext { font-size: 17px; font-weight: 700; line-height: 1.35; }
.opts { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.opt { text-align: left; padding: 14px 14px 14px 46px; border-radius: 15px; background: var(--bg); font-weight: 700; position: relative; border: 2px solid transparent; transition: transform .12s, background .25s, border-color .25s; }
.opt::before { content: attr(data-n); position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; background: var(--line); font-size: 13px; }
.opt:active { transform: scale(.98); }
.opt.right { background: rgba(47, 163, 107, .14); border-color: var(--green); animation: pop .4s; }
.opt.right::before { content: "✓"; background: var(--green); color: #fff; }
.opt.wrong { background: rgba(229, 72, 77, .12); border-color: var(--red); animation: shake .4s; }
.opt.wrong::before { content: "✕"; background: var(--red); color: #fff; }
.opt.dim { opacity: .5; }
@keyframes pop { 0% { transform: scale(1) } 40% { transform: scale(1.03) } 100% { transform: scale(1) } }
@keyframes shake { 0%,100% { transform: translateX(0) } 20% { transform: translateX(-7px) } 40% { transform: translateX(6px) } 60% { transform: translateX(-4px) } 80% { transform: translateX(3px) } }
.explain { margin-top: 14px; padding: 14px; border-radius: 18px; background: var(--bg); animation: fadeUp .35s both; }
.explain .who { font-weight: 800; }
.explain .verdict { font-size: 18px; font-weight: 800; }
.rule { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 800; padding: 5px 10px; border-radius: 999px; background: rgba(62, 142, 247, .14); color: var(--blue); }
.pbar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: linear-gradient(90deg, #ffd768, #ffb800); border-radius: 99px; transition: width .5s cubic-bezier(.2,.8,.2,1); }

/* ---------- progress ---------- */
.ring { width: 150px; height: 150px; position: relative; margin: 6px auto 4px; }
.ring svg { transform: rotate(-90deg); }
.ring .rv { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .rv b { font-size: 34px; font-weight: 800; display: block; line-height: 1; }
.topic { margin: 12px 0; }
.topic .tt { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.tbar { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.tbar i { display: block; height: 100%; border-radius: 99px; width: 0; transition: width .9s cubic-bezier(.2,.8,.2,1); }

/* ---------- result ---------- */
.result { text-align: center; padding: 22px 16px; }
.result .big { font-size: 56px; line-height: 1; }
.mist { text-align: left; margin-top: 10px; padding: 12px; border-radius: 14px; background: var(--bg); font-size: 14px; }

/* ---------- sheet ---------- */
#sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 40; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 90vh; overflow-y: auto; background: var(--card); border-radius: 26px 26px 0 0; z-index: 41;
  transform: translateY(105%); transition: transform .38s cubic-bezier(.2,.8,.2,1); padding: 8px 18px calc(22px + var(--safe-b)); max-width: 560px; margin: 0 auto; }
#sheet.open { transform: none; }
#sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet-grip { width: 42px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 12px; }
.sheet-cover { border-radius: 20px; overflow: hidden; height: 190px; margin-bottom: 14px; }
.sheet-cover svg { width: 100%; height: 100%; display: block; }
.bullets { padding: 0; margin: 12px 0 16px; list-style: none; }
.bullets li { padding: 8px 0 8px 30px; position: relative; font-weight: 600; border-bottom: 1px dashed var(--line); }
.bullets li::before { content: "✓"; position: absolute; left: 4px; top: 8px; width: 18px; height: 18px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 800; display: grid; place-items: center; }

/* ---------- toast & confetti ---------- */
#toast { position: fixed; left: 50%; top: 16px; transform: translate(-50%, -260%); visibility: hidden; background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 14px; font-weight: 700; z-index: 60;
  transition: transform .35s cubic-bezier(.2,.8,.2,1), visibility .35s; max-width: 90vw; box-shadow: 0 10px 24px rgba(0,0,0,.25); }
#toast.show { transform: translate(-50%, 0); visibility: visible; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }

/* ---------- курсы на виду ---------- */
.btn.green { background: var(--green); color: #fff; box-shadow: 0 6px 16px rgba(47, 163, 107, .35); }
.h2.with-link { display: flex; align-items: baseline; justify-content: space-between; }
.h2 .lnk { font-size: 14px; font-weight: 800; color: var(--blue); padding: 4px 2px; }
.pstrip { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 2px 16px 12px; scrollbar-width: none; }
.pstrip::-webkit-scrollbar { display: none; }
.pmini { flex: 0 0 64%; scroll-snap-align: start; border-radius: 20px; overflow: hidden; color: #fff; position: relative; text-align: left;
  box-shadow: var(--shadow); display: flex; flex-direction: column; animation: fadeUp .45s cubic-bezier(.2,.8,.2,1) both; transition: transform .15s; }
.pmini:nth-child(2) { animation-delay: .07s; } .pmini:nth-child(3) { animation-delay: .14s; }
.pmini:active { transform: scale(.97); }
.pmini .pc { height: 100px; overflow: hidden; }
.pmini .pc svg, .promo .pc svg { width: 100%; height: 100%; display: block; }
.pmini .pb { padding: 10px 12px 13px; }
.pmini .pb b { display: block; font-size: 15px; line-height: 1.2; margin-bottom: 3px; }
.pmini .pb span { font-size: 12px; opacity: .8; font-weight: 600; line-height: 1.25; display: block; }
.pmini .pflag, .pmini .powned { top: 8px; font-size: 11px; padding: 4px 8px; }
.pmini .pflag { left: 8px; } .pmini .powned { right: 8px; }
.promo { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; margin-top: 12px; padding: 10px; border-radius: 18px; color: #fff;
  box-shadow: var(--shadow); animation: fadeUp .45s .3s cubic-bezier(.2,.8,.2,1) both; transition: transform .15s; }
.promo:active { transform: scale(.98); }
.promo .pc { flex: 0 0 88px; height: 62px; border-radius: 12px; overflow: hidden; }
.promo .pt { flex: 1; font-size: 13px; font-weight: 600; line-height: 1.3; opacity: .95; }
.promo .pt b { display: block; font-size: 14px; font-weight: 800; margin-bottom: 2px; opacity: 1; }
.promo .go { font-size: 26px; font-weight: 800; color: var(--accent); padding-right: 4px; }
.promo.big { flex-direction: column; align-items: stretch; padding: 0; overflow: hidden; gap: 0; }
.promo.big .pc { flex: none; height: 130px; border-radius: 0; }
.promo.big .pt { padding: 12px 14px 0; font-size: 14px; }
.promo.big .pt b { font-size: 17px; margin-bottom: 4px; }
.promo.big .btn { margin: 12px 14px 14px; width: auto; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(255, 197, 49, .65); } 70% { box-shadow: 0 0 0 14px rgba(255, 197, 49, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 197, 49, 0); } }
.tab-center.pulse .ti { animation: ring 1.9s ease-out infinite; }
