/* ============================================================
   NUMBERSYSTEM • Чистые стили (только v2)
   Префикс .ns- для изоляции
   ============================================================ */

/* ============================================================
   🔹 БАЗОВЫЕ ЭЛЕМЕНТЫ
   ============================================================ */
.ns-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(44, 95, 141, 0.12);
  border: 2px solid transparent;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.ns-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #2c5f8d, #4a7c59, #f59e0b);
  opacity: 0.8;
}
.ns-card:hover {
  border-color: #2c5f8d;
  transform: translateY(-2px);
}

.ns-header {
  text-align: center;
  padding: 1.5rem 1rem;
  margin-bottom: 0.5rem;
}
.ns-title {
  font-size: 2.25rem;
  font-weight: 800;
  color: #2c5f8d;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.ns-title i {
  font-size: 2rem;
  color: #f59e0b;
}
.ns-subtitle {
  color: #6b7280;
  font-size: 1.1rem;
  font-weight: 500;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ============================================================
   🔹 СТАТИСТИКА
   ============================================================ */
.ns-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 0 auto 1.5rem;
  max-width: 900px;
}
.ns-stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 0.75rem 0.5rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border-top: 3px solid #6b7280;
}
.ns-stat-card.success { border-top-color: #4a7c59; }
.ns-stat-card.danger { border-top-color: #ef4444; }
.ns-stat-card.warning { border-top-color: #f59e0b; }
.ns-stat-card.info { border-top-color: #2c5f8d; }
.ns-stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1e293b;
  line-height: 1;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.ns-stat-label {
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 600;
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ============================================================
   🔹 ЗАДАНИЕ (основной блок)
   ============================================================ */
.ns-task {
  background: linear-gradient(135deg, #2c5f8d 0%, #1e4a6b 100%);
  color: #fff;
  border-radius: 16px;
  padding: 1.75rem 1.5rem;
  text-align: center;
  margin: 1rem 0;
  position: relative;
  overflow: hidden;
  z-index: 1;
}
/* Плавающие цифры на фоне */
.ns-task::before {
  content: '01011001';
  position: absolute;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 7rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.06);
  animation: ns-float-digits 28s linear infinite;
  pointer-events: none;
  white-space: nowrap;
  top: -15%;
  left: -15%;
  z-index: 0;
  letter-spacing: 0.5rem;
}
@keyframes ns-float-digits {
  0%   { transform: translate(-40%, -40%) rotate(-8deg); opacity: 0; }
  8%   { opacity: 0.06; }
  92%  { opacity: 0.06; }
  100% { transform: translate(340%, 140%) rotate(8deg); opacity: 0; }
}
/* Блик */
.ns-task::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,0.08) 45%, rgba(255,255,255,0.15) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: ns-shimmer 3.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}
@keyframes ns-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.ns-task-value {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: 1px;
  position: relative;
  z-index: 3;
  font-family: 'SF Mono', 'Fira Code', monospace;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.ns-task-hint {
  font-size: 0.9rem;
  opacity: 0.95;
  margin-top: 0.4rem;
  position: relative;
  z-index: 3;
  font-weight: 500;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.ns-task-badge {
  background: linear-gradient(135deg, #2c5f8d, #1e4a6b);
  color: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ============================================================
   🔹 ПОЛЕ ОТВЕТА И КНОПКИ
   ============================================================ */
.ns-answer-area {
  display: flex;
  gap: 1rem;
  min-height: 140px;
  margin: 1rem 0;
}
.ns-answer-input {
  flex: 7;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ns-answer-input input {
  flex: 1;
  width: 100%;
  font-size: 2rem;
  font-weight: 700;
  padding: 1rem;
  border: 4px solid #cbd5e1;
  border-radius: 16px;
  text-align: center;
  font-family: 'SF Mono', 'Fira Code', monospace;
  letter-spacing: 3px;
  background: #fff;
  transition: all 0.2s ease;
  box-sizing: border-box;
}
.ns-answer-input input:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.2);
  outline: none;
}
.ns-answer-input input.correct {
  border-color: #16a34a;
  background: rgba(220, 252, 231, 0.8);
  animation: ns-bounce 0.3s ease;
}
.ns-answer-input input.incorrect {
  border-color: #dc2626;
  background: rgba(254, 226, 226, 0.8);
  animation: ns-shake 0.3s ease;
}
@keyframes ns-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}
@keyframes ns-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.ns-feedback {
  min-height: 26px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

/* Кнопки */
.ns-answer-area .ns-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  padding: 0.5rem 1rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.ns-btn-check { background: #4a7c59; color: #fff; }
.ns-btn-check:hover {
  background: #3a6347;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 124, 89, 0.3);
}
.ns-btn-new { background: #2c5f8d; color: #fff; }
.ns-btn-new:hover {
  background: #1e4a6b;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(44, 95, 141, 0.3);
}
.ns-btn-reset {
  background: transparent;
  border: 2px solid #6b7280;
  color: #6b7280;
}
.ns-btn-reset:hover {
  background: #6b7280;
  color: #fff;
  transform: translateY(-2px);
}

/* ============================================================
   🔹 НАСТРОЙКИ: БАЗЫ И СЛОЖНОСТЬ
   ============================================================ */
.ns-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.ns-base-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f1f5f9;
  border: 2px solid transparent;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.ns-base-chip input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}
.ns-base-chip:hover {
  background: #e2e8f0;
  transform: scale(1.05);
}
.ns-base-chip:has(input:checked) {
  background: #2c5f8d;
  color: #fff;
  border-color: #f59e0b;
  box-shadow: 0 4px 12px rgba(44, 95, 141, 0.25);
}
/* Группировка по сложности */
.ns-base-chip[data-difficulty="simple"] { border-color: rgba(74, 124, 89, 0.3); }
.ns-base-chip[data-difficulty="simple"]:has(input:checked) {
  background: #4a7c59;
  border-color: #2c5f8d;
}
.ns-base-chip[data-difficulty="medium"] { border-color: rgba(245, 158, 11, 0.3); }
.ns-base-chip[data-difficulty="medium"]:has(input:checked) {
  background: #f59e0b;
  color: #1e293b;
  border-color: #d97706;
}
.ns-base-chip[data-difficulty="hard"] {
  border-color: rgba(139, 92, 246, 0.4);
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
}
.ns-base-chip[data-difficulty="hard"]::after {
  content: '★';
  position: absolute;
  top: -4px; right: -4px;
  font-size: 0.65rem;
  color: #8b5cf6;
  font-weight: 800;
}
.ns-base-chip[data-difficulty="hard"]:has(input:checked) {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
  border-color: #5b21b6;
}

/* Кнопки сложности */
.ns-difficulty {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.ns-diff-btn {
  flex: 1;
  min-width: 70px;
  padding: 0.5rem 0.25rem;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  font-size: 0.9rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}
.ns-diff-btn input { display: none; }
.ns-diff-btn:has(input:checked) {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}
.ns-diff-btn small {
  font-weight: 400;
  opacity: 0.85;
}

/* ============================================================
   🔹 ИСТОРИЯ
   ============================================================ */
.ns-history {
  max-height: 240px;
  overflow-y: auto;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.ns-history-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ns-history-item:last-child { border-bottom: none; }
.ns-history-item:hover { background: #f1f5f9; }
.ns-history-item.correct {
  border-left: 4px solid #4a7c59;
  background: rgba(74, 124, 89, 0.06);
}
.ns-history-item.incorrect {
  border-left: 4px solid #ef4444;
  background: rgba(239, 68, 68, 0.06);
}
.ns-history-item.warning {
  border-left: 4px solid #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}

/* Подсказка */
.ns-tip {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-left: 4px solid #92400e;
  border-radius: 0 12px 12px 0;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  margin: 0.75rem 0 1.25rem;
  animation: ns-fadeIn 0.4s ease;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #1e293b;
}
@keyframes ns-fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.ns-tip i { margin-right: 0.5rem; color: #92400e; }

/* ============================================================
   🔹 ОБОЙМА С ПАТРОНАМИ (визуализация задания)
   ============================================================ */
.ns-magazine {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border-radius: 16px;
  padding: 0.75rem 1rem;
  margin: 0 auto 1rem;
  width: 100%;
  max-width: 100%;
  border: 2px solid #334155;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.ns-magazine .magazine-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #334155;
}
.ns-magazine .magazine-header i { color: #f59e0b; }
.ns-magazine .magazine-count {
  background: #f59e0b;
  color: #1e293b;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
}
.magazine-bullets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-start;
  min-height: 32px;
  width: 100%;
}

/* Пуля */
.magazine-bullet {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #334155;
  border: 2px solid #475569;
  position: relative;
  transition: all 0.25s ease;
  cursor: help;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.magazine-bullet:hover {
  transform: scale(1.1);
  z-index: 10;
}

/* Цветовая дифференциация по диапазону */
.magazine-bullet[data-range="32"] { --bh: 142; }   /* зелёный */
.magazine-bullet[data-range="256"] { --bh: 38; }    /* янтарный */
.magazine-bullet[data-range="4096"] { --bh: 262; }  /* фиолетовый */

/* Пустые пули */
.magazine-bullet[data-range].empty {
  border-color: hsl(var(--bh), 60%, 50%);
  background: hsl(var(--bh), 60%, 95%);
}

/* Решённые пули */
.magazine-bullet[data-range].solved {
  background: linear-gradient(135deg, hsl(var(--bh), 60%, 45%), hsl(var(--bh), 60%, 35%));
  border-color: hsl(var(--bh), 60%, 35%);
  box-shadow: 0 0 0 2px rgba(74, 124, 89, 0.3);
}
.magazine-bullet.solved::after {
  content: '✓';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Активная пуля (текущая) */
.magazine-bullet[data-range].active {
  background: linear-gradient(135deg, hsl(var(--bh), 70%, 55%), hsl(var(--bh), 70%, 45%));
  border-color: hsl(var(--bh), 70%, 45%);
  animation: ns-bullet-pulse 1.5s ease-in-out infinite;
}
@keyframes ns-bullet-pulse {
  0%, 100% { box-shadow: 0 0 0 3px hsla(var(--bh), 70%, 50%, 0.4); }
  50% { box-shadow: 0 0 0 6px hsla(var(--bh), 70%, 50%, 0); }
}

/* Эффект выстрела */
.magazine-bullet.hit { animation: ns-bullet-hit 0.4s ease-out; }
@keyframes ns-bullet-hit {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.magazine-bullet.hit::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, hsla(var(--bh), 70%, 60%, 0.6) 0%, transparent 70%);
  animation: ns-smoke 0.4s ease-out forwards;
  pointer-events: none;
}
@keyframes ns-smoke {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(2.5); }
}

/* Легенда цветов */
.ns-magazine-legend {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding: 0.5rem 0;
  font-size: 0.75rem;
  color: #94a3b8;
}
.ns-magazine-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.ns-magazine-legend .legend-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid;
}
.ns-magazine-legend .legend-dot.easy {
  background: hsl(142, 60%, 95%);
  border-color: hsl(142, 60%, 50%);
}
.ns-magazine-legend .legend-dot.medium {
  background: hsl(38, 70%, 95%);
  border-color: hsl(38, 90%, 50%);
}
.ns-magazine-legend .legend-dot.hard {
  background: hsl(262, 70%, 96%);
  border-color: hsl(262, 70%, 60%);
}

/* ============================================================
   🔹 СЕКРЕТНОЕ СЛОВО (показ после выполнения)
   ============================================================ */
.ns-secret-inline {
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1rem;
  color: #fff;
  animation: ns-secret-slide 0.4s ease-out;
}
.ns-secret-inline .secret-label {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}
.ns-secret-inline .secret-word {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  animation: ns-secret-pulse 2s ease-in-out infinite;
}
@keyframes ns-secret-slide {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes ns-secret-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* ============================================================
   🔹 РЕЖИМ ЗАДАНИЯ: БЛОКИРОВКИ И СКРЫТИЯ
   ============================================================ */
body.ns-task-mode .ns-tip,
body.ns-task-mode .ns-difficulty,
body.ns-task-mode #from-checkboxes,
body.ns-task-mode #to-checkboxes,
body.ns-task-mode .ns-card .fw-bold:has(.fa-gauge),
body.ns-task-mode .ns-card .fw-bold:has(.fa-layer-group),
body.ns-task-mode .ns-card:has(.fa-clipboard-list),
body.ns-task-mode #taskControlBox,
body.ns-task-mode .ns-card .row.g-4 small.fw-medium:has(+ #from-checkboxes),
body.ns-task-mode .ns-card .row.g-4 small.fw-medium:has(+ #to-checkboxes),
body.ns-task-mode #resetStatsBtn {
  display: none !important;
}

/* Блокировка выбора баз в режиме задания */
.ns-settings.task-mode .ns-base-chip:not([data-allowed="1"]) {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.5);
}
.ns-settings.task-mode .ns-base-chip:not([data-allowed="1"]):hover {
  transform: none;
}

/* Завершённое задание */
.ns-task.task-complete {
  border: 3px solid #22c55e !important;
  background: linear-gradient(135deg, #166534, #14532d) !important;
  animation: ns-complete-glow 1.5s ease-in-out infinite;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}
@keyframes ns-complete-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(34, 197, 94, 0); }
}
.ns-task.task-complete .ns-task-badge {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
}

/* Скрываем элементы при завершении задания */
body.ns-task-mode .ns-task.task-complete .ns-task-value,
body.ns-task-mode .ns-task.task-complete .ns-task-hint,
body.ns-task-mode .ns-task.task-complete .ns-answer-area,
body.ns-task-mode .ns-task.task-complete #taskModeBadge {
  display: none !important;
}

/* Блокированное поле ввода */
#userAnswer:disabled {
  background: #f1f5f9;
  cursor: not-allowed;
  opacity: 0.8;
}

/* ============================================================
   🔹 УТИЛИТЫ И АДАПТИВ
   ============================================================ */
/* Скроллбар */
.ns-history::-webkit-scrollbar { width: 6px; }
.ns-history::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 3px; }
.ns-history::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.ns-history::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Адаптив */
@media (max-width: 992px) {
  .ns-answer-area { flex-direction: column; min-height: auto; }
  .ns-answer-input, .ns-answer-buttons { flex: none; width: 100%; }
  .ns-answer-input input { min-height: 80px; font-size: 1.75rem; }
  .ns-answer-buttons {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .ns-answer-area .ns-btn {
    min-height: 45px;
    flex: 1 1 calc(50% - 0.25rem);
  }
}
@media (max-width: 768px) {
  .ns-title { font-size: 1.75rem; }
  .ns-task-value { font-size: 1.75rem; }
  .ns-stats { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .ns-stat-value { font-size: 1.35rem; }
  .ns-stat-label { font-size: 0.7rem; }
  .ns-diff-btn { min-width: 60px; padding: 0.5rem; font-size: 0.85rem; }
}
@media (max-width: 576px) {
  .magazine-bullet { width: 24px; height: 24px; }
  .magazine-bullet.solved::after { font-size: 0.6rem; }
}

/* Сообщение при отсутствии секретного слова */
.ns-task .alert-warning {
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border: 2px solid #f59e0b;
  border-radius: 12px;
  color: #92400e;
  font-weight: 500;
}
.ns-task .alert-warning i { color: #d97706; }


/* ============================================================
   🔹 РЕЖИМ ЗАДАНИЯ: ПОКАЗ ОБОЙМЫ
   ============================================================ */
/* Показываем обойму и легенду только в режиме задания */
body.ns-task-mode .ns-magazine,
body.ns-task-mode .ns-magazine-legend {
  display: block !important;
}
body.ns-task-mode .ns-magazine-legend {
  display: flex !important; /* для flex-контейнера легенды */
}



.magazine-bullet.hit::after {
  content: '';
  position: absolute;
  width: 4px; height: 4px;
  background: #fbbf24;
  border-radius: 50%;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  box-shadow:
    10px -10px 0 #f59e0b,
    -10px 10px 0 #f59e0b,
    15px 0 0 #fbbf24,
    -15px 0 0 #fbbf24;
  animation: ns-sparks 0.5s ease-out forwards;
  pointer-events: none;
}
@keyframes ns-sparks {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2) rotate(15deg); }
}
