:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --panel: #ffffff;
  --line: #d7e2df;
  --green: #16a34a;
  --green-dark: #0f7a36;
  --red: #dc2626;
  --blue: #2563eb;
  --yellow: #fbbf24;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  font-family: "Nunito", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: #edf7f2;
}

button,
select {
  font: inherit;
}

button:focus-visible,
select:focus-visible {
  outline: 4px solid rgba(37, 99, 235, 0.3);
  outline-offset: 3px;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  place-items: center;
  padding: 14px;
}

.play-area {
  display: grid;
  width: min(920px, 100%);
  gap: 12px;
}

.topbar,
.feedback-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-block {
  min-width: 0;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--blue);
  font-size: 16px;
  font-weight: 900;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.lesson-progress,
.stars,
.settings-button {
  display: inline-flex;
  height: 46px;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-weight: 900;
}

.lesson-progress {
  min-width: 72px;
  color: var(--blue);
  font-size: 17px;
}

.stars {
  min-width: 76px;
  gap: 7px;
  border-color: #f4d56b;
  background: #fff8d8;
  color: #92400e;
  font-size: 21px;
}

.star-icon {
  color: var(--yellow);
  text-shadow: 0 1px 0 #b45309;
}

.settings-wrap {
  position: relative;
}

.settings-button {
  width: 46px;
  padding: 0;
  cursor: pointer;
  color: #475467;
  font-size: 23px;
}

.settings-button:hover,
.settings-button[aria-expanded="true"] {
  border-color: #93c5fd;
  background: #eff6ff;
  color: var(--blue);
}

.settings-panel {
  position: absolute;
  z-index: 10;
  top: 54px;
  right: 0;
  width: 270px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 32px rgba(23, 32, 51, 0.18);
}

.settings-panel[hidden] {
  display: none;
}

.settings-title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 900;
}

.setting-row {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #475467;
  font-size: 14px;
  font-weight: 800;
}

.voice-mode,
.cue-picker select {
  min-height: 36px;
  border: 2px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--blue);
  font-weight: 900;
}

.voice-mode {
  min-width: 82px;
  padding: 0 10px;
  cursor: pointer;
}

.cue-picker select {
  max-width: 132px;
  padding: 0 6px;
  cursor: pointer;
}

.word-card {
  position: relative;
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  min-height: 138px;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  border: 3px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.word-card.revealed {
  grid-template-columns: 108px 108px minmax(0, 1fr);
  border-color: #86efac;
}

.listen-button,
.next-button,
.option-button {
  cursor: pointer;
  border: 0;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

.listen-button {
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 8px 0 var(--green-dark);
  font-size: 39px;
}

.listen-button:hover,
.next-button:not(:disabled):hover,
.option-button:not(:disabled):hover {
  transform: translateY(-2px);
  filter: brightness(1.03);
}

.listen-button:active,
.next-button:not(:disabled):active,
.option-button:not(:disabled):active {
  transform: translateY(2px);
}

.result-picture {
  display: grid;
  width: 108px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 8px;
  background: var(--card-color, #f97316);
  color: #ffffff;
  font-size: 62px;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.1);
}

.result-picture[hidden] {
  display: none;
}

.word-block {
  min-width: 0;
}

.word {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 31px;
  font-weight: 900;
  line-height: 1.05;
}

.phrase {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.phrase:empty {
  display: none;
}

.word-card.revealed .word {
  font-size: 48px;
}

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

.option-button {
  display: grid;
  min-width: 0;
  min-height: 146px;
  place-items: center;
  padding: 12px 8px 10px;
  border: 3px solid #dfe6e4;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 0 #dfe6e4;
}

.option-button.correct {
  border-color: #4ade80;
  background: #dcfce7;
  box-shadow: 0 8px 0 #86efac;
}

.option-button.wrong {
  border-color: #f87171;
  background: #fee2e2;
  box-shadow: 0 8px 0 #fecaca;
  animation: wrong-shake 0.26s ease;
}

.option-button:disabled:not(.correct):not(.wrong) {
  cursor: default;
  opacity: 0.68;
}

.option-icon {
  display: block;
  font-size: 62px;
  line-height: 1;
}

.option-icon.scene-icon {
  font-size: 42px;
  white-space: nowrap;
}

.result-picture.scene-icon {
  font-size: 36px;
  white-space: nowrap;
}

.option-labels {
  display: grid;
  min-width: 0;
  min-height: 43px;
  align-content: end;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.option-button.show-label .option-labels {
  visibility: visible;
  opacity: 1;
}

.option-word,
.option-cn {
  display: block;
  overflow-wrap: anywhere;
}

.option-word {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.05;
}

.option-cn {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.feedback-row {
  min-height: 58px;
}

.feedback {
  min-width: 0;
  margin: 0;
  color: var(--blue);
  font-size: 24px;
  font-weight: 900;
  line-height: 1.15;
}

.next-button {
  min-width: 142px;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 8px;
  background: #172033;
  box-shadow: 0 7px 0 rgba(23, 32, 51, 0.28);
  color: #ffffff;
  font-size: 19px;
  font-weight: 900;
}

.next-button:disabled {
  cursor: default;
  background: #98a2b3;
  box-shadow: 0 5px 0 #d0d5dd;
  opacity: 0.55;
}

.reward-burst {
  position: absolute;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.reward-burst span {
  --star-x: 0px;
  --star-y: -48px;
  position: absolute;
  top: 50%;
  left: 50%;
  color: #fbbf24;
  font-size: 26px;
  opacity: 0;
  text-shadow: 0 2px 0 #b45309;
  animation: reward-star 0.72s ease-out forwards;
}

.reward-burst span:nth-child(1) { --star-x: -150px; --star-y: -45px; }
.reward-burst span:nth-child(2) { --star-x: -76px; --star-y: -70px; animation-delay: 0.04s; }
.reward-burst span:nth-child(3) { --star-x: 0px; --star-y: -78px; animation-delay: 0.08s; }
.reward-burst span:nth-child(4) { --star-x: 76px; --star-y: -70px; animation-delay: 0.04s; }
.reward-burst span:nth-child(5) { --star-x: 150px; --star-y: -45px; }

.word-card.reward-medium .reward-burst span {
  color: #facc15;
  font-size: 20px;
  animation-duration: 0.58s;
}

.word-card.reward-medium .reward-burst span:nth-child(1) {
  --star-x: -62px;
  --star-y: -48px;
}

.word-card.reward-medium .reward-burst span:nth-child(2) {
  --star-x: 62px;
  --star-y: -48px;
  animation-delay: 0.05s;
}

.word-card.reward-strong {
  animation: reward-pop 0.52s ease;
}

.word-card.reward-medium {
  animation: reward-soft 0.48s ease;
}

.stars.reward-strong {
  animation: reward-counter 0.52s ease;
}

.feedback[data-reward="strong"] {
  color: #b45309;
}

.feedback[data-reward="medium"],
.feedback[data-reward="gentle"] {
  color: var(--green-dark);
}

@keyframes reward-pop {
  0%, 100% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.035);
  }
}

@keyframes reward-soft {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.025);
  }
}

@keyframes reward-counter {
  0%, 100% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.16);
  }
}

@keyframes reward-star {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.45);
  }
  28% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--star-x)), calc(-50% + var(--star-y))) scale(1.08);
  }
}

@keyframes wrong-shake {
  0%, 100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-5px);
  }
  70% {
    transform: translateX(5px);
  }
}

@media (max-width: 720px) {
  .app-shell {
    align-items: start;
    padding: 7px;
  }

  .play-area {
    gap: 8px;
  }

  .topbar {
    gap: 7px;
  }

  h1 {
    font-size: 24px;
  }

  .subtitle {
    margin-top: 3px;
    font-size: 13px;
  }

  .top-actions {
    gap: 4px;
  }

  .lesson-progress,
  .stars,
  .settings-button {
    height: 38px;
    border-width: 2px;
  }

  .lesson-progress {
    min-width: 52px;
    font-size: 14px;
  }

  .stars {
    min-width: 54px;
    gap: 4px;
    font-size: 17px;
  }

  .settings-button {
    width: 38px;
    font-size: 19px;
  }

  .settings-panel {
    top: 45px;
    width: min(270px, calc(100vw - 14px));
  }

  .word-card {
    grid-template-columns: 68px minmax(0, 1fr);
    min-height: 88px;
    gap: 8px;
    padding: 8px;
    border-width: 2px;
  }

  .word-card.revealed {
    grid-template-columns: 68px 68px minmax(0, 1fr);
  }

  .listen-button,
  .result-picture {
    width: 62px;
    height: 62px;
  }

  .listen-button {
    box-shadow: 0 5px 0 var(--green-dark);
    font-size: 28px;
  }

  .result-picture {
    font-size: 39px;
    box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.1);
  }

  .word {
    font-size: 23px;
  }

  .word-card.revealed .word {
    font-size: 29px;
  }

  .phrase {
    margin-top: 3px;
    font-size: 14px;
  }

  .options-grid {
    gap: 7px;
  }

  .option-button {
    min-height: 108px;
    padding: 7px 3px 5px;
    border-width: 2px;
    box-shadow: 0 5px 0 #dfe6e4;
  }

  .option-button.correct {
    box-shadow: 0 5px 0 #86efac;
  }

  .option-button.wrong {
    box-shadow: 0 5px 0 #fecaca;
  }

  .option-icon {
    font-size: 45px;
  }

  .option-icon.scene-icon {
    font-size: 27px;
  }

  .result-picture.scene-icon {
    font-size: 24px;
  }

  .option-labels {
    min-height: 34px;
  }

  .option-word {
    font-size: 15px;
  }

  .option-cn {
    margin-top: 1px;
    font-size: 11px;
  }

  .feedback-row {
    min-height: 49px;
    gap: 7px;
  }

  .feedback {
    font-size: 18px;
  }

  .next-button {
    min-width: 96px;
    min-height: 42px;
    padding: 0 10px;
    box-shadow: 0 5px 0 rgba(23, 32, 51, 0.28);
    font-size: 16px;
  }
}

@media (max-width: 360px) {
  h1 {
    font-size: 21px;
  }

  .subtitle {
    font-size: 12px;
  }

  .lesson-progress {
    min-width: 48px;
  }

  .stars {
    min-width: 50px;
  }

  .word-card.revealed {
    grid-template-columns: 60px 60px minmax(0, 1fr);
  }

  .listen-button,
  .result-picture {
    width: 56px;
    height: 56px;
  }

  .word-card.revealed .word {
    font-size: 25px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
