:root {
  color-scheme: light;
  --ink: #244262;
  --soft: rgba(255,255,255,.78);
  --blue: #42a7e5;
  --teal: #31b8ad;
  --orange: #ff8a46;
  --purple: #7d68df;
  --green: #2ca85f;
  --red: #e0524d;
  --yellow: #d99b1f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 12%, rgba(255,230,129,.9), transparent 36%),
    radial-gradient(circle at 83% 16%, rgba(107,199,247,.75), transparent 38%),
    linear-gradient(135deg, #fff5c8, #d9f3ff 58%, #f7f0ff);
}

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-size: clamp(34px, 5vw, 52px);
  line-height: 1.05;
  color: #24558c;
  text-shadow: 0 4px 0 rgba(255,255,255,.85);
}

.end-btn, .stat button, .task-bar button, .designer button {
  border-radius: 999px;
  padding: 16px 28px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, #ff7c51, #ffc343);
  box-shadow: 0 10px 24px rgba(255,132,72,.25);
}

.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: var(--soft);
  border: 3px solid rgba(255,255,255,.75);
  box-shadow: inset 0 1px 0 #fff, 0 12px 28px rgba(67,98,130,.08);
  font-size: 22px;
  font-weight: 800;
}
.stat span, .stat label { color: #687793; }
.stat strong { font-size: 34px; color: #27558a; }
.group-control {
  grid-column: span 3;
  display: grid;
  grid-template-columns: auto auto minmax(180px, 1fr) auto;
  min-height: 80px;
}
.group-control input { accent-color: #ff705e; min-width: 260px; }
.group-control button, .design-stat button, .review-stat button { background: #fff; color: #315b8b; box-shadow: 0 8px 22px rgba(45,80,120,.1); }
.group-control button, .design-stat button, .review-stat button { padding: 12px 22px; }

.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,.82);
  border: 3px solid rgba(255,255,255,.75);
  box-shadow: 0 12px 30px rgba(73,92,121,.08);
}
.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: #285789; }
.panel-head span, .designer-title span { color: #66748f; 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: #3e5b7e; }
.tile {
  min-height: 54px;
  border-radius: 16px;
  font-size: 26px;
  font-weight: 900;
  color: #1d304c;
  background: linear-gradient(135deg, #fff8dc, #fff1c4);
  box-shadow: 0 7px 0 #eadfa8, 0 14px 22px rgba(90,84,40,.08);
  transition: transform .18s ease, background .18s ease, color .18s ease;
}
.tile.final-tile { background: linear-gradient(135deg, #dcfff0, #eafff8); box-shadow: 0 7px 0 #cdebc4, 0 14px 22px rgba(40,90,64,.08); }
.tile.training-chip {
  min-height: 46px;
  color: #315b8b;
  background: #edf5ff;
  box-shadow: 0 5px 0 #cfe0f3;
  cursor: default;
  opacity: .9;
}
.tile.selected {
  color: #fff;
  background: linear-gradient(135deg, #0782bb, #30beb0);
  box-shadow: 0 8px 0 #0b6f78, 0 16px 26px rgba(0,108,151,.18);
  transform: translateY(-4px) scale(1.05);
  animation: selectedPulse .85s ease both;
}
@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: #e7f7f8; }
.task-bar strong { margin-right: auto; color: #6b55d9; font-size: 24px; }
.task-bar button { padding: 14px 26px; background: #fff; color: #315b8b; box-shadow: 0 8px 22px rgba(45,80,120,.1); }
.stage {
  position: relative;
  height: 420px;
  margin-top: 18px;
  border: 3px dashed #b9dcff;
  border-radius: 26px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #fff, #eefbff);
  overflow: hidden;
}
.stage[hidden], .design-workspace[hidden] { display: none; }
.design-workspace {
  min-height: 420px;
  margin-top: 18px;
  padding: 22px;
  border: 3px dashed #b9dcff;
  border-radius: 26px;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 14px;
  background: linear-gradient(180deg, #fff, #eefbff);
}
.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: #24558c;
  background: #d7ebff;
  box-shadow: inset 0 1px 0 #fff, 0 16px 30px rgba(49,95,139,.12);
}
.heard-char:empty { display: none; }
.merge { display: flex; align-items: center; justify-content: center; margin-top: 88px; }
.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(66,167,229,.45); }
.final-piece { background: rgba(255,171,102,.45); margin-left: -20px; }
.plus { position: relative; z-index: 2; color: #8b6add; font-size: 64px; font-weight: 900; }
.pinyin-result { position: absolute; bottom: 42px; font-size: 70px; font-weight: 900; color: #37679b; text-shadow: 0 8px 0 #bcdaf2; }
.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: #687793; }
#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: #345b84; }
.feedback { text-align: center; min-height: 62px; font-size: 26px; font-weight: 900; color: #345b84; }
.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: #fff7df; 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, #42a7e5, #31b8ad);
}

.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(66,167,229,.58); }
.designer-choice span:last-child { background: rgba(255,171,102,.58); }
.designer-choice strong {
  position: relative;
  z-index: 2;
  margin: 0 -8px;
  color: #8b6add;
  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, #fff, #eefbff);
  border: 3px dashed #b9dcff;
  color: #55708e;
  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: #244262;
  background: #fff7dc;
  box-shadow: 0 7px 0 #eadfa8, 0 14px 22px rgba(90,84,40,.08);
}
.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 #bedcff;
  border-radius: 16px;
  padding: 0 16px;
  background: #eaf4ff;
  color: #27496f;
  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 minmax(140px, 1fr) 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; }
}
