:root {
  --glass: rgba(12, 16, 25, 0.74);
  --glass-strong: rgba(12, 16, 25, 0.9);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #E9EDF3;
  --muted: #9AA6B8;
  --faint: #66728A;
  --accent: #FFB020;
  --accent-hi: #FFC550;
  --accent-ink: #1E1405;
  --danger: #FF5A4E;
  --ok: #3DDC97;
  --tension: #FF7040;
  --compression: #3CA8FF;
  --mech: #FF50C8;
  --r: 14px;
  --r-sm: 10px;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.38);
  --font-display: 'Geologica', 'Onest', system-ui, sans-serif;
  --font-ui: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0B0F18; color: var(--text); }
body {
  font-family: var(--font-ui); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: crosshair; }
#stage.c-grab { cursor: grab; }
#stage.c-grabbing { cursor: grabbing; }
#stage.c-pointer { cursor: pointer; }
#stage.c-default { cursor: default; }
#stage.c-erase { cursor: cell; }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}
.muted { color: var(--muted); }
.kicker { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }

/* Иконки */
.ico { width: 20px; height: 20px; display: block; flex: none; }
.ico svg, [data-icon] svg { width: 100%; height: 100%; display: block; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid transparent; border-radius: 12px; padding: 11px 18px;
  font-weight: 600; cursor: pointer; transition: transform .15s, background .15s, border-color .15s, box-shadow .15s;
  background: rgba(255,255,255,0.06); color: var(--text);
}
.btn:hover { background: rgba(255,255,255,0.12); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible, .icon-btn:focus-visible, .tool:focus-visible, .play:focus-visible, .level-card-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px rgba(255,176,32,0.28); }
.btn-primary:hover { background: var(--accent-hi); }
.btn-glass { background: var(--glass); border-color: var(--line-strong); backdrop-filter: blur(10px); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.btn-danger { background: rgba(255,90,78,0.14); color: #FFB3AB; border-color: rgba(255,90,78,0.3); }
.btn-danger:hover { background: rgba(255,90,78,0.24); }
.btn-lg { padding: 15px 22px; font-size: 16px; justify-content: space-between; min-width: 280px; }
.btn-lg small { font-weight: 500; font-size: 13px; opacity: 0.72; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text);
  transition: background .15s, color .15s; position: relative; padding: 0;
}
.icon-btn > svg, .icon-btn > span > svg { width: 20px; height: 20px; }
.icon-btn:hover { background: rgba(255,255,255,0.1); }
.icon-btn.glass { width: 46px; height: 46px; }
.icon-btn.glass:hover { background: rgba(28,34,48,0.9); }
.icon-btn-sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn-sm > svg { width: 16px; height: 16px; }
.icon-btn.on { color: var(--accent); background: rgba(255,176,32,0.12); }
.icon-btn[disabled] { opacity: 0.35; cursor: not-allowed; }
.icon-btn.locked { opacity: 0.55; }

/* Подсказки */
[data-tip] { position: relative; }
@media (hover: hover) {
  [data-tip]:hover::after {
    content: attr(data-tip); position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    background: var(--glass-strong); color: var(--text); border: 1px solid var(--line-strong);
    padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 500; white-space: nowrap;
    pointer-events: none; z-index: 50; box-shadow: var(--shadow);
  }
  .dock [data-tip]:hover::after { top: auto; bottom: calc(100% + 10px); }
}

/* Экраны меню */
.screen { position: fixed; inset: 0; z-index: 10; }
#menu { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(20px, 6vw, 96px); pointer-events: none; }
#menu::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(8,11,18,0.88) 0%, rgba(8,11,18,0.62) 34%, rgba(8,11,18,0) 62%);
}
.menu-panel { position: relative; max-width: 560px; pointer-events: auto; animation: rise .7s cubic-bezier(.2,.8,.2,1) both; }
.brand { display: flex; align-items: center; gap: 18px; }
.brand-mark { width: 64px; height: 64px; flex: none; filter: drop-shadow(0 8px 20px rgba(255,176,32,0.25)); }
.brand h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(44px, 6.4vw, 78px); line-height: 0.95; margin: 0; letter-spacing: -0.02em; }
.tagline { margin: 8px 0 0; color: var(--accent); font-weight: 600; font-size: 15px; letter-spacing: 0.02em; }
.lead { font-size: 18px; line-height: 1.55; color: #D2D9E4; margin: 28px 0 30px; max-width: 30em; }
.menu-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.legend-inline { display: flex; align-items: center; gap: 10px; margin-top: 30px; flex-wrap: wrap; font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 11px; border-radius: 999px; font-weight: 600; font-size: 12px; }
.chip::before { content: ''; width: 18px; height: 5px; border-radius: 3px; background: currentColor; }
.chip-c { color: #7CC8FF; background: rgba(60,168,255,0.14); }
.chip-t { color: #FF9E7A; background: rgba(255,112,64,0.14); }
.menu-note { position: absolute; left: clamp(20px, 6vw, 96px); bottom: 20px; margin: 0; font-size: 12px; color: var(--faint); max-width: 640px; pointer-events: auto; }
.menu-note p { margin: 0; }
.menu-note .credit { margin-top: 4px; font-size: 11.5px; color: #7D889C; }
.menu-note a { color: #A9B4C6; text-decoration: underline; text-decoration-color: rgba(169,180,198,0.35); text-underline-offset: 2px; }
.menu-note a:hover { color: var(--text); }
.embed .menu-note .sites { display: none; }

/* Промокод: призыв, прогресс, итоги */
.promo-cta {
  display: flex; align-items: center; gap: 14px; width: 100%; max-width: 490px; margin-top: 18px; padding: 12px 14px 12px 12px;
  border-radius: 16px; border: 1px solid rgba(255,176,32,0.38); cursor: pointer; text-align: left; color: var(--text);
  background: linear-gradient(110deg, rgba(255,176,32,0.18), rgba(255,176,32,0.05) 60%, rgba(255,112,64,0.08));
  box-shadow: 0 10px 30px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.06);
  transition: transform .15s, border-color .15s, background .15s;
}
.promo-cta:hover { border-color: rgba(255,176,32,0.7); transform: translateY(-1px); }
.promo-cta:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pc-ic { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--accent); color: var(--accent-ink); padding: 10px; box-shadow: 0 6px 18px rgba(255,176,32,0.35); }
.pc-ic svg { stroke-width: 2; }
.pc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pc-title { font-family: var(--font-display); font-weight: 700; font-size: 15.5px; line-height: 1.25; }
.pc-sub { font-size: 12.5px; color: #D7CBB2; line-height: 1.35; }
.pc-bar:empty { display: none; }
.pc-bar { display: block; margin-top: 6px; }
.pc-go { width: 20px; height: 20px; flex: none; color: var(--accent); }
.promo-cta[data-kind="won"] { border-color: rgba(61,220,151,0.5); background: linear-gradient(110deg, rgba(61,220,151,0.18), rgba(61,220,151,0.05) 60%, rgba(255,176,32,0.08)); }
.promo-cta[data-kind="won"] .pc-ic { background: var(--ok); box-shadow: 0 6px 18px rgba(61,220,151,0.35); }
.promo-cta.promo-wide { max-width: none; margin: 0 0 22px; }

.pbar { position: relative; display: block; height: 6px; border-radius: 99px; background: rgba(255,255,255,0.1); overflow: visible; }
.pbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: linear-gradient(90deg, #FFB020, #FFC550); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.pbar b { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 2px; background: #E9EDF3; box-shadow: 0 0 0 2px rgba(11,15,24,0.8); }

.promo-note { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: 12px; font-size: 13px; color: #E8D9B8; background: rgba(255,176,32,0.07); border: 1px solid rgba(255,176,32,0.2); }
.promo-note svg { width: 20px; height: 20px; flex: none; color: var(--accent); }
.promo-note.won { color: #C9F5E0; background: rgba(61,220,151,0.08); border-color: rgba(61,220,151,0.3); }
.promo-note.won svg { color: var(--ok); }

.final-score { margin: 16px 0 4px; padding: 16px 18px; border-radius: 16px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); }
.final-score .fs-num { font-family: var(--font-mono); font-size: 38px; font-weight: 700; line-height: 1; margin-bottom: 12px; }
.final-score .fs-num small { font-size: 14px; color: var(--muted); font-weight: 500; }
.final-score .fs-cap { margin-top: 9px; font-size: 12.5px; color: var(--muted); }
.final-score.compact { padding: 12px 14px; }
.final-score .fs-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 10px; flex-wrap: wrap; }
.final-score .fs-row span { color: var(--muted); }

.promo-box { margin-top: 14px; padding: 18px; border-radius: 18px; text-align: center; border: 1px solid rgba(61,220,151,0.4);
  background: radial-gradient(420px 160px at 50% 0%, rgba(61,220,151,0.16), transparent 70%), rgba(61,220,151,0.05); }
.promo-box .promo-k { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ok); }
.promo-code { display: inline-flex; align-items: center; gap: 14px; margin: 10px 0 12px; padding: 10px 12px 10px 20px; border-radius: 14px; cursor: pointer;
  border: 2px dashed rgba(61,220,151,0.65); background: rgba(11,15,24,0.6); color: var(--text); transition: border-color .15s, background .15s; }
.promo-code:hover { border-color: var(--ok); background: rgba(11,15,24,0.85); }
.promo-code .pc-val { font-family: var(--font-mono); font-size: 30px; font-weight: 700; letter-spacing: 0.06em; }
.promo-code .pc-copy { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px; background: rgba(61,220,151,0.16); color: #BDF3DA; font-size: 13px; font-weight: 600; }
.promo-code .pc-copy svg { width: 16px; height: 16px; }
.promo-box p { max-width: 30em; margin: 0 auto 14px; font-size: 13.5px; }
.promo-box .btn { width: 100%; max-width: 340px; }
.promo-box.locked { border-color: rgba(255,176,32,0.35); background: rgba(255,176,32,0.05); text-align: left; }
.promo-box.locked .promo-k { color: var(--accent); }
.promo-need { display: block; font-family: var(--font-display); font-size: 20px; margin: 6px 0 6px; }
.promo-box.locked p { margin: 0 0 12px; max-width: none; }
.redo-list { display: flex; flex-wrap: wrap; gap: 6px; }
.redo-list .btn { width: auto; max-width: none; font-weight: 500; }
.redo-st { font-family: var(--font-mono); color: var(--accent); font-size: 12px; }

.offer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.offer { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 16px; text-decoration: none; color: var(--text);
  background: rgba(255,255,255,0.04); border: 1px solid var(--line-strong); transition: transform .15s, border-color .15s, background .15s; }
.offer:hover { transform: translateY(-2px); background: rgba(255,255,255,0.07); }
.offer-hd:hover { border-color: rgba(60,168,255,0.6); }
.offer-pz:hover { border-color: rgba(255,176,32,0.6); }
.offer-k { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.offer-hd .offer-k { color: #7CC8FF; }
.offer-pz .offer-k { color: var(--accent); }
.offer b { font-family: var(--font-display); font-size: 17px; line-height: 1.2; }
.offer-t { font-size: 13px; color: #C3CBD8; line-height: 1.45; flex: 1; }
.offer-go { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-weight: 600; font-size: 13.5px; }
.offer-hd .offer-go { color: #9CD6FF; }
.offer-pz .offer-go { color: var(--accent-hi); }
.offer-go svg { width: 16px; height: 16px; }
.finale h3 { margin-top: 22px; }

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

#levels { background: radial-gradient(1200px 600px at 70% -10%, rgba(255,176,32,0.08), transparent 60%), rgba(8,11,18,0.84); backdrop-filter: blur(6px); overflow-y: auto; }
.levels-inner { max-width: 1240px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 40px) 60px; }
.levels-head { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.levels-head h2 { font-family: var(--font-display); font-size: 32px; margin: 0; font-weight: 700; }
.levels-head p { margin: 2px 0 0; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }
.level-card-btn {
  text-align: left; padding: 0; border-radius: 16px; overflow: hidden; cursor: pointer;
  background: rgba(16,21,32,0.92); border: 1px solid var(--line); color: var(--text);
  transition: transform .2s, border-color .2s, box-shadow .2s; animation: rise .5s both;
}
.level-card-btn:hover { transform: translateY(-3px); border-color: rgba(255,176,32,0.5); box-shadow: 0 16px 40px rgba(0,0,0,0.45); }
.level-thumb { display: block; width: 100%; aspect-ratio: 16 / 9; background: #151B28; }
.level-meta { padding: 12px 14px 14px; display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; align-items: center; }
.level-num { grid-row: span 2; font-family: var(--font-mono); font-weight: 700; font-size: 22px; color: var(--accent); width: 34px; }
.level-title { font-family: var(--font-display); font-weight: 600; font-size: 17px; }
.level-topic { font-size: 13px; color: var(--muted); }
.level-stars { grid-row: span 2; display: flex; gap: 2px; }
.level-stars svg { width: 17px; height: 17px; }
.star-on { color: var(--accent); }
.star-off { color: rgba(255,255,255,0.16); }
.level-best { grid-column: 2 / 4; font-size: 12px; color: var(--muted); font-family: var(--font-mono); margin-top: 4px; }
.free-card .level-num { color: #7CC8FF; }

/* HUD */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#hud > * , .hud-top > *, .hud-bottom > * { pointer-events: auto; }
.hud-top { position: absolute; top: 12px; left: 12px; right: 12px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 12px; pointer-events: none !important; }
.hud-left { display: flex; gap: 10px; align-items: flex-start; pointer-events: none !important; }
.hud-left > * { pointer-events: auto; }
.level-card { padding: 9px 14px 10px; min-width: 190px; }
.lc-kicker { font-size: 11px; color: var(--accent); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.lc-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; line-height: 1.2; }
.lc-mass { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.lc-mass b { font-family: var(--font-mono); font-size: 14px; color: var(--text); font-weight: 600; }
.lc-ref { font-family: var(--font-mono); }
.hud-center { display: flex; justify-content: center; pointer-events: none !important; }
.hud-center > * { pointer-events: auto; }
.status { padding: 9px 16px; min-height: 42px; display: flex; align-items: center; gap: 10px; font-weight: 500; white-space: nowrap; max-width: 520px; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.status .ok { background: var(--ok); box-shadow: 0 0 10px rgba(61,220,151,0.6); }
.status .warn { background: var(--accent); box-shadow: 0 0 10px rgba(255,176,32,0.6); }
.status .bad { background: var(--danger); box-shadow: 0 0 10px rgba(255,90,78,0.6); }
.status .mech { background: var(--mech); box-shadow: 0 0 10px rgba(255,80,200,0.6); animation: blink 1s infinite; }
.status .run { background: var(--accent); animation: blink .6s infinite; }
.status .num { font-family: var(--font-mono); font-weight: 600; }
.status .prog { width: 120px; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.1); overflow: hidden; }
.status .prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #FFD27A); border-radius: 3px; }
.status .sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
@keyframes blink { 50% { opacity: 0.35; } }
.hud-right { justify-self: end; display: flex; align-items: center; gap: 2px; padding: 3px; }
.hud-right .sep { width: 1px; height: 22px; background: var(--line-strong); margin: 0 4px; }

.brief { position: absolute; top: 88px; left: 12px; width: 318px; padding: 12px 14px 14px; animation: rise .4s both; }
.brief-head { display: flex; justify-content: space-between; align-items: center; margin: -2px -6px 4px 0; }
.brief p { margin: 0; color: #D5DCE6; }
.brief .brief-hint { margin-top: 8px; color: var(--muted); font-size: 13px; padding-left: 10px; border-left: 2px solid rgba(255,176,32,0.5); }

.inspector { position: absolute; top: 76px; right: 12px; width: 300px; padding: 14px; animation: rise .25s both; max-height: calc(100vh - 220px); overflow-y: auto; }
.insp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.insp-title { font-family: var(--font-display); font-weight: 600; font-size: 16px; line-height: 1.25; }
.insp-sub { font-size: 12px; color: var(--muted); }
.insp-rows { display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; font-size: 13px; margin: 10px 0; }
.insp-rows dt { color: var(--muted); }
.insp-rows dd { margin: 0; font-family: var(--font-mono); font-weight: 500; text-align: right; }
.insp-sep { grid-column: 1 / -1; height: 1px; background: var(--line); margin: 4px 0; }
.stepper { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.05); border: 1px solid var(--line); border-radius: 11px; padding: 4px; }
.stepper .val { flex: 1; text-align: center; font-family: var(--font-mono); font-weight: 600; font-size: 14px; }
.stepper .val small { display: block; font-family: var(--font-ui); font-size: 11px; color: var(--muted); font-weight: 500; }
.seg { display: flex; background: rgba(255,255,255,0.05); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; margin-top: 8px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px 6px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted); }
.seg button.on { background: rgba(255,176,32,0.16); color: var(--accent); }
.seg button:hover:not(.on) { color: var(--text); background: rgba(255,255,255,0.06); }
.util { margin: 6px 0 2px; }
.util-top { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.util-top b { font-family: var(--font-mono); color: var(--text); font-weight: 600; }
.util-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.08); overflow: hidden; position: relative; }
.util-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.util-bar::after { content: ''; position: absolute; left: calc(100% / 1.2); top: -2px; bottom: -2px; width: 2px; background: rgba(255,255,255,0.5); }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag-t { background: rgba(255,112,64,0.16); color: #FFA383; }
.tag-c { background: rgba(60,168,255,0.16); color: #8ED0FF; }
.tag-0 { background: rgba(255,255,255,0.08); color: var(--muted); }
.tag-bad { background: rgba(255,90,78,0.18); color: #FFB0A8; }
.insp-note { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
.insp-actions { display: flex; gap: 8px; margin-top: 12px; }
.insp-actions .btn { flex: 1; }
.load-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.load-row .stepper { flex: 1; }

.legend { position: absolute; left: 12px; bottom: 86px; padding: 9px 12px; width: 300px; font-size: 11px; color: var(--muted); }
.legend-bar { height: 7px; border-radius: 4px; background: linear-gradient(90deg, #82ECFF 0%, #3CA8FF 22%, #9EAAB8 50%, #FF7040 78%, #FF3C2E 100%); }
.legend-labels { display: flex; justify-content: space-between; margin-top: 5px; font-family: var(--font-mono); }

.hud-bottom { position: absolute; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b)); display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 12px; pointer-events: none !important; }
.speed { justify-self: start; display: flex; align-items: center; gap: 10px; padding: 10px 14px; height: 62px; width: 300px; }
.speed label { font-size: 12px; color: var(--muted); font-weight: 500; }
.speed output { font-family: var(--font-mono); font-weight: 600; width: 40px; text-align: right; }
input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.12); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid #1A1206; cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid #1A1206; cursor: pointer; }

.dock { display: flex; gap: 3px; padding: 6px; }
.tool {
  width: 58px; height: 62px; border-radius: 11px; border: 1px solid transparent; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #C8D0DC;
  transition: background .15s, color .15s, transform .15s; position: relative; padding: 0;
}
.tool .ico { width: 24px; height: 24px; }
.tool .tl { font-size: 10.5px; font-weight: 500; letter-spacing: 0.01em; white-space: nowrap; }
.tool .key { position: absolute; top: 4px; right: 6px; font-size: 9px; font-family: var(--font-mono); color: var(--faint); }
.tool:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.tool.on { background: rgba(255,176,32,0.15); color: var(--accent); border-color: rgba(255,176,32,0.35); }
.tool.on .key { color: rgba(255,176,32,0.7); }
.dock-sep { width: 1px; background: var(--line-strong); margin: 8px 3px; }
.dock.dim .tool { opacity: 0.45; }

.play {
  justify-self: end; height: 62px; padding: 0 26px 0 20px; border-radius: 18px; border: 0; cursor: pointer;
  background: linear-gradient(180deg, #FFC24A, #F59E0B); color: var(--accent-ink);
  display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 17px; font-family: var(--font-display); white-space: nowrap;
  box-shadow: 0 10px 30px rgba(245,158,11,0.4), inset 0 1px 0 rgba(255,255,255,0.45);
  transition: transform .15s, box-shadow .15s, background .2s;
}
.play:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(245,158,11,0.5), inset 0 1px 0 rgba(255,255,255,0.45); }
.play:active { transform: translateY(0); }
.play .play-ico { width: 24px; height: 24px; }
.play.stop { background: linear-gradient(180deg, #3A4356, #262D3B); color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.12); }

.fps { position: absolute; left: 12px; top: 160px; font-family: var(--font-mono); font-size: 11px; color: #9EF5C5; background: rgba(0,0,0,0.5); padding: 3px 7px; border-radius: 6px; }

/* Тосты */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 20px); z-index: 60;
  background: var(--glass-strong); border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; font-weight: 500; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.err { border-color: rgba(255,90,78,0.45); }
.toast .btn { padding: 5px 10px; font-size: 13px; white-space: nowrap; flex: none; }

/* Модальные окна */
#modalRoot { position: fixed; inset: 0; z-index: 80; display: none; }
#modalRoot.open { display: grid; place-items: center; }
.modal-back { position: absolute; inset: 0; background: rgba(4,6,12,0.55); backdrop-filter: blur(3px); animation: fade .25s both; }
.modal {
  position: relative; width: min(560px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow-y: auto;
  background: rgba(14,18,28,0.95); border: 1px solid var(--line-strong); border-radius: 20px; padding: 26px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55); animation: pop .35s cubic-bezier(.2,.9,.25,1.1) both; user-select: text; -webkit-user-select: text;
}
.modal-wide { width: min(760px, calc(100vw - 28px)); }
.modal h2 { font-family: var(--font-display); font-weight: 700; font-size: 26px; margin: 0 0 6px; line-height: 1.15; }
.modal h3 { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin: 20px 0 8px; }
.modal p { margin: 0 0 10px; color: #CFD6E1; }
.modal .x { position: absolute; top: 14px; right: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.97); } }

.result-stars { display: flex; justify-content: center; gap: 10px; margin: 2px 0 14px; }
.result-stars svg { width: 54px; height: 54px; color: rgba(255,255,255,0.12); transition: color .3s; }
.result-stars .lit svg { color: var(--accent); }
.result-stars .lit { color: var(--accent); animation: starpop .5s cubic-bezier(.2,.9,.3,1.4) both; filter: drop-shadow(0 4px 14px rgba(255,176,32,0.5)); }
@keyframes starpop { from { transform: scale(0.2) rotate(-40deg); opacity: 0; } }
.result-head { text-align: center; }
.result-head .kicker { display: block; margin-bottom: 4px; }
.score { font-family: var(--font-mono); font-size: 40px; font-weight: 700; text-align: center; margin: 6px 0 2px; }
.score small { font-size: 14px; color: var(--muted); font-weight: 500; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin-top: 16px; padding: 14px 16px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--font-mono); text-align: right; font-weight: 500; }
.cause { margin-top: 14px; padding: 14px 16px; border-radius: 14px; background: rgba(255,90,78,0.08); border: 1px solid rgba(255,90,78,0.25); }
.cause b { display: block; font-family: var(--font-display); font-size: 16px; margin-bottom: 4px; color: #FFC2BB; }
.cause p { margin: 0; }
.cause .formula { font-family: var(--font-mono); font-size: 13px; color: #FFD9D4; margin-top: 8px; }
.tip { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: rgba(255,176,32,0.08); border: 1px solid rgba(255,176,32,0.22); color: #F3DDB2; font-size: 13.5px; }
.stars-rule { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 8px; }

.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; align-items: center; }
kbd { font-family: var(--font-mono); font-size: 11.5px; background: rgba(255,255,255,0.08); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; padding: 2px 6px; white-space: nowrap; color: var(--text); }
.formula-box { font-family: var(--font-mono); background: rgba(255,255,255,0.05); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 6px 0 10px; color: #E3E8F0; }
.modal ul { margin: 0 0 10px; padding-left: 18px; color: #CFD6E1; }
.modal li { margin: 3px 0; }

.set-list { display: grid; gap: 4px; margin-top: 10px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row .lbl b { display: block; font-weight: 600; }
.set-row .lbl span { font-size: 12.5px; color: var(--muted); }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 13px; background: rgba(255,255,255,0.14); transition: background .2s; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
select.sel {
  font: inherit; color: var(--text); background: rgba(255,255,255,0.06); border: 1px solid var(--line-strong);
  border-radius: 9px; padding: 7px 10px; cursor: pointer; min-width: 120px;
}
select.sel option { background: #141A27; }

/* Карточка испытания, скорость, меню «Ещё» */
.level-card { cursor: pointer; }
.level-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lc-no { display: none; }
.speed-btn, .brief-go { display: none; }
.hud-right .a-more, .hud-right .a-fs { display: none; }
.more-pop {
  position: absolute; z-index: 30; width: 270px; max-width: calc(100vw - 12px); max-height: calc(100% - 70px); overflow-y: auto;
  padding: 6px; display: flex; flex-direction: column; gap: 2px; background: var(--glass-strong); animation: rise .18s both;
  overscroll-behavior: contain;
}
.mp-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 7px 10px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text); text-align: left; cursor: pointer; font-size: 14px; font-weight: 500;
}
.mp-item:hover, .mp-item:focus-visible { background: rgba(255,255,255,0.08); outline: none; }
.mp-item:active { background: rgba(255,255,255,0.12); }
.mp-item .ico { width: 20px; height: 20px; color: #C8D0DC; }
.mp-item.on .ico { color: var(--accent); }
.mp-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.mp-txt small { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 1px; }
.mp-sw { position: relative; width: 34px; height: 20px; border-radius: 10px; background: rgba(255,255,255,0.14); flex: none; transition: background .2s; }
.mp-sw::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; }
.mp-item.on .mp-sw { background: var(--accent); }
.mp-item.on .mp-sw::after { transform: translateX(14px); }

/* Мобильные */
@media (max-width: 900px) {
  .brief { width: 280px; }
  .speed { width: auto; }
  .speed label { display: none; }
  .legend { width: 240px; }
}
@media (max-width: 720px) {
  #menu { justify-content: flex-start; padding: 24px 20px calc(14px + var(--safe-b)); }
  .menu-panel { margin-top: auto; }
  #menu::before { background: linear-gradient(0deg, rgba(8,11,18,0.97) 0%, rgba(8,11,18,0.93) 58%, rgba(8,11,18,0.62) 71%, rgba(8,11,18,0.12) 80%, rgba(8,11,18,0) 100%); }
  .brand-mark { width: 52px; height: 52px; }
  .lead { font-size: 15.5px; line-height: 1.5; margin: 14px 0 18px; }
  .btn-lg { min-width: 0; width: 100%; padding: 13px 20px; }
  .menu-actions { align-items: stretch; }
  #menu { overflow-y: auto; overscroll-behavior: contain; }
  .menu-note { position: relative; left: auto; right: auto; bottom: auto; margin-top: 16px; font-size: 10.5px; line-height: 1.4; }
  .menu-note .credit { font-size: 10.5px; }
  .legend-inline { display: none; }
  .promo-cta { max-width: none; margin-top: 14px; padding: 10px 12px 10px 10px; gap: 12px; }
  .pc-ic { width: 38px; height: 38px; padding: 9px; }
  .pc-title { font-size: 14.5px; }
  .pc-sub { font-size: 12px; }
  .promo-cta.promo-wide { margin-bottom: 14px; }
  .offer-grid { grid-template-columns: 1fr; }
  .promo-code .pc-val { font-size: 26px; }
  .final-score .fs-num { font-size: 32px; }
  .levels-inner { padding: 20px 12px 40px; }
  .levels-head { align-items: flex-start; margin-bottom: 16px; }
  .levels-head h2 { font-size: 26px; }
  .levels-head p { font-size: 13px; }
  .level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .level-card-btn { border-radius: 12px; }
  .level-meta { grid-template-columns: auto 1fr; padding: 8px 10px 10px; gap: 1px 7px; }
  .level-num { grid-row: auto; font-size: 14px; width: auto; }
  .level-title { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .level-topic { grid-column: 1 / -1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .level-stars { grid-row: auto; grid-column: 1 / -1; margin-top: 5px; order: 2; }
  .level-stars svg { width: 14px; height: 14px; }
  .level-best { grid-column: 1 / -1; font-size: 10.5px; margin-top: 3px; order: 3; }
  .help-grid { grid-template-columns: 1fr; }
  .modal { --mpx: 18px; --mpb: 22px; padding: 22px 18px; }
  .modal.result .modal-actions { gap: 8px; }
  .modal.result .modal-actions .btn { flex: 1 1 auto; padding-left: 12px; padding-right: 12px; font-size: 14px; white-space: nowrap; }
  .modal.result .modal-actions .btn-primary { flex-basis: 100%; }
  .modal h2 { font-size: 22px; }
  .result-stars svg { width: 44px; height: 44px; }
}

/* Телефон: общее для обоих положений — компактные панели, редкие действия в меню «Ещё» */
@media (max-width: 720px), (max-height: 520px) and (orientation: landscape) {
  .hud-top { display: flex; gap: 6px; align-items: stretch; }
  .hud-left { flex: 1 1 auto; min-width: 0; gap: 6px; align-items: stretch; }
  .hud-left .icon-btn.glass { flex: none; width: 40px; height: auto; border-radius: 12px; }
  .level-card { flex: 0 1 auto; min-width: 0; padding: 3px 12px 4px 11px; border-radius: 12px; display: flex; flex-direction: column; justify-content: center; }
  .lc-kicker, .lc-ml { display: none; }
  .lc-title { display: flex; align-items: baseline; gap: 7px; font-size: 14px; line-height: 1.2; min-width: 0; white-space: nowrap; }
  .lc-no { display: inline; flex: none; font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--accent); }
  .lc-no:empty { display: none; }
  .lc-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .lc-mass { margin-top: 1px; font-size: 11px; line-height: 1.2; gap: 5px; overflow: hidden; }
  .lc-mass b { font-size: 12px; }
  .hud-center { gap: 6px; align-items: stretch; min-width: 0; }
  .status { min-width: 0; max-width: none; min-height: 0; padding: 0 12px; gap: 8px; font-size: 12.5px; border-radius: 12px; }
  .status > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .status .dot, .status .num, .status .prog { flex: none; }
  .status .prog { width: 56px; }
  .status .sub { display: none; }
  .speed-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 48px; padding: 0 10px; border-radius: 12px; font-family: var(--font-mono); font-weight: 600; font-size: 13px; color: var(--text); cursor: pointer; }
  .speed-btn:active { background: rgba(28,34,48,0.95); }
  .hud-right { flex: none; gap: 0; padding: 3px; border-radius: 12px; align-items: center; }
  .hud-right .icon-btn { width: 36px; height: 34px; border-radius: 9px; }
  .hud-right .a-sec, .hud-right .sep { display: none; }
  .hud-right .a-more { display: grid; }
  .speed, .legend { display: none; }
  .dock { padding: 3px; gap: 1px; }
  .dock-sep, .tool .key { display: none; }
  .tool { gap: 3px; border-radius: 10px; }
  .tool .ico { width: 21px; height: 21px; }
  .tool .tl { font-size: 9.5px; letter-spacing: -0.01em; }
  .play { flex-direction: column; justify-content: center; gap: 3px; padding: 0; width: 64px; font-size: 11px; border-radius: 15px; }
  .play .play-ico { width: 22px; height: 22px; }
  .play:hover { transform: none; }
  .brief { padding: 10px 12px 12px; font-size: 13px; overflow-y: auto; overscroll-behavior: contain; }
  .brief .brief-hint { font-size: 12.5px; }
  .brief .brief-go { display: flex; justify-content: center; width: 100%; margin-top: 10px; padding: 9px 14px; font-size: 14px; background: rgba(255,176,32,0.14); color: var(--accent); border-color: rgba(255,176,32,0.38); }
  .brief .brief-go:active { background: rgba(255,176,32,0.24); }
  .inspector { padding: 10px 12px; overscroll-behavior: contain; }
  .insp-head { margin-bottom: 6px; }
  .insp-title { font-size: 15px; }
  .insp-rows { grid-template-columns: 1fr auto 1fr auto; gap: 3px 8px; font-size: 12px; margin: 8px 0; }
  .insp-rows dd { padding-right: 6px; }
  .insp-rows dt { line-height: 1.25; }
  /* кнопки итога испытания прилипают к низу окна — не нужно листать до «Следующего испытания» */
  .modal.result .modal-actions { position: sticky; bottom: calc(-1 * var(--mpb, 22px)); z-index: 2; margin: 14px calc(-1 * var(--mpx, 18px)) calc(-1 * var(--mpb, 22px)); padding: 12px var(--mpx, 18px) var(--mpb, 22px); background: linear-gradient(180deg, rgba(14,18,28,0) 0, rgb(14,18,28) 12px); }
}

/* Телефон вертикально: сверху строка испытания и строка состояния, снизу инструменты и «Испытать» */
@media (max-width: 720px) and (orientation: portrait), (max-width: 720px) and (min-height: 521px) {
  .hud-top { top: calc(8px + env(safe-area-inset-top, 0px)); left: 8px; right: 8px; flex-wrap: wrap; }
  .hud-left { order: 1; flex: 1 1 0; height: 42px; }
  .hud-right { order: 2; height: 42px; }
  .hud-center { order: 3; flex: 1 0 100%; height: 34px; justify-content: space-between; }
  .status { flex: 0 1 auto; }
  .hud-bottom { display: flex; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); gap: 6px; align-items: stretch; }
  .dock { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .dock::-webkit-scrollbar { display: none; }
  .dock.more-r { -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent); mask-image: linear-gradient(90deg, #000 82%, transparent); }
  .tool { flex: 1 0 41px; width: auto; height: 50px; }
  .play { flex: none; height: auto; width: 60px; }
  .brief { top: auto; bottom: calc(72px + var(--safe-b)); left: 8px; right: 8px; width: auto; max-height: 46vh; }
  .inspector { top: auto; bottom: calc(72px + var(--safe-b)); left: 8px; right: 8px; width: auto; max-height: 44vh; }
  .toast { bottom: calc(80px + var(--safe-b)); }
}

/* Телефон горизонтально: высоты мало — инструменты колонкой слева, «Испытать» справа внизу, схема на всю высоту */
@media (max-height: 520px) and (orientation: landscape) {
  #hud { --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px); }
  .hud-top { top: 6px; left: calc(6px + var(--sl)); right: calc(6px + var(--sr)); height: 40px; }
  .hud-left { flex: 0 0 auto; max-width: 40%; }
  .hud-left .icon-btn.glass { width: 42px; }
  .hud-center { flex: 1 1 auto; justify-content: center; }
  .status { flex: 0 1 auto; }
  .hud-right .a-fs { display: grid; }
  .hud-bottom { position: static; display: block; }
  .dock {
    position: absolute; left: calc(6px + var(--sl)); top: 52px; display: grid;
    grid-template-columns: repeat(var(--dock-cols, 2), 48px); grid-auto-rows: 44px; gap: 1px;
    max-height: calc(100% - 58px - var(--safe-b)); overflow-y: auto; scrollbar-width: none;
  }
  .dock::-webkit-scrollbar { display: none; }
  .tool { width: 48px; height: 44px; }
  .tool .ico { width: 20px; height: 20px; }
  .tool .tl { font-size: 9px; }
  .play { position: absolute; right: calc(6px + var(--sr)); bottom: calc(6px + var(--safe-b)); width: 70px; height: 62px; }
  /* задание — карточкой по центру поверх схемы; закрывается кнопкой или касанием схемы */
  .brief { inset: 0; margin: auto; height: fit-content; width: min(460px, calc(100vw - 40px)); max-height: calc(100% - 20px); padding: 10px 14px 12px; font-size: 13px; line-height: 1.4; box-shadow: 0 0 0 100vmax rgba(4,6,12,0.38), 0 20px 50px rgba(0,0,0,0.5); }
  .brief .brief-hint { font-size: 12.5px; margin-top: 6px; }
  .brief .brief-go { margin-top: 8px; padding: 7px 14px; }
  .inspector { top: 52px; right: calc(84px + var(--sr)); width: min(300px, 44vw); max-height: calc(100% - 58px - var(--safe-b)); }
  .insp-rows { grid-template-columns: 1fr auto; gap: 2px 10px; }
  .insp-rows dd { padding-right: 0; white-space: nowrap; }
  .more-pop { max-height: calc(100% - 56px); width: min(470px, calc(100vw - 120px)); display: grid; grid-template-columns: 1fr 1fr; align-content: start; }
  .mp-item { min-height: 40px; padding: 5px 10px; gap: 10px; font-size: 13.5px; }
  .mp-txt small { font-size: 11px; }
  .toast { top: 54px; bottom: auto; transform: translate(-50%, -12px); max-width: calc(100vw - 180px); }
  .toast.show { transform: translate(-50%, 0); }

  /* меню и список испытаний на низком экране */
  #menu { justify-content: flex-start; padding: 12px calc(22px + env(safe-area-inset-left, 0px)) 12px; overflow-y: auto; overscroll-behavior: contain; }
  #menu::before { background: linear-gradient(90deg, rgba(8,11,18,0.95) 0%, rgba(8,11,18,0.86) 42%, rgba(8,11,18,0.35) 58%, rgba(8,11,18,0) 70%); }
  .menu-panel { max-width: min(440px, 54vw); margin-top: auto; }
  .brand { gap: 12px; }
  .brand-mark { width: 40px; height: 40px; }
  .brand h1 { font-size: 34px; }
  .tagline { margin-top: 4px; font-size: 12.5px; }
  .lead { font-size: 13.5px; line-height: 1.45; margin: 10px 0 12px; }
  .menu-actions { flex-direction: row; flex-wrap: wrap; align-items: stretch; gap: 8px; }
  .btn-lg { min-width: 0; width: auto; flex: 0 0 auto; padding: 10px 16px; font-size: 14.5px; gap: 10px; white-space: nowrap; }
  .btn-lg small { font-size: 11.5px; }
  .btn-glass.btn-lg small { display: none; }
  .menu-actions .btn-ghost { flex: 0 0 auto; padding: 4px 8px; font-size: 13px; white-space: nowrap; }
  .promo-cta { max-width: none; margin-top: 8px; padding: 8px 10px 8px 8px; gap: 10px; border-radius: 14px; }
  .pc-ic { width: 32px; height: 32px; padding: 7px; border-radius: 10px; }
  .pc-title { font-size: 13.5px; }
  .pc-sub { font-size: 11.5px; }
  .legend-inline { display: none; }
  .menu-note { position: relative; left: auto; right: auto; bottom: auto; max-width: min(620px, calc(100vw - 44px)); margin: 10px 0 auto; font-size: 10px; line-height: 1.4; }
  .menu-note .credit { font-size: 10px; }
  .levels-inner { padding: 12px calc(16px + env(safe-area-inset-left, 0px)) 24px; }
  .levels-head { margin-bottom: 10px; gap: 12px; align-items: center; }
  .levels-head h2 { font-size: 22px; }
  .levels-head p { font-size: 12.5px; }
  .promo-cta.promo-wide { margin-bottom: 12px; }
  .level-grid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 10px; }
  .level-thumb { aspect-ratio: 2 / 1; object-fit: cover; }
  .level-card-btn { border-radius: 12px; }
  .level-meta { grid-template-columns: auto 1fr auto; padding: 7px 10px 9px; gap: 1px 7px; }
  .level-num { grid-row: auto; font-size: 13px; width: auto; }
  .level-title { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .level-stars svg { width: 13px; height: 13px; }
  .level-stars { grid-row: auto; }
  .level-topic { grid-column: 1 / -1; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .level-best { grid-column: 1 / -1; font-size: 10.5px; margin-top: 2px; }

  /* окна: меньше отступы, чтобы итог испытания помещался по высоте */
  .modal { --mpx: 20px; --mpb: 14px; padding: 16px 20px 14px; max-height: calc(100vh - 16px); border-radius: 16px; width: min(600px, calc(100vw - 24px)); }
  .modal.result:has(.result-stars) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); column-gap: 18px; align-items: center; }
  .modal.result:has(.result-stars) > * { grid-column: 1 / -1; }
  .modal.result:has(.result-stars) > .result-stars, .modal.result:has(.result-stars) > .result-head, .modal.result:has(.result-stars) > .score { grid-column: 1; }
  .modal.result:has(.result-stars) > .kv { grid-column: 2; grid-row: 1 / span 3; margin: 0 28px 0 0; }
  .modal.result .result-head p { margin-bottom: 0; font-size: 13px; }
  .stars-rule { font-size: 11.5px; margin: 8px 0 0; }
  .promo-note { margin-top: 8px; padding: 8px 10px; font-size: 12.5px; }
  .modal-wide { width: min(720px, calc(100vw - 24px)); }
  .modal h2 { font-size: 20px; }
  .modal h3 { font-size: 15px; margin: 12px 0 6px; }
  .modal .x { top: 10px; right: 10px; }
  .modal-actions { margin-top: 14px; }
  .result-stars { margin: 0 0 6px; gap: 8px; }
  .result-stars svg { width: 34px; height: 34px; }
  .score { font-size: 28px; margin: 2px 0 0; }
  .kv { margin-top: 10px; padding: 10px 12px; gap: 4px 14px; font-size: 13px; }
  .cause { margin-top: 10px; padding: 10px 12px; }
  .tip { margin-top: 10px; padding: 10px 12px; font-size: 13px; }
  .offer-grid { grid-template-columns: 1fr 1fr; }
}
/* совсем низкий экран (телефон горизонтально с панелями браузера): описание прячем, чтобы обложка помещалась целиком */
@media (max-height: 340px) and (orientation: landscape) {
  .lead { display: none; }
  .tagline { margin-bottom: 12px; }
  .brand h1 { font-size: 30px; }
  .btn-lg { padding: 9px 14px; }
  .btn-primary.btn-lg small { display: none; }
  .menu-actions .btn-ghost { padding: 4px 6px; }
  .promo-cta { margin-top: 10px; }
  .menu-note { margin-top: 8px; }
}
@media (min-height: 521px) and (max-height: 560px) and (min-width: 721px) {
  .brief { display: none; }
}
@media (max-height: 780px) and (min-width: 721px) and (min-height: 521px) {
  #menu { padding-top: 28px; padding-bottom: 64px; }
  .brand-mark { width: 56px; height: 56px; }
  .brand h1 { font-size: clamp(40px, 5.4vw, 64px); }
  .lead { font-size: 16.5px; margin: 18px 0 20px; }
  .legend-inline { display: none; }
  .promo-cta { margin-top: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
