:root {
  --font-body: 'Manrope', system-ui, -apple-system, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;

  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.4rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2rem);
  --text-2xl: clamp(2rem, 1.5rem + 2vw, 3rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;

  --radius-sm: 0.5rem; --radius-md: 0.75rem; --radius-lg: 1rem;
  --radius-xl: 1.5rem; --radius-full: 9999px;

  /* Bright, playful, kid-friendly palette (light) */
  --color-bg: #f6f5ff;
  --color-surface: #ffffff;
  --color-surface-2: #f2f0ff;
  --color-surface-offset: #ebe9ff;
  --color-border: #e0dcff;
  --color-divider: #ede9ff;

  --color-text: #1c1a3d;
  --color-text-muted: #6c6a90;
  --color-text-faint: #a9a6c9;
  --color-text-inverse: #ffffff;

  --color-primary: #5b45ff;      /* indigo */
  --color-primary-hover: #4a37e8;
  --color-primary-highlight: #e6e1ff;

  --color-success: #16a56a;
  --color-success-highlight: #d7f5e6;
  --color-error: #ef4262;
  --color-error-highlight: #ffdde3;
  --color-warning: #f59e0b;
  --color-warning-highlight: #fff2d4;
  --color-accent: #ff8a3d;       /* orange */
  --color-accent-2: #22c1e0;     /* cyan */
  --color-purple: #a855f7;

  --shadow-sm: 0 1px 2px rgba(28,26,61,0.06);
  --shadow-md: 0 6px 20px rgba(91,69,255,0.10);
  --shadow-lg: 0 20px 40px rgba(91,69,255,0.18);
  --transition: 200ms cubic-bezier(.16,1,.3,1);
}
[data-theme="dark"] {
  --color-bg: #0f0e1a;
  --color-surface: #191830;
  --color-surface-2: #1f1e3a;
  --color-surface-offset: #262444;
  --color-border: #2c2a52;
  --color-divider: #24234a;
  --color-text: #e9e7ff;
  --color-text-muted: #a5a2cc;
  --color-text-faint: #6d6a9d;
  --color-primary: #8b7cff;
  --color-primary-hover: #a496ff;
  --color-primary-highlight: #2c2957;
  --color-success: #5cd39a;
  --color-success-highlight: #1e4a37;
  --color-error: #ff7185;
  --color-error-highlight: #4a1e2c;
  --color-warning: #ffbc4d;
  --color-warning-highlight: #4a3418;
  --shadow-md: 0 6px 20px rgba(0,0,0,0.35);
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: none; text-size-adjust: none; -webkit-font-smoothing: antialiased; }
body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background:
    radial-gradient(80% 60% at 100% 0%, rgba(255,138,61,0.10), transparent 60%),
    radial-gradient(70% 50% at 0% 100%, rgba(34,193,224,0.10), transparent 60%),
    var(--color-bg);
  line-height: 1.5;
  overscroll-behavior-y: contain;
  padding-bottom: env(safe-area-inset-bottom);
  padding-top: env(safe-area-inset-top);
}
[data-theme="dark"] body {
  background:
    radial-gradient(80% 60% at 100% 0%, rgba(139,124,255,0.12), transparent 60%),
    radial-gradient(70% 50% at 0% 100%, rgba(34,193,224,0.08), transparent 60%),
    var(--color-bg);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
svg { display: block; }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ===== Top bar ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface);
  position: sticky; top: 0; z-index: 10;
}
.topbar__brand {
  display: flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em;
  font-size: var(--text-lg);
}
.topbar__brand .bolt {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  display: grid; place-items: center; color: white; font-weight: 900;
  box-shadow: var(--shadow-md);
}
.topbar__stats { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; }
.stat {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-weight: 700; font-size: var(--text-sm);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
}
.stat--fire { background: linear-gradient(135deg, #ffedd5, #ffd9b8); color: #c2410c; }
.stat--xp   { background: linear-gradient(135deg, var(--color-primary-highlight), #ded7ff); color: var(--color-primary); }
[data-theme="dark"] .stat--fire { background: rgba(255,138,61,.18); color: #ffbc85; }

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: var(--radius-full); background: var(--color-surface-2);
  color: var(--color-text);
}
.icon-btn:hover { background: var(--color-surface-offset); }

/* ===== Screens ===== */
.screen {
  padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-5);
  flex: 1;
}
.hero-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.hero-sub { color: var(--color-text-muted); font-size: var(--text-base); }

/* Progress card */
.pcard {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.pcard__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.pcard__value { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 800; }
.pcard__label { color: var(--color-text-muted); font-size: var(--text-sm); }
.bar { height: 12px; border-radius: var(--radius-full); background: var(--color-surface-offset); overflow: hidden; }
.bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent-2));
  border-radius: inherit;
  transition: width 500ms ease;
}
.pcard__meta { display: flex; gap: var(--space-4); margin-top: var(--space-3); flex-wrap: wrap; }
.meta { font-size: var(--text-sm); color: var(--color-text-muted); }
.meta b { color: var(--color-text); font-weight: 700; }

/* Mode tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-align: left;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  display: flex; flex-direction: column; gap: var(--space-2);
  min-height: 130px;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--color-primary); }
.tile__ico { width: 40px; height: 40px; border-radius: var(--radius-md); display: grid; place-items: center; color: white; font-size: 22px; }
.tile__ico--a { background: linear-gradient(135deg, #5b45ff, #22c1e0); }
.tile__ico--b { background: linear-gradient(135deg, #ff8a3d, #ef4262); }
.tile__ico--c { background: linear-gradient(135deg, #16a56a, #22c1e0); }
.tile__ico--d { background: linear-gradient(135deg, #a855f7, #5b45ff); }
.tile__ico--v { background: linear-gradient(135deg, #f59e0b, #ef4262); }
.tile__title { font-weight: 700; font-size: var(--text-base); }
.tile__sub { color: var(--color-text-muted); font-size: var(--text-sm); }

.big-cta {
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: white; font-weight: 800; font-size: var(--text-base);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition), box-shadow var(--transition);
  min-height: 56px; width: 100%;
}
.big-cta:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.big-cta[disabled] { opacity: .5; cursor: not-allowed; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-full);
  background: var(--color-surface); border: 1px solid var(--color-border);
  color: var(--color-text); font-weight: 600; font-size: var(--text-sm);
  min-height: 44px;
  /* Фикс тач-задержки iOS/Android — без этого double-tap zoom съедает первый тап */
  touch-action: manipulation;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0.08);
  -webkit-user-select: none;
  user-select: none;
}
.btn:disabled, .btn[disabled] { cursor: not-allowed; opacity: 0.55; }
/* :hover — только для устройств с настоящим hover (мышь). На тач-экране залипает после тапа и мешает второму клику */
@media (hover: hover) {
  .btn:hover { background: var(--color-surface-2); border-color: var(--color-primary); }
  .btn--primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
  .btn--ghost:hover { background: var(--color-surface-2); color: var(--color-text); }
}
/* Активное состояние — визуальная обратная связь на тач */
.btn:active { transform: scale(0.97); transition: transform 60ms ease-out; }
.btn--primary { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--color-text-muted); }
.btn--danger { background: var(--color-error); color: white; border-color: var(--color-error); }

/* ===== Session ===== */
.session-head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  position: sticky; top: 0; z-index: 10;
  background: var(--color-surface);
}
.session-head .bar { flex: 1; }

/* Card */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-4);
  min-height: 340px;
}
.card__level {
  display: inline-flex; align-items: center; gap: var(--space-1);
  align-self: flex-start;
  font-size: var(--text-xs); font-weight: 700;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-primary-highlight); color: var(--color-primary);
  letter-spacing: 0.05em; text-transform: uppercase;
}
.card__word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-2xl);
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-align: center;
  padding: var(--space-3) 0;
}
.card__ipa { color: var(--color-text-muted); font-size: var(--text-base); text-align: center; }
.card__ru { color: var(--color-text); text-align: center; font-size: var(--text-lg); font-weight: 600; }
.card__ex { text-align: center; color: var(--color-text-muted); font-style: italic; font-size: var(--text-sm); }
.card__ex b { color: var(--color-text); font-style: normal; }

.speaker {
  width: 64px; height: 64px; align-self: center;
  border-radius: var(--radius-full);
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  display: grid; place-items: center; font-size: 28px;
  border: 2px solid transparent;
}
.speaker:hover { background: var(--color-primary); color: white; }
.speaker.playing { animation: pulse 1.2s infinite; }
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(91,69,255,0.15); }
}

/* Choice buttons */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.choice {
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  text-align: center; font-weight: 600; font-size: var(--text-base);
  min-height: 52px;
  word-break: break-word;
  transition: all var(--transition);
}
/* для 3-х вариантов и меньше — одна колонка; для 8 — 4х2 на широком экране */
.choices:has(.choice:nth-child(3):last-child), .choices:has(.choice:nth-child(2):last-child) { grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .choices:has(.choice:nth-child(8)) { grid-template-columns: repeat(4, 1fr); }
}
.choice:hover:not([disabled]) { border-color: var(--color-primary); background: var(--color-surface-2); }
.choice.correct { border-color: var(--color-success); background: var(--color-success-highlight); color: var(--color-success); }
.choice.wrong { border-color: var(--color-error); background: var(--color-error-highlight); color: var(--color-error); }
.choice[disabled] { cursor: default; }

/* Input */
.dictate {
  display: flex; gap: var(--space-2); align-items: stretch;
  width: 100%; min-width: 0;
}
.dictate input {
  flex: 1; min-width: 0;
  padding: var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--text-lg);
  font-family: var(--font-display);
  font-weight: 700;
  background: var(--color-surface);
  color: var(--color-text);
  letter-spacing: 0.02em;
}
.dictate input:focus { outline: none; border-color: var(--color-primary); }
.dictate input.correct { border-color: var(--color-success); background: var(--color-success-highlight); }
.dictate input.wrong { border-color: var(--color-error); background: var(--color-error-highlight); }
.dictate button { flex-shrink: 0; padding-inline: var(--space-4); }
.hint {
  display: flex; gap: var(--space-1); justify-content: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: 0.2em;
  color: var(--color-text-faint);
  font-size: var(--text-lg);
}

/* Card action row */
.card-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3);
}
.card-actions:has(> :only-child) { grid-template-columns: 1fr; }
.card-actions .btn { min-height: 52px; font-size: var(--text-base); }
.card-actions .btn--primary.grow { width: 100%; }

.footer-actions { display: flex; gap: var(--space-3); justify-content: space-between; padding: var(--space-4); }

/* Result screen */
.result-hero {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-3); align-items: center;
}
.result-hero .medal {
  width: 96px; height: 96px; border-radius: var(--radius-full);
  background: linear-gradient(135deg, #ffd76b, #ff8a3d);
  display: grid; place-items: center; font-size: 48px; color: white;
  box-shadow: var(--shadow-lg);
}

/* Toggle group */
.toggles {
  display: flex; gap: var(--space-2); flex-wrap: wrap;
}
.toggle {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted);
}
.toggle[aria-pressed="true"] {
  background: var(--color-primary); color: white; border-color: var(--color-primary);
}

/* Small helpers */
.h2 { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 700; }
.muted { color: var(--color-text-muted); }
.right { margin-left: auto; }
.grow { flex: 1; }
.center { text-align: center; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,14,26,0.5);
  display: grid; place-items: center; padding: var(--space-4);
  z-index: 100;
}
.modal {
  background: var(--color-surface); border-radius: var(--radius-xl);
  padding: var(--space-6); max-width: 480px; width: 100%;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: var(--space-4);
  max-height: 90dvh; overflow: auto;
}

/* Verbs table */
.vtable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
.vtable th, .vtable td { padding: var(--space-2) var(--space-3); text-align: left; border-bottom: 1px solid var(--color-divider); }
.vtable th { color: var(--color-text-muted); font-weight: 700; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; }

/* Loader */
.loader { display: grid; place-items: center; min-height: 60dvh; gap: var(--space-4); }
.spin { width: 40px; height: 40px; border: 3px solid var(--color-border); border-top-color: var(--color-primary); border-radius: 50%; animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  background: var(--color-text); color: var(--color-bg);
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-full);
  font-size: var(--text-sm); font-weight: 600;
  box-shadow: var(--shadow-lg); z-index: 200;
  opacity: 0; transition: opacity 200ms;
}
.toast.show { opacity: 1; }

@media (max-width: 380px) {
  .tiles { grid-template-columns: 1fr; }
}

/* ============ v2 additions ============ */

/* Rank card on home */
.rank-card {
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: white;
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.rank-card .pcard__value,
.rank-card .pcard__label { color: white; opacity: .92; }
/* Светлый вариант (герой на home) — текст тёмный, чтобы было видно на светлом градиенте */
.rank-card--hero .pcard__label { color: #374151; opacity: 1; }
.rank-card--hero .pcard__value { color: #1f2937; }
.rank-card--hero .muted { color: #6b7280 !important; }
.rank-card--hero .rank-next { color: #6b7280 !important; }
.rank-card .bar { background: rgba(255,255,255,0.25); }
.rank-card::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(60% 50% at 100% 0%, rgba(255,255,255,0.25), transparent 60%);
  pointer-events: none;
}
.rank-card__row { display: flex; align-items: center; gap: var(--space-3); position: relative; }
.rank-card__medal {
  width: 56px; height: 56px; border-radius: var(--radius-full);
  background: rgba(255,255,255,0.22);
  display: grid; place-items: center; font-size: 28px;
  flex-shrink: 0;
}
.rank-card__name { font-family: var(--font-display); font-weight: 800; font-size: var(--text-xl); line-height: 1.1; }
.rank-card__sub { opacity: .9; font-size: var(--text-sm); }
.rank-card__bar {
  margin-top: var(--space-3); height: 10px; border-radius: var(--radius-full);
  background: rgba(255,255,255,0.25); overflow: hidden;
  position: relative;
}
.rank-card__bar::after {
  content: ""; position: absolute; inset: 0; width: var(--rank-progress, 0%);
  background: white; border-radius: inherit; transition: width 500ms ease;
}
.rank-card__xp { margin-top: var(--space-2); font-size: var(--text-sm); opacity: .95; position: relative; display: flex; justify-content: space-between; }

/* Stats grid */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3);
}
.stat-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-1);
}
.stat-box__ico { font-size: 22px; }
.stat-box__value { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; line-height: 1; }
.stat-box__label { color: var(--color-text-muted); font-size: var(--text-xs); }

/* 7-day chart */
.chart7 {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--space-2);
  align-items: end;
  height: 120px;
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.chart7__col { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); height: 100%; justify-content: end; }
.chart7__bar {
  width: 100%;
  min-height: 3px;
  background: linear-gradient(180deg, var(--color-primary), var(--color-accent-2));
  border-radius: var(--radius-sm);
  transition: height 400ms ease;
}
.chart7__label { font-size: var(--text-xs); color: var(--color-text-muted); }
.chart7__col--green .chart7__label { color: #16a34a; font-weight: 700; }
.chart7__bar--green { background: linear-gradient(180deg, #22c55e, #16a34a) !important; box-shadow: 0 0 0 2px #86efac inset; }
.chart7__check { font-size: var(--text-xs); color: #16a34a; font-weight: 800; line-height: 1; margin-top: 2px; }
.weak-line { display: flex; justify-content: space-between; padding: var(--space-2) 0; border-bottom: 1px solid var(--color-divider); font-size: var(--text-sm); }
.weak-line:last-child { border-bottom: none; }
.weak-line b { font-family: var(--font-display); font-weight: 700; }
.weak-line span { color: var(--color-text-muted); }

/* Honest report table */
.honest-table {
  display: flex; flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.honest-row {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1fr auto;
  gap: var(--space-2);
  padding: var(--space-3);
  align-items: center;
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-sm);
}
.honest-row:last-child { border-bottom: none; }
.honest-row--head { background: var(--color-surface-2); color: var(--color-text-muted); font-weight: 700; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; }
.honest-row--sus { background: var(--color-error-highlight); }
.honest-row b { font-family: var(--font-display); font-weight: 700; }
.honest-badge {
  display: inline-block;
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 700;
  background: var(--color-surface-2); color: var(--color-text-muted);
}
.honest-badge--ok { background: var(--color-success-highlight); color: var(--color-success); }
.honest-badge--sus { background: var(--color-error-highlight); color: var(--color-error); }

/* Ranks list */
.rank-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  opacity: .6;
}
.rank-row--got { opacity: 1; border-color: var(--color-primary); background: var(--color-primary-highlight); }
.rank-dot {
  width: 40px; height: 40px; border-radius: var(--radius-full);
  background: var(--color-surface-2);
  display: grid; place-items: center; font-size: 20px;
}
.rank-row--got .rank-dot { background: linear-gradient(135deg, var(--color-primary), var(--color-accent)); color: white; }
.rank-row__name { font-family: var(--font-display); font-weight: 700; }
.rank-row__xp { color: var(--color-text-muted); font-size: var(--text-sm); }

/* Achievements */
.ach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
.ach-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-1);
  opacity: .45;
  filter: grayscale(0.6);
}
.ach-tile--got { opacity: 1; filter: none; border-color: var(--color-accent); box-shadow: 0 4px 12px rgba(255,138,61,0.15); }
.ach-tile__ico { font-size: 28px; }
.ach-tile__name { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); }
.ach-tile--got .ach-tile__name { color: var(--color-text); }

/* Menu list (settings) */
.menu-list { display: flex; flex-direction: column; gap: var(--space-2); }
.menu-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: left; width: 100%;
  font-weight: 600;
}
.menu-item:hover { border-color: var(--color-primary); }
.menu-item__ico { font-size: 22px; width: 36px; text-align: center; }

/* Reader */
.reader-list { display: flex; flex-direction: column; gap: var(--space-3); }
.reader-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-2);
  text-align: left; width: 100%;
  transition: transform var(--transition), box-shadow var(--transition);
}
.reader-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--color-primary); }
.reader-card__kind {
  font-size: var(--text-xs); font-weight: 700;
  color: var(--color-primary); text-transform: uppercase; letter-spacing: 0.05em;
}
.reader-card__title { font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); }
.reader-card__preview { color: var(--color-text-muted); font-size: var(--text-sm); line-height: 1.4; }

.reader-head { display: flex; align-items: center; gap: var(--space-3); }
.reader-head h2 { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; }
.reader-text {
  font-size: var(--text-base);
  line-height: 1.7;
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.reader-text p { margin-bottom: var(--space-3); }
.rw {
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 2px;
  transition: background 150ms;
}
.rw:hover { background: var(--color-primary-highlight); }
.rw.tapped { background: var(--color-primary-highlight); color: var(--color-primary); font-weight: 600; }
.rw.known { background: var(--color-success-highlight); }
.reader-ru {
  padding: var(--space-3);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-style: italic;
}

/* Balloon game */
.balloon-wrap {
  display: flex; flex-direction: column;
  gap: var(--space-2);
}
[data-theme="dark"] .balloon-wrap {
  background: linear-gradient(180deg, #1a2340 0%, #191830 100%);
}
.balloon-topbar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
[data-theme="dark"] .balloon-topbar { background: rgba(25,24,48,0.7); }
.balloon-hud {
  margin-left: auto;
  display: flex; gap: var(--space-3); align-items: center;
  font-weight: 700;
}
.balloon-score { color: var(--color-primary); font-family: var(--font-display); font-size: var(--text-lg); }
.balloon-timer { color: var(--color-accent); font-family: var(--font-display); font-size: var(--text-lg); }
.balloon-miss { color: var(--color-error); font-size: var(--text-sm); }
.balloon-prompt {
  padding: var(--space-3) var(--space-4);
  background: rgba(255,255,255,0.85);
  border-radius: var(--radius-full);
  margin: var(--space-3);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  text-align: center;
  box-shadow: var(--shadow-md);
}
[data-theme="dark"] .balloon-prompt { background: rgba(25,24,48,0.9); }
.balloon-canvas {
  width: 100%;
  min-height: 70dvh;
  height: 70dvh;
  display: block;
  touch-action: manipulation;
  background: linear-gradient(180deg, #e0f2fe 0%, #f5f3ff 100%);
  border-radius: var(--radius-lg);
}

/* Verb detail */
.verb-forms {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
}
.verb-form { text-align: center; display: flex; flex-direction: column; gap: var(--space-1); }
.verb-form__label { font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.verb-form__value { font-family: var(--font-display); font-weight: 800; font-size: var(--text-lg); }

/* Session card + progress bar */
.session-card {
  display: flex; flex-direction: column; gap: var(--space-4);
  flex: 1;
}

/* ===== Session layout — высота подстраивается под клавиатуру ===== */
/* --vvh: высота видимой части viewport, выставляется из JS на visualViewport resize */
:root { --vvh: 100dvh; --kb: 0px; }

/* Когда активна сессия — блокируем общий скролл тела, чтобы клава не могла его сдвигать */
body.session-active { overflow: hidden; overscroll-behavior: none; }
body.session-active #app { height: var(--vvh); min-height: 0; overflow: hidden; }
body.session-active .topbar { display: none; } /* во время сессии верхний бар не нужен — больше места */
body.session-active .screen { padding: 0; gap: 0; height: 100%; min-height: 0; overflow: hidden; }

.session-shell {
  display: flex; flex-direction: column;
  height: 100%; min-height: 0;
}
.session-shell .progress {
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  flex: 0 0 auto;
}
.session-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-4);
  display: flex; flex-direction: column;
}
.session-body .card {
  min-height: 0;
  box-shadow: none;
  padding: var(--space-4);
  gap: var(--space-3);
  flex: 1 1 auto;
}
/* Клава не должна перекрывать ввод: в карточке с <form.dictate> делаем её sticky bottom */
.session-body .card .dictate {
  position: sticky; bottom: 0; z-index: 5;
  background: var(--color-surface);
  padding: var(--space-2) 0 calc(var(--space-1) + env(safe-area-inset-bottom));
  margin-top: auto; /* прижимаем к низу, верхняя часть карточки занимает остальное */
}
.session-body .card .reveal { flex: 0 0 auto; }
/* верхняя часть карточки занимает все доступное место; iOS не дёргает слово вверх */
.session-body .card .card__word,
.session-body .card .word,
.session-body .card .ru,
.session-body .card .card__ipa,
.session-body .card .ipa { flex: 0 0 auto; }
/* input — крупный, iOS не будет зумить (font-size ≥ 16px) */
.session-body .card .dictate input { font-size: max(16px, var(--text-lg)); }
/* Панель ввода — приклеена к низу, всегда над клавиатурой */
.input-dock {
  flex: 0 0 auto;
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
  background: var(--color-surface);
  border-top: 1px solid var(--color-divider);
  box-shadow: 0 -8px 24px rgba(0,0,0,0.08);
}
[data-theme="dark"] .input-dock { box-shadow: 0 -8px 24px rgba(0,0,0,0.35); }
.input-dock .dictate { margin: 0; }
.input-dock .reveal { margin-top: var(--space-2); font-size: var(--text-sm); }

/* Когда в карточке нет input'а — панели нет, всё просто в body */

.progress { display: flex; align-items: center; gap: var(--space-3); flex: 1; }
.progress__bar {
  flex: 1; height: 10px; border-radius: var(--radius-full);
  background: var(--color-surface-offset); overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  transition: width 300ms ease;
  border-radius: inherit;
}
.progress__fill--time { background: linear-gradient(90deg, #f59e0b, #ef4444); transition: width 200ms linear; }
.progress__count { font-weight: 700; font-size: var(--text-sm); color: var(--color-text-muted); min-width: 92px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Sentence display */
.sentence {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  text-align: center;
  padding: var(--space-3) 0;
  line-height: 1.4;
}

/* Answer row for honest self-grading */
.answer-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-2);
}
.answer-row .btn { min-height: 52px; }
.grade-hint {
  font-size: var(--text-sm); color: var(--color-text-muted); text-align: center;
  padding: var(--space-2);
}

/* Result screen additions */
.result-xp {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
}
.result-line { font-size: var(--text-base); color: var(--color-text-muted); }
.result-ach { display: flex; flex-direction: column; gap: var(--space-2); }
.ach-line {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-warning-highlight);
  border-radius: var(--radius-md);
  font-weight: 600;
}

/* Speaker big variant */
.speaker--big {
  width: 96px; height: 96px; font-size: 44px;
}

/* Choice variant for english word target */
.choice--en {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-lg);
}

/* Example block */
.example, .verb-example {
  padding: var(--space-3);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.example__en { font-family: var(--font-display); font-weight: 600; }
.example__ru { color: var(--color-text-muted); font-style: italic; margin-top: 4px; }
.reveal { margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px dashed var(--color-divider); }

/* Field (label + input) */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label { font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); }
.field input, .field textarea, .field select {
  padding: var(--space-3);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-base);
  min-height: 48px;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--color-primary); }
.field textarea { resize: vertical; min-height: 80px; }

/* Word modal (reader popup) */
.modal--word { max-width: 380px; }
.modal--word .card__word { font-size: var(--text-xl); padding: 0; }

/* Stack helper */
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.rank-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rank-info__name { font-family: var(--font-display); font-weight: 800; font-size: var(--text-lg); line-height: 1.1; }

/* Modal close */
.modal-close {
  align-self: flex-end;
  width: 36px; height: 36px; border-radius: var(--radius-full);
  background: var(--color-surface-2); color: var(--color-text-muted);
  display: grid; place-items: center; font-size: 20px;
  margin-bottom: calc(-1 * var(--space-4));
}
.modal-close:hover { background: var(--color-surface-offset); color: var(--color-text); }

/* Btn variants */
.btn--warning { background: var(--color-warning); color: white; border-color: var(--color-warning); }
.btn--warning:hover { filter: brightness(0.95); }
.btn--success { background: var(--color-success); color: white; border-color: var(--color-success); }
.btn--success:hover { filter: brightness(0.95); }

/* Choice grid 2col for balloon results */
.choices--2 { grid-template-columns: 1fr 1fr; }

/* Small screens */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .ach-grid { grid-template-columns: repeat(2, 1fr); }
  .verb-forms { grid-template-columns: 1fr; gap: var(--space-2); }
  .honest-row { grid-template-columns: 1fr; gap: var(--space-1); }
  .honest-row--head { display: none; }
  .answer-row { grid-template-columns: 1fr; }
}

/* Card content classes (word/ru/ipa) */
.card .word, .modal .word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-2xl);
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-align: center;
  padding: var(--space-2) 0;
}
.card .ipa, .modal .ipa {
  color: var(--color-text-muted);
  font-size: var(--text-base);
  text-align: center;
}
.card .ru, .modal .ru {
  color: var(--color-text);
  text-align: center;
  font-size: var(--text-lg);
  font-weight: 600;
}



/* ================ Аватары рангов ================ */
.rank-card--hero { padding: var(--space-4); }
.rank-hero {
  display: flex; align-items: center; gap: var(--space-4);
  margin-bottom: var(--space-2);
}
.rank-avatar {
  width: 96px; height: 96px; object-fit: cover; object-position: top;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.25), rgba(255,255,255,.05));
  box-shadow: 0 8px 24px rgba(0,0,0,.15), 0 0 0 3px rgba(255,255,255,.6) inset;
  flex-shrink: 0;
}
.rank-avatar--big { width: 128px; height: 128px; border-radius: 24px; }
.rank-hero__info { flex: 1; min-width: 0; }
.rank-hero__info .pcard__value { color: white; font-size: var(--text-2xl); }
.rank-hero__info .pcard__label { color: rgba(255,255,255,.9); }
.rank-next { color: rgba(255,255,255,.85) !important; font-size: var(--text-sm); margin-top: var(--space-1); }

.rank-avatars-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2);
  margin-top: var(--space-2);
}
.rank-avatar-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: var(--space-2); border-radius: 12px;
  background: var(--color-surface-2, #f1f5f9);
  opacity: 0.45; filter: grayscale(0.8);
  transition: opacity .3s, filter .3s;
}
.rank-avatar-tile.got { opacity: 1; filter: none; box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.rank-avatar-mini {
  width: 68px; height: 68px; object-fit: cover; object-position: top;
  border-radius: 14px; background: rgba(255,255,255,.5);
}
.rank-avatar-tile__name { font-size: var(--text-xs); font-weight: 700; text-align: center; }
.rank-avatar-tile__xp { font-size: 11px; }
@media (max-width: 480px) {
  .rank-avatars-row { grid-template-columns: repeat(2, 1fr); }
  .rank-avatar { width: 72px; height: 72px; border-radius: 14px; }
  .rank-avatar--big { width: 96px; height: 96px; }
}

/* Grade actions — 2 варианта вместо 3 */
.grade--2 { grid-template-columns: 1fr 1fr !important; }

/* ================ Детективные рассказы ================ */
.stories-list {
  display: grid; grid-template-columns: 1fr; gap: var(--space-3);
  margin: var(--space-3) 0;
}
.story-card {
  position: relative; text-align: left;
  padding: var(--space-4);
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: white;
  border: none; border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.15);
  transition: transform .15s;
  display: flex; flex-direction: column; gap: var(--space-2);
}
.story-card:hover { transform: translateY(-2px); }
.story-card__badge {
  display: inline-block; align-self: flex-start;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,.15); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.story-card__badge--done {
  background: #22c55e; color: white; margin-top: var(--space-2);
}
.story-card__title { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; line-height: 1.2; }
.story-card__meta {
  display: flex; justify-content: space-between; gap: var(--space-2);
  color: rgba(255,255,255,.75); font-size: var(--text-sm);
}
.story-card .bar { background: rgba(255,255,255,.15); }
.story-card .bar__fill { background: linear-gradient(90deg, #38bdf8, #a78bfa); }

.story-head__title { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; }

/* Подчёркивание словарных слов в тексте убрано — все слова кликабельны, но визуально не выделяются */

.story-vocab-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin-top: var(--space-2);
}
.story-vocab-item {
  padding: 8px 10px;
  background: var(--color-surface-2, #f1f5f9);
  border-radius: 10px;
  font-size: var(--text-sm);
  display: flex; flex-direction: column; gap: 2px;
}
.story-vocab-item__head {
  display: flex; align-items: center; gap: 4px;
}
.story-vocab-item__en { font-weight: 700; color: var(--color-text); font-size: var(--text-base); }
.story-vocab-item .muted { font-size: 13px; line-height: 1.25; }
.speaker--inline {
  background: none; border: none; cursor: pointer;
  font-size: 14px; padding: 0 2px; opacity: 0.55; line-height: 1;
}
.speaker--inline:hover { opacity: 1; }
@media (max-width: 380px) {
  .story-vocab-grid { grid-template-columns: 1fr; }
}

/* ================ Continue reading row ================ */
.continue-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3); border-radius: 12px;
  background: linear-gradient(135deg, #1e293b, #334155);
  color: white; border: none; cursor: pointer; text-align: left;
  width: 100%; margin-bottom: var(--space-2);
  transition: transform .12s;
}
.continue-row:hover { transform: translateY(-1px); }
.continue-row__ico { font-size: 24px; flex-shrink: 0; }
.continue-row__body { flex: 1; min-width: 0; }
.continue-row__title { font-weight: 700; font-size: var(--text-base); margin-bottom: 2px; }
.continue-row__body .muted { color: rgba(255,255,255,.75); }
.continue-row__body .bar { background: rgba(255,255,255,.15); margin-top: 6px; }
.continue-row__body .bar__fill { background: linear-gradient(90deg, #38bdf8, #a78bfa); }
.continue-row__arrow { font-size: 20px; opacity: 0.7; flex-shrink: 0; }

/* === Fix 2026-09-10: гарантированно кликабельная «Дальше» на телефоне === */
.reveal .btn, .card-actions .btn { position: relative; z-index: 2; }
/* Полноширинная «Дальше» когда стоит одна в reveal или в конце flex-строки */
.reveal .card-actions,
.reveal > .btn--primary {
  width: 100%;
}
.reveal > .btn--primary {
  min-height: 56px;
  padding: 16px 22px;
  font-size: var(--text-base);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}
.reveal .card-actions .btn--primary {
  min-height: 56px;
  flex: 2 1 60%;
  padding: 16px 22px;
  font-size: var(--text-base);
}
.reveal .card-actions .btn { min-height: 52px; }
@media (max-width: 480px){
  .reveal .card-actions { flex-direction: column; }
  .reveal .card-actions .btn { width: 100%; }
}

