:root {
  color-scheme: light;
  --ink: #25314d;
  --muted: #61708a;
  --paper: rgba(255, 255, 255, 0.9);
  --line: rgba(37, 49, 77, 0.16);
  --mint: #bff7dd;
  --yellow: #ffe27a;
  --pink: #ff9ac2;
  --blue: #8fd3ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 226, 122, 0.62), transparent 25%),
    radial-gradient(circle at 84% 18%, rgba(143, 211, 255, 0.55), transparent 24%),
    linear-gradient(135deg, #fff7d2 0%, #dff8ff 48%, #edffe9 100%);
}

button,
select { font: inherit; }

button {
  min-height: 44px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

button:hover,
button:focus-visible { background: #fff09f; }

button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 22px;
  align-items: center;
  min-height: 210px;
}

.kicker {
  margin: 0 0 8px;
  color: #40786a;
  font-weight: 900;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(36px, 7vw, 68px);
  line-height: 1;
  letter-spacing: 0;
}

.intro,
.status-panel p {
  color: var(--muted);
  line-height: 1.75;
}

.factory {
  position: relative;
  width: 210px;
  aspect-ratio: 1;
}

.factory span {
  position: absolute;
  display: block;
}

.cloud {
  width: 72px;
  height: 38px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: white;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  bottom: 14px;
  width: 34px;
  height: 34px;
  border: 2px solid var(--ink);
  border-bottom: 0;
  border-radius: 50% 50% 0 0;
  background: white;
}

.cloud::before { left: 8px; }
.cloud::after { right: 8px; }
.cloud-a { top: 10px; left: 8px; }
.cloud-b { top: 34px; right: 2px; transform: scale(0.82); }

.chimney {
  left: 116px;
  top: 60px;
  width: 38px;
  height: 74px;
  border: 2px solid var(--ink);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: repeating-linear-gradient(0deg, #ff9ac2 0 14px, #fff 14px 25px);
}

.roof {
  left: 42px;
  top: 86px;
  width: 130px;
  height: 82px;
  border: 2px solid var(--ink);
  border-radius: 18px 18px 8px 8px;
  background: linear-gradient(135deg, #ffb04e, #ff7aa8);
  transform: skewX(-9deg);
}

.body {
  left: 30px;
  top: 128px;
  width: 150px;
  height: 58px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--mint);
}

.wheel {
  bottom: 12px;
  width: 36px;
  height: 36px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--blue);
}

.wheel-a { left: 48px; }
.wheel-b { right: 42px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.toolbar label {
  display: grid;
  gap: 6px;
  font-weight: 900;
}

select {
  min-width: 180px;
  min-height: 44px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.toolbar button { padding: 0 18px; }

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

.status-panel,
.puzzle-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 16px 38px rgba(37, 49, 77, 0.13);
}

.status-panel { padding: 18px; }

h2 {
  margin: 0 0 10px;
  font-size: 24px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.stats div {
  padding: 12px;
  border: 2px solid rgba(37, 49, 77, 0.12);
  border-radius: 8px;
  background: #fffdf3;
}

dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

dd {
  margin: 4px 0 0;
  font-size: 24px;
  font-weight: 900;
}

.rule-card {
  padding: 14px;
  border-radius: 8px;
  background: #e9fff3;
  border: 2px dashed rgba(37, 49, 77, 0.25);
}

.rule-card p { margin: 8px 0 0; }

.message {
  min-height: 54px;
  padding: 12px;
  border-radius: 8px;
  background: #fff1f7;
  font-weight: 900;
}

.message.win {
  background: #e4ffec;
  color: #257448;
}

.message.miss {
  background: #fff1cf;
  color: #8a5a00;
}

.puzzle-panel {
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 20px;
}

.sequence {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 14px;
}

.question-mark {
  width: min(150px, 42vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  justify-self: center;
  border: 3px dashed rgba(37, 49, 77, 0.45);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
  color: #ff7aa8;
  font-size: 76px;
  font-weight: 900;
}

.choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(96px, 1fr));
  gap: 12px;
}

.choice {
  padding: 8px;
  background: white;
}

.choice.correct { background: #bff7dd; }
.choice.wrong { background: #ffcad7; }

.tile {
  min-height: 122px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  box-shadow: inset 0 -8px 0 rgba(37, 49, 77, 0.05);
}

.shape {
  position: relative;
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  border: 3px solid var(--ink);
  color: var(--ink);
}

.shape.circle { border-radius: 50%; }
.shape.square { border-radius: 12px; }

.shape.diamond {
  transform: rotate(45deg);
  border-radius: 10px;
}

.shape.diamond .count,
.shape.diamond .face { transform: rotate(-45deg); }

.shape.triangle {
  width: 0;
  height: 0;
  border-left: 44px solid transparent;
  border-right: 44px solid transparent;
  border-bottom: 78px solid currentColor;
  background: transparent !important;
  border-top: 0;
}

.shape.triangle::after {
  content: "";
  position: absolute;
  left: -34px;
  top: 9px;
  width: 0;
  height: 0;
  border-left: 34px solid transparent;
  border-right: 34px solid transparent;
  border-bottom: 59px solid var(--fill, #ffe27a);
}

.shape.triangle .count,
.shape.triangle .face {
  z-index: 1;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.shape.triangle .count { top: 29px; }
.shape.triangle .face { bottom: -64px; }

.count {
  font-size: 28px;
  font-weight: 900;
}

.face {
  position: absolute;
  bottom: 7px;
  font-size: 21px;
  line-height: 1;
}

@media (max-width: 820px) {
  .hero,
  .game-layout { grid-template-columns: 1fr; }

  .factory { justify-self: center; }

  .sequence,
  .choices { grid-template-columns: repeat(2, minmax(110px, 1fr)); }
}

@media (max-width: 520px) {
  .app {
    width: min(100vw - 18px, 420px);
    padding: 14px 0;
  }

  .toolbar,
  .toolbar button,
  select { width: 100%; }

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

  .tile { min-height: 110px; }
}
