:root {
  --bg: #fbf8f3;
  --ink: #241f1a;
  --ink-2: #6b6259;
  --ink-3: #a49a8d;
  --line: #e8e0d4;
  --red: #b23a35;
  --red-soft: #f3e2df;
  --gold: #a8802c;
  --card: #fffdf9;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body { user-select: none; -webkit-user-select: none; }

.app {
  min-height: 100vh;
  padding: 20px 18px calc(28px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
}

.page { display: none; }
.page.is-on { display: block; }

.hd { margin-bottom: 18px; }
.hd-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
h1 { font-size: 22px; margin: 0; letter-spacing: 2px; }
h2 { font-size: 19px; margin: 0; }
.link {
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 14px;
  padding: 6px 2px;
}

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg-btn {
  flex: 1;
  border: 0;
  background: #fff;
  color: var(--ink-2);
  font-size: 15px;
  padding: 11px 0;
  font-family: inherit;
}
.seg-btn.is-on { background: var(--red); color: #fff; }

.daily {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 18px;
  text-align: center;
  margin-bottom: 18px;
}
.daily-label { font-size: 13px; color: var(--ink-3); letter-spacing: 4px; }
.daily-char {
  font-size: 76px;
  line-height: 1.1;
  color: var(--red);
  font-weight: 700;
  margin: 6px 0 8px;
}
.daily-meta { font-size: 13px; color: var(--ink-2); }

.btn-main {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 14px;
  background: var(--red);
  color: #fff;
  font-size: 18px;
  font-family: inherit;
  padding: 16px 0;
  letter-spacing: 2px;
}
.btn-sub {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink-2);
  font-size: 16px;
  font-family: inherit;
  padding: 14px 0;
  margin-top: 10px;
}
.foot-note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
}

/* 对局 */
.play-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.play-tags { display: flex; align-items: center; }
.tag {
  font-size: 13px;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  margin-right: 8px;
}
.tag-char { color: var(--red); border-color: var(--red-soft); font-size: 18px; padding: 1px 12px; }
.time-num { font-size: 20px; font-weight: 700; color: var(--ink); }

.timebar {
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 14px;
}
.timebar-fill {
  height: 100%;
  width: 100%;
  background: var(--red);
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 120ms linear;
}
.timebar-fill.is-low { background: #7a2b27; }

.hearts { height: 26px; margin-bottom: 8px; font-size: 18px; color: var(--red); letter-spacing: 4px; }

.lead {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
.lead-text { font-size: 17px; line-height: 1.7; }
.lead-from { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

.ask { font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.ask span { color: var(--red); font-weight: 700; font-size: 16px; }

.options { display: flex; flex-direction: column; }
.opt {
  display: block;
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
  padding: 12px 14px;
  margin-bottom: 10px;
  transition: background 120ms ease, border-color 120ms ease;
}
.opt.is-right { background: #eaf3e9; border-color: #b8d6b3; }
.opt.is-wrong { background: var(--red-soft); border-color: #e2b3ae; }
.opt.is-muted { color: var(--ink-3); }
.opt:disabled { opacity: 1; }

.feedback { display: none; }
.feedback.is-on { display: block; }
.fb-text { font-size: 15px; line-height: 1.7; margin-bottom: 4px; }
.fb-from { font-size: 12px; color: var(--ink-3); margin-bottom: 12px; }
.btn-next {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  padding: 14px 0;
}

/* 结算 */
.done-title { text-align: center; margin: 18px 0 6px; font-size: 20px; }
.done-score { text-align: center; margin-bottom: 20px; }
.score-num { font-size: 60px; font-weight: 700; color: var(--red); }
.score-unit { font-size: 14px; color: var(--ink-2); margin-left: 6px; }
.done-rows { border-top: 1px solid var(--line); margin-bottom: 20px; }
.done-rows .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-2);
}
.done-rows .row b { color: var(--ink); font-weight: 500; max-width: 70%; text-align: right; }

/* 图鉴 */
.char-grid { display: flex; flex-wrap: wrap; margin: 0 -5px; }
.char-cell { width: 25%; padding: 6px 5px; text-align: center; }
.seal {
  width: 58px;
  height: 58px;
  margin: 0 auto 4px;
  border-radius: 50%;
  border: 2px solid var(--line);
  color: var(--ink-3);
  font-size: 24px;
  line-height: 54px;
  background: #fff;
}
.seal.is-lit {
  border-color: var(--red);
  color: #fff;
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}
.char-cap { font-size: 11px; color: var(--ink-3); }

.poem-grid { display: flex; flex-wrap: wrap; margin: 0 -4px; }
.poem-cell {
  width: 33.333%;
  padding: 5px 4px;
}
.poem-cell > button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-family: inherit;
  padding: 10px 6px;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}
.poem-cell > button.is-lit { background: var(--red-soft); border-color: #e0b8b3; color: #7a2b27; }
.poem-cell .pg { display: block; font-size: 11px; color: var(--ink-3); }

.poem-meta { font-size: 12px; color: var(--ink-3); margin-bottom: 12px; }
.poem-lines .ln {
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-2);
}
.poem-lines .ln.is-done { background: #fff; border-color: #d9c8b6; color: var(--ink); }

/* 专题 */
.zt-list { margin-bottom: 14px; }
.zt-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-family: inherit;
  padding: 13px 14px;
  margin-bottom: 10px;
  text-align: left;
}
.zt-item .zt-name { font-size: 16px; color: var(--ink); }
.zt-item .zt-sub { display: block; font-size: 12px; color: var(--ink-3); }
.zt-item .zt-badge { font-size: 12px; color: var(--red); }

.zt-chars { display: flex; flex-wrap: wrap; margin: 0 -4px; }
.zt-char {
  width: 20%;
  padding: 5px 4px;
}
.zt-char > button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-family: inherit;
  font-size: 20px;
  padding: 8px 0 6px;
  color: var(--ink);
}
.zt-char > button small { display: block; font-size: 10px; color: var(--ink-3); }
.zt-char > button:disabled { color: var(--ink-3); background: #f6f2ec; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: rgba(36, 31, 26, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
.toast.is-on { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

.update-bar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--red);
  color: #fff;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(178, 58, 53, 0.28);
}
