/* Word Scramble game specific styles */

/* Layout */
.word_scramble-section {
  padding: 2rem 0 1rem;
}

.word_scramble-layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 2.5rem;
  align-items: start;
  margin-top: 1rem;
}

/* Visual / Hint panel */
.word_scramble-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.scramble-scene {
  position: relative;
  width: 100%;
  max-width: 320px;
  height: 420px;
  background: linear-gradient(180deg, #ede9fe 0%, #f5f3ff 100%);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

[data-theme="dark"] .scramble-scene {
  background: linear-gradient(180deg, #2e1065 0%, #1f2937 100%);
  border-color: #374151;
}

.scramble-icon {
  font-size: 5rem;
  animation: scrambleFloat 3s ease-in-out infinite;
  z-index: 1;
}

.scramble-letters-preview {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 1rem;
  z-index: 1;
}

.scramble-preview-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.6rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
  animation: tilePop 0.3s ease backwards;
}

.scramble-preview-tile:nth-child(1) {
  animation-delay: 0.05s;
}

.scramble-preview-tile:nth-child(2) {
  animation-delay: 0.1s;
}

.scramble-preview-tile:nth-child(3) {
  animation-delay: 0.15s;
}

.scramble-preview-tile:nth-child(4) {
  animation-delay: 0.2s;
}

.scramble-preview-tile:nth-child(5) {
  animation-delay: 0.25s;
}

.scramble-preview-tile:nth-child(6) {
  animation-delay: 0.3s;
}

.scramble-preview-tile:nth-child(7) {
  animation-delay: 0.35s;
}

.scramble-preview-tile:nth-child(8) {
  animation-delay: 0.4s;
}

.scramble-preview-tile:nth-child(9) {
  animation-delay: 0.45s;
}

.scramble-preview-tile:nth-child(10) {
  animation-delay: 0.5s;
}

@keyframes tilePop {
  0% {
    transform: scale(0.5) rotate(-10deg);
    opacity: 0;
  }

  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

@keyframes scrambleFloat {

  0%,
  100% {
    transform: translateY(0) rotate(-5deg);
  }

  50% {
    transform: translateY(-10px) rotate(5deg);
  }
}

/* Sparkles */
.scramble-sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.sparkle {
  position: absolute;
  font-size: 1.2rem;
  opacity: 0.5;
  animation: sparkleFloat 4s ease-in-out infinite;
}

.sparkle.s1 {
  top: 15%;
  left: 15%;
  animation-delay: 0s;
}

.sparkle.s2 {
  top: 25%;
  right: 15%;
  animation-delay: -1s;
}

.sparkle.s3 {
  bottom: 25%;
  left: 20%;
  animation-delay: -2s;
}

.sparkle.s4 {
  bottom: 15%;
  right: 20%;
  animation-delay: -3s;
}

@keyframes sparkleFloat {

  0%,
  100% {
    transform: translateY(0) scale(1);
    opacity: 0.3;
  }

  50% {
    transform: translateY(-12px) scale(1.3);
    opacity: 0.8;
  }
}

/* Life hearts */
.word_scramble-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 */
.word_scramble-stats {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.word_scramble-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;
}

.word_scramble-stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.word_scramble-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-color);
}

/* Category */
.word_scramble-category {
  text-align: center;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  color: var(--text-secondary);
}

.category-value {
  font-weight: 600;
  color: var(--primary-color);
}

/* Timer */
.word_scramble-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  transition: color 0.3s ease;
}

.word_scramble-timer.warning {
  color: var(--warning-color);
  animation: timerPulse 1s ease-in-out infinite;
}

.word_scramble-timer.danger {
  color: var(--error-color);
  animation: timerPulse 0.5s ease-in-out infinite;
}

@keyframes timerPulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }
}

/* Scrambled tiles */
.word_scramble-tiles {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0;
  min-height: 3.5rem;
}

.word_scramble-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.8rem;
  height: 3.2rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.4rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  position: relative;
}

.word_scramble-tile:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.05);
  box-shadow: var(--shadow-lg);
}

.word_scramble-tile:active:not(:disabled) {
  transform: translateY(0) scale(0.95);
}

.word_scramble-tile:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.word_scramble-tile.used {
  opacity: 0.2;
  pointer-events: none;
}

.word_scramble-tile.correct {
  background: var(--success-color);
  animation: tileCorrect 0.4s ease;
}

.word_scramble-tile.wrong {
  background: var(--error-color);
  animation: tileWrong 0.4s ease;
}

@keyframes tileCorrect {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes tileWrong {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

/* Answer slots */
.word_scramble-answer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
  min-height: 3.5rem;
}

.word_scramble-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.8rem;
  height: 3.2rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  transition: all 0.2s ease;
  background: var(--bg-secondary);
}

.word_scramble-slot.filled {
  border-style: solid;
  border-color: var(--primary-color);
  background: var(--bg-primary);
  animation: slotFill 0.3s ease;
}

.word_scramble-slot.correct {
  border-color: var(--success-color);
  background: rgba(16, 185, 129, 0.1);
}

.word_scramble-slot.wrong {
  border-color: var(--error-color);
  background: rgba(239, 68, 68, 0.1);
  animation: tileWrong 0.4s ease;
}

@keyframes slotFill {
  0% {
    transform: scale(0.8);
    opacity: 0.5;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Hint */
.word_scramble-hint {
  text-align: center;
  min-height: 1.5rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-style: italic;
}

/* Feedback */
.word_scramble-feedback {
  text-align: center;
  min-height: 1.5rem;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.word_scramble-feedback.success {
  color: var(--success-color);
}

.word_scramble-feedback.error {
  color: var(--error-color);
}

.word_scramble-feedback.info {
  color: var(--primary-color);
}

/* Actions */
.word_scramble-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.word_scramble-actions .btn {
  flex: 1;
  min-width: 120px;
  justify-content: center;
}

/* Info section */
.word_scramble-info {
  padding: 3rem 0;
}

.word_scramble-slot.filled {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.word_scramble-slot.filled:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.word_scramble-slot.filled:active {
  transform: scale(0.95);
}

/* Responsive */
@media (max-width: 900px) {
  .word_scramble-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .word_scramble-visual {
    order: -1;
  }

  .scramble-scene {
    max-width: 260px;
    height: 320px;
  }

  .scramble-icon {
    font-size: 3.5rem;
  }

  .scramble-preview-tile {
    width: 1.8rem;
    height: 2.2rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 600px) {

  .word_scramble-tile,
  .word_scramble-slot {
    width: 2.2rem;
    height: 2.6rem;
    font-size: 1.1rem;
  }

  .word_scramble-actions {
    flex-direction: column;
  }

  .word_scramble-actions .btn {
    width: 100%;
  }

  .word_scramble-stat {
    min-width: 65px;
    padding: 0.5rem 0.8rem;
  }

  .word_scramble-stat-value {
    font-size: 1.15rem;
  }

  .word_scramble-timer {
    font-size: 1rem;
  }
}

@media (max-width: 380px) {

  .word_scramble-tile,
  .word_scramble-slot {
    width: 1.9rem;
    height: 2.3rem;
    font-size: 0.95rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

  .scramble-icon,
  .sparkle,
  .scramble-preview-tile,
  .word_scramble-tile,
  .word_scramble-slot,
  .life-heart,
  .word_scramble-timer {
    animation: none !important;
    transition: none !important;
  }
}