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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 32px 20px 20px;
}

#app {
  width: 100%;
  max-width: 600px;
}

.container {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  padding: 30px;
}

h1 {
  text-align: center;
  color: #333;
  margin-bottom: 10px;
  font-size: 2em;
}

.input-section {
  display: grid;
  gap: 20px;
  margin-bottom: 30px;
}

.input-group {
  display: flex;
  flex-direction: column;
}

label {
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  font-size: 0.95em;
}

input[type='text'] {
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 1em;
  text-transform: uppercase;
  transition: border-color 0.3s;
}

input[type='text']:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input[type='text']::placeholder {
  color: #999;
}

.letter-boxes {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.letter-box {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border-color: #6aaa64;
  background: #eef9ed;
  text-align: center;
  text-transform: uppercase;
  font-size: 1.45em;
  font-weight: 700;
  line-height: 1;
}

.letter-box:focus {
  border-color: #4f8f49;
  box-shadow: 0 0 0 3px rgba(106, 170, 100, 0.18);
}

.misplaced-box {
  width: 100%;
  min-height: 44px;
  padding: 8px 6px;
  border-color: #d6b23f;
  background: #fff8dc;
  text-align: center;
  text-transform: uppercase;
  font-size: clamp(0.85rem, 2.6vw, 1rem);
  font-weight: 700;
  line-height: 1;
}

.misplaced-box:focus {
  border-color: #c79a11;
  box-shadow: 0 0 0 3px rgba(199, 154, 17, 0.16);
}

.button-group {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
}

button {
  flex: 1;
  padding: 12px 20px;
  font-size: 1em;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-search {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-search:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

.btn-clear {
  background: #f0f0f0;
  color: #333;
}

.btn-clear:hover {
  background: #e0e0e0;
}

.results-section {
  margin-top: 20px;
}

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

.results-title {
  font-size: 1.1em;
  font-weight: 600;
  color: #333;
}

.results-count {
  background: #667eea;
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.9em;
  font-weight: 600;
}

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

.word-item {
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  font-weight: 600;
  font-size: 1.1em;
  cursor: pointer;
  transition: all 0.2s;
  color: #333;
}

.word-item:hover {
  border-color: #667eea;
  background: #f0f3ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.no-results {
  text-align: center;
  padding: 40px 20px;
  color: #999;
}

.loading {
  text-align: center;
  padding: 20px;
  color: #667eea;
  font-weight: 600;
}

.error {
  background: #fee;
  border: 1px solid #fcc;
  color: #c33;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.info-box {
  background: #f0f3ff;
  border-left: 4px solid #667eea;
  padding: 12px;
  border-radius: 4px;
  font-size: 0.9em;
  color: #555;
  margin-top: 20px;
}

@media (max-width: 480px) {
  body {
    padding-top: 20px;
  }

  .container {
    padding: 20px;
  }

  h1 {
    font-size: 1.5em;
  }

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

  .word-item {
    padding: 10px;
    font-size: 1em;
  }

  .misplaced-box {
    min-height: 40px;
    padding-inline: 4px;
  }
}
