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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height - fixes Chrome mobile */
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.container {
  max-width: 600px;
  width: 100%;
}

h1 {
  color: white;
  text-align: center;
  margin-bottom: 10px;
  font-size: 1.8rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  margin-bottom: 20px;
  font-size: 0.95rem;
}

/* Category Selector */
.category-selector {
  background: white;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.category-selector label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
}

.category-selector select {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.3s;
}

.category-selector select:focus {
  outline: none;
  border-color: #667eea;
}

/* Remembered Words List */
.remembered-list {
  margin-top: 12px;
  border-top: 1px solid #e0e0e0;
  padding-top: 12px;
}

.remembered-list-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: #555;
  padding: 4px 0;
  width: 100%;
  text-align: left;
}

.remembered-list-toggle:hover {
  color: #667eea;
}

.toggle-icon {
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.remembered-list.expanded .toggle-icon {
  transform: rotate(90deg);
}

.remembered-list-content {
  display: none;
  margin-top: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.remembered-list.expanded .remembered-list-content {
  display: block;
}

.remembered-list-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.remembered-list-content li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  background: #f5f5f5;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

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

.remembered-list-content .word-text {
  flex: 1;
}

.remembered-list-content .word-japanese {
  font-weight: 600;
  color: #333;
}

.remembered-list-content .word-vietnamese {
  color: #666;
  font-size: 0.85rem;
}

.remembered-list-content .unmark-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: #999;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s;
}

.remembered-list-content .unmark-btn:hover {
  background: #e74c3c;
  color: white;
}

.remembered-list-empty {
  color: #999;
  font-style: italic;
  font-size: 0.85rem;
  padding: 8px 0;
}

/* Audio Options */
.audio-options {
  background: white;
  border-radius: 12px;
  padding: 12px 15px;
  margin-bottom: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  color: #333;
  margin-bottom: 8px;
}

.checkbox-label:last-of-type {
  margin-bottom: 0;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #667eea;
}

.reset-btn {
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid #e74c3c;
  border-radius: 8px;
  background: transparent;
  color: #e74c3c;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.reset-btn:hover {
  background: #e74c3c;
  color: white;
}

/* Flash Card */
.flashcard-container {
  perspective: 1000px;
  margin-bottom: 20px;
}

.flashcard {
  width: 100%;
  height: 300px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
}

.flashcard-front {
  background: linear-gradient(145deg, #ffffff 0%, #f5f5f5 100%);
}

.flashcard-back {
  background: linear-gradient(145deg, #4facfe 0%, #00f2fe 100%);
  transform: rotateY(180deg);
}

.japanese {
  font-size: 2.5rem;
  font-weight: bold;
  color: #333;
  margin-bottom: 15px;
  text-align: center;
}

.romaji {
  font-size: 1.3rem;
  color: #666;
  font-style: italic;
  text-align: center;
}

.vietnamese {
  font-size: 1.8rem;
  font-weight: bold;
  color: white;
  text-align: center;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.hint {
  position: absolute;
  bottom: 20px;
  font-size: 0.85rem;
  color: #999;
}

.flashcard-back .hint {
  color: rgba(255, 255, 255, 0.8);
}

/* Speak Button */
.speak-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(145deg, #667eea, #764ba2);
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  z-index: 10;
}

.speak-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.speak-btn:active {
  transform: scale(0.95);
}

.speak-btn.speaking {
  animation: pulse 0.5s ease infinite;
}

.speak-btn-back {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.speak-btn-back:hover {
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Mark Remembered Button */
.mark-btn {
  position: absolute;
  top: 15px;
  left: 15px;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffd700, #ffaa00);
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(255, 170, 0, 0.4);
  z-index: 10;
}

.mark-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(255, 170, 0, 0.6);
}

.mark-btn:active {
  transform: scale(0.95);
}

.mark-btn.remembered {
  background: linear-gradient(145deg, #4CAF50, #45a049);
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.mark-btn-back {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.mark-btn-back:hover {
  background: rgba(255, 255, 255, 0.5);
}

.mark-btn-back.remembered {
  background: rgba(76, 175, 80, 0.6);
}

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

/* Controls */
.controls {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 30px;
  border: none;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-prev,
.btn-next {
  background: white;
  color: #667eea;
  width: 100px;
  height: 50px;
  font-size: 1.5rem;
  justify-content: center;
}

.btn-prev:hover,
.btn-next:hover {
  background: #f0f0f0;
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.btn-shuffle {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid white;
  padding: 12px 16px;
  width: 50px;
  justify-content: center;
}

.btn-shuffle:hover {
  background: white;
  color: #667eea;
}

.btn-auto {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid white;
  padding: 12px 16px;
  width: 50px;
  justify-content: center;
}

.btn-auto:hover {
  background: white;
  color: #667eea;
}

.btn-auto.active {
  background: #4CAF50;
  border-color: #4CAF50;
  color: white;
}

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

/* Progress */
.progress-container {
  background: white;
  border-radius: 12px;
  padding: 15px 20px;
  margin-bottom: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.progress-text {
  text-align: center;
  margin-bottom: 10px;
  font-weight: 600;
  color: #333;
}

.progress-bar {
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Mode Toggle */
.mode-toggle {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.mode-btn {
  padding: 8px 20px;
  border: 2px solid white;
  border-radius: 20px;
  background: transparent;
  color: white;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s;
}

.mode-btn.active {
  background: white;
  color: #667eea;
}

.mode-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.2);
}

/* Keyboard shortcuts info */
.shortcuts {
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  margin-top: 20px;
}

.shortcuts kbd {
  background: rgba(255, 255, 255, 0.2);
  padding: 3px 8px;
  border-radius: 4px;
  margin: 0 3px;
}

/* Animation for card change */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.flashcard.animate {
  animation: slideIn 0.3s ease;
}

/* Responsive */
@media (max-width: 500px) {
  h1 {
    font-size: 1.4rem;
  }
  
  .flashcard {
    height: 250px;
  }
  
  .japanese {
    font-size: 2rem;
  }
  
  .romaji {
    font-size: 1.1rem;
  }
  
  .vietnamese {
    font-size: 1.4rem;
  }
  
  .controls {
    gap: 8px;
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }
  
  .btn-auto,
  .btn-shuffle {
    padding: 10px 14px;
  }
  
  .shortcuts {
    display: none;
  }
}

/* Footer */
.footer {
  text-align: center;
  margin-top: 20px;
  padding-top: 15px;
}

.footer a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}

.footer a:hover {
  color: white;
  text-decoration: underline;
}
