:root {
  --bg: #efe2c6;
  --ink: #2b241b;
  --muted: #6a5844;
  --card: #fffaf2;
  --line: #ead7b8;
  --red-line: #e7a3a0;
  --yellow: #ffe08a;
  --orange: #e36b2c;
  --green: #14663a;
  --green-bg: #e4f6ea;
  --bad: #8d2b24;
  --bad-bg: #fdecea;
  --warn-bg: #fff4d6;
  --shadow: 0 16px 40px rgba(90, 58, 20, 0.12);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { touch-action: manipulation; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

.app { max-width: 980px; margin: 0 auto; padding: 24px 18px 48px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); letter-spacing: 0.08em; }
h1 { margin: 0; font-size: 2.4rem; line-height: 1; font-family: Palatino, "Songti SC", serif; }
h2 { margin: 0; font-size: 1.7rem; }
.howto { margin: 8px 0 0; max-width: 38rem; line-height: 1.6; }

.btn, .shop button, .role, .chip, .option, .pick button, .token, .blank, .judge, .key {
  border: 2px solid var(--ink);
  background: #fff;
  border-radius: 14px;
}
.btn { min-height: 48px; padding: 0 16px; font-weight: 700; }
.btn.primary { width: 100%; background: var(--ink); color: #fffaf2; font-size: 1.15rem; min-height: 56px; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 42px; }

.map-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.shop {
  background: var(--card);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 230px;
}
.shop.lock { opacity: 0.62; }
.mark {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--yellow); border: 2px solid var(--ink); font-weight: 800;
}
.shop .rel { font-weight: 800; font-size: 1.25rem; margin: 0; }
.shop p { margin: 0; line-height: 1.45; }
.dots { display: flex; gap: 6px; margin: 6px 0; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); background: transparent; }
.dot.on { background: var(--orange); }
.shop button { margin-top: auto; min-height: 48px; font-weight: 800; background: var(--yellow); }

.book {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px 20px 16px 36px;
  position: relative;
}
.book::before {
  content: "";
  position: absolute;
  top: 14px; bottom: 14px; left: 16px;
  width: 2px; background: var(--red-line);
}
.kicker { margin: 0; color: var(--muted); font-weight: 700; }
.level-line { margin: 4px 0 12px; color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pill { padding: 6px 10px; border-radius: 999px; background: #f6efe3; color: var(--muted); font-weight: 700; }
.pill.on { background: var(--ink); color: #fffaf2; }
.pill.done { background: var(--green-bg); color: var(--green); }
.story { font-size: 1.35rem; line-height: 1.75; margin: 0 0 12px; }
.story-num {
  display: inline-block; min-width: 1.5em; padding: 0 0.35em; margin: 0 0.08em;
  background: var(--yellow); border-radius: 999px; font-weight: 800; text-align: center;
}
.done-line { margin: 0 0 6px; color: var(--green); font-weight: 700; }
.done-line span { display: inline-block; min-width: 3em; }
.ask { font-size: 1.15rem; font-weight: 800; margin: 12px 0; }

.chips, .roles, .pick-row, .options, .ops, .frac-row, .judge-row, .paint-row, .conv-list {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.chip, .role, .option, .conv, .judge, .token, .blank {
  min-height: 52px; padding: 8px 12px; text-align: left; font-weight: 700;
}
.chip { min-width: 88px; }
.chip b, .pick b { display: block; font-size: 1.4rem; }
.chip small { color: var(--muted); font-weight: 700; }
.chip.on, .role.on, .option.on, .conv.on, .judge.on, .pick.on, .blank.on, .token.on {
  background: var(--yellow);
}
.role, .option, .conv { flex: 1 1 180px; }
.role strong, .bucket strong { display: block; min-height: 1.2em; font-size: 1.2rem; }

.wallet, .sidebox, .bucket {
  border: 2px dashed var(--ink);
  border-radius: 16px;
  padding: 10px 12px;
  background: #fff;
}
.wallet { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.wallet strong { font-size: 1.8rem; }
.pick { border: 2px solid var(--line); border-radius: 14px; padding: 8px; min-width: 108px; background: #fff; display: flex; flex-direction: column; gap: 6px; }
.pick.on { border-color: var(--ink); background: #fff8df; }
.pick button, .token, .blank, .key { min-height: 42px; }
.pick button { width: 100%; }
.strip-tools { display: flex; gap: 8px; margin: 10px 0; }
.strips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 72px; align-items: center; }
.strip, .ghost-strip {
  width: 54px; height: 68px; border-radius: 8px;
  display: grid; place-items: center; font-weight: 800; font-size: 1.2rem;
}
.strip { background: var(--yellow); border: 2px solid #e0b83a; }
.ghost-strip { border: 2px dashed #c3b59a; color: transparent; }
.sidebox { margin-top: 10px; }
.bucket-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.bucket { width: 100%; min-height: 92px; text-align: left; background: #fff; }
.bucket.on { background: #fff8df; }
.road { margin-top: 12px; }
.road-full, .road-walk { padding: 10px 12px; border-radius: 12px; font-weight: 800; }
.road-full { background: #dcecff; }
.road-walk { margin-top: 6px; background: #ffe08a; width: 68%; }

.cake { width: min(280px, 72vw); height: auto; display: block; margin: 8px auto; }
.cake path { cursor: pointer; }

.formula { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 64px; margin: 8px 0; font-size: 1.4rem; font-weight: 800; }
.blank, .token { min-width: 52px; text-align: center; }
.answer-line { display: flex; align-items: center; gap: 8px; font-size: 1.4rem; font-weight: 800; margin: 8px 0; }
.answer-box, .frac-box {
  min-width: 72px; min-height: 56px; border: 2px solid var(--ink); border-radius: 12px;
  display: grid; place-items: center; background: #fff; font-size: 1.5rem;
}
.answer-box.on, .frac-box.on { background: var(--yellow); }
.frac-row { align-items: center; font-size: 1.6rem; font-weight: 800; margin: 8px 0; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 320px; margin-top: 8px; }
.key { font-size: 1.3rem; font-weight: 800; background: #fff; }

.checkbar {
  padding-top: 10px; margin-top: 16px;
}
.checkbar .btn, .book > .btn { display: block; width: 100%; margin-top: 8px; }
.feedback { border-radius: 12px; padding: 10px 12px; font-weight: 800; line-height: 1.5; margin-bottom: 8px; }
.feedback.good { background: var(--green-bg); color: var(--green); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }
.feedback.warn { background: var(--warn-bg); color: #6a4b10; }
.hint { margin: 0 0 8px; color: var(--muted); }

.stars { font-size: 2rem; letter-spacing: 0.15em; margin: 8px 0; }
.lesson { font-size: 1.25rem; line-height: 1.6; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.stat { background: var(--card); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 2rem; }
.preview { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

@media (max-width: 800px) {
  .map-grid { grid-template-columns: 1fr; }
  h1 { font-size: 2rem; }
  .story { font-size: 1.2rem; }
  .app { padding: 16px 12px 32px; }
  .book { padding-left: 30px; }
  .top { flex-wrap: wrap; align-items: flex-start; }
  .top > div { width: 100%; }
  .top > button { margin-left: auto; white-space: nowrap; flex: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
