:root {
  color-scheme: light;
  --bg: linear-gradient(180deg, #fff8f3 0%, #fff5ff 42%, #eef7ff 100%);
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --ink: #3d3557;
  --muted: #7c7595;
  --line: rgba(91, 73, 151, 0.14);
  --pink: #ff6da8;
  --rose: #ff8fbf;
  --yellow: #ffd45b;
  --orange: #ff9d4d;
  --blue: #66a8ff;
  --green: #52b87d;
  --purple: #7b5fe0;
  --shadow: 0 24px 60px rgba(120, 95, 190, 0.16);
  font-family: "Nunito", "Noto Sans SC", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

.app {
  width: min(900px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 18px 0 30px;
}

.hero,
.pinyin-card,
.panel,
.feedback {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(260px, 0.95fr);
  gap: 20px;
  padding: 24px;
  border-radius: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--purple);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.hero h1,
.result-title {
  margin: 0;
  line-height: 1.15;
}

.intro,
.helper-copy,
.result-summary,
.ticket-copy,
.ride-result,
.progress-sub {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.7;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-tags span,
.focus-chip,
.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
}

.hero-tags span {
  background: #fff2cc;
  color: #9a6a14;
}

.primary-btn,
.secondary-btn,
.listen-btn,
.action-btn,
.next-btn {
  border: none;
  font: inherit;
  cursor: pointer;
}

.primary-btn,
.secondary-btn,
.next-btn {
  min-height: 52px;
  padding: 0 20px;
  border-radius: 16px;
  font-size: 17px;
  font-weight: 800;
}

.primary-btn {
  background: linear-gradient(135deg, #ff90ba 0%, #ffb65c 100%);
  color: #fff;
  box-shadow: 0 18px 28px rgba(255, 142, 181, 0.28);
}

.primary-btn--wide {
  width: 100%;
  margin-top: 18px;
}

.secondary-btn {
  background: #fff;
  color: #5e4e97;
  border: 1px solid rgba(94, 78, 151, 0.16);
}

.secondary-btn--ghost {
  color: var(--muted);
}

.hero-wheel {
  display: grid;
  place-items: center;
}

.mini-wheel {
  position: relative;
  width: 250px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fffef5 0 28%, transparent 28%),
    conic-gradient(from -22.5deg, #ffd45b 0 45deg, #ffc0dd 45deg 90deg, #9fd6ff 90deg 135deg, #cdb5ff 135deg 180deg, #ffe28b 180deg 225deg, #ffc0dd 225deg 270deg, #9fd6ff 270deg 315deg, #cdb5ff 315deg 360deg);
  border: 12px solid #fff;
  box-shadow: 0 18px 34px rgba(116, 90, 182, 0.2);
}

.mini-wheel::before,
.mini-wheel::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 88%;
  background: rgba(90, 72, 148, 0.16);
  transform-origin: center;
  transform: translate(-50%, -50%);
}

.mini-wheel::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.mini-wheel-core {
  position: absolute;
  inset: 50%;
  width: 78px;
  height: 78px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  color: #6f57c9;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(111, 87, 201, 0.16);
}

.mini-cabin {
  position: absolute;
  min-width: 94px;
  padding: 8px 10px;
  border-radius: 14px;
  background: #fff;
  color: #6d5d97;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 10px 18px rgba(112, 86, 170, 0.14);
}

.mini-cabin--1 { top: -6px; left: 50%; transform: translateX(-50%); }
.mini-cabin--2 { right: -22px; top: 50%; transform: translateY(-50%); }
.mini-cabin--3 { bottom: -6px; left: 50%; transform: translateX(-50%); }
.mini-cabin--4 { left: -22px; top: 50%; transform: translateY(-50%); }

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 6px 14px;
}

.score-group {
  display: flex;
  gap: 10px;
  align-self: flex-start;
}

.score-pill {
  background: rgba(255, 255, 255, 0.92);
  color: #66578b;
}

.score-pill strong {
  margin-left: 6px;
}

.score-pill--pink {
  background: #fff0f7;
  color: #d15d97;
}

.pinyin-card {
  padding: 26px 24px;
  border-radius: 30px;
  text-align: center;
  position: relative;
}

.card-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.focus-chip {
  background: #edf4ff;
  color: #5f86c9;
}

.show-hanzi-btn {
  min-width: 74px;
  min-height: 38px;
  padding: 0 14px;
  border: none;
  border-radius: 999px;
  background: #fff1d7;
  color: #b46f1e;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(255, 188, 112, 0.18);
}

.show-hanzi-btn[aria-pressed="true"] {
  background: linear-gradient(135deg, #ffd680 0%, #ffb563 100%);
  color: #8d4f09;
}

.word {
  margin: 22px 0 8px;
  font-size: clamp(58px, 10vw, 96px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.08em;
}

.pinyin {
  margin: 0;
  color: #ff8b3d;
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.listen-row {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.listen-btn {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  background: #fff2f8;
  color: #c64f87;
  font-size: 15px;
  font-weight: 800;
}

.listen-btn.is-speaking {
  background: #ffe2a8;
  color: #9b6410;
}

.feedback {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 20px;
  text-align: center;
  font-weight: 700;
}

.feedback.good {
  color: #1e8d5d;
  background: rgba(82, 184, 125, 0.12);
}

.feedback.retry {
  color: #c06d20;
  background: rgba(255, 157, 77, 0.14);
}

.action-row,
.result-actions {
  display: flex;
  gap: 14px;
  margin-top: 16px;
}

.action-btn {
  flex: 1;
  min-height: 58px;
  border-radius: 18px;
  font-size: 18px;
  font-weight: 800;
}

.action-btn--good {
  background: linear-gradient(135deg, #ff94b5 0%, #ffbf63 100%);
  color: #fff;
}

.action-btn--retry {
  background: #fff;
  border: 1px solid rgba(113, 95, 178, 0.16);
  color: #6f61a8;
}

.next-btn {
  width: 100%;
  margin-top: 14px;
  background: #7465da;
  color: #fff;
}

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

.panel {
  padding: 20px;
  border-radius: 24px;
}

.panel h3 {
  margin: 0 0 12px;
}

.review-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

.mengko-picker {
  margin-top: 14px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(109, 92, 164, 0.1);
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.picker-title {
  margin: 0;
  color: #6b5e91;
  font-size: 14px;
  font-weight: 800;
}

.swap-btn {
  border: none;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: #fff2d8;
  color: #ac6b18;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(255, 188, 112, 0.14);
}

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

.mengko-chip {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(118, 98, 186, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  color: #6b5c93;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(112, 86, 170, 0.08);
}

.mengko-chip.is-selected {
  background: linear-gradient(135deg, #ffd584 0%, #ff9fc6 100%);
  color: #57365f;
  border-color: transparent;
  box-shadow: 0 14px 24px rgba(255, 157, 77, 0.2);
}

.ferris-scene {
  position: relative;
  min-height: 420px;
  margin-top: 8px;
  border-radius: 24px;
  background:
    radial-gradient(circle at top, rgba(255, 251, 232, 0.98), transparent 32%),
    linear-gradient(180deg, #fdf4ff 0%, #f2f8ff 52%, #e8f7f0 100%);
  overflow: hidden;
  perspective: 1200px;
}

.ferris-stars span {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.8);
}

.ferris-stars span:nth-child(1) { top: 36px; left: 18%; }
.ferris-stars span:nth-child(2) { top: 72px; left: 74%; }
.ferris-stars span:nth-child(3) { top: 48px; left: 52%; }
.ferris-stars span:nth-child(4) { top: 120px; left: 10%; }
.ferris-stars span:nth-child(5) { top: 110px; left: 86%; }

.ferris-wheel {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 300px;
  height: 300px;
  transform: translate(-50%, -50%) rotateX(12deg);
  border-radius: 50%;
  border: 14px solid rgba(255, 255, 255, 0.98);
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.92), transparent 24%),
    radial-gradient(circle at center, transparent 0 26%, rgba(255, 255, 255, 0.96) 26% 31%, transparent 31%),
    conic-gradient(from -22.5deg, #ffd45b 0 45deg, #ffc0dd 45deg 90deg, #9fd6ff 90deg 135deg, #cdb5ff 135deg 180deg, #ffe28b 180deg 225deg, #ffc0dd 225deg 270deg, #9fd6ff 270deg 315deg, #cdb5ff 315deg 360deg);
  box-shadow:
    0 26px 48px rgba(116, 90, 182, 0.24),
    inset 0 -16px 28px rgba(103, 78, 173, 0.2),
    inset 0 10px 18px rgba(255, 255, 255, 0.52);
  transform-style: preserve-3d;
  z-index: 2;
}

.ferris-wheel.is-spinning {
  animation: ferris-spin 4.4s cubic-bezier(0.22, 0.7, 0.22, 1) 1;
}

.ferris-wheel::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 10px solid rgba(255, 255, 255, 0.56);
  transform: translateZ(-14px);
  box-shadow:
    inset 0 -12px 22px rgba(93, 72, 152, 0.22),
    0 6px 10px rgba(255, 255, 255, 0.2);
}

.ferris-wheel::after {
  content: "";
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  border: 3px solid rgba(112, 89, 192, 0.16);
  box-shadow:
    inset 0 12px 22px rgba(255, 255, 255, 0.4),
    inset 0 -10px 18px rgba(110, 85, 184, 0.16);
}

.ferris-hub {
  position: absolute;
  inset: 50%;
  width: 88px;
  height: 88px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #fffefc 0 18%, #ffeac8 18% 48%, #ffd28b 48% 100%);
  color: #7059c8;
  font-size: 17px;
  font-weight: 800;
  z-index: 3;
  box-shadow: 0 10px 20px rgba(112, 89, 192, 0.18), inset 0 -8px 12px rgba(208, 148, 48, 0.2);
}

.ferris-spoke {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 260px;
  margin-left: -3px;
  margin-top: -130px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86) 0%, rgba(145, 123, 215, 0.22) 18%, rgba(106, 88, 171, 0.18) 100%);
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.28);
}

.ferris-spoke--2 { transform: rotate(45deg); }
.ferris-spoke--3 { transform: rotate(90deg); }
.ferris-spoke--4 { transform: rotate(135deg); }

.ferris-cabins {
  position: absolute;
  inset: 0;
}

.cabin {
  position: absolute;
  width: 96px;
  min-height: 50px;
  padding: 8px 10px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 242, 249, 0.96) 52%, rgba(240, 231, 255, 0.94) 100%);
  color: #66588b;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  line-height: 1.2;
  box-shadow:
    0 14px 22px rgba(110, 84, 177, 0.2),
    inset 0 10px 12px rgba(255, 255, 255, 0.55),
    inset 0 -8px 12px rgba(132, 105, 198, 0.12);
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.88);
  transform-style: preserve-3d;
}

.cabin::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  width: 2px;
  height: 14px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(122, 101, 184, 0.35));
}

.cabin.is-empty {
  color: #b3abc9;
}

.cabin--1 { top: -14px; left: 50%; transform: translateX(-50%); z-index: 2; }
.cabin--2 { top: 18%; right: -8px; z-index: 3; }
.cabin--3 { top: 50%; right: -18px; transform: translateY(-50%); z-index: 5; }
.cabin--4 { bottom: 18%; right: -8px; z-index: 6; }
.cabin--5 { bottom: -14px; left: 50%; transform: translateX(-50%); z-index: 7; }
.cabin--6 { bottom: 18%; left: -8px; z-index: 6; }
.cabin--7 { top: 50%; left: -18px; transform: translateY(-50%); z-index: 5; }
.cabin--8 { top: 18%; left: -8px; z-index: 3; }

.ferris-base {
  position: absolute;
  left: 50%;
  bottom: 24px;
  width: 220px;
  height: 120px;
  transform: translateX(-50%);
  background:
    linear-gradient(65deg, transparent 0 44%, #8e79d4 44% 48%, transparent 48%),
    linear-gradient(-65deg, transparent 0 44%, #8e79d4 44% 48%, transparent 48%),
    linear-gradient(180deg, transparent 0 72%, #b9a8e8 72% 100%);
  z-index: 1;
}

.ferris-foreground {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 322px;
  height: 322px;
  transform: translate(-50%, -50%) rotateX(12deg);
  border-radius: 50%;
  border: 16px solid rgba(255, 255, 255, 0.56);
  border-top-color: transparent;
  border-left-color: rgba(255, 255, 255, 0.34);
  border-right-color: rgba(255, 255, 255, 0.34);
  clip-path: inset(48% -8% -8% -8%);
  box-shadow:
    0 18px 26px rgba(116, 90, 182, 0.12),
    inset 0 -12px 18px rgba(107, 81, 180, 0.16);
  z-index: 4;
  pointer-events: none;
}

@keyframes ferris-spin {
  0% { transform: translate(-50%, -50%) rotateX(12deg) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotateX(12deg) rotate(720deg); }
}

@media (max-width: 760px) {
  .app {
    width: min(100vw - 18px, 520px);
    padding-top: 10px;
  }

  .hero,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 20px;
  }

  .word {
    margin-top: 20px;
  }

  .topbar,
  .score-group,
  .action-row,
  .result-actions {
    flex-direction: column;
  }

  .score-group {
    width: 100%;
  }

  .score-pill,
  .action-btn,
  .secondary-btn {
    width: 100%;
  }

  .ferris-scene {
    min-height: 390px;
  }

  .ferris-wheel {
    width: 268px;
    height: 268px;
    transform: translate(-50%, -50%) rotateX(10deg);
  }

  .ferris-foreground {
    width: 288px;
    height: 288px;
    transform: translate(-50%, -50%) rotateX(10deg);
  }

  .ferris-spoke {
    height: 232px;
    margin-top: -116px;
  }

  .cabin {
    width: 88px;
    min-height: 46px;
    font-size: 11px;
  }

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