:root {
  --bg: #0a1322;
  --card: #101d33;
  --card-border: rgba(120, 160, 220, 0.14);
  --tile: #16253f;
  --tile-hover: #1b2d4d;
  --text: #f2f6ff;
  --muted: #93a4c0;
  --accent: #2f7bff;
  --accent-deep: #1d5fe0;
  --track: #24344f;
  --radius-card: 22px;
  --radius-item: 14px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(120% 60% at 50% 0%, #10244a 0%, var(--bg) 62%) var(--bg);
  -webkit-tap-highlight-color: transparent;
}

.screen {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  padding: 20px 16px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.title {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.lead {
  margin-top: 10px;
  font-size: 15.5px;
  line-height: 1.45;
  color: #d3dcee;
}

/* Level card */
.level {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 12px;
  margin-top: 18px;
  padding: 14px;
  background: var(--tile);
  border: 1px solid var(--card-border);
  border-radius: 18px;
}

.level-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  font-size: 22px;
  border-radius: 12px;
  background: linear-gradient(160deg, #3b8bff, var(--accent-deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.level-name { font-size: 17px; font-weight: 700; }
.level-day { margin-top: 2px; font-size: 14px; color: var(--muted); }
.level-count { align-self: start; font-size: 15px; font-weight: 600; color: var(--muted); }

.bar {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--track);
}

.bar-fill {
  width: 0;
  min-width: 12px;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f7bff, #5aa2ff);
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Menu */
.menu {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.menu-item {
  display: grid;
  grid-template-columns: 40px 1fr 20px;
  align-items: center;
  column-gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 14px 8px 10px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  text-align: left;
  color: var(--text);
  background: var(--tile);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-item);
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease;
}

.menu-item:hover { background: var(--tile-hover); }
.menu-item:active { transform: scale(0.98); }
.menu-item:focus-visible { outline: 2px solid #8bb8ff; outline-offset: 2px; }

.menu-item.primary {
  background: linear-gradient(180deg, #3a86ff, var(--accent-deep));
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 18px rgba(47, 123, 255, 0.35);
}

.menu-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  font-size: 22px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.07);
}

.primary .menu-icon { background: rgba(255, 255, 255, 0.18); }

.chevron {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.75;
}

.hint {
  margin-top: 16px;
  font-size: 15px;
  color: #d3dcee;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text);
  background: #1d2f4f;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Екрани */
[hidden] { display: none !important; }

[data-view] { animation: view-in 0.25s ease; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.stack { display: grid; gap: 12px; }

/* Банер уроку */
.banner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 96px;
  padding: 18px 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-card);
  background: linear-gradient(120deg, #1a46c9 0%, #2f7bff 62%, #5a9dff 100%);
  box-shadow: 0 10px 30px rgba(20, 70, 200, 0.35);
}

.banner-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.banner-text { position: relative; }
.banner-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.banner-sub { margin-top: 4px; font-size: 15px; color: rgba(255, 255, 255, 0.85); }

.pill {
  position: relative;
  flex: none;
  padding: 7px 14px;
  font-size: 15px;
  font-weight: 600;
  background: rgba(10, 30, 90, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

/* Заголовки секцій */
.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.section-icon { font-size: 30px; line-height: 1; }
.section-head h2, .task h2, .done h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.section-sub { margin-top: 2px; font-size: 14px; color: var(--muted); }

/* Фрази */
.phrases { display: grid; gap: 10px; }

.phrase {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: start;
  column-gap: 12px;
  padding: 14px 12px;
  background: var(--tile);
  border: 1px solid var(--card-border);
  border-radius: 16px;
}

.phrase-num {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  font-size: 16px;
  font-weight: 700;
  background: #234a99;
  border-radius: 50%;
}

.phrase-en { font-size: 19px; font-weight: 700; line-height: 1.3; }
.phrase-tr { margin-top: 3px; font-size: 14.5px; font-style: italic; color: #7fa8e6; }
.phrase-ua { margin-top: 3px; font-size: 16px; color: #e3eaf7; }

/* Нові слова */
.words { display: grid; gap: 6px; }

.word-row {
  display: grid;
  grid-template-columns: 44% 1fr;
  align-items: center;
  padding: 11px 14px;
  background: var(--tile);
  border-radius: 12px;
}

.word-en { font-size: 18px; font-weight: 700; }
.word-ua { font-size: 15.5px; color: #b9c6dd; }

/* Завдання на завтра */
.task {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 123, 255, 0.12), 0 10px 30px rgba(0, 0, 0, 0.28);
}

.task-icon { flex: none; font-size: 40px; line-height: 1; }
.task h2 { font-size: 18px; }
.task-text { margin-top: 4px; font-size: 15px; line-height: 1.45; color: #cbd6ea; }

/* Урок завершено */
.done h2 { font-size: 19px; }
.done-text { margin-top: 8px; font-size: 15.5px; line-height: 1.45; color: #d3dcee; }

.btn-wide {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  margin-top: 16px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--tile);
  border: 1px solid rgba(90, 162, 255, 0.35);
  border-radius: var(--radius-item);
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease;
}

.btn-wide:hover { background: var(--tile-hover); }
.btn-wide:active { transform: scale(0.98); }
.btn-wide:focus-visible { outline: 2px solid #8bb8ff; outline-offset: 2px; }

.btn-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  background: var(--accent);
  border-radius: 7px;
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Мій прогрес */
.progress-head { display: flex; align-items: center; gap: 14px; }
.progress-head h2, .card-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 54px;
  height: 54px;
  background: linear-gradient(160deg, #3b8bff, var(--accent-deep));
  border-radius: 50%;
}

.avatar svg { width: 30px; height: 30px; fill: #fff; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.stat {
  padding: 12px 6px 10px;
  text-align: center;
  background: var(--tile);
  border: 1px solid var(--card-border);
  border-radius: 14px;
}

.stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.stat-label { margin-top: 4px; font-size: 14px; color: var(--muted); }

.next-level { margin-top: 18px; }

.next-level-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 15px;
  color: #d3dcee;
}

.next-level-pct { font-weight: 600; color: var(--muted); }

.streak {
  margin-top: 16px;
  padding: 12px 14px;
  font-size: 16px;
  font-weight: 600;
  background: var(--tile);
  border-radius: 12px;
}

.card-title { margin-bottom: 12px; }

.stat-list { display: grid; gap: 4px; padding: 0; margin: 0; list-style: none; }

.stat-list li {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  column-gap: 12px;
  padding: 8px 2px;
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  font-size: 18px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50%;
}

.stat-name { font-size: 16px; color: #d3dcee; }
.stat-num { font-size: 17px; font-weight: 700; }

.btn-wide.back svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Рівні */
.ladder { display: grid; gap: 8px; padding: 0; margin: 0; list-style: none; }

.ladder-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  column-gap: 12px;
  padding: 10px 12px;
  background: var(--tile);
  border: 1px solid var(--card-border);
  border-radius: 14px;
}

.ladder-badge {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  font-size: 18px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 50%;
}

.ladder-name { font-size: 16px; font-weight: 700; }
.ladder-sub { margin-top: 1px; font-size: 13px; color: var(--muted); }
.ladder-status { font-size: 14px; font-weight: 600; color: var(--muted); text-align: right; }

.ladder-row.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 123, 255, 0.12);
}
.ladder-row.is-current .ladder-badge { background: var(--accent); }
.ladder-row.is-current .ladder-status { color: #8bb8ff; }

.ladder-row.is-done .ladder-badge { color: #3ddc84; background: rgba(61, 220, 132, 0.14); }
.ladder-row.is-done .ladder-status { color: #3ddc84; }

.ladder-row.is-locked { opacity: 0.6; }

/* Новий рівень і день-пауза */
.levelup {
  display: flex;
  align-items: center;
  gap: 14px;
  border-color: rgba(61, 220, 132, 0.5);
  background: linear-gradient(180deg, rgba(61, 220, 132, 0.1), var(--card));
}

.levelup-icon { flex: none; font-size: 38px; line-height: 1; }
.levelup h2 { font-size: 19px; font-weight: 700; }
.levelup-text { margin-top: 4px; font-size: 15px; line-height: 1.45; color: #d3dcee; }

.pause h2 { font-size: 19px; font-weight: 700; }

/* Службове */
.demo-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-top: 14px;
  padding: 0 4px;
  font-size: 13px;
}

.demo-label { width: 100%; color: var(--muted); }

.demo-link {
  padding: 5px 11px;
  color: #b9c6dd;
  text-decoration: none;
  border: 1px solid var(--card-border);
  border-radius: 999px;
}

.demo-link.active { color: #fff; background: var(--accent-deep); border-color: transparent; }
.demo-link:focus-visible { outline: 2px solid #8bb8ff; outline-offset: 2px; }

.load-error { padding: 24px 8px; text-align: center; color: var(--muted); }

body:not(.ready) .screen { visibility: hidden; }

/* Вікторина */
.quiz-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.quiz-head-text { flex: 1; min-width: 0; }

.quiz-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  font-size: 24px;
  background: linear-gradient(160deg, #a98bff, #7a5be6);
  border-radius: 50%;
}

.quiz-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.quiz-count { flex: none; align-self: flex-start; font-size: 15px; font-weight: 600; color: var(--muted); }

.quiz-q {
  margin: 22px 0 16px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.quiz-icon.review { background: linear-gradient(160deg, #3b8bff, var(--accent-deep)); }

.quiz-hint {
  margin: -8px 0 16px;
  font-size: 15.5px;
  font-style: italic;
  color: #9fb6da;
}

.quiz-reveal {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(47, 123, 255, 0.1);
  border: 1px solid rgba(90, 162, 255, 0.3);
  border-radius: 12px;
}

.quiz-reveal-en { font-size: 16px; font-weight: 700; }
.quiz-reveal-tr { margin-top: 2px; font-size: 14px; font-style: italic; color: #7fa8e6; }

.quiz-options { display: grid; gap: 10px; }

.quiz-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 10px 16px;
  font: inherit;
  font-size: 17px;
  font-weight: 500;
  text-align: left;
  color: var(--text);
  background: var(--tile);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-item);
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.quiz-option:hover { background: var(--tile-hover); }
.quiz-option:active { transform: scale(0.99); }
.quiz-option:focus-visible { outline: 2px solid #8bb8ff; outline-offset: 2px; }

.quiz-mark { flex: none; font-size: 20px; font-weight: 700; }

.quiz-option.correct {
  background: rgba(61, 220, 132, 0.12);
  border-color: #3ddc84;
  box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.14);
}
.quiz-option.correct .quiz-mark { color: #3ddc84; }

.quiz-option.wrong {
  background: rgba(255, 93, 108, 0.12);
  border-color: #ff5d6c;
}
.quiz-option.wrong .quiz-mark { color: #ff5d6c; }

.quiz-option.dim { opacity: 0.55; }
/* поки відповідь летить на сервер: показуємо, що кнопки вже не приймають натискань */
.quiz-options.sending { opacity: 0.6; pointer-events: none; }
.quiz-option.correct, .quiz-option.wrong, .quiz-option.dim { cursor: default; }
.quiz-option.correct:hover, .quiz-option.wrong:hover { background-color: inherit; }

/* Головна синя кнопка */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  margin-top: 16px;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #3a86ff, var(--accent-deep));
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-item);
  box-shadow: 0 6px 18px rgba(47, 123, 255, 0.35);
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:focus-visible { outline: 2px solid #8bb8ff; outline-offset: 2px; }
.btn-primary:disabled { opacity: 0.4; box-shadow: none; cursor: default; }

.btn-primary svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.done .btn-primary + .btn-wide { margin-top: 10px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .bar-fill, .menu-item, .toast, .btn-wide, .btn-primary, .quiz-option { transition: none; }
  [data-view] { animation: none; }
}
