:root {
  --ink: #203033;
  --muted: #647174;
  --paper: #fffaf0;
  --leaf: #2f7d6d;
  --leaf-deep: #1f5f5d;
  --coral: #ff705f;
  --sky: #c9e7ff;
  --sun: #ffd25f;
  --line: rgba(32, 48, 51, 0.14);
  --shadow: 0 18px 46px rgba(31, 95, 93, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Kaiti SC", "STKaiti", "Songti SC", "PingFang SC", serif;
  background:
    linear-gradient(135deg, rgba(201, 231, 255, 0.95), rgba(255, 250, 240, 0.92) 36%, rgba(255, 210, 95, 0.2)),
    radial-gradient(circle at 20% 20%, rgba(47, 125, 109, 0.16), transparent 30%),
    #fffaf0;
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

.name-gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 50% 10%, rgba(255, 210, 95, 0.34), transparent 28%),
    linear-gradient(135deg, rgba(201, 231, 255, 0.94), rgba(255, 250, 240, 0.96));
}

.name-card {
  width: min(480px, 100%);
  padding: clamp(24px, 7vw, 44px);
  border: 2px solid rgba(47, 125, 109, 0.24);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.name-card h2 {
  margin: 0 0 22px;
  font-size: clamp(36px, 8vw, 64px);
  line-height: 0.95;
}

.name-card label {
  display: block;
  margin-bottom: 8px;
  color: var(--leaf-deep);
  font-weight: 900;
}

.name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
}

.name-row input {
  min-height: 52px;
  width: 100%;
  padding: 0 14px;
  border: 2px solid rgba(47, 125, 109, 0.24);
  color: var(--ink);
  background: white;
  font-size: 22px;
  font-weight: 900;
}

.name-row .primary-button {
  margin-top: 0;
  padding: 0 18px;
}

.player-badge {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: 10px;
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  color: white;
  background: var(--leaf-deep);
  border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 18px rgba(31, 95, 93, 0.22);
  font-weight: 900;
}

.player-badge span {
  font-size: 12px;
  opacity: 0.82;
}

.player-badge strong {
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
}

.rules-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 48, 51, 0.36);
  backdrop-filter: blur(8px);
}

.rules-card {
  position: relative;
  width: min(560px, 100%);
  padding: clamp(22px, 6vw, 38px);
  border: 2px solid rgba(47, 125, 109, 0.28);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(255, 250, 240, 0.96)),
    radial-gradient(circle at 80% 12%, rgba(255, 210, 95, 0.28), transparent 30%);
  box-shadow: 0 24px 58px rgba(31, 95, 93, 0.26);
}

.rules-card h2 {
  margin: 0 0 18px;
  font-size: clamp(34px, 7vw, 58px);
  line-height: 0.95;
}

.rules-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  min-height: 38px;
  color: white;
  background: var(--leaf-deep);
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
}

.rules-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 1.2em;
  color: var(--ink);
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 800;
  line-height: 1.35;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.top-actions {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.rules-button {
  min-height: 38px;
  padding: 0 14px;
  color: white;
  background: var(--leaf-deep);
  border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 20px rgba(31, 95, 93, 0.18);
  font-weight: 900;
}

.hero {
  min-height: 250px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  align-items: end;
  gap: 28px;
  padding: 34px clamp(22px, 5vw, 58px);
  border: 1px solid var(--line);
  background:
    linear-gradient(120deg, rgba(255, 250, 240, 0.96), rgba(201, 231, 255, 0.82)),
    repeating-linear-gradient(90deg, rgba(47, 125, 109, 0.08) 0 1px, transparent 1px 34px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--leaf-deep);
  font-size: 18px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(54px, 10vw, 118px);
  line-height: 0.9;
  letter-spacing: 0;
}

.lesson {
  margin: 18px 0 0;
  font-size: clamp(20px, 3vw, 32px);
  color: var(--muted);
}

.mascot {
  width: min(240px, 100%);
  justify-self: center;
  filter: drop-shadow(0 20px 24px rgba(255, 112, 95, 0.25));
}

.dashboard {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 52px);
  right: 12px;
  z-index: 20;
  width: 112px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin: 0;
  padding: 5px;
  border: 2px solid rgba(47, 125, 109, 0.26);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 24px rgba(31, 95, 93, 0.2);
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.dashboard.dragging {
  cursor: grabbing;
  box-shadow: 0 14px 30px rgba(31, 95, 93, 0.28);
}

.stat,
.ghost-button,
.mode-tab,
.level-settings,
.voice-settings,
.game-board,
.word-bank {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
}

.stat {
  min-height: 42px;
  display: grid;
  align-content: center;
  padding: 5px;
  background: rgba(255, 250, 240, 0.84);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.stat strong {
  display: block;
  margin-top: 3px;
  font-size: 19px;
  line-height: 1.05;
}

.stat:first-child {
  grid-column: 1 / -1;
  min-height: 54px;
  color: white;
  background: var(--leaf);
}

.stat:first-child span {
  color: rgba(255, 255, 255, 0.82);
}

.stat:first-child strong {
  font-size: 30px;
  letter-spacing: 0.02em;
}

.stat:nth-child(3) strong {
  font-size: 15px;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

button:active {
  transform: translateY(1px);
}

.ghost-button,
.primary-button,
.sound-button,
.back-button,
.choice,
.mode-tab,
.level-settings select,
.voice-test,
.voice-settings select {
  min-height: 48px;
}

.ghost-button {
  min-height: 42px;
  padding: 0 4px;
  color: var(--leaf-deep);
  background: rgba(255, 255, 255, 0.86);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.mode-tab {
  padding: 14px;
  color: var(--ink);
  font-weight: 800;
}

.mode-tab.active {
  color: white;
  background: var(--leaf);
  box-shadow: 0 12px 24px rgba(47, 125, 109, 0.22);
}

.level-settings {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px;
}

.level-settings label {
  color: var(--leaf-deep);
  font-weight: 900;
}

.level-settings select {
  width: 100%;
  padding: 0 14px;
  border: 1px solid rgba(47, 125, 109, 0.26);
  border-radius: 0;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.voice-settings {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px;
}

.voice-settings label {
  color: var(--leaf-deep);
  font-weight: 900;
}

.voice-settings select {
  width: 100%;
  padding: 0 14px;
  border: 1px solid rgba(47, 125, 109, 0.26);
  border-radius: 0;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.voice-test {
  padding: 0 18px;
  color: white;
  background: var(--leaf-deep);
  font-weight: 900;
}

.game-board {
  padding: clamp(18px, 4vw, 34px);
}

.round-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.round-start {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  color: var(--leaf-deep);
  border: 1px solid rgba(47, 125, 109, 0.25);
  background: rgba(47, 125, 109, 0.08);
  font-weight: 800;
}

.back-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--leaf-deep);
  border: 1px solid rgba(47, 125, 109, 0.25);
  background: rgba(255, 255, 255, 0.86);
  font-size: 16px;
  font-weight: 900;
}

.back-button:disabled {
  color: rgba(100, 113, 116, 0.55);
  background: rgba(255, 255, 255, 0.42);
  cursor: not-allowed;
}

.sound-button {
  width: 58px;
  color: white;
  background: var(--coral);
  font-weight: 900;
}

.challenge {
  min-height: 168px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px 0;
}

.big-word {
  font-size: clamp(58px, 12vw, 120px);
  line-height: 1;
  font-weight: 900;
}

.pinyin {
  margin-top: 14px;
  color: var(--leaf-deep);
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
}

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 20px;
}

.answer-zone {
  min-height: 156px;
}

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

.choice {
  padding: 18px;
  color: var(--ink);
  border: 2px solid transparent;
  background: white;
  box-shadow: 0 10px 22px rgba(32, 48, 51, 0.08);
  font-size: clamp(24px, 4vw, 42px);
  font-weight: 900;
}

.choice.correct {
  border-color: var(--leaf);
  background: rgba(47, 125, 109, 0.12);
}

.choice.wrong {
  border-color: var(--coral);
  background: rgba(255, 112, 95, 0.12);
}

.choice.speak-check {
  color: white;
  background: var(--leaf-deep);
}

.primary-button {
  margin-top: 18px;
  padding: 0 24px;
  color: white;
  background: var(--leaf-deep);
  font-weight: 900;
}

.card-panel {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 30px;
  background: white;
  border: 2px solid rgba(47, 125, 109, 0.22);
  box-shadow: 0 16px 34px rgba(32, 48, 51, 0.12);
}

.review-label {
  margin-bottom: 8px;
  color: var(--leaf-deep);
  font-size: 18px;
  font-weight: 900;
}

.review-choice {
  font-size: clamp(20px, 3vw, 30px);
}

.feedback {
  min-height: 32px;
  margin: 16px 0 0;
  font-size: 22px;
  font-weight: 900;
  text-align: center;
}

.feedback.good {
  color: var(--leaf-deep);
}

.feedback.bad {
  color: var(--coral);
}

.word-bank {
  margin-top: 20px;
  padding: 22px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 30px;
}

.section-head span {
  color: var(--muted);
}

.bank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.bank-card {
  padding: 12px;
  background: rgba(255, 250, 240, 0.86);
  border: 1px solid var(--line);
}

.bank-card.mastered {
  color: white;
  border-color: rgba(31, 95, 93, 0.42);
  background: linear-gradient(135deg, var(--leaf), var(--leaf-deep));
  box-shadow: 0 10px 20px rgba(31, 95, 93, 0.18);
}

.bank-card strong {
  display: block;
  font-size: 22px;
}

.bank-card span {
  display: block;
  margin-top: 4px;
  color: var(--leaf-deep);
  font-size: 15px;
}

.bank-card.mastered span {
  color: rgba(255, 255, 255, 0.78);
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 20px, 680px);
    padding-top: 10px;
  }

  .hero {
    min-height: 220px;
    grid-template-columns: 1fr;
    padding: 24px;
  }

  .mascot {
    width: 160px;
    justify-self: start;
  }

  .mode-tabs,
  .level-settings,
  .voice-settings,
  .choice-grid {
    grid-template-columns: 1fr;
  }

  .name-row {
    grid-template-columns: 1fr;
  }

}
