:root {
  --ink: #17211d;
  --muted: #66756e;
  --paper: #fffdf7;
  --canvas: #f3efe4;
  --line: #ded8c8;
  --green: #19735f;
  --green-deep: #0f4f40;
  --gold: #dfa83c;
  --blue: #406f9f;
  --red: #c5534d;
  --shadow: 0 28px 80px rgba(34, 42, 36, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 14%, rgba(223, 168, 60, 0.16), transparent 26%),
    linear-gradient(90deg, rgba(23, 33, 29, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(23, 33, 29, 0.04) 1px, transparent 1px),
    var(--canvas);
  background-size: auto, 32px 32px, 32px 32px, auto;
  font-family: "Songti SC", "Noto Serif SC", "Microsoft YaHei", serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1160px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px;
}

.screen {
  min-height: calc(100vh - 64px);
}

.setup-screen {
  display: grid;
  align-items: center;
  padding-bottom: 84px;
}

.setup-layout {
  display: grid;
  grid-template-columns: 0.92fr 1.08fr;
  gap: 28px;
  align-items: stretch;
}

.intro-panel,
.setup-card,
.listen-stage,
.celebrate,
.check-card,
.answer-review {
  border: 1px solid rgba(222, 216, 200, 0.92);
  border-radius: 14px;
  background: rgba(255, 253, 247, 0.92);
  box-shadow: var(--shadow);
}

.intro-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 690px;
  padding: 34px;
  overflow: hidden;
}

.book-scene {
  position: relative;
  width: min(100%, 360px);
  height: 250px;
  margin-bottom: 34px;
}

.book-card {
  position: absolute;
  left: 12px;
  top: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 280px;
  height: 178px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  box-shadow: 18px 18px 0 rgba(25, 115, 95, 0.16);
  transform: rotate(-2deg);
}

.book-page {
  position: relative;
  overflow: hidden;
}

.book-page.left {
  border-right: 2px solid rgba(23, 33, 29, 0.2);
}

.book-page.left::after {
  content: "";
  position: absolute;
  right: -24px;
  top: -16px;
  width: 72px;
  height: 220px;
  background: #f5e9c9;
  transform: rotate(12deg);
}

.book-page span {
  position: absolute;
  left: 28px;
  width: 70px;
  height: 7px;
  border-radius: 999px;
}

.book-page span:nth-child(1) {
  top: 42px;
  background: var(--green);
}

.book-page span:nth-child(2) {
  top: 66px;
  width: 48px;
  background: var(--gold);
}

.book-page span:nth-child(3) {
  top: 98px;
  width: 82px;
  background: rgba(64, 111, 159, 0.28);
}

.book-page.right i {
  position: absolute;
  left: 38px;
  top: 48px;
  width: 64px;
  height: 64px;
  border: 8px solid var(--blue);
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
  transform: rotate(45deg);
}

.desk-line {
  position: absolute;
  left: -60px;
  right: -140px;
  bottom: 28px;
  height: 18px;
  border-radius: 999px;
  background: rgba(25, 115, 95, 0.12);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  font-size: clamp(66px, 9vw, 116px);
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(25px, 4vw, 40px);
  line-height: 1.16;
}

.lead {
  max-width: 460px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.9;
}

.setup-card {
  min-height: 690px;
  padding: 26px;
}

.card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.status-pill,
.parse-status,
.hint-box,
.praise-box {
  border: 1px solid rgba(64, 111, 159, 0.24);
  border-radius: 10px;
  padding: 10px 12px;
  background: #edf5fb;
  color: #244b72;
  font-size: 14px;
  line-height: 1.7;
}

.status-pill {
  max-width: 240px;
}

.grade-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.grade-tab {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
}

.grade-tab.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.words-input {
  width: 100%;
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  background: #fff;
  color: var(--ink);
  outline: none;
  resize: vertical;
  font-size: 23px;
  line-height: 1.8;
}

.words-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(25, 115, 95, 0.12);
}

.start-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.photo-button {
  display: grid;
  place-items: center;
  min-height: 62px;
  border: 2px dashed #ccb987;
  border-radius: 12px;
  background: #fff7df;
  color: var(--ink);
  font-weight: 900;
}

.photo-button input {
  display: none;
}

.primary-btn,
.secondary-btn,
.gold-btn,
.hint-btn {
  min-height: 62px;
  border: 0;
  border-radius: 12px;
  padding: 0 20px;
  font-weight: 900;
}

.primary-btn {
  background: var(--green);
  color: #fff;
}

.secondary-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.gold-btn {
  background: var(--gold);
  color: var(--ink);
}

.hint-btn {
  background: #e9f2ee;
  color: var(--green-deep);
}

.preview {
  width: 100%;
  max-height: 280px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  object-fit: contain;
  background: #fff;
}

.dictation-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.practice-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.timer {
  min-width: 128px;
  border: 1px solid rgba(25, 115, 95, 0.28);
  border-radius: 12px;
  padding: 14px 18px;
  background: rgba(255, 253, 247, 0.86);
  color: var(--green-deep);
  text-align: center;
  font-size: 32px;
  font-weight: 900;
}

.listen-stage {
  display: grid;
  gap: 24px;
  border-color: #e5c77b;
  padding: 32px;
  background: #fff7df;
}

.sound-board {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 220px;
}

.sound-board span {
  display: block;
  width: 12%;
  max-width: 90px;
  min-width: 34px;
  border-radius: 999px;
  background: var(--gold);
  animation: pulse 1.1s ease-in-out infinite;
}

.sound-board span:nth-child(1) { height: 34px; animation-delay: 0s; }
.sound-board span:nth-child(2) { height: 82px; background: var(--green); animation-delay: 0.1s; }
.sound-board span:nth-child(3) { height: 132px; background: var(--blue); animation-delay: 0.2s; }
.sound-board span:nth-child(4) { height: 74px; background: var(--green); animation-delay: 0.3s; }
.sound-board span:nth-child(5) { height: 104px; animation-delay: 0.4s; }

@keyframes pulse {
  0%, 100% { transform: scaleY(0.72); opacity: 0.72; }
  50% { transform: scaleY(1); opacity: 1; }
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.hint-box,
.parse-status {
  margin-top: 14px;
}

.celebrate {
  position: relative;
  overflow: hidden;
  margin: 22px 0 18px;
  padding: 34px;
  background:
    radial-gradient(circle at 86% 18%, rgba(223, 168, 60, 0.26), transparent 20%),
    linear-gradient(135deg, #edf8f2, #fffdf7 72%);
}

.celebrate h2 {
  font-size: clamp(54px, 11vw, 100px);
}

.finish-summary {
  margin: 12px 0 8px;
  color: var(--green-deep);
  font-size: 24px;
  font-weight: 900;
}

.rank-text {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.rank-panel {
  border: 1px solid rgba(25, 115, 95, 0.18);
  border-radius: 14px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.rank-meter {
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(25, 115, 95, 0.12);
}

.rank-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 900ms ease;
}

.rank-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.rank-labels strong {
  color: var(--green-deep);
}

.rank-bars {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  gap: 10px;
  height: 96px;
  margin-top: 18px;
}

.rank-bars span {
  border-radius: 10px 10px 4px 4px;
  background: rgba(25, 115, 95, 0.18);
}

.rank-bars span:nth-child(1) { height: 34%; }
.rank-bars span:nth-child(2) { height: 48%; }
.rank-bars span:nth-child(3) { height: 62%; background: rgba(64, 111, 159, 0.24); }
.rank-bars span:nth-child(4) { height: 76%; background: rgba(223, 168, 60, 0.34); }
.rank-bars span:nth-child(5) { height: 92%; background: rgba(25, 115, 95, 0.42); }

.check-card {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 16px;
  padding: 22px;
  margin-bottom: 18px;
}

.praise-box {
  grid-column: 1 / -1;
  background: #fff;
  color: var(--green-deep);
  font-size: 19px;
}

.tag {
  display: inline-block;
  margin-bottom: 6px;
  border-radius: 999px;
  padding: 2px 10px;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.fireworks-layer {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: hidden;
}

.spark {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  animation: spark-fly 900ms ease-out forwards;
}

@keyframes spark-fly {
  from {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.15);
  }
}

.finish-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.hidden {
  display: none !important;
}

.site-footer {
  margin-top: 78px;
  padding-bottom: 32px;
  color: rgba(23, 33, 29, 0.48);
  text-align: center;
  font-size: 15px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .app {
    padding: 18px;
  }

  .setup-screen {
    display: block;
  }

  .setup-layout {
    grid-template-columns: 1fr;
  }

  .intro-panel,
  .setup-card {
    min-height: auto;
  }

  .intro-panel {
    padding: 24px;
  }

  .book-scene {
    height: 170px;
    margin-bottom: 22px;
  }

  .book-card {
    width: 200px;
    height: 132px;
  }

  .lead {
    font-size: 18px;
  }

  .words-input {
    min-height: 300px;
  }

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

@media (max-width: 560px) {
  .start-row,
  .control-grid,
  .finish-actions {
    grid-template-columns: 1fr;
  }

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

  .grade-tab {
    min-height: 48px;
    padding: 0 6px;
    font-size: 14px;
  }

  .practice-top {
    flex-direction: column;
  }

  .timer {
    width: 100%;
  }

  .listen-stage {
    padding: 20px;
  }

  .sound-board {
    min-height: 160px;
  }
}
