/* Preserve native hidden state even for components with display:flex/grid. */
[hidden] { display: none !important; }

/* ==========================================================================
   SMART RUBIK — design tokens
   Акценты — это НЕ произвольный бренд-цвет, а реальные цвета граней
   кубика (см. python/constants.py FACE_COLORS). Тёмный графит, а не
   чистый чёрный: у кубика и так шесть насыщенных цветов, фон должен
   им не мешать, а не спорить ещё одним ярким пятном.
   ========================================================================== */

:root {
  --bg: #0B0F1A;
  --bg-stage: #0D1424;
  --bg-elevated: #131A2C;
  --bg-elevated-2: #182140;
  --border: #232C46;
  --border-soft: #1A2238;

  --text: #E9ECF6;
  --text-muted: #8B93AC;
  --text-faint: #5B6382;

  /* Ровно те же hex, что в python/constants.py FACE_COLORS — чтобы кнопки
     ходов и панели визуально совпадали с самим кубиком. */
  --face-u: #F5F7FA;
  --face-d: #FFD500;
  --face-f: #12B76A;
  --face-b: #2E6BFF;
  --face-r: #EF4444;
  --face-l: #FF8A1F;

  --accent: var(--face-b);
  --accent-hover: #4C82FF;
  --success: var(--face-f);
  --danger: var(--face-r);

  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* -------------------------------------------------------------------- */
/* Boot screen — маленький, но фирменный: мини-кубик "собирается" пока   */
/* грузится Pyodide. Не generic spinner.                                */
/* -------------------------------------------------------------------- */

#boot-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

#boot-cube {
  position: relative;
  width: 64px;
  height: 64px;
  transform-style: preserve-3d;
  transform: rotateX(-28deg) rotateY(35deg);
  animation: boot-spin 2.6s linear infinite;
}

@keyframes boot-spin {
  to { transform: rotateX(-28deg) rotateY(395deg); }
}

.boot-face {
  position: absolute;
  width: 64px;
  height: 64px;
  border: 2px solid rgba(11, 15, 26, 0.55);
  border-radius: 4px;
}
.boot-face.f-u { background: var(--face-u); transform: rotateX(90deg) translateZ(32px); }
.boot-face.f-d { background: var(--face-d); transform: rotateX(-90deg) translateZ(32px); }
.boot-face.f-f { background: var(--face-f); transform: translateZ(32px); }
.boot-face.f-b { background: var(--face-b); transform: rotateY(180deg) translateZ(32px); }
.boot-face.f-r { background: var(--face-r); transform: rotateY(90deg) translateZ(32px); }
.boot-face.f-l { background: var(--face-l); transform: rotateY(-90deg) translateZ(32px); }

#boot-label {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* -------------------------------------------------------------------- */
/* Layout                                                                */
/* -------------------------------------------------------------------- */

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px 26px 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.brand-tag {
  margin-left: 12px;
  font-size: 13px;
  color: var(--text-faint);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sound-toggle {
  font-size: 17px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  width: 38px;
  height: 38px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.12s ease;
}
.sound-toggle:hover { background: var(--bg-elevated-2); }
.sound-toggle.muted { opacity: 0.45; }

.profile-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
.profile-name { font-weight: 600; color: var(--text); }
.profile-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-faint);
}
.profile-level { color: var(--accent); font-family: var(--font-mono); font-size: 12px; }
.profile-coins { color: var(--face-d); font-family: var(--font-mono); font-size: 12px; }

.achievement-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translate(-50%, -20px);
  background: var(--bg-elevated-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-m);
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 20;
}
.achievement-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.achievement-toast b { color: var(--face-d); }

.size-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 3px;
}

.size-chip {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 7px 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.size-chip:hover { color: var(--text); }
.size-chip.active { background: var(--accent); color: #05070D; }

/* -------------------------------------------------------------------- */
/* Tabs — Игра / Академия. Тот же язык, что и переключатель размера,     */
/* но крупнее и на всю ширину — это разделы приложения, а не параметр.   */
/* -------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 6px;
  padding: 0 26px 14px;
}

.tab {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 4px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.stage-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  padding: 0 26px 20px;
  min-height: 0;
}

/* -------------------------------------------------------------------- */
/* Cube stage — сам кубик "парит" в открытом пространстве, без рамки    */
/* карточки: это главный герой страницы, а не ещё одна плитка сетки.    */
/* -------------------------------------------------------------------- */

.cube-stage {
  position: relative;
  border-radius: var(--radius-l);
  background:
    radial-gradient(ellipse 60% 55% at 50% 45%, rgba(46, 107, 255, 0.14), transparent 70%),
    var(--bg-stage);
  overflow: hidden;
  min-height: 0;
}

#cube-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#cube-canvas:active { cursor: grabbing; }

.stage-hint {
  position: absolute;
  left: 20px;
  bottom: 18px;
  font-size: 12px;
  color: var(--text-faint);
  pointer-events: none;
}

.solved-banner {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translate(-50%, -14px);
  background: var(--success);
  color: #052015;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.solved-banner.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* -------------------------------------------------------------------- */
/* Rail — не однородная сетка карточек: у таймера, ленты ходов и        */
/* кнопок разное визуальное устройство, потому что это разные вещи.     */
/* -------------------------------------------------------------------- */

.rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.timer-block {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-l);
  padding: 20px 22px;
}

.timer-readout {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.timer-meta {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.dot-sep { margin: 0 8px; opacity: 0.4; }

.progress-block { padding: 0 2px; }

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-elevated-2);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--face-f), var(--accent));
  transition: width 0.3s ease;
}
.progress-label {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-faint);
}

.history-strip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 12px 14px;
}
.history-eyebrow {
  display: block;
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.history-moves {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
  line-height: 1.6;
}

/* Кнопки ходов подсвечены цветом СВОЕЙ грани — не декоративно, а
   функционально: помогает выучить связку буква <-> цвет. */
.moves-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.move-btn {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-top: 2px solid var(--face-color, var(--border-soft));
  border-radius: 7px;
  padding: 9px 0;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.12s ease;
}
.move-btn:hover { background: var(--bg-elevated-2); }
.move-btn:active { transform: translateY(1px) scale(0.96); }
.move-btn:disabled { opacity: 0.35; cursor: default; }

.actions-row {
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 11px 0;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--bg-elevated-2); }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #05070D;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

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

.scramble-len {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 0 10px;
}

.scramble-readout {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.6;
  min-height: 1.6em;
}

.foothint {
  padding: 10px 26px 16px;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
}

/* -------------------------------------------------------------------- */
/* Responsive: под 900px кубик и панель управления идут друг под другом  */
/* -------------------------------------------------------------------- */

@media (max-width: 900px) {
  .stage-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 46vh 1fr;
  }
  .brand-tag { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #boot-cube { animation: none; }
  .move-btn, .btn, .progress-fill, .solved-banner { transition: none; }
}

/* -------------------------------------------------------------------- */
/* Академия — список уроков и экран практики.                            */
/* -------------------------------------------------------------------- */

.academy-progress-block {
  padding: 0 2px 4px;
}

.academy-lesson-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: calc(100vh - 340px);
  overflow-y: auto;
}

.academy-chapter-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.02em;
  margin: 12px 2px 2px;
}
.academy-chapter-label:first-child { margin-top: 2px; }

.academy-lesson-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.academy-lesson-row:hover { background: var(--bg-elevated-2); }
.academy-lesson-row.locked {
  cursor: default;
  opacity: 0.45;
}
.academy-lesson-row.locked:hover { background: var(--bg-elevated); }

.academy-lesson-marker {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  background: var(--bg-elevated-2);
  color: var(--text-muted);
}
.academy-lesson-row.completed .academy-lesson-marker {
  background: var(--success);
  color: #052015;
}

.academy-lesson-text { flex: 1; min-width: 0; }
.academy-lesson-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.academy-lesson-chapter {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 1px;
}

.academy-lesson-xp {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--face-d);
}

.academy-practice {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.academy-back {
  align-self: flex-start;
  padding: 6px 12px;
}

.academy-lesson-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
}

.academy-lesson-goal {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.academy-goal-block { display: flex; flex-direction: column; gap: 6px; }
.academy-goal-label {
  font-size: 12px;
  color: var(--text-faint);
}

.academy-feedback {
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 12px 14px;
  min-height: 1.4em;
  line-height: 1.5;
}
.academy-feedback.error { border-color: var(--danger); color: #ffb3b3; }
.academy-feedback.success { border-color: var(--success); color: var(--success); }

#academy-complete-btn {
  background: var(--success);
  border-color: var(--success);
  color: #052015;
}
#academy-complete-btn:hover { background: #16d67a; }

/* -------------------------------------------------------------------- */
/* Магазин — темы кубика и звуковые наборы.                              */
/* -------------------------------------------------------------------- */

.shop-coins-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 2px 10px;
}
.shop-coins-label {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--face-d);
}
.shop-coins-hint {
  font-size: 11.5px;
  color: var(--text-faint);
}

.shop-section-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.02em;
  margin: 14px 2px 6px;
}
.shop-section-label:first-of-type { margin-top: 2px; }

.shop-item-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shop-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 10px 12px;
}

.shop-item-swatch {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  overflow: hidden;
  border: 1px solid var(--border-soft);
}
.shop-item-swatch span { display: block; }

.shop-item-info { flex: 1; min-width: 0; }
.shop-item-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.shop-item-price {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.shop-item-btn {
  flex: 0 0 auto;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-s);
  border: 1px solid var(--border-soft);
  background: var(--bg-elevated-2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease;
}
.shop-item-btn:hover { background: var(--accent); color: #05070D; border-color: var(--accent); }
.shop-item-btn.equipped {
  background: var(--success);
  color: #052015;
  border-color: var(--success);
  cursor: default;
}
.shop-item-btn.equipped:hover { background: var(--success); }
.shop-item-btn:disabled { opacity: 0.5; cursor: default; }

/* -------------------------------------------------------------------- */
/* Кубик дня и разбор сборки.                                            */
/* -------------------------------------------------------------------- */

.daily-card {
  background: linear-gradient(135deg, var(--bg-elevated-2), var(--bg-elevated));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-l);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.daily-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.daily-card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
}
.daily-card-streak {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--face-d);
}
.daily-card-status {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}
.daily-card.completed .daily-card-status { color: var(--success); }
.daily-card.at-risk .daily-card-status { color: var(--face-r); }
#btn-daily:disabled { opacity: 0.5; }

.breakdown-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 12px 14px;
}
.breakdown-eyebrow {
  display: block;
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.breakdown-stages {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}
.breakdown-stage-line { white-space: nowrap; }
.breakdown-stage-range {
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: 11.5px;
}

/* -------------------------------------------------------------------- */
/* Запуск алгоритма текстом.                                             */
/* -------------------------------------------------------------------- */

.algorithm-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.algorithm-eyebrow {
  font-size: 12px;
  color: var(--text-faint);
}
.algorithm-input {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-s);
  padding: 9px 10px;
  outline: none;
}
.algorithm-input:focus { border-color: var(--accent); }
.algorithm-actions { display: flex; gap: 6px; }
.algorithm-actions .btn { font-size: 12.5px; padding: 8px 0; }
.algorithm-error {
  font-size: 12px;
  color: var(--face-r);
  min-height: 1.2em;
}

/* -------------------------------------------------------------------- */
/* Курсы — полноразмерная страница чтения, а не узкая боковая панель:   */
/* тексту нужен воздух, это была реальная проблема в десктоп-версии.    */
/* -------------------------------------------------------------------- */

.courses-page {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  padding: 0 26px 20px;
  min-height: 0;
}

.courses-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.courses-progress-block { padding: 0 2px; }

.courses-nav-module {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.02em;
  margin: 10px 2px 2px;
}
.courses-nav-module:first-child { margin-top: 2px; }

.courses-nav-row {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 9px 11px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.courses-nav-row:hover { background: var(--bg-elevated-2); }
.courses-nav-row.active { border-color: var(--accent); background: var(--bg-elevated-2); }
.courses-nav-row.completed .courses-nav-marker { background: var(--success); color: #052015; }

.courses-nav-marker {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-family: var(--font-mono);
  font-weight: 600;
  background: var(--bg-elevated-2);
  color: var(--text-muted);
}
.courses-nav-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.courses-reader {
  overflow-y: auto;
  padding-right: 4px;
}

.courses-reader-empty {
  color: var(--text-faint);
  font-size: 14px;
  margin-top: 40px;
  text-align: center;
}

.courses-reader-module {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.courses-reader-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  margin: 4px 0 2px;
  line-height: 1.2;
}

.courses-reader-subtitle {
  color: var(--text-muted);
  font-size: 14.5px;
  margin: 0 0 12px;
}

.courses-reader-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
}
.courses-reader-meta span {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
}
.course-completed-badge { background: var(--success) !important; color: #052015 !important; }

.course-box {
  border-radius: var(--radius-m);
  padding: 13px 15px;
  margin-bottom: 14px;
}
.course-box p { margin: 6px 0 0; font-size: 14px; line-height: 1.6; color: var(--text); }
.course-box-label {
  font-size: 11.5px;
  color: var(--text-faint);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.course-box-intro { background: #102542; }
.course-box-key { background: var(--bg-elevated-2); border: 1px solid var(--border-soft); }
.course-box-key ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; line-height: 1.7; }
.course-box-remember { background: #2B2112; }
.course-box-remember p { color: #FFF1D6; font-weight: 600; }
.course-box-practice { background: #0E2A25; }

.courses-section-heading {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin: 4px 0 10px;
}

.course-theory-step {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.course-theory-step-num {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #05070D;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.course-theory-step p { margin: 0; font-size: 14.5px; line-height: 1.65; color: var(--text); }

.course-demo {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 12px 15px;
  margin-bottom: 14px;
}
.course-demo-moves {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--accent);
  margin-top: 6px;
  letter-spacing: 0.02em;
}

.course-quiz-block {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.course-quiz-question {
  font-size: 15px;
  font-weight: 600;
  margin: 6px 0 10px;
}
.course-quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.course-quiz-option:hover { background: var(--bg-elevated); }
.course-quiz-option.correct { border-color: var(--success); background: rgba(18, 183, 106, 0.15); }
.course-quiz-option.incorrect { border-color: var(--danger); background: rgba(239, 68, 68, 0.12); }
.course-quiz-option:disabled { cursor: default; }
.course-quiz-feedback { font-size: 13px; margin: 8px 0 0; line-height: 1.5; }
.course-quiz-feedback.correct { color: var(--success); }
.course-quiz-feedback.incorrect { color: var(--danger); }

.course-actions {
  display: flex;
  gap: 8px;
  margin: 4px 0 40px;
}

@media (max-width: 900px) {
  .courses-page { grid-template-columns: 1fr; }
  .courses-nav { max-height: 220px; }
}

/* -------------------------------------------------------------------- */
/* Профиль — статистика, лучшие результаты, достижения.                  */
/* -------------------------------------------------------------------- */

.profile-page {
  flex: 1;
  overflow-y: auto;
  padding: 0 26px 30px;
}
.profile-page-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.profile-header-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-l);
  padding: 18px 20px;
}
.profile-avatar {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #05070D;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-header-text { flex: 1; }
.profile-header-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
}
.profile-header-rank {
  font-size: 12.5px;
  color: var(--accent);
  margin-top: 2px;
}

.profile-xp-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-l);
  padding: 16px 20px;
}
.profile-xp-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.profile-xp-top span:first-child { color: var(--text); font-weight: 600; }

.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.profile-stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 12px 14px;
}
.profile-stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.profile-stat-label {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 2px;
}

.profile-section-heading {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  margin: 6px 0 2px;
}

.profile-empty-hint {
  color: var(--text-faint);
  font-size: 13px;
  margin: 0;
}

.profile-best-times {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.profile-best-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 10px 14px;
  font-size: 13.5px;
}
.profile-best-row .size-label { font-weight: 600; }
.profile-best-row .time-label { font-family: var(--font-mono); color: var(--accent); }
.profile-best-row .moves-label { font-family: var(--font-mono); color: var(--text-faint); font-size: 12px; }

.profile-achievements {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.profile-achievement-chip {
  background: linear-gradient(135deg, var(--bg-elevated-2), var(--bg-elevated));
  border: 1px solid var(--face-d);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--face-d);
  font-weight: 600;
}

/* -------------------------------------------------------------------- */
/* Исследование — панель для школьного/учебного сравнения групп.        */
/* -------------------------------------------------------------------- */

.research-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.research-hint {
  font-size: 11.5px;
  color: var(--text-faint);
  margin: -4px 0 2px;
  line-height: 1.4;
}
.research-status {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

/* On phones, keep controls and lessons in the normal document flow. */
@media (max-width: 900px) {
  #app { height: auto; min-height: 100dvh; }
  .topbar { padding: 16px; align-items: center; }
  .topbar-right { width: 100%; flex-wrap: wrap; }
  .profile-chip { white-space: nowrap; }
  .size-switch { flex-basis: 100%; max-width: none; }
  .size-chip { flex: 1 0 44px; padding: 8px; }
  .tabs { padding: 0 16px 12px; overflow-x: auto; flex-shrink: 0; }
  .tab { white-space: nowrap; }
  .stage-layout { flex: none; padding: 0 16px 20px; grid-template-rows: min(90vw, 420px) auto; }
  .rail { overflow: visible; }
  .courses-page { flex: none; padding: 0 16px 20px; }
  .courses-reader { overflow: visible; }
  .course-actions { flex-wrap: wrap; }
  .foothint { padding: 12px 16px; }
}
