:root {
  --color-bg: #f8f9fc;
  --color-bg-card: #ffffff;
  --color-text: #1a1a2e;
  --color-text-muted: #6b7280;
  --color-primary: #2c5f8a;
  --color-primary-hover: #234d72;
  --color-primary-light: #e8f0f8;
  --color-correct: #2e7d4f;
  --color-wrong: #c0392b;
  --color-border: #e2e8f0;
  --color-accent: #c4956a;
  --color-accent-light: #f0f4f9;
  --color-premium: #b8860b;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-pill: 50px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="dark"] {
  --color-bg: #0f1722;
  --color-bg-card: #1a2535;
  --color-text: #e2e8f0;
  --color-text-muted: #8899aa;
  --color-primary: #4a9eda;
  --color-primary-hover: #5db0ec;
  --color-primary-light: #1a2d40;
  --color-correct: #4caf7a;
  --color-wrong: #e05555;
  --color-border: #2a3a4e;
  --color-accent: #c4956a;
  --color-accent-light: #1e2d3d;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  padding: 0 16px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
}

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

.header-left h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-primary);
}

.header-right {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* Stats Bar */
.stats-bar {
  display: flex;
  gap: 16px;
  padding: 4px 0 16px;
}

.stat {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

/* Main */
main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  padding: 8px 0;
}

.screen {
  display: none;
  width: 100%;
}

.screen.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

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

.card {
  background: var(--color-bg-card);
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Start Screen */
.welcome-card h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--color-primary);
}

.welcome-card p {
  color: var(--color-text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.category-select h3,
.difficulty-select h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.difficulty-select {
  margin-top: 24px;
}

.btn {
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 1rem;
  transition: all 0.15s ease;
}

.btn-category {
  display: block;
  width: 100%;
  text-align: left;
  padding: 16px 20px;
  margin-bottom: 10px;
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.btn-category:hover {
  background: var(--color-border);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-category.btn-all {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-category.btn-all .category-label,
.btn-category.btn-all .category-letters {
  color: #fff;
}

.category-label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--color-text);
}

.category-letters {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.difficulty-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-diff {
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  background: var(--color-bg);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  border: 1.5px solid var(--color-border);
}

.btn-diff.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.btn-diff:hover:not(.active) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Quiz Screen */
.quiz-card {
  text-align: center;
  padding: 48px 24px;
  position: relative;
}

.btn-cancel {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-cancel:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.word-display {
  margin-bottom: 12px;
}

.word-text {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--color-text);
}

.word-text .blank {
  display: inline-block;
  min-width: 36px;
  border-bottom: 3px solid var(--color-primary);
  margin: 0 2px;
  color: var(--color-primary);
}

.translation {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 36px;
  min-height: 1.4em;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

.btn-choice {
  padding: 12px 22px;
  font-size: 1.2rem;
  font-weight: 600;
  background: var(--color-bg);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-pill);
  min-width: 64px;
  transition: all 0.15s ease;
  color: var(--color-primary);
}

.btn-choice:hover:not(:disabled) {
  background: var(--color-primary);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn-choice:disabled {
  cursor: default;
}

.btn-choice.correct {
  background: var(--color-correct);
  border-color: var(--color-correct);
  color: #fff;
  transform: scale(1.05);
}

.btn-choice.wrong {
  background: var(--color-wrong);
  border-color: var(--color-wrong);
  color: #fff;
  opacity: 0.7;
}

.btn-choice.reveal {
  border-color: var(--color-correct);
  background: rgba(46, 125, 79, 0.1);
  color: var(--color-correct);
}

.feedback {
  min-height: 2em;
  font-size: 1.05rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.feedback.correct {
  color: var(--color-correct);
}

.feedback.wrong {
  color: var(--color-wrong);
}

.btn-next {
  padding: 12px 32px;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.btn-next:hover {
  background: var(--color-primary-hover);
}

.progress-bar-container {
  margin-top: 24px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

/* Results Screen */
.results-card {
  text-align: center;
}

.results-card h2 {
  font-size: 1.5rem;
  color: var(--color-primary);
  margin-bottom: 24px;
}

.results-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 24px;
}

.result-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.result-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
}

.result-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.results-message {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 24px;
  padding: 12px;
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
}

.results-message:empty {
  display: none;
}

.btn-primary {
  padding: 14px 32px;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-pill);
  font-weight: 600;
  width: 100%;
  margin-bottom: 12px;
  font-size: 1rem;
}

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

.btn-secondary {
  padding: 14px 32px;
  background: transparent;
  color: var(--color-text-muted);
  border-radius: var(--radius-pill);
  font-weight: 500;
  width: 100%;
  border: 1.5px solid var(--color-border);
}

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

/* Stats Screen */
.stats-card h2 {
  font-size: 1.5rem;
  color: var(--color-primary);
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  border: 1px solid var(--color-border);
}

.stat-number {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-primary);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-accuracy-bar {
  margin-bottom: 24px;
}

.stat-accuracy-bar h3 {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.accuracy-bar-container {
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.accuracy-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 4px;
  transition: width 0.5s ease;
  width: 0%;
}

.accuracy-percent {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary);
}

/* Paywall Screen */
.paywall-card {
  text-align: center;
}

.paywall-card h2 {
  font-size: 1.5rem;
  color: var(--color-premium);
  margin-bottom: 12px;
}

.paywall-card > p {
  color: var(--color-text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.premium-features {
  text-align: left;
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 24px;
  border: 1px solid var(--color-border);
}

.premium-features h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.premium-features ul {
  list-style: none;
}

.premium-features li {
  padding: 6px 0;
  font-size: 0.95rem;
  color: var(--color-text);
}

.btn-premium {
  padding: 16px 32px;
  background: var(--color-premium);
  color: #fff;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 1.05rem;
  width: 100%;
  margin-bottom: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-premium:hover {
  background: #9a7209;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.paywall-note {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 12px;
}

/* Ad Banner */
.ad-banner {
  padding: 12px 0;
  text-align: center;
}

.ad-banner.hidden {
  display: none;
}

.ad-placeholder {
  background: var(--color-primary-light);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

/* Install Banner & Android Promo */
.install-banner,
.android-promo {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-bg-card);
  border-top: 1px solid var(--color-border);
  padding: 12px 16px;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  animation: slideUp 0.3s ease;
}

.install-banner.hidden,
.android-promo.hidden {
  display: none;
}

.install-content,
.promo-content {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
  font-size: 0.85rem;
}

.install-content span,
.promo-content span {
  flex: 1;
  color: var(--color-text);
}

.install-buttons {
  display: flex;
  gap: 8px;
}

.btn-install {
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.85rem;
}

.btn-promo {
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
}

.btn-dismiss {
  padding: 6px 10px;
  background: none;
  color: var(--color-text-muted);
  font-size: 1rem;
  border-radius: var(--radius-sm);
}

.btn-dismiss:hover {
  background: var(--color-primary-light);
}

.promo-content svg {
  color: #3ddc84;
  flex-shrink: 0;
}

/* Footer */
footer {
  text-align: center;
  padding: 20px 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.footer-links {
  margin-top: 8px;
}

.footer-links a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

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

/* Animations */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.3s ease;
}

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

.pop {
  animation: pop 0.3s ease;
}

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

.slide-up {
  animation: slideUp 0.3s ease;
}

/* Responsive */
@media (max-width: 400px) {
  .word-text {
    font-size: 1.9rem;
  }

  .btn-choice {
    padding: 10px 16px;
    font-size: 1.05rem;
    min-width: 56px;
  }

  .card {
    padding: 24px 16px;
  }
}
