/* Guess the word game specific styles */

/* Layout */
.guess_the_word-section {
  padding: 2rem 0 1rem;
}

.guess_the_word-layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 2.5rem;
  align-items: start;
  margin-top: 1rem;
}

/* Balloon scene */
.guess_the_word-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.balloon-scene {
  position: relative;
  width: 100%;
  max-width: 320px;
  height: 420px;
  background: linear-gradient(180deg, #dbeafe 0%, #eff6ff 100%);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

[data-theme="dark"] .balloon-scene {
  background: linear-gradient(180deg, #1e3a5f 0%, #1f2937 100%);
  border-color: #374151;
}

/* Clouds */
.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  filter: blur(1px);
  animation: cloudFloat 8s ease-in-out infinite;
}

[data-theme="dark"] .cloud {
  background: rgba(255, 255, 255, 0.15);
}

.cloud-1 {
  width: 60px;
  height: 30px;
  top: 40px;
  left: 20px;
  animation-delay: 0s;
}

.cloud-2 {
  width: 80px;
  height: 35px;
  top: 80px;
  right: 30px;
  animation-delay: -2s;
}

.cloud-3 {
  width: 50px;
  height: 25px;
  bottom: 60px;
  left: 50px;
  animation-delay: -4s;
}

@keyframes cloudFloat {

  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(15px);
  }
}

/* ============================================================
   BALLOON
   The whole balloon + string is wrapped into .balloon-wrap.
   Stages 0..6 move .balloon-wrap up by 28px per wrong letter.
   "lost" flies the wrap fully out of the scene.
   "won"  moves the wrap to the center of the scene.
   ============================================================ */

.balloon-wrap {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.5s ease;
  z-index: 2;
  will-change: transform, opacity;
}

.balloon-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: top center;
  animation: balloonFloat 3s ease-in-out infinite;
}

.balloon {
  position: relative;
  width: 80px;
  height: 100px;
  background: radial-gradient(circle at 35% 30%, #f87171, #dc2626 60%, #b91c1c);
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  box-shadow: 0 10px 30px rgba(220, 38, 38, 0.3);
  animation: balloonFloat 3s ease-in-out infinite;
}

.balloon-highlight {
  position: absolute;
  top: 15%;
  left: 20%;
  width: 20px;
  height: 30px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  transform: rotate(-20deg);
}

.balloon-knot {
  position: absolute;
  bottom: -8px;
  left: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  background: #b91c1c;
  border-radius: 0 0 4px 4px;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

/* The string always goes from the balloon down to the ground */
.balloon-string {
  width: 2px;
  background: #6b7280;
  height: 60px;
  margin-top: -2px;
  transition: height 0.5s ease, opacity 0.5s ease;
  border-radius: 1px;
}

/* Stage-based rise */
.balloon-scene[data-stage="0"] .balloon-wrap {
  transform: translateX(-50%) translateY(0);
}

.balloon-scene[data-stage="1"] .balloon-wrap {
  transform: translateX(-50%) translateY(-28px);
}

.balloon-scene[data-stage="2"] .balloon-wrap {
  transform: translateX(-50%) translateY(-56px);
}

.balloon-scene[data-stage="3"] .balloon-wrap {
  transform: translateX(-50%) translateY(-84px);
}

.balloon-scene[data-stage="4"] .balloon-wrap {
  transform: translateX(-50%) translateY(-112px);
}

.balloon-scene[data-stage="5"] .balloon-wrap {
  transform: translateX(-50%) translateY(-140px);
}

.balloon-scene[data-stage="6"] .balloon-wrap {
  transform: translateX(-50%) translateY(-168px);
}

/* String shortens slightly as the balloon rises */
.balloon-scene[data-stage="0"] .balloon-string {
  height: 60px;
}

.balloon-scene[data-stage="1"] .balloon-string {
  height: 52px;
}

.balloon-scene[data-stage="2"] .balloon-string {
  height: 46px;
}

.balloon-scene[data-stage="3"] .balloon-string {
  height: 40px;
}

.balloon-scene[data-stage="4"] .balloon-string {
  height: 34px;
}

.balloon-scene[data-stage="5"] .balloon-string {
  height: 28px;
}

.balloon-scene[data-stage="6"] .balloon-string {
  height: 22px;
}

/* Lose: balloon + string fly up and out of the scene */
.balloon-scene[data-stage="lost"] .balloon-wrap {
  transform: translateX(-50%) translateY(-560px) rotate(20deg) scale(0.6);
  opacity: 0;
  transition: transform 1.2s cubic-bezier(0.4, 0, 0.7, 1),
    opacity 1s ease-in 0.3s;
}

.balloon-scene[data-stage="lost"] .balloon-string {
  height: 0;
  opacity: 0;
  transition: height 1.2s cubic-bezier(0.4, 0, 0.7, 1),
    opacity 1s ease-in 0.3s;
}

.balloon-scene[data-stage="lost"] .balloon {
  animation: none;
}

/* Win: balloon moves to the center of the scene and celebrates */
.balloon-scene[data-stage="won"] .balloon-wrap {
  transform: translateX(-50%) translateY(-140px) scale(1.15);
}

.balloon-scene[data-stage="won"] .balloon-body {
  animation: balloonCelebrate 0.6s ease-in-out 3;
}

.balloon-scene[data-stage="won"] .balloon-string {
  height: 30px;
}

.balloon-scene[data-stage="won"] .balloon {
  animation: balloonCelebrate 0.6s ease-in-out 3;
}

@keyframes balloonFloat {

  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }

  50% {
    transform: translateY(-6px) rotate(1deg);
  }
}

@keyframes balloonCelebrate {

  0%,
  100% {
    transform: rotate(0deg);
  }

  25% {
    transform: rotate(-8deg);
  }

  75% {
    transform: rotate(8deg);
  }
}

/* Life hearts */
.guess_the_word-life {
  display: flex;
  gap: 0.4rem;
  font-size: 1.4rem;
}

.life-heart {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.life-heart.lost {
  opacity: 0.2;
  transform: scale(0.8);
  filter: grayscale(1);
}

/* Stats */
.guess_the_word-stats {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.guess_the_word-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-secondary);
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  min-width: 80px;
}

.guess_the_word-stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.guess_the_word-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-color);
}

/* Category */
.guess_the_word-category {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 1rem;
  color: var(--text-secondary);
}

.category-value {
  font-weight: 600;
  color: var(--primary-color);
}

/* Word display */
.guess_the_word-word {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0;
  min-height: 3.5rem;
}

.guess_the_word-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 3rem;
  border-bottom: 3px solid var(--border-color);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  transition: all 0.3s ease;
  text-transform: uppercase;
}

.guess_the_word-letter.revealed {
  border-bottom-color: var(--primary-color);
  animation: letterReveal 0.4s ease;
}

.guess_the_word-letter.space {
  border-bottom-color: transparent;
  width: 1rem;
}

@keyframes letterReveal {
  0% {
    transform: scale(0.5) rotateY(90deg);
    opacity: 0;
  }

  100% {
    transform: scale(1) rotateY(0);
    opacity: 1;
  }
}

/* Hint */
.guess_the_word-hint {
  text-align: center;
  min-height: 1.5rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-style: italic;
}

/* Keyboard */
.guess_the_word-keyboard {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.guess_the_word-key {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  text-transform: uppercase;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

.guess_the_word-key:hover:not(:disabled) {
  background: var(--primary-color);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.guess_the_word-key:active:not(:disabled) {
  transform: translateY(0);
}

.guess_the_word-key:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.guess_the_word-key.correct {
  background: var(--success-color);
  color: white;
  border-color: var(--success-color);
  opacity: 1;
}

.guess_the_word-key.wrong {
  background: var(--error-color);
  color: white;
  border-color: var(--error-color);
  opacity: 1;
}

/* Feedback */
.guess_the_word-feedback {
  text-align: center;
  min-height: 1.5rem;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.guess_the_word-feedback.success {
  color: var(--success-color);
}

.guess_the_word-feedback.error {
  color: var(--error-color);
}

.guess_the_word-feedback.info {
  color: var(--primary-color);
}

/* Actions */
.guess_the_word-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.guess_the_word-actions .btn {
  flex: 1;
  min-width: 120px;
  justify-content: center;
}

/* Info section */
.guess_the_word-info {
  padding: 3rem 0;
}

/* Responsive */
@media (max-width: 900px) {
  .guess_the_word-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .guess_the_word-visual {
    order: -1;
  }

  .balloon-scene {
    max-width: 260px;
    height: 360px;
  }

  .balloon {
    width: 65px;
    height: 82px;
  }
}

@media (max-width: 600px) {
  .guess_the_word-keyboard {
    grid-template-columns: repeat(7, 1fr);
    gap: 0.3rem;
  }

  .guess_the_word-key {
    font-size: 0.85rem;
  }

  .guess_the_word-letter {
    width: 1.8rem;
    height: 2.4rem;
    font-size: 1.2rem;
  }

  .guess_the_word-actions {
    flex-direction: column;
  }

  .guess_the_word-actions .btn {
    width: 100%;
  }

  .guess_the_word-stat {
    min-width: 65px;
    padding: 0.5rem 0.8rem;
  }

  .guess_the_word-stat-value {
    font-size: 1.15rem;
  }
}

@media (max-width: 380px) {
  .guess_the_word-keyboard {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

  .balloon,
  .cloud,
  .guess_the_word-letter.revealed,
  .life-heart {
    animation: none !important;
    transition: none !important;
  }
}