:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #627082;
  --line: #d9e1ea;
  --accent: #2878c8;
  --accent-dark: #185a9d;
  --good: #188455;
  --warn: #b95516;
  --soft: #eef5fb;
  --shadow: 0 16px 42px rgba(28, 46, 70, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.15;
}

.subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 18px;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span {
  min-width: 92px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
}

.stats strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.mode-tabs {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tab {
  min-width: 92px;
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

select {
  min-width: 150px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  font-size: 24px;
  line-height: 1;
}

.trainer {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}

.card-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 22px;
  align-items: stretch;
}

.image-frame {
  min-height: 390px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  overflow: hidden;
}

.image-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.answer-block {
  min-height: 390px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.answer {
  font-size: 56px;
  line-height: 1.08;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.prompt {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.choice-grid button {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
}

.choice-grid button.correct {
  border-color: var(--good);
  background: #e8f7ef;
  color: var(--good);
}

.choice-grid button.wrong {
  border-color: #d27777;
  background: #fff0f0;
  color: #9c2f2f;
}

.spell-panel {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.spell-panel input {
  flex: 1;
  min-width: 0;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  font-size: 22px;
}

.spell-panel button {
  min-width: 110px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.feedback {
  min-height: 30px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 18px;
}

.feedback.good {
  color: var(--good);
  font-weight: 700;
}

.feedback.warn {
  color: var(--warn);
  font-weight: 700;
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.actions button,
.progress-head button {
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  font-weight: 800;
}

.primary {
  background: var(--accent);
}

.primary:hover,
.spell-panel button:hover {
  background: var(--accent-dark);
}

.secondary {
  background: #5d7088;
}

.success {
  background: var(--good);
}

.progress-section {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.progress-head h2 {
  font-size: 22px;
}

.progress-head button {
  min-height: 42px;
  background: #7a5668;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}

.word-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

.word-chip.current {
  border-color: var(--accent);
  color: var(--accent);
  background: #eef7ff;
}

.word-chip.known {
  border-color: #b8e2cb;
  color: var(--good);
  background: #effaf4;
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .app {
    width: min(100vw - 20px, 680px);
    padding-top: 14px;
  }

  .topbar,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    justify-content: stretch;
  }

  .stats span {
    flex: 1;
  }

  .mode-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .tab {
    min-width: 0;
  }

  .select-wrap {
    justify-content: space-between;
  }

  .card-panel {
    grid-template-columns: 1fr;
  }

  .image-frame,
  .answer-block {
    min-height: 260px;
  }

  .answer {
    font-size: 42px;
  }

  .choice-grid,
  .actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 26px;
  }

  .trainer,
  .progress-section {
    padding: 12px;
  }

  .choice-grid,
  .actions,
  .spell-panel {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
