/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #6366f1;
  --secondary: #7c3aed;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-light: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #334155;
  --gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-lg: 20px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

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

input, select {
  font-family: inherit;
  font-size: 16px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  font-size: 14px;
  max-width: 90vw;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }

/* ===== Auth Pages ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.auth-card {
  background: rgba(30, 41, 59, 0.9);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  font-size: 56px;
  margin-bottom: 12px;
}

.auth-header h1 {
  font-size: 28px;
  margin-bottom: 4px;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.auth-switch a {
  color: var(--primary-light);
  text-decoration: none;
  font-weight: 500;
}

.auth-switch a:hover { text-decoration: underline; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--gradient);
  color: white;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover { box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4); }

.btn-secondary {
  background: var(--bg-card-light);
  color: var(--text-primary);
}

.btn-secondary:hover { background: var(--border); }

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-block { width: 100%; }
.btn-large { padding: 14px 28px; font-size: 16px; }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
}

.btn-icon:hover { background: var(--bg-card-light); }

/* ===== App Layout ===== */
.app-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 768px;
  margin: 0 auto;
  background: var(--bg-dark);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo { font-size: 32px; }
.app-title { font-size: 18px; font-weight: 700; }
.app-subtitle { font-size: 12px; color: var(--text-muted); }

.app-header-stats {
  display: flex;
  gap: 12px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-icon { font-size: 16px; }

/* ===== Navigation ===== */
.app-nav {
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4px;
  gap: 2px;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 8px;
  color: var(--text-muted);
  transition: all 0.2s;
  font-size: 12px;
}

.nav-btn .nav-icon { font-size: 20px; }

.nav-btn:hover { background: var(--bg-card-light); color: var(--text-secondary); }

.nav-btn.active {
  background: var(--gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

@media (min-width: 600px) {
  .nav-btn { flex-direction: row; gap: 6px; font-size: 14px; }
}

/* ===== Content Sections ===== */
.app-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  padding-bottom: 80px;
}

.content-section { display: none; animation: fadeIn 0.3s ease; }
.content-section.active { display: block; }

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

.section-header {
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 24px;
  margin-bottom: 4px;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

.level-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

.level-picker select {
  padding: 8px 12px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.section-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin-top: 12px;
}

.accent-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.accent-buttons {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.accent-btn {
  padding: 6px 14px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.accent-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card-light);
}

.accent-btn.active {
  background: var(--gradient);
  color: white;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

.accent-toggle {
  cursor: pointer;
  user-select: none;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.accent-toggle:hover {
  background: var(--bg-card-light);
}

.accent-toggle:active {
  transform: scale(0.95);
}

.phonetic-accent {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary);
  color: white;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.5px;
}

/* ===== Word Card ===== */
.word-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.word-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--text-muted);
}

.progress-text {
  background: var(--bg-card-light);
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 500;
}

.word-display {
  text-align: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.word-text {
  font-size: 42px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
  word-break: break-word;
}

.word-phonetic {
  color: var(--text-muted);
  font-size: 18px;
  margin-bottom: 20px;
  font-family: "Lucida Sans Unicode", Arial, sans-serif;
}

.word-audio-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-audio {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--bg-card-light);
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-audio:hover { background: var(--primary); color: white; }
.btn-audio .audio-icon { font-size: 18px; }

.replay-count {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 18px;
}

.word-actions {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.word-answer {
  padding-top: 20px;
  border-top: 1px solid var(--border);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 1000px; }
}

.answer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pos-badge {
  background: var(--primary);
  color: white;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

.definition {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.explanation {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.examples-section h4 {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.examples {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.example-item {
  background: var(--bg-dark);
  padding: 12px 16px;
  border-radius: 10px;
  border-left: 3px solid var(--primary);
}

.example-en { color: var(--text-primary); font-size: 15px; font-weight: 500; }
.example-zh { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.action-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.action-buttons .btn { flex: 1; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon { font-size: 80px; margin-bottom: 16px; }

.empty-state h2 { margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); margin-bottom: 20px; }

/* ===== Search ===== */
.search-box {
  margin-bottom: 20px;
}

.search-input {
  width: 100%;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 28px;
  color: var(--text-primary);
  font-size: 15px;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hint {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 14px;
}

.search-result-item, .wrong-item {
  background: var(--bg-card);
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.result-header, .wrong-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.result-header h3, .wrong-header h3 {
  font-size: 20px;
  color: var(--text-primary);
}

.phonetic-small {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: normal;
  margin-left: 6px;
  font-family: "Lucida Sans Unicode", Arial, sans-serif;
}

.wrong-actions { display: flex; gap: 4px; }

.result-pos {
  color: var(--text-primary);
  font-size: 15px;
  margin-bottom: 6px;
}

.result-explanation {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 12px;
  line-height: 1.5;
}

.result-examples {
  background: var(--bg-dark);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
}

.result-examples p { margin-bottom: 6px; }
.result-examples p:last-child { margin-bottom: 0; }
.result-examples strong { color: var(--text-primary); }
.result-examples em { color: var(--text-muted); font-style: normal; font-size: 13px; }

/* ===== Wrong List ===== */
.wrong-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== Game ===== */
.game-levels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 600px) {
  .game-levels { grid-template-columns: repeat(3, 1fr); }
}

.game-level-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  transition: transform 0.2s;
}

.game-level-card:hover { transform: translateY(-2px); }

.game-level-card h3 {
  font-size: 22px;
  margin-bottom: 4px;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-level-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.stars {
  font-size: 24px;
  margin-bottom: 8px;
  letter-spacing: 4px;
}

.level-status {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.game-play {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
}

.game-header {
  margin-bottom: 24px;
  text-align: center;
}

.game-progress {
  background: var(--bg-card-light);
  padding: 6px 16px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
}

.game-question { text-align: center; margin-bottom: 24px; }

.game-word {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 8px;
}

.game-phonetic {
  color: var(--text-muted);
  font-size: 18px;
  margin-bottom: 16px;
  font-family: "Lucida Sans Unicode", Arial, sans-serif;
}

.game-prompt {
  color: var(--text-secondary);
  font-size: 14px;
}

.game-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.game-option {
  padding: 14px 18px;
  background: var(--bg-card-light);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  text-align: left;
  font-size: 15px;
  transition: all 0.2s;
  line-height: 1.4;
}

.game-option:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--bg-dark);
}

.game-option.correct {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.game-option.wrong {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.game-option:disabled { cursor: not-allowed; }

.game-feedback {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  min-height: 24px;
}

.game-feedback.correct { color: var(--success); }
.game-feedback.wrong { color: var(--danger); }

.game-result {
  text-align: center;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  border: 1px solid var(--border);
}

.game-result h2 {
  font-size: 28px;
  margin-bottom: 16px;
}

.result-stars {
  font-size: 48px;
  letter-spacing: 8px;
  margin-bottom: 16px;
}

.result-text {
  color: var(--text-secondary);
  font-size: 18px;
  margin-bottom: 24px;
}

.result-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== Profile ===== */
.profile-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  border: 1px solid var(--border);
}

.profile-avatar {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  background: var(--gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.profile-card h2 {
  font-size: 24px;
  margin-bottom: 24px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (min-width: 480px) {
  .profile-stats { grid-template-columns: repeat(4, 1fr); }
}

.profile-stat {
  background: var(--bg-dark);
  padding: 16px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.stat-label {
  color: var(--text-muted);
  font-size: 12px;
}

.profile-progress {
  margin-bottom: 24px;
  text-align: left;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.progress-bar-bg {
  height: 12px;
  background: var(--bg-dark);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 6px;
  transition: width 0.5s ease;
  min-width: 0;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ===== Mobile Small Screens ===== */
@media (max-width: 380px) {
  .word-text { font-size: 32px; }
  .game-word { font-size: 36px; }
  .app-header { padding: 12px 16px; }
  .app-content { padding: 16px; }
  .word-card { padding: 18px; }
}
