/* Палитра с макета ТЗ: фиолетовый градиент, жёлтый акцент, крупные скругления. */
:root {
  --bg: #4b2fd6;
  --bg-2: #7b5cff;
  --card: rgba(255, 255, 255, .12);
  --card-solid: #2f1b7a;
  --line: rgba(255, 255, 255, .18);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, .68);
  --accent: #ffd84d;
  --accent-2: #ff6b3d;
  --green: #3ddc84;
  --red: #ff5a6e;
  --radius: 18px;
}

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

body {
  margin: 0;
  padding: 0 14px calc(84px + env(safe-area-inset-bottom));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(170deg, var(--bg-2) 0%, var(--bg) 45%, #2b1a86 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- заставка ---------- */
.splash {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); z-index: 50; color: var(--muted); font-size: 14px;
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .25); border-top-color: var(--accent);
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- шапка ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 4px; }
.level-badge {
  background: rgba(0, 0, 0, .28); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
}
.help-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(0, 0, 0, .28); color: var(--text); font-size: 16px; font-weight: 700;
}

.logo {
  margin: 6px 0 10px; text-align: center; font-size: 34px; line-height: .95;
  font-weight: 900; letter-spacing: -.5px; text-transform: uppercase;
  text-shadow: 0 4px 0 rgba(0, 0, 0, .25);
}
.logo span { display: block; color: var(--accent); font-size: 44px; }
.title { font-size: 24px; font-weight: 800; margin: 18px 0 4px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.lead { color: var(--muted); font-size: 14px; line-height: 1.45; text-align: center; margin: 0 0 18px; }
.note { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 14px 0; }

/* ---------- карточки ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  backdrop-filter: blur(6px);
}
.card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 800; }
.card p { margin: 0 0 12px; font-size: 13px; color: var(--muted); line-height: 1.45; }

/* ---------- онбординг ---------- */
.grades { display: flex; gap: 10px; }
.grade {
  flex: 1; padding: 16px 0; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, .2); color: var(--text); font-size: 18px; font-weight: 800;
}
.grade.on { background: var(--accent); color: #2b1a86; border-color: var(--accent); }

.subjects { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.subj {
  padding: 12px 10px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, .2); color: var(--text); font-size: 13px;
  font-weight: 600; text-align: left; display: flex; align-items: center; gap: 8px;
}
.subj.on { background: var(--accent); color: #2b1a86; border-color: var(--accent); }

/* ---------- кнопки ---------- */
.btn-main {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 16px; border: none; border-radius: var(--radius);
  background: linear-gradient(180deg, #ffe27a, var(--accent));
  color: #2b1a86; font-size: 16px; font-weight: 800; font-family: inherit;
  box-shadow: 0 5px 0 #d9a800; margin-bottom: 12px;
}
.btn-main:active { transform: translateY(3px); box-shadow: 0 2px 0 #d9a800; }
.btn-main:disabled { opacity: .5; box-shadow: none; }
.btn-main.small { padding: 13px; font-size: 14px; justify-content: center; }
.btn-task { text-align: left; }
.btn-icon { font-size: 22px; }
.btn-text { flex: 1; display: flex; flex-direction: column; }
.btn-text small { font-weight: 600; opacity: .7; font-size: 11px; }
.btn-arrow { font-size: 22px; opacity: .6; }
.btn-ghost {
  width: 100%; padding: 13px; border-radius: var(--radius); border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 14px; font-family: inherit;
}
.btn-copy {
  padding: 8px 12px; border-radius: 10px; border: none;
  background: var(--accent); color: #2b1a86; font-weight: 700; font-size: 12px;
}

/* ---------- мишка ---------- */
.bear-stage { position: relative; text-align: center; margin: 6px 0 16px; }
.bear {
  font-size: 96px; line-height: 1; filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .35));
  animation: float 3.5s ease-in-out infinite;
}
.bear img { width: 190px; height: auto; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.bubble {
  position: absolute; top: 20px; background: #fff; color: #2b1a86;
  border-radius: 12px; padding: 6px 10px; font-size: 11px; line-height: 1.25;
  font-weight: 600; box-shadow: 0 4px 10px rgba(0, 0, 0, .2);
}
.bubble-left { left: 0; transform: rotate(-8deg); }
.bubble-right { right: 0; transform: rotate(8deg); }

.stats { display: flex; gap: 10px; margin-bottom: 14px; }
.stat {
  flex: 1; background: rgba(0, 0, 0, .26); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px; display: grid;
  grid-template-columns: 28px 1fr; grid-template-rows: auto auto; column-gap: 8px;
}
.stat-icon { grid-row: 1 / 3; font-size: 24px; align-self: center; }
.stat-label { font-size: 11px; color: var(--muted); }
.stat b { font-size: 19px; font-weight: 800; }

.progress-block { margin-bottom: 16px; }
.progress-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.progress { height: 12px; border-radius: 999px; background: rgba(0, 0, 0, .3); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--green), var(--accent)); transition: width .5s ease; }

.warn {
  background: rgba(255, 216, 77, .16); border: 1px solid rgba(255, 216, 77, .4);
  border-radius: 14px; padding: 12px; font-size: 12px; color: #ffe9a3; text-align: center;
}

/* ---------- задания ---------- */
.task {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.task-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 800; font-size: 14px; }
.task-num { margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 600; }
.task-body { font-size: 14px; line-height: 1.5; }
.task-body p { margin: 0 0 10px; }
.task-body table { width: 100%; border-collapse: collapse; font-size: 12px; }
.task-body td, .task-body th { border: 1px solid var(--line); padding: 4px 6px; }
.task-answer { display: flex; gap: 8px; margin-top: 12px; }
.input {
  flex: 1; width: 100%; padding: 13px; border-radius: 12px; font-size: 15px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, .28); color: var(--text);
  font-family: inherit; margin-bottom: 10px;
}
.input::placeholder { color: rgba(255, 255, 255, .45); }
.task-answer .input { margin-bottom: 0; }
.btn-send {
  padding: 0 18px; border-radius: 12px; border: none; background: var(--accent);
  color: #2b1a86; font-weight: 800; font-size: 14px;
}
.verdict { margin-top: 12px; padding: 12px; border-radius: 12px; font-size: 13px; line-height: 1.45; }
.verdict.ok { background: rgba(61, 220, 132, .16); border: 1px solid rgba(61, 220, 132, .4); }
.verdict.no { background: rgba(255, 90, 110, .14); border: 1px solid rgba(255, 90, 110, .4); }
.verdict b { display: block; margin-bottom: 4px; }
.explain { margin-top: 8px; color: var(--muted); font-size: 12px; max-height: 200px; overflow: auto; }

/* ---------- барабан ---------- */
.wheel-wrap { position: relative; display: flex; justify-content: center; margin: 10px 0 18px; }
.wheel-pointer { position: absolute; top: -6px; font-size: 26px; color: var(--accent); z-index: 2; }
.wheel {
  width: 240px; height: 240px; border-radius: 50%;
  border: 8px solid var(--accent); box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  transition: transform 4s cubic-bezier(.15, .8, .2, 1);
}
.prizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.prize {
  background: rgba(0, 0, 0, .24); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 6px; text-align: center; font-size: 10px; color: var(--muted);
}
.prize span { display: block; font-size: 20px; margin-bottom: 4px; }
.ways { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.history { font-size: 12px; color: var(--muted); }
.history div { padding: 7px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; }
.history div:last-child { border-bottom: none; }

/* ---------- рейтинг ---------- */
.me-card { text-align: center; }
.me-card b { font-size: 26px; display: block; }
.rating-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rating-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.rating-row:last-child { border-bottom: none; }
.rating-row.me { background: rgba(255, 216, 77, .16); font-weight: 800; }
.rating-place { width: 28px; font-weight: 800; }
.rating-score { margin-left: auto; font-weight: 700; }

/* ---------- материалы, гейт ---------- */
.gate-list { margin-bottom: 14px; }
.gate-row {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; margin-bottom: 8px; font-size: 14px;
}
.gate-row a { margin-left: auto; color: var(--accent); font-weight: 700; text-decoration: none; font-size: 13px; }
.gate-row.ok { border-color: rgba(61, 220, 132, .5); }

.mat-row {
  display: flex; align-items: center; gap: 10px; padding: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; margin-bottom: 8px; color: var(--text); text-decoration: none;
}
.mat-row small { display: block; color: var(--muted); font-size: 11px; }

/* ---------- ролики ---------- */
.link-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.link-row code {
  flex: 1; font-size: 11px; padding: 10px; border-radius: 10px;
  background: rgba(0, 0, 0, .3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ref-stats { display: flex; gap: 8px; font-size: 12px; color: var(--muted); }
.ref-stats b { color: var(--text); }
.qr { width: 190px; display: block; margin: 0 auto; border-radius: 14px; background: #fff; padding: 8px; }

/* ---------- таббар ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  background: rgba(24, 12, 74, .96); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px); z-index: 20;
}
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 10px; font-family: inherit; display: flex; flex-direction: column;
  align-items: center; gap: 3px; padding: 4px 0;
}
.tab span { font-size: 19px; }
.tab.active { color: var(--accent); }

/* ---------- тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: #1b0f5c; border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 14px; font-size: 13px; max-width: 88%;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 40; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ---------- тест на уровень ---------- */
.timer {
  font-size: 18px; font-weight: 800; padding: 6px 12px; border-radius: 999px;
  background: rgba(0, 0, 0, .3); border: 1px solid var(--line);
}
.timer.low { background: rgba(255, 90, 110, .25); border-color: var(--red); }
.exam-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.exam-item .num { font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.exam-item.done { border-color: rgba(61, 220, 132, .45); }
.result-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-align: center; margin-bottom: 14px; }
.result-score { font-size: 44px; font-weight: 900; color: var(--accent); line-height: 1; }
.result-level { font-size: 17px; font-weight: 800; margin: 8px 0 6px; }
.review-row { display: flex; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.review-row:last-child { border-bottom: none; }
.review-row .mark { width: 22px; }
.review-row small { display: block; color: var(--muted); font-size: 11px; }


/* ---------- варианты ответа ---------- */
.options { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.option {
  text-align: left; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, .24);
  color: var(--text); font-family: inherit; font-size: 14px; line-height: 1.35;
}
.option:active { transform: scale(.99); }
.option.picked { background: var(--accent); color: #2b1a86; border-color: var(--accent); }
.option:disabled { opacity: .55; }
/* Картинки из базы Умскул приходят абсолютными ссылками на их CDN */
.task-body img, .exam-item img { max-width: 100%; height: auto; border-radius: 10px; background: #fff; margin: 6px 0; }
