/* Карточки слов: цвета из темы Telegram, вне Telegram — светлая и тёмная запасные. */
:root {
  --bg: #ffffff;
  --text: #1c1c1e;
  --muted: #8a8a8e;
  --card: #f2f2f7;
  --line: #e1e1e6;
  --accent: #2481cc;
  --accent-text: #ffffff;
  --ok: #2e9e5b;
  --bad: #d64545;
  --almost: #c98a12;
  --ok-soft: rgba(46, 158, 91, .14);
  --bad-soft: rgba(214, 69, 69, .14);
  --almost-soft: rgba(201, 138, 18, .16);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #17181b;
    --text: #f2f2f5;
    --muted: #9a9aa2;
    --card: #232428;
    --line: #34353a;
    --accent: #4ea3e8;
    --ok: #4cc37f;
    --bad: #ef6b6b;
    --almost: #e6ac3c;
    color-scheme: dark;
  }
}
:root.tg {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1c1c1e);
  --muted: var(--tg-theme-hint-color, #8a8a8e);
  --card: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --line: var(--tg-theme-section-separator-color, rgba(128, 128, 128, .25));
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top { display: flex; align-items: center; gap: 12px; padding: 4px 0 16px; }
.progress { flex: 1; height: 6px; border-radius: 3px; background: var(--card); overflow: hidden; }
.bar { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.count { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }
.count:empty { display: none; }

.screen { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.label { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.word { font-size: 32px; line-height: 1.2; font-weight: 650; overflow-wrap: anywhere; margin: 0; }
.ru { font-size: 22px; margin: 0; overflow-wrap: anywhere; }
.example { font-size: 16px; color: var(--muted); margin: 0; }
.example i { color: var(--text); }
.others { font-size: 14px; color: var(--muted); margin: 0; }
.forms { font-size: 15px; margin: 0; }

button {
  font: inherit;
  border: 0;
  border-radius: 12px;
  min-height: 48px;
  padding: 10px 16px;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { cursor: default; }
.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; width: 100%; }
.secondary { background: var(--card); color: var(--text); width: 100%; }
.ghost { background: transparent; color: var(--accent); width: 100%; }
.row { display: flex; gap: 10px; }
.row > button { flex: 1; }

.speak {
  width: 52px;
  min-height: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--accent);
  font-size: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.speak.big { width: 88px; height: 88px; font-size: 38px; }
.speak.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(36, 129, 204, .35); } 50% { box-shadow: 0 0 0 10px rgba(36, 129, 204, 0); } }

.options { display: flex; flex-direction: column; gap: 10px; }
.option { background: var(--card); color: var(--text); text-align: left; width: 100%; border: 2px solid transparent; }
.option.right { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.row > .option { text-align: center; font-size: 20px; font-weight: 600; }

.answer {
  width: 100%;
  font: inherit;
  font-size: 20px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.answer:focus { border-color: var(--accent); }

.result { border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.result.correct { background: var(--ok-soft); }
.result.wrong { background: var(--bad-soft); }
.result.almost { background: var(--almost-soft); }
.result.learned { background: var(--card); }
.result .mark { font-weight: 650; margin: 0; }
.result.correct .mark { color: var(--ok); }
.result.wrong .mark { color: var(--bad); }
.result.almost .mark { color: var(--almost); }
.result .pair { margin: 0; font-size: 19px; }
.result .note { margin: 0; font-size: 15px; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.done { text-align: center; padding-top: 24px; display: flex; flex-direction: column; gap: 14px; }
.done h1 { font-size: 26px; margin: 0; }
.score { display: flex; justify-content: center; gap: 28px; }
.score b { display: block; font-size: 30px; color: var(--text); }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 448px;
  margin: 0 auto;
  background: var(--text);
  color: var(--bg);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
}
