:root {
  --bg:        #0a0a0f;
  --surface:   #13131a;
  --surface2:  #1c1c26;
  --text:      #e5e7eb;
  --text2:     #9ca3af;
  --accent:    #60a5fa;
  --accent-glow:#60a5fa33;
  --green:     #34d399;
  --green-glow:#34d39933;
  --red:       #f87171;
  --red-glow:  #f8717133;
  --orange:    #fb923c;
  --orange-glow:#fb923c33;
  --border:    #2a2a35;
  --shadow-sm: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -1px rgba(0,0,0,0.2);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -2px rgba(0,0,0,0.2);
  --radius:    16px;
  --radius-lg: 24px;
  
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding: 0 16px;
  padding-top: calc(90px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
  line-height: 1.5;
}

body.settings-open {
  overflow: hidden;
  height: 100dvh;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg);
  padding: calc(12px + var(--safe-top)) 16px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.back {
  font-size: 2rem;
  color: var(--accent);
  text-decoration: none;
  transition: transform 0.2s;
}

.back:hover {
  transform: scale(1.15);
}

h1 {
  font-size: 1.6rem;
  font-weight: 600;
  flex: 1;
  text-align: center;
  letter-spacing: -0.02em;
}

.big-btn {
  display: block;
  width: 100%;
  max-width: 400px;
  margin: 20px auto;
  padding: 22px 32px;
  font-size: 1.35rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-lg);
  text-align: center;
  text-decoration: none;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
}

.big-btn:hover,
.big-btn:focus-visible {
  background: var(--surface2);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-md);
  transform: translateY(-2px);
}

.word-list-container {
  height: calc(100dvh - var(--safe-top) - 80px); /* высота шапки ~80px */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 8px 100px;           /* ← ключевой момент: большой отступ снизу */
  margin: 0 -8px;
  box-sizing: border-box;
}

/* Если слов мало — всё равно растягиваем до низа */
.word-list-container:has(> :last-child) {
  min-height: calc(100dvh - var(--safe-top) - 80px);
}

.word-item {
  padding: 18px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  margin: 0 8px 12px;
  font-size: 1.18rem;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: center;
}

.word-item:hover {
  background: var(--surface2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Модальные окна */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: var(--safe-top) 16px var(--safe-bottom);
}

.modal-box {
  background: var(--surface);
  padding: 32px 28px;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  text-align: center;
}

#modal-hy,
#modal-ru {
  text-align: center;
}

#modal-hy {
  font-size: clamp(1.8rem, 10vw, 3.2rem);
  line-height: 1.15;
  margin: 20px 0;
  font-weight: 500;
  color: var(--accent);
  word-break: break-all;
  overflow-wrap: anywhere;
  hyphens: auto;
}

/* Кнопки */
.modal-box button,
.action-btn,
.success,
.danger {
  font-size: 1.05rem;
  font-weight: 500;
  padding: 14px 28px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.22s ease;
  border: none;
  width: 100%;
  margin: 10px 0;
}

.action-btn {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  color: white;
  box-shadow: 0 4px 12px rgba(59,130,246,0.35);
  position: sticky;
  top: calc(12px + var(--safe-top));
  z-index: 10;
  margin: 0 0 16px;
}

.success {
  background: linear-gradient(135deg, #10b981, #34d399);
  color: white;
  box-shadow: 0 4px 12px rgba(16,185,129,0.35);
}

.danger {
  background: linear-gradient(135deg, #ef4444, #f87171);
  color: white;
  box-shadow: 0 4px 12px rgba(239,68,68,0.35);
}

.action-btn:hover,
.success:hover,
.danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

/* Статистика */
.stats {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.stats-row {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-bottom: 16px;
  font-size: 1.3rem;
  font-weight: 500;
}

.correct-count::before {
  content: "✔ ";
  color: var(--green);
  margin-right: 8px;
  font-weight: bold;
}

.wrong-count::before {
  content: "✘ ";
  color: var(--red);
  margin-right: 8px;
  font-weight: bold;
}

.reset-tag {
  display: inline-block;
  background: rgba(249, 115, 22, 0.18);
  color: var(--orange);
  font-size: 0.92rem;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(249, 115, 22, 0.3);
  margin: 8px 0 16px;
}

.stats .reset-time-none {
  color: var(--text2);
  font-size: 0.95rem;
  font-style: italic;
  margin: 12px 0;
}

#reset {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 10px 20px;
  font-size: 0.98rem;
  border-radius: var(--radius);
  transition: all 0.2s;
}

#reset:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: var(--red);
  transform: translateY(-1px);
}

/* Вопросы и ответы */
.question {
  font-size: 2.8rem;
  font-weight: 600;
  text-align: center;
  margin: 48px 0 64px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.answers {
  display: grid;
  gap: 16px;
}

.answer-btn {
  padding: 22px 28px;
  font-size: 1.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-lg);
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.answer-btn:hover {
  background: var(--surface2);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.answer-btn.correct {
  background: linear-gradient(135deg, var(--green), #10b981);
  color: white;
  border: none;
  box-shadow: 0 0 0 4px var(--green-glow), var(--shadow-md);
  transform: scale(1.04);
}

.answer-btn.wrong {
  background: linear-gradient(135deg, var(--red), #ef4444);
  color: white;
  border: none;
  box-shadow: 0 0 0 4px var(--red-glow), var(--shadow-md);
  transform: scale(1.02);
}

/* Плавное появление */
.question, .answers {
  opacity: 0;
  animation: fadeIn 0.5s forwards;
}

@keyframes fadeIn {
  to { opacity: 1; }
}