:root {
  --ink: #1d2433;
  --muted: #667085;
  --line: #d9e2ec;
  --paper: #fffdfa;
  --sea: #0f8b8d;
  --leaf: #4f9d69;
  --sun: #f7c948;
  --coral: #ef6f6c;
  --violet: #5b5f97;
  --sky: #e7f5ff;
  --mint: #e9fbef;
  --rose: #fff0f0;
  --shadow: 0 18px 40px rgba(29, 36, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(231, 245, 255, 0.9), rgba(255, 240, 240, 0.55) 48%, rgba(233, 251, 239, 0.9)),
    #f5f9fb;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  min-height: 94px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  border: 2px solid rgba(15, 139, 141, 0.18);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.88);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--sea);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
}

h2 {
  font-size: 22px;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 86px);
  gap: 8px;
}

.stats-strip div {
  min-height: 58px;
  display: grid;
  place-items: center;
  padding: 6px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
}

.stats-strip strong {
  font-size: 24px;
  line-height: 1;
}

.stats-strip span {
  color: var(--muted);
  font-size: 12px;
}

.workbench {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.source-panel,
.game-panel {
  min-width: 0;
  border: 2px solid rgba(91, 95, 151, 0.14);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.94);
  box-shadow: var(--shadow);
}

.source-panel {
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.icon-button,
.ghost-button,
.primary-button,
.choice,
.tab,
.image-chip {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.icon-button {
  width: 42px;
  color: white;
  background: var(--sea);
  font-size: 22px;
}

.image-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 14px 0;
  max-height: 210px;
  overflow: auto;
}

.image-chip {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 6px;
  color: var(--ink);
  text-align: left;
  background: #ffffff;
  border: 1px solid var(--line);
}

.image-chip.is-active {
  outline: 3px solid rgba(247, 201, 72, 0.75);
}

.image-chip img {
  width: 54px;
  height: 42px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--sky);
}

.image-chip span {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-preview {
  margin: 0;
  display: grid;
  gap: 8px;
}

.source-preview img {
  width: 100%;
  height: min(58vh, 560px);
  object-fit: contain;
  border-radius: 8px;
  background: #101828;
}

.source-preview figcaption {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.game-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 720px;
  padding: 16px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.tab {
  background: #ffffff;
  color: var(--muted);
  border: 1px solid var(--line);
}

.tab.is-active {
  color: white;
  background: var(--violet);
}

.lesson-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
}

.lesson-row label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

select {
  min-width: 150px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
}

.ghost-button {
  padding: 0 15px;
  color: var(--sea);
  background: var(--sky);
}

.primary-button {
  padding: 0 18px;
  color: white;
  background: var(--coral);
}

.game-stage {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.72)),
    repeating-linear-gradient(0deg, transparent 0 44px, rgba(15, 139, 141, 0.08) 45px 46px);
  border: 1px solid var(--line);
  padding: 18px;
}

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

.stage-title h3 {
  margin: 0;
  font-size: 24px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  color: #14213d;
  background: var(--sun);
  font-size: 13px;
  font-weight: 900;
}

.big-char {
  display: grid;
  place-items: center;
  width: min(320px, 64vw);
  height: min(320px, 64vw);
  margin: 22px auto;
  border: 8px solid #ffffff;
  border-radius: 8px;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(239, 111, 108, 0.22) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(0deg, transparent calc(50% - 1px), rgba(239, 111, 108, 0.22) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    #fff;
  box-shadow: var(--shadow);
  font-family: KaiTi, STKaiti, "Microsoft YaHei", serif;
  font-size: clamp(108px, 20vw, 210px);
  line-height: 1;
  transition: transform 180ms ease, opacity 180ms ease;
}

.big-char.is-hidden {
  opacity: 0;
  transform: scale(0.88);
}

.fall-zone {
  position: relative;
  height: 260px;
  overflow: hidden;
  border: 3px solid rgba(15, 139, 141, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(231, 245, 255, 0.88), rgba(255, 253, 250, 0.96)),
    repeating-linear-gradient(90deg, transparent 0 72px, rgba(247, 201, 72, 0.16) 73px 75px);
}

.fall-zone::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 18%, rgba(239, 111, 108, 0.18), transparent 18%),
    radial-gradient(circle at 82% 24%, rgba(79, 157, 105, 0.16), transparent 16%),
    radial-gradient(circle at 62% 74%, rgba(91, 95, 151, 0.12), transparent 18%);
  pointer-events: none;
}

.fall-char {
  position: absolute;
  left: 50%;
  top: -98px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  margin-left: -48px;
  border: 6px solid #ffffff;
  border-radius: 8px;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(239, 111, 108, 0.22) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(0deg, transparent calc(50% - 1px), rgba(239, 111, 108, 0.22) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    #ffffff;
  box-shadow: 0 14px 28px rgba(29, 36, 51, 0.18);
  font-family: KaiTi, STKaiti, "Microsoft YaHei", serif;
  font-size: 66px;
  font-weight: 900;
  line-height: 1;
  animation: fallDown 4.3s linear forwards;
}

.fall-slow {
  animation-duration: 5.2s;
}

.fall-normal {
  animation-duration: 4.3s;
}

.fall-fast {
  animation-duration: 3.4s;
}

.fall-char.is-caught {
  animation-play-state: paused;
  border-color: var(--sun);
  transform: translateY(165px) scale(1.08);
}

.fall-char.is-missed {
  animation-play-state: paused;
  opacity: 0.55;
  transform: translateY(210px) rotate(9deg);
}

.catch-line {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 1;
  width: min(320px, 84%);
  min-height: 46px;
  display: grid;
  place-items: center;
  transform: translateX(-50%);
  border: 2px dashed rgba(15, 139, 141, 0.45);
  border-radius: 8px;
  color: var(--sea);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 900;
}

@keyframes fallDown {
  from {
    transform: translateY(0) rotate(-2deg);
  }
  to {
    transform: translateY(260px) rotate(3deg);
  }
}

.choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.choice {
  min-height: 88px;
  background: #ffffff;
  border: 2px solid var(--line);
  color: var(--ink);
  font-family: KaiTi, STKaiti, "Microsoft YaHei", serif;
  font-size: clamp(34px, 6vw, 56px);
}

.pinyin-choices {
  margin-top: 14px;
}

.pinyin-choice {
  min-height: 76px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
  font-size: clamp(24px, 4vw, 36px);
  letter-spacing: 0;
}

.choice.is-right {
  border-color: var(--leaf);
  background: var(--mint);
}

.choice.is-wrong {
  border-color: var(--coral);
  background: var(--rose);
}

.feedback {
  min-height: 32px;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.match-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 10px;
}

.match-card {
  aspect-ratio: 1;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-family: KaiTi, STKaiti, "Microsoft YaHei", serif;
  font-size: clamp(34px, 7vw, 62px);
  font-weight: 900;
}

.match-card.is-closed {
  color: transparent;
  background:
    linear-gradient(135deg, rgba(15, 139, 141, 0.18), rgba(247, 201, 72, 0.26)),
    #ffffff;
}

.match-card.is-done {
  border-color: var(--leaf);
  background: var(--mint);
}

.word-game {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.word-target {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  min-height: 330px;
  border: 3px solid rgba(247, 201, 72, 0.7);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(239, 111, 108, 0.18) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(0deg, transparent calc(50% - 1px), rgba(239, 111, 108, 0.18) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    #ffffff;
  box-shadow: 0 14px 28px rgba(29, 36, 51, 0.12);
}

.word-target strong {
  font-family: KaiTi, STKaiti, "Microsoft YaHei", serif;
  font-size: clamp(110px, 13vw, 180px);
  line-height: 1;
}

.target-label {
  color: var(--sea);
  font-size: 14px;
  font-weight: 900;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.word-card {
  min-height: 96px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 900;
  letter-spacing: 0;
}

.word-card.is-right {
  border-color: var(--leaf);
  background: var(--mint);
}

.word-card.is-wrong {
  border-color: var(--coral);
  background: var(--rose);
}

.hunt-game {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.hunt-target {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  min-height: 360px;
  padding: 14px;
  border: 3px solid rgba(15, 139, 141, 0.24);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(231, 245, 255, 0.9), rgba(255, 255, 255, 0.96));
}

.hunt-target span {
  color: var(--sea);
  font-size: 14px;
  font-weight: 900;
}

.hunt-target strong {
  display: grid;
  place-items: center;
  width: 128px;
  height: 128px;
  border: 5px solid #ffffff;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(239, 111, 108, 0.2) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(0deg, transparent calc(50% - 1px), rgba(239, 111, 108, 0.2) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    #fff;
  box-shadow: 0 14px 28px rgba(29, 36, 51, 0.12);
  font-family: KaiTi, STKaiti, "Microsoft YaHei", serif;
  font-size: 88px;
  line-height: 1;
}

.hunt-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(56px, 1fr));
  gap: 10px;
}

.hunt-card {
  aspect-ratio: 1;
  min-height: 56px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  font-family: KaiTi, STKaiti, "Microsoft YaHei", serif;
  font-size: clamp(30px, 4.4vw, 52px);
  font-weight: 900;
}

.hunt-card:hover {
  border-color: rgba(15, 139, 141, 0.6);
  background: var(--sky);
}

.hunt-card.is-right {
  border-color: var(--leaf);
  background: var(--mint);
}

.hunt-card.is-wrong {
  border-color: var(--coral);
  background: var(--rose);
}

.review-actions,
.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.review-actions button {
  min-width: 130px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 360px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.spark {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  pointer-events: none;
  animation: pop 680ms ease-out forwards;
}

@keyframes pop {
  from {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(var(--x), var(--y)) scale(0.25);
  }
}

@media (max-width: 980px) {
  .topbar,
  .workbench {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .stats-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .workbench {
    display: grid;
  }

  .source-preview img {
    height: 320px;
  }

  .game-panel {
    min-height: 660px;
  }

  .hunt-game {
    grid-template-columns: 1fr;
  }

  .hunt-target {
    min-height: 220px;
  }

  .word-game {
    grid-template-columns: 1fr;
  }

  .word-target {
    min-height: 210px;
  }

}

@media (max-width: 620px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .source-panel,
  .game-panel {
    padding: 12px;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-tabs,
  .choices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .match-grid {
    grid-template-columns: repeat(3, minmax(68px, 1fr));
  }

  .word-grid {
    grid-template-columns: 1fr;
  }

  .hunt-grid {
    grid-template-columns: repeat(4, minmax(50px, 1fr));
  }
}
