/* ============================================================
   ICE RUSH — интерфейс
   Стекло, мягкие тени, крупные кнопки, читаемость на телефоне.
   ============================================================ */

:root {
  --bg: #0b1220;
  --glass: rgba(20, 32, 54, 0.55);
  --glass-2: rgba(30, 46, 74, 0.45);
  --stroke: rgba(160, 200, 255, 0.16);
  --stroke-2: rgba(160, 200, 255, 0.30);
  --text: #eaf2fb;
  --muted: #9db2cd;
  --accent: #7fd0ff;
  --accent-2: #c08cff;
  --gold: #ffd45c;
  --good: #5cffc8;
  --bad: #ff6a80;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.42);
  --radius: 18px;
  /* Внутри Telegram отступы приходят от клиента (шапка, «чёлка»),
     поэтому берём максимум из системного env() и того, что сообщил SDK. */
  --tg-top: 0px;
  --tg-bottom: 0px;
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-bottom));
  --safe-t: max(env(safe-area-inset-top, 0px), var(--tg-top));
}

* { 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: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
}

#scene {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none;
}

/* Виньетка и лёгкая цветокоррекция поверх сцены: добавляет глубины кадру
   и не стоит ни одного лишнего draw call. */
#grade {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    radial-gradient(118% 88% at 50% 42%, transparent 42%, rgba(6, 12, 26, .40) 100%),
    linear-gradient(180deg, rgba(120, 170, 255, .10) 0%, transparent 34%, rgba(10, 20, 40, .18) 100%);
  mix-blend-mode: multiply;
}
#grade.warm {
  background:
    radial-gradient(118% 88% at 50% 42%, transparent 44%, rgba(24, 12, 6, .38) 100%),
    linear-gradient(180deg, rgba(255, 200, 140, .12) 0%, transparent 34%, rgba(30, 16, 8, .16) 100%);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ============================================================
   ОБЩИЕ ЭЛЕМЕНТЫ
   ============================================================ */

.glass {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

button {
  font: inherit; color: inherit; cursor: pointer;
  border: 1px solid var(--stroke); background: var(--glass-2);
  border-radius: 14px; padding: 12px 18px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: transform .12s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
button:hover { background: rgba(60, 90, 140, 0.5); border-color: var(--stroke-2); }
button:active { transform: scale(.97); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.primary {
  background: linear-gradient(135deg, #3aa0ff, #7f5cff);
  border-color: rgba(180, 220, 255, .45);
  font-weight: 650; letter-spacing: .3px;
  box-shadow: 0 10px 30px rgba(60, 130, 255, .35);
}
.primary:hover { background: linear-gradient(135deg, #4fb0ff, #8f6cff); }
.primary.big { width: 100%; padding: 18px; font-size: 1.1rem; margin-top: 22px; }

.ghost { background: rgba(255, 255, 255, .05); }
.ghost.small { padding: 8px 14px; font-size: .85rem; }

h2 { margin: 0 0 12px; font-size: 1.45rem; font-weight: 650; letter-spacing: .2px; }
h3.sec {
  margin: 26px 0 12px; font-size: .82rem; font-weight: 700;
  letter-spacing: 1.6px; text-transform: uppercase; color: var(--muted);
}
.lead { color: var(--muted); margin: 6px 0 4px; max-width: 62ch; }

/* ============================================================
   ЭКРАНЫ
   ============================================================ */

/* Выше виньетки (z-index 1), но ниже HUD (5) */
#screens { position: fixed; inset: 0; pointer-events: none; z-index: 2; }

.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
  pointer-events: auto;
  background: radial-gradient(120% 80% at 50% -10%, rgba(30, 60, 110, .55), rgba(6, 10, 20, .88));
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade .28s ease;
  overflow: hidden;
}
.screen.active { display: flex; }
.screen.overlay { background: rgba(4, 8, 16, .72); align-items: center; justify-content: center; }

@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: calc(14px + var(--safe-t)) 20px 14px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(10, 18, 32, .45);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  flex: 0 0 auto;
}
.topbar .title { font-size: 1.15rem; font-weight: 650; flex: 1; }
.topbar .back { padding: 8px 14px; border-radius: 12px; font-size: .95rem; }

.pad { padding: 20px 20px calc(40px + var(--safe-b)); overflow-y: auto; flex: 1; }
.pad::-webkit-scrollbar, .list-pane::-webkit-scrollbar { width: 8px; }
.pad::-webkit-scrollbar-thumb, .list-pane::-webkit-scrollbar-thumb {
  background: rgba(140, 180, 230, .22); border-radius: 8px;
}

/* ---------- логотип ---------- */
.logo {
  font-weight: 800; letter-spacing: 3px; font-size: 2.6rem; line-height: 1;
  display: flex; gap: .3em; align-items: baseline;
}
.logo span { color: var(--accent); text-shadow: 0 0 28px rgba(127, 208, 255, .55); }
.logo b {
  background: linear-gradient(120deg, #fff, #c08cff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo.small { font-size: 1.25rem; letter-spacing: 2px; }

/* ---------- загрузка ---------- */
#scrLoad { align-items: center; justify-content: center; }
.load-box { text-align: center; }
.load-sub { color: var(--muted); margin: 14px 0 20px; }
.load-bar {
  width: 240px; height: 6px; border-radius: 6px; margin: 0 auto;
  background: rgba(255, 255, 255, .1); overflow: hidden;
}
.load-bar > div {
  height: 100%; width: 0%; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .3s ease;
}

/* ---------- кошелёк ---------- */
.wallet { display: flex; gap: 10px; flex-wrap: wrap; }
.wallet .cur {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--stroke);
  font-variant-numeric: tabular-nums; font-size: .92rem;
}
.wallet .cur i { font-style: normal; font-size: 1.05em; }
.wallet.mini .cur { padding: 4px 10px; font-size: .84rem; }

/* ---------- главное меню ---------- */
.menu-body { flex: 1; overflow-y: auto; padding: 20px 20px calc(30px + var(--safe-b)); }

.menu-hero {
  display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 20px 22px; margin-bottom: 22px;
}
.hero-name { font-size: 1.5rem; font-weight: 700; }
.hero-role { color: var(--muted); font-size: .92rem; margin-bottom: 12px; }
.hero-lvl { display: flex; align-items: center; gap: 12px; }
.lvl-badge {
  padding: 4px 12px; border-radius: 999px; font-size: .82rem;
  background: linear-gradient(135deg, rgba(127, 208, 255, .25), rgba(192, 140, 255, .25));
  border: 1px solid var(--stroke-2);
}
.xp-bar { width: 160px; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.xp-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.hero-best { display: flex; gap: 24px; align-items: flex-end; }
.hero-best em { display: block; font-style: normal; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.hero-best b { font-size: 1.4rem; font-variant-numeric: tabular-nums; }

.mode-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.mode-card {
  text-align: left; padding: 18px; border-radius: var(--radius);
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--glass); border: 1px solid var(--stroke);
}
.mode-card:hover { border-color: var(--stroke-2); transform: translateY(-2px); }
.mode-card .ico {
  font-size: 1.6rem; width: 46px; height: 46px; flex: 0 0 auto;
  display: grid; place-items: center; border-radius: 14px;
  background: rgba(127, 208, 255, .12); border: 1px solid var(--stroke);
}
.mode-card .nm { font-weight: 650; margin-bottom: 4px; }
.mode-card .ab { font-size: .85rem; color: var(--muted); line-height: 1.35; }

.menu-nav {
  display: grid; gap: 10px; margin-top: 22px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
.nav-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; }
.nav-btn i { font-style: normal; font-size: 1.4rem; }
.nav-btn span { font-size: .85rem; }

/* ---------- выбор старта ---------- */
.diff-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.diff-card {
  text-align: left; padding: 16px; border-radius: 16px;
  background: var(--glass-2); border: 1px solid var(--stroke);
}
.diff-card.on { border-color: var(--accent); background: rgba(60, 130, 210, .28); box-shadow: 0 0 0 1px var(--accent) inset; }
.diff-card .nm { font-weight: 650; margin-bottom: 6px; }
.diff-card .ab { font-size: .82rem; color: var(--muted); line-height: 1.35; }

.rink-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.rink-chip {
  flex: 0 0 auto; padding: 10px 16px; border-radius: 14px; font-size: .9rem;
  background: var(--glass-2); border: 1px solid var(--stroke); white-space: nowrap;
}
.rink-chip.on { border-color: var(--accent); background: rgba(60, 130, 210, .3); }
.rink-chip.locked { opacity: .4; }

.tour-list { display: grid; gap: 10px; margin-top: 16px; }
.tour-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border-radius: 14px; background: var(--glass-2); border: 1px solid var(--stroke);
  text-align: left; width: 100%;
}
.tour-row.on { border-color: var(--accent); background: rgba(60, 130, 210, .28); }
.tour-row.locked { opacity: .45; }
.tour-row .n { font-weight: 700; font-size: 1.1rem; width: 28px; color: var(--muted); }
.tour-row .info { flex: 1; }
.tour-row .info b { display: block; }
.tour-row .info em { font-style: normal; font-size: .8rem; color: var(--muted); }
.tour-row .req { font-size: .82rem; text-align: right; color: var(--muted); }

/* ---------- сплит: превью + список ---------- */
.split { flex: 1; display: flex; min-height: 0; }
.preview-pane {
  flex: 1 1 42%; position: relative; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 20px; gap: 10px; pointer-events: none;
}
.preview-pane > * { pointer-events: auto; }
.preview-hint {
  font-size: .8rem; color: var(--muted); letter-spacing: 1px; text-transform: uppercase;
  background: rgba(10, 18, 32, .5); padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--stroke);
}
.list-pane {
  flex: 1 1 58%; overflow-y: auto; padding: 18px 20px calc(30px + var(--safe-b));
  background: rgba(8, 14, 26, .55); border-left: 1px solid var(--stroke);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.list-pane.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); align-content: start; }

/* ---------- карточки фигуристов ---------- */
.skater-card {
  display: block; width: 100%; text-align: left; margin-bottom: 12px;
  padding: 16px; border-radius: 16px; background: var(--glass-2); border: 1px solid var(--stroke);
}
.skater-card.on { border-color: var(--accent); background: rgba(60, 130, 210, .26); }
.skater-card.locked { opacity: .6; }
.skater-card .hd { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.skater-card .nm { font-weight: 650; font-size: 1.08rem; }
.skater-card .rl { font-size: .82rem; color: var(--accent); }
.skater-card .ab { font-size: .85rem; color: var(--muted); margin: 6px 0 10px; }
.bars { display: grid; gap: 5px; grid-template-columns: repeat(2, 1fr); }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: .74rem; color: var(--muted); }
.bar-row .bn { flex: 0 0 92px; }
.bar-row .bt { flex: 1; height: 5px; border-radius: 4px; background: rgba(255, 255, 255, .09); overflow: hidden; }
.bar-row .bf { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ---------- магазин ---------- */
.shop-tabs {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 20px;
  border-bottom: 1px solid var(--stroke); background: rgba(10, 18, 32, .4);
  flex: 0 0 auto;
}
.shop-tab {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; font-size: .86rem;
  background: rgba(255, 255, 255, .05); white-space: nowrap;
}
.shop-tab.on { background: rgba(60, 130, 210, .35); border-color: var(--accent); }

.item {
  padding: 14px; border-radius: 16px; text-align: left;
  background: var(--glass-2); border: 1px solid var(--stroke);
  display: flex; flex-direction: column; gap: 8px; min-height: 132px;
}
.item.on { border-color: var(--good); box-shadow: 0 0 0 1px var(--good) inset; }
.item.owned .price { color: var(--good); }
.item .sw {
  width: 100%; height: 34px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .18);
}
.item .nm { font-size: .9rem; font-weight: 600; line-height: 1.25; flex: 1; }
.item .price { font-size: .84rem; color: var(--gold); font-variant-numeric: tabular-nums; }
.item .mod { font-size: .74rem; color: var(--accent); }
.item.cant { opacity: .55; }

/* ---------- дерево навыков ---------- */
.stats-panel { padding: 16px 18px; margin-bottom: 18px; }
.stats-panel .bars { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }

.branch-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; }
.branch-tab { flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; font-size: .86rem; }
.branch-tab.on { background: rgba(60, 130, 210, .35); border-color: var(--accent); }

.skill-tree { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.skill {
  padding: 14px; border-radius: 16px; text-align: left;
  background: var(--glass-2); border: 1px solid var(--stroke);
  display: flex; flex-direction: column; gap: 6px;
}
.skill.done { border-color: var(--good); background: rgba(40, 120, 100, .22); }
.skill.locked { opacity: .5; }
.skill .nm { font-weight: 650; display: flex; justify-content: space-between; gap: 8px; }
.skill .lv { font-size: .78rem; color: var(--accent); }
.skill .ab { font-size: .8rem; color: var(--muted); line-height: 1.35; }
.skill .ft { font-size: .82rem; display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 4px; }
.skill .cost { color: var(--gold); }
.skill .why { color: var(--bad); font-size: .76rem; }

/* ---------- катки ---------- */
.rink-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.rink-card {
  padding: 16px; border-radius: 16px; text-align: left;
  border: 1px solid var(--stroke); position: relative; overflow: hidden;
  min-height: 130px; display: flex; flex-direction: column; justify-content: flex-end;
}
.rink-card .nm { font-weight: 650; position: relative; }
.rink-card .sb { font-size: .82rem; color: rgba(255, 255, 255, .7); position: relative; }
.rink-card .lk { font-size: .8rem; color: var(--gold); margin-top: 6px; position: relative; }
.rink-card.locked { filter: saturate(.35) brightness(.7); }

/* ---------- задания ---------- */
.streak-card { padding: 16px 18px; display: flex; align-items: center; gap: 16px; }
.streak-card .big { font-size: 2rem; font-weight: 700; color: var(--gold); }
.quest-list, .ach-list { display: grid; gap: 10px; }
.quest, .ach {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border-radius: 14px; background: var(--glass-2); border: 1px solid var(--stroke);
}
.quest .txt, .ach .txt { flex: 1; }
.quest .txt b, .ach .txt b { display: block; font-weight: 600; }
.quest .txt em, .ach .txt em { font-style: normal; font-size: .8rem; color: var(--muted); }
.quest .pr { width: 110px; }
.quest .pr .bt { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.quest .pr .bf { height: 100%; background: linear-gradient(90deg, var(--accent), var(--good)); }
.quest .pr .lb { font-size: .74rem; color: var(--muted); text-align: right; margin-top: 3px; }
.quest.done, .ach.done { border-color: var(--good); background: rgba(40, 120, 100, .18); }
.ach .ic { font-size: 1.4rem; }

/* ---------- настройки ---------- */
.setting {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 16px; border-radius: 14px; margin-bottom: 10px;
  background: var(--glass-2); border: 1px solid var(--stroke);
}
.setting .lb { flex: 1; }
.setting .lb b { display: block; font-weight: 600; }
.setting .lb em { font-style: normal; font-size: .8rem; color: var(--muted); }
.setting input[type=range] { width: 150px; accent-color: var(--accent); }
.seg { display: flex; gap: 6px; }
.seg button { padding: 8px 14px; font-size: .85rem; border-radius: 10px; }
.seg button.on { background: rgba(60, 130, 210, .4); border-color: var(--accent); }
.switch { width: 52px; height: 30px; border-radius: 999px; padding: 3px; position: relative; }
.switch .kn {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--muted); transition: left .18s ease, background .18s ease;
}
.switch.on { background: rgba(60, 160, 255, .45); border-color: var(--accent); }
.switch.on .kn { left: 25px; background: #fff; }

/* ---------- пауза ---------- */
.dialog { padding: 26px; width: min(420px, 90vw); display: grid; gap: 10px; }
.dialog h2 { text-align: center; }
.pause-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 12px; text-align: center;
}
.pause-stats div em { display: block; font-style: normal; font-size: .74rem; color: var(--muted); }
.pause-stats div b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }

/* ---------- результаты ---------- */
#scrResult { overflow-y: auto; }
.result-wrap { padding: calc(20px + var(--safe-t)) 20px calc(30px + var(--safe-b)); max-width: 980px; margin: 0 auto; width: 100%; }
.result-head { display: flex; align-items: center; gap: 20px; padding: 20px 24px; margin-bottom: 16px; }
.grade {
  width: 72px; height: 72px; flex: 0 0 auto; border-radius: 20px;
  display: grid; place-items: center; font-size: 2.4rem; font-weight: 800;
  background: linear-gradient(135deg, rgba(127, 208, 255, .3), rgba(192, 140, 255, .3));
  border: 1px solid var(--stroke-2); text-shadow: 0 0 20px rgba(127, 208, 255, .6);
}
.result-title { flex: 1; }
.result-title h2 { margin: 0; }
.result-total { text-align: right; }
.result-total em { display: block; font-style: normal; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.result-total b { font-size: 2rem; font-variant-numeric: tabular-nums; }

.result-cols { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.res-card { padding: 18px 20px; }
.res-card h3 { margin: 0 0 12px; font-size: .8rem; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); }
.protocol { max-height: 300px; overflow-y: auto; display: grid; gap: 4px; }
.prow {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  padding: 7px 10px; border-radius: 10px; background: rgba(255, 255, 255, .04);
  font-size: .86rem;
}
.prow .en { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .eg { font-variant-numeric: tabular-nums; width: 44px; text-align: right; }
.prow .ev { font-variant-numeric: tabular-nums; width: 52px; text-align: right; font-weight: 600; }
.prow.good .eg { color: var(--good); }
.prow.bad { background: rgba(255, 90, 110, .12); }
.prow.bad .eg { color: var(--bad); }
.prow .fl { grid-column: 1 / -1; font-size: .74rem; color: var(--bad); }
.protocol-sum {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--stroke); text-align: center;
}
.protocol-sum em { display: block; font-style: normal; font-size: .72rem; color: var(--muted); }
.protocol-sum b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.res-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 18px; }
.res-stats div { display: flex; justify-content: space-between; font-size: .88rem; padding: 5px 0; }
.res-stats div span { color: var(--muted); }
.res-stats div b { font-variant-numeric: tabular-nums; }
.res-rewards { display: flex; gap: 10px; flex-wrap: wrap; }
.res-rewards .rw {
  padding: 8px 14px; border-radius: 12px; font-variant-numeric: tabular-nums;
  background: rgba(255, 212, 92, .12); border: 1px solid rgba(255, 212, 92, .3);
}
.res-new {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: rgba(92, 255, 200, .12); border: 1px solid rgba(92, 255, 200, .35);
  font-size: .88rem;
}
.result-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.result-actions button { flex: 1; min-width: 130px; }

/* ============================================================
   HUD
   ============================================================ */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud > * { pointer-events: none; }
.hud button { pointer-events: auto; }

.hud-top {
  position: absolute; top: calc(12px + var(--safe-t)); left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 0 16px; gap: 12px;
}
.hud-left { display: flex; flex-direction: column; gap: 6px; }
.stat-big {
  font-size: 2.3rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 16px rgba(0, 0, 0, .6);
}
.stat-big em { font-style: normal; font-size: .95rem; color: var(--muted); margin-left: 4px; }
.stat-row { display: flex; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px; font-size: .88rem; font-variant-numeric: tabular-nums;
  background: rgba(10, 18, 32, .55); border: 1px solid var(--stroke);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.chip i { font-style: normal; }
.chip.coin i { color: var(--accent); }
.chip.mult { color: var(--gold); font-weight: 700; transition: transform .16s ease; }
.chip.mult.pump { transform: scale(1.25); }

.hud-right { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.score-line {
  display: flex; gap: 8px; align-items: baseline; font-variant-numeric: tabular-nums;
  background: rgba(10, 18, 32, .5); padding: 3px 11px; border-radius: 999px;
  border: 1px solid var(--stroke); font-size: .9rem;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.score-line b { font-size: .68rem; letter-spacing: 1px; color: var(--muted); font-weight: 700; }
.edge-badge {
  margin-top: 3px; padding: 5px 11px; border-radius: 12px; text-align: right;
  background: rgba(10, 18, 32, .5); border: 1px solid var(--stroke);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.edge-code { display: block; font-weight: 700; font-size: .9rem; color: var(--accent); letter-spacing: 1px; }
.edge-jumps { display: block; font-size: .7rem; color: var(--muted); }

/* --- Flow --- */
.flow-wrap {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + var(--safe-b)); width: min(340px, 62vw); text-align: center;
}
.flow-bar {
  height: 10px; border-radius: 8px; overflow: hidden;
  background: rgba(10, 18, 32, .6); border: 1px solid var(--stroke);
}
.flow-fill {
  height: 100%; width: 0%; border-radius: 8px;
  background: linear-gradient(90deg, #3aa0ff, #c08cff, #5cffc8);
  transition: width .12s linear;
}
.flow-wrap.full .flow-fill { animation: flowPulse .8s ease-in-out infinite; }
@keyframes flowPulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.7); } }
.flow-label {
  font-size: .66rem; letter-spacing: 3px; color: var(--muted); margin-top: 4px; font-weight: 700;
}
.flow-wrap.full .flow-label { color: var(--good); }
.stamina-bar {
  height: 4px; border-radius: 4px; margin-top: 5px; overflow: hidden;
  background: rgba(10, 18, 32, .5);
}
.stamina-fill { height: 100%; width: 100%; background: rgba(255, 212, 92, .65); transition: width .2s linear; }

/* --- бонусы --- */
.hud-powers {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 8px;
}
.power-chip {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px;
  border-radius: 999px; font-size: .82rem;
  background: rgba(10, 18, 32, .6); border: 1px solid var(--stroke);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fade .25s ease;
}
.power-chip .pi { font-style: normal; font-size: 1.1rem; }
.power-chip .pb { width: 40px; height: 4px; border-radius: 3px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.power-chip .pf { height: 100%; background: currentColor; }

/* --- всплывающие подписи элементов --- */
.element-pop {
  position: absolute; left: 50%; top: 26%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.pop {
  padding: 8px 18px; border-radius: 999px; font-weight: 650; white-space: nowrap;
  background: rgba(10, 18, 32, .68); border: 1px solid var(--stroke-2);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: popIn .32s cubic-bezier(.2, 1.4, .4, 1), popOut .4s ease 1.1s forwards;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .6);
}
.pop .goe { margin-left: 8px; font-variant-numeric: tabular-nums; }
.pop.good { border-color: rgba(92, 255, 200, .5); box-shadow: 0 0 24px rgba(92, 255, 200, .25); }
.pop.good .goe { color: var(--good); }
.pop.bad { border-color: rgba(255, 106, 128, .5); }
.pop.bad .goe { color: var(--bad); }
.pop.big { font-size: 1.2rem; padding: 12px 26px; }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.8); } to { opacity: 1; transform: none; } }
@keyframes popOut { to { opacity: 0; transform: translateY(-18px); } }

.hud-quest {
  position: absolute; right: 16px; bottom: calc(20px + var(--safe-b));
  font-size: .8rem; color: var(--muted); text-align: right; max-width: 40vw;
  background: rgba(10, 18, 32, .5); padding: 6px 12px; border-radius: 12px;
  border: 1px solid var(--stroke);
}
.hud-shield {
  position: absolute; right: 16px; top: calc(120px + var(--safe-t));
  display: flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  background: rgba(92, 255, 200, .14); border: 1px solid rgba(92, 255, 200, .4); font-size: .86rem;
}
.hud-shield i { font-style: normal; }

/* --- обучение --- */
.tutorial-card {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(90px + var(--safe-t)); width: min(400px, 88vw);
  padding: 14px 18px; border-radius: 16px; text-align: center;
  background: rgba(10, 18, 32, .7); border: 1px solid var(--stroke-2);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  animation: fade .3s ease;
}
.tut-title { font-weight: 650; margin-bottom: 4px; }
.tut-hint { font-size: .86rem; color: var(--muted); }
.tut-dots { display: flex; gap: 5px; justify-content: center; margin-top: 10px; }
.tut-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .22); }
.tut-dots i.on { background: var(--accent); }
.tut-dots i.done { background: var(--good); }

.pause-btn {
  position: absolute; right: 16px; top: calc(72px + var(--safe-t));
  width: 42px; height: 42px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: .8rem;
  background: rgba(10, 18, 32, .55);
}

/* --- сенсорное управление --- */
.touch { position: absolute; inset: 0; }
.touch-btn {
  position: absolute; border-radius: 50%; display: grid; place-items: center;
  background: rgba(20, 34, 56, .38); border: 1px solid var(--stroke);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 1.3rem; color: rgba(255, 255, 255, .8);
}
.touch-btn:active { background: rgba(60, 120, 200, .5); }
.touch-btn.tl { left: 18px; bottom: calc(96px + var(--safe-b)); width: 66px; height: 66px; }
.touch-btn.tr { left: 96px; bottom: calc(96px + var(--safe-b)); width: 66px; height: 66px; }
.touch-btn.tj { right: 18px; bottom: calc(120px + var(--safe-b)); width: 86px; height: 86px; font-size: 1.6rem; }
.touch-btn.td { right: 112px; bottom: calc(96px + var(--safe-b)); width: 66px; height: 66px; }
.touch-btn.ts {
  right: 30px; bottom: calc(224px + var(--safe-b)); width: 58px; height: 58px; font-size: 1.2rem;
  color: var(--gold); border-color: rgba(255, 212, 92, .3);
}
.touch-btn.ts.ready { background: rgba(255, 212, 92, .3); animation: flowPulse .9s ease-in-out infinite; }
body.lefty .touch-btn.tl { left: auto; right: 96px; }
body.lefty .touch-btn.tr { left: auto; right: 18px; }
body.lefty .touch-btn.tj { right: auto; left: 18px; }
body.lefty .touch-btn.td { right: auto; left: 112px; }
body.lefty .touch-btn.ts { right: auto; left: 30px; }

/* ============================================================
   УВЕДОМЛЕНИЯ
   ============================================================ */
#toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(16px + var(--safe-t)); z-index: 50;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 18px; border-radius: 999px; font-size: .9rem;
  background: rgba(10, 18, 32, .8); border: 1px solid var(--stroke-2);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  animation: toastIn .3s cubic-bezier(.2, 1.3, .4, 1), toastOut .4s ease 2.4s forwards;
}
.toast.good { border-color: rgba(92, 255, 200, .5); }
.toast.gold { border-color: rgba(255, 212, 92, .5); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-14px); } }

/* ============================================================
   АДАПТИВ
   ============================================================ */
@media (max-width: 860px) {
  .split { flex-direction: column; }
  .preview-pane { flex: 0 0 30vh; }
  .list-pane { border-left: none; border-top: 1px solid var(--stroke); }
  .result-head { flex-wrap: wrap; }
  .hero-best { width: 100%; }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  .logo { font-size: 2rem; }
  .stat-big { font-size: 1.9rem; }
  .topbar { padding: calc(10px + var(--safe-t)) 14px 10px; }
  .pad, .menu-body { padding-left: 14px; padding-right: 14px; }
  .menu-nav { grid-template-columns: repeat(3, 1fr); }
  .hud-top { padding: 0 12px; }
  .edge-badge { display: none; }
  .hud-quest { display: none; }
  .flow-wrap { width: 58vw; bottom: calc(200px + var(--safe-b)); }
  .hud-powers { top: auto; bottom: calc(240px + var(--safe-b)); transform: none; flex-direction: row; flex-wrap: wrap; right: 16px; }
  .power-chip .pn { display: none; }
  .list-pane.grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
  .grade { width: 56px; height: 56px; font-size: 1.8rem; }
  .result-total b { font-size: 1.5rem; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .flow-wrap { bottom: calc(10px + var(--safe-b)); width: 40vw; }
  .touch-btn.tj { width: 68px; height: 68px; bottom: calc(70px + var(--safe-b)); }
  .touch-btn.tl, .touch-btn.tr, .touch-btn.td { width: 54px; height: 54px; bottom: calc(60px + var(--safe-b)); }
  .touch-btn.ts { bottom: calc(146px + var(--safe-b)); width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
