:root {
  --bg: #fff7ed;
  --bg2: #ffedd5;
  --ink: #3b2f2a;
  --muted: #8a7a70;
  --primary: #ea580c;
  --primary-d: #c2410c;
  --green: #16a34a;
  --red: #dc2626;
  --card: #ffffff;
  --shadow: 0 6px 18px rgba(120, 70, 30, 0.12);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* top bar */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: #fff; box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 18px; }
.stats { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.coin b { color: var(--primary); }
.badge {
  background: var(--primary); color: #fff; padding: 2px 10px;
  border-radius: 999px; font-size: 12px;
}

main { max-width: 860px; margin: 0 auto; padding: 22px 16px 60px; }

/* screens */
.screen { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.game-title {
  text-align: center; font-size: 40px; margin: 36px 0 4px;
  color: var(--primary-d); letter-spacing: 2px;
}
.subtitle { text-align: center; color: var(--muted); margin: 0 0 28px; }
.pick-h, .map-h { text-align: center; font-size: 20px; margin: 8px 0 18px; }

/* character pick */
.char-list { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.char-card {
  width: 180px; background: var(--card); border: 3px solid transparent;
  border-radius: var(--radius); padding: 18px 14px; text-align: center;
  cursor: pointer; box-shadow: var(--shadow); transition: .15s;
}
.char-card:hover { transform: translateY(-3px); }
.char-card.sel { border-color: var(--primary); }
.char-emoji { font-size: 44px; }
.char-name { font-weight: 700; margin: 6px 0 2px; }
.char-desc { font-size: 12px; color: var(--muted); }

.btn-primary {
  display: block; margin: 28px auto 0; background: var(--primary);
  color: #fff; border: none; padding: 13px 34px; font-size: 16px;
  border-radius: 999px; cursor: pointer; box-shadow: var(--shadow);
}
.btn-primary:disabled { background: #d9c7ba; cursor: not-allowed; }
.btn-ghost {
  background: #fff; border: 2px solid #f0d9c4; color: var(--primary-d);
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-size: 14px;
}
.btn-ghost:hover { background: #fff3e9; }
.hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* kingdoms */
.kingdom-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.kingdom-card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); transition: .15s;
}
.k-head { display: flex; align-items: center; gap: 12px; }
.k-emoji { font-size: 38px; flex-shrink: 0; }
.k-info { flex: 1; min-width: 0; }
.k-name { font-weight: 700; font-size: 17px; margin: 0; }
.k-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.k-progress { font-size: 12px; color: var(--primary-d); background: #fde9d6; padding: 4px 10px; border-radius: 999px; white-space: nowrap; flex-shrink: 0; }
.lv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.lv-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 10px 4px; border-radius: 12px; border: 2px solid transparent;
  background: #fff7ed; color: var(--ink); cursor: pointer; transition: .12s;
  font-family: inherit; text-align: center; min-height: 74px;
}
.lv-tile .lv-num { font-size: 12px; font-weight: 700; color: var(--primary-d); }
.lv-tile .lv-icon { font-size: 16px; }
.lv-tile .lv-label { font-size: 10px; color: var(--muted); line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lv-tile.open { background: #fff; border-color: var(--primary); }
.lv-tile.open:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.lv-tile.open .lv-label { color: var(--ink); font-weight: 600; }
.lv-tile.done { background: #ecfdf3; border-color: var(--green); }
.lv-tile.done .lv-num { color: var(--green); }
.lv-tile.done .lv-label { color: #15803d; }
.lv-tile.locked { background: #f3f0ec; cursor: not-allowed; opacity: .65; }
.lv-tile.locked .lv-num { color: #b0a89f; }
.lv-tile.locked .lv-label { color: #b0a89f; }
.lv-tile.plock { background: #f3f0ec; cursor: not-allowed; opacity: .7; }
.lv-tile.plock .lv-num { color: #b0a89f; }
.lv-tile.plock .lv-label { color: #b0a89f; }
@media (max-width: 420px) { .lv-grid { grid-template-columns: repeat(3, 1fr); } }

.nav-row { display: flex; gap: 10px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }

/* level */
.level-head { margin-bottom: 14px; }
.level-title { font-size: 20px; font-weight: 700; margin: 10px 0; text-align: center; }
.step-bar { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.step {
  font-size: 12px; padding: 5px 12px; border-radius: 999px;
  background: #fff; color: var(--muted); border: 2px solid #f0d9c4;
}
.step.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.step.done { background: var(--green); color: #fff; border-color: var(--green); }

.level-body { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-height: 280px; }
.fragment-bubble {
  background: #fff3e9; border-radius: 14px; padding: 18px; line-height: 1.7; font-size: 15px;
}
.fragment-emoji { font-size: 34px; }
.points { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.point-chip { background: #fde9d6; color: var(--primary-d); padding: 5px 12px; border-radius: 999px; font-size: 13px; }

.tier-h { font-weight: 700; margin: 18px 0 10px; }
.q-card { border: 2px solid #f0d9c4; border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.q-text { font-weight: 600; margin-bottom: 10px; }
.opt {
  display: block; width: 100%; text-align: left; background: #fff;
  border: 2px solid #eee; border-radius: 10px; padding: 10px 14px; margin: 6px 0;
  cursor: pointer; font-size: 14px;
}
.opt:hover { border-color: #f0c9a8; }
.opt.right { background: #dcfce7; border-color: var(--green); }
.opt.wrong { background: #fee2e2; border-color: var(--red); }
.opt:disabled { cursor: default; }
.explain { font-size: 13px; color: var(--muted); margin-top: 6px; }
.q-result { font-size: 13px; font-weight: 700; margin-top: 6px; }

.guardian-box { background: #fef2f2; border: 2px solid #fecaca; border-radius: 14px; padding: 18px; }
.guardian-box textarea {
  width: 100%; min-height: 90px; border: 2px solid #f0d9c4; border-radius: 10px;
  padding: 10px; font-size: 14px; font-family: inherit; resize: vertical;
}
.rubric { margin-top: 12px; }
.rubric li { margin: 4px 0; color: var(--ink); }

.reward-box { text-align: center; padding: 16px; }
.reward-emoji { font-size: 50px; }
.reward-coins { font-size: 22px; color: var(--primary); font-weight: 700; }
.reward-title { display: inline-block; margin-top: 8px; background: var(--primary); color: #fff; padding: 4px 14px; border-radius: 999px; }

.btn-next { display: block; margin: 18px auto 0; background: var(--primary); color: #fff; border: none; padding: 11px 28px; border-radius: 999px; cursor: pointer; font-size: 15px; }

/* cave */
.cave-list { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.cave-item {
  background: var(--card); border-radius: 12px; padding: 14px; box-shadow: var(--shadow);
  border-left: 5px solid var(--red);
}
.cave-q { font-weight: 600; }
.cave-meta { font-size: 12px; color: var(--muted); margin: 6px 0; }
.btn-fight { background: var(--red); color: #fff; border: none; padding: 8px 16px; border-radius: 999px; cursor: pointer; font-size: 13px; }
.empty-tip { text-align: center; color: var(--muted); padding: 30px; }

/* rank */
.rank-cards { display: flex; gap: 14px; justify-content: center; margin: 20px 0; flex-wrap: wrap; }
.rank-card { background: var(--card); border-radius: var(--radius); padding: 18px 22px; text-align: center; box-shadow: var(--shadow); min-width: 130px; }
.rank-ico { font-size: 30px; }
.rank-num { font-size: 30px; font-weight: 800; color: var(--primary); }
.rank-label { font-size: 12px; color: var(--muted); }
.title-wall { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0; }
.title-pill { background: #fde9d6; color: var(--primary-d); padding: 6px 14px; border-radius: 999px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: #3b2f2a; color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 14px; z-index: 50; box-shadow: var(--shadow);
}

/* Pro 激活 / 模式 */
.pro-box { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 14px 0; }
.pro-status { font-size: 13px; color: var(--muted); padding: 6px 14px; background: #fff; border-radius: 999px; box-shadow: var(--shadow); }
.pro-status.pro-on { color: #fff; background: linear-gradient(135deg, #f59e0b, #ea580c); }
.pro-badge { background: linear-gradient(135deg, #f59e0b, #ea580c); color: #fff; margin-left: 6px; }

/* 页脚管理入口（仅一个低调链接） */
.site-footer { text-align: center; padding: 18px 0 6px; }
.site-footer a { font-size: 12px; color: var(--muted); text-decoration: none; opacity: .7; }
.site-footer a:hover { opacity: 1; text-decoration: underline; }
