/* 小小理财家 · 基础样式 · 浅色主题 · 移动优先 */
:root {
  --bg: #F7FAF8;
  --surface: #FFFFFF;
  --surface-2: #EFF6F2;
  --text: #14352B;
  --text-2: #5A756A;
  --line: #DCE8E1;
  --brand: #1D9E75;
  --brand-dark: #0F6E56;
  --brand-soft: #E1F5EE;
  --amber: #B45309;
  --amber-soft: #FEF3C7;
  --red: #B91C1C;
  --shadow: 0 1px 2px rgba(20,53,43,.06);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-dark); }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px;
}
.brand-name { font-weight: 600; font-size: 16px; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.nav-btn {
  border: 0; background: transparent; color: var(--text-2);
  padding: 7px 12px; border-radius: 9px; white-space: nowrap; font-size: 14px;
}
.nav-btn:hover { background: var(--surface-2); }
.nav-btn.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); font-weight: 600;
}

/* 主区 */
.view { flex: 1; padding: 20px 16px 32px; max-width: 1080px; width: 100%; margin: 0 auto; }
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 24px; line-height: 1.3; margin: 0 0 6px; }
.page-head p { margin: 0; color: var(--text-2); }
.back-link {
  display: inline-block; margin-bottom: 12px; border: 0; background: none;
  color: var(--brand-dark); padding: 0; font-size: 14px;
}

/* 卡片与网格 */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* 按钮 */
.btn {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; padding: 9px 15px; font-size: 14px;
  transition: transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-soft { background: var(--surface-2); }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.linkbtn { border: 0; background: none; color: var(--text-2); padding: 0; text-decoration: underline; font-size: 13px; }

/* 层级入口卡 */
.level-card { text-align: left; display: flex; flex-direction: column; gap: 8px; padding: 20px; }
.level-card .lv-tag { font-size: 12px; color: var(--brand-dark); background: var(--brand-soft); padding: 3px 9px; border-radius: 20px; align-self: flex-start; }
.level-card h2 { margin: 2px 0 0; font-size: 19px; }
.level-card .lv-desc { color: var(--text-2); font-size: 14px; margin: 0; }
.level-card .lv-go { color: var(--brand-dark); font-weight: 600; font-size: 14px; margin-top: 2px; }

/* 小游戏 */
.game-card { text-align: left; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.game-card h3 { margin: 0; font-size: 17px; }
.game-card p { margin: 0; color: var(--text-2); font-size: 13px; }
.star-line { color: var(--amber); font-size: 13px; }
.question { font-size: 20px; font-weight: 600; margin: 8px 0 16px; }
.coin-bank { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.coin {
  min-width: 62px; padding: 10px 8px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--amber-soft); color: #7C2D12;
  font-weight: 600; text-align: center;
}
.coin small { display: block; font-weight: 400; font-size: 11px; opacity: .8; }
.coin:active { transform: scale(.96); }
.wallet {
  min-height: 60px; border: 1px dashed var(--line); border-radius: 12px;
  padding: 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  background: #FCFDFC;
}
.wallet .coin { padding: 6px 10px; min-width: auto; }
.amount { font-size: 26px; font-weight: 700; color: var(--brand-dark); }
.feedback { min-height: 26px; margin-top: 10px; font-size: 14px; }
.feedback.ok { color: var(--brand-dark); }
.feedback.no { color: var(--red); }
.progress { height: 8px; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 8px; }

/* 选项按钮 */
.choice {
  display: block; width: 100%; text-align: left;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); padding: 12px 14px; margin-bottom: 8px;
}
.choice:hover { border-color: var(--brand); }
.choice.correct { border-color: var(--brand); background: var(--brand-soft); }
.choice.wrong { border-color: var(--red); background: #FEE2E2; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; }
.input, select.input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; background: var(--surface);
}
input[type=range] { width: 100%; accent-color: var(--brand); }

/* 三罐 */
.jar-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.jar {
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px;
  text-align: center; background: var(--surface);
}
.jar .jar-icon { font-size: 28px; }
.jar .jar-name { font-weight: 600; margin-top: 4px; }
.jar .jar-val { font-size: 20px; color: var(--brand-dark); font-weight: 700; }
.jar.save { background: #E1F5EE; }
.jar.spend { background: #FEF3C7; }
.jar.share { background: #E6F1FB; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--text-2); font-weight: 600; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.positive { color: var(--red); }   /* 国内习惯：收入/增加用红 */
.negative { color: var(--brand-dark); } /* 支出/减少用绿 */

/* 弹层 */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20,53,43,.42);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.hidden { display: none !important; }
.modal-box {
  background: var(--surface); border-radius: 16px;
  padding: 22px; width: min(440px, 100%);
  max-height: 86vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.14);
}
.modal-box h3 { margin: 0 0 10px; font-size: 19px; }
.modal-box p { color: var(--text-2); margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.gate-question { font-size: 26px; font-weight: 700; text-align: center; margin: 14px 0; }
.gate-input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; text-align: center; font-size: 18px; }
.gate-error { color: var(--red); min-height: 22px; margin-top: 6px; font-size: 13px; }
.gate-tip { font-size: 13px; }

/* 提示 */
.toast-stack { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; display: grid; gap: 6px; width: min(420px, calc(100% - 32px)); }
.toast {
  background: var(--text); color: #fff; padding: 10px 16px;
  border-radius: 10px; text-align: center; font-size: 14px;
  opacity: 1; transition: opacity .35s ease;
}
.toast.out { opacity: 0; }
.toast.warn { background: var(--amber); }

.footer {
  border-top: 1px solid var(--line); background: var(--surface);
  padding: 12px 16px; text-align: center; color: var(--text-2); font-size: 12px;
}
.footer .dot { margin: 0 7px; opacity: .5; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; background: var(--surface-2); color: var(--text-2); }
.hint { color: var(--text-2); font-size: 12px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }

@media (max-width: 620px) {
  .brand-name { font-size: 15px; }
  .nav {
    order: 3; flex-basis: 100%;
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 3px; overflow: visible;
    border-top: 1px solid var(--line); padding-top: 7px;
  }
  .nav-btn { padding: 7px 2px; font-size: 12px; text-align: center; }
  .icon-btn { margin-left: auto; }
  .view { padding: 16px 12px 26px; }
  .page-head h1 { font-size: 21px; }
  .jar-grid { gap: 6px; }
  .jar { padding: 10px 6px; }
  .jar .jar-icon { font-size: 22px; }
  .footer span.dot { display: none; }
  .footer span { display: block; margin: 2px 0; }
  th, td { padding: 7px 6px; font-size: 12px; }
}
