:root {
  --primary: #6c5ce7;
  --primary-light: #a29bfe;
  --primary-dark: #4a3db5;
  --secondary: #00b894;
  --secondary-light: #55efc4;
  --accent: #fdcb6e;
  --accent-bright: #f9ca24;
  --danger: #e17055;
  --danger-light: #fab1a0;
  --bg: #f8f7ff;
  --bg-card: #ffffff;
  --text: #2d3436;
  --text-light: #636e72;
  --text-white: #ffffff;
  --shadow: 0 4px 15px rgba(108, 92, 231, 0.15);
  --shadow-lg: 0 8px 30px rgba(108, 92, 231, 0.2);
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(108, 92, 231, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(0, 184, 148, 0.05) 0%, transparent 50%);
}

#app {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
}

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

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.8); }
  70% { transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 5px rgba(0, 184, 148, 0.3); }
  50% { box-shadow: 0 0 20px rgba(0, 184, 148, 0.6); }
}

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

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

@keyframes confettiFall {
  0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

@keyframes levelUp {
  0% { transform: scale(1); }
  25% { transform: scale(1.2) rotate(-5deg); }
  50% { transform: scale(1.3) rotate(5deg); }
  75% { transform: scale(1.2) rotate(-3deg); }
  100% { transform: scale(1); }
}

.animate-in {
  animation: fadeInUp 0.4s ease-out both;
}

.animate-pop {
  animation: popIn 0.4s ease-out both;
}

.animate-bounce {
  animation: bounce 0.5s ease-out;
}

.animate-shake {
  animation: shake 0.4s ease-out;
}

.animate-glow {
  animation: glow 1s ease-in-out 2;
}

.animate-star {
  animation: starPulse 0.3s ease-out;
}

.animate-level-up {
  animation: levelUp 0.6s ease-out;
}

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

.header h1 {
  font-size: 2rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.header .subtitle {
  color: var(--text-light);
  font-size: 1rem;
}

/* Mascot */
.mascot {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  animation: fadeInUp 0.5s ease-out 0.1s both;
}

.mascot-emoji {
  font-size: 2.2rem;
  flex-shrink: 0;
}

.mascot-text {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
}

/* Level Badge */
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  color: var(--text);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(253, 203, 110, 0.4);
}

/* Stats Row */
.stats-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  animation: fadeInUp 0.5s ease-out 0.15s both;
}

.stat-card {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-card .stat-icon {
  font-size: 1.3rem;
  margin-bottom: 2px;
}

.stat-card .stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 0.7rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Daily Goal */
.daily-goal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  animation: fadeInUp 0.5s ease-out 0.2s both;
}

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

.daily-goal-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.daily-goal-count {
  font-size: 0.8rem;
  color: var(--text-light);
  font-weight: 500;
}

.progress-bar-outer {
  background: #e9e5ff;
  border-radius: 10px;
  height: 12px;
  overflow: hidden;
}

.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 10px;
  transition: width 0.5s ease-out;
  min-width: 0;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

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

.btn:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--text-white);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary), #00a381);
  color: var(--text-white);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  color: var(--text);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary-light);
}

.btn-outline:hover {
  background: var(--primary);
  color: var(--text-white);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #d63031);
  color: var(--text-white);
}

.btn-small {
  padding: 10px 16px;
  font-size: 0.9rem;
}

.btn + .btn {
  margin-top: 10px;
}

/* Menu buttons */
.menu-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}

.menu-btn .menu-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.menu-btn .menu-label {
  display: flex;
  flex-direction: column;
}

.menu-btn .menu-label span:first-child {
  font-size: 1.05rem;
}

.menu-btn .menu-label span:last-child {
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.8;
  margin-top: 2px;
}

/* Game HUD */
.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  gap: 8px;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: 0.9rem;
}

.hud-item .hud-icon {
  font-size: 1.1rem;
}

/* Timer */
.timer-bar {
  width: 100%;
  height: 6px;
  background: #e9e5ff;
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.timer-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--danger), var(--accent));
  border-radius: 3px;
  transition: width 0.5s linear;
}

.timer-bar-inner.warning {
  background: var(--danger);
}

/* Question Progress Bar */
.question-progress {
  width: 100%;
  height: 8px;
  background: #e9e5ff;
  border-radius: 4px;
  margin-bottom: 16px;
  overflow: hidden;
}

.question-progress-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 4px;
  transition: width 0.4s ease-out;
}

/* Question Card */
.question-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  text-align: center;
}

.question-type-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.question-text {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 4px;
}

.question-highlight {
  color: var(--primary);
  font-style: italic;
}

/* Input area */
.answer-input-area {
  margin-bottom: 16px;
}

.answer-input {
  width: 100%;
  padding: 16px 20px;
  border: 3px solid var(--primary-light);
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  font-family: var(--font);
  text-align: center;
  transition: all var(--transition);
  background: var(--bg-card);
  color: var(--text);
}

.answer-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.15);
}

.answer-input.correct {
  border-color: var(--secondary);
  background: #e6fff8;
}

.answer-input.wrong {
  border-color: var(--danger);
  background: #fff0ed;
}

/* Multiple Choice */
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.choice-btn {
  padding: 16px 12px;
  border: 3px solid var(--primary-light);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  color: var(--text);
  text-align: center;
  word-break: break-word;
}

.choice-btn:hover {
  border-color: var(--primary);
  background: #f0eeff;
  transform: translateY(-1px);
}

.choice-btn:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.choice-btn.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--text-white);
}

.choice-btn.correct {
  border-color: var(--secondary);
  background: var(--secondary);
  color: var(--text-white);
  pointer-events: none;
}

.choice-btn.wrong {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--text-white);
  pointer-events: none;
}

.choice-btn.dimmed {
  opacity: 0.5;
  pointer-events: none;
}

/* Feedback */
.feedback-area {
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  text-align: center;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.5;
}

.feedback-area.correct {
  background: linear-gradient(135deg, #e6fff8, #d4fceb);
  color: #00855a;
  border: 2px solid var(--secondary-light);
}

.feedback-area.wrong {
  background: linear-gradient(135deg, #fff0ed, #ffe0db);
  color: #b33a23;
  border: 2px solid var(--danger-light);
}

.feedback-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
  display: block;
}

.feedback-detail {
  font-weight: 400;
  font-size: 0.9rem;
  margin-top: 4px;
  opacity: 0.9;
}

/* Summary Screen */
.summary-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  text-align: center;
  margin-bottom: 20px;
}

.summary-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.summary-message {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 20px;
}

.summary-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.summary-stat {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
}

.summary-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.summary-stat-label {
  font-size: 0.75rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.summary-stars-earned {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent-bright);
  margin-bottom: 8px;
}

.summary-extras {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 16px;
  line-height: 1.6;
}

/* Progress Screen */
.progress-section {
  margin-bottom: 20px;
}

.progress-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.progress-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: var(--shadow);
  text-align: center;
}

.progress-item-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
}

.progress-item-label {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 2px;
}

/* Session history */
.session-list {
  list-style: none;
}

.session-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.session-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-mode {
  font-weight: 600;
  font-size: 0.9rem;
}

.session-date {
  font-size: 0.75rem;
  color: var(--text-light);
}

.session-score {
  font-weight: 700;
  color: var(--primary);
  font-size: 1rem;
}

.session-accuracy {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* Word lists */
.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-tag {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.word-tag.weak {
  background: #fff0ed;
  color: var(--danger);
  border: 1px solid var(--danger-light);
}

.word-tag.strong {
  background: #e6fff8;
  color: var(--secondary);
  border: 1px solid var(--secondary-light);
}

/* Settings */
.settings-section {
  margin-top: 20px;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #eee;
}

.toggle-label {
  font-size: 0.95rem;
  font-weight: 500;
}

.toggle-switch {
  position: relative;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 28px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--secondary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

.toggle-switch input:focus-visible + .toggle-slider {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* Confirm dialog */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeInUp 0.2s ease-out;
}

.confirm-dialog {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.3s ease-out;
}

.confirm-dialog h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.confirm-dialog p {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 20px;
}

.confirm-buttons {
  display: flex;
  gap: 10px;
}

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

/* Level up notification */
.level-up-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  color: var(--text);
  padding: 16px 28px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: popIn 0.4s ease-out, fadeInUp 0.4s ease-out reverse forwards 2.5s;
  text-align: center;
}

/* Confetti */
#confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}

/* Back button */
.back-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0;
  font-family: var(--font);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
}

.back-btn:hover {
  color: var(--primary-dark);
}

.back-btn:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-light);
}

.empty-state-emoji {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-state-text {
  font-size: 1rem;
  line-height: 1.5;
}

/* Nav bar at bottom for settings link */
.nav-footer {
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

.nav-footer button {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font);
  padding: 4px 8px;
}

.nav-footer button:hover {
  color: var(--primary);
}

/* Responsive */
@media (max-width: 400px) {
  #app {
    padding: 12px 10px 30px;
  }

  .header h1 {
    font-size: 1.6rem;
  }

  .question-text {
    font-size: 1.15rem;
  }

  .btn {
    padding: 14px 18px;
    font-size: 1rem;
  }

  .choices-grid {
    grid-template-columns: 1fr;
  }

  .summary-stats {
    grid-template-columns: 1fr 1fr;
  }

  .stats-row {
    flex-wrap: wrap;
  }

  .stat-card {
    min-width: calc(50% - 6px);
  }
}

@media (min-width: 601px) {
  #app {
    padding: 30px 24px 50px;
  }
}

/* Print: hide */
@media print {
  body { display: none; }
}
