:root {
  color-scheme: dark;
  --text: #f7fbff;
  --muted: #9aa8c9;
  --line: rgba(255,255,255,.12);
  --accent: #93ecff;
  --accent2: #d5b9ff;
  --bgx-far: 0px;
  --bgy-far: 0px;
  --bgx-mid: 0px;
  --bgy-mid: 0px;
  --bgx-near: 0px;
  --bgy-near: 0px;
  --bg-tilt: 0deg;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #01020a 0%, #030816 55%, #020512 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
}

button, input { font: inherit; }

.space-backdrop,
#glCanvas,
.modal {
  position: fixed;
  inset: 0;
}

.space-backdrop {
  pointer-events: none;
  overflow: hidden;
  background: radial-gradient(1400px 800px at 50% 50%, rgba(255,255,255,.03), transparent 72%);
}

.space-video-wrap,
.space-dust,
.space-glow,
.vignette {
  position: absolute;
  inset: -8%;
}

.space-video-wrap {
  overflow: hidden;
  opacity: .88;
  will-change: transform;
  transform: translate3d(var(--bgx-mid), var(--bgy-mid), 0) scale(1.12);
  filter: brightness(.74) contrast(1.18) saturate(1.06);
}

.space-video {
  position: absolute;
  inset: 50% auto auto 50%;
  width: max(112vw, calc(100vh * 1.7778));
  height: auto;
  min-width: 100%;
  min-height: 100%;
  transform: translate(-50%, -50%);
  object-fit: cover;
}

.space-dust {
  inset: -10%;
  background:
    radial-gradient(1200px 250px at 56% 48%, rgba(255,255,255,.05), transparent 72%),
    radial-gradient(1400px 320px at 54% 50%, rgba(116, 150, 255, .08), transparent 76%),
    radial-gradient(1600px 360px at 52% 49%, rgba(242, 216, 255, .05), transparent 79%);
  transform: rotate(-18deg) translate3d(calc(var(--bgx-mid) * .45), calc(var(--bgy-mid) * .45), 0) scale(1.1);
  filter: blur(18px);
  opacity: .32;
}

.space-glow {
  inset: -6%;
  background:
    radial-gradient(900px 600px at 18% 26%, rgba(64, 94, 220, .10), transparent 72%),
    radial-gradient(980px 620px at 72% 18%, rgba(160, 68, 220, .09), transparent 72%),
    radial-gradient(1300px 240px at 56% 49%, rgba(228, 238, 255, .05), transparent 78%);
  transform: translate3d(calc(var(--bgx-far) * .4), calc(var(--bgy-far) * .4), 0) scale(1.05);
  filter: blur(26px);
  opacity: .55;
}

.vignette {
  inset: -2%;
  background:
    radial-gradient(circle at center, transparent 48%, rgba(0,0,0,.24) 76%, rgba(0,0,0,.56) 100%),
    linear-gradient(180deg, rgba(1,3,12,.04), rgba(1,3,12,.24));
}

#glCanvas {
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#glCanvas.dragging { cursor: grabbing; }

.game-topbar {
  position: fixed;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 18px 24px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(1, 3, 12, .72), transparent);
}

.game-topbar a,
.game-topbar .game-progress {
  pointer-events: auto;
}

.back-link,
.game-progress {
  color: rgba(235, 248, 255, .84);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .08em;
  text-decoration: none;
  text-transform: uppercase;
}

.back-link:hover { color: #fff; }
.back-link span { color: var(--accent); font-size: 18px; margin-right: 5px; }

.game-brand {
  display: grid;
  gap: 3px;
  text-align: center;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .75);
}

.game-brand strong {
  color: #fff;
  font-size: 15px;
  letter-spacing: .02em;
}

.game-brand span {
  color: rgba(196, 219, 255, .72);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.game-progress {
  display: grid;
  justify-self: end;
  gap: 3px;
  min-width: 178px;
  text-align: right;
  line-height: 1.1;
}
.game-progress > div:first-child span:first-child { color: #fff2a4; font-size: 16px; }

/* В текущем маршруте учитываются только игры и тесты. */
.site-metrics span:nth-child(2),
.site-metrics span:nth-child(4) { display: none; }
.progress-points { color: #d8c7ff; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.progress-points span { color: #ffeaa4; font-size: 14px; }
.site-metrics { display: flex; justify-content: flex-end; gap: 8px; color: rgba(196, 219, 255, .65); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.site-metrics b { color: #c8f4ff; font-size: 11px; }

.intro {
  position: fixed;
  z-index: 7;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 45%, rgba(8, 26, 74, .08), rgba(1, 3, 12, .32));
  transition: opacity .45s ease, visibility .45s ease;
}

.intro.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-card {
  width: min(560px, 100%);
  padding: clamp(28px, 5vw, 48px);
  border-radius: 30px;
  text-align: center;
}

.intro-kicker {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.intro h1 {
  margin: 0 0 16px;
  font-size: clamp(36px, 7vw, 64px);
  line-height: .98;
  letter-spacing: -.06em;
  text-shadow: 0 0 32px rgba(147, 236, 255, .22);
}

.intro p {
  margin: 0 auto 12px;
  max-width: 460px;
  color: #e2ecff;
  line-height: 1.6;
}

.intro .intro-note { color: var(--muted); font-size: 14px; }
.intro .primary-btn { margin-top: 14px; min-width: 180px; }

.glass {
  background: linear-gradient(180deg, rgba(14, 22, 42, .82), rgba(8, 13, 27, .68));
  border: 1px solid rgba(255,255,255,.11);
  box-shadow:
    0 28px 80px rgba(0,0,0,.48),
    inset 0 1px 0 rgba(255,255,255,.06),
    0 0 0 1px rgba(147,236,255,.04);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
}

.modal {
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(1, 3, 9, .52);
  z-index: 8;
}

.modal.hidden { display: none; }

.modal-card {
  position: relative;
  width: min(620px, 100%);
  border-radius: 30px;
  padding: 30px;
  animation: modalIn .26s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.icon-btn {
  position: absolute;
  right: 14px;
  top: 12px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: var(--text);
  background: rgba(255,255,255,.06);
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.10); }

.task-status {
  min-height: 14px;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .18em;
}

.modal h2 {
  margin: 0 44px 12px 0;
  font-size: clamp(28px, 4vw, 36px);
  line-height: 1.02;
  letter-spacing: -.04em;
}

.modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.task-question {
  margin-top: 22px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.1);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.03));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.task-question strong { display: block; margin-bottom: 12px; color: var(--text); }
.site-task-state { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.site-task-state.is-ready { color: #b9ffdf; }
.site-task-state.is-warning { color: #ffc0d0; }
.requirement-meter {
  display: inline-flex;
  margin: 2px 0 0;
  padding: 7px 10px;
  border: 1px solid rgba(147,236,255,.16);
  border-radius: 999px;
  color: #bfe9ff;
  background: rgba(69, 117, 180, .14);
  font-size: 11px;
  font-weight: 750;
}
.star-reward {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  color: #fff0a5;
  font-size: 13px;
  font-weight: 800;
}
.star-reward span { color: #fff5bc; font-size: 20px; text-shadow: 0 0 14px rgba(255, 226, 113, .9); }
.achievement-task {
  position: relative;
  overflow: hidden;
  border-color: rgba(255, 232, 141, .2);
  background:
    radial-gradient(circle at 92% 12%, rgba(255, 231, 133, .13), transparent 30%),
    linear-gradient(145deg, rgba(105, 91, 181, .14), rgba(255,255,255,.035));
}
.achievement-task::after {
  content: '✦';
  position: absolute;
  top: 11px;
  right: 18px;
  color: rgba(255, 241, 166, .68);
  font-size: 28px;
  text-shadow: 0 0 18px rgba(255, 224, 112, .8);
}
.achievement-kicker {
  display: block;
  margin-bottom: 11px;
  color: #fff0a5;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .16em;
}
.achievement-source {
  display: inline-flex;
  margin-top: 13px;
  padding: 6px 9px;
  border: 1px solid rgba(147,236,255,.18);
  border-radius: 999px;
  color: rgba(200, 225, 255, .72);
  font-size: 11px;
}
.achievement-done {
  border-color: rgba(151, 255, 210, .24);
  background: linear-gradient(145deg, rgba(45, 134, 126, .2), rgba(255,255,255,.035));
}
.site-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}
.site-link:hover { color: #fff; text-decoration: underline; text-underline-offset: 4px; }
.final-link { margin-top: 16px; color: #fff0a3; }
.answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.answer {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  padding: 13px 14px;
  background: rgba(255,255,255,.04);
  color: var(--text);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.answer:hover,
.answer.selected {
  transform: translateY(-1px);
  border-color: rgba(147,236,255,.45);
  background: rgba(147,236,255,.11);
  box-shadow: 0 0 24px rgba(147,236,255,.10), inset 0 0 0 1px rgba(147,236,255,.08);
}
.feedback { margin-top: 12px; color: #ffb9cf; font-size: 13px; line-height: 1.45; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 24px; }
.primary-btn {
  border: 0; border-radius: 15px; padding: 13px 22px; cursor: pointer; font-weight: 800; color: #061019;
  background: linear-gradient(135deg, #9ce9ff, #d6b7ff);
  box-shadow: 0 16px 34px rgba(147,236,255,.16), inset 0 1px 0 rgba(255,255,255,.45);
}
.primary-btn:disabled { opacity: .35; cursor: not-allowed; }

@media (max-width: 720px) {
  .game-topbar { grid-template-columns: auto 1fr auto; gap: 8px; padding: 12px 14px; }
  .game-brand strong { font-size: 12px; }
  .game-brand span { display: none; }
  .back-link, .game-progress { font-size: 9px; letter-spacing: .04em; }
  .game-progress { min-width: 132px; gap: 2px; }
  .game-progress > div:first-child span:first-child { font-size: 14px; }
  .progress-points span { font-size: 12px; }
  .site-metrics { gap: 4px; font-size: 8px; }
  .space-video { width: max(142vw, calc(100vh * 1.7778)); }
  .space-video-wrap { transform: translate3d(var(--bgx-mid), var(--bgy-mid), 0) scale(1.14); }
  .modal-card { border-radius: 24px; padding: 24px 20px; }
  .answers { grid-template-columns: 1fr; }
}
.csp-webgl-error {
    padding: 40px;
    color: white;
}
