/* Game specific styles for Word Search */

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.back-btn {
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.3s ease;
}

.back-btn:hover {
  transform: translateX(-5px);
  color: var(--primary);
}

.game-container {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  margin-bottom: 3rem;
  position: relative;
}

.game-info {
  background-color: var(--surface);
  padding: 2rem;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.stats {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem;
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.1);
}

.stat-item i {
  font-size: 1.2rem;
  color: var(--primary);
}

.settings {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings h3 {
  margin-bottom: 0.5rem;
}

.category-buttons,
.difficulty-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.category-btn,
.difficulty-btn {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: none;
  padding: 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  display: flex;
  align-items: center;
}

.category-btn::before,
.difficulty-btn::before {
  content: '';
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  margin-right: 0.8rem;
  transition: all 0.3s ease;
}

.category-btn.active,
.difficulty-btn.active {
  background-color: rgba(127, 90, 240, 0.2);
}

.category-btn.active::before,
.difficulty-btn.active::before {
  background-color: var(--primary);
  border-color: var(--primary);
}

.hint-container {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 1rem;
  border-radius: 10px;
  max-height: 250px;
  overflow-y: auto;
}

.hint-container h3 {
  margin-bottom: 1rem;
}

#word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.word-item {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  user-select: none;
}

.word-item.found {
  background-color: var(--secondary);
  text-decoration: line-through;
  opacity: 0.7;
}

.action-btn {
  background-color: var(--accent);
  color: var(--text);
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 30px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: auto;
}

.action-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(255, 137, 6, 0.4);
}

.gameplay-area {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.puzzle-container {
  background-color: var(--surface);
  border-radius: 15px;
  padding: 1rem;
  position: relative;
  width: 100%;
  max-width: min(80vh, 500px); /* Limit max width based on viewport height */
  margin: 0 auto;
}

/* Create perfect square container using aspect-ratio */
.puzzle-container::before {
  content: '';
  display: block;
  padding-top: 100%; /* 1:1 aspect ratio */
}

#puzzle-grid {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 2px;
}

.puzzle-cell {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  user-select: none;
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.puzzle-cell:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.puzzle-cell.selected {
  background-color: var(--primary);
  color: white;
}

.puzzle-cell.found {
  background-color: var(--secondary);
  color: white;
}

#selection-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#message-container {
  text-align: center;
  font-size: 1.2rem;
  font-weight: bold;
  min-height: 2rem;
  color: var(--secondary);
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(22, 22, 26, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(3px);
}

.overlay-content {
  text-align: center;
  padding: 2rem;
  background-color: var(--surface);
  border-radius: 15px;
  max-width: 90%;
  width: 400px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.overlay-content h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

#new-best {
  color: var(--secondary);
  font-weight: bold;
  display: none;
}

/* Grid sizes based on difficulty */
.grid-easy {
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  font-size: clamp(1rem, 3vw, 1.5rem);
}

.grid-medium {
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(12, 1fr);
  font-size: clamp(0.8rem, 2.5vw, 1.2rem);
  gap: 1px;
}

.grid-hard {
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  font-size: clamp(0.7rem, 2vw, 1rem);
  gap: 1px;
}

#selection-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Media Queries */
@media (max-width: 768px) {
  .game-container {
    grid-template-columns: 1fr;
  }
  
  .game-info {
    order: 2;
  }
  
  .gameplay-area {
    order: 1;
  }
  
  .puzzle-cell {
    font-size: 0.9rem;
  }
}

/* Animations */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes highlight {
  0% {
    background-color: var(--primary);
  }
  100% {
    background-color: var(--secondary);
  }
}

.word-found {
  animation: highlight 0.5s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.overlay.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}