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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background: linear-gradient(to bottom right, #0f172a, #1e1b4b, #0f172a);
  min-height: 100vh;
  color: #e2e8f0;
  padding: 20px;
  position: relative;
  overflow-x: hidden;
}

/* Animated Background Stars */
.stars {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.stars::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  background-image: 
    radial-gradient(2px 2px at 20% 30%, #ffffff, transparent),
    radial-gradient(2px 2px at 40% 70%, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 60% 10%, #ffffff, transparent),
    radial-gradient(1px 1px at 80% 50%, rgba(255,255,255,0.6), transparent),
    radial-gradient(2px 2px at 10% 80%, #ffffff, transparent);
  background-repeat: repeat;
  background-size: 1000px 1000px;
  animation: sparkle 20s linear infinite;
}

@keyframes sparkle {
  from { transform: translateX(0); }
  to { transform: translateX(-1000px); }
}

/* Container */
.container {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 40px;
  animation: fadeInUp 0.6s ease-out;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  margin-bottom: 30px;
}

.back-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  transform: translateX(-4px);
}

.title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  background: linear-gradient(to right, #10b981, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.icon {
  font-size: clamp(2rem, 5vw, 2.5rem);
  filter: drop-shadow(0 0 20px rgba(16, 185, 129, 0.3));
}

.subtitle {
  color: #94a3b8;
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* Search Section */
.search-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 30px;
  animation: fadeInUp 0.6s ease-out 0.2s both;
}

.search-box {
  display: flex;
  gap: 12px;
  background: rgba(30, 41, 59, 0.5);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 16px;
  padding: 8px;
  transition: all 0.3s ease;
}

.search-box:focus-within {
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

#search {
  flex: 1;
  background: transparent;
  border: none;
  color: #e2e8f0;
  font-size: 16px;
  padding: 12px 16px;
  outline: none;
}

#search::placeholder {
  color: #64748b;
}

.search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.search-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
}

.random-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #06b6d4;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.random-btn:hover {
  background: rgba(6, 182, 212, 0.2);
  transform: translateY(-2px);
}

/* Result Card */
.result-card {
  background: rgba(30, 41, 59, 0.5);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 20px;
  padding: 32px;
  margin-bottom: 30px;
  min-height: 300px;
  animation: fadeInUp 0.6s ease-out 0.4s both;
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 236px;
  color: #64748b;
  text-align: center;
}

.placeholder svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.placeholder p {
  font-size: 1.1rem;
}

.word-header {
  border-bottom: 2px solid rgba(16, 185, 129, 0.2);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.word-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: #10b981;
  margin-bottom: 8px;
}

.phonetic {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #94a3b8;
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.play-audio {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  transition: all 0.3s ease;
}

.play-audio:hover {
  background: rgba(16, 185, 129, 0.2);
  transform: scale(1.05);
}

.meaning-section {
  margin-bottom: 24px;
}

.part-of-speech {
  display: inline-block;
  background: rgba(6, 182, 212, 0.1);
  color: #06b6d4;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.definition {
  background: rgba(15, 23, 42, 0.5);
  border-left: 3px solid #10b981;
  padding: 16px;
  margin-bottom: 12px;
  border-radius: 8px;
  line-height: 1.6;
}

.definition::before {
  content: '🔹';
  margin-right: 8px;
}

.example {
  background: rgba(139, 92, 246, 0.1);
  border-left: 3px solid #8b5cf6;
  padding: 12px;
  margin: 8px 0 12px 20px;
  border-radius: 6px;
  font-style: italic;
  color: #c4b5fd;
}

.example::before {
  content: '✏️';
  margin-right: 8px;
}

.copy-btn {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 8px;
  transition: all 0.3s ease;
}

.copy-btn:hover {
  background: rgba(16, 185, 129, 0.2);
}

.error-message {
  color: #f87171;
  text-align: center;
  padding: 20px;
  font-size: 1.1rem;
}

/* History Section */
.history-section {
  background: rgba(30, 41, 59, 0.5);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 20px;
  padding: 24px;
  animation: fadeInUp 0.6s ease-out 0.6s both;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.history-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e2e8f0;
  font-size: 1.3rem;
  font-weight: 700;
}

.clear-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.clear-btn:hover {
  background: rgba(239, 68, 68, 0.2);
}

.history-list {
  list-style: none;
  display: grid;
  gap: 10px;
}

.history-list li {
  background: rgba(15, 23, 42, 0.5);
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.history-list li:hover {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  transform: translateX(4px);
}

/* Footer */
footer {
  text-align: center;
  padding: 30px 20px;
  color: #64748b;
  font-size: 0.9rem;
  position: relative;
  z-index: 1;
}

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

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 16px;
  }

  .title {
    font-size: 2rem;
  }

  .search-box {
    flex-direction: column;
  }

  .search-btn {
    width: 100%;
    justify-content: center;
  }

  .result-card {
    padding: 20px;
  }

  .word-title {
    font-size: 2rem;
  }

  .history-header {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .clear-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.8);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, #10b981, #06b6d4);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(to bottom, #059669, #0891b2);
}
