/* Общая геометрия и оформление страницы */
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  padding: 24px 12px 60px;
  background: #0f1a2e;
  color: #e8eef5;
  font-family: 'Inter', sans-serif;
  text-align: center;
}

/*
  УмКвест — Учебная змейка
  Основано на JavaScript-Snake Пэтрика Гиллеспи (MIT License)
  https://github.com/patorjk/JavaScript-Snake
*/

/* Основные стили игрового поля */
#game-area {
  position: relative;
  display: inline-block;
}

.snake-board-container {
  position: relative;
  display: inline-block;
}

.snake-canvas {
  display: block;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* Игровое поле */
.snake-playing-field {
  background-color: #0d1b2a;
  border: 3px solid #1a2a3a;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

/* Змейка */
.snake-snakebody-block {
  background-color: #4a90d9;
  border: 1px solid #3a7bc8;
  border-radius: 2px;
  position: absolute;
}

.snake-snakebody-head {
  background-color: #3a7bc8;
  border: 2px solid #2a6bb8;
  border-radius: 4px;
  z-index: 10;
}

.snake-snakebody-alive .snake-snakebody-block {
  background-image: 
    linear-gradient(135deg, #5aa0e9 0%, #4a90d9 50%, #3a7bc8 100%),
    linear-gradient(135deg, #5aa0e9 0%, #4a90d9 50%, #3a7bc8 100%);
  background-size: 100% 100%;
}

.snake-snakebody-dead .snake-snakebody-block {
  background-color: #6a7a8a;
  border-color: #5a6a7a;
  opacity: 0.7;
}

/* Еда / Ответы */
.snake-food-block {
  position: absolute;
  border-radius: 50%;
  transition: transform 0.1s ease;
  z-index: 5;
}

.snake-food-block:hover {
  transform: scale(1.1);
}

.snake-food-block.option-a {
  background: linear-gradient(135deg, #4a90d9, #3a7bc8);
  box-shadow: 0 0 12px rgba(74, 144, 217, 0.6);
  border: 3px solid #5aa0e9;
}

.snake-food-block.option-b {
  background: linear-gradient(135deg, #6bc76b, #5ab85a);
  box-shadow: 0 0 12px rgba(107, 199, 107, 0.6);
  border: 3px solid #7bd87b;
}

.snake-food-block.option-c {
  background: linear-gradient(135deg, #f0c850, #e8b840);
  box-shadow: 0 0 12px rgba(240, 200, 80, 0.6);
  border: 3px solid #f5d060;
}

.snake-food-block.correct {
  animation: pulseCorrect 1s ease-in-out infinite;
}

@keyframes pulseCorrect {
  0%, 100% { box-shadow: 0 0 12px rgba(40, 167, 69, 0.6); border-color: #28a745; }
  50% { box-shadow: 0 0 24px rgba(40, 167, 69, 0.9); border-color: #34ce57; }
}

.snake-food-block.incorrect {
  animation: pulseIncorrect 0.5s ease-in-out 3;
}

@keyframes pulseIncorrect {
  0%, 100% { box-shadow: 0 0 12px rgba(220, 53, 69, 0.6); border-color: #dc3545; }
  50% { box-shadow: 0 0 24px rgba(220, 53, 69, 0.9); border-color: #e84555; }
}

/* Метки вариантов ответа */
.answer-label-on-field {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(15, 25, 40, 0.9);
  color: white;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  pointer-events: none;
  z-index: 6;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* UI панели */
.game-ui {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 10;
}

/* Индикатор паузы */
.pause-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 25, 40, 0.9);
  color: white;
  padding: 24px 40px;
  border-radius: 16px;
  font-size: 1.3rem;
  font-weight: 600;
  text-align: center;
  z-index: 100;
  display: none;
  font-family: 'Comfortaa', cursive;
}

.pause-indicator.visible {
  display: block;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

/* Диалоги (в стиле TUI) */
.snake-dos-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.snake-dos-alert {
  background: #1a1a2e;
  border: 3px double #4a90d9;
  border-radius: 8px;
  padding: 24px;
  max-width: 90vw;
  width: 100%;
  max-width: 480px;
  font-family: 'Inter', sans-serif;
  color: #e8eef5;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.snake-dos-alert-message {
  margin-bottom: 20px;
  line-height: 1.6;
  font-size: 1.1rem;
}

.snake-dos-alert .tui-button {
  width: 100%;
  padding: 12px;
  font-size: 1.1rem;
}

.tui-window {
  background: #1a1a2e;
  border: 2px solid #4a90d9;
  border-radius: 8px;
}

.tui-border-double {
  border-style: double;
}

.tui-button {
  background: linear-gradient(135deg, #4a90d9, #3a7bc8);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 6px;
  font-family: 'Comfortaa', cursive;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tui-button:hover {
  background: linear-gradient(135deg, #3a7bc8, #2a6bb8);
  transform: translateY(-1px);
}

/* Результаты */
.snake-try-again-dialog,
.snake-win-dialog {
  background: #0d1b2a;
  color: #e8eef5;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  padding: 24px;
  border-radius: 8px;
  border: 3px double #4a90d9;
  text-align: center;
}

.snake-win-dialog h2,
.snake-try-again-dialog h2 {
  font-family: 'Comfortaa', cursive;
  color: #4a90d9;
  margin-bottom: 16px;
}

.snake-panel-component {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: #e8eef5;
  margin: 8px 0;
}

.snake-panel-component strong {
  color: #4a90d9;
}

/* Скроллбар для списка ошибок */
.mistakes-list::-webkit-scrollbar {
  width: 8px;
}

.mistakes-list::-webkit-scrollbar-track {
  background: #e8eef5;
  border-radius: 4px;
}

.mistakes-list::-webkit-scrollbar-thumb {
  background: #b8c5d6;
  border-radius: 4px;
}

.mistakes-list::-webkit-scrollbar-thumb:hover {
  background: #a8b5c6;
}

/* Адаптивность */
@media (max-width: 600px) {
  .ui-panel {
    padding: 8px 12px;
    min-width: 100px;
  }
  
  .ui-score {
    font-size: 1rem;
  }
  
  .pause-indicator {
    padding: 16px 24px;
    font-size: 1.1rem;
  }
  
  .snake-dialog-controls {
    padding: 12px;
  }
  
  .snake-control-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .snake-control-row label {
    min-width: auto;
  }
  
  .snake-control-row select {
    flex: 1;
  }
}

/* Ландшафтная ориентация на телефонах */
@media (max-height: 500px) and (orientation: landscape) {
  .welcome-content {
    padding: 24px;
  }
  
  .welcome-title {
    font-size: 1.8rem;
  }
  
  .welcome-info {
    padding: 16px;
  }
  
  .question-card {
    padding: 24px;
  }
  
  .question-card h2 {
    font-size: 1.3rem;
  }
  
  .question-text {
    font-size: 1.1rem;
  }
  
  .answer-option {
    padding: 12px 16px;
    font-size: 1rem;
  }
  
  .start-btn {
    padding: 12px 24px;
    font-size: 1.1rem;
  }
}

.tui-button:active {
  transform: translateY(0);
}

.tui-input {
  background: #0f1a2e;
  color: #e8eef5;
  border: 2px solid #3a5a7a;
  padding: 8px 12px;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  width: 100%;
  box-sizing: border-box;
}

.tui-input:focus {
  outline: none;
  border-color: #4a90d9;
}

/* Экран приветствия в игре */
.snake-welcome-dialog {
  background: #0d1b2a;
  color: #e8eef5;
  font-family: 'Comfortaa', cursive;
  text-align: center;
  padding: 32px;
  border-radius: 8px;
  border: 3px double #4a90d9;
}

.snake-welcome-dialog h1 {
  font-size: 2rem;
  color: #4a90d9;
  margin-bottom: 8px;
  text-shadow: 0 4px 20px rgba(74, 144, 217, 0.3);
}

.snake-welcome-dialog p {
  color: #a8b8c8;
  margin-bottom: 24px;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}

/* Кнопки управления в диалоге */
.snake-dialog-controls {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid rgba(74, 144, 217, 0.2);
}

.snake-control-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.snake-control-row:last-child {
  margin-bottom: 0;
}

.snake-control-row label {
  color: #a8b8c8;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  min-width: 80px;
}

.snake-control-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

#go_full_screen {
  display: none;
}

@media (pointer: fine) {
  #go_full_screen {
    display: inline-block;
  }
}

.game-ui > * {
  pointer-events: auto;
}

.ui-panel {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 10px 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  font-family: 'Inter', sans-serif;
  min-width: 120px;
  text-align: center;
}

.ui-score {
  font-weight: 700;
  font-size: 1.1rem;
  color: #2d3a4a;
}

.ui-score span {
  color: #4a90d9;
}

.ui-question-num {
  font-weight: 600;
  color: #5a6a7a;
  font-size: 0.95rem;
}

.ui-speed {
  font-size: 0.85rem;
  color: #6a7a8a;
}

/* Оформление экранов и элементов управления */
body { touch-action: manipulation; }

    .umquest-gamepad {
      display: none;
      position: fixed;
      right: 12px;
      bottom: calc(12px + env(safe-area-inset-bottom, 0px));
      z-index: 10001;
      grid-template-columns: repeat(3, 56px);
      grid-template-rows: repeat(3, 56px);
      gap: 8px;
      user-select: none;
      -webkit-user-select: none;
    }

    .umquest-gamepad button {
      padding: 0;
      font-size: 24px;
      color: #2d3a4a;
      background: rgba(255, 255, 255, 0.9);
      border: 2px solid #b8c5d6;
      border-radius: 14px;
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
      box-shadow: 0 2px 8px rgba(0,0,0,0.1);
      transition: all 0.1s ease;
    }

    .umquest-gamepad button:active {
      background: rgba(200, 220, 240, 0.95);
      transform: scale(0.95);
    }

    .umquest-gamepad button.pause-btn {
      font-size: 20px;
      background: rgba(255, 200, 100, 0.9);
      border-color: #e8b050;
    }

    .umquest-gamepad button.pause-btn:active {
      background: rgba(255, 180, 80, 0.95);
    }

.question-overlay {
      position: fixed;
      top: 0; left: 0; right: 0; bottom: 0;
      background: rgba(15, 25, 40, 0.92);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      z-index: 1000;
      padding: 20px;
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .question-overlay.visible {
      opacity: 1;
      visibility: visible;
    }

    .question-card {
      background: white;
      border-radius: 20px;
      padding: 32px;
      max-width: 90vw;
      width: 100%;
      max-width: 520px;
      box-shadow: 0 20px 60px rgba(0,0,0,0.3);
      text-align: center;
      animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    @keyframes slideUp {
      from { opacity: 0; transform: translateY(30px) scale(0.95); }
      to { opacity: 1; transform: translateY(0) scale(1); }
    }

    .question-card h2 {
      margin: 0 0 20px;
      color: #2d3a4a;
      font-family: 'Comfortaa', cursive;
      font-size: 1.6rem;
      line-height: 1.3;
    }

    .question-text {
      font-size: 1.2rem;
      color: #3a4a5a;
      margin-bottom: 24px;
      line-height: 1.5;
      font-weight: 500;
    }

    .answer-options {
      display: flex;
      flex-direction: column;
      gap: 12px;
      margin-bottom: 24px;
    }

    .answer-option {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 16px 20px;
      background: #f5f8fc;
      border: 2px solid #dce4ee;
      border-radius: 14px;
      font-size: 1.1rem;
      color: #2d3a4a;
      cursor: pointer;
      transition: all 0.2s ease;
      text-align: left;
    }

    .answer-option:hover,
    .answer-option:focus {
      background: #e8f0fa;
      border-color: #4a90d9;
      transform: translateX(4px);
    }

    .answer-option.correct {
      background: #e8f8f0;
      border-color: #28a745;
      color: #1e7a2e;
    }

    .answer-option.incorrect {
      background: #fdeaea;
      border-color: #dc3545;
      color: #a02828;
    }

    .answer-label {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 36px;
      height: 36px;
      background: #4a90d9;
      color: white;
      border-radius: 10px;
      font-weight: 700;
      font-size: 1rem;
      flex-shrink: 0;
    }

    .answer-option.correct .answer-label { background: #28a745; }
    .answer-option.incorrect .answer-label { background: #dc3545; }
.results-screen {
      text-align: center;
      padding: 20px;
    }

    .results-screen h2 {
      font-family: 'Comfortaa', cursive;
      font-size: 2rem;
      color: #2d3a4a;
      margin-bottom: 8px;
    }

    .results-score {
      font-size: 3.5rem;
      font-weight: 700;
      color: #4a90d9;
      font-family: 'Comfortaa', cursive;
      margin: 16px 0;
    }

    .results-message {
      font-size: 1.2rem;
      color: #5a6a7a;
      margin-bottom: 24px;
      line-height: 1.5;
    }

    .mistakes-list {
      text-align: left;
      background: #f8f9fb;
      border-radius: 14px;
      padding: 20px;
      margin: 20px 0;
      max-height: 300px;
      overflow-y: auto;
    }

    .mistakes-list h3 {
      margin: 0 0 16px;
      color: #2d3a4a;
      font-size: 1.1rem;
    }

    .mistake-item {
      padding: 12px;
      background: white;
      border-radius: 10px;
      margin-bottom: 10px;
      border-left: 4px solid #dc3545;
    }

    .mistake-item:last-child { margin-bottom: 0; }

    .mistake-question { font-weight: 600; color: #2d3a4a; margin-bottom: 6px; }
    .mistake-your { color: #a02828; font-size: 0.95rem; }
    .mistake-correct { color: #1e7a2e; font-size: 0.95rem; }
    .mistake-explanation { color: #5a6a7a; font-size: 0.9rem; margin-top: 6px; font-style: italic; }

    .btn-group {
      display: flex;
      gap: 12px;
      justify-content: center;
      flex-wrap: wrap;
    }

    .topic-selector {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 16px;
      margin-top: 20px;
    }

    .topic-card {
      background: white;
      border: 2px solid #e8eef5;
      border-radius: 16px;
      padding: 24px;
      text-align: center;
      cursor: pointer;
      transition: all 0.2s ease;
    }

    .topic-card:hover {
      border-color: #4a90d9;
      transform: translateY(-4px);
      box-shadow: 0 8px 24px rgba(74, 144, 217, 0.15);
    }

    .topic-card.selected {
      border-color: #4a90d9;
      background: #f0f7ff;
    }

    .topic-icon { font-size: 2.5rem; margin-bottom: 12px; }
    .topic-title { font-family: 'Comfortaa', cursive; font-size: 1.2rem; font-weight: 700; color: #2d3a4a; margin-bottom: 6px; }
    .topic-desc { font-size: 0.95rem; color: #6a7a8a; }

    .import-section {
      margin-top: 24px;
      padding: 20px;
      background: #f8faff;
      border: 2px dashed #b8c5d6;
      border-radius: 14px;
      text-align: center;
    }

    .import-section h3 {
      margin: 0 0 12px;
      color: #2d3a4a;
      font-family: 'Comfortaa', cursive;
    }

    .import-section p { color: #6a7a8a; margin-bottom: 16px; font-size: 0.95rem; }

    .file-input-wrapper {
      position: relative;
      display: inline-block;
    }

    .file-input-wrapper input[type="file"] {
      position: absolute;
      opacity: 0;
      width: 100%; height: 100%;
      cursor: pointer;
    }
.snake-board-container {
      position: relative;
      display: inline-block;
    }

    .game-ui {
      position: absolute;
      top: 12px;
      left: 12px;
      right: 12px;
      display: flex;
      justify-content: space-between;
      pointer-events: none;
      z-index: 10;
    }

    .game-ui > * { pointer-events: auto; }

    .ui-panel {
      background: rgba(255,255,255,0.95);
      backdrop-filter: blur(8px);
      border-radius: 12px;
      padding: 10px 16px;
      box-shadow: 0 4px 16px rgba(0,0,0,0.1);
      font-family: 'Inter', sans-serif;
    }

    .ui-score { font-weight: 700; font-size: 1.1rem; color: #2d3a4a; }
    .ui-score span { color: #4a90d9; }
    .ui-question-num { font-weight: 600; color: #5a6a7a; font-size: 0.95rem; }
    .ui-speed { font-size: 0.85rem; color: #6a7a8a; }

    .pause-indicator {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background: rgba(15, 25, 40, 0.85);
      color: white;
      padding: 24px 40px;
      border-radius: 16px;
      font-size: 1.3rem;
      font-weight: 600;
      text-align: center;
      z-index: 100;
      display: none;
    }

    .pause-indicator.visible { display: block; animation: pulse 1.5s ease-in-out infinite; }
    @keyframes pulse { 0%,100% { opacity: 0.8; } 50% { opacity: 1; } }

    .snake-canvas { display: block; }

    .tui-window { background: #1a1a2e; border: 2px solid #4a90d9; border-radius: 8px; }
    .tui-border-double { border-style: double; }
    .tui-button {
      background: #4a90d9; color: white; border: none;
      padding: 10px 24px; border-radius: 6px;
      font-family: 'Comfortaa', cursive; font-weight: 600; cursor: pointer;
    }
    .tui-button:hover { background: #3a7bc8; }
    .tui-input {
      background: #0f1a2e; color: #e8eef5; border: 2px solid #3a5a7a;
      padding: 8px 12px; border-radius: 6px; font-family: 'Inter', sans-serif;
    }

    .welcome-screen {
      position: fixed;
      top: 0; left: 0; right: 0; bottom: 0;
      background: linear-gradient(135deg, #1a2a3a 0%, #0f1a2e 100%);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      z-index: 2000;
      padding: 20px;
      overflow-y: auto;
    }

    .welcome-content {
      background: rgba(255,255,255,0.05);
      border: 2px solid rgba(74,144,217,0.3);
      border-radius: 24px;
      padding: 40px;
      max-width: 560px;
      width: 100%;
      text-align: center;
      box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    }

.welcome-title {
      font-family: 'Comfortaa', cursive;
      font-size: 2.5rem;
      color: #4a90d9;
      margin-bottom: 8px;
      text-shadow: 0 4px 20px rgba(74,144,217,0.3);
    }

    .welcome-subtitle {
      color: #a8b8c8;
      font-size: 1.1rem;
      margin-bottom: 32px;
    }

    .welcome-info {
      background: rgba(255,255,255,0.03);
      border-radius: 14px;
      padding: 20px;
      margin-bottom: 24px;
      text-align: left;
    }

    .welcome-info h3 {
      color: #4a90d9;
      font-family: 'Comfortaa', cursive;
      margin: 0 0 12px;
      font-size: 1.1rem;
    }

    .welcome-info ul {
      margin: 0; padding-left: 20px;
      color: #c8d8e8;
      line-height: 1.8;
    }

    .welcome-info li { margin-bottom: 6px; }

    .controls-help {
      display: flex;
      gap: 16px;
      justify-content: center;
      flex-wrap: wrap;
      margin-top: 24px;
    }

    .control-key {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      background: rgba(74,144,217,0.2);
      border: 1px solid rgba(74,144,217,0.4);
      padding: 8px 16px;
      border-radius: 8px;
      color: #e8f0fa;
      font-size: 0.9rem;
    }

    .control-key kbd {
      background: rgba(255,255,255,0.1);
      padding: 2px 8px;
      border-radius: 4px;
      font-family: monospace;
      font-size: 0.85em;
    }

    @media (pointer: coarse) {
      .controls-help { display: none; }
    }

    .attribution {
      position: fixed;
      bottom: 10px;
      left: 50%;
      transform: translateX(-50%);
      font-size: 0.7rem;
      color: rgba(255,255,255,0.4);
      text-align: center;
      z-index: 100;
      max-width: 90vw;
    }

    .attribution a { color: rgba(74,144,217,0.8); text-decoration: none; }
    .attribution a:hover { text-decoration: underline; }

    .file-btn {
      display: inline-block;
      padding: 12px 24px;
      background: #fff;
      border: 2px solid #4a90d9;
      color: #4a90d9;
      border-radius: 10px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s;
    }

    .file-btn:hover { background: #f0f7ff; }

    .error-toast {
      position: fixed;
      bottom: 20px;
      left: 50%;
      transform: translateX(-50%) translateY(100px);
      background: #dc3545;
      color: white;
      padding: 14px 24px;
      border-radius: 10px;
      box-shadow: 0 8px 24px rgba(220, 53, 69, 0.3);
      z-index: 10000;
      opacity: 0;
      transition: all 0.3s ease;
      max-width: 90vw;
      text-align: center;
    }

    .error-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

    .speed-control {
      display: flex;
      align-items: center;
      gap: 12px;
      margin-top: 16px;
      padding: 16px;
      background: #f5f8fc;
      border-radius: 12px;
    }

    .speed-control label { font-weight: 600; color: #2d3a4a; }
    .speed-control input[type="range"] {
      flex: 1;
      accent-color: #4a90d9;
    }
    .speed-value { font-weight: 700; color: #4a90d9; min-width: 40px; }

    .btn {
      padding: 14px 28px;
      font-size: 1.1rem;
      font-weight: 600;
      border-radius: 12px;
      cursor: pointer;
      font-family: 'Comfortaa', cursive;
      border: none;
      transition: all 0.2s ease;
    }

    .btn-primary {
      background: linear-gradient(135deg, #4a90d9, #3a7bc8);
      color: white;
      box-shadow: 0 4px 16px rgba(74, 144, 217, 0.4);
    }

    .btn-primary:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 24px rgba(74, 144, 217, 0.5);
    }

    .btn-secondary {
      background: #f0f3f8;
      color: #4a5a6a;
      border: 2px solid #dce4ee;
    }

    .btn-secondary:hover {
      background: #e8eef5;
      border-color: #b8c5d6;
    }

    .start-btn {
      background: linear-gradient(135deg, #4a90d9, #3a7bc8);
      color: white;
      border: none;
      padding: 16px 32px;
      font-size: 1.2rem;
      font-weight: 700;
      border-radius: 14px;
      cursor: pointer;
      font-family: 'Comfortaa', cursive;
      transition: all 0.2s ease;
      box-shadow: 0 4px 16px rgba(74, 144, 217, 0.4);
    }

    .start-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 24px rgba(74, 144, 217, 0.5);
    }

    .start-btn:active { transform: translateY(0); }

    .explanation-box {
      background: #fff8e8;
      border: 2px solid #f0c850;
      border-radius: 12px;
      padding: 16px;
      margin-top: 16px;
      font-size: 1rem;
      color: #5a4a1e;
      line-height: 1.5;
      text-align: left;
      animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

    .progress-bar {
      height: 8px;
      background: #e8eef5;
      border-radius: 4px;
      overflow: hidden;
      margin-bottom: 16px;
    }

    .progress-fill {
      height: 100%;
      background: linear-gradient(90deg, #4a90d9, #6bc76b);
      border-radius: 4px;
      transition: width 0.4s ease;
      width: 0%;
    }

    .stats-row {
      display: flex;
      justify-content: space-between;
      margin-bottom: 16px;
      font-size: 1rem;
      color: #5a6a7a;
    }

    .stats-row span { font-weight: 600; color: #2d3a4a; }
    @media (pointer: coarse) {
      .umquest-gamepad { display: grid; }
    }

/* Длинные экраны остаются доступными при небольшой высоте окна. */
.welcome-screen { justify-content: flex-start; padding-bottom: 60px; }
.welcome-content { margin-block: auto; flex-shrink: 0; }
.question-overlay { overflow-y: auto; justify-content: flex-start; }
.question-card { margin-block: auto; flex-shrink: 0; }
.answer-option.selected { background: #e8f0fa; border-color: #4a90d9; }
.start-btn:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 600px) {
  .welcome-content { padding: 24px 16px; }
  .question-card { padding: 24px 16px; }
}

/* Exit a lesson without waiting for its final question. */
.game-toolbar {
  width: min(580px, 100%);
  margin: 0 auto 12px;
  text-align: left;
}
.game-toolbar[hidden] { display: none; }
.question-actions {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 16px;
}
.menu-button {
  padding: 10px 16px;
  border: 2px solid #b8c5d6;
  border-radius: 10px;
  background: #f0f3f8;
  color: #2d3a4a;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.menu-button:hover { background: #e8eef5; border-color: #4a90d9; }
.menu-button:focus-visible { outline: 3px solid #4a90d9; outline-offset: 3px; }
