/* Connections - Daily Word Grouping Game Styles */

/* Override body background for clean white look */
body.connections-page {
  background: #ffffff !important;
}

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

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

.connections-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 0.5rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 80px);
}

/* Solved Categories Area */
.solved-categories {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
  min-height: 0;
}

.solved-row {
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  animation: solvedReveal 0.5s ease;
}

.solved-row.difficulty-0 { background: #f9df6d; color: #1a1a1a; }
.solved-row.difficulty-1 { background: #a0c35a; color: #1a1a1a; }
.solved-row.difficulty-2 { background: #b0c4ef; color: #1a1a1a; }
.solved-row.difficulty-3 { background: #ba81c5; color: #1a1a1a; }

.solved-category-name {
  font-weight: 800;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.solved-category-words {
  font-size: 0.9rem;
  font-weight: 500;
}

@keyframes solvedReveal {
  0% {
    opacity: 0;
    transform: scaleY(0);
  }
  100% {
    opacity: 1;
    transform: scaleY(1);
  }
}

/* Word Grid */
.word-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 1rem;
}

.word-tile {
  background: #efefe6;
  border: none;
  border-radius: 12px;
  padding: 1rem 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #1a1a1a;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  text-align: center;
  word-break: break-word;
  line-height: 1.2;
  user-select: none;
  touch-action: manipulation;
  position: relative;
}

.word-tile:hover {
  background: #e0e0d6;
  transform: scale(1.02);
}

.word-tile:active {
  transform: scale(0.97);
}

.word-tile.selected {
  background: #5a594e;
  color: #ffffff;
}

.word-tile.selected:hover {
  background: #4a493e;
}

.word-tile.shake {
  animation: tileShake 0.5s ease;
}

.word-tile.bounce-out {
  animation: tileBounceOut 0.4s ease forwards;
}

@keyframes tileShake {
  0%, 100% { transform: translateX(0); }
  15%, 45%, 75% { transform: translateX(-6px); }
  30%, 60%, 90% { transform: translateX(6px); }
}

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

/* Mistakes Indicator */
.mistakes-area {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  color: #555;
}

.mistakes-label {
  font-weight: 500;
  margin-right: 0.5rem;
}

.mistake-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #5a594e;
  margin: 0 3px;
  transition: all 0.3s ease;
  vertical-align: middle;
}

.mistake-dot.used {
  background: #d1d1c7;
  transform: scale(0.8);
}

/* Game Controls */
.game-controls {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.game-btn {
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid #1a1a1a;
  background: #ffffff;
  color: #1a1a1a;
  touch-action: manipulation;
}

.game-btn:hover {
  background: #f0f0f0;
  transform: translateY(-1px);
}

.game-btn:active {
  transform: translateY(0);
}

.game-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.game-btn.submit-btn {
  background: #1a1a1a;
  color: #ffffff;
}

.game-btn.submit-btn:hover {
  background: #333;
}

.game-btn.submit-btn:disabled {
  background: #1a1a1a;
  opacity: 0.4;
}

/* Game Over Message */
.game-result {
  text-align: center;
  padding: 1.5rem;
  animation: fadeIn 0.5s ease;
}

.game-result h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: #1a1a1a;
}

.game-result p {
  color: #555;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.result-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 1rem auto;
  max-width: 200px;
}

.result-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.result-square {
  width: 40px;
  height: 40px;
  border-radius: 6px;
}

.result-square.d0 { background: #f9df6d; }
.result-square.d1 { background: #a0c35a; }
.result-square.d2 { background: #b0c4ef; }
.result-square.d3 { background: #ba81c5; }

.share-results-btn {
  display: inline-block;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 0.8rem 2rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 1rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.share-results-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* 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;
}

.rules-content {
  background: white;
  border-radius: 12px;
  max-width: 480px;
  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;
}

.example-colors {
  display: flex;
  gap: 8px;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.color-example {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
}

.color-example.d0 { background: #f9df6d; }
.color-example.d1 { background: #a0c35a; }
.color-example.d2 { background: #b0c4ef; }
.color-example.d3 { background: #ba81c5; }

/* 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%, #f8fafc 100%);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  max-width: 400px;
  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: 2rem;
  line-height: 1.5;
}

.completion-subtitle strong {
  color: #10b981;
}

.completion-share-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 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(16, 185, 129, 0.3);
}

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

/* One Away popup */
.one-away-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: 100;
  animation: popIn 0.3s ease, fadeOut 0.5s ease 1.5s forwards;
}

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

@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); }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .connections-container {
    padding: 0.25rem;
    min-height: calc(100vh - 60px);
  }

  .word-grid {
    gap: 6px;
  }

  .word-tile {
    padding: 0.75rem 0.25rem;
    font-size: 0.8rem;
    min-height: 56px;
    border-radius: 8px;
  }

  .game-controls {
    gap: 0.5rem;
  }

  .game-btn {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }

  .solved-row {
    padding: 0.75rem;
  }

  .solved-category-name {
    font-size: 0.85rem;
  }

  .solved-category-words {
    font-size: 0.8rem;
  }

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

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

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

@media (max-width: 380px) {
  .word-tile {
    padding: 0.6rem 0.15rem;
    font-size: 0.7rem;
    min-height: 48px;
  }

  .game-controls {
    flex-wrap: wrap;
  }
}
