/* OINO / Тапалак — MVP styles. Минимум. Mobile-first. */
:root {
  --bg: #f5f4ef;
  --card: #ffffff;
  --ink: #1c1a16;
  --muted: #6b6760;
  --accent: #c95e2b;
  --accent-soft: #f3d2bf;
  --ok: #2f8a4a;
  --ok-soft: #d3eddc;
  --bad: #b53b2e;
  --bad-soft: #f4d8d4;
  --line: #e5e2db;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28,26,22,0.04), 0 8px 24px rgba(28,26,22,0.06);
  --max-width: 640px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Kyrgyz", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.lang-switch {
  display: flex;
  gap: 4px;
}

.lang-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-btn:hover { color: var(--ink); border-color: var(--ink); }
.lang-btn.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.feed {
  max-width: var(--max-width);
  margin: 24px auto;
  padding: 0 16px 80px;
}

.card-slot { animation: fadeIn 0.25s ease; }

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 22px 20px;
  margin-bottom: 16px;
}

.card-empty { text-align: center; color: var(--muted); padding: 40px 20px; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.task-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-weight: 600;
}

.task-difficulty {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.diff-easy { color: var(--ok); border-color: var(--ok-soft); }
.diff-hard { color: var(--bad); border-color: var(--bad-soft); }

.card-question {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 22px;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

/* Лемма-герой: кыргызское слово как главный визуальный акцент */
.card-hero {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 10px 0 22px;
  color: var(--ink);
  padding: 14px 8px;
  word-break: break-word;
}

@media (max-width: 480px) {
  .card-hero { font-size: 30px; padding: 10px 4px; margin: 4px 0 18px; }
}

.task-title {
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}

.task-label-alt {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.task-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 14px;
  font-style: italic;
}

.card-options {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}

.opt-btn {
  font: inherit;
  font-size: 17px;
  text-align: left;
  background: var(--card);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  min-height: 56px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.opt-btn:hover { border-color: var(--ink); transform: translateY(-1px); }
.opt-btn:active { transform: translateY(0); }

.card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
  gap: 10px;
}

.skip-btn {
  font: inherit;
  font-size: 14px;
  background: transparent;
  color: var(--muted);
  border: none;
  cursor: pointer;
  padding: 8px 12px;
}

.skip-btn:hover { color: var(--ink); }

.next-btn.primary {
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 12px 22px;
  cursor: pointer;
  transition: background 0.15s ease;
}

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

/* Result card */
.card-result.correct { border-left: 4px solid var(--ok); }
.card-result.incorrect { border-left: 4px solid var(--bad); }

.card-result .task-label {
  color: var(--ok);
  font-size: 16px;
  letter-spacing: 0;
  text-transform: none;
}
.card-result.incorrect .task-label { color: var(--bad); }

.answer-block { margin: 18px 0; }

.answer-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: baseline; flex-wrap: wrap; }
.answer-label { font-size: 13px; color: var(--muted); }
.answer-text { font-weight: 600; }
.correct-text { color: var(--ok); }
.wrong-text { color: var(--bad); text-decoration: line-through; }

.answer-meaning { margin-top: -2px; }
.meaning-text { font-size: 14px; color: var(--ink); font-style: italic; opacity: 0.85; }

.explanation { margin: 14px 0; padding: 12px 14px; background: var(--bg); border-radius: 10px; border: 1px solid var(--line); }
.explanation summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 14px; }
.explanation p { margin: 10px 0 0; color: var(--ink); font-size: 15px; }

/* Раскрытое по умолчанию объяснение (без <details>) */
.explanation-open {
  margin: 14px 0;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* Тёплая речь-итог поверх карточки результата */
.result-intro {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
  margin: 8px 0 14px;
}
.result-intro strong {
  color: var(--ok);
  font-weight: 700;
}
.card-result.incorrect .result-intro strong { color: var(--bad); }

.answer-block.secondary { opacity: 0.92; }

/* Подзаголовок ранг-баннера со «спичем» */
.rank-text { display: flex; flex-direction: column; gap: 4px; }
.rank-speech {
  font-size: 13px;
  color: #4b2a8f;
  font-weight: 400;
  line-height: 1.4;
}

.footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 8px;
  background: linear-gradient(to top, var(--bg) 50%, transparent);
  pointer-events: none;
}

@media (max-width: 480px) {
  .card { padding: 22px 18px 18px; }
  .card-question { font-size: 19px; }
  .opt-btn { font-size: 16px; padding: 12px 14px; }
}

/* === Stats bar в шапке === */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink);
}

.stats-summary {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-weight: 600;
}
.stats-summary .stats-num { font-variant-numeric: tabular-nums; }
.stats-summary .stats-num:first-child { color: var(--ok); }
.stats-summary .stats-sep { color: var(--muted); margin: 0 2px; }

.stats-streak {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}

.stats-hint {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

.stats-inline {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Убираем синюю обводку фокуса от тапа — она путала «правильный» вариант */
.opt-btn:focus,
.opt-btn:focus-visible {
  outline: none;
  border-color: var(--line);
}
.opt-btn:active { border-color: var(--ink); transform: scale(0.99); }

/* На сенсорных устройствах :hover не должен залипать */
@media (hover: none) {
  .opt-btn:hover { border-color: var(--line); transform: none; }
}

/* === Бейдж ранга в шапке === */
.rank-badge {
  font-size: 13px;
  font-weight: 600;
  color: #6b3fb5;
  background: #efe7ff;
  border: 1px solid #d3c2f6;
  border-radius: 10px;
  padding: 3px 10px;
  white-space: nowrap;
}

/* === Баннер «новый уровень» (пурпурный, отличается от жёлтой вехи) === */
.rank-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #efe7ff, #d3c2f6);
  border: 1px solid #a988e8;
  color: #3d1d7a;
  padding: 12px 16px;
  border-radius: 12px;
  margin: -6px 0 16px;
  font-weight: 500;
  font-size: 15px;
  animation: rankIn 0.55s cubic-bezier(.2, .9, .3, 1.3);
}
.rank-banner strong { font-weight: 700; }
.rank-sub { font-size: 13px; color: #6b3fb5; opacity: 0.85; margin-left: 4px; }

.rank-emoji {
  font-size: 24px;
  display: inline-block;
  animation: rankPulse 1s ease;
}

@keyframes rankIn {
  from { opacity: 0; transform: translateY(-14px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes rankPulse {
  0% { transform: scale(0.6); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* === Веха-баннер === */
.milestone-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #fff2c5, #ffd591);
  border: 1px solid #f0b04a;
  color: #6a4400;
  padding: 12px 16px;
  border-radius: 12px;
  margin: -6px 0 16px;
  font-weight: 600;
  font-size: 15px;
  animation: milestoneIn 0.5s cubic-bezier(.2, .9, .3, 1.3);
}

.milestone-emoji {
  font-size: 22px;
  display: inline-block;
  animation: milestoneSpin 0.8s ease;
}

@keyframes milestoneIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes milestoneSpin {
  0% { transform: rotate(-20deg) scale(0.8); }
  60% { transform: rotate(15deg) scale(1.2); }
  100% { transform: rotate(0) scale(1); }
}

/* === Тряска на incorrect === */
@keyframes shake {
  0% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

.shake-anim { animation: shake 0.5s ease; }

/* === Конфетти на correct === */
.confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.card-result { position: relative; overflow: visible; }

.confetti-piece {
  position: absolute;
  top: 30%;
  left: 50%;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  opacity: 0;
  animation: confettiFall 1.4s cubic-bezier(.2, .8, .3, 1) forwards;
}

.confetti-piece:nth-child(1)  { background: #c95e2b; animation-delay: 0.00s; --dx: -120px; --dy: 220px; --rot: 320deg; }
.confetti-piece:nth-child(2)  { background: #f0b04a; animation-delay: 0.04s; --dx:  140px; --dy: 240px; --rot: -180deg; }
.confetti-piece:nth-child(3)  { background: #2f8a4a; animation-delay: 0.02s; --dx: -180px; --dy: 200px; --rot: 240deg; }
.confetti-piece:nth-child(4)  { background: #4a78d0; animation-delay: 0.06s; --dx:  160px; --dy: 260px; --rot: -300deg; }
.confetti-piece:nth-child(5)  { background: #c95e2b; animation-delay: 0.08s; --dx: -100px; --dy: 280px; --rot: 200deg; }
.confetti-piece:nth-child(6)  { background: #f0b04a; animation-delay: 0.10s; --dx:  200px; --dy: 220px; --rot: -200deg; }
.confetti-piece:nth-child(7)  { background: #2f8a4a; animation-delay: 0.12s; --dx: -150px; --dy: 260px; --rot: 360deg; }
.confetti-piece:nth-child(8)  { background: #b53b2e; animation-delay: 0.14s; --dx:  120px; --dy: 200px; --rot: -120deg; }
.confetti-piece:nth-child(9)  { background: #4a78d0; animation-delay: 0.16s; --dx: -200px; --dy: 240px; --rot: 280deg; }
.confetti-piece:nth-child(10) { background: #f0b04a; animation-delay: 0.18s; --dx:  100px; --dy: 250px; --rot: -260deg; }
.confetti-piece:nth-child(11) { background: #c95e2b; animation-delay: 0.20s; --dx: -130px; --dy: 280px; --rot: 320deg; }
.confetti-piece:nth-child(12) { background: #2f8a4a; animation-delay: 0.22s; --dx:  170px; --dy: 220px; --rot: -180deg; }
.confetti-piece:nth-child(13) { background: #b53b2e; animation-delay: 0.24s; --dx: -110px; --dy: 240px; --rot: 220deg; }
.confetti-piece:nth-child(14) { background: #4a78d0; animation-delay: 0.26s; --dx:  150px; --dy: 260px; --rot: -340deg; }
.confetti-piece:nth-child(15) { background: #f0b04a; animation-delay: 0.28s; --dx: -170px; --dy: 200px; --rot: 300deg; }
.confetti-piece:nth-child(16) { background: #c95e2b; animation-delay: 0.30s; --dx:  120px; --dy: 250px; --rot: -160deg; }
.confetti-piece:nth-child(17) { background: #2f8a4a; animation-delay: 0.32s; --dx: -160px; --dy: 280px; --rot: 240deg; }
.confetti-piece:nth-child(18) { background: #b53b2e; animation-delay: 0.34s; --dx:  180px; --dy: 220px; --rot: -220deg; }
.confetti-piece:nth-child(19) { background: #4a78d0; animation-delay: 0.36s; --dx: -120px; --dy: 240px; --rot: 200deg; }
.confetti-piece:nth-child(20) { background: #f0b04a; animation-delay: 0.38s; --dx:  140px; --dy: 260px; --rot: -300deg; }

@keyframes confettiFall {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(0deg); }
  10% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot));
  }
}

/* Уважаем reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .confetti-piece, .shake-anim, .milestone-emoji, .milestone-banner { animation: none; }
}
