/* ==========================================
   БАЗОВЫЕ СТИЛИ И ПЕРЕМЕННЫЕ
   ========================================== */

:root {
  --primary: #ff8c42;
  --primary-hover: #ff7528;
  --secondary: #4a90e2;
  --success: #4caf50;
  --error: #f44336;
  --warning: #ff9800;
  --text-primary: #2c3e50;
  --text-secondary: #7f8c8d;
  --bg-light: #f9f9f9;
  --bg-white: #ffffff;
  --border: #e0e0e0;
  --shadow: rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --spacing: 1rem;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--text-primary);
  background: #fef8f0;
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

/* ==========================================
   HEADER
   ========================================== */

.app-header {
  background: var(--primary);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px var(--shadow);
  position: relative;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-header__logo {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.app-header__titles {
  display: flex;
  flex-direction: column;
}

.app-header__title {
  font-family: "Baloo 2", cursive;
  font-size: 1.8rem;
  color: var(--bg-white);
  margin: 0;
  line-height: 1.2;
}

.title-main {
  display: block;
}

.app-header__tagline {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 400;
  margin: 0.25rem 0 0 0;
}

/* Right side of header */
.app-header__right {
  display: flex;
  align-items: center;
}

/* Языковой переключатель - капсула */
.app-header__languages {
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50px;
  padding: 4px;
  gap: 0;
}

.language-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1.2rem;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.25s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.language-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.15);
}

.language-btn--active {
  background: var(--bg-white) !important;
  color: var(--primary) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ==========================================
   MAIN CONTAINER
   ========================================== */

.app-main {
  padding: 1rem 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ==========================================
   FOOTER
   ========================================== */

.app-footer {
  background: var(--primary);
  color: var(--bg-white);
  text-align: center;
  padding: 0.75rem;
  font-size: 0.85rem;
}

/* ==========================================
   ЭКРАНЫ (SCREENS)
   ========================================== */

.screen {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px var(--shadow);
  padding: 1.5rem;
  max-width: 800px;
  width: 100%;
  animation: fadeIn 0.3s ease;
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
}

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

.screen__header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.screen__title {
  font-family: "Baloo 2", cursive;
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.screen__description {
  color: var(--text-secondary);
  font-size: 1rem;
}

.screen__content {
  margin-bottom: 1.25rem;
}

.screen__footer {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* ==========================================
   ФОРМЫ И ИНПУТЫ
   ========================================== */

.form-group {
  margin-bottom: 1rem;
}

.form-group__label {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.form-group__input,
.form-group__select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s ease;
}

.form-group__input:focus,
.form-group__select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 140, 66, 0.1);
}

.form-group__input[type="number"] {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
}

/* Ползунок (Range Slider) */
.slider-container {
  margin: 1rem 0;
}

.slider-value {
  display: block;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1rem;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 5px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
  transition: all 0.3s ease;
}

.slider::-moz-range-thumb:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

/* ==========================================
   КНОПКИ
   ========================================== */

.btn {
  padding: 0.875rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn--primary {
  background: var(--primary);
  color: var(--bg-white);
}

.btn--primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 140, 66, 0.3);
}

.btn--secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn--secondary:hover {
  background: var(--primary);
  color: var(--bg-white);
  transform: translateY(-2px);
}

.btn--large {
  padding: 1.25rem 3rem;
  font-size: 1.2rem;
}

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

/* ==========================================
   АБАКУС
   ========================================== */

.abacus-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  min-height: 350px;
}

/* ==========================================
   ИГРОВАЯ ЗОНА
   ========================================== */

.game-zone {
  text-align: center;
}

.game-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-light);
  border-radius: var(--radius);
}

.game-status__item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.game-status__label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.game-status__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.game-status__value--success {
  color: var(--success);
}

.game-status__value--error {
  color: var(--error);
}

.game-message {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 1rem 0;
  min-height: 2rem;
}

.game-message--prepare {
  color: var(--warning);
  animation: pulse 1s infinite;
}

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

/* Зона ввода ответа */
.game-input-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}

.game-input-zone .form-group__input {
  width: 100%;
  max-width: 400px;
}

/* Feedback */
.feedback {
  margin: 0.75rem 0;
  padding: 1rem;
  border-radius: var(--radius);
  font-size: 1.2rem;
  font-weight: 600;
}

.feedback--correct {
  background: rgba(76, 175, 80, 0.1);
  color: var(--success);
}

.feedback--incorrect {
  background: rgba(244, 67, 54, 0.1);
  color: var(--error);
}

.feedback__text {
  margin-bottom: 1rem;
}

.feedback__buttons {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

/* Кнопка "Показать снова" */
.btn--show-again {
  min-width: 180px;
}

/* Кнопка "Далее" */
.btn--continue {
  min-width: 180px;
}

/* Кнопка "Пропустить" */
.btn--skip {
  background: transparent;
  color: var(--primary);
  border: none;
  font-size: 0.95rem;
  text-decoration: underline;
  padding: 0.5rem 1rem;
}

.btn--skip:hover {
  color: var(--primary-hover);
}

/* Кнопка выхода */
.btn--exit {
  margin-top: 2rem;
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn--exit:hover {
  background: var(--primary);
  color: var(--bg-white);
}

/* ==========================================
   РЕЗУЛЬТАТЫ
   ========================================== */

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.result-card {
  background: var(--bg-light);
  padding: 1.5rem;
  border-radius: var(--radius);
  text-align: center;
}

.result-card__value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.result-card__value--success {
  color: var(--success);
}

.result-card__value--error {
  color: var(--error);
}

.result-card__label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================
   TOAST УВЕДОМЛЕНИЯ
   ========================================== */

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  box-shadow: 0 4px 12px var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 300px;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s ease;
}

.toast--show {
  opacity: 1;
  transform: translateX(0);
}

.toast--hide {
  opacity: 0;
  transform: translateX(400px);
}

.toast__icon {
  font-size: 1.5rem;
}

.toast__message {
  flex: 1;
  font-weight: 500;
}

.toast__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  line-height: 1;
}

.toast--success {
  border-left: 4px solid var(--success);
}

.toast--error {
  border-left: 4px solid var(--error);
}

.toast--warning {
  border-left: 4px solid var(--warning);
}

.toast--info {
  border-left: 4px solid var(--primary);
}

/* ==========================================
   АДАПТИВНОСТЬ
   ========================================== */

@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .app-header__brand {
    flex-direction: column;
    text-align: center;
  }

  .app-header__title {
    font-size: 1.5rem;
  }

  .app-header__right {
    align-items: center;
  }

  .app-main {
    padding: 1rem;
  }

  .screen {
    padding: 1.5rem;
  }

  .screen__title {
    font-size: 1.5rem;
  }

  .abacus-container {
    padding: 1rem;
    min-height: 300px;
  }

  .game-status {
    flex-direction: column;
    gap: 1rem;
  }

  .feedback__buttons {
    flex-direction: column;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
  }

  .toast {
    min-width: auto;
  }

  .series-inputs {
    grid-template-columns: 1fr;
  }

  .series-input-wrapper {
    margin-bottom: 1rem;
  }
}

/* ==========================================
   CHECKBOXES FOR NUMBER RANGES
   ========================================== */

.form-group__checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  transition: background-color 0.2s ease;
}

.checkbox-label:hover {
  background-color: var(--bg-light);
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
}

.checkbox-label span {
  font-size: 0.95rem;
  color: var(--text-primary);
}

/* ==========================================
   SERIES INPUT FIELDS
   ========================================== */

.series-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  width: 100%;
  margin-bottom: 0.75rem;
}

.series-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.series-input-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}

.series-input {
  width: 100%;
  padding: 0.6rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  font-family: inherit;
  transition: all 0.3s ease;
}

.series-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 140, 66, 0.1);
}

/* ==========================================
   SERIES FEEDBACK
   ========================================== */

.feedback__answers-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0.75rem 0 0.5rem 0;
  text-align: center;
}

.feedback__answers-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
  max-height: 250px;
  overflow-y: auto;
  padding: 0.25rem;
}

.feedback__answer-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.feedback__answer-item--correct {
  background-color: rgba(76, 175, 80, 0.1);
  border: 2px solid var(--success);
  color: var(--success);
}

.feedback__answer-item--incorrect {
  background-color: rgba(244, 67, 54, 0.1);
  border: 2px solid var(--error);
  color: var(--error);
}

.feedback__answer-number {
  font-size: 0.875rem;
  opacity: 0.7;
}

.feedback__answer-value {
  font-size: 1.125rem;
}

.feedback__answer-user {
  font-size: 0.875rem;
  opacity: 0.7;
  margin-left: 0.25rem;
}
