:root {
  --bg-top: #fff4d8;
  --bg-bottom: #dff7f3;
  --ink: #1d2a37;
  --soft-ink: #445468;
  --card: #ffffff;
  --line: #dce7ea;
  --warm: #ff7b35;
  --cool: #0f9d8a;
  --gold: #ffca3a;
  --danger: #d94d3f;
  --ok: #1d9f55;
  --title-font: "STKaiti", "KaiTi", "Kaiti SC", serif;
  --body-font: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--body-font);
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
  position: relative;
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 123, 53, 0.2), transparent 30%),
    radial-gradient(circle at 82% 15%, rgba(15, 157, 138, 0.2), transparent 35%),
    radial-gradient(circle at 40% 82%, rgba(255, 202, 58, 0.2), transparent 30%);
  z-index: 0;
}

.page {
  max-width: 1060px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  position: relative;
  z-index: 1;
}

.panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 14px 30px rgba(39, 64, 78, 0.1);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 14px;
  backdrop-filter: blur(2px);
}

.hero {
  text-align: center;
  padding: 28px 16px;
}

.eyebrow {
  margin: 0;
  font-size: 14px;
  color: var(--cool);
  letter-spacing: 0.08em;
}

h1 {
  margin: 6px 0 12px;
  font-family: var(--title-font);
  font-size: clamp(34px, 6vw, 52px);
  line-height: 1.1;
}

h2 {
  margin: 0 0 8px;
  font-family: var(--title-font);
  font-size: clamp(24px, 4vw, 32px);
}

.hero-sub {
  margin: 0 auto;
  max-width: 700px;
  color: var(--soft-ink);
  line-height: 1.6;
  font-size: 16px;
}

.assessment-panel p {
  margin: 0;
  color: #4f6072;
}

.assessment-meta {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  font-weight: 700;
  color: #2c4055;
}

.assessment-char {
  margin-top: 10px;
  min-height: 118px;
  border-radius: 16px;
  border: 1px dashed #c9dde4;
  background: #f6fbfd;
  display: grid;
  place-items: center;
  text-align: center;
  font-family: var(--title-font);
  font-size: clamp(50px, 10vw, 92px);
  line-height: 1;
  color: #1f3347;
}

.assessment-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.assessment-result {
  min-height: 24px;
  margin-top: 10px;
  font-weight: 700;
}

.progress-panel {
  display: grid;
  gap: 12px;
}

.progress-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: #e9f2f5;
  overflow: hidden;
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--warm), var(--gold), var(--cool));
  transition: width 0.28s ease;
}

.actions-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.scope-hint {
  margin: 0;
  width: 100%;
  color: #3c4f61;
  font-weight: 700;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: #eef6f8;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.btn:disabled,
.mini-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.btn.primary {
  background: linear-gradient(135deg, #ff9147, #ffba3a);
}

.btn.ghost {
  background: #fbe9e7;
  color: #943329;
}

.card-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.card {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 12px;
  display: grid;
  gap: 8px;
  box-shadow: 0 8px 18px rgba(48, 67, 80, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(35, 56, 73, 0.14);
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 4px;
  background: var(--tone-color);
}

.card.tone-1 {
  --tone-color: #ff7b35;
}

.card.tone-2 {
  --tone-color: #0f9d8a;
}

.card.tone-3 {
  --tone-color: #4d8ef7;
}

.card.tone-4 {
  --tone-color: #d94d3f;
}

.card.mastered {
  border-color: #9fd8bc;
  background: linear-gradient(180deg, #ffffff, #f2fff7);
}

.card.spotlight {
  outline: 3px solid #ffbe58;
  outline-offset: -3px;
}

.char {
  font-family: var(--title-font);
  font-size: 56px;
  line-height: 1;
  margin: 4px 0 0;
}

.pinyin {
  margin: 0;
  color: #2e4153;
  font-size: 20px;
  font-weight: 700;
}

.pinyin small {
  margin-left: 6px;
  color: #718091;
  font-size: 13px;
}

.illustration {
  min-height: 84px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.9), transparent 45%),
    linear-gradient(135deg, rgba(255, 174, 124, 0.3), rgba(89, 197, 188, 0.3));
  font-size: 37px;
  letter-spacing: 2px;
}

.word,
.hint {
  margin: 0;
}

.word {
  font-weight: 700;
}

.hint {
  font-size: 14px;
  line-height: 1.45;
  color: #4f6072;
}

.card-actions {
  margin-top: 4px;
  display: flex;
  gap: 6px;
}

.mini-btn {
  flex: 1;
  border: 0;
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  background: #eff6f8;
}

.mini-btn.master-btn {
  background: #ecf8ef;
  color: #1f7a45;
}

.mini-btn.master-btn.on {
  background: #1f9f56;
  color: white;
}

.quiz-panel p {
  margin: 0;
  color: #4f6072;
}

.quiz-meta {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  font-weight: 700;
  color: #2c4055;
}

.quiz-prompt {
  margin-top: 10px;
  padding: 14px;
  border-radius: 12px;
  background: #f6fbfd;
  border: 1px dashed #c9dde4;
  font-size: 21px;
  min-height: 62px;
  display: grid;
  place-items: center;
  text-align: center;
  line-height: 1.4;
}

.quiz-options {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.quiz-option {
  border: 1px solid #d4e4ea;
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  font-size: 22px;
  font-family: var(--title-font);
  cursor: pointer;
}

.quiz-option.pinyin {
  font-family: var(--body-font);
  font-weight: 700;
  font-size: 21px;
}

.quiz-option:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

.quiz-option.correct {
  border-color: #86d7ac;
  background: #f1fff6;
}

.quiz-option.wrong {
  border-color: #e9a59e;
  background: #fff4f2;
}

.quiz-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quiz-feedback {
  min-height: 24px;
  margin-top: 8px;
  font-weight: 700;
}

.quiz-feedback.ok {
  color: var(--ok);
}

.quiz-feedback.no {
  color: var(--danger);
}

.dict-meta {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  font-weight: 700;
  color: #2c4055;
}

.dict-controls {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dict-prompt {
  margin-top: 10px;
  padding: 14px;
  border-radius: 12px;
  background: #f6fbfd;
  border: 1px dashed #c9dde4;
  min-height: 56px;
  display: grid;
  place-items: center;
  text-align: center;
  line-height: 1.4;
  font-size: 18px;
}

.dict-mode-switch {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-btn {
  min-width: 96px;
}

.mode-btn.on {
  background: #0f9d8a;
  color: #fff;
}

.dict-area {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #d7e6eb;
  background: #fcfeff;
}

.dict-area label,
.dict-area p {
  margin: 0;
  color: #4f6072;
}

.dict-input-row {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#dictInput {
  min-width: 140px;
  max-width: 220px;
  border: 1px solid #bfd5de;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 26px;
  font-family: var(--title-font);
  text-align: center;
  background: #fff;
}

#dictCanvas {
  margin-top: 10px;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid #c8dbe3;
  background: #fff;
  touch-action: none;
}

.dict-write-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dict-answer {
  margin-top: 10px;
  font-size: 20px;
  font-weight: 700;
  color: #223a4f;
}

.dict-judge {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@keyframes pop {
  from {
    transform: scale(0.96);
  }
  to {
    transform: scale(1);
  }
}

.card,
.quiz-prompt {
  animation: pop 0.26s ease;
}

@media (max-width: 640px) {
  .panel {
    border-radius: 16px;
    padding: 14px;
  }

  .char {
    font-size: 48px;
  }

  .pinyin {
    font-size: 18px;
  }

  .quiz-prompt {
    font-size: 19px;
  }

  .assessment-char {
    min-height: 98px;
    font-size: clamp(44px, 14vw, 70px);
  }

  #dictInput {
    width: 100%;
    max-width: none;
  }

  #dictCanvas {
    max-width: 100%;
  }
}
