@import url('https://fonts.googleapis.com/css2?family=PT+Sans:wght@400;700&family=PT+Sans+Narrow:wght@400;700&display=swap');

.dgt-root {
  --bg: #1a1d21;
  --bg-alt: #212429;
  --surface: #2a2e35;
  --surface-2: #33373f;
  --text: #eeece4;
  --text-dim: #9298a3;
  --text-faint: #656b76;
  --blue: #0a5ca8;
  --blue-bright: #2b7fd0;
  --yellow: #e8b23d;
  --red: #b3453c;
  --red-bright: #d65c4f;
  --green: #4c9a6a;
  --green-bright: #5fb87f;
  --border: #383c44;
  font-family: 'PT Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  min-height: 560px;
}
.dgt-root * { box-sizing: border-box; }
.dgt-root button { font-family: inherit; }
.dgt-root button:focus-visible,
.dgt-root .dgt-word:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

.dgt-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 22px 16px 40px;
}
@media (min-width: 760px) {
  .dgt-container { max-width: 640px; padding: 32px 24px 50px; }
  .dgt-title { font-size: 30px !important; }
  .dgt-sign-word { font-size: 38px !important; }
  .dgt-qcard-es { font-size: 19px !important; }
}

.dgt-title {
  font-family: 'PT Sans Narrow', sans-serif;
  font-weight: 700;
  font-size: 25px;
  letter-spacing: 0.3px;
  margin: 0 0 6px;
  color: var(--text);
}
.dgt-subtitle { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin: 0; }
.dgt-laneline {
  height: 3px;
  margin: 16px 0 18px;
  background-image: repeating-linear-gradient(90deg, var(--yellow) 0 14px, transparent 14px 24px);
  opacity: 0.5;
  border-radius: 2px;
}

.dgt-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 18px;
}
.dgt-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: 'PT Sans Narrow', sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
  padding: 10px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.dgt-tab.active { background: var(--blue); color: #fff; }
.dgt-tab:not(.active):hover { color: var(--text); background: var(--surface); }

.dgt-stats-row { display: flex; gap: 8px; margin-bottom: 16px; }
.dgt-stat {
  flex: 1;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}
.dgt-stat-num {
  font-family: 'PT Sans Narrow', sans-serif;
  font-weight: 700;
  font-size: 21px;
  color: var(--yellow);
  line-height: 1.1;
}
.dgt-stat-num.good { color: var(--green-bright); }
.dgt-stat-num.bad { color: var(--red-bright); }
.dgt-stat-label { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }

.dgt-progress-track {
  height: 6px;
  background: var(--bg-alt);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}
.dgt-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--yellow));
  border-radius: 4px;
  transition: width .3s ease;
}

.dgt-sign-wrap { perspective: 1200px; margin-bottom: 18px; }
.dgt-sign {
  position: relative;
  min-height: 220px;
  border-radius: 16px;
  cursor: pointer;
  transition: transform .45s cubic-bezier(.4,.2,.2,1);
  transform-style: preserve-3d;
}
.dgt-sign.flipped { transform: rotateY(180deg); }
.dgt-sign-face {
  position: absolute; inset: 0; border-radius: 16px; backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px 22px; text-align: center;
}
.dgt-sign-front { background: var(--blue); border: 6px solid rgba(255,255,255,0.9); box-shadow: 0 12px 28px rgba(0,0,0,0.35); }
.dgt-sign-back { background: var(--surface-2); border: 1px solid var(--border); transform: rotateY(180deg); }
.dgt-sign-word {
  font-family: 'PT Sans Narrow', sans-serif; font-weight: 700; font-size: 33px; color: #fff;
  letter-spacing: 0.2px; line-height: 1.15; word-break: break-word;
}
.dgt-sign-hint { margin-top: 14px; font-size: 12px; color: rgba(255,255,255,0.75); }
.dgt-sign-freq {
  position: absolute; top: 12px; right: 14px; font-family: 'PT Sans Narrow', sans-serif;
  font-size: 12px; font-weight: 700; color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.18); padding: 2px 9px; border-radius: 20px;
}
.dgt-sign-ru { font-size: 19px; color: var(--text); line-height: 1.4; font-weight: 700; }
.dgt-sign-es { margin-top: 10px; font-size: 13px; color: var(--text-faint); }
.dgt-sign-loading { font-size: 13px; color: var(--text-faint); font-style: italic; }

.dgt-actions { display: flex; gap: 10px; margin-bottom: 8px; }
.dgt-btn {
  flex: 1; border: none; border-radius: 10px; padding: 14px 10px; font-weight: 700;
  font-size: 14px; cursor: pointer; transition: filter .15s ease, transform .1s ease, background .15s ease;
}
.dgt-btn:active { transform: scale(0.97); }
.dgt-btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.dgt-btn-learning { background: rgba(179,69,60,0.18); color: #e08277; border: 1px solid rgba(179,69,60,0.4); }
.dgt-btn-learning:hover { background: rgba(179,69,60,0.28); }
.dgt-btn-known { background: rgba(76,154,106,0.18); color: #7fc99a; border: 1px solid rgba(76,154,106,0.4); }
.dgt-btn-known:hover { background: rgba(76,154,106,0.28); }
.dgt-btn-primary { background: var(--blue); color: #fff; width: 100%; margin-bottom: 10px; }
.dgt-btn-primary:hover { background: var(--blue-bright); }
.dgt-btn-ghost { background: var(--surface); color: var(--text-dim); border: 1px solid var(--border); }
.dgt-btn-ghost:hover { color: var(--text); }

.dgt-skip {
  text-align: center; font-size: 12px; color: var(--text-faint); margin: 0 0 6px;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}

.dgt-topic-select { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.dgt-chip {
  border: 1px solid var(--border); background: var(--bg-alt); color: var(--text-dim);
  font-size: 11.5px; font-weight: 700; padding: 7px 12px; border-radius: 20px; cursor: pointer;
  font-family: 'PT Sans Narrow', sans-serif; letter-spacing: 0.3px;
}
.dgt-chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.dgt-qnote { font-size: 11.5px; color: var(--text-faint); margin: -6px 0 14px; line-height: 1.4; }

.dgt-qcard {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 18px; margin-bottom: 14px;
}
.dgt-qcard-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.dgt-qcard-topic {
  font-family: 'PT Sans Narrow', sans-serif; font-size: 12px; font-weight: 700; color: var(--yellow);
  letter-spacing: 0.4px; text-transform: uppercase;
}
.dgt-qcard-num { font-size: 12px; color: var(--text-faint); }
.dgt-qimg {
  display: block; width: 100%; max-height: 240px; object-fit: contain;
  background: #0e1013; border-radius: 10px; margin-bottom: 14px; border: 1px solid var(--border);
}
.dgt-qcard-es { font-size: 17px; line-height: 1.5; color: var(--text); font-weight: 700; margin-bottom: 6px; }
.dgt-qcard-hint { font-size: 11px; color: var(--text-faint); margin-bottom: 14px; }

.dgt-opt {
  display: flex; gap: 10px; padding: 11px 10px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14.5px; line-height: 1.4; margin-top: 8px; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  background: var(--surface);
}
.dgt-opt:hover { background: var(--surface-2); }
.dgt-opt.selected { border-color: var(--blue); background: rgba(10,92,168,0.18); }
.dgt-opt.correct { border-color: var(--green); background: rgba(76,154,106,0.2); }
.dgt-opt.incorrect { border-color: var(--red); background: rgba(179,69,60,0.2); }
.dgt-opt.disabled { cursor: default; }
.dgt-opt-letter {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2);
  color: var(--text-dim); font-family: 'PT Sans Narrow', sans-serif; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.dgt-opt.correct .dgt-opt-letter { background: var(--green); color: #fff; }
.dgt-opt.incorrect .dgt-opt-letter { background: var(--red); color: #fff; }
.dgt-opt-text { color: var(--text); flex: 1; }

.dgt-feedback {
  display: flex; align-items: center; gap: 8px; font-family: 'PT Sans Narrow', sans-serif;
  font-weight: 700; font-size: 15px; margin: 12px 0 2px; letter-spacing: 0.3px;
}
.dgt-feedback.correct { color: var(--green-bright); }
.dgt-feedback.incorrect { color: var(--red-bright); }

.dgt-translation { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.dgt-translation-ru { color: var(--text); font-size: 15px; font-weight: 700; margin-bottom: 10px; line-height: 1.4; }
.dgt-translation-opt {
  display: flex; gap: 8px; color: var(--text-dim); font-size: 13.5px; line-height: 1.4;
  padding: 5px 0; border-top: 1px solid var(--border);
}
.dgt-translation-opt:first-of-type { border-top: none; }
.dgt-translation-opt-letter {
  flex-shrink: 0; font-family: 'PT Sans Narrow', sans-serif; font-weight: 700; color: var(--yellow); width: 14px;
}
.dgt-translation-missing { color: var(--text-faint); font-size: 13px; font-style: italic; }

.dgt-empty { text-align: center; padding: 40px 20px; color: var(--text-faint); font-size: 14px; }

/* tappable words */
.dgt-word {
  cursor: pointer; border-bottom: 1.5px dotted rgba(238,236,228,0.35);
  transition: background .12s ease, border-color .12s ease; border-radius: 3px; padding: 0 1px;
}
.dgt-word:hover { background: rgba(43,127,208,0.18); }
.dgt-word.weak { border-bottom-color: var(--red-bright); border-bottom-style: solid; }
.dgt-word.known { border-bottom-color: var(--green-bright); border-bottom-style: solid; }
.dgt-word.active-tap { background: rgba(232,178,61,0.28); border-bottom-color: var(--yellow); }

/* translation panel - sits inline near the top when a word is tapped */
.dgt-translate-bar {
  background: var(--surface-2); border: 1px solid var(--blue);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 16px;
  animation: dgt-fade-in .15s ease;
}
@keyframes dgt-fade-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.dgt-translate-bar-word {
  font-family: 'PT Sans Narrow', sans-serif; font-weight: 700; color: var(--yellow); font-size: 15px;
}
.dgt-translate-bar-ru { color: var(--text); font-size: 14.5px; margin-top: 2px; }
.dgt-translate-bar-loading { color: var(--text-faint); font-size: 13px; font-style: italic; }

.dgt-scorebar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dgt-score { font-family: 'PT Sans Narrow', sans-serif; font-weight: 700; font-size: 14px; color: var(--text-dim); }
.dgt-score b { color: var(--green-bright); }
.dgt-score i { color: var(--red-bright); font-style: normal; }

@media (prefers-reduced-motion: reduce) {
  .dgt-sign, .dgt-progress-fill, .dgt-word, .dgt-opt { transition: none !important; }
}

/* ============ standalone shell additions ============ */
html, body {
  margin: 0; padding: 0; background: #1a1d21;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: 'PT Sans', 'Segoe UI', system-ui, sans-serif;
  overscroll-behavior-y: none;
}
.dgt-root {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
.dgt-root button, .dgt-word, .dgt-opt, .dgt-chip, .dgt-tab, .dgt-sign {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.dgt-container { padding-top: max(22px, env(safe-area-inset-top)); }
.dgt-qimg { cursor: zoom-in; }
/* варианты ответа: короткое нажатие = ответ, удержание слова = перевод.
   Без этого долгое нажатие на телефоне выделяет текст и открывает меню. */
.dgt-opt {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.dgt-opt:not(.disabled) .dgt-word { cursor: pointer; }
.dgt-opt:not(.disabled) .dgt-word:hover { background: transparent; }

/* контекстный перевод: начальная форма и пояснение термина */
.dgt-translate-bar-lemma { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; }
.dgt-translate-bar-lemma b { color: var(--text); font-weight: 700; }
.dgt-translate-bar-note { color: var(--text-faint); font-size: 12.5px; margin-top: 4px; line-height: 1.4; font-style: italic; }

/* подсказка «установить как приложение» (pwa.js) */
.dgt-install {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 456px; margin: 0 auto; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px 12px 16px;
  background: #2a2e35; color: #eeece4;
  border: 1px solid #383c44; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  font: 14px/1.4 'PT Sans', 'Segoe UI', system-ui, sans-serif;
}
.dgt-install-text { flex: 1; }
.dgt-install-btn {
  flex: none; padding: 8px 14px; border: 0; border-radius: 8px;
  background: #e8b23d; color: #1a1d21; font: inherit; font-weight: 700; cursor: pointer;
}
.dgt-install-close {
  flex: none; width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: transparent; color: #9298a3; font-size: 22px; line-height: 1; cursor: pointer;
}
