:root {
  /* Основные цвета */
  --bg-primary: #F7F5F2;
  --bg-secondary: #EDE8E2;
  --bg-dark: #2D3436;
  
  /* Игровые цвета (смягчённые) */
  --green-correct: #7CB587;
  --green-light: #C8E6C9;
  
  --yellow-present: #E8C547;
  --yellow-light: #FFF3CD;
  
  --gray-absent: #9E9E9E;
  --gray-light: #E0E0E0;
  
  /* Акценты */
  --accent-purple: #9C88FF;
  --accent-coral: #FF8A80;
  
  /* Текст */
  --text-primary: #2D3436;
  --text-secondary: #636E72;
  --text-light: #B2BEC3;
  
  /* Размеры */
  --cell-size: 56px;
  --cell-height: 72px;
  --border-radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  outline: none;
}

button:focus-visible {
  outline: 2px solid var(--accent-purple);
  outline-offset: 2px;
}

.wordle-helper {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.app-header h1 {
  font-size: 24px;
  font-weight: 700;
}

.instructions {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: var(--border-radius);
  margin-bottom: 28px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: var(--shadow);
}

.instructions summary {
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-primary);
}

.instructions summary::-webkit-details-marker {
  display: none;
}

.instructions summary::after {
  content: '▾';
  color: var(--text-secondary);
  transition: transform 0.2s ease;
  margin-left: 12px;
}

.instructions[open] summary::after {
  transform: rotate(180deg);
}

.instructions-content {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.25s ease, opacity 0.2s ease;
}

.instructions[open] .instructions-content {
  grid-template-rows: 1fr;
  opacity: 1;
}

.instructions-content > * {
  overflow: hidden;
}

.instructions-list {
  padding-left: 20px;
  margin: 12px 0;
  color: var(--text-secondary);
}

.instructions-list li {
  margin-bottom: 8px;
}

.instructions-list li:last-child {
  margin-bottom: 0;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.legend-absent {
  background: var(--gray-absent);
}

.legend-present {
  background: var(--yellow-present);
}

.legend-correct {
  background: var(--green-correct);
}

.instructions summary:focus-visible {
  outline: 2px solid var(--accent-purple);
  outline-offset: 4px;
  border-radius: 6px;
}

.instructions[open] summary {
  margin-bottom: 4px;
}

.reset-btn {
  background: var(--accent-coral);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}

.reset-btn:hover {
  background: #E57373;
}

.letter-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-width: 350px;
  margin: 0 auto 24px;
}

.letter-cell {
  width: var(--cell-size);
  height: var(--cell-height);
  border-radius: var(--border-radius);
  background: var(--bg-secondary);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'SF Mono', 'JetBrains Mono', 'Consolas', monospace;
  font-size: 32px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  position: relative;
}

.letter-cell.empty {
  background: var(--gray-light);
  cursor: default;
}

.letter-cell:not(.empty) {
  cursor: pointer;
}

.letter-cell:not(.empty):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.letter-cell:not(.empty):active {
  transform: translateY(0);
}

.letter-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.letter-cell.empty {
  background: var(--gray-light);
}

.letter-cell.correct {
  background: var(--green-correct);
  color: white;
}

.letter-cell.present {
  background: var(--yellow-present);
  color: white;
}

.letter-cell.absent {
  background: var(--gray-absent);
  color: white;
}

.letter-cell.selected {
  outline: 3px solid var(--accent-purple);
  outline-offset: 2px;
}

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

.letter-cell.changing-state {
  animation: stateChange 0.3s ease;
}

.letter-cell .mini-indicators {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 2px;
}

.mini-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-purple);
  opacity: 0.8;
}

.history {
  margin-bottom: 32px;
}

.attempt {
  display: grid;
  grid-template-columns: repeat(5, var(--cell-size));
  gap: 8px;
  margin-bottom: 16px;
  max-width: 350px;
  margin-left: auto;
  margin-right: auto;
}

.attempt .letter-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  font-size: 24px;
}

.controls {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}

.btn {
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--accent-purple);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #7C73FF;
  transform: translateY(-1px);
}

.btn:disabled {
  background: var(--gray-light);
  color: var(--text-light);
  cursor: not-allowed;
}

.position-picker-container {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: var(--border-radius);
  margin-bottom: 32px;
}

.position-picker-container h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.position-chips {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.position-chip {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--gray-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.position-chip:hover {
  background: #D5D5D5;
}

.position-chip.selected {
  background: var(--accent-coral);
  color: white;
}

.position-chip.current-position {
  background: var(--accent-purple);
  color: white;
  cursor: not-allowed;
}

.results {
  margin-bottom: 32px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.results h2 {
  font-size: 18px;
}

.word-count {
  background: var(--accent-purple);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

.word-list {
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 16px;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.word-item {
  background: white;
  padding: 8px 12px;
  border-radius: 8px;
  text-align: center;
  font-family: 'SF Mono', 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.word-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
}

.keyboard {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 16px 8px;
  margin-top: auto;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 8px;
}

.keyboard-row:last-child {
  margin-bottom: 0;
}

.key {
  height: 48px;
  padding: 0 6px;
  border-radius: 8px;
  background: white;
  font-size: 16px;
  font-weight: 600;
  min-width: 0;
  flex: 1 1 0;
  transition: all 0.15s ease;
}

.key:hover {
  background: #F5F5F5;
  transform: translateY(-1px);
}

.key:active {
  transform: translateY(0);
}

.key-wide {
  flex: 1.6 1 0;
  min-width: 0;
  padding: 0 10px;
}

.key-enter {
  background: var(--green-correct);
  color: white;
}

.key-enter:hover {
  background: #6FA87A;
}

.key.correct {
  background: var(--green-correct);
  color: white;
}

.key.present {
  background: var(--yellow-present);
  color: white;
}

.key.absent {
  background: var(--gray-absent);
  color: white;
}

#backspace {
  background: var(--gray-absent);
  color: white;
}

#backspace:hover {
  background: #8E8E8E;
}

/* Responsive */
@media (max-width: 480px) {
  :root {
    --cell-size: 48px;
    --cell-height: 64px;
  }
  
  .wordle-helper {
    padding: 16px 12px 32px;
  }
  
  .app-header h1 {
    font-size: 20px;
  }
  
  .letter-cell {
    font-size: 28px;
  }
  
  .key {
    height: 44px;
    min-width: 0;
    font-size: 14px;
    padding: 0 6px;
  }
  
  .key-wide {
    min-width: 0;
  }

  .keyboard-row {
    gap: 2px;
  }
  
  .word-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  }
  
  .word-item {
    font-size: 13px;
    padding: 6px 10px;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.attempt {
  animation: fadeIn 0.3s ease;
}

.word-item {
  animation: fadeIn 0.2s ease;
}

/* Scrollbar styling */
.word-list::-webkit-scrollbar {
  width: 6px;
}

.word-list::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 3px;
}

.word-list::-webkit-scrollbar-thumb {
  background: var(--gray-absent);
  border-radius: 3px;
}

.word-list::-webkit-scrollbar-thumb:hover {
  background: #757575;
}
