:root {
  --bg-deep: #0a0c10;
  --bg-panel: #111822;
  --bg-elevated: #161f2e;
  --border: #2a3444;
  --text: #e8ecf1;
  --text-muted: #94a3b8;
  --accent: #2ec4b6;
  --accent-dim: #249e92;
  --primary: #5b7cfa;
  --warning: #f59e0b;
  --danger: #f87171;
  --grid-floor: #1a2434;
  --grid-wall: #2a3548;
  --shadow: rgba(0, 0, 0, 0.5);
  --radius: 12px;
  --font-sans: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  min-height: calc(100vh - 8rem);
  display: flex;
  flex-direction: column;
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem 0 1rem;
  border-bottom: 1px solid rgba(42, 52, 68, 0.75);
}

.brand {
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

.brand__logo {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.45rem;
  color: var(--accent);
  background: linear-gradient(145deg, rgba(91, 124, 250, 0.15), rgba(46, 196, 182, 0.08));
  border: 1px solid rgba(91, 124, 250, 0.35);
  border-radius: 12px;
  padding: 0.4rem 0.6rem;
  box-shadow: 0 8px 28px var(--shadow), 0 0 24px rgba(91, 124, 250, 0.12);
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand__sub {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.topbar__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* Учебная полоса: модуль, концепция CS, навыки */
.learning-strip {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  margin: 0 0 1rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid rgba(91, 124, 250, 0.22);
  background: linear-gradient(135deg, rgba(17, 24, 38, 0.85) 0%, rgba(12, 16, 24, 0.92) 100%);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.learning-strip__dim {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: rgba(46, 196, 182, 0.1);
  border: 1px solid rgba(46, 196, 182, 0.35);
}

.learning-strip__body {
  min-width: 0;
  flex: 1;
}

.learning-strip__module {
  margin: 0 0 0.2rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
}

.learning-strip__concept {
  margin: 0 0 0.55rem;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.35;
}

.learning-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.skill-chip {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(42, 52, 68, 0.95);
  background: rgba(8, 10, 16, 0.65);
  color: var(--text-muted);
}

.canvas-frame--edu {
  position: relative;
}

.canvas-frame--edu::after {
  content: "Обучение · 2D";
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.75);
  pointer-events: none;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) minmax(320px, 420px);
  gap: 1rem;
  padding: 1rem 0;
  align-items: start;
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: linear-gradient(165deg, rgba(17, 24, 38, 0.95) 0%, rgba(12, 16, 24, 0.98) 100%);
  border: 1px solid rgba(42, 52, 68, 0.9);
  border-radius: var(--radius);
  padding: 1.1rem 1.1rem 1.2rem;
  box-shadow: 0 16px 40px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.panel h2 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.panel__hint {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.panel__hint code {
  font-size: 0.78em;
  color: var(--accent);
  background: rgba(61, 214, 198, 0.08);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}

.level-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 52vh;
  overflow: auto;
}

.level-btn {
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.level-btn:hover {
  border-color: var(--primary);
  background: #1c2738;
}

.level-btn--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(61, 214, 198, 0.35);
}

.level-btn--done {
  opacity: 0.92;
}

.level-btn--done::after {
  content: " ✓";
  color: var(--accent);
  font-weight: 700;
}

.level-num {
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-right: 0.35rem;
}

.progress-wrap {
  margin-top: 0.85rem;
  height: 6px;
  background: #0a0e14;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: inherit;
  transition: width 0.35s ease;
}

.stage-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

.stage-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.stage-desc {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.story-strip {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(108, 140, 255, 0.08) 0%, rgba(61, 214, 198, 0.08) 100%);
  border-left: 3px solid var(--primary);
}

.story-strip--enter {
  animation: story-in 0.55s ease-out both;
}

@keyframes story-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.story-mascot {
  position: relative;
  flex-shrink: 0;
  width: 56px;
  height: 72px;
  animation: mascot-float 2.8s ease-in-out infinite;
}

@keyframes mascot-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.mascot__ring {
  position: absolute;
  left: 50%;
  top: 0;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  border-radius: 50%;
  border: 3px solid rgba(108, 140, 255, 0.85);
  box-shadow: 0 0 0 4px rgba(108, 140, 255, 0.2), 0 0 24px rgba(108, 140, 255, 0.35);
  animation: ring-pulse 2s ease-in-out infinite;
}

@keyframes ring-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.04);
    opacity: 0.92;
  }
}

.mascot__head {
  position: absolute;
  left: 50%;
  top: 10px;
  width: 38px;
  height: 32px;
  margin-left: -19px;
  border-radius: 12px;
  background: linear-gradient(180deg, #7b98ff 0%, var(--primary) 100%);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.15);
}

.mascot__face {
  position: absolute;
  left: 50%;
  top: 20px;
  width: 32px;
  margin-left: -16px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.mascot__eye {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0a0f18;
  animation: blink 4s step-end infinite;
}

@keyframes blink {
  0%,
  96%,
  100% {
    transform: scaleY(1);
  }
  98% {
    transform: scaleY(0.15);
  }
}

.mascot__body {
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 36px;
  height: 22px;
  margin-left: -18px;
  border-radius: 10px;
  background: linear-gradient(180deg, #1e2a40 0%, #121a28 100%);
  border: 1px solid var(--border);
}

.story-copy {
  min-width: 0;
}

.story-chapter {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.story-body {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.45;
}

.canvas-frame {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(42, 52, 68, 0.95);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  background: #05070a;
  line-height: 0;
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: auto;
}

.canvas-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(4px);
  transition: opacity 0.25s ease, visibility 0.25s;
}

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

.objectives {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card--victory {
  padding: 1.5rem 1.75rem;
  text-align: center;
  max-width: 360px;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(61, 214, 198, 0.25), 0 24px 64px var(--shadow);
}

.card--victory h3 {
  margin: 0 0 0.5rem;
  color: var(--accent);
}

.card--victory p {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.snippet-toolbar {
  margin-bottom: 0.5rem;
}

.snippet-toolbar__label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0d121a;
  color: var(--accent);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.chip:hover {
  border-color: var(--primary);
  background: #121a26;
}

.code-editor {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #080c12;
  color: var(--text);
  resize: vertical;
  min-height: 220px;
  caret-color: var(--accent);
}

.code-editor:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.2);
}

.exec-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.speed-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.65rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.speed-row input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
}

.btn {
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: linear-gradient(180deg, #7b98ff 0%, var(--primary) 100%);
  color: #0a0f18;
  border-color: #5a75e6;
  box-shadow: 0 6px 20px rgba(108, 140, 255, 0.35);
}

.btn--primary:hover {
  filter: brightness(1.05);
}

.btn--accent {
  background: linear-gradient(180deg, #4ce8d8 0%, var(--accent-dim) 100%);
  color: #051016;
  border-color: var(--accent-dim);
  box-shadow: 0 6px 20px rgba(61, 214, 198, 0.28);
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn--ghost:hover {
  border-color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
}

.btn--small {
  font-size: 0.78rem;
  padding: 0.35rem 0.55rem;
}

.btn__icon {
  margin-right: 0.25rem;
}

.card--mentor {
  margin-top: 0.85rem;
  padding: 0.75rem 0.85rem;
  border-left: 3px solid var(--primary);
}

.mentor__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
}

.mentor__btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.mentor__badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
}

.mentor-ai-log {
  margin: 0 0 0.55rem;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px dashed rgba(108, 140, 255, 0.35);
  min-height: 0;
  max-height: 200px;
  overflow: auto;
}

.mentor-step {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 0.35rem;
  padding-left: 0.15rem;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.mentor-step:last-child {
  margin-bottom: 0;
}

.mentor-step--visible {
  opacity: 1;
  transform: translateX(0);
}

.mentor__text {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.console {
  margin-top: 0.85rem;
  overflow: hidden;
}

.console__head {
  padding: 0.45rem 0.65rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: #0a0f16;
}

.console__body {
  margin: 0;
  padding: 0.55rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--accent);
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.console__body--err {
  color: var(--danger);
}

.footer {
  padding: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 560px;
  width: calc(100% - 2rem);
  background: var(--bg-panel);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.modal::backdrop {
  background: rgba(5, 8, 12, 0.78);
  backdrop-filter: blur(3px);
}

.modal__inner {
  position: relative;
  padding: 1.25rem 1.35rem 1.35rem;
}

.modal__close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.modal__close:hover {
  background: #1f2a3d;
}

.modal h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.cmd-list {
  margin: 0 0 1rem;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.cmd-list code {
  color: var(--accent);
  font-size: 0.9em;
}

.example-block {
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  background: #080c12;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
}

.modal__note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card--hints {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.hints-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.hints-panel__title {
  margin: 0;
  font-size: 0.92rem;
}

.hints-panel__body {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
  min-height: 2.75rem;
}

.card--parallel {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.parallel-block__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.parallel-tab {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-muted);
  cursor: pointer;
}

.parallel-tab:hover {
  color: var(--text);
  border-color: rgba(46, 196, 182, 0.45);
}

.parallel-tab--active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(46, 196, 182, 0.08);
}

.parallel-block__code {
  margin: 0;
  max-height: 11rem;
  overflow: auto;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  background: #080c12;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
  white-space: pre-wrap;
}

