/* Подключение анимаций */
@import url('animations.css');

body {
  font-family: 'Comic Sans MS', cursive, sans-serif;
  background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
  color: white;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.container {
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  max-width: 600px;
}

h1 {
  font-size: 3em;
  margin-bottom: 20px;
  text-shadow: 3px 3px 0 #000;
}

p {
  font-size: 1.2em;
  margin-bottom: 30px;
}

.start-btn {
  background: #ffcc00;
  color: #000;
  border: none;
  padding: 10px 20px;
  font-size: 0.95em;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  font-weight: bold;
  margin: 4px;
  min-width: 130px;
  display: inline-block;
}

.start-btn:hover {
  transform: scale(1.05);
  background: #ffdd33;
}

.start-btn:active {
  transform: scale(0.98);
}

.lessons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin: 30px 0;
}

.lesson-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid white;
  padding: 12px;
  font-size: 0.95em;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
}

.premium-btn {
  background: linear-gradient(45deg, #ff416c, #ff4b2b) !important;
  animation: pulse 2s infinite;
}

.premium-btn:hover {
  transform: scale(1.05) !important;
  background: linear-gradient(45deg, #ff4b2b, #ff416c) !important;
}

.lesson-btn:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  transform: none !important;
}

/* Цвета для уровней */
.lesson-btn.completed {
  background: linear-gradient(45deg, #4CAF50, #8BC34A) !important;
  color: white !important;
}

.lesson-btn.current {
  background: linear-gradient(45deg, #FFEB3B, #FFC107) !important;
  color: black !important;
  animation: pulse 2s infinite;
}

.lesson-btn.available {
  background: linear-gradient(45deg, #F44336, #FF9800) !important;
  color: white !important;
}

.lesson-btn.locked {
  background: linear-gradient(45deg, #9E9E9E, #607D8B) !important;
  color: white !important;
  opacity: 0.7 !important;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 235, 59, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(255, 235, 59, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 235, 59, 0); }
}

.lesson-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-3px);
}

.lesson-container {
  background: rgba(0, 0, 0, 0.3);
  padding: 25px;
  border-radius: 15px;
  margin-top: 20px;
  text-align: left;
  line-height: 1.6;
}

.lesson-container h2 {
  margin-top: 0;
  border-bottom: 2px solid #ffcc00;
  padding-bottom: 10px;
  color: #ffcc00;
}

.lesson-container h3 {
  color: #ffdd33;
  margin-top: 20px;
  margin-bottom: 10px;
}

.lesson-container p {
  margin-bottom: 15px;
}

.lesson-container ul,
.lesson-container ol {
  padding-left: 25px;
  margin-bottom: 15px;
}

.lesson-container li {
  margin-bottom: 8px;
}

.lesson-container strong {
  color: #ffcc00;
  font-weight: bold;
}

.lesson-container input {
  width: 100%;
  padding: 10px;
  margin: 10px 0;
  border-radius: 5px;
  border: none;
  font-size: 1em;
}

/* Стили для сообщения бота */
.bot-message {
  background: linear-gradient(45deg, #00b09b, #96c93d);
  color: white;
  padding: 15px;
  border-radius: 10px;
  margin-top: 20px;
  animation: fadeIn 0.5s ease;
}

.bot-message h4 {
  margin: 0 0 10px 0;
  color: white;
  text-align: center;
}

.bot-message p {
  margin: 0;
  text-align: center;
  font-size: 1.1em;
  line-height: 1.4;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Стили для заблокированных уроков */
.locked-lesson {
  text-align: center;
  padding: 30px;
  background: linear-gradient(45deg, #ff416c, #ff4b2b);
  border-radius: 15px;
  color: white;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 75, 43, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(255, 75, 43, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 75, 43, 0); }
}

.locked-lesson h3 {
  margin-top: 0;
  color: #ffcc00;
  font-size: 1.5em;
}

.locked-lesson ul {
  text-align: left;
  max-width: 400px;
  margin: 20px auto;
}

.purchase-btn {
  background: #ffcc00;
  color: #000;
  border: none;
  padding: 12px 25px;
  font-size: 1.1em;
  border-radius: 50px;
  cursor: pointer;
  font-weight: bold;
  transition: transform 0.2s, background 0.2s;
  margin-top: 15px;
}

.purchase-btn:hover {
  transform: scale(1.05);
  background: #ffdd33;
}

.lesson-container button {
  background: #ffcc00;
  color: #000;
  border: none;
  padding: 10px 20px;
  font-size: 1em;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
}

.next-button-container {
  margin-top: 20px;
  text-align: center;
}

.lesson-container button:hover {
  background: #ffdd33;
}

.result {
  margin-top: 20px;
  padding: 15px;
  border-radius: 10px;
}

.success {
  background: rgba(0, 255, 0, 0.2);
  border: 2px solid #0f0;
}

.error {
  background: rgba(255, 0, 0, 0.2);
  border: 2px solid #f00;
}

.badge {
  font-size: 2em;
  text-align: center;
  margin: 10px 0;
  animation: badgeAnimation 0.5s ease;
}

@keyframes badgeAnimation {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* Стили для заголовка с информацией о пользователе */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

#authButtons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 20px 0;
}

.user-info-header {
  background: rgba(255, 255, 255, 0.2);
  padding: 10px 15px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-link {
  background: #ffcc00;
  color: #000;
  border: none;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9em;
  text-decoration: none;
}

.account-link:hover {
  background: #ffdd33;
}

/* Стили для списка наград */
.rewards-list {
  margin: 20px 0;
}

.reward-item {
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 10px;
}

.reward-item .badge {
  font-size: 2em;
  animation: none; /* Отключаем анимацию для бейджиков в списке */
}

.reward-item h3 {
  margin: 0 0 5px 0;
  font-size: 1.1em;
}

.reward-item p {
  margin: 0;
  color: #ccc;
}

/* Стили для формы регистрации */
#registerForm input {
  width: 100%;
  padding: 12px;
  margin: 10px 0;
  border-radius: 8px;
  border: none;
  font-size: 1em;
}

.verification-section {
  display: flex;
  gap: 10px;
  margin: 10px 0;
}

.verification-section input {
  flex: 1;
}

.verification-section button {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 12px 15px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9em;
}

.verification-section button:hover {
  background: #45a049;
}

/* Стили для друзей */
#friendsSection input {
  width: 100%;
  padding: 10px;
  margin: 10px 0;
  border-radius: 8px;
  border: none;
  font-size: 1em;
}

.friends-list {
  margin: 20px 0;
}

.friend-item {
  background: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 10px;
}

.friend-info h3 {
  margin: 0 0 5px 0;
  color: #ffcc00;
}

.friend-info p {
  margin: 3px 0;
  color: #ccc;
}

/* Стили для числового ID */
#userId {
  font-weight: bold;
  color: #ffcc00;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 8px;
  border-radius: 5px;
  font-family: monospace;
}

/* Стили для аватарки */
.avatar-section {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
}

.avatar {
  font-size: 3em;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;
}

.change-avatar-btn {
  background: #ffcc00;
  color: #000;
  border: none;
  padding: 8px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9em;
}

.change-avatar-btn:hover {
  background: #ffdd33;
}

/* Стили для настроек аккаунта */
.account-settings {
  margin: 15px 0;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-btn {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9em;
}

.settings-btn:hover {
  background: #45a049;
}

/* Стили для форм изменения */
#changeUsernameForm input,
#changePasswordForm input {
  display: block;
  width: 100%;
  padding: 8px;
  margin: 5px 0;
  border-radius: 5px;
  border: none;
  font-size: 1em;
}

#changeUsernameForm button,
#changePasswordForm button {
  background: #ffcc00;
  color: #000;
  border: none;
  padding: 8px 15px;
  border-radius: 5px;
  cursor: pointer;
  margin: 5px 2px;
}

#changeUsernameForm button:hover,
#changePasswordForm button:hover {
  background: #ffdd33;
}

/* Стили для выбора аватарки */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 10px 0;
}

.avatar-option {
  font-size: 2em;
  text-align: center;
  padding: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.avatar-option:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Стили для управления аватаркой */
.avatar-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 15px;
}

.upload-photo-btn {
  background: #2196F3;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9em;
}

.upload-photo-btn:hover {
  background: #0b7dda;
}

.frame-controls {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(255, 255, 255, 0.1);
  padding: 10px;
  border-radius: 5px;
}

.frame-controls label {
  font-size: 0.8em;
  color: #ccc;
}

.frame-controls select,
.frame-controls input {
  margin: 2px 0;
  padding: 5px;
  border-radius: 3px;
  border: none;
  font-size: 0.9em;
}

.account-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* Стили для аватарки в заголовке */
.user-info-header img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

/* Контейнер для аватарки с рамкой */
.avatar-container {
  position: relative;
  display: inline-block;
}

/* Радужная анимированная рамка с бегущим градиентом */
.rainbow-frame {
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  border-radius: inherit;
  background: linear-gradient(90deg,
    #ff0000, #ff4000, #ff8000, #ffbf00,
    #ffff00, #bfff00, #80ff00, #40ff00,
    #00ff00, #00ff40, #00ff80, #00ffbf,
    #00ffff, #00bfff, #0080ff, #0040ff,
    #0000ff, #4b0082, #9400d3, #ff0080,
    #ff0040, #ff0000);
  background-size: 300% 100%;
  animation: gradientFlow 5s linear infinite;
  z-index: -1;
  /* Создаём рамку с помощью маски */
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;
  mask-composite: exclude;
  padding: 5px;
  border: 5px solid transparent;
  box-sizing: border-box;
}

/* Анимация бегущего градиента */
@keyframes gradientFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

/* Рамка с обычным цветом */
.normal-frame {
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  border-radius: inherit;
  z-index: -1;
  border: 5px solid;
  padding: 5px;
  background: transparent;
}

.delete-btn {
  background: #f44336 !important;
}

.delete-btn:hover {
  background: #d32f2f !important;
}

/* Стили для купленных уровней */
.purchased-levels {
  margin: 20px 0;
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

.level-item {
  background: rgba(0, 255, 0, 0.2);
  padding: 15px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.level-badge {
  font-size: 2em;
}

.level-item h3 {
  margin: 0 0 5px 0;
  color: #4CAF50;
}

.level-item p {
  margin: 0;
  color: #ccc;
}

.disabled-btn {
  background: #cccccc !important;
  cursor: not-allowed !important;
  opacity: 0.6 !important;
}

.disabled-btn:hover {
  transform: none !important;
  background: #cccccc !important;
}

.back-btn {
  background: linear-gradient(45deg, #6a11cb, #2575fc) !important;
  color: white !important;
  border: none !important;
}

.back-btn:hover {
  background: linear-gradient(45deg, #2575fc, #6a11cb) !important;
  transform: scale(1.05) !important;
}

.success-message {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(45deg, #4CAF50, #8BC34A);
  color: white;
  padding: 15px 30px;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  z-index: 1000;
  animation: slideDown 0.5s, fadeOut 0.5s 1.5s;
  font-weight: bold;
  text-align: center;
}

@keyframes slideDown {
  0% { top: -50px; opacity: 0; }
  100% { top: 20px; opacity: 1; }
}

@keyframes fadeOut {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* Стили для системы тестов (quizSystem.js) */
.quiz-container {
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 204, 0, 0.3);
  border-radius: 15px;
  padding: 25px;
  margin-top: 20px;
}

.quiz-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.quiz-progress span {
  font-weight: bold;
  color: #ffcc00;
}

.progress-bar {
  flex: 1;
  margin-left: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffcc00, #ffdd33);
  transition: width 0.3s ease;
  border-radius: 10px;
}

.question-card {
  background: rgba(255, 255, 255, 0.05);
  padding: 20px;
  border-radius: 15px;
  margin-bottom: 20px;
}

.question-text {
  color: #ffcc00;
  font-size: 1.3em;
  margin-bottom: 20px;
  text-align: center;
}

.variants-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.variant-option {
  background: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  text-align: left;
}

.variant-option:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 204, 0, 0.5);
  transform: translateX(5px);
}

.variant-option.selected {
  background: rgba(255, 204, 0, 0.3);
  border-color: #ffcc00;
  transform: translateX(10px);
}

.variant-text {
  font-size: 1.1em;
  line-height: 1.5;
}

.quiz-result {
  text-align: center;
  padding: 40px;
}

.final-score {
  background: rgba(255, 204, 0, 0.1);
  padding: 30px;
  border-radius: 15px;
  margin: 20px 0;
  border: 2px solid rgba(255, 204, 0, 0.3);
}

.final-score h3 {
  color: #ffcc00;
  font-size: 1.5em;
  margin-bottom: 15px;
}

/* Адаптивность для тестов */
@media (max-width: 600px) {
  .quiz-progress {
    flex-direction: column;
    gap: 10px;
  }

  .progress-bar {
    width: 100%;
    margin-left: 0;
  }

  .question-text {
    font-size: 1.1em;
  }

  .variant-option {
    padding: 12px;
  }

  .variant-text {
    font-size: 1em;
  }
}

/* Стили для заданий с кодом (codeTasks.js) */
.code-task-container {
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 204, 0, 0.3);
  border-radius: 15px;
  padding: 25px;
  margin-top: 20px;
}

.code-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.code-progress span {
  font-weight: bold;
  color: #ffcc00;
}

.code-task-card {
  background: rgba(255, 255, 255, 0.05);
  padding: 20px;
  border-radius: 15px;
  margin-bottom: 20px;
}

.task-question {
  color: #ffcc00;
  font-size: 1.3em;
  margin-bottom: 20px;
  text-align: center;
  font-family: 'Courier New', monospace;
}

.code-variants {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.code-option {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  overflow-x: auto;
}

.code-option:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 204, 0, 0.5);
  transform: translateX(5px);
}

.code-option.selected {
  background: rgba(255, 204, 0, 0.2);
  border-color: #ffcc00;
  transform: translateX(10px);
  box-shadow: 0 0 15px rgba(255, 204, 0, 0.3);
}

.code-option pre {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.code-option code {
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: 0.95em;
  line-height: 1.5;
  color: #e0e0e0;
}

/* Подсветка синтаксиса Python */
.keyword {
  color: #ff79c6;
  font-weight: bold;
}

.function {
  color: #8be9fd;
}

.constant {
  color: #bd93f9;
}

.string {
  color: #f1fa8c;
}

.comment {
  color: #6272a4;
  font-style: italic;
}

.code-task-result {
  text-align: center;
  padding: 40px;
}

/* Адаптивность для заданий с кодом */
@media (max-width: 600px) {
  .code-progress {
    flex-direction: column;
    gap: 10px;
  }

  .code-progress .progress-bar {
    width: 100%;
    margin-left: 0;
  }

  .task-question {
    font-size: 1.1em;
  }

  .code-option {
    padding: 12px;
  }

  .code-option code {
    font-size: 0.85em;
  }
}