/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
  background: #f0f4f8;
  color: #1a1a2e;
  line-height: 1.5;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}
#app { width: 100%; max-width: 520px; padding: 20px; }

/* ── Login ──────────────────────────────────────────────────── */
.login-box {
  background: #fff;
  border-radius: 20px;
  padding: 40px 32px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
  text-align: center;
}
.login-box h1 { font-size: 1.6rem; margin-bottom: 4px; }
.login-box p { color: #666; margin-bottom: 24px; font-size: 0.95rem; }
.login-box input {
  width: 100%; padding: 14px 16px; font-size: 1rem; border: 2px solid #e0e7ef;
  border-radius: 12px; outline: none; transition: border .2s;
}
.login-box input:focus { border-color: #4f7cff; }
.login-box button {
  width: 100%; margin-top: 12px; padding: 14px; font-size: 1rem; font-weight: 600;
  background: #4f7cff; color: #fff; border: none; border-radius: 12px;
  cursor: pointer; transition: background .2s;
}
.login-box button:hover { background: #3a66e0; }
.login-error { color: #e74c3c; font-size: 0.9rem; margin-top: 10px; display: none; }

/* ── Header ─────────────────────────────────────────────────── */
.header {
  background: #fff;
  border-radius: 16px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.header h1 { font-size: 1.1rem; font-weight: 700; }
.header h1 span { color: #4f7cff; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-actions .badge { font-size: 0.75rem; color: #666; }
.header-actions button {
  background: none; border: 1px solid #e0e7ef; border-radius: 8px;
  padding: 6px 12px; font-size: 0.8rem; cursor: pointer; color: #555;
  transition: all .2s;
}
.header-actions button:hover { background: #f5f7fa; border-color: #c0c8d4; }

/* ── Stats Bar ──────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.stat-card .num { font-size: 1.1rem; font-weight: 700; color: #1a1a2e; }
.stat-card .label { font-size: 0.65rem; color: #888; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card.accent .num { color: #4f7cff; }

/* ── Mode Selector ──────────────────────────────────────────── */
.mode-selector {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.mode-btn {
  flex: 1; padding: 10px; text-align: center; font-size: 0.85rem; font-weight: 500;
  background: #fff; border: 2px solid #e0e7ef; border-radius: 12px;
  cursor: pointer; transition: all .2s; color: #555;
}
.mode-btn:hover { border-color: #b0c0d4; }
.mode-btn.active { border-color: #4f7cff; background: #eef3ff; color: #4f7cff; font-weight: 600; }
.mode-btn .icon { margin-right: 4px; }

/* ── Category selector ──────────────────────────────────────── */
.cat-selector { margin-bottom: 16px; }
.cat-selector select {
  width: 100%; padding: 12px 14px; font-size: 0.95rem;
  border: 2px solid #e0e7ef; border-radius: 12px; background: #fff;
  outline: none; cursor: pointer; appearance: auto; color: #333;
}
.cat-selector select:focus { border-color: #4f7cff; }

/* ── Card ──────────────────────────────────────────────────── */
.card-area { margin-bottom: 16px; }
.card {
  background: #fff; border-radius: 20px; padding: 40px 24px 30px;
  text-align: center; min-height: 220px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.06);
  display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}
.card .category-tag {
  position: absolute; top: 12px; left: 16px;
  font-size: 0.7rem; color: #aaa; text-transform: uppercase; letter-spacing: 0.5px;
}
.card .question { font-size: 1.5rem; font-weight: 600; margin-bottom: 8px; }
.card .hint { font-size: 0.8rem; color: #999; }
.card .answer {
  font-size: 1.3rem; font-weight: 600; color: #4f7cff;
  margin-top: 16px; padding: 16px 0; display: none;
  animation: fadeIn .3s ease;
}
.card .answer.visible { display: block; }
.card .direction-badge {
  font-size: 0.7rem; color: #bbb; position: absolute; top: 12px; right: 16px;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Card buttons ───────────────────────────────────────────── */
.card-buttons { display: flex; gap: 10px; margin-top: 8px; }
.card-buttons button {
  flex: 1; padding: 14px; font-size: 0.95rem; border: none; border-radius: 14px;
  font-weight: 600; cursor: pointer; transition: all .2s;
}
.btn-show { background: #f0f4ff; color: #4f7cff; }
.btn-show:hover { background: #e0e8ff; }
.card-buttons .btn-sound {
  flex: 0 0 auto; width: 52px; padding: 14px 0; font-size: 1.1rem;
  background: #f0f4ff; color: #4f7cff; border: none; border-radius: 14px;
  font-weight: 600; cursor: pointer; transition: all .2s;
}
.card-buttons .btn-sound:hover { background: #e0e8ff; transform: scale(1.05); }
.btn-sound {
  background: #f0f4ff; color: #4f7cff; border: 1px solid #d0d8e4; border-radius: 10px;
  padding: 8px 14px; font-size: 0.9rem; cursor: pointer; transition: all .2s;
}
.btn-sound:hover { background: #e0e8ff; }
.btn-sound-inline {
  background: none; border: 1px solid #e0e7ef; border-radius: 50%;
  width: 28px; height: 28px; font-size: 0.9rem; cursor: pointer;
  vertical-align: middle; margin-left: 6px; transition: all .2s;
}
.btn-sound-inline:hover { background: #f0f4ff; border-color: #4f7cff; }
.btn-known { background: #34c759; color: #fff; }
.btn-known:hover { background: #2db84e; }
.btn-not { background: #ff6b6b; color: #fff; }
.btn-not:hover { background: #e55a5a; }
.btn-next { background: #4f7cff; color: #fff; }
.btn-next:hover { background: #3a66e0; }

/* ── Quiz ────────────────────────────────────────────────────── */
.quiz-area { margin-bottom: 16px; }
.quiz-question {
  background: #fff; border-radius: 20px; padding: 30px 24px;
  text-align: center; margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.06);
}
.quiz-question .q-label { font-size: 0.75rem; color: #999; margin-bottom: 8px; text-transform: uppercase; }
.quiz-question .q-text { font-size: 1.5rem; font-weight: 600; }
.quiz-question .q-count { font-size: 0.8rem; color: #bbb; margin-top: 8px; }

.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-opt {
  width: 100%; padding: 16px 18px; font-size: 1rem; text-align: left;
  background: #fff; border: 2px solid #e0e7ef; border-radius: 14px;
  cursor: pointer; transition: all .2s;
}
.quiz-opt:hover { border-color: #b0c0d4; background: #fafbfc; }
.quiz-opt.correct { border-color: #34c759; background: #e9f7ed; color: #1a7a2e; }
.quiz-opt.wrong { border-color: #ff6b6b; background: #fdeaea; color: #b33a3a; }
.quiz-opt:disabled { cursor: default; opacity: 0.7; }
.quiz-opt.correct:disabled { opacity: 1; }
.quiz-opt.reveal { border-color: #4f7cff; background: #eef3ff; }

.quiz-feedback { margin-top: 14px; text-align: center; font-size: 0.95rem; min-height: 28px; }
.quiz-feedback .correct-text { color: #34c759; font-weight: 600; }
.quiz-feedback .wrong-text { color: #ff6b6b; font-weight: 600; }
.quiz-feedback .answer-reveal { color: #4f7cff; margin-top: 4px; font-size: 0.85rem; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  background: #fff; border-radius: 20px; padding: 40px 24px; text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.06);
}
.empty-state .emoji { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 6px; }
.empty-state p { color: #888; font-size: 0.9rem; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  #app { padding: 12px; }
  .stats-bar { grid-template-columns: 1fr 1fr; }
  .card { padding: 30px 16px 24px; min-height: 180px; }
  .card .question { font-size: 1.3rem; }
  .quiz-question .q-text { font-size: 1.3rem; }
}