/* ============================================================
   levels.css — стили игровых уровней (1–5)
   ============================================================ */

/* ===== Общий каркас уровня ===== */
.level-screen { position: relative; min-height: 100vh; padding: 84px 20px 20px; }
.level-bg { position: absolute; inset: 0; background-size: cover; background-position: center; z-index: 0; }
.level-overlay { position: absolute; inset: 0; z-index: 1; }
#level1 .level-bg { background-image: url('../img/level1-bg.jpg'); }
#level1 .level-overlay { background: linear-gradient(135deg, rgba(16,69,31,0.75), rgba(34,139,34,0.55)); }
#level2 .level-bg { background-image: url('../img/level2-bg.jpg'); }
#level2 .level-overlay { background: linear-gradient(135deg, rgba(0,105,148,0.75), rgba(0,150,199,0.55)); }
#level3 .level-bg { background-image: url('../img/level3-bg.jpg'); }
#level3 .level-overlay { background: linear-gradient(135deg, rgba(75,0,130,0.75), rgba(138,43,226,0.55)); }
#level4 .level-bg { background-image: url('../img/level4-bg.jpg'); }
#level4 .level-overlay { background: linear-gradient(135deg, rgba(255,140,0,0.75), rgba(255,165,0,0.55)); }
#level5 .level-bg { background-image: url('../img/level5-bg.jpg'); }
#level5 .level-overlay { background: linear-gradient(135deg, rgba(255,20,147,0.75), rgba(255,105,180,0.55)); }
.level-content { position: relative; z-index: 10; max-width: 900px; margin: 0 auto; background: rgba(255,255,255,0.95); border-radius: 20px; padding: 25px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); animation: levelIn 0.45s ease; }
@keyframes levelIn { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.level-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.btn-back { background: #6c757d; color: white; border: none; padding: 10px 20px; border-radius: 10px; cursor: pointer; font-family: inherit; font-size: 1em; transition: all 0.3s; }
.btn-back:hover { background: #5a6268; }
.level-title { font-size: clamp(1.3em, 3vw, 2em); color: #333; text-align: center; flex: 1; }
.progress { font-size: 1.05em; color: #c44569; font-weight: bold; background: #fff0f6; border: 2px solid #ffb3d1; padding: 5px 14px; border-radius: 50px; white-space: nowrap; }
/* Визуальный прогресс: обёртка чип + полоска делений */
.progress-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.progress-track { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 150px; }
.progress-seg {
  width: 20px; height: 9px; border-radius: 6px;
  background: rgba(255,255,255,0.5);
  border: 1.5px solid rgba(196,69,105,0.35);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.progress-seg.done {
  background: linear-gradient(90deg, #ffd700, #ffb300);
  border-color: #e6a817;
  box-shadow: 0 0 8px rgba(255,193,7,0.65);
}
.progress-seg.pop { animation: segPop 0.45s ease; }
@keyframes segPop { 0% { transform: scale(0.4); } 55% { transform: scale(1.45); } 100% { transform: scale(1); } }
.story-intro { background: linear-gradient(135deg, #fff9c4, #fff59d); padding: 18px; border-radius: 15px; margin-bottom: 20px; border-left: 5px solid #ffd700; }
.story-intro p { color: #333; line-height: 1.6; }
.game-area { min-height: 350px; position: relative; }
.btn-hint { background: linear-gradient(45deg, #9c27b0, #ba68c8); color: white; border: none; padding: 12px 25px; border-radius: 15px; cursor: pointer; font-family: inherit; font-size: 1em; font-weight: 800; text-shadow: 0 1px 2px rgba(0,0,0,0.3); margin-top: 20px; transition: all 0.3s; box-shadow: 0 5px 15px rgba(156,39,176,0.4); }
.btn-hint:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(156,39,176,0.6); }
.decorative-emojis { position: absolute; bottom: 15px; left: 0; width: 100%; display: flex; justify-content: space-around; font-size: 1.8em; opacity: 0.6; z-index: 5; pointer-events: none; }

/* ===== Тематические рамки карточек уровней =====
   Каждая локация — свой цвет и «водяной знак»-эмодзи в углу,
   чтобы уровни отличались даже не глядя на фон. */
.level-content { overflow: hidden; }
#level1 .level-content {
  border-top: 7px solid #2e7d32;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3), 0 0 0 1px rgba(46,125,50,0.25), 0 -3px 22px rgba(46,125,50,0.35);
}
#level1 .level-content::after,
#level2 .level-content::after,
#level3 .level-content::after,
#level4 .level-content::after,
#level5 .level-content::after {
  content: ''; position: absolute; right: -18px; bottom: -26px;
  font-size: 9em; opacity: 0.07; pointer-events: none; line-height: 1;
  transform: rotate(-12deg);
}
#level1 .level-content::after { content: '🌳'; }
#level2 .level-content {
  border-top: 7px solid #0277bd;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3), 0 0 0 1px rgba(2,119,189,0.25), 0 -3px 22px rgba(2,119,189,0.35);
}
#level2 .level-content::after { content: '🌊'; }
#level3 .level-content {
  border-top: 7px solid #7b1fa2;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3), 0 0 0 1px rgba(123,31,162,0.25), 0 -3px 22px rgba(123,31,162,0.35);
}
#level3 .level-content::after { content: '🔮'; }
#level4 .level-content {
  border-top: 7px solid #ef6c00;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3), 0 0 0 1px rgba(239,108,0,0.25), 0 -3px 22px rgba(239,108,0,0.35);
}
#level4 .level-content::after { content: '🗼'; }
#level5 .level-content {
  border-top: 7px solid #c2185b;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3), 0 0 0 1px rgba(194,24,91,0.25), 0 -3px 22px rgba(194,24,91,0.35);
}
#level5 .level-content::after { content: '🌈'; }
/* Цвет заголовка уровня — в тон локации */
#level1 .level-title { color: #2e7d32; }
#level2 .level-title { color: #0277bd; }
#level3 .level-title { color: #7b1fa2; }
#level4 .level-title { color: #ef6c00; }
#level5 .level-title { color: #c2185b; }
/* Чип прогресса «x/N» тоже перекрашивается */
#level1 .progress { background: #e8f5e9; border-color: #a5d6a7; color: #2e7d32; }
#level2 .progress { background: #e1f5fe; border-color: #81d4fa; color: #0277bd; }
#level3 .progress { background: #f3e5f5; border-color: #ce93d8; color: #7b1fa2; }
#level4 .progress { background: #fff3e0; border-color: #ffcc80; color: #ef6c00; }
#level5 .progress { background: #fce4ec; border-color: #f48fb1; color: #c2185b; }

/* ===== Уровень 1 — Лес Загадок (светлячки в волшебном лесу) ===== */
/* Вместо серого поля — настоящий волшебный ночной лес (img/forest-bg.png):
   светлячки прячутся в темноте, а волшебная палочка освещает путь */
#gameArea1 {
  position: relative; height: 430px; cursor: none;
  border-radius: 15px; overflow: hidden;
  background: #0a2416 url('../img/forest-bg.jpg') center/cover no-repeat;
  border: 3px solid rgba(255, 213, 79, 0.55);
  box-shadow: inset 0 0 80px rgba(2, 14, 8, 0.72), 0 6px 18px rgba(0,0,0,0.28);
}
/* Винетка: края темнее — светлячки и свет палочки заметнее */
#gameArea1::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, rgba(3,20,11,0.16) 0%, rgba(3,20,11,0.6) 100%);
}
/* Подсказка-ленточка сверху леса */
#gameArea1::after {
  content: '✨ Веди волшебной палочкой по лесу — светлячки прячутся в темноте!';
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 0.92em; font-weight: bold; white-space: nowrap; max-width: 96%;
  overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 2px 6px rgba(0,0,0,0.85);
  background: rgba(6, 26, 15, 0.62);
  border: 1.5px solid rgba(255, 213, 79, 0.45);
  padding: 7px 18px; border-radius: 50px;
  pointer-events: none;
}
/* Когда все светлячки пойманы — подсказка больше не нужна */
#gameArea1.done::after { display: none; }
.firefly {
  position: absolute; width: 26px; height: 26px;
  background: radial-gradient(circle, #fffde7, #ffee58 55%, #ffeb3b);
  border-radius: 50%; cursor: none; opacity: 0;
  transition: opacity 0.3s;
  box-shadow: 0 0 18px #ffff00, 0 0 38px #ffeb3b;
  pointer-events: auto;
  animation: fireflyFloat 3.6s ease-in-out infinite;
}
/* Светлячок появляется рядом с палочкой — тёпло пульсирует */
.firefly.visible {
  opacity: 1;
  animation: fireflyFloat 3.6s ease-in-out infinite, fireflyPulse 0.9s ease-in-out infinite;
}
.firefly.caught { opacity: 0; pointer-events: none; animation: none; }
/* Лёгкое парение светлячка */
@keyframes fireflyFloat {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(7px, -11px); }
}
/* Пульсация свечения найденного светлячка */
@keyframes fireflyPulse {
  0%, 100% { box-shadow: 0 0 16px #ffff00, 0 0 34px #ffeb3b; }
  50% { box-shadow: 0 0 28px #ffff9c, 0 0 60px #ffeb3b; }
}
/* Магический свет волшебной палочки — мягкое пятно света следует за курсором
   и «освещает» лес вокруг (появляется рядом с ним светлячок) */
.wand-light {
  position: fixed; width: 320px; height: 320px;
  margin: -160px 0 0 -160px;
  border-radius: 50%; pointer-events: none; z-index: 9997;
  display: none;
  background: radial-gradient(circle,
    rgba(255, 249, 196, 0.34) 0%,
    rgba(255, 238, 150, 0.16) 42%,
    rgba(255, 238, 150, 0) 70%);
}
.sparkle-cursor { position: fixed; pointer-events: none; font-size: 24px; z-index: 9999; transform: translate(-50%, -50%); }
.sparkle-trail { position: fixed; pointer-events: none; font-size: 16px; z-index: 9998; animation: sparkleFade 1s forwards; }
@keyframes sparkleFade { to { opacity: 0; transform: scale(0.5) rotate(180deg); } }
@media (max-width: 600px) {
  #gameArea1 { height: 380px; }
  #gameArea1::after { font-size: 0.78em; padding: 6px 12px; }
}

/* ===== Уровень 2 — Волшебное Озеро (последовательности) ===== */
.task-question { text-align: center; font-size: 1.2em; color: #333; margin-bottom: 20px; font-weight: bold; }
.number-sequence { display: flex; justify-content: center; gap: 10px; margin: 20px 0; flex-wrap: wrap; }
.number-box { background: linear-gradient(135deg, #e3f2fd, #bbdefb); border: 3px solid #1976d2; padding: 15px 25px; border-radius: 15px; font-size: 1.5em; font-weight: bold; color: #1976d2; min-width: 60px; text-align: center; }
.number-box.question { background: linear-gradient(135deg, #fff3e0, #ffe0b2); border-color: #ff9800; color: #ff9800; animation: pulse 1.5s infinite; cursor: pointer; }
.number-box.filled { background: linear-gradient(135deg, #c8e6c9, #a5d6a7); border-color: #4caf50; color: #2e7d32; animation: none; }
.answer-options { display: flex; justify-content: center; gap: 15px; margin-top: 25px; flex-wrap: wrap; }
.answer-block { background: linear-gradient(135deg, #f3e5f5, #e1bee7); border: 3px solid #9c27b0; padding: 15px 30px; border-radius: 15px; font-size: 1.3em; font-weight: bold; color: #9c27b0; cursor: pointer; transition: all 0.3s; font-family: inherit; }
.answer-block:hover { transform: scale(1.05); }
.answer-block.selected { border-color: #ffd700; box-shadow: 0 0 20px #ffd700; transform: scale(1.1); }
.answer-block.used { opacity: 0.3; cursor: not-allowed; pointer-events: none; }

/* ===== Уровень 3 — Замок Колдуньи (сетка) ===== */
.grid-question { text-align: center; font-size: 1.1em; color: #333; margin-bottom: 15px; font-weight: bold; }
.magic-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; max-width: 500px; margin: 20px auto; }
.grid-cell { background: linear-gradient(135deg, #ede7f6, #d1c4e9); border: 2px solid #673ab7; padding: 15px 5px; border-radius: 10px; font-size: 1.1em; font-weight: bold; color: #673ab7; text-align: center; cursor: pointer; transition: all 0.3s; font-family: inherit; }
.grid-cell:hover { background: linear-gradient(135deg, #d1c4e9, #b39ddb); transform: scale(1.05); }
.grid-cell.correct { background: linear-gradient(135deg, #c8e6c9, #a5d6a7); border-color: #4caf50; color: #2e7d32; pointer-events: none; }

/* ===== Уровень 4 — Башня Магии (слайдер) ===== */
.slider-question { text-align: center; font-size: 1.1em; color: #333; margin-bottom: 20px; font-weight: bold; line-height: 1.6; }
.slider-container { text-align: center; margin: 30px 0; }
.slider-value { font-size: 4em; font-weight: bold; color: #ff6b9d; margin: 15px 0; }
.magic-slider { width: 80%; max-width: 500px; height: 10px; border-radius: 5px; background: #ddd; outline: none; -webkit-appearance: none; }
.magic-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(45deg, #ff6b9d, #c44569); cursor: pointer; box-shadow: 0 0 10px rgba(255,107,157,0.5); }
.magic-slider::-moz-range-thumb { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(45deg, #ff6b9d, #c44569); cursor: pointer; border: none; box-shadow: 0 0 10px rgba(255,107,157,0.5); }
.btn-check { background: linear-gradient(45deg, #4caf50, #81c784); color: white; border: none; padding: 12px 35px; border-radius: 15px; cursor: pointer; font-family: inherit; font-size: 1.1em; margin-top: 15px; transition: all 0.3s; box-shadow: 0 5px 15px rgba(76,175,80,0.4); }
.btn-check:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(76,175,80,0.6); }

/* ===== Уровень 5 — Радужная Поляна (пары) ===== */
.matching-game { display: flex; justify-content: space-around; gap: 20px; margin: 20px 0; flex-wrap: wrap; }
.matching-column { flex: 1; min-width: 250px; }
.matching-column h4 { text-align: center; color: #333; margin-bottom: 10px; font-size: 1.1em; }
.matching-item { background: linear-gradient(135deg, #fff3e0, #ffe0b2); border: 3px solid #ff9800; padding: 12px 15px; margin: 8px 0; border-radius: 15px; font-size: 1em; cursor: pointer; transition: all 0.3s; text-align: center; }
.matching-item:hover { transform: translateX(5px); }
.matching-item.selected { border-color: #2196f3; box-shadow: 0 0 15px #2196f3; background: linear-gradient(135deg, #e3f2fd, #bbdefb); }
.matching-item.matched { background: linear-gradient(135deg, #c8e6c9, #a5d6a7); border-color: #4caf50; cursor: not-allowed; opacity: 0.7; pointer-events: none; }

/* ===== Адаптивность уровней ===== */
@media (max-width: 600px) {
  .level-screen { padding: 76px 12px 16px; }
  .magic-grid { grid-template-columns: repeat(5, 1fr); gap: 5px; }
  .grid-cell { padding: 10px 3px; font-size: 0.9em; }
  .number-box { padding: 10px 15px; font-size: 1.2em; min-width: 50px; }
  .answer-block { padding: 12px 20px; font-size: 1.1em; }
  .slider-value { font-size: 3em; }
  .level-content { padding: 15px; }
}
