/* Базові стилі для мінігри «Додай "н"» */
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Arial', sans-serif;
  color: #f5f5f5;
  background: transparent;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* Фон та його анімація */
#background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  background-image: url('./background.png');
  background-size: cover;
  background-position: center;
  /* Робимо фон темнішим для контрастності */
  filter: brightness(0.6);
  animation: bgMove 40s linear infinite alternate;
}

@keyframes bgMove {
  from {
    background-position: 50% 0%;
  }
  to {
    background-position: 50% 100%;
  }
}

/* Мерехтливі зірки */
#star-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
  animation: twinkle 2s infinite ease-in-out;
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.8;
    transform: scale(1);
  }
  50% {
    opacity: 0.3;
    transform: scale(1.5);
  }
}

/* Перекриття для стартового та фінального екранів */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
  z-index: 5;
}

.start-content,
.finish-content {
  max-width: 550px;
  width: 100%;
  background: rgba(0, 0, 0, 0.7);
  padding: 2rem 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.start-content img {
  width: 130px;
  height: auto;
}

.start-content h1 {
  font-size: 1.6rem;
  margin: 0;
  color: #ffd27f;
  text-align: center;
}

.start-content p {
  font-size: 1rem;
  line-height: 1.4;
  color: #f5e6c6;
  margin: 0;
  text-align: center;
}

.start-content button {
  padding: 0.8rem 1.6rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 0.5rem;
  background: linear-gradient(90deg, #f7c84d 0%, #a47c4a 100%);
  color: #1e1e1e;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.start-content button:hover {
  transform: scale(1.05);
}

/* Основний ігровий контейнер */
#game-container {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1rem;
  box-sizing: border-box;
  z-index: 2;
}

.header h2 {
  margin: 0.5rem 0;
  font-size: 1.6rem;
  font-weight: 700;
  color: #ffd27f;
}

.instructions {
  font-size: 1rem;
  color: #f5e6c6;
  margin: 0 0 1rem;
  max-width: 600px;
  text-align: center;
}

/* Панель спроб та прогресу */
.scoreboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 550px;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.tries {
  display: flex;
  gap: 0.25rem;
  font-size: 1.6rem;
  color: #e57373;
}

.progress {
  font-size: 1rem;
  color: #f5e6c6;
}

/* Слово */
#word-area {
  font-size: 2.2rem;
  font-weight: 700;
  color: #ffd27f;
  display: flex;
  gap: 0.2rem;
  flex-wrap: wrap;
  justify-content: center;
  user-select: none;
  min-height: 80px;
}

#word-area .letter {
  padding: 0 0.05em;
  position: relative;
}

#word-area .blank {
  border-bottom: 2px dashed #ffd27f;
  min-width: 1.4rem;
  text-align: center;
  color: #ffd27f;
}

#word-area .filled {
  color: #a1e7b2;
  border-bottom: none;
}

/* Варіанти вибору */
#choices-container {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  max-width: 600px;
}

.choice-btn {
  padding: 0.6rem 1.2rem;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  background: linear-gradient(90deg, #f7c84d 0%, #a47c4a 100%);
  color: #1e1e1e;
  transition: transform 0.1s ease;
  min-width: 64px;
  text-align: center;
}

.choice-btn:hover {
  transform: scale(1.05);
}

.choice-btn.disabled {
  cursor: default;
  opacity: 0.5;
  pointer-events: none;
}

.choice-btn.correct {
  background: linear-gradient(90deg, #8bc34a 0%, #4caf50 100%);
  color: #1e1e1e;
}

.choice-btn.incorrect {
  background: linear-gradient(90deg, #e57373 0%, #d32f2f 100%);
  color: #1e1e1e;
}

/* Пояснення */
#explanation {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #f5e6c6;
  line-height: 1.4;
  max-width: 600px;
  text-align: center;
}

/* Фінальний екран */
.finish-content h2 {
  font-size: 1.6rem;
  color: #ffd27f;
  margin: 0;
}

.finish-content p {
  font-size: 1rem;
  line-height: 1.4;
  color: #f5e6c6;
  margin: 0.5rem 0 1rem;
  text-align: center;
}

.finish-content p strong {
  color: #ffd27f;
  font-weight: 700;
}

.finish-content .cta-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  align-items: center;
}

.finish-content .cta-buttons a {
  padding: 0.7rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 0.5rem;
  color: #1e1e1e;
  background: linear-gradient(90deg, #f7c84d 0%, #a47c4a 100%);
  text-decoration: none;
  display: inline-block;
  transition: transform 0.1s ease;
  width: 100%;
  max-width: 300px;
  text-align: center;
}

.finish-content .cta-buttons a:hover {
  transform: scale(1.05);
}

/* Загальний прогрес-бар */
.general-progress {
  width: 100%;
  max-width: 400px;
  margin: 0.5rem 0 1rem;
}

.general-progress-bar {
  width: 100%;
  height: 0.5rem;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 0.4rem;
  overflow: hidden;
}

.general-progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f7c84d 0%, #a47c4a 100%);
  border-radius: 0.4rem;
  transition: width 0.3s ease;
}

.general-progress-text {
  margin-top: 0.3rem;
  font-size: 0.9rem;
  color: #f5e6c6;
  text-align: center;
}

/* Адаптація для мобільних пристроїв */
@media (max-width: 600px) {
  .start-content,
  .finish-content {
    padding: 1.5rem 1rem;
  }
  #word-area {
    font-size: 1.8rem;
    min-height: 70px;
  }
  .scoreboard {
    flex-direction: column;
    align-items: center;
  }
  .scoreboard > * {
    margin-top: 0.4rem;
  }
  .tries {
    font-size: 1.3rem;
  }
  #choices-container {
    gap: 0.5rem;
  }
  .choice-btn {
    min-width: 56px;
  }
}