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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#app {
  width: 100%;
  max-width: 500px;
  min-height: 100vh;
  position: relative;
  padding: 20px;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
}

.screen.active {
  display: flex;
}

/* Главное меню */
#screen-menu h1 {
  font-size: 2em;
  margin-bottom: 40px;
  text-align: center;
}

.btn {
  display: block;
  width: 100%;
  max-width: 350px;
  padding: 18px 24px;
  margin: 12px 0;
  border: none;
  border-radius: 14px;
  font-size: 1.1em;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
  font-weight: 600;
  text-align: center;
}

.btn:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.btn-primary {
  background: #e94560;
  color: #fff;
}

.btn-secondary {
  background: #0f3460;
  color: #fff;
}

.btn-back {
  background: transparent;
  color: #aaa;
  border: 1px solid #444;
  max-width: 200px;
  padding: 12px;
  font-size: 0.95em;
}

.btn-save {
  background: #2ecc71;
  color: #fff;
}

.btn-add {
  background: #3498db;
  color: #fff;
}

/* Выбор языка */
#screen-lang h2 {
  margin-bottom: 30px;
}

.lang-btn {
  width: 100%;
  max-width: 350px;
  padding: 18px;
  margin: 8px 0;
  background: #16213e;
  color: #eee;
  border: 1px solid #333;
  border-radius: 14px;
  font-size: 1.1em;
  cursor: pointer;
  transition: background 0.2s;
}

.lang-btn:active {
  background: #1a3a6e;
}

/* Карточка */
.learn-header {
  width: 100%;
  margin-bottom: 20px;
}

.card-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  perspective: 1000px;
}

.flashcard {
  width: 100%;
  max-width: 400px;
  height: 220px;
  position: relative;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.flashcard:active {
  cursor: grabbing;
}

.flashcard-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: #16213e;
  border: 2px solid #333;
}

.flashcard-back {
  transform: rotateY(180deg);
  background: #0f3460;
}

.word-original {
  font-size: 2.5em;
  font-weight: 700;
  margin-bottom: 10px;
}

.word-transcription {
  font-size: 1.2em;
  color: #aaa;
}

.word-translation {
  font-size: 2.5em;
  font-weight: 700;
  color: #e94560;
}

/* Счётчик */
.counter {
  margin-top: 20px;
  font-size: 1.1em;
  color: #aaa;
}

.learn-empty,
.learn-done {
  text-align: center;
  margin-top: 20px;
}

.learn-empty p,
.learn-done p {
  font-size: 1.3em;
  margin-bottom: 20px;
}

/* Редактор */
#screen-edit {
  justify-content: flex-start;
  padding-top: 20px;
}

#screen-edit h2 {
  margin-bottom: 20px;
}

#edit-list {
  width: 100%;
  max-height: 55vh;
  overflow-y: auto;
  margin-bottom: 16px;
}

.edit-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}

.edit-row .row-num {
  color: #888;
  min-width: 30px;
  font-size: 0.9em;
  text-align: right;
}

.edit-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid #444;
  border-radius: 8px;
  background: #16213e;
  color: #eee;
  font-size: 0.95em;
}

.edit-row input::placeholder {
  color: #555;
}

.edit-row .btn-delete {
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 1em;
  flex-shrink: 0;
}

/* Утилиты */
.hidden {
  display: none !important;
}