/* Word Search - Daily Word Hunt Game Styles */

/* Override body background */
body.wordsearch-page {
  background: #ffffff !important;
}

body.wordsearch-page::before {
  display: none !important;
}

/* Hide SEO content visually but keep for search engines */
.seo-content,
.seo-expansion,
footer {
  display: none !important;
}

/* Container */
.wordsearch-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

/* Category Header */
.category-header {
  text-align: center;
  margin-bottom: 0.75rem;
}

.category-label {
  display: block;
  font-size: 0.8rem;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.category-name {
  font-size: 1.5rem;
  font-weight: 800;
  color: #0891b2;
  margin: 0;
}

/* Game Stats Bar */
.game-stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
}

.stat-found {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.stat-timer {
  font-variant-numeric: tabular-nums;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  background: #f1f5f9;
  padding: 0.3rem 0.75rem;
  border-radius: 8px;
  font-size: 1.05rem;
  min-width: 60px;
  text-align: center;
}

/* Game Layout */
.game-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  justify-content: center;
}

/* Grid Wrapper - contains canvas overlay and grid */
.grid-wrapper {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

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

/* Word Grid */
.word-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.grid-cell {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
  z-index: 1;
  border-radius: 4px;
}

.grid-cell:hover {
  background: rgba(8, 145, 178, 0.08);
}

.grid-cell.selecting {
  background: rgba(8, 145, 178, 0.15);
  color: #0891b2;
}

/* Found word cell highlights - cycle through palette */
.grid-cell.found-0 { background: rgba(8, 145, 178, 0.2); color: #0e7490; }
.grid-cell.found-1 { background: rgba(168, 85, 247, 0.2); color: #7c3aed; }
.grid-cell.found-2 { background: rgba(16, 185, 129, 0.2); color: #059669; }
.grid-cell.found-3 { background: rgba(245, 158, 11, 0.2); color: #d97706; }
.grid-cell.found-4 { background: rgba(239, 68, 68, 0.2); color: #dc2626; }
.grid-cell.found-5 { background: rgba(59, 130, 246, 0.2); color: #2563eb; }
.grid-cell.found-6 { background: rgba(236, 72, 153, 0.2); color: #db2777; }
.grid-cell.found-7 { background: rgba(34, 197, 94, 0.2); color: #16a34a; }
.grid-cell.found-8 { background: rgba(249, 115, 22, 0.2); color: #ea580c; }
.grid-cell.found-9 { background: rgba(99, 102, 241, 0.2); color: #4f46e5; }
.grid-cell.found-10 { background: rgba(20, 184, 166, 0.2); color: #0d9488; }
.grid-cell.found-11 { background: rgba(217, 70, 239, 0.2); color: #c026d3; }

/* Word List */
.word-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 140px;
  padding: 0.5rem 0;
}

.word-list-item {
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
}

.word-list-item.found {
  color: #94a3b8;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.word-list-item.found::before {
  content: '\2713';
  position: absolute;
  left: -0.2rem;
  color: #10b981;
  font-weight: 800;
  font-size: 0.9rem;
}

/* Selection line on canvas - handled in JS */

/* Completion Overlay */
.completion-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
}

.completion-box {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdfa 100%);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.4s ease;
}

.completion-emoji {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 0.6s ease;
}

.completion-title {
  font-size: 2rem;
  font-weight: 800;
  color: #1a1a1a;
  margin-bottom: 0.5rem;
}

.completion-subtitle {
  font-size: 1.1rem;
  color: #52525b;
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.completion-time {
  font-size: 1.8rem;
  font-weight: 800;
  color: #0891b2;
  margin-bottom: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.completion-rating {
  font-size: 1rem;
  color: #71717a;
  margin-bottom: 1.5rem;
}

.completion-share-btn {
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.3);
  margin-bottom: 0.75rem;
}

.completion-share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(8, 145, 178, 0.4);
}

.completion-close-btn {
  background: none;
  border: 2px solid #d1d5db;
  border-radius: 12px;
  padding: 0.75rem 2rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease;
}

.completion-close-btn:hover {
  border-color: #9ca3af;
  color: #374151;
}

/* Rules Modal */
.rules-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  animation: fadeIn 0.2s ease;
}

.rules-content {
  background: white;
  border-radius: 16px;
  max-width: 440px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  padding: 2rem;
}

.rules-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 2rem;
  color: #666;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
}

.rules-close:hover {
  color: #333;
}

.rules-header h2 {
  margin: 0 0 0.5rem 0;
  color: #1a1a1a;
  font-size: 1.5rem;
}

.rules-subtitle {
  color: #666;
  margin: 0 0 1.5rem 0;
}

.rules-body p {
  color: #333;
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.rules-body ul {
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}

.rules-body li {
  color: #333;
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.rules-direction-demo {
  display: grid;
  grid-template-columns: repeat(4, 28px);
  gap: 2px;
  justify-content: center;
  margin: 1rem 0;
}

.rules-demo-cell {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 4px;
  background: #f1f5f9;
  color: #64748b;
}

.rules-demo-cell.highlight {
  background: rgba(8, 145, 178, 0.2);
  color: #0891b2;
  font-weight: 800;
}

.rules-play-btn {
  display: block;
  width: 100%;
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0.9rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 1rem;
  transition: all 0.2s ease;
}

.rules-play-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.3);
}

/* Toast Popup */
.toast-popup {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  z-index: 10001;
  animation: popIn 0.3s ease, fadeOut 0.5s ease 1.5s forwards;
}

/* Confetti canvas */
#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

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

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

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-20px); }
  60% { transform: translateY(-10px); }
}

@keyframes popIn {
  0% { transform: translateX(-50%) scale(0.8); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes wordFound {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.grid-cell.just-found {
  animation: wordFound 0.4s ease;
}

/* Responsive - Tablet */
@media (max-width: 768px) {
  .wordsearch-container {
    padding: 0.25rem 0.5rem;
  }

  .game-layout {
    flex-direction: column;
    align-items: center;
  }

  .grid-cell {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }

  .word-list {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 0.75rem;
    min-width: auto;
    width: 100%;
    padding: 0.75rem 0;
  }

  .word-list-item {
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
  }

  .word-list-item.found::before {
    left: -0.15rem;
    font-size: 0.8rem;
  }

  .category-name {
    font-size: 1.3rem;
  }
}

/* Responsive - Mobile */
@media (max-width: 500px) {
  .grid-cell {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  .game-stats {
    gap: 1rem;
    font-size: 0.9rem;
  }

  .stat-timer {
    font-size: 0.9rem;
    padding: 0.2rem 0.6rem;
  }

  .word-list-item {
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
  }

  .completion-box {
    padding: 2rem 1.5rem;
    max-width: 95%;
  }

  .completion-emoji {
    font-size: 3rem;
  }

  .completion-title {
    font-size: 1.6rem;
  }

  .completion-time {
    font-size: 1.4rem;
  }
}

/* Extra small screens */
@media (max-width: 380px) {
  .grid-cell {
    width: 25px;
    height: 25px;
    font-size: 0.72rem;
  }

  .word-list-item {
    font-size: 0.75rem;
  }

  .game-stats {
    gap: 0.5rem;
    font-size: 0.85rem;
  }
}
