/* ============================================================================
   WORDLE GAME STYLES
   All selectors scoped to #wordle-game
   Prefix: .wg- for all class names
   ============================================================================ */

#wordle-game {
  width: 100%;
  font-family: var(--font-body);
}

#wordle-game * {
  box-sizing: border-box;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

#wordle-game.wg-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.wg-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--clr-border);
  border-top-color: var(--clr-accent);
  border-radius: 50%;
  animation: wg-spin 0.8s linear infinite;
}

@keyframes wg-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================================
   SCREEN WRAPPER
   ============================================================================ */

.wg-screen {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 200px;
}

.wg-screen h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--clr-text);
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.wg-screen p {
  color: var(--clr-text-muted);
  margin-bottom: var(--space-md);
  line-height: 1.6;
}

/* ============================================================================
   SETUP SCREEN
   ============================================================================ */

.wg-setup {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-lg);
  padding: var(--space-xl);
}

.wg-setup h2 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}

.wg-setup p {
  max-width: 400px;
  font-size: 1.125rem;
}

.wg-start-btn {
  padding: var(--space-md) var(--space-xl);
  font-size: 1rem;
  min-height: 50px;
}

/* ============================================================================
   PLAYING SCREEN
   ============================================================================ */

.wg-playing {
  gap: var(--space-xl);
  padding: var(--space-md) 0;
}

/* Stats Bar */
.wg-stats {
  display: flex;
  justify-content: space-around;
  gap: var(--space-lg);
  padding: var(--space-md);
  background: var(--clr-surface-2);
  border-radius: var(--border-radius);
  margin-bottom: var(--space-md);
}

.wg-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
}

.wg-stat-label {
  font-size: 0.75rem;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wg-stat-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--clr-accent);
}

/* Guesses Grid */
.wg-guesses {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.wg-guess {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-xs);
}

.wg-tile {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 4vw, 1.5rem);
  font-weight: 700;
  color: var(--clr-text);
  border: 2px solid var(--clr-border);
  border-radius: var(--border-radius);
  background: var(--clr-surface-2);
  text-transform: uppercase;
  transition: all var(--transition);
  min-height: 50px;
}

.wg-tile--empty {
  background: var(--clr-surface);
  border-color: var(--clr-border);
}

.wg-tile--correct {
  background: #10b981;
  border-color: #059669;
  box-shadow: var(--glow-cyan);
  color: white;
}

.wg-tile--present {
  background: #f59e0b;
  border-color: #d97706;
  color: white;
}

.wg-tile--absent {
  background: var(--clr-text-dim);
  border-color: var(--clr-border);
  color: var(--clr-text-muted);
  opacity: 0.6;
}

/* Keyboard */
.wg-keyboard {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  padding: 0 var(--space-sm);
  max-width: 100%;
}

.wg-keyboard-row {
  display: flex;
  justify-content: center;
  gap: var(--space-xs);
  flex-wrap: nowrap;
  width: 100%;
}

/* Ensure all rows have proportional width */
.wg-keyboard-row:first-child {
  /* QWERTY - 10 keys */
}

.wg-keyboard-row:nth-child(2) {
  /* ASDFGH - 9 keys */
  padding: 0 calc(1 * ((100% / 10) / 2));
}

.wg-keyboard-row:nth-child(3) {
  /* ZXCVBNM - 7 keys */
  padding: 0 calc(1.5 * ((100% / 10) / 2));
}

.wg-key {
  flex: 1;
  min-width: 28px;
  max-width: 40px;
  min-height: 40px;
  padding: var(--space-xs) 4px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--clr-text);
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wg-key:hover:not(.wg-key--eliminated) {
  background: var(--clr-accent);
  border-color: var(--clr-accent);
  color: var(--clr-bg);
  box-shadow: var(--glow-cyan);
}

.wg-key:active:not(.wg-key--eliminated) {
  transform: scale(0.95);
}

.wg-key--available {
  cursor: pointer;
}

.wg-key--correct {
  background: #10b981;
  border-color: #059669;
  color: white;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
  font-weight: 700;
}

.wg-key--present {
  background: #f59e0b;
  border-color: #d97706;
  color: white;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
  font-weight: 700;
}

.wg-key--eliminated {
  background: var(--clr-text-dim);
  border-color: var(--clr-border);
  color: var(--clr-text-muted);
  opacity: 0.5;
  cursor: not-allowed;
}

/* Input Area */
.wg-input-area {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.wg-input {
  flex: 1;
  padding: var(--space-md);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--clr-text);
  background: var(--clr-surface-2);
  border: 2px solid var(--clr-border);
  border-radius: var(--border-radius);
  text-transform: uppercase;
  letter-spacing: 2px;
  min-height: 50px;
  transition: all var(--transition);
}

.wg-input:focus {
  outline: none;
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.1);
  background: var(--clr-surface);
}

.wg-input::placeholder {
  color: var(--clr-text-dim);
}

.wg-submit {
  padding: var(--space-md) var(--space-lg);
  min-height: 50px;
  min-width: 100px;
  font-weight: 600;
  text-transform: uppercase;
}

.wg-hint {
  font-size: 0.875rem;
  color: var(--clr-text-muted);
  text-align: center;
}

.wg-error {
  display: none;
  font-size: 0.875rem;
  color: var(--clr-accent-2);
  text-align: center;
  margin-top: var(--space-sm);
  animation: wg-fade-in 0.2s ease-out;
}

@keyframes wg-fade-in {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes wg-shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  75% {
    transform: translateX(8px);
  }
}

/* ============================================================================
   RESULT SCREEN
   ============================================================================ */

.wg-result {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-xl);
  gap: var(--space-lg);
  min-height: 400px;
}

.wg-result-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  max-width: 500px;
  padding: var(--space-xl);
  border-radius: var(--border-radius-lg);
  border: 2px solid var(--clr-border);
}

.wg-result--won {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(0, 229, 255, 0.1) 100%);
  border-color: #10b981;
}

.wg-result--lost {
  background: linear-gradient(135deg, rgba(255, 61, 107, 0.1) 0%, rgba(255, 61, 107, 0.05) 100%);
  border-color: var(--clr-accent-2);
}

.wg-result-content h2 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
}

.wg-result-word {
  font-size: 1.25rem;
  color: var(--clr-accent);
  padding: var(--space-md);
  background: var(--clr-surface-2);
  border-radius: var(--border-radius);
  width: 100%;
}

.wg-result-word strong {
  font-family: var(--font-display);
  color: var(--clr-accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.wg-play-again {
  padding: var(--space-md) var(--space-xl);
  min-height: 50px;
  min-width: 150px;
  font-weight: 600;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

/* Mobile (default) */
@media (max-width: 480px) {
  .wg-tile {
    min-height: 40px;
  }

  .wg-key {
    flex: 1;
    min-width: 20px;
    max-width: 35px;
    min-height: 36px;
    padding: 4px 2px;
    font-size: 0.65rem;
  }

  .wg-setup {
    padding: var(--space-lg);
  }

  .wg-result {
    padding: var(--space-lg);
    min-height: 300px;
  }

  .wg-result-content {
    padding: var(--space-lg);
  }
}

/* Small devices */
@media (min-width: 480px) and (max-width: 640px) {
  .wg-key {
    flex: 1;
    min-width: 28px;
    max-width: 38px;
    min-height: 38px;
    padding: 4px 3px;
    font-size: 0.7rem;
  }
}

/* Tablet and up */
@media (min-width: 641px) and (max-width: 900px) {
  .wg-tile {
    min-height: 60px;
  }

  .wg-key {
    flex: 1;
    min-width: 32px;
    max-width: 45px;
    min-height: 42px;
    padding: 6px 4px;
    font-size: 0.8rem;
  }

  .wg-input {
    font-size: 1.5rem;
  }

  .wg-playing {
    padding: var(--space-xl) 0;
  }
}

/* Desktop */
@media (min-width: 901px) {
  .wg-tile {
    min-height: 70px;
  }

  .wg-key {
    flex: 1;
    min-width: 36px;
    max-width: 50px;
    min-height: 46px;
    padding: 8px 6px;
    font-size: 0.85rem;
  }

  .wg-playing {
    padding: var(--space-2xl) 0;
  }

  .wg-keyboard {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

.wg-key:focus,
.wg-input:focus,
.wg-submit:focus {
  outline: 2px solid var(--clr-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  #wordle-game * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}