:root {
  --ink: #1f2a44;
  --muted: #60708b;
  --paper: #fffdf8;
  --panel: #ffffff;
  --line: #d9e4ec;
  --blue: #2f80ed;
  --blue-dark: #1d5ec4;
  --mint: #4fc79a;
  --coral: #ff7668;
  --sun: #ffd85c;
  --shadow: 0 18px 50px rgba(39, 70, 105, 0.16);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    linear-gradient(180deg, #dff5ff 0%, #f8fbeb 46%, #f7efe1 100%);
}

button {
  font: inherit;
}

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

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

.eyebrow {
  margin: 0 0 4px;
  color: #296b54;
  font-size: 14px;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.04;
  letter-spacing: 0;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stat-pill {
  min-width: 92px;
  padding: 10px 14px;
  border: 1px solid rgba(31, 42, 68, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 26px rgba(39, 70, 105, 0.08);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat-pill strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
  line-height: 1;
}

.town-stage {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.town-art {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgba(31, 42, 68, 0.1);
  border-radius: 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.town-light {
  opacity: 0.42;
  transition: opacity 240ms ease, filter 240ms ease, transform 240ms ease;
}

.town-light.is-lit {
  opacity: 1;
  filter: drop-shadow(0 0 8px rgba(255, 216, 92, 0.72));
}

#sunCore.is-lit {
  transform-origin: 105px 82px;
  transform: scale(1.04);
}

.cloud {
  opacity: 0.72;
}

.cloud.small {
  opacity: 0.62;
}

.learned-strip {
  min-height: 42px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 6px;
}

.learned-badge {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid #f2c85b;
  border-radius: var(--radius);
  box-shadow: 0 8px 18px rgba(39, 70, 105, 0.12);
  font-size: 24px;
  font-weight: 900;
}

.review-badge {
  color: #a3352a;
  background: #ffe0dd;
  border-color: #ff9b90;
}

.game-board {
  display: grid;
  grid-template-columns: minmax(280px, 0.86fr) minmax(340px, 1.14fr);
  gap: 16px;
  align-items: stretch;
}

.question-area,
.choice-area {
  min-width: 0;
  border: 1px solid rgba(31, 42, 68, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 40px rgba(39, 70, 105, 0.12);
}

.question-area {
  padding: 18px;
}

.choice-area {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 14px;
  padding: 18px;
}

.mode-chip {
  width: fit-content;
  padding: 7px 10px;
  color: #1d5b48;
  background: #dff5ea;
  border: 1px solid #bce8d2;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 900;
}

.prompt-line {
  margin-top: 12px;
  color: var(--ink);
  font-size: 26px;
  font-weight: 900;
  line-height: 1.18;
}

.clue-panel {
  min-height: 248px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 12px;
  margin-top: 18px;
  padding: 18px;
  border: 2px solid #e9d8b2;
  border-radius: 18px;
  background: #fff8e9;
}

.clue-visual {
  min-height: 148px;
  display: grid;
  place-items: center;
  color: #253657;
  font-size: clamp(76px, 15vw, 138px);
  font-weight: 950;
  line-height: 1;
  text-align: center;
}

.clue-visual svg {
  width: min(166px, 80%);
  max-height: 154px;
}

.clue-caption {
  margin: 0;
  color: var(--ink);
  font-size: 26px;
  font-weight: 950;
  line-height: 1.08;
}

.clue-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 750;
  line-height: 1.35;
}

.action-row,
.bottom-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.bottom-row {
  justify-content: space-between;
  margin-top: 0;
}

.tool-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 15px;
  color: var(--ink);
  background: #ffffff;
  border: 2px solid #d8e5ee;
  border-radius: var(--radius);
  box-shadow: 0 8px 18px rgba(39, 70, 105, 0.08);
  cursor: pointer;
  font-size: 16px;
  font-weight: 900;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.tool-button:hover:not(:disabled) {
  background: #f4fbff;
  border-color: #94c9f6;
}

.tool-button:focus-visible,
.choice-button:focus-visible {
  outline: 4px solid rgba(47, 128, 237, 0.32);
  outline-offset: 2px;
}

.tool-button:disabled {
  opacity: 0.44;
  cursor: not-allowed;
  box-shadow: none;
}

.tool-button.primary {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.tool-button.primary:hover:not(:disabled) {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.tool-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.progress-track {
  height: 12px;
  padding: 2px;
  border-radius: 999px;
  background: #edf3f6;
  border: 1px solid #d7e3eb;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--sun), var(--coral));
  transition: width 220ms ease;
}

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

.choice-button {
  min-width: 0;
  min-height: 170px;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 16px 10px;
  color: var(--ink);
  background: #ffffff;
  border: 3px solid #d8e5ee;
  border-radius: 18px;
  box-shadow: 0 14px 28px rgba(39, 70, 105, 0.12);
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.choice-button:hover:not(:disabled) {
  background: #f8fcff;
  border-color: #8fc6f4;
}

.choice-button:disabled {
  cursor: default;
}

.choice-button .choice-char {
  font-size: clamp(58px, 8vw, 96px);
  font-weight: 950;
  line-height: 1;
}

.choice-button .choice-word {
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
}

.choice-button .choice-icon {
  width: 96px;
  height: 96px;
}

.choice-button.is-correct {
  background: #e8fff4;
  border-color: #32b77e;
  box-shadow: 0 0 0 5px rgba(50, 183, 126, 0.15), 0 14px 28px rgba(39, 70, 105, 0.12);
}

.choice-button.is-wrong {
  background: #fff0ed;
  border-color: #ff7668;
}

.choice-button.is-hint {
  border-color: #ffd05b;
  box-shadow: 0 0 0 5px rgba(255, 208, 91, 0.22), 0 14px 28px rgba(39, 70, 105, 0.12);
}

.feedback {
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 11px 13px;
  color: var(--ink);
  background: #f5f8fb;
  border: 1px solid #dce6ed;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 850;
  line-height: 1.35;
}

.feedback.good {
  background: #e9fff3;
  border-color: #a9ebcb;
  color: #176247;
}

.feedback.try {
  background: #fff4ee;
  border-color: #ffc6b9;
  color: #874034;
}

.feedback.done {
  background: #fff8df;
  border-color: #f4d473;
  color: #6d5114;
}

.mini-icon svg {
  display: block;
}

.celebration {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 42, 68, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  overflow: hidden;
}

.celebration.is-show {
  opacity: 1;
  pointer-events: auto;
}

.celebration-panel {
  position: relative;
  width: min(560px, 100%);
  padding: 34px 28px 26px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 216, 92, 0.34), transparent 35%),
    #fffdf8;
  border: 3px solid #ffd76c;
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(31, 42, 68, 0.28);
  transform: translateY(18px) scale(0.96);
}

.celebration.is-show .celebration-panel {
  animation: celebration-pop 520ms cubic-bezier(0.2, 1.25, 0.28, 1) forwards;
}

.celebration-sun {
  width: 118px;
  height: 118px;
  margin: 0 auto 6px;
  filter: drop-shadow(0 12px 18px rgba(255, 184, 77, 0.28));
}

.celebration.is-show .celebration-sun {
  animation: celebration-spin 5s linear infinite;
}

.celebration-kicker {
  margin: 0;
  color: #287257;
  font-size: 15px;
  font-weight: 950;
}

.celebration h2 {
  margin: 4px 0 8px;
  color: var(--ink);
  font-size: clamp(34px, 8vw, 54px);
  line-height: 1;
  letter-spacing: 0;
}

.celebration-score {
  margin: 0 auto 15px;
  color: #624b12;
  font-size: 22px;
  font-weight: 950;
}

.celebration-words {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 132px;
  overflow: auto;
  padding: 5px 0 2px;
}

.celebration-words span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #ffffff;
  border: 2px solid #f2c85b;
  border-radius: var(--radius);
  box-shadow: 0 8px 18px rgba(39, 70, 105, 0.1);
  font-size: 22px;
  font-weight: 950;
}

.celebration-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.celebration-stars span {
  position: absolute;
  width: 18px;
  height: 18px;
  background: #ffd85c;
  clip-path: polygon(50% 0%, 61% 34%, 98% 35%, 68% 55%, 79% 91%, 50% 70%, 21% 91%, 32% 55%, 2% 35%, 39% 34%);
  opacity: 0.92;
}

.celebration-stars span:nth-child(1) {
  top: 72px;
  left: 54px;
  animation: star-float 1.9s ease-in-out infinite;
}

.celebration-stars span:nth-child(2) {
  top: 52px;
  right: 72px;
  animation: star-float 2.3s ease-in-out 120ms infinite;
}

.celebration-stars span:nth-child(3) {
  top: 168px;
  left: 34px;
  background: #6bd6b6;
  animation: star-float 2.1s ease-in-out 240ms infinite;
}

.celebration-stars span:nth-child(4) {
  top: 182px;
  right: 38px;
  background: #ff9388;
  animation: star-float 2.5s ease-in-out 80ms infinite;
}

.celebration-stars span:nth-child(5) {
  top: 22px;
  left: 50%;
  background: #7dc9ff;
  animation: star-float 2s ease-in-out 180ms infinite;
}

.confetti span {
  position: absolute;
  top: -40px;
  width: 12px;
  height: 28px;
  border-radius: 3px;
  background: #ff7668;
  opacity: 0;
}

.celebration.is-show .confetti span {
  animation: confetti-fall 1.9s ease-in forwards;
}

.confetti span:nth-child(1) { left: 6%; background: #ff7668; animation-delay: 0ms; }
.confetti span:nth-child(2) { left: 14%; background: #ffd85c; animation-delay: 120ms; }
.confetti span:nth-child(3) { left: 23%; background: #4fc79a; animation-delay: 40ms; }
.confetti span:nth-child(4) { left: 31%; background: #49b8d9; animation-delay: 210ms; }
.confetti span:nth-child(5) { left: 42%; background: #ffb84d; animation-delay: 90ms; }
.confetti span:nth-child(6) { left: 51%; background: #ff7668; animation-delay: 260ms; }
.confetti span:nth-child(7) { left: 60%; background: #4fc79a; animation-delay: 140ms; }
.confetti span:nth-child(8) { left: 68%; background: #ffd85c; animation-delay: 20ms; }
.confetti span:nth-child(9) { left: 76%; background: #49b8d9; animation-delay: 190ms; }
.confetti span:nth-child(10) { left: 84%; background: #ff9388; animation-delay: 80ms; }
.confetti span:nth-child(11) { left: 91%; background: #6bd6b6; animation-delay: 230ms; }
.confetti span:nth-child(12) { left: 96%; background: #ffd85c; animation-delay: 150ms; }

@keyframes celebration-pop {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  70% {
    opacity: 1;
    transform: translateY(-4px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes celebration-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes star-float {
  0%, 100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }
  50% {
    transform: translateY(-10px) rotate(14deg) scale(1.12);
  }
}

@keyframes confetti-fall {
  0% {
    opacity: 0;
    transform: translateY(-30px) rotate(0deg);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0.92;
    transform: translateY(112vh) rotate(380deg);
  }
}

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats {
    width: 100%;
    justify-content: flex-start;
  }

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

  .town-art {
    border-radius: 20px;
  }

  .clue-panel {
    min-height: 210px;
  }

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

  .choice-button {
    min-height: 104px;
    grid-template-columns: auto 1fr;
    justify-items: start;
    padding: 12px 16px;
  }

  .choice-button .choice-char {
    font-size: 64px;
  }

  .choice-button .choice-icon {
    width: 74px;
    height: 74px;
  }

  .celebration-panel {
    padding: 26px 18px 20px;
  }

  .celebration-sun {
    width: 92px;
    height: 92px;
  }

  .celebration-words {
    max-height: 104px;
  }
}

@media (max-width: 430px) {
  .app-shell {
    width: min(100% - 14px, 420px);
  }

  h1 {
    font-size: 31px;
  }

  .stat-pill {
    min-width: 84px;
  }

  .question-area,
  .choice-area {
    padding: 12px;
    border-radius: 14px;
  }

  .prompt-line {
    font-size: 22px;
  }

  .clue-caption {
    font-size: 23px;
  }

  .tool-button {
    width: 100%;
  }

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

  .celebration {
    padding: 10px;
  }

  .celebration h2 {
    font-size: 36px;
  }

  .celebration-score {
    font-size: 19px;
  }

  .celebration-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

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