:root {
  color-scheme: light;
  --ink: #3a5244;
  --soft: rgba(255,255,255,.82);
  --blue: #6b9e9a;
  --teal: #5a947e;
  --orange: #d49440;
  --purple: #7a9a85;
  --green: #3d8056;
  --red: #c4594f;
  --yellow: #c89b38;
  --cream: #faf6ed;
  --wood: #e8dfc8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "楷体", "PingFang SC", "Microsoft YaHei", serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 10%, rgba(168,198,160,.35), transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(200,220,195,.3), transparent 50%),
    linear-gradient(180deg, #f6f3e8, #edf5eb 50%, #f5f0e5);
}

button, input, select { font: inherit; }
button { cursor: pointer; border: 0; }

.app { width: min(1180px, calc(100% - 18px)); margin: 0 auto; padding: 22px 0 46px; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
h1 {
  margin: 0;
  font-family: "ZCOOL KuaiLe", "Kaiti SC", "STKaiti", cursive;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.1;
  color: #4a6b52;
  text-shadow: 0 3px 0 rgba(255,255,255,.7);
}

.end-btn, .stat button, .task-bar button, .designer button {
  border-radius: 999px;
  padding: 16px 28px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, #5a946e, #8ab88a);
  box-shadow: 0 10px 24px rgba(90,140,100,.2);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 22px;
}
.stat {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border-radius: 22px;
  background: rgba(255,255,255,.82);
  border: 2px solid rgba(200,210,180,.4);
  box-shadow: 0 8px 20px rgba(80,100,60,.06);
  font-size: 22px;
  font-weight: 800;
}
.stat span, .stat label { color: #7a8a70; }
.stat strong { font-size: 34px; color: #4a6b52; }
.group-control {
  grid-column: span 3;
  display: grid;
  grid-template-columns: auto auto auto minmax(140px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 80px;
}
.group-control input { accent-color: #ff705e; min-width: 0; width: 100%; }
.group-control button, .design-stat button, .review-stat button { background: #fff; color: #4a6b52; box-shadow: 0 6px 16px rgba(80,100,60,.08); }
.group-control button, .design-stat button, .review-stat button { padding: 12px 22px; }
.question-idx {
  color: #4a6b52;
  font-size: 22px;
  white-space: nowrap;
}
.next-group-btn {
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #5a946e, #3d8056);
  box-shadow: 0 8px 20px rgba(60,120,70,.18);
  border: 0;
  cursor: pointer;
  white-space: nowrap;
  font-size: 18px;
}

.play-grid { display: grid; grid-template-columns: 180px minmax(300px, 1fr) 300px; gap: 16px; align-items: start; }
.panel, .stage-card, .designer, .summary {
  border-radius: 28px;
  background: rgba(255,255,255,.85);
  border: 2px solid rgba(200,210,180,.35);
  box-shadow: 0 10px 24px rgba(80,100,60,.06);
}
.panel { padding: 20px 18px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
h2 { margin: 0; font-size: 26px; color: #4a6b52; }
.panel-head span, .designer-title span { color: #7a8a70; font-weight: 800; }

.tile-grid, .final-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.final-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
.final-section { margin-bottom: 18px; }
.final-section h3 { margin: 10px 0 8px; font-size: 20px; color: #5a7a65; }
.tile {
  min-height: 54px;
  border-radius: 16px;
  font-size: 26px;
  font-weight: 900;
  color: #3a5244;
  background: linear-gradient(135deg, #f2f7ec, #e2edda);
  box-shadow: 0 6px 0 #c4d6b4, 0 12px 18px rgba(80,100,60,.06);
  transition: transform .18s ease, background .18s ease, color .18s ease;
}
.tile.final-tile { background: linear-gradient(135deg, #e8f2f0, #d8ebe6); box-shadow: 0 6px 0 #b8d5cc, 0 12px 18px rgba(60,90,70,.06); }
.tile.training-chip {
  min-height: 46px;
  color: #5a7a65;
  background: #e8efde;
  box-shadow: 0 5px 0 #c8d6b8;
  cursor: default;
  opacity: .9;
}
.tile.selected {
  color: #fff;
  background: linear-gradient(135deg, #5a946e, #3d8056);
  box-shadow: 0 7px 0 #2a5a3c, 0 14px 20px rgba(60,120,70,.18);
  transform: translateY(-4px) scale(1.05);
  animation: selectedPulse .85s ease both;
}
.tile.correct-reveal {
  position: relative;
  color: #fff;
  background: linear-gradient(135deg, #4d8a60, #6bb882);
  box-shadow: 0 7px 0 #356a3f, 0 14px 20px rgba(60,120,70,.2);
  transform: translateY(-4px) scale(1.05);
  animation: selectedPulse .85s ease both;
}
.tile.correct-reveal::after {
  content: "✓";
  position: absolute;
  top: -10px;
  right: -10px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: #3d8056;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 3px 8px rgba(0,0,0,.12);
  animation: popIn .35s ease-out;
}
@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes selectedPulse { 50% { transform: translateY(-8px) scale(1.12); } }

.stage-card { padding: 24px 28px; }
.task-bar { min-height: 82px; display: flex; align-items: center; gap: 14px; padding: 12px 26px; border-radius: 21px; background: #e8efe2; }
.task-bar strong { margin-right: auto; color: #5a7a65; font-size: 24px; }
.task-bar button { padding: 14px 26px; background: #fff; color: #4a6b52; box-shadow: 0 6px 16px rgba(80,100,60,.08); }
.stage {
  position: relative;
  height: 420px;
  margin-top: 18px;
  border: 3px dashed #bcd5c4;
  border-radius: 26px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #fffef8, #f0f7ed);
  overflow: hidden;
}
.stage[hidden], .design-workspace[hidden] { display: none; }
.design-workspace {
  min-height: 420px;
  margin-top: 18px;
  padding: 22px;
  border: 3px dashed #bcd5c4;
  border-radius: 26px;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 14px;
  background: linear-gradient(180deg, #fffef8, #f0f7ed);
}
.design-column {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}
.design-column > strong {
  font-size: 22px;
  color: #285789;
}
.heard-char {
  position: absolute;
  top: 36px;
  min-width: 190px;
  min-height: 140px;
  display: grid;
  place-items: center;
  border-radius: 26px;
  font-size: 92px;
  font-weight: 900;
  color: #4a6b52;
  background: #e2ede0;
  box-shadow: inset 0 1px 0 #fff, 0 12px 24px rgba(80,100,60,.08);
}
.heard-char:empty { display: none; }
.merge { display: flex; align-items: flex-end; justify-content: center; gap: 40px; margin-top: 100px; }
.piece-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
}
.piece-check {
  font-size: 34px;
  height: 48px;
  line-height: 48px;
  position: relative;
  z-index: 2;
}
.piece {
  width: 116px;
  height: 116px;
  display: grid;
  place-items: center;
  border-radius: 26px;
  font-size: 56px;
  color: #fff;
  font-weight: 900;
  text-shadow: 0 3px 0 rgba(0,0,0,.1);
}
.initial-piece { background: rgba(107,158,122,.4); }
.final-piece { background: rgba(150,172,120,.4); }
.plus { position: relative; z-index: 2; color: #7a9a85; font-size: 64px; font-weight: 900; }
.pinyin-result { position: absolute; bottom: 6px; font-size: 64px; font-weight: 900; color: #4a6b52; text-shadow: 0 6px 0 #c4d6b4; }
.stage.correct .pinyin-result { color: var(--green); transform: scale(1.08); }
.stage.tone .pinyin-result { color: var(--yellow); }
.stage.wrong .pinyin-result { color: var(--red); font-size: 56px; }

.tone-box { padding: 22px 28px 12px; }
.tone-labels { display: flex; justify-content: space-between; font-weight: 800; color: #7a8a70; }
.tone-btns { display: flex; gap: 8px; margin-top: 10px; }
.tone-btn {
  flex: 1;
  min-height: 58px;
  border-radius: 16px;
  font-size: 38px;
  font-weight: 900;
  color: #4a6b52;
  background: #fff;
  box-shadow: 0 6px 0 #d4deca, 0 12px 20px rgba(80,100,60,.06);
  transition: transform .18s ease, background .18s ease, color .18s ease, box-shadow .18s ease;
  cursor: pointer;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}
.tone-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #d4deca, 0 14px 22px rgba(80,100,60,.1); }
.tone-btn.active {
  color: #fff;
  background: linear-gradient(135deg, #6b9e8a, #5a946e);
  box-shadow: 0 7px 0 #3a6a4a, 0 14px 22px rgba(90,140,100,.2);
  transform: translateY(-3px);
  border-color: transparent;
}
#toneSlider { width: 100%; accent-color: #ff705e; }
#tonePreview { display: block; text-align: center; color: #ff705e; font-size: 35px; }
.steps { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin: 10px 0 18px; }
.steps span { padding: 14px 24px; border-radius: 999px; background: #fff; font-size: 22px; font-weight: 900; color: #5a7a65; }
.feedback { text-align: center; min-height: 62px; font-size: 26px; font-weight: 900; color: #4a6b52; }
.feedback.correct { color: var(--green); font-size: 34px; }
.feedback.tone { color: var(--yellow); font-size: 30px; }
.feedback.wrong { color: var(--red); font-size: 24px; }
.answer { text-align: center; padding: 18px; border-radius: 20px; background: #f4f0e4; font-size: 25px; font-weight: 900; }
.answer button {
  margin-left: 14px;
  border-radius: 999px;
  padding: 10px 18px;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, #5a946e, #3d8056);
}

.designer { display: none; margin-top: 30px; padding: 28px 32px; }
.designer.collapsed { display: none; }
.designer-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 20px; }
.designer-grid {
  display: grid;
  grid-template-columns: 180px minmax(320px, 1fr) 300px;
  gap: 16px;
  align-items: start;
}
.designer-side, .designer-center {
  border-radius: 24px;
  background: rgba(255,255,255,.72);
  border: 3px solid rgba(255,255,255,.76);
  padding: 20px 18px;
}
.designer-finals .final-grid { grid-template-columns: repeat(4, 1fr); }
.designer-center {
  min-height: 480px;
  display: grid;
  gap: 18px;
}
.designer-choice {
  min-height: 124px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.designer-choice span {
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  font-size: 52px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.1);
}
.designer-choice span:first-child { background: rgba(107,158,122,.5); }
.designer-choice span:last-child { background: rgba(150,172,120,.5); }
.designer-choice strong {
  position: relative;
  z-index: 2;
  margin: 0 -8px;
  color: #7a9a85;
  font-size: 56px;
}
.designer-tone { padding: 0 18px; }
.candidate-zone {
  min-height: 140px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 12px;
  align-content: start;
  padding: 16px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fffef8, #f0f7ed);
  border: 3px dashed #bcd5c4;
  color: #5a7a65;
  font-size: 24px;
  font-weight: 900;
}
.inline-candidates {
  min-height: 0;
  overflow: auto;
}
.inline-selected {
  min-height: 0;
  overflow: auto;
  align-content: start;
}
.candidate-card {
  min-height: 94px;
  display: grid;
  place-items: center;
  gap: 4px;
  border-radius: 18px;
  color: #3a5244;
  background: #f0f4e8;
  box-shadow: 0 7px 0 #c4d6b4, 0 14px 22px rgba(80,100,60,.06);
}
.candidate-card strong { font-size: 42px; line-height: 1; }
.candidate-card span { font-size: 18px; font-weight: 900; }
.empty-candidates { grid-column: 1 / -1; align-self: center; text-align: center; }
.chosen-zone {
  display: grid;
  gap: 12px;
}
.chosen-zone > strong {
  font-size: 22px;
  color: #285789;
}
.designer-form { display: grid; grid-template-columns: repeat(5, 1fr); gap: 18px; align-items: end; }
.designer label { display: grid; gap: 8px; font-weight: 900; }
.designer select, .designer input {
  min-height: 58px;
  border: 3px solid #c4d6b4;
  border-radius: 16px;
  padding: 0 16px;
  background: #f0f4e8;
  color: #3a5244;
  font-weight: 800;
}
.custom-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 18px; }
.custom-card { padding: 14px; border-radius: 16px; background: #fff; font-weight: 900; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.custom-card button {
  padding: 7px 10px;
  border-radius: 999px;
  color: #315b8b;
  background: #eaf4ff;
  box-shadow: none;
}
.summary { margin-top: 30px; padding: 28px; }

@media (max-width: 760px) {
  .app { width: min(740px, calc(100% - 16px)); padding-top: 20px; }
  .status-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .designer-form { grid-template-columns: 1fr; }
  .designer-grid { grid-template-columns: 154px minmax(280px, 1fr) 250px; gap: 10px; }
  .designer-side, .designer-center { padding: 18px 14px; }
  .designer-center { min-height: 430px; }
  .designer-choice span { width: 92px; height: 92px; font-size: 42px; }
  .designer-choice strong { font-size: 48px; }
  .candidate-card strong { font-size: 36px; }
  .play-grid { grid-template-columns: 154px minmax(280px, 1fr) 250px; gap: 10px; }
  .stat { min-height: 62px; padding: 10px 14px; font-size: 18px; border-radius: 18px; }
  .stat strong { font-size: 28px; }
  .group-control { grid-template-columns: auto auto auto minmax(140px, 1fr) auto auto; min-height: 70px; }
  .group-control input { min-width: 0; width: 100%; }
  .panel { padding: 18px 14px; }
  .tile-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .final-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .tile { min-height: 48px; font-size: 23px; border-radius: 15px; }
  .final-section h3 { font-size: 18px; margin: 10px 0 8px; }
  h2 { font-size: 22px; }
  .panel-head span { font-size: 14px; }
  .stage-card { padding: 18px 20px; }
  .task-bar { padding: 10px 14px; gap: 8px; }
  .task-bar strong { font-size: 20px; }
  .task-bar button { padding: 12px 16px; }
  .stage { height: 390px; }
  .piece { width: 96px; height: 96px; font-size: 46px; }
  .plus { font-size: 50px; }
  .pinyin-result { font-size: 58px; }
}

@media (max-width: 660px) {
  .app { min-width: 704px; }
}
